Subtract loans from leaderboard calculations

This commit is contained in:
James Grugett 2022-03-01 21:23:37 -08:00
parent 1dd078562a
commit 9e9535ce56
2 changed files with 5 additions and 3 deletions

View File

@ -45,8 +45,9 @@ export function scoreUsersByContract(contract: Contract, bets: Bet[]) {
const investments = bets
.filter((bet) => !bet.sale)
.map((bet) => {
const { userId, amount } = bet
return { userId, payout: -amount }
const { userId, amount, loanAmount } = bet
const payout = -amount - (loanAmount ?? 0)
return { userId, payout }
})
const netPayouts = [...resolvePayouts, ...salePayouts, ...investments]

View File

@ -52,7 +52,8 @@ const computeInvestmentValue = async (
if (!contract || contract.isResolved) return 0
if (bet.sale || bet.isSold) return 0
return calculatePayout(contract, bet, 'MKT')
const payout = calculatePayout(contract, bet, 'MKT')
return payout - (bet.loanAmount ?? 0)
})
}