Trading Examples
Limit order vs. market order
When you open or decrease a position, you choose how the order is executed:
Type
isLimitOrder
isIocOrder
Behavior
Market order
false
—
Execute immediately at market. Use slippage (pricesSlippage, collateralSlippage) to bound worst price.
Limit order
true
false
Stored as a pending order; executes when the price condition is met. Typically use zero or small slippage (pricesSlippage: 0).
IOC limit order
true
true
Fill only if the limit can be met immediately; otherwise cancel (no partial fill).
Market: best for “get in/out now”; you accept some slippage.
Limit: best when you want a specific price; order stays pending until the price condition is met.
IOC limit: “fill at my price or not at all” in one block.
ZLP / SLP: Open position (market order)
Execute immediately with slippage protection:
const tx = await zlpAPI.openPositionV2(
'usdc', // collateral token
'btc', // index token
BigInt(1000000), // size
BigInt(100000), // collateral amount
['coinObjectId'], // coin objects
true, // long position
BigInt(50000), // reserve amount
30000, // index price (reference)
1.5, // collateral price (reference)
false, // isLimitOrder: false = market order
false, // isIocOrder (ignored for market)
0.003, // pricesSlippage: 0.3% for market
0.5, // collateralSlippage: 50% for market
BigInt(500), // relayer fee
'referralAddress',
'senderAddress'
)ZLP / SLP: Open position (limit order)
Pending order at your limit price; use zero or small slippage:
ZLP / SLP: Open position (IOC limit order)
Fill only if the limit can be met immediately; otherwise the order does not execute:
Last updated