4/5
# Liquidation Exercise In this exercise, you'll learn how to liquidate an under-collateralized debt from Aave V3. The starter code for this exercise is provided in `foundry/src/exercises/Liquidate.sol` Solution is provided in `foundry/src/solutions/Liquidate.sol` ## Task 1 - Liquidate an under-collateralized loan ```solidity function liquidate(address collateral, address borrowedToken, address user) public { // Task 1.1 - Get the amount of borrowed token that the user owes to Aave V3 // Task 1.2 - Transfer the full borrowed amount from msg.sender // Task 1.3 - Approve the pool contract to spend borrowed token from this contract // Task 1.4 - Call liquidate } ``` Liquidate an under-collateralized debt - `collateral` is the collateral token to receive - `borrowedToken` is the token borrowed by `user` - `user` is the account that has the under-collateralized debt > Hints > > - Call `pool.getReserveData` to get the address of the variable debt token for `borrowedToken` > - Get the debt of `user` > - Call `pool.liquidationCall` ## Test ```shell forge test --fork-url $FORK_URL --fork-block-number $FORK_BLOCK_NUM --match-path test/Liquidate.test.sol -vvv ```
In this exercise, you'll learn how to liquidate an under-collateralized debt from Aave V3.
The starter code for this exercise is provided in foundry/src/exercises/Liquidate.sol
Solution is provided in foundry/src/solutions/Liquidate.sol
Liquidate an under-collateralized debt
collateral
is the collateral token to receive
borrowedToken
is the token borrowed by user
user
is the account that has the under-collateralized debt
Hints
Call
pool.getReserveData
to get the address of the variable debt token forborrowedToken
Get the debt of
user
Call
pool.liquidationCall
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
Aave V3 core functionalities and key features
APY & APR, market forces, utilization rates, interest rate models
Reserves, ATokens, debt tokens, liquidity and borrow index
Aave smart contracts architecture
Supply, borrow, repay, withdrawal, liquidation
Compound interest
Reserve factors, liquidation pricing, credit delegation, LTV
Aave V3 flash loans
How to buy long and sell short using Aave V3
How to build a functional app to buy long, sell short, and close a position.
Last updated on July 20, 2025
Duration: 8min
Duration: 49min
Duration: 43min
Duration: 12min
Course Overview
About the course
Aave V3 core functionalities and key features
APY & APR, market forces, utilization rates, interest rate models
Reserves, ATokens, debt tokens, liquidity and borrow index
Aave smart contracts architecture
Supply, borrow, repay, withdrawal, liquidation
Compound interest
Reserve factors, liquidation pricing, credit delegation, LTV
Aave V3 flash loans
How to buy long and sell short using Aave V3
How to build a functional app to buy long, sell short, and close a position.
Last updated on July 20, 2025