Skip to content

Latest commit

 

History

History
64 lines (40 loc) · 2.01 KB

File metadata and controls

64 lines (40 loc) · 2.01 KB

Fast Khaki Raccoon

Medium

Stable pairs on aerodrome are un-usable

Summary

Stable is hardcoded to false, meaning that we would not be able to use any stable pools on aerodrome ( USDC : USDT оr WETH : stETH ), even if they have the highest liquidity for the pair and thus the lowest slippage and fee.

Root Cause

We have hardcoded stable to false, meaning that we would not be able to use aerodrome stable pools:

https://github.com/sherlock-audit/2025-01-peapods-finance/blob/main/contracts/contracts/dex/AerodromeDexAdapter.sol#L71

        _routes[0] = IAerodromeRouter.Route({
            from: _tokenIn,
            to: _tokenOut,
            stable: false,
            factory: IAerodromeRouter(V2_ROUTER).defaultFactory()
        });

We can see from aerodrome's code that we are not able to get a stable pool is stable is false

https://github.com/aerodrome-finance/contracts/blob/main/contracts/Router.sol#L70

    function poolFor(address tokenA, address tokenB, bool stable, address _factory) public view returns (address pool) {
        address _defaultFactory = defaultFactory;
        address factory = _factory == address(0) ? _defaultFactory : _factory;
        if (!IFactoryRegistry(factoryRegistry).isPoolFactoryApproved(factory)) revert PoolFactoryDoesNotExist();

        (address token0, address token1) = sortTokens(tokenA, tokenB);
        bytes32 salt = keccak256(abi.encodePacked(token0, token1, stable));
        pool = Clones.predictDeterministicAddress(IPoolFactory(factory).implementation(), salt, factory);
    }

Internal Pre-conditions

No response

External Pre-conditions

No response

Attack Path

The contract will not work with stable pools in general.

Impact

The stable pools can be the ones with highest liquidity and thus lowest slippage and fees. Even more true if we are swapping between stable pairs like USDC : USDT оr WETH : stETH

PoC

No response

Mitigation

Consider adding the ability to add stable to the input parameters.