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

stable-layer-sdk

v3.1.0

Published

A TypeScript SDK for Stable Layer

Readme

Stable Layer SDK

TypeScript SDK for the Stable Layer protocol on Sui blockchain. Mint and burn stablecoins, and claim yield farming rewards.

Installation

npm install stable-layer-sdk @mysten/sui @mysten/bcs

Quick Start

import { StableLayerClient } from "stable-layer-sdk";

const client = await StableLayerClient.initialize({
  network: "mainnet", // or "testnet" (mint/burn/claim use mock_farm; see src/libs/constants.testnet.ts)
  sender: "0xYOUR_ADDRESS",
});

Testnet republish overrides: optional mockFarmRegistryId, mockFarmPackageId, mockUsdbCoinType on initialize.

Examples

Mint Stablecoins

Deposit USDC to mint stablecoins. The SDK builds a transaction that mints via Stable Layer and deposits into the vault farm (mainnet); on testnet, flow uses mock_farm::receive after mint.

import { coinWithBalance, Transaction } from "@mysten/sui/transactions";

const tx = new Transaction();

// Mint with auto-transfer (coin sent to sender automatically)
await client.buildMintTx({
  tx,
  stableCoinType: "0x6d9fc...::btc_usdc::BtcUSDC",
  usdcCoin: coinWithBalance({
    balance: BigInt(1_000_000),
    type: "0xdba34...::usdc::USDC",
  })(tx),
  amount: BigInt(1_000_000),
});

// Or get the coin back for further composition
const coin = await client.buildMintTx({
  tx,
  stableCoinType: "0x6d9fc...::btc_usdc::BtcUSDC",
  usdcCoin: coinWithBalance({
    balance: BigInt(1_000_000),
    type: "0xdba34...::usdc::USDC",
  })(tx),
  amount: BigInt(1_000_000),
  autoTransfer: false,
});

Burn Stablecoins

Burn stablecoins to redeem USDC.

const tx = new Transaction();

// Burn a specific amount
await client.buildBurnTx({
  tx,
  stableCoinType: "0x6d9fc...::btc_usdc::BtcUSDC",
  amount: BigInt(1_000_000),
});

// Or burn entire balance
await client.buildBurnTx({
  tx,
  stableCoinType: "0x6d9fc...::btc_usdc::BtcUSDC",
  all: true,
});

Claim Rewards

Claim yield (mainnet: vault farm; testnet: mock_farm::claim).

const tx = new Transaction();

await client.buildClaimTx({
  tx,
  stableCoinType: "0x6d9fc...::btc_usdc::BtcUSDC",
});

Query Total Supply

// Total supply across all coin types
const totalSupply = await client.getTotalSupply();

// Total supply for a specific coin type
const btcUsdcSupply = await client.getTotalSupplyByCoinType("0x6d9fc...::btc_usdc::BtcUSDC");

Signing and Executing

All build* methods return a Transaction that you sign and execute with the Sui SDK:

import { SuiGrpcClient } from "@mysten/sui/grpc";
import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";

const suiClient = new SuiGrpcClient({
  network: "mainnet",
  baseUrl: "https://fullnode.mainnet.sui.io:443",
});
const keypair = Ed25519Keypair.fromSecretKey(YOUR_PRIVATE_KEY);

const tx = new Transaction();
await client.buildMintTx({ tx /* ... */ });

const result = await suiClient.signAndExecuteTransaction({
  transaction: tx,
  signer: keypair,
});

Testing

pnpm exec vitest run hits mainnet RPC from test/e2e/. Use QUERY_OUTPUT=1 or pnpm query-output for extra simulation logs. Optional E2E_ASSERT_POSITIVE=1 asserts a positive USDB preview in the manager getClaimRewardUsdbAmount e2e (default only checks type and non-negative amount so CI does not depend on live accrued rewards). Opt-in live testnet mint/burn: pnpm test:e2e:testnet (env vars in test/e2e/testnet-mint-burn.e2e.ts).

API

StableLayerClient.initialize(config)

Creates a client with config fetched from chain (via Bucket Protocol SDK). Returns Promise<StableLayerClient>.

| Parameter | Type | Description | | ---------------- | ------------------------ | ---------------------- | | config.network | "mainnet" \| "testnet" | Sui network | | config.sender | string | Default sender address |

Transaction & query methods

All methods accept a tx (Transaction) and optional sender to override the default. Set autoTransfer: false to get the resulting coin back instead of auto-transferring.

| Method | Description | | ---------------------------------- | -------------------------------------------------------------------------------------------- | | buildMintTx(params) | Mint from USDC (testnet: + mock_farm::receive) | | buildBurnTx(params) | Burn to USDC (testnet: mock_farm::pay) | | buildClaimTx(params) | Claim rewards (testnet: mock_farm::claim) | | buildSetMaxSupplyTx(params) | Update max supply | | getClaimRewardUsdbAmount(params) | Simulate buildClaimTx; sum USDB credit (testnet: mock USDB type) — throws if dry-run fails | | getTotalSupply() | Total supply from registry | | getTotalSupplyByCoinType(type) | Supply for one coin type |

getConstants(network) / StableLayerClient.getConstants

Returns protocol object IDs and type strings for mainnet or testnet without building a client.

License

MIT