The Precision Challenge
Cosmos SDK and Ethereum use different decimal precisions for their native tokens:- Cosmos SDK: 6 decimals (1 ATOM = 10^6 uatom)
- Ethereum: 18 decimals (1 ETH = 10^18 wei)
PreciseBank Solution
The PreciseBank module solves this by decomposing balances into integer and fractional components:a(n) in smallest units:
a(n)= Total balance in 18-decimal units (atest)b(n)= Integer balance in 6-decimal units (uatom) - stored in x/bankf(n)= Fractional balance (remainder) - stored in x/precisebank- Constraint:
0 ≤ f(n) < 10^12
Example
Balance of 1,234,567,890,123,456,789 atest decomposes to:Reserve Backing
A module reserve account maintains supply consistency:Implementation
Storage:- 6-decimal amounts stored in existing bank module
- Only fractional remainders stored separately in precisebank
- Full 18-decimal precision reconstructed on query
Why This Approach
Backward Compatibility: Existing bank module continues to work unchanged for non-EVM operations. Storage Efficiency: Only stores fractional amounts when needed, not full 18-decimal balances for every account. Precision Guarantee: No rounding or precision loss - every atest is tracked accurately. Performance: Single multiplication and addition reconstructs full precision without expensive arbitrary-precision math.Related Documentation
- PreciseBank Module Reference - Full implementation details
- VM Module Configuration - Extended denomination setup