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

@miradexio/client

v0.1.2

Published

Headless crypto swap SDK — BTC/XMR atomic swaps, THORChain, Chainflip, NEAR Intents. Works in Node.js, browsers, React Native, and bots.

Downloads

345

Readme

@miradexio/client

TypeScript SDK for cross-chain swaps. Runs in-process in the browser or in Node, holding keys and signing locally. The server is untrusted: every state claim is verified on-chain. For BTC↔XMR the SDK runs the full atomic-swap drive loop itself; for THORChain, Chainflip, and NEAR Intents it verifies the deposit binding against the upstream's own infrastructure (THORNode/Midgard, Chainflip broker, 1Click).

Quick start

pnpm add @miradexio/client
# or
npm install @miradexio/client
import { MiradexEngine, type PlatformAdapter } from '@miradexio/client';

const platform: PlatformAdapter = /* see PlatformAdapter below */;

const engine = new MiradexEngine(
  {
    apiUrl: 'https://api.miradex.io/',
    network: 'mainnet',
    slippageBps: 300,
  },
  platform,
);

engine.on('state', (s) => {
  console.log(s.activeFlow?.kind, s.activeFlow?.snapshot.phase);
});

// BTC ↔ XMR (atomicswap)
await engine.startAtomicSwap({
  amount: '0.01',
  destAddress: '8...',
  refundAddress: 'bc1q...',
});

// Routed providers (thorchain, chainflip, near_intents)
const { quotes } = await engine.apiClient.getQuotes({
  from: 'BTC',
  to: 'ETH',
  amount: '0.01',
});
await engine.startSwap({
  fromToken: 'BTC',
  fromChain: 'bitcoin',
  toToken: 'ETH',
  toChain: 'ethereum',
  amount: '0.01',
  destAddress: '0x...',
  refundAddress: 'bc1q...',
  selectedQuote: quotes[0],
});

Providers

atomicswap — BTC ↔ XMR via the btc-xmr two-curve atomic-swap protocol. BTC locks into a 2-of-2 P2WSH; adaptor signatures tie Alice's BTC redemption to revealing the Monero scalar Bob needs to sweep. Refund is timelocked Bitcoin script and the SDK builds and broadcasts it without the server.

thorchain — 12 connected chains (BTC, ETH, BSC, AVAX, BASE, SOL, TRON, XRP, …) via THORChain Asgard TSS vaults. The SDK reads the active vault list from THORNode and Midgard directly.

chainflip — Bitcoin, Ethereum, Arbitrum, Solana, Polkadot, and Polkadot Assethub via per-swap deposit channels with destination and Fill-or-Kill refund addresses bound at channel creation. The SDK reads the channel from the broker and confirms.

near_intents — roughly 45 chains via NEAR Intents 1Click solver settlement. The SDK reads intent status from 1Click directly.


The SDK surface

The default import is @miradexio/client. Sub-path exports cover atomic-swap-only, verification-only, and bundler-friendly subsets; see the exports field in package.json.

PlatformAdapter

The engine is decoupled from host I/O. Implement PlatformAdapter for your environment; see the miradex-web browser adapter for a reference.

Direct entry points

Drive flows without the engine:

import { runAtomicSwap, SwapExecutor } from '@miradexio/client';

// Atomic swap, low-level:
await runAtomicSwap({
  api: apiClient,
  params: { amount: '0.01', destAddress: '8...', refundAddress: 'bc1q...', network: 'mainnet' },
  callbacks: { onProgress, onDepositRequired, saveKeystore, loadKeystore },
  signal: abortController.signal,
});

// Routed swap, low-level:
const executor = new SwapExecutor(apiClient);
const result = await executor.executeSwap({
  from: 'BTC', to: 'ETH', amount: '0.01',
  destAddress: '0x...', refundAddress: 'bc1q...',
  provider: 'thorchain',
});

Security model

The server is untrusted. Bitcoin state is verified against Electrum servers, Monero against monerod RPC servers, THORChain against THORNode + Midgard, Chainflip against the broker, NEAR Intents against 1Click.


Configuration

EngineConfig

The first argument to new MiradexEngine:

| Field | Type | Default | | --- | --- | --- | | apiUrl | string | required | | network | 'mainnet' \| 'testnet' \| 'regtest' | 'mainnet' | | slippageBps | number | 100 (1.00%) | | apiTimeout | number | 60_000 ms | | apiMaxRetries | number | 3 | | monerodNodes | readonly string[] | network default | | fetchFn | typeof fetch | globalThis.fetch |

Defaults are exported from src/lib/default-config.ts.


Build

pnpm install
pnpm -F @miradexio/client build       # tsc → dist/
pnpm -F @miradexio/client typecheck
pnpm -F @miradexio/client test

License

MIT. See LICENSE.