diff --git a/common/contract.ts b/common/contract.ts index 7f5c5fd5..77568f49 100644 --- a/common/contract.ts +++ b/common/contract.ts @@ -29,7 +29,7 @@ export type FullContract< closeEmailsSent?: number - volume?: number + volume: number volume24Hours: number volume7Days: number diff --git a/functions/src/create-answer.ts b/functions/src/create-answer.ts index bc075fb9..fbde2666 100644 --- a/functions/src/create-answer.ts +++ b/functions/src/create-answer.ts @@ -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)) { diff --git a/functions/src/place-bet.ts b/functions/src/place-bet.ts index f2ce3bc0..68789096 100644 --- a/functions/src/place-bet.ts +++ b/functions/src/place-bet.ts @@ -130,7 +130,7 @@ export const placeBet = functions.runWith({ minInstances: 1 }).https.onCall( totalBets: newTotalBets, totalLiquidity: newTotalLiquidity, collectedFees: addObjects(fees ?? {}, collectedFees ?? {}), - volume: (volume ?? 0) + Math.abs(amount), + volume: volume + Math.abs(amount), }) ) diff --git a/functions/src/sell-bet.ts b/functions/src/sell-bet.ts index 1dd57d2b..4b31cfde 100644 --- a/functions/src/sell-bet.ts +++ b/functions/src/sell-bet.ts @@ -81,7 +81,7 @@ export const sellBet = functions.runWith({ minInstances: 1 }).https.onCall( totalShares: newTotalShares, totalBets: newTotalBets, collectedFees: addObjects(fees ?? {}, collectedFees ?? {}), - volume: (volume ?? 0) + bet.amount, + volume: volume + bet.amount, }) ) diff --git a/functions/src/update-contract-metrics.ts b/functions/src/update-contract-metrics.ts index d95dcd80..c3801df6 100644 --- a/functions/src/update-contract-metrics.ts +++ b/functions/src/update-contract-metrics.ts @@ -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, })