Skip to content

Commit

Permalink
Sort redemption bets after non-redemptions
Browse files Browse the repository at this point in the history
  • Loading branch information
IanPhilips committed Jul 11, 2024
1 parent b076a66 commit 7896233
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions common/src/calculate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7896233

Please sign in to comment.