Closed ruidazeng closed 3 weeks ago
I think this is an interesting idea! Currently, this repo focuses only on triangular arbitrage, but adding the ability to detect more than three cycles could be a great feature. I haven't looked into four-cycle opportunities yet, but your examples show that they could definitely exist. Thanks for sharing your thoughts!
@Herklos
Some other thoughts:
The set of all cycle is for a specific set is significantly larger than the set of all triangular cycles for exchanges if there is an exchange ticker available between every currency to each other; moreover, in that scenario, most longer cycle can be composed entirely from the smaller 3-cycles (triangular cycles), hence higher order cycle detections are not necessary.
However, for smaller DEX that concerns with super niche currencies, where links do not necessarily exist between every currencies (like the example below, very simplified of course and completely made up), then the triangular will completely miss the arbitrage opportunity (in example: Solana > Ethereum > Algorand > Uniswap > Solana), even when if it's extremely profitable:
Either way, the algorithm is the same - Johnson's Algorithm (1975) for finding the shortest paths between all pairs of vertices in an edge-weighted directed graph.
@Herklos Would you
cycle_detector
be of any interest in terms of arbitrage opportunity detection? For the test case, total profit from the best triangular arbitrage opportunity is approximately 452.63% (SELL ETH to BTC at 0.30, SELL BTC to USDC at 35,000, BUY ETH from USDC at approximately 0.000526 (reversed from USDC to ETH) vs 477.5% binance opportunity below:In my opinion (I might be wrong about this), if less available currency exchange quotes exist, then the triangular arbitrage opportunity pales in comparison of higher-order cycle arbitrage opportunity. This might be true for some certain crypto currency that are not available on central exchanges and are only traded by AMMs (automated market makers); as an anecdote, my advisor once received compensation for his crypto contributions in the form of a very very niche currency that required a long path to convert back to cash.