5/5
# Flash Exercises 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/Flash.sol` Solution is provided in `foundry/src/solutions/Flash.sol` ## Task 1 - Initiate flash loan ```solidity function flash(address token, uint256 amount) public {} ``` Initiate the flash loan - `token` is the token to borrow - `amount` is the amount to borrow > Hints > > - Call `pool.flashLoanSimple` > - ABI encode `msg.sender` and pass it as input to `params` ## Task 2 - Repay flash loan ```solidity function executeOperation( address asset, uint256 amount, uint256 fee, address initiator, bytes calldata params ) public returns (bool) { // Task 2.1 - Check that msg.sender is the pool contract // Task 2.2 - Check that initiator is this contract // Task 2.3 - Decode caller from params and transfer // flash loan fee from this caller // Task 2.4 - Approve the pool to spend flash loaned amount + fee // Task 2.5 - Return true } ``` Implement the callback function called by Aave. > Hints > > - ABI decode `params` and transfer the flash loan fee from the caller that is encoded into `params` ## Test ```shell forge test --fork-url $FORK_URL --fork-block-number $FORK_BLOCK_NUM --match-path test/Flash.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/Flash.sol
Solution is provided in foundry/src/solutions/Flash.sol
Initiate the flash loan
token
is the token to borrow
amount
is the amount to borrow
Hints
Call
pool.flashLoanSimple
ABI encode
msg.sender
and pass it as input toparams
Implement the callback function called by Aave.
Hints
ABI decode
params
and transfer the flash loan fee from the caller that is encoded intoparams
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