diff --git a/pkg/liquidity-source/algebra/integral/pool_simulator.go b/pkg/liquidity-source/algebra/integral/pool_simulator.go index aa547d93f..09a67cbfa 100644 --- a/pkg/liquidity-source/algebra/integral/pool_simulator.go +++ b/pkg/liquidity-source/algebra/integral/pool_simulator.go @@ -525,14 +525,14 @@ func (p *PoolSimulator) calculateSwap(overrideFee, pluginFee uint32, zeroToOne b var liquidityDelta = new(int256.Int) if zeroToOne { currentTick = step.nextTick - 1 + initializedTick = step.nextTick - 1 liquidityDelta = liquidityDelta.Neg(liquidityNet) } else { currentTick = step.nextTick + initializedTick = step.nextTick liquidityDelta = liquidityNet } - initializedTick = step.nextTick - currentLiquidity, err = addDelta(currentLiquidity, liquidityDelta) if err != nil { return nil, nil, nil, 0, nil, FeesAmount{}, err diff --git a/pkg/liquidity-source/algebra/integral/pool_simulator_test.go b/pkg/liquidity-source/algebra/integral/pool_simulator_test.go index 43400286d..313af43ae 100644 --- a/pkg/liquidity-source/algebra/integral/pool_simulator_test.go +++ b/pkg/liquidity-source/algebra/integral/pool_simulator_test.go @@ -361,17 +361,17 @@ func TestCalcAmountOut(t *testing.T) { expectedResult: &pool.CalcAmountOutResult{ TokenAmountOut: &pool.TokenAmount{ Token: "0xf55bec9cafdbe8730f096aa55dad6d22d44099df", - Amount: big.NewInt(279874986), // Expected amount after swap + Amount: big.NewInt(1425476892), // Expected amount after swap }, Fee: &pool.TokenAmount{ Token: "0x06efdbff2a14a7c8e15944d1f4a48f9f95f663a4", - Amount: big.NewInt(641334), // Expected fees + Amount: big.NewInt(3207826239749998), // Expected fees }, SwapInfo: StateUpdate{ GlobalState: GlobalState{ Unlocked: true, LastFee: 15000, - Tick: -61, + Tick: -487914, PluginConfig: mockPluginConfig, CommunityFee: mockCommunityFee, },