Make volume a non-optional field of contract
This commit is contained in:
parent
510e4400d3
commit
69e142e279
|
@ -29,7 +29,7 @@ export type FullContract<
|
|||
|
||||
closeEmailsSent?: number
|
||||
|
||||
volume?: number
|
||||
volume: number
|
||||
volume24Hours: number
|
||||
volume7Days: number
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ export const createAnswer = functions.runWith({ minInstances: 1 }).https.onCall(
|
|||
totalShares: newTotalShares,
|
||||
totalBets: newTotalBets,
|
||||
answers: [...(contract.answers ?? []), answer],
|
||||
volume: (volume ?? 0) + amount,
|
||||
volume: volume + amount,
|
||||
})
|
||||
|
||||
if (!isFinite(newBalance)) {
|
||||
|
|
|
@ -130,7 +130,7 @@ export const placeBet = functions.runWith({ minInstances: 1 }).https.onCall(
|
|||
totalBets: newTotalBets,
|
||||
totalLiquidity: newTotalLiquidity,
|
||||
collectedFees: addObjects<Fees>(fees ?? {}, collectedFees ?? {}),
|
||||
volume: (volume ?? 0) + Math.abs(amount),
|
||||
volume: volume + Math.abs(amount),
|
||||
})
|
||||
)
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ export const sellBet = functions.runWith({ minInstances: 1 }).https.onCall(
|
|||
totalShares: newTotalShares,
|
||||
totalBets: newTotalBets,
|
||||
collectedFees: addObjects<Fees>(fees ?? {}, collectedFees ?? {}),
|
||||
volume: (volume ?? 0) + bet.amount,
|
||||
volume: volume + bet.amount,
|
||||
})
|
||||
)
|
||||
|
||||
|
|
|
@ -22,11 +22,9 @@ export const updateContractMetrics = functions.pubsub
|
|||
contracts.map((contract) => async () => {
|
||||
const volume24Hours = await computeVolumeFrom(contract, oneDay)
|
||||
const volume7Days = await computeVolumeFrom(contract, oneDay * 7)
|
||||
const volume = await computeVolumeFrom(contract, oneDay * 365)
|
||||
|
||||
const contractRef = firestore.doc(`contracts/${contract.id}`)
|
||||
return contractRef.update({
|
||||
volume,
|
||||
volume24Hours,
|
||||
volume7Days,
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue
Block a user