liquidation flash loan
Requirements
The smart contract should allow you to perform a flash loan, a liquidation, and an asset exchange in one blockchain transaction.
Your contract is required to provide a unified interface operate to help ease marking. By calling operate, the flash loan, liquidation, and asset exchange should be executed properly. You are allowed to “hardcode” the execution logic and parameters in the operate function.
You are expected to liquidate 0x59CE4a2AC5bC3f5F225439B2993b86B42f6d3e9F on Aave V2 which was liquidated at block 12489620. Check out the original liquidation transaction
Links to an external site..
To test your contract:
docker build -t liquidation-flash-loan .
docker run -e ALCHE_API=”$YOUR ALCHEMY ETHEREUM MAINNET API” -it liquidation-flash-loan npm test
Your grade is determined by the profit you earn in the test case. After the program execution, you should see Profit xxx ETH at the end of a successful liquidation. If you are not using the docker environment, for successful execution you should see a profit.txt file which contains the amount of ETH that you earned after the liquidation. If your implementation is correct, you should be receiving at least 21 ETH as the profit. Note that we reduce the gas fee to be zero to encourage programming complicated liquidation strategies.
Submission
Your submission should be a single LiquidationOperator.sol file that contains at most one import statement import “hardhat/console.sol”;. If you plan to include libraries or interfaces from other npm packages, please manually add them to your contract file so that we have a unified environment for grading. The code package is blow.
liquidation-flash-loan.zip