From cf74a195b2c731f2c2e4071f082f7a4886bd5ebb Mon Sep 17 00:00:00 2001 From: James Grugett Date: Thu, 8 Sep 2022 22:57:02 -0500 Subject: [PATCH] Redeem shares: pay back a smaller frac of your loan --- common/redeem.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/redeem.ts b/common/redeem.ts index e0839ff8..f786a1c2 100644 --- a/common/redeem.ts +++ b/common/redeem.ts @@ -13,7 +13,10 @@ export const getRedeemableAmount = (bets: RedeemableBet[]) => { const yesShares = sumBy(yesBets, (b) => b.shares) const noShares = sumBy(noBets, (b) => b.shares) const shares = Math.max(Math.min(yesShares, noShares), 0) - const soldFrac = shares > 0 ? Math.min(yesShares, noShares) / shares : 0 + const soldFrac = + shares > 0 + ? Math.min(yesShares, noShares) / Math.max(yesShares, noShares) + : 0 const loanAmount = sumBy(bets, (bet) => bet.loanAmount ?? 0) const loanPayment = loanAmount * soldFrac const netAmount = shares - loanPayment