Approximations may finish with inaccurate values
The HybridPool contract's approximation functions may stop before converging due to a loop limit, and the inaccurate result is still used as correct. This could lead to incorrect liquidity calculations, potentially causing financial loss.
Submitted by 0xsanson, also found by broccoli
Impact
In HybridPool.sol, functions _computeLiquidityFromAdjustedBalances, _getY and _getYD may finish before approximation converge, since it’s limited by MAX_LOOP_LIMIT iterations. In this situation the final estimated value will still be treated as correct, even though it could be relatively inaccurate.
Recommended Mitigation Steps
Consider reverting the transactions if this doesn’t occur. See https://blog.openzeppelin.com/saddle-contracts-audit/ issue [M03], with their relative fix.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely, the approximation loops are capped by a maximum iteration limit without verifying convergence, and the code does not revert when the limit is reached.
Impact
The inaccurate estimated value is treated as correct, which could lead to incorrect liquidity calculations and potential financial loss.
What the attacker needed
None
The fix
The transactions should be reverted if convergence does not occur, as suggested by the recommended mitigation steps.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Smart contracts sometimes use repeated calculations to estimate a value. If they stop too early, the estimate can be wrong. Here, the contract does not check if the estimate is good enough and just uses it, which could cause problems.