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

Precision Loss in Arithmetic Operations in VaultReader::getPriceImpactInCollateral()

Summary

The contract performs multiple division operations that could lead to precision loss.

Vulnerability Details

In the getPriceImpactInCollateral() function, there are division operations that may result in precision loss:

uint256 expectedSizeInTokensDelta = sizeDeltaInUsd / prices.indexTokenPrice.min;
uint256 curSizeInTokens = getPositionSizeInTokens(positionKey);
uint256 realSizeInTokensDelta = curSizeInTokens - prevSizeInTokens;
int256 priceImpactInTokens = expectedSizeInTokensDelta.toInt256() - realSizeInTokensDelta.toInt256();
int256 priceImpactInCollateralTokens = priceImpactInTokens * prices.indexTokenPrice.min.toInt256() / prices.shortTokenPrice.min.toInt256();
return priceImpactInCollateralTokens;

Impact

Precision loss could lead to inaccurate calculations of position sizes, fees, or price impacts, potentially resulting in small financial discrepancies.

Tools Used

Manual code review

Recommendations

  • Use a standard precision library for fixed-point arithmetic

  • Consider increasing the precision of intermediate calculations

  • Implement rounding mechanisms to handle precision loss consistently

Updates

Lead Judging Commences

n0kto Lead Judge 5 months ago
Submission Judgement Published
Invalidated
Reason: Too generic
Assigned finding tags:

Suppositions

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.

Support

FAQs

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