Use generic payout function for leaderboard profit calculation. Exclude redemptions in volume calculation

This commit is contained in:
James Grugett 2022-03-15 17:47:05 -05:00
parent c183e00d47
commit 77b2c9893d
2 changed files with 3 additions and 3 deletions

View File

@ -39,5 +39,5 @@ const computeVolumeFrom = async (contract: Contract, timeAgoMs: number) => {
.where('createdTime', '>', Date.now() - timeAgoMs)
)
return _.sumBy(bets, (bet) => Math.abs(bet.amount))
return _.sumBy(bets, (bet) => (bet.isRedemption ? 0 : Math.abs(bet.amount)))
}

View File

@ -6,8 +6,8 @@ import { getValues } from './utils'
import { Contract } from '../../common/contract'
import { Bet } from '../../common/bet'
import { User } from '../../common/user'
import { calculateDpmPayout } from '../../common/calculate-dpm'
import { batchedWaitAll } from '../../common/util/promise'
import { calculatePayout } from '../../common/calculate'
const firestore = admin.firestore()
@ -53,7 +53,7 @@ const computeInvestmentValue = async (
if (!contract || contract.isResolved) return 0
if (bet.sale || bet.isSold) return 0
const payout = calculateDpmPayout(contract, bet, 'MKT')
const payout = calculatePayout(contract, bet, 'MKT')
return payout - (bet.loanAmount ?? 0)
})
}