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

@parqxchange/sdk

v0.3.0

Published

TypeScript SDK for Parquet — the perpetual futures DEX on Solana.

Readme

Parquet SDK

TypeScript client for the Parquet perpetuals protocol on Solana — Anchor program clients, account decoders, PDA helpers, dual-feed oracle resolution, and a typed indexer client.

Instruction builders return TransactionInstruction[] only. You build, sign, and send — the SDK never holds keys or sends transactions for you.

Installation

npm install @parqxchange/sdk
# or: yarn add @parqxchange/sdk / pnpm add @parqxchange/sdk

Depends directly on @solana/web3.js ^1.98 and @coral-xyz/anchor ^0.32 — match these versions in your app to avoid duplicate web3.js instances. Node >=18 for the indexer client (AbortSignal.timeout); discriminators are computed with @noble/hashes, so the main and /minimal entries carry no Node-only crypto — only /node requires Node.

Getting Started

import { Connection, PublicKey } from "@solana/web3.js";
import {
  PROGRAM_IDS_V4,
  IndexerClient,
  getMarketOracleFeeds,
  openPosition,
  PerpClient,
} from "@parqxchange/sdk";

const connection = new Connection("https://api.mainnet-beta.solana.com");

// 1. Read market stats from the indexer.
const indexer = new IndexerClient("https://api.parquet.exchange");
const stats = await indexer.getStats("aapl-usdc");
console.log(stats.markPrice, stats.openInterest);

// 2. Resolve the dual-feed oracle accounts for a market.
const oracleProgramId = new PublicKey(PROGRAM_IDS_V4.ORACLE_ADAPTER);
const marketId = new TextEncoder().encode("aapl-usdc"); // market id = ascii symbol
const { primaryFeed, secondaryFeed } = await getMarketOracleFeeds(
  connection,
  marketId,
  oracleProgramId,
);

// 3. Build an openPosition instruction (you sign + send it).
const perpClient = new PerpClient(program); // your Anchor Program for the perp-engine
const ixs = await openPosition(
  {
    perpClient,
    perpEngineId: new PublicKey(PROGRAM_IDS_V4.PERP_ENGINE),
    poolProgramId: new PublicKey(PROGRAM_IDS_V4.POOL_PROGRAM),
    oracleProgramId,
    marketId,
    primaryFeedAccount: primaryFeed,
    secondaryFeedAccount: secondaryFeed,
  },
  { signer: wallet.publicKey, signerUsdc: usdcAta },
  {
    side: { long: {} },
    sizeUsdc: 1_000_000_000n,      // 1,000 USDC notional (6 decimals)
    walletCollateral: 100_000_000n, // 100 USDC margin
    fromQueueAmount: 0n,
    acceptablePrice: 0n,            // ⚠️ 0 = no slippage guard — set a real limit in prod
    minOutputUsdc: 0n,
    positionNonce: 0n,
    referralCode: Array(32).fill(0),
  },
);
// → add ixs to a transaction, sign with `wallet`, and send.

Entry points

| Import | Use | |--------|-----| | @parqxchange/sdk | Full surface — program clients, decoders, events, indexer, PDA + oracle helpers. | | @parqxchange/sdk/minimal | Perp trading actions + getMarketOracleFeeds only (smaller dependency graph). | | @parqxchange/sdk/node | loadTradingKeypair and other Node/fs helpers. Never import from browser bundles. | | @parqxchange/sdk/risk/score | Health→risk-score + named-state ladder (riskScoreFromHealthMilli, RISK_STATES) only — tiny, dependency-free. |

API surface

  • Program clientsPerpClient, PoolClient, OracleClient, PriceFeedClient, FeeDistributorClient, StakingClient
  • Actions (build instructions) — openPosition, closePosition, updateMargin, addLiquidity, removeLiquidity, crankFundingRate
  • Account resolversresolveOpenPositionAccounts, resolveClosePositionAccounts, resolveUpdateMarginAccounts, resolveLiquidityAccounts
  • Unified-LP-pool (category) helpersresolveCategoryTradeAccounts, categoryBuilderArg for markets backed by a shared CategoryPool (the consolidated equity-us pool)
  • OraclegetMarketOracleFeeds, clearMarketOracleFeedsCache
  • DecodersdecodePosition, decodeMarketState, decodePoolState, decodeCategoryPool, decodeMarketRisk, decodeOrder, … and identifyAccountType (poolShapeOf distinguishes a legacy PoolState from a CategoryPool)
  • EventsParquetEventEmitter, decodeAnchorEvent
  • IndexerIndexerClient (getStats)
  • AuthregisterTradingKey / revokeTradingKey (+ buildRegisterTradingKeyIx / buildRevokeTradingKeyIx)
  • Session keysgenerateSessionKey, buildEnableSession, signWithSession (ephemeral delegate keys for delegated / one-click trading)
  • Risk scoreriskScoreFromHealthMilli, riskStateFromHealthMilli, RISK_STATES (also a standalone @parqxchange/sdk/risk/score entry)
  • Deposit (Jupiter)getSwapQuote, buildSwapTransaction (keyless swap-to-USDC; returns an unsigned transaction)
  • Constants / utilsPROGRAM_IDS_V4, withComputeBudget, buildVersionedTransaction, PDA helpers

Decoding on-chain errors

import { decodeError, isParquetError, ParquetError } from "@parqxchange/sdk";

try {
  await program.methods.openPosition(/* … */).rpc();
} catch (err) {
  // Pass the caught error OBJECT (Anchor error or RPC "custom program error: 0x…").
  if (isParquetError(err, ParquetError.BelowMinCollateral)) {
    // handle insufficient collateral
  }
  console.log(decodeError(err)); // → ParquetError code, or null
}

decodeError takes the caught error object, never a raw number.

Production notes

  • Set slippage guards. acceptablePrice / minOutputUsdc of 0n disable protection.
  • Always pass both oracle feeds from getMarketOracleFeeds (or a resolver) on open/close — never hardcode feed PDAs.
  • Keep loadTradingKeypair server-side (/node entry) so bundlers don't pull fs into the browser.
  • decodeAnchorEvent returns null for unknown/malformed/truncated payloads — validate at app boundaries.

Documentation

Full reference, market ids, and the complete production checklist: docs.parquet.exchange/developer/sdk

License

MIT