DeFiFoundry
50,000 USDC
View results
Submission Details
Severity: medium
Invalid

Potential Rounding Errors in Price Impact Calculation

VaultReader

In getPriceImpactInCollateral the expected token delta is computed as:

uint256 expectedSizeInTokensDelta = sizeDeltaInUsd / prices.indexTokenPrice.min;

Because this is integer division, truncation may occur. Later, the function computes a price impact in collateral terms by comparing this expected delta with the real token delta. In a highly leveraged context even minor rounding errors could distort fee or impact calculations.

Impact:
Even minor rounding differences could lead to inaccurate calculations of the price impact on collateral. Over many transactions or in highly leveraged situations, such discrepancies could cause measurable drift in fee assessments or position adjustments—thereby potentially violating the “Depositor Share Value Preservation” invariant.

Validation:
The code subtracts the actual change (curSizeInTokens – prevSizeInTokens) from the expected delta, then scales it back into collateral terms. The use of integer division (without compensating for decimals) is a concrete source of error in financial computations.

Recommendation:
Consider reordering the operations (multiplying before dividing) or using a fixed‑point math library to reduce truncation errors and better capture fractional differences.

Updates

Lead Judging Commences

n0kto Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Too generic

Support

FAQs

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

Give us feedback!