Concepts · 6 min read
Slippage, reference prices and minimum output
Slippage is the gap between the price you expected and the price you got. To enforce a rule like “stop if the execution would exceed 1% slippage”, you first have to say what the expected price is.
The reference Tarmac uses
Tarmac's reference is the mid price of the deepest USDG pool for the pair at quote time, before fees and price impact. For a Uniswap v3 pool that mid price comes straight from the pool's sqrtPriceX96.
price (token1 per token0, raw units) = sqrtPriceX96² / 2¹⁹² reference output = amountIn × price (or ÷ price, by direction) slippage (bps) = ceil((reference − quoted) × 10 000 / reference)
Because the reference excludes fees, measured slippage includes the pool fee plus price impact. A 0.05% pool can never quote better than 5 bps below the mid.
Two markets, same instruction
| Market | Quote for 100 USDG | Slippage | Under a 100 bps rule |
|---|---|---|---|
| Deep pool (fixture) | 0.048602 WETH | 6 bps | Swap allowed |
| Shallow pool (fixture) | 0.047303 WETH | 273 bps | Agent should stop |
The live USDG/WETH 0.05% pool on Robinhood Chain quoted 100 USDG at 6 bps when we checked it read-only — the same order as the fixture's deep market.
From a rule to a minimum output
Checking the quote is not enough: the market can move between quote and execution. So when a swap is allowed, Tarmac sets the swap's minimum output from the same reference and the same limit, rounded in the conservative direction:
amountOutMinimum = ceil(reference × (10 000 − maxSlippageBps) / 10 000)
If the agent passes a stricter minimum, it is kept. A looser one is raised. On a fork, the deadline is enforced on-chain through SwapRouter02.multicall(deadline, …), so a stale transaction reverts instead of filling late.
All amounts are integers in base units: USDG has 6 decimals, WETH and Robinhood stock tokens 18. Slippage is in basis points (1 bps = 0.01%).