@anywalletkit/protocol-swap2-chainflip

中文文档
0.4.4发布于 2026/11/07Apache-2.0TypeScriptESM + CJS构建来源已验证近 30 天下载 2294

Chainflip vault swaps for the swap2 engine: native BTC / ETH / SOL / TRX and USDC / USDT across Ethereum, Arbitrum, Solana, Tron and Bitcoin through Chainflip's public backend (its own broker, 0 bps, no account). Sources in this release: Ethereum, Arbitru

原始使用文档
文档目录7 节
  1. Install
  2. Why vault swaps and not deposit channels
  3. What is checked before signing
  4. Minimums
  5. Status
  6. Behind remoteProvider
  7. Config

@anywalletkit/protocol-swap2-chainflip

npm

Chainflip vault swaps as a swap2 provider: native BTC / ETH / SOL / TRX and USDC / USDT between Ethereum, Arbitrum, Solana, Tron and Bitcoin, priced by Chainflip's JIT AMM. Quotes and encoding come from Chainflip's public backend (chainflip-swap.chainflip.io). You need no broker account, there is no API key, and the commission is 0 bps.

Install

npm install @anywalletkit/protocol-swap2-chainflip @anywalletkit/core
# or: pnpm add @anywalletkit/protocol-swap2-chainflip @anywalletkit/core  ·  yarn add @anywalletkit/protocol-swap2-chainflip @anywalletkit/core

On npm: @anywalletkit/protocol-swap2-chainflip, published from the release workflow with provenance.

import {chainflipProvider} from "@anywalletkit/protocol-swap2-chainflip/provider";
import {RouterSwap2Protocol} from "@anywalletkit/protocol-swap2-router/swap2/router";

const swap2 = new RouterSwap2Protocol(tronAccount, {fromChain: "tron:728126428", providers: [chainflipProvider()]});
const res = await swap2.swap2({fromToken: "USDT", toToken: "USDC", toChain: 42161, fromTokenAmount: 20_000_000n});
const status = await swap2.getSwap2Status(res.id); // pending → depositReceived → completed (+ egress tx) | refunded
From (sources)How the swap is sent
Ethereum, ArbitrumxSwapNative / xSwapToken on the Chainflip Vault; tokens get an exact approval to the Vault first
TronTRC-20 USDT (or TRX) to the Vault, with the swap as a binary note in raw_data.data (memoEncoding: "hex")

Destinations: Ethereum (ETH, USDC, USDT, WBTC), Arbitrum (ETH, USDC, USDT), Solana (SOL, USDC, USDT), Tron (TRX, USDT) and Bitcoin (BTC). Solana and Bitcoin as sources are not wired yet.

Why vault swaps and not deposit channels

A deposit channel is an address that Chainflip's broker opens for you. The client cannot prove where that address forwards the funds: the backend has no lookup by deposit address. With a vault swap, the swap parameters are in the transaction itself — calldata on EVM, the note on Tron — so the wallet can decode and check them before signing. A Tron vault swap also skips the channel's ingress cost (live 2026-10-20: $20 USDT → 19.48 USDC through the Vault vs −19.5 % through a channel).

What is checked before signing

The provider never forwards the encoder's output blindly. getQuote decodes it (SCALE VersionedCfParameters V1, the Tron note, or the EVM Vault ABI) and refuses the quote unless all of the following hold:

  • the target is the known Vault for the source chain (CF_VAULTS). On Tron it must be a TRC-20 transfer(Vault, amountIn) of the quoted token;
  • the destination chain id, output asset id and destination address bytes match the request (EVM hex, Tron 20 B, Solana 32 B, BTC as ASCII);
  • the refund address is the sender, and the swap is fill-or-kill: minPriceX128 ≥ ceil(minOut · 2^128 / amountIn), retry ≤ 600 blocks, and the oracle slippage guard is what we asked for;
  • there is no DCA, no boost, no broker commission and no affiliates.

The minimum output is either the caller's minAmountOut or the expected amount less the slippage (slippageBps, or the backend's recommendation when none is given). If the price can't be met within the retry window, Chainflip refunds the input to the sender.

Minimums

These are Chainflip's per-asset ingress minimums. A smaller amount gets no quote. Ethereum USDC/USDT: $20. Arbitrum, Solana and Tron stables: $10. BTC: 40 000 sat. TRX: 30.

Status

trackIntent reads GET /v2/swaps/{sourceTxHash}:

  • 404 means the swap is not seen yet (pending);
  • RECEIVING, SWAPPING and SENDING mean the deposit was received;
  • COMPLETED returns the destination tx (swapEgress.txRef);
  • FAILED returns refunded if a refund egress exists, otherwise failed.

The endpoint rate-limits (429); the provider retries once.

Behind remoteProvider

When the provider runs on your server, spread its pins into the app's stub: remoteProvider({name: "chainflip", baseUrl, ...chainflipPins}). The engine then lets the EVM route call and approve only the Chainflip Vault in CF_VAULTS, never an address the backend names; without the pins the stub gets no EVM calldata route (fail closed). The pins carry verifyQuote: chainflipVerifyQuote, the provider's own decode run on the device: the EVM vault call, or the Tron note, must name the app's destination, refund address and a minimum price that guarantees the quoted minimum. A Tron vault swap is a send to the Tron Vault, so the pins also open the stub to that deposit route (depositAddressRoutes); the verifier pins the Vault it pays.

Config

chainflipProvider({
  enabled: true,                    // default
  apiUrl: "https://chainflip-swap.chainflip.io",
  maxOraclePriceSlippageBps: 100,   // oracle guard in the fill-or-kill params; default = the quote's recommendation, null = off
})

版本与发布记录

@anywalletkit/protocol-swap2-chainflip 共发布 15 个版本,首次发布于 2026/10/25;过去 12 个月发布了 15 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.4.4latest2026/11/07今天
0.4.32026/11/052 天前
0.4.22026/11/035 天前
0.4.12026/10/308 天前
0.4.02026/10/309 天前
0.3.02026/10/2910 天前

关于 @anywalletkit/protocol-swap2-chainflip 的常见问题

@anywalletkit/protocol-swap2-chainflip 是什么?

Chainflip vault swaps for the swap2 engine: native BTC / ETH / SOL / TRX and USDC / USDT across Ethereum, Arbitrum, Solana, Tron and Bitcoin through Chainflip's public backend (its own broker, 0 bps, no account). Sources in this release: Ethereum, Arbitru

如何安装 @anywalletkit/protocol-swap2-chainflip?

在项目目录运行 npm install @anywalletkit/protocol-swap2-chainflip,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@anywalletkit/core(0.8.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@anywalletkit/protocol-swap2-chainflip 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@anywalletkit/protocol-swap2-chainflip 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@anywalletkit/protocol-swap2-chainflip 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@anywalletkit/protocol-swap2-chainflip 可以商用吗?

@anywalletkit/protocol-swap2-chainflip 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@anywalletkit/protocol-swap2-chainflip 的下载量有多少?

根据 npm 官方下载统计,@anywalletkit/protocol-swap2-chainflip 在 2026/10/06 – 2026/11/04 这 30 天内被下载 2,294 次,日均约 76 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@anywalletkit/protocol-swap2-chainflip 还在维护吗?

最新版本 0.4.4 发布于 2026/11/07(今天);至今共发布 15 个版本,其中过去 12 个月发布了 15 个;首次发布于 2026/10/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。