The VaultReader contract determines a position's net value by converting collateral and fee amounts into their USD equivalents. Currently, it utilizes the minimum price (e.g., prices.shortTokenPrice.min and prices.longTokenPrice.min) for these conversions. A comment in the code suggests that using the maximum price for fee calculations could help ensure appropriate fee collection under volatile market conditions. While this issue is of low severity, it may result in undercharging fees and create economic imbalances over time.
Current Implementation: The contract computes the net value as follows:
Collateral Conversion: Collateral amounts are converted into USD using prices.shortTokenPrice.min.
Fee Deductions: Fees (funding, borrowing, and position fees) are also calculated using prices.shortTokenPrice.min.
Identified Issue: A comment in the code suggests that fee conversion might be more accurate if based on the maximum price instead. If the actual market price is higher than the minimum price, using the minimum price undervalues fees in USD terms, leading to potential undercharging.
Undercharged Fees: When the market price exceeds the minimum oracle price, the conversion results in a lower USD fee amount than intended. While this discrepancy may seem minor per transaction, frequent occurrences in volatile markets could lead to significant cumulative undercharges.
Manual Code Review: A thorough examination of the VaultReader contract’s net value calculation logic.
Reassess Fee Conversion Price Basis:
Consider using prices.shortTokenPrice.max (and prices.longTokenPrice.max for long token fees) to ensure fees are collected at their appropriate USD value.
This approach would help maintain the intended fee collection mechanism and prevent economic imbalances caused by undercharging.
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.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.