Skip to main content

Accounts / Access Keys

Account Structure

A wallet owner can register an account on Orderly for each supported builder. Each wallet owner can thus have multiple accounts (not interlinked with each other) registered with Orderly.

Account ID

Each account is identified by an account ID, calculated as follows:
  1. Convert the wallet address to bytes
  2. Convert the keccak256 hash of the brokerId string to bytes
  3. Concatenate the results of (1) and (2)
  4. Take the keccak256 hash of (3) and convert back to a hex string

Authorization

Orderly uses the EIP-712 standard to authenticate wallets and accounts for critical actions, such as:
  • Account creation
  • Access key (Orderly Key) addition
  • Withdrawal requests
For these actions, wallet owners must sign specific messages from their wallet and pass the signature through the REST APIs. The following sections describe the steps needed to complete each action. Depositing into Orderly is a direct on-chain transaction that also requires signing from the wallet owner. For other actions, such as calling trading-related RESTful APIs, only the Orderly Key is required.

Access Key (Orderly Key)

Orderly uses the ed25519 elliptic curve standard for access keys. Users can generate access keys using any public ed25519 library and then add them to any account through a REST API. Access Key scopes are independent. Granting one scope does not grant any other scope:
  • read: Accesses private account data from endpoints that require read, plus designated account configuration APIs such as POST /v1/client/leverages and POST /v1/client/maintenance_config.
  • trading: Accesses order and trading operations that require the trading scope. A key with trading alone does not receive read access.
  • asset: Accesses asset operations that require the asset scope.
For a normal trading integration that also reads balances, positions, or other private account data, assign both scopes as read,trading. Add asset separately when the integration needs asset operations.
Access keys also have expirations for security reasons. The maximum allowed expiration is 365 days.

Account Registration

To register an account on Orderly:
  1. Choose a valid chain/builder to register the account on
  2. Check if the wallet is already registered via this API or if the account already exists via this API
  3. Get a nonce from the Get registration nonce API
  4. Sign a message from the wallet using the EIP-712 standard in the following format and obtain the signature:
where:

Add Access Key

To add a new access key on Orderly:
  1. Generate an ed25519 key pair
  2. Sign a message from the wallet using the EIP-712 standard in the following format and obtain the signature:
where:
  1. Send all the necessary information via the Add Orderly Key API
Users can also check the validity of a particular Orderly access key via the Get Orderly Key API.

Deposits / Withdrawals

Deposit

Token deposits can be made on any supported chain. To create a deposit request:
  1. Approve spending of the token by the smart contract
  2. Call the deposit function of the smart contract with the following structured data:
Note that deposits will take some time to reflect depending on the origin chain, to allow for finalization of the cross-chain transaction. Once the deposit is credited, the balance will update and the transaction can be seen on the Get asset history API.

Withdrawal

To withdraw tokens from Orderly:
  1. Choose a valid chain to withdraw your funds to
  2. Check if the chain has sufficient liquidity
  3. Get a withdrawal nonce
  4. Sign an EIP-712 message in the following format:
where:
  1. Call the request to withdraw API to complete the withdrawal request

Settle PnL

Any realized and unrealized PnL accrued from open or closed positions needs to be “settled” into the USDC balance of the account. PnL settlement can happen anytime for any account if other users trigger a settlement. Any user can also trigger PnL settlement of their own account by following these steps:
  1. Get a Settle PnL nonce
  2. Sign an EIP-712 message in the following format:
where:
  1. Call the Settle PnL API to complete the request