The function euroCollateral() use's the function tokenToEurAvg
which is using chain-link's pricing function to get the price of an asset. Here, the number of hours used in averaging is not sufficient.
The function euroCollateral() would be used to compute the amount of EUORs to be minted for the available asset balance.
https://github.com/Cyfrin/2023-12-the-standard/blob/91132936cb09ef9bf82f38ab1106346e2ad60f91/contracts/SmartVaultV3.sol#L67-L73
Later the calculated euros would be used in many places. one of the place is maxMintable
.
https://github.com/Cyfrin/2023-12-the-standard/blob/91132936cb09ef9bf82f38ab1106346e2ad60f91/contracts/SmartVaultV3.sol#L75-L77
the output of maxMintable()
would be used to decide the liquidation condition by using the below function.
https://github.com/Cyfrin/2023-12-the-standard/blob/91132936cb09ef9bf82f38ab1106346e2ad60f91/contracts/SmartVaultV3.sol#L99-L101
https://github.com/Cyfrin/2023-12-the-standard/blob/91132936cb09ef9bf82f38ab1106346e2ad60f91/contracts/SmartVaultV3.sol#L114-L123
But, when we look at the function tokenToEurAvg
,
https://github.com/Cyfrin/2023-12-the-standard/blob/91132936cb09ef9bf82f38ab1106346e2ad60f91/contracts/utils/PriceCalculator.sol#L43-L49
It is using the chain-link price data to calculate the asset price. Since this place misses the validation of stale price, the old price value would influence the asset price calculation. This would directly affect on the function which are in scope.
also, the hours used in averaging is not sufficient.
https://github.com/Cyfrin/2023-12-the-standard/blob/91132936cb09ef9bf82f38ab1106346e2ad60f91/contracts/utils/PriceCalculator.sol#L18-L37
stale price would be causing impact on the liquidation. Some time it would be lead to early liquidation or missing from liquidation.
Manual review.
We suggest to follow the chain-links recommended procedure when calculating the asset price.
Please update the function tokenToEurAvg
to fix this issue.
https://docs.chain.link/data-feeds/using-data-feeds
Use number of hours as 24 in averaging.
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.