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

@hadron-fi/sdk-v2

v0.4.2

Published

TypeScript client SDK for the v2 Hadron AMM program on Solana.

Readme

@hadron-fi/sdk-v2

TypeScript client SDK for the v2 Hadron program on Solana.

[!WARNING] We strongly encourage you to use a Hadron SDK — this @hadron-fi/sdk-v2 TypeScript package or the hadron-sdk-v2 Rust crate — not the raw IDL — to interact with Hadron. Hadron is a pinocchio (non-Anchor) program with a custom, non-Borsh instruction wire format (1-byte discriminators, length-prefix-free vecs with explicit count args, length-based optional trailing fields, and empty account discriminators). A generic Anchor/IDL/Borsh client will mis-encode instructions and can produce malformed transactions. The IDL is intended for structural/read use (explorers, account decoding, Surfpool); to build and send instructions, use a Hadron SDK (build* functions / the Hadron class in TypeScript, or the Rust crate).

Install

npm install @hadron-fi/sdk-v2 @solana/web3.js @solana/spl-token

@solana/web3.js and @solana/spl-token are peer dependencies; install them alongside.

Quickstart

Hadron is a Programmable Prop AMM: each pool prices from an oracle midprice, a spread, and curves you write. This SDK targets the upgraded program (V2, live on mainnet since 2026-11-23).

import { Hadron, PoolState, priceToQ32, toAtoms } from "@hadron-fi/sdk-v2";

const DEC = { base: 9, quote: 6 };   // SOL / USDC: from your own config

// 1. create, with swaps off: keys handed over and fee accounts made in the same transaction
const { instructions, poolAddress } = Hadron.initialize(admin.publicKey, {
  mintX: SOL, mintY: USDC, authority: admin.publicKey,
  initialMidpriceQ32: priceToQ32(121.05, DEC),
  maxCurvePoints: 32,
  setup: { quotingAuthority: crank.publicKey, feeRecipient: await Hadron.fetchFeeRecipient(connection) },
});
await send(instructions, [admin]);   // your own code: sign and send as one transaction

// 2. load with your decimals (checked against the mints), price it, fund it
const pool = await Hadron.load(connection, poolAddress, { decimals: DEC });
await send([
  pool.updateMidprice(crank.publicKey, { midpriceQ32: priceToQ32(121.05, DEC) }),
  pool.deposit(admin.publicKey, { amountX: toAtoms(200, DEC.base), amountY: toAtoms(24_000, DEC.quote) }),
], [admin, crank]);

// 3. a design in tokens and bps: bids sized in base, asks in quote, depth that refills each slot
const groups = await pool.set(crank.publicKey, {
  use: "depth", shape: "step",
  bids: [{ bps: 5, base: 0 }, { bps: 15, base: 20 }, { bps: 40, base: 70 }, { bps: 40, base: 190 }],
  asks: [{ bps: 5, quote: 0 }, { bps: 15, quote: 2_422 }, { bps: 40, quote: 8_484 }, { bps: 40, quote: 23_068 }],
  refill: { basePerSlot: 2, quotePerSlot: 240 },
});
const check = await pool.preview(groups);   // the program's checks and the resulting book; sends nothing
console.table(check.book);
for (const g of groups) await send(g, [crank]);

// 4. go live (only the pool authority can)
await send([pool.setPoolState(admin.publicKey, { newState: PoolState.Initialized })], [admin]);

New pools start in RejectSwaps: deposits work, swaps don't, until the authority sets Initialized.

Does Hadron.initialize's list fit one transaction? A legacy transaction holds 1,232 bytes. The list has one allocate per 10,240 bytes of prefabs (82 bytes each; the default prefabs need one). Signers are payer and creator (default authority), plus authority when setup changes a role or limit or initialPoolState isn't RejectSwaps; each distinct signer is 96 bytes. Measured with payer paying the fee and no compute-budget instructions (two add 52 bytes):

| | 1 signer | 2 signers | 3 signers | |---|---|---|---| | no setup | up to 6 allocates (61,440 B of prefabs) | up to 5 (51,200 B) | | | full setup (all four roles, staleness, guard, fee accounts) | up to 3 (30,720 B) | 1 (10,240 B) | never (1,251 B with the default prefabs) |

Over the limit, send two transactions: the allocates first, then the rest. Allocates alone fit 12 to a transaction (11 with two signers). The quickstart above (one signer, quotingAuthority and feeRecipient, one allocate) is 923 bytes.

Designs

pool.set(authority, design) takes one of the dashboard's designs and returns the instructions, grouped by transaction. A change too big for one transaction is staged through the standby slot, so the live book never has half of it.

| use | What it is | |---|---| | prop | Price impact by trade size; every trade reads the whole curve. | | depth | Depth that is used up and comes back at refill per slot. | | range | Liquidity between two prices, no crank, held in bins like a DLMM's: the bin at the pool price trades at it. Add or remove liquidity through set(design, { deposit }) / { withdraw }, never a bare withdrawal (that leaves takers an arbitrage); snapshot().rangeOffCurve and rangePrice say when to set it again. | | custom | All four curves, in your own factors. |

Also: pool.preview(groups), pool.snapshot() (state, price age, balances, depth used, guard), set(..., { slot }) and switchTo(authority, slot, { refill }) for stored designs, pool.rangeDeposit, Hadron.fromOrders (venue orders into depth points), Hadron.fromRecipe / Hadron.toRecipe (the dashboard's strategy.json). These calls need load({ decimals }).

Spread triggers

Charge or discount a swap by what its transaction carries: who signed it, which accounts it names, and the flow Jupiter attests when it routes to the pool.

import { ANY_PROGRAM, JUPITER_EVENT_AUTHORITY, JUPITER_SIGNED_FLOWS } from "@hadron-fi/sdk-v2";

await send([await pool.addSpreadTriggers(admin.publicKey, [
  // 15 bps more when this wallet signs
  { account: BOT, programId: ANY_PROGRAM, spreadBps: 15, signer: true },
  // 20 off for jup.ag or any signed Jupiter flow, counted once
  { spreadBps: -20, whenAny: [{ jupiterFlow: JUPITER_SIGNED_FLOWS }, { account: COSIGNER, programId: ANY_PROGRAM, signer: true }] },
])], [admin]);

0.4.1's rows ({ account, programId, spreadBps }) work as before. Also removeSpreadTriggers, getSpreadTriggers, explainSpread(signature).

Raw builders

Every instruction has a build* function taking atoms and Q32, and the Hadron class has a method for each. They don't need decimals. New in 0.4.2: refill (updateRefillConfig, refillPriceDepth), Integrated curves (setCurve({ sizeMode })), transfer-hook accounts ({ hookAccounts } as the last argument of deposit, withdraw, swap and closePoolInstructions; resolveTransferHookAccounts), swap destinations, staleness up to 65,535 slots. See CHANGELOG.md for everything new and the seven differences from 0.4.1.

The package also exposes:

  • decode* decoders for every on-chain state account
  • PDA derivation helpers (getConfigAddress, derivePoolAddresses, ...)
  • Converters (priceToQ32, q32ToPrice, toAtoms, fromAtoms) and fixed-point helpers (toQ32, fromQ32, spreadBpsToQ32)

Program ID

HADRoNbLovyqhCsocfYQYB7QdfCAAinN9HTePvBCVDQ8

Deployed on Solana mainnet.

License

Apache-2.0.