deepbookv3-balance-manager
Installation
SKILL.md
DeepBook V3: BalanceManager
BalanceManager is a shared object (sui::object::UID) in DeepBook V3 that holds and manages all user balances for various assets (both base and quote tokens). Except for direct swaps, almost all trading operations in DeepBook V3 require a BalanceManager as an input.
1. Key Concepts
Shared Object Design
- Single Manager for All Pools: A trader can use a single
BalanceManageracross all pools they interact with (e.g. SUI/USDC, DEEP/SUI). - Settlement: When orders match, funds are directly deposited into or withdrawn from the
BalanceManager's internal balances.
TradeProofs and Equivocation
To execute any trade, you must provide a BalanceManager and a TradeProof to verify authorization. There are two ways to obtain a TradeProof:
- Direct Owner: Generated directly by the owner of the
BalanceManager. Since this does not require an owned object parameter (it operates on the shared manager itself with the transaction sender being the owner), there is no risk of equivocation. High-frequency trading (HFT) engines should always trade as the default owner. - Cap Owner: Generated by a holder of a
TradeCap. SinceTradeCapis an owned object, sending it in a transaction carries the risk of equivocation (double-spending or locking the object in consensus).