diff --git a/x/gamm/keeper/swap_test.go b/x/gamm/keeper/swap_test.go index fd0cd8497324782dac2ee0582e8257bf980a89b7..f2c578350b891d53b259626091fa9edd528af723 100644 --- a/x/gamm/keeper/swap_test.go +++ b/x/gamm/keeper/swap_test.go @@ -97,13 +97,9 @@ func (suite *KeeperTestSuite) TestBalancerPoolSimpleSwapExactAmountIn() { spotPriceBefore, err := keeper.CalculateSpotPrice(ctx, poolId, test.param.tokenIn.Denom, test.param.tokenOutDenom) suite.NoError(err, "test: %v", test.name) - prevGasConsumed := suite.Ctx.GasMeter().GasConsumed() tokenOutAmount, err := keeper.SwapExactAmountIn(ctx, suite.TestAccs[0], poolId, test.param.tokenIn, test.param.tokenOutDenom, test.param.tokenOutMinAmount) suite.NoError(err, "test: %v", test.name) suite.True(tokenOutAmount.Equal(test.param.expectedTokenOut), "test: %v", test.name) - gasConsumedForSwap := suite.Ctx.GasMeter().GasConsumed() - prevGasConsumed - // We consume `types.GasFeeForSwap` directly, so the extra I/O operation mean we end up consuming more. - suite.Assert().Greater(gasConsumedForSwap, uint64(types.BalancerGasFeeForSwap)) suite.AssertEventEmitted(ctx, types.TypeEvtTokenSwapped, 1) @@ -205,15 +201,11 @@ func (suite *KeeperTestSuite) TestBalancerPoolSimpleSwapExactAmountOut() { spotPriceBefore, err := keeper.CalculateSpotPrice(ctx, poolId, test.param.tokenInDenom, test.param.tokenOut.Denom) suite.NoError(err, "test: %v", test.name) - prevGasConsumed := suite.Ctx.GasMeter().GasConsumed() tokenInAmount, err := keeper.SwapExactAmountOut(ctx, suite.TestAccs[0], poolId, test.param.tokenInDenom, test.param.tokenInMaxAmount, test.param.tokenOut) suite.NoError(err, "test: %v", test.name) suite.True(tokenInAmount.Equal(test.param.expectedTokenInAmount), "test: %v\n expect_eq actual: %s, expected: %s", test.name, tokenInAmount, test.param.expectedTokenInAmount) - gasConsumedForSwap := suite.Ctx.GasMeter().GasConsumed() - prevGasConsumed - // We consume `types.GasFeeForSwap` directly, so the extra I/O operation mean we end up consuming more. - suite.Assert().Greater(gasConsumedForSwap, uint64(types.BalancerGasFeeForSwap)) suite.AssertEventEmitted(ctx, types.TypeEvtTokenSwapped, 1) diff --git a/x/gamm/pool-models/balancer/pool.go b/x/gamm/pool-models/balancer/pool.go index 510502d8ee55decc76da4c3fafff66844fbadd23..b49b83451d99028403f6059b8e9201817728b0d0 100644 --- a/x/gamm/pool-models/balancer/pool.go +++ b/x/gamm/pool-models/balancer/pool.go @@ -583,8 +583,6 @@ func (p *Pool) SwapInAmtGivenOut( // ApplySwap. func (p *Pool) applySwap(ctx sdk.Context, tokensIn sdk.Coins, tokensOut sdk.Coins) error { - // Fixed gas consumption per swap to prevent spam - ctx.GasMeter().ConsumeGas(types.BalancerGasFeeForSwap, "balancer swap computation") // Also ensures that len(tokensIn) = 1 = len(tokensOut) inPoolAsset, outPoolAsset, err := p.parsePoolAssetsCoins(tokensIn, tokensOut) if err != nil { diff --git a/x/gamm/types/constants.go b/x/gamm/types/constants.go index 537939d963e08f1aa8774b1cdbe9fd6a9536d787..a019135e22401ca7a1d334704e5029f36bd98894 100644 --- a/x/gamm/types/constants.go +++ b/x/gamm/types/constants.go @@ -11,8 +11,7 @@ const ( OneShareExponent = 18 // Raise 10 to the power of SigFigsExponent to determine number of significant figures. // i.e. SigFigExponent = 8 is 10^8 which is 100000000. This gives 8 significant figures. - SigFigsExponent = 8 - BalancerGasFeeForSwap = 10_000 + SigFigsExponent = 8 ) var (