Skip to content

Migrate from SilentSwap V2

@silentswap/sdk@2.0.0 keeps the package name and familiar lifecycle names, but removes the V2 authentication and authorization ceremony. Existing V2 orders are not convertible: let them finish under your pinned 0.x integration before cutting over.

Migrate with an agent

Install the SilentSwap integration skill and let an agent perform the mechanical audit and rewrite. The skill preserves application-specific wallet decisions as explicit TODOs instead of guessing a wallet brand.

mkdir -p .agents/skills/silentswap-integration/references
curl -fsSL https://docs.silentswap.com/skill/SKILL.md \
  -o .agents/skills/silentswap-integration/SKILL.md
curl -fsSL https://docs.silentswap.com/skill/references/complete-example.ts \
  -o .agents/skills/silentswap-integration/references/complete-example.ts

Use this prompt:

Use $silentswap-integration to migrate this application from @silentswap/sdk 0.x to 2.x.
Audit every old import and call site; remove nonce, SIWE, facilitator, and authorization
persistence; migrate quote, placeOrder, trackOrderViaWebSocket, executeRefund, errors, and
client configuration; flag pending V2 orders that must finish on pinned 0.x; run the
consumer typecheck; and leave TODOs only where this app must choose its wallet adapters.

For Claude Code, install the same folder under .claude/skills/silentswap-integration.

API mapping

V2V3
createSilentSwapClientunchanged
nonce/SIWE authenticationremoved
facilitator groupremoved
quote({ outputs, pro })quote({ privacy, inputAddress, outputs, integratorFee })
sign authorizationsremoved; review the quote, then deposit
order()placeOrder(quote)
trackOrderViaWebSocketsame name; transport is adaptive
executeRefundsame name; accepts a private order reference
Simple Bridgesame product name; use privacy: false
pro / integratorIdintegratorFee / integratorAddress
React/Vue/widget packagesdiscontinued; React 2.x is planned

Do not mechanically translate the old pro integrator ID into an integrator fee. Only add integratorFee and integratorAddress after the application owner has approved the USDC-denominated fee and payout address.

Rewrite each output

V2 and V3 both call the array outputs, but each row is simpler in V3:

V2 output fieldV3 output field
recipientaddress
USDC decimal-string valuebigint amount in USDC base units
non-USDC valuerecompute the V3 USDC payout budget; do not copy destination-native units
CAIP-19 assetderive destination chainId and dest only
methodremoved
facilitatorPublicKeysremoved
extra.swapoptional dest, when it names an arbitrary destination asset

Derive top-level sourceAsset or sourceToken independently from the old application's source selection/deposit flow. Review ambiguous CAIP-19 or extra.swap values with the application owner; an agent should leave a focused TODO instead of guessing chain or token metadata.

Revised order flow

import { createSilentSwapClient } from '@silentswap/sdk';
import { parseUnits } from 'viem';
import type { WalletClient } from 'viem';
 
declare const account: `0x${string}`;
declare const recipient: `0x${string}`;
declare const walletClient: WalletClient;
 
const client = createSilentSwapClient({ walletClient });
 
const quote = await client.quote({
  privacy: true,
  inputAddress: account,
  sourceChainId: 1,
  sourceAsset: 'USDC',
  outputs: [
    {
      address: recipient,
      chainId: 8453,
      amount: parseUnits('10', 6),
    },
  ],
});
 
// Render quote.outputs/recipients, amounts, assets, fees, and expiresAt here.
const order = await client.placeOrder(quote);
const stop = client.trackOrderViaWebSocket(order.reference, console.log, console.error);
void stop;

There is no replacement authorization ceremony. The user reviews the RFQ in your trusted UI, then placeOrder handles an ERC-20 approval when necessary and submits the deposit. Unlike V2, tracking no longer returns a promise that resolves to the final status: it emits states through callbacks and immediately returns the teardown function. Refunds now return { refundTxHash } from client.executeRefund(privateReference).

Behavioral changes

  • V3 throws typed errors instead of returning [error, value] tuples.
  • Production baseUrl is optional and defaults to https://api.silentswap.com.
  • Public request terminology remains outputs[]; the SDK maps it to the private backend's unchanged recipients[] wire field.
  • privacy: true always requires inputAddress.
  • privacy: false uses Simple Bridge with the same quote/place/track lifecycle.
  • Integrator fees use USDC base units and require integratorAddress when positive.
  • Browser integrations must register their exact HTTPS production origin with SilentSwap support. Node and server integrations do not need CORS registration.

Remove persisted V2 nonces, SIWE tokens, facilitator wallets, authorization signatures, and WebSocket recovery data. Do not reinterpret them as V3 credentials.