Andrew Melville
Block Scholes Ltd.
Email: andrew.melville@blockscholes.com
DeFi Lending and Borrowing Protocols
These platforms facilitate the lending and borrowing of crypto-assets between users without the need for a custodial third party. In most protocols, lenders deposit their assets to a pool in return for a token that accrues interest and can be redeemed for the assets deposited (plus a profit) at a later date. Depositing assets also grants users the ability to borrow assets from the platform up to some limit of value proportional to their deposit. As positions are generally required to be overcollateralised, this value is lower than the value of assets deposited.
The two protocols described in this note differ mainly in their interest rate mechanics, with Aave offering a choice between a stable and variable rate, and Compound quoting a variable rate only. Aave also offers an innovative “flash loan” product that differentiates it from its competitor. The interest rates on both protocols are a function of the proportion of assets deposited and borrowed. Importantly, each protocol’s governance system controls the parameters of the loans and pays out rewards to holders of the protocol’s equity token from the fees paid by borrowers to incentivise good governance.
AAVE
Aave is a collection of smart contracts on the Ethereum network that aggregates lenders’ assets and allows users to borrow assets from a given pool in two ways. The first is via an overcollateralised loan, where borrowers are required to deposit assets that exceed the value of their loan and is analogous to the system facilitated by Aave’s competitor, Compound. The second is via a “flash loan” that does not require any collateral, but instead requires that the borrower returns the borrowed assets in a very short time (within one transaction block). This product is an innovation by Aave that has proved itself to be useful to many DeFi projects, whilst also facilitating many exploits.
Lending
Users contribute cryptoassets to a shared pool. In return they receive Aave interest-bearing tokens, or “aTokens” (e.g. users will receive aETH in return for depositing ETH), that tokenise the users’ share of the loan pool’s assets. These aTokens can be traded on the secondary market like any other ERC-20 compliant token. Note that the exchange rate between aTokens and ERC-20 tokens is pegged at 1:1 and, as borrowers pay borrowing rate fees on the closure of their loan positions, interest is distributed to aToken holders directly by continuously increasing their wallet balance (and not by increasing the value of the tokens they hold).
Figure 1 Diagram of lending and borrowing to and from an Aave ETH lending pool. Liquidity providers deposit ETH in return for aETH tokens that represent their share in the pool’s assets. Borrowers overcollateralise loans of ETH by depositing other ERC20 tokens to the smart contract (e.g. wBTC, USDC, or DAI).
Borrowing
To borrow from a pool of assets users must first deposit assets into a smart contract. They can then receive assets of lower value than their deposits, much like a DAI minting loan. The amount by which these loans are overcollateralised is different for each asset depending on its volatility. This parameter is determined by governance proposals that are voted on by AAVE tokenholders.
The borrower is able to switch between a stable and variable rate of interest at any time during the period of the loan (more on this below). There is no fixed term for these loans which is made possible by the fact that borrowing is made from an aggregated pool of assets, rather than peer- to-peer. To close the position, borrowed assets must be repaid in the same denomination as the loan (with added interest fees). For example, if a user borrows 1 ETH they must repay (1+r) ETH for some interest accrued (r>0).
Loan Liquidation
Loans on Aave are not peer-to-peer, but are instead between individual borrowers and pools of assets contributed by a group of lenders. As such, the loan positions do not expire, but do accrue interest over time. This reduces the ratio between the borrowers’ collateralisation ratio and their debt position, which borrowers can increase either by depositing more collateral or paying back part of the balance on their loan.
If either the accrual of interest on their loan or a drop in value of their collateral causes the ratio between assets borrowed and the collateral to drop below a liquidation threshold, the borrower’s loan will be liquidated.
When this happens, “liquidators” are able to repay up to 50% of the borrower’s debt. In return they receive the equivalent value of collateral (up to 50% of the value of the debt) plus an incentive bonus that is taken from the borrower’s collateral as a penalty fee. Any user of the network can participate as a liquidator, meaning that there is intense competition to be the first to call the liquidation function on an underwater loan. Doing so allows the liquidator to pay back part of the loan in return for a bonus taken from the original borrower’s collateral. The size of the liquidation bonus is different for each asset and is determined by governance proposals voted on by AAVE tokenholders.
Example
To illustrate this process, consider a loan of 15,000 DAI backed by 10 ETH at a price of $2,000 per ETH. This position has total collateral of $20,000 ETH and, assuming that each DAI is worth $1 throughout, is collateralised by 133%.
If the value of ETH then drops to $1,800, the collateral ratio drops to 120%. If this is enough to bring the borrower’s “health factor” below 1 then the position will be liquidated. A liquidator can then pay up to 7,500 DAI (50% of the loan) to the smart contract in return for 7,500 DAI worth of ETH with an added 5% liquidation bonus for a total of 7,875 DAI worth of ETH. At the new price of $1,800 per ETH, the liquidator receives a total of 4.375 ETH (the bonus 5% fee translates to the 5% return available by liquidating, before transaction fees).
After the liquidation process the outstanding loan of 7,500 DAI is backed by 5.625 ETH which, at an ETH price of $1,800, is worth $10,125. Therefore the collateralisation ratio has been restored above the liquidation ratio to 135%.
Health Factor
In the example above we noted that the liquidation of positions is triggered when the borrower’s “health factor” is below 1. This value is a weighted average of the liquidation thresholds of the collateral assets
where the liquidation threshold corresponds to the minimum allowed ratio between a loan position and the collateral that backs it. The liquidation threshold is set by governance voting and controls the level at which an asset’s loans are able to be liquidated.
Flash Loans and “One-Block Liquidity”
Aave’s flash loans are intended to offer liquidity that is immediately returned within the same block of transactions. These can provide the capital needed to liquidate over-collateralised loans (such as those that back the minting of DAI) before they become under-collateralised.
In this use-case example, a smart contract is able to borrow DAI from Aave without depositing collateral and use that to liquidate a DAI loan that, whilst still over-collaterised, has fallen below its collateral ratio. The DAI is paid back to the vault, releasing the borrower’s deposit to the liquidator, who can then sell it for more DAI than was loaned from Aave, and “pay-back” the flash loan whilst keeping the difference.
Provided that these actions are included in the same block of transactions on the Ethereum blockchain, the flash loan is paid back within the required time. If instead the loan is not paid back in the same transaction block that processed the loan, the initial loan is declared void, and so too are the following transactions. (See here for some other use cases for flash loans).
Figure 2 Diagram describing a liquidator utilising Aave’s “flash-loan” functionality in order to liquidate another user’s loan whose collateral value has fallen too low. The liquidator receives collateral, plus a tip, for paying back part of the borrower’s loan. As long as these transactions are all completed within the same block, the liquidator need not provide collateral for their loan as the pool assumes no credit risk.
COMPOUND
Compound was created in September 2018 by the California based Compound Labs, Inc. Like Aave, Compound operates decentralised lending and borrowing pools using smart contracts on the Ethereum network. In a similar fashion, Compound aggregates assets deposited by lenders into a pool. It is from this pool that users can borrow assets.
Unless every asset in a market is borrowed, users can withdraw their assets at any time, without waiting for a specific loan to mature. However, the system motivates users to provide liquidity by offering competitive interest rates. Lenders receive an ERC-20 token (called a “cToken”) in return for depositing assets to be loaned. This is similar but not equivalent to the aTokens provided to lenders by Aave. Instead of being pegged to the underlying asset that they represent, the value attributable to the cTokens increases as they accrue interest on their loans. The tokens can then be redeemed for an increasing amount of the asset they deposited when they remove the liquidity from the lending pool.
Lending
Users contribute cryptoassets to a shared pool (e.g. ETH). In return they receive Compound interest-bearing tokens, or “cTokens”, that tokenise the share in the loan pool’s assets. (e.g. a user will receive cETH in return for depositing ETH). These cTokens can be traded on the secondary market like any other ERC-20 token. Note that the exchange rate between cTokens and the token deposited is not 1:1 (as is the case with aTokens), and each token is instead valued to reflect the users contribution to the total value of assets in the pool. The total value of assets in the pool grows as borrowers pay borrowing rate fees on the closure of their loan positions, and so too does the value of cTokens held by each lender.
Borrowing
To borrow from a pool of assets, users must first deposit assets into a smart contract. They can then receive assets lower than the value of their deposited assets, much like a DAI minting loan. The amount by which these loans are overcollateralised is different for each asset, and is determined by the collateralisation factor. These can be changed by holders of the governance token COMP with a minimum waiting period of 7 days.
Just as with AAVE, the borrower is able to switch between a stable and variable rate of interest at any time during the period of the loan. There is no fixed term for these loans, which is made possible by the fact that borrowing is made from an aggregated pool of assets. To close the position, borrowed assets must be repaid in the same denomination (with added interest fees).
Loan Liquidation
Like loans on Aave, loans on Compound can be liquidated if the collateral that backs them drops in value relative to the outstanding debt position. Borrowers can increase this ratio either by depositing more collateral or paying back part of the balance on their loan.
If either the accrual of interest on their loan or a drop in value of their collateral causes the position to become undercollateralised, the borrower’s loan will be liquidated. When this happens a “liquidator” is able to purchase the borrower’s collateral at a discount to the market price. The size of this discount is set by holders of the COMP governance token.
As the incentive for liquidators to close part of an underwater loan position is paid out permanently from the borrower’s collateral, borrowers are incentivised to maintain the ratio between their debt position and the assets that it backs.