Skip to main content
The wrapper contract is a thin Solidity contract deployed by nexroute on each supported chain. It accepts a single calldata blob containing the user’s Permit2 authorisation, the aggregator swap calldata, and nexroute’s backrun calldata, and executes them atomically in one transaction. Use this shape when you want the simplest integration: no partner contract changes, no router modifications, just a single function call from the user’s transaction.

Interface

execute is the entrypoint partners call. It handles the Permit2 pull, the aggregator swap, and the backrun atomically.

Flow

  1. Get aggregator swap calldata. Set receiver = user so output tokens go directly to the end user, not the wrapper.
  2. Ask nexroute for a backrun via the backrun API.
  3. Have the user sign a Permit2 PermitTransferFrom typed-data message with spender = <wrapper address>, permitted.token = <input token>, permitted.amount = <amount in>.
  4. ABI-encode execute(permit, signature, swapData, backrunData) and submit it as the user’s transaction.

What you receive from nexroute

A JSON-RPC envelope from the eth_backrun API. The fields used by this shape: When the JSON-RPC result is null, no arbitrage opportunity was found. Either skip the wrapper entirely and submit the user’s swap directly, or call execute(...) with backrunData = "0x" so the wrapper’s internal backrun step is a no-op.

Permit2 signature

The user signs the Permit2 typed-data domain. Domain values:
The user must have approved Permit2 (0x000000000022D473030F116dDEE9F6B43aC78BA3) for the input token at least once. After that, every Embedded transaction is one off-chain signature.

Building the execute call

Submission

The resulting transaction can be submitted through any RPC. For mempool privacy, submit through a private relay.

Invariants

  • Permit2 spender must equal the wrapper contract address.
  • The aggregator swap calldata must set receiver = user. Otherwise output tokens stay in the wrapper and are swept to the nexroute fee wallet.
  • The wrapper holds an allowance to the target aggregator only for the duration of the swap; allowance is revoked before the backrun runs.

Failure modes

  • Permit2 signature invalid or expired: revert before any funds move.
  • Aggregator swap reverts: revert; Permit2 pull is rolled back atomically. User loses only gas.
  • Backrun reverts: caught silently. User swap still completes. User pays gas for the failed attempt.

Gas

Approximate execute gas cost: 200k–350k depending on the depth of the backrun arbitrage path. The wrapper itself adds roughly 60k–80k over a direct aggregator call (Permit2 pull, approval, revoke, delegatecall).

Deployments

Contract addresses per chain are published as part of integrator onboarding. Contact nexroute for current addresses on your target chain(s).