Expand description
A blockchain wallet account holding unleveraged native and ERC-20 token balances.
The account is multi-currency with no base currency, no margin entries, and no borrowing:
every reported total is the observed on-chain balance and negative totals are rejected.
ERC-20 allowances are spender authorizations and are not represented as balances or locked
funds.
§Balance locking
Locked balances track local pending-order reservations per (InstrumentId, Currency),
without changing the reported on-chain totals: free = total - locked. Account state events
contribute totals only; locked and free balances are always derived from local reservations.
Rebuilding an instrument reservation clears its prior currency locks before applying the new
exact set. Computed BUY notionals for non-inverse, non-quanto instruments round up to the
observed currency’s smallest unit so the reservation never understates the possible spend.
§Graceful degradation
When total locked exceeds total balance (e.g., due to on-chain state latency), the account clamps locked to total rather than raising an error. This yields zero free balance, preventing new orders while avoiding crashes in live trading.