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

@wkalidev/b2s-contracts

v1.2.1

Published

$B2S Token — Smart Contracts & TypeScript SDK for Base2Stacks DeFi on Stacks mainnet

Readme

@wkalidev/b2s-contracts

$B2S Token — TypeScript SDK & Smart Contract addresses for Base2Stacks DeFi on Stacks mainnet.

npm version npm downloads CI License: MIT Stacks Mainnet


Why this SDK?

If you're building on Stacks and need to interact with $B2S DeFi contracts (token, staking, liquidity pool, governance, prediction markets), this SDK gives you:

  • ✅ All mainnet contract addresses in one place — no more copy-pasting
  • TypeScript-first — full type definitions included
  • Tree-shakeable — ESM + CJS, import only what you need
  • Helper functions — AMM swap math, APY calculator, address utils
  • Client classesB2SClient, RewardsClient, OracleClient ready to use

Installation

npm install @wkalidev/b2s-contracts
# or
yarn add @wkalidev/b2s-contracts
# or
pnpm add @wkalidev/b2s-contracts

Deployed Contracts (Stacks Mainnet)

Deployer: SP936YWJPST8GB8FFRCN7CC6P2YR5K6NNBAARQ96

| Contract | Name | Description | |----------|------|-------------| | b2s-token-v4 | $B2S Token | SIP-010 fungible token, 6 decimals | | b2s-staking-vault-v2 | Staking Vault | 12.5–37.5% APY with lock multipliers | | b2s-liquidity-pool-v6 | AMM Pool | Constant product AMM, 0.25% fee | | b2s-rewards-distributor-v3 | Rewards | 5 B2S daily claim | | b2s-governance | DAO | On-chain proposals & voting | | b2s-fee-router | Fee Router | Bridge fee collection & distribution | | b2s-prediction-market | Prediction | AMM-style prediction markets | | b2s-price-oracle | Oracle | Clarity 4 price feeds |


Quick Start

Get contract addresses

import { CONTRACTS, CONTRACT_NAMES, getContractId } from '@wkalidev/b2s-contracts/contracts'

// Full contract IDs
console.log(CONTRACTS['b2s-token-v4'])
// → 'SP936YWJPST8GB8FFRCN7CC6P2YR5K6NNBAARQ96.b2s-token-v4'

// Get any contract ID
const stakingId = getContractId(CONTRACT_NAMES.STAKING_VAULT)
// → 'SP936YWJPST8GB8FFRCN7CC6P2YR5K6NNBAARQ96.b2s-staking-vault-v2'

Read $B2S balance

import { B2SClient } from '@wkalidev/b2s-contracts'

const client = new B2SClient() // defaults to mainnet

const { formatted } = await client.getBalance('SP1ABC...XYZ')
console.log(`Balance: ${formatted} B2S`)

AMM swap calculation

import { calcSwapOutput, calcEffectiveApy, calcBridgeFee } from '@wkalidev/b2s-contracts/helpers'

// Calculate swap output (no RPC call needed)
const { amountOut, fee, priceImpact } = calcSwapOutput(
  1_000_000n,   // 1 B2S in
  50_000_000n,  // reserve B2S
  10_000_000n,  // reserve STX
)

// APY based on lock duration
calcEffectiveApy(2100) // → 37.5%
calcEffectiveApy(1050) // → 25%
calcEffectiveApy(0)    // → 12.5%

// Bridge fee breakdown
const { totalFeeMicro, toTreasury, toStakers } = calcBridgeFee(1_000_000_000n)

Staking rewards

import { RewardsClient } from '@wkalidev/b2s-contracts'

const rewards = new RewardsClient()

const pending = await rewards.getPendingRewards('SP1ABC...XYZ')
console.log(`Pending: ${pending.formatted} B2S`)

const info = await rewards.getStakerInfo('SP1ABC...XYZ')
console.log(`Staked: ${info?.stakedFormatted} B2S`)

Price oracle

import { OracleClient } from '@wkalidev/b2s-contracts'

const oracle = new OracleClient()
const { price } = await oracle.getPrice('STX-USD')
console.log(`STX price: $${price}`)

Utilities

import {
  toMicroUnits,
  fromMicroUnits,
  formatB2S,
  blocksToDuration,
  isValidStacksAddress,
  truncateAddress,
} from '@wkalidev/b2s-contracts/helpers'

formatB2S(5_000_000n)              // → '5.000000 B2S'
blocksToDuration(2100)             // → '~14d 0h'
isValidStacksAddress('SP1ABC...') // → true
truncateAddress('SP936YWJ...RQ96') // → 'SP936Y...R96'

TypeScript Types

import type {
  TokenBalance,
  StakePosition,
  PoolReserves,
  SwapQuote,
  BridgeTransaction,
  Proposal,
  ClaimRecord,
  PriceFeed,
  Result,
} from '@wkalidev/b2s-contracts/types'

Development

git clone https://github.com/wkalidev/b2s-token-contract.git
cd b2s-token-contract
npm install
npm run build
npm test

Clarity contracts

clarinet check   # type-check contracts
clarinet test    # run contract tests

Live App

base2stacks-tracker.vercel.app — the full DeFi dApp using this SDK on Stacks mainnet.


Contributing

PRs welcome! See CONTRIBUTING.md

License

MIT — © 2026 wkalidev


Built for #StacksBuilderRewards April 2026 🏆