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

Fee Conversion Price Basis in VaultReader

Summary

The VaultReader contract calculates a position's net value by converting various fee and collateral amounts into a USD-equivalent value. In doing so, it uses the minimum price (e.g., prices.shortTokenPrice.min and prices.longTokenPrice.min) to convert collateral amounts and fee amounts. An inline comment suggests that using the maximum price for fee conversion could help the protocol collect an appropriate fee amount under volatile market conditions. This issue, while considered low severity, may lead to undercharging fees and subtle economic imbalances.

Vulnerability Details

  • Current Implementation:
    The net value is computed as follows:

    uint256 netValue =
    positionInfo.position.numbers.collateralAmount * prices.shortTokenPrice.min +
    positionInfo.fees.funding.claimableLongTokenAmount * prices.longTokenPrice.min +
    positionInfo.fees.funding.claimableShortTokenAmount * prices.shortTokenPrice.min -
    positionInfo.fees.borrowing.borrowingFeeUsd -
    positionInfo.fees.funding.fundingFeeAmount * prices.shortTokenPrice.min -
    positionInfo.fees.positionFeeAmount * prices.shortTokenPrice.min;
    if (positionInfo.basePnlUsd >= 0) {
    netValue = netValue + uint256(positionInfo.basePnlUsd);
    } else {
    netValue = netValue - uint256(-positionInfo.basePnlUsd);
    }
    • Collateral Amount Conversion: The collateral is converted to a USD equivalent using prices.shortTokenPrice.min.

    • Fee Deductions: Fees (funding, borrowing, position fees) are also converted using prices.shortTokenPrice.min.

  • Issue Identified
    The inline comment indicates that using the maximum price for fee conversions might be preferable to ensure that the protocol collects a sufficiently high fee. The concern is that if the market price is higher than the minimum price, converting fees with the min price understates the fee’s USD value.

Impact

  • Undercharged Fees:
    If the actual market price exceeds the minimum oracle price, the USD value of fees will be converted into a lower token amount. This results in the protocol collecting fewer fees than intended.
    While this issue is low severity on its own, repeated undercharging in volatile markets could lead to subtle yet significant economic distortions.

Tools Used

  • Manual Code Review:
    Detailed examination of the VaultReader contract’s net value computation logic.

Recommendations

  1. Re-Evaluate the Price Basis for Fee Conversion:

    • Consider using prices.shortTokenPrice.max (and similarly, prices.longTokenPrice.max for long token components) for fee conversion. This would convert fee amounts into collateral tokens more conservatively, ensuring the protocol collects the intended fee in USD terms.

Updates

Lead Judging Commences

n0kto Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational or Gas

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.

Support

FAQs

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

Give us feedback!