-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add flash loans #7
Comments
took a stab at adding this. This is still untested since we want to try using the snapshots. Best way for that might actually be a testing crate that generates various snapshots depending on the state required but that's out of scope for this issue. The tldr is that:
I like this approach vs executing the transfer + invocation in the The real main question here is how to handle the receiver contract, i.e the contract called by blend when executing the flash loan. Right now, it's |
Awesome! I agree that For now, I would use It might be worth it to implement #11 alongside this and/or before extensive testing is written. This way, the |
Add flash loan capabilities to Blend.
Technical Notes
Add a new action type to Blend called "FlashBorrow"
-> FlashBorrow will immediately send the sepecified amount of tokens, then invoke "processFlashLoan" on the user. This will fail if the user is not a contract.
The usage of flash loans would be as follows:
Deploy a flash loan strategy. (TODO - determine if interface is good)
Consider -> USDCXLMArbContract.processFlashLoan(from: Address, asset: Address, amount: i128) that takes in USDC to do some USDC<->XLM arbs and ends up with USDC.
The contract would need to return the USDC to from, or panic if some condition is not met
Invoke the the Blend pool with the following request stack, such that from is the user conducting the flash loan (IE - the one that actually takes on the liabilities)
Requests:
-> SupplyCollateral 50,000 XLM (user -> from)
-> FlashBorrow 100,000 USDC (user -> contract)
-> Repay 95,000 USDC (user -> from)
After the requests, the health factor for from is checked. Assuming 50k XLM is enough collateral to cover a 5k USDC loan, the transaction would complete successfully.
One benefit here is that flash loan strategies can be deployed and used by anyone.
The text was updated successfully, but these errors were encountered: