From 39009b1caab227270246092be7a38824f7561cfb Mon Sep 17 00:00:00 2001 From: Charles Dusek Date: Thu, 13 Jun 2024 09:32:05 -0500 Subject: [PATCH] Update drop amounts calc without BigInt --- x/market/keeper/drop.go | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/x/market/keeper/drop.go b/x/market/keeper/drop.go index 3cbba68..8c55199 100644 --- a/x/market/keeper/drop.go +++ b/x/market/keeper/drop.go @@ -433,23 +433,13 @@ func dropAmounts(drops sdk.Int, pool types.Pool, member1 types.Member, member2 t return sdk.ZeroInt(), sdk.ZeroInt(), status.Error(codes.InvalidArgument, "invalid drops") } - // see `msg_server_redeem_drop` for our bigint strategy - // `dropAmtMember1 = (drops * member1.Balance) / pool.Drops` - tmp := big.NewInt(0) - tmp.Mul(drops.BigInt(), member1.Balance.BigInt()) - tmp.Quo(tmp, pool.Drops.BigInt()) - dropAmtMember1 := sdk.NewIntFromBigInt(tmp).Add(sdk.NewIntFromUint64(1)) - tmp = big.NewInt(0) + dropAmtMember1 := (drops.Mul(member1.Balance)).Quo(pool.Drops) if dropAmtMember1.LTE(sdk.ZeroInt()) { return dropAmtMember1, sdk.ZeroInt(), sdkerrors.Wrapf(types.ErrAmtZero, "%s", member1.DenomB) } - // `dropAmtMember2 = (drops * member2.Balance) / pool.Drops` - tmp.Mul(drops.BigInt(), member2.Balance.BigInt()) - tmp.Quo(tmp, pool.Drops.BigInt()) - dropAmtMember2 := sdk.NewIntFromBigInt(tmp).Add(sdk.NewIntFromUint64(1)) - //tmp = big.NewInt(0) + dropAmtMember2 := (dropAmtMember1.Mul(member2.Balance)).Quo(member1.Balance) if dropAmtMember2.LTE(sdk.ZeroInt()) { return dropAmtMember1, dropAmtMember2, sdkerrors.Wrapf(types.ErrAmtZero, "%s", member2.DenomB)