DeFiFoundry
60,000 USDC
View results
Submission Details
Severity: low
Invalid

Unbounded Loop leads to excessive gas consumption

Vulnerability Details

https://github.com/Cyfrin/2024-07-zaros/blob/main/src/perpetuals/branches/TradingAccountBranch.sol

The loops in getAccountMarginBreakdown and getAccountLeverage functions iterate over tradingAccount.activeMarketsIds without any bounds. If the length of activeMarketsIds is large, it can lead to high gas consumption and potential transaction failures.

Impact

Unbounded loops can lead to excessive gas consumption, potentially causing transactions to fail due to reaching the block gas limit.

Tools Used

Manual code review

Recommendations

Consider adding a limit to the number of iterations or refactor the logic to avoid unbounded loops. For example, you can batch the processing or use off-chain computation for large datasets.

Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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