migrate cfmm: use sale amount as shares for sold bets
This commit is contained in:
parent
c68cdc6f3e
commit
dc9af1c5b0
|
@ -48,10 +48,11 @@ async function recalculateContract(contractRef: DocRef, isCommit = false) {
|
|||
)
|
||||
|
||||
for (let bet of bets) {
|
||||
const shares =
|
||||
bet.isSold || bet.sale
|
||||
? 0
|
||||
: calculateStandardDpmPayout(contract, bet, bet.outcome)
|
||||
const shares = bet.sale
|
||||
? -bet.sale.amount
|
||||
: bet.isSold
|
||||
? bets.find((b) => b.sale?.betId === bet.id)?.sale?.amount ?? 0
|
||||
: calculateStandardDpmPayout(contract, bet, bet.outcome)
|
||||
|
||||
console.log(
|
||||
'converting',
|
||||
|
|
|
@ -397,7 +397,10 @@ export function ContractBetsTable(props: {
|
|||
sales.map((sale) => [sale.sale?.betId ?? '', sale])
|
||||
)
|
||||
|
||||
const [redemptions, normalBets] = _.partition(buys, (b) => b.isRedemption)
|
||||
const [redemptions, normalBets] = _.partition(
|
||||
contract.mechanism === 'cpmm-1' ? bets : buys,
|
||||
(b) => b.isRedemption
|
||||
)
|
||||
const amountRedeemed = Math.floor(
|
||||
-0.5 * _.sumBy(redemptions, (b) => b.shares)
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user