5/5
# Repay Exercise In this exercise, you'll learn how to repay tokens to Aave V3. The starter code for this exercise is provided in `foundry/src/exercises/Repay.sol` Solution is provided in `foundry/src/solutions/Repay.sol` ## Task 1 - Repay all the debt owed to Aave V3 ```solidity function repay(address token) public returns (uint256) { // Task 1.1 // msg.sender will pay for the interest on borrow. // Transfer the difference (debt - balance in this contract) // Task 1.2 - Approve the pool contract to transfer debt from this contract // Task 1.3 - Repay all the debt to Aave V3 // All the debt can be repaid by setting the amount to repay to a number // greater than or equal to the current debt // Task 1.4 - Return the amount that was repaid } ``` Implement the `repay` function to repay `token` to Aave. - `token` is the token to repay - Pay all of debt that this contract owes to Aave > Hint - Call `pool.repay` ## Test ```shell forge test --fork-url $FORK_URL --fork-block-number $FORK_BLOCK_NUM --match-path test/Repay.test.sol -vvv ```
In this exercise, you'll learn how to repay tokens to Aave V3.
The starter code for this exercise is provided in foundry/src/exercises/Repay.sol
Solution is provided in foundry/src/solutions/Repay.sol
Implement the repay
function to repay token
to Aave.
token
is the token to repay
Pay all of debt that this contract owes to Aave
Hint - Call
pool.repay
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