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) {
|
for (let bet of bets) {
|
||||||
const shares =
|
const shares = bet.sale
|
||||||
bet.isSold || bet.sale
|
? -bet.sale.amount
|
||||||
? 0
|
: bet.isSold
|
||||||
: calculateStandardDpmPayout(contract, bet, bet.outcome)
|
? bets.find((b) => b.sale?.betId === bet.id)?.sale?.amount ?? 0
|
||||||
|
: calculateStandardDpmPayout(contract, bet, bet.outcome)
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
'converting',
|
'converting',
|
||||||
|
|
|
@ -397,7 +397,10 @@ export function ContractBetsTable(props: {
|
||||||
sales.map((sale) => [sale.sale?.betId ?? '', sale])
|
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(
|
const amountRedeemed = Math.floor(
|
||||||
-0.5 * _.sumBy(redemptions, (b) => b.shares)
|
-0.5 * _.sumBy(redemptions, (b) => b.shares)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user