Skip to main content
Adjust the margin on an isolated position via PerpsClient.updatePositionMargin. The SDK-managed agent signs the action; the user’s wallet is not prompted.
The examples on this page use Hyperliquid (provider: 'hyperliquid'). Replace the provider value with any supported DEX from getProviders().

updatePositionMargin

const result = await perps.updatePositionMargin({
  provider: 'hyperliquid',
  address: userAddress,
  market: { marketId: 'BTC', categoryId: 'hyperliquid' },
  action: 'add',
  amount: '500.00',
});
Pass action: 'remove' (with a positive amount) to withdraw margin from the position without changing its size. API Reference: POST /createAction · /executeAction