The examples on this page use Hyperliquid (
provider: 'hyperliquid'). Replace the provider value with any supported provider from getProviders().Parameters
Returns
AvailableToTrade:
This is the per-market figure an order panel reads before it lets the user size an order. It differs from
AccountSummary.availableMargin, which stays account-scoped and does not reflect one market’s margin asset.
Per-market reads
Each shipped provider answers per market, sobuy and sell can differ:
- Hyperliquid reads the venue’s
activeAssetData.availableToTradeas[buy, sell]— see Hyperliquid / Account figures. - Lighter derives it from
available_balanceand the open position. The side that reduces or flips an existing position gets the initial margin requirement plus available margin plus released margin, sobuyandselldiffer when a position exists. - Ondo reads
/v1/perps/max_order_sizeand needs a session.
Provider fallback
The fallback applies only to a provider that has no per-market figure for the market: a Hyperliquid or Lighter spot market. For that market the plugin returnsundefined, and the SDK falls back to an account-scoped read. It fetches the account with getAccount(), derives getAccountSummary(), and returns the account’s availableMargin as both buy and sell, in the market’s quote asset.
A plugin read that throws propagates, and the SDK does not fall back. Ondo with no session throws SetupRequired.
Throws
PerpsError with one code for the account’s access state. See Account access.
SetupRequired— the venue needs a credential (a Lighter auth token or an Ondo session) and none is stored.Unauthorized— the venue rejects the credential.AccountNotFound— the wallet has no venue account.
getAccount on every Lighter market. On Lighter, the read throws AccountNotFound for a wallet with no Lighter account, and Unauthorized when an auth token resolves for the registered API key and Lighter rejects the token.