From f83853ef7d6e3a85ae4d1ac518dac1a2aa6b3b86 Mon Sep 17 00:00:00 2001 From: beer-1 Date: Fri, 16 Aug 2024 17:33:42 +0900 Subject: [PATCH 1/3] use QuoTruncate for QuoteSpotPrice --- x/move/types/connector.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/move/types/connector.go b/x/move/types/connector.go index 7953c54a..8e6b0d0a 100644 --- a/x/move/types/connector.go +++ b/x/move/types/connector.go @@ -417,7 +417,7 @@ func GetQuoteSpotPrice( numerator := weightQuote.MulInt(balanceBase).TruncateDec() denominator := weightBase.MulInt(balanceQuote).TruncateDec() - return numerator.Quo(denominator) + return numerator.QuoTruncate(denominator) } // ReadUnbondingInfosFromStakingState util function to read unbonding coin amount from the StakingState From c2cdb443c5f90cfd477998a6727accdeb5999222 Mon Sep 17 00:00:00 2001 From: beer-1 Date: Fri, 16 Aug 2024 18:15:33 +0900 Subject: [PATCH 2/3] use QuoTruncate for gas price --- x/move/ante/gas_prices.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/move/ante/gas_prices.go b/x/move/ante/gas_prices.go index acae841d..8affb5c6 100644 --- a/x/move/ante/gas_prices.go +++ b/x/move/ante/gas_prices.go @@ -32,7 +32,7 @@ func (d GasPricesDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool } // CSR: store a tx gas prices - ctx = ctx.WithValue(GasPricesContextKey, sdk.NewDecCoinsFromCoins(feeCoins...).QuoDec(math.LegacyNewDec(int64(gas)))) + ctx = ctx.WithValue(GasPricesContextKey, sdk.NewDecCoinsFromCoins(feeCoins...).QuoDecTruncate(math.LegacyNewDec(int64(gas)))) } if next != nil { From 18ed0328a4b990140bf692e22637981b80442fe6 Mon Sep 17 00:00:00 2001 From: beer-1 Date: Fri, 16 Aug 2024 18:21:09 +0900 Subject: [PATCH 3/3] use tokens from shares tuncated --- x/move/keeper/staking.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/move/keeper/staking.go b/x/move/keeper/staking.go index 663f5172..fadfbffa 100644 --- a/x/move/keeper/staking.go +++ b/x/move/keeper/staking.go @@ -38,7 +38,7 @@ func (k Keeper) ShareToAmount(ctx context.Context, valAddr sdk.ValAddress, share return math.ZeroInt(), err } - tokens := val.TokensFromShares(sdk.NewDecCoins(share)) + tokens := val.TokensFromSharesTruncated(sdk.NewDecCoins(share)) return tokens.AmountOf(share.Denom).TruncateInt(), nil }