The decreaseCollateral
and increaseCollateral
functions in the ShortRecordFacet
contract calculate the short's collateral ratio based on the cached asset price, which may be outdated, leading to a divergence between the actual collateral ratio (based on the asset spot price) and the calculated collateral ratio.
According to the conditions for updating the oracle, decreasing the short's collateral via the ShortRecordFacet.decreaseCollateral
function should update the oracle price if the oracle price is older than 15 minutes.
However, in the current implementation of the decreaseCollateral
function, the short's collateral ratio, cRatio
, is calculated by calling the getCollateralRatio
function in line 94:
The called getCollateralRatio
function uses the LibOracle.getPrice
function to calculate the collateral ratio:
The LibOracle.getPrice
function returns the currently cached asset price, which potentially is older than 15 minutes.
Consequently, the calculated cRatio
in line 94 of the decreaseCollateral
function is based on the potentially outdated asset price, resulting in the collateral ratio being inaccurate and diverging from the actual collateral ratio based on the current asset spot price.
A short owner can exploit this by decreasing the short's collateral up to the point where the resulting collateral ratio is equal to the initial margin (i.e., 500%). As the collateral ratio, cRatio
, is calculated in line 94 based on the outdated cached oracle price, the short owner can withdraw more collateral than the actual collateral ratio (based on the asset spot price) would allow.
Similarly, the increaseCollateral
function is affected as well.
Short-position owners can withdraw more collateral than eligible, negatively affecting the overall asset's collateral ratio.
Manual Review
Consider using the LibOracle.getSavedOrSpotOraclePrice
function together with the getCollateralRatioSpotPrice
function to calculate the collateral ratio based on the current asset price.
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.