The Zaros system supports various collateral types by converting their values to USD for margin calculations. However, WSTETH and WEETH lack direct USD price feeds and are priced relative to ETH. Currently, there is no distinct method for valuing these assets in USD. The existing implementation retrieves their prices in ETH and incorrectly sets these prices directly as USD without performing the necessary conversion. This approach could lead to severe consequences for both users and the protocol.
In Zaros, margin collaterals are valued in USD, and the system fetches prices from Chainlink data feeds. Most collateral types have a direct collateralType/USD data feed. However, two collateral types, WSTETH and WEETH, lack direct collateralType/USD price feeds and only have collateralType/ETH price feeds. This necessitates a different approach to convert the price to USD. The ETH/USD price should first be fetched, followed by the collateralType/ETH price, and then converted to USD. Currently, the system applies the same method for all collateral types, including those with indirect price feeds, which is incorrect.
For example, the getMarginBalanceUsd function in TradingAccount.sol performs this calculation incorrectly:
In this function, marginCollateralConfiguration.getPrice() for WEETH, for example, returns the price in ETH rather than USD. This incorrect valuation can lead to significant issues, as the getMarginBalanceUsd() function is used in various components like LiquidationBranch and OrderBranch, etc. which makes the system prone to errors.
Incorrect valuation of margin collateral could lead to substantial financial losses for both users and the protocol. For example, due to fluctuations in ETH prices, due to the fact that the system mistakenly interpret ETH prices as USD prices. This miscalculation could result in previously non-liquidatable positions becoming liquidatable or users being able to withdraw less margin than originally deposited, ultimately leading to significant financial losses.
VSCode, manual code review
Implement a correct method to calculate the USD value of WSTETH and WEETH.
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.