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

@kaleidorg/wdk-protocol-swap-kaleidoswap

v1.0.0-beta.2

Published

WDK swap protocol plugin for KaleidoSwap — trade Bitcoin and RGB assets on the Lightning Network.

Readme

@kaleidoswap/wdk-protocol-swap-kaleidoswap

WDK SwapProtocol plugin for KaleidoSwap — trade Bitcoin and RGB assets (USDT, XAU₮) on the Lightning Network.

Overview

KaleidoswapProtocol extends the WDK SwapProtocol base class and implements the KaleidoSwap REST API flow: quote → order → deposit → fill. It integrates directly into the WDK account model and can be registered alongside any WalletManager.

WDK host app
  └── account.registerProtocol('bitcoin', 'kaleidoswap', KaleidoswapProtocol)
        └── KaleidoswapProtocol  ──HTTPS──▶  KaleidoSwap API
                                              /api/v1/market/quote
                                              /api/v1/swaps/orders
                                              /api/v1/swaps/orders/status

Key properties:

  • No extra runtime dependencies — uses native fetch
  • Asset list and trading pairs cached for 5 minutes
  • Amounts converted to/from raw integers using asset precision
  • Supports all RGB asset pairs available on KaleidoSwap

Installation

npm install @kaleidoswap/wdk-protocol-swap-kaleidoswap

Requires @tetherto/wdk-wallet as a peer dependency:

npm install @tetherto/wdk-wallet

Usage

import RlnWalletManager from '@kaleidoswap/wdk-wallet-rln'
import KaleidoswapProtocol from '@kaleidoswap/wdk-protocol-swap-kaleidoswap'

const manager = new RlnWalletManager(null, { nodeUrl: 'http://localhost:3001' })
const account = await manager.getAccount()

// Register the KaleidoSwap swap protocol on the account
account.registerProtocol('bitcoin', 'kaleidoswap', KaleidoswapProtocol, {
  baseUrl: 'https://api.staging.kaleidoswap.com'
})

// Get a quote
const quote = await account.quoteSwap('bitcoin', 'kaleidoswap', {
  fromAssetId: 'BTC',
  toAssetId: 'rgb:2dkSTbr-...',   // USDT on staging
  fromLayer: 'lightning',
  toLayer: 'lightning',
  fromAmount: 0.001                // 0.001 BTC
})

console.log(quote.tokenInAmount)   // raw sats in
console.log(quote.tokenOutAmount)  // raw USDT units out
console.log(quote.price)

// Place a swap order
const swap = await account.swap('bitcoin', 'kaleidoswap', {
  fromAssetId: 'BTC',
  toAssetId: 'rgb:2dkSTbr-...',
  fromLayer: 'lightning',
  toLayer: 'lightning',
  fromAmount: 0.001,
  receiverAddress: '<your-rgb-invoice>',
  receiverAddressFormat: 'rgb_invoice'
})

console.log(swap.orderId)
console.log(swap.depositAddress)    // send funds here to trigger the swap

// Poll order status
const status = await protocol.getOrderStatus(swap.orderId)
console.log(status.status)          // 'Waiting' | 'Filled' | 'Failed'

API

Constructor

new KaleidoswapProtocol(account, { baseUrl })

| Option | Required | Description | |--------|----------|-------------| | baseUrl | ✅ | KaleidoSwap API base URL |

quoteSwap(options)

Returns a price quote without creating an order.

quoteSwap({
  fromAssetId: string,     // asset protocol ID or ticker (e.g. 'BTC')
  toAssetId: string,       // asset protocol ID (e.g. 'rgb:2dkSTbr-...')
  fromLayer: string,       // 'lightning' | 'bitcoin'
  toLayer: string,
  fromAmount: number       // human-readable amount (e.g. 0.001 BTC)
}) → {
  tokenInAmount: bigint,   // raw units in
  tokenOutAmount: bigint,  // raw units out
  rfqId: string,           // quote ID (valid ~10 seconds)
  expiresAt: number,
  price: number,
  fee: bigint
}

swap(options)

Gets a fresh quote and creates a swap order. Returns a deposit address the caller must fund to trigger the swap.

swap({
  fromAssetId: string,
  toAssetId: string,
  fromLayer: string,
  toLayer: string,
  fromAmount: number,
  receiverAddress: string,         // where to receive the output asset
  receiverAddressFormat: string    // e.g. 'rgb_invoice' | 'lightning_invoice'
}) → {
  hash: string,                    // order ID
  orderId: string,
  depositAddress: string | null,   // fund this address to trigger the swap
  depositAddressFormat: string | null,
  tokenInAmount: bigint,
  tokenOutAmount: bigint,
  fee: bigint
}

getOrderStatus(orderId)

Polls an order's state.

getOrderStatus(orderId: string) → KaleidoswapOrder
// { id, status, from_asset, to_asset, created_at, ... }

Asset IDs

KaleidoSwap uses protocol IDs (RGB asset IDs or 'BTC') — not tickers:

| Asset | Layer | ID | |-------|-------|-----| | BTC | lightning | BTC | | USDT | lightning | rgb:2JEUOrsc-... (staging) | | XAU₮ | lightning | rgb:Vf25LAhx-... (staging) |

Use GET /api/v1/market/assets to discover IDs for any environment.

Caching

Asset and pair lists are cached in-memory for 5 minutes to reduce API calls during rapid quoting. Cache is per-instance.

Tests

npm test

12 unit tests covering quoteSwap, swap, getOrderStatus, and error paths.

License

Apache-2.0 — KaleidoSwap