Example repo on how to take a flash loan with DyDx from ( https://etherscan.io/address/0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e )
npm i
npm run flat
- Copy content from the
FlashloanTaker.flat.sol
file to the Remix. - Remove the second
pragma experimental ABIEncoderV2;
- Deploy contact with tiny amount of token at the time of deployment
cp .env.example .env
- Specify
PRIVATE_KEY
andGAS_PRICE
in the.env
file npx truffle migrate --network mainnet --reset
- Send a tiny amount of the token you want to borrow to the smart contract. E.g. if you borrow WETH the
FlashloanTaker
has to have 1 wei (one wrapped wei) on the balance.
- Refinancing. Refinance your interest to a lower interest in another lending protocol. Taking flash loan from Aave in Dai, closing a CDP by sending the Dai to the CDP, taking the ETH which was as a collateral to Compound (whichever has better interest rate for borrowers)
- Closing CDP. The same as above but just closing the CDP without any DAI.
- Arbitrage.