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

@bitflowlabs/core-sdk

v2.4.0

Published

SDK for interacting with Bitflow Protocol

Downloads

3,972

Readme

Bitflow SDK

Bitflow SDK is a powerful and easy-to-use library for interacting with the Bitflow Protocol. It provides a set of tools to seamlessly integrate Bitflow functionality into your applications. Currently, the SDK is available by request only. If you are interested in integrating with the BitFlow SDK please reach out to the team on Discord.

Table of Contents

Installation

Install the Bitflow SDK using npm:

npm install @bitflowlabs/core-sdk

Latest Stable Version is 2.4.0

Configuration

Before using the Bitflow SDK, you need to set up your environment variables. Create a .env file in your project root with the following variables:

# will be provided by Bitflow
BITFLOW_API_HOST=https://example-api-host.com
# will be provided by Bitflow
BITFLOW_API_KEY=<your_api_key_here>
# your provider address
BITFLOW_PROVIDER_ADDRESS=<your_provider_address_here>
# will be provided by Bitflow or can be your own Stacks Node
READONLY_CALL_API_HOST=https://example-readonly-api.com
# will be provided by Bitflow or can be your own Stacks Node
READONLY_CALL_API_KEY=<your_readonly_api_key_here>
# will be provided by Bitflow
KEEPER_API_HOST=https://example-keeper-api.com
# will be provided by Bitflow 
KEEPER_API_KEY=<your_keeper_api_key_here>

Usage

Here's a step-by-step guide to implement the Bitflow SDK in your project:

  1. Import the SDK:
import { BitflowSDK } from '@bitflowlabs/core-sdk';
  1. Initialize the SDK:
// if no parameters are provided, the SDK will try to use the environment variables
const bitflow = new BitflowSDK({
  BITFLOW_API_HOST: string,
  BITFLOW_API_KEY: string,
  BITFLOW_PROVIDER_ADDRESS: string,
  READONLY_CALL_API_HOST: string,
  READONLY_CALL_API_KEY: string,
  KEEPER_API_HOST: string,
  KEEPER_API_KEY: string
});
  1. Use the SDK methods to interact with the Bitflow Protocol. Here are some common operations:

Available Functions

Get Available Tokens

Retrieve a list of all available tokens:

const tokens = await bitflow.getAvailableTokens();
console.log(tokens);

Get Possible Swaps

Get all possible swap options for a given token:

const tokenXId = 'token-stx'; // the `tokenId` prop from `Token` interface
const swapOptions = await bitflow.getPossibleSwaps(tokenXId);
console.log(swapOptions);

Get All Possible Token Y

Retrieve all possible tokens that can be swapped for a given token:

const tokenXId = 'token-stx';
const possibleTokens = await bitflow.getAllPossibleTokenY(tokenXId);
console.log(possibleTokens);

Get All Possible Token Y Routes

Get all possible routes for swapping between two tokens:

const tokenXId = 'token-usda';
const tokenYId = 'token-stx';
const routes = await bitflow.getAllPossibleTokenYRoutes(tokenXId, tokenYId);
console.log(routes);

Getting Quote for Route

Get the quotes for a swap between two tokens:

const tokenXId = 'token-usda';
const tokenYId = 'token-stx';
const amount = 100; // Amount of tokenX to swap
const quoteResult = await bitflow.getQuoteForRoute(tokenXId, tokenYId, amount);
console.log(quoteResult);

Getting Swap Parameters

Get the necessary parameters for signing a swap transaction:

const swapExecutionData = {
  route: selectedRoute,
  amount: 100,
  tokenXDecimals: selectedRoute.tokenXDecimals,
  tokenYDecimals: selectedRoute.tokenYDecimals,
};
const senderAddress = 'your_stacks_address';
const slippageTolerance = 0.01; // 1%

const swapParams = await bitflow.getSwapParams(
  swapExecutionData,
  senderAddress,
  slippageTolerance
);
console.log(swapParams);

Executing Swap (uses @stacks/connect)

This function uses the @stacks/connect library to execute a swap transaction:

const swapExecutionData = {
  route: selectedRoute,
  amount: 100,
  tokenXDecimals: selectedRoute.tokenXDecimals,
  tokenYDecimals: selectedRoute.tokenYDecimals,
};
const senderAddress = 'your_stacks_address';
const slippageTolerance = 0.01; // 1%

await bitflow.executeSwap(
  swapExecutionData,
  senderAddress,
  slippageTolerance,
  stacksProvider, // a valid object of type `StacksProvider` from `@stacks/connect`
  (data) => console.log('Swap executed:', data),
  () => console.log('Swap cancelled')
);

Types

The SDK exports several TypeScript types that you can use in your application:

  • BitflowSDKConfig: Represents the configuration object for the Bitflow SDK.
  • Token: Represents a token with its properties.
  • SwapOptions: Represents possible swap options for a token.
  • PostConditionType: Represents the type of a post-condition used in transactions.
  • SelectedSwapRoute: Represents a selected swap route with its details.
  • RouteQuote: Represents the quote for a swap route.
  • QuoteResult: Represents the result of a quote request, including the best RouteQuote and all possible routes.
  • SwapExecutionData: Represents the data needed to execute a swap.
  • SwapDataParamsAndPostConditions: Represents the parameters and post-conditions needed to execute/sign a swap transaction.
import {
  Token,
  SwapOptions,
  SelectedSwapRoute,
  QuoteResult,
  SwapExecutionData,
  SwapDataParamsAndPostConditions,
} from '@bitflowlabs/core-sdk';

Troubleshooting

If you encounter any issues while using the Bitflow SDK, please check the following:

  1. Ensure all environment variables are correctly set in your .env file.
  2. Make sure you have the latest version of the SDK installed.
  3. Check that you're using a valid Stacks address for the senderAddress parameter.

License

This project is licensed under the MIT License - see the LICENSE file for details.