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

@bluefin-exchange/pro-sdk

v2.0.0

Published

OpenAPI client for @bluefin-exchange/pro-sdk

Downloads

4,489

Readme

Bluefin Pro SDK for TypeScript/JavaScript

TypeScript/JavaScript SDK for interacting with the Bluefin Pro exchange API and Sui blockchain contracts.

npm version

Installation

Install the SDK using npm or yarn:

npm install @bluefin-exchange/pro-sdk
# or
yarn add @bluefin-exchange/pro-sdk

Peer Dependencies

The SDK requires the following peer dependencies:

npm install @mysten/sui

Quick Start

1. Initialize the SDK

import {
  BluefinProSdk,
  BluefinRequestSigner,
  makeSigner,
} from "@bluefin-exchange/pro-sdk";
import { SuiJsonRpcClient } from "@mysten/sui/jsonRpc";
import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
import { hexToBytes } from "@noble/hashes/utils.js";

// Create wallet from private key
const wallet = Ed25519Keypair.fromSecretKey(
  hexToBytes("YOUR_PRIVATE_KEY_HEX")
);

// Or create wallet from mnemonic
// const wallet = Ed25519Keypair.deriveKeypair("your mnemonic phrase here");

// Create request signer
const signer = new BluefinRequestSigner(makeSigner(wallet, false));

// Initialize SDK client
const client = new BluefinProSdk(
  signer,
  "mainnet", // or "testnet" for staging, "devnet" for development
  new SuiJsonRpcClient({ url: "https://fullnode.mainnet.sui.io:443", network: "mainnet" })
);

// Initialize the SDK (authenticates and loads exchange configuration)
await client.initialize();

2. Get Market Data

// Get exchange information and available markets
const exchangeInfo = await client.exchangeDataApi.getExchangeInfo();
console.log("Available markets:", exchangeInfo.data.markets);

// Get market ticker
const ticker = await client.exchangeDataApi.getMarketTicker("BTC-PERP");
console.log("BTC-PERP ticker:", ticker.data);

// Get orderbook depth
const orderbook = await client.exchangeDataApi.getOrderbookDepth("BTC-PERP");
console.log("Orderbook:", orderbook.data);

// Get recent trades
const trades = await client.exchangeDataApi.getRecentTrades("BTC-PERP");
console.log("Recent trades:", trades.data);

3. Place an Order

import { OrderType, OrderSide, OrderTimeInForce } from "@bluefin-exchange/pro-sdk";

const orderParams = {
  clientOrderId: "unique-order-id-123",
  type: OrderType.Limit,
  symbol: "BTC-PERP",
  priceE9: "45000000000000", // Price in E9 format (45000 * 1e9)
  quantityE9: "100000000", // Quantity in E9 format (0.1 BTC * 1e9)
  side: OrderSide.Long,
  leverageE9: "2000000000", // 2x leverage
  isIsolated: false,
  expiresAtMillis: Date.now() + 24 * 60 * 60 * 1000, // 24 hours
  postOnly: false,
  reduceOnly: false,
  timeInForce: OrderTimeInForce.Gtt,
};

const result = await client.createOrder(orderParams);
console.log("Order created:", result.data);

4. Get Account Information

import { TradeType } from "@bluefin-exchange/pro-sdk";

// Get account details
const accountDetails = await client.accountDataApi.getAccountDetails(
  wallet.getPublicKey().toSuiAddress()
);
console.log("Account details:", accountDetails.data);

// Get account trade history
const tradeHistory = await client.accountDataApi.getAccountTrades(
  "BTC-PERP",
  Date.now() - 7 * 24 * 60 * 60 * 1000, // Last 7 days
  Date.now(),
  100,
  TradeType.Order,
  1
);
console.log("Trade history:", tradeHistory.data);

WebSocket Streams

Market Data Stream

Subscribe to real-time market data updates:

import { MarketDataStreamName } from "@bluefin-exchange/pro-sdk";

// Create market data stream listener
const marketListener = await client.createMarketDataStreamListener(
  async (msg) => {
    console.log("Market update:", msg);
  }
);

// Subscribe to market data streams
await marketListener.send(
  JSON.stringify({
    method: "Subscribe",
    dataStreams: [
      {
        symbol: "BTC-PERP",
        streams: [
          MarketDataStreamName.Ticker,
          MarketDataStreamName.RecentTrade,
          MarketDataStreamName.PartialDepth5,
        ],
      },
    ],
  })
);

Account Data Stream

Subscribe to account updates:

import { AccountDataStream } from "@bluefin-exchange/pro-sdk";

// Create account data stream listener
const accountListener = await client.createAccountDataStreamListener(
  async (msg) => {
    console.log("Account update:", msg);
  }
);

// Subscribe to account data streams
await accountListener.send(
  JSON.stringify({
    method: "Subscribe",
    dataStreams: [
      AccountDataStream.AccountOrderUpdate,
      AccountDataStream.AccountPositionUpdate,
      AccountDataStream.AccountTradeUpdate,
      AccountDataStream.AccountTransactionUpdate,
      AccountDataStream.AccountUpdate,
    ],
  })
);

Advanced Features

Deposit and Withdraw

// Deposit USDC to exchange (amount in base units)
await client.deposit("1000000000"); // 1 USDC (1 * 1e9)

// Withdraw USDC from exchange
await client.withdraw("USDC", "500000000"); // 0.5 USDC (0.5 * 1e9)

Update Leverage

// Update leverage for a specific market
await client.updateLeverage("BTC-PERP", "5000000000"); // 5x leverage

Adjust Isolated Margin

// Add margin to isolated position
await client.adjustIsolatedMargin("BTC-PERP", "100000000000", true); // Add 100 USDC

Batch Claim Rewards

// Get available rewards
const rewards = await client.rewardsDataApi.getCampaignRewards(
  "TRADE_AND_EARN",
  wallet.getPublicKey().toSuiAddress()
);

// Claim rewards (see docs/batch-claim-rewards-guide.md for detailed guide)
const claimPayloads = /* transform rewards to BatchClaimParams */;
const txResult = await client.batchClaimRewards(claimPayloads);

See docs/batch-claim-rewards-guide.md for a complete guide on claiming rewards.

API Reference

The SDK provides access to the following API categories:

  • ExchangeDataApi: Market data, tickers, orderbooks, candles, funding rates
  • AccountDataApi: Account details, positions, orders, trade history, transactions
  • TradeApi: Order placement, cancellation, leverage updates
  • AuthApi: Authentication and session management
  • RewardsApi: Campaign rewards and claiming

For detailed API documentation, see the auto-generated docs in the src/docs directory.

Environment Configuration

The SDK supports three environments:

  • mainnet: Production environment
  • testnet: Staging environment for testing
  • devnet: Development environment

Each environment has different API endpoints configured automatically.

See example.ts for the complete example code.