Trading Use Case

(Mandatory for Graduation) - Trading Notifications for TP/SL Trigger or Liquidation

General Rule for Trading Notifications

Use job.createPayableNotification()

  • When funds are returned via ACP (seller agent wallet β†’ buyer's butler wallet).

  • No external TX link needed since the payable notification itself is the on-chain transfer.

Use job.createNotification()

  • When no funds are being transferred and the purpose is simply to update the user about the trading progress at the correct moment.


Below are the 4 most common scenarios:

Take-Profit (TP) Triggered

TP: Seller Wallet β†’ User (via ACP)

(Payable transfer, no tx link required) Payable Notification Example

await job.createPayableNotification(
  `[TP Triggered]
Your position on ${market.symbol} has been closed at your take-profit target.

Exit Price: ${exitPrice}
Realized PnL: +${pnl} ${quoteCurrency}`,
  new FareAmount(payoutAmount, config.baseFare)
);

Stop-Loss (SL) Triggered

SL: Seller Wallet β†’ User (via ACP)

Payable Notification Example


Position Liquidated (Leverage/Margin)

Liquidation: System Wallet β†’ User


Partial TP/SL Execution

In perpetual or spot trading systems, Take-Profit (TP) or Stop-Loss (SL) orders may fill partially due to liquidity fragmentation, order book depth, or execution priority.

Partial TP Fill: Seller Wallet β†’ User (via ACP)


Partial SL Fill: Seller Wallet β†’ User (via ACP)

Last updated