One order, every pool, one transaction.
How a routed swap works
A routed swap is one transaction with four steps inside it.
- Split. The router quotes every pool of the stock (USDG and WETH pairs, every fee tier that clears the depth floor) and assigns a share of the order to each pool on a 10% grid, so that the total amount out is the largest.
- Fill. Each share is swapped in its pool. WETH-quoted pools take a hop through the deepest WETH/USDG pool. Every leg checks its own minimum out.
- Backrun. After the fills the pools no longer agree on a price. The router buys in the pools that are now cheap and sells in the ones that are now dear until the difference is smaller than the fees it would cost to keep going.
- Rebate. Whatever the backrun netted is split by the constants in
config/protocol.tsand paid out in the same transaction. The trader's share goes to the address that sent the swap.
If any step fails the whole transaction reverts. There is no state between steps for anyone to act on.
Why pools drift
One Robinhood stock token can trade in up to eight pools: against USDG and against WETH, in the 0.01%, 0.05%, 0.3% and 1% fee tiers. Each pool has its own price. Nothing on chain keeps them equal.
Prices drift apart for ordinary reasons. A swap lands in one pool and moves it. The stock's reference price changes and one pool's liquidity providers react before the others. A WETH-quoted pool moves with ETH while a USDG pool does not. Thin pools move more per dollar than deep ones.
Arbitrage bots close the gaps, but only when a gap is larger than the fees on both legs plus gas, and only after the swap that opened it has already been mined. Between those moments the stock has several prices, and any trader who hits a single pool pays that pool's price rather than the best one.
Fee bands and when a gap is real
A spread between two pools is only worth anything after paying both pools' fees. The scoreboard shows two numbers for every stock:
- Spread is
(max − min) / midacross the stock's pools that clear the depth floor, in basis points. - After fees subtracts the two cheapest fee tiers among those pools, which is what a two-pool backrun pays. A 30 bps gap between a 0.05% pool and a 0.3% pool is worth 30 − 5 − 30 = −5 bps: nothing.
The depth floor matters as much as the fee. A pool that would move 2% on less than 2,500 USDG of flow shows whatever price the last small trade left it at. Its spread against a deep pool looks enormous and cannot be captured. Such pools are hidden, and a stock needs at least 2 pools above the floor to be routable at all.
The split algorithm
For an order of size S the router asks QuoterV2 for the amount out of each eligible pool at 10%, 20% … 100% of S. That is ten quotes per pool, all in one multicall against the current block.
With those tables in hand the split is a small exact optimisation: choose a number of tenths for each pool so that the tenths sum to ten and the total amount out is maximised. With at most eight pools and ten steps this is a bounded knapsack that a dynamic programme solves in microseconds. Fractions that failed to quote (a pool too shallow for that size) are excluded rather than guessed.
The result is compared with the best single pool. On small orders the single pool usually wins and the preview says so; the split starts to matter when an order is large relative to the depth of the best pool.
The backrun
Every quote returns the pool's sqrtPriceX96 after the fill, so the router knows what the pools will look like once the order is in. From those prices it computes the remaining gap and trades it down: buy the cheap side, sell the dear side, sized so that the last unit of the trade still clears fees.
Two properties make this different from an external arbitrage:
- It happens in the same transaction as the swap that opened the gap. There is no block in which the gap exists for anyone else.
- It is sized from the same quotes as the fill, so it cannot be front-run by a change in state between quote and execution. If state changed, the transaction reverts and nothing happens.
The preview shows this gap as before → after in basis points, and an upper bound in USDG for what the backrun could capture on that order size. Upper bound, because it assumes the whole order's worth of flow can be traded across the gap; the real capture is what the pools actually give.
Rebate and split
Captured profit is split 50 / 40 / 10: trader, $GNAR stakers, treasury. The percentages are immutable in the contract; only the recipient addresses of the staker and treasury shares can be changed by the owner.
The rebate number in the route preview is an upper bound: it assumes the whole order's worth of flow can be traded across the gap that is left after the fill. The real rebate is whatever the backrun actually nets, which can be less and is never more.
There is no swap fee. A swap that captures nothing pays nothing beyond pool fees and gas. Until the token exists the staker share is held by the treasury and reported on the security page.
Risks
- Unaudited until stated otherwise. The security page lists test results as they are published; until it does, assume none.
- Single sequencer. Robinhood Chain has one sequencer. Ordering within a block is its call, and downtime stops everything, including the backrun.
- Stock tokens can pause. The tokens are upgradeable beacon proxies controlled by their issuer. A paused token makes every pool of that stock untradeable at once.
- Quotes are exact for one block only. A quote from block N describes the pools at block N. The transaction executes at N+1 or later. Minimum-out checks protect the fill; they do not guarantee the preview's number.
- Depth is a lower bound. The depth shown uses the liquidity active at the current tick. Real depth beyond that tick may be higher or lower.
Glossary
- Basis point (bps)
- One hundredth of one percent. 100 bps = 1%.
- Backrun
- A trade placed immediately after another trade to profit from the price it left behind.
- Depth
- The amount of quote token needed to move a pool's price by a set percentage. Used here at 2%.
- Mid
- The depth-weighted average price of a stock across its pools.
- Quote token
- The token a stock is priced in: USDG or WETH.
- Routable
- A stock with at least 2 pools above the depth floor, so an order can be split and a gap can exist.
- Spread
- The gap between the highest and lowest pool price of one stock, relative to mid.
- USDG
- Global Dollar, the stablecoin the stock tokens are mostly quoted in. Six decimals.