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

bitfi-solana-js

v1.1.7

Published

A JavaScript/TypeScript library for interacting with the Bitfi Solana smart contract.

Readme

Bitfi Solana JS

A JavaScript/TypeScript library for interacting with the Bitfi Solana smart contract.

Overview

This library provides a set of utilities and functions to interact with the Bitfi smart contract on the Solana blockchain. It handles operations such as:

  • Trade deposits
  • Trade settlements
  • Claims
  • Total fee (protocol fee + affiliate fee) management
  • Nonce account management for settling the trade
  • Decode list of accounts

Installation

npm install bitfi-solana-js

Usage

Deposit

When the user want to deposit SOL/Spl token to the Bitfi program.

import { createDepositAndVaultAtaIfNeededAndNonceAccountInstructions, DepositInstructionParam } from 'bitfi-solana-js';

// Deposit params receive from the backend/solver
const depositParams: DepositInstructionParam = {}
// Build necessary instructions for depositing
const instructions = await createDepositAndVaultAtaIfNeededAndNonceAccountInstructions(depositParams);
// Build the transaction with built instructions
const transaction = new Transaction().add(...instructions);
transaction.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
transaction.feePayer = user.publicKey;

// Send the transaction to the network
// Note: Transactions need to be signed by the user and user ephemeral account
const signature = await sendAndConfirmTransaction(connection, transaction, [user, userEphemeral], { commitment: 'confirmed' });
console.log(`Signature: ${signature}`);

Settlement

When the pmm already paid the user, then the mpcs can settle the trade. Settlement needs two step

Step 1: User presign the settlement transaction using userEphemeral key, allow the mpcs can settle the trade with agreed informations from user

import { createUserPresignSettlementTransactionAndSerializeToString } from "bitfi-solana-js";
// Build the presign transaction, serialize it to string, then send to the solver
const settlementPresign = await createUserPresignSettlementTransactionAndSerializeToString({
    connection: connection,
    tradeId: tradeId,
    mpcPubkey: mpc.publicKey,
    pmmPubkey: pmm.publicKey,
    userEphemeral: userEphemeral,
});
console.log(`Settlement presign: ${settlementPresign}`);

Step 2: MPCs get the presign transaction, sign with mpc keys, then send to the Solana to settle the trade

// recover transaction from the presign string
const recoveredTransaction = Transaction.from(Buffer.from(settlementPresign, 'hex'));
// Sign the transaction with mpc keys
recoveredTransaction.partialSign(mpc);
// Send the transaction to the network
const latestBlockhash = await connection.getLatestBlockhash();
const sig = await connection.sendRawTransaction(recoveredTransaction.serialize(), {
    skipPreflight: false,
})
await connection.confirmTransaction({
    signature: sig,
    blockhash: latestBlockhash.blockhash,
    lastValidBlockHeight: latestBlockhash.lastValidBlockHeight
}, 'confirmed')

console.log(`Settlement success at ${sig}`);

Claim

When the trade is timed out, the user can claim the deposit back.

import { createClaimInstructions } from "bitfi-solana-js";

// Create claim instructions
const instructions = await createClaimAndRefundAtaAndProtocolAtaIfNeededInstructions({
    tradeId,
    connection,
    userPubkey: user.publicKey,
})

// Build the transaction with built instructions
const transaction = new Transaction().add(...instructions);
// Send the transaction to the network
const signature = await sendAndConfirmTransaction(connection, transaction, [user], { commitment: 'confirmed' });
console.log(`Claim success at ${signature}`);    

Set total fee

When the user deposit the SOL/Spl token, the mpcs can set the total fee for the trade.

import { createSetTotalFeeInstructions } from "bitfi-solana-js";

const instructions = await createSetTotalFeeInstructions({
    tradeId,
    amount: '0.0001',
    connection,
    mpcPubkey: mpc.publicKey,
});

// Build the transaction with built instructions
const transaction = new Transaction().add(...instructions);
// Send the transaction to the network
const signature = await sendAndConfirmTransaction(connection, transaction, [mpc], { commitment: 'confirmed' });
console.log(`Set fee success at ${signature}`);

Decode list of accounts,

When some parties want to decode list of accounts, maybe fetched from a transaction.

import { decodeTradeDetailAccounts } from "bitfi-solana-js";

// Some tx hash, maybe a deposit transaction
const txHash = `...`
const parsedTx = await connection.getParsedTransaction(txHash, 'confirmed');

const accounts = parsedTx?.transaction.message.accountKeys;
const accountPubkey = accounts.map((account) => account.pubkey);
const results = await decodePaymentReceiptAccounts(connection, accountPubkey);
console.log('Trade details', results.filter((result) => result.error !== null));