The decreaseCollateral
function does not update the oracle price as it's stated in the docs, this could lead to wrong cRatio
being calculated and thus cause short undercollateralization after collateral decrease resulting in losses for the user and/or protocol.
The issue occurs in the decreaseCollateral
function below :
As you can see the function calls immediately getCollateralRatio
to get the short collateral ration, this function uses the previously saved oracle price in its calculation :
The protocol docs about the oracles does state that the oracle price should be updated if decreaseCollateral
is called and it's 15 min past the saved oracle time, you can check here.
Because the price is not updated before decreasing a short collateral amount, it can result in the following :
A short becoming undercollateralized if the asset price have dropped quickly compared to old saved price (which can happen in highly volatile market), this will lead for sure to losses for the protocol or the short holder.
The short holder may not be allowed to decrease the collateral amount because the saved price is below the current one.
Short becoming undercollateralized after collateral decrease with decreaseCollateral
resulting in potential losses for the user and/or protocol.
Manual review
Use both getSavedOrSpotOraclePrice
and getCollateralRatioSpotPrice
to ensure that the collateral ratio is calculated with the correct price, the following modification should be made to the decreaseCollateral
function :
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.