In the AAVE protocol, liquidation and collateral play a crucial role in ensuring the stability of the lending and borrowing market. In this article, we’ll take a deep dive into the concepts of liquidation and collateral and how they work in the AAVE protocol.
What is Liquidation?
When a borrower defaults on a loan, the lender is at risk of losing their investment. To protect themselves, lenders can choose to liquidate the borrower’s collateral, which is the asset that the borrower put up as security for the loan.
In the AAVE protocol, liquidation is a process that allows lenders to sell a borrower’s collateral to recover their investment in case the borrower defaults on the loan. The AAVE protocol has a built-in liquidation mechanism that automatically triggers liquidation when a borrower’s loan becomes too risky.
How Does Liquidation Work in AAVE?
The AAVE protocol uses a collateralization ratio to determine when a borrower’s loan becomes too risky. The collateralization ratio is calculated as the value of the borrower’s collateral divided by the value of the loan. For example, if a borrower has put up 1 ETH as collateral for a 0.5 ETH loan, the collateralization ratio is 2 (1 ETH / 0.5 ETH).
The AAVE protocol has a minimum collateralization ratio that borrowers must maintain to avoid liquidation. If the collateralization ratio falls below the minimum threshold, the AAVE protocol automatically triggers liquidation and sells the borrower’s collateral to recover the lender’s investment.
The minimum collateralization ratio is set by the AAVE protocol and depends on the riskiness of the asset being borrowed. For example, the minimum collateralization ratio for stablecoins (such as USDC or DAI) is typically lower than the minimum collateralization ratio for more volatile assets (such as ETH or BTC).
What is Collateral?
Collateral is the asset that a borrower puts up as security for a loan. In the AAVE protocol, borrowers can put up a wide variety of assets as collateral, including cryptocurrencies, stablecoins, and even tokenized real-world assets (such as real estate or art).
The value of the collateral is used to determine the size of the loan that the borrower can take out. For example, if a borrower puts up 1 ETH as collateral, they may be able to borrow up to 50% of the value of the collateral, depending on the asset and the loan terms.
Types of Collateral in AAVE
The AAVE protocol supports a wide variety of assets as collateral, including cryptocurrencies, stablecoins, and tokenized real-world assets. Some examples of popular collateral assets on AAVE include:
- Ethereum (ETH)
- Bitcoin (BTC)
- Chainlink (LINK)
- USDC (USDC)
- DAI (DAI)
In addition to these assets, AAVE also supports tokenized real-world assets as collateral. These assets are represented by non-fungible tokens (NFTs) that are backed by real-world assets, such as real estate or art.
Conclusion
In this article, we covered the concepts of liquidation and collateral and how they work in the AAVE protocol. We explained how the AAVE protocol uses liquidation to protect lenders from defaulting borrowers and how collateral is used to determine the size of the loan. We also introduced the different types of collateral that are supported by AAVE, including cryptocurrencies, stablecoins, and tokenized real-world assets. Understanding these concepts is essential for building applications that leverage the power of the AAVE protocol and the Ethereum blockchain.
Exercises
To review these concepts, we will go through a series of exercises designed to test your understanding and apply what you have learned.
Create a function that takes a collateralization ratio and a minimum collateralization ratio as arguments and returns a boolean indicating whether the collateralization ratio is below the minimum threshold.
function isBelowMinimumThreshold(collateralizationRatio, minimumCollateralizationRatio) {
return collateralizationRatio < minimumCollateralizationRatio;
}
Create a function that takes a loan amount and a collateral amount as arguments and returns the collateralization ratio.
function calculateCollateralizationRatio(loanAmount, collateralAmount) {
return collateralAmount / loanAmount;
}
Create a function that takes a borrower’s account address, a loan asset address, and a collateral asset address as arguments and returns the borrower’s current collateralization ratio for the loan.
async function getBorrowerCollateralizationRatio(borrower, loanAsset, collateralAsset) {
const loanAmount = await lendingPool.methods.getBorrowerLoan(borrower, loanAsset).call();
const collateralAmount = await lendingPool.methods.getBorrowerCollateral(borrower, collateralAsset).call();
return calculateCollateralizationRatio(loanAmount, collateralAmount);
}
Create a function that takes a borrower’s account address, a loan asset address, and a collateral asset address as arguments and returns a boolean indicating whether the borrower’s loan is at risk of liquidation.
async function isLoanAtRiskOfLiquidation(borrower, loanAsset, collateralAsset) {
const minimumCollateralizationRatio = await lendingPool.methods.getMinimumCollateralizationRatio(loanAsset).call();
const collateralizationRatio = await getBorrowerCollateralizationRatio(borrower, loanAsset, collateralAsset);
return isBelowMinimumThreshold(collateralizationRatio, minimumCollateralizationRatio);
}
Create a function that takes a borrower’s account address, a loan asset address, and a collateral asset address as arguments and returns the amount of collateral that the borrower needs to add to their loan to meet the minimum collateralization ratio.
async function getAmountOfCollateralNeeded(borrower, loanAsset, collateralAsset) {
const minimumCollateralizationRatio = await lendingPool.methods.getMinimumCollateralizationRatio(loanAsset).call();
const loanAmount = await lendingPool.methods.getBorrowerLoan(borrower, loanAsset).call();
const collateralAmount = await lendingPool.methods.getBorrowerCollateral(borrower, collateralAsset).call();
const collateralizationRatio = calculateCollateralizationRatio(loanAmount, collateralAmount);
const difference = minimumCollateralizationRatio - collateralizationRatio;
return difference * loanAmount;
}