Skip to Content
Symmio Trading-SDK — the SDK surface for builders on Arbitrum
CoreGaslessgetSessionKeySelectors

getSessionKeySelectors

The selector set to grant a session key. Resolves the chain’s contracts generation and unions the instant-trade lifecycle with gasless account management, de-duplicated.

import { getSessionKeySelectors, grantDelegation } from "@symmio/trading-core"; await grantDelegation(config, { account: { addr: subAccount, isPartyB: false }, delegatedSigner: sessionKeyAddress, selectors: getSessionKeySelectors(config, { chainId }), expiryTimestamp, gasless: true, });

Why one function instead of two constants

A session key needs authority from two different places: the trade lifecycle (sendQuote, requestToClosePosition, addMarginToNextVA) and gasless account management (allocate, margin, cancels, the operational-fee approval). Those sets are disjoint, and they are shaped differently — one is chain-dependent, because a v0.8.5 chain’s open leg is the legacy sendQuoteWithAffiliateAndData.

Granting only one of them is the common mistake, and it is not a compile error: grant the trade set and every account write still prompts the wallet; grant the account set and the key cannot trade. Either way the failure arrives much later as an on-chain InvalidDelegation. This function is the single answer.

One prompt, then silence

Because the contract enforces that grantDelegation is owner-only, this grant is the only wallet prompt a session key ever costs. Every write it covers afterwards is promptless — and, relayed, needs no native gas either.

Scope

chainIdnumberoptional

Optional chain override.

tradebooleanoptional

The instant trade lifecycle. Defaults to true.

accountbooleanoptional

Relayable account management. Defaults to true.

withdrawbooleanoptional

initiateWithdraw. Defaults to false — see below.

coreCallsbooleanoptional

AccountLayer _call, including delegated timelock approval requests. Defaults to false.

timelockSchedulingbooleanoptional

AccountLayer scheduleTimelockOp. Defaults to false, independently of coreCalls.

coreCalls grants broad Core-call authority, not a withdrawal-only permission. It is never enabled by withdraw: true or by solver capability detection. The consumer must explicitly request it with appropriate consent. These flags build a delegation scope; they do not configure the account’s timelock policy or submit an operation.

// Explicitly allow this key to sign protected withdrawal approval requests. const selectors = getSessionKeySelectors(config, { chainId, withdraw: true, coreCalls: true }); // Only if the key also needs to schedule operations, add timelockScheduling: true.

Values are derived from the pinned ABIs, normalized and de-duplicated. Existing scope order is preserved; optional Core-call and scheduling selectors are appended. For revocation, probe every scope the app could previously have granted, even when the current consent switch is off.

withdraw is opt-in because it is collateral-exit authority. initiateWithdraw takes a caller-supplied receiver, and Instant Layer delegation is selector-and-expiry only — there is no argument or value scope. A key holding it can move the sub-account’s collateral to any address it chooses, unattended, for the life of the grant.

finalizeWithdrawRequest and requestCancelWithdraw are in the default account scope and stay there: neither takes a receiver, so both can only complete or cancel a withdrawal whose destination the owner already fixed.

Returns

readonly Hex[]
The de-duplicated selector set for the requested scope on that chain.

Throws

SESSION_KEY_SELECTORS_UNSUPPORTED_CHAIN when account, withdraw, coreCalls, or timelockScheduling is requested on a chain whose contractsVersion is not "0.8.6". The account-management selectors exist only on perps-core 0.8.6 deployments, and the function refuses rather than silently returning a narrower set than you asked for.

Gate the scope on supportsGaslessService — which tests the same condition — and fall back to { account: false, withdraw: false } for a trade-only key:

const supported = supportsGaslessService(config, { chainId }); const selectors = getSessionKeySelectors(config, { chainId, account: supported, withdraw: false });

Gasless-wallet execution is a separate grant

This function covers the InstantLayer surface — trading, account management, withdrawals. It does not cover gaslessWalletExecute, which the GaslessLayer authorizes against its own sentinel selector plus each inner call selector. Build that set with getGaslessWalletExecuteSelectors and grant it alongside — in the same selectors array, or as its own grant.

Last updated on