diff --git a/functions/src/scripts/migrate-to-cfmm.ts b/functions/src/scripts/migrate-to-cfmm.ts index f86c9924..a741eb08 100644 --- a/functions/src/scripts/migrate-to-cfmm.ts +++ b/functions/src/scripts/migrate-to-cfmm.ts @@ -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', diff --git a/web/components/bets-list.tsx b/web/components/bets-list.tsx index b86910d6..b1059b34 100644 --- a/web/components/bets-list.tsx +++ b/web/components/bets-list.tsx @@ -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) )