Base units
Base units are the smallest amounts a chain or a token can count. One ETH is 10¹⁸ wei, one SOL is 10⁹ lamports, and one BTC is 10⁸ satoshis. One ERC-20 token is 10 to the power of its decimals in base units. Chains store whole numbers of base units, so amounts stay exact.
In BlockJuice
BlockJuice keeps amounts in base units from the raw table to the mart. analytics.latest_balances holds each balance in the asset’s base units: wei for ETH, lamports for SOL, satoshis for BTC, and token units for an ERC-20 or SPL token. The value of erc20_transfers, the amounts in dex_trades and the amount of bridge_transfers are in the token’s base units too.
To turn base units into whole tokens, divide by 10 to the power of the token’s decimals. analytics.tokens holds the decimals of each token you list, read from its contract. A null means the contract does not say, so do not assume 18. Join on chain and token, never on symbol, because several tokens share a symbol.
A few tables use whole units instead, and say so. Polymarket amounts are whole pUSD and whole shares. oracle_prices scales each Chainlink answer by the feed’s decimals into a price in quote units.
Example
This query turns ERC-20 transfers into whole tokens. Casting 10 to numeric keeps the division in numeric, not floating point.
select t.block_timestamp, k.symbol, t.value / power(10::numeric, k.decimals) as amount
from analytics.erc20_transfers t
join analytics.tokens k using (chain, token)
where k.decimals is not null
order by t.block_timestamp desc
limit 20