From 0c1639709e18918741c599993538de512215c80b Mon Sep 17 00:00:00 2001 From: Hoang Trinh Date: Mon, 28 Oct 2024 21:59:08 +0700 Subject: [PATCH] fix: CalcAmountIn uniswap-v2 wrong index of tokenIn (#559) --- pkg/liquidity-source/uniswap-v2/pool_simulator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/liquidity-source/uniswap-v2/pool_simulator.go b/pkg/liquidity-source/uniswap-v2/pool_simulator.go index 3bcd9a326..169feec63 100644 --- a/pkg/liquidity-source/uniswap-v2/pool_simulator.go +++ b/pkg/liquidity-source/uniswap-v2/pool_simulator.go @@ -184,7 +184,7 @@ func (s *PoolSimulator) CalcAmountIn(param poolpkg.CalcAmountInParams) (*poolpkg } return &poolpkg.CalcAmountInResult{ - TokenAmountIn: &poolpkg.TokenAmount{Token: s.Pool.Info.Tokens[indexOut], Amount: amountIn.ToBig()}, + TokenAmountIn: &poolpkg.TokenAmount{Token: s.Pool.Info.Tokens[indexIn], Amount: amountIn.ToBig()}, // NOTE: we don't use fee to update balance so that we don't need to calculate it. I put it number.Zero to avoid null pointer exception Fee: &poolpkg.TokenAmount{Token: s.Pool.Info.Tokens[indexIn], Amount: integer.Zero()}, Gas: s.gas.Swap,