Oracles and their importance

‘Oracle’ is a word of ancient Greek origin, that indicated a priestess through whom a deity is believed to speak. Most people will have heard of Pythia, the oracle of Delphi in Greek mythology, who would make prophecies. This is also the naming inspiration for Pyth, a project covered here.

In modern day culture, an oracle refers to a person giving wise decisions or opinions. Warren Buffet earned the nickname of ‘The Oracle of Omaha’ due to his investing prowess. However, in the crypto industry, an oracle refers to a provider of some sort of data or information. Usually, this data is the price of something. For example, BTC/USDC = 37,000, ETH/USDC = 2,400, SOL/USDC = 40.0 and so forth. An example of a live oracle price feed can be seen here. Another use of oracle data is the cryptonary discord bot price ticker. But how is this data sourced, and why is it important?

If I ask you what the price of Ethereum currently is, you will most likely open up the exchange of your choice, look up the trading pair and then tell me the price. The price which the exchange reports is the price at which the most recent trade occurred.

If there is enough liquidity in the market, then the price reported will be accurate. Prices across exchanges are very similar, as if any big differences occur, traders can make a risk-free profit, just like the below example:

If I was to offer you SOL with a price of SOL/USDC = 10, you would immediately identify the difference in price. You would look to buy the SOL from me at 10USDC, and then sell it at exchanges who are offering a price of 40USDC.

For the above scenario, I have probably been misinformed about the price. Regardless, you will stand to profit from the difference in information. This inherently answers why the ‘price reported’ is important.

With internet access being necessary to participate in the crypto space, most users will be able to manually source an accurate price. Discrepancies as large as the above rarely occur, however they still do and will be covered in another journal. Now let us replace ‘me’ with your favourite decentralised finance (DeFi) protocol in the above example. How does the protocol know what the price of other tokens are, or its Total Value Locked (TVL) in USDC ?

The protocol can’t just look at its favourite exchange like you did in our first example. This data must be published on-chain, and this is what oracles do. The best-known oracle is Chainlink. From Wikipedia:

“Chainlink is a decentralized oracle network and cryptocurrency that provides real-world data to blockchains. It is one of the main sources of data used to feed information to applications in decentralized finance.”

Oracles are necessary to allow DeFi protocols to interact with the crypto ecosystem and the real world. Any platform that offers financial products such as loans, yield farming, liquidity pools and so forth, requires accurate and up to date price data.

In the case of liquidity pools, the price is of pivotal importance both when a user adds and removes liquidity. Liquidity is usually provided in a one-to-one ratio of the coin’s value.

I am looking to provide liquidity for a SOL/USDC liquidity pool. I would have to provide 40 USDC for the 1 SOL I am looking to deposit into the pool. I receive liquidity pool tokens which represent the funds I provided to the liquidity pool.

This is as the current price of SOL/USDC = 40.0 as mentioned above. The DeFi protocol needs to know the correct price of SOL in terms of USDC. This is to make sure that the correct ratio of funds is deposited by users. The above example would also apply if I were to remove my liquidity immediately after providing it.

I exchange my liquidity pool tokens to recover my funds. As I am doing this only minutes after providing the funds, the price has not changed.  I will receive back 1 SOL and 40 USDC.

It is necessary for the protocol to have an accurate price at all times to ensure that the above operations occur with the correct ratios. If in the above example, when withdrawing my liquidity, the protocol has the wrong price, I will receive the wrong proportion of tokens. If someone were to manipulate the price which the protocol sees, the following malicious actions could be taken:

  1. Deposit liquidity with the correct price
  2. Then simultaneously:
    • Change the price which the protocol sees. For example, instead of SOL/USDC = 40.0 which was used for the deposit, make the protocol think the price is SOL/USDC = 20.0.
    • Withdraw your liquidity, with the falsified price being used by the protocol, receiving more SOL than was initially deposited.

This allows the malicious actor to take advantage of the protocol. A similar example is any DeFi protocol that allow a user to take out a collateralised loan. The user is required to lock away some of their funds with the protocol as collateral for the loan being provided. Let us assume that the protocol requires 200USDC worth of collateral funds to be locked away to allow for a loan of 100USDC.

I am looking to use 5SOL as collateral with a DeFi protocol to take out a loan of 100USDC. With SOL/USDC = 40.0, the current value of the 5SOL is equivalent to 200USDC, which is the required collateral for the 100USDC loan.

If a malicious actor could control the price which the protocol uses to work out the value of the collateral, they could take out under collateralized loans. By tricking the protocol into thinking SOL/USDC = 100.0, the malicious actor would only need to provide 2SOL and not 5SOL to take out a loan of 100USDC.

To be resistant to the above scenarios outlined above, many oracles are decentralised. If there was only one provider of data to the oracle, then the data provider could look to manipulate the data feed for their personal advantage. It is important to understand that the role of the oracle is publishing these price on-chain so they are available to other DeFi protocols. How each oracle sources the data feeds they publish to the blockchain is up to them. Ultimately, this plays a huge role in determining their value.

Most oracles look to have multiple independent data sources for any assets they are reporting prices on. The below diagram outlines this:

The oracle will combine all the prices it receives from the different sources and come to a ‘true price’. This price will be very close to all the exchange prices. Of course, as can be seen despite the price of bitcoin being taken from multiple sources, there is nothing stopping the oracle from publishing a manipulated price for the oracles’ own gain.

To protect against this many oracle protocols have multiple nodes that provide the same price data. These oracles are referred to as decentralised oracles. This protects against an oracle node operator acting maliciously for their own personal gain. The diagram below serves to illustrate this:

We have covered the importance of a correct price being available on-chain and how oracles facilitate this. Some basic examples of how malicious actors can manipulate the price feed used by protocols for their own personal gain helped illustrate the importance of accurate price data. With an understanding of how oracles work, in the next journal, we will review how some DeFi protocols were recently exploited by malicious actors, leading to millions of USDC being stolen. As an investor in the cryptocurrency space, an understanding of the risks present in the space, and not only the potential rewards is essential.

Sign up for our FREE mailing list

Join 12,590 others now and get actionable research and analysis sent directly to your inbox.

Post a Comment

GET YOUR CRYPTO DAILY BRIEF

Delivered daily, straight to your inbox.