amounts 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -0
- data/README.md +26 -1
- data/lib/amount/active_record/railtie.rb +15 -0
- data/lib/amount/display.rb +26 -8
- data/lib/amount/registry.rb +5 -2
- data/lib/amount/serialization.rb +5 -0
- data/lib/amount/version.rb +1 -1
- data/lib/amounts.rb +12 -0
- data/lib/generators/amount/active_record/registry_generator.rb +60 -0
- data/lib/generators/amount/active_record/templates/presets/all.fragment +494 -0
- data/lib/generators/amount/active_record/templates/presets/crypto.fragment +180 -0
- data/lib/generators/amount/active_record/templates/presets/fiat.fragment +163 -0
- data/lib/generators/amount/active_record/templates/presets/metals.fragment +151 -0
- data/lib/generators/amount/active_record/templates/registry.rb.tt +33 -0
- data/test/test_active_record.rb +4 -4
- data/test/test_amount.rb +65 -2
- data/test/test_registry_generator.rb +104 -0
- metadata +14 -7
- data/LICENSE.txt +0 -21
- data/test/dummy/log/development.log +0 -0
|
@@ -0,0 +1,494 @@
|
|
|
1
|
+
# Registry overview:
|
|
2
|
+
# Major Fiat Currencies:
|
|
3
|
+
# - This preset is a curated basket of widely used fiat currencies for general product and treasury workflows.
|
|
4
|
+
# - Minor-unit precision follows ISO-4217-style currency fractions: most entries use 2 decimals, while JPY uses 0.
|
|
5
|
+
# - Display symbols are English-oriented defaults inspired by CLDR conventions and may need localization in real applications.
|
|
6
|
+
# - Source: Unicode CLDR currency symbols and localization notes: https://cldr.unicode.org/translation/currency-names-and-symbols/currency-names
|
|
7
|
+
#
|
|
8
|
+
# Precious And Industrial Metals:
|
|
9
|
+
# - This preset is a curated basket of metals commonly tracked in treasury, vault, and commodities workflows.
|
|
10
|
+
# - Display-unit conversion factors use standard mass relationships such as troy-ounce to gram and kilogram to pound.
|
|
11
|
+
# - Storage decimals here are preset defaults chosen for application headroom; they are not exchange-mandated market standards.
|
|
12
|
+
# - Source: NIST precious-metals conversion guidance: https://www.nist.gov/pml/weights-and-measures/laws-and-regulations/precious-metals-conversion
|
|
13
|
+
# - Source: NIST metric and customary conversion guidance: https://www.nist.gov/pml/weights-and-measures/common-conversion-factors-ii
|
|
14
|
+
#
|
|
15
|
+
# Large-Cap Crypto Assets:
|
|
16
|
+
# - This preset is a curated basket of prominent crypto assets intended for developer-facing ledgers and wallet-style products.
|
|
17
|
+
# - It is not a literal mirror of any single market-cap top-20 list; the basket favors assets with broadly understood denomination conventions and common integration relevance.
|
|
18
|
+
# - Where an asset is multichain, the preset documents the denomination convention the initializer assumes.
|
|
19
|
+
# - Source: Large-cap market snapshot used as a selection input on April 24, 2026: https://coinmarketcap.com/historical/20260424/
|
|
20
|
+
|
|
21
|
+
# USD: United States dollar.
|
|
22
|
+
# Fact: Uses 2 decimal places for cents.
|
|
23
|
+
# Preset default: Uses "$" as the default display symbol in an English-oriented UI.
|
|
24
|
+
# Preset default: Renders as a prefix amount, for example "$12.34".
|
|
25
|
+
# Source: Currency symbol conventions: https://cldr.unicode.org/translation/currency-names-and-symbols/currency-names
|
|
26
|
+
Amount.register :USD,
|
|
27
|
+
decimals: 2,
|
|
28
|
+
display_symbol: "$",
|
|
29
|
+
display_position: :prefix,
|
|
30
|
+
ui_decimals: 2
|
|
31
|
+
|
|
32
|
+
# EUR: Euro.
|
|
33
|
+
# Fact: Uses 2 decimal places for cents.
|
|
34
|
+
# Preset default: Uses the euro sign as the default display symbol.
|
|
35
|
+
# Preset default: Renders as a prefix amount for a compact English-oriented default.
|
|
36
|
+
# Source: Currency symbol conventions: https://cldr.unicode.org/translation/currency-names-and-symbols/currency-names
|
|
37
|
+
Amount.register :EUR,
|
|
38
|
+
decimals: 2,
|
|
39
|
+
display_symbol: "€",
|
|
40
|
+
display_position: :prefix,
|
|
41
|
+
ui_decimals: 2
|
|
42
|
+
|
|
43
|
+
# GBP: British pound sterling.
|
|
44
|
+
# Fact: Uses 2 decimal places for pence.
|
|
45
|
+
# Preset default: Uses the pound sign as the default display symbol.
|
|
46
|
+
# Preset default: Renders as a prefix amount.
|
|
47
|
+
# Source: Currency symbol conventions: https://cldr.unicode.org/translation/currency-names-and-symbols/currency-names
|
|
48
|
+
Amount.register :GBP,
|
|
49
|
+
decimals: 2,
|
|
50
|
+
display_symbol: "£",
|
|
51
|
+
display_position: :prefix,
|
|
52
|
+
ui_decimals: 2
|
|
53
|
+
|
|
54
|
+
# JPY: Japanese yen.
|
|
55
|
+
# Fact: Uses 0 decimal places under standard minor-unit conventions.
|
|
56
|
+
# Preset default: Uses the yen sign as the default display symbol.
|
|
57
|
+
# Preset default: Renders as a prefix amount with no fractional UI digits.
|
|
58
|
+
# Source: Currency symbol conventions: https://cldr.unicode.org/translation/currency-names-and-symbols/currency-names
|
|
59
|
+
Amount.register :JPY,
|
|
60
|
+
decimals: 0,
|
|
61
|
+
display_symbol: "¥",
|
|
62
|
+
display_position: :prefix,
|
|
63
|
+
ui_decimals: 0
|
|
64
|
+
|
|
65
|
+
# CHF: Swiss franc.
|
|
66
|
+
# Fact: Uses 2 decimal places for rappen/centimes.
|
|
67
|
+
# Preset default: Uses the ISO code as the display symbol to avoid locale ambiguity.
|
|
68
|
+
# Preset default: Renders as a suffix amount, for example "12.34 CHF".
|
|
69
|
+
# Source: Currency symbol conventions: https://cldr.unicode.org/translation/currency-names-and-symbols/currency-names
|
|
70
|
+
Amount.register :CHF,
|
|
71
|
+
decimals: 2,
|
|
72
|
+
display_symbol: "CHF",
|
|
73
|
+
display_position: :suffix,
|
|
74
|
+
ui_decimals: 2
|
|
75
|
+
|
|
76
|
+
# CAD: Canadian dollar.
|
|
77
|
+
# Fact: Uses 2 decimal places for cents.
|
|
78
|
+
# Preset default: Uses "CA$" instead of plain "$" to avoid collision with USD.
|
|
79
|
+
# Source: Currency symbol conventions: https://cldr.unicode.org/translation/currency-names-and-symbols/currency-names
|
|
80
|
+
Amount.register :CAD,
|
|
81
|
+
decimals: 2,
|
|
82
|
+
display_symbol: "CA$",
|
|
83
|
+
display_position: :prefix,
|
|
84
|
+
ui_decimals: 2
|
|
85
|
+
|
|
86
|
+
# AUD: Australian dollar.
|
|
87
|
+
# Fact: Uses 2 decimal places for cents.
|
|
88
|
+
# Preset default: Uses "A$" instead of plain "$" to avoid collision with USD.
|
|
89
|
+
# Source: Currency symbol conventions: https://cldr.unicode.org/translation/currency-names-and-symbols/currency-names
|
|
90
|
+
Amount.register :AUD,
|
|
91
|
+
decimals: 2,
|
|
92
|
+
display_symbol: "A$",
|
|
93
|
+
display_position: :prefix,
|
|
94
|
+
ui_decimals: 2
|
|
95
|
+
|
|
96
|
+
# NZD: New Zealand dollar.
|
|
97
|
+
# Fact: Uses 2 decimal places for cents.
|
|
98
|
+
# Preset default: Uses "NZ$" instead of plain "$" to avoid collision with USD.
|
|
99
|
+
# Source: Currency symbol conventions: https://cldr.unicode.org/translation/currency-names-and-symbols/currency-names
|
|
100
|
+
Amount.register :NZD,
|
|
101
|
+
decimals: 2,
|
|
102
|
+
display_symbol: "NZ$",
|
|
103
|
+
display_position: :prefix,
|
|
104
|
+
ui_decimals: 2
|
|
105
|
+
|
|
106
|
+
# SGD: Singapore dollar.
|
|
107
|
+
# Fact: Uses 2 decimal places for cents.
|
|
108
|
+
# Preset default: Uses "S$" instead of plain "$" to avoid collision with USD.
|
|
109
|
+
# Source: Currency symbol conventions: https://cldr.unicode.org/translation/currency-names-and-symbols/currency-names
|
|
110
|
+
Amount.register :SGD,
|
|
111
|
+
decimals: 2,
|
|
112
|
+
display_symbol: "S$",
|
|
113
|
+
display_position: :prefix,
|
|
114
|
+
ui_decimals: 2
|
|
115
|
+
|
|
116
|
+
# HKD: Hong Kong dollar.
|
|
117
|
+
# Fact: Uses 2 decimal places for cents.
|
|
118
|
+
# Preset default: Uses "HK$" instead of plain "$" to avoid collision with USD.
|
|
119
|
+
# Source: Currency symbol conventions: https://cldr.unicode.org/translation/currency-names-and-symbols/currency-names
|
|
120
|
+
Amount.register :HKD,
|
|
121
|
+
decimals: 2,
|
|
122
|
+
display_symbol: "HK$",
|
|
123
|
+
display_position: :prefix,
|
|
124
|
+
ui_decimals: 2
|
|
125
|
+
|
|
126
|
+
# CNY: Chinese yuan renminbi.
|
|
127
|
+
# Fact: Uses 2 decimal places for jiao/fen display.
|
|
128
|
+
# Preset default: Uses "CN¥" to avoid confusion with other yen/yuan symbols in multi-currency UIs.
|
|
129
|
+
# Source: Currency symbol conventions: https://cldr.unicode.org/translation/currency-names-and-symbols/currency-names
|
|
130
|
+
Amount.register :CNY,
|
|
131
|
+
decimals: 2,
|
|
132
|
+
display_symbol: "CN¥",
|
|
133
|
+
display_position: :prefix,
|
|
134
|
+
ui_decimals: 2
|
|
135
|
+
|
|
136
|
+
# INR: Indian rupee.
|
|
137
|
+
# Fact: Uses 2 decimal places for paise.
|
|
138
|
+
# Preset default: Uses the rupee sign as the default display symbol.
|
|
139
|
+
# Preset default: Renders as a prefix amount.
|
|
140
|
+
# Source: Currency symbol conventions: https://cldr.unicode.org/translation/currency-names-and-symbols/currency-names
|
|
141
|
+
Amount.register :INR,
|
|
142
|
+
decimals: 2,
|
|
143
|
+
display_symbol: "₹",
|
|
144
|
+
display_position: :prefix,
|
|
145
|
+
ui_decimals: 2
|
|
146
|
+
|
|
147
|
+
# MXN: Mexican peso.
|
|
148
|
+
# Fact: Uses 2 decimal places for centavos.
|
|
149
|
+
# Preset default: Uses "MX$" instead of plain "$" to avoid collision with USD.
|
|
150
|
+
# Source: Currency symbol conventions: https://cldr.unicode.org/translation/currency-names-and-symbols/currency-names
|
|
151
|
+
Amount.register :MXN,
|
|
152
|
+
decimals: 2,
|
|
153
|
+
display_symbol: "MX$",
|
|
154
|
+
display_position: :prefix,
|
|
155
|
+
ui_decimals: 2
|
|
156
|
+
|
|
157
|
+
# BRL: Brazilian real.
|
|
158
|
+
# Fact: Uses 2 decimal places for centavos.
|
|
159
|
+
# Preset default: Uses the common Brazilian real symbol "R$".
|
|
160
|
+
# Source: Currency symbol conventions: https://cldr.unicode.org/translation/currency-names-and-symbols/currency-names
|
|
161
|
+
Amount.register :BRL,
|
|
162
|
+
decimals: 2,
|
|
163
|
+
display_symbol: "R$",
|
|
164
|
+
display_position: :prefix,
|
|
165
|
+
ui_decimals: 2
|
|
166
|
+
|
|
167
|
+
# AED: United Arab Emirates dirham.
|
|
168
|
+
# Fact: Uses 2 decimal places for fils.
|
|
169
|
+
# Preset default: Uses the ISO code as the display symbol for an unambiguous English-oriented default.
|
|
170
|
+
# Preset default: Renders as a suffix amount.
|
|
171
|
+
# Source: Currency symbol conventions: https://cldr.unicode.org/translation/currency-names-and-symbols/currency-names
|
|
172
|
+
Amount.register :AED,
|
|
173
|
+
decimals: 2,
|
|
174
|
+
display_symbol: "AED",
|
|
175
|
+
display_position: :suffix,
|
|
176
|
+
ui_decimals: 2
|
|
177
|
+
|
|
178
|
+
# GOLD: Gold measured with troy-ounce display defaults.
|
|
179
|
+
# Fact: The alternate gram display uses 1 troy ounce = 31.1035 grams.
|
|
180
|
+
# Fact: The alternate kilogram display uses 1 troy ounce = 0.0311035 kilograms.
|
|
181
|
+
# Preset default: Uses 8 storage decimals as a high-precision preset default rather than a market mandate.
|
|
182
|
+
# Preset default: Defaults to troy-ounce display because that is common for bullion pricing.
|
|
183
|
+
# Source: NIST precious-metals conversion guidance: https://www.nist.gov/pml/weights-and-measures/laws-and-regulations/precious-metals-conversion
|
|
184
|
+
Amount.register :GOLD,
|
|
185
|
+
decimals: 8,
|
|
186
|
+
display_symbol: "oz t",
|
|
187
|
+
display_position: :suffix,
|
|
188
|
+
ui_decimals: 4,
|
|
189
|
+
display_units: {
|
|
190
|
+
oz_t: { scale: 1, symbol: "oz t", ui_decimals: 4 },
|
|
191
|
+
gram: { scale: "31.1035", symbol: "g", ui_decimals: 2 },
|
|
192
|
+
kg: { scale: "0.0311035", symbol: "kg", ui_decimals: 5 }
|
|
193
|
+
},
|
|
194
|
+
default_display: :oz_t
|
|
195
|
+
|
|
196
|
+
# SILVER: Silver measured with troy-ounce display defaults.
|
|
197
|
+
# Fact: The alternate gram display uses 1 troy ounce = 31.1035 grams.
|
|
198
|
+
# Fact: The alternate kilogram display uses 1 troy ounce = 0.0311035 kilograms.
|
|
199
|
+
# Preset default: Uses 8 storage decimals as a high-precision preset default.
|
|
200
|
+
# Preset default: Defaults to troy-ounce display for consistency with common bullion quoting.
|
|
201
|
+
# Source: NIST precious-metals conversion guidance: https://www.nist.gov/pml/weights-and-measures/laws-and-regulations/precious-metals-conversion
|
|
202
|
+
Amount.register :SILVER,
|
|
203
|
+
decimals: 8,
|
|
204
|
+
display_symbol: "oz t",
|
|
205
|
+
display_position: :suffix,
|
|
206
|
+
ui_decimals: 4,
|
|
207
|
+
display_units: {
|
|
208
|
+
oz_t: { scale: 1, symbol: "oz t", ui_decimals: 4 },
|
|
209
|
+
gram: { scale: "31.1035", symbol: "g", ui_decimals: 2 },
|
|
210
|
+
kg: { scale: "0.0311035", symbol: "kg", ui_decimals: 5 }
|
|
211
|
+
},
|
|
212
|
+
default_display: :oz_t
|
|
213
|
+
|
|
214
|
+
# PLATINUM: Platinum measured with troy-ounce display defaults.
|
|
215
|
+
# Fact: The alternate gram display uses 1 troy ounce = 31.1035 grams.
|
|
216
|
+
# Fact: The alternate kilogram display uses 1 troy ounce = 0.0311035 kilograms.
|
|
217
|
+
# Preset default: Uses 8 storage decimals as a high-precision preset default.
|
|
218
|
+
# Preset default: Defaults to troy-ounce display for commodity-style pricing.
|
|
219
|
+
# Source: NIST precious-metals conversion guidance: https://www.nist.gov/pml/weights-and-measures/laws-and-regulations/precious-metals-conversion
|
|
220
|
+
Amount.register :PLATINUM,
|
|
221
|
+
decimals: 8,
|
|
222
|
+
display_symbol: "oz t",
|
|
223
|
+
display_position: :suffix,
|
|
224
|
+
ui_decimals: 4,
|
|
225
|
+
display_units: {
|
|
226
|
+
oz_t: { scale: 1, symbol: "oz t", ui_decimals: 4 },
|
|
227
|
+
gram: { scale: "31.1035", symbol: "g", ui_decimals: 2 },
|
|
228
|
+
kg: { scale: "0.0311035", symbol: "kg", ui_decimals: 5 }
|
|
229
|
+
},
|
|
230
|
+
default_display: :oz_t
|
|
231
|
+
|
|
232
|
+
# PALLADIUM: Palladium measured with troy-ounce display defaults.
|
|
233
|
+
# Fact: The alternate gram display uses 1 troy ounce = 31.1035 grams.
|
|
234
|
+
# Fact: The alternate kilogram display uses 1 troy ounce = 0.0311035 kilograms.
|
|
235
|
+
# Preset default: Uses 8 storage decimals as a high-precision preset default.
|
|
236
|
+
# Preset default: Defaults to troy-ounce display for commodity-style pricing.
|
|
237
|
+
# Source: NIST precious-metals conversion guidance: https://www.nist.gov/pml/weights-and-measures/laws-and-regulations/precious-metals-conversion
|
|
238
|
+
Amount.register :PALLADIUM,
|
|
239
|
+
decimals: 8,
|
|
240
|
+
display_symbol: "oz t",
|
|
241
|
+
display_position: :suffix,
|
|
242
|
+
ui_decimals: 4,
|
|
243
|
+
display_units: {
|
|
244
|
+
oz_t: { scale: 1, symbol: "oz t", ui_decimals: 4 },
|
|
245
|
+
gram: { scale: "31.1035", symbol: "g", ui_decimals: 2 },
|
|
246
|
+
kg: { scale: "0.0311035", symbol: "kg", ui_decimals: 5 }
|
|
247
|
+
},
|
|
248
|
+
default_display: :oz_t
|
|
249
|
+
|
|
250
|
+
# COPPER: Copper measured with metric-mass defaults.
|
|
251
|
+
# Fact: The tonne display uses 1 kg = 0.001 t.
|
|
252
|
+
# Fact: The pound display uses 1 kg = 2.2046226218 lb.
|
|
253
|
+
# Preset default: Uses kilograms as the default display unit for industrial inventory and warehouse-style workflows.
|
|
254
|
+
# Preset default: Uses 6 storage decimals as a high-precision preset default.
|
|
255
|
+
# Source: NIST metric and customary conversion guidance: https://www.nist.gov/pml/weights-and-measures/common-conversion-factors-ii
|
|
256
|
+
Amount.register :COPPER,
|
|
257
|
+
decimals: 6,
|
|
258
|
+
display_symbol: "kg",
|
|
259
|
+
display_position: :suffix,
|
|
260
|
+
ui_decimals: 3,
|
|
261
|
+
display_units: {
|
|
262
|
+
kg: { scale: 1, symbol: "kg", ui_decimals: 3 },
|
|
263
|
+
tonne: { scale: "0.001", symbol: "t", ui_decimals: 6 },
|
|
264
|
+
lb: { scale: "2.2046226218", symbol: "lb", ui_decimals: 2 }
|
|
265
|
+
},
|
|
266
|
+
default_display: :kg
|
|
267
|
+
|
|
268
|
+
# ALUMINUM: Aluminum measured with metric-mass defaults.
|
|
269
|
+
# Fact: The tonne display uses 1 kg = 0.001 t.
|
|
270
|
+
# Fact: The pound display uses 1 kg = 2.2046226218 lb.
|
|
271
|
+
# Preset default: Uses kilograms as the default display unit.
|
|
272
|
+
# Preset default: Uses 6 storage decimals as a high-precision preset default.
|
|
273
|
+
# Source: NIST metric and customary conversion guidance: https://www.nist.gov/pml/weights-and-measures/common-conversion-factors-ii
|
|
274
|
+
Amount.register :ALUMINUM,
|
|
275
|
+
decimals: 6,
|
|
276
|
+
display_symbol: "kg",
|
|
277
|
+
display_position: :suffix,
|
|
278
|
+
ui_decimals: 3,
|
|
279
|
+
display_units: {
|
|
280
|
+
kg: { scale: 1, symbol: "kg", ui_decimals: 3 },
|
|
281
|
+
tonne: { scale: "0.001", symbol: "t", ui_decimals: 6 },
|
|
282
|
+
lb: { scale: "2.2046226218", symbol: "lb", ui_decimals: 2 }
|
|
283
|
+
},
|
|
284
|
+
default_display: :kg
|
|
285
|
+
|
|
286
|
+
# NICKEL: Nickel measured with metric-mass defaults.
|
|
287
|
+
# Fact: The tonne display uses 1 kg = 0.001 t.
|
|
288
|
+
# Fact: The pound display uses 1 kg = 2.2046226218 lb.
|
|
289
|
+
# Preset default: Uses kilograms as the default display unit.
|
|
290
|
+
# Preset default: Uses 6 storage decimals as a high-precision preset default.
|
|
291
|
+
# Source: NIST metric and customary conversion guidance: https://www.nist.gov/pml/weights-and-measures/common-conversion-factors-ii
|
|
292
|
+
Amount.register :NICKEL,
|
|
293
|
+
decimals: 6,
|
|
294
|
+
display_symbol: "kg",
|
|
295
|
+
display_position: :suffix,
|
|
296
|
+
ui_decimals: 3,
|
|
297
|
+
display_units: {
|
|
298
|
+
kg: { scale: 1, symbol: "kg", ui_decimals: 3 },
|
|
299
|
+
tonne: { scale: "0.001", symbol: "t", ui_decimals: 6 },
|
|
300
|
+
lb: { scale: "2.2046226218", symbol: "lb", ui_decimals: 2 }
|
|
301
|
+
},
|
|
302
|
+
default_display: :kg
|
|
303
|
+
|
|
304
|
+
# ZINC: Zinc measured with metric-mass defaults.
|
|
305
|
+
# Fact: The tonne display uses 1 kg = 0.001 t.
|
|
306
|
+
# Fact: The pound display uses 1 kg = 2.2046226218 lb.
|
|
307
|
+
# Preset default: Uses kilograms as the default display unit.
|
|
308
|
+
# Preset default: Uses 6 storage decimals as a high-precision preset default.
|
|
309
|
+
# Source: NIST metric and customary conversion guidance: https://www.nist.gov/pml/weights-and-measures/common-conversion-factors-ii
|
|
310
|
+
Amount.register :ZINC,
|
|
311
|
+
decimals: 6,
|
|
312
|
+
display_symbol: "kg",
|
|
313
|
+
display_position: :suffix,
|
|
314
|
+
ui_decimals: 3,
|
|
315
|
+
display_units: {
|
|
316
|
+
kg: { scale: 1, symbol: "kg", ui_decimals: 3 },
|
|
317
|
+
tonne: { scale: "0.001", symbol: "t", ui_decimals: 6 },
|
|
318
|
+
lb: { scale: "2.2046226218", symbol: "lb", ui_decimals: 2 }
|
|
319
|
+
},
|
|
320
|
+
default_display: :kg
|
|
321
|
+
|
|
322
|
+
# BTC: Bitcoin.
|
|
323
|
+
# Fact: Uses 8 decimal places under the satoshi convention.
|
|
324
|
+
# Fact: The smallest commonly referenced unit is 1 satoshi = 0.00000001 BTC.
|
|
325
|
+
# Preset default: Adds mBTC and satoshi display units for wallet and fee-oriented UIs.
|
|
326
|
+
# Preset default: Uses a suffix symbol to avoid fiat-style ambiguity.
|
|
327
|
+
# Source: Bitcoin developer docs: https://developer.bitcoin.org/
|
|
328
|
+
Amount.register :BTC,
|
|
329
|
+
decimals: 8,
|
|
330
|
+
display_symbol: "BTC",
|
|
331
|
+
display_position: :suffix,
|
|
332
|
+
ui_decimals: 8,
|
|
333
|
+
display_units: {
|
|
334
|
+
btc: { scale: 1, symbol: "BTC", ui_decimals: 8 },
|
|
335
|
+
mbtc: { scale: "1000", symbol: "mBTC", ui_decimals: 5 },
|
|
336
|
+
satoshi: { scale: "100000000", symbol: "sat", ui_decimals: 0 }
|
|
337
|
+
},
|
|
338
|
+
default_display: :btc
|
|
339
|
+
|
|
340
|
+
# ETH: Ether.
|
|
341
|
+
# Fact: Uses 18 decimal places because 1 ETH = 10^18 wei.
|
|
342
|
+
# Fact: The gwei display unit uses 1 ETH = 10^9 gwei.
|
|
343
|
+
# Preset default: Adds gwei and wei display units because fee and gas tooling often surfaces those denominations.
|
|
344
|
+
# Preset default: Uses a suffix symbol to avoid fiat-style ambiguity.
|
|
345
|
+
# Source: Ethereum denomination docs: https://ethereum.org/en/developers/docs/intro-to-ether/
|
|
346
|
+
Amount.register :ETH,
|
|
347
|
+
decimals: 18,
|
|
348
|
+
display_symbol: "ETH",
|
|
349
|
+
display_position: :suffix,
|
|
350
|
+
ui_decimals: 6,
|
|
351
|
+
display_units: {
|
|
352
|
+
eth: { scale: 1, symbol: "ETH", ui_decimals: 6 },
|
|
353
|
+
gwei: { scale: "1000000000", symbol: "gwei", ui_decimals: 0 },
|
|
354
|
+
wei: { scale: "1000000000000000000", symbol: "wei", ui_decimals: 0 }
|
|
355
|
+
},
|
|
356
|
+
default_display: :eth
|
|
357
|
+
|
|
358
|
+
# USDT: Tether USDt.
|
|
359
|
+
# Fact: This preset assumes the widely used 6-decimal denomination used by the common ERC-20-style representation of USDT.
|
|
360
|
+
# Fact: USDT is multichain in practice, so chain-specific integrations should verify decimals against the concrete deployment they use.
|
|
361
|
+
# Preset default: Uses "$" as a stablecoin-style display default in English-oriented UIs.
|
|
362
|
+
# Source: Tether overview and supported-protocol context: https://tether.to/en/how-it-works
|
|
363
|
+
Amount.register :USDT,
|
|
364
|
+
decimals: 6,
|
|
365
|
+
display_symbol: "$",
|
|
366
|
+
display_position: :prefix,
|
|
367
|
+
ui_decimals: 2
|
|
368
|
+
|
|
369
|
+
# XRP: XRP.
|
|
370
|
+
# Fact: Uses 6 decimal places because XRP is precise to the nearest drop.
|
|
371
|
+
# Fact: The XRPL documents 1 drop = 0.000001 XRP.
|
|
372
|
+
# Preset default: Uses a suffix symbol to avoid fiat-style ambiguity.
|
|
373
|
+
# Source: XRPL currency formats: https://xrpl.org/currency-formats.html
|
|
374
|
+
Amount.register :XRP,
|
|
375
|
+
decimals: 6,
|
|
376
|
+
display_symbol: "XRP",
|
|
377
|
+
display_position: :suffix,
|
|
378
|
+
ui_decimals: 4
|
|
379
|
+
|
|
380
|
+
# BNB: BNB.
|
|
381
|
+
# Fact: Uses 18 decimal places under the wei-style denomination used across BNB EVM infrastructure.
|
|
382
|
+
# Preset default: Uses a suffix symbol to avoid fiat-style ambiguity.
|
|
383
|
+
# Source: BNB Chain denomination note: https://docs.bnbchain.org/bnb-greenfield/getting-started/general-faqs/
|
|
384
|
+
Amount.register :BNB,
|
|
385
|
+
decimals: 18,
|
|
386
|
+
display_symbol: "BNB",
|
|
387
|
+
display_position: :suffix,
|
|
388
|
+
ui_decimals: 4
|
|
389
|
+
|
|
390
|
+
# USDC: USD Coin.
|
|
391
|
+
# Fact: This preset uses the widely deployed 6-decimal denomination for USDC integrations.
|
|
392
|
+
# Preset default: Uses "$" as a stablecoin-style display default in English-oriented UIs.
|
|
393
|
+
# Source: Circle USDC overview: https://www.circle.com/usdc
|
|
394
|
+
Amount.register :USDC,
|
|
395
|
+
decimals: 6,
|
|
396
|
+
display_symbol: "$",
|
|
397
|
+
display_position: :prefix,
|
|
398
|
+
ui_decimals: 2
|
|
399
|
+
|
|
400
|
+
# SOL: Solana.
|
|
401
|
+
# Fact: Uses 9 decimal places because 1 SOL = 1,000,000,000 lamports.
|
|
402
|
+
# Preset default: Adds a lamport display unit because low-level Solana tooling often surfaces lamports directly.
|
|
403
|
+
# Source: Solana account structure docs: https://solana.com/docs/core/accounts/account-structure
|
|
404
|
+
Amount.register :SOL,
|
|
405
|
+
decimals: 9,
|
|
406
|
+
display_symbol: "SOL",
|
|
407
|
+
display_position: :suffix,
|
|
408
|
+
ui_decimals: 4,
|
|
409
|
+
display_units: {
|
|
410
|
+
sol: { scale: 1, symbol: "SOL", ui_decimals: 4 },
|
|
411
|
+
lamport: { scale: "1000000000", symbol: "lamports", ui_decimals: 0 }
|
|
412
|
+
},
|
|
413
|
+
default_display: :sol
|
|
414
|
+
|
|
415
|
+
# TRX: TRON.
|
|
416
|
+
# Fact: Uses 6 decimal places because 1 TRX = 1,000,000 SUN.
|
|
417
|
+
# Preset default: Uses a suffix symbol to avoid fiat-style ambiguity.
|
|
418
|
+
# Source: TRON TRX docs: https://developers.tron.network/v3.7/docs/trx
|
|
419
|
+
Amount.register :TRX,
|
|
420
|
+
decimals: 6,
|
|
421
|
+
display_symbol: "TRX",
|
|
422
|
+
display_position: :suffix,
|
|
423
|
+
ui_decimals: 4
|
|
424
|
+
|
|
425
|
+
# DOGE: Dogecoin.
|
|
426
|
+
# Fact: Uses the 8-decimal Bitcoin-family denomination convention.
|
|
427
|
+
# Preset default: Uses a suffix symbol to avoid fiat-style ambiguity.
|
|
428
|
+
# Preset default: Uses 4 UI decimals by default to keep ordinary wallet-style values readable.
|
|
429
|
+
# Source: Dogecoin project site: https://dogecoin.com/
|
|
430
|
+
Amount.register :DOGE,
|
|
431
|
+
decimals: 8,
|
|
432
|
+
display_symbol: "DOGE",
|
|
433
|
+
display_position: :suffix,
|
|
434
|
+
ui_decimals: 4
|
|
435
|
+
|
|
436
|
+
# BCH: Bitcoin Cash.
|
|
437
|
+
# Fact: Uses the 8-decimal Bitcoin-family denomination convention.
|
|
438
|
+
# Preset default: Uses a suffix symbol to avoid fiat-style ambiguity.
|
|
439
|
+
# Source: Bitcoin Cash project site: https://bitcoincash.org/
|
|
440
|
+
Amount.register :BCH,
|
|
441
|
+
decimals: 8,
|
|
442
|
+
display_symbol: "BCH",
|
|
443
|
+
display_position: :suffix,
|
|
444
|
+
ui_decimals: 6
|
|
445
|
+
|
|
446
|
+
# ADA: Cardano.
|
|
447
|
+
# Fact: Uses 6 decimal places because 1 ADA = 1,000,000 lovelace.
|
|
448
|
+
# Preset default: Uses a suffix symbol to avoid fiat-style ambiguity.
|
|
449
|
+
# Source: Cardano developer docs: https://developers.cardano.org/docs/build/native-tokens/minting/
|
|
450
|
+
Amount.register :ADA,
|
|
451
|
+
decimals: 6,
|
|
452
|
+
display_symbol: "ADA",
|
|
453
|
+
display_position: :suffix,
|
|
454
|
+
ui_decimals: 4
|
|
455
|
+
|
|
456
|
+
# LINK: Chainlink.
|
|
457
|
+
# Fact: Uses the common ERC-20 18-decimal denomination convention for LINK.
|
|
458
|
+
# Preset default: Uses a suffix symbol to avoid fiat-style ambiguity.
|
|
459
|
+
# Source: Chainlink developer docs hub: https://docs.chain.link/
|
|
460
|
+
Amount.register :LINK,
|
|
461
|
+
decimals: 18,
|
|
462
|
+
display_symbol: "LINK",
|
|
463
|
+
display_position: :suffix,
|
|
464
|
+
ui_decimals: 4
|
|
465
|
+
|
|
466
|
+
# XLM: Stellar lumens.
|
|
467
|
+
# Fact: Uses 7 decimal places because 1 XLM = 10,000,000 stroops.
|
|
468
|
+
# Preset default: Uses a suffix symbol to avoid fiat-style ambiguity.
|
|
469
|
+
# Source: Stellar docs using stroops: https://developers.stellar.org/docs/tools/cli/stellar-cli
|
|
470
|
+
Amount.register :XLM,
|
|
471
|
+
decimals: 7,
|
|
472
|
+
display_symbol: "XLM",
|
|
473
|
+
display_position: :suffix,
|
|
474
|
+
ui_decimals: 4
|
|
475
|
+
|
|
476
|
+
# DAI: Dai stablecoin.
|
|
477
|
+
# Fact: Uses 18 decimal places according to the Dai token contract documentation.
|
|
478
|
+
# Preset default: Uses "$" as a stablecoin-style display default in English-oriented UIs.
|
|
479
|
+
# Source: Maker Dai detailed docs: https://docs.makerdao.com/smart-contract-modules/dai-module/dai-detailed-documentation
|
|
480
|
+
Amount.register :DAI,
|
|
481
|
+
decimals: 18,
|
|
482
|
+
display_symbol: "$",
|
|
483
|
+
display_position: :prefix,
|
|
484
|
+
ui_decimals: 2
|
|
485
|
+
|
|
486
|
+
# LTC: Litecoin.
|
|
487
|
+
# Fact: Uses the 8-decimal Bitcoin-family denomination convention.
|
|
488
|
+
# Preset default: Uses a suffix symbol to avoid fiat-style ambiguity.
|
|
489
|
+
# Source: Litecoin project site: https://litecoin.org/
|
|
490
|
+
Amount.register :LTC,
|
|
491
|
+
decimals: 8,
|
|
492
|
+
display_symbol: "LTC",
|
|
493
|
+
display_position: :suffix,
|
|
494
|
+
ui_decimals: 6
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# Registry overview:
|
|
2
|
+
# Large-Cap Crypto Assets:
|
|
3
|
+
# - This preset is a curated basket of prominent crypto assets intended for developer-facing ledgers and wallet-style products.
|
|
4
|
+
# - It is not a literal mirror of any single market-cap top-20 list; the basket favors assets with broadly understood denomination conventions and common integration relevance.
|
|
5
|
+
# - Where an asset is multichain, the preset documents the denomination convention the initializer assumes.
|
|
6
|
+
# - Source: Large-cap market snapshot used as a selection input on April 24, 2026: https://coinmarketcap.com/historical/20260424/
|
|
7
|
+
|
|
8
|
+
# BTC: Bitcoin.
|
|
9
|
+
# Fact: Uses 8 decimal places under the satoshi convention.
|
|
10
|
+
# Fact: The smallest commonly referenced unit is 1 satoshi = 0.00000001 BTC.
|
|
11
|
+
# Preset default: Adds mBTC and satoshi display units for wallet and fee-oriented UIs.
|
|
12
|
+
# Preset default: Uses a suffix symbol to avoid fiat-style ambiguity.
|
|
13
|
+
# Source: Bitcoin developer docs: https://developer.bitcoin.org/
|
|
14
|
+
Amount.register :BTC,
|
|
15
|
+
decimals: 8,
|
|
16
|
+
display_symbol: "BTC",
|
|
17
|
+
display_position: :suffix,
|
|
18
|
+
ui_decimals: 8,
|
|
19
|
+
display_units: {
|
|
20
|
+
btc: { scale: 1, symbol: "BTC", ui_decimals: 8 },
|
|
21
|
+
mbtc: { scale: "1000", symbol: "mBTC", ui_decimals: 5 },
|
|
22
|
+
satoshi: { scale: "100000000", symbol: "sat", ui_decimals: 0 }
|
|
23
|
+
},
|
|
24
|
+
default_display: :btc
|
|
25
|
+
|
|
26
|
+
# ETH: Ether.
|
|
27
|
+
# Fact: Uses 18 decimal places because 1 ETH = 10^18 wei.
|
|
28
|
+
# Fact: The gwei display unit uses 1 ETH = 10^9 gwei.
|
|
29
|
+
# Preset default: Adds gwei and wei display units because fee and gas tooling often surfaces those denominations.
|
|
30
|
+
# Preset default: Uses a suffix symbol to avoid fiat-style ambiguity.
|
|
31
|
+
# Source: Ethereum denomination docs: https://ethereum.org/en/developers/docs/intro-to-ether/
|
|
32
|
+
Amount.register :ETH,
|
|
33
|
+
decimals: 18,
|
|
34
|
+
display_symbol: "ETH",
|
|
35
|
+
display_position: :suffix,
|
|
36
|
+
ui_decimals: 6,
|
|
37
|
+
display_units: {
|
|
38
|
+
eth: { scale: 1, symbol: "ETH", ui_decimals: 6 },
|
|
39
|
+
gwei: { scale: "1000000000", symbol: "gwei", ui_decimals: 0 },
|
|
40
|
+
wei: { scale: "1000000000000000000", symbol: "wei", ui_decimals: 0 }
|
|
41
|
+
},
|
|
42
|
+
default_display: :eth
|
|
43
|
+
|
|
44
|
+
# USDT: Tether USDt.
|
|
45
|
+
# Fact: This preset assumes the widely used 6-decimal denomination used by the common ERC-20-style representation of USDT.
|
|
46
|
+
# Fact: USDT is multichain in practice, so chain-specific integrations should verify decimals against the concrete deployment they use.
|
|
47
|
+
# Preset default: Uses "$" as a stablecoin-style display default in English-oriented UIs.
|
|
48
|
+
# Source: Tether overview and supported-protocol context: https://tether.to/en/how-it-works
|
|
49
|
+
Amount.register :USDT,
|
|
50
|
+
decimals: 6,
|
|
51
|
+
display_symbol: "$",
|
|
52
|
+
display_position: :prefix,
|
|
53
|
+
ui_decimals: 2
|
|
54
|
+
|
|
55
|
+
# XRP: XRP.
|
|
56
|
+
# Fact: Uses 6 decimal places because XRP is precise to the nearest drop.
|
|
57
|
+
# Fact: The XRPL documents 1 drop = 0.000001 XRP.
|
|
58
|
+
# Preset default: Uses a suffix symbol to avoid fiat-style ambiguity.
|
|
59
|
+
# Source: XRPL currency formats: https://xrpl.org/currency-formats.html
|
|
60
|
+
Amount.register :XRP,
|
|
61
|
+
decimals: 6,
|
|
62
|
+
display_symbol: "XRP",
|
|
63
|
+
display_position: :suffix,
|
|
64
|
+
ui_decimals: 4
|
|
65
|
+
|
|
66
|
+
# BNB: BNB.
|
|
67
|
+
# Fact: Uses 18 decimal places under the wei-style denomination used across BNB EVM infrastructure.
|
|
68
|
+
# Preset default: Uses a suffix symbol to avoid fiat-style ambiguity.
|
|
69
|
+
# Source: BNB Chain denomination note: https://docs.bnbchain.org/bnb-greenfield/getting-started/general-faqs/
|
|
70
|
+
Amount.register :BNB,
|
|
71
|
+
decimals: 18,
|
|
72
|
+
display_symbol: "BNB",
|
|
73
|
+
display_position: :suffix,
|
|
74
|
+
ui_decimals: 4
|
|
75
|
+
|
|
76
|
+
# USDC: USD Coin.
|
|
77
|
+
# Fact: This preset uses the widely deployed 6-decimal denomination for USDC integrations.
|
|
78
|
+
# Preset default: Uses "$" as a stablecoin-style display default in English-oriented UIs.
|
|
79
|
+
# Source: Circle USDC overview: https://www.circle.com/usdc
|
|
80
|
+
Amount.register :USDC,
|
|
81
|
+
decimals: 6,
|
|
82
|
+
display_symbol: "$",
|
|
83
|
+
display_position: :prefix,
|
|
84
|
+
ui_decimals: 2
|
|
85
|
+
|
|
86
|
+
# SOL: Solana.
|
|
87
|
+
# Fact: Uses 9 decimal places because 1 SOL = 1,000,000,000 lamports.
|
|
88
|
+
# Preset default: Adds a lamport display unit because low-level Solana tooling often surfaces lamports directly.
|
|
89
|
+
# Source: Solana account structure docs: https://solana.com/docs/core/accounts/account-structure
|
|
90
|
+
Amount.register :SOL,
|
|
91
|
+
decimals: 9,
|
|
92
|
+
display_symbol: "SOL",
|
|
93
|
+
display_position: :suffix,
|
|
94
|
+
ui_decimals: 4,
|
|
95
|
+
display_units: {
|
|
96
|
+
sol: { scale: 1, symbol: "SOL", ui_decimals: 4 },
|
|
97
|
+
lamport: { scale: "1000000000", symbol: "lamports", ui_decimals: 0 }
|
|
98
|
+
},
|
|
99
|
+
default_display: :sol
|
|
100
|
+
|
|
101
|
+
# TRX: TRON.
|
|
102
|
+
# Fact: Uses 6 decimal places because 1 TRX = 1,000,000 SUN.
|
|
103
|
+
# Preset default: Uses a suffix symbol to avoid fiat-style ambiguity.
|
|
104
|
+
# Source: TRON TRX docs: https://developers.tron.network/v3.7/docs/trx
|
|
105
|
+
Amount.register :TRX,
|
|
106
|
+
decimals: 6,
|
|
107
|
+
display_symbol: "TRX",
|
|
108
|
+
display_position: :suffix,
|
|
109
|
+
ui_decimals: 4
|
|
110
|
+
|
|
111
|
+
# DOGE: Dogecoin.
|
|
112
|
+
# Fact: Uses the 8-decimal Bitcoin-family denomination convention.
|
|
113
|
+
# Preset default: Uses a suffix symbol to avoid fiat-style ambiguity.
|
|
114
|
+
# Preset default: Uses 4 UI decimals by default to keep ordinary wallet-style values readable.
|
|
115
|
+
# Source: Dogecoin project site: https://dogecoin.com/
|
|
116
|
+
Amount.register :DOGE,
|
|
117
|
+
decimals: 8,
|
|
118
|
+
display_symbol: "DOGE",
|
|
119
|
+
display_position: :suffix,
|
|
120
|
+
ui_decimals: 4
|
|
121
|
+
|
|
122
|
+
# BCH: Bitcoin Cash.
|
|
123
|
+
# Fact: Uses the 8-decimal Bitcoin-family denomination convention.
|
|
124
|
+
# Preset default: Uses a suffix symbol to avoid fiat-style ambiguity.
|
|
125
|
+
# Source: Bitcoin Cash project site: https://bitcoincash.org/
|
|
126
|
+
Amount.register :BCH,
|
|
127
|
+
decimals: 8,
|
|
128
|
+
display_symbol: "BCH",
|
|
129
|
+
display_position: :suffix,
|
|
130
|
+
ui_decimals: 6
|
|
131
|
+
|
|
132
|
+
# ADA: Cardano.
|
|
133
|
+
# Fact: Uses 6 decimal places because 1 ADA = 1,000,000 lovelace.
|
|
134
|
+
# Preset default: Uses a suffix symbol to avoid fiat-style ambiguity.
|
|
135
|
+
# Source: Cardano developer docs: https://developers.cardano.org/docs/build/native-tokens/minting/
|
|
136
|
+
Amount.register :ADA,
|
|
137
|
+
decimals: 6,
|
|
138
|
+
display_symbol: "ADA",
|
|
139
|
+
display_position: :suffix,
|
|
140
|
+
ui_decimals: 4
|
|
141
|
+
|
|
142
|
+
# LINK: Chainlink.
|
|
143
|
+
# Fact: Uses the common ERC-20 18-decimal denomination convention for LINK.
|
|
144
|
+
# Preset default: Uses a suffix symbol to avoid fiat-style ambiguity.
|
|
145
|
+
# Source: Chainlink developer docs hub: https://docs.chain.link/
|
|
146
|
+
Amount.register :LINK,
|
|
147
|
+
decimals: 18,
|
|
148
|
+
display_symbol: "LINK",
|
|
149
|
+
display_position: :suffix,
|
|
150
|
+
ui_decimals: 4
|
|
151
|
+
|
|
152
|
+
# XLM: Stellar lumens.
|
|
153
|
+
# Fact: Uses 7 decimal places because 1 XLM = 10,000,000 stroops.
|
|
154
|
+
# Preset default: Uses a suffix symbol to avoid fiat-style ambiguity.
|
|
155
|
+
# Source: Stellar docs using stroops: https://developers.stellar.org/docs/tools/cli/stellar-cli
|
|
156
|
+
Amount.register :XLM,
|
|
157
|
+
decimals: 7,
|
|
158
|
+
display_symbol: "XLM",
|
|
159
|
+
display_position: :suffix,
|
|
160
|
+
ui_decimals: 4
|
|
161
|
+
|
|
162
|
+
# DAI: Dai stablecoin.
|
|
163
|
+
# Fact: Uses 18 decimal places according to the Dai token contract documentation.
|
|
164
|
+
# Preset default: Uses "$" as a stablecoin-style display default in English-oriented UIs.
|
|
165
|
+
# Source: Maker Dai detailed docs: https://docs.makerdao.com/smart-contract-modules/dai-module/dai-detailed-documentation
|
|
166
|
+
Amount.register :DAI,
|
|
167
|
+
decimals: 18,
|
|
168
|
+
display_symbol: "$",
|
|
169
|
+
display_position: :prefix,
|
|
170
|
+
ui_decimals: 2
|
|
171
|
+
|
|
172
|
+
# LTC: Litecoin.
|
|
173
|
+
# Fact: Uses the 8-decimal Bitcoin-family denomination convention.
|
|
174
|
+
# Preset default: Uses a suffix symbol to avoid fiat-style ambiguity.
|
|
175
|
+
# Source: Litecoin project site: https://litecoin.org/
|
|
176
|
+
Amount.register :LTC,
|
|
177
|
+
decimals: 8,
|
|
178
|
+
display_symbol: "LTC",
|
|
179
|
+
display_position: :suffix,
|
|
180
|
+
ui_decimals: 6
|