Skip to content
Business logic Audit finding Intermediate

V2AMO is not compatible with Velodrome/Aerodrome

The SolidlyV2AMO contract's interfaces for gauges and routers do not match those of Velodrome/Aerodrome, so calls to get rewards or perform swaps would fail. This prevents the contract from working with those DEXes as intended.

0x37 Follow with Greese, KupiaSec and 4 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-10-axion-judging/issues/239

Found by

0x37, Greese, KupiaSec, PNS, carrotsmuggler, pkqs90, y4y

Summary

According to the docs, the Dex scope for SolidlyV2 includes Velodrome/Aerodrome.

We expect the SolidlyV2 tech-implementation work with the “classic” pools on the following Dexes: Velodrome, Aerodrome, Thena, Equalizer (Fantom/Sonic/Base), Ramses and forks (legacy pools), Tokan

However, for Velodrome/Aerodrome implementations, the current SolidlyV2AMO is not compatible.

Root Cause

There are two parts of integration with Velodrome/Aerodrome that are buggy:

  1. Gauge
  2. Router

Let's go through them one by one (Note, since Velodrome and Aerodrome have basically the same code, I will only post Aerodrome code):

1. Gauge

The main difference is in the getReward() function.

Aerodrome interface: https://github.com/aerodrome-finance/contracts/blob/main/contracts/interfaces/IGauge.sol

Solidity
interface IGauge {
    ...
    function getReward(address _account) external;
    ...
}

SolidiyV2AMO interface: https://github.com/sherlock-audit/2024-10-axion/blob/main/liquidity-amo/contracts/interfaces/v2/IGauge.sol#L4

Solidity
interface IGauge {
    ...
    function getReward(address account, address[] memory tokens) external;

    function getReward(uint256 tokenId) external;

    function getReward() external;
    ...
}

2. Router

The main difference is:

  1. Aerodrome uses poolFor instead of pairFor when querying a pool/pair.
  2. The Route struct is implemented differently, and is used when performing swap

Aerodrome interface: https://github.com/aerodrome-finance/contracts/blob/main/contracts/interfaces/IRouter.sol#L6

Solidity
interface IRouter {
    struct Route {
        address from;
        address to;
        bool stable;
        address factory;
    }

    function poolFor(
        address tokenA,
        address tokenB,
        bool stable,
        address _factory
    ) external view returns (address pool);

    function swapExactTokensForTokens(
        uint256 amountIn,
        uint256 amountOutMin,
        Route[] calldata routes,
        address to,
        uint256 deadline
    ) external returns (uint256[] memory amounts);
    ...
}

SolidiyV2AMO interface: https://github.com/sherlock-audit/2024-10-axion/blob/main/liquidity-amo/contracts/interfaces/v2/ISolidlyRouter.sol#L4

Solidity
interface ISolidlyRouter {
    struct route {
        address from;
        address to;
        bool stable;
    }

    function pairFor(address tokenA, address tokenB, bool stable) external view returns (address pair);

    function swapExactTokensForTokens(
        uint256 amountIn,
        uint256 amountOutMin,
        route[] memory routes,
        address to,
        uint256 deadline
    ) external returns (uint256[] memory amounts);
    ...
}

Internal pre-conditions

N/A

External pre-conditions

N/A

Attack Path

N/A

Impact

SolidlyV2AMO does not work with Aerodrome/Velodrome as expected.

PoC

N/A

Mitigation

N/A

Discussion

sherlock-admin2

The protocol team fixed this issue in the following PRs/commits: https://github.com/AXION-MONEY/liquidity-amo/pull/9

The original report as published on Sherlock, by 0x37. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The contract's interface definitions for the gauge's getReward function and the router's poolFor/Route struct do not match the actual interfaces used by Velodrome/Aerodrome.

What the attacker needed

None

The fix

The protocol team fixed this issue in a pull request.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

This is a smart contract that is supposed to work with two exchanges, Velodrome and Aerodrome. But the contract expects the exchanges to have certain functions with specific inputs, and the exchanges actually have different function signatures. So when the contract tries to call them, the calls will not work.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by 0x37

View all

79 more disclosed reports, best first.

More from AXION

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.