Incomplete TVL Calculation in AerodromeConnector::_getPositionTVL Function
Submitted by KupiaSec, also found by Weed0607, pkqs90 (1, 2), said, Inspex, BenRai (1, 2), Zac, and 0xAlix2
Impact
The AerodromeConnector::stake function allows to stake liquidity tokens to the gauge pool. However, the AerodromeConnector::_getPositionTVL function, which is responsible for calculating the Total Value Locked (TVL), does not take into account the liquidity tokens deposited in the gauge pool. This oversight will result in an incorrect calculation of the TVL, which could negatively impact the overall functionality of the protocol that utilizes the TVL metric.
Proof of Concept
The AerodromeConnector::stake function allows to deposit and stake liquidity tokens in the gauge pool.
AerodromeConnector.sol
100: function stake(address pool, uint256 liquidity) public onlyManager nonReentrant {
101: address gauge = voter.gauges(pool);
102: IERC20(pool).forceApprove(address(gauge), liquidity);
103: IGauge(gauge).deposit(liquidity, address(this)); // @audit-info this sends tokens to the gauge
104: }
The implementation of the Gauge::deposit is as follows:
function deposit(uint256 _amount, address _recipient) external {
_depositFor(_amount, _recipient);
}
function _depositFor(uint256 _amount, address _recipient) internal nonReentrant {
if (_amount == 0) revert ZeroAmount();
if (!IVoter(voter).isAlive(address(this))) revert NotAlive();
address sender = _msgSender();
_updateRewards(_recipient);
IERC20(stakingToken).safeTransferFrom(sender, address(this), _amount); // @audit-info liquidity tokens are sent to the gauge.
totalSupply += _amount;
balanceOf[_recipient] += _amount;
emit Deposit(sender, _recipient, _amount);
}
As evident from the preceding code snippet, when the Gauge::deposit function is invoked, staked liquidity tokens are sent to the gauge pool. However, the implementation of the AerodromeConnector::_getPositionTVL function only accounts for the liquidity tokens held in the Aerodrome pool, and does not consider the tokens that have been staked in the gauge pool. This oversight in the AerodromeConnector::_getPositionTVL function will result in an incomplete calculation of the Total Value Locked (TVL).
AerodromeConnector.sol
125: function _getPositionTVL(HoldingPI memory p, address base) public view override returns (uint256) {
126: PositionBP memory pBP = registry.getPositionBP(vaultId, p.positionId);
127: (address pool) = abi.decode(pBP.data, (address));
128: uint256 balance = IERC20(pool).balanceOf(address(this)); // @audit-issue only accounts the liquidity token balance at the aerodrome pool, does not include the gauge pool
129: uint256 totalSupply = IERC20(pool).totalSupply();
130: (uint256 reserve0, uint256 reserve1,) = IPool(pool).getReserves();
131: uint256 amount0 = balance * reserve0 / totalSupply;
132: uint256 amount1 = balance * reserve1 / totalSupply;
133: return _getValue(IPool(pool).token0(), base, amount0) + _getValue(IPool(pool).token1(), base, amount1);
134: }
As a result, the Total Value Locked (TVL) value calculated by the AerodromeConnector::_getPositionTVL function will be less than the actual value, as it does not account for the liquidity tokens staked in the gauge pool. This underestimation of the TVL could negatively impact the overall functionality of the protocol that relies on the TVL metric.
Recommended Mitigation Steps
It is recommended to fix the _getPositionTVL function to take account liquidity tokens staked in the gauge pool as follows:
function _getPositionTVL(HoldingPI memory p, address base) public view override returns (uint256) {
PositionBP memory pBP = registry.getPositionBP(vaultId, p.positionId);
(address pool) = abi.decode(pBP.data, (address));
+ address gauge = voter.gauges(pool);
- uint256 balance = IERC20(pool).balanceOf(address(this));
+ uint256 balance = IERC20(pool).balanceOf(address(this)) + IERC20(gauge).balanceOf(address(this));
uint256 totalSupply = IERC20(pool).totalSupply();
(uint256 reserve0, uint256 reserve1,) = IPool(pool).getReserves();
uint256 amount0 = balance * reserve0 / totalSupply;
uint256 amount1 = balance * reserve1 / totalSupply;
return _getValue(IPool(pool).token0(), base, amount0) + _getValue(IPool(pool).token1(), base, amount1);
}
HadiEsna (NOYA) confirmed and commented:
True, needs to be fixed. But I think Medium severity not High, because it’s not going to cause loss of funds in any way.
Finalizing as High Risk as TVL affects share calculation.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A high-severity business logic bug in NOYA. Code4rena made it public on 17 February 2025. Found in the 2024-04-noya audit contest (finding H-06), also found by 5 other wardens.
About Business logic
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
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.