Free lesson · On-chain markets
Raw token amounts and economic event types
Open interactive lessonPractice calculationsExplore labs
Start with the idea
An event log records what a contract emitted. It does not automatically tell you who economically traded, what currency value changed or whether ownership changed.
Symbols, units & horizon
- q: displayed token units
- a_raw: nonnegative integer base units emitted by the contract
- d: token decimals, a nonnegative integer
- one verified token contract/version
When and why to use this
Build a data manifest with token units and economic event categories before estimating volume or wallet activity.
An event log records what a contract emitted. It does not automatically tell you who economically traded, what currency value changed or whether ownership changed.
Normalize raw integer amounts using token decimals verified at the relevant contract/version. Identify chain, block hash, transaction hash and event index to avoid duplicate logs.
Classify swaps, transfers, mints, burns and bridge operations separately. A transfer count can include self-transfers or exchange wallet management. Keep raw records so classifications can be audited and revised.
Raw token amounts and economic event types
- Read the raw integer amount without floating-point truncation.
- Obtain the token’s decimal convention from the correct contract/version.
- Divide by ten to that power and retain enough precision for reconciliation.
Raw amount 1,250,000 with six decimals is 1.25 token units. Interpreting it as an 18-decimal asset would be wrong by 10^12.
Apply it in a strategy
- Build a data manifest with token units and economic event categories before estimating volume or wallet activity.
- Record the input timestamp, executable quantity, currency and horizon. Reconcile the result with a cash-flow or state table.
- Stress this failure condition: Wrong decimals, duplicated logs and address-as-person assumptions can produce enormous but meaningless metrics.
Research deliverable
Build and explain a raw token amounts and economic event types worksheet. Build a data manifest with token units and economic event categories before estimating volume or wallet activity.
Evidence boundary: Synthetic arithmetic and scenarios illustrate mechanics. They are not historical returns, a paper replication, or evidence of an executable edge. Research sources and their access limitations are recorded at the end of this module.
Research sources, review dates and limitations
Python implementation
Self-contained teaching example. Python 3.10+; dependencies and input conventions are shown in the code and notation. Run in your own Python environment.
# Python 3.10+; standard library unless NumPy is imported below.
# Inputs and outputs use the units defined in this lesson. Synthetic teaching example.
from decimal import Decimal
def token_units(raw,decimals):
if not isinstance(raw,int) or raw<0 or not isinstance(decimals,int) or decimals<0: raise ValueError("Integer raw amount and decimals required")
return Decimal(raw)/(Decimal(10)**decimals)
print(token_units(1250000,6))Continue learning
On-Chain Markets: Data, Oracles and Execution — all lessons- Raw token amounts and economic event types
- Transaction gas in a reporting currency
- Minimum output and ordering risk
- Time-weighted reference prices
- Stale oracle health versus executable collateral value
- Bridge fragmentation and capital lock-up
- Inclusion, finality and conditional loss scenarios
- A reproducible on-chain economics study
Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations