The examples on this page use Hyperliquid (
provider: 'hyperliquid'). Replace the provider value with any supported provider from getProviders().getPortfolioHistory is a method on PerpsClient (not on the low-level PerpsSDKClient), not a standalone imported function. It throws an SDKError when the provider does not implement the read.
Parameters
PortfolioHistoryRange
PortfolioHistoryRange is a string union imported from @lifi/perps-sdk.
Returns
PortfolioHistoryResponse:
PortfolioHistoryPoint fields
Point spacing and
all coverage are provider-defined. totalPnl is the last pnl sample.
- Hyperliquid: non-unified accounts read the perps-only window; unified and portfolio-margin accounts read the combined window, so the scope of
accountValuedepends on the account mode. - Lighter: bucket resolution is 24h → 1h, 7d → 1h, 30d → 1d, and
all→ up to 1000 daily buckets.
Auth requirements
Each provider reads portfolio history with its own credential. The requirement is per provider.Hyperliquid
Hyperliquid needs no auth. The SDK reads portfolio history from a public Hyperliquidinfo endpoint using only the account address.
Ondo
Ondo needs an active session. The user signs in withsiweLogin before this call. A call with no stored session throws SetupRequired. A call with a session that Ondo rejects throws Unauthorized.
Lighter
Lighter needs the account auth token or the read-only token. The SDK resolves a token from its stored key automatically. A call with no resolvable token throwsSetupRequired, a token that Lighter rejects throws Unauthorized, and a wallet with no Lighter account throws AccountNotFound.
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.