Skip to content

Commit

Permalink
fix: CalcAmountIn uniswap-v2 wrong index of tokenIn (#559)
Browse files Browse the repository at this point in the history
  • Loading branch information
piavgh authored Oct 28, 2024
1 parent abe7e88 commit 0c16397
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/liquidity-source/uniswap-v2/pool_simulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0c16397

Please sign in to comment.