dev
dart 1,156 lines 33.2 KB
Raw
1 import 'package:cw_core/amount/money.dart';
2 import 'package:cw_core/currency.dart';
3 import 'package:cw_core/currency_groups.dart';
4 import 'package:cw_core/enumerable_item.dart';
5 import 'package:collection/collection.dart';
6 import 'package:cw_core/format_fixed.dart';
7
8 class CryptoCurrency extends EnumerableItem<int> with Serializable<int> implements Currency {
9 const CryptoCurrency({
10 String title = '',
11 int raw = -1,
12 required this.name,
13 required this.decimals,
14 this.fullName,
15 this.iconPath,
16 this.flatIconPath,
17 this.tag,
18 this.chainIconPath,
19 this.enabled = false,
20 this.isPotentialScam = false,
21 this.groups = const {},
22 }) : super(title: title, raw: raw);
23
24 final String? flatIconPath;
25 final String? chainIconPath;
26 final bool enabled;
27 final bool isPotentialScam;
28 final Set<String> groups;
29
30 @override
31 final String name;
32
33 @override
34 final String? fullName;
35
36 @override
37 final String? tag;
38
39 @override
40 final String? iconPath;
41
42 @override
43 final int decimals;
44
45 @override
46 String get symbol => title;
47
48 set enabled(bool value) => this.enabled = value;
49
50 static const all = [
51 CryptoCurrency.xmr,
52 CryptoCurrency.btc,
53 CryptoCurrency.btcln,
54 CryptoCurrency.eth,
55 CryptoCurrency.ltc,
56 CryptoCurrency.doge,
57 CryptoCurrency.usdterc20,
58 CryptoCurrency.usdtbsc,
59 CryptoCurrency.usdttrc20,
60 CryptoCurrency.usdc,
61 CryptoCurrency.deuro,
62 CryptoCurrency.maticpoly,
63 CryptoCurrency.sol,
64 CryptoCurrency.trx,
65 CryptoCurrency.bch,
66 CryptoCurrency.ada,
67 CryptoCurrency.bnb,
68 CryptoCurrency.dai,
69 CryptoCurrency.dash,
70 CryptoCurrency.eos,
71 CryptoCurrency.nano,
72 CryptoCurrency.xlm,
73 CryptoCurrency.xrp,
74 CryptoCurrency.xhv,
75 CryptoCurrency.ape,
76 CryptoCurrency.avaxc,
77 CryptoCurrency.btt,
78 CryptoCurrency.bttc,
79 CryptoCurrency.firo,
80 CryptoCurrency.usdt,
81 CryptoCurrency.hbar,
82 CryptoCurrency.sc,
83 CryptoCurrency.usdcsol,
84 CryptoCurrency.zec,
85 CryptoCurrency.zen,
86 CryptoCurrency.xvg,
87 CryptoCurrency.usdcpoly,
88 CryptoCurrency.dcr,
89 CryptoCurrency.kmd,
90 CryptoCurrency.mana,
91 CryptoCurrency.matic,
92 CryptoCurrency.mkr,
93 CryptoCurrency.near,
94 CryptoCurrency.oxt,
95 CryptoCurrency.paxg,
96 CryptoCurrency.pivx,
97 CryptoCurrency.rune,
98 CryptoCurrency.rvn,
99 CryptoCurrency.scrt,
100 CryptoCurrency.uni,
101 CryptoCurrency.stx,
102 CryptoCurrency.shib,
103 CryptoCurrency.aave,
104 CryptoCurrency.arb,
105 CryptoCurrency.bat,
106 CryptoCurrency.comp,
107 CryptoCurrency.cro,
108 CryptoCurrency.ens,
109 CryptoCurrency.ftm,
110 CryptoCurrency.frax,
111 CryptoCurrency.gusd,
112 CryptoCurrency.gtc,
113 CryptoCurrency.grt,
114 CryptoCurrency.ldo,
115 CryptoCurrency.nexo,
116 CryptoCurrency.cake,
117 CryptoCurrency.pepe,
118 CryptoCurrency.storj,
119 CryptoCurrency.tusd,
120 CryptoCurrency.wbtc,
121 CryptoCurrency.weth,
122 CryptoCurrency.zrx,
123 CryptoCurrency.dydx,
124 CryptoCurrency.steth,
125 CryptoCurrency.banano,
126 CryptoCurrency.usdtPoly,
127 CryptoCurrency.usdcEPoly,
128 CryptoCurrency.kaspa,
129 CryptoCurrency.digibyte,
130 CryptoCurrency.usdtSol,
131 CryptoCurrency.usdcTrc20,
132 CryptoCurrency.tbtc,
133 CryptoCurrency.wow,
134 CryptoCurrency.zano,
135 CryptoCurrency.ton,
136 CryptoCurrency.flip,
137 CryptoCurrency.ndeps,
138 CryptoCurrency.deps,
139 CryptoCurrency.baseEth,
140 CryptoCurrency.usde,
141 CryptoCurrency.arbEth,
142 CryptoCurrency.usdcArb,
143 CryptoCurrency.usdtArb,
144 ];
145
146 static const havenCurrencies = [
147 xag,
148 xau,
149 xaud,
150 xbtc,
151 xcad,
152 xchf,
153 xcny,
154 xeur,
155 xgbp,
156 xjpy,
157 xnok,
158 xnzd,
159 xusd,
160 ];
161
162 // well technically not currencies but since we had them a long time ago and don't want to break
163 // the app for users who had contacts saved for them
164 static const zcashCurrencies = [zec, zaddr, tzec];
165
166 // title, tag (if applicable), fullName (if unique), raw, name, iconPath
167 static const xmr = CryptoCurrency(
168 title: 'XMR',
169 fullName: 'Monero',
170 raw: 0,
171 name: 'xmr',
172 iconPath: 'assets/new-ui/crypto_full_icons/monero.svg',
173 decimals: 12,
174 flatIconPath: "assets/new-ui/balance_card_icons/monero.svg");
175 static const ada = CryptoCurrency(
176 title: 'ADA',
177 fullName: 'Cardano',
178 raw: 1,
179 name: 'ada',
180 iconPath: 'assets/images/ada_icon.png',
181 decimals: 6);
182 static const bch = CryptoCurrency(
183 title: 'BCH',
184 fullName: 'Bitcoin Cash',
185 raw: 2,
186 name: 'bch',
187 iconPath: 'assets/new-ui/crypto_full_icons/bitcoin-cash.svg',
188 decimals: 8,
189 flatIconPath: "assets/new-ui/balance_card_icons/bitcoin_cash.svg");
190 static const bnb = CryptoCurrency(
191 title: 'BNB',
192 tag: 'BSC',
193 fullName: 'BNB',
194 raw: 3,
195 name: 'bnb',
196 iconPath: 'assets/new-ui/crypto_full_icons/bnb.svg',
197 decimals: 18,
198 flatIconPath: "assets/new-ui/balance_card_icons/bnb.svg",
199 chainIconPath: "assets/new-ui/chain_badges/bnb.svg");
200 static const btc = CryptoCurrency(
201 title: 'BTC',
202 fullName: 'Bitcoin',
203 raw: 4,
204 name: 'btc',
205 iconPath: 'assets/new-ui/crypto_full_icons/bitcoin.svg',
206 decimals: 8,
207 flatIconPath: "assets/new-ui/balance_card_icons/bitcoin.svg");
208 static const dai = CryptoCurrency(
209 title: 'DAI',
210 tag: 'ETH',
211 fullName: 'Dai',
212 raw: 5,
213 name: 'dai',
214 iconPath: 'assets/new-ui/crypto_full_icons/dai.svg',
215 decimals: 18,
216 groups: const {CurrencyGroups.stablecoin});
217 static const dash = CryptoCurrency(
218 title: 'DASH',
219 fullName: 'Dash',
220 raw: 6,
221 name: 'dash',
222 iconPath: 'assets/images/dash_icon.png',
223 decimals: 8);
224 static const eos = CryptoCurrency(
225 title: 'EOS',
226 fullName: 'EOS',
227 raw: 7,
228 name: 'eos',
229 iconPath: 'assets/images/eos_icon.png',
230 decimals: 4);
231 static const eth = CryptoCurrency(
232 title: 'ETH',
233 fullName: 'Ethereum',
234 raw: 8,
235 name: 'eth',
236 iconPath: 'assets/new-ui/crypto_full_icons/ethereum.svg',
237 decimals: 18,
238 flatIconPath: "assets/new-ui/balance_card_icons/ethereum.svg",
239 chainIconPath: "assets/new-ui/chain_badges/ethereum.svg");
240 static const ltc = CryptoCurrency(
241 title: 'LTC',
242 fullName: 'Litecoin',
243 raw: 9,
244 name: 'ltc',
245 iconPath: 'assets/new-ui/crypto_full_icons/litecoin.svg',
246 decimals: 8,
247 flatIconPath: "assets/new-ui/balance_card_icons/litecoin.svg",
248 chainIconPath: "assets/new-ui/chain_badges/mweb.svg");
249 static const nano = CryptoCurrency(
250 title: 'XNO',
251 fullName: 'Nano',
252 raw: 10,
253 name: 'xno',
254 iconPath: 'assets/new-ui/crypto_full_icons/nano.svg',
255 decimals: 30,
256 flatIconPath: "assets/new-ui/balance_card_icons/nano.svg");
257 static const trx = CryptoCurrency(
258 title: 'TRX',
259 fullName: 'TRON',
260 raw: 11,
261 name: 'trx',
262 iconPath: 'assets/new-ui/crypto_full_icons/tron.svg',
263 decimals: 6,
264 flatIconPath: "assets/new-ui/balance_card_icons/tron.svg",
265 chainIconPath: "assets/new-ui/chain_badges/tron.svg");
266 static const usdt = CryptoCurrency(
267 title: 'USDT',
268 tag: 'OMNI',
269 fullName: 'Tether',
270 raw: 12,
271 name: 'usdt',
272 iconPath: 'assets/new-ui/crypto_full_icons/usdt.svg',
273 decimals: 6,
274 groups: const {CurrencyGroups.stablecoin});
275 static const usdterc20 = CryptoCurrency(
276 title: 'USDT',
277 tag: 'ETH',
278 fullName: 'Tether',
279 raw: 13,
280 name: 'usdterc20',
281 iconPath: 'assets/new-ui/crypto_full_icons/usdt.svg',
282 decimals: 6,
283 groups: const {CurrencyGroups.stablecoin});
284 static const xlm = CryptoCurrency(
285 title: 'XLM',
286 fullName: 'Stellar',
287 raw: 14,
288 name: 'xlm',
289 iconPath: 'assets/images/xlm_icon.png',
290 decimals: 7);
291 static const xrp = CryptoCurrency(
292 title: 'XRP',
293 fullName: 'Ripple',
294 raw: 15,
295 name: 'xrp',
296 iconPath: 'assets/images/xrp_icon.png',
297 decimals: 6);
298 static const xhv = CryptoCurrency(
299 title: 'XHV',
300 fullName: 'Haven Protocol',
301 raw: 16,
302 name: 'xhv',
303 iconPath: 'assets/images/xhv_logo.png',
304 decimals: 12);
305
306 static const xag = CryptoCurrency(title: 'XAG', tag: 'XHV', raw: 17, name: 'xag', decimals: 12);
307 static const xau = CryptoCurrency(title: 'XAU', tag: 'XHV', raw: 18, name: 'xau', decimals: 12);
308 static const xaud =
309 CryptoCurrency(title: 'XAUD', tag: 'XHV', raw: 19, name: 'xaud', decimals: 12);
310 static const xbtc =
311 CryptoCurrency(title: 'XBTC', tag: 'XHV', raw: 20, name: 'xbtc', decimals: 12);
312 static const xcad =
313 CryptoCurrency(title: 'XCAD', tag: 'XHV', raw: 21, name: 'xcad', decimals: 12);
314 static const xchf =
315 CryptoCurrency(title: 'XCHF', tag: 'XHV', raw: 22, name: 'xchf', decimals: 12);
316 static const xcny =
317 CryptoCurrency(title: 'XCNY', tag: 'XHV', raw: 23, name: 'xcny', decimals: 12);
318 static const xeur =
319 CryptoCurrency(title: 'XEUR', tag: 'XHV', raw: 24, name: 'xeur', decimals: 12);
320 static const xgbp =
321 CryptoCurrency(title: 'XGBP', tag: 'XHV', raw: 25, name: 'xgbp', decimals: 12);
322 static const xjpy =
323 CryptoCurrency(title: 'XJPY', tag: 'XHV', raw: 26, name: 'xjpy', decimals: 12);
324 static const xnok =
325 CryptoCurrency(title: 'XNOK', tag: 'XHV', raw: 27, name: 'xnok', decimals: 12);
326 static const xnzd =
327 CryptoCurrency(title: 'XNZD', tag: 'XHV', raw: 28, name: 'xnzd', decimals: 12);
328 static const xusd =
329 CryptoCurrency(title: 'XUSD', tag: 'XHV', raw: 29, name: 'xusd', decimals: 12);
330
331 static const ape = CryptoCurrency(
332 title: 'APE',
333 tag: 'ETH',
334 fullName: 'ApeCoin',
335 raw: 30,
336 name: 'ape',
337 iconPath: 'assets/images/ape_icon.png',
338 decimals: 18);
339 static const avaxc = CryptoCurrency(
340 title: 'AVAX',
341 tag: 'AVAXC',
342 fullName: 'Avalanche',
343 raw: 31,
344 name: 'avaxc',
345 iconPath: 'assets/new-ui/crypto_full_icons/avax.svg',
346 decimals: 9);
347 static const btt = CryptoCurrency(
348 title: 'BTT',
349 tag: 'ETH',
350 fullName: 'BitTorrent',
351 raw: 32,
352 name: 'btt',
353 iconPath: 'assets/images/btt_icon.png',
354 decimals: 18);
355 static const bttc = CryptoCurrency(
356 title: 'BTTC',
357 tag: 'TRX',
358 fullName: 'BitTorrent-NEW',
359 raw: 33,
360 name: 'bttc',
361 iconPath: 'assets/images/btt_icon.png',
362 decimals: 18);
363 static const doge = CryptoCurrency(
364 title: 'DOGE',
365 fullName: 'Dogecoin',
366 raw: 34,
367 name: 'doge',
368 iconPath: 'assets/new-ui/crypto_full_icons/dogecoin.svg',
369 decimals: 8,
370 flatIconPath: "assets/new-ui/balance_card_icons/dogecoin.svg");
371 static const firo = CryptoCurrency(
372 title: 'FIRO', raw: 35, name: 'firo', iconPath: 'assets/images/firo_icon.png', decimals: 8);
373 static const usdttrc20 = CryptoCurrency(
374 title: 'USDT',
375 tag: 'TRX',
376 fullName: 'Tether',
377 raw: 36,
378 name: 'usdttrc20',
379 iconPath: 'assets/new-ui/crypto_full_icons/usdt.svg',
380 decimals: 6,
381 groups: const {CurrencyGroups.stablecoin});
382 static const hbar = CryptoCurrency(
383 title: 'HBAR',
384 fullName: 'Hedera',
385 raw: 37,
386 name: 'hbar',
387 iconPath: 'assets/images/hbar_icon.png',
388 decimals: 8);
389 static const sc = CryptoCurrency(
390 title: 'SC',
391 fullName: 'Siacoin',
392 raw: 38,
393 name: 'sc',
394 iconPath: 'assets/images/sc_icon.png',
395 decimals: 16);
396 static const sol = CryptoCurrency(
397 title: 'SOL',
398 fullName: 'Solana',
399 raw: 39,
400 name: 'sol',
401 iconPath: 'assets/new-ui/crypto_full_icons/solana.svg',
402 decimals: 9,
403 flatIconPath: "assets/new-ui/balance_card_icons/solana.svg",
404 chainIconPath: "assets/new-ui/chain_badges/solana.svg");
405 static const usdc = CryptoCurrency(
406 title: 'USDC',
407 tag: 'ETH',
408 fullName: 'USDC',
409 raw: 40,
410 name: 'usdc',
411 iconPath: 'assets/new-ui/crypto_full_icons/usdc.svg',
412 decimals: 6,
413 groups: const {CurrencyGroups.stablecoin});
414 static const usdcsol = CryptoCurrency(
415 title: 'USDC',
416 tag: 'SOL',
417 fullName: 'USDC Coin',
418 raw: 41,
419 name: 'usdcsol',
420 iconPath: 'assets/new-ui/crypto_full_icons/usdc.svg',
421 decimals: 6,
422 groups: const {CurrencyGroups.stablecoin});
423 static const zaddr = CryptoCurrency(
424 title: 'ZZEC',
425 tag: 'ZEC',
426 fullName: 'Shielded Zcash',
427 raw: 42,
428 name: 'zaddr',
429 iconPath: 'assets/new-ui/crypto_full_icons/zcash.svg',
430 decimals: 8);
431 static const tzec = CryptoCurrency(
432 title: 'tZEC',
433 tag: 'ZEC',
434 fullName: 'Transparent Zcash',
435 raw: 43,
436 name: 'zec',
437 iconPath: 'assets/new-ui/crypto_full_icons/zcash.svg',
438 decimals: 8);
439 static const zen = CryptoCurrency(
440 title: 'ZEN',
441 fullName: 'Horizen',
442 raw: 44,
443 name: 'zen',
444 iconPath: 'assets/images/zen_icon.png',
445 decimals: 8);
446 static const xvg = CryptoCurrency(
447 title: 'XVG',
448 fullName: 'Verge',
449 raw: 45,
450 name: 'xvg',
451 iconPath: 'assets/images/xvg_icon.png',
452 decimals: 8);
453
454 static const usdcpoly = CryptoCurrency(
455 title: 'USDC',
456 tag: 'POL',
457 fullName: 'USDC',
458 raw: 46,
459 name: 'usdcpoly',
460 iconPath: 'assets/new-ui/crypto_full_icons/usdc.svg',
461 decimals: 6,
462 groups: const {CurrencyGroups.stablecoin});
463 static const dcr = CryptoCurrency(
464 title: 'DCR',
465 fullName: 'Decred',
466 raw: 47,
467 name: 'dcr',
468 iconPath: 'assets/new-ui/crypto_full_icons/decred.svg',
469 decimals: 8,
470 flatIconPath: "assets/new-ui/balance_card_icons/decred.svg");
471 static const kmd = CryptoCurrency(
472 title: 'KMD',
473 fullName: 'Komodo',
474 raw: 48,
475 name: 'kmd',
476 iconPath: 'assets/images/kmd_icon.png',
477 decimals: 8);
478 static const mana = CryptoCurrency(
479 title: 'MANA',
480 tag: 'ETH',
481 fullName: 'Decentraland',
482 raw: 49,
483 name: 'mana',
484 iconPath: 'assets/images/mana_icon.png',
485 decimals: 18);
486 static const maticpoly = CryptoCurrency(
487 title: 'POL',
488 tag: 'POL',
489 fullName: 'Polygon',
490 raw: 50,
491 name: 'maticpoly',
492 iconPath: 'assets/new-ui/crypto_full_icons/polygon.svg',
493 decimals: 18,
494 flatIconPath: "assets/new-ui/balance_card_icons/polygon.svg",
495 chainIconPath: "assets/new-ui/chain_badges/polygon.svg");
496 static const matic = CryptoCurrency(
497 title: 'MATIC',
498 tag: 'ETH',
499 fullName: 'Polygon',
500 raw: 51,
501 name: 'matic',
502 iconPath: 'assets/new-ui/crypto_full_icons/polygon.svg',
503 decimals: 18,
504 flatIconPath: "assets/new-ui/balance_card_icons/polygon.svg");
505 static const mkr = CryptoCurrency(
506 title: 'MKR',
507 tag: 'ETH',
508 fullName: 'Maker',
509 raw: 52,
510 name: 'mkr',
511 iconPath: 'assets/images/mkr_icon.png',
512 decimals: 18);
513 static const near = CryptoCurrency(
514 title: 'NEAR',
515 fullName: 'NEAR Protocol',
516 raw: 53,
517 name: 'near',
518 iconPath: 'assets/images/near_icon.png',
519 decimals: 24);
520 static const oxt = CryptoCurrency(
521 title: 'OXT',
522 tag: 'ETH',
523 fullName: 'Orchid',
524 raw: 54,
525 name: 'oxt',
526 iconPath: 'assets/images/oxt_icon.png',
527 decimals: 18);
528 static const paxg = CryptoCurrency(
529 title: 'PAXG',
530 tag: 'ETH',
531 fullName: 'Pax Gold',
532 raw: 55,
533 name: 'paxg',
534 iconPath: 'assets/new-ui/crypto_full_icons/paxg.svg',
535 decimals: 18);
536 static const pivx = CryptoCurrency(
537 title: 'PIVX', raw: 56, name: 'pivx', iconPath: 'assets/images/pivx_icon.png', decimals: 8);
538 static const rune = CryptoCurrency(
539 title: 'RUNE',
540 fullName: 'Thorchain',
541 raw: 57,
542 name: 'rune',
543 iconPath: 'assets/images/rune_icon.png',
544 decimals: 18);
545 static const rvn = CryptoCurrency(
546 title: 'RVN',
547 fullName: 'Ravencoin',
548 raw: 58,
549 name: 'rvn',
550 iconPath: 'assets/images/rvn_icon.png',
551 decimals: 8);
552 static const scrt = CryptoCurrency(
553 title: 'SCRT',
554 fullName: 'Secret Network',
555 raw: 59,
556 name: 'scrt',
557 iconPath: 'assets/images/scrt_icon.png',
558 decimals: 6);
559 static const uni = CryptoCurrency(
560 title: 'UNI',
561 tag: 'ETH',
562 fullName: 'Uniswap',
563 raw: 60,
564 name: 'uni',
565 iconPath: 'assets/images/uni_icon.png',
566 decimals: 18);
567 static const stx = CryptoCurrency(
568 title: 'STX',
569 fullName: 'Stacks',
570 raw: 61,
571 name: 'stx',
572 iconPath: 'assets/images/stx_icon.png',
573 decimals: 8);
574 static const btcln = CryptoCurrency(
575 title: 'BTC',
576 tag: 'LN',
577 fullName: 'Bitcoin Lightning Network',
578 raw: 62,
579 name: 'btcln',
580 iconPath: 'assets/new-ui/crypto_full_icons/lightning.svg',
581 chainIconPath: "assets/new-ui/chain_badges/lightning.svg",
582 decimals: 8);
583 static const shib = CryptoCurrency(
584 title: 'SHIB',
585 tag: 'ETH',
586 fullName: 'Shiba Inu',
587 raw: 63,
588 name: 'shib',
589 iconPath: 'assets/images/shib_icon.png',
590 decimals: 18);
591 static const aave = CryptoCurrency(
592 title: 'AAVE',
593 tag: 'ETH',
594 fullName: 'Aave',
595 raw: 64,
596 name: 'aave',
597 iconPath: 'assets/images/aave_icon.png',
598 decimals: 18);
599 static const arb = CryptoCurrency(
600 title: 'ARB',
601 fullName: 'Arbitrum',
602 raw: 65,
603 name: 'arb',
604 iconPath: 'assets/new-ui/crypto_full_icons/arbitrum.svg',
605 decimals: 18,
606 flatIconPath: "assets/new-ui/balance_card_icons/arbitrum.svg",
607 chainIconPath: "assets/new-ui/chain_badges/arbitrum.svg");
608 static const bat = CryptoCurrency(
609 title: 'BAT',
610 tag: 'ETH',
611 fullName: 'Basic Attention Token',
612 raw: 66,
613 name: 'bat',
614 iconPath: 'assets/images/bat_icon.png',
615 decimals: 18);
616 static const comp = CryptoCurrency(
617 title: 'COMP',
618 tag: 'ETH',
619 fullName: 'Compound',
620 raw: 67,
621 name: 'comp',
622 iconPath: 'assets/images/comp_icon.png',
623 decimals: 18);
624 static const cro = CryptoCurrency(
625 title: 'CRO',
626 tag: 'ETH',
627 fullName: 'Crypto.com Cronos',
628 raw: 68,
629 name: 'cro',
630 iconPath: 'assets/images/cro_icon.png',
631 decimals: 8);
632 static const ens = CryptoCurrency(
633 title: 'ENS',
634 tag: 'ETH',
635 fullName: 'Ethereum Name Service',
636 raw: 69,
637 name: 'ens',
638 iconPath: 'assets/images/ens_icon.png',
639 decimals: 18);
640 static const ftm = CryptoCurrency(
641 title: 'FTM',
642 tag: 'ETH',
643 fullName: 'Fantom',
644 raw: 70,
645 name: 'ftm',
646 iconPath: 'assets/images/ftm_icon.png',
647 decimals: 18);
648 static const frax = CryptoCurrency(
649 title: 'FRAX',
650 tag: 'ETH',
651 fullName: 'Frax',
652 raw: 71,
653 name: 'frax',
654 iconPath: 'assets/images/frax_icon.png',
655 decimals: 18);
656 static const gusd = CryptoCurrency(
657 title: 'GUSD',
658 tag: 'ETH',
659 fullName: 'Gemini USD',
660 raw: 72,
661 name: 'gusd',
662 iconPath: 'assets/images/gusd_icon.png',
663 decimals: 2);
664 static const gtc = CryptoCurrency(
665 title: 'GTC',
666 tag: 'ETH',
667 fullName: 'Gitcoin',
668 raw: 73,
669 name: 'gtc',
670 iconPath: 'assets/images/gtc_icon.png',
671 decimals: 18);
672 static const grt = CryptoCurrency(
673 title: 'GRT',
674 tag: 'ETH',
675 fullName: 'The Graph',
676 raw: 74,
677 name: 'grt',
678 iconPath: 'assets/images/grt_icon.png',
679 decimals: 18);
680 static const ldo = CryptoCurrency(
681 title: 'LDO',
682 tag: 'ETH',
683 fullName: 'Lido DAO',
684 raw: 75,
685 name: 'ldo',
686 iconPath: 'assets/images/ldo_icon.png',
687 decimals: 18);
688 static const nexo = CryptoCurrency(
689 title: 'NEXO',
690 tag: 'ETH',
691 fullName: 'Nexo',
692 raw: 76,
693 name: 'nexo',
694 iconPath: 'assets/images/nexo_icon.png',
695 decimals: 18);
696 static const cake = CryptoCurrency(
697 title: 'CAKE',
698 tag: 'BSC',
699 fullName: 'PancakeSwap',
700 raw: 77,
701 name: 'cake',
702 iconPath: 'assets/images/cake_icon.png',
703 decimals: 18);
704 static const pepe = CryptoCurrency(
705 title: 'PEPE',
706 tag: 'ETH',
707 fullName: 'Pepe',
708 raw: 78,
709 name: 'pepe',
710 iconPath: 'assets/images/pepe_icon.png',
711 decimals: 18);
712 static const storj = CryptoCurrency(
713 title: 'STORJ',
714 tag: 'ETH',
715 fullName: 'Storj',
716 raw: 79,
717 name: 'storj',
718 iconPath: 'assets/images/storj_icon.png',
719 decimals: 8);
720 static const tusd = CryptoCurrency(
721 title: 'TUSD',
722 tag: 'ETH',
723 fullName: 'TrueUSD',
724 raw: 80,
725 name: 'tusd',
726 iconPath: 'assets/images/tusd_icon.png',
727 decimals: 18);
728 static const wbtc = CryptoCurrency(
729 title: 'WBTC',
730 tag: 'ETH',
731 fullName: 'Wrapped Bitcoin',
732 raw: 81,
733 name: 'wbtc',
734 iconPath: 'assets/new-ui/crypto_full_icons/wbtc.svg',
735 decimals: 8);
736 static const weth = CryptoCurrency(
737 title: 'WETH',
738 tag: 'ETH',
739 fullName: 'Wrapped Ethereum',
740 raw: 82,
741 name: 'weth',
742 iconPath: 'assets/new-ui/crypto_full_icons/ethereum.svg',
743 decimals: 18);
744 static const zrx = CryptoCurrency(
745 title: 'ZRX',
746 tag: 'ETH',
747 fullName: '0x Protocol',
748 raw: 83,
749 name: 'zrx',
750 iconPath: 'assets/images/zrx_icon.png',
751 decimals: 18);
752 static const dydx = CryptoCurrency(
753 title: 'DYDX',
754 tag: 'ETH',
755 fullName: 'dYdX',
756 raw: 84,
757 name: 'dydx',
758 iconPath: 'assets/images/dydx_icon.png',
759 decimals: 18);
760 static const steth = CryptoCurrency(
761 title: 'STETH',
762 tag: 'ETH',
763 fullName: 'Lido Staked Ethereum',
764 raw: 85,
765 name: 'steth',
766 iconPath: 'assets/new-ui/crypto_full_icons/ethereum.svg',
767 decimals: 18);
768 static const banano = CryptoCurrency(
769 title: 'BAN',
770 fullName: 'Banano',
771 raw: 86,
772 name: 'banano',
773 iconPath: 'assets/images/nano_icon.png',
774 decimals: 29,
775 flatIconPath: "assets/new-ui/balance_card_icons/nano.svg");
776 static const usdtPoly = CryptoCurrency(
777 title: 'USDT',
778 tag: 'POL',
779 fullName: 'Tether (PoS)',
780 raw: 87,
781 name: 'usdtpoly',
782 iconPath: 'assets/new-ui/crypto_full_icons/usdt.svg',
783 decimals: 6,
784 groups: const {CurrencyGroups.stablecoin});
785 static const usdcEPoly = CryptoCurrency(
786 title: 'USDC.E',
787 tag: 'POL',
788 fullName: 'USDC (PoS)',
789 raw: 88,
790 name: 'usdcepoly',
791 iconPath: 'assets/new-ui/crypto_full_icons/usdc.svg',
792 decimals: 6);
793 static const kaspa = CryptoCurrency(
794 title: 'KAS',
795 fullName: 'Kaspa',
796 raw: 89,
797 name: 'kas',
798 iconPath: 'assets/images/kaspa_icon.png',
799 decimals: 8);
800 static const digibyte = CryptoCurrency(
801 title: 'DGB',
802 fullName: 'DigiByte',
803 raw: 90,
804 name: 'dgb',
805 iconPath: 'assets/images/digibyte.png',
806 decimals: 8);
807 static const usdtSol = CryptoCurrency(
808 title: 'USDT',
809 tag: 'SOL',
810 fullName: 'Tether',
811 raw: 91,
812 name: 'usdtsol',
813 iconPath: 'assets/new-ui/crypto_full_icons/usdt.svg',
814 decimals: 6,
815 groups: const {CurrencyGroups.stablecoin});
816 static const usdcTrc20 = CryptoCurrency(
817 title: 'USDC',
818 tag: 'TRX',
819 fullName: 'USDC Coin',
820 raw: 92,
821 name: 'usdctrc20',
822 iconPath: 'assets/new-ui/crypto_full_icons/usdc.svg',
823 decimals: 6,
824 groups: const {CurrencyGroups.stablecoin});
825 static const tbtc = CryptoCurrency(
826 title: 'tBTC',
827 fullName: 'Testnet Bitcoin',
828 raw: 93,
829 name: 'tbtc',
830 iconPath: 'assets/images/tbtc.png',
831 decimals: 8);
832 static const wow = CryptoCurrency(
833 title: 'WOW',
834 fullName: 'Wownero',
835 raw: 94,
836 name: 'wow',
837 iconPath: 'assets/images/crypto/wownero.svg',
838 decimals: 11);
839 static const ton = CryptoCurrency(
840 title: 'TON',
841 fullName: 'Toncoin',
842 raw: 95,
843 name: 'ton',
844 iconPath: 'assets/new-ui/crypto_full_icons/ton.svg',
845 decimals: 8);
846 static const zano = CryptoCurrency(
847 title: 'ZANO',
848 tag: 'ZANO',
849 fullName: 'Zano',
850 raw: 96,
851 name: 'zano',
852 iconPath: 'assets/new-ui/crypto_full_icons/zano.svg',
853 decimals: 12,
854 flatIconPath: "assets/new-ui/balance_card_icons/zano.svg",
855 chainIconPath: "assets/new-ui/chain_badges/zano.svg");
856 static const flip = CryptoCurrency(
857 title: 'FLIP',
858 tag: 'ETH',
859 fullName: 'Chainflip',
860 raw: 97,
861 name: 'flip',
862 iconPath: 'assets/images/flip_icon.png',
863 decimals: 18);
864 static const deuro = CryptoCurrency(
865 title: 'DEURO',
866 tag: 'ETH',
867 fullName: 'Decentralized Euro',
868 raw: 98,
869 name: 'deuro',
870 iconPath: 'assets/images/deuro_icon.png',
871 decimals: 18,
872 groups: const {CurrencyGroups.stablecoin});
873 static const usdtbsc = CryptoCurrency(
874 title: 'USDT',
875 tag: 'BSC',
876 fullName: 'USDT Binance coin',
877 raw: 99,
878 name: 'usdtbsc',
879 iconPath: 'assets/new-ui/crypto_full_icons/usdt.svg',
880 decimals: 18,
881 groups: const {CurrencyGroups.stablecoin});
882 static const ndeps = CryptoCurrency(
883 title: 'NDEPS',
884 tag: 'ETH',
885 fullName: 'Native Decentralized Euro Protocol Share',
886 raw: 100,
887 name: 'ndeps',
888 iconPath: 'assets/images/ndeps_icon.png',
889 decimals: 18);
890 static const deps = CryptoCurrency(
891 title: 'DEPS',
892 tag: 'ETH',
893 fullName: 'Decentralized Euro Protocol Share',
894 raw: 101,
895 name: 'deps',
896 iconPath: 'assets/images/deps_icon.png',
897 decimals: 18);
898 static const kbtc = CryptoCurrency(
899 title: 'KBTC',
900 tag: 'ETH',
901 fullName: 'Kraken Wrapped Bitcoin',
902 raw: 102,
903 name: 'kbtc',
904 iconPath: 'assets/images/kbtc_icon.png',
905 decimals: 8);
906 static const cbbtc = CryptoCurrency(
907 title: 'CBBTC',
908 tag: 'ETH',
909 fullName: 'Coinbase Wrapped BTC',
910 raw: 103,
911 name: 'cbbtc',
912 iconPath: 'assets/images/cbbtc_icon.png',
913 decimals: 8);
914 static const baseEth = CryptoCurrency(
915 title: 'ETH',
916 tag: 'BASE',
917 fullName: 'Ethereum',
918 raw: 104,
919 name: 'baseth',
920 iconPath: 'assets/new-ui/crypto_full_icons/ethereum.svg',
921 decimals: 18,
922 flatIconPath: "assets/new-ui/balance_card_icons/base.svg",
923 chainIconPath: "assets/new-ui/chain_badges/base.svg");
924 static const usde = CryptoCurrency(
925 title: 'USDE',
926 tag: 'BASE',
927 fullName: 'Ethena USDE',
928 raw: 105,
929 name: 'usde',
930 iconPath: 'assets/new-ui/crypto_full_icons/usde.svg',
931 decimals: 18);
932 static const arbEth = CryptoCurrency(
933 title: 'ETH',
934 tag: 'ARB',
935 fullName: 'Ethereum',
936 raw: 106,
937 name: 'arbeth',
938 iconPath: 'assets/new-ui/crypto_full_icons/ethereum.svg',
939 decimals: 18,
940 flatIconPath: "assets/new-ui/balance_card_icons/arbitrum.svg",
941 chainIconPath: "assets/new-ui/chain_badges/arbitrum.svg");
942 static const zec = CryptoCurrency(
943 title: 'ZEC',
944 fullName: 'Zcash',
945 raw: 107,
946 name: 'zec',
947 iconPath: 'assets/new-ui/crypto_full_icons/zcash.svg',
948 decimals: 8,
949 flatIconPath: "assets/new-ui/balance_card_icons/zcash.svg");
950 static const usdcArb = CryptoCurrency(
951 title: 'USDC',
952 tag: 'ARB',
953 fullName: 'USDC Coin',
954 raw: 108,
955 name: 'usdcarb',
956 iconPath: 'assets/new-ui/crypto_full_icons/usdc.svg',
957 decimals: 6,
958 groups: const {CurrencyGroups.stablecoin});
959 static const usdtArb = CryptoCurrency(
960 title: 'USDT',
961 tag: 'ARB',
962 fullName: 'USDT Tether',
963 raw: 109,
964 name: 'usdtarb',
965 iconPath: 'assets/new-ui/crypto_full_icons/usdt.svg',
966 decimals: 6,
967 groups: const {CurrencyGroups.stablecoin});
968 static const ltcmweb = CryptoCurrency(
969 title: 'LTC',
970 fullName: 'Litecoin MWeb',
971 raw: 110,
972 name: 'ltcmweb',
973 iconPath: 'assets/new-ui/crypto_full_icons/litecoin.svg',
974 decimals: 8);
975
976 static final Map<int, CryptoCurrency> _rawCurrencyMap = [
977 ...all,
978 ...havenCurrencies,
979 ...zcashCurrencies
980 ].fold<Map<int, CryptoCurrency>>(<int, CryptoCurrency>{}, (acc, item) {
981 acc.addAll({item.raw: item});
982 return acc;
983 });
984
985 static final Map<String, CryptoCurrency> _nameCurrencyMap = [
986 ...all,
987 ...havenCurrencies,
988 ...zcashCurrencies
989 ].fold<Map<String, CryptoCurrency>>(<String, CryptoCurrency>{}, (acc, item) {
990 acc.addAll({item.name: item});
991 return acc;
992 });
993
994 static final Map<String, CryptoCurrency> _fullNameCurrencyMap = [
995 ...all,
996 ...havenCurrencies,
997 ...zcashCurrencies
998 ].fold<Map<String, CryptoCurrency>>(<String, CryptoCurrency>{}, (acc, item) {
999 if (item.fullName != null) {
1000 acc.addAll({item.fullName!.toLowerCase(): item});
1001 }
1002 return acc;
1003 });
1004
1005 // Scheme to currency mapping for URI scheme
1006 static final Map<String, CryptoCurrency> _schemeCurrencyMap = {
1007 'bitcoin': btc,
1008 'bitcoincash': bch,
1009 'polygon': maticpoly,
1010 'solana': sol,
1011 'nano-gpt': nano,
1012 'secret': scrt,
1013 'stellar': xlm,
1014 'avalanche': avaxc,
1015 'binance': bnb,
1016 'tether': usdt,
1017 'usdcoin': usdc,
1018 'wrappedbitcoin': wbtc,
1019 'wrappedether': weth,
1020 'shibainu': shib,
1021 'zcash': zec,
1022 'lightning': btcln,
1023 'base': baseEth,
1024 'arbitrum': arbEth,
1025 'bsc': bnb,
1026 };
1027
1028 static CryptoCurrency deserialize({required int raw}) {
1029 if (CryptoCurrency._rawCurrencyMap[raw] == null) {
1030 final s = 'Unexpected token: $raw for CryptoCurrency deserialize';
1031 throw ArgumentError.value(raw, 'raw', s);
1032 }
1033 return CryptoCurrency._rawCurrencyMap[raw]!;
1034 }
1035
1036 static CryptoCurrency? safeDeserialize({int? raw}) {
1037 if (raw == null || raw < 0) return null;
1038 return _rawCurrencyMap[raw];
1039 }
1040
1041 // TODO: refactor this
1042 static CryptoCurrency fromString(String name, {CryptoCurrency? walletCurrency}) {
1043 final schemeMatch = _schemeCurrencyMap[name.toLowerCase()];
1044 if (schemeMatch != null) return schemeMatch;
1045
1046 try {
1047 return CryptoCurrency.all.firstWhere((element) =>
1048 element.title.toLowerCase() == name.toLowerCase() &&
1049 (element.tag == null ||
1050 element.tag == name ||
1051 element.tag == walletCurrency?.title ||
1052 element.tag == walletCurrency?.tag));
1053 } catch (_) {}
1054
1055 // search by fullName if not found by title:
1056 try {
1057 return CryptoCurrency.all.firstWhere((element) => element.fullName?.toLowerCase() == name);
1058 } catch (_) {}
1059
1060 if (CryptoCurrency._nameCurrencyMap[name.toLowerCase()] == null) {
1061 final s = 'Unexpected token: $name for CryptoCurrency fromString';
1062 throw ArgumentError.value(name, 'name', s);
1063 }
1064
1065 return CryptoCurrency._nameCurrencyMap[name.toLowerCase()]!;
1066 }
1067
1068 static CryptoCurrency fromFullName(String name) {
1069 if (CryptoCurrency._fullNameCurrencyMap[name.split("(").first.trim().toLowerCase()] == null) {
1070 final s = 'Unexpected token: $name for CryptoCurrency fromFullName';
1071 throw ArgumentError.value(name, 'Fullname', s);
1072 }
1073 return CryptoCurrency._fullNameCurrencyMap[name.split("(").first.trim().toLowerCase()]!;
1074 }
1075
1076 static CryptoCurrency? safeParseCurrencyFromString(
1077 String? raw, {
1078 String? tag,
1079 CryptoCurrency? walletCurrency,
1080 }) {
1081 if (raw == null || raw.isEmpty) return null;
1082
1083 if (tag?.toLowerCase() == "lightning") tag = "LN";
1084
1085 if (tag != null && tag.isNotEmpty) {
1086 final match = CryptoCurrency.all.firstWhereOrNull(
1087 (e) =>
1088 e.title.toUpperCase() == raw.toUpperCase() &&
1089 e.tag?.toUpperCase() == tag?.toUpperCase(),
1090 );
1091 if (match != null) return match;
1092 return null;
1093 }
1094
1095 // Try for native currency with same title and tag
1096 if (tag == null || tag.isEmpty) {
1097 final match = CryptoCurrency.all.firstWhereOrNull(
1098 (e) => e.title.toUpperCase() == raw.toUpperCase() && (e.tag == raw.toUpperCase()),
1099 );
1100
1101 if (match != null) return match;
1102 }
1103
1104 try {
1105 return CryptoCurrency.fromString(raw, walletCurrency: walletCurrency);
1106 } catch (_) {}
1107
1108 // try cleaned (keep only A–Z/0–9)
1109 final cleaned = raw.trim().toUpperCase().replaceAll(RegExp(r'[^A-Z0-9]'), '');
1110 try {
1111 return CryptoCurrency.fromString(cleaned, walletCurrency: walletCurrency);
1112 } catch (_) {}
1113
1114 return null;
1115 }
1116
1117 CryptoCurrency copyWith({
1118 String? title,
1119 int? raw,
1120 String? name,
1121 String? fullName,
1122 String? iconPath,
1123 String? tag,
1124 int? decimals,
1125 bool? enabled,
1126 bool? isPotentialScam,
1127 Set<String>? groups,
1128 }) =>
1129 CryptoCurrency(
1130 title: title ?? this.title,
1131 raw: raw ?? this.raw,
1132 name: name ?? this.name,
1133 fullName: fullName ?? this.fullName,
1134 iconPath: iconPath ?? this.iconPath,
1135 tag: tag ?? this.tag,
1136 decimals: decimals ?? this.decimals,
1137 enabled: enabled ?? this.enabled,
1138 isPotentialScam: isPotentialScam ?? this.isPotentialScam,
1139 groups: groups ?? this.groups,
1140 );
1141
1142 @override
1143 String toString() => title;
1144
1145 bool titleAndTagEqual(CryptoCurrency other) => title == other.title && tag == other.tag;
1146
1147 @override
1148 Money parseAmount(String value) => Money.parse(value, this);
1149
1150 @override
1151 Money? tryParseAmount(String value) => Money.tryParse(value, this);
1152
1153 /// Format the raw amount into its decimal representation eg. turn Sats into Bitcoin
1154 String formatAmount(BigInt amount, {int? fractionalDigits, bool trimZeros = true}) =>
1155 formatFixed(amount, decimals, fractionalDigits: fractionalDigits, trimZeros: trimZeros);
1156 }