Skip to Content
Symmio Trading-SDK — the SDK surface for builders on HyperEVM
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 }.

The handler returns 200 on accept, but the order is only “confirmed” once the WebSocket reports state: "new" and successful: true. Callers should subscribe via watchTpSlNotifications and reconcile — the React layer does this automatically.

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

  • 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

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

setQuoteTpSlMutationOptions returns { mutationKey, mutationFn }; the mutationFn takes the same parameters object as the action.

Last updated on