What I wrote above is basically the summary, it crawled the mempool and checked the address interfaces to discover Defi exchanges automatically.
I found maybe 20-30 exchanges that were not publicly advertised, so there was quite a bit of liquidity there. It looked for triangular arbitrage opportunities, then optimised the amount and computed gas costs to check if it was profitable. There was a lot of compute required, about 12,000 paths a second were searched and a profitable trade would be found about once every 3 hours.
“Optimising the amount” was a bit tricky too - too little you leave money on the table, too much you cause slippage - but you know the good thing about DeFi is that through our ETH nodes we have a copy of the blockchain and I had already written an EVM disassembler for another project, so I had a lot of knowledge of EVM internals - so I could simulate the trade executions inside the optimiser locally, which greatly helped “realism”
The whole system was profitable for about 8 months, it netted me about 180k usd before it tapered off - I don’t know why but I suspect someone else found the strategy/was doing the same thing, so I took the cash out of it, paid tax and moved on.
If you’re interested in the tech it was all just pure Python, networkx for the graph stuff, shared memory, multiprocessing and lots of IPC, the whole thing operated in RAM because it has to be quick (exponential number of paths to search) - anything important (debugging / trade execution) was thrown in a queue and written out by another process
I found maybe 20-30 exchanges that were not publicly advertised, so there was quite a bit of liquidity there. It looked for triangular arbitrage opportunities, then optimised the amount and computed gas costs to check if it was profitable. There was a lot of compute required, about 12,000 paths a second were searched and a profitable trade would be found about once every 3 hours.
“Optimising the amount” was a bit tricky too - too little you leave money on the table, too much you cause slippage - but you know the good thing about DeFi is that through our ETH nodes we have a copy of the blockchain and I had already written an EVM disassembler for another project, so I had a lot of knowledge of EVM internals - so I could simulate the trade executions inside the optimiser locally, which greatly helped “realism”
The whole system was profitable for about 8 months, it netted me about 180k usd before it tapered off - I don’t know why but I suspect someone else found the strategy/was doing the same thing, so I took the cash out of it, paid tax and moved on.
If you’re interested in the tech it was all just pure Python, networkx for the graph stuff, shared memory, multiprocessing and lots of IPC, the whole thing operated in RAM because it has to be quick (exponential number of paths to search) - anything important (debugging / trade execution) was thrown in a queue and written out by another process
After that, I built this https://atomictessellator.com