Skip to main content
Avantis v2 has two distinct TP/SL mechanisms. Pick by whether you want to close the whole position or part of it:

Full-position TP/SL

None keeps a leg unchanged (the SDK copies its current value from the position — the signed intent always carries both legs). stop_loss=0 truly removes the SL. A position always has a TP on-chain, so take_profit=0 resets it to the pair’s max-gain cap (typically +2500%) instead of removing it.
v2 removed the public updateTpAndSl contract entry point, so this is intent-only: the SDK signs an UpdateTpSlReq and submits it to the core API, which executes it through the Avantis operator. The same path is used in relayer and execution="direct" mode. A success response means the update was accepted; with wait=True (default) the SDK polls the position until the new levels are visible.
You can also set TP/SL at open time; see market orders.

Partial TP/SL (trigger orders)

Signs a trigger order and stores it with the operator, who executes it on-chain when the price hits. Keep the returned dict: its entityId is your handle for updating and cancelling.
Existing triggers appear on Position.price_triggers when you fetch positions: partial orders carry is_global=False and a stored-order entityId; the global TP/SL shows up as is_global=True entries with deterministic global-tp-* / global-sl-* ids. Passing a global id to update_partial_tp_sl / cancel_partial_tp_sl raises a ValidationError — manage those levels with update_tp_sl.

Update a partial TP/SL

Replaces the stored order in place (atomic edit) with a freshly signed one. Pass the full new order, not a diff:
An update mints a new entityId (the backend deletes the old order and stores the replacement atomically). Always adopt the returned dict’s entityId — the one you passed in is gone.

Cancel a partial TP/SL

The cancel signs an EIP-712 CancelOffchainOrder message over the order’s entityId as proof of ownership. The trader key or an active delegate key both work.