For the complete documentation index, see llms.txt. This page is also available as Markdown.

Swap & Bridge Integration

Use TaskType.GetTokenOut for cross-chain swaps and bridges where the user receives a target token on a destination chain.


When to use each pattern

User goal
Task type
Amount pattern

Swap token A → token B on another chain

GetTokenOut

Forward quote: set tokenInAmount

Bridge same asset to another chain

GetTokenOut

Forward quote: set tokenInAmount

Receive exact output (e.g. pay exactly 50 USDC on Base)

GetTokenOut or ProtocolInteraction

Reverse quote: tokenInAmount: "0", set minTokenOut


Forward quote

User specifies how much they want to spend:

const { taskTypeString, intentData } = await sdk.getTaskData({
  taskType: TaskType.GetTokenOut,
  intentData: {
    isNative: false,
    depositTokenAddress: SOURCE_USDC,
    tokenInAmount: parseUnits("100", 6).toString(),  // user spends 100 USDC
    outputTokenAddress: DEST_USDC,
    minTokenOut: "0",                               // accept any output >= 0
    destinationChainId: "8453",
    protocolHashIdentifier: "0x0000000000000000000000000000000000000000000000000000000000000000",
    recipient: sponsorAddress,
  },
  extraDataTypestring: "",
  extraData: {},
});

Display quote.tokenOut to the user as the expected receive amount.


Reverse quote

User needs an exact output; Epoch computes the required input:

Reverse quotes are required for fixed-price purchases (raffle tickets, exact payment amounts).


Approvals

Before or during solveIntent, the user may need to approve the input token on the source chain. The SDK returns approval transactions when needed.

Your UI should:

  1. Detect when approval is required (from quote or solve response).

  2. Prompt the user to sign the approval transaction.

  3. Proceed to the main intent solve after approval confirms.

Ensure the wallet is on the source chain before signing.


Displaying quotes

Show the user:

Field
Label suggestion

quote.tokenIn

"You pay"

quote.tokenInSymbol

Token symbol

quote.tokenOut

"You receive"

quote.path

Optional: "Route" (human-readable summary)

Slippage / fees

If exposed in quote response

Always require explicit user confirmation before calling solveIntent.


Routing & liquidity options

Optional routingAndLiquidityOptions lets integrators choose how the swap is filled:

Preset
When to use

any

Default — best quote across all solvers

filler-single-transaction

Prefer Epoch filler liquidity — the user signs one transaction for seamless end-to-end execution (protocol interactions are handled behind the scenes)

external-multi-transactions

External aggregators only (multi-step signing)

custom

Pin specific solver address(es)

Pass the same options to getIntentQuote and solveIntent:

See SDK Reference.


Chain and token selection

  • Source chain: where the user's wallet is connected and input tokens exist.

  • Destination chain: where output tokens are delivered (destinationChainId).

  • Use token addresses from Chains & Tokens.


Resource locks

If quote.resourceLockRequired === true, the intent requires Compact collateral. See Core Concepts and contact Epoch for Compact partner setup.


Next steps

Last updated