From 26cc06a99a871269156bebf7ced30cbf3bb903d7 Mon Sep 17 00:00:00 2001 From: Charles Dusek Date: Thu, 6 Jun 2024 09:24:08 -0500 Subject: [PATCH] Add safe round up to division --- x/market/keeper/drop.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/market/keeper/drop.go b/x/market/keeper/drop.go index c2eb82f0..1da418e2 100644 --- a/x/market/keeper/drop.go +++ b/x/market/keeper/drop.go @@ -398,7 +398,7 @@ func dropAmounts(drops sdk.Int, pool types.Pool, member1 types.Member, member2 t tmp := big.NewInt(0) tmp.Mul(drops.BigInt(), member1.Balance.BigInt()) tmp.Quo(tmp, pool.Drops.BigInt()) - dropAmtMember1 := sdk.NewIntFromBigInt(tmp) + dropAmtMember1 := sdk.NewIntFromBigInt(tmp).Add(sdk.NewIntFromUint64(1)) tmp = big.NewInt(0) if dropAmtMember1.LTE(sdk.ZeroInt()) { @@ -408,7 +408,7 @@ func dropAmounts(drops sdk.Int, pool types.Pool, member1 types.Member, member2 t // `dropAmtMember2 = (drops * member2.Balance) / pool.Drops` tmp.Mul(drops.BigInt(), member2.Balance.BigInt()) tmp.Quo(tmp, pool.Drops.BigInt()) - dropAmtMember2 := sdk.NewIntFromBigInt(tmp) + dropAmtMember2 := sdk.NewIntFromBigInt(tmp).Add(sdk.NewIntFromUint64(1)) //tmp = big.NewInt(0) if dropAmtMember2.LTE(sdk.ZeroInt()) {