Deposit/Withdrawal
Overview of deposit and withdrawal flow
Deposit
Token deposits can be made on any supported chains (list here)
To create a deposit request, users can follow the following steps:
Determine necessary deposit fee in WEI
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 |
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
- install Web3j CLI
web3j generate solidity -a <./path/to/Vault.json> -o <./out-path/to/Vault.java> -p <package-name>
Withdrawal
Follow the following steps to withdraw your tokens from Orderly Network:
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 Network 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 Withdraw
:
Example:
where:
Name | Type | Required | Description |
---|---|---|---|
brokerId | string | Y | Builder ID, the valid list can be found [here] |
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 | int | 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.
Example
The example code is very similar to the Orderly key registration, except it uses the EIP-712 on-chain domain and the signed message is different.