Skip to main content
This guide shows you how to deposit tokens into vaults, set up the necessary approvals, and withdraw your funds.

Prerequisites

You need:
  • Tokens to deposit (e.g., USDC, MirrorTokens)
  • The token addresses
  • The vault addresses (look up via BookManager.getVault(currency))
  • The Controller and BookManager addresses
See Addresses for deployed contract addresses.

Step 1: Approve tokens for deposits

The Controller needs permission to transfer your tokens to deposit them into vaults.

TypeScript (viem)

Solidity

Step 2: Deposit into vaults

Once approved, deposit your tokens into their respective vaults via the Controller.

TypeScript (viem)

Solidity

Step 3: Approve vaults for trading

The BookManager needs permission to manage your vault shares during trading operations (locking, settling, etc.).

Get vault addresses

First, retrieve the vault addresses:

Approve vaults

Solidity

Step 4: Check your vault balance

You can check your vault balance at any time:

Step 5: Withdraw from vaults

To withdraw tokens back to your wallet:

TypeScript (viem)

Solidity

Note: Withdrawals will fail if you try to withdraw more than maxWithdraw(user). Cancel your open orders first to unlock collateral.

Summary

To start trading:
  1. Approve Controller on tokens (for deposits)
  2. Deposit tokens into vaults via Controller
  3. Approve BookManager on vaults (for trading)
  4. You’re ready to place orders!
To stop trading and withdraw:
  1. Cancel all open orders (to unlock collateral)
  2. Withdraw funds via Controller.withdrawFromVault

Troubleshooting

“Insufficient balance” when depositing:
  • Check your token balance with token.balanceOf(user)
  • Ensure you’ve approved enough tokens
“Insufficient available balance” when withdrawing:
  • Check vault.maxWithdraw(user)—you may have locked collateral
  • Cancel orders to unlock funds
“Transfer amount exceeds allowance” during trading:
  • Ensure you’ve approved the BookManager on the vault (not the token)

See also