Flash loans are composed using a smart contract. So basically you create a smart contract that will call all the DEX/loan platform/other contract functions necessary to obtain the loan, carry out swaps and pay it back. You then deploy that contract.
Then you would have a separate program running on your client machine to scan for market opportunities, and when it spots one, have that program send a transaction to your deployed smart contract to initiate the loan and set into action whatever logic you programmed into the smart contract that will yield a profit.
Yes, it’s quite a rabbit hole indeed. It is hard to believe that something like this is even possible, let alone profitable, but it really can be. I have seen single flash loan transactions yield up to $46k in profits. That profit is irrevocably delivered back to you in a couple of seconds.
How are the transactions composed, with a smart contract/s, in combination with Dex API’s?