Skip to content

Commit cbf4344

Browse files
committed
send tokens after amount out calculation
1 parent 00a4130 commit cbf4344

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

contracts/contracts/strategies/algebra/StableSwapAMMStrategy.sol

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff 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) ||

0 commit comments

Comments
 (0)