Part 2

Zaros
PerpetualsDEXFoundrySolidity
70,000 USDC
View results
Submission Details
Severity: medium
Invalid

[M-2]Reliance on Unstable Enumeration Order in LiveMarkets::getLiveMarketsIds

Summary

LiveMarket:: getMarketAtIndex is using EnumerableSet from openzeppelin for the iteration order of elements which can change unpredictably when elements are added or removed, leading to incorrect index-based logic when trying to retrieve all .

Vulnerability Details

The getLiveMarketsIdsfunction returns an array of live marketIDs by iterating through an EnumerableSet using index-based access (at(i)). While functionally correct, this pattern creates a hidden risk for systems that consume the returned array, as EnumerableSet does not guarantee stable iteration order. The order of IDs can change unpredictably when markets are added/removed, violating assumptions in dependent logic.

function getLiveMarketsIds(Data storage self) internal view returns (uint128[] memory marketIds) {
uint256 liveMarketsLength = self.liveMarketIds.length();
marketIds = new uint128[](liveMarketsLength);
for (uint256 i; i < liveMarketsLength; i++) {
@> marketIds[i] = uint128(self.liveMarketIds.at(i));
}
}

}

Impact

Incorrect operation of corr logic relying on market order or UI display inconsistently.

Tools Used

Manual review

Recommendations

getLiveMarketsIds function does create a hidden risk if the consuming logic assumes a stable enumeration order. Developers should either:

Indicate that the order of market IDs is non-deterministic and should not be relied upon.

If order is important, consider maintaining a separate ordered list or using a data structure that guarantees order consistency.

Updates

Lead Judging Commences

inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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