The Problems That Are Solved Using The AAVE V2 Protocol and The Covalent API

Joseph Appolos
9 min readMar 8, 2021

The blockchain has been a blessing to us since the introduction of bitcoin in 2008, and has evolved greatly in diverse ways, opening new doors in its wake. It has then been applied in different fields; from medicine to finance, governance, gaming, lending, identify security and so on. All these were made possible by the DeFi explosion on the ethereum blockchain and other emerging blockchains alike.

Due to high usage and adoption, the data on the blockchain has become enormous and rarely follow any standard; these data when harnessed and streamlined, can be used in various cases to better the DeFi ecosystem and the general public as well. In this article, I’ll be discussing the problems that can be solved using the AAVE V2 Protocol and the Covalent API

The Aave V2 Protocol

Aave is an open source decentralized money market protocol that enables users to earn interests on deposits and borrow cryptocurrencies in a trustless manner. Aave started out as a P2P (peer-to-peer) lending platform on the ethereum blockchain as ETHLend on November 2017 and was renamed AAVE as they upgraded to a P2C (peer-to-contract) model in September 2018. The birth of the Aave Protocol marks Aave’s shift from a decentralized P2P lending strategy (direct loan relationship between lenders and borrowers) to a pool-based strategy. Aave has gained huge adoption amongst dApps lovers and was ranked among the top 3 dApps on ethereum blockchain for months. Just on December 2020, version 2 of the protocol was launched (Aave V2) which embodied so many improvements from the V1. Let’s look at those problems that can/have been solved by Aave V2.

The Problem Aave V2 Solves.

1) Gas Optimisation
Some of the solutions currently implemented in Aave V1 were designed and developed when the Ethereum Network was notably different. The exponential growth of DeFi has grown the number of transactions twofold or more, applying more pressure in the blockchain leading to increased gas costs; in this regard, Aave made an improvement.
The V2 release optimises execution costs by approximating exponential formula with a binomial expansion, which works well with a small base. unlike the V1 which uses only exponential formula to calculate compound interests. Also, the V1 internally uses SafeMath to guarantee the integrity of operations, but it was discovered that SafeMath incurred intensive high costs in critical areas of the protocol, with a 30 gas fee for each call. With this, the V2 protocol was reststructured to remove SafeMath, which saves 10-15k gas on some operations.

In the initial V1 release, the protocol loops through all the active assets to identify the user deposits and loans. This would result in high gas consumption and reduced scalability - as the cost of withdrawing/borrowing/repaying/liquidating assets would increase as more assets are listed on the protocol. This was solved in the v2 protocol by creating a bitmask with pairs of bits; where one pair indicates if an asset is used as collateral, while the second whether an asset is borrowed by the user.

2) Lending and Borrowing Made Easy

Lenders provide liquidity by depositing cryptocurrencies in a pool contract. Simultaneously, in the same contract, the pooled funds can be borrowed by placing a collateral. Loans do not need to be individually matched, instead they rely on the pooled funds, as well as the amounts borrowed and their collateral. This enables instant loans with characteristics based on the state of the pool. The V2 allows users to swap all assets deposited to the protocol even when they are used as collateral. Say I deposited UNI and ETH, which I’ve used as collateral for the loan I borrowed, I can trade them for DAI or USDC anytime in the protocol; this reduces liquidation of positions on the protocol. Also, users can now pay their debts with any asset they’re holding on the protocol. How smooth and simple can it get? Anyone in any part of the globe can borrow assets instantly without intermediaries or barriers due to location. New start-ups are being empowered with capital for their projects. Lenders on the other hand earn huge returns from the pool by providing liquidity through the automated yield farming.

3) Transparency
When it comes to lending and borrowing in centralised finance (CeFi) in the real world, trust, transparency and reliability has always been a major issue both for the financial institution and the borrower. The V2 protocol allows users to interact with a smart contract where the rules have been predefined an immutable. For example: The interest rate for both borrowers and lenders on V2 is decided algorithmically; that is —

• For borrowers, it depends on the cost of money - the amount of funds available in the pool at a specific time.

As funds are borrowed from the pool, the amount of funds available decreases which raises the interest rate.

• For lenders, this interest rate corresponds to the earn rate, with the algorithm safeguarding a liquidity reserve

to guarantee withdrawals at any time.

This rule will remain unchanged as long a s the blockchain runs, no matter the amount of loans a user takes. This is not possible in centralised finance where the terms of the loans are subject to review.

4) Tokenisation of Depts
Borrowers' debts are represented by tokens (aTokens) in V2 instead of internal accounting within. Once a deposit is made to the protocol, the corresponding aToken starts minting and accumulates interests on the deposit. These aTokens give credit to the depositor to borrow; this credit can be transferred to another wallet different from the on the contract, this can be a cold wallet or a hot wallet. For example, Mr A made can make a deposit and transfer the credit to borrow to the wallet of Mr B. This is only possible with DeFi, Aave V2 to be specific. Also, these tokens can also be used for delegation for approval of undercollaterised loans. Users can take undercollateralised loans as long as they receive delegation from other users that provide collateral. Awesome, right? Aave V2 has taken a huge step in solving liquidity problems in start up and the likes.

5) Providing Uncollaterised Loans
This is made possible through flash loans. Flash loans are the first uncollateralized loan option in DeFi, made available only by the Aave protocol! Designed for developers, enable you to borrow instantly and easily, no collateral needed provided that the liquidity is returned to the pool within one transaction block. It allows users to borrow assets in the protocol use the loan and payback with the interest in a single network transaction. This provides users with a variety of tools such as refinance, collateral swap, arbitrage(price differences on different platforms) and liquidate.

COVALENT API

What is covalent?
Covalent is a data infrastructure company that solves data related problem on the blockchain by providing unified API to bring full transparency and visibility to assets across all blockchain networks. The blockchain contains enormous data lying around in different places without any order; internally, Covalent implement various solutions to develop an index of these blockchain data, standardize it, and make it externally available to developers in the industry through the Covalent API.
Some of these data include, but not limited to live exchange rates for supported crypto and fiat trading pairs, token balances and historical values for all digital assets, access to decoded event logs, tax liabilities for a cryptocurrency-based company, Uniswap ROI on open positions and so on. The company was co-founded and established by Ganesh Swami and Levi Aul in 2017. Let’s look closely at some of the problems that the Covalent API solves

The Problems that The Covalent API Solves

1) Data Infrastructure and Availability
The number of organisations and technology companies across different fields that have expressed interest in adopting blockchain technology in their operations have increased in recent times. This increasing desire is driven by the will to leverage the benefits of this technology like efficiency streamline operations, enhance speed, e.t.c that have been increasingly publicised. Businesses are finding the adoption and integration of this decentralised technology in operations to be rather difficult due to its shear complexity and technical nature of the blockchain. Covalent, by means of their unified API, have bridged this gap. All data related problems have been solved. The Covalent API contains the richest blockchain data on the Internet today. Developers can use Covalent to access over 25 billion rich transaction data indexed since the genesis of Ethereum (and other blockchain). They can access more than 30,000 price feeds for fiat and crypto pairs and access approximately 300,000 smart contracts. For now, Covalent provide easy standardized access to price data, Ethereum nameservices, block data, historical rates, token balances, NFT data (with their NFT end point), and much more. For example, wallets can use the API to aggregate data regarding DeFi protocols and provide their users with accurate information regarding their portfolio value, Institutional funds could use the Covalent API to ensure their taxes are in order, as every DeFi transaction is a taxable event.

2) Speed
Covalent API has a refresh rate of 30 seconds. Any call made on the API produces returns almost immediately. Covalent can be seen as a network of its own with all its data available on a single click. Data which would normally take a developer more than one week to acquire will only take few seconds (sometimes Milli seconds) to obtain with the unified Covalent API. Say you want to get token balances for a wallet address, this will display almost immediately as an output also with this amazing speed, the API produces accurate results.

3) No-Code Solution

Covalent philosophy is "no-code solution" which is the future. Developers don’t have to be code masters to use the Covalent API. the APIs are simple, easy to run and user friendly so that anyone will be able to use it, thus increasing the target audience. The Covalent team spent years copying the entire blockchain— every block, every transaction, every log event, every bounce update to a database; then users only need to create a pivot table on top of the base layer database to access this robust data. So all you need to do is build you dApps and integrate the API.

4) Blockchain Integration
Covalent innitally was indexing only data on the ethereum blockchain but has lately expanded their broadband to other networks. As more dApps and users partner with Covalent or use the API, more data is being stored on the covalent API, making it more rich. Recently, they partnered with Matic and now a user can switch from ethereum blockchain to Matic and BSC using the "ChainId" Command. Also there are other networks that’s been integrated into the Covalent API, there will be an official announcement for this. As more developers are going multichain, the Covalent API is the best tool for indexing and connecting with the network you need.

5) NFTs End chain
The data in the NFT space is a mess and a bit complex, it’s unlike anything else on the blockchain. The data is quite difficult to streamline. Ethereum don’t have a storage layer for NFTs, so all the NFT metadata is stored off-chain in all kinds of random places making it inconsistent. Covalent had to get all these data and index them in one place; now a user can get NFT balances and all the transactions and historical data for a wallet address from genesis in wasp speed. There’s a lot more that can be done with the Covalent NFT endpoint! Also, the NFT and the DeFi merging which bring liquidity to NFT basket is another solution that the Covalent API can produce.

6) Transparency

With all the data on ethereum and other networks indexed onto a unified API, all transactions, historical records of a wallet or exchanges (DEX or CEX) can be seen by just a single call on the API. Developers and users can keep track of assets (tokens or NTFs), wallets and other dApps. Every single DeFi transaction is a taxable event, Covalent calculates liabilities for the biggest funds in the crypto-space. The rich data structures of Crypto networks which are currently inaccessible without a tool like Covalent can now be accessed.

Conclusion
These protocol and API discussed herein are awesome and powerful tools for both developers and end users inside and outside the DeFi ecosystem they've paved way for greater development in the DeFi ecosystem most especially. A lot more problems than the ones mentioned in this article can be solved with them, expect more.

--

--