Vault

The vault is an optional on-chain token custody mechanism. Orders prepared via the HTTP API default to fundingSource: "wallet", which pulls tokens directly from the caller's wallet when the order is placed (up front, not at a later fill) via the pool's auto-pull flow (needs a prior ERC-20 approval to the SpotPool contract, or msg.value on native pools). Wallet auto-pull supports all order types, including resting GTC / PostOnly.

To use the vault instead, deposit tokens first and then set fundingSource: "vault" when placing orders. The vault flow is:

  1. Approve the pool contract to spend your tokens.
  2. Deposit them into the vault.
  3. Place orders funded from the vault balance.

Vault-funded orders support all order types including resting limit orders.

Reading a native SOMI balance directly on-chain. When you call the vault's getWithdrawableBalance(owner, token) contract method for native SOMI, pass the sentinel 0x28f34DeFd2b4CB48d9eE6d89f2Be4Bc601694c00 (the NATIVE_TOKEN constant), not address(0) - the latter returns 0 and makes funds look missing. The HTTP vault/balance endpoint below abstracts this away. See getWithdrawableBalance.

POST /v0/markets/{symbol}/vault/approve

POST /v0/markets/{symbol}/vault/deposit

POST /v0/markets/{symbol}/vault/withdraw

GET /v0/markets/{symbol}/vault/balance