ChainlinkOracle
should use the updatedAt
value from the latestRoundData()
function to make sure that the latest answer is recent enough to be used.
In the current implementation of distributeAssets
function:
there is no freshness check. This could lead to stale prices being used.
If the market price of the token drops very quickly, and Chainlink's feed does not get updated in time, the smart contract will continue to believe the token is worth more than the market value.
Chainlink also advise developers to check for the updatedAt
before using the price:
Your application should track the latestTimestamp variable or use the updatedAt value from the latestRoundData() function to make sure that the latest answer is recent enough for your application to use it. If your application detects that the reported answer is not updated within the heartbeat or within time limits that you determine are acceptable for your application, pause operation or switch to an alternate operation mode while identifying the cause of the delay.
Additionally, they have this heartbeat concept:
Chainlink Price Feeds do not provide streaming data. Rather, the aggregator updates its latestAnswer when the value deviates beyond a specified threshold or when the heartbeat idle time has passed. You can find the heartbeat and deviation values for each data feed at data.chain.link or in the Contract Addresses lists.
The Heartbeat for EUR/USD is 24h.
Source: https://data.chain.link/ethereum/mainnet/fiat/eur-usd
distributeAssets
function is used to calculate the value and transfer various tokens. If the price is not accurate, it will lead to a deviation in the token price and affect the calculation of asset prices.
Stale asset prices can lead to bad debts to the protocol as the collateral assets can be overvalued, and the collateral value can not cover the loans.
Manual Review
Consider adding the missing freshness check for stale 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.