Flash loan experiment using AAVE.
The experiment basically bootstraps a flash loan and executes it, interacting with Oasis and Maker along the way.
The financial operation doesn't make much sense per-se. The point of the experiment is not making money, but having a basic understanding of what programming a flash loan feels like.
Anyhow, here's what it does:
- Borows 1000 DAI from the AAVE flash pool.
- Swaps 1000 DAI to ~1010 USDC using Oasis.
- Opens a Maker vault depositing 1010 USDC as collateral.
- Withdraws ~750 DAI from the vault.
- Withdraws 250 DAI from the EOA account and pays back the flash loan + fees.
- Contract ends up owning a 1010 USDC vault, which was purchased with 250 DAI.
Note: Atm, the opened vault is actually locked, since it belongs to a contract that has no way to interact with it. However, it shouldn't be hard to transfer the vault ownership to the signer EOA.
- Clone
- Install with
yarn
- Compile contracts with
yarn compile
- Start a local fork of mainnet using:
ganache-cli \
--fork https://mainnet.infura.io/v3/<your-infura-key> \
--networkId 66 \
--unlock 0x4d10ae710Bd8D1C31bd7465c8CBC3add6F279E81 \
--gasLimit 8000000
- Start the script with
yarn start