@circle-fin/app-kit 1.13.0 → 1.15.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/CHANGELOG.md +122 -0
- package/README.md +3 -3
- package/bridge.cjs +8388 -515
- package/bridge.d.cts +640 -61
- package/bridge.d.mts +640 -61
- package/bridge.d.ts +640 -61
- package/bridge.mjs +8389 -516
- package/chains.cjs +275 -15
- package/chains.d.cts +117 -2
- package/chains.d.mts +117 -2
- package/chains.d.ts +117 -2
- package/chains.mjs +275 -16
- package/context.d.cts +577 -57
- package/context.d.mts +577 -57
- package/context.d.ts +577 -57
- package/earn.cjs +973 -271
- package/earn.d.cts +577 -57
- package/earn.d.mts +577 -57
- package/earn.d.ts +577 -57
- package/earn.mjs +919 -221
- package/estimateBridge.cjs +8388 -518
- package/estimateBridge.d.cts +704 -82
- package/estimateBridge.d.mts +704 -82
- package/estimateBridge.d.ts +704 -82
- package/estimateBridge.mjs +8390 -520
- package/estimateSwap.cjs +982 -237
- package/estimateSwap.d.cts +577 -57
- package/estimateSwap.d.mts +577 -57
- package/estimateSwap.d.ts +577 -57
- package/estimateSwap.mjs +981 -237
- package/index.cjs +21401 -8522
- package/index.d.cts +6045 -2149
- package/index.d.mts +6045 -2149
- package/index.d.ts +6045 -2149
- package/index.mjs +21401 -8524
- package/package.json +17 -6
- package/server.cjs +10040 -0
- package/server.cjs.map +1 -0
- package/server.d.cts +2467 -0
- package/server.d.mts +2467 -0
- package/server.d.ts +2467 -0
- package/server.mjs +10028 -0
- package/server.mjs.map +1 -0
- package/swap.cjs +982 -237
- package/swap.d.cts +577 -57
- package/swap.d.mts +577 -57
- package/swap.d.ts +577 -57
- package/swap.mjs +981 -237
- package/unifiedBalance.cjs +20510 -7599
- package/unifiedBalance.d.cts +807 -201
- package/unifiedBalance.d.mts +807 -201
- package/unifiedBalance.d.ts +807 -201
- package/unifiedBalance.mjs +20513 -7603
package/estimateBridge.d.ts
CHANGED
|
@@ -167,6 +167,30 @@ interface BaseChainDefinition {
|
|
|
167
167
|
* ```
|
|
168
168
|
*/
|
|
169
169
|
kitContracts?: KitContracts;
|
|
170
|
+
/**
|
|
171
|
+
* Optional CCTPx configuration.
|
|
172
|
+
*
|
|
173
|
+
* @description When provided, the chain supports CCTPx (Cross-Chain Token Service).
|
|
174
|
+
* CCTPx is a service-level protocol layered on top of CCTP v2's message-passing layer
|
|
175
|
+
* that enables cross-chain transfers of registered tokens (Circle-issued or otherwise).
|
|
176
|
+
*
|
|
177
|
+
* The CCTS contract is deployed via CREATE3 so its address is deterministic and may
|
|
178
|
+
* be committed to chain config ahead of the on-chain deployment.
|
|
179
|
+
*
|
|
180
|
+
* Use the {@link isCCTPXSupported} type guard to check if a chain has CCTPx support
|
|
181
|
+
* before accessing this property.
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```typescript
|
|
185
|
+
* if (isCCTPXSupported(chain)) {
|
|
186
|
+
* console.log('CCTS address:', chain.cctpx.serviceAddress)
|
|
187
|
+
* }
|
|
188
|
+
* ```
|
|
189
|
+
*
|
|
190
|
+
* @see {@link CCTPXChainConfig} for the structure of CCTPx configuration.
|
|
191
|
+
* @see {@link isCCTPXSupported} for checking CCTPx support.
|
|
192
|
+
*/
|
|
193
|
+
cctpx?: CCTPXChainConfig;
|
|
170
194
|
/**
|
|
171
195
|
* Optional Gateway contract configuration for Gateway protocol support.
|
|
172
196
|
*
|
|
@@ -486,6 +510,34 @@ interface CCTPConfig {
|
|
|
486
510
|
destination: boolean;
|
|
487
511
|
};
|
|
488
512
|
}
|
|
513
|
+
/**
|
|
514
|
+
* Configuration for Circle's Cross-Chain Token Service (CCTS) — the CCTPx protocol.
|
|
515
|
+
*
|
|
516
|
+
* @category Types
|
|
517
|
+
*
|
|
518
|
+
* @description Contains the CCTS proxy contract address on a given chain. The CCTS
|
|
519
|
+
* contract is the service-level entry point for CCTPx cross-chain transfers of
|
|
520
|
+
* registered tokens (Circle-issued or otherwise). Addresses are deterministic via CREATE3
|
|
521
|
+
* and may be committed to chain config ahead of the on-chain deploy.
|
|
522
|
+
*
|
|
523
|
+
* @example
|
|
524
|
+
* ```typescript
|
|
525
|
+
* const cctpxConfig: CCTPXChainConfig = {
|
|
526
|
+
* serviceAddress: '0x1234567890abcdef1234567890abcdef12345678'
|
|
527
|
+
* }
|
|
528
|
+
* ```
|
|
529
|
+
*/
|
|
530
|
+
interface CCTPXChainConfig {
|
|
531
|
+
/**
|
|
532
|
+
* The CrossChainTokenService (CCTS) proxy contract address on this chain.
|
|
533
|
+
*
|
|
534
|
+
* @description Deterministic CREATE3 address. Used by the SDK as the `to` field
|
|
535
|
+
* when calling `crossChainTransfer` and `resolveTokenManager`.
|
|
536
|
+
*
|
|
537
|
+
* @example "0x1234567890abcdef1234567890abcdef12345678"
|
|
538
|
+
*/
|
|
539
|
+
serviceAddress: string;
|
|
540
|
+
}
|
|
489
541
|
/**
|
|
490
542
|
* Available kit contract types for enhanced chain functionality.
|
|
491
543
|
*
|
|
@@ -559,6 +611,19 @@ interface GatewayV1Contracts {
|
|
|
559
611
|
* @example "0xD05E7D2E7d30b92c5F17d7d0fC575fce231F1A48"
|
|
560
612
|
*/
|
|
561
613
|
depositForHandler?: string;
|
|
614
|
+
/**
|
|
615
|
+
* The address of the `GenericExecutor` contract.
|
|
616
|
+
*
|
|
617
|
+
* @description Optional. The contract that acts as `mintRecipient` and
|
|
618
|
+
* `destinationCaller` for the CCTP v2 prepaid FORWARD path. It receives the
|
|
619
|
+
* CCTP mint and calls {@link GatewayV1Contracts.depositForHandler} to
|
|
620
|
+
* complete the fast deposit into the {@link GatewayV1Contracts.wallet}.
|
|
621
|
+
* Present only on chains that are fast-deposit destinations; other Gateway
|
|
622
|
+
* chains omit it.
|
|
623
|
+
*
|
|
624
|
+
* @example "0xFa7be2f04F3Ad4ca969260729c6d45B5625984A7"
|
|
625
|
+
*/
|
|
626
|
+
genericExecutor?: string;
|
|
562
627
|
}
|
|
563
628
|
/**
|
|
564
629
|
* Versioned map of Gateway contract configurations.
|
|
@@ -679,9 +744,10 @@ declare enum Blockchain {
|
|
|
679
744
|
Algorand_Testnet = "Algorand_Testnet",
|
|
680
745
|
Aptos = "Aptos",
|
|
681
746
|
Aptos_Testnet = "Aptos_Testnet",
|
|
682
|
-
Arc_Testnet = "Arc_Testnet",
|
|
683
747
|
Arbitrum = "Arbitrum",
|
|
684
748
|
Arbitrum_Sepolia = "Arbitrum_Sepolia",
|
|
749
|
+
Arc = "Arc",
|
|
750
|
+
Arc_Testnet = "Arc_Testnet",
|
|
685
751
|
Avalanche = "Avalanche",
|
|
686
752
|
Avalanche_Fuji = "Avalanche_Fuji",
|
|
687
753
|
Base = "Base",
|
|
@@ -860,6 +926,7 @@ declare enum SwapChain {
|
|
|
860
926
|
XDC = "XDC",
|
|
861
927
|
HyperEVM = "HyperEVM",
|
|
862
928
|
Monad = "Monad",
|
|
929
|
+
Arc = "Arc",
|
|
863
930
|
Arc_Testnet = "Arc_Testnet"
|
|
864
931
|
}
|
|
865
932
|
/**
|
|
@@ -873,7 +940,7 @@ declare enum SwapChain {
|
|
|
873
940
|
* Use `isSwapSupportedChain()` for runtime validation.
|
|
874
941
|
*/
|
|
875
942
|
type SwapChainDefinition = ChainDefinition & {
|
|
876
|
-
chain: Blockchain.Ethereum | Blockchain.Base | Blockchain.Polygon | Blockchain.Solana | Blockchain.Arbitrum | Blockchain.Optimism | Blockchain.Avalanche | Blockchain.Linea | Blockchain.Ink | Blockchain.World_Chain | Blockchain.Unichain | Blockchain.Plume | Blockchain.Sei | Blockchain.Sonic | Blockchain.XDC | Blockchain.HyperEVM | Blockchain.Monad | Blockchain.Arc_Testnet;
|
|
943
|
+
chain: Blockchain.Ethereum | Blockchain.Base | Blockchain.Polygon | Blockchain.Solana | Blockchain.Arbitrum | Blockchain.Optimism | Blockchain.Avalanche | Blockchain.Linea | Blockchain.Ink | Blockchain.World_Chain | Blockchain.Unichain | Blockchain.Plume | Blockchain.Sei | Blockchain.Sonic | Blockchain.XDC | Blockchain.HyperEVM | Blockchain.Monad | Blockchain.Arc | Blockchain.Arc_Testnet;
|
|
877
944
|
};
|
|
878
945
|
/**
|
|
879
946
|
* Chain identifier accepted by swap operations.
|
|
@@ -934,6 +1001,7 @@ type SwapChainIdentifier = SwapChainDefinition | SwapChain | `${SwapChain}`;
|
|
|
934
1001
|
*/
|
|
935
1002
|
declare enum BridgeChain {
|
|
936
1003
|
Arbitrum = "Arbitrum",
|
|
1004
|
+
Arc = "Arc",
|
|
937
1005
|
Avalanche = "Avalanche",
|
|
938
1006
|
Base = "Base",
|
|
939
1007
|
Codex = "Codex",
|
|
@@ -1030,6 +1098,7 @@ type BridgeChainIdentifier = ChainDefinition | BridgeChain | `${BridgeChain}`;
|
|
|
1030
1098
|
* ```
|
|
1031
1099
|
*/
|
|
1032
1100
|
declare enum EarnChain {
|
|
1101
|
+
Arc = "Arc",
|
|
1033
1102
|
Arc_Testnet = "Arc_Testnet"
|
|
1034
1103
|
}
|
|
1035
1104
|
/**
|
|
@@ -1063,7 +1132,7 @@ type EarnChainIdentifier = EarnChainDefinition | EarnChain | `${EarnChain}`;
|
|
|
1063
1132
|
* console.log(EARN_BRIDGE_SOURCE_BLOCKCHAINS.join(', '))
|
|
1064
1133
|
* ```
|
|
1065
1134
|
*/
|
|
1066
|
-
declare const EARN_BRIDGE_SOURCE_BLOCKCHAINS: readonly [Blockchain.Arbitrum_Sepolia, Blockchain.Base_Sepolia, Blockchain.Ethereum_Sepolia];
|
|
1135
|
+
declare const EARN_BRIDGE_SOURCE_BLOCKCHAINS: readonly [Blockchain.Arbitrum, Blockchain.Arbitrum_Sepolia, Blockchain.Base, Blockchain.Base_Sepolia, Blockchain.Ethereum, Blockchain.Ethereum_Sepolia];
|
|
1067
1136
|
/**
|
|
1068
1137
|
* Blockchains supported as the source chain for cross-chain Earn deposits.
|
|
1069
1138
|
*
|
|
@@ -1103,13 +1172,13 @@ type EarnBridgeSourceChainIdentifier = EarnBridgeSourceChainDefinition | EarnBri
|
|
|
1103
1172
|
* console.log(EARN_BRIDGE_DESTINATION_BLOCKCHAINS.join(', '))
|
|
1104
1173
|
* ```
|
|
1105
1174
|
*/
|
|
1106
|
-
declare const EARN_BRIDGE_DESTINATION_BLOCKCHAINS: readonly [Blockchain.Arc_Testnet];
|
|
1175
|
+
declare const EARN_BRIDGE_DESTINATION_BLOCKCHAINS: readonly [Blockchain.Arc, Blockchain.Arc_Testnet];
|
|
1107
1176
|
/**
|
|
1108
1177
|
* Blockchains supported as the destination (vault) chain for cross-chain Earn
|
|
1109
1178
|
* deposits.
|
|
1110
1179
|
*
|
|
1111
1180
|
* Intentionally narrower than {@link EarnChain}: cross-chain deposits
|
|
1112
|
-
*
|
|
1181
|
+
* land on Arc (mainnet) or Arc Testnet.
|
|
1113
1182
|
*/
|
|
1114
1183
|
type EarnBridgeDestinationBlockchain = (typeof EARN_BRIDGE_DESTINATION_BLOCKCHAINS)[number];
|
|
1115
1184
|
/**
|
|
@@ -1122,13 +1191,13 @@ type EarnBridgeDestinationChainDefinition = ChainDefinition & {
|
|
|
1122
1191
|
};
|
|
1123
1192
|
/**
|
|
1124
1193
|
* Chain identifier accepted for the destination (vault) side of a cross-chain
|
|
1125
|
-
* Earn deposit. Constrains the destination to Arc Testnet.
|
|
1194
|
+
* Earn deposit. Constrains the destination to Arc or Arc Testnet.
|
|
1126
1195
|
*
|
|
1127
1196
|
* @example
|
|
1128
1197
|
* ```typescript
|
|
1129
1198
|
* import type { EarnBridgeDestinationChainIdentifier } from '@core/chains'
|
|
1130
1199
|
*
|
|
1131
|
-
* const destination: EarnBridgeDestinationChainIdentifier = '
|
|
1200
|
+
* const destination: EarnBridgeDestinationChainIdentifier = 'Arc'
|
|
1132
1201
|
* ```
|
|
1133
1202
|
*/
|
|
1134
1203
|
type EarnBridgeDestinationChainIdentifier = EarnBridgeDestinationChainDefinition | EarnBridgeDestinationBlockchain | `${EarnBridgeDestinationBlockchain}`;
|
|
@@ -2345,6 +2414,171 @@ interface CCTPActionMap {
|
|
|
2345
2414
|
readonly v2: CCTPv2ActionMap;
|
|
2346
2415
|
}
|
|
2347
2416
|
|
|
2417
|
+
/**
|
|
2418
|
+
* Action map for Circle's CCTPx protocol operations.
|
|
2419
|
+
*
|
|
2420
|
+
* Define the parameter schemas for CCTPx actions that enable cross-chain transfers
|
|
2421
|
+
* of registered tokens (Circle-issued or otherwise) through Circle's `CrossChainTokenService`
|
|
2422
|
+
* (CCTS) contract.
|
|
2423
|
+
*
|
|
2424
|
+
* @remarks
|
|
2425
|
+
* CCTPx is a service-level protocol layered on top of CCTP v2's message-passing layer.
|
|
2426
|
+
* The CCTS contract coordinates token locking/burning, fee collection, and cross-chain
|
|
2427
|
+
* message dispatch. The SDK obtains a signed fee quote from IRIS, then calls
|
|
2428
|
+
* `crossChainTransfer` on CCTS with the quote bytes verbatim and the native fee as
|
|
2429
|
+
* `msg.value`. The auto-relay flow handled by Circle's Orbit relayer (paid for via the
|
|
2430
|
+
* `FORWARD` fee component included in the signed quote) means no separate
|
|
2431
|
+
* `receiveMessage` step is required on the destination.
|
|
2432
|
+
*
|
|
2433
|
+
* USDC and EURC bridging continues to use CCTP v2 (`cctp.v2.*`) actions, not CCTPx.
|
|
2434
|
+
*
|
|
2435
|
+
* @example
|
|
2436
|
+
* ```typescript
|
|
2437
|
+
* import type { ActionPayload } from '@core/adapter'
|
|
2438
|
+
*
|
|
2439
|
+
* const transferParams: ActionPayload<'cctpx.crossChainTransfer'> = {
|
|
2440
|
+
* tokenId: '0xabc123...',
|
|
2441
|
+
* amount: 1_000_000n,
|
|
2442
|
+
* destinationDomain: 1,
|
|
2443
|
+
* destinationAddress: '0xRecipient',
|
|
2444
|
+
* destinationCaller: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2445
|
+
* minFinalityThreshold: 1000,
|
|
2446
|
+
* claim: { signedQuote: '0xdeadbeef...', refundAddress: '0xSenderEOA...' },
|
|
2447
|
+
* autoExecuteHookData: false,
|
|
2448
|
+
* hookData: '0x',
|
|
2449
|
+
* serviceAddress: '0xCCTSProxy...',
|
|
2450
|
+
* nativeFeeAmount: 100_000n,
|
|
2451
|
+
* fromChain,
|
|
2452
|
+
* }
|
|
2453
|
+
* ```
|
|
2454
|
+
*/
|
|
2455
|
+
interface CCTPXActionMap {
|
|
2456
|
+
/**
|
|
2457
|
+
* Initiate a CCTPx cross-chain transfer through the `CrossChainTokenService` contract.
|
|
2458
|
+
*
|
|
2459
|
+
* Encode and submit a `crossChainTransfer(...)` call to the CCTS proxy on the source
|
|
2460
|
+
* chain, passing the IRIS-signed fee quote bytes verbatim and the native fee as
|
|
2461
|
+
* `msg.value`. The contract emits CCTP v2's `MessageSent` event, which IRIS attests
|
|
2462
|
+
* to before Circle's Orbit relayer auto-executes the destination mint.
|
|
2463
|
+
*
|
|
2464
|
+
* @remarks
|
|
2465
|
+
* The caller (typically `CCTPXBridgingProvider`) is responsible for:
|
|
2466
|
+
* - Resolving `tokenId` and the per-chain `tokenAddress` from the IRIS token registry
|
|
2467
|
+
* - Approving the per-token `TokenManager` for `amount` before this call
|
|
2468
|
+
* - Fetching `claim.signedQuote` and computing `nativeFeeAmount` from IRIS
|
|
2469
|
+
*
|
|
2470
|
+
* This action only encodes and submits the on-chain call; it does not perform any
|
|
2471
|
+
* off-chain orchestration.
|
|
2472
|
+
*/
|
|
2473
|
+
crossChainTransfer: ActionParameters & {
|
|
2474
|
+
/**
|
|
2475
|
+
* The CCTPx tokenId for the asset being transferred.
|
|
2476
|
+
*
|
|
2477
|
+
* Provided as a 32-byte hex string assigned by CCTPx at registration time.
|
|
2478
|
+
* The same `tokenId` is used across all chains for a given token; per-chain
|
|
2479
|
+
* `tokenAddress` is resolved from the IRIS token registry separately.
|
|
2480
|
+
*/
|
|
2481
|
+
tokenId: string;
|
|
2482
|
+
/**
|
|
2483
|
+
* Amount of the token to transfer, in the token's smallest units.
|
|
2484
|
+
*/
|
|
2485
|
+
amount: bigint;
|
|
2486
|
+
/**
|
|
2487
|
+
* CCTP domain identifier of the destination chain.
|
|
2488
|
+
*
|
|
2489
|
+
* CCTPx reuses CCTP v2 domain numbering; pass `dstChain.cctp.domain`.
|
|
2490
|
+
*/
|
|
2491
|
+
destinationDomain: number;
|
|
2492
|
+
/**
|
|
2493
|
+
* Recipient address on the destination chain, encoded as bytes.
|
|
2494
|
+
*
|
|
2495
|
+
* For EVM destinations this is a 20-byte address encoded as a hex string.
|
|
2496
|
+
*/
|
|
2497
|
+
destinationAddress: string;
|
|
2498
|
+
/**
|
|
2499
|
+
* `bytes32` value restricting which address may execute on the destination.
|
|
2500
|
+
*
|
|
2501
|
+
* Omit (or pass the 32-byte zero hash) to allow permissionless relay — the
|
|
2502
|
+
* default for auto-relayed CCTPx transfers. When omitted, the handler
|
|
2503
|
+
* substitutes the zero hash.
|
|
2504
|
+
*
|
|
2505
|
+
* @defaultValue `ZERO_HASH` — permissionless relay
|
|
2506
|
+
*/
|
|
2507
|
+
destinationCaller?: string;
|
|
2508
|
+
/**
|
|
2509
|
+
* Minimum finality threshold for attestation eligibility.
|
|
2510
|
+
*
|
|
2511
|
+
* Use `1000` for FAST transfers (pre-finality) or `2000` for SLOW transfers
|
|
2512
|
+
* (full finality). For FAST, the `claim.signedQuote` must include a
|
|
2513
|
+
* `PRE_FINALITY` item; otherwise the on-chain call reverts.
|
|
2514
|
+
*/
|
|
2515
|
+
minFinalityThreshold: number;
|
|
2516
|
+
/**
|
|
2517
|
+
* The CCTS fee-quote claim — maps 1:1 to the on-chain
|
|
2518
|
+
* `IFeeManager.QuoteClaim` tuple.
|
|
2519
|
+
*
|
|
2520
|
+
* The contract requires a tuple here, not a flat bytes blob. Encoding the
|
|
2521
|
+
* signed quote without the tuple wrapper produces a different function
|
|
2522
|
+
* selector and the call will revert.
|
|
2523
|
+
*/
|
|
2524
|
+
claim: {
|
|
2525
|
+
/**
|
|
2526
|
+
* IRIS-signed fee quote bytes, passed verbatim to the contract.
|
|
2527
|
+
*
|
|
2528
|
+
* Obtained from `POST /v1/quote/cctpx/{tokenId}/{src}/{dst}`. Contains the
|
|
2529
|
+
* version-prefixed ABI-encoded `Quote` struct and Circle's signature; the
|
|
2530
|
+
* `FeeManager` contract validates the signature against the quote items.
|
|
2531
|
+
*/
|
|
2532
|
+
signedQuote: string;
|
|
2533
|
+
/**
|
|
2534
|
+
* Address that receives any native-fee refund from `FeeManager`.
|
|
2535
|
+
*
|
|
2536
|
+
* Forwarded verbatim to `FeeManager` for refund attribution. The contract
|
|
2537
|
+
* accepts `address(0)` (the zero address) to disable refunds, so omitting
|
|
2538
|
+
* this field is safe; the handler will substitute the zero address.
|
|
2539
|
+
*
|
|
2540
|
+
* @defaultValue `ZERO_ADDRESS` — refunds disabled
|
|
2541
|
+
*/
|
|
2542
|
+
refundAddress?: string;
|
|
2543
|
+
};
|
|
2544
|
+
/**
|
|
2545
|
+
* Whether the destination chain should auto-execute the hook data.
|
|
2546
|
+
*
|
|
2547
|
+
* For basic transfers this is `false`. Reserved for advanced integrations
|
|
2548
|
+
* that bundle a post-mint hook on the destination.
|
|
2549
|
+
*/
|
|
2550
|
+
autoExecuteHookData: boolean;
|
|
2551
|
+
/**
|
|
2552
|
+
* Optional hook data bytes passed through to the destination handler.
|
|
2553
|
+
*
|
|
2554
|
+
* Pass `'0x'` (empty bytes) for basic transfers.
|
|
2555
|
+
*/
|
|
2556
|
+
hookData: string;
|
|
2557
|
+
/**
|
|
2558
|
+
* The `CrossChainTokenService` proxy address on the source chain.
|
|
2559
|
+
*
|
|
2560
|
+
* Used as the transaction `to` field. Typically sourced from
|
|
2561
|
+
* `srcChain.cctpx.serviceAddress` — but is passed as an explicit parameter
|
|
2562
|
+
* so the action does not depend on chain-config narrowing at the call site.
|
|
2563
|
+
*/
|
|
2564
|
+
serviceAddress: string;
|
|
2565
|
+
/**
|
|
2566
|
+
* Native gas amount to send as `msg.value`.
|
|
2567
|
+
*
|
|
2568
|
+
* Must exactly equal `sum(quote.items[].amount)` when `feeToken` is the
|
|
2569
|
+
* native currency (the P0 default). The contract verifies the value against
|
|
2570
|
+
* the signed quote; do not over-send.
|
|
2571
|
+
*/
|
|
2572
|
+
nativeFeeAmount: bigint;
|
|
2573
|
+
/**
|
|
2574
|
+
* Source chain definition.
|
|
2575
|
+
*
|
|
2576
|
+
* Provides the adapter with chain context (chainId, RPC, etc.) for the call.
|
|
2577
|
+
*/
|
|
2578
|
+
fromChain: ChainDefinition;
|
|
2579
|
+
};
|
|
2580
|
+
}
|
|
2581
|
+
|
|
2348
2582
|
/**
|
|
2349
2583
|
* Permit signature standards for gasless token approvals.
|
|
2350
2584
|
*
|
|
@@ -3440,6 +3674,8 @@ interface NativeActionMap {
|
|
|
3440
3674
|
interface ActionMap {
|
|
3441
3675
|
/** CCTP-specific operations with automatic address resolution. */
|
|
3442
3676
|
readonly cctp: CCTPActionMap;
|
|
3677
|
+
/** CCTPx operations (CrossChainTokenService) for cross-chain transfers of registered tokens (Circle-issued or otherwise). */
|
|
3678
|
+
readonly cctpx: CCTPXActionMap;
|
|
3443
3679
|
/** Gateway Wallet operations, versioned (e.g. gateway.v1.deposit). */
|
|
3444
3680
|
readonly gateway: GatewayActionMap;
|
|
3445
3681
|
/** Native token operations (ETH, SOL, MATIC, etc.). */
|
|
@@ -4564,29 +4800,15 @@ interface TokenSymbolRegistry {
|
|
|
4564
4800
|
*/
|
|
4565
4801
|
type TokenSymbol = keyof TokenSymbolRegistry extends never ? string : LiteralUnion<Extract<keyof TokenSymbolRegistry, string>>;
|
|
4566
4802
|
/**
|
|
4567
|
-
*
|
|
4803
|
+
* Token selector accepted by adapters and the static
|
|
4804
|
+
* {@link TokenRegistry.resolve} method.
|
|
4568
4805
|
*
|
|
4569
4806
|
* @remarks
|
|
4570
|
-
*
|
|
4571
|
-
*
|
|
4572
|
-
*
|
|
4573
|
-
*
|
|
4574
|
-
* Using a symbol is preferred when the token is in the registry, as it
|
|
4575
|
-
* automatically resolves decimals and the correct chain address.
|
|
4576
|
-
*
|
|
4577
|
-
* @example
|
|
4578
|
-
* ```typescript
|
|
4579
|
-
* // By symbol (preferred for known tokens)
|
|
4580
|
-
* const selector1: TokenSelector = 'USDC'
|
|
4581
|
-
*
|
|
4582
|
-
* // By raw locator (for arbitrary tokens)
|
|
4583
|
-
* const selector2: TokenSelector = {
|
|
4584
|
-
* locator: '0x1234...',
|
|
4585
|
-
* decimals: 18,
|
|
4586
|
-
* }
|
|
4587
|
-
* ```
|
|
4807
|
+
* Keep this alias at adapter and registry boundaries so their accepted token
|
|
4808
|
+
* forms remain explicit even when other product surfaces define narrower
|
|
4809
|
+
* token inputs.
|
|
4588
4810
|
*/
|
|
4589
|
-
type
|
|
4811
|
+
type RegistryTokenSelector = TokenSymbol | RawTokenSelector;
|
|
4590
4812
|
/**
|
|
4591
4813
|
* The resolved token information after registry lookup.
|
|
4592
4814
|
*
|
|
@@ -4636,12 +4858,12 @@ interface TokenRegistry {
|
|
|
4636
4858
|
/**
|
|
4637
4859
|
* Resolve a token selector to concrete token information for a chain.
|
|
4638
4860
|
*
|
|
4639
|
-
* @param selector - The token to resolve
|
|
4861
|
+
* @param selector - The token to resolve. Accepts a symbol or raw locator.
|
|
4640
4862
|
* @param chainId - The chain identifier to resolve for.
|
|
4641
4863
|
* @returns The resolved token information.
|
|
4642
4864
|
* @throws When the token cannot be resolved (unknown symbol, missing decimals, etc.).
|
|
4643
4865
|
*/
|
|
4644
|
-
resolve(selector:
|
|
4866
|
+
resolve(selector: RegistryTokenSelector, chainId: ChainIdentifier): ResolvedToken;
|
|
4645
4867
|
/**
|
|
4646
4868
|
* Resolve a token by chain-specific locator (address/program ID).
|
|
4647
4869
|
*
|
|
@@ -5463,6 +5685,55 @@ TChainDefinition extends ChainDefinition = ChainDefinition> extends WalletContex
|
|
|
5463
5685
|
* Must be a valid address format for the specified blockchain.
|
|
5464
5686
|
*/
|
|
5465
5687
|
recipientAddress?: string;
|
|
5688
|
+
/**
|
|
5689
|
+
* Whether Circle's relayer submits the destination transaction.
|
|
5690
|
+
*
|
|
5691
|
+
* How an omitted value resolves, and whether an explicit `false` is accepted,
|
|
5692
|
+
* is provider-specific.
|
|
5693
|
+
*/
|
|
5694
|
+
useForwarder?: boolean;
|
|
5695
|
+
/**
|
|
5696
|
+
* Optional destination dApp deposit action for a fast cross-chain transfer.
|
|
5697
|
+
*
|
|
5698
|
+
* When set, the burned USDC is minted to Circle's GenericExecutor on the
|
|
5699
|
+
* destination chain, which calls the registered dApp (for example, a Gateway
|
|
5700
|
+
* `depositFor`) in the same relayed flow. Consumed by the CCTP v2 provider's
|
|
5701
|
+
* executor-deposit path; requires `useForwarder: true`.
|
|
5702
|
+
*
|
|
5703
|
+
* @see {@link BridgeDepositAction}
|
|
5704
|
+
*/
|
|
5705
|
+
deposit?: BridgeDepositAction;
|
|
5706
|
+
}
|
|
5707
|
+
/**
|
|
5708
|
+
* Destination dApp deposit action for a fast cross-chain transfer.
|
|
5709
|
+
*
|
|
5710
|
+
* When present on a bridge destination, the CCTP v2 provider routes the
|
|
5711
|
+
* transfer through Circle's GenericExecutor: the burned USDC is minted to the
|
|
5712
|
+
* executor on the destination chain, which then calls the registered dApp (for
|
|
5713
|
+
* example, a Gateway `depositFor`) in the same relayed flow. Encoded into
|
|
5714
|
+
* executor hookData via `buildDepositForGenericExecutorPayload`.
|
|
5715
|
+
*
|
|
5716
|
+
* @example
|
|
5717
|
+
* ```typescript
|
|
5718
|
+
* import type { BridgeDepositAction } from '@core/provider'
|
|
5719
|
+
*
|
|
5720
|
+
* const deposit: BridgeDepositAction = {
|
|
5721
|
+
* dappId: 'gateway_deposit',
|
|
5722
|
+
* params: ['0xTokenMessengerWithFees', '0xDepositAccount', 0n],
|
|
5723
|
+
* }
|
|
5724
|
+
* ```
|
|
5725
|
+
*/
|
|
5726
|
+
interface BridgeDepositAction {
|
|
5727
|
+
/**
|
|
5728
|
+
* Registered dApp identifier the GenericExecutor invokes on the destination
|
|
5729
|
+
* chain (for example, `'gateway_deposit'`).
|
|
5730
|
+
*/
|
|
5731
|
+
dappId: string;
|
|
5732
|
+
/**
|
|
5733
|
+
* Positional arguments for the dApp function, in ABI order. Dynamic amount
|
|
5734
|
+
* slots are filled in by the executor from the minted amount.
|
|
5735
|
+
*/
|
|
5736
|
+
params: readonly unknown[];
|
|
5466
5737
|
}
|
|
5467
5738
|
/**
|
|
5468
5739
|
* Parameters for executing a cross-chain bridge operation.
|
|
@@ -5473,17 +5744,70 @@ interface BridgeParams$1<TFromCapabilities extends AdapterCapabilities = Adapter
|
|
|
5473
5744
|
*
|
|
5474
5745
|
* @defaultValue ChainDefinition
|
|
5475
5746
|
*/
|
|
5476
|
-
TChainDefinition extends ChainDefinition = ChainDefinition
|
|
5747
|
+
TChainDefinition extends ChainDefinition = ChainDefinition,
|
|
5748
|
+
/**
|
|
5749
|
+
* The token type the provider accepts.
|
|
5750
|
+
*
|
|
5751
|
+
* @defaultValue 'USDC'
|
|
5752
|
+
*
|
|
5753
|
+
* @remarks
|
|
5754
|
+
* The default preserves the original USDC-only contract for consumers that
|
|
5755
|
+
* omit the token type. Providers that accept a different token type pass
|
|
5756
|
+
* `TToken` explicitly.
|
|
5757
|
+
*
|
|
5758
|
+
* @example
|
|
5759
|
+
* ```typescript
|
|
5760
|
+
* // Default — TToken resolves to 'USDC'
|
|
5761
|
+
* type DefaultParams = BridgeParams // params.token is typed as 'USDC'
|
|
5762
|
+
*
|
|
5763
|
+
* // Provider that identifies tokens by a hex string template literal
|
|
5764
|
+
* type HexTokenParams = BridgeParams<
|
|
5765
|
+
* AdapterCapabilities,
|
|
5766
|
+
* AdapterCapabilities,
|
|
5767
|
+
* ChainDefinition,
|
|
5768
|
+
* `0x${string}`
|
|
5769
|
+
* > // params.token is typed as `0x${string}`
|
|
5770
|
+
* ```
|
|
5771
|
+
*/
|
|
5772
|
+
TToken extends string = 'USDC'> {
|
|
5477
5773
|
/** The source adapter containing wallet and chain information */
|
|
5478
5774
|
source: WalletContext<TFromCapabilities, TChainDefinition>;
|
|
5479
5775
|
/** The destination adapter containing wallet and chain information */
|
|
5480
5776
|
destination: DestinationWalletContext<TToCapabilities, TChainDefinition>;
|
|
5481
5777
|
/** The amount to transfer (as a string to avoid precision issues) */
|
|
5482
5778
|
amount: string;
|
|
5483
|
-
/** The token to transfer (
|
|
5484
|
-
token:
|
|
5779
|
+
/** The token to transfer (provider-defined; defaults to `'USDC'`) */
|
|
5780
|
+
token: TToken;
|
|
5485
5781
|
/** Bridge configuration (e.g., fast burn settings) */
|
|
5486
5782
|
config: BridgeConfig;
|
|
5783
|
+
/**
|
|
5784
|
+
* Optional server-signed quote to reuse, typically the
|
|
5785
|
+
* {@link EstimateResult.quote} returned by an earlier `estimate` call.
|
|
5786
|
+
*
|
|
5787
|
+
* When present and still valid, a provider with a server-signed quote
|
|
5788
|
+
* model may reuse it instead of fetching a fresh quote, so the fee the
|
|
5789
|
+
* caller was quoted is the fee they pay. Providers decide when a reused
|
|
5790
|
+
* quote is still valid (e.g. freshness, fee token, speed); an unusable or
|
|
5791
|
+
* mismatched quote is ignored and a fresh one is fetched. Transfer
|
|
5792
|
+
* parameters are validated by the provider's on-chain contract, so a quote
|
|
5793
|
+
* reused for a different transfer is rejected there rather than silently.
|
|
5794
|
+
* Providers without a quote model ignore this field entirely, and do so
|
|
5795
|
+
* silently — nothing verifies that a quote reached the provider that issued
|
|
5796
|
+
* it, because the route is matched to a provider only after these
|
|
5797
|
+
* parameters are validated. A quote is meaningful only on the route that
|
|
5798
|
+
* produced it.
|
|
5799
|
+
*
|
|
5800
|
+
* Typed `unknown`: a caller reaches `bridge` through a provider-agnostic
|
|
5801
|
+
* surface, so this shared type names no provider's shape. It is public
|
|
5802
|
+
* input in any case, and is validated before any field is read — by the
|
|
5803
|
+
* provider that serves the route, or by the kit for routes it prices
|
|
5804
|
+
* itself. Treat it as opaque and pass it back unmodified.
|
|
5805
|
+
*
|
|
5806
|
+
* This is a `bridge` input. A quote is an output of `estimate`, not an
|
|
5807
|
+
* input to it — `estimate` always returns a freshly-priced quote, and a
|
|
5808
|
+
* provider may reject a quote passed to `estimate` rather than ignore it.
|
|
5809
|
+
*/
|
|
5810
|
+
quote?: unknown;
|
|
5487
5811
|
/**
|
|
5488
5812
|
* Optional invocation metadata for tracing and correlation.
|
|
5489
5813
|
*
|
|
@@ -5493,6 +5817,43 @@ TChainDefinition extends ChainDefinition = ChainDefinition> {
|
|
|
5493
5817
|
*/
|
|
5494
5818
|
invocationMeta?: InvocationMeta;
|
|
5495
5819
|
}
|
|
5820
|
+
/**
|
|
5821
|
+
* A non-fatal advisory surfaced on a {@link BridgeResult} or an
|
|
5822
|
+
* {@link EstimateResult}.
|
|
5823
|
+
*
|
|
5824
|
+
* Warnings report things the caller should know about that did not fail the
|
|
5825
|
+
* operation — for example a requested FAST transfer that was degraded to SLOW.
|
|
5826
|
+
* They are additive and optional: providers populate them when relevant and
|
|
5827
|
+
* leave `warnings` undefined otherwise, so consumers that ignore the field are
|
|
5828
|
+
* unaffected.
|
|
5829
|
+
*
|
|
5830
|
+
* The codes are shared across both results, so a check written against one
|
|
5831
|
+
* works against the other. A code is raised only where its condition can
|
|
5832
|
+
* arise, so an estimate reaches a subset of what a bridge does.
|
|
5833
|
+
*
|
|
5834
|
+
* @example
|
|
5835
|
+
* ```typescript
|
|
5836
|
+
* const downgrade = result.warnings?.find(w => w.code === 'SPEED_DOWNGRADED')
|
|
5837
|
+
* if (downgrade) {
|
|
5838
|
+
* // Inform the user that the requested FAST speed was not available.
|
|
5839
|
+
* showToast(`Transfer speed changed to ${String(downgrade.data?.['actual'])}`)
|
|
5840
|
+
* }
|
|
5841
|
+
* ```
|
|
5842
|
+
*/
|
|
5843
|
+
interface BridgeWarning {
|
|
5844
|
+
/**
|
|
5845
|
+
* Stable machine-readable warning code (e.g. `'SPEED_DOWNGRADED'`). Prefer
|
|
5846
|
+
* branching on this over `message`.
|
|
5847
|
+
*/
|
|
5848
|
+
code: string;
|
|
5849
|
+
/** Optional human-readable explanation for logging or display. */
|
|
5850
|
+
message?: string;
|
|
5851
|
+
/**
|
|
5852
|
+
* Optional structured context for the warning (e.g.
|
|
5853
|
+
* `{ requested: 'FAST', actual: 'SLOW' }`).
|
|
5854
|
+
*/
|
|
5855
|
+
data?: Record<string, unknown>;
|
|
5856
|
+
}
|
|
5496
5857
|
/**
|
|
5497
5858
|
* Cost estimation result for a cross-chain transfer operation.
|
|
5498
5859
|
*
|
|
@@ -5509,10 +5870,28 @@ TChainDefinition extends ChainDefinition = ChainDefinition> {
|
|
|
5509
5870
|
* console.log('Total gas fees:', estimate.gasFees.length)
|
|
5510
5871
|
* console.log('Protocol fees:', estimate.fees.length)
|
|
5511
5872
|
* ```
|
|
5873
|
+
*
|
|
5874
|
+
* @typeParam TToken - The symbol type of the estimated token. Defaults to
|
|
5875
|
+
* `'USDC'` for source compatibility. Provider-agnostic kit internals use
|
|
5876
|
+
* `string` explicitly.
|
|
5877
|
+
* @typeParam TFeeToken - The symbol type of the protocol/service fee token
|
|
5878
|
+
* (`fees[].token`). Defaults to `'USDC'` for source compatibility. The fee
|
|
5879
|
+
* token is independent of the transferred token — a wETH transfer may pay
|
|
5880
|
+
* its fee in native currency or USDC.
|
|
5881
|
+
* @typeParam TQuote - The shape of `quote`. Defaults to `unknown`, since a
|
|
5882
|
+
* result read across providers could carry any of their quote shapes; a
|
|
5883
|
+
* provider narrows it to the one it returns.
|
|
5512
5884
|
*/
|
|
5513
|
-
interface EstimateResult {
|
|
5514
|
-
/**
|
|
5515
|
-
|
|
5885
|
+
interface EstimateResult<TToken extends string = 'USDC', TFeeToken extends string = 'USDC', TQuote = unknown> {
|
|
5886
|
+
/**
|
|
5887
|
+
* The token being estimated.
|
|
5888
|
+
*
|
|
5889
|
+
* @remarks
|
|
5890
|
+
* `TToken` defaults to `'USDC'` to preserve source compatibility for
|
|
5891
|
+
* consumers that use the result type without an explicit generic. Kits that
|
|
5892
|
+
* route across providers use `EstimateResult<string, string>` internally.
|
|
5893
|
+
*/
|
|
5894
|
+
token: TToken;
|
|
5516
5895
|
/** The amount being transferred */
|
|
5517
5896
|
amount: string;
|
|
5518
5897
|
/** Information about the source chain and address */
|
|
@@ -5548,13 +5927,64 @@ interface EstimateResult {
|
|
|
5548
5927
|
fees: {
|
|
5549
5928
|
/** The type of fee - from the bridge kit, provider (CCTP), or forwarder (Circle Orbit relayer) */
|
|
5550
5929
|
type: 'kit' | 'provider' | 'forwarder';
|
|
5551
|
-
/**
|
|
5552
|
-
|
|
5930
|
+
/**
|
|
5931
|
+
* The token symbol in which the fee is charged. Legacy providers
|
|
5932
|
+
* populate this with `'USDC'`. Providers whose fee token is
|
|
5933
|
+
* server-chosen per quote populate this with a best-effort symbol
|
|
5934
|
+
* resolved by the provider (e.g. native currency symbol for the
|
|
5935
|
+
* source chain, `'USDC'` for the chain's USDC address, or the
|
|
5936
|
+
* raw address string as a fallback when the symbol is unknown).
|
|
5937
|
+
* A provider whose quote carries the canonical raw address exposes it
|
|
5938
|
+
* there; narrow `quote` to that provider's type to read it.
|
|
5939
|
+
*
|
|
5940
|
+
* The static type is the `TFeeToken` generic (defaults to `string`);
|
|
5941
|
+
* USDC-only providers narrow it to `'USDC'`.
|
|
5942
|
+
*/
|
|
5943
|
+
token: TFeeToken;
|
|
5553
5944
|
/** The fee amount (as a string to avoid precision issues) */
|
|
5554
5945
|
amount: string | null;
|
|
5555
5946
|
/** Optional error object if the estimate failed */
|
|
5556
5947
|
error?: unknown;
|
|
5557
5948
|
}[];
|
|
5949
|
+
/**
|
|
5950
|
+
* Optional server-signed quote.
|
|
5951
|
+
*
|
|
5952
|
+
* Carries what the provider received from its off-chain quote service,
|
|
5953
|
+
* for the caller to pass back to `bridge` and be charged the fee they
|
|
5954
|
+
* were quoted. Providers without a server-signed quote model (e.g. CCTP
|
|
5955
|
+
* v2 USDC bridges) leave this field undefined; the `fees[]` array is the
|
|
5956
|
+
* single source of fee data for those providers.
|
|
5957
|
+
*
|
|
5958
|
+
* Typed as the `TQuote` parameter, which defaults to `unknown`, because a
|
|
5959
|
+
* result read through a provider-agnostic surface could have come from any
|
|
5960
|
+
* of them. A provider narrows it to what it actually returns — raw signed
|
|
5961
|
+
* bytes for some, a metadata object for others — and any per-component fee
|
|
5962
|
+
* breakdown lives there; `fees[]` carries the single fee summary either way.
|
|
5963
|
+
* Narrow it to the issuing provider's type before reading a field.
|
|
5964
|
+
*/
|
|
5965
|
+
quote?: TQuote;
|
|
5966
|
+
/**
|
|
5967
|
+
* Optional non-fatal advisories about how this estimate was produced.
|
|
5968
|
+
*
|
|
5969
|
+
* An estimate can differ from what the caller asked for without failing —
|
|
5970
|
+
* the speed may be re-priced — and that difference leaves no positive trace
|
|
5971
|
+
* anywhere else in the result: it can only be inferred by comparing the
|
|
5972
|
+
* quote's fee items against the speed that was asked for, on a provider
|
|
5973
|
+
* whose quote exposes them. The codes are drawn
|
|
5974
|
+
* from the same set a bridge uses, so a consumer checks both results the same
|
|
5975
|
+
* way.
|
|
5976
|
+
*
|
|
5977
|
+
* @see {@link BridgeWarning}
|
|
5978
|
+
*
|
|
5979
|
+
* @example
|
|
5980
|
+
* ```typescript
|
|
5981
|
+
* const estimate = await kit.estimate(params)
|
|
5982
|
+
* const repriced = estimate.warnings?.some(
|
|
5983
|
+
* (w) => w.code === SPEED_DOWNGRADED_WARNING_CODE,
|
|
5984
|
+
* )
|
|
5985
|
+
* ```
|
|
5986
|
+
*/
|
|
5987
|
+
warnings?: BridgeWarning[];
|
|
5558
5988
|
}
|
|
5559
5989
|
/**
|
|
5560
5990
|
* Configuration options for customizing bridge behavior.
|
|
@@ -5656,6 +6086,14 @@ interface BridgeConfig {
|
|
|
5656
6086
|
* ```
|
|
5657
6087
|
*/
|
|
5658
6088
|
customFee?: CustomFee | undefined;
|
|
6089
|
+
/**
|
|
6090
|
+
* Which leg pays the protocol fee.
|
|
6091
|
+
*
|
|
6092
|
+
* `'source'` leaves the delivered amount unreduced; `'destination'` takes the
|
|
6093
|
+
* fee from it. Omit it to let the routed provider decide — a provider rejects
|
|
6094
|
+
* a value it cannot honour.
|
|
6095
|
+
*/
|
|
6096
|
+
feePayment?: 'source' | 'destination' | undefined;
|
|
5659
6097
|
}
|
|
5660
6098
|
/**
|
|
5661
6099
|
* Custom fee configuration charged by the integrator.
|
|
@@ -5852,22 +6290,83 @@ interface ForwarderDestination<TChainIdentifier extends ChainIdentifier$1 = Chai
|
|
|
5852
6290
|
*/
|
|
5853
6291
|
type BridgeDestination<TAdapterCapabilities extends AdapterCapabilities = AdapterCapabilities, TChainIdentifier extends ChainIdentifier$1 = ChainIdentifier$1> = ((AdapterContext<TAdapterCapabilities, TChainIdentifier> | BridgeDestinationWithAddress<TAdapterCapabilities, TChainIdentifier>) & {
|
|
5854
6292
|
/**
|
|
5855
|
-
* Enable Circle's
|
|
6293
|
+
* Enable Circle's relayer to submit the destination transaction.
|
|
5856
6294
|
*
|
|
5857
|
-
*
|
|
5858
|
-
*
|
|
5859
|
-
*
|
|
6295
|
+
* Where the relay fee is charged depends on the route and on
|
|
6296
|
+
* {@link BridgeConfig.feePayment}: it may be taken from the amount that
|
|
6297
|
+
* arrives, or priced into a quote the source transaction pays.
|
|
5860
6298
|
*
|
|
5861
|
-
*
|
|
6299
|
+
* Whether the option is required, optional, or refused depends on the
|
|
6300
|
+
* routed provider and the rest of the config.
|
|
5862
6301
|
*/
|
|
5863
6302
|
useForwarder?: boolean;
|
|
5864
6303
|
}) | ForwarderDestination<TChainIdentifier>;
|
|
5865
6304
|
|
|
6305
|
+
/**
|
|
6306
|
+
* Display symbols the provider recognizes as a convenience for callers.
|
|
6307
|
+
*
|
|
6308
|
+
* A consumer may pass one of these symbols instead of a raw bytes32 token
|
|
6309
|
+
* id; the provider resolves it to the symbol's canonical bytes32 id via
|
|
6310
|
+
* {@link KNOWN_TOKEN_IDS_BY_NETWORK} (a symbol can map to more than one
|
|
6311
|
+
* bridge, so the map pins the canonical one). This list does NOT gate
|
|
6312
|
+
* routability: any token the IRIS registry lists with deployments on both
|
|
6313
|
+
* endpoints routes when passed by its bytes32 id, whether listed here or
|
|
6314
|
+
* not.
|
|
6315
|
+
*
|
|
6316
|
+
* @example
|
|
6317
|
+
* ```typescript
|
|
6318
|
+
* for (const symbol of KNOWN_TOKEN_SYMBOLS) console.log(symbol)
|
|
6319
|
+
* ```
|
|
6320
|
+
*/
|
|
6321
|
+
declare const KNOWN_TOKEN_SYMBOLS: readonly ["cirBTC", "wETH", "EURC"];
|
|
6322
|
+
/**
|
|
6323
|
+
* A known token symbol. Derived from {@link KNOWN_TOKEN_SYMBOLS} so the
|
|
6324
|
+
* type and the runtime set never drift.
|
|
6325
|
+
*
|
|
6326
|
+
* @example
|
|
6327
|
+
* ```typescript
|
|
6328
|
+
* const sym: KnownTokenSymbol = 'cirBTC'
|
|
6329
|
+
* ```
|
|
6330
|
+
*/
|
|
6331
|
+
type KnownTokenSymbol = (typeof KNOWN_TOKEN_SYMBOLS)[number];
|
|
6332
|
+
|
|
6333
|
+
/**
|
|
6334
|
+
* CCTPx token identifier: a bytes32 hex string. Within one CrossChainTokenService
|
|
6335
|
+
* deployment it names the same registered token on every chain that deployment
|
|
6336
|
+
* spans, which is what makes a cross-chain transfer addressable by id alone. Passed verbatim to the
|
|
6337
|
+
* `CrossChainTokenService.crossChainTransfer` contract call and used as the
|
|
6338
|
+
* `tokenId` path segment on the IRIS fee-quote endpoint.
|
|
6339
|
+
*/
|
|
6340
|
+
type CCTPXTokenId = `0x${string}`;
|
|
6341
|
+
/**
|
|
6342
|
+
* A token value accepted by {@link CCTPXTokenId}-keyed route checks.
|
|
6343
|
+
*
|
|
6344
|
+
* The provider's `supportsRoute` accepts either a {@link KnownTokenSymbol},
|
|
6345
|
+
* which it resolves to a bytes32 id via the per-network map, or a
|
|
6346
|
+
* {@link CCTPXTokenId} passed directly. This union is the honest type of what
|
|
6347
|
+
* the route check accepts, so callers and JSDoc examples never need an `as`
|
|
6348
|
+
* cast to pass a symbol.
|
|
6349
|
+
*
|
|
6350
|
+
* @example
|
|
6351
|
+
* ```typescript
|
|
6352
|
+
* const bySymbol: CCTPXRouteToken = 'cirBTC'
|
|
6353
|
+
* const byId: CCTPXRouteToken =
|
|
6354
|
+
* '0x0000000000000000000000000000000000000000000000000000000063697254'
|
|
6355
|
+
* ```
|
|
6356
|
+
*/
|
|
6357
|
+
type CCTPXRouteToken = CCTPXTokenId | KnownTokenSymbol;
|
|
6358
|
+
|
|
5866
6359
|
/**
|
|
5867
6360
|
* The expiry window of a signed quote.
|
|
5868
6361
|
*
|
|
5869
6362
|
* A signed quote is short-lived; refresh it immediately before submitting
|
|
5870
6363
|
* on-chain rather than caching it.
|
|
6364
|
+
*
|
|
6365
|
+
* The API uses different field names depending on `mode`:
|
|
6366
|
+
* - `TIMESTAMP` → `expiresAt` (unix seconds)
|
|
6367
|
+
* - `BLOCK_NUMBER` → `expiresAtBlock` (source-chain block number)
|
|
6368
|
+
*
|
|
6369
|
+
* @internal
|
|
5871
6370
|
*/
|
|
5872
6371
|
type FeeQuoteExpiry = {
|
|
5873
6372
|
/** Identify an exact Unix timestamp expiry. */
|
|
@@ -5884,13 +6383,28 @@ type FeeQuoteExpiry = {
|
|
|
5884
6383
|
};
|
|
5885
6384
|
|
|
5886
6385
|
/**
|
|
5887
|
-
*
|
|
6386
|
+
* Token string accepted by `bridge` / `estimate`.
|
|
6387
|
+
*
|
|
6388
|
+
* Use `'USDC'` for CCTP v2, a known CCTPx symbol (`'cirBTC'`, `'wETH'`,
|
|
6389
|
+
* `'EURC'`), or a 32-byte hex CCTPx token id.
|
|
6390
|
+
*
|
|
6391
|
+
* @example
|
|
6392
|
+
* ```typescript
|
|
6393
|
+
* import type { BridgeToken } from '@circle-fin/bridge-kit'
|
|
6394
|
+
*
|
|
6395
|
+
* const usdc: BridgeToken = 'USDC'
|
|
6396
|
+
* const eurc: BridgeToken = 'EURC'
|
|
6397
|
+
* const tokenId: BridgeToken =
|
|
6398
|
+
* '0x0000000000000000000000000000000000000000000000000000000063697254'
|
|
6399
|
+
* ```
|
|
6400
|
+
*/
|
|
6401
|
+
type BridgeToken = 'USDC' | CCTPXRouteToken;
|
|
6402
|
+
/**
|
|
6403
|
+
* Configuration accepted by `bridge` and `estimate`.
|
|
5888
6404
|
*
|
|
5889
6405
|
* @remarks
|
|
5890
|
-
*
|
|
5891
|
-
*
|
|
5892
|
-
* in source-chain USDC, and leaves the destination mint unreduced. Omit the
|
|
5893
|
-
* option (or use `'destination'`) to preserve the existing max-fee behavior.
|
|
6406
|
+
* The kit's name for {@link BridgeConfig}, kept as the parameter type so a
|
|
6407
|
+
* kit-only option can be added here without touching the provider-facing config.
|
|
5894
6408
|
*
|
|
5895
6409
|
* @example
|
|
5896
6410
|
* ```typescript
|
|
@@ -5903,10 +6417,7 @@ type FeeQuoteExpiry = {
|
|
|
5903
6417
|
* ```
|
|
5904
6418
|
* @since 1.14.0
|
|
5905
6419
|
*/
|
|
5906
|
-
|
|
5907
|
-
/** Select source-side signed fees or the legacy destination-side fee path. */
|
|
5908
|
-
feePayment?: 'source' | 'destination';
|
|
5909
|
-
}
|
|
6420
|
+
type BridgeExecutionConfig = BridgeConfig;
|
|
5910
6421
|
/**
|
|
5911
6422
|
* Describe one signed Fee Service line item in human-readable USDC.
|
|
5912
6423
|
*
|
|
@@ -5977,25 +6488,6 @@ interface ReceiveExactEstimateResult extends EstimateResult {
|
|
|
5977
6488
|
/** Opaque signed quote bytes to pass to {@link BridgeKit.bridge}. */
|
|
5978
6489
|
readonly quote: string;
|
|
5979
6490
|
}
|
|
5980
|
-
/**
|
|
5981
|
-
* Result returned by {@link BridgeKit.estimate} for legacy and source-fee modes.
|
|
5982
|
-
*
|
|
5983
|
-
* @example
|
|
5984
|
-
* ```typescript
|
|
5985
|
-
* import {
|
|
5986
|
-
* BridgeKit,
|
|
5987
|
-
* type BridgeEstimateResult,
|
|
5988
|
-
* type BridgeParams,
|
|
5989
|
-
* } from '@circle-fin/bridge-kit'
|
|
5990
|
-
*
|
|
5991
|
-
* declare const params: BridgeParams
|
|
5992
|
-
* const kit = new BridgeKit()
|
|
5993
|
-
* const result: BridgeEstimateResult = await kit.estimate(params)
|
|
5994
|
-
* if ('amountReceived' in result) console.log(result.totalDebit)
|
|
5995
|
-
* ```
|
|
5996
|
-
* @since 1.14.0
|
|
5997
|
-
*/
|
|
5998
|
-
type BridgeEstimateResult = EstimateResult | ReceiveExactEstimateResult;
|
|
5999
6491
|
type FeeFunction<TFromAdapterCapabilities extends AdapterCapabilities, TToAdapterCapabilities extends AdapterCapabilities> = (params: BridgeParams$1<TFromAdapterCapabilities, TToAdapterCapabilities>) => Promise<string> | string;
|
|
6000
6492
|
type FeeRecipientFunction<TFromAdapterCapabilities extends AdapterCapabilities, TToAdapterCapabilities extends AdapterCapabilities> = (feePayoutChain: ChainDefinition, params: BridgeParams$1<TFromAdapterCapabilities, TToAdapterCapabilities>) => Promise<string> | string;
|
|
6001
6493
|
/**
|
|
@@ -6013,6 +6505,13 @@ type FeeRecipientFunction<TFromAdapterCapabilities extends AdapterCapabilities,
|
|
|
6013
6505
|
* Use `computeFee` (recommended) for human-readable amounts, or `calculateFee` (deprecated)
|
|
6014
6506
|
* for smallest-unit amounts. Only one should be provided.
|
|
6015
6507
|
*
|
|
6508
|
+
* **USDC only.** Because the fee is collected on top of the transfer amount and
|
|
6509
|
+
* split through CCTPv2's USDC flow, this policy cannot apply to any other token.
|
|
6510
|
+
* Bridging a non-USDC token (for example CCTPx `cirBTC` or `wETH`)
|
|
6511
|
+
* is rejected with `INPUT_VALIDATION_FAILED` before anything is submitted —
|
|
6512
|
+
* on `bridge` and `estimate` alike — rather than proceeding without the fee.
|
|
6513
|
+
* A per-call `config.customFee` is rejected the same way.
|
|
6514
|
+
*
|
|
6016
6515
|
* @example
|
|
6017
6516
|
* ```typescript
|
|
6018
6517
|
* import type { CustomFeePolicy, BridgeParams } from '@circle-fin/bridge-kit'
|
|
@@ -6090,7 +6589,8 @@ type CustomFeePolicy$2 = {
|
|
|
6090
6589
|
* - The `from` field specifies the source adapter context (wallet and chain).
|
|
6091
6590
|
* - The `to` field specifies the destination, supporting both explicit and derived recipient addresses.
|
|
6092
6591
|
* - The `config` field allows customization of bridge behavior (e.g., transfer speed).
|
|
6093
|
-
* - The `token` field is optional and defaults to 'USDC'
|
|
6592
|
+
* - The `token` field is optional and defaults to `'USDC'`. It accepts
|
|
6593
|
+
* `'USDC'`, a known CCTPx symbol, or a bytes32 CCTPx token id.
|
|
6094
6594
|
*
|
|
6095
6595
|
* @typeParam TFromAdapterCapabilities - The source adapter capabilities type.
|
|
6096
6596
|
* @typeParam TToAdapterCapabilities - The destination adapter capabilities type.
|
|
@@ -6158,10 +6658,29 @@ interface BridgeParams<TFromAdapterCapabilities extends AdapterCapabilities = Ad
|
|
|
6158
6658
|
*/
|
|
6159
6659
|
config?: BridgeExecutionConfig;
|
|
6160
6660
|
/**
|
|
6161
|
-
* The token to transfer. Defaults to 'USDC'
|
|
6162
|
-
*
|
|
6661
|
+
* The token to transfer. Defaults to `'USDC'`.
|
|
6662
|
+
*
|
|
6663
|
+
* A known symbol is a convenience for a canonical CCTPx registration. A
|
|
6664
|
+
* symbol that maps to more than one bridge resolves to the registration
|
|
6665
|
+
* pinned by the provider. Pass the bridge's bytes32 token id directly when
|
|
6666
|
+
* an exact registration is required.
|
|
6667
|
+
*
|
|
6668
|
+
* If omitted, defaults to `'USDC'`.
|
|
6669
|
+
*
|
|
6670
|
+
* @example
|
|
6671
|
+
* ```typescript
|
|
6672
|
+
* // USDC via CCTPv2 (default)
|
|
6673
|
+
* const usdc: BridgeParams['token'] = 'USDC'
|
|
6674
|
+
*
|
|
6675
|
+
* // CCTPx by bare symbol — resolves via the known-symbol map
|
|
6676
|
+
* const bare: BridgeParams['token'] = 'wETH'
|
|
6677
|
+
*
|
|
6678
|
+
* // CCTPx by bytes32 token id
|
|
6679
|
+
* const explicit: BridgeParams['token'] =
|
|
6680
|
+
* '0x0000000000000000000000000000000000000000000000000000000063697254'
|
|
6681
|
+
* ```
|
|
6163
6682
|
*/
|
|
6164
|
-
token?:
|
|
6683
|
+
token?: BridgeToken;
|
|
6165
6684
|
/**
|
|
6166
6685
|
* Optional invocation metadata for tracing and correlation.
|
|
6167
6686
|
*
|
|
@@ -6184,15 +6703,68 @@ interface BridgeParams<TFromAdapterCapabilities extends AdapterCapabilities = Ad
|
|
|
6184
6703
|
*/
|
|
6185
6704
|
invocationMeta?: InvocationMeta;
|
|
6186
6705
|
/**
|
|
6187
|
-
*
|
|
6706
|
+
* Optional server-signed quote to reuse — pass the `quote` returned by an
|
|
6707
|
+
* earlier {@link BridgeKit.estimate | estimate} call straight back so the
|
|
6708
|
+
* fee you were quoted is the fee you pay.
|
|
6709
|
+
*
|
|
6710
|
+
* Treat the value as opaque, and never log or decode it. It belongs to
|
|
6711
|
+
* whichever provider issued it and carries that provider's own shape,
|
|
6712
|
+
* which is why it is typed `unknown` here: a route is matched to a
|
|
6713
|
+
* provider after these parameters are validated, so the kit cannot know
|
|
6714
|
+
* whose quote this is. The provider that serves the route validates it
|
|
6715
|
+
* before reading any field.
|
|
6716
|
+
*
|
|
6717
|
+
* An unusable quote is not handled the same way everywhere, so take the
|
|
6718
|
+
* value from an estimate result rather than constructing one:
|
|
6719
|
+
* - A provider with a reusable quote model (e.g. CCTPx) reuses it while it
|
|
6720
|
+
* is fresh and matches the requested fee token and speed; otherwise it
|
|
6721
|
+
* transparently fetches a fresh quote and flags a `QUOTE_NOT_REUSED`
|
|
6722
|
+
* result warning, so a stale quote is never worse than passing none.
|
|
6723
|
+
* - Receive-exact bridging (`config.feePayment: 'source'`) instead
|
|
6724
|
+
* **rejects** a quote that is invalid, mismatched, expired, or too close
|
|
6725
|
+
* to expiry, rather than repricing behind your back.
|
|
6726
|
+
* - Providers with no quote model (e.g. USDC via CCTP v2) ignore it —
|
|
6727
|
+
* **silently**. Route selection happens after these parameters are
|
|
6728
|
+
* validated, so the kit cannot tell whose quote this is, and nothing
|
|
6729
|
+
* checks that it reached the provider that issued it. In practice this
|
|
6730
|
+
* bites when the token changes between `estimate` and `bridge`: a quote
|
|
6731
|
+
* from a CCTPx token (`cirBTC`, `wETH`) passed to a plain USDC bridge is
|
|
6732
|
+
* dropped without an error or a warning, and the fee comes from CCTP v2
|
|
6733
|
+
* instead. Keeping the same token routes back to the same provider, so
|
|
6734
|
+
* the quote arrives. Re-estimate whenever the transfer changes.
|
|
6735
|
+
*
|
|
6736
|
+
* The transfer parameters (amount, recipient, chains) are validated
|
|
6737
|
+
* on-chain, so a quote reused for a different transfer is rejected by the
|
|
6738
|
+
* contract rather than silently — reuse a quote only for the transfer it
|
|
6739
|
+
* was estimated for.
|
|
6740
|
+
*
|
|
6741
|
+
* This field is for {@link BridgeKit.bridge | bridge} only. A quote is
|
|
6742
|
+
* produced by `estimate` and consumed by `bridge`, and `estimate` always
|
|
6743
|
+
* returns a freshly-priced one. Passing a quote back into `estimate` is a
|
|
6744
|
+
* usage error: CCTPx rejects it outright, while receive-exact ignores it and
|
|
6745
|
+
* prices afresh, so the quote you get back is never the one you sent. Take
|
|
6746
|
+
* the quote from the estimate result, not from your input.
|
|
6188
6747
|
*
|
|
6189
|
-
* @
|
|
6190
|
-
*
|
|
6191
|
-
*
|
|
6192
|
-
*
|
|
6193
|
-
*
|
|
6748
|
+
* @example
|
|
6749
|
+
* ```typescript
|
|
6750
|
+
* const estimate = await kit.estimate({
|
|
6751
|
+
* from: { adapter: sourceAdapter, chain: 'Ethereum' },
|
|
6752
|
+
* to: { adapter: destAdapter, chain: 'Base' },
|
|
6753
|
+
* amount: '100',
|
|
6754
|
+
* token: 'wETH',
|
|
6755
|
+
* })
|
|
6756
|
+
*
|
|
6757
|
+
* // Reuse the quoted fee for the bridge.
|
|
6758
|
+
* const result = await kit.bridge({
|
|
6759
|
+
* from: { adapter: sourceAdapter, chain: 'Ethereum' },
|
|
6760
|
+
* to: { adapter: destAdapter, chain: 'Base' },
|
|
6761
|
+
* amount: '100',
|
|
6762
|
+
* token: 'wETH',
|
|
6763
|
+
* quote: estimate.quote,
|
|
6764
|
+
* })
|
|
6765
|
+
* ```
|
|
6194
6766
|
*/
|
|
6195
|
-
quote?:
|
|
6767
|
+
quote?: unknown;
|
|
6196
6768
|
}
|
|
6197
6769
|
|
|
6198
6770
|
/**
|
|
@@ -7684,6 +8256,18 @@ interface AppKitContext {
|
|
|
7684
8256
|
chain: ChainDefinition;
|
|
7685
8257
|
params: OperationParamsMap[T];
|
|
7686
8258
|
}): Promise<string>;
|
|
8259
|
+
/**
|
|
8260
|
+
* Optional client-side configuration forwarded to the underlying
|
|
8261
|
+
* {@link createOnrampKit} factory when `kit.onramp` is accessed.
|
|
8262
|
+
*
|
|
8263
|
+
* @remarks
|
|
8264
|
+
* The onramp namespace on the client carries NO secret — the
|
|
8265
|
+
* long-lived `apiKey` lives exclusively on the server entry
|
|
8266
|
+
* (`@circle-fin/app-kit/server`). These options exist purely so
|
|
8267
|
+
* staging / SSR consumers can override the widget origin or
|
|
8268
|
+
* inject a host `Window`.
|
|
8269
|
+
*/
|
|
8270
|
+
onramp?: AppKitOnrampClientConfig | undefined;
|
|
7687
8271
|
/**
|
|
7688
8272
|
* Operation-scoped custom fee policies.
|
|
7689
8273
|
*
|
|
@@ -7755,6 +8339,35 @@ interface AppKitContext {
|
|
|
7755
8339
|
*/
|
|
7756
8340
|
headers?: Record<string, string>;
|
|
7757
8341
|
}
|
|
8342
|
+
/**
|
|
8343
|
+
* Client-side onramp configuration carried on {@link AppKitContext.onramp}.
|
|
8344
|
+
*
|
|
8345
|
+
* @remarks
|
|
8346
|
+
* No secret material lives here — the server-only `apiKey` is
|
|
8347
|
+
* configured on the matching `@circle-fin/app-kit/server` entry. Both
|
|
8348
|
+
* fields are optional with safe production defaults; the typical
|
|
8349
|
+
* application leaves them unset and instantiates `new AppKit()`.
|
|
8350
|
+
*/
|
|
8351
|
+
interface AppKitOnrampClientConfig {
|
|
8352
|
+
/**
|
|
8353
|
+
* Override the hosted widget origin. Defaults to the onramp-kit
|
|
8354
|
+
* production origin.
|
|
8355
|
+
*
|
|
8356
|
+
* @remarks
|
|
8357
|
+
* Override for staging environments only — production traffic
|
|
8358
|
+
* should always use the default.
|
|
8359
|
+
*/
|
|
8360
|
+
readonly widgetBaseUrl?: string | undefined;
|
|
8361
|
+
/**
|
|
8362
|
+
* Inject a host `Window` for testing or SSR-friendly bundles.
|
|
8363
|
+
*
|
|
8364
|
+
* @remarks
|
|
8365
|
+
* Production code leaves this unset and relies on the global
|
|
8366
|
+
* `window`. Exposed (not `@internal`) so SSR frameworks can
|
|
8367
|
+
* hand-feed the host window after hydration.
|
|
8368
|
+
*/
|
|
8369
|
+
readonly window?: Window | undefined;
|
|
8370
|
+
}
|
|
7758
8371
|
|
|
7759
8372
|
/**
|
|
7760
8373
|
* Estimate the costs and details of a cross-chain bridge transfer using the AppKit context.
|
|
@@ -7795,6 +8408,15 @@ interface AppKitContext {
|
|
|
7795
8408
|
* console.log('Estimated gas fees:', estimate.gasFees)
|
|
7796
8409
|
* ```
|
|
7797
8410
|
*/
|
|
7798
|
-
declare
|
|
8411
|
+
declare function estimateBridge(context: AppKitContext, params: Omit<BridgeParams, 'token'> & {
|
|
8412
|
+
token?: 'USDC';
|
|
8413
|
+
config: {
|
|
8414
|
+
feePayment: 'source';
|
|
8415
|
+
};
|
|
8416
|
+
}): Promise<ReceiveExactEstimateResult>;
|
|
8417
|
+
declare function estimateBridge(context: AppKitContext, params: Omit<BridgeParams, 'token'> & {
|
|
8418
|
+
token?: 'USDC';
|
|
8419
|
+
}): Promise<EstimateResult>;
|
|
8420
|
+
declare function estimateBridge(context: AppKitContext, params: BridgeParams): Promise<EstimateResult<string, string>>;
|
|
7799
8421
|
|
|
7800
8422
|
export { estimateBridge };
|