@daimo/pay-common 1.19.10 → 1.19.11
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/dist/chain.d.ts +3 -0
- package/dist/chain.js +30 -0
- package/dist/chain.js.map +1 -1
- package/dist/daimoPay.d.ts +85 -4
- package/dist/daimoPay.js +9 -1
- package/dist/daimoPay.js.map +1 -1
- package/dist/token.d.ts +12 -8
- package/dist/token.js +41 -97
- package/dist/token.js.map +1 -1
- package/package.json +1 -1
- package/src/chain.ts +31 -0
- package/src/daimoPay.ts +104 -3
- package/src/token.ts +47 -102
package/src/daimoPay.ts
CHANGED
|
@@ -61,6 +61,7 @@ export enum DaimoPayIntentStatus {
|
|
|
61
61
|
STARTED = "payment_started",
|
|
62
62
|
COMPLETED = "payment_completed",
|
|
63
63
|
BOUNCED = "payment_bounced",
|
|
64
|
+
REFUNDED = "payment_refunded",
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
/**
|
|
@@ -242,7 +243,7 @@ export type DaimoPayHydratedOrder = {
|
|
|
242
243
|
userMetadata: DaimoPayUserMetadata | null;
|
|
243
244
|
/** Nullable because old intents don't have expiration time. */
|
|
244
245
|
expirationTs: bigint | null;
|
|
245
|
-
/** External source type, or null. EG "untron"
|
|
246
|
+
/** External source type, or null. EG "untron". */
|
|
246
247
|
extSourceType: string | null;
|
|
247
248
|
/** External source ID. Set when extSourceType is set. */
|
|
248
249
|
extSourceId: string | null;
|
|
@@ -250,6 +251,12 @@ export type DaimoPayHydratedOrder = {
|
|
|
250
251
|
hopChainId: number | null;
|
|
251
252
|
/** Transaction hash for hop start */
|
|
252
253
|
hopStartTxHash: Hex | null;
|
|
254
|
+
/** If set, indicates slow finish with estimated completion time. Unix timestamp. */
|
|
255
|
+
finishSlowEta: number | null;
|
|
256
|
+
/** Next time this fulfillment can be retried for processing. Unix timestamp. */
|
|
257
|
+
retryProcessingAt: number | null;
|
|
258
|
+
/** Number of retry attempts for this fulfillment. */
|
|
259
|
+
retryCount: number;
|
|
253
260
|
};
|
|
254
261
|
|
|
255
262
|
export type DaimoPayOrderWithOrg = DaimoPayOrder & {
|
|
@@ -404,7 +411,7 @@ export type WalletPaymentOption = {
|
|
|
404
411
|
|
|
405
412
|
export type ExternalPaymentOptionMetadata = {
|
|
406
413
|
id: ExternalPaymentOptions;
|
|
407
|
-
optionType: "external" | "
|
|
414
|
+
optionType: "external" | "exchange";
|
|
408
415
|
cta: string;
|
|
409
416
|
logoURI: string;
|
|
410
417
|
logoShape: "circle" | "squircle";
|
|
@@ -444,13 +451,19 @@ export enum ExternalPaymentOptions {
|
|
|
444
451
|
Optimism = "Optimism",
|
|
445
452
|
Polygon = "Polygon",
|
|
446
453
|
Ethereum = "Ethereum",
|
|
447
|
-
|
|
454
|
+
/** @deprecated - ZKP2P payment apps no longer supported */
|
|
448
455
|
AllPaymentApps = "AllPaymentApps",
|
|
456
|
+
/** @deprecated - ZKP2P payment apps no longer supported */
|
|
449
457
|
Venmo = "Venmo",
|
|
458
|
+
/** @deprecated - ZKP2P payment apps no longer supported */
|
|
450
459
|
CashApp = "CashApp",
|
|
460
|
+
/** @deprecated - ZKP2P payment apps no longer supported */
|
|
451
461
|
MercadoPago = "MercadoPago",
|
|
462
|
+
/** @deprecated - ZKP2P payment apps no longer supported */
|
|
452
463
|
Revolut = "Revolut",
|
|
464
|
+
/** @deprecated - ZKP2P payment apps no longer supported */
|
|
453
465
|
Wise = "Wise",
|
|
466
|
+
/** @deprecated - ZKP2P payment apps no longer supported */
|
|
454
467
|
Zelle = "Zelle",
|
|
455
468
|
/** @deprecated - kept for backwards compatibility with old SDK versions */
|
|
456
469
|
Daimo = "Daimo",
|
|
@@ -575,7 +588,10 @@ export enum DaimoPayEventType {
|
|
|
575
588
|
export type PaymentStartedEvent = {
|
|
576
589
|
type: DaimoPayEventType.PaymentStarted;
|
|
577
590
|
isTestEvent?: boolean;
|
|
591
|
+
/** Order ID (base58) for order flows, session ID for DA flows */
|
|
578
592
|
paymentId: DaimoPayOrderID;
|
|
593
|
+
/** Session ID (always present) */
|
|
594
|
+
sessionId: string;
|
|
579
595
|
chainId: number;
|
|
580
596
|
txHash: Hex | string | null;
|
|
581
597
|
payment: DaimoPayOrderView;
|
|
@@ -584,7 +600,10 @@ export type PaymentStartedEvent = {
|
|
|
584
600
|
export type PaymentCompletedEvent = {
|
|
585
601
|
type: DaimoPayEventType.PaymentCompleted;
|
|
586
602
|
isTestEvent?: boolean;
|
|
603
|
+
/** Order ID (base58) for order flows, session ID for DA flows */
|
|
587
604
|
paymentId: DaimoPayOrderID;
|
|
605
|
+
/** Session ID (always present) */
|
|
606
|
+
sessionId: string;
|
|
588
607
|
chainId: number;
|
|
589
608
|
txHash: Hex;
|
|
590
609
|
payment: DaimoPayOrderView;
|
|
@@ -593,7 +612,10 @@ export type PaymentCompletedEvent = {
|
|
|
593
612
|
export type PaymentBouncedEvent = {
|
|
594
613
|
type: DaimoPayEventType.PaymentBounced;
|
|
595
614
|
isTestEvent?: boolean;
|
|
615
|
+
/** Order ID (base58) for order flows, session ID for DA flows */
|
|
596
616
|
paymentId: DaimoPayOrderID;
|
|
617
|
+
/** Session ID (always present) */
|
|
618
|
+
sessionId: string;
|
|
597
619
|
chainId: number;
|
|
598
620
|
txHash: Hex;
|
|
599
621
|
payment: DaimoPayOrderView;
|
|
@@ -602,7 +624,10 @@ export type PaymentBouncedEvent = {
|
|
|
602
624
|
export type PaymentRefundedEvent = {
|
|
603
625
|
type: DaimoPayEventType.PaymentRefunded;
|
|
604
626
|
isTestEvent?: boolean;
|
|
627
|
+
/** Order ID (base58) for order flows, session ID for DA flows */
|
|
605
628
|
paymentId: DaimoPayOrderID;
|
|
629
|
+
/** Session ID (always present) */
|
|
630
|
+
sessionId: string;
|
|
606
631
|
refundAddress: Address;
|
|
607
632
|
chainId: number;
|
|
608
633
|
tokenAddress: Address;
|
|
@@ -620,6 +645,7 @@ export type DaimoPayEvent =
|
|
|
620
645
|
export enum DAFulfillmentStatus {
|
|
621
646
|
STARTED = "deposit_started",
|
|
622
647
|
COMPLETED = "deposit_completed",
|
|
648
|
+
BOUNCED = "deposit_bounced",
|
|
623
649
|
}
|
|
624
650
|
|
|
625
651
|
export type DAFulfillment = {
|
|
@@ -658,3 +684,78 @@ export type DA = {
|
|
|
658
684
|
createdAt: string; // Seconds since epoch
|
|
659
685
|
fulfillments: DAFulfillment[];
|
|
660
686
|
};
|
|
687
|
+
|
|
688
|
+
// Session types for the new modal flow
|
|
689
|
+
|
|
690
|
+
export type SessionState =
|
|
691
|
+
| "pending"
|
|
692
|
+
| "processing"
|
|
693
|
+
| "completed"
|
|
694
|
+
| "bounced"
|
|
695
|
+
| "expired";
|
|
696
|
+
|
|
697
|
+
/** Common fields for all navigation nodes */
|
|
698
|
+
type NavNodeCommon = {
|
|
699
|
+
id: string;
|
|
700
|
+
/** Page header title when this node is active */
|
|
701
|
+
title: string;
|
|
702
|
+
/** Button label when shown as option in parent (defaults to title) */
|
|
703
|
+
label?: string;
|
|
704
|
+
/** Icons to display on option button (defaults to child icons or node icon) */
|
|
705
|
+
icons?: string[];
|
|
706
|
+
};
|
|
707
|
+
|
|
708
|
+
export type NavNodeChooseOption = NavNodeCommon & {
|
|
709
|
+
type: "ChooseOption";
|
|
710
|
+
options: NavNode[];
|
|
711
|
+
/** Layout for displaying options. Defaults to "list". */
|
|
712
|
+
layout?: "list" | "grid";
|
|
713
|
+
};
|
|
714
|
+
|
|
715
|
+
export type NavNodeDepositAddress = NavNodeCommon & {
|
|
716
|
+
type: "DepositAddress";
|
|
717
|
+
address: Address;
|
|
718
|
+
chainId: number;
|
|
719
|
+
icon?: string;
|
|
720
|
+
minimumUsd: number;
|
|
721
|
+
maximumUsd: number;
|
|
722
|
+
expiresAt: number; // Unix timestamp (createdAt + 1 hour)
|
|
723
|
+
tokenSuffix: string; // e.g., "USDT or USDC"
|
|
724
|
+
};
|
|
725
|
+
|
|
726
|
+
export type NavNodeDeeplink = NavNodeCommon & {
|
|
727
|
+
type: "Deeplink";
|
|
728
|
+
url: string;
|
|
729
|
+
icon?: string;
|
|
730
|
+
};
|
|
731
|
+
|
|
732
|
+
export type NavNodeExchange = NavNodeCommon & {
|
|
733
|
+
type: "Exchange";
|
|
734
|
+
exchangeId: "Coinbase" | "Binance" | "Lemon";
|
|
735
|
+
icon?: string;
|
|
736
|
+
minimumUsd: number;
|
|
737
|
+
maximumUsd: number;
|
|
738
|
+
};
|
|
739
|
+
|
|
740
|
+
export type NavNodeTronDeposit = NavNodeCommon & {
|
|
741
|
+
type: "TronDeposit";
|
|
742
|
+
icon?: string;
|
|
743
|
+
minimumUsd: number;
|
|
744
|
+
maximumUsd: number;
|
|
745
|
+
};
|
|
746
|
+
|
|
747
|
+
export type NavNode =
|
|
748
|
+
| NavNodeChooseOption
|
|
749
|
+
| NavNodeDepositAddress
|
|
750
|
+
| NavNodeDeeplink
|
|
751
|
+
| NavNodeExchange
|
|
752
|
+
| NavNodeTronDeposit;
|
|
753
|
+
|
|
754
|
+
export type Session = {
|
|
755
|
+
sessionId: UUID;
|
|
756
|
+
state: SessionState;
|
|
757
|
+
da: DA;
|
|
758
|
+
navTree: NavNode[];
|
|
759
|
+
/** Custom theme CSS URL, overrides default theme */
|
|
760
|
+
themeCssUrl?: string;
|
|
761
|
+
};
|
package/src/token.ts
CHANGED
|
@@ -87,16 +87,6 @@ export const arbitrumUSDC: Token = token({
|
|
|
87
87
|
logoURI: TokenLogo.USDC,
|
|
88
88
|
});
|
|
89
89
|
|
|
90
|
-
export const arbitrumAxlUSDC: Token = token({
|
|
91
|
-
chainId: arbitrum.chainId,
|
|
92
|
-
token: getAddress("0xEB466342C4d449BC9f53A865D5Cb90586f405215"),
|
|
93
|
-
decimals: 6,
|
|
94
|
-
fiatISO: "USD",
|
|
95
|
-
name: "Axelar Wrapped USDC",
|
|
96
|
-
symbol: "axlUSDC",
|
|
97
|
-
logoURI: TokenLogo.USDC,
|
|
98
|
-
});
|
|
99
|
-
|
|
100
90
|
export const arbitrumDAI: Token = token({
|
|
101
91
|
chainId: arbitrum.chainId,
|
|
102
92
|
token: getAddress("0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"),
|
|
@@ -131,7 +121,6 @@ const arbitrumTokens: Token[] = [
|
|
|
131
121
|
arbitrumETH,
|
|
132
122
|
arbitrumWETH,
|
|
133
123
|
arbitrumUSDC,
|
|
134
|
-
arbitrumAxlUSDC,
|
|
135
124
|
arbitrumDAI,
|
|
136
125
|
arbitrumUSDT,
|
|
137
126
|
arbitrumUSDCe,
|
|
@@ -202,16 +191,6 @@ export const baseUSDT: Token = token({
|
|
|
202
191
|
logoURI: TokenLogo.USDT,
|
|
203
192
|
});
|
|
204
193
|
|
|
205
|
-
export const baseAxlUSDC: Token = token({
|
|
206
|
-
chainId: base.chainId,
|
|
207
|
-
token: getAddress("0xEB466342C4d449BC9f53A865D5Cb90586f405215"),
|
|
208
|
-
decimals: 6,
|
|
209
|
-
fiatISO: "USD",
|
|
210
|
-
name: "Axelar Wrapped USDC",
|
|
211
|
-
symbol: "axlUSDC",
|
|
212
|
-
logoURI: TokenLogo.USDC,
|
|
213
|
-
});
|
|
214
|
-
|
|
215
194
|
const baseTokens: Token[] = [
|
|
216
195
|
baseETH,
|
|
217
196
|
baseWETH,
|
|
@@ -220,7 +199,6 @@ const baseTokens: Token[] = [
|
|
|
220
199
|
baseUSDbC,
|
|
221
200
|
baseDAI,
|
|
222
201
|
baseUSDT,
|
|
223
|
-
baseAxlUSDC,
|
|
224
202
|
];
|
|
225
203
|
|
|
226
204
|
//
|
|
@@ -243,16 +221,6 @@ export const bscWBNB: Token = token({
|
|
|
243
221
|
logoURI: TokenLogo.BNB,
|
|
244
222
|
});
|
|
245
223
|
|
|
246
|
-
export const bscAxlUSDC: Token = token({
|
|
247
|
-
chainId: bsc.chainId,
|
|
248
|
-
token: getAddress("0x4268B8F0B87b6Eae5d897996E6b845ddbD99Adf3"),
|
|
249
|
-
decimals: 6,
|
|
250
|
-
fiatISO: "USD",
|
|
251
|
-
name: "Axelar Wrapped USDC",
|
|
252
|
-
symbol: "axlUSDC",
|
|
253
|
-
logoURI: TokenLogo.USDC,
|
|
254
|
-
});
|
|
255
|
-
|
|
256
224
|
export const bscUSDC: Token = token({
|
|
257
225
|
chainId: bsc.chainId,
|
|
258
226
|
token: getAddress("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),
|
|
@@ -273,7 +241,7 @@ export const bscUSDT: Token = token({
|
|
|
273
241
|
logoURI: TokenLogo.USDT,
|
|
274
242
|
});
|
|
275
243
|
|
|
276
|
-
const bscTokens: Token[] = [bscBNB, bscWBNB,
|
|
244
|
+
const bscTokens: Token[] = [bscBNB, bscWBNB, bscUSDC, bscUSDT];
|
|
277
245
|
|
|
278
246
|
//
|
|
279
247
|
// Celo
|
|
@@ -289,16 +257,6 @@ export const celoCelo: Token = token({
|
|
|
289
257
|
logoURI: TokenLogo.CELO,
|
|
290
258
|
});
|
|
291
259
|
|
|
292
|
-
export const celoAxlUSDC: Token = token({
|
|
293
|
-
chainId: celo.chainId,
|
|
294
|
-
token: getAddress("0xEB466342C4d449BC9f53A865D5Cb90586f405215"),
|
|
295
|
-
decimals: 6,
|
|
296
|
-
fiatISO: "USD",
|
|
297
|
-
name: "Axelar Wrapped USDC",
|
|
298
|
-
symbol: "axlUSDC",
|
|
299
|
-
logoURI: TokenLogo.USDC,
|
|
300
|
-
});
|
|
301
|
-
|
|
302
260
|
export const celoUSDC: Token = token({
|
|
303
261
|
chainId: celo.chainId,
|
|
304
262
|
token: getAddress("0xcebA9300f2b948710d2653dD7B07f33A8B32118C"),
|
|
@@ -329,13 +287,7 @@ export const celoCUSD: Token = token({
|
|
|
329
287
|
logoURI: TokenLogo.cUSD,
|
|
330
288
|
});
|
|
331
289
|
|
|
332
|
-
const celoTokens: Token[] = [
|
|
333
|
-
celoCelo,
|
|
334
|
-
celoAxlUSDC,
|
|
335
|
-
celoUSDC,
|
|
336
|
-
celoUSDT,
|
|
337
|
-
celoCUSD,
|
|
338
|
-
];
|
|
290
|
+
const celoTokens: Token[] = [celoCelo, celoUSDC, celoUSDT, celoCUSD];
|
|
339
291
|
|
|
340
292
|
//
|
|
341
293
|
// Ethereum
|
|
@@ -493,16 +445,6 @@ export const lineaUSDC: Token = token({
|
|
|
493
445
|
logoURI: TokenLogo.USDC,
|
|
494
446
|
});
|
|
495
447
|
|
|
496
|
-
export const lineaAxlUSDC: Token = token({
|
|
497
|
-
chainId: linea.chainId,
|
|
498
|
-
token: getAddress("0xEB466342C4d449BC9f53A865D5Cb90586f405215"),
|
|
499
|
-
decimals: 6,
|
|
500
|
-
fiatISO: "USD",
|
|
501
|
-
name: "Axelar Wrapped USDC",
|
|
502
|
-
symbol: "axlUSDC",
|
|
503
|
-
logoURI: TokenLogo.USDC,
|
|
504
|
-
});
|
|
505
|
-
|
|
506
448
|
export const lineaDAI: Token = token({
|
|
507
449
|
chainId: linea.chainId,
|
|
508
450
|
token: getAddress("0x4AF15ec2A0BD43Db75dd04E62FAA3B8EF36b00d5"),
|
|
@@ -513,13 +455,7 @@ export const lineaDAI: Token = token({
|
|
|
513
455
|
logoURI: TokenLogo.DAI,
|
|
514
456
|
});
|
|
515
457
|
|
|
516
|
-
const lineaTokens: Token[] = [
|
|
517
|
-
lineaETH,
|
|
518
|
-
lineaWETH,
|
|
519
|
-
lineaUSDC,
|
|
520
|
-
lineaAxlUSDC,
|
|
521
|
-
lineaDAI,
|
|
522
|
-
];
|
|
458
|
+
const lineaTokens: Token[] = [lineaETH, lineaWETH, lineaUSDC, lineaDAI];
|
|
523
459
|
|
|
524
460
|
//
|
|
525
461
|
// Monad
|
|
@@ -588,16 +524,6 @@ export const optimismUSDC: Token = token({
|
|
|
588
524
|
logoURI: TokenLogo.USDC,
|
|
589
525
|
});
|
|
590
526
|
|
|
591
|
-
export const optimismAxlUSDC: Token = token({
|
|
592
|
-
chainId: optimism.chainId,
|
|
593
|
-
token: getAddress("0xEB466342C4d449BC9f53A865D5Cb90586f405215"),
|
|
594
|
-
decimals: 6,
|
|
595
|
-
fiatISO: "USD",
|
|
596
|
-
name: "Axelar Wrapped USDC",
|
|
597
|
-
symbol: "axlUSDC",
|
|
598
|
-
logoURI: TokenLogo.USDC,
|
|
599
|
-
});
|
|
600
|
-
|
|
601
527
|
export const optimismDAI: Token = token({
|
|
602
528
|
chainId: optimism.chainId,
|
|
603
529
|
token: getAddress("0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"),
|
|
@@ -632,7 +558,6 @@ const optimismTokens = [
|
|
|
632
558
|
optimismETH,
|
|
633
559
|
optimismWETH,
|
|
634
560
|
optimismUSDC,
|
|
635
|
-
optimismAxlUSDC,
|
|
636
561
|
optimismDAI,
|
|
637
562
|
optimismUSDT,
|
|
638
563
|
optimismUSDCe,
|
|
@@ -677,16 +602,6 @@ export const polygonUSDC: Token = token({
|
|
|
677
602
|
logoURI: TokenLogo.USDC,
|
|
678
603
|
});
|
|
679
604
|
|
|
680
|
-
export const polygonAxlUSDC: Token = token({
|
|
681
|
-
chainId: polygon.chainId,
|
|
682
|
-
token: getAddress("0x750e4C4984a9e0f12978eA6742Bc1c5D248f40ed"),
|
|
683
|
-
decimals: 6,
|
|
684
|
-
fiatISO: "USD",
|
|
685
|
-
name: "Axelar Wrapped USDC",
|
|
686
|
-
symbol: "axlUSDC",
|
|
687
|
-
logoURI: TokenLogo.USDC,
|
|
688
|
-
});
|
|
689
|
-
|
|
690
605
|
export const polygonDAI: Token = token({
|
|
691
606
|
chainId: polygon.chainId,
|
|
692
607
|
token: getAddress("0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063"),
|
|
@@ -722,7 +637,6 @@ const polygonTokens: Token[] = [
|
|
|
722
637
|
polygonWPOL,
|
|
723
638
|
polygonWETH,
|
|
724
639
|
polygonUSDC,
|
|
725
|
-
polygonAxlUSDC,
|
|
726
640
|
polygonDAI,
|
|
727
641
|
polygonUSDT,
|
|
728
642
|
polygonUSDCe,
|
|
@@ -797,7 +711,17 @@ export const solanaUSDC: Token = token({
|
|
|
797
711
|
logoURI: TokenLogo.USDC,
|
|
798
712
|
});
|
|
799
713
|
|
|
800
|
-
const
|
|
714
|
+
export const solanaUSDT: Token = token({
|
|
715
|
+
chainId: solana.chainId,
|
|
716
|
+
token: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
|
|
717
|
+
decimals: 6,
|
|
718
|
+
fiatISO: "USD",
|
|
719
|
+
name: "Tether USD",
|
|
720
|
+
symbol: "USDT",
|
|
721
|
+
logoURI: TokenLogo.USDT,
|
|
722
|
+
});
|
|
723
|
+
|
|
724
|
+
const solanaTokens: Token[] = [solanaUSDC, solanaUSDT, solanaWSOL, solanaSOL];
|
|
801
725
|
|
|
802
726
|
//
|
|
803
727
|
// Tron
|
|
@@ -914,7 +838,6 @@ enum TokenType {
|
|
|
914
838
|
WRAPPED_NATIVE = "WRAPPED_NATIVE",
|
|
915
839
|
NATIVE_USDC = "NATIVE_USDC",
|
|
916
840
|
BRIDGED_USDC = "BRIDGED_USDC",
|
|
917
|
-
AXL_USDC = "AXL_USDC",
|
|
918
841
|
DAI = "DAI",
|
|
919
842
|
}
|
|
920
843
|
|
|
@@ -929,7 +852,6 @@ const tokensByChainAndType: Map<
|
|
|
929
852
|
[TokenType.WRAPPED_NATIVE]: arbitrumWETH,
|
|
930
853
|
[TokenType.NATIVE_USDC]: arbitrumUSDC,
|
|
931
854
|
[TokenType.BRIDGED_USDC]: arbitrumUSDCe,
|
|
932
|
-
[TokenType.AXL_USDC]: arbitrumAxlUSDC,
|
|
933
855
|
[TokenType.DAI]: arbitrumDAI,
|
|
934
856
|
},
|
|
935
857
|
],
|
|
@@ -940,7 +862,6 @@ const tokensByChainAndType: Map<
|
|
|
940
862
|
[TokenType.WRAPPED_NATIVE]: baseWETH,
|
|
941
863
|
[TokenType.NATIVE_USDC]: baseUSDC,
|
|
942
864
|
[TokenType.BRIDGED_USDC]: baseUSDbC,
|
|
943
|
-
[TokenType.AXL_USDC]: baseAxlUSDC,
|
|
944
865
|
[TokenType.DAI]: baseDAI,
|
|
945
866
|
},
|
|
946
867
|
],
|
|
@@ -950,7 +871,6 @@ const tokensByChainAndType: Map<
|
|
|
950
871
|
[TokenType.NATIVE]: bscBNB,
|
|
951
872
|
[TokenType.WRAPPED_NATIVE]: bscWBNB,
|
|
952
873
|
[TokenType.BRIDGED_USDC]: bscUSDC,
|
|
953
|
-
[TokenType.AXL_USDC]: bscAxlUSDC,
|
|
954
874
|
},
|
|
955
875
|
],
|
|
956
876
|
[
|
|
@@ -960,7 +880,6 @@ const tokensByChainAndType: Map<
|
|
|
960
880
|
[TokenType.NATIVE]: celoCelo,
|
|
961
881
|
[TokenType.WRAPPED_NATIVE]: celoCelo,
|
|
962
882
|
[TokenType.NATIVE_USDC]: celoUSDC,
|
|
963
|
-
[TokenType.AXL_USDC]: celoAxlUSDC,
|
|
964
883
|
},
|
|
965
884
|
],
|
|
966
885
|
[
|
|
@@ -993,7 +912,6 @@ const tokensByChainAndType: Map<
|
|
|
993
912
|
[TokenType.NATIVE]: lineaETH,
|
|
994
913
|
[TokenType.WRAPPED_NATIVE]: lineaWETH,
|
|
995
914
|
[TokenType.NATIVE_USDC]: lineaUSDC,
|
|
996
|
-
[TokenType.AXL_USDC]: lineaAxlUSDC,
|
|
997
915
|
[TokenType.DAI]: lineaDAI,
|
|
998
916
|
},
|
|
999
917
|
],
|
|
@@ -1012,7 +930,6 @@ const tokensByChainAndType: Map<
|
|
|
1012
930
|
[TokenType.WRAPPED_NATIVE]: optimismWETH,
|
|
1013
931
|
[TokenType.NATIVE_USDC]: optimismUSDC,
|
|
1014
932
|
[TokenType.BRIDGED_USDC]: optimismUSDCe,
|
|
1015
|
-
[TokenType.AXL_USDC]: optimismAxlUSDC,
|
|
1016
933
|
[TokenType.DAI]: optimismDAI,
|
|
1017
934
|
},
|
|
1018
935
|
],
|
|
@@ -1023,7 +940,6 @@ const tokensByChainAndType: Map<
|
|
|
1023
940
|
[TokenType.WRAPPED_NATIVE]: polygonWPOL,
|
|
1024
941
|
[TokenType.NATIVE_USDC]: polygonUSDC,
|
|
1025
942
|
[TokenType.BRIDGED_USDC]: polygonUSDCe,
|
|
1026
|
-
[TokenType.AXL_USDC]: polygonAxlUSDC,
|
|
1027
943
|
[TokenType.DAI]: polygonDAI,
|
|
1028
944
|
},
|
|
1029
945
|
],
|
|
@@ -1079,10 +995,6 @@ export function getChainNativeUSDC(chainId: number): Token | undefined {
|
|
|
1079
995
|
return tokensByChainAndType.get(chainId)?.[TokenType.NATIVE_USDC];
|
|
1080
996
|
}
|
|
1081
997
|
|
|
1082
|
-
export function getChainAxlUSDC(chainId: number): Token | undefined {
|
|
1083
|
-
return tokensByChainAndType.get(chainId)?.[TokenType.AXL_USDC];
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1086
998
|
/** Returns native USDC when available, otherwise bridged USDC. */
|
|
1087
999
|
export function getChainBestUSDC(chainId: number): Token | undefined {
|
|
1088
1000
|
const t = tokensByChainAndType.get(chainId);
|
|
@@ -1098,6 +1010,39 @@ export function tokensEqual(a: Token, b: Token): boolean {
|
|
|
1098
1010
|
return a.chainId === b.chainId && a.token === b.token;
|
|
1099
1011
|
}
|
|
1100
1012
|
|
|
1013
|
+
/**
|
|
1014
|
+
* Returns true if the token is the native token or wrapped native token.
|
|
1015
|
+
* Useful for checking if a token needs special native/wrapped handling.
|
|
1016
|
+
*/
|
|
1017
|
+
export function isNativeOrWrappedNative(
|
|
1018
|
+
chainId: number,
|
|
1019
|
+
tokenAddr: string,
|
|
1020
|
+
): boolean {
|
|
1021
|
+
const tokens = tokensByChainAndType.get(chainId);
|
|
1022
|
+
if (!tokens) return false;
|
|
1023
|
+
return (
|
|
1024
|
+
tokens[TokenType.NATIVE]?.token === tokenAddr ||
|
|
1025
|
+
tokens[TokenType.WRAPPED_NATIVE]?.token === tokenAddr
|
|
1026
|
+
);
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
/**
|
|
1030
|
+
* For pricing/API lookups, native tokens should use their wrapped equivalent.
|
|
1031
|
+
* Returns the wrapped native address if given native or wrapped native,
|
|
1032
|
+
* otherwise returns the original address unchanged.
|
|
1033
|
+
*/
|
|
1034
|
+
export function getWrappedAddressForLookup(
|
|
1035
|
+
chainId: number,
|
|
1036
|
+
tokenAddr: string,
|
|
1037
|
+
): string {
|
|
1038
|
+
if (isNativeOrWrappedNative(chainId, tokenAddr)) {
|
|
1039
|
+
const wrapped =
|
|
1040
|
+
tokensByChainAndType.get(chainId)?.[TokenType.WRAPPED_NATIVE];
|
|
1041
|
+
if (wrapped) return wrapped.token;
|
|
1042
|
+
}
|
|
1043
|
+
return tokenAddr;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1101
1046
|
/* --------------------- Native Token Utils --------------------- */
|
|
1102
1047
|
|
|
1103
1048
|
function nativeETH(chainId: number): Token {
|