Skip to content

Execution

Execution primitives answer pre- and post-trade execution questions: “how much slippage on this swap?” and “did I get sandwiched?”

  • CalculateSlippage — pre-trade slippage and price-impact decomposition for a proposed swap.
  • DetectMEV — post-trade comparison of actual on-chain output vs the invariant-implied output.

Execution analytics — slippage, price impact, MEV exposure — are V2/V3 only in v2.0. The math is available in BalancerExchange.get_amount_out and StableswapExchange.get_amount_out; the gap is primitive packaging, not derivation.

ProtocolCoverageNotes
Uniswap V2FullCalculateSlippage, DetectMEV.
Uniswap V3FullBoth primitives. max_size_at_1pct is V2-only on CalculateSlippage (V3 tick-walking infra not yet implemented).
BalancerDeferred (v2.1)Sibling primitives or protocol-dispatching extension planned; Bucket A. Math is in BalancerExchange.get_amount_out.
StableswapDeferred (v2.1)Same as Balancer; math in StableswapExchange.get_amount_out.

Closing this gap also unblocks full CompareProtocols.slippage_at_amount plumbing.

In the curated v2.0 set: CalculateSlippage. Not in: DetectMEV (post-trade forensic; agents typically want this after observing a settled trade, less common than pre-trade slippage).