Skip to content
Audit finding Advanced

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.

0xsanson Follow

Originally disclosed on Code4rena

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.

The original report as published on Code4rena, by 0xsanson. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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.

More by 0xsanson

View all

8 more disclosed reports, best first.

More from Sushi Trident contest phase 1

View all

The newest disclosed reports for this program.

Similar reports

Same bug class and techniques, clearest first.