Skip to content

How do DeFi lending markets use Oracles to source data?

  • by

Oracles act as the backbone for DeFi lending markets by providing reliable and secured pricing feeds about tokens. But what exactly happens under the hood? Are there any limitations associated with it? Let’s take a closer look!

What are lending markets and how do they work?

The rise of decentralized finance (DeFi) protocols over the last two years have been one of the greatest success stories of crypto. With a Total Value Locked of $61.4 billion (DefiLlama as of Aug 2022), it is easy to understand why this once niche area of crypto has garnered a lot of attention. However, as many crypto evangelists know, this is just the beginning. DeFi aims to completely overhaul the financial landscape by reducing barriers to entry, ensuring faster transaction speeds that result in massive cost savings and providing crypto holders with the opportunity to utilize their idle assets. Every legacy industry has a responsibility to keep up with new technology trends or face oblivion. On its current trajectory, DeFi is on course to have a massive impact on traditional finance.

The most popular area of DeFi to date are Lending Markets. Lending Markets use DLT technology and smart contracts to enable peer-to-peer lending through the innovative use of a protocol that eliminate the risk usually associated with traditional finance.

In its simplest form, DeFi users become lenders by depositing their coins into a DeFi-based smart contract for which in return they receive a minted token native to the protocol (eg DAO, aToken, cTokens). Such tokens can be redeemed at any time and the rate of exchange between the deposited and native tokens represents the APY which is determined by the ratio between the supplied and borrowed tokens in a particular market.

On the other side of the application are borrowers who are able to access funds thanks to the overcollateralization of their own digital assets that they have deposited. There is a wide variety of lending protocols, each providing a unique suite of products and services. However, the most popular type is called the liquidity pool model.

Using ETH as collateral allows the DeFi trader to borrow DAI on a lending platform

There are a number of benefits to this decentralized, peer-to-peer lending model. Firstly every borrower has access to unlimited liquidity if they have the assets available to collateralize the loan. Secondly, the promise of healthy rates of APY encourages the crypto holder to make use of their assets and prevent them from sitting idle. Finally, because the model is peer-to-peer and written in code there is no need for lengthy and exhaustive AML and KYC checks thereby lowering barriers of entry and enabling anyone to participate.

Why lending markets need oracles

There are many reasons why oracles are essential to the development of not only DeFi but any smart contract and the further development of blockchain as a whole. In its simplest terms, on-chain code used in a smart contract is unable to process real-world data. Oracles exist as essential middleware which enable smart contracts and blockchains to connect with external resources.

This combination of smart contracts, blockchains, and oracles is often referred to as hybrid smart contracts. This kind of ecosystem is well positioned to enable the development of advanced blockchain applications. Oracles act as the data on-ramp to blockchains and smart contracts. Without oracles a blockchain is a toothless tiger akin to a computer not connected to the internet.

With that being said, oracles are more than just essential data feeds. In the lending market model, oracles act as a filtration and authentication medium verifying the integrity and security of information critical in the execution of high-worth contracts. Lending market protocols need accurate and current market price data supplied in a timely manner to enable lenders and borrowers to make effective decisions. Furthermore, borrowers must prove evidence of their ability to collateralize any potential loan.

As many lending markets are composable in nature it is essential that oracles are able to process and connect data which enable further smart contracts to be built allowing for continued connectivity and interoperability. Efficient, cost effective and versatile oracles are essential to the continued development of the DeFi lending protocol. Accountability, transparency and trustlessness can all be achieved through the integration of effective oracle design.

Examples of lending markets and how they source data

Every lending protocol needs access to the highest quality market data to open, settle, and liquidate undercollateralized loans at prices that are both globally accurate and fair to the market. Without accuracy and fairness, consumer protection is in danger.

There are a number of successful lending protocols on the market to date but, for the purpose of this discussion, we will look at two of the biggest names — Aave and Compound.

Aave is an Ethereum-based, open source, non custodial, decentralized lending platform which offers users over 100 ways to integrate while providing access to 31 different liquidity pools. With a total value locked of $6.46 billion, it is essential that Aave customers have access to trusted, secure and accurate data at all times.

Aave currently uses Chainlink decentralized oracles, aggregators and price feeds which enable the platform to update price frequency results using a liquidation strategy. This means that prices supplied are refreshed every time the deviation crosses a certain threshold differing across assets with the maximum being 2%. If the returned price by the Chainlink aggregator is ≤0 then the call is forwarded to a fallback oracle which is owned by Aave Governance. The Aave protocol uses a series of functions to produce asset prices that are returned in the base currency of the Aave market.

Once market data has been received via Chainlink aggregators, Aave makes use of a ‘Lending Pool Data Provider’ contract which performs computation and provides data for the lending pool itself. In particular the contract:

  • Calculates user balance in equivalent ETH to assess the borrowing limit of a user and their current position health.
  • Calculates the average loan to value and the average liquidation ratio.
  • Aggregates data from the Lending Pool Core in order to provide quality data to the Lending Pool.

Although Aave is one of the biggest protocols providing peer-to-peer lending, the site only has support for 30 tokens with the majority of trades using Ethereum. The reasons behind this are twofold. Firstly, on-chain storage is expensive and hard to scale. This will no doubt create problems going forward. Secondly, due to the high costs involved, updates are infrequent which deters any opportunity to integrate more volatile and less popular tokens. RedStone Finance data oracles addresses both issues with its innovative, on-demand data delivery scheme.

As mentioned above, there are numerous other lending markets, all of which need access to accurate, timely, and trusted data. One of them, Compound, uses Chainlink Price Feeds to supply the ‘Comptroller smart contract’ used by Compound. This price data used by Compound is known as Open Price Data and is open source, hosted on GitHub and maintained by the community.

The Compound smart contract uses a ‘View Contract’ which verifies that all prices fall within an acceptable boundary of time-weighted average prices of the token/ETH pair via Uniswap v2 (referred to as the Anchor Price). Furthermore, the Chainlink price feed submits prices for each native token through an individual ValidatorProxy contract making each VP the only valid reporter for the underlying asset price.

It is clear from the two examples above that the use of data oracles is prevalent in the lending market space. APIs allow oracles to connect with external sources and aggregate the data before it is made available to the customer. Other techniques such as dismissing outliers and accessing numerous sources ensure that any data feed is accessible. Some oracles utilize a special mechanism to resolve disputes around data validity, RedStone included. With that in mind, any modern data oracle needs to not only supply accurate and timely data in an efficient manner but also must act as a filtration mechanism that identifies and rejects any data which is suspicious or misconfigured.

Potential of new lending markets that could be created on top of RedStone data

Lending markets have been a major contributor to the success story of DeFi. Although many of the original market leaders are still active today, the lessening returns for borrowers and the high rates of collateral required are losing their attraction for many. However, there are a number of innovative products in the pipeline which threaten to reignite the lending market.

Let’s go back for a moment to Aave as it was one of the first DeFi protocols to provide Flash Loans where borrowing and repayment occur within one Ethereum transaction. This is one area that, given it gets enough traction, could create a significant demand for accessible data. However, that being said the pain of numerous Flash Loan-enabled hacks is still fresh in our minds. A good example of that is the Cream Finance hack where, by exploiting a vulnerability in the platform’s lending system, hackers were able to drain it using Flash Loans.

Another interesting trend in the lending market is that of the Stability Pool. This concept was introduced by Liquity Protocol and allows holders of the native stablecoin — LUSD — to contribute to the liquidity source that enables debt repayment from liquidated loans. Users who contribute to the Stability Pool make liquidation ‘gains’ and receive LQTY tokens as an extra reward.

Finally, Hubble Protocol allows users to earn a yield on any collateral locked into a smart contract. Running on the Solana network, Hubble supports a wide variety of assets that can be used as collateral and generate yield through the minting of native stablecoin USDH.

All three of these examples would rely heavily on efficient, fast, and effective data. Oracles have the potential to provide the backbone to a new class of decentralized lending protocols. As long as the data is trusted, secure and accessible, the opportunities for future application development are endless.

The benefits of using RedStone Finance for data aggregation are many. In particular, RedStone uses a higher frequency of price collection and is therefore able to support less liquid and more volatile tokens allowing for more opportunities to scale than most of its competitors. Also, RedStone stands apart from its competitors in its ability to dramatically reduce storage costs by ‘fetching’ the data when required rather than storing it on a blockchain. This mechanism considerably reduces storage space and its associated costs. So much so that it is calculated that RedStone Finance is able to call 1gb worth of data at 1:50,0000th of the cost of storing the data on the Ethereum blockchain. By calling the data when it is needed rather than taking up valuable storage space we can provide a more cost-effective and energy-efficient data access solution than any of the nearest competitors.

At RedStone we are on a mission to build the next generation of Oracles. Our solution has an unrivaled ability to exert significant control over any new data listings. Result? The flexibility to follow any emerging market trends, alongside substantial cost savings, allows us to stay at the frontier of a new wave of Decentralised Finance.

Join us on the journey!

Twitter | Discord | Website | Github | Linkedin