Skip to main content

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.

Given a user transaction description, returns ready-to-use backrun calldata that the partner composes into the user transaction so the swap and backrun execute atomically in one on-chain transaction. nexroute does not dispatch the transaction in this mode; the partner (or the user’s wallet) submits it. Returns result: null when no profitable arbitrage is found, in which case the partner proceeds without a backrun.
Privacy is the dispatcher’s responsibility. If mempool exposure is a concern, the dispatching path must use a private relay.

Request

POST to your embedded endpoint with a JSON-RPC 2.0 envelope.

Params

params is a single-element array containing the user transaction description.
FieldTypeRequiredDescription
tostringyesTarget contract the user transaction calls (e.g. the aggregator router).
calldatastringyesHex-encoded calldata of the user transaction (the swap).
valuestringnoNative-token value attached to the user transaction, as a decimal string. Omit or set to "0" if none.
tokenInstringyesInput token of the user swap.
amountInstringyesInput amount as a decimal string in token base units.

Example

curl -X POST https://your-embedded-endpoint \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "eth_backrun",
    "params": [{
      "to": "0x1231deb6f5749ef6ce6943a275a1d3e7486f4eae",
      "calldata": "0x...",
      "value": "0",
      "tokenIn": "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
      "amountIn": "1000000000000000000"
    }]
  }'

Response

A JSON-RPC envelope echoing the request id. result is a BackrunResult object when a profitable backrun is found, or null when none.

BackrunResult

FieldTypeDescription
calldatastringBackrun calldata, pre-wrapped so the partner can plug it into the user transaction without further encoding.
contractstringAddress of the backrun contract the calldata targets.
gasintegerEstimated gas for the backrun portion.
profitTokenstringToken in which the simulated gross profit is denominated.
grossProfitstringSimulated gross profit in profitToken base units (decimal string).
netProfitEthstringSimulated net profit after gas, denominated in the chain’s native token (decimal string). Use this to decide whether bundling is worth it on your side.
netProfitUsdstringSimulated net profit in USD (decimal string, oracle-converted).

Examples

Backrun found
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "calldata": "0x...",
    "contract": "0x0000000000000000000000000000000000000000",
    "gas": 215000,
    "profitToken": "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
    "grossProfit": "1234567890000000",
    "netProfitEth": "983456789000000",
    "netProfitUsd": "0.31"
  }
}
No profitable backrun
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": null
}

Errors

CodeCause
-32601Method not supported on this endpoint
-32000Missing or malformed required field (tokenIn, amountIn, etc.)
-32603Internal error during simulation (rare)