manifold/web/lib/firebase/liquidity.ts
mantikoros 0cd9943e0d
Liquidity withdrawal (#457)
* withdrawLiquidity cloud function

* update rules

* exclude antes from getCpmmLiquidityPoolWeights

* update correct lp shares

* liquidity panel

* don't create bet if less than 1 surplus share

* withdrawLiquidity return type

* static analysis fix

* hook dependency

* prettier

* renaming

* typo

* getCpmmLiquidityPoolWeights: always exclude antes

* delete unused function

* casting
2022-06-08 13:00:49 -05:00

18 lines
540 B
TypeScript

import { collection, query } from 'firebase/firestore'
import { db } from './init'
import { listenForValues } from './utils'
import { LiquidityProvision } from 'common/liquidity-provision'
export function listenForLiquidity(
contractId: string,
setLiquidity: (lps: LiquidityProvision[]) => void
) {
const lpQuery = query(collection(db, 'contracts', contractId, 'liquidity'))
return listenForValues<LiquidityProvision>(lpQuery, (lps) => {
lps.sort((lp1, lp2) => lp1.createdTime - lp2.createdTime)
setLiquidity(lps)
})
}