Our pathfinding algorithm
Last updated
Last updated
We don’t just rely on intuition; our algorithms are backed by solid math to ensure precision:
Max Output Equation: Our core algorithm employs a sophisticated equation to maximize output. Given two tokens A and B with liquidity pools ( L_A ) and ( L_B ), the equation is:
where PA → B
is the price of token A in terms of token B, and Δ LB
represents the change in liquidity for token B due to the swap.
Optimal Pathfinding: We use a pathfinding algorithm inspired by Brent’s method to ensure the best route is selected. Our implementation involves:
where xn
is the current estimate, xn-1
is the previous estimate, and f(x)
represents the function that calculates the output of the swap. This approach combines Brent’s algorithm with inverse parabolic interpolation to speed up convergence and optimize routing decisions.
Arbitrage Efficiency Function: To minimize scalar deviations and optimize arbitrage opportunities, we use:
where Pi, buy
and Pi, sell
are the buy and sell prices of token i
, Wi
represents the weight of each price opportunity, and Earb
is the efficiency score for the arbitrage opportunity. This formula helps in evaluating the best routes for exploiting price differences across multiple exchanges.