nautilus_model/
currencies.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2025 Nautech Systems Pty Ltd. All rights reserved.
3//  https://nautechsystems.io
4//
5//  Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6//  You may not use this file except in compliance with the License.
7//  You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9//  Unless required by applicable law or agreed to in writing, software
10//  distributed under the License is distributed on an "AS IS" BASIS,
11//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//  See the License for the specific language governing permissions and
13//  limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16//! Common `Currency` constants.
17
18use std::{
19    collections::HashMap,
20    sync::{LazyLock, Mutex, OnceLock},
21};
22
23use ustr::Ustr;
24
25use crate::{enums::CurrencyType, types::Currency};
26
27///////////////////////////////////////////////////////////////////////////////
28// Fiat currencies
29///////////////////////////////////////////////////////////////////////////////
30static AUD_LOCK: OnceLock<Currency> = OnceLock::new();
31static BRL_LOCK: OnceLock<Currency> = OnceLock::new();
32static CAD_LOCK: OnceLock<Currency> = OnceLock::new();
33static CHF_LOCK: OnceLock<Currency> = OnceLock::new();
34static CNY_LOCK: OnceLock<Currency> = OnceLock::new();
35static CNH_LOCK: OnceLock<Currency> = OnceLock::new();
36static CZK_LOCK: OnceLock<Currency> = OnceLock::new();
37static DKK_LOCK: OnceLock<Currency> = OnceLock::new();
38static EUR_LOCK: OnceLock<Currency> = OnceLock::new();
39static GBP_LOCK: OnceLock<Currency> = OnceLock::new();
40static HKD_LOCK: OnceLock<Currency> = OnceLock::new();
41static HUF_LOCK: OnceLock<Currency> = OnceLock::new();
42static ILS_LOCK: OnceLock<Currency> = OnceLock::new();
43static INR_LOCK: OnceLock<Currency> = OnceLock::new();
44static JPY_LOCK: OnceLock<Currency> = OnceLock::new();
45static KRW_LOCK: OnceLock<Currency> = OnceLock::new();
46static MXN_LOCK: OnceLock<Currency> = OnceLock::new();
47static NOK_LOCK: OnceLock<Currency> = OnceLock::new();
48static NZD_LOCK: OnceLock<Currency> = OnceLock::new();
49static PLN_LOCK: OnceLock<Currency> = OnceLock::new();
50static RUB_LOCK: OnceLock<Currency> = OnceLock::new();
51static SAR_LOCK: OnceLock<Currency> = OnceLock::new();
52static SEK_LOCK: OnceLock<Currency> = OnceLock::new();
53static SGD_LOCK: OnceLock<Currency> = OnceLock::new();
54static THB_LOCK: OnceLock<Currency> = OnceLock::new();
55static TRY_LOCK: OnceLock<Currency> = OnceLock::new();
56static TWD_LOCK: OnceLock<Currency> = OnceLock::new();
57static USD_LOCK: OnceLock<Currency> = OnceLock::new();
58static ZAR_LOCK: OnceLock<Currency> = OnceLock::new();
59
60///////////////////////////////////////////////////////////////////////////////
61// Commodity backed currencies
62///////////////////////////////////////////////////////////////////////////////
63static XAG_LOCK: OnceLock<Currency> = OnceLock::new();
64static XAU_LOCK: OnceLock<Currency> = OnceLock::new();
65static XPT_LOCK: OnceLock<Currency> = OnceLock::new();
66
67///////////////////////////////////////////////////////////////////////////////
68// Crypto currencies
69///////////////////////////////////////////////////////////////////////////////
70static ONEINCH_LOCK: OnceLock<Currency> = OnceLock::new();
71static AAVE_LOCK: OnceLock<Currency> = OnceLock::new();
72static ACA_LOCK: OnceLock<Currency> = OnceLock::new();
73static ADA_LOCK: OnceLock<Currency> = OnceLock::new();
74static AVAX_LOCK: OnceLock<Currency> = OnceLock::new();
75static BCH_LOCK: OnceLock<Currency> = OnceLock::new();
76static BTC_LOCK: OnceLock<Currency> = OnceLock::new();
77static BTTC_LOCK: OnceLock<Currency> = OnceLock::new();
78static BNB_LOCK: OnceLock<Currency> = OnceLock::new();
79static BRZ_LOCK: OnceLock<Currency> = OnceLock::new();
80static BSV_LOCK: OnceLock<Currency> = OnceLock::new();
81static BUSD_LOCK: OnceLock<Currency> = OnceLock::new();
82static CAKE_LOCK: OnceLock<Currency> = OnceLock::new();
83static DASH_LOCK: OnceLock<Currency> = OnceLock::new();
84static DOGE_LOCK: OnceLock<Currency> = OnceLock::new();
85static DOT_LOCK: OnceLock<Currency> = OnceLock::new();
86static EOS_LOCK: OnceLock<Currency> = OnceLock::new();
87static ETH_LOCK: OnceLock<Currency> = OnceLock::new();
88static ETHW_LOCK: OnceLock<Currency> = OnceLock::new();
89static JOE_LOCK: OnceLock<Currency> = OnceLock::new();
90static LINK_LOCK: OnceLock<Currency> = OnceLock::new();
91static LTC_LOCK: OnceLock<Currency> = OnceLock::new();
92static LUNA_LOCK: OnceLock<Currency> = OnceLock::new();
93static NBT_LOCK: OnceLock<Currency> = OnceLock::new();
94static SOL_LOCK: OnceLock<Currency> = OnceLock::new();
95static TRX_LOCK: OnceLock<Currency> = OnceLock::new();
96static TRYB_LOCK: OnceLock<Currency> = OnceLock::new();
97static TUSD_LOCK: OnceLock<Currency> = OnceLock::new();
98static SHIB_LOCK: OnceLock<Currency> = OnceLock::new();
99static VTC_LOCK: OnceLock<Currency> = OnceLock::new();
100static WSB_LOCK: OnceLock<Currency> = OnceLock::new();
101static XBT_LOCK: OnceLock<Currency> = OnceLock::new();
102static XEC_LOCK: OnceLock<Currency> = OnceLock::new();
103static XLM_LOCK: OnceLock<Currency> = OnceLock::new();
104static XMR_LOCK: OnceLock<Currency> = OnceLock::new();
105static XRP_LOCK: OnceLock<Currency> = OnceLock::new();
106static XTZ_LOCK: OnceLock<Currency> = OnceLock::new();
107static USDC_LOCK: OnceLock<Currency> = OnceLock::new();
108static USDC_POS_LOCK: OnceLock<Currency> = OnceLock::new();
109static USDP_LOCK: OnceLock<Currency> = OnceLock::new();
110static USDT_LOCK: OnceLock<Currency> = OnceLock::new();
111static ZEC_LOCK: OnceLock<Currency> = OnceLock::new();
112
113impl Currency {
114    ///////////////////////////////////////////////////////////////////////////
115    // Crypto currencies
116    ///////////////////////////////////////////////////////////////////////////
117    #[allow(non_snake_case)]
118    #[must_use]
119    pub fn AUD() -> Self {
120        *AUD_LOCK.get_or_init(|| Self {
121            code: Ustr::from("AUD"),
122            precision: 2,
123            iso4217: 36,
124            name: Ustr::from("Australian dollar"),
125            currency_type: CurrencyType::Fiat,
126        })
127    }
128    #[allow(non_snake_case)]
129    #[must_use]
130    pub fn BRL() -> Self {
131        *BRL_LOCK.get_or_init(|| Self {
132            code: Ustr::from("BRL"),
133            precision: 2,
134            iso4217: 986,
135            name: Ustr::from("Brazilian real"),
136            currency_type: CurrencyType::Fiat,
137        })
138    }
139
140    #[allow(non_snake_case)]
141    #[must_use]
142    pub fn CAD() -> Self {
143        *CAD_LOCK.get_or_init(|| Self {
144            code: Ustr::from("CAD"),
145            precision: 2,
146            iso4217: 124,
147            name: Ustr::from("Canadian dollar"),
148            currency_type: CurrencyType::Fiat,
149        })
150    }
151
152    #[allow(non_snake_case)]
153    #[must_use]
154    pub fn CHF() -> Self {
155        *CHF_LOCK.get_or_init(|| Self {
156            code: Ustr::from("CHF"),
157            precision: 2,
158            iso4217: 756,
159            name: Ustr::from("Swiss franc"),
160            currency_type: CurrencyType::Fiat,
161        })
162    }
163
164    #[allow(non_snake_case)]
165    #[must_use]
166    pub fn CNY() -> Self {
167        *CNY_LOCK.get_or_init(|| Self {
168            code: Ustr::from("CNY"),
169            precision: 2,
170            iso4217: 156,
171            name: Ustr::from("Chinese yuan"),
172            currency_type: CurrencyType::Fiat,
173        })
174    }
175
176    #[allow(non_snake_case)]
177    #[must_use]
178    pub fn CNH() -> Self {
179        *CNH_LOCK.get_or_init(|| Self {
180            code: Ustr::from("CNH"),
181            precision: 2,
182            iso4217: 0,
183            name: Ustr::from("Chinese yuan (offshore)"),
184            currency_type: CurrencyType::Fiat,
185        })
186    }
187
188    #[allow(non_snake_case)]
189    #[must_use]
190    pub fn CZK() -> Self {
191        *CZK_LOCK.get_or_init(|| Self {
192            code: Ustr::from("CZK"),
193            precision: 2,
194            iso4217: 203,
195            name: Ustr::from("Czech koruna"),
196            currency_type: CurrencyType::Fiat,
197        })
198    }
199
200    #[allow(non_snake_case)]
201    #[must_use]
202    pub fn DKK() -> Self {
203        *DKK_LOCK.get_or_init(|| Self {
204            code: Ustr::from("DKK"),
205            precision: 2,
206            iso4217: 208,
207            name: Ustr::from("Danish krone"),
208            currency_type: CurrencyType::Fiat,
209        })
210    }
211
212    #[allow(non_snake_case)]
213    #[must_use]
214    pub fn EUR() -> Self {
215        *EUR_LOCK.get_or_init(|| Self {
216            code: Ustr::from("EUR"),
217            precision: 2,
218            iso4217: 978,
219            name: Ustr::from("Euro"),
220            currency_type: CurrencyType::Fiat,
221        })
222    }
223
224    #[allow(non_snake_case)]
225    #[must_use]
226    pub fn GBP() -> Self {
227        *GBP_LOCK.get_or_init(|| Self {
228            code: Ustr::from("GBP"),
229            precision: 2,
230            iso4217: 826,
231            name: Ustr::from("British Pound"),
232            currency_type: CurrencyType::Fiat,
233        })
234    }
235
236    #[allow(non_snake_case)]
237    #[must_use]
238    pub fn HKD() -> Self {
239        *HKD_LOCK.get_or_init(|| Self {
240            code: Ustr::from("HKD"),
241            precision: 2,
242            iso4217: 344,
243            name: Ustr::from("Hong Kong dollar"),
244            currency_type: CurrencyType::Fiat,
245        })
246    }
247
248    #[allow(non_snake_case)]
249    #[must_use]
250    pub fn HUF() -> Self {
251        *HUF_LOCK.get_or_init(|| Self {
252            code: Ustr::from("HUF"),
253            precision: 2,
254            iso4217: 348,
255            name: Ustr::from("Hungarian forint"),
256            currency_type: CurrencyType::Fiat,
257        })
258    }
259
260    #[allow(non_snake_case)]
261    #[must_use]
262    pub fn ILS() -> Self {
263        *ILS_LOCK.get_or_init(|| Self {
264            code: Ustr::from("ILS"),
265            precision: 2,
266            iso4217: 376,
267            name: Ustr::from("Israeli new shekel"),
268            currency_type: CurrencyType::Fiat,
269        })
270    }
271
272    #[allow(non_snake_case)]
273    #[must_use]
274    pub fn INR() -> Self {
275        *INR_LOCK.get_or_init(|| Self {
276            code: Ustr::from("INR"),
277            precision: 2,
278            iso4217: 356,
279            name: Ustr::from("Indian rupee"),
280            currency_type: CurrencyType::Fiat,
281        })
282    }
283
284    #[allow(non_snake_case)]
285    #[must_use]
286    pub fn JPY() -> Self {
287        *JPY_LOCK.get_or_init(|| Self {
288            code: Ustr::from("JPY"),
289            precision: 0,
290            iso4217: 392,
291            name: Ustr::from("Japanese yen"),
292            currency_type: CurrencyType::Fiat,
293        })
294    }
295    #[allow(non_snake_case)]
296    #[must_use]
297    pub fn KRW() -> Self {
298        *KRW_LOCK.get_or_init(|| Self {
299            code: Ustr::from("KRW"),
300            precision: 0,
301            iso4217: 410,
302            name: Ustr::from("South Korean won"),
303            currency_type: CurrencyType::Fiat,
304        })
305    }
306
307    #[allow(non_snake_case)]
308    #[must_use]
309    pub fn MXN() -> Self {
310        *MXN_LOCK.get_or_init(|| Self {
311            code: Ustr::from("MXN"),
312            precision: 2,
313            iso4217: 484,
314            name: Ustr::from("Mexican peso"),
315            currency_type: CurrencyType::Fiat,
316        })
317    }
318
319    #[allow(non_snake_case)]
320    #[must_use]
321    pub fn NOK() -> Self {
322        *NOK_LOCK.get_or_init(|| Self {
323            code: Ustr::from("NOK"),
324            precision: 2,
325            iso4217: 578,
326            name: Ustr::from("Norwegian krone"),
327            currency_type: CurrencyType::Fiat,
328        })
329    }
330
331    #[allow(non_snake_case)]
332    #[must_use]
333    pub fn NZD() -> Self {
334        *NZD_LOCK.get_or_init(|| Self {
335            code: Ustr::from("NZD"),
336            precision: 2,
337            iso4217: 554,
338            name: Ustr::from("New Zealand dollar"),
339            currency_type: CurrencyType::Fiat,
340        })
341    }
342
343    #[allow(non_snake_case)]
344    #[must_use]
345    pub fn PLN() -> Self {
346        *PLN_LOCK.get_or_init(|| Self {
347            code: Ustr::from("PLN"),
348            precision: 2,
349            iso4217: 985,
350            name: Ustr::from("Polish złoty"),
351            currency_type: CurrencyType::Fiat,
352        })
353    }
354
355    #[allow(non_snake_case)]
356    #[must_use]
357    pub fn RUB() -> Self {
358        *RUB_LOCK.get_or_init(|| Self {
359            code: Ustr::from("RUB"),
360            precision: 2,
361            iso4217: 643,
362            name: Ustr::from("Russian ruble"),
363            currency_type: CurrencyType::Fiat,
364        })
365    }
366
367    #[allow(non_snake_case)]
368    #[must_use]
369    pub fn SAR() -> Self {
370        *SAR_LOCK.get_or_init(|| Self {
371            code: Ustr::from("SAR"),
372            precision: 2,
373            iso4217: 682,
374            name: Ustr::from("Saudi riyal"),
375            currency_type: CurrencyType::Fiat,
376        })
377    }
378
379    #[allow(non_snake_case)]
380    #[must_use]
381    pub fn SEK() -> Self {
382        *SEK_LOCK.get_or_init(|| Self {
383            code: Ustr::from("SEK"),
384            precision: 2,
385            iso4217: 752,
386            name: Ustr::from("Swedish krona"),
387            currency_type: CurrencyType::Fiat,
388        })
389    }
390
391    #[allow(non_snake_case)]
392    #[must_use]
393    pub fn SGD() -> Self {
394        *SGD_LOCK.get_or_init(|| Self {
395            code: Ustr::from("SGD"),
396            precision: 2,
397            iso4217: 702,
398            name: Ustr::from("Singapore dollar"),
399            currency_type: CurrencyType::Fiat,
400        })
401    }
402
403    #[allow(non_snake_case)]
404    #[must_use]
405    pub fn THB() -> Self {
406        *THB_LOCK.get_or_init(|| Self {
407            code: Ustr::from("THB"),
408            precision: 2,
409            iso4217: 764,
410            name: Ustr::from("Thai baht"),
411            currency_type: CurrencyType::Fiat,
412        })
413    }
414
415    #[allow(non_snake_case)]
416    #[must_use]
417    pub fn TRY() -> Self {
418        *TRY_LOCK.get_or_init(|| Self {
419            code: Ustr::from("TRY"),
420            precision: 2,
421            iso4217: 949,
422            name: Ustr::from("Turkish lira"),
423            currency_type: CurrencyType::Fiat,
424        })
425    }
426
427    #[allow(non_snake_case)]
428    #[must_use]
429    pub fn TWD() -> Self {
430        *TWD_LOCK.get_or_init(|| Self {
431            code: Ustr::from("TWD"),
432            precision: 2,
433            iso4217: 901,
434            name: Ustr::from("New Taiwan dollar"),
435            currency_type: CurrencyType::Fiat,
436        })
437    }
438
439    #[allow(non_snake_case)]
440    #[must_use]
441    pub fn USD() -> Self {
442        *USD_LOCK.get_or_init(|| Self {
443            code: Ustr::from("USD"),
444            precision: 2,
445            iso4217: 840,
446            name: Ustr::from("United States dollar"),
447            currency_type: CurrencyType::Fiat,
448        })
449    }
450    #[allow(non_snake_case)]
451    #[must_use]
452    pub fn ZAR() -> Self {
453        *ZAR_LOCK.get_or_init(|| Self {
454            code: Ustr::from("ZAR"),
455            precision: 2,
456            iso4217: 710,
457            name: Ustr::from("South African rand"),
458            currency_type: CurrencyType::Fiat,
459        })
460    }
461
462    #[allow(non_snake_case)]
463    #[must_use]
464    pub fn XAG() -> Self {
465        *XAG_LOCK.get_or_init(|| Self {
466            code: Ustr::from("XAG"),
467            precision: 2,
468            iso4217: 961,
469            name: Ustr::from("Silver (one troy ounce)"),
470            currency_type: CurrencyType::CommodityBacked,
471        })
472    }
473
474    #[allow(non_snake_case)]
475    #[must_use]
476    pub fn XAU() -> Self {
477        *XAU_LOCK.get_or_init(|| Self {
478            code: Ustr::from("XAU"),
479            precision: 2,
480            iso4217: 959,
481            name: Ustr::from("Gold (one troy ounce)"),
482            currency_type: CurrencyType::CommodityBacked,
483        })
484    }
485
486    #[allow(non_snake_case)]
487    #[must_use]
488    pub fn XPT() -> Self {
489        *XPT_LOCK.get_or_init(|| Self {
490            code: Ustr::from("XPT"),
491            precision: 2,
492            iso4217: 962,
493            name: Ustr::from("Platinum (one troy ounce)"),
494            currency_type: CurrencyType::CommodityBacked,
495        })
496    }
497
498    #[allow(non_snake_case)]
499    #[must_use]
500    pub fn ONEINCH() -> Self {
501        *ONEINCH_LOCK.get_or_init(|| Self {
502            code: Ustr::from("1INCH"),
503            precision: 8,
504            iso4217: 0,
505            name: Ustr::from("1inch Network"),
506            currency_type: CurrencyType::Crypto,
507        })
508    }
509
510    #[allow(non_snake_case)]
511    #[must_use]
512    pub fn AAVE() -> Self {
513        *AAVE_LOCK.get_or_init(|| Self {
514            code: Ustr::from("AAVE"),
515            precision: 8,
516            iso4217: 0,
517            name: Ustr::from("Aave"),
518            currency_type: CurrencyType::Crypto,
519        })
520    }
521
522    #[allow(non_snake_case)]
523    #[must_use]
524    pub fn ACA() -> Self {
525        *ACA_LOCK.get_or_init(|| Self {
526            code: Ustr::from("ACA"),
527            precision: 8,
528            iso4217: 0,
529            name: Ustr::from("Acala Token"),
530            currency_type: CurrencyType::Crypto,
531        })
532    }
533
534    #[allow(non_snake_case)]
535    #[must_use]
536    pub fn ADA() -> Self {
537        *ADA_LOCK.get_or_init(|| Self {
538            code: Ustr::from("ADA"),
539            precision: 6,
540            iso4217: 0,
541            name: Ustr::from("Cardano"),
542            currency_type: CurrencyType::Crypto,
543        })
544    }
545
546    #[allow(non_snake_case)]
547    #[must_use]
548    pub fn AVAX() -> Self {
549        *AVAX_LOCK.get_or_init(|| Self {
550            code: Ustr::from("AVAX"),
551            precision: 8,
552            iso4217: 0,
553            name: Ustr::from("Avalanche"),
554            currency_type: CurrencyType::Crypto,
555        })
556    }
557
558    #[allow(non_snake_case)]
559    #[must_use]
560    pub fn BCH() -> Self {
561        *BCH_LOCK.get_or_init(|| Self {
562            code: Ustr::from("BCH"),
563            precision: 8,
564            iso4217: 0,
565            name: Ustr::from("Bitcoin Cash"),
566            currency_type: CurrencyType::Crypto,
567        })
568    }
569
570    #[allow(non_snake_case)]
571    #[must_use]
572    pub fn BTC() -> Self {
573        *BTC_LOCK.get_or_init(|| Self {
574            code: Ustr::from("BTC"),
575            precision: 8,
576            iso4217: 0,
577            name: Ustr::from("Bitcoin"),
578            currency_type: CurrencyType::Crypto,
579        })
580    }
581
582    #[allow(non_snake_case)]
583    #[must_use]
584    pub fn BTTC() -> Self {
585        *BTTC_LOCK.get_or_init(|| Self {
586            code: Ustr::from("BTTC"),
587            precision: 8,
588            iso4217: 0,
589            name: Ustr::from("BitTorrent"),
590            currency_type: CurrencyType::Crypto,
591        })
592    }
593
594    #[allow(non_snake_case)]
595    #[must_use]
596    pub fn BNB() -> Self {
597        *BNB_LOCK.get_or_init(|| Self {
598            code: Ustr::from("BNB"),
599            precision: 8,
600            iso4217: 0,
601            name: Ustr::from("Binance Coin"),
602            currency_type: CurrencyType::Crypto,
603        })
604    }
605
606    #[allow(non_snake_case)]
607    #[must_use]
608    pub fn BRZ() -> Self {
609        *BRZ_LOCK.get_or_init(|| Self {
610            code: Ustr::from("BRZ"),
611            precision: 6,
612            iso4217: 0,
613            name: Ustr::from("Brazilian Digital Token"),
614            currency_type: CurrencyType::Crypto,
615        })
616    }
617
618    #[allow(non_snake_case)]
619    #[must_use]
620    pub fn BSV() -> Self {
621        *BSV_LOCK.get_or_init(|| Self {
622            code: Ustr::from("BSV"),
623            precision: 8,
624            iso4217: 0,
625            name: Ustr::from("Bitcoin SV"),
626            currency_type: CurrencyType::Crypto,
627        })
628    }
629
630    #[allow(non_snake_case)]
631    #[must_use]
632    pub fn BUSD() -> Self {
633        *BUSD_LOCK.get_or_init(|| Self {
634            code: Ustr::from("BUSD"),
635            precision: 8,
636            iso4217: 0,
637            name: Ustr::from("Binance USD"),
638            currency_type: CurrencyType::Crypto,
639        })
640    }
641
642    #[allow(non_snake_case)]
643    #[must_use]
644    pub fn CAKE() -> Self {
645        *CAKE_LOCK.get_or_init(|| Self {
646            code: Ustr::from("CAKE"),
647            precision: 8,
648            iso4217: 0,
649            name: Ustr::from("PancakeSwap"),
650            currency_type: CurrencyType::Crypto,
651        })
652    }
653
654    #[allow(non_snake_case)]
655    #[must_use]
656    pub fn DASH() -> Self {
657        *DASH_LOCK.get_or_init(|| Self {
658            code: Ustr::from("DASH"),
659            precision: 8,
660            iso4217: 0,
661            name: Ustr::from("Dash"),
662            currency_type: CurrencyType::Crypto,
663        })
664    }
665
666    #[allow(non_snake_case)]
667    #[must_use]
668    pub fn DOT() -> Self {
669        *DOT_LOCK.get_or_init(|| Self {
670            code: Ustr::from("DOT"),
671            precision: 8,
672            iso4217: 0,
673            name: Ustr::from("Polkadot"),
674            currency_type: CurrencyType::Crypto,
675        })
676    }
677
678    #[allow(non_snake_case)]
679    #[must_use]
680    pub fn DOGE() -> Self {
681        *DOGE_LOCK.get_or_init(|| Self {
682            code: Ustr::from("DOGE"),
683            precision: 8,
684            iso4217: 0,
685            name: Ustr::from("Dogecoin"),
686            currency_type: CurrencyType::Crypto,
687        })
688    }
689
690    #[allow(non_snake_case)]
691    #[must_use]
692    pub fn EOS() -> Self {
693        *EOS_LOCK.get_or_init(|| Self {
694            code: Ustr::from("EOS"),
695            precision: 8,
696            iso4217: 0,
697            name: Ustr::from("EOS"),
698            currency_type: CurrencyType::Crypto,
699        })
700    }
701
702    #[allow(non_snake_case)]
703    #[must_use]
704    pub fn ETH() -> Self {
705        *ETH_LOCK.get_or_init(|| Self {
706            code: Ustr::from("ETH"),
707            precision: 8,
708            iso4217: 0,
709            name: Ustr::from("Ethereum"),
710            currency_type: CurrencyType::Crypto,
711        })
712    }
713
714    #[allow(non_snake_case)]
715    #[must_use]
716    pub fn ETHW() -> Self {
717        *ETHW_LOCK.get_or_init(|| Self {
718            code: Ustr::from("ETHW"),
719            precision: 8,
720            iso4217: 0,
721            name: Ustr::from("EthereumPoW"),
722            currency_type: CurrencyType::Crypto,
723        })
724    }
725
726    #[allow(non_snake_case)]
727    #[must_use]
728    pub fn JOE() -> Self {
729        *JOE_LOCK.get_or_init(|| Self {
730            code: Ustr::from("JOE"),
731            precision: 8,
732            iso4217: 0,
733            name: Ustr::from("JOE"),
734            currency_type: CurrencyType::Crypto,
735        })
736    }
737
738    #[allow(non_snake_case)]
739    #[must_use]
740    pub fn LINK() -> Self {
741        *LINK_LOCK.get_or_init(|| Self {
742            code: Ustr::from("LINK"),
743            precision: 8,
744            iso4217: 0,
745            name: Ustr::from("Chainlink"),
746            currency_type: CurrencyType::Crypto,
747        })
748    }
749
750    #[allow(non_snake_case)]
751    #[must_use]
752    pub fn LTC() -> Self {
753        *LTC_LOCK.get_or_init(|| Self {
754            code: Ustr::from("LTC"),
755            precision: 8,
756            iso4217: 0,
757            name: Ustr::from("Litecoin"),
758            currency_type: CurrencyType::Crypto,
759        })
760    }
761
762    #[allow(non_snake_case)]
763    #[must_use]
764    pub fn LUNA() -> Self {
765        *LUNA_LOCK.get_or_init(|| Self {
766            code: Ustr::from("LUNA"),
767            precision: 8,
768            iso4217: 0,
769            name: Ustr::from("Terra"),
770            currency_type: CurrencyType::Crypto,
771        })
772    }
773
774    #[allow(non_snake_case)]
775    #[must_use]
776    pub fn NBT() -> Self {
777        *NBT_LOCK.get_or_init(|| Self {
778            code: Ustr::from("NBT"),
779            precision: 8,
780            iso4217: 0,
781            name: Ustr::from("NanoByte Token"),
782            currency_type: CurrencyType::Crypto,
783        })
784    }
785
786    #[allow(non_snake_case)]
787    #[must_use]
788    pub fn SOL() -> Self {
789        *SOL_LOCK.get_or_init(|| Self {
790            code: Ustr::from("SOL"),
791            precision: 8,
792            iso4217: 0,
793            name: Ustr::from("Solana"),
794            currency_type: CurrencyType::Crypto,
795        })
796    }
797
798    #[allow(non_snake_case)]
799    #[must_use]
800    pub fn SHIB() -> Self {
801        *SHIB_LOCK.get_or_init(|| Self {
802            code: Ustr::from("SHIB"),
803            precision: 8,
804            iso4217: 0,
805            name: Ustr::from("Shiba Inu"),
806            currency_type: CurrencyType::Crypto,
807        })
808    }
809
810    #[allow(non_snake_case)]
811    #[must_use]
812    pub fn TRX() -> Self {
813        *TRX_LOCK.get_or_init(|| Self {
814            code: Ustr::from("TRX"),
815            precision: 8,
816            iso4217: 0,
817            name: Ustr::from("TRON"),
818            currency_type: CurrencyType::Crypto,
819        })
820    }
821
822    #[allow(non_snake_case)]
823    #[must_use]
824    pub fn TRYB() -> Self {
825        *TRYB_LOCK.get_or_init(|| Self {
826            code: Ustr::from("TRYB"),
827            precision: 8,
828            iso4217: 0,
829            name: Ustr::from("BiLibra"),
830            currency_type: CurrencyType::Crypto,
831        })
832    }
833
834    #[allow(non_snake_case)]
835    #[must_use]
836    pub fn TUSD() -> Self {
837        *TUSD_LOCK.get_or_init(|| Self {
838            code: Ustr::from("TUSD"),
839            precision: 8,
840            iso4217: 0,
841            name: Ustr::from("TrueUSD"),
842            currency_type: CurrencyType::Crypto,
843        })
844    }
845
846    #[allow(non_snake_case)]
847    #[must_use]
848    pub fn VTC() -> Self {
849        *VTC_LOCK.get_or_init(|| Self {
850            code: Ustr::from("VTC"),
851            precision: 8,
852            iso4217: 0,
853            name: Ustr::from("Vertcoin"),
854            currency_type: CurrencyType::Crypto,
855        })
856    }
857
858    #[allow(non_snake_case)]
859    #[must_use]
860    pub fn WSB() -> Self {
861        *WSB_LOCK.get_or_init(|| Self {
862            code: Ustr::from("WSB"),
863            precision: 8,
864            iso4217: 0,
865            name: Ustr::from("WallStreetBets DApp"),
866            currency_type: CurrencyType::Crypto,
867        })
868    }
869
870    #[allow(non_snake_case)]
871    #[must_use]
872    pub fn XBT() -> Self {
873        *XBT_LOCK.get_or_init(|| Self {
874            code: Ustr::from("XBT"),
875            precision: 8,
876            iso4217: 0,
877            name: Ustr::from("Bitcoin"),
878            currency_type: CurrencyType::Crypto,
879        })
880    }
881
882    #[allow(non_snake_case)]
883    #[must_use]
884    pub fn XEC() -> Self {
885        *XEC_LOCK.get_or_init(|| Self {
886            code: Ustr::from("XEC"),
887            precision: 8,
888            iso4217: 0,
889            name: Ustr::from("eCash"),
890            currency_type: CurrencyType::Crypto,
891        })
892    }
893
894    #[allow(non_snake_case)]
895    #[must_use]
896    pub fn XLM() -> Self {
897        *XLM_LOCK.get_or_init(|| Self {
898            code: Ustr::from("XLM"),
899            precision: 8,
900            iso4217: 0,
901            name: Ustr::from("Stellar Lumen"),
902            currency_type: CurrencyType::Crypto,
903        })
904    }
905
906    #[allow(non_snake_case)]
907    #[must_use]
908    pub fn XMR() -> Self {
909        *XMR_LOCK.get_or_init(|| Self {
910            code: Ustr::from("XMR"),
911            precision: 8,
912            iso4217: 0,
913            name: Ustr::from("Monero"),
914            currency_type: CurrencyType::Crypto,
915        })
916    }
917
918    #[allow(non_snake_case)]
919    #[must_use]
920    pub fn USDT() -> Self {
921        *USDT_LOCK.get_or_init(|| Self {
922            code: Ustr::from("USDT"),
923            precision: 8,
924            iso4217: 0,
925            name: Ustr::from("Tether"),
926            currency_type: CurrencyType::Crypto,
927        })
928    }
929
930    #[allow(non_snake_case)]
931    #[must_use]
932    pub fn XRP() -> Self {
933        *XRP_LOCK.get_or_init(|| Self {
934            code: Ustr::from("XRP"),
935            precision: 6,
936            iso4217: 0,
937            name: Ustr::from("XRP"),
938            currency_type: CurrencyType::Crypto,
939        })
940    }
941
942    #[allow(non_snake_case)]
943    #[must_use]
944    pub fn XTZ() -> Self {
945        *XTZ_LOCK.get_or_init(|| Self {
946            code: Ustr::from("XTZ"),
947            precision: 6,
948            iso4217: 0,
949            name: Ustr::from("Tezos"),
950            currency_type: CurrencyType::Crypto,
951        })
952    }
953
954    #[must_use]
955    #[allow(non_snake_case)]
956    pub fn USDC() -> Self {
957        *USDC_LOCK.get_or_init(|| Self {
958            code: Ustr::from("USDC"),
959            precision: 8,
960            iso4217: 0,
961            name: Ustr::from("USD Coin"),
962            currency_type: CurrencyType::Crypto,
963        })
964    }
965
966    #[must_use]
967    #[allow(non_snake_case)]
968    pub fn USDC_POS() -> Self {
969        *USDC_POS_LOCK.get_or_init(|| Self {
970            code: Ustr::from("USDC.e"),
971            precision: 6,
972            iso4217: 0,
973            name: Ustr::from("USD Coin (PoS)"),
974            currency_type: CurrencyType::Crypto,
975        })
976    }
977
978    #[allow(non_snake_case)]
979    #[must_use]
980    pub fn USDP() -> Self {
981        *USDP_LOCK.get_or_init(|| Self {
982            code: Ustr::from("USDP"),
983            precision: 4,
984            iso4217: 0,
985            name: Ustr::from("Pax Dollar"),
986            currency_type: CurrencyType::Crypto,
987        })
988    }
989
990    #[allow(non_snake_case)]
991    #[must_use]
992    pub fn ZEC() -> Self {
993        *ZEC_LOCK.get_or_init(|| Self {
994            code: Ustr::from("ZEC"),
995            precision: 8,
996            iso4217: 0,
997            name: Ustr::from("Zcash"),
998            currency_type: CurrencyType::Crypto,
999        })
1000    }
1001}
1002
1003/// A map of built-in `Currency` constants.
1004pub static CURRENCY_MAP: LazyLock<Mutex<HashMap<String, Currency>>> = LazyLock::new(|| {
1005    let mut map = HashMap::new();
1006    ///////////////////////////////////////////////////////////////////////////
1007    // Fiat currencies
1008    ///////////////////////////////////////////////////////////////////////////
1009    map.insert(Currency::AUD().code.to_string(), Currency::AUD());
1010    map.insert(Currency::BRL().code.to_string(), Currency::BRL());
1011    map.insert(Currency::CAD().code.to_string(), Currency::CAD());
1012    map.insert(Currency::CHF().code.to_string(), Currency::CHF());
1013    map.insert(Currency::CNY().code.to_string(), Currency::CNY());
1014    map.insert(Currency::CNH().code.to_string(), Currency::CNH());
1015    map.insert(Currency::CZK().code.to_string(), Currency::CZK());
1016    map.insert(Currency::DKK().code.to_string(), Currency::DKK());
1017    map.insert(Currency::EUR().code.to_string(), Currency::EUR());
1018    map.insert(Currency::GBP().code.to_string(), Currency::GBP());
1019    map.insert(Currency::HKD().code.to_string(), Currency::HKD());
1020    map.insert(Currency::HUF().code.to_string(), Currency::HUF());
1021    map.insert(Currency::ILS().code.to_string(), Currency::ILS());
1022    map.insert(Currency::INR().code.to_string(), Currency::INR());
1023    map.insert(Currency::JPY().code.to_string(), Currency::JPY());
1024    map.insert(Currency::KRW().code.to_string(), Currency::KRW());
1025    map.insert(Currency::MXN().code.to_string(), Currency::MXN());
1026    map.insert(Currency::NOK().code.to_string(), Currency::NOK());
1027    map.insert(Currency::NZD().code.to_string(), Currency::NZD());
1028    map.insert(Currency::PLN().code.to_string(), Currency::PLN());
1029    map.insert(Currency::RUB().code.to_string(), Currency::RUB());
1030    map.insert(Currency::SAR().code.to_string(), Currency::SAR());
1031    map.insert(Currency::SEK().code.to_string(), Currency::SEK());
1032    map.insert(Currency::SGD().code.to_string(), Currency::SGD());
1033    map.insert(Currency::THB().code.to_string(), Currency::THB());
1034    map.insert(Currency::TRY().code.to_string(), Currency::TRY());
1035    map.insert(Currency::USD().code.to_string(), Currency::USD());
1036    map.insert(Currency::XAG().code.to_string(), Currency::XAG());
1037    map.insert(Currency::XAU().code.to_string(), Currency::XAU());
1038    map.insert(Currency::XPT().code.to_string(), Currency::XPT());
1039    map.insert(Currency::ZAR().code.to_string(), Currency::ZAR());
1040    ///////////////////////////////////////////////////////////////////////////
1041    // Crypto currencies
1042    ///////////////////////////////////////////////////////////////////////////
1043    map.insert(Currency::AAVE().code.to_string(), Currency::AAVE());
1044    map.insert(Currency::ACA().code.to_string(), Currency::ACA());
1045    map.insert(Currency::ADA().code.to_string(), Currency::ADA());
1046    map.insert(Currency::AVAX().code.to_string(), Currency::AVAX());
1047    map.insert(Currency::BCH().code.to_string(), Currency::BCH());
1048    map.insert(Currency::BTC().code.to_string(), Currency::BTC());
1049    map.insert(Currency::BTTC().code.to_string(), Currency::BTTC());
1050    map.insert(Currency::BNB().code.to_string(), Currency::BNB());
1051    map.insert(Currency::BRZ().code.to_string(), Currency::BRZ());
1052    map.insert(Currency::BSV().code.to_string(), Currency::BSV());
1053    map.insert(Currency::BUSD().code.to_string(), Currency::BUSD());
1054    map.insert(Currency::DASH().code.to_string(), Currency::DASH());
1055    map.insert(Currency::DOGE().code.to_string(), Currency::DOGE());
1056    map.insert(Currency::DOT().code.to_string(), Currency::DOT());
1057    map.insert(Currency::EOS().code.to_string(), Currency::EOS());
1058    map.insert(Currency::ETH().code.to_string(), Currency::ETH());
1059    map.insert(Currency::ETHW().code.to_string(), Currency::ETHW());
1060    map.insert(Currency::JOE().code.to_string(), Currency::JOE());
1061    map.insert(Currency::LINK().code.to_string(), Currency::LINK());
1062    map.insert(Currency::LTC().code.to_string(), Currency::LTC());
1063    map.insert(Currency::LUNA().code.to_string(), Currency::LUNA());
1064    map.insert(Currency::NBT().code.to_string(), Currency::NBT());
1065    map.insert(Currency::SOL().code.to_string(), Currency::SOL());
1066    map.insert(Currency::TRX().code.to_string(), Currency::TRX());
1067    map.insert(Currency::TRYB().code.to_string(), Currency::TRYB());
1068    map.insert(Currency::TUSD().code.to_string(), Currency::TUSD());
1069    map.insert(Currency::VTC().code.to_string(), Currency::VTC());
1070    map.insert(Currency::WSB().code.to_string(), Currency::WSB());
1071    map.insert(Currency::XBT().code.to_string(), Currency::XBT());
1072    map.insert(Currency::XEC().code.to_string(), Currency::XEC());
1073    map.insert(Currency::XLM().code.to_string(), Currency::XLM());
1074    map.insert(Currency::XMR().code.to_string(), Currency::XMR());
1075    map.insert(Currency::XRP().code.to_string(), Currency::XRP());
1076    map.insert(Currency::XTZ().code.to_string(), Currency::XTZ());
1077    map.insert(Currency::USDC().code.to_string(), Currency::USDC());
1078    map.insert(Currency::USDC_POS().code.to_string(), Currency::USDC_POS());
1079    map.insert(Currency::USDP().code.to_string(), Currency::USDP());
1080    map.insert(Currency::USDT().code.to_string(), Currency::USDT());
1081    map.insert(Currency::ZEC().code.to_string(), Currency::ZEC());
1082    Mutex::new(map)
1083});