mentorship2022
mentorship2022 copied to clipboard
Flash Loan Liquidations
Exercise name: Flash Loan Liquidations
Assignment #: 10
Track: Smart contracts
Testing framework: Foundry
Deployment framework: Foundry (forge create)
Node provider:
Target network:
Assignment summary
Refactor the Single Collateral Vault to allow any user to liquidate undercollateralized positions. You will also use your AMM from the previous assignment, and the Flash Loan Yield Bearing Vault from assignment #9.
Introduce a loan-to-value ratio of 66%. Any user can liquidate an undercollateralized position by paying its debt. The position will be deleted and the collateral sent to the liquidator.
Deploy an AMM for the debt and collateral tokens.
Deploy a Flash Loan Yield Bearing Vault for which the underlying and lendable asset is the same as the debt asset in the collateralised debt engine.
Now, code a smart contract that takes a flash loan from the ERC3156 flash loan lender, pays the debt of an undercollateralized position, sells the collateral obtained in your AMM, uses the debt tokens obtained to repay the flash loan, and sends the profit to the caller.
Additional Details
Peripheral Goals