[!TIP]
Deposit Method Selection:
This page explains Standard Vault Deposit, where the user connects their wallet and invokes the smart contract deposit function.
If your users are depositing from a Centralized Exchange (CEX) or using a custodial wallet that does not support DApps, refer to the Deposit by Transfer guide.
Deposit
Token deposits can be made on any supported chains (list here) To create a deposit request:Approve spending of the token by the Vault smart contract
Get Vault & USDC contract addresses from the Smart Contract Addresses page.
All our smart contracts are verified, meaning you can retrieve the Vault & Token ABIs from the block explorers of any supported mainnets or testnets.
[!IMPORTANT] The addresses and RPC nodes used in the following examples are for Arbitrum Sepolia testnet. Since Orderly is an omnichain protocol, when deploying to production, replace these with the correct contract addresses and RPC endpoints for your target chain.
Example code
Example code
Call the `deposit` function of the smart contract
Contains the following structured data:where:
| Name | Type | Required | Description |
|---|---|---|---|
| accountId | bytes | Y | The account id of the user in bytes. |
| brokerHash | bytes | Y | The keccak256 hash of the builder id (eg “woofi_dex”) |
| tokenHash | bytes | Y | The keccak256 hash of the token string (eg “USDC”) |
| tokenAmount | int | Y | Amount of tokens to be deposited |
Example code
Example code
Deposits will take some time to reflect depending on the origin chain, to allow for finalizing of
the cross-chain transaction involved in the deposit. Once the deposit is credited, the balance
will update and the transaction can be seen on the Get asset history
API.
Full example
Code generation via ABI file
Code generation via ABI file
- Java
- TypeScript
- install Web3j CLI
web3j generate solidity -a <./path/to/Vault.json> -o <./out-path/to/Vault.java> -p <package-name>
Withdrawal
[!WARNING]
PnL Settlement Requirement: Any realized profit from open or recently closed positions must be settled via the Settle PnL flow before it can be added to your withdrawable_balance. If you attempt to withdraw without settling your PnL, the withdrawal amount may exceed your available balance and fail. See Settle PnL for details.
To withdraw tokens from Orderly:
Choose a valid chain to withdraw your funds to
A list of supported chains can be found on our Smart Contract Addresses page.
Check if the chain has sufficient liquidity
Since Orderly is an omnichain trading infrastructure, the liquidity of withdrawn assets might need to move across chains. If there is not enough liquidity of the withdrawn asset on the target chain, then an
additional cross-chain transaction fee will be deducted from the user’s account.
Obtain a withdrawal nonce
Get a nonce from Get Withdrawal Nonce API.
Obtain a signature from EIP-712
Sign an EIP-712 message of message type Example:where:
Withdraw:| Name | Type | Required | Description |
|---|---|---|---|
| brokerId | string | Y | The unique identifier of the Builder (also known as Broker ID). A list of valid IDs can be retrieved via the Get list of builders API. |
| chainId | int | Y | Chain ID of the chain that the funds should be withdrawn to (within those that are supported by the Network) |
| receiver | string | Y | Address of the receiver, which should be equal to the address of the account. |
| token | string | Y | The string representation of the token that is being withdrawn (eg “USDC”) |
| amount | string | Y | Amount of tokens to be withdrawn |
| withdrawNonce | int | Y | Valid withdrawal nonce from Get Withdrawal Nonce API |
| timestamp | timestamp | Y | current timestamp in UNIX milliseconds |
Make a withdraw request
Call the Create withdraw request API.
Full Example
Unlike key registration which uses the off-chain domain, a withdrawal signature requires the on-chain domain targeting the Orderly Ledger contract. Furthermore, note the type formatting difference:- In the EIP-712 cryptography signature message,
amountmust be represented as a numeric value (uint256/BigInt). - In the final REST API JSON payload, the
amountfield must be serialized as a String.