Index of every page on this site: llms.txt
All skills
availproject avatar

/nexus-sdk-swap-flows

@8f83d92
Run it yourself

Implement swapWithExactIn, swapWithExactOut, and swapAndExecute flows with Nexus SDK. Use when wiring swap operations, swap intent hooks, or swap event progress updates.

Use this Skill: https://skilld.dev/gh/availproject/widgets/nexus-sdk-swap-flows

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈48 tokens for metadata: the name and description. ≈586 when used: this file.

Description uses 2.4% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈192 characters, or 2.4%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Swap Flows

Call swapWithExactIn(input, options?)

  • Use when input amount is fixed and sources are known.
  • Signature:
    • sdk.swapWithExactIn(input, { onEvent? })
  • Params (ExactInSwapInput):
    • sources?: { chainId: number; tokenAddress: Hex; amountRaw?: bigint }[]
    • toChainId: number
    • toTokenAddress: Hex
  • Notes:
    • Ensure sources[].amountRaw values are in smallest units when provided.
    • Use chain-specific token addresses (see TOKEN_CONTRACT_ADDRESSES).
  • Result (SwapResult):
    • SwapResult with sourceSwaps, destinationSwap, and intentExplorerUrl.

Call swapWithExactOut(input, options?)

  • Use when desired output amount is fixed.
  • Signature:
    • sdk.swapWithExactOut(input, { onEvent? })
  • Params (ExactOutSwapInput):
    • toChainId: number
    • toTokenAddress: Hex
    • toAmountRaw: bigint
    • toNativeAmountRaw?: bigint (optional native token output)
    • sources?: { chainId: number; tokenAddress: Hex }[] (optional)
  • Notes:
    • If sources is omitted, SDK auto-selects sources.

Call swapAndExecute(input, options?)

  • Use to perform swap (if needed) and then execute a contract call.
  • Signature:
    • sdk.swapAndExecute(input, { onEvent? })
  • Params (SwapAndExecuteParams):
    • toChainId: number
    • toTokenAddress: Hex
    • toAmountRaw: bigint
    • sources?: { chainId: number; tokenAddress: Hex }[]
    • execute: SwapExecuteParams
  • SwapExecuteParams:
    • to: Hex
    • data?: Hex
    • value?: bigint
    • gas: bigint
    • gasPrice?: 'low' | 'medium' | 'high'
    • tokenApproval?: { toTokenAddress: Hex; amount: bigint; spender: Hex }
  • Result (SwapAndExecuteResult):
    • swapResult: SuccessfulSwapResult | null (null if swap skipped)

Use token addresses and chains

  • Use SDK constants for addresses and chain IDs:
    • SUPPORTED_CHAINS
    • TOKEN_CONTRACT_ADDRESSES

Attach swap intent hook

  • Set sdk.setOnSwapIntentHook(...) and call allow() to proceed.
  • If the hook is not set, the SDK auto-approves.

Stream swap events

  • Listen for NEXUS_EVENTS.SWAP_STEP_COMPLETE.
  • Handle special cases like swap skipped (e.g., already on destination token).

Convert amounts to bigint

  • Use sdk.utils.parseUnits(value, decimals) or
  • sdk.convertTokenReadableAmountToBigInt(value, tokenSymbol, chainId) when decimals vary by chain.

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

1 warning8mo3 checks · Risk SAFE
  • Gen Agent Trust Hub9mo

    This skill provides documentation for using the Nexus SDK to perform cryptocurrency swaps. It contains no executable code, malicious instructions, or security vulnerabilities.

  • Socket8mo

    No alerts

  • Snyk9mo

    Risk: MEDIUM · No issues

Signed by skilld at 8f83d92. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last week.

Activeupdated 5 months ago

README badge

README badge for availproject/widgets/nexus-sdk-swap-flows