Skip to Content
Symmio Trading-SDK — the SDK surface for builders on Arbitrum
CoreTP/SLsetQuoteTpSl

setQuoteTpSl

Submit a TP and/or SL order to the handler. Accepts one or both sides in a single call. Internally: resolves the handler URL + signing spec, rounds trigger prices and derives slippage-shifted fill prices via priceSlippageCalculation, builds a TpSlConditionalOrderMessage with non-null legs only, signs it with the session-key wallet client, and POSTs { typedData, signature, signer }.

A resolved call establishes submission acceptance, not confirmed creation or editing. Observe current order state through searchTpSlOrders. Notifications from watchTpSlNotifications can prompt reconciliation, but cannot identify which mutation completed or order successive changes.

import { setQuoteTpSl } from "@symmio/trading-core"; const { cohQuoteId } = await setQuoteTpSl(config, { from: sessionKey, quoteId: 42n, virtualAccount, subAccount, symbolId: 7n, positionType: PositionType.LONG, quantity: "100", pricePrecision: 4, tp: { triggerPrice: "150", priceType: "markPrice" }, sl: { triggerPrice: "80", priceType: "markPrice" }, });

Parameters

quoteIdbigintrequired

On-chain quote id (or a negative tempQuoteId for a pre-chain instant open).

virtualAccountAddressrequired

PartyA (the VA address) that owns the quote.

subAccountAddressrequired

SubAccount that owns the VA.

symbolIdbigintrequired

Solver market id.

positionTypePositionTyperequired

Quote direction (LONG / SHORT).

quantitystringrequired

Quote quantity (decimal string).

pricePrecisionnumberrequired

Market price precision (rounds prices to N decimals).

tpSetTpSlSideoptional

Take-profit side. Omit to skip TP.

slSetTpSlSideoptional

Stop-loss side. Omit to skip SL.

affiliateAddressoptional

Affiliate to bind to the order. Defaults to chainConfig.addresses.affiliatesAddress.

slippagenumberoptional

Slippage percent applied when deriving each leg’s fill price. Defaults to DEFAULT_TPSL_SLIPPAGE_LOWCAPS (90).

fromAddressoptional

Session-key signer the wallet client resolves for. Defaults to the connected wallet in the React layer.

chainIdnumberoptional

Target chain id. Defaults to the config’s defaultChainId.

At least one of tp or sl must be provided.

Returns

SetQuoteTpSlReturnType
successtrue

Always true on a resolved call (failures throw).

cohQuoteIdstringoptional

Handler-issued conditional-order id, when reported on the response.

Throws

  • SET_TPSL_INVALID_RESPONSE when successful is missing or is neither boolean true nor string "true" (explicit false / "false" instead yields SET_TPSL_REJECTED). A malformed response or transport failure may follow an accepted write: reconcile state before considering a retry.
  • Validation errors for zero or unsafe quote IDs and non-positive or unsafe symbol IDs. Negative temporary quote IDs are supported; numeric wire fields must represent the input exactly.
  • SymmError when the chain has no tpsl config, both tp and sl are omitted, or signing fails.
  • SymmApiError when the handler request fails.

Mutation options

A resolved call means submission acceptance, not confirmed creation. TP and SL can complete independently. Observe live order state through search; notifications can prompt a read but do not identify a particular mutation or provide an order revision. These are signed EIP-712 messages, not on-chain transactions. The action does not automatically retry writes.

import { setQuoteTpSlMutationOptions } from "@symmio/trading-core"; import { useMutation } from "@tanstack/react-query"; useMutation(setQuoteTpSlMutationOptions(config));

setQuoteTpSlMutationOptions returns { mutationKey, mutationFn, retry: false }; the mutationFn takes the same parameters object as the action. Automatic retries are explicitly disabled, including host-level mutation retry defaults. A lost acknowledgment, timeout or network error may follow an accepted write. Reconcile state before explicitly submitting again; do not override this policy without a proven replay guarantee.

Last updated on