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

@deriverse/client-state

v1.0.24

Published

Client state management utilities for Deriverse SDK on Solana.

Downloads

230

Readme

@deriverse/client-state

TypeScript client-state utilities for Deriverse trading workflows on Solana.

This package is designed to work alongside @deriverse/kit and @solana/kit. It maintains in-memory client token and instrument state while processing Deriverse engine/log events.

Requirements

  • Node.js 20 or newer.
  • CommonJS runtime.
  • Runtime dependencies on @deriverse/kit and @solana/kit.

Installation

npm install @deriverse/client-state

What This Package Provides

  • createClientState(...) for initializing token and instrument state from a Deriverse Engine, Solana rpc, and selected instrIds.
  • State models for token balances, spot/perp order maps, PnL, fees/rebates, pending spot tokens, perp leverage, funding, loss coverage, lookup table data, sequence numbers, and per-instrument update slots.
  • Utility functions for in-order exposure, collateral value, withdrawable funds, effective leverage, liquidation price, good-health price, and health calculations.
  • ClientState.update(engine, slot, logsNotifications) for applying Deriverse engine/log events and invoking optional callbacks, including slot-aware deposit and withdraw handlers.

Minimal Usage

import { createClientState } from "@deriverse/client-state";

const state = await createClientState({
  engine,
  rpc,
  instrIds: [1, 2],
  onError: async (report, error) => {
    console.error(error, report);
  },
  onDeposit: (report, previousWithdraw, slot) => {
    console.log("deposit", report, slot);
  },
  onWithdraw: (report, previousDeposit, slot) => {
    console.log("withdraw", report, slot);
  }
});

if (!state) {
  throw new Error("Unable to initialize client state");
}

// Later, when a log notification arrives:
state.update(engine, slot, logsNotification);

createClientState(...) returns null when required engine state cannot be initialized, including missing instruments, existing spot state, or existing open perp orders for the requested instruments.

Solana Program IDs And Versions

| Network | Program ID | Version | | --- | --- | --- | | Mainnet | DRVSpZ2YUYYKgZP8XtLhAGtT1zYSCKzeHfb4DgRnrgqD | 1 | | Devnet | CDESjex4EDBKLwx9ZPzVbjiHEHatasb5fhSJZMzNfvw2 | 7 |

Build

npm run build

Publish

npm run build
npm pack --dry-run
npm publish

The prepack script runs npm run build automatically, but check the generated dist files before publishing.

License

Apache-2.0. See LICENSE.