File tree Expand file tree Collapse file tree
contracts/contracts/strategies/algebra Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -698,12 +698,13 @@ contract StableSwapAMMStrategy is InitializableAbstractStrategy {
698698 address _tokenIn ,
699699 address _tokenOut
700700 ) internal {
701- // Transfer in tokens to the pool
702- IERC20 (_tokenIn).safeTransfer (pool, _amountIn);
703-
704701 // Calculate how much out tokens we get from the swap
705702 uint256 amountOut = IPair (pool).getAmountOut (_amountIn, _tokenIn);
706703
704+ // Transfer in tokens to the pool after the amountOut calculation has been mde.
705+ // This way we don't have to worry about sending tokens to pool confusing the pool's reserves.
706+ IERC20 (_tokenIn).safeTransfer (pool, _amountIn);
707+
707708 // Safety check that we are dealing with the correct pool tokens
708709 require (
709710 (_tokenIn == asset && _tokenOut == oToken) ||
You can’t perform that action at this time.
0 commit comments