fix(univ4): Make slither happy
--- don't change below this line --- ENG-4222 Took 17 minutes Took 47 seconds Took 14 seconds
This commit is contained in:
@@ -450,7 +450,8 @@ contract TychoRouter is
|
|||||||
{
|
{
|
||||||
require(data.length >= 20, "Invalid data length");
|
require(data.length >= 20, "Invalid data length");
|
||||||
bytes4 selector = bytes4(data[data.length - 4:]);
|
bytes4 selector = bytes4(data[data.length - 4:]);
|
||||||
address executor = address(uint160(bytes20(data[data.length - 24:data.length - 4])));
|
address executor =
|
||||||
|
address(uint160(bytes20(data[data.length - 24:data.length - 4])));
|
||||||
bytes memory protocolData = data[:data.length - 24];
|
bytes memory protocolData = data[:data.length - 24];
|
||||||
|
|
||||||
if (!executors[executor]) {
|
if (!executors[executor]) {
|
||||||
|
|||||||
@@ -75,7 +75,6 @@ contract UniswapV4Executor is IExecutor, V4Router {
|
|||||||
params[1] = abi.encode(key.currency0, amountIn);
|
params[1] = abi.encode(key.currency0, amountIn);
|
||||||
params[2] = abi.encode(key.currency1, amountOutMin);
|
params[2] = abi.encode(key.currency1, amountOutMin);
|
||||||
swapData = abi.encode(actions, params);
|
swapData = abi.encode(actions, params);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
PathKey[] memory path = new PathKey[](pools.length);
|
PathKey[] memory path = new PathKey[](pools.length);
|
||||||
for (uint256 i = 0; i < pools.length; i++) {
|
for (uint256 i = 0; i < pools.length; i++) {
|
||||||
@@ -109,8 +108,8 @@ contract UniswapV4Executor is IExecutor, V4Router {
|
|||||||
params[2] = abi.encode(Currency.wrap(tokenOut), amountOutMin);
|
params[2] = abi.encode(Currency.wrap(tokenOut), amountOutMin);
|
||||||
swapData = abi.encode(actions, params);
|
swapData = abi.encode(actions, params);
|
||||||
}
|
}
|
||||||
bytes memory fullData =
|
bytes memory fullData =
|
||||||
abi.encodePacked( swapData, callbackExecutor, callbackSelector);
|
abi.encodePacked(swapData, callbackExecutor, callbackSelector);
|
||||||
uint256 tokenOutBalanceBefore;
|
uint256 tokenOutBalanceBefore;
|
||||||
|
|
||||||
tokenOutBalanceBefore = tokenOut == address(0)
|
tokenOutBalanceBefore = tokenOut == address(0)
|
||||||
@@ -132,11 +131,12 @@ contract UniswapV4Executor is IExecutor, V4Router {
|
|||||||
|
|
||||||
// necessary to convert bytes memory to bytes calldata
|
// necessary to convert bytes memory to bytes calldata
|
||||||
function executeActions(bytes memory unlockData) public {
|
function executeActions(bytes memory unlockData) public {
|
||||||
|
// slither-disable-next-line unused-return
|
||||||
poolManager.unlock(unlockData);
|
poolManager.unlock(unlockData);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _decodeData(bytes calldata data)
|
function _decodeData(bytes calldata data)
|
||||||
public
|
internal
|
||||||
pure
|
pure
|
||||||
returns (
|
returns (
|
||||||
address tokenIn,
|
address tokenIn,
|
||||||
@@ -148,7 +148,7 @@ contract UniswapV4Executor is IExecutor, V4Router {
|
|||||||
UniswapV4Pool[] memory pools
|
UniswapV4Pool[] memory pools
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if(data.length < 123) {
|
if (data.length < 123) {
|
||||||
revert UniswapV4Executor__InvalidDataLength();
|
revert UniswapV4Executor__InvalidDataLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,6 +168,7 @@ contract UniswapV4Executor is IExecutor, V4Router {
|
|||||||
uint24 fee;
|
uint24 fee;
|
||||||
int24 tickSpacing;
|
int24 tickSpacing;
|
||||||
|
|
||||||
|
// slither-disable-next-line assembly
|
||||||
assembly {
|
assembly {
|
||||||
intermediaryToken := mload(add(poolsData, add(offset, 20)))
|
intermediaryToken := mload(add(poolsData, add(offset, 20)))
|
||||||
fee := shr(232, mload(add(poolsData, add(offset, 52))))
|
fee := shr(232, mload(add(poolsData, add(offset, 52))))
|
||||||
@@ -178,10 +179,7 @@ contract UniswapV4Executor is IExecutor, V4Router {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function _pay(Currency token, address payer, uint256 amount)
|
function _pay(Currency token, address, uint256 amount) internal override {
|
||||||
internal
|
|
||||||
override
|
|
||||||
{
|
|
||||||
IERC20(Currency.unwrap(token)).safeTransfer(
|
IERC20(Currency.unwrap(token)).safeTransfer(
|
||||||
address(poolManager), amount
|
address(poolManager), amount
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -104,10 +104,10 @@ contract UniswapV4ExecutorTest is Test, Constants {
|
|||||||
deal(USDE_ADDR, address(uniswapV4Exposed), amountIn);
|
deal(USDE_ADDR, address(uniswapV4Exposed), amountIn);
|
||||||
uint256 usdeBalanceBeforePool = USDE.balanceOf(poolManager);
|
uint256 usdeBalanceBeforePool = USDE.balanceOf(poolManager);
|
||||||
uint256 usdeBalanceBeforeSwapExecutor =
|
uint256 usdeBalanceBeforeSwapExecutor =
|
||||||
USDE.balanceOf(address(uniswapV4Exposed));
|
USDE.balanceOf(address(uniswapV4Exposed));
|
||||||
|
|
||||||
UniswapV4Executor.UniswapV4Pool[] memory pools =
|
UniswapV4Executor.UniswapV4Pool[] memory pools =
|
||||||
new UniswapV4Executor.UniswapV4Pool[](1);
|
new UniswapV4Executor.UniswapV4Pool[](1);
|
||||||
pools[0] = UniswapV4Executor.UniswapV4Pool({
|
pools[0] = UniswapV4Executor.UniswapV4Pool({
|
||||||
intermediaryToken: USDT_ADDR,
|
intermediaryToken: USDT_ADDR,
|
||||||
fee: uint24(100),
|
fee: uint24(100),
|
||||||
@@ -139,11 +139,10 @@ contract UniswapV4ExecutorTest is Test, Constants {
|
|||||||
deal(USDE_ADDR, address(uniswapV4Exposed), amountIn);
|
deal(USDE_ADDR, address(uniswapV4Exposed), amountIn);
|
||||||
uint256 usdeBalanceBeforePool = USDE.balanceOf(poolManager);
|
uint256 usdeBalanceBeforePool = USDE.balanceOf(poolManager);
|
||||||
uint256 usdeBalanceBeforeSwapExecutor =
|
uint256 usdeBalanceBeforeSwapExecutor =
|
||||||
USDE.balanceOf(address(uniswapV4Exposed));
|
USDE.balanceOf(address(uniswapV4Exposed));
|
||||||
|
|
||||||
|
|
||||||
UniswapV4Executor.UniswapV4Pool[] memory pools =
|
UniswapV4Executor.UniswapV4Pool[] memory pools =
|
||||||
new UniswapV4Executor.UniswapV4Pool[](2);
|
new UniswapV4Executor.UniswapV4Pool[](2);
|
||||||
pools[0] = UniswapV4Executor.UniswapV4Pool({
|
pools[0] = UniswapV4Executor.UniswapV4Pool({
|
||||||
intermediaryToken: USDT_ADDR,
|
intermediaryToken: USDT_ADDR,
|
||||||
fee: uint24(100),
|
fee: uint24(100),
|
||||||
@@ -171,7 +170,8 @@ contract UniswapV4ExecutorTest is Test, Constants {
|
|||||||
USDE.balanceOf(address(uniswapV4Exposed)),
|
USDE.balanceOf(address(uniswapV4Exposed)),
|
||||||
usdeBalanceBeforeSwapExecutor - amountIn
|
usdeBalanceBeforeSwapExecutor - amountIn
|
||||||
);
|
);
|
||||||
assertTrue(IERC20(WBTC_ADDR).balanceOf(address(uniswapV4Exposed)) == amountOut);
|
assertTrue(
|
||||||
|
IERC20(WBTC_ADDR).balanceOf(address(uniswapV4Exposed)) == amountOut
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user