Enlighten me then which part do I have incorrect. What I explained has been done already outside of OPs example. You can code a bot to identify arbitrage opportunities and then use flashloans to capitalize on the entire opportunity as it will give the liquidity necessary.
Its its all on DEXes and the entire transaction goes through smart contracts then it can be written to stop the execution if you can't pay back the flashloan when it the final step resolves.
I.E. You're bot identifies arbitrage through 3 different assets on 2 different DEXes. Lets say its a 4 steps and requires 4 contracts to execute if the arbitrage opportunity fails then it will automatically cancel and you lose the gas.
If it all resolves in the same block its legit. It seems like you don't get how they work.
"This is exactly what one user did, and he made $16,182 within seconds, using absolutely no investment but some pocket change for the gas fees.
Seen in block 10566089, what the user did was the following.
First, he borrowed 2,048,000 USDCT using dYdX’s flash loan. Remember, because it’s a flash loan, he doesn’t have to post any collateral as long as he repays the amount within the same block.
He then swapped this amount for 2,028,367 DAI on Curve y pool. After that, he swapped the DAI for 2,064,182 USDC on Curve’s SUSD pool, and lastly, he paid back the 2,048,000 USDC to dYdX, all within the same block.
All of this is possible because of the different stablecoin rate at the various lending protocols. And while 1% difference might not seem like a lot, when one is able to borrow high amounts and arbitrage this difference, the profits can be substantial."