Skip to Content
Symmio Trading-SDK — the SDK surface for builders on Arbitrum
Session KeyProvider integration

Provider integration

Session keys are wired into @symmio/trading-react through SymmioProvider’s getWalletClient resolver. Every SDK write that passes from: sessionKeyAddress routes signing through the session-key manager; every other write routes to the wagmi-connected wallet.

The resolver

getWalletClient has the signature ({ chainId, from }) => Promise<SymmioWalletClient>. Return a session-key-backed client when from matches the loaded session key, otherwise fall through to the wagmi wallet:

function useAppGetWalletClient(manager: SessionKeyManager) { return useCallback( async ({ chainId, from }: { chainId: number; from?: Address }) => { const sessionAddress = manager.getAddress(); if (sessionAddress && from?.toLowerCase() === sessionAddress.toLowerCase()) { return sessionKeyWalletClient(manager, chainId); } return await getWalletClient(wagmiConfig, { chainId }); }, [manager], ); } <SymmioProvider symmioConfig={{ [SymmioSupportedChainId.ARBITRUM]: { addresses: { affiliatesAddress: "0xYourRegisteredAffiliate…" } }, }} getWalletClient={useAppGetWalletClient(manager)} > {children} </SymmioProvider>;

sessionKeyWalletClient(manager, chainId) is a small helper the consuming app owns — it turns the session-key private key into a viem walletClient bound to the chain. @symmio/session-key does not ship it; the manager gives you the address (getAddress) and the signing primitives (sign, signTypedData) to build one. Every SDK write that sets from to the session key’s address then signs via this path without a wallet prompt.

When you leave getWalletClient unset, SymmioProvider defaults to the wagmi wallet for every write — so a wallet popup on every action. Providing this resolver is what makes trading popup-free.

Which actions sign with the session key

These route through the session-key manager when from is the session-key address:

  • TP/SL — useSetQuoteTpSl, useDeleteQuoteTpSl (EIP-712 conditional-order message).
  • Instant Open — useInstantOpen, useInstantOpenAuto, useInstantOpenWithTpSl (EIP-712 open + optional TP/SL leg).
  • Instant Close — useInstantClose, useInstantCloseAuto, and their bulk variants.
  • Relayable account management — allocate, deallocate, add/remove margin, the quote and close cancels, withdraw completion and cancellation, and the operational-fee approval. Pass from alongside gasless and the write is signed by the key and relayed, with no wallet prompt and no native gas. These need the account scope of getSessionKeySelectors, which exists only on perps-core 0.8.6 chains.
  • Withdrawal initiation — only when the key was granted the opt-in withdraw scope.

Which actions stay on the connected wallet

These always route to the owner wallet, regardless of session-key configuration:

  • Wallet connect / disconnect / chain switch — not signing, just wagmi calls.
  • Grant delegation — the act of authorizing the key. The contract enforces it: _verifyOperation routes any operation targeting the Instant Layer to _verifyGrantOperation, which rejects a signer that is not the account owner. This is the floor — one prompt, and no SDK change removes it.
  • Revoking a delegation — initiateRevokeDelegation and finalizeRevokeDelegation also target the Instant Layer, so they cannot be relayed and always cost native gas — including when the key revokes itself.
  • Deposits — depositForAccount and depositAndAllocateForAccount pull the owner’s ERC-20 collateral, which the key holds no allowance for.
  • Account creation, deletion and renaming — createSubAccounts carries no onlyAccountOwner guard, so the Instant Layer’s scope cannot confine it; the other two stay owner-signed by product decision.

A session key that is not the account owner cannot take the wallet path as a fallback. CoreFacet._call is onlyAccountOwner, and the key holds no native gas, so a write sent with from: sessionKeyAddress and gasless: false reverts NotOwner. Pair from with the relay, or send from the owner.

The imports above (useCallback, getWalletClient from wagmi/actions, wagmiConfig) come from your app. SessionKeyManager and Address come from @symmio/session-key and viem. SymmioProvider comes from @symmio/trading-react.

Last updated on