@circle-fin/app-kit 1.14.0 → 1.15.1
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 +72 -0
- package/README.md +3 -3
- package/bridge.cjs +7464 -454
- package/bridge.d.cts +585 -61
- package/bridge.d.mts +585 -61
- package/bridge.d.ts +585 -61
- package/bridge.mjs +7464 -454
- package/chains.cjs +146 -5
- package/chains.d.cts +108 -2
- package/chains.d.mts +108 -2
- package/chains.d.ts +108 -2
- package/chains.mjs +146 -6
- package/context.d.cts +522 -57
- package/context.d.mts +522 -57
- package/context.d.ts +522 -57
- package/earn.cjs +478 -181
- package/earn.d.cts +522 -57
- package/earn.d.mts +522 -57
- package/earn.d.ts +522 -57
- package/earn.mjs +478 -181
- package/estimateBridge.cjs +7464 -457
- package/estimateBridge.d.cts +643 -82
- package/estimateBridge.d.mts +643 -82
- package/estimateBridge.d.ts +643 -82
- package/estimateBridge.mjs +7464 -457
- package/estimateSwap.cjs +528 -185
- package/estimateSwap.d.cts +522 -57
- package/estimateSwap.d.mts +522 -57
- package/estimateSwap.d.ts +522 -57
- package/estimateSwap.mjs +528 -185
- package/index.cjs +11548 -2936
- package/index.d.cts +5073 -1738
- package/index.d.mts +5073 -1738
- package/index.d.ts +5073 -1738
- package/index.mjs +11547 -2937
- 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 +528 -185
- package/swap.d.cts +522 -57
- package/swap.d.mts +522 -57
- package/swap.d.ts +522 -57
- package/swap.mjs +528 -185
- package/unifiedBalance.cjs +742 -44
- package/unifiedBalance.d.cts +223 -1
- package/unifiedBalance.d.mts +223 -1
- package/unifiedBalance.d.ts +223 -1
- package/unifiedBalance.mjs +742 -44
package/bridge.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
|
*
|
|
@@ -692,9 +744,10 @@ declare enum Blockchain {
|
|
|
692
744
|
Algorand_Testnet = "Algorand_Testnet",
|
|
693
745
|
Aptos = "Aptos",
|
|
694
746
|
Aptos_Testnet = "Aptos_Testnet",
|
|
695
|
-
Arc_Testnet = "Arc_Testnet",
|
|
696
747
|
Arbitrum = "Arbitrum",
|
|
697
748
|
Arbitrum_Sepolia = "Arbitrum_Sepolia",
|
|
749
|
+
Arc = "Arc",
|
|
750
|
+
Arc_Testnet = "Arc_Testnet",
|
|
698
751
|
Avalanche = "Avalanche",
|
|
699
752
|
Avalanche_Fuji = "Avalanche_Fuji",
|
|
700
753
|
Base = "Base",
|
|
@@ -873,6 +926,7 @@ declare enum SwapChain {
|
|
|
873
926
|
XDC = "XDC",
|
|
874
927
|
HyperEVM = "HyperEVM",
|
|
875
928
|
Monad = "Monad",
|
|
929
|
+
Arc = "Arc",
|
|
876
930
|
Arc_Testnet = "Arc_Testnet"
|
|
877
931
|
}
|
|
878
932
|
/**
|
|
@@ -886,7 +940,7 @@ declare enum SwapChain {
|
|
|
886
940
|
* Use `isSwapSupportedChain()` for runtime validation.
|
|
887
941
|
*/
|
|
888
942
|
type SwapChainDefinition = ChainDefinition & {
|
|
889
|
-
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;
|
|
890
944
|
};
|
|
891
945
|
/**
|
|
892
946
|
* Chain identifier accepted by swap operations.
|
|
@@ -947,6 +1001,7 @@ type SwapChainIdentifier = SwapChainDefinition | SwapChain | `${SwapChain}`;
|
|
|
947
1001
|
*/
|
|
948
1002
|
declare enum BridgeChain {
|
|
949
1003
|
Arbitrum = "Arbitrum",
|
|
1004
|
+
Arc = "Arc",
|
|
950
1005
|
Avalanche = "Avalanche",
|
|
951
1006
|
Base = "Base",
|
|
952
1007
|
Codex = "Codex",
|
|
@@ -1043,6 +1098,7 @@ type BridgeChainIdentifier = ChainDefinition | BridgeChain | `${BridgeChain}`;
|
|
|
1043
1098
|
* ```
|
|
1044
1099
|
*/
|
|
1045
1100
|
declare enum EarnChain {
|
|
1101
|
+
Arc = "Arc",
|
|
1046
1102
|
Arc_Testnet = "Arc_Testnet"
|
|
1047
1103
|
}
|
|
1048
1104
|
/**
|
|
@@ -1076,7 +1132,7 @@ type EarnChainIdentifier = EarnChainDefinition | EarnChain | `${EarnChain}`;
|
|
|
1076
1132
|
* console.log(EARN_BRIDGE_SOURCE_BLOCKCHAINS.join(', '))
|
|
1077
1133
|
* ```
|
|
1078
1134
|
*/
|
|
1079
|
-
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];
|
|
1080
1136
|
/**
|
|
1081
1137
|
* Blockchains supported as the source chain for cross-chain Earn deposits.
|
|
1082
1138
|
*
|
|
@@ -1116,13 +1172,13 @@ type EarnBridgeSourceChainIdentifier = EarnBridgeSourceChainDefinition | EarnBri
|
|
|
1116
1172
|
* console.log(EARN_BRIDGE_DESTINATION_BLOCKCHAINS.join(', '))
|
|
1117
1173
|
* ```
|
|
1118
1174
|
*/
|
|
1119
|
-
declare const EARN_BRIDGE_DESTINATION_BLOCKCHAINS: readonly [Blockchain.Arc_Testnet];
|
|
1175
|
+
declare const EARN_BRIDGE_DESTINATION_BLOCKCHAINS: readonly [Blockchain.Arc, Blockchain.Arc_Testnet];
|
|
1120
1176
|
/**
|
|
1121
1177
|
* Blockchains supported as the destination (vault) chain for cross-chain Earn
|
|
1122
1178
|
* deposits.
|
|
1123
1179
|
*
|
|
1124
1180
|
* Intentionally narrower than {@link EarnChain}: cross-chain deposits
|
|
1125
|
-
*
|
|
1181
|
+
* land on Arc (mainnet) or Arc Testnet.
|
|
1126
1182
|
*/
|
|
1127
1183
|
type EarnBridgeDestinationBlockchain = (typeof EARN_BRIDGE_DESTINATION_BLOCKCHAINS)[number];
|
|
1128
1184
|
/**
|
|
@@ -1135,13 +1191,13 @@ type EarnBridgeDestinationChainDefinition = ChainDefinition & {
|
|
|
1135
1191
|
};
|
|
1136
1192
|
/**
|
|
1137
1193
|
* Chain identifier accepted for the destination (vault) side of a cross-chain
|
|
1138
|
-
* Earn deposit. Constrains the destination to Arc Testnet.
|
|
1194
|
+
* Earn deposit. Constrains the destination to Arc or Arc Testnet.
|
|
1139
1195
|
*
|
|
1140
1196
|
* @example
|
|
1141
1197
|
* ```typescript
|
|
1142
1198
|
* import type { EarnBridgeDestinationChainIdentifier } from '@core/chains'
|
|
1143
1199
|
*
|
|
1144
|
-
* const destination: EarnBridgeDestinationChainIdentifier = '
|
|
1200
|
+
* const destination: EarnBridgeDestinationChainIdentifier = 'Arc'
|
|
1145
1201
|
* ```
|
|
1146
1202
|
*/
|
|
1147
1203
|
type EarnBridgeDestinationChainIdentifier = EarnBridgeDestinationChainDefinition | EarnBridgeDestinationBlockchain | `${EarnBridgeDestinationBlockchain}`;
|
|
@@ -2358,6 +2414,171 @@ interface CCTPActionMap {
|
|
|
2358
2414
|
readonly v2: CCTPv2ActionMap;
|
|
2359
2415
|
}
|
|
2360
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
|
+
|
|
2361
2582
|
/**
|
|
2362
2583
|
* Permit signature standards for gasless token approvals.
|
|
2363
2584
|
*
|
|
@@ -3453,6 +3674,8 @@ interface NativeActionMap {
|
|
|
3453
3674
|
interface ActionMap {
|
|
3454
3675
|
/** CCTP-specific operations with automatic address resolution. */
|
|
3455
3676
|
readonly cctp: CCTPActionMap;
|
|
3677
|
+
/** CCTPx operations (CrossChainTokenService) for cross-chain transfers of registered tokens (Circle-issued or otherwise). */
|
|
3678
|
+
readonly cctpx: CCTPXActionMap;
|
|
3456
3679
|
/** Gateway Wallet operations, versioned (e.g. gateway.v1.deposit). */
|
|
3457
3680
|
readonly gateway: GatewayActionMap;
|
|
3458
3681
|
/** Native token operations (ETH, SOL, MATIC, etc.). */
|
|
@@ -4577,29 +4800,15 @@ interface TokenSymbolRegistry {
|
|
|
4577
4800
|
*/
|
|
4578
4801
|
type TokenSymbol = keyof TokenSymbolRegistry extends never ? string : LiteralUnion<Extract<keyof TokenSymbolRegistry, string>>;
|
|
4579
4802
|
/**
|
|
4580
|
-
*
|
|
4803
|
+
* Token selector accepted by adapters and the static
|
|
4804
|
+
* {@link TokenRegistry.resolve} method.
|
|
4581
4805
|
*
|
|
4582
4806
|
* @remarks
|
|
4583
|
-
*
|
|
4584
|
-
*
|
|
4585
|
-
*
|
|
4586
|
-
*
|
|
4587
|
-
* Using a symbol is preferred when the token is in the registry, as it
|
|
4588
|
-
* automatically resolves decimals and the correct chain address.
|
|
4589
|
-
*
|
|
4590
|
-
* @example
|
|
4591
|
-
* ```typescript
|
|
4592
|
-
* // By symbol (preferred for known tokens)
|
|
4593
|
-
* const selector1: TokenSelector = 'USDC'
|
|
4594
|
-
*
|
|
4595
|
-
* // By raw locator (for arbitrary tokens)
|
|
4596
|
-
* const selector2: TokenSelector = {
|
|
4597
|
-
* locator: '0x1234...',
|
|
4598
|
-
* decimals: 18,
|
|
4599
|
-
* }
|
|
4600
|
-
* ```
|
|
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.
|
|
4601
4810
|
*/
|
|
4602
|
-
type
|
|
4811
|
+
type RegistryTokenSelector = TokenSymbol | RawTokenSelector;
|
|
4603
4812
|
/**
|
|
4604
4813
|
* The resolved token information after registry lookup.
|
|
4605
4814
|
*
|
|
@@ -4649,12 +4858,12 @@ interface TokenRegistry {
|
|
|
4649
4858
|
/**
|
|
4650
4859
|
* Resolve a token selector to concrete token information for a chain.
|
|
4651
4860
|
*
|
|
4652
|
-
* @param selector - The token to resolve
|
|
4861
|
+
* @param selector - The token to resolve. Accepts a symbol or raw locator.
|
|
4653
4862
|
* @param chainId - The chain identifier to resolve for.
|
|
4654
4863
|
* @returns The resolved token information.
|
|
4655
4864
|
* @throws When the token cannot be resolved (unknown symbol, missing decimals, etc.).
|
|
4656
4865
|
*/
|
|
4657
|
-
resolve(selector:
|
|
4866
|
+
resolve(selector: RegistryTokenSelector, chainId: ChainIdentifier): ResolvedToken;
|
|
4658
4867
|
/**
|
|
4659
4868
|
* Resolve a token by chain-specific locator (address/program ID).
|
|
4660
4869
|
*
|
|
@@ -5476,6 +5685,13 @@ TChainDefinition extends ChainDefinition = ChainDefinition> extends WalletContex
|
|
|
5476
5685
|
* Must be a valid address format for the specified blockchain.
|
|
5477
5686
|
*/
|
|
5478
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;
|
|
5479
5695
|
/**
|
|
5480
5696
|
* Optional destination dApp deposit action for a fast cross-chain transfer.
|
|
5481
5697
|
*
|
|
@@ -5528,17 +5744,70 @@ interface BridgeParams$1<TFromCapabilities extends AdapterCapabilities = Adapter
|
|
|
5528
5744
|
*
|
|
5529
5745
|
* @defaultValue ChainDefinition
|
|
5530
5746
|
*/
|
|
5531
|
-
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'> {
|
|
5532
5773
|
/** The source adapter containing wallet and chain information */
|
|
5533
5774
|
source: WalletContext<TFromCapabilities, TChainDefinition>;
|
|
5534
5775
|
/** The destination adapter containing wallet and chain information */
|
|
5535
5776
|
destination: DestinationWalletContext<TToCapabilities, TChainDefinition>;
|
|
5536
5777
|
/** The amount to transfer (as a string to avoid precision issues) */
|
|
5537
5778
|
amount: string;
|
|
5538
|
-
/** The token to transfer (
|
|
5539
|
-
token:
|
|
5779
|
+
/** The token to transfer (provider-defined; defaults to `'USDC'`) */
|
|
5780
|
+
token: TToken;
|
|
5540
5781
|
/** Bridge configuration (e.g., fast burn settings) */
|
|
5541
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;
|
|
5542
5811
|
/**
|
|
5543
5812
|
* Optional invocation metadata for tracing and correlation.
|
|
5544
5813
|
*
|
|
@@ -5677,6 +5946,43 @@ interface BridgeStep {
|
|
|
5677
5946
|
*/
|
|
5678
5947
|
errorCategory?: BridgeStepErrorCategory;
|
|
5679
5948
|
}
|
|
5949
|
+
/**
|
|
5950
|
+
* A non-fatal advisory surfaced on a {@link BridgeResult} or an
|
|
5951
|
+
* {@link EstimateResult}.
|
|
5952
|
+
*
|
|
5953
|
+
* Warnings report things the caller should know about that did not fail the
|
|
5954
|
+
* operation — for example a requested FAST transfer that was degraded to SLOW.
|
|
5955
|
+
* They are additive and optional: providers populate them when relevant and
|
|
5956
|
+
* leave `warnings` undefined otherwise, so consumers that ignore the field are
|
|
5957
|
+
* unaffected.
|
|
5958
|
+
*
|
|
5959
|
+
* The codes are shared across both results, so a check written against one
|
|
5960
|
+
* works against the other. A code is raised only where its condition can
|
|
5961
|
+
* arise, so an estimate reaches a subset of what a bridge does.
|
|
5962
|
+
*
|
|
5963
|
+
* @example
|
|
5964
|
+
* ```typescript
|
|
5965
|
+
* const downgrade = result.warnings?.find(w => w.code === 'SPEED_DOWNGRADED')
|
|
5966
|
+
* if (downgrade) {
|
|
5967
|
+
* // Inform the user that the requested FAST speed was not available.
|
|
5968
|
+
* showToast(`Transfer speed changed to ${String(downgrade.data?.['actual'])}`)
|
|
5969
|
+
* }
|
|
5970
|
+
* ```
|
|
5971
|
+
*/
|
|
5972
|
+
interface BridgeWarning {
|
|
5973
|
+
/**
|
|
5974
|
+
* Stable machine-readable warning code (e.g. `'SPEED_DOWNGRADED'`). Prefer
|
|
5975
|
+
* branching on this over `message`.
|
|
5976
|
+
*/
|
|
5977
|
+
code: string;
|
|
5978
|
+
/** Optional human-readable explanation for logging or display. */
|
|
5979
|
+
message?: string;
|
|
5980
|
+
/**
|
|
5981
|
+
* Optional structured context for the warning (e.g.
|
|
5982
|
+
* `{ requested: 'FAST', actual: 'SLOW' }`).
|
|
5983
|
+
*/
|
|
5984
|
+
data?: Record<string, unknown>;
|
|
5985
|
+
}
|
|
5680
5986
|
/**
|
|
5681
5987
|
* Result object returned after a successful cross-chain bridge operation.
|
|
5682
5988
|
*
|
|
@@ -5691,11 +5997,24 @@ interface BridgeStep {
|
|
|
5691
5997
|
* console.log(`Steps executed: ${result.steps.length}`)
|
|
5692
5998
|
* ```
|
|
5693
5999
|
*/
|
|
5694
|
-
interface BridgeResult {
|
|
6000
|
+
interface BridgeResult<TToken extends string = 'USDC'> {
|
|
5695
6001
|
/** The amount that was transferred (as a string to avoid precision issues) */
|
|
5696
6002
|
amount: string;
|
|
5697
|
-
/**
|
|
5698
|
-
|
|
6003
|
+
/**
|
|
6004
|
+
* The token that was transferred.
|
|
6005
|
+
*
|
|
6006
|
+
* @remarks
|
|
6007
|
+
* `TToken` defaults to `'USDC'` to preserve source compatibility for
|
|
6008
|
+
* consumers that use the result type without an explicit generic. Kits that
|
|
6009
|
+
* route across providers use `BridgeResult<string>` internally.
|
|
6010
|
+
*
|
|
6011
|
+
* Provider implementations narrow this in their own subclass code
|
|
6012
|
+
* by passing a literal as the `TToken` generic — for example a
|
|
6013
|
+
* USDC-only provider declares `BridgeResult<'USDC'>`, and a
|
|
6014
|
+
* provider whose tokens are bytes32 identifiers declares the result
|
|
6015
|
+
* with a `0x`-prefixed template-literal string type.
|
|
6016
|
+
*/
|
|
6017
|
+
token: TToken;
|
|
5699
6018
|
/** The state of the transfer */
|
|
5700
6019
|
state: 'pending' | 'success' | 'error';
|
|
5701
6020
|
/** The bridge configuration that was used for this operation */
|
|
@@ -5733,6 +6052,12 @@ interface BridgeResult {
|
|
|
5733
6052
|
};
|
|
5734
6053
|
/** Array of steps that were executed during the bridge process */
|
|
5735
6054
|
steps: BridgeStep[];
|
|
6055
|
+
/**
|
|
6056
|
+
* Non-fatal advisories surfaced during the bridge (e.g. a FAST→SLOW speed
|
|
6057
|
+
* downgrade). Optional and additive — providers populate it when relevant
|
|
6058
|
+
* and leave it undefined otherwise. See {@link BridgeWarning}.
|
|
6059
|
+
*/
|
|
6060
|
+
warnings?: BridgeWarning[];
|
|
5736
6061
|
}
|
|
5737
6062
|
/**
|
|
5738
6063
|
* Configuration options for customizing bridge behavior.
|
|
@@ -5834,6 +6159,14 @@ interface BridgeConfig {
|
|
|
5834
6159
|
* ```
|
|
5835
6160
|
*/
|
|
5836
6161
|
customFee?: CustomFee | undefined;
|
|
6162
|
+
/**
|
|
6163
|
+
* Which leg pays the protocol fee.
|
|
6164
|
+
*
|
|
6165
|
+
* `'source'` leaves the delivered amount unreduced; `'destination'` takes the
|
|
6166
|
+
* fee from it. Omit it to let the routed provider decide — a provider rejects
|
|
6167
|
+
* a value it cannot honour.
|
|
6168
|
+
*/
|
|
6169
|
+
feePayment?: 'source' | 'destination' | undefined;
|
|
5837
6170
|
}
|
|
5838
6171
|
/**
|
|
5839
6172
|
* Custom fee configuration charged by the integrator.
|
|
@@ -6030,25 +6363,95 @@ interface ForwarderDestination<TChainIdentifier extends ChainIdentifier$1 = Chai
|
|
|
6030
6363
|
*/
|
|
6031
6364
|
type BridgeDestination<TAdapterCapabilities extends AdapterCapabilities = AdapterCapabilities, TChainIdentifier extends ChainIdentifier$1 = ChainIdentifier$1> = ((AdapterContext<TAdapterCapabilities, TChainIdentifier> | BridgeDestinationWithAddress<TAdapterCapabilities, TChainIdentifier>) & {
|
|
6032
6365
|
/**
|
|
6033
|
-
* Enable Circle's
|
|
6366
|
+
* Enable Circle's relayer to submit the destination transaction.
|
|
6034
6367
|
*
|
|
6035
|
-
*
|
|
6036
|
-
*
|
|
6037
|
-
*
|
|
6368
|
+
* Where the relay fee is charged depends on the route and on
|
|
6369
|
+
* {@link BridgeConfig.feePayment}: it may be taken from the amount that
|
|
6370
|
+
* arrives, or priced into a quote the source transaction pays.
|
|
6038
6371
|
*
|
|
6039
|
-
*
|
|
6372
|
+
* Whether the option is required, optional, or refused depends on the
|
|
6373
|
+
* routed provider and the rest of the config.
|
|
6040
6374
|
*/
|
|
6041
6375
|
useForwarder?: boolean;
|
|
6042
6376
|
}) | ForwarderDestination<TChainIdentifier>;
|
|
6043
6377
|
|
|
6044
6378
|
/**
|
|
6045
|
-
*
|
|
6379
|
+
* Display symbols the provider recognizes as a convenience for callers.
|
|
6380
|
+
*
|
|
6381
|
+
* A consumer may pass one of these symbols instead of a raw bytes32 token
|
|
6382
|
+
* id; the provider resolves it to the symbol's canonical bytes32 id via
|
|
6383
|
+
* {@link KNOWN_TOKEN_IDS_BY_NETWORK} (a symbol can map to more than one
|
|
6384
|
+
* bridge, so the map pins the canonical one). This list does NOT gate
|
|
6385
|
+
* routability: any token the IRIS registry lists with deployments on both
|
|
6386
|
+
* endpoints routes when passed by its bytes32 id, whether listed here or
|
|
6387
|
+
* not.
|
|
6388
|
+
*
|
|
6389
|
+
* @example
|
|
6390
|
+
* ```typescript
|
|
6391
|
+
* for (const symbol of KNOWN_TOKEN_SYMBOLS) console.log(symbol)
|
|
6392
|
+
* ```
|
|
6393
|
+
*/
|
|
6394
|
+
declare const KNOWN_TOKEN_SYMBOLS: readonly ["cirBTC", "wETH", "EURC"];
|
|
6395
|
+
/**
|
|
6396
|
+
* A known token symbol. Derived from {@link KNOWN_TOKEN_SYMBOLS} so the
|
|
6397
|
+
* type and the runtime set never drift.
|
|
6398
|
+
*
|
|
6399
|
+
* @example
|
|
6400
|
+
* ```typescript
|
|
6401
|
+
* const sym: KnownTokenSymbol = 'cirBTC'
|
|
6402
|
+
* ```
|
|
6403
|
+
*/
|
|
6404
|
+
type KnownTokenSymbol = (typeof KNOWN_TOKEN_SYMBOLS)[number];
|
|
6405
|
+
|
|
6406
|
+
/**
|
|
6407
|
+
* CCTPx token identifier: a bytes32 hex string. Within one CrossChainTokenService
|
|
6408
|
+
* deployment it names the same registered token on every chain that deployment
|
|
6409
|
+
* spans, which is what makes a cross-chain transfer addressable by id alone. Passed verbatim to the
|
|
6410
|
+
* `CrossChainTokenService.crossChainTransfer` contract call and used as the
|
|
6411
|
+
* `tokenId` path segment on the IRIS fee-quote endpoint.
|
|
6412
|
+
*/
|
|
6413
|
+
type CCTPXTokenId = `0x${string}`;
|
|
6414
|
+
/**
|
|
6415
|
+
* A token value accepted by {@link CCTPXTokenId}-keyed route checks.
|
|
6416
|
+
*
|
|
6417
|
+
* The provider's `supportsRoute` accepts either a {@link KnownTokenSymbol},
|
|
6418
|
+
* which it resolves to a bytes32 id via the per-network map, or a
|
|
6419
|
+
* {@link CCTPXTokenId} passed directly. This union is the honest type of what
|
|
6420
|
+
* the route check accepts, so callers and JSDoc examples never need an `as`
|
|
6421
|
+
* cast to pass a symbol.
|
|
6422
|
+
*
|
|
6423
|
+
* @example
|
|
6424
|
+
* ```typescript
|
|
6425
|
+
* const bySymbol: CCTPXRouteToken = 'cirBTC'
|
|
6426
|
+
* const byId: CCTPXRouteToken =
|
|
6427
|
+
* '0x0000000000000000000000000000000000000000000000000000000063697254'
|
|
6428
|
+
* ```
|
|
6429
|
+
*/
|
|
6430
|
+
type CCTPXRouteToken = CCTPXTokenId | KnownTokenSymbol;
|
|
6431
|
+
|
|
6432
|
+
/**
|
|
6433
|
+
* Token string accepted by `bridge` / `estimate`.
|
|
6434
|
+
*
|
|
6435
|
+
* Use `'USDC'` for CCTP v2, a known CCTPx symbol (`'cirBTC'`, `'wETH'`,
|
|
6436
|
+
* `'EURC'`), or a 32-byte hex CCTPx token id.
|
|
6437
|
+
*
|
|
6438
|
+
* @example
|
|
6439
|
+
* ```typescript
|
|
6440
|
+
* import type { BridgeToken } from '@circle-fin/bridge-kit'
|
|
6441
|
+
*
|
|
6442
|
+
* const usdc: BridgeToken = 'USDC'
|
|
6443
|
+
* const eurc: BridgeToken = 'EURC'
|
|
6444
|
+
* const tokenId: BridgeToken =
|
|
6445
|
+
* '0x0000000000000000000000000000000000000000000000000000000063697254'
|
|
6446
|
+
* ```
|
|
6447
|
+
*/
|
|
6448
|
+
type BridgeToken = 'USDC' | CCTPXRouteToken;
|
|
6449
|
+
/**
|
|
6450
|
+
* Configuration accepted by `bridge` and `estimate`.
|
|
6046
6451
|
*
|
|
6047
6452
|
* @remarks
|
|
6048
|
-
*
|
|
6049
|
-
*
|
|
6050
|
-
* in source-chain USDC, and leaves the destination mint unreduced. Omit the
|
|
6051
|
-
* option (or use `'destination'`) to preserve the existing max-fee behavior.
|
|
6453
|
+
* The kit's name for {@link BridgeConfig}, kept as the parameter type so a
|
|
6454
|
+
* kit-only option can be added here without touching the provider-facing config.
|
|
6052
6455
|
*
|
|
6053
6456
|
* @example
|
|
6054
6457
|
* ```typescript
|
|
@@ -6061,10 +6464,7 @@ type BridgeDestination<TAdapterCapabilities extends AdapterCapabilities = Adapte
|
|
|
6061
6464
|
* ```
|
|
6062
6465
|
* @since 1.14.0
|
|
6063
6466
|
*/
|
|
6064
|
-
|
|
6065
|
-
/** Select source-side signed fees or the legacy destination-side fee path. */
|
|
6066
|
-
feePayment?: 'source' | 'destination';
|
|
6067
|
-
}
|
|
6467
|
+
type BridgeExecutionConfig = BridgeConfig;
|
|
6068
6468
|
type FeeFunction<TFromAdapterCapabilities extends AdapterCapabilities, TToAdapterCapabilities extends AdapterCapabilities> = (params: BridgeParams$1<TFromAdapterCapabilities, TToAdapterCapabilities>) => Promise<string> | string;
|
|
6069
6469
|
type FeeRecipientFunction<TFromAdapterCapabilities extends AdapterCapabilities, TToAdapterCapabilities extends AdapterCapabilities> = (feePayoutChain: ChainDefinition, params: BridgeParams$1<TFromAdapterCapabilities, TToAdapterCapabilities>) => Promise<string> | string;
|
|
6070
6470
|
/**
|
|
@@ -6082,6 +6482,13 @@ type FeeRecipientFunction<TFromAdapterCapabilities extends AdapterCapabilities,
|
|
|
6082
6482
|
* Use `computeFee` (recommended) for human-readable amounts, or `calculateFee` (deprecated)
|
|
6083
6483
|
* for smallest-unit amounts. Only one should be provided.
|
|
6084
6484
|
*
|
|
6485
|
+
* **USDC only.** Because the fee is collected on top of the transfer amount and
|
|
6486
|
+
* split through CCTPv2's USDC flow, this policy cannot apply to any other token.
|
|
6487
|
+
* Bridging a non-USDC token (for example CCTPx `cirBTC` or `wETH`)
|
|
6488
|
+
* is rejected with `INPUT_VALIDATION_FAILED` before anything is submitted —
|
|
6489
|
+
* on `bridge` and `estimate` alike — rather than proceeding without the fee.
|
|
6490
|
+
* A per-call `config.customFee` is rejected the same way.
|
|
6491
|
+
*
|
|
6085
6492
|
* @example
|
|
6086
6493
|
* ```typescript
|
|
6087
6494
|
* import type { CustomFeePolicy, BridgeParams } from '@circle-fin/bridge-kit'
|
|
@@ -6159,7 +6566,8 @@ type CustomFeePolicy$2 = {
|
|
|
6159
6566
|
* - The `from` field specifies the source adapter context (wallet and chain).
|
|
6160
6567
|
* - The `to` field specifies the destination, supporting both explicit and derived recipient addresses.
|
|
6161
6568
|
* - The `config` field allows customization of bridge behavior (e.g., transfer speed).
|
|
6162
|
-
* - The `token` field is optional and defaults to 'USDC'
|
|
6569
|
+
* - The `token` field is optional and defaults to `'USDC'`. It accepts
|
|
6570
|
+
* `'USDC'`, a known CCTPx symbol, or a bytes32 CCTPx token id.
|
|
6163
6571
|
*
|
|
6164
6572
|
* @typeParam TFromAdapterCapabilities - The source adapter capabilities type.
|
|
6165
6573
|
* @typeParam TToAdapterCapabilities - The destination adapter capabilities type.
|
|
@@ -6227,10 +6635,29 @@ interface BridgeParams<TFromAdapterCapabilities extends AdapterCapabilities = Ad
|
|
|
6227
6635
|
*/
|
|
6228
6636
|
config?: BridgeExecutionConfig;
|
|
6229
6637
|
/**
|
|
6230
|
-
* The token to transfer. Defaults to 'USDC'
|
|
6231
|
-
*
|
|
6638
|
+
* The token to transfer. Defaults to `'USDC'`.
|
|
6639
|
+
*
|
|
6640
|
+
* A known symbol is a convenience for a canonical CCTPx registration. A
|
|
6641
|
+
* symbol that maps to more than one bridge resolves to the registration
|
|
6642
|
+
* pinned by the provider. Pass the bridge's bytes32 token id directly when
|
|
6643
|
+
* an exact registration is required.
|
|
6644
|
+
*
|
|
6645
|
+
* If omitted, defaults to `'USDC'`.
|
|
6646
|
+
*
|
|
6647
|
+
* @example
|
|
6648
|
+
* ```typescript
|
|
6649
|
+
* // USDC via CCTPv2 (default)
|
|
6650
|
+
* const usdc: BridgeParams['token'] = 'USDC'
|
|
6651
|
+
*
|
|
6652
|
+
* // CCTPx by bare symbol — resolves via the known-symbol map
|
|
6653
|
+
* const bare: BridgeParams['token'] = 'wETH'
|
|
6654
|
+
*
|
|
6655
|
+
* // CCTPx by bytes32 token id
|
|
6656
|
+
* const explicit: BridgeParams['token'] =
|
|
6657
|
+
* '0x0000000000000000000000000000000000000000000000000000000063697254'
|
|
6658
|
+
* ```
|
|
6232
6659
|
*/
|
|
6233
|
-
token?:
|
|
6660
|
+
token?: BridgeToken;
|
|
6234
6661
|
/**
|
|
6235
6662
|
* Optional invocation metadata for tracing and correlation.
|
|
6236
6663
|
*
|
|
@@ -6253,15 +6680,68 @@ interface BridgeParams<TFromAdapterCapabilities extends AdapterCapabilities = Ad
|
|
|
6253
6680
|
*/
|
|
6254
6681
|
invocationMeta?: InvocationMeta;
|
|
6255
6682
|
/**
|
|
6256
|
-
*
|
|
6683
|
+
* Optional server-signed quote to reuse — pass the `quote` returned by an
|
|
6684
|
+
* earlier {@link BridgeKit.estimate | estimate} call straight back so the
|
|
6685
|
+
* fee you were quoted is the fee you pay.
|
|
6686
|
+
*
|
|
6687
|
+
* Treat the value as opaque, and never log or decode it. It belongs to
|
|
6688
|
+
* whichever provider issued it and carries that provider's own shape,
|
|
6689
|
+
* which is why it is typed `unknown` here: a route is matched to a
|
|
6690
|
+
* provider after these parameters are validated, so the kit cannot know
|
|
6691
|
+
* whose quote this is. The provider that serves the route validates it
|
|
6692
|
+
* before reading any field.
|
|
6693
|
+
*
|
|
6694
|
+
* An unusable quote is not handled the same way everywhere, so take the
|
|
6695
|
+
* value from an estimate result rather than constructing one:
|
|
6696
|
+
* - A provider with a reusable quote model (e.g. CCTPx) reuses it while it
|
|
6697
|
+
* is fresh and matches the requested fee token and speed; otherwise it
|
|
6698
|
+
* transparently fetches a fresh quote and flags a `QUOTE_NOT_REUSED`
|
|
6699
|
+
* result warning, so a stale quote is never worse than passing none.
|
|
6700
|
+
* - Receive-exact bridging (`config.feePayment: 'source'`) instead
|
|
6701
|
+
* **rejects** a quote that is invalid, mismatched, expired, or too close
|
|
6702
|
+
* to expiry, rather than repricing behind your back.
|
|
6703
|
+
* - Providers with no quote model (e.g. USDC via CCTP v2) ignore it —
|
|
6704
|
+
* **silently**. Route selection happens after these parameters are
|
|
6705
|
+
* validated, so the kit cannot tell whose quote this is, and nothing
|
|
6706
|
+
* checks that it reached the provider that issued it. In practice this
|
|
6707
|
+
* bites when the token changes between `estimate` and `bridge`: a quote
|
|
6708
|
+
* from a CCTPx token (`cirBTC`, `wETH`) passed to a plain USDC bridge is
|
|
6709
|
+
* dropped without an error or a warning, and the fee comes from CCTP v2
|
|
6710
|
+
* instead. Keeping the same token routes back to the same provider, so
|
|
6711
|
+
* the quote arrives. Re-estimate whenever the transfer changes.
|
|
6712
|
+
*
|
|
6713
|
+
* The transfer parameters (amount, recipient, chains) are validated
|
|
6714
|
+
* on-chain, so a quote reused for a different transfer is rejected by the
|
|
6715
|
+
* contract rather than silently — reuse a quote only for the transfer it
|
|
6716
|
+
* was estimated for.
|
|
6717
|
+
*
|
|
6718
|
+
* This field is for {@link BridgeKit.bridge | bridge} only. A quote is
|
|
6719
|
+
* produced by `estimate` and consumed by `bridge`, and `estimate` always
|
|
6720
|
+
* returns a freshly-priced one. Passing a quote back into `estimate` is a
|
|
6721
|
+
* usage error: CCTPx rejects it outright, while receive-exact ignores it and
|
|
6722
|
+
* prices afresh, so the quote you get back is never the one you sent. Take
|
|
6723
|
+
* the quote from the estimate result, not from your input.
|
|
6257
6724
|
*
|
|
6258
|
-
* @
|
|
6259
|
-
*
|
|
6260
|
-
*
|
|
6261
|
-
*
|
|
6262
|
-
*
|
|
6725
|
+
* @example
|
|
6726
|
+
* ```typescript
|
|
6727
|
+
* const estimate = await kit.estimate({
|
|
6728
|
+
* from: { adapter: sourceAdapter, chain: 'Ethereum' },
|
|
6729
|
+
* to: { adapter: destAdapter, chain: 'Base' },
|
|
6730
|
+
* amount: '100',
|
|
6731
|
+
* token: 'wETH',
|
|
6732
|
+
* })
|
|
6733
|
+
*
|
|
6734
|
+
* // Reuse the quoted fee for the bridge.
|
|
6735
|
+
* const result = await kit.bridge({
|
|
6736
|
+
* from: { adapter: sourceAdapter, chain: 'Ethereum' },
|
|
6737
|
+
* to: { adapter: destAdapter, chain: 'Base' },
|
|
6738
|
+
* amount: '100',
|
|
6739
|
+
* token: 'wETH',
|
|
6740
|
+
* quote: estimate.quote,
|
|
6741
|
+
* })
|
|
6742
|
+
* ```
|
|
6263
6743
|
*/
|
|
6264
|
-
quote?:
|
|
6744
|
+
quote?: unknown;
|
|
6265
6745
|
}
|
|
6266
6746
|
|
|
6267
6747
|
/**
|
|
@@ -7753,6 +8233,18 @@ interface AppKitContext {
|
|
|
7753
8233
|
chain: ChainDefinition;
|
|
7754
8234
|
params: OperationParamsMap[T];
|
|
7755
8235
|
}): Promise<string>;
|
|
8236
|
+
/**
|
|
8237
|
+
* Optional client-side configuration forwarded to the underlying
|
|
8238
|
+
* {@link createOnrampKit} factory when `kit.onramp` is accessed.
|
|
8239
|
+
*
|
|
8240
|
+
* @remarks
|
|
8241
|
+
* The onramp namespace on the client carries NO secret — the
|
|
8242
|
+
* long-lived `apiKey` lives exclusively on the server entry
|
|
8243
|
+
* (`@circle-fin/app-kit/server`). These options exist purely so
|
|
8244
|
+
* staging / SSR consumers can override the widget origin or
|
|
8245
|
+
* inject a host `Window`.
|
|
8246
|
+
*/
|
|
8247
|
+
onramp?: AppKitOnrampClientConfig | undefined;
|
|
7756
8248
|
/**
|
|
7757
8249
|
* Operation-scoped custom fee policies.
|
|
7758
8250
|
*
|
|
@@ -7824,6 +8316,35 @@ interface AppKitContext {
|
|
|
7824
8316
|
*/
|
|
7825
8317
|
headers?: Record<string, string>;
|
|
7826
8318
|
}
|
|
8319
|
+
/**
|
|
8320
|
+
* Client-side onramp configuration carried on {@link AppKitContext.onramp}.
|
|
8321
|
+
*
|
|
8322
|
+
* @remarks
|
|
8323
|
+
* No secret material lives here — the server-only `apiKey` is
|
|
8324
|
+
* configured on the matching `@circle-fin/app-kit/server` entry. Both
|
|
8325
|
+
* fields are optional with safe production defaults; the typical
|
|
8326
|
+
* application leaves them unset and instantiates `new AppKit()`.
|
|
8327
|
+
*/
|
|
8328
|
+
interface AppKitOnrampClientConfig {
|
|
8329
|
+
/**
|
|
8330
|
+
* Override the hosted widget origin. Defaults to the onramp-kit
|
|
8331
|
+
* production origin.
|
|
8332
|
+
*
|
|
8333
|
+
* @remarks
|
|
8334
|
+
* Override for staging environments only — production traffic
|
|
8335
|
+
* should always use the default.
|
|
8336
|
+
*/
|
|
8337
|
+
readonly widgetBaseUrl?: string | undefined;
|
|
8338
|
+
/**
|
|
8339
|
+
* Inject a host `Window` for testing or SSR-friendly bundles.
|
|
8340
|
+
*
|
|
8341
|
+
* @remarks
|
|
8342
|
+
* Production code leaves this unset and relies on the global
|
|
8343
|
+
* `window`. Exposed (not `@internal`) so SSR frameworks can
|
|
8344
|
+
* hand-feed the host window after hydration.
|
|
8345
|
+
*/
|
|
8346
|
+
readonly window?: Window | undefined;
|
|
8347
|
+
}
|
|
7827
8348
|
|
|
7828
8349
|
/**
|
|
7829
8350
|
* Execute a cross-chain bridge operation using the AppKit context.
|
|
@@ -7861,6 +8382,9 @@ interface AppKitContext {
|
|
|
7861
8382
|
* console.log(`Bridged ${result.amount} ${result.token} (${result.state})`)
|
|
7862
8383
|
* ```
|
|
7863
8384
|
*/
|
|
7864
|
-
declare
|
|
8385
|
+
declare function bridge(context: AppKitContext, params: Omit<BridgeParams, 'token'> & {
|
|
8386
|
+
token?: 'USDC';
|
|
8387
|
+
}): Promise<BridgeResult>;
|
|
8388
|
+
declare function bridge(context: AppKitContext, params: BridgeParams): Promise<BridgeResult<string>>;
|
|
7865
8389
|
|
|
7866
8390
|
export { bridge };
|