Skip to main content
Function:
ABI Object:
Parameters:
  • signer - The account signer
  • subaccount - The Trading Account object
  • market - The PerpMarket object
  • tp_trigger_price - Optional take-profit trigger price `<Option<u64>>`
  • tp_limit_price - Optional take-profit limit price `<Option<u64>>`
  • tp_size - Optional take-profit size `<Option<u64>>`
  • sl_trigger_price - Optional stop-loss trigger price `<Option<u64>>`
  • sl_limit_price - Optional stop-loss limit price `<Option<u64>>`
  • sl_size - Optional stop-loss size `<Option<u64>>`
  • builder_address - Optional builder address `<Option<address>>`
  • builder_fees - Optional builder fee `<Option<u64>>`, in units of 0.0001% (basis points × 100; e.g. 1000 = 10 bps = 0.1%, the protocol maximum). The TypeScript SDK takes basis points and does this conversion for you

Constraints

  • Requires an open position in the market (ENO_POSITION_FOR_TP_SL) and at least one of tp_trigger_price / sl_trigger_price
  • Each trigger is validated against the current mark price: for a long, the TP trigger must be above mark and the SL trigger below it; for a short, the reverse. A trigger on the wrong side aborts with EINVALID_TRIGGER_PRICE
  • tp_size / sl_size cannot exceed the open position size (EINVALID_TP_SL_SIZE)
Example: