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

@surged/sdk

v0.3.1

Published

Pricing formula, quotes, calldata encoders and ABIs for Surged, the token launchpad on Arc.

Readme

@surged/sdk

TypeScript for Surged, the token launchpad on Arc: the pricing formula, quotes with the snipe tax, calldata encoders, the bundle consent, unit helpers and the generated ABIs. It is the same code the Surged app runs, and its tests compare it byte for byte against what the contracts compute, so a quote from this package matches what the chain will do.

Pure TypeScript on top of viem: no React, no Node APIs, no network calls of its own. It runs the same in a browser, in a worker and on a server.

Install

npm add @surged/sdk viem

viem is a peer in practice. The package returns viem's types and expects you to send the calldata with it, though nothing stops you passing the data and value it returns to ethers or to a raw JSON-RPC call.

Where things live

| | | | -------- | ---------------------------------------------------------------- | | App | surged.fun | | Api | https://api.surged.fun | | Chain | Arc mainnet, chain id 5042 (testnet 5042002 is also shipped) | | Explorer | explorer.arc.io |

The shape of a trade

  1. Read the curve. GET /launches/{token} returns its terms and its current state.
  2. Price the trade locally. previewBuy and previewSell run the exact formula of the contract. No round trip, no eth_call, and you can chain quotes to simulate a sequence of trades.
  3. Send the calldata. encodeBuy and encodeSell build it; you sign and send it.

Before you start

Two things about Arc catch people out:

  • USDC is the native coin and it has 18 decimals, while the ERC-20 view of the same balance has 6. Every amount in this package is in the 18-decimal units unless it says otherwise; toNativeUnits and toErc20Units are the only conversions you need.
  • Gas is paid in USDC, so a buy that spends the whole balance leaves nothing to pay for itself.

Modules

| Module | What it gives you | | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | | curve | previewBuy, previewSell, quoteBuy, quoteSell, applyBuy, applySell, sellableTokens, readyToGraduate, curveStateFromApi and the math underneath. | | units | toNativeUnits, toErc20Units, minOutWithSlippage, BPS. | | encoders | encodeLaunchToken, encodeBuy, encodeSell, encodeLaunchAndBuy, encodeLaunchAndBuyMany, encodeLaunchAndBuyManyFrom. | | bundle | bundleBuyTypedData, hashBundleBuy: the consent a wallet signs to join a bundle. | | errors | explainError, decodeLaunchpadError: a stable code and a sentence, never raw calldata. | | chains | arc, arcTestnet, USDC_PREDEPLOY, NATIVE_QUOTE, ARC_BLOCK_TIME_MS. | | abi | The generated ABIs: factory, curve, hooked curve, forwarder, escrow, token, locker. | | addresses | deployments[chainId]: the live contracts on each chain. |

Every amount is a bigint

Nothing in this package takes or returns a number for an amount. Token balances and USDC amounts on Arc do not fit in a JavaScript number, and a quote computed through one is wrong without failing.

The api sends amounts as decimal strings for the same reason. curveStateFromApi is the one place they become bigint; use it rather than mapping the fields yourself.

Quote a buy

import {
  curveStateFromApi,
  previewBuy,
  minOutWithSlippage,
  DEFAULT_SLIPPAGE_BPS,
} from '@surged/sdk'

const launch = await fetch(`${API}/launches/${token}`).then((r) => r.json())
const { head } = await fetch(`${API}/health`).then((r) => r.json())

// The buy lands in the next block, which is the block the snipe tax is priced at.
const quote = previewBuy(curveStateFromApi(launch), quoteIn, { currentBlock: BigInt(head) + 1n })
const minTokensOut = minOutWithSlippage(quote.tokensOut, DEFAULT_SLIPPAGE_BPS)

quote.crossing tells you the buy sells the last tokens and graduates the token into its Uniswap pool; quote.refund is what the curve sends back in that case.

Launch a token with a first buy

import { encodeLaunchAndBuy, deployments, NATIVE_QUOTE } from '@surged/sdk'

const { data, value } = encodeLaunchAndBuy({
  params, // TokenParams: name, symbol, logoUri, description, socials, creatorFeeRecipient, creatorTaxBps, expectedEconomics, salt
  launchConfigId: 0n,
  pairToken: NATIVE_QUOTE,
  snipeTaxExemptions: [],
  launchFee, // LaunchFactory.launchFee(), also served by the api
  quoteIn,
  minTokensOut,
  recipient,
})
await wallet.sendTransaction({ to: deployments[5042].launchForwarder, data, value })

Sign a bundle consent

Version 0.3.0 requires a deployed v2 forwarder. Check /config.bundleConsent.supported and verify the live getter immediately before approvals/signatures. Never infer compatibility from the package version or stored deployment address. Revalidate the launch hash and nonces after simulation before sending; changed terms require new signatures.

import { bundleAuthorizationCalls, bundleBuyTypedData } from '@surged/sdk'
import { isHex } from 'viem'

// Read against the exact launch being signed; this includes current factory policy.
const [version, launchHash, nonce] = await client.multicall({
  contracts: bundleAuthorizationCalls(forwarder, launch, [buyer]),
  allowFailure: false,
  batchSize: 0,
})
if (version !== 2n || !isHex(launchHash, { strict: true }) || launchHash.length !== 66 || typeof nonce !== 'bigint') {
  throw new Error('Secure bundle consent is unavailable for this forwarder')
}

const signature = await wallet.signTypedData(
  bundleBuyTypedData(chainId, forwarder, {
    buyer,
    quoteIn,
    minTokensOut,
    initiator,
    launchHash,
    nonce,
    deadline,
  }),
)

quoteIn must be a multiple of 1e12 for a native quote: the forwarder pulls it through the USDC predeploy.

Versions

The package ships recorded deployment addresses and encoders. The unreleased 0.3.0 v2 forwarder changes require a new verified deployment before use; existing addresses do not become v2 when this package is installed.

  • A redeploy of any contract is a minor bump, never a patch. Pinning ~0.2.0 keeps you on contracts that still exist.
  • The formula and the encoders change only on a minor. A patch is for a bug that made this package disagree with the chain, where the old behaviour was already wrong.

While the package is 0.x the public surface may still change between minors. Pin an exact version if you run unattended.

License

MIT