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.3.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, agent check-in), 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 classes — B2SClient, RewardsClient, OracleClient, AgentClient, QuestClient

Installation

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

Deployed Contracts (Stacks Mainnet)

Deployer: SP1V72500C63KN9E348QDK9X879MASSTN0J3KBQ5N

| 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-staking-vault-v3 | Staking Vault v3 | Latest staking vault | | b2s-liquidity-pool-v6 | AMM Pool | Constant product AMM, 0.25% fee | | b2s-rewards-distributor | 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 | On-chain price feeds | | b2s-airdrop | Airdrop | Token airdrop distribution | | stacks-quest-v2 | Quest Game | Daily on-chain puzzle game | | stacks-quest-agent-v3 | Agent | Daily check-in + action log | | toolkit-math | Math | Safe Clarity arithmetic |


Quick Start

Get contract addresses

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

console.log(CONTRACTS['b2s-token-v4'])
// → 'SP1V72500C63KN9E348QDK9X879MASSTN0J3KBQ5N.b2s-token-v4'

const stakingId = getContractId(CONTRACT_NAMES.STAKING_VAULT)
// → 'SP1V72500C63KN9E348QDK9X879MASSTN0J3KBQ5N.b2s-staking-vault-v2'

Read $B2S balance

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

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

Agent — Daily check-in & streaks

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

const agent = new AgentClient()

// Get user streak
const streak = await agent.getStreak('SP1ABC...XYZ')
console.log(`Streak: ${streak.currentStreak} days`)
console.log(`Best: ${streak.bestStreak} days`)

// Check if user checked in today
const checkedIn = await agent.hasCheckedInToday('SP1ABC...XYZ')
console.log(`Checked in today: ${checkedIn}`)

// Get check-in fee (in microSTX)
const fee = await agent.getCheckinFee()
console.log(`Fee: ${fee / 1_000_000} STX`)

// Global stats
const stats = await agent.getGlobalStats()
console.log(`Total check-ins: ${stats.totalCheckins}`)
console.log(`Total fees collected: ${stats.totalFees} microSTX`)

Quest — Daily puzzle game

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

const quest = new QuestClient()

// Get player stats
const stats = await quest.getPlayerStats('SP1ABC...XYZ')
console.log(`Games played: ${stats.totalPlayed}`)
console.log(`Games won: ${stats.totalWon}`)
console.log(`Current streak: ${stats.currentStreak}`)

// Check if player already played today
const played = await quest.hasPlayedToday('SP1ABC...XYZ')
console.log(`Played today: ${played}`)

// Get today's puzzle type
const puzzle = await quest.getTodayPuzzle()
console.log(`Today's puzzle: ${puzzle?.puzzleType}`)

// Global stats
const global = await quest.getGlobalStats()
console.log(`Total games: ${global.totalGames}`)

AMM swap calculation

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

const { amountOut, fee, priceImpact } = calcSwapOutput(
  1_000_000n,
  50_000_000n,
  10_000_000n,
)

calcEffectiveApy(2100) // → 37.5%
calcEffectiveApy(0)    // → 12.5%

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`)

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('SP1V725...BQ5N') // → 'SP1V72...Q5N'

TypeScript Types

import type {
  TokenBalance, StakePosition, PoolReserves, SwapQuote,
  BridgeTransaction, Proposal, ClaimRecord, PriceFeed,
  CheckinStreak, AgentGlobalStats, AgentAction,
  QuestAttempt, PlayerStats, DailyPuzzle,
  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

Live Apps


Changelog

v1.3.0

  • Added AgentClient — streak, check-in, global stats
  • Added QuestClient — player stats, puzzle, game stats
  • New types: CheckinStreak, AgentGlobalStats, PlayerStats, DailyPuzzle

v1.2.3

  • B2SClient, RewardsClient, OracleClient, FeeRouterClient
  • AMM math helpers, APY calculator, bridge fee calculator

Contributing

PRs welcome! See CONTRIBUTING.md

License

MIT — © 2026 wkalidev


Built for #StacksBuilderRewards 2026