Javascript

Arbitrage Basics: Graph Theory for Multi-Pair Arbitrage Detection

Welcome Back to Arbitrage Basics

In our previous post on triangular arbitrage, we covered 3-pair arbitrage. This time we’ll use graph theory to find arbitrage across any number of trading pairs.

By modeling pairs as a weighted directed graph, we can use Bellman-Ford to detect negative cycles, which correspond directly to profitable arbitrage loops.

Why Graph Theory for Arbitrage?

Traditional triangular arbitrage only checks predefined 3-token paths. But what if profitable opportunities exist across 4, 5, or even 10 different tokens? Manual enumeration becomes computationally expensive and misses complex paths.

Read More

Arbitrage Basics: Triangular Arbitrage on Uniswap (With JS Examples)

Welcome to Arbitrage Basics

This blog post series covers the math, finance, and programming behind arbitrage trading. In this first post, we’ll walk through the basics and write a simple arbitrage script in JS. It won’t generate real profits, but understanding the fundamentals is key before building something that can.

The most basic kind of Arbitrage: Triangular Arbitrage

Triangular arbitrage exploits price discrepancies between three trading pairs to generate profits. Start with ETH, trade it for LINK, then LINK for SHIB, then SHIB back to ETH. If exchange rates are misaligned, you end up with more ETH than you started with. The profit comes from temporary price inefficiencies caused by large trades or slow arbitrage by other traders.

Read More