Skip to content

    Press / to search, [ and ] for the previous and next page.

    Developer reference

    EIP-712

    The exact typed data the contracts and the relayer verify. Type strings and hashes come from the contracts' exported constants and are checked against the TypeScript definitions at build time.

    Types

    TypeDomainWho signsVerified on-chain
    OpenPositionexchangewallet or session keyyes
    Type string OpenPosition(address user,uint32 instrumentId,bool isLong,uint128 size,uint32 leverage,bool useDebt,uint256 nonce,uint64 deadline)
    Typehash 0xfce2fb41f9ff0457a0f012e62cfd6a7cff4e8439ae20008ab6979c740ba5a983
    Closeexchangewallet or session keyyes
    Type string Close(address user,uint256[] positionIds,uint256 nonce,uint64 deadline)
    Typehash 0x9cc23a52214afa42e1ae53cdb2e79dc2d0cd33c33faca383ed3b149300adcb13
    WithdrawToCoreexchangewallet onlyyes
    Type string WithdrawToCore(address user,uint256 amount,uint256 nonce,uint64 deadline)
    Typehash 0xac4ddb8d63e9d7a862c5d61ce47517623a448262414a7eef6797102104b31214
    RegisterSessionKeyexchangewallet onlyyes
    Type string RegisterSessionKey(address user,address key,uint64 expiry,address feeAddress,uint256 nonce,uint64 deadline)
    Typehash 0xd3d9a309f635415423ab81e7e3fb16d2117cc8e1edc90506adde9eaa3855edd2
    RegisterSessionKeyV2exchangewallet onlyyes
    Type string RegisterSessionKeyV2(address user,address key,uint64 expiry,address feeAddress,uint64 maxBuilderFee,address referrer,uint256 nonce,uint64 deadline)
    Typehash 0x768549c4ec62ba892ffe75fc24ce07bdbe7e6b6f0f359e49248461f08920a885
    RevokeSessionKeysexchangewallet onlyyes
    Type string RevokeSessionKeys(address user,address[] keys,bool all,uint256 nonce,uint64 deadline)
    Typehash 0x01026316a272dd97577cb59b037b3a0753aaf9bb1e3e933c358f48655bc6f9a0
    Stakestakingwallet onlyyes
    Type string Stake(address user,uint256 amount,uint256 nonce,uint64 deadline)
    Typehash 0x0e9469f2731f138fe05733a3ab1961961d9def010d73419c3f5b55ae6d64e8b0
    Unstakestakingwallet onlyyes
    Type string Unstake(address user,uint256 amount,uint256 nonce,uint64 deadline)
    Typehash 0x1ecc9b0f79f4bb74abad4adb49babe57570219b3bc83a569a9b25299f833a9ce
    Claimstakingwallet onlyyes
    Type string Claim(address user,uint256 nonce,uint64 deadline)
    Typehash 0x98df9450683706f5e3c8e5a81515893081ae7460248fbba60c7781957adc9f8f
    Distributestakingwallet onlyyes
    Type string Distribute(address user,uint256 nonce,uint64 deadline)
    Typehash 0x23f3bc470a64f8283203a55adc575bcd5f81b7c537b6831c6886e4a0e2101e5a
    CancelIntentcancelwallet or session keyno (relayer only)
    Type string CancelIntent(address user,bytes32 intentId,uint256 deadline)
    Typehash 0xa35cd971369839445ca1bec7da15d6528a097bd9c3d0ebaf7d5d4f368f537b71

    EIP-712 domains: Mainnet · Chain id 999

    Not deployed yet. Addresses appear here once the deployment manifest exists.

    EIP-712 domains: Testnet · Chain id 998

    Not deployed yet. Addresses appear here once the deployment manifest exists.

    EIP-712 domains: Local devnet · Chain id 31337

    DomainNameVersionVerifying contractDomain separator
    exchangeBRAND Exchange10x7f15d9a4c024f5dfd02f05fdc29d878303557a7a0x32feb5fa802dc6038aa5b03343479b376a22e23d22111997dac15fa1c22d8234
    stakingBRAND Staking10x9884648892a3863f736c7b60717601402238f7e90x50b8602ac68d63e54de8bf922c15ad7033b27cabffb2f84e65928cb93215af9d
    cancelBRAND Intent Cancel10x7f15d9a4c024f5dfd02f05fdc29d878303557a7a0xa275f0050bf700eb0965aff68c4b08936432a7395dd933727c9eff930b8dbe1b

    Domains

    Three domains sign everything:

    • Exchange - verifying contract: the Exchange proxy. Trading, withdrawals and session keys. The SessionKeyManager verifies these signatures for the Exchange.
    • Staking - verifying contract: the Staking proxy. Stake, unstake, claim and distribute.
    • Cancel - verifying contract: the Exchange proxy, with its own name. Only the relayer checks it; no contract does.

    All three use the full four-field domain (name, version, chainId, verifyingContract). Both contracts expose their domain through ERC-5267 eip712Domain().

    Nonces and deadlines

    Nonces are unordered: each account has a bitmap, and a nonce n uses bit n mod 256 of word n / 256. Any unused nonce works, in any order. A nonce can be burned on-chain without signing anything by calling invalidateUnorderedNonces(word, mask) from the wallet.

    Clients sign deadlines 1 hour ahead; the relayer accepts deadlines up to 61 minutes ahead.

    Wire format

    On the wire every integer field is a canonical decimal string and every address and hash lowercase hex; the signature travels as v, r, s next to the message fields. High-s signatures are rejected.

    Intent ids

    The relayer keys each signed message by

    intentId = keccak256( keccak256(utf8(intentIdTag)) ‖ digest ‖ signer )
    

    packed without padding: the 32-byte tag hash, the 32-byte EIP-712 digest and the 20-byte recovered signer (the session key for session-signed messages). The tag of each network is listed on contracts. Signature bytes are not part of the id, so a malleated signature cannot produce a new id.

    Last updated: