Skip to content

Commit

Permalink
⚡ Smol optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
z0r0z committed Feb 12, 2024
1 parent 041d77c commit 6c5ade4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
6 changes: 3 additions & 3 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ IETest:testBalanceInETH() (gas: 53716)
IETest:testCommandSendERC0() (gas: 114380)
IETest:testCommandSendETH() (gas: 80852)
IETest:testCommandSendUSDC() (gas: 147088)
IETest:testCommandSwapDAI() (gas: 101624)
IETest:testCommandSwapUSDC() (gas: 157016)
IETest:testDeploy() (gas: 2191672)
IETest:testCommandSwapDAI() (gas: 101576)
IETest:testCommandSwapUSDC() (gas: 156929)
IETest:testDeploy() (gas: 2169813)
IETest:testENSNameFromENSHelper() (gas: 29103)
IETest:testENSNameOwnership() (gas: 109154)
IETest:testIENameSetting() (gas: 8187)
Expand Down
16 changes: 9 additions & 7 deletions src/IE.sol
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,15 @@ contract IE {
bool zeroForOne = _tokenIn < _tokenOut;
uint256 _amountIn = _stringToUint(amountIn, isETH ? 18 : _tokenIn.readDecimals());
address pool = _computePoolAddress(_tokenIn, _tokenOut);
ISwapRouter(pool).swap(
msg.sender,
zeroForOne,
int256(_amountIn),
zeroForOne ? MIN_SQRT_RATIO + 1 : MAX_SQRT_RATIO - 1,
abi.encode(zeroForOne, _tokenIn, msg.sender)
);
unchecked {
ISwapRouter(pool).swap(
msg.sender,
zeroForOne,
int256(_amountIn),
zeroForOne ? MIN_SQRT_RATIO + 1 : MAX_SQRT_RATIO - 1,
abi.encode(zeroForOne, _tokenIn, msg.sender)
);
}
}

/// @dev Callback for IUniswapV3PoolActions#swap.
Expand Down

0 comments on commit 6c5ade4

Please sign in to comment.