The Standard

The Standard
DeFiHardhat
20,000 USDC
View results
Submission Details
Severity: medium
Valid

Difference in Price in Borrow Process and Liquidation Process May Lead To a Depeg of EUROs

Summary

The liquidation process only considers the current price, while the borrowing process takes the average price over the last 4 hours. This can result in burning an insufficient amount of EUROs.

Vulnerability Details

The current price is used in LiquidationPool in distributeAssets() function:

if (asset.amount > 0) {
(,int256 assetPriceUsd,,,) = Chainlink.AggregatorV3Interface(asset.token.clAddr).latestRoundData();
uint256 _portion = asset.amount * _positionStake / stakeTotal;
uint256 costInEuros = _portion * 10 ** (18 - asset.token.dec) * uint256(assetPriceUsd) / uint256(priceEurUsd)
* _hundredPC / _collateralRate;

However, in smartVaultV3 in the euroCollateral() function, the price is an average of the last 4 hours calculated by the PriceCalculator.

function euroCollateral() private view returns (uint256 euros) {
ITokenManager.Token[] memory acceptedTokens = getTokenManager().getAcceptedTokens();
for (uint256 i = 0; i < acceptedTokens.length; i++) {
ITokenManager.Token memory token = acceptedTokens[i];
euros += calculator.tokenToEurAvg(token, getAssetBalance(token.symbol, token.addr));
}
}

If Alice has minted 30,000 euros, she has 33,000 euros in collateral. Her collateral has lost value and she now has only 30,000 euros in collateral. However, this value is an average, and if the value of her collateral with the latest price is 20,000 euros, only 20,000 euros will be burned.

Impact

This will cause the euro to depeg since, until now, the euro is supposed to be pegged to the average value of the collaterals.

Tools Used

Manuel review

Recommendations

Check in the distributeAssets() function the average price and not the latest price.

Updates

Lead Judging Commences

hrishibhat Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Bad-debt

hrishibhat Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

avg-spot-price

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.