sherlock-audit / 2024-03-zivoe-judging

8 stars 6 forks source link

Title: Inconsistent Handling of Token Order in Uniswap Pool Validation,`ZivoeSwapper::handle_validation_0502b1c5` assetIn should be token0 when zeroForOne_0 is true #716

Closed sherlock-admin3 closed 6 months ago

sherlock-admin3 commented 6 months ago

Title: Inconsistent Handling of Token Order in Uniswap Pool Validation,ZivoeSwapper::handle_validation_0502b1c5 assetIn should be token0 when zeroForOne_0 is true

Low/Info issue submitted by recursiveEth

Summary

The functions handle_validation_e449022e and handle_validation_0502b1c5 within the ZivoeSwapper contract inconsistently handle the order of tokens in Uniswap pool validations. This inconsistency can lead to incorrect token order assumptions and potential failures in token swap operations.

Vulnerability Detail

In handle_validation_0502b1c5, when zeroForOne_0 is true, the validation assumes that assetIn corresponds to token1() of the UniswapV2 pool. However, in handle_validation_e449022e, the correct token order is used, with assetIn corresponding to token0() when zeroForOne_0 is true

Impact

he inconsistency in handling token order can result in erroneous assumptions about the token pair order in Uniswap pools. This can lead to failed swap operations, loss of funds

Code Snippet

https://github.com/sherlock-audit/2024-03-zivoe/blob/main/zivoe-core-foundry/src/lockers/Utility/ZivoeSwapper.sol#L133

if (zeroForOne_0) {
  // In handle_validation_e449022e
  require(IUniswapV3Pool_ZivoeSwapper(
    address(uint160(uint256(_c[0])))
  ).token0() == assetIn, "handle_validation_e449022e() token0() != assetIn");

  // In handle_validation_0502b1c5
  require(IUniswapV2Pool_ZivoeSwapper(
    address(uint160(uint256(_d[0])))
  ).token1() == assetIn, "handle_validation_0502b1c5() token1() != assetIn");
}

Tool used

Manual Review

Recommendation

Ensure that the handling of token order in Uniswap pool validations is consistent across different functions within the contract.

pseudonaut commented 6 months ago

SafeMath is present in Solidity 0.8.0+ , not valid