agentwallet-sdk 2.5.0 → 3.0.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/README.md +218 -0
- package/dist/bridge/client.d.ts +17 -49
- package/dist/bridge/client.d.ts.map +1 -1
- package/dist/bridge/client.js +94 -124
- package/dist/bridge/client.js.map +1 -1
- package/dist/bridge/index.d.ts +4 -2
- package/dist/bridge/index.d.ts.map +1 -1
- package/dist/bridge/index.js +8 -2
- package/dist/bridge/index.js.map +1 -1
- package/dist/bridge/types.d.ts +100 -19
- package/dist/bridge/types.d.ts.map +1 -1
- package/dist/bridge/types.js +167 -18
- package/dist/bridge/types.js.map +1 -1
- package/dist/bridge/unified.d.ts +101 -0
- package/dist/bridge/unified.d.ts.map +1 -0
- package/dist/bridge/unified.js +284 -0
- package/dist/bridge/unified.js.map +1 -0
- package/dist/chains.d.ts +25 -0
- package/dist/chains.d.ts.map +1 -1
- package/dist/chains.js +33 -0
- package/dist/chains.js.map +1 -1
- package/dist/index.d.ts +13 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/dist/solana/bridge.d.ts +144 -0
- package/dist/solana/bridge.d.ts.map +1 -0
- package/dist/solana/bridge.js +352 -0
- package/dist/solana/bridge.js.map +1 -0
- package/dist/solana/index.d.ts +8 -0
- package/dist/solana/index.d.ts.map +1 -0
- package/dist/solana/index.js +6 -0
- package/dist/solana/index.js.map +1 -0
- package/dist/solana/swap.d.ts +85 -0
- package/dist/solana/swap.d.ts.map +1 -0
- package/dist/solana/swap.js +173 -0
- package/dist/solana/swap.js.map +1 -0
- package/dist/solana/types.d.ts +126 -0
- package/dist/solana/types.d.ts.map +1 -0
- package/dist/solana/types.js +10 -0
- package/dist/solana/types.js.map +1 -0
- package/dist/solana/wallet.d.ts +83 -0
- package/dist/solana/wallet.d.ts.map +1 -0
- package/dist/solana/wallet.js +164 -0
- package/dist/solana/wallet.js.map +1 -0
- package/dist/solana/x402.d.ts +69 -0
- package/dist/solana/x402.d.ts.map +1 -0
- package/dist/solana/x402.js +154 -0
- package/dist/solana/x402.js.map +1 -0
- package/dist/x402/index.d.ts +1 -1
- package/dist/x402/index.d.ts.map +1 -1
- package/dist/x402/index.js +1 -1
- package/dist/x402/index.js.map +1 -1
- package/dist/x402/types.d.ts +4 -2
- package/dist/x402/types.d.ts.map +1 -1
- package/dist/x402/types.js +12 -1
- package/dist/x402/types.js.map +1 -1
- package/package.json +8 -3
package/dist/bridge/types.d.ts
CHANGED
|
@@ -1,24 +1,73 @@
|
|
|
1
1
|
import type { Address, Hash, Hex } from 'viem';
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
/**
|
|
3
|
+
* All EVM chains supported by CCTP V2 (16 chains).
|
|
4
|
+
* Solana is non-EVM and handled separately via SolanaCCTPBridge.
|
|
5
|
+
*/
|
|
6
|
+
export type BridgeChain = 'ethereum' | 'avalanche' | 'optimism' | 'arbitrum' | 'base' | 'polygon' | 'unichain' | 'linea' | 'codex' | 'sonic' | 'worldchain' | 'sei' | 'xdc' | 'hyperevm' | 'ink' | 'plume';
|
|
7
|
+
/** Solana — non-EVM, handled by SolanaCCTPBridge */
|
|
8
|
+
export type CCTPSolanaChain = 'solana';
|
|
9
|
+
/** All CCTP V2 supported chains: 16 EVM + Solana */
|
|
10
|
+
export type CCTPSupportedChain = BridgeChain | CCTPSolanaChain;
|
|
11
|
+
/**
|
|
12
|
+
* CCTP V2 domain IDs — Circle's internal chain identifiers.
|
|
13
|
+
* Source: https://developers.circle.com/cctp/concepts/supported-chains-and-domains
|
|
14
|
+
* These are used in smart contract calls and the attestation API.
|
|
15
|
+
*/
|
|
16
|
+
export declare const CCTP_DOMAIN_IDS: Record<CCTPSupportedChain, number>;
|
|
17
|
+
/** EVM chain IDs for all supported bridge chains */
|
|
7
18
|
export declare const BRIDGE_CHAIN_IDS: Record<BridgeChain, number>;
|
|
8
|
-
/**
|
|
19
|
+
/** Default public RPC URLs — replace with paid provider in production */
|
|
20
|
+
export declare const BRIDGE_RPC_URLS: Record<BridgeChain, string>;
|
|
21
|
+
/**
|
|
22
|
+
* USDC contract addresses per chain — official Circle deployments.
|
|
23
|
+
* Source: https://developers.circle.com/stablecoins/usdc-contract-addresses
|
|
24
|
+
*/
|
|
9
25
|
export declare const USDC_CONTRACT: Record<BridgeChain, Address>;
|
|
10
26
|
/**
|
|
11
|
-
* CCTP V2 TokenMessengerV2 addresses
|
|
12
|
-
*
|
|
13
|
-
*
|
|
27
|
+
* CCTP V2 TokenMessengerV2 addresses — same address on all EVM chains.
|
|
28
|
+
* Source: https://developers.circle.com/cctp/references/contract-addresses
|
|
29
|
+
* Verified: 0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d (all chains)
|
|
14
30
|
*/
|
|
15
31
|
export declare const TOKEN_MESSENGER_V2: Record<BridgeChain, Address>;
|
|
16
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* CCTP V2 MessageTransmitterV2 addresses — same address on all EVM chains.
|
|
34
|
+
* Source: https://developers.circle.com/cctp/references/contract-addresses
|
|
35
|
+
* Verified: 0x81D40F21F12A8F0E3252Bccb954D722d4c464B64 (all chains)
|
|
36
|
+
*/
|
|
17
37
|
export declare const MESSAGE_TRANSMITTER_V2: Record<BridgeChain, Address>;
|
|
38
|
+
/**
|
|
39
|
+
* Solana CCTP V2 program addresses (domain 5).
|
|
40
|
+
* Source: https://developers.circle.com/cctp/references/solana-programs
|
|
41
|
+
*/
|
|
42
|
+
export declare const SOLANA_CCTP_PROGRAMS: {
|
|
43
|
+
/** Handles incoming messages + mints USDC on Solana */
|
|
44
|
+
readonly MESSAGE_TRANSMITTER_V2: "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC";
|
|
45
|
+
/** Handles burn + combined TokenMessenger + TokenMinter on Solana */
|
|
46
|
+
readonly TOKEN_MESSENGER_MINTER_V2: "CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe";
|
|
47
|
+
};
|
|
48
|
+
/** Solana USDC mint address (mainnet) */
|
|
49
|
+
export declare const SOLANA_USDC_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
50
|
+
/** Solana CCTP domain ID */
|
|
51
|
+
export declare const SOLANA_CCTP_DOMAIN = 5;
|
|
52
|
+
/**
|
|
53
|
+
* Platform bridge fee: 0.1% (10 basis points).
|
|
54
|
+
* Applied on source chain before bridging. Circle CCTP itself is feeless.
|
|
55
|
+
*/
|
|
56
|
+
export declare const PLATFORM_FEE_BPS = 10n;
|
|
57
|
+
export declare const PLATFORM_FEE_DENOMINATOR = 10000n;
|
|
58
|
+
/**
|
|
59
|
+
* Calculate 0.1% platform fee for a given bridge amount.
|
|
60
|
+
* @param amount - USDC amount in base units (6 decimals)
|
|
61
|
+
*/
|
|
62
|
+
export declare function calcBridgeFee(amount: bigint): bigint;
|
|
63
|
+
/**
|
|
64
|
+
* Calculate the actual bridged amount after platform fee deduction.
|
|
65
|
+
*/
|
|
66
|
+
export declare function calcAmountAfterFee(amount: bigint): bigint;
|
|
18
67
|
/**
|
|
19
68
|
* CCTP V2 minFinalityThreshold values.
|
|
20
|
-
* - FAST (0): ~
|
|
21
|
-
* - FINALIZED (1000): Full on-chain finality. Use for large amounts.
|
|
69
|
+
* - FAST (0): ~8–20 seconds. Circle fast attestation. Recommended for agents.
|
|
70
|
+
* - FINALIZED (1000): Full on-chain finality. Use for large amounts (>$10k).
|
|
22
71
|
*/
|
|
23
72
|
export declare const FINALITY_THRESHOLD: {
|
|
24
73
|
readonly FAST: 0;
|
|
@@ -34,8 +83,8 @@ export declare const ATTESTATION_POLL_INTERVAL_MS = 5000;
|
|
|
34
83
|
export interface BridgeOptions {
|
|
35
84
|
/**
|
|
36
85
|
* Minimum finality threshold.
|
|
37
|
-
* - 0 (FAST): ~
|
|
38
|
-
* - 1000 (FINALIZED): Full finality (slower but more secure)
|
|
86
|
+
* - 0 (FAST): ~8–20 seconds using Circle's fast attestation
|
|
87
|
+
* - 1000 (FINALIZED): Full finality (slower but more secure for large amounts)
|
|
39
88
|
* @default 0 (fast finality)
|
|
40
89
|
*/
|
|
41
90
|
minFinalityThreshold?: number;
|
|
@@ -59,6 +108,11 @@ export interface BridgeOptions {
|
|
|
59
108
|
* Circle attestation API override (for testing).
|
|
60
109
|
*/
|
|
61
110
|
attestationApiUrl?: string;
|
|
111
|
+
/**
|
|
112
|
+
* Whether to apply the 0.1% platform fee.
|
|
113
|
+
* @default true
|
|
114
|
+
*/
|
|
115
|
+
applyPlatformFee?: boolean;
|
|
62
116
|
}
|
|
63
117
|
/** Result of a bridge.burn() operation */
|
|
64
118
|
export interface BurnResult {
|
|
@@ -83,7 +137,7 @@ export interface AttestationResponse {
|
|
|
83
137
|
attestation: Hex | null;
|
|
84
138
|
error?: string;
|
|
85
139
|
}
|
|
86
|
-
/** Result of the full bridge() operation */
|
|
140
|
+
/** Result of the full bridge() operation (EVM chains) */
|
|
87
141
|
export interface BridgeResult {
|
|
88
142
|
/** Transaction hash of the burn on source chain */
|
|
89
143
|
burnTxHash: Hash;
|
|
@@ -91,17 +145,44 @@ export interface BridgeResult {
|
|
|
91
145
|
mintTxHash: Hash;
|
|
92
146
|
/** Amount bridged in USDC base units (6 decimals) */
|
|
93
147
|
amount: bigint;
|
|
148
|
+
/** Platform fee collected (0.1% of amount) */
|
|
149
|
+
platformFee: bigint;
|
|
94
150
|
/** Source chain name */
|
|
95
|
-
fromChain:
|
|
151
|
+
fromChain: CCTPSupportedChain;
|
|
96
152
|
/** Destination chain name */
|
|
97
|
-
toChain:
|
|
153
|
+
toChain: CCTPSupportedChain;
|
|
98
154
|
/** Recipient address on destination chain */
|
|
99
|
-
recipient:
|
|
155
|
+
recipient: string;
|
|
100
156
|
/** CCTP nonce */
|
|
101
157
|
nonce: bigint;
|
|
102
158
|
/** Total time in milliseconds from burn to mint */
|
|
103
159
|
elapsedMs: number;
|
|
104
160
|
}
|
|
161
|
+
/** Quote for a bridge operation */
|
|
162
|
+
export interface BridgeQuote {
|
|
163
|
+
/** Input amount (USDC, 6 decimals) */
|
|
164
|
+
inputAmount: bigint;
|
|
165
|
+
/** Platform fee (0.1%) */
|
|
166
|
+
platformFee: bigint;
|
|
167
|
+
/** Amount that will arrive at destination */
|
|
168
|
+
outputAmount: bigint;
|
|
169
|
+
/** Source chain */
|
|
170
|
+
fromChain: CCTPSupportedChain;
|
|
171
|
+
/** Destination chain */
|
|
172
|
+
toChain: CCTPSupportedChain;
|
|
173
|
+
/** Estimated time in seconds */
|
|
174
|
+
estimatedTimeSeconds: number;
|
|
175
|
+
/** Whether fast transfer is available on the source chain */
|
|
176
|
+
fastTransferAvailable: boolean;
|
|
177
|
+
}
|
|
105
178
|
/** Error codes for actionable bridge error messages */
|
|
106
|
-
export type BridgeErrorCode = 'UNSUPPORTED_CHAIN' | 'INSUFFICIENT_ALLOWANCE' | 'INSUFFICIENT_BALANCE' | 'BURN_FAILED' | 'ATTESTATION_TIMEOUT' | 'ATTESTATION_ERROR' | 'MINT_FAILED' | 'INVALID_AMOUNT' | 'NO_WALLET_CLIENT';
|
|
179
|
+
export type BridgeErrorCode = 'UNSUPPORTED_CHAIN' | 'UNSUPPORTED_ROUTE' | 'INSUFFICIENT_ALLOWANCE' | 'INSUFFICIENT_BALANCE' | 'BURN_FAILED' | 'ATTESTATION_TIMEOUT' | 'ATTESTATION_ERROR' | 'MINT_FAILED' | 'INVALID_AMOUNT' | 'NO_WALLET_CLIENT' | 'NO_SOLANA_WALLET' | 'SAME_CHAIN';
|
|
180
|
+
/**
|
|
181
|
+
* Chains that support CCTP V2 Fast Transfer (8–20 second attestation).
|
|
182
|
+
* Chains NOT listed here use Standard Transfer (up to ~15 min on Ethereum).
|
|
183
|
+
* Source: https://developers.circle.com/cctp/concepts/supported-chains-and-domains
|
|
184
|
+
*/
|
|
185
|
+
export declare const FAST_TRANSFER_CHAINS: Set<CCTPSupportedChain>;
|
|
186
|
+
/** Get estimated bridge time in seconds for a given source chain */
|
|
187
|
+
export declare function getEstimatedBridgeSeconds(chain: CCTPSupportedChain): number;
|
|
107
188
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/bridge/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/bridge/types.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAI/C;;;GAGG;AACH,MAAM,MAAM,WAAW,GACnB,UAAU,GACV,WAAW,GACX,UAAU,GACV,UAAU,GACV,MAAM,GACN,SAAS,GACT,UAAU,GACV,OAAO,GACP,OAAO,GACP,OAAO,GACP,YAAY,GACZ,KAAK,GACL,KAAK,GACL,UAAU,GACV,KAAK,GACL,OAAO,CAAC;AAEZ,oDAAoD;AACpD,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC;AAEvC,oDAAoD;AACpD,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG,eAAe,CAAC;AAI/D;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAkBrD,CAAC;AAEX,oDAAoD;AACpD,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAiB/C,CAAC;AAEX,yEAAyE;AACzE,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAiB9C,CAAC;AAIX;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,WAAW,EAAE,OAAO,CAiB7C,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,WAAW,EAAE,OAAO,CAiBlD,CAAC;AAEX;;;;GAI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BAAqB,EAAE,OAAO,CAAC;CAChC;AAED,uDAAuD;AACvD,MAAM,MAAM,eAAe,GACvB,mBAAmB,GACnB,mBAAmB,GACnB,wBAAwB,GACxB,sBAAsB,GACtB,aAAa,GACb,qBAAqB,GACrB,mBAAmB,GACnB,aAAa,GACb,gBAAgB,GAChB,kBAAkB,GAClB,kBAAkB,GAClB,YAAY,CAAC;AAEjB;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,yBAY/B,CAAC;AAEH,oEAAoE;AACpE,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,kBAAkB,GAAG,MAAM,CAE3E"}
|
package/dist/bridge/types.js
CHANGED
|
@@ -1,48 +1,175 @@
|
|
|
1
|
-
|
|
1
|
+
// ─── CCTP Domain IDs ───
|
|
2
|
+
/**
|
|
3
|
+
* CCTP V2 domain IDs — Circle's internal chain identifiers.
|
|
4
|
+
* Source: https://developers.circle.com/cctp/concepts/supported-chains-and-domains
|
|
5
|
+
* These are used in smart contract calls and the attestation API.
|
|
6
|
+
*/
|
|
2
7
|
export const CCTP_DOMAIN_IDS = {
|
|
3
8
|
ethereum: 0,
|
|
9
|
+
avalanche: 1,
|
|
4
10
|
optimism: 2,
|
|
5
11
|
arbitrum: 3,
|
|
12
|
+
solana: 5,
|
|
6
13
|
base: 6,
|
|
14
|
+
polygon: 7,
|
|
15
|
+
unichain: 10,
|
|
16
|
+
linea: 11,
|
|
17
|
+
codex: 12,
|
|
18
|
+
sonic: 13,
|
|
19
|
+
worldchain: 14,
|
|
20
|
+
sei: 16,
|
|
21
|
+
xdc: 18,
|
|
22
|
+
hyperevm: 19,
|
|
23
|
+
ink: 21,
|
|
24
|
+
plume: 22,
|
|
7
25
|
};
|
|
8
|
-
/** EVM chain IDs for supported bridge chains */
|
|
26
|
+
/** EVM chain IDs for all supported bridge chains */
|
|
9
27
|
export const BRIDGE_CHAIN_IDS = {
|
|
10
28
|
ethereum: 1,
|
|
29
|
+
avalanche: 43114,
|
|
11
30
|
optimism: 10,
|
|
12
31
|
arbitrum: 42161,
|
|
13
32
|
base: 8453,
|
|
33
|
+
polygon: 137,
|
|
34
|
+
unichain: 130,
|
|
35
|
+
linea: 59144,
|
|
36
|
+
codex: 81224, // Codex mainnet chain ID — verified at thirdweb.com/codex
|
|
37
|
+
sonic: 146,
|
|
38
|
+
worldchain: 480,
|
|
39
|
+
sei: 1329, // Sei EVM (Pacific-1 mainnet)
|
|
40
|
+
xdc: 50,
|
|
41
|
+
hyperevm: 999, // HyperLiquid EVM mainnet chain ID
|
|
42
|
+
ink: 57073,
|
|
43
|
+
plume: 98866, // Plume mainnet chain ID
|
|
44
|
+
};
|
|
45
|
+
/** Default public RPC URLs — replace with paid provider in production */
|
|
46
|
+
export const BRIDGE_RPC_URLS = {
|
|
47
|
+
ethereum: 'https://cloudflare-eth.com',
|
|
48
|
+
avalanche: 'https://api.avax.network/ext/bc/C/rpc',
|
|
49
|
+
optimism: 'https://mainnet.optimism.io',
|
|
50
|
+
arbitrum: 'https://arb1.arbitrum.io/rpc',
|
|
51
|
+
base: 'https://mainnet.base.org',
|
|
52
|
+
polygon: 'https://polygon-rpc.com',
|
|
53
|
+
unichain: 'https://mainnet.unichain.org',
|
|
54
|
+
linea: 'https://rpc.linea.build',
|
|
55
|
+
codex: 'https://rpc.codex.xyz',
|
|
56
|
+
sonic: 'https://rpc.soniclabs.com',
|
|
57
|
+
worldchain: 'https://worldchain-mainnet.g.alchemy.com/public',
|
|
58
|
+
sei: 'https://evm-rpc.sei-apis.com',
|
|
59
|
+
xdc: 'https://rpc.xinfin.network',
|
|
60
|
+
hyperevm: 'https://rpc.hyperliquid.xyz/evm',
|
|
61
|
+
ink: 'https://rpc-gel.inkonchain.com',
|
|
62
|
+
plume: 'https://rpc.plume.org',
|
|
14
63
|
};
|
|
15
64
|
// ─── CCTP V2 Contract Addresses ───
|
|
16
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* USDC contract addresses per chain — official Circle deployments.
|
|
67
|
+
* Source: https://developers.circle.com/stablecoins/usdc-contract-addresses
|
|
68
|
+
*/
|
|
17
69
|
export const USDC_CONTRACT = {
|
|
18
|
-
base: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
19
70
|
ethereum: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
71
|
+
avalanche: '0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E',
|
|
20
72
|
optimism: '0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85',
|
|
21
73
|
arbitrum: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
|
|
74
|
+
base: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
75
|
+
polygon: '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359',
|
|
76
|
+
unichain: '0x078D782b760474a361dDA0AF3839290b0EF57AD6',
|
|
77
|
+
linea: '0x176211869cA2b568f2A7D4EE941E073a821EE1ff',
|
|
78
|
+
codex: '0xd996633a415985DBd7D6D12f4A4343E31f5037cf',
|
|
79
|
+
sonic: '0x29219dd400f2Bf60E5a23d13Be72B486D4038894',
|
|
80
|
+
worldchain: '0x79A02482A880bCe3F13E09da970dC34dB4cD24D1',
|
|
81
|
+
sei: '0xe15fC38F6D8c56aF07bbCBe3BAf5708A2Bf42392',
|
|
82
|
+
xdc: '0xfA2958CB79b0491CC627c1557F441eF849Ca8eb1',
|
|
83
|
+
hyperevm: '0xb88339CB7199b77E23DB6E890353E22632Ba630f',
|
|
84
|
+
ink: '0x2D270e6886d130D724215A266106e6832161EAEd',
|
|
85
|
+
plume: '0x222365EF19F7947e5484218551B56bb3965Aa7aF',
|
|
22
86
|
};
|
|
23
87
|
/**
|
|
24
|
-
* CCTP V2 TokenMessengerV2 addresses
|
|
25
|
-
*
|
|
26
|
-
*
|
|
88
|
+
* CCTP V2 TokenMessengerV2 addresses — same address on all EVM chains.
|
|
89
|
+
* Source: https://developers.circle.com/cctp/references/contract-addresses
|
|
90
|
+
* Verified: 0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d (all chains)
|
|
27
91
|
*/
|
|
28
92
|
export const TOKEN_MESSENGER_V2 = {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
optimism: '
|
|
32
|
-
arbitrum: '
|
|
93
|
+
ethereum: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
94
|
+
avalanche: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
95
|
+
optimism: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
96
|
+
arbitrum: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
97
|
+
base: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
98
|
+
polygon: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
99
|
+
unichain: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
100
|
+
linea: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
101
|
+
codex: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
102
|
+
sonic: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
103
|
+
worldchain: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
104
|
+
sei: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
105
|
+
xdc: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
106
|
+
hyperevm: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
107
|
+
ink: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
108
|
+
plume: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
33
109
|
};
|
|
34
|
-
/**
|
|
110
|
+
/**
|
|
111
|
+
* CCTP V2 MessageTransmitterV2 addresses — same address on all EVM chains.
|
|
112
|
+
* Source: https://developers.circle.com/cctp/references/contract-addresses
|
|
113
|
+
* Verified: 0x81D40F21F12A8F0E3252Bccb954D722d4c464B64 (all chains)
|
|
114
|
+
*/
|
|
35
115
|
export const MESSAGE_TRANSMITTER_V2 = {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
optimism: '
|
|
39
|
-
arbitrum: '
|
|
116
|
+
ethereum: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
117
|
+
avalanche: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
118
|
+
optimism: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
119
|
+
arbitrum: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
120
|
+
base: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
121
|
+
polygon: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
122
|
+
unichain: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
123
|
+
linea: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
124
|
+
codex: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
125
|
+
sonic: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
126
|
+
worldchain: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
127
|
+
sei: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
128
|
+
xdc: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
129
|
+
hyperevm: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
130
|
+
ink: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
131
|
+
plume: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
132
|
+
};
|
|
133
|
+
// ─── Solana CCTP V2 Program Addresses ───
|
|
134
|
+
/**
|
|
135
|
+
* Solana CCTP V2 program addresses (domain 5).
|
|
136
|
+
* Source: https://developers.circle.com/cctp/references/solana-programs
|
|
137
|
+
*/
|
|
138
|
+
export const SOLANA_CCTP_PROGRAMS = {
|
|
139
|
+
/** Handles incoming messages + mints USDC on Solana */
|
|
140
|
+
MESSAGE_TRANSMITTER_V2: 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC',
|
|
141
|
+
/** Handles burn + combined TokenMessenger + TokenMinter on Solana */
|
|
142
|
+
TOKEN_MESSENGER_MINTER_V2: 'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe',
|
|
40
143
|
};
|
|
144
|
+
/** Solana USDC mint address (mainnet) */
|
|
145
|
+
export const SOLANA_USDC_MINT = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v';
|
|
146
|
+
/** Solana CCTP domain ID */
|
|
147
|
+
export const SOLANA_CCTP_DOMAIN = 5;
|
|
148
|
+
// ─── Platform Fee ───
|
|
149
|
+
/**
|
|
150
|
+
* Platform bridge fee: 0.1% (10 basis points).
|
|
151
|
+
* Applied on source chain before bridging. Circle CCTP itself is feeless.
|
|
152
|
+
*/
|
|
153
|
+
export const PLATFORM_FEE_BPS = 10n; // 10 basis points = 0.1%
|
|
154
|
+
export const PLATFORM_FEE_DENOMINATOR = 10000n;
|
|
155
|
+
/**
|
|
156
|
+
* Calculate 0.1% platform fee for a given bridge amount.
|
|
157
|
+
* @param amount - USDC amount in base units (6 decimals)
|
|
158
|
+
*/
|
|
159
|
+
export function calcBridgeFee(amount) {
|
|
160
|
+
return (amount * PLATFORM_FEE_BPS) / PLATFORM_FEE_DENOMINATOR;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Calculate the actual bridged amount after platform fee deduction.
|
|
164
|
+
*/
|
|
165
|
+
export function calcAmountAfterFee(amount) {
|
|
166
|
+
return amount - calcBridgeFee(amount);
|
|
167
|
+
}
|
|
41
168
|
// ─── CCTP V2 Finality Thresholds ───
|
|
42
169
|
/**
|
|
43
170
|
* CCTP V2 minFinalityThreshold values.
|
|
44
|
-
* - FAST (0): ~
|
|
45
|
-
* - FINALIZED (1000): Full on-chain finality. Use for large amounts.
|
|
171
|
+
* - FAST (0): ~8–20 seconds. Circle fast attestation. Recommended for agents.
|
|
172
|
+
* - FINALIZED (1000): Full on-chain finality. Use for large amounts (>$10k).
|
|
46
173
|
*/
|
|
47
174
|
export const FINALITY_THRESHOLD = {
|
|
48
175
|
FAST: 0,
|
|
@@ -55,4 +182,26 @@ export const CIRCLE_ATTESTATION_API = 'https://iris-api.circle.com';
|
|
|
55
182
|
export const MAX_ATTESTATION_POLLS = 60;
|
|
56
183
|
/** Polling interval for attestation (milliseconds) */
|
|
57
184
|
export const ATTESTATION_POLL_INTERVAL_MS = 5000;
|
|
185
|
+
/**
|
|
186
|
+
* Chains that support CCTP V2 Fast Transfer (8–20 second attestation).
|
|
187
|
+
* Chains NOT listed here use Standard Transfer (up to ~15 min on Ethereum).
|
|
188
|
+
* Source: https://developers.circle.com/cctp/concepts/supported-chains-and-domains
|
|
189
|
+
*/
|
|
190
|
+
export const FAST_TRANSFER_CHAINS = new Set([
|
|
191
|
+
'ethereum',
|
|
192
|
+
'optimism',
|
|
193
|
+
'arbitrum',
|
|
194
|
+
'base',
|
|
195
|
+
'unichain',
|
|
196
|
+
'linea',
|
|
197
|
+
'codex',
|
|
198
|
+
'worldchain',
|
|
199
|
+
'ink',
|
|
200
|
+
'plume',
|
|
201
|
+
'solana',
|
|
202
|
+
]);
|
|
203
|
+
/** Get estimated bridge time in seconds for a given source chain */
|
|
204
|
+
export function getEstimatedBridgeSeconds(chain) {
|
|
205
|
+
return FAST_TRANSFER_CHAINS.has(chain) ? 20 : 900; // 20s fast / 15min standard
|
|
206
|
+
}
|
|
58
207
|
//# sourceMappingURL=types.js.map
|
package/dist/bridge/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/bridge/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/bridge/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AAC;AAED,sCAAsC;AAEtC;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,CAAC;IACP,SAAS,EAAE,IAAI;CACP,CAAC;AAEX,iCAAiC;AAEjC,2CAA2C;AAC3C,MAAM,CAAC,MAAM,sBAAsB,GAAG,6BAA6B,CAAC;AAEpE,sDAAsD;AACtD,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAExC,sDAAsD;AACtD,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAK,CAAC;AA8HlD;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAqB;IAC9D,UAAU;IACV,UAAU;IACV,UAAU;IACV,MAAM;IACN,UAAU;IACV,OAAO;IACP,OAAO;IACP,YAAY;IACZ,KAAK;IACL,OAAO;IACP,QAAQ;CACT,CAAC,CAAC;AAEH,oEAAoE;AACpE,MAAM,UAAU,yBAAyB,CAAC,KAAyB;IACjE,OAAO,oBAAoB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,4BAA4B;AACjF,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { WalletClient } from 'viem';
|
|
2
|
+
import type { Keypair } from '@solana/web3.js';
|
|
3
|
+
import { BridgeError } from './client.js';
|
|
4
|
+
import type { BridgeChain, BridgeResult } from './types.js';
|
|
5
|
+
import { type CCTPSupportedChain, type BridgeQuote, CCTP_DOMAIN_IDS, BRIDGE_CHAIN_IDS, BRIDGE_RPC_URLS, calcBridgeFee } from './types.js';
|
|
6
|
+
import { SolanaBridgeError } from '../solana/bridge.js';
|
|
7
|
+
export interface UnifiedBridgeConfig {
|
|
8
|
+
/** EVM wallet client (required for any EVM source chain) */
|
|
9
|
+
evmSigner?: WalletClient;
|
|
10
|
+
/** Solana keypair (required when Solana is source) */
|
|
11
|
+
solanaWallet?: Keypair;
|
|
12
|
+
/** Solana RPC URL (default: mainnet-beta public) */
|
|
13
|
+
solanaRpcUrl?: string;
|
|
14
|
+
/** Override EVM RPC URLs per chain */
|
|
15
|
+
evmRpcOverrides?: Partial<Record<BridgeChain, string>>;
|
|
16
|
+
/** Circle attestation API override */
|
|
17
|
+
attestationApiUrl?: string;
|
|
18
|
+
/** Platform fee wallet address (future: fee collection) */
|
|
19
|
+
feeWallet?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface UnifiedBridgeParams {
|
|
22
|
+
/** USDC amount in base units (6 decimals). 1 USDC = 1_000_000 */
|
|
23
|
+
amount: bigint;
|
|
24
|
+
/** Source chain */
|
|
25
|
+
sourceChain: CCTPSupportedChain;
|
|
26
|
+
/** Destination chain */
|
|
27
|
+
destinationChain: CCTPSupportedChain;
|
|
28
|
+
/** Recipient address (hex for EVM, base58 for Solana destination) */
|
|
29
|
+
destinationAddress: string;
|
|
30
|
+
/** Finality: 0 = fast (~20s), 1000 = finalized (~15min) */
|
|
31
|
+
minFinalityThreshold?: number;
|
|
32
|
+
/** Apply 0.1% platform fee (default: true) */
|
|
33
|
+
applyPlatformFee?: boolean;
|
|
34
|
+
/** Override destination RPC URL */
|
|
35
|
+
destinationRpcUrl?: string;
|
|
36
|
+
}
|
|
37
|
+
export type { BridgeResult, BridgeQuote, CCTPSupportedChain };
|
|
38
|
+
/**
|
|
39
|
+
* UnifiedBridge — Cross-chain USDC bridge across all 17 CCTP V2 supported chains.
|
|
40
|
+
*
|
|
41
|
+
* Routing:
|
|
42
|
+
* - EVM → EVM: BridgeModule (approve → burn → attest → mint)
|
|
43
|
+
* - EVM → Solana: BridgeModule burn + SolanaCCTPBridge receive
|
|
44
|
+
* - Solana → EVM: SolanaCCTPBridge burn + EVM receiveMessage
|
|
45
|
+
* - Solana → Solana: throws (use native Solana transfer instead)
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* import { UnifiedBridge } from 'agentwallet-sdk';
|
|
50
|
+
* import { createWalletClient } from 'viem';
|
|
51
|
+
*
|
|
52
|
+
* const bridge = new UnifiedBridge({ evmSigner });
|
|
53
|
+
*
|
|
54
|
+
* // Bridge 1 USDC from Base to Polygon
|
|
55
|
+
* const result = await bridge.bridge({
|
|
56
|
+
* amount: 1_000_000n,
|
|
57
|
+
* sourceChain: 'base',
|
|
58
|
+
* destinationChain: 'polygon',
|
|
59
|
+
* destinationAddress: '0x...',
|
|
60
|
+
* });
|
|
61
|
+
* console.log(bridge.getSupportedChains()); // 17 chains!
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare class UnifiedBridge {
|
|
65
|
+
private readonly config;
|
|
66
|
+
private readonly solanaConnection;
|
|
67
|
+
constructor(config?: UnifiedBridgeConfig);
|
|
68
|
+
/**
|
|
69
|
+
* Bridge USDC between any two CCTP V2 supported chains.
|
|
70
|
+
* Routes automatically based on source/destination chain types.
|
|
71
|
+
*/
|
|
72
|
+
bridge(params: UnifiedBridgeParams): Promise<BridgeResult>;
|
|
73
|
+
/**
|
|
74
|
+
* Get all supported chains (16 EVM + Solana = 17 total).
|
|
75
|
+
*/
|
|
76
|
+
getSupportedChains(): CCTPSupportedChain[];
|
|
77
|
+
/**
|
|
78
|
+
* Get a bridge quote: fee breakdown + estimated time.
|
|
79
|
+
*/
|
|
80
|
+
getQuote(params: {
|
|
81
|
+
amount: bigint;
|
|
82
|
+
sourceChain: CCTPSupportedChain;
|
|
83
|
+
destinationChain: CCTPSupportedChain;
|
|
84
|
+
}): BridgeQuote;
|
|
85
|
+
/**
|
|
86
|
+
* Check if a route is supported.
|
|
87
|
+
*/
|
|
88
|
+
isRouteSupported(source: CCTPSupportedChain, destination: CCTPSupportedChain): boolean;
|
|
89
|
+
private bridgeEvmToEvm;
|
|
90
|
+
private bridgeSolanaToEvm;
|
|
91
|
+
private bridgeEvmToSolana;
|
|
92
|
+
private validateParams;
|
|
93
|
+
/**
|
|
94
|
+
* Convert a Solana base58 address to a 32-byte hex string for EVM mintRecipient.
|
|
95
|
+
* Per Circle docs: hex-encoded USDC token account address.
|
|
96
|
+
*/
|
|
97
|
+
private solanaAddressToHex;
|
|
98
|
+
}
|
|
99
|
+
export { BridgeError, SolanaBridgeError };
|
|
100
|
+
export { CCTP_DOMAIN_IDS, BRIDGE_CHAIN_IDS, BRIDGE_RPC_URLS, calcBridgeFee, };
|
|
101
|
+
//# sourceMappingURL=unified.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unified.d.ts","sourceRoot":"","sources":["../../src/bridge/unified.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAgB,WAAW,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,eAAe,EACf,gBAAgB,EAChB,eAAe,EAEf,aAAa,EAGd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAoB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAI1E,MAAM,WAAW,mBAAmB;IAClC,4DAA4D;IAC5D,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,sDAAsD;IACtD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,oDAAoD;IACpD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sCAAsC;IACtC,eAAe,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;IACvD,sCAAsC;IACtC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,2DAA2D;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,iEAAiE;IACjE,MAAM,E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