Skip to main content
In Embedded mode, the backrun runs in the same on-chain transaction as the user’s swap. There is no separate backrun transaction. The user signs once (typically a Permit2 typed-data message), and a single transaction is broadcast that the chain executes atomically. This is one of three integration modes for Cashback. For the alternatives where the backrun is a separate transaction landing behind the user’s, see Dispatch mode and Async mode.

How it differs from Dispatch mode

How it works

  1. The partner obtains aggregator swap calldata in their normal flow.
  2. The partner asks nexroute for a backrun via the backrun API; nexroute simulates how the swap will move the pool and returns calldata that arbitrages the resulting price.
  3. The user signs a Permit2 typed-data message authorising the input token movement (token, amount, spender, deadline, nonce).
  4. The resulting transaction is broadcast (typically by the user’s wallet). The user’s swap and the backrun execute atomically. If the backrun reverts, the user’s swap still completes.

Integration shapes

Embedded mode is a pattern, not a single integration. nexroute supports multiple shapes; pick the one that fits your stack.

Wrapper contract

Partner calls a nexroute-provided contract that handles Permit2 pull, aggregator forwarding, and atomic backrun in one entrypoint.

Calldata composition

Partner receives backrun calldata and composes it into their own router, multicall, or post-hook.
Both shapes use the same backrun API and the same trust model.

When to choose Embedded mode

nexroute recommends Dispatch mode when feasible. Reasons:
  • Faster. Dispatch mode is one round trip from partner to nexroute, after which nexroute dispatches the tx directly via private partnerships. Embedded mode adds a separate backrun API round trip before the user signs and relies on the dispatcher’s broadcast path, which is typically slower than direct dispatch.
  • Cleaner separation of concerns. The partner submits a raw signed transaction and nexroute owns the backrun end-to-end. Embedded mode pulls backrun integration into the partner’s transaction construction.
  • Privacy by default. Dispatch mode forwards via private partnerships; Embedded mode privacy depends on whoever broadcasts.
Embedded mode is the right choice when neither Dispatch nor Async mode is available. The decisive question is who dispatches the user transaction:
  • The user’s wallet, or any party the partner doesn’t control. Dispatch mode requires the partner to relay the signed transaction through nexroute’s private endpoint, and Async mode still requires the partner to hold the signed transaction to notify nexroute; if your integration ends with the user clicking submit in their wallet, neither is available. Embedded mode is the way.
  • The partner’s own backend or a controlled dispatcher. Use Dispatch mode, or Async mode when a relay hop before dispatch is not affordable.
If mempool exposure is a concern in Embedded mode, the dispatcher must use a private relay.

Get started

Wrapper contract

Walkthrough for the wrapper-contract shape.

Calldata composition

Walkthrough for the calldata-composition shape.

Backrun API

Endpoint, request, response.

Security

Trust model and failure semantics.