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
quoteIdbigintrequiredOn-chain quote id (or a negative tempQuoteId for a pre-chain instant open).
virtualAccountAddressrequiredPartyA (the VA address) that owns the quote.
subAccountAddressrequiredSubAccount that owns the VA.
symbolIdbigintrequiredSolver market id.
positionTypePositionTyperequiredQuote direction (LONG / SHORT).
quantitystringrequiredQuote quantity (decimal string).
pricePrecisionnumberrequiredMarket price precision (rounds prices to N decimals).
Take-profit side. Omit to skip TP.
Stop-loss side. Omit to skip SL.
affiliateAddressoptionalAffiliate to bind to the order. Defaults to chainConfig.addresses.affiliatesAddress.
slippagenumberoptionalSlippage percent applied when deriving each leg’s fill price. Defaults to DEFAULT_TPSL_SLIPPAGE_LOWCAPS (90).
fromAddressoptionalSession-key signer the wallet client resolves for. Defaults to the connected wallet in the React layer.
chainIdnumberoptionalTarget chain id. Defaults to the config’s defaultChainId.
At least one of tp or sl must be provided.
Returns
SetQuoteTpSlReturnTypesuccesstrueAlways true on a resolved call (failures throw).
cohQuoteIdstringoptionalHandler-issued conditional-order id, when reported on the response.
Throws
SET_TPSL_INVALID_RESPONSEwhensuccessfulis missing or is neither booleantruenor string"true"(explicitfalse/"false"instead yieldsSET_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.
SymmErrorwhen the chain has notpslconfig, bothtpandslare omitted, or signing fails.SymmApiErrorwhen 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.
Related
SetTpSlSide— the per-side input shape.watchTpSlNotifications— notification signals for reconciliation.useSetQuoteTpSl/useInstantOpenWithTpSl— React bindings.