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

@xian-tech/dex

v0.3.2

Published

Deterministic Xian DEX quoting and transaction planning

Readme

@xian-tech/dex

Dependency-free routing and transaction-planning primitives for DEX clients, agents, and browser applications. The package performs no RPC reads, key handling, simulation, signing, or submission.

The public surface has three layers:

  • protocol-neutral route enumeration driven by caller-supplied pool and quote adapters;
  • reusable constant-product pricing with numeric or string pool IDs and optional per-pool fees;
  • an explicit canonical Xian DEX v1 adapter for con_pairs / con_dex call shapes and fee-on-transfer behavior.

Canonical Xian DEX v1

import {
  deadlineFromNow,
  planXianDexV1ExactInExecution,
  selectBestXianDexV1ExactInRoute,
} from "@xian-tech/dex";

const quote = selectBestXianDexV1ExactInRoute({
  pairs,
  fromToken: "currency",
  toToken: "con_usdc",
  amountIn: 10,
  feeBps: 30,
  maxHops: 3,
});

if (!quote) throw new Error("No route");

const plan = planXianDexV1ExactInExecution({
  quote,
  recipient: agentAddress,
  allowance,
  approvalAmount: 10,
  slippageBps: 50,
  deadline: deadlineFromNow(15),
  routerContract: "con_dex",
  feeOnTransferTokens: knownFeeOnTransferTokens,
});

for (const call of plan.calls) await submitCall(call);

Pass routerContract to target another deployment of the same v1 contract interface. The canonical adapter chooses the supporting fee-on-transfer entrypoint for flagged source/destination tokens and rejects a flagged intermediate token.

Another DEX or Pool Model

Use the routing core with records and quote semantics owned by the integration:

import { selectBestExactInRoute } from "@xian-tech/dex/routing";

const quote = selectBestExactInRoute({
  pools,
  adapter: {
    poolId: (pool) => pool.address,
    tokens: (pool) => pool.assets,
    quoteExactIn: ({ pool, fromToken, amountIn }) =>
      quoteStablePool(pool, fromToken, amountIn),
  },
  fromToken: "currency",
  toToken: "con_usdc",
  amountIn: 10,
});

An execution adapter supplies the approval and swap ABI. The generic planner then applies slippage and allowance rules without assuming a router contract, function name, or keyword shape. See tests/execution.test.ts for a complete custom-ABI example.

Boundaries

  • Pool state and quote adapters are caller-owned.
  • All built-in quote math currently uses JavaScript numbers. Consumers needing arbitrary precision must validate against on-chain simulation before signing.
  • The generic router handles simple non-split exact-input routes. DEX-specific split routing or concentrated-liquidity traversal belongs in an adapter or a future focused module.
  • New DEX integrations should add adapters, not duplicate the routing core.

Validation

From the xian-js root:

npm run typecheck
npm run build
npm run test

Against a stack localnet with the canonical demo pool installed:

XIAN_PRIVATE_KEY="$XIAN_PRIVATE_KEY" npm run test:live:dex

The smoke test reads real reserves and signer fees, plans through the Xian DEX v1 adapter, submits any required approval plus the exact planned router call, and requires finalized successful receipts.