Control which chains your tokens are sourced from, or let Nexus optimize the route automatically.
When a user does a Nexus operation, it involves the sourcing of liquidity by Nexus from wherever they have it.Source chain selection determines which chains liquidity is routed through to reach the destination chain. Every operation accepts an optional sources parameter for this.Showing a subset of supported chains. See Supported Chains & Tokens for the full list.
Bridge Methods
For Bridge Methods, sources is simply an array of chain IDs to limit sourcing liquidity from.
sources?: number[];
If omitted, the SDK selects sources automatically: it accumulates the user's balances across chains until the requested amount plus fees is covered. If the combined balances can't cover it, the operation fails with an INSUFFICIENT_BALANCE error. But if needed, the developer can pass sources to limit liquidity to be sourced from the specified chains ONLY.
Swap Methods
For Swap Methods, sources are specific tokens on specific chains, so each entry names the chainId and tokenAddress. For ExactIn swaps, each source can also carry an amountRaw to fix how much of it to spend.
As with bridges, omitting sources lets the SDK pick from all available swap balances.
Re-planning from the intent hook
Before an operation executes, the onIntent hook presents the intent. For bridge operations the intent includes both selectedSources (what the SDK picked) and availableSources (everything it could have picked), and calling refresh(selectedSources) from the hook rebuilds the intent with a different source selection — so users can override the route without restarting the operation. Swap intents offer the same via refresh(sources). See Hooks for details.