@bluefin-exchange/bluefin7k-aggregator-sdk

中文文档
7.7.0发布于 2026/09/28MITTypeScriptES Module构建来源已验证近 30 天下载 2.6万

bash npm i @bluefin-exchange/bluefin7k-aggregator-sdk

原始使用文档
文档目录15 节
  1. Installation
  2. Usage
  3. Config
  4. Set API Key
  5. Set BluefinX API key
  6. Set Sui Client
  7. Enable Pyth-priced sources
  8. Set Endpoint Provider (API Version)
  9. Swap
  10. BluefinX
  11. Limit Orders
  12. DCA Orders
  13. Prices
  14. Miscellaneous
  15. License

Bluefin7k Aggregator TypeScript SDK

Installation

npm i @bluefin-exchange/bluefin7k-aggregator-sdk

This package requires @pythnetwork/pyth-sui-js as a peer dependency. If your project does not have it, you need to install it.

npm i @pythnetwork/pyth-sui-js

Usage

You can import the entire SDK as a module:

import SevenK from "@bluefin-exchange/bluefin7k-aggregator-sdk";

or import specific functions as needed:

import { getQuote, buildTx } from "@bluefin-exchange/bluefin7k-aggregator-sdk";

Config

Configuration is optional, but if provided, it must be set before invoking any SDK functions.

Set API Key

You can use our SDK with a default rate limit of 5 requests per second without needing an API key.

  • For frontend (in-browser) usage, no API key is required, and the rate limit cannot be increased.

  • For backend (server-side) usage, the API key is optional for default usage. However, to request a higher rate limit, you must provide both an API key and partner information.

To request a rate limit increase, please submit your request at our Discord. Create a ticket to request an API key for Bluefin7k Aggregator.

UsageAPI Key RequiredDefault Rate LimitCan Request Higher Rate Limit
FrontendNo5 requests/secondNo
BackendOptional (required to increase limit)5 requests/second (without key)Yes (requires API Key & partner information)
import { Config } from "@bluefin-exchange/bluefin7k-aggregator-sdk";

Config.setApiKey("YOUR_API_KEY");
console.log("API key", Config.getApiKey());

Set BluefinX API key

Setting a BluefinX API key is optional. However, if you'd like to use one — for example, to avoid rate limits when routing through BluefinX — you'll need to request an API key directly from Bluefin.

import { Config } from "@bluefin-exchange/bluefin7k-aggregator-sdk";

Config.setBluefinXApiKey("YOUR_BLUEFINX_API_KEY");
console.log("BluefinX API key", Config.getBluefinXApiKey());

Set Sui Client

The SDK uses a single primary Sui client that accepts any ClientWithCoreApi implementation (gRPC, JSON-RPC, or GraphQL). Set via setSuiClient. Defaults to gRPC for best performance. This client is used for transaction execution, simulation, coin fetching, and Pyth price feed operations (as of @pythnetwork/pyth-sui-js v4, Pyth reads transport-agnostically through the unified .core API).

import { SuiGrpcClient } from "@mysten/sui/grpc";
import { Config } from "@bluefin-exchange/bluefin7k-aggregator-sdk";

const network = "mainnet";

// Primary client for transaction execution, simulation, and coin fetching
const suiClient = new SuiGrpcClient({
  baseUrl: "https://fullnode.mainnet.sui.io:443",
  network,
});
Config.setSuiClient(suiClient);

Note: this package only supports mainnet.

Enable Pyth-priced sources

A few liquidity sources price their swaps from a Pyth oracle, and buildTx has to attach a signed Pyth price update for a route that uses one:

  • steamm_oracle_quoter
  • steamm_oracle_quoter_v2
  • obric — not usable at present, see below
  • haedal_pmm — not usable at present, see below
  • sevenk_v1 — not usable at present, see below

obric, haedal_pmm and sevenk_v1 cannot be enabled by any client configuration today. Their on-chain packages still target the pre-upgrade Pyth deployment, so they reject the price objects this SDK produces, and the pre-upgrade price feeds they would otherwise read stopped updating at the 26 August 2026 Pyth Core cutover. They need a new on-chain release from each protocol; supplying a Pyth key does not help. The rest of this section applies to the two steamm_oracle_quoter sources.

These sources are off by default. Since the Pyth Core upgrade on 26 August 2026, every Hermes caller needs an API key, so the SDK cannot fetch a price update on its own. Quotes and swaps work fine without any Pyth setup — the aggregator routes around these sources, and in current mainnet liquidity that costs well under 0.01% on major pairs.

The SDK targets the upgraded Pyth Core deployment: https://pyth.dourolabs.app/hermes with the upgraded Sui state objects. Get a key from Pyth Terminal (a free trial is included), then:

import { Config } from "@bluefin-exchange/bluefin7k-aggregator-sdk";

// Server side, holding a Pyth Pro access token directly:
Config.usePythPro({ accessToken: process.env.PYTH_ACCESS_TOKEN! });

// Browser side, where a token cannot be shipped to the client — name your own
// endpoint that holds the token on the page's behalf:
Config.usePythPro({
  updateDataUrl: "https://your.api.example/price-update-data",
});

The updateDataUrl endpoint must answer GET <url>?ids=<comma-separated feed ids> with { "updateData": ["<base64 price update>", ...] }.

Call this once, before any getQuote, alongside your other Config setup.

Already run your own Pyth plumbing? Config.setPythConnection() also enables these sources. If you take that route you must also call Config.setPythClient() with state ids from the same Pyth deployment your connection fetches from: setPythConnection moves the price fetch and setPythClient moves the on-chain state, and a mismatch between them fails inside Wormhole's VAA verification with an error that never mentions Pyth. usePythPro exists to move both together, so prefer it unless you need your own connection object.

setPythClient() on its own does not enable these sources — it moves the on-chain state ids, not the price fetch.

When a source is dropped because no Pyth endpoint is configured, the SDK logs a one-time warning naming the sources and the setup call.

Set Endpoint Provider (API Version)

You can toggle between different API versions:

  • "Bluefin7k" (default) - Uses v2/quote endpoint
  • "Bluefin7kV2" - Uses v3/quote endpoint with RFQ support
import { Config } from "@bluefin-exchange/bluefin7k-aggregator-sdk";

// Use v2 API (default)
Config.setEndpointProvider("Bluefin7k");

// Use v3 API with RFQ support
Config.setEndpointProvider("Bluefin7kV2");

Swap

See Swap.

BluefinX

See BluefinX.

Limit Orders

See Limit Orders.

DCA Orders

See DCA Orders.

Prices

import { getTokenPrice, getTokenPrices, getSuiPrice } from "@bluefin-exchange/bluefin7k-aggregator-sdk";

const tokenPrice = await getTokenPrice(
  "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC",
);

const tokenPrices = await getTokenPrices([
  "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",
  "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC",
]);

const suiPrice = await getSuiPrice();

Miscellaneous

If you encounter issues when importing functions from this SDK in a Node.js environment, refer to src/examples/nodejs/ for guidance.

License

Bluefin7k Aggregator TypeScript SDK released under the MIT license. See the LICENSE file for details.

版本与发布记录

@bluefin-exchange/bluefin7k-aggregator-sdk 共发布 60 个版本,首次发布于 2025/06/06;过去 12 个月发布了 40 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
7.7.0latest2026/09/281 个月前
7.6.32026/08/282 个月前
7.6.22026/08/272 个月前
7.6.12026/08/272 个月前
7.6.02026/08/262 个月前
7.5.02026/08/053 个月前

其他发布通道:next → 7.0.0。

关于 @bluefin-exchange/bluefin7k-aggregator-sdk 的常见问题

@bluefin-exchange/bluefin7k-aggregator-sdk 是什么?

bash npm i @bluefin-exchange/bluefin7k-aggregator-sdk

如何安装 @bluefin-exchange/bluefin7k-aggregator-sdk?

在项目目录运行 npm install @bluefin-exchange/bluefin7k-aggregator-sdk,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@mysten/sui(^2.31.3)、@pythnetwork/pyth-sui-js(^4.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@bluefin-exchange/bluefin7k-aggregator-sdk 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@bluefin-exchange/bluefin7k-aggregator-sdk 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@bluefin-exchange/bluefin7k-aggregator-sdk 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=24。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@bluefin-exchange/bluefin7k-aggregator-sdk 可以商用吗?

@bluefin-exchange/bluefin7k-aggregator-sdk 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bluefin-exchange/bluefin7k-aggregator-sdk 的下载量有多少?

根据 npm 官方下载统计,@bluefin-exchange/bluefin7k-aggregator-sdk 在 2026/10/09 – 2026/11/07 这 30 天内被下载 26,075 次,日均约 869 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bluefin-exchange/bluefin7k-aggregator-sdk 还在维护吗?

最新版本 7.7.0 发布于 2026/09/28(1 个月前);至今共发布 60 个版本,其中过去 12 个月发布了 40 个;首次发布于 2025/06/06。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。