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.Documentation Index
Fetch the complete documentation index at: https://docs.nexroute.io/llms.txt
Use this file to discover all available pages before exploring further.
Interface
execute is the entrypoint partners call. backrun is the function the wrapper invokes internally on delegatecall(backrunData). sweep exists so any dust trapped in the contract can be forwarded to the nexroute fee wallet.
Flow
- Get aggregator swap calldata. Set
receiver = userso output tokens go directly to the end user, not the wrapper. - Ask nexroute for a backrun via the backrun API.
- Have the user sign a Permit2
PermitTransferFromtyped-data message withspender = <wrapper address>,permitted.token = <input token>,permitted.amount = <amount in>. - ABI-encode
execute(permit, signature, swapData, backrunData)and submit it as the user’s transaction.
What you receive from nexroute
| Field | Description |
|---|---|
target | not used in this shape; the wrapper invokes the backrun internally via delegatecall |
callData | pass as the backrunData argument to execute(...); null when no arbitrage opportunity is found |
callData 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 delegatecall is a no-op.
Permit2 signature
The user signs the Permit2 typed-data domain. Domain values: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
Approximateexecute 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).