Aave Flash Loans
Aave Credit Delegation
My project takes advantage of AAVE flashloans and delegated borrowing to allow anyone to leverage the value of any token against any other one supported by AAVE. The contract have to functions, open and close : The open function will swap user funds and a flashloan of token A to buy token B, the token B is then deposited as collateral on AAVE, finally the flashloan owed amount is then borrowed from AAVE. The user ends up with some aToken B (valued 3 times the initial amount of token A) and debt token A (valued at 2 times the initial amount). Price variations of token B will end up in more profit that if the user did only swap token A for token B, however if price of token B goes down relative to token A all funds could be lost. The close function will repay the debt using a flashloan and swap the aToken B for token A to repay the flashloan.
How It's Made
My dev environment was mainly: - the Remix IDE for the contract development - Metamask on a ganache fork for experimentation - vim for the web UX - lots of memes - a lot of doc reading (Solidity, AAVE, 1Inch, web3.js) The most notable hacky bit would be the 1Inch swap function that can only be called by previously calling an API, this induce slippage when it is executed and you can't be sure of the returned amount you will get.