Skip to main content
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.market.baseAsset.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

ParameterTypeRequiredDescription
clientPerpsSDKClientYesSDK client
params.providerstringYesDEX identifier
params.addressstringYesUser’s wallet address
params.marketIdstringNoFilter by the canonical Market.id (not display symbol)
params.limitnumberNoItems per page (default 50, max 100)
params.cursorstringNoPagination cursor from previous response
optionsSDKRequestOptionsNoRequest options

Returns

PositionsResponse:
FieldTypeDescription
providerstringProvider identifier
positionsPosition[]Open positions
paginationPaginationPagination metadata

Position fields

FieldTypeDescription
marketMarketDisplayMarket identity (providerId, id, categoryId, baseAsset, quoteAsset). Display symbol is market.baseAsset.displaySymbol.
side'LONG' | 'SHORT'Position direction
sizestringPosition size
entryPricestringAverage entry price
markPricestringCurrent mark price
liquidationPricestringEstimated liquidation price
unrealizedPnlstringUnrealized profit/loss
leveragenumberCurrent leverage
marginUsedstringMargin allocated
marginMode'ISOLATED' | 'CROSS'Margin mode
API Reference: GET /positions