The sumReturnUint256 function in MarketUtils library may revert when calculating open interest adjustments due to underflow in negative position size scenarios. While the revert behavior is protected by Solidity 0.8's built-in checks, improved validation and documentation would enhance code clarity.
The function attempts to subtract a negative delta from the current open interest without explicit validation:
The function is used in getMinCollateralFactorForOpenInterest() for calculating changes in open interest positions. While Solidity 0.8+ prevents actual underflows through built-in checks, the abrupt reversion could be handled more gracefully.
Severity: Low
Likelihood: Low
Impact: Low
The issue is mitigated by:
Built-in Solidity 0.8+ overflow/underflow protection
Alignment with business logic (open interest cannot be negative)
No loss of funds possible
Add explicit validation and documentation:
Manual code review
Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelihood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.
There is no real proof, concrete root cause, specific impact, or enough details in those submissions. Examples include: "It could happen" without specifying when, "If this impossible case happens," "Unexpected behavior," etc. Make a Proof of Concept (PoC) using external functions and realistic parameters. Do not test only the internal function where you think you found something.
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.