Crosschain Swaps
Swap any token on any chain to any other token on any chain using ExactIn or ExactOut methods.
In Nexus, users can do crosschain swaps (aka Swap Methods) which allows them to go from any token on any source chain(s), to any token on any destination chain.
Swaps are routed through multiple DEX aggregators (such as LiFi, Bebop, and 0x), which are quoted in parallel, with the best quote winning. When the swap crosses chains, the aggregator legs are combined with the Nexus bridge leg. Canonical assets like ETH, USDC and USDT are used as the "interim" or "express" tokens to make routing simpler and cheaper for users.
The pipeline is: optional source swap → bridge leg → optional destination swap. On supported chains, the SDK may automatically execute swap legs through a short-lived smart account (via EIP-7702) so multiple steps can be batched — no configuration needed.
Showing a subset of supported chains. See Supported Chains & Tokens for the full list.
The SDK manages the full transaction lifecycle and selects the route with the best quote. Three routings are possible:
There are essentially 2 types of Swap actions a user can do with Nexus. An
The
The
There is also
Routing possibilities
- Bridge → Destination Swap: A user sends a canonical asset like USDT from chain A, and gets a custom asset like DEGEN on chain B.
- Source Swap → Bridge: A user sends a custom asset like OP from chain A, and gets a canonical asset like USDT on chain B.
- Source Swap → Bridge → Destination Swap: A user sends a custom asset like OP from chain A, and gets a custom asset like PEPE on chain B.
Exact In & Exact Out Swaps
ExactIn swap and an ExactOut swap. In both cases, the destination is addressed by the token's contract address (toTokenAddress) and chain ID (toChainId) — swaps reach far more tokens than the canonical bridge set, so tokens are identified by address rather than symbol.
Let's dive into each one in detail.
ExactIn swap
ExactIn swap method is for performing exact input swaps, which swaps a fixed amount of one or more tokens on N number of source chains for a maximum possible (variable) amount of another token on the destination chain.
User decides exactly which tokens and their amounts that they want to swap. The user decides the exact input amount for the swap. The output amount here may vary based on slippage, fees, etc.
This operation uses the SwapExactInParams type and the swapWithExactIn() function from the Swap Methods in the SDK.
ExactOut swap
ExactOut swap method is for performing exact output swaps, which swap a minimum possible amount of one or more tokens on N source chains for a fixed amount of another token.
User decides the exact output amount they would like to receive at the end of the action. Nexus does the hard work of figuring out which tokens and balances it can use and executes the swap for the desired output amount.
This operation uses the SwapExactOutParams type and the swapWithExactOut() function from the Swap Methods in the SDK.
Swap & Execute
swapAndExecute(), which swaps into the destination token and then calls a smart contract on the destination chain in one flow — the swap counterpart of Bridge & Execute.
Note
All swap methods accept a
slippageTolerance option (default 0.5%) to bound how much the received amount may drift from the quote.