From 7896233ae36cbe432713022247e69dfa611534c0 Mon Sep 17 00:00:00 2001 From: Ian Philips Date: Wed, 10 Jul 2024 18:19:49 -0700 Subject: [PATCH] Sort redemption bets after non-redemptions --- common/src/calculate.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/src/calculate.ts b/common/src/calculate.ts index 2d3078f2ca..15f4dd309a 100644 --- a/common/src/calculate.ts +++ b/common/src/calculate.ts @@ -163,8 +163,10 @@ function getCpmmInvested(yourBets: Bet[]) { const totalShares: { [outcome: string]: number } = {} const totalSpent: { [outcome: string]: number } = {} - const sortedBets = sortBy(yourBets, 'createdTime') - const sharePurchases = sortedBets.map((bet) => [bet]).flat() + const sharePurchases = sortBy(yourBets, [ + 'createdTime', + (bet) => (bet.isRedemption ? 1 : 0), + ]) for (const purchase of sharePurchases) { const { outcome, shares, amount } = purchase