Creates a router client without making a network request.
A later read or transaction request fails with an AftermathTransportError
of kind network when neither config.baseUrl nor config.network is set.
Optionalconfig: CallerConfig
Optional API host, network, endpoint, and access-token configuration.
The mutable configuration used for subsequent requests.
Static ReadonlyconstantsStatic safety limits used by router requests.
The maximum external fee fraction accepted in a route request. 0.5 is 50%.
Appends a complete route to an existing transaction.
The method serializes the supplied transaction for the API, sends the route
request, and parses the returned serialized transaction into a new
Transaction. The input transaction is not mutated. Use the returned
coinOutId when the response exposes the swap output. It can be undefined.
Existing transaction, sender, complete route, slippage, and optional input coin argument.
A new transaction and the optional output coin argument.
AftermathTransportError when the API request, serialization response, or transaction parsing fails.
// 1) Create a route
const route = await router.getCompleteTradeRouteGivenAmountIn({ ... });
// 2) Initialize your transaction
const tx = new Transaction();
// 3) Add router instructions
const { tx: updatedTx, coinOutId } =
await router.addTransactionForCompleteTradeRoute({
tx,
completeRoute: route,
slippage: 0.01,
walletAddress: "0x<your_address>"
});
// 4) Continue building your transaction with the resulting coinOutId, if desired
updatedTx.transferObjects([coinOutId!], "0x<your_address>");
Requests an exact-input route for a specified coin amount.
The API may split the input across several routes. Each route can contain
several sequential paths, and each path identifies its DEX protocol and
pool. referrer and externalFee are forwarded to the API. Protocol and
pool allowlists and blocklists constrain route selection.
Input and output types, input amount in smallest units, and optional routing constraints.
Amount of coin being given away
OptionalabortSignal: AbortSignal
Optional caller-owned cancellation signal.
A promise for the complete route, including split portions, path fees, and amounts.
const route = await router.getCompleteTradeRouteGivenAmountIn({
coinInType: "0x2::sui::SUI",
coinOutType: "0x<...>::coin::TOKEN",
coinInAmount: BigInt(10_000_000_000),
// optional fields:
referrer: "0x<referrer_address>",
externalFee: {
recipient: "0x<fee_collector>",
feePercentage: 0.01
},
protocolBlacklist: ["Cetus", "BlueMove"],
poolBlacklist: ["0x<pool_id>"]
});
console.log(route);
Requests an exact-output route for a target coin amount.
slippage is required because the router must protect the input needed to
reach the target. The API may split the trade across routes and chain paths
across protocols. Amounts are smallest-unit bigint values.
Input and output types, target output in smallest units, slippage, and optional constraints.
Amount of coin expected to receive
OptionalabortSignal: AbortSignal
Optional caller-owned cancellation signal.
A promise for the complete exact-output route.
Fetches routed trade events for one wallet from the indexer.
Wallet address and optional numeric cursor and page limit.
A promise for paginated RouterTradeEvent values. A full page advances nextCursor.
Fetches every coin type currently supported by the router.
A promise for fully qualified Sui coin type strings.
Fetches an unsigned transaction for a previously calculated complete route.
The request serializes nested bigint amounts and fixed split portions as
strings ending in n. The API response is parsed into a Transaction, and
walletAddress is assigned as its sender. The method does not sign or submit it.
Sender, complete route, route slippage, and optional sponsorship or recipient settings.
A promise for the unsigned parsed Transaction returned by the API.
const route = await router.getCompleteTradeRouteGivenAmountIn({ ... });
const transactionBytes = await router.getTransactionForCompleteTradeRoute({
walletAddress: "0x<your_address>",
completeRoute: route,
slippage: 0.01
});
// The returned bytes can now be signed and executed using your chosen wallet.
Fetches the router's total 24-hour trading volume.
A promise for the numeric API value. This class does not convert its unit.
Fetches supported coin types whose API path matches a filter string.
The filter segment appended to the supported-coins endpoint.
OptionalabortSignal: AbortSignal
Optional caller-owned cancellation signal.
A promise for matching fully qualified coin type strings.
StaticapiReturns the canonical Aftermath API host for a Sui network.
To target a custom or local host, pass baseUrl in CallerConfig to the
constructor instead.
The Sui network whose host to return.
The network's HTTPS or local HTTP API host.
StaticdefaultReturns the canonical Sui fullnode URL for a network.
The network whose fullnode URL to return. undefined
defaults to mainnet.
The network's fullnode URL.
Provides HTTP reads, route construction, and transaction builders for Aftermath's smart order router.
Route amounts and fees are
bigintvalues in the corresponding coin's smallest unit. Decimal percentages such as slippage and external fees usenumbervalues where0.01means 1%. The router can split a trade across several sub-routes and can chain several protocol paths within each route.Example