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

pbcurve

v1.1.5

Published

Pizza's impl agnostic bonding curve lib with ts bindings

Readme

pbcurve

Build & publish

The npm package ships both the TypeScript wrapper (dist) and the wasm-bindgen artifacts generated by wasm-pack (native/pkg for Node, native/pkg-web for browsers).

  • Run npm run build to produce all outputs locally (node wasm, web wasm, TS builds).
  • npm pack/npm publish trigger the same build through the prepack script, ensuring the JS glue + .wasm blobs are always included in the tarball.
  • Verify the contents with npm pack --dry-run after a build.

Usage

Node / SSR (CommonJS or ESM)

import { Curve } from "pbcurve/node"; // or `const { Curve } = require("pbcurve");`

const DECIMALS = 10n ** 8n;
const cfg = {
  total_supply: 1_000_000n * 10n ** 8n,
  sell_amount: 500_000n * 10n ** 8n,
  vt: 250_000n * 10n ** 8n,
  mc_target_sats: 10_000_000n * 10n ** 8n,
};

const curve = (await Curve.create(cfg)).expect("curve init failed");
const price = curve.snapshot(0n).expect("snapshot").x;
const raised = curve.cumulativeQuoteToStep(100_000n * DECIMALS).expect("quote");

Browser / Edge runtimes

import { initWebCurveWasm, Curve } from "pbcurve/web";

await initWebCurveWasm(); // optional: pass your own fetch/URL/Response

const DECIMALS = 10n ** 8n;
const cfg = {
  total_supply: 1_000_000n * 10n ** 8n,
  sell_amount: 500_000n * 10n ** 8n,
  vt: 250_000n * 10n ** 8n,
  mc_target_sats: 10_000_000n * 10n ** 8n,
};

const curve = (await Curve.create(cfg)).expect("curve init failed");
const quote = curve.quoteInGivenAssetOut(0n, 1_000n * 10n ** 8n).expect("quote");
const raised = curve.cumulativeQuoteToStep(25_000n * DECIMALS).expect("quote");

initWebCurveWasm accepts anything wasm-pack’s loader does (URL, Request, Response, or an ArrayBuffer/Module), so you can hook it into your bundler/asset pipeline easily. Subsequent Curve.create calls reuse the initialized module automatically.

Helpers

Call curve.mcSatsAtStep(step) to estimate the FDV (in sats) at any point on the curve. It runs inside the wasm core so you avoid duplicating the math in JS/TS.

Next.js / Turbopack (fetching WASM over HTTP)

Next.js' Turbopack loader still cannot bundle .wasm modules that wasm-pack emits. The package therefore ships a pbcurve/next entry point that lazily fetches the WebAssembly blob at runtime:

  1. When you install pbcurve, a postinstall hook copies native/pkg-web/curve_wasm_bg.wasm into your app's existing public/pbcurve/ directory (it only runs if a public/ folder is present, so Node-only apps are untouched). Commit that file so deployments can serve /pbcurve/curve_wasm_bg.wasm. If you disable npm scripts or do not have a public/ directory, copy the file manually: cp node_modules/pbcurve/native/pkg-web/curve_wasm_bg.wasm public/pbcurve/.
  2. Import from pbcurve/next and pass the public URL of the wasm file each time you create a curve (usually /pbcurve/curve_wasm_bg.wasm). The factory fetches + instantiates the module once and reuses it afterwards.
import { Curve } from "pbcurve/next";

const DECIMALS = 10n ** 8n;
const cfg = {
  total_supply: 1_000_000n * DECIMALS,
  sell_amount: 500_000n * DECIMALS,
  vt: 250_000n * DECIMALS,
  mc_target_sats: 10_000_000n * DECIMALS,
};

const wasmUrl = "/pbcurve/curve_wasm_bg.wasm";
const curve = (
  await Curve.create(cfg, {
    wasmUrl,
    // optional: fetch, requestInit
  })
).expect("curve init failed");
const price = curve.snapshot(0n).expect("snapshot").x;

Pass a custom fetch implementation (and requestInit) if you need authenticated fetches or want to run the loader from within a different runtime like Next.js Route Handlers. Relative URLs are resolved against window.location.origin, so on the server (or during next dev’s SSR pass) you must provide an absolute wasmUrl or guard the initialization so it only runs in the browser.