migration: make up fake share qty for sold shares
This commit is contained in:
parent
dc9af1c5b0
commit
789a505f97
|
@ -8,7 +8,7 @@ const formatter = new Intl.NumberFormat('en-US', {
|
||||||
})
|
})
|
||||||
|
|
||||||
export function formatMoney(amount: number) {
|
export function formatMoney(amount: number) {
|
||||||
const newAmount = Math.floor(amount) === 0 ? 0 : Math.floor(amount) // handle -0 case
|
const newAmount = Math.round(amount) === 0 ? 0 : Math.floor(amount) // handle -0 case
|
||||||
return (
|
return (
|
||||||
ENV_CONFIG.moneyMoniker + ' ' + formatter.format(newAmount).replace('$', '')
|
ENV_CONFIG.moneyMoniker + ' ' + formatter.format(newAmount).replace('$', '')
|
||||||
)
|
)
|
||||||
|
|
|
@ -47,11 +47,18 @@ async function recalculateContract(contractRef: DocRef, isCommit = false) {
|
||||||
(b) => b.createdTime
|
(b) => b.createdTime
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const getSoldBetPayout = (bet: Bet) => {
|
||||||
|
const soldBet = bets.find((b) => bet.sale?.betId === b.id)
|
||||||
|
return soldBet
|
||||||
|
? -soldBet.amount / Math.sqrt(soldBet.probBefore * soldBet.probAfter)
|
||||||
|
: 0
|
||||||
|
}
|
||||||
|
|
||||||
for (let bet of bets) {
|
for (let bet of bets) {
|
||||||
const shares = bet.sale
|
const shares = bet.sale
|
||||||
? -bet.sale.amount
|
? getSoldBetPayout(bet)
|
||||||
: bet.isSold
|
: bet.isSold
|
||||||
? bets.find((b) => b.sale?.betId === bet.id)?.sale?.amount ?? 0
|
? bet.amount / Math.sqrt(bet.probBefore * bet.probAfter) // make up fake share qty
|
||||||
: calculateStandardDpmPayout(contract, bet, bet.outcome)
|
: calculateStandardDpmPayout(contract, bet, bet.outcome)
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user