Redeem shares: pay back a smaller frac of your loan
This commit is contained in:
parent
677b20a7ba
commit
cf74a195b2
|
@ -13,7 +13,10 @@ export const getRedeemableAmount = (bets: RedeemableBet[]) => {
|
||||||
const yesShares = sumBy(yesBets, (b) => b.shares)
|
const yesShares = sumBy(yesBets, (b) => b.shares)
|
||||||
const noShares = sumBy(noBets, (b) => b.shares)
|
const noShares = sumBy(noBets, (b) => b.shares)
|
||||||
const shares = Math.max(Math.min(yesShares, noShares), 0)
|
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 loanAmount = sumBy(bets, (bet) => bet.loanAmount ?? 0)
|
||||||
const loanPayment = loanAmount * soldFrac
|
const loanPayment = loanAmount * soldFrac
|
||||||
const netAmount = shares - loanPayment
|
const netAmount = shares - loanPayment
|
||||||
|
|
Loading…
Reference in New Issue
Block a user