Skip to content

Balances and Ledger ​

A balance answers how much is available now. The ledger answers which finalized movements changed that amount. Deposit and withdrawal details describe transaction progress. Use the appropriate resource for wallet displays, transaction tracking, and reconciliation.

Three balance amounts ​

Balances are maintained by account and asset type. USDT and ETH balances are separate; do not aggregate raw units across different assets.

FieldMeaningUsed for
available_amount_rawCurrently spendable fundsChecking funds before withdrawals/transfers
pending_withdraw_amount_rawFunds reserved for pending withdrawalsDisplaying pending withdrawal amounts
total_amount_rawAvailable funds plus withdrawal reservationsCurrent wallet holdings
decimalsThe decimal scale for raw unitsConverting to display amounts

When total and available balances differ, inspect pending withdrawal reservations. For uncompleted external deposits, retrieve deposit state rather than adding the detected amount to your own spendable-balance calculation.

Customer wallet withdrawal example ​

Assume a customer holds 100 USDT and withdraws 20 USDT externally with an illustrative 1 USDT fee. No other transactions are concurrent.

PointAvailableReservedTotalInterpretation
Before withdrawal1000100All funds are spendable
After acceptance7921100Reserve principal 20 + fee 1
Completed79079Reserved funds are withdrawn
Reservation released after failure/rejection/cancellation1000100Principal and fee become available again

Completion and release are different outcomes. Check final withdrawal detail and the returned balance together. These are display amounts; with decimals=6, the 21 USDT reservation is 21000000 raw units.

What a ledger entry represents ​

The ledger appends records of finalized balance movements. An entry represents one movement within a transaction, so multiple entries can refer to one transaction.

transaction_typeCodeentry_typeMeaning
DEPOSIT1000CREDITCompleted external deposit
WITHDRAW2000DEBITCompleted external withdrawal
INTERNAL_OUT3000DEBITInternal transfer sent
INTERNAL_IN4000CREDITInternal transfer received
ADJUSTMENT5000Depends on entryAdjustment movement

Names in the table describe meaning; the API returns numeric transaction_type codes. amount_raw is an absolute value: CREDIT increases funds and DEBIT decreases them. entry_code distinguishes principal, fees, and other entry purposes.

ref_type and ref_id link entries to a transaction. ref_type=1000 refers to a deposit; ref_type=2000 refers to a withdrawal or internal transfer. Distinguish principal and fee entries, then inspect all relevant entries with the same reference.

Reconcile balances and ledger entries ​

Reconciliation verifies that transactions, ledger entries, and balances agree. For a finalized interval involving one account and asset without other reservations or concurrent activity:

text
closing balance = opening balance + CREDIT total - DEBIT total

After a 100 USDT deposit and a completed 20 USDT withdrawal with a 1 USDT fee, the finalized balance is 79 USDT. When reservations are pending, do not substitute the available balance alone into this equation; account for reserved funds and the comparison interval.

Validate with raw amounts, balance_after_raw, and transaction references. Store account IDs with ledger_id and preserve ledger order. See Transaction Reconciliation for synchronization guidance.

Internal transfer and payment movements ​

An internal transfer records INTERNAL_OUT / DEBIT on the source account and INTERNAL_IN / CREDIT on the recipient. Both sides share the withdrawal reference; internal transfer fees are zero.

For example, a customer pays 10 USDT from a 100 USDT balance. The customer holds 90 USDT afterward, and a merchant with an initial zero balance holds 10 USDT. Other account transfers work the same way. Confirm individual transfers/payments through transaction detail rather than balance differences alone.

Interpret query results ​

An asset without activity may be absent from the all-balances response. A single-asset query can return BALANCE_NOT_FOUND when no balance exists; check the account, asset, and deposit state.

Follow Check Balances and Ledger for queries. Deposit Flow explains crediting, and Withdrawal Flow explains reservation and finalization.

OOLIN is a digital asset operations infrastructure product by BPMG.