Flash Loans Exercise 1
Intro
In this exercise, your goal is to implement an ETH Pool that enables flash loans.
You will also implement 2 receivers contracts:
- A "Receiver" contract which requests a flashloan and pays it back.
- A "Greedy Receiver" contract which requests the loan and doesn't pay it back.
After implementing the contracts, you will have to test them and make sure that the logic works.
Accounts
- 0 - Deployer & Owner
- 1 - User
Tasks
Task 1
Implement the Pool.sol contract.
Complete the flashLoan function:
- Revert the transaction in case there is not enough ETH in pool (Less than requested).
- Call the
getEthfunction onmsg.senderwith the requested amount of ETH. - Make sure that the ETH was paid back.
Task 2
Implement the Receiver.sol contract:
- Complete the
flashLoanfunction so it will request a flash loan from the pool. - Complete the
getEthfunction so it sends back the ETH to thePoolcontract.
Task 3
Implement the GreedyReceiver.sol contract:
- Complete the
flashLoanfunction so it will request a flash loan from the pool. - Complete the
getEthfunction so it DOESN'T send back the ETH to thePoolcontract.
Note: Should you consider anything else is needed to be implemented for the contracts to work, please proceed. The instructions given are not exhaustive.
Task 4
Complete the tests in the tests.js file.