Delegate the session key
Session keys are how you avoid wallet popups on every trade. Generate an ephemeral keypair, give it on-chain authority to sign for your sub-account for some bounded time window, and then let it sign all the EIP-712 trade messages off-chain. The InstantLayer verifies these delegations on every executeBatch / executeTemplate call: when your session key's signature recovers, the InstantLayer checks that the calldata's selector is in the active delegated set for (sub, sessionKey).
Signed by. Owner EOA. The call goes to the InstantLayer.
Function. grantDelegation(DelegationInfo info), where DelegationInfo is:
struct DelegationInfo {
Account account; // (subAccount, isPartyB=false)
address delegatedSigner; // the session key's address
bytes4[] selectors; // what they're allowed to sign for
uint256 expiryTimestamp; // unix seconds
}The selectors are where this gets subtle. You need five of them:
0xa6d66852
addMarginToNextVA: pre-funding a VA before opening a position
0xa7f3b34b
sendQuoteWithAffiliateAndData: opening a position
0x501e891f
requestToClosePosition: closing a position
0xeaa31b19
ID the COH (TP/SL service) keys delegations under
0x00000001
ID services use to verify session-key auth
The first three are real Symmio function selectors, and the InstantLayer checks them on every executeBatch. The last two are four-byte tags the off-chain services use as lookup keys when they answer "is this session key authorized to talk to me?"
Last updated

