Skip to content

Commit

Permalink
fix: move downscaledAmount variable around to avoid stack too deep error
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlak committed Apr 10, 2024
1 parent 8befbd0 commit fcf65cb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/DFMM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,6 @@ contract DFMM is IDFMM {
} else {
// Otherwise, execute the callback and assert the input amount has been paid
// given the before and after balances of the input token.
uint256 downscaledAmount =
downscaleUp(state.amountIn, computeScalingFactor(state.tokenIn));
uint256 preBalance = ERC20(state.tokenIn).balanceOf(address(this));

ISwapCallback(msg.sender).swapCallback(
Expand All @@ -280,6 +278,8 @@ contract DFMM is IDFMM {
callbackData
);

uint256 downscaledAmount =
downscaleUp(state.amountIn, computeScalingFactor(state.tokenIn));
uint256 postBalance = ERC20(state.tokenIn).balanceOf(address(this));
if (postBalance < preBalance + downscaledAmount) {
revert InvalidTransfer();
Expand Down

0 comments on commit fcf65cb

Please sign in to comment.