npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@anywalletkit/protocol-swap2-chainflip

v0.4.1

Published

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

Readme

@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, Arbitrum | xSwapNative / xSwapToken on the Chainflip Vault; tokens get an exact approval to the Vault first | | Tron | TRC-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
})