Table of Contents
Fetching ...

A Line Graph-Based Framework for Identifying Optimal Routing Paths in Decentralized Exchanges

Yu Zhang, Yafei Li, Claudio Tessone

TL;DR

The paper tackles the problem of identifying profitable multi-hop trading paths across decentralized exchanges by introducing a line-graph-based framework (LG). It constructs a token graph from liquidity pools, transforms it into a line graph, and applies an LG routing algorithm that traverses the line graph to maximize output under CPMM rules, with a finite termination guaranteed even in arbitrage scenarios. Empirical results on Uniswap V2 data show that LG matches or surpasses DFS in profitability while maintaining comparable gas costs, though the method exhibits exponential runtime growth with graph size. The work demonstrates LG’s viability for real-world routing and sets the stage for potential deployment in DEX aggregators and further optimization to handle larger graphs.

Abstract

Decentralized exchanges, such as those employing constant product market makers (CPMMs) like Uniswap V2, play a crucial role in the blockchain ecosystem by enabling peer-to-peer token swaps without intermediaries. Despite the increasing volume of transactions, there remains limited research on identifying optimal trading paths across multiple DEXs. This paper presents a novel line-graph-based algorithm (LG) designed to efficiently discover profitable trading routes within DEX environments. We benchmark LG against the widely adopted Depth-First Search (DFS) algorithm under a linear routing scenario, encompassing platforms such as Uniswap, SushiSwap, and PancakeSwap. Experimental results demonstrate that LG consistently identifies trading paths that are as profitable as, or more profitable than, those found by DFS, while incurring comparable gas costs. Evaluations on Uniswap V2 token graphs across two temporal snapshots further validate LG's performance. Although LG exhibits exponential runtime growth with respect to graph size in empirical tests, it remains viable for practical, real-world use cases. Our findings underscore the potential of the LG algorithm for industrial adoption, offering tangible benefits to traders and market participants in the DeFi space.

A Line Graph-Based Framework for Identifying Optimal Routing Paths in Decentralized Exchanges

TL;DR

The paper tackles the problem of identifying profitable multi-hop trading paths across decentralized exchanges by introducing a line-graph-based framework (LG). It constructs a token graph from liquidity pools, transforms it into a line graph, and applies an LG routing algorithm that traverses the line graph to maximize output under CPMM rules, with a finite termination guaranteed even in arbitrage scenarios. Empirical results on Uniswap V2 data show that LG matches or surpasses DFS in profitability while maintaining comparable gas costs, though the method exhibits exponential runtime growth with graph size. The work demonstrates LG’s viability for real-world routing and sets the stage for potential deployment in DEX aggregators and further optimization to handle larger graphs.

Abstract

Decentralized exchanges, such as those employing constant product market makers (CPMMs) like Uniswap V2, play a crucial role in the blockchain ecosystem by enabling peer-to-peer token swaps without intermediaries. Despite the increasing volume of transactions, there remains limited research on identifying optimal trading paths across multiple DEXs. This paper presents a novel line-graph-based algorithm (LG) designed to efficiently discover profitable trading routes within DEX environments. We benchmark LG against the widely adopted Depth-First Search (DFS) algorithm under a linear routing scenario, encompassing platforms such as Uniswap, SushiSwap, and PancakeSwap. Experimental results demonstrate that LG consistently identifies trading paths that are as profitable as, or more profitable than, those found by DFS, while incurring comparable gas costs. Evaluations on Uniswap V2 token graphs across two temporal snapshots further validate LG's performance. Although LG exhibits exponential runtime growth with respect to graph size in empirical tests, it remains viable for practical, real-world use cases. Our findings underscore the potential of the LG algorithm for industrial adoption, offering tangible benefits to traders and market participants in the DeFi space.

Paper Structure

This paper contains 14 sections, 2 theorems, 2 equations, 9 figures, 2 algorithms.

Key Result

Theorem 1

In an arbitrage loop with the accumulative product of the token exchange rate larger than one, given the market maker function $f$ monotonically increasing and concave, for any fixed amount of input of a specific token in the arbitrage loop, the number of traversal round to get the higher output of

Figures (9)

  • Figure 1: Orginal graph $G$ with 4 tokens and 5 liquidity pools. So, $M_G=4$ and $E_G=5$, where $M$ and $E$ denote the number of nodes and edges.
  • Figure 2: The line graph ($L(G)$) of the original graph $G$ with 4 tokens and 5 liquidity pools as shown in Fig.\ref{['origraph']}. The number of vertices in the line graph equals the number of edges in the original graph, namely, $M_{L(G)}=E_G$. The number of links in the line graph equals the sum of the degree's square of each token minus two times the number of edges in graph $G$, namely $E_{L(G)} =\sum {d_i}^2-2E_G$, where $d_i$ denotes the degree of token $i$ in the original graph $G$. The added extra node to simplify calculation is the green vertex $(O,v_1)$ which connects to the other two vertices, $(v_1,v_3)$ and $(v_1,v_2)$.
  • Figure 3: The distribution of performance discrepancy ratio between the two algorithms, line-graph-based algorithm, and DFS algorithm, by inputting different amounts of money (10$, 100$, 1,000$, and 10,000$). $lg$ and $dfs$ represent the target token outputs for line-graph-based algorithm and DFS algorithm, respectively. The Y-axis shows the percentage of token pairs where the line-graph-based algorithm outperforms the DFS algorithm by the corresponding ratio.
  • Figure 4: Proportion of Token Pairs with $\frac{lg-dfs}{dfs}> 0.001$ under Different $M$. $M$ denotes the money input in trading for each pair of tokens.
  • Figure 5: Mean and Median of $\frac{lg-dfs}{dfs}$ with $\frac{lg-dfs}{dfs}> 0.001$ under Different $M$. $M$ denotes the money input in trading for each pair of tokens.
  • ...and 4 more figures

Theorems & Definitions (4)

  • Theorem 1
  • proof
  • Theorem 2
  • proof