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

@moonpay/wdk-protocol-swidge-moonpay-trade

v0.1.2

Published

WDK Swidge protocol implementation for MoonPay Trade

Readme

@moonpay/wdk-protocol-swidge-moonpay-trade

Built with WDK npm License

WDK Swidge protocol module for MoonPay Trade. Implements ISwidgeProtocol from @tetherto/wdk-wallet v1.0.0-beta.9, wrapping MoonPay's SwapsXYZ API swap and bridge infrastructure.

Installation

npm install @moonpay/wdk-protocol-swidge-moonpay-trade

Usage

import MoonPayTradeSwidgeProtocol from '@moonpay/wdk-protocol-swidge-moonpay-trade';

const protocol = new MoonPayTradeSwidgeProtocol(account, {
  apiKey: process.env.SWAPS_XYZ_KEY,
});

// Discover supported tokens
const chains = await protocol.getSupportedChains();
const tokens = await protocol.getSupportedTokens({ fromChain: 1 }); // Ethereum

// Quote
const quote = await protocol.quoteSwidge({
  fromToken: '1:0xdAC17F958D2ee523a2206206994597C13D831ec7',   // USDT on Ethereum
  toToken: '8453:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', // USDC on Base
  fromTokenAmount: 10_000_000n, // 10 USDT (6 decimals)
});

// Execute (requires full IWalletAccount)
const result = await protocol.swidge({ /* same options */ });

// Poll status
const status = await protocol.getSwidgeStatus(result.id);

See examples/e2e.mjs for a complete runnable example.

Token identifiers

Tokens are identified as "<chainId>:<tokenAddress>". Use getSupportedTokens() to discover valid identifiers:

const tokens = await protocol.getSupportedTokens({ fromChain: 1 });
// e.g. { token: '1:0xA0b8...', chain: 1, symbol: 'USDC', decimals: 6 }

Configuration

| Option | Type | Required | Default | Description | |---|---|---|---|---| | apiKey | string | ✅ | — | x-api-key credential for SwapsXYZ API | | baseUrl | string | | https://api-v2.swaps.xyz | SwapsXYZ API base URL | | maxProtocolFeeBps | number \| bigint | | — | Reject swidge if protocol fee exceeds this bps | | maxNetworkFeeBps | number \| bigint | | — | Reject swidge if network fee exceeds this bps | | cacheTtlMs | number | | 600000 (10 min) | Token/chain list cache TTL. Set 0 to disable. |

Status mapping

| SwapsXYZ API status | SwidgeStatus | |---|---| | pending, submitted, approval_*, payout_created | pending | | success, completed | completed | | failed | failed | | requires refund, refund_requested | refund-pending | | refunded | refunded | | expired | expired | | cancelled | cancelled |

Fee mapping

| SwapsXYZ API field | SwidgeFeeType | Notes | |---|---|---| | applicationFee + protocolFee | protocol | MoonPay spread + underlying protocol fee (both summed) | | bridgeFee | network | Gas / bridge infrastructure cost |

Error types

| Class | Thrown when | |---|---| | AccountRequiredError | swidge() called without a full IWalletAccount | | FeeLimitExceededError | Fee guard (maxProtocolFeeBps / maxNetworkFeeBps) exceeded; .feeType, .actualBps, .limitBps available | | ProviderApiError | SwapsXYZ API returns a non-2xx response; .endpoint, .status, .responseBody available | | UnknownStatusError | getSwidgeStatus() receives an unrecognised status string; .rawStatus available | | InvalidTokenIdError | Token identifier is not in "<chainId>:<address>" format; .tokenId available |

Supported chains and tokens

Chains and tokens are dynamically discovered from the SwapsXYZ API at runtime:

const chains = await protocol.getSupportedChains(); // all chains
const tokens = await protocol.getSupportedTokens(); // all tokens
const ethTokens = await protocol.getSupportedTokens({ fromChain: 1 }); // Ethereum only

Results are cached for 10 minutes by default (configurable via cacheTtlMs).

Support