Interface
execute is the entrypoint partners call. It handles the Permit2 pull, the aggregator swap, and the backrun atomically.
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
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: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).