Elixir
How it works

A disagreement between executable exchange rates

A token can trade in a COIN/USDG pool and a COIN/stock-token pool. When the stock token's dollar price moves, the second pool's implied dollar price for COIN changes before the pools rebalance. That gap is the opportunity, and it only counts once a complete route closes back to cash (USDG).

A complete trade closes the loop
100 USDG → 100 COIN → 1 stock token → 102 USDG

Two units of gross surplus before fees and costs. Finishing with a stock token valued at 102 dollars is not the same as holding cash: a reference valuation does not repay a USDG obligation. The final conversion must be available at an executable price, quoted at the actual size.

Direction follows price, not the label

If the stock rises and the stock pool now values COIN more highly: buy COIN in the cheaper cash pool, sell into the richer stock pool, convert proceeds back to cash. If the stock pool is cheaper, reverse the route. Always buying one side excludes half the opportunities.

Units matter. Normalise token ordering and decimals for v4 pools, and identify assets by chain ID and address, never by ticker string.

Atomic settlement

Uniswap v4 settles the net balances of several swaps at the end of one unlock callback. Every currency debt must be resolved before it finishes. The executor is built to finish holding USDG and to revert unless USDG grew by at least the required surplus — a losing route costs only gas, never principal.

Route calculator

A large displayed gap can disappear after fees

Let F(q) be the cash returned by the complete route for input q, including pool fees and impact. Choose the size that maximises F(q) − q − execution costs and require the result to clear an uncertainty margin. This models the fee part; impact and depth need the live contracts.

Result, no price impact modelled
Route returns
1,033.2525 USDG
Surplus before gas
33.2525 USDG
Net after gas
33.0725 USDG
Break-even edge for these fees
0.653%
Naive fee sum
0.650%

The break-even edge is 1 ÷ (product of fee factors) − 1. Adding fee percentages is only a small-fee approximation: with two 20% input fees the true hurdle is 56.25%, not 40%.

Reverts still cost

A reverted transaction protects swap state, not spending. Surplus measured inside the executor excludes failed attempts. A profitable trade and a profitable business are separate measurements.

Depth sets capacity

The cheapest visible unit is not the average price for a large purchase. Crossing a tick changes the next unit's price and liquidity. More nominal pools can mean less depth per route.

Every leg quoted at size

The engine quotes each leg through the on-chain quoter at the actual proposed size before committing. Spot-price percentages are not used to decide execution.