I just implemented a PoC of flash loans last week. My work is a general implementation for any chain with CosmWasm support. I have designed the PoC to maximize safety of the lenders.
My solution includes:
- smart contracts executing, for example arbitrage
- a single smart contract
- has security mechanisms guaranteeing atomic transactions
- is matching flash loan requests from borrowers with lenders available
- charges relayer’s fee for providing atomic transaction execution layer
- smart contracts providing liquidity to all requests coming through the gateway
- have a way to perform the last action during a flash loan transaction and revert it altogether if somethings not right
- charges liquidity provider fee (can be different based on the lender’s settings)
So far, the PoC allows using native coins (Luna + all Terra stable coins). However, the goal for the PoC was to prove the atomic transactions execution capability. After testing, I think this goal was reached.
Further idea is to also use IBC in later stages to allow for more arbitrage opportunities.
Let me know if you’re interested integrating this PoC on testnet with liquidity of the Anchor Protocol.