@daimo/pay-common 1.6.4 → 1.7.0

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.
package/src/token.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { getAddress, zeroAddress } from "viem";
2
+ import { assertNotNull } from "./assert";
2
3
  import {
3
4
  arbitrum,
4
5
  base,
@@ -14,12 +15,20 @@ import {
14
15
  } from "./chain";
15
16
 
16
17
  export type Token = {
18
+ /** Chain ID, eg 10 for OP Mainnet */
17
19
  chainId: number;
20
+ /** Ethereum (capitalized) or Solana token address */
18
21
  token: string;
22
+ /** Name, eg "Wrapped Bitcoin" */
19
23
  name?: string;
24
+ /** Symbol, eg "WBTC" */
20
25
  symbol: string;
26
+ /** Token decimals, eg 8 for WBTC */
21
27
  decimals: number;
28
+ /** Logo URI. Fetch required, not guaranteed to be base64. */
22
29
  logoURI?: string;
30
+ /** Fiat ISO code for stablecoins, eg "USD" or "EUR" */
31
+ fiatISO?: string;
23
32
  };
24
33
 
25
34
  export enum TokenLogo {
@@ -61,6 +70,7 @@ export const arbitrumUSDC: Token = {
61
70
  token: getAddress("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),
62
71
  name: "USD Coin",
63
72
  symbol: "USDC",
73
+ fiatISO: "USD",
64
74
  decimals: 6,
65
75
  logoURI: TokenLogo.USDC,
66
76
  };
@@ -69,6 +79,7 @@ export const arbitrumAxlUSDC: Token = {
69
79
  chainId: arbitrum.chainId,
70
80
  token: getAddress("0xEB466342C4d449BC9f53A865D5Cb90586f405215"),
71
81
  decimals: 6,
82
+ fiatISO: "USD",
72
83
  name: "Axelar Wrapped USDC",
73
84
  symbol: "axlUSDC",
74
85
  logoURI: TokenLogo.USDC,
@@ -78,6 +89,7 @@ export const arbitrumDAI: Token = {
78
89
  chainId: arbitrum.chainId,
79
90
  token: getAddress("0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"),
80
91
  decimals: 18,
92
+ fiatISO: "USD",
81
93
  name: "Dai Stablecoin",
82
94
  symbol: "DAI",
83
95
  logoURI: TokenLogo.DAI,
@@ -87,6 +99,7 @@ export const arbitrumUSDT: Token = {
87
99
  chainId: arbitrum.chainId,
88
100
  token: getAddress("0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"),
89
101
  decimals: 6,
102
+ fiatISO: "USD",
90
103
  name: "Tether USD",
91
104
  symbol: "USDT",
92
105
  logoURI: TokenLogo.USDT,
@@ -96,6 +109,7 @@ export const arbitrumUSDCe: Token = {
96
109
  chainId: arbitrum.chainId,
97
110
  token: getAddress("0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8"),
98
111
  decimals: 6,
112
+ fiatISO: "USD",
99
113
  name: "Bridged USD Coin",
100
114
  symbol: "USDCe",
101
115
  logoURI: TokenLogo.USDC,
@@ -131,6 +145,7 @@ export const baseUSDC: Token = {
131
145
  token: getAddress("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),
132
146
  name: "USD Coin",
133
147
  symbol: "USDC",
148
+ fiatISO: "USD",
134
149
  decimals: 6,
135
150
  logoURI: TokenLogo.USDC,
136
151
  };
@@ -139,6 +154,7 @@ export const baseEURC: Token = {
139
154
  chainId: base.chainId,
140
155
  token: getAddress("0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42"),
141
156
  decimals: 6,
157
+ fiatISO: "EUR",
142
158
  name: "EURC",
143
159
  symbol: "EURC",
144
160
  logoURI: TokenLogo.EURC,
@@ -149,6 +165,7 @@ export const baseUSDbC: Token = {
149
165
  token: getAddress("0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA"),
150
166
  name: "Bridged USD Coin", // USDbC has a bad name & logo on CoinGecko
151
167
  symbol: "USDbC",
168
+ fiatISO: "USD",
152
169
  decimals: 6,
153
170
  logoURI: `https://daimo.com/assets/foreign-coin-logos/USDbC.png`,
154
171
  };
@@ -158,6 +175,7 @@ export const baseDAI: Token = {
158
175
  token: getAddress("0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb"),
159
176
  name: "Dai Stablecoin",
160
177
  symbol: "DAI",
178
+ fiatISO: "USD",
161
179
  decimals: 18,
162
180
  logoURI: TokenLogo.DAI,
163
181
  };
@@ -167,6 +185,7 @@ export const baseUSDT: Token = {
167
185
  token: getAddress("0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2"),
168
186
  name: "Tether USD",
169
187
  symbol: "USDT",
188
+ fiatISO: "USD",
170
189
  decimals: 6,
171
190
  logoURI: TokenLogo.USDT,
172
191
  };
@@ -175,6 +194,7 @@ export const baseAxlUSDC: Token = {
175
194
  chainId: base.chainId,
176
195
  token: getAddress("0xEB466342C4d449BC9f53A865D5Cb90586f405215"),
177
196
  decimals: 6,
197
+ fiatISO: "USD",
178
198
  name: "Axelar Wrapped USDC",
179
199
  symbol: "axlUSDC",
180
200
  logoURI: TokenLogo.USDC,
@@ -210,6 +230,7 @@ export const blastUSDB: Token = {
210
230
  chainId: blast.chainId,
211
231
  token: getAddress("0x4300000000000000000000000000000000000003"),
212
232
  decimals: 18,
233
+ fiatISO: "USD",
213
234
  name: "USDB",
214
235
  symbol: "USDB",
215
236
  logoURI: TokenLogo.USDB,
@@ -241,6 +262,7 @@ export const bscAxlUSDC: Token = {
241
262
  chainId: bsc.chainId,
242
263
  token: getAddress("0x4268B8F0B87b6Eae5d897996E6b845ddbD99Adf3"),
243
264
  decimals: 6,
265
+ fiatISO: "USD",
244
266
  name: "Axelar Wrapped USDC",
245
267
  symbol: "axlUSDC",
246
268
  logoURI: TokenLogo.USDC,
@@ -250,7 +272,8 @@ export const bscUSDC: Token = {
250
272
  chainId: bsc.chainId,
251
273
  token: getAddress("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),
252
274
  decimals: 18,
253
- name: "Binance-Peg USD Coin",
275
+ fiatISO: "USD",
276
+ name: "USD Coin",
254
277
  symbol: "USDC",
255
278
  logoURI: TokenLogo.USDC,
256
279
  };
@@ -259,6 +282,7 @@ export const bscUSDT: Token = {
259
282
  chainId: bsc.chainId,
260
283
  token: getAddress("0x55d398326f99059fF775485246999027B3197955"),
261
284
  decimals: 18,
285
+ fiatISO: "USD",
262
286
  name: "Tether USD",
263
287
  symbol: "USDT",
264
288
  logoURI: TokenLogo.USDT,
@@ -285,6 +309,7 @@ export const ethereumUSDC: Token = {
285
309
  chainId: ethereum.chainId,
286
310
  token: getAddress("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),
287
311
  decimals: 6,
312
+ fiatISO: "USD",
288
313
  name: "USD Coin",
289
314
  symbol: "USDC",
290
315
  logoURI: TokenLogo.USDC,
@@ -294,6 +319,7 @@ export const ethereumDAI: Token = {
294
319
  chainId: ethereum.chainId,
295
320
  token: getAddress("0x6B175474E89094C44Da98b954EedeAC495271d0F"),
296
321
  decimals: 18,
322
+ fiatISO: "USD",
297
323
  name: "Dai Stablecoin",
298
324
  symbol: "DAI",
299
325
  logoURI: TokenLogo.DAI,
@@ -303,6 +329,7 @@ export const ethereumUSDT: Token = {
303
329
  chainId: ethereum.chainId,
304
330
  token: getAddress("0xdAC17F958D2ee523a2206206994597C13D831ec7"),
305
331
  decimals: 6,
332
+ fiatISO: "USD",
306
333
  name: "Tether USD",
307
334
  symbol: "USDT",
308
335
  logoURI: TokenLogo.USDT,
@@ -312,6 +339,7 @@ export const ethereumEURC: Token = {
312
339
  chainId: ethereum.chainId,
313
340
  token: getAddress("0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c"),
314
341
  decimals: 6,
342
+ fiatISO: "EUR",
315
343
  name: "EURC",
316
344
  symbol: "EURC",
317
345
  logoURI: TokenLogo.EURC,
@@ -345,6 +373,7 @@ export const lineaUSDC: Token = {
345
373
  chainId: linea.chainId,
346
374
  token: getAddress("0x176211869cA2b568f2A7D4EE941E073a821EE1ff"),
347
375
  decimals: 6,
376
+ fiatISO: "USD",
348
377
  name: "USD Coin",
349
378
  symbol: "USDC",
350
379
  logoURI: TokenLogo.USDC,
@@ -354,6 +383,7 @@ export const lineaAxlUSDC: Token = {
354
383
  chainId: linea.chainId,
355
384
  token: getAddress("0xEB466342C4d449BC9f53A865D5Cb90586f405215"),
356
385
  decimals: 6,
386
+ fiatISO: "USD",
357
387
  name: "Axelar Wrapped USDC",
358
388
  symbol: "axlUSDC",
359
389
  logoURI: TokenLogo.USDC,
@@ -363,6 +393,7 @@ export const lineaDAI: Token = {
363
393
  chainId: linea.chainId,
364
394
  token: getAddress("0x4AF15ec2A0BD43Db75dd04E62FAA3B8EF36b00d5"),
365
395
  decimals: 18,
396
+ fiatISO: "USD",
366
397
  name: "Dai Stablecoin",
367
398
  symbol: "DAI",
368
399
  logoURI: TokenLogo.DAI,
@@ -400,6 +431,7 @@ export const mantleBridgedUSDC: Token = {
400
431
  chainId: mantle.chainId,
401
432
  token: getAddress("0x09Bc4E0D864854c6aFB6eB9A9cdF58aC190D0dF9"),
402
433
  decimals: 6,
434
+ fiatISO: "USD",
403
435
  name: "USD Coin",
404
436
  symbol: "USDC",
405
437
  logoURI: TokenLogo.USDC,
@@ -409,6 +441,7 @@ export const mantleUSDT: Token = {
409
441
  chainId: mantle.chainId,
410
442
  token: getAddress("0x201eba5cc46d216ce6dc03f6a759e8e766e956ae"),
411
443
  decimals: 6,
444
+ fiatISO: "USD",
412
445
  name: "Tether USD",
413
446
  symbol: "USDT",
414
447
  logoURI: TokenLogo.USDT,
@@ -418,6 +451,7 @@ export const mantleAxlUSDC: Token = {
418
451
  chainId: mantle.chainId,
419
452
  token: getAddress("0xEB466342C4d449BC9f53A865D5Cb90586f405215"),
420
453
  decimals: 6,
454
+ fiatISO: "USD",
421
455
  name: "Axelar Wrapped USDC",
422
456
  symbol: "axlUSDC",
423
457
  logoURI: TokenLogo.USDC,
@@ -450,6 +484,7 @@ export const optimismUSDC: Token = {
450
484
  chainId: optimism.chainId,
451
485
  token: getAddress("0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85"),
452
486
  decimals: 6,
487
+ fiatISO: "USD",
453
488
  name: "USD Coin",
454
489
  symbol: "USDC",
455
490
  logoURI: TokenLogo.USDC,
@@ -459,6 +494,7 @@ export const optimismAxlUSDC: Token = {
459
494
  chainId: optimism.chainId,
460
495
  token: getAddress("0xEB466342C4d449BC9f53A865D5Cb90586f405215"),
461
496
  decimals: 6,
497
+ fiatISO: "USD",
462
498
  name: "Axelar Wrapped USDC",
463
499
  symbol: "axlUSDC",
464
500
  logoURI: TokenLogo.USDC,
@@ -468,6 +504,7 @@ export const optimismDAI: Token = {
468
504
  chainId: optimism.chainId,
469
505
  token: getAddress("0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"),
470
506
  decimals: 18,
507
+ fiatISO: "USD",
471
508
  name: "Dai Stablecoin",
472
509
  symbol: "DAI",
473
510
  logoURI: TokenLogo.DAI,
@@ -477,6 +514,7 @@ export const optimismUSDT: Token = {
477
514
  chainId: optimism.chainId,
478
515
  token: getAddress("0x94b008aA00579c1307B0EF2c499aD98a8ce58e58"),
479
516
  decimals: 6,
517
+ fiatISO: "USD",
480
518
  name: "Tether USD",
481
519
  symbol: "USDT",
482
520
  logoURI: TokenLogo.USDT,
@@ -486,6 +524,7 @@ export const optimismUSDCe: Token = {
486
524
  chainId: optimism.chainId,
487
525
  token: getAddress("0x7F5c764cBc14f9669B88837ca1490cCa17c31607"),
488
526
  decimals: 6,
527
+ fiatISO: "USD",
489
528
  name: "Bridged USD Coin",
490
529
  symbol: "USDCe",
491
530
  logoURI: TokenLogo.USDC,
@@ -534,6 +573,7 @@ export const polygonUSDC: Token = {
534
573
  chainId: polygon.chainId,
535
574
  token: getAddress("0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359"),
536
575
  decimals: 6,
576
+ fiatISO: "USD",
537
577
  name: "USD Coin",
538
578
  symbol: "USDC",
539
579
  logoURI: TokenLogo.USDC,
@@ -543,6 +583,7 @@ export const polygonAxlUSDC: Token = {
543
583
  chainId: polygon.chainId,
544
584
  token: getAddress("0x750e4C4984a9e0f12978eA6742Bc1c5D248f40ed"),
545
585
  decimals: 6,
586
+ fiatISO: "USD",
546
587
  name: "Axelar Wrapped USDC",
547
588
  symbol: "axlUSDC",
548
589
  logoURI: TokenLogo.USDC,
@@ -552,6 +593,7 @@ export const polygonDAI: Token = {
552
593
  chainId: polygon.chainId,
553
594
  token: getAddress("0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063"),
554
595
  decimals: 18,
596
+ fiatISO: "USD",
555
597
  name: "Dai Stablecoin",
556
598
  symbol: "DAI",
557
599
  logoURI: TokenLogo.DAI,
@@ -561,6 +603,7 @@ export const polygonUSDT: Token = {
561
603
  chainId: polygon.chainId,
562
604
  token: getAddress("0xc2132D05D31c914a87C6611C10748AEb04B58e8F"),
563
605
  decimals: 6,
606
+ fiatISO: "USD",
564
607
  name: "Tether USD",
565
608
  symbol: "USDT",
566
609
  logoURI: TokenLogo.USDT,
@@ -570,7 +613,8 @@ export const polygonUSDCe: Token = {
570
613
  chainId: polygon.chainId,
571
614
  token: getAddress("0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"),
572
615
  decimals: 6,
573
- name: "Bridged USD Coin",
616
+ fiatISO: "USD",
617
+ name: "USD Coin (PoS)",
574
618
  symbol: "USDCe",
575
619
  logoURI: TokenLogo.USDC,
576
620
  };
@@ -612,6 +656,7 @@ export const solanaUSDC: Token = {
612
656
  chainId: solana.chainId,
613
657
  token: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
614
658
  decimals: 6,
659
+ fiatISO: "USD",
615
660
  name: "USD Coin",
616
661
  symbol: "USDC",
617
662
  logoURI: TokenLogo.USDC,
@@ -634,10 +679,20 @@ export const worldchainWETH: Token = {
634
679
  logoURI: TokenLogo.ETH,
635
680
  };
636
681
 
682
+ export const worldchainWBTC: Token = {
683
+ chainId: worldchain.chainId,
684
+ token: getAddress("0x03c7054bcb39f7b2e5b2c7acb37583e32d70cfa3"),
685
+ decimals: 8,
686
+ name: "Wrapped Bitcoin",
687
+ symbol: "WBTC",
688
+ logoURI: TokenLogo.WBTC,
689
+ };
690
+
637
691
  export const worldchainUSDCe: Token = {
638
692
  chainId: worldchain.chainId,
639
693
  token: getAddress("0x79A02482A880bCE3F13e09Da970dC34db4CD24d1"),
640
694
  decimals: 6,
695
+ fiatISO: "USD",
641
696
  name: "Bridged USD Coin",
642
697
  symbol: "USDCe",
643
698
  logoURI: TokenLogo.USDC,
@@ -655,40 +710,46 @@ export const worldchainWLD: Token = {
655
710
  const worldchainTokens: Token[] = [
656
711
  worldchainETH,
657
712
  worldchainWETH,
713
+ worldchainWBTC,
658
714
  worldchainUSDCe,
659
715
  worldchainWLD,
660
716
  ];
661
717
 
662
- export const supportedTokens: Token[] = [
663
- ...arbitrumTokens,
664
- ...baseTokens,
665
- ...blastTokens,
666
- ...bscTokens,
667
- ...ethereumTokens,
668
- ...lineaTokens,
669
- ...mantleTokens,
670
- ...optimismTokens,
671
- ...polygonTokens,
672
- ...solanaTokens,
673
- ...worldchainTokens,
674
- ];
675
-
676
- /* --------------------- Token Utils --------------------- */
677
-
678
- // Export tokens for each supported chain
679
- const tokensByChainId = new Map<number, Token[]>();
680
-
681
- for (const token of supportedTokens) {
682
- const toks = tokensByChainId.get(token.chainId) || [];
683
- tokensByChainId.set(token.chainId, toks);
684
- toks.push(token);
685
- }
686
-
687
- /** All supported tokens on a given chain. */
688
- export function getTokensForChain(chainId: number): Token[] {
689
- const ret = tokensByChainId.get(chainId);
690
- if (ret == null) throw new Error(`Unsupported chain ${chainId}`);
691
- return ret;
718
+ const knownTokensByChain = new Map<number, Token[]>([
719
+ [arbitrum.chainId, arbitrumTokens],
720
+ [base.chainId, baseTokens],
721
+ [blast.chainId, blastTokens],
722
+ [bsc.chainId, bscTokens],
723
+ [ethereum.chainId, ethereumTokens],
724
+ [linea.chainId, lineaTokens],
725
+ [mantle.chainId, mantleTokens],
726
+ [optimism.chainId, optimismTokens],
727
+ [polygon.chainId, polygonTokens],
728
+ [solana.chainId, solanaTokens],
729
+ [worldchain.chainId, worldchainTokens],
730
+ ]);
731
+
732
+ /**
733
+ * Common tokens, included for convenience.
734
+ *
735
+ * Daimo Pay supports payment in many more tokens. In general, the goal for
736
+ * Pay is to accept all tokens with DEX liquidity on any major chain.
737
+ */
738
+ export const knownTokens: Token[] = Array.from(
739
+ knownTokensByChain.values(),
740
+ ).flat();
741
+
742
+ /* --------------------- Tokens By Address --------------------- */
743
+
744
+ const tokensByChainAddr = new Map<string, Token>(
745
+ knownTokens.map((t) => [`${t.chainId}-${t.token}`, t]),
746
+ );
747
+
748
+ export function getKnownToken(
749
+ chainId: number,
750
+ tokenAddress: string,
751
+ ): Token | undefined {
752
+ return tokensByChainAddr.get(`${chainId}-${tokenAddress}`);
692
753
  }
693
754
 
694
755
  /* --------------------- Tokens By Type --------------------- */
@@ -702,107 +763,146 @@ enum TokenType {
702
763
  DAI = "DAI",
703
764
  }
704
765
 
705
- const tokensByChainAndType: Record<
766
+ const tokensByChainAndType: Map<
706
767
  number,
707
768
  Partial<Record<TokenType, Token>>
708
- > = {
709
- [arbitrum.chainId]: {
710
- [TokenType.NATIVE]: arbitrumETH,
711
- [TokenType.WRAPPED_NATIVE]: arbitrumWETH,
712
- [TokenType.NATIVE_USDC]: arbitrumUSDC,
713
- [TokenType.BRIDGED_USDC]: arbitrumUSDCe,
714
- [TokenType.AXL_USDC]: arbitrumAxlUSDC,
715
- [TokenType.DAI]: arbitrumDAI,
716
- },
717
- [base.chainId]: {
718
- [TokenType.NATIVE]: baseETH,
719
- [TokenType.WRAPPED_NATIVE]: baseWETH,
720
- [TokenType.NATIVE_USDC]: baseUSDC,
721
- [TokenType.BRIDGED_USDC]: baseUSDbC,
722
- [TokenType.AXL_USDC]: baseAxlUSDC,
723
- [TokenType.DAI]: baseDAI,
724
- },
725
- [blast.chainId]: {
726
- [TokenType.NATIVE]: blastETH,
727
- [TokenType.WRAPPED_NATIVE]: blastWETH,
728
- },
729
- [bsc.chainId]: {
730
- [TokenType.NATIVE]: bscBNB,
731
- [TokenType.WRAPPED_NATIVE]: bscWBNB,
732
- [TokenType.BRIDGED_USDC]: bscUSDC,
733
- [TokenType.AXL_USDC]: bscAxlUSDC,
734
- },
735
- [ethereum.chainId]: {
736
- [TokenType.NATIVE]: ethereumETH,
737
- [TokenType.WRAPPED_NATIVE]: ethereumWETH,
738
- [TokenType.NATIVE_USDC]: ethereumUSDC,
739
- [TokenType.DAI]: ethereumDAI,
740
- },
741
- [linea.chainId]: {
742
- [TokenType.NATIVE]: lineaETH,
743
- [TokenType.WRAPPED_NATIVE]: lineaWETH,
744
- [TokenType.NATIVE_USDC]: lineaUSDC,
745
- [TokenType.AXL_USDC]: lineaAxlUSDC,
746
- [TokenType.DAI]: lineaDAI,
747
- },
748
- [mantle.chainId]: {
749
- [TokenType.NATIVE]: mantleMNT,
750
- [TokenType.WRAPPED_NATIVE]: mantleWMNT,
751
- [TokenType.BRIDGED_USDC]: mantleBridgedUSDC,
752
- [TokenType.AXL_USDC]: mantleAxlUSDC,
753
- },
754
- [optimism.chainId]: {
755
- [TokenType.NATIVE]: optimismETH,
756
- [TokenType.WRAPPED_NATIVE]: optimismWETH,
757
- [TokenType.NATIVE_USDC]: optimismUSDC,
758
- [TokenType.BRIDGED_USDC]: optimismUSDCe,
759
- [TokenType.AXL_USDC]: optimismAxlUSDC,
760
- [TokenType.DAI]: optimismDAI,
761
- },
762
- [polygon.chainId]: {
763
- [TokenType.NATIVE]: polygonPOL,
764
- [TokenType.WRAPPED_NATIVE]: polygonWPOL,
765
- [TokenType.NATIVE_USDC]: polygonUSDC,
766
- [TokenType.BRIDGED_USDC]: polygonUSDCe,
767
- [TokenType.AXL_USDC]: polygonAxlUSDC,
768
- [TokenType.DAI]: polygonDAI,
769
- },
770
- [solana.chainId]: {
771
- [TokenType.NATIVE]: solanaSOL,
772
- [TokenType.WRAPPED_NATIVE]: solanaWSOL,
773
- [TokenType.NATIVE_USDC]: solanaUSDC,
774
- },
775
- [worldchain.chainId]: {
776
- [TokenType.NATIVE]: worldchainETH,
777
- [TokenType.WRAPPED_NATIVE]: worldchainWETH,
778
- [TokenType.BRIDGED_USDC]: worldchainUSDCe,
779
- },
780
- };
781
-
782
- export function getChainNativeToken(chainId: number): Token | undefined {
783
- return tokensByChainAndType[chainId][TokenType.NATIVE];
769
+ > = new Map([
770
+ [
771
+ arbitrum.chainId,
772
+ {
773
+ [TokenType.NATIVE]: arbitrumETH,
774
+ [TokenType.WRAPPED_NATIVE]: arbitrumWETH,
775
+ [TokenType.NATIVE_USDC]: arbitrumUSDC,
776
+ [TokenType.BRIDGED_USDC]: arbitrumUSDCe,
777
+ [TokenType.AXL_USDC]: arbitrumAxlUSDC,
778
+ [TokenType.DAI]: arbitrumDAI,
779
+ },
780
+ ],
781
+ [
782
+ base.chainId,
783
+ {
784
+ [TokenType.NATIVE]: baseETH,
785
+ [TokenType.WRAPPED_NATIVE]: baseWETH,
786
+ [TokenType.NATIVE_USDC]: baseUSDC,
787
+ [TokenType.BRIDGED_USDC]: baseUSDbC,
788
+ [TokenType.AXL_USDC]: baseAxlUSDC,
789
+ [TokenType.DAI]: baseDAI,
790
+ },
791
+ ],
792
+ [
793
+ blast.chainId,
794
+ {
795
+ [TokenType.NATIVE]: blastETH,
796
+ [TokenType.WRAPPED_NATIVE]: blastWETH,
797
+ },
798
+ ],
799
+ [
800
+ bsc.chainId,
801
+ {
802
+ [TokenType.NATIVE]: bscBNB,
803
+ [TokenType.WRAPPED_NATIVE]: bscWBNB,
804
+ [TokenType.BRIDGED_USDC]: bscUSDC,
805
+ [TokenType.AXL_USDC]: bscAxlUSDC,
806
+ },
807
+ ],
808
+ [
809
+ ethereum.chainId,
810
+ {
811
+ [TokenType.NATIVE]: ethereumETH,
812
+ [TokenType.WRAPPED_NATIVE]: ethereumWETH,
813
+ [TokenType.NATIVE_USDC]: ethereumUSDC,
814
+ [TokenType.DAI]: ethereumDAI,
815
+ },
816
+ ],
817
+ [
818
+ linea.chainId,
819
+ {
820
+ [TokenType.NATIVE]: lineaETH,
821
+ [TokenType.WRAPPED_NATIVE]: lineaWETH,
822
+ [TokenType.NATIVE_USDC]: lineaUSDC,
823
+ [TokenType.AXL_USDC]: lineaAxlUSDC,
824
+ [TokenType.DAI]: lineaDAI,
825
+ },
826
+ ],
827
+ [
828
+ mantle.chainId,
829
+ {
830
+ [TokenType.NATIVE]: mantleMNT,
831
+ [TokenType.WRAPPED_NATIVE]: mantleWMNT,
832
+ [TokenType.BRIDGED_USDC]: mantleBridgedUSDC,
833
+ [TokenType.AXL_USDC]: mantleAxlUSDC,
834
+ },
835
+ ],
836
+ [
837
+ optimism.chainId,
838
+ {
839
+ [TokenType.NATIVE]: optimismETH,
840
+ [TokenType.WRAPPED_NATIVE]: optimismWETH,
841
+ [TokenType.NATIVE_USDC]: optimismUSDC,
842
+ [TokenType.BRIDGED_USDC]: optimismUSDCe,
843
+ [TokenType.AXL_USDC]: optimismAxlUSDC,
844
+ [TokenType.DAI]: optimismDAI,
845
+ },
846
+ ],
847
+ [
848
+ polygon.chainId,
849
+ {
850
+ [TokenType.NATIVE]: polygonPOL,
851
+ [TokenType.WRAPPED_NATIVE]: polygonWPOL,
852
+ [TokenType.NATIVE_USDC]: polygonUSDC,
853
+ [TokenType.BRIDGED_USDC]: polygonUSDCe,
854
+ [TokenType.AXL_USDC]: polygonAxlUSDC,
855
+ [TokenType.DAI]: polygonDAI,
856
+ },
857
+ ],
858
+ [
859
+ solana.chainId,
860
+ {
861
+ [TokenType.NATIVE]: solanaSOL,
862
+ [TokenType.WRAPPED_NATIVE]: solanaWSOL,
863
+ [TokenType.NATIVE_USDC]: solanaUSDC,
864
+ },
865
+ ],
866
+ [
867
+ worldchain.chainId,
868
+ {
869
+ [TokenType.NATIVE]: worldchainETH,
870
+ [TokenType.WRAPPED_NATIVE]: worldchainWETH,
871
+ [TokenType.BRIDGED_USDC]: worldchainUSDCe,
872
+ },
873
+ ],
874
+ ]);
875
+
876
+ export function getChainNativeToken(chainId: number): Token {
877
+ return assertNotNull(
878
+ tokensByChainAndType.get(chainId)?.[TokenType.NATIVE],
879
+ () => `missing native token for chainId ${chainId}`,
880
+ );
784
881
  }
785
882
 
786
- export function getChainWrappedNativeToken(chainId: number): Token | undefined {
787
- return tokensByChainAndType[chainId][TokenType.WRAPPED_NATIVE];
883
+ export function getChainWrappedNativeToken(chainId: number): Token {
884
+ return assertNotNull(
885
+ tokensByChainAndType.get(chainId)?.[TokenType.WRAPPED_NATIVE],
886
+ () => `missing wrapped native token for chainId ${chainId}`,
887
+ );
788
888
  }
789
889
 
790
890
  export function getChainNativeUSDC(chainId: number): Token | undefined {
791
- return tokensByChainAndType[chainId][TokenType.NATIVE_USDC];
891
+ return tokensByChainAndType.get(chainId)?.[TokenType.NATIVE_USDC];
792
892
  }
793
893
 
794
894
  export function getChainAxlUSDC(chainId: number): Token | undefined {
795
- return tokensByChainAndType[chainId][TokenType.AXL_USDC];
895
+ return tokensByChainAndType.get(chainId)?.[TokenType.AXL_USDC];
796
896
  }
797
897
 
798
898
  /** Returns native USDC when available, otherwise bridged USDC. */
799
899
  export function getChainBestUSDC(chainId: number): Token | undefined {
800
- const t = tokensByChainAndType[chainId];
801
- return t[TokenType.NATIVE_USDC] ?? t[TokenType.BRIDGED_USDC];
900
+ const t = tokensByChainAndType.get(chainId);
901
+ return t?.[TokenType.NATIVE_USDC] ?? t?.[TokenType.BRIDGED_USDC];
802
902
  }
803
903
 
804
904
  export function getChainDAI(chainId: number): Token | undefined {
805
- return tokensByChainAndType[chainId][TokenType.DAI];
905
+ return tokensByChainAndType.get(chainId)?.[TokenType.DAI];
806
906
  }
807
907
 
808
908
  /* --------------------- Native Token Utils --------------------- */