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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@etherfuse/stablebond-sdk

v2.0.60

Published

JavaScript client for the stablebond program

Readme

Etherfuse Stablebond Program SDK

The StablebondProgram class provides a set of methods to interact with the Stablebond program on the Solana blockchain.

We're currently using this ourselves at app.etherfuse.com.

We also have a devnet version of the program running at devnet.etherfuse.com. This is useful for testing and development, reach out to us for play-money and we'll transfer you some fake tokens to use.

A users's bond lifecycle is as follows:

  1. User is granted/airdropped a bond, indicating they have been given access to the platform.
  2. User leverages the bond to gain access to the platform by calling grantAccess.
  3. User purchases and mints new bonds by calling mintBond.
  4. User lets bonds mature for a period of time, ideally a year or more, but can do so immediately after purchasing.
  5. User redeems bonds by calling redeemBonds, getting an NFT that will store the user's bonds in a vault until the next issuance, similar to unstaking solana.
  6. User redeems the NFT by calling redeemNFT, getting the payment stablecoin for the bonds they redeemed, the same token used to pay for the bond.

Usage

Though the SDK includes all autogenerated code and types from the program, we recommend interacting with the program through the StablebondProgram class. There are exported types to enable faster development and better type safety.

The pattern for interacting with the class is that static methods reveal catalog information about availible bonds, while instance methods are used to interact with the context of a user's wallet. This way, catalog infomation can be refreshed independently of the user's wallet state.

First, import the StablebondProgram class:

import { StablebondProgram } from "@etherfuse/stablebond-sdk";

Collect the static stablebond information

const bonds = await StablebondProgram.getBonds(rpcEndpoint);

Then, once a user has authenticated, create an instance of the StablebondProgram class:

const stablebondProgram = new StablebondProgram(rpcEndpoint, wallet);

Instance Methods

getUserBondBalances

async getUserBondBalances(): Promise<Map<string, Decimal>>

Fetches the user's bond balances in the Stablebond program.

getUserTokens

async getUserTokens(): Promise<Stablebond[]>

Fetches the user's tokens in the Stablebond program, combining getBonds and getUserBondBalances. We don't call this in our code, but it's available for you to use.

getUserNFTs

async getUserNFTs(): Promise<PartialNFT[]>

Fetches the user's NFTs in the Stablebond program. For the sake of effiency, catalog information about the bond is excluded. This information can be patched back in to complete a full NFT object using the static mapper method mapToCompleteNFT.

hasAccess

async hasAccess(): Promise<boolean>

Checks if the user has access to the Stablebond program.

grantAccess

async grantAccess(bondAddress: string, bondMint: string): Promise<Uint8Array>

Grants access to the user by leveraging a bond in their wallet, proving they have sought out and requsted access to the platform.

hasKYC

async hasKYC(): Promise<boolean>

Checks if the user has completed KYC (Know Your Customer) verification in the Stablebond program.

mintBond

async mintBond(stablebondAddress: Address, uiAmount: Decimal): Promise<Uint8Array>

Mints new bonds for the user matching the specified amount. Amount is is in the payment token of the bond, without specifying the amount of bonds to purchase.

instantRedeemBonds

async instantRedeemBonds(stablebondAddress: Address, passedUIAmount?: Decimal): Promise<Uint8Array>

Instantly redeems bonds in the Stablebond program. This results in a user getting paid out in the payment token of the bond, minus a fee. The fee and available liquidity are determined by the bond's instant redeem configuration.

createPurchaseOrder

async createPurchaseOrder(stablebondAddress: Address, paymentAmount: Decimal): Promise<Uint8Array>

Creates a purchase order for the user to reserve bonds in the upcoming issuance within the Stablebond program. The amount is in the payment token of the bond, without specifying the amount of bonds to purchase.

redeemPurchaseOrder

async redeemPurchaseOrder(nftMintString: Address): Promise<Uint8Array>

Redeems a purchase order for the user to claim bonds previously paid for within the Stablebond program.

redeemBonds

async redeemBonds(stablebondAddress: Address, passedUIAmount?: Decimal): Promise<Uint8Array>

Redeems bonds in the Stablebond program. This results in a user receiving an NFT that will mature at the end of the current issuance.

redeemNFT

async redeemNFT(nftMintString: Address): Promise<Uint8Array>

Redeems an NFT in the Stablebond program. This results in a user receiving the underlying asset of the NFT.

Static Methods

getBonds

static async getBonds(rpcEndpoint: string): Promise<Stablebond[]>

Fetches the bonds in the Stablebond program.

getBond

static async getBond(rpcEndpoint: string, bondAddress: string): Promise<Stablebond>

Fetches a bond in the Stablebond program.

getBondPrices

static async getBondPrices(host = StablebondProgram.etherfuseHost): Promise<{ [mint: string]: PriceData }>

Fetches current prices for active bonds, keyed by bond mint. This defaults to using the etherfuse production host.

getBondPrice

static async getBondPrice(mint: Address, host = StablebondProgram.etherfuseHost): Promise<PriceData>

Fetches the current price for a bond in its payment token. This defaults to using the etherfuse production host.

mapToCompleteNFT

static mapToCompleteNFT({ ...nft }: PartialNFT, bond: Stablebond): NFT

Maps a PartialNFT and a Stablebond to a complete NFT.

For more details, refer to the StablebondProgram class in the source code.

getInterestOverTime

static getInterestOverTime(basisPoints: number, secondsPast: number): Decimal

Calculates the interest accrued over a period of time given a rate in basis points. This is used internally to calculate bond values but may be useful for external calculations.

Parameters:

  • basisPoints: The interest rate in basis points (1/100th of a percent)
  • secondsPast: The number of seconds that have passed

Returns a Decimal representing the multiplier to apply to the principal amount.