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.
Unbounded loops can lead to excessive gas consumption, potentially causing transactions to fail due to reaching the block gas limit.
Manual code review
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.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.