Place TP/SL order

Create a Take Profit or Stop Loss order. Orders are stored off-chain and executed on-chain when the stop price condition is met.

Order Types:

  • TAKE_PROFIT: Triggers when price moves favorably (long: price >= stop_price, short: price <= stop_price)
  • STOP_LOSS: Triggers when price moves unfavorably (long: price <= stop_price, short: price >= stop_price)

Stop Price Options:

  • MARK_PRICE: Use oracle mark price for trigger
  • LAST_TRADED_PRICE: Use last traded price for trigger

Signature: Signer signs VerifySignature with hash = keccak256(encodedTpslOrderData)

TPSL Order Encoding:

bytes[0:8]   = marketId (uint64, big-endian)
bytes[8:24]  = size (uint128, big-endian)
bytes[24:40] = limitPrice (uint128, big-endian, 0 for market order)
bytes[40:56] = stopPrice (uint128, big-endian)
bytes[56]    = flags: bit0=side, bit1=stopType(0=profit,1=loss), bit2=orderType(0=market,1=limit), bit3=stopPriceOption(0=mark,1=last)
Language
Click Try It! to start a request and see the response here!