@daimo/pay-common 1.19.9 → 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 +4 -0
- package/dist/chain.js +40 -1
- package/dist/chain.js.map +1 -1
- package/dist/daimoPay.d.ts +124 -4
- package/dist/daimoPay.js +15 -2
- package/dist/daimoPay.js.map +1 -1
- package/dist/token.d.ts +16 -8
- package/dist/token.js +78 -97
- package/dist/token.js.map +1 -1
- package/package.json +1 -1
- package/src/chain.ts +41 -0
- package/src/daimoPay.ts +148 -4
- package/src/token.ts +90 -102
package/src/daimoPay.ts
CHANGED
|
@@ -18,6 +18,7 @@ import { assertNotNull } from "./assert";
|
|
|
18
18
|
import {
|
|
19
19
|
BigIntStr,
|
|
20
20
|
SolanaPublicKey,
|
|
21
|
+
UUID,
|
|
21
22
|
zAddress,
|
|
22
23
|
zBigIntStr,
|
|
23
24
|
} from "./primitiveTypes";
|
|
@@ -60,6 +61,7 @@ export enum DaimoPayIntentStatus {
|
|
|
60
61
|
STARTED = "payment_started",
|
|
61
62
|
COMPLETED = "payment_completed",
|
|
62
63
|
BOUNCED = "payment_bounced",
|
|
64
|
+
REFUNDED = "payment_refunded",
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
/**
|
|
@@ -241,7 +243,7 @@ export type DaimoPayHydratedOrder = {
|
|
|
241
243
|
userMetadata: DaimoPayUserMetadata | null;
|
|
242
244
|
/** Nullable because old intents don't have expiration time. */
|
|
243
245
|
expirationTs: bigint | null;
|
|
244
|
-
/** External source type, or null. EG "untron"
|
|
246
|
+
/** External source type, or null. EG "untron". */
|
|
245
247
|
extSourceType: string | null;
|
|
246
248
|
/** External source ID. Set when extSourceType is set. */
|
|
247
249
|
extSourceId: string | null;
|
|
@@ -249,6 +251,12 @@ export type DaimoPayHydratedOrder = {
|
|
|
249
251
|
hopChainId: number | null;
|
|
250
252
|
/** Transaction hash for hop start */
|
|
251
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;
|
|
252
260
|
};
|
|
253
261
|
|
|
254
262
|
export type DaimoPayOrderWithOrg = DaimoPayOrder & {
|
|
@@ -290,7 +298,7 @@ export function isDehydrated(
|
|
|
290
298
|
export type DaimoPayOrderView = {
|
|
291
299
|
id: DaimoPayOrderID;
|
|
292
300
|
status: DaimoPayIntentStatus;
|
|
293
|
-
createdAt: string;
|
|
301
|
+
createdAt: string; // Seconds since epoch
|
|
294
302
|
display: {
|
|
295
303
|
intent: string;
|
|
296
304
|
paymentValue: string;
|
|
@@ -403,7 +411,7 @@ export type WalletPaymentOption = {
|
|
|
403
411
|
|
|
404
412
|
export type ExternalPaymentOptionMetadata = {
|
|
405
413
|
id: ExternalPaymentOptions;
|
|
406
|
-
optionType: "external" | "
|
|
414
|
+
optionType: "external" | "exchange";
|
|
407
415
|
cta: string;
|
|
408
416
|
logoURI: string;
|
|
409
417
|
logoShape: "circle" | "squircle";
|
|
@@ -443,13 +451,19 @@ export enum ExternalPaymentOptions {
|
|
|
443
451
|
Optimism = "Optimism",
|
|
444
452
|
Polygon = "Polygon",
|
|
445
453
|
Ethereum = "Ethereum",
|
|
446
|
-
|
|
454
|
+
/** @deprecated - ZKP2P payment apps no longer supported */
|
|
447
455
|
AllPaymentApps = "AllPaymentApps",
|
|
456
|
+
/** @deprecated - ZKP2P payment apps no longer supported */
|
|
448
457
|
Venmo = "Venmo",
|
|
458
|
+
/** @deprecated - ZKP2P payment apps no longer supported */
|
|
449
459
|
CashApp = "CashApp",
|
|
460
|
+
/** @deprecated - ZKP2P payment apps no longer supported */
|
|
450
461
|
MercadoPago = "MercadoPago",
|
|
462
|
+
/** @deprecated - ZKP2P payment apps no longer supported */
|
|
451
463
|
Revolut = "Revolut",
|
|
464
|
+
/** @deprecated - ZKP2P payment apps no longer supported */
|
|
452
465
|
Wise = "Wise",
|
|
466
|
+
/** @deprecated - ZKP2P payment apps no longer supported */
|
|
453
467
|
Zelle = "Zelle",
|
|
454
468
|
/** @deprecated - kept for backwards compatibility with old SDK versions */
|
|
455
469
|
Daimo = "Daimo",
|
|
@@ -574,7 +588,10 @@ export enum DaimoPayEventType {
|
|
|
574
588
|
export type PaymentStartedEvent = {
|
|
575
589
|
type: DaimoPayEventType.PaymentStarted;
|
|
576
590
|
isTestEvent?: boolean;
|
|
591
|
+
/** Order ID (base58) for order flows, session ID for DA flows */
|
|
577
592
|
paymentId: DaimoPayOrderID;
|
|
593
|
+
/** Session ID (always present) */
|
|
594
|
+
sessionId: string;
|
|
578
595
|
chainId: number;
|
|
579
596
|
txHash: Hex | string | null;
|
|
580
597
|
payment: DaimoPayOrderView;
|
|
@@ -583,7 +600,10 @@ export type PaymentStartedEvent = {
|
|
|
583
600
|
export type PaymentCompletedEvent = {
|
|
584
601
|
type: DaimoPayEventType.PaymentCompleted;
|
|
585
602
|
isTestEvent?: boolean;
|
|
603
|
+
/** Order ID (base58) for order flows, session ID for DA flows */
|
|
586
604
|
paymentId: DaimoPayOrderID;
|
|
605
|
+
/** Session ID (always present) */
|
|
606
|
+
sessionId: string;
|
|
587
607
|
chainId: number;
|
|
588
608
|
txHash: Hex;
|
|
589
609
|
payment: DaimoPayOrderView;
|
|
@@ -592,7 +612,10 @@ export type PaymentCompletedEvent = {
|
|
|
592
612
|
export type PaymentBouncedEvent = {
|
|
593
613
|
type: DaimoPayEventType.PaymentBounced;
|
|
594
614
|
isTestEvent?: boolean;
|
|
615
|
+
/** Order ID (base58) for order flows, session ID for DA flows */
|
|
595
616
|
paymentId: DaimoPayOrderID;
|
|
617
|
+
/** Session ID (always present) */
|
|
618
|
+
sessionId: string;
|
|
596
619
|
chainId: number;
|
|
597
620
|
txHash: Hex;
|
|
598
621
|
payment: DaimoPayOrderView;
|
|
@@ -601,7 +624,10 @@ export type PaymentBouncedEvent = {
|
|
|
601
624
|
export type PaymentRefundedEvent = {
|
|
602
625
|
type: DaimoPayEventType.PaymentRefunded;
|
|
603
626
|
isTestEvent?: boolean;
|
|
627
|
+
/** Order ID (base58) for order flows, session ID for DA flows */
|
|
604
628
|
paymentId: DaimoPayOrderID;
|
|
629
|
+
/** Session ID (always present) */
|
|
630
|
+
sessionId: string;
|
|
605
631
|
refundAddress: Address;
|
|
606
632
|
chainId: number;
|
|
607
633
|
tokenAddress: Address;
|
|
@@ -615,3 +641,121 @@ export type DaimoPayEvent =
|
|
|
615
641
|
| PaymentCompletedEvent
|
|
616
642
|
| PaymentBouncedEvent
|
|
617
643
|
| PaymentRefundedEvent;
|
|
644
|
+
|
|
645
|
+
export enum DAFulfillmentStatus {
|
|
646
|
+
STARTED = "deposit_started",
|
|
647
|
+
COMPLETED = "deposit_completed",
|
|
648
|
+
BOUNCED = "deposit_bounced",
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
export type DAFulfillment = {
|
|
652
|
+
id: UUID;
|
|
653
|
+
daAddr: Address;
|
|
654
|
+
status: DAFulfillmentStatus;
|
|
655
|
+
createdAt: string; // Seconds since epoch
|
|
656
|
+
source: {
|
|
657
|
+
payerAddress: Address | SolanaPublicKey | null;
|
|
658
|
+
txHash: Hex | string | null;
|
|
659
|
+
chainId: string;
|
|
660
|
+
tokenAddress: Address | SolanaPublicKey;
|
|
661
|
+
tokenSymbol: string;
|
|
662
|
+
amountUnits: string;
|
|
663
|
+
usdValue: string;
|
|
664
|
+
};
|
|
665
|
+
destination: {
|
|
666
|
+
destinationAddress: Address;
|
|
667
|
+
chainId: string;
|
|
668
|
+
tokenAddress: Address;
|
|
669
|
+
tokenSymbol: string;
|
|
670
|
+
amountUnits: string | null;
|
|
671
|
+
txHash: Hex | null;
|
|
672
|
+
};
|
|
673
|
+
};
|
|
674
|
+
|
|
675
|
+
export type DA = {
|
|
676
|
+
daAddr: Address;
|
|
677
|
+
org: DaimoPayOrgPublicInfo;
|
|
678
|
+
destinationChainId: string;
|
|
679
|
+
destinationAddress: Address;
|
|
680
|
+
destinationTokenAddress: Address;
|
|
681
|
+
destinationTokenSymbol: string;
|
|
682
|
+
refundAddress: Address;
|
|
683
|
+
expiresAt: string; // Seconds since epoch
|
|
684
|
+
createdAt: string; // Seconds since epoch
|
|
685
|
+
fulfillments: DAFulfillment[];
|
|
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
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
celo,
|
|
8
8
|
ethereum,
|
|
9
9
|
gnosis,
|
|
10
|
+
hyperEvm,
|
|
10
11
|
linea,
|
|
11
12
|
monad,
|
|
12
13
|
optimism,
|
|
@@ -44,6 +45,7 @@ export enum TokenLogo {
|
|
|
44
45
|
ETH = "https://pay.daimo.com/coin-logos/eth.png",
|
|
45
46
|
EURC = "https://pay.daimo.com/coin-logos/eurc.png",
|
|
46
47
|
EURe = "https://pay.daimo.com/coin-logos/eure.png",
|
|
48
|
+
HYPE = "https://pay.daimo.com/coin-logos/hype.png",
|
|
47
49
|
MON = "https://pay.daimo.com/coin-logos/mon.png",
|
|
48
50
|
POL = "https://pay.daimo.com/coin-logos/pol.png",
|
|
49
51
|
SOL = "https://pay.daimo.com/coin-logos/sol.png",
|
|
@@ -85,16 +87,6 @@ export const arbitrumUSDC: Token = token({
|
|
|
85
87
|
logoURI: TokenLogo.USDC,
|
|
86
88
|
});
|
|
87
89
|
|
|
88
|
-
export const arbitrumAxlUSDC: Token = token({
|
|
89
|
-
chainId: arbitrum.chainId,
|
|
90
|
-
token: getAddress("0xEB466342C4d449BC9f53A865D5Cb90586f405215"),
|
|
91
|
-
decimals: 6,
|
|
92
|
-
fiatISO: "USD",
|
|
93
|
-
name: "Axelar Wrapped USDC",
|
|
94
|
-
symbol: "axlUSDC",
|
|
95
|
-
logoURI: TokenLogo.USDC,
|
|
96
|
-
});
|
|
97
|
-
|
|
98
90
|
export const arbitrumDAI: Token = token({
|
|
99
91
|
chainId: arbitrum.chainId,
|
|
100
92
|
token: getAddress("0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"),
|
|
@@ -129,7 +121,6 @@ const arbitrumTokens: Token[] = [
|
|
|
129
121
|
arbitrumETH,
|
|
130
122
|
arbitrumWETH,
|
|
131
123
|
arbitrumUSDC,
|
|
132
|
-
arbitrumAxlUSDC,
|
|
133
124
|
arbitrumDAI,
|
|
134
125
|
arbitrumUSDT,
|
|
135
126
|
arbitrumUSDCe,
|
|
@@ -200,16 +191,6 @@ export const baseUSDT: Token = token({
|
|
|
200
191
|
logoURI: TokenLogo.USDT,
|
|
201
192
|
});
|
|
202
193
|
|
|
203
|
-
export const baseAxlUSDC: Token = token({
|
|
204
|
-
chainId: base.chainId,
|
|
205
|
-
token: getAddress("0xEB466342C4d449BC9f53A865D5Cb90586f405215"),
|
|
206
|
-
decimals: 6,
|
|
207
|
-
fiatISO: "USD",
|
|
208
|
-
name: "Axelar Wrapped USDC",
|
|
209
|
-
symbol: "axlUSDC",
|
|
210
|
-
logoURI: TokenLogo.USDC,
|
|
211
|
-
});
|
|
212
|
-
|
|
213
194
|
const baseTokens: Token[] = [
|
|
214
195
|
baseETH,
|
|
215
196
|
baseWETH,
|
|
@@ -218,7 +199,6 @@ const baseTokens: Token[] = [
|
|
|
218
199
|
baseUSDbC,
|
|
219
200
|
baseDAI,
|
|
220
201
|
baseUSDT,
|
|
221
|
-
baseAxlUSDC,
|
|
222
202
|
];
|
|
223
203
|
|
|
224
204
|
//
|
|
@@ -241,16 +221,6 @@ export const bscWBNB: Token = token({
|
|
|
241
221
|
logoURI: TokenLogo.BNB,
|
|
242
222
|
});
|
|
243
223
|
|
|
244
|
-
export const bscAxlUSDC: Token = token({
|
|
245
|
-
chainId: bsc.chainId,
|
|
246
|
-
token: getAddress("0x4268B8F0B87b6Eae5d897996E6b845ddbD99Adf3"),
|
|
247
|
-
decimals: 6,
|
|
248
|
-
fiatISO: "USD",
|
|
249
|
-
name: "Axelar Wrapped USDC",
|
|
250
|
-
symbol: "axlUSDC",
|
|
251
|
-
logoURI: TokenLogo.USDC,
|
|
252
|
-
});
|
|
253
|
-
|
|
254
224
|
export const bscUSDC: Token = token({
|
|
255
225
|
chainId: bsc.chainId,
|
|
256
226
|
token: getAddress("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),
|
|
@@ -271,7 +241,7 @@ export const bscUSDT: Token = token({
|
|
|
271
241
|
logoURI: TokenLogo.USDT,
|
|
272
242
|
});
|
|
273
243
|
|
|
274
|
-
const bscTokens: Token[] = [bscBNB, bscWBNB,
|
|
244
|
+
const bscTokens: Token[] = [bscBNB, bscWBNB, bscUSDC, bscUSDT];
|
|
275
245
|
|
|
276
246
|
//
|
|
277
247
|
// Celo
|
|
@@ -287,16 +257,6 @@ export const celoCelo: Token = token({
|
|
|
287
257
|
logoURI: TokenLogo.CELO,
|
|
288
258
|
});
|
|
289
259
|
|
|
290
|
-
export const celoAxlUSDC: Token = token({
|
|
291
|
-
chainId: celo.chainId,
|
|
292
|
-
token: getAddress("0xEB466342C4d449BC9f53A865D5Cb90586f405215"),
|
|
293
|
-
decimals: 6,
|
|
294
|
-
fiatISO: "USD",
|
|
295
|
-
name: "Axelar Wrapped USDC",
|
|
296
|
-
symbol: "axlUSDC",
|
|
297
|
-
logoURI: TokenLogo.USDC,
|
|
298
|
-
});
|
|
299
|
-
|
|
300
260
|
export const celoUSDC: Token = token({
|
|
301
261
|
chainId: celo.chainId,
|
|
302
262
|
token: getAddress("0xcebA9300f2b948710d2653dD7B07f33A8B32118C"),
|
|
@@ -327,13 +287,7 @@ export const celoCUSD: Token = token({
|
|
|
327
287
|
logoURI: TokenLogo.cUSD,
|
|
328
288
|
});
|
|
329
289
|
|
|
330
|
-
const celoTokens: Token[] = [
|
|
331
|
-
celoCelo,
|
|
332
|
-
celoAxlUSDC,
|
|
333
|
-
celoUSDC,
|
|
334
|
-
celoUSDT,
|
|
335
|
-
celoCUSD,
|
|
336
|
-
];
|
|
290
|
+
const celoTokens: Token[] = [celoCelo, celoUSDC, celoUSDT, celoCUSD];
|
|
337
291
|
|
|
338
292
|
//
|
|
339
293
|
// Ethereum
|
|
@@ -434,6 +388,38 @@ export const gnosisEURe: Token = token({
|
|
|
434
388
|
|
|
435
389
|
const gnosisTokens: Token[] = [gnosisXDAI, gnosisUSDCe, gnosisEURe];
|
|
436
390
|
|
|
391
|
+
//
|
|
392
|
+
// HyperEVM
|
|
393
|
+
//
|
|
394
|
+
|
|
395
|
+
export const hyperEvmHYPE = nativeToken({
|
|
396
|
+
chainId: hyperEvm.chainId,
|
|
397
|
+
name: "HYPE",
|
|
398
|
+
symbol: "HYPE",
|
|
399
|
+
logoURI: TokenLogo.HYPE,
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
export const hyperEvmWHYPE: Token = token({
|
|
403
|
+
chainId: hyperEvm.chainId,
|
|
404
|
+
token: getAddress("0x5555555555555555555555555555555555555555"),
|
|
405
|
+
decimals: 18,
|
|
406
|
+
name: "Wrapped HYPE",
|
|
407
|
+
symbol: "WHYPE",
|
|
408
|
+
logoURI: TokenLogo.HYPE,
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
export const hyperEvmUSDC: Token = token({
|
|
412
|
+
chainId: hyperEvm.chainId,
|
|
413
|
+
token: getAddress("0xb88339CB7199b77E23DB6E890353E22632Ba630f"),
|
|
414
|
+
decimals: 6,
|
|
415
|
+
fiatISO: "USD",
|
|
416
|
+
name: "USD Coin",
|
|
417
|
+
symbol: "USDC",
|
|
418
|
+
logoURI: TokenLogo.USDC,
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
const hyperEvmTokens: Token[] = [hyperEvmHYPE, hyperEvmWHYPE, hyperEvmUSDC];
|
|
422
|
+
|
|
437
423
|
//
|
|
438
424
|
// Linea
|
|
439
425
|
//
|
|
@@ -459,16 +445,6 @@ export const lineaUSDC: Token = token({
|
|
|
459
445
|
logoURI: TokenLogo.USDC,
|
|
460
446
|
});
|
|
461
447
|
|
|
462
|
-
export const lineaAxlUSDC: Token = token({
|
|
463
|
-
chainId: linea.chainId,
|
|
464
|
-
token: getAddress("0xEB466342C4d449BC9f53A865D5Cb90586f405215"),
|
|
465
|
-
decimals: 6,
|
|
466
|
-
fiatISO: "USD",
|
|
467
|
-
name: "Axelar Wrapped USDC",
|
|
468
|
-
symbol: "axlUSDC",
|
|
469
|
-
logoURI: TokenLogo.USDC,
|
|
470
|
-
});
|
|
471
|
-
|
|
472
448
|
export const lineaDAI: Token = token({
|
|
473
449
|
chainId: linea.chainId,
|
|
474
450
|
token: getAddress("0x4AF15ec2A0BD43Db75dd04E62FAA3B8EF36b00d5"),
|
|
@@ -479,13 +455,7 @@ export const lineaDAI: Token = token({
|
|
|
479
455
|
logoURI: TokenLogo.DAI,
|
|
480
456
|
});
|
|
481
457
|
|
|
482
|
-
const lineaTokens: Token[] = [
|
|
483
|
-
lineaETH,
|
|
484
|
-
lineaWETH,
|
|
485
|
-
lineaUSDC,
|
|
486
|
-
lineaAxlUSDC,
|
|
487
|
-
lineaDAI,
|
|
488
|
-
];
|
|
458
|
+
const lineaTokens: Token[] = [lineaETH, lineaWETH, lineaUSDC, lineaDAI];
|
|
489
459
|
|
|
490
460
|
//
|
|
491
461
|
// Monad
|
|
@@ -554,16 +524,6 @@ export const optimismUSDC: Token = token({
|
|
|
554
524
|
logoURI: TokenLogo.USDC,
|
|
555
525
|
});
|
|
556
526
|
|
|
557
|
-
export const optimismAxlUSDC: Token = token({
|
|
558
|
-
chainId: optimism.chainId,
|
|
559
|
-
token: getAddress("0xEB466342C4d449BC9f53A865D5Cb90586f405215"),
|
|
560
|
-
decimals: 6,
|
|
561
|
-
fiatISO: "USD",
|
|
562
|
-
name: "Axelar Wrapped USDC",
|
|
563
|
-
symbol: "axlUSDC",
|
|
564
|
-
logoURI: TokenLogo.USDC,
|
|
565
|
-
});
|
|
566
|
-
|
|
567
527
|
export const optimismDAI: Token = token({
|
|
568
528
|
chainId: optimism.chainId,
|
|
569
529
|
token: getAddress("0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"),
|
|
@@ -598,7 +558,6 @@ const optimismTokens = [
|
|
|
598
558
|
optimismETH,
|
|
599
559
|
optimismWETH,
|
|
600
560
|
optimismUSDC,
|
|
601
|
-
optimismAxlUSDC,
|
|
602
561
|
optimismDAI,
|
|
603
562
|
optimismUSDT,
|
|
604
563
|
optimismUSDCe,
|
|
@@ -643,16 +602,6 @@ export const polygonUSDC: Token = token({
|
|
|
643
602
|
logoURI: TokenLogo.USDC,
|
|
644
603
|
});
|
|
645
604
|
|
|
646
|
-
export const polygonAxlUSDC: Token = token({
|
|
647
|
-
chainId: polygon.chainId,
|
|
648
|
-
token: getAddress("0x750e4C4984a9e0f12978eA6742Bc1c5D248f40ed"),
|
|
649
|
-
decimals: 6,
|
|
650
|
-
fiatISO: "USD",
|
|
651
|
-
name: "Axelar Wrapped USDC",
|
|
652
|
-
symbol: "axlUSDC",
|
|
653
|
-
logoURI: TokenLogo.USDC,
|
|
654
|
-
});
|
|
655
|
-
|
|
656
605
|
export const polygonDAI: Token = token({
|
|
657
606
|
chainId: polygon.chainId,
|
|
658
607
|
token: getAddress("0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063"),
|
|
@@ -688,7 +637,6 @@ const polygonTokens: Token[] = [
|
|
|
688
637
|
polygonWPOL,
|
|
689
638
|
polygonWETH,
|
|
690
639
|
polygonUSDC,
|
|
691
|
-
polygonAxlUSDC,
|
|
692
640
|
polygonDAI,
|
|
693
641
|
polygonUSDT,
|
|
694
642
|
polygonUSDCe,
|
|
@@ -763,7 +711,17 @@ export const solanaUSDC: Token = token({
|
|
|
763
711
|
logoURI: TokenLogo.USDC,
|
|
764
712
|
});
|
|
765
713
|
|
|
766
|
-
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];
|
|
767
725
|
|
|
768
726
|
//
|
|
769
727
|
// Tron
|
|
@@ -839,6 +797,7 @@ const knownTokensByChain = new Map<number, Token[]>([
|
|
|
839
797
|
[celo.chainId, celoTokens],
|
|
840
798
|
[ethereum.chainId, ethereumTokens],
|
|
841
799
|
[gnosis.chainId, gnosisTokens],
|
|
800
|
+
[hyperEvm.chainId, hyperEvmTokens],
|
|
842
801
|
[linea.chainId, lineaTokens],
|
|
843
802
|
[monad.chainId, monadTokens],
|
|
844
803
|
[optimism.chainId, optimismTokens],
|
|
@@ -879,7 +838,6 @@ enum TokenType {
|
|
|
879
838
|
WRAPPED_NATIVE = "WRAPPED_NATIVE",
|
|
880
839
|
NATIVE_USDC = "NATIVE_USDC",
|
|
881
840
|
BRIDGED_USDC = "BRIDGED_USDC",
|
|
882
|
-
AXL_USDC = "AXL_USDC",
|
|
883
841
|
DAI = "DAI",
|
|
884
842
|
}
|
|
885
843
|
|
|
@@ -894,7 +852,6 @@ const tokensByChainAndType: Map<
|
|
|
894
852
|
[TokenType.WRAPPED_NATIVE]: arbitrumWETH,
|
|
895
853
|
[TokenType.NATIVE_USDC]: arbitrumUSDC,
|
|
896
854
|
[TokenType.BRIDGED_USDC]: arbitrumUSDCe,
|
|
897
|
-
[TokenType.AXL_USDC]: arbitrumAxlUSDC,
|
|
898
855
|
[TokenType.DAI]: arbitrumDAI,
|
|
899
856
|
},
|
|
900
857
|
],
|
|
@@ -905,7 +862,6 @@ const tokensByChainAndType: Map<
|
|
|
905
862
|
[TokenType.WRAPPED_NATIVE]: baseWETH,
|
|
906
863
|
[TokenType.NATIVE_USDC]: baseUSDC,
|
|
907
864
|
[TokenType.BRIDGED_USDC]: baseUSDbC,
|
|
908
|
-
[TokenType.AXL_USDC]: baseAxlUSDC,
|
|
909
865
|
[TokenType.DAI]: baseDAI,
|
|
910
866
|
},
|
|
911
867
|
],
|
|
@@ -915,7 +871,6 @@ const tokensByChainAndType: Map<
|
|
|
915
871
|
[TokenType.NATIVE]: bscBNB,
|
|
916
872
|
[TokenType.WRAPPED_NATIVE]: bscWBNB,
|
|
917
873
|
[TokenType.BRIDGED_USDC]: bscUSDC,
|
|
918
|
-
[TokenType.AXL_USDC]: bscAxlUSDC,
|
|
919
874
|
},
|
|
920
875
|
],
|
|
921
876
|
[
|
|
@@ -925,7 +880,6 @@ const tokensByChainAndType: Map<
|
|
|
925
880
|
[TokenType.NATIVE]: celoCelo,
|
|
926
881
|
[TokenType.WRAPPED_NATIVE]: celoCelo,
|
|
927
882
|
[TokenType.NATIVE_USDC]: celoUSDC,
|
|
928
|
-
[TokenType.AXL_USDC]: celoAxlUSDC,
|
|
929
883
|
},
|
|
930
884
|
],
|
|
931
885
|
[
|
|
@@ -944,13 +898,20 @@ const tokensByChainAndType: Map<
|
|
|
944
898
|
[TokenType.NATIVE_USDC]: gnosisUSDCe,
|
|
945
899
|
},
|
|
946
900
|
],
|
|
901
|
+
[
|
|
902
|
+
hyperEvm.chainId,
|
|
903
|
+
{
|
|
904
|
+
[TokenType.NATIVE]: hyperEvmHYPE,
|
|
905
|
+
[TokenType.WRAPPED_NATIVE]: hyperEvmWHYPE,
|
|
906
|
+
[TokenType.NATIVE_USDC]: hyperEvmUSDC,
|
|
907
|
+
},
|
|
908
|
+
],
|
|
947
909
|
[
|
|
948
910
|
linea.chainId,
|
|
949
911
|
{
|
|
950
912
|
[TokenType.NATIVE]: lineaETH,
|
|
951
913
|
[TokenType.WRAPPED_NATIVE]: lineaWETH,
|
|
952
914
|
[TokenType.NATIVE_USDC]: lineaUSDC,
|
|
953
|
-
[TokenType.AXL_USDC]: lineaAxlUSDC,
|
|
954
915
|
[TokenType.DAI]: lineaDAI,
|
|
955
916
|
},
|
|
956
917
|
],
|
|
@@ -969,7 +930,6 @@ const tokensByChainAndType: Map<
|
|
|
969
930
|
[TokenType.WRAPPED_NATIVE]: optimismWETH,
|
|
970
931
|
[TokenType.NATIVE_USDC]: optimismUSDC,
|
|
971
932
|
[TokenType.BRIDGED_USDC]: optimismUSDCe,
|
|
972
|
-
[TokenType.AXL_USDC]: optimismAxlUSDC,
|
|
973
933
|
[TokenType.DAI]: optimismDAI,
|
|
974
934
|
},
|
|
975
935
|
],
|
|
@@ -980,7 +940,6 @@ const tokensByChainAndType: Map<
|
|
|
980
940
|
[TokenType.WRAPPED_NATIVE]: polygonWPOL,
|
|
981
941
|
[TokenType.NATIVE_USDC]: polygonUSDC,
|
|
982
942
|
[TokenType.BRIDGED_USDC]: polygonUSDCe,
|
|
983
|
-
[TokenType.AXL_USDC]: polygonAxlUSDC,
|
|
984
943
|
[TokenType.DAI]: polygonDAI,
|
|
985
944
|
},
|
|
986
945
|
],
|
|
@@ -1036,10 +995,6 @@ export function getChainNativeUSDC(chainId: number): Token | undefined {
|
|
|
1036
995
|
return tokensByChainAndType.get(chainId)?.[TokenType.NATIVE_USDC];
|
|
1037
996
|
}
|
|
1038
997
|
|
|
1039
|
-
export function getChainAxlUSDC(chainId: number): Token | undefined {
|
|
1040
|
-
return tokensByChainAndType.get(chainId)?.[TokenType.AXL_USDC];
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1043
998
|
/** Returns native USDC when available, otherwise bridged USDC. */
|
|
1044
999
|
export function getChainBestUSDC(chainId: number): Token | undefined {
|
|
1045
1000
|
const t = tokensByChainAndType.get(chainId);
|
|
@@ -1055,6 +1010,39 @@ export function tokensEqual(a: Token, b: Token): boolean {
|
|
|
1055
1010
|
return a.chainId === b.chainId && a.token === b.token;
|
|
1056
1011
|
}
|
|
1057
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
|
+
|
|
1058
1046
|
/* --------------------- Native Token Utils --------------------- */
|
|
1059
1047
|
|
|
1060
1048
|
function nativeETH(chainId: number): Token {
|