HertzFlow SDK

SDK

About

The HertzFlow SDK is a TypeScript-based SDK developed for interacting with HertzFlow protocol. It provides a comprehensive set of tools and utilities for building decentralized trading applications, managing positions, executing orders, and monitoring real-time market data.

Installation

Using npm

npm install @hertzflow/sdk-v2

Using yarn

yarn add @hertzflow/sdk-v2

Using pnpm

pnpm add @hertzflow/sdk-v2

Getting Started

Basic Configuration

import { HertzFlowSDK } from "@hertzflow/sdk-v2";

const sdk = new HertzFlowSDK({
  chainId: 97,                                       // BSC Testnet
  rpcUrl: "https://data-seed-prebsc-1-s1.binance.org:8545",
  oracleUrl: "https://oracle.hertzflow.com",
  statsUrl: "https://stats.hertzflow.com",
  account: "0xYourWalletAddress",
});

With Custom Viem Clients

With WebSocket Support

API Reference

Read Methods

Markets

Method
Description

sdk.markets.getMarkets()

Fetch all available trading markets

sdk.markets.getMarketsInfo()

Get comprehensive market data with prices and configs

sdk.markets.getMarketsConfigs(markets)

Fetch market configuration parameters

sdk.markets.getMarketsValues(params)

Get market runtime values (funding rates, pool amounts)

sdk.markets.getDailyVolumes()

Get trading volumes per market

sdk.markets.getTradingInstruments()

Get trading instruments with metadata

Positions

Method
Description

sdk.positions.getPositions(params)

Fetch raw position data for account

sdk.positions.getPositionsInfo(params)

Get enhanced positions with calculated metrics

sdk.positions.getPositionsConstants()

Get system constants (min collateral, max orders)

sdk.positions.getUserReferralInfo()

Get user's referral code and tier info

Tokens

Method
Description

sdk.tokens.getTokensData()

Fetch all available tokens with metadata

sdk.tokens.getTokenRecentPrices()

Get latest token prices from oracle

sdk.tokens.getTokensBalances(account?, tokensList?)

Get user token balances

sdk.tokens.getTokenTotalSupplies(tokenAddresses)

Get total supply of tokens

Orders

Method
Description

sdk.orders.getOrders(params)

Fetch all user orders with filtering

sdk.orders.getOrdersInfo(params)

Get enhanced order data with market info

Trades

Method
Description

sdk.trades.getTradeHistory(params)

Get market trade history

sdk.trades.getUserTradeHistory(params)

Get user's trade history with pagination

Claims

Method
Description

sdk.claim.getClaimableFundingData(markets)

Get claimable funding fees by market

sdk.claim.getClaimableCollaterals(params)

Get claimable price impact rebates

sdk.claim.getClaimHistory(params)

Get claim history with pagination

Utils

Method
Description

sdk.utils.getGasLimits()

Fetch gas limits for all operations

sdk.utils.getGasPrice()

Get current network gas price

sdk.utils.getEstimatedGasFee(type, params)

Estimate gas for operation

sdk.utils.getExecutionFee(type, tokensData, prices, params)

Calculate execution fee

Write Methods

Quick Methods

Method
Description

sdk.orders.long(params)

Quick method to open a long position

sdk.orders.short(params)

Quick method to open a short position

sdk.orders.swap(params)

Quick method to execute a token swap

Full Order Methods

Method
Description

sdk.orders.createIncreaseOrderTxn(params)

Create position increase order

sdk.orders.createDecreaseOrderTxn(params)

Close or reduce position

sdk.orders.createSwapOrderTxn(params)

Execute token swap order

sdk.orders.updateOrderTxn(params)

Modify existing order

sdk.orders.cancelOrdersTxn(orderKeys)

Cancel one or multiple orders

Pool Operations

Method
Description

sdk.orders.createHmDepositTxn(params)

Deposit to HM pool

sdk.orders.createHmWithdrawalTxn(params)

Withdraw from HM pool

sdk.orders.createHlvDepositTxn(params)

Deposit to HLV vault

sdk.orders.createHlvWithdrawalTxn(params)

Withdraw from HLV vault

Token Operations

Method
Description

sdk.orders.createWrapOrUnwrapTxn(params)

Wrap or unwrap native tokens

sdk.allowance.approveToken(tokenAddress, spenderAddress, amount?)

Approve token for spending

sdk.allowance.approveTokenForSyntheticsRouter(tokenAddress, amount?)

Approve for SyntheticsRouter

Claim Operations

Method
Description

sdk.claim.claimFundingFees(params)

Claim funding fees for markets

sdk.claim.claimPriceImpactRebates(params)

Claim price impact rebates

sdk.claim.claimAllRebates(params)

Batch claim funding and rebates

Event Subscriptions

Position Events

Order Events

Deposit/Withdrawal Events

Configuration Options

SDK Configuration Interface

Supported Chains

Chain
Chain ID
Description

BSC Testnet

97

BNB Smart Chain Testnet

Token Customization

You can override token information:

Market Availability

Control which markets are available:

UI Fee Configuration

Set up UI fee receiver:

Usage Examples

Opening a Long Position

Fetching Positions with Metrics

Subscribing to Real-Time Events

Claiming Rewards

Account Management

Switching Accounts

Updating Wallet Client

Resource Cleanup

Always destroy the SDK when done to clean up resources:

Last updated