Deposit

Token deposits can be made on any supported chains (list here)

To create a deposit request, users can follow the following steps:

1

Approve spending of the token by the Vault smart contract

Get Vault & USDC deposit address from here. All our smart contracts are verified, so you can get Vault & USDC ABI files via explorer, e.g. on Arbitrum Sepolia you can copy Vault ABI from here.

2

Determine necessary deposit fee in WEI

3

Call the `deposit` function of the smart contract

Contains the following structured data:

struct DepositData {
  bytes32 accountId;
  bytes32 brokerHash;
  bytes32 tokenHash;
  uint128 tokenAmount;
}

where:

NameTypeRequiredDescription
accountIdbytesYThe account id of the user in bytes.
brokerHashbytesYThe keccak256 hash of the builder id (eg “woofi_dex”)
tokenHashbytesYThe keccak256 hash of the token string (eg “USDC“)
tokenAmountintYAmount 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:

1

Choose a valid chain to withdraw your funds to

A list of supported chains can be found on our Smart Contract Addresses page.

2

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.

3

Obtain a withdrawal nonce

Get a nonce from Get Withdrawal Nonce API.

4

Obtain a signature from EIP-712

Sign an EIP-712 message of message type Withdraw:

"Withdraw": [
    {"name": "brokerId", "type": "string"},
    {"name": "chainId", "type": "uint256"},
    {"name": "receiver", "type": "address"},
    {"name": "token", "type": "string"},
    {"name": "amount", "type": "uint256"},
    {"name": "withdrawNonce", "type": "uint64"},
    {"name": "timestamp", "type": "uint64"},
]

Example:

{
  "brokerId": "woofi_pro",
  "chainId": 80001,
  "receiver": "0x036Cb579025d3535a0ADcD929D05481a3189714b",
  "token": "USDC",
  "amount": 1000000,
  "withdrawNonce": 1,
  "timestamp": 1685973017064
}

where:

NameTypeRequiredDescription
brokerIdstringYBuilder ID, the valid list can be found [here]
chainIdintYChain ID of the chain that the funds should be withdrawn to (within those that are supported by the Network)
receiverstringYAddress of the receiver, which should be equal to the address of the account.
tokenstringYThe string representation of the token that is being withdrawn (eg “USDC”)
amountintYAmount of tokens to be withdrawn
withdrawNonceintYValid withdrawal nonce from Get Withdrawal Nonce API
timestamptimestampYcurrent timestamp in UNIX milliseconds
5

Make a withdraw request

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.