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

@routerx.exchange/sdk

v0.1.12

Published

RouterX frontend SDK — EIP-1193 quote & swap against RXRouter

Readme

@routerx.exchange/sdk

RouterX frontend SDK: quote and swap against on-chain RXRouter via an EIP-1193 provider (no routerx-api HTTP).

Provider configuration

provider is optional for read-only operations. RouterX selects its read provider in this order:

  1. provider (an EIP-1193 wallet provider)
  2. rpcUrls (your HTTPS JSON-RPC endpoints)
  3. Curated built-in public RPC URLs

Public RPCs are best-effort only; supply rpcUrls for production reliability. A wallet is still required for approve and swap. You can connect or replace a wallet later with setProvider(provider), clear it with setProvider(undefined), and update the RPC fallback with setRpcUrls(urls).

Install

npm install @routerx.exchange/sdk

Quote before wallet connect

import { RouterX, NATIVE_PLACEHOLDER } from '@routerx.exchange/sdk';

const rx = new RouterX({
  chainId: 'base',
  rpcUrls: ['https://your-base-rpc.example'],
});

const quote = await rx.swap.quote({
  tokenIn: NATIVE_PLACEHOLDER,
  tokenOut: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
  amountIn: '1000000000000000000',
});

// When the user connects a wallet:
rx.setProvider(window.ethereum);

Quick start

import { RouterX, NATIVE_PLACEHOLDER } from '@routerx.exchange/sdk';

const rx = new RouterX({ provider: window.ethereum, chainId: 8453 });

const q = await rx.swap.quote({
  tokenIn: NATIVE_PLACEHOLDER,
  tokenOut: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
  amountIn: '1000000000000000000',
});

const { tx, hash } = await rx.swap.swap({
  tokenIn: q.tokenIn,
  tokenOut: q.tokenOut,
  amountIn: q.amountIn,
  to: account,
});

For ERC-20 inputs on RouterX chains, prefer swapWithPermit2 (approve Permit2 once, then EIP-712 SignatureTransfer + swapNoSplit*WithPermit2). Native tokenIn still uses swap.

await rx.swap.swapWithPermit2({
  tokenIn: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
  tokenOut: '0x4200000000000000000000000000000000000006',
  amountIn: '1000000',
  to: account,
  // nonce / deadline optional — SDK picks an unused Permit2 nonce and a 20-minute deadline
});

chainId accepts a number (e.g. 8453) or a chain code (e.g. 'base').

Limit orders (Maker)

The default Maker API is https://limitorder-api.routerx.exchange. Override it with limitOrderApiUrl when using another deployment:

const rx = new RouterX({
  chainId: 8453,
  provider: window.ethereum,
  limitOrderApiUrl: 'https://limitorder-api.routerx.exchange',
});

Creating an order does not approve tokens automatically. Approve the Maker asset for the chain's limit-order protocol, then create and submit the signed order:

await rx.limitOrder.approve({ token: makerAsset, amount: makingAmount });

const created = await rx.limitOrder.create({
  makerAsset,
  takerAsset,
  makingAmount,
  takingAmount,
  maker: account,
});

Use cancelOrders({ orderHashes }) for gasless cancellation. For a hard on-chain cancellation, pass the full Maker order to cancelOrderOnChain(order).

buildOrder/create leave getMakerAmount/getTakerAmount empty (0x) by default, which the limit-order protocol treats as exact-fill only — the order must be filled in full in a single fill. Pass partialFill: true to enable linear partial fills (sets AmountCalculator getters via encodeLinearAmountGetters, also exported from the package). You can still pass custom getMakerAmount/getTakerAmount calldata explicitly; explicit getters always win. DCA orders set these getters automatically since they always fill partially across many swaps.

DCA (experimental)

dca is experimental: its create/list submission and listing paths call planned API endpoints (/v1/dca/orders) that may not be deployed on every environment yet, and request/response shapes may still change. cancelOrders currently reuses the plain limit-order cancel endpoints (/v1/orders/cancel-sign, /v1/orders/cancel) — there is no dedicated DCA cancel endpoint yet, so cancellation may 404 or behave unexpectedly until the API adds first-class DCA cancel support. Endpoint paths and payload shapes for this module should be expected to change without a major version bump while it remains experimental.

DCA requires an executor address, supplied as executorAddress when constructing RouterX or returned by the limit-order API chain configuration. It reuses the same limit-order approval and gasless cancellation methods.

API

| Namespace | Method | Description | | --- | --- | --- | | swap | quote | On-chain quote (findBestPathWithGas → fallback findBestPath) | | swap | buildSwapTx | Quote + build an unsigned swap transaction | | swap | getAllowance / approve | ERC-20 allowance (spender = Router) | | swap | swap | Send swap, optionally with auto-approve | | swap | getPermit2TypedData / buildSwapTxWithPermit2 | Permit2 typed data + *WithPermit2 calldata | | swap | getPermit2Allowance / approvePermit2 | ERC-20 allowance (spender = Permit2) | | swap | swapWithPermit2 | Approve Permit2 (optional) + sign + send *WithPermit2 | | limitOrder | buildOrder / getSignMessage / signOrder | Build and sign Maker orders | | limitOrder | create / createFromOrder / submitOrder | Submit Maker orders | | limitOrder | list / activeMakingAmount | Query Maker orders and active amounts | | limitOrder | cancelOrders / cancelOrderOnChain | Gasless or hard cancellation | | limitOrder | getAllowance / approve | LOP allowance and approval | | dca (experimental) | buildOrder / buildSchedule / create / list | Build, sign, submit, and list DCA orders | | dca (experimental) | cancelOrders / getAllowance / approve | Shared LOP cancellation and approval |