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.
Current Implementation:
The net value is computed as follows:
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.
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.
Manual Code Review:
Detailed examination of the VaultReader contract’s net value computation logic.
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.
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.