Returns the user’s open positions, paginated.
The examples on this page use Hyperliquid (provider: 'hyperliquid'). Replace the provider value with any supported DEX from getProviders().
import { getPositions } from '@lifi/perps-sdk';
const result = await getPositions(client, {
provider: 'hyperliquid',
address: userAddress,
});
for (const pos of result.positions) {
console.log(pos.asset.displaySymbol, pos.side, pos.size, 'PnL:', pos.unrealizedPnl);
}
// Pagination
if (result.pagination.hasMore) {
const nextPage = await getPositions(client, {
provider: 'hyperliquid',
address: userAddress,
cursor: result.pagination.cursor,
});
}
Parameters
| Parameter | Type | Required | Description |
|---|
client | PerpsSDKClient | Yes | SDK client |
params.provider | string | Yes | DEX identifier |
params.address | string | Yes | User’s wallet address |
params.symbol | string | No | Filter by asset identifier |
params.limit | number | No | Items per page (default 50, max 100) |
params.cursor | string | No | Pagination cursor from previous response |
options | SDKRequestOptions | No | Request options |
Returns
PositionsResponse:
| Field | Type | Description |
|---|
provider | string | Provider identifier |
positions | Position[] | Open positions |
pagination | Pagination | Pagination metadata |
Position fields
| Field | Type | Description |
|---|
asset | AssetDisplay | Asset identity (assetId, market, displaySymbol, displayQuote) |
side | 'LONG' | 'SHORT' | Position direction |
size | string | Position size |
entryPrice | string | Average entry price |
markPrice | string | Current mark price |
liquidationPrice | string | Estimated liquidation price |
unrealizedPnl | string | Unrealized profit/loss |
leverage | number | Current leverage |
marginUsed | string | Margin allocated |
marginMode | 'ISOLATED' | 'CROSS' | Margin mode |
API Reference: GET /positions