Smart contracts can only access data available on the blockchain; we call this on-chain data.

Sometimes, a contract may need data that is not available on the blockchain e.g A user may want the price data of $SUSHI on all the different centralized exchanges so he/she can compare it with SushiSwap's pool price.

Smart contracts can only fetch on-chain data. This means a contract that can frequently and accurately update the token's price is needed.

But how do we make sure that the price returned by the contract is accurate? Who will be the one updating it? How can one make sure it is not lying and giving the wrong price?

Introducing - Oracles

An Oracle like Chainlink is a network of nodes that manage and aggregate different contracts containing off-chain data (Tokens prices, weather, randomness, or many other things).

The accuracy of the data is achieved by aggregating the data from honest nodes within the network. When an Oracle submits data on-chain, this data is kept forever. The system can check to see if the node is resilient and whether or not it has been a good actor since inception.

With this system in place, we can ensure that the data is correct and use it for any DeFi application e.g Kashi.