DeFiHardhat
12,000 USDC
View results
Submission Details
Severity: low
Invalid

Hardcoded `LOG_MAX_INCREASE` && `LOG_MAX_`DECREASE` does not consider volatilities of all used assets

Summary

The MultiFlowPump is designed to handle multiple tokens, but it applies a universal cap for the maximum percentage change of token reserves, represented by the variables LOG_MAX_INCREASE and LOG_MAX_DECREASE. This one-size-fits-all approach may not accurately reflect the inherent volatility of different tokens, potentially distorting the SMA and EMA values.

Vulnerability Details

The smart contract uses immutable variables to cap changes in token reserves per block time passed.

//MultiFlowPump.sol update()
capExponent = ((deltaTimestamp - 1) / CAP_INTERVAL + 1).fromUInt();
//MultiFlowPump.sol update()
...
uint256 _reserve;
for (uint256 i; i < numberOfReserves; ++i) {
// Use a minimum of 1 for reserve. Geometric means will be set to 0 if a reserve is 0.
_reserve = reserves[i];
pumpState.lastReserves[i] =
_capReserve(pumpState.lastReserves[i], (_reserve > 0 ? _reserve : 1).fromUIntToLog2(), capExponent);
//MultiFlowPump.sol _capReserve()
...
if (lastReserve.cmp(reserve) == 1) {
bytes16 minReserve = lastReserve.add(capExponent.mul(LOG_MAX_DECREASE));
// if reserve < minimum reserve, set reserve to minimum reserve
if (minReserve.cmp(reserve) == 1) reserve = minReserve;
}
// Reserve increasing or staying the same (lastReserve <= reserve)
else {
bytes16 maxReserve = lastReserve.add(capExponent.mul(LOG_MAX_INCREASE));
// If reserve > maximum reserve, set reserve to maximum reserve
if (reserve.cmp(maxReserve) == 1) reserve = maxReserve;
}

This is implemented in the _capReserve() function, which sets limits on how much token reserves can increase or decrease based on predefined percentages. If a token's reserve changes exceed these limits, the change is capped.

Impact

The uniform cap can lead to inaccurate pricing for tokens that have different volatility profiles:

  • Some trading pairs may appear more stale than their actual trading activities.

  • While for more other stable tokens, these restrictions might not have any effect at all

Tools Used

Manual review

Recommendations

The different assets volatilities should be taken into account. This is usually the case when working with oracles and AMMs. As UniswapV3 uses different tick spacings while chainlink utilizes different heartbeats for every pair price.
Consider using a token specific LOG_MAX_INCREASE and LOG_MAX_DECREASE in the prices calculation.

Updates

Lead Judging Commences

giovannidisiena Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
Assigned finding tags:

Informational/Invalid

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.