Don't accidentally make meaningless zero bets

This commit is contained in:
Marshall Polaris 2022-07-05 13:56:25 -07:00
parent 4d1c50a6cc
commit 7a546edfe9

View File

@ -21,6 +21,9 @@ export const redeemShares = async (userId: string, contractId: string) => {
const betsSnap = await trans.get(betsColl.where('userId', '==', userId))
const bets = betsSnap.docs.map((doc) => doc.data() as Bet)
const { shares, loanPayment, netAmount } = getRedeemableAmount(bets)
if (netAmount === 0) {
return { status: 'success' }
}
const [yesBet, noBet] = getRedemptionBets(shares, loanPayment, contract)
const userDoc = firestore.doc(`users/${userId}`)