Place Isolated Order
Create an isolated position with isolated margin for a provided market / product.
An isolated position has its own dedicated margin for a given product. Opening an isolated position, creates a corresponding isolated subaccount that holds that margin. You can later view your isolated positions (and isolated subaccounts) via Isolated Positions. The cross-subaccount that creates the isolated position is known as the parent subaccount.
You can perform the following actions to manage your isolated positions:
Place Order: Use
PlaceOrder
to reduce/close your isolated position. The specifiedsender
needs to be the isolated subaccount for the providedproductId
.Transfer Quote: Use
TransferQuote
to increase/reduce your quote margin to/from the isolated subaccount. The specifiedsender
needs to be isolated subaccount for the providedproductId
.
Notes:
Isolated subaccounts can only transfer quote to/from the parent cross-subaccount.
Isolated subaccounts can sign
PlaceOrder
/TransferQuote
requests using the parent's wallet or the parent's linked signer.See Isolated Margin to learn more.
Rate limits
120 orders/minute or 2 orders/sec per wallet. (weight=5)
A max of 10 open isolated positions per address.
See more details in API Rate limits.
Request
Request Parameters
product_id
number
Yes
isolated_order
object
Yes
isolated_order.sender
string
Yes
Hex string representing the cross subaccount's 32 bytes (address + subaccount name) of the tx sender.
isolated_order.priceX18
string
Yes
Price of the order multiplied by 1e18.
isolated_order.amount
string
Yes
Quantity of the order multiplied by 1e18.
isolated_order.expiration
string
Yes
isolated_order.margin
bool
Yes
Amount of quote margin to transfer to the isolated position from the cross-subaccount.
isolated_order.nonce
string
Yes
signature
string
Yes
digest
string
No
Hex string representing a hash of the order.
borrow_margin
boolean
No
Whether the cross subaccount can borrow quote for the margin transfer into the isolated subaccount. If not provided, it defaults to true
.
id
number
No
Signing
See more details and examples in our signing page.
The solidity typed data struct that needs to be signed is:
sender
: a bytes32
sent as a hex string; includes the address and the subaccount identifier
priceX18
: an int128
representing the price of the order multiplied by 1e18, sent as a string. For example, a price of 1 USDC would be sent as "1000000000000000000"
amount
: an int128
representing the quantity of the order multiplied by 1e18, sent as a string. A positive amount means that this is a buy order, and a negative amount means this is a sell order.
margin
: an int128
representing the quote margin to transfer from the parent subaccount into the isolated subaccount multiplied by 1e18, sent as a string. Margin cannot be negative.
Order Expiration
expiration
: a time after which the order should automatically be cancelled, as a timestamp in seconds after the unix epoch, sent as a string. The most significant two bits of expiration
also encode the order type:
0
⇒ Default order, where it will attempt to take from the book and then become a resting limit order if there is quantity remaining
1
⇒ Immediate-or-cancel order, which is the same as a default order except it doesn’t become a resting limit order
2
⇒ Fill-or-kill order, which is the same as an IOC order except either the entire order has to be filled or none of it.
3
⇒ Post-only order, where the order is not allowed to take from the book. An error is returned if the order would cross the bid ask spread.
For example, to submit an IOC order with an expiration of 1000 seconds, we would set expiration as follows:
Reserved Bits
The 4th to 6th most significant bits in the expiration
field are reserved and must be unset. Orders using reserved bits will be rejected.
Order Nonce
nonce
: used to differentiate between the same order multiple times, and a user trying to place an order with the same parameters twice. Sent as a string. Encodes two bit of information:
Most significant
44
bits encoding the time in milliseconds (arecv_time
) after which the order should be ignored by the matching engineLeast significant
20
bits are a random integer used to avoid hash collisionsFor example, to place an order with a random integer of
1000
, and a discard time 50 ms from now, we would send a nonce of((timestamp_ms() + 50) << 20) + 1000)
Note: for signing you should always use the data type specified in the solidity struct which might be different from the type sent in the request e.g: nonce
should be an uint64
for Signing but should be sent as a string
in the final payload.
Response
Success
Failure
Last updated