Skip to main content

Build Close Position REST API Endpoint

Build close position action. Queries position, builds market close order, returns hash to sign.

Updated on
May 19, 2026
info

Exchange API calls do not consume Quicknode API credits. Transactions through this endpoint are appended with a builder fee. See hyperliquidapi.com for a full breakdown. To white-label with your own builder code, contact us.


Body Parameters

action
object
REQUIRED

Close position action object

type
string

Action type ("closePosition")

asset
string

Asset name to close (e.g., "BTC", "ETH", "MEGA")

user
string

User address (0x-prefixed hex string)

fraction
number

Fraction of position to close (0-1, defaults to 1.0 for full close)

slippage
number

Optional slippage tolerance as a decimal (e.g. 0.05 = 5%). Default 3%. Range 0.1% to 10%. Applied to the market-style close order price.

priorityFee
integer or string

Optional priority fee rate. The value is interpreted as p / 100000000 of filled notional, so 10000 equals 1 basis point and the maximum is 80000 (8 basis points). Applies only to IOC orders; the generated close order is a market-style IOC order, so it is eligible. Charged from the undelegated staking HYPE balance (use Build Priority Funding Deposit to fund it). Not available for outcome assets.

Returns

hash
string

Hash to sign with wallet (0x-prefixed hex string)

nonce
integer

Unique nonce for this action (timestamp in milliseconds)

action
object

Processed action object in wire format - market close order with IOC tif and 3% slippage

type
string

Action type ("order")

orders
array

Array of order objects in wire format

a
integer

Asset index (0 for BTC, 1 for ETH, 217 for MEGA, etc.)

b
boolean

Buy side (false for closing long, true for closing short)

p
string

Computed price with 3% slippage applied (stringified number)

s
string

Size to close as a stringified number

r
boolean

Reduce-only flag (true for close position orders)

t
object

Order type specification (IOC limit)

limit
object

Limit order type

tif
string

Time in force ("Ioc" - Immediate or Cancel)

grouping
string

Order grouping strategy: "na" (Normal Action)

isSpot
boolean

Whether this is a spot market order

builderFee
string

Builder fee as percentage string (e.g., "0.04%")

builderFeeRaw
integer

Builder fee in basis points (e.g., 40 = 0.04%)

builder
string

Builder address (0x-prefixed hex string)

nextStep
string

Instructions for next step: sign the hash with private key (ECDSA), then POST /exchange with action, nonce, and signature (r, s, v)

priorityFee
integer

Priority fee rate, if specified in the request. The value is interpreted as p / 100000000 of filled notional, so 10000 equals 1 basis point and the maximum is 80000 (8 basis points).

closePositionContext
object

Additional context about the close position operation

originalAction
string

Original action type ("closePosition")

asset
integer

Asset index

assetName
string

Asset name (e.g., "MEGA", "BTC")

isSpot
boolean

Whether this is a spot market

positionSide
string

Current position side ("long" or "short")

positionSize
number

Current position size (absolute value)

closeSize
number

Size being closed (absolute value)

fraction
number

Fraction of position closed (1.0 for full close)

closeSide
string

Order side to close position ("sell" for long, "buy" for short)

midPrice
number

Current mid price

slippedPrice
string

Price with 3% slippage applied (stringified number)

Request
Don't have an account yet?
Create your Quicknode endpoint in seconds and start building
Get started for free