Skip to main content
Returns the account summary for a DEX including balances, margin, and fee tier.
The examples on this page use Hyperliquid (provider: 'hyperliquid'). Replace the provider value with any supported DEX from getProviders().
import { getAccount } from '@lifi/perps-sdk';

const account = await getAccount(client, {
  provider: 'hyperliquid',
  address: userAddress,
});

console.log('Balances:', account.balances); // Balance[]
console.log('Collateral:', account.collateralBalances); // Balance[]
console.log('Margin used:', account.marginUsed);
console.log('Unrealized PnL:', account.unrealizedPnl);

Parameters

ParameterTypeRequiredDescription
clientPerpsSDKClientYesSDK client from createPerpsClient()
params.providerstringYesDEX identifier
params.addressstringYesUser’s wallet address
optionsSDKRequestOptionsNoRequest options

Returns

AccountResponse:
FieldTypeDescription
providerstringProvider identifier
addressstringUser’s wallet address
balancesBalance[]Flat, non-collateral holdings
collateralBalancesBalance[]SDK-determined collateral subset (spot balances in a category’s quote asset)
marginUsedstringMargin currently in use
unrealizedPnlstringTotal unrealized PnL
feeTierFeeTierMaker and taker fee rates
configAccountConfigProvider-specific account state — a discriminated union over provider. Narrow with config.provider === 'hyperliquid' / 'lighter' to access provider-specific fields. See AccountConfig.
Each Balance:
FieldTypeDescription
categoryIdstringWhich category/venue this balance sits in — references a ProviderCategory
assetAssetThe held asset
unitsstringAmount held, in asset units
valueUsdstringUSD value of the holding
Positions and orders are fetched separately via getPositions() and getOrders().

accountExists

Thin existence check for a provider account at address — useful for gating signing-mode or onboarding flows on whether the user has any account state with the provider yet.
const exists = await perps.accountExists('hyperliquid', userAddress);
ParameterTypeRequiredDescription
providerstringYesDEX identifier
addressstringYesUser’s wallet address
Returns: Promise<boolean>true when getAccount resolves, false when the backend reports PerpsErrorCode.AccountNotFound. Any other error (transport, validation, server) is re-thrown. API Reference: GET /account