@circle-fin/app-kit 1.15.3 → 1.17.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.
Files changed (60) hide show
  1. package/CHANGELOG.md +91 -0
  2. package/README.md +5 -2
  3. package/borrow.cjs +28146 -0
  4. package/borrow.cjs.map +1 -0
  5. package/borrow.d.cts +10752 -0
  6. package/borrow.d.mts +10752 -0
  7. package/borrow.d.ts +10752 -0
  8. package/borrow.mjs +28118 -0
  9. package/borrow.mjs.map +1 -0
  10. package/bridge.cjs +2084 -328
  11. package/bridge.d.cts +121 -18
  12. package/bridge.d.mts +121 -18
  13. package/bridge.d.ts +121 -18
  14. package/bridge.mjs +2084 -328
  15. package/chains.cjs +78 -7
  16. package/chains.d.cts +2 -0
  17. package/chains.d.mts +2 -0
  18. package/chains.d.ts +2 -0
  19. package/chains.mjs +78 -7
  20. package/context.cjs +1 -0
  21. package/context.d.cts +121 -18
  22. package/context.d.mts +121 -18
  23. package/context.d.ts +121 -18
  24. package/context.mjs +1 -0
  25. package/earn.cjs +5322 -3219
  26. package/earn.d.cts +1149 -984
  27. package/earn.d.mts +1149 -984
  28. package/earn.d.ts +1149 -984
  29. package/earn.mjs +5322 -3219
  30. package/estimateBridge.cjs +2082 -326
  31. package/estimateBridge.d.cts +121 -18
  32. package/estimateBridge.d.mts +121 -18
  33. package/estimateBridge.d.ts +121 -18
  34. package/estimateBridge.mjs +2082 -326
  35. package/estimateSwap.cjs +8817 -6974
  36. package/estimateSwap.d.cts +169 -18
  37. package/estimateSwap.d.mts +169 -18
  38. package/estimateSwap.d.ts +169 -18
  39. package/estimateSwap.mjs +8822 -6979
  40. package/index.cjs +33149 -20719
  41. package/index.d.cts +23174 -2736
  42. package/index.d.mts +23174 -2736
  43. package/index.d.ts +23174 -2736
  44. package/index.mjs +33090 -20713
  45. package/package.json +17 -7
  46. package/server.cjs +133 -12
  47. package/server.d.cts +29 -10
  48. package/server.d.mts +29 -10
  49. package/server.d.ts +29 -10
  50. package/server.mjs +133 -12
  51. package/swap.cjs +8817 -6974
  52. package/swap.d.cts +169 -18
  53. package/swap.d.mts +169 -18
  54. package/swap.d.ts +169 -18
  55. package/swap.mjs +8822 -6979
  56. package/unifiedBalance.cjs +528 -138
  57. package/unifiedBalance.d.cts +108 -11
  58. package/unifiedBalance.d.mts +108 -11
  59. package/unifiedBalance.d.ts +108 -11
  60. package/unifiedBalance.mjs +528 -138
@@ -551,8 +551,23 @@ interface CCTPXChainConfig {
551
551
  * const contractType: KitContractType = 'bridge' // Valid
552
552
  * const invalidType: KitContractType = 'invalid' // TypeScript error
553
553
  * ```
554
- */
555
- type KitContractType = 'bridge' | 'adapter';
554
+ *
555
+ * @remarks
556
+ * `'senderPreservingBatcher'` carries a stricter requirement than the others,
557
+ * because setting it wrong fails silently rather than loudly. It must name a
558
+ * batching contract that preserves the calling EOA as `msg.sender` in every
559
+ * subcall — on Arc, the `Multicall3From` predeploy, which achieves that
560
+ * through the `CallFrom` precompile. The name is deliberately more specific
561
+ * than "batcher": the ubiquitous Multicall3 at
562
+ * `0xcA11bde05977b3631167028862bE2a173976CA11` has the same ABI and the same
563
+ * selectors but does **not** qualify, since each subcall would arrive as the
564
+ * Multicall3 contract, so a batched `approve` would grant an allowance from
565
+ * the batcher's own balance rather than from the user's — a field named just
566
+ * `batcher` would make that misconfiguration look valid. Leave
567
+ * `senderPreservingBatcher` unset on any chain lacking one; an unset field
568
+ * simply means callers fall back to submitting calls one at a time.
569
+ */
570
+ type KitContractType = 'bridge' | 'adapter' | 'senderPreservingBatcher';
556
571
  /**
557
572
  * Configuration for Gateway v1 contracts.
558
573
  *
@@ -884,10 +899,10 @@ declare enum Blockchain {
884
899
  *
885
900
  * Unlike the full {@link Blockchain} enum, SwapChain includes mainnet
886
901
  * networks and explicitly whitelisted testnets (e.g., {@link Arc_Testnet})
887
- * where adapter contracts are deployed (CCTPv2 support).
902
+ * where Adapter contracts are deployed.
888
903
  *
889
904
  * Dynamic validation via {@link isSwapSupportedChain} ensures chains
890
- * automatically work when adapter contracts and supported tokens are deployed.
905
+ * automatically work when Adapter contracts and supported tokens are deployed.
891
906
  *
892
907
  * @example
893
908
  * ```typescript
@@ -927,20 +942,22 @@ declare enum SwapChain {
927
942
  HyperEVM = "HyperEVM",
928
943
  Monad = "Monad",
929
944
  Arc = "Arc",
945
+ Cronos = "Cronos",
946
+ Morph = "Morph",
930
947
  Arc_Testnet = "Arc_Testnet"
931
948
  }
932
949
  /**
933
950
  * Chain definition that supports swap operations.
934
951
  *
935
952
  * @remarks
936
- * Expanded from 4 to ~18 supported chains based on:
937
- * - CCTPv2 support (adapter contract deployed)
953
+ * Expanded from 4 to supported mainnets and whitelisted testnets based on:
954
+ * - A deployed Adapter contract, configured directly or through CCTP v2
938
955
  * - Mainnet chains plus whitelisted testnets (e.g., Arc Testnet)
939
956
  *
940
957
  * Use `isSwapSupportedChain()` for runtime validation.
941
958
  */
942
959
  type SwapChainDefinition = ChainDefinition & {
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;
960
+ 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.Cronos | Blockchain.Morph | Blockchain.Arc_Testnet;
944
961
  };
945
962
  /**
946
963
  * Chain identifier accepted by swap operations.
@@ -1436,8 +1453,13 @@ type PreparedChainRequest = EvmPreparedChainRequest | SolanaPreparedChainRequest
1436
1453
  * Parameters for preparing an EVM contract execution.
1437
1454
  */
1438
1455
  type EvmPreparedChainRequestParams = {
1439
- /** The type of the prepared execution. */
1440
- type: 'evm';
1456
+ /**
1457
+ * The type of the prepared execution. Optional here because EVM is the
1458
+ * only chain type `Adapter.prepare()` implementations narrow their param
1459
+ * type to in practice — callers that only ever prepare EVM requests can
1460
+ * omit it rather than repeat a discriminator that never varies for them.
1461
+ */
1462
+ type?: 'evm';
1441
1463
  /** The ABI of the contract. */
1442
1464
  abi: Abi | string[];
1443
1465
  /** The address of the contract. */
@@ -2716,6 +2738,57 @@ interface EarnActionMap {
2716
2738
  readonly claimRewards: ExecuteEarnParams;
2717
2739
  }
2718
2740
 
2741
+ /** Permit standards accepted by Borrow Adapter executions. */
2742
+ declare enum BorrowPermitType {
2743
+ /** Tokens must be approved separately. */
2744
+ NONE = 0,
2745
+ /** EIP-2612 permit calldata accompanies the token input. */
2746
+ EIP2612 = 1
2747
+ }
2748
+ /** Token input forwarded by Borrow Kit to the Adapter Contract. */
2749
+ interface BorrowTokenInput {
2750
+ readonly permitType: BorrowPermitType;
2751
+ readonly token: `0x${string}`;
2752
+ readonly amount: bigint;
2753
+ readonly permitCalldata: `0x${string}`;
2754
+ }
2755
+ /** A single instruction in a Circle-signed Borrow execution. */
2756
+ interface BorrowInstruction {
2757
+ readonly target: `0x${string}`;
2758
+ readonly data: `0x${string}`;
2759
+ readonly value: string | bigint;
2760
+ readonly tokenIn: `0x${string}`;
2761
+ readonly amountToApprove: string | bigint;
2762
+ readonly tokenOut: `0x${string}`;
2763
+ readonly minTokenOut: string | bigint;
2764
+ }
2765
+ /** A token recipient in a Circle-signed Borrow execution. */
2766
+ interface BorrowTokenRecipient {
2767
+ readonly token: `0x${string}`;
2768
+ readonly beneficiary: `0x${string}`;
2769
+ }
2770
+ /** Circle-signed Borrow parameters forwarded to the Adapter Contract. */
2771
+ interface BorrowExecutionParams {
2772
+ readonly instructions: readonly BorrowInstruction[];
2773
+ readonly tokens: readonly BorrowTokenRecipient[];
2774
+ readonly execId: string | bigint;
2775
+ readonly deadline: string | bigint;
2776
+ readonly metadata: `0x${string}`;
2777
+ }
2778
+ /** Parameters for a service-signed Borrow Adapter execution. */
2779
+ interface ExecuteBorrowParams extends ActionParameters {
2780
+ readonly executeParams: BorrowExecutionParams;
2781
+ readonly tokenInputs: BorrowTokenInput[];
2782
+ readonly signature: `0x${string}`;
2783
+ }
2784
+ /** Borrow actions supported by EVM adapters. */
2785
+ interface BorrowActionMap {
2786
+ /** Execute a Circle-signed partial loan repayment. */
2787
+ readonly repay: ExecuteBorrowParams;
2788
+ /** Execute a Circle-signed borrow. */
2789
+ readonly execute: ExecuteBorrowParams;
2790
+ }
2791
+
2719
2792
  /**
2720
2793
  * Single instruction to execute within the Adapter Contract.
2721
2794
  *
@@ -3672,6 +3745,8 @@ interface NativeActionMap {
3672
3745
  * @see {@link ActionPayload} for extracting payload types
3673
3746
  */
3674
3747
  interface ActionMap {
3748
+ /** Borrow operations that execute service-signed payloads. */
3749
+ readonly borrow: BorrowActionMap;
3675
3750
  /** CCTP-specific operations with automatic address resolution. */
3676
3751
  readonly cctp: CCTPActionMap;
3677
3752
  /** CCTPx operations (CrossChainTokenService) for cross-chain transfers of registered tokens (Circle-issued or otherwise). */
@@ -3691,6 +3766,7 @@ interface ActionMap {
3691
3766
  /** Earn operations that execute service-signed payloads via the adapter contract. */
3692
3767
  readonly earn: EarnActionMap;
3693
3768
  }
3769
+
3694
3770
  /**
3695
3771
  * Determine if a type represents an action parameter object (leaf node).
3696
3772
  *
@@ -6133,6 +6209,44 @@ type BridgeDestination<TAdapterCapabilities extends AdapterCapabilities = Adapte
6133
6209
  useForwarder?: boolean;
6134
6210
  }) | ForwarderDestination<TChainIdentifier>;
6135
6211
 
6212
+ /** Token metadata for one side of a swap route step. */
6213
+ interface SwapRouteToken {
6214
+ readonly symbol: string;
6215
+ readonly address: string;
6216
+ readonly decimals: number;
6217
+ }
6218
+ /** Amount estimates for a swap route step, expressed in base units. */
6219
+ interface SwapRouteStepEstimate {
6220
+ readonly fromAmount: string;
6221
+ readonly toAmount: string;
6222
+ readonly gasCostUSD?: string;
6223
+ }
6224
+ /** A single swap or bridge hop selected by the route provider. */
6225
+ interface SwapRouteStep {
6226
+ /** Hop kind, for example `swap` or `bridge`. */
6227
+ readonly type: string;
6228
+ /** Protocol identifier, for example `cctp-v2`. */
6229
+ readonly tool: string;
6230
+ /** Display name for {@link SwapRouteStep.tool}. */
6231
+ readonly toolName: string;
6232
+ readonly fromToken: SwapRouteToken;
6233
+ readonly toToken: SwapRouteToken;
6234
+ readonly estimate: SwapRouteStepEstimate;
6235
+ /** Provider-specific details that are not part of the stable step shape. */
6236
+ readonly metadata?: Readonly<Record<string, unknown>>;
6237
+ }
6238
+ /** Provider and executable hops selected for a swap. */
6239
+ interface SwapRoute {
6240
+ /**
6241
+ * Provider that routed the swap, for example `lifi` or `circle`. Treat as
6242
+ * an opaque identifier; new providers can appear without an SDK release.
6243
+ */
6244
+ readonly provider: string;
6245
+ readonly steps: readonly SwapRouteStep[];
6246
+ /** Provider-specific details that are not part of the stable route shape. */
6247
+ readonly metadata?: Readonly<Record<string, unknown>>;
6248
+ }
6249
+
6136
6250
  /**
6137
6251
  * Represents a token amount with its symbol and value.
6138
6252
  *
@@ -6331,7 +6445,7 @@ interface ServiceSwapConfig {
6331
6445
  *
6332
6446
  * @defaultValue true
6333
6447
  */
6334
- batchTransactions?: boolean;
6448
+ batchTransactions?: boolean | undefined;
6335
6449
  }
6336
6450
  /**
6337
6451
  * Parameters for initiating a swap operation through the Stablecoin Service.
@@ -6484,6 +6598,14 @@ interface ServiceSwapFee {
6484
6598
  * addresses are not available from the proxy response.
6485
6599
  */
6486
6600
  readonly recipientAddress?: string;
6601
+ /** Provider-defined fee component (for example `FORWARD`). */
6602
+ readonly component?: string;
6603
+ /**
6604
+ * Chain on which the fee is charged, as reported by the service
6605
+ * (a `Blockchain` value such as `'Ethereum'`). Not validated
6606
+ * against the `Blockchain` enum.
6607
+ */
6608
+ readonly chain?: string;
6487
6609
  }
6488
6610
 
6489
6611
  /**
@@ -6848,6 +6970,33 @@ interface SwapConfig {
6848
6970
  * `apiKey` is omitted, and `apiKey` takes precedence when both are set.
6849
6971
  */
6850
6972
  kitKey?: string;
6973
+ /**
6974
+ * Enable or disable atomic batched execution of the approval and swap.
6975
+ *
6976
+ * When `true` (or omitted), an EVM swap that needs an on-chain ERC-20
6977
+ * approval submits the approval and the swap as one atomic batch if the
6978
+ * connected wallet supports it (EIP-5792, or a signing strategy that
6979
+ * declares atomic batching). Set to `false` to force the sequential
6980
+ * approve-then-swap flow.
6981
+ *
6982
+ * @remarks
6983
+ * Has no effect on the gasless permit path, native-token swaps, or Solana,
6984
+ * which already execute as a single transaction. USDT input always uses the
6985
+ * sequential path because its allowance must be reset to zero first. The
6986
+ * batched path relies on the wallet's own gas estimation for the swap call;
6987
+ * set `false` if your wallet under-estimates gas for complex routes or
6988
+ * rejects batched calls.
6989
+ *
6990
+ * @defaultValue `undefined` (batching attempted when the wallet supports it)
6991
+ *
6992
+ * @example
6993
+ * ```typescript
6994
+ * const config: SwapConfig = {
6995
+ * batchTransactions: false, // force sequential approve → swap
6996
+ * }
6997
+ * ```
6998
+ */
6999
+ batchTransactions?: boolean | undefined;
6851
7000
  }
6852
7001
  /**
6853
7002
  * Estimation result for a swap operation.
@@ -6960,6 +7109,8 @@ interface SwapEstimate {
6960
7109
  * and kit fees (if configured). Amounts are in decimal format for display.
6961
7110
  */
6962
7111
  readonly fees?: readonly ServiceSwapFee[];
7112
+ /** Provider and executable hops selected for the swap. */
7113
+ readonly route?: SwapRoute;
6963
7114
  }
6964
7115
  /**
6965
7116
  * Resolved parameters for swap operations after validation and normalization.
@@ -8293,8 +8444,8 @@ interface AppKitContext {
8293
8444
  *
8294
8445
  * This property stores event handlers that are registered via the AppKit's
8295
8446
  * `on()` method. Handlers are grouped by operation type. The runtime buckets
8296
- * are `bridge` and `earn`; the context can add more operation buckets as
8297
- * AppKit wires action handlers for additional kits.
8447
+ * are `bridge`, `earn`, and `borrow`; the context can add more operation
8448
+ * buckets as AppKit wires action handlers for additional kits.
8298
8449
  *
8299
8450
  * Within each operation bucket, handlers are keyed by action name (for
8300
8451
  * example, `bridge.approve` or `earn.deposit`) or `*` for wildcard handlers.
@@ -8313,13 +8464,13 @@ interface AppKitContext {
8313
8464
  * // Earn handlers are registered with EarnKit when earn operations run
8314
8465
  * ```
8315
8466
  */
8316
- actions: Record<'bridge' | 'earn', Record<string, ((payload: unknown) => void)[]>>;
8467
+ actions: Record<'bridge' | 'earn' | 'borrow', Record<string, ((payload: unknown) => void)[]>>;
8317
8468
  /**
8318
- * Disable success analytics for the underlying EarnKit, SwapKit, and
8319
- * UnifiedBalanceKit.
8469
+ * Disable success analytics for the underlying EarnKit, SwapKit,
8470
+ * BorrowKit, and UnifiedBalanceKit.
8320
8471
  *
8321
- * When `true`, completed earn, swap, and unified balance operations will not
8322
- * POST analytics events. This does not disable error reporting; use
8472
+ * When `true`, completed earn, swap, borrow, and unified balance operations
8473
+ * will not POST analytics events. This does not disable error reporting; use
8323
8474
  * {@link AppKitContext.disableErrorReporting} for that. Defaults to `false`.
8324
8475
  *
8325
8476
  * @defaultValue false
@@ -8329,7 +8480,7 @@ interface AppKitContext {
8329
8480
  * Disable error telemetry for all sub-kits.
8330
8481
  *
8331
8482
  * When `true`, none of the underlying kits (BridgeKit, SwapKit, EarnKit,
8332
- * UnifiedBalanceKit) will POST error details to the telemetry
8483
+ * BorrowKit, UnifiedBalanceKit) will POST error details to the telemetry
8333
8484
  * endpoint when operations throw. Defaults to `false` (enabled).
8334
8485
  *
8335
8486
  * @defaultValue false
@@ -551,8 +551,23 @@ interface CCTPXChainConfig {
551
551
  * const contractType: KitContractType = 'bridge' // Valid
552
552
  * const invalidType: KitContractType = 'invalid' // TypeScript error
553
553
  * ```
554
- */
555
- type KitContractType = 'bridge' | 'adapter';
554
+ *
555
+ * @remarks
556
+ * `'senderPreservingBatcher'` carries a stricter requirement than the others,
557
+ * because setting it wrong fails silently rather than loudly. It must name a
558
+ * batching contract that preserves the calling EOA as `msg.sender` in every
559
+ * subcall — on Arc, the `Multicall3From` predeploy, which achieves that
560
+ * through the `CallFrom` precompile. The name is deliberately more specific
561
+ * than "batcher": the ubiquitous Multicall3 at
562
+ * `0xcA11bde05977b3631167028862bE2a173976CA11` has the same ABI and the same
563
+ * selectors but does **not** qualify, since each subcall would arrive as the
564
+ * Multicall3 contract, so a batched `approve` would grant an allowance from
565
+ * the batcher's own balance rather than from the user's — a field named just
566
+ * `batcher` would make that misconfiguration look valid. Leave
567
+ * `senderPreservingBatcher` unset on any chain lacking one; an unset field
568
+ * simply means callers fall back to submitting calls one at a time.
569
+ */
570
+ type KitContractType = 'bridge' | 'adapter' | 'senderPreservingBatcher';
556
571
  /**
557
572
  * Configuration for Gateway v1 contracts.
558
573
  *
@@ -884,10 +899,10 @@ declare enum Blockchain {
884
899
  *
885
900
  * Unlike the full {@link Blockchain} enum, SwapChain includes mainnet
886
901
  * networks and explicitly whitelisted testnets (e.g., {@link Arc_Testnet})
887
- * where adapter contracts are deployed (CCTPv2 support).
902
+ * where Adapter contracts are deployed.
888
903
  *
889
904
  * Dynamic validation via {@link isSwapSupportedChain} ensures chains
890
- * automatically work when adapter contracts and supported tokens are deployed.
905
+ * automatically work when Adapter contracts and supported tokens are deployed.
891
906
  *
892
907
  * @example
893
908
  * ```typescript
@@ -927,20 +942,22 @@ declare enum SwapChain {
927
942
  HyperEVM = "HyperEVM",
928
943
  Monad = "Monad",
929
944
  Arc = "Arc",
945
+ Cronos = "Cronos",
946
+ Morph = "Morph",
930
947
  Arc_Testnet = "Arc_Testnet"
931
948
  }
932
949
  /**
933
950
  * Chain definition that supports swap operations.
934
951
  *
935
952
  * @remarks
936
- * Expanded from 4 to ~18 supported chains based on:
937
- * - CCTPv2 support (adapter contract deployed)
953
+ * Expanded from 4 to supported mainnets and whitelisted testnets based on:
954
+ * - A deployed Adapter contract, configured directly or through CCTP v2
938
955
  * - Mainnet chains plus whitelisted testnets (e.g., Arc Testnet)
939
956
  *
940
957
  * Use `isSwapSupportedChain()` for runtime validation.
941
958
  */
942
959
  type SwapChainDefinition = ChainDefinition & {
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;
960
+ 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.Cronos | Blockchain.Morph | Blockchain.Arc_Testnet;
944
961
  };
945
962
  /**
946
963
  * Chain identifier accepted by swap operations.
@@ -1436,8 +1453,13 @@ type PreparedChainRequest = EvmPreparedChainRequest | SolanaPreparedChainRequest
1436
1453
  * Parameters for preparing an EVM contract execution.
1437
1454
  */
1438
1455
  type EvmPreparedChainRequestParams = {
1439
- /** The type of the prepared execution. */
1440
- type: 'evm';
1456
+ /**
1457
+ * The type of the prepared execution. Optional here because EVM is the
1458
+ * only chain type `Adapter.prepare()` implementations narrow their param
1459
+ * type to in practice — callers that only ever prepare EVM requests can
1460
+ * omit it rather than repeat a discriminator that never varies for them.
1461
+ */
1462
+ type?: 'evm';
1441
1463
  /** The ABI of the contract. */
1442
1464
  abi: Abi | string[];
1443
1465
  /** The address of the contract. */
@@ -2716,6 +2738,57 @@ interface EarnActionMap {
2716
2738
  readonly claimRewards: ExecuteEarnParams;
2717
2739
  }
2718
2740
 
2741
+ /** Permit standards accepted by Borrow Adapter executions. */
2742
+ declare enum BorrowPermitType {
2743
+ /** Tokens must be approved separately. */
2744
+ NONE = 0,
2745
+ /** EIP-2612 permit calldata accompanies the token input. */
2746
+ EIP2612 = 1
2747
+ }
2748
+ /** Token input forwarded by Borrow Kit to the Adapter Contract. */
2749
+ interface BorrowTokenInput {
2750
+ readonly permitType: BorrowPermitType;
2751
+ readonly token: `0x${string}`;
2752
+ readonly amount: bigint;
2753
+ readonly permitCalldata: `0x${string}`;
2754
+ }
2755
+ /** A single instruction in a Circle-signed Borrow execution. */
2756
+ interface BorrowInstruction {
2757
+ readonly target: `0x${string}`;
2758
+ readonly data: `0x${string}`;
2759
+ readonly value: string | bigint;
2760
+ readonly tokenIn: `0x${string}`;
2761
+ readonly amountToApprove: string | bigint;
2762
+ readonly tokenOut: `0x${string}`;
2763
+ readonly minTokenOut: string | bigint;
2764
+ }
2765
+ /** A token recipient in a Circle-signed Borrow execution. */
2766
+ interface BorrowTokenRecipient {
2767
+ readonly token: `0x${string}`;
2768
+ readonly beneficiary: `0x${string}`;
2769
+ }
2770
+ /** Circle-signed Borrow parameters forwarded to the Adapter Contract. */
2771
+ interface BorrowExecutionParams {
2772
+ readonly instructions: readonly BorrowInstruction[];
2773
+ readonly tokens: readonly BorrowTokenRecipient[];
2774
+ readonly execId: string | bigint;
2775
+ readonly deadline: string | bigint;
2776
+ readonly metadata: `0x${string}`;
2777
+ }
2778
+ /** Parameters for a service-signed Borrow Adapter execution. */
2779
+ interface ExecuteBorrowParams extends ActionParameters {
2780
+ readonly executeParams: BorrowExecutionParams;
2781
+ readonly tokenInputs: BorrowTokenInput[];
2782
+ readonly signature: `0x${string}`;
2783
+ }
2784
+ /** Borrow actions supported by EVM adapters. */
2785
+ interface BorrowActionMap {
2786
+ /** Execute a Circle-signed partial loan repayment. */
2787
+ readonly repay: ExecuteBorrowParams;
2788
+ /** Execute a Circle-signed borrow. */
2789
+ readonly execute: ExecuteBorrowParams;
2790
+ }
2791
+
2719
2792
  /**
2720
2793
  * Single instruction to execute within the Adapter Contract.
2721
2794
  *
@@ -3672,6 +3745,8 @@ interface NativeActionMap {
3672
3745
  * @see {@link ActionPayload} for extracting payload types
3673
3746
  */
3674
3747
  interface ActionMap {
3748
+ /** Borrow operations that execute service-signed payloads. */
3749
+ readonly borrow: BorrowActionMap;
3675
3750
  /** CCTP-specific operations with automatic address resolution. */
3676
3751
  readonly cctp: CCTPActionMap;
3677
3752
  /** CCTPx operations (CrossChainTokenService) for cross-chain transfers of registered tokens (Circle-issued or otherwise). */
@@ -3691,6 +3766,7 @@ interface ActionMap {
3691
3766
  /** Earn operations that execute service-signed payloads via the adapter contract. */
3692
3767
  readonly earn: EarnActionMap;
3693
3768
  }
3769
+
3694
3770
  /**
3695
3771
  * Determine if a type represents an action parameter object (leaf node).
3696
3772
  *
@@ -6133,6 +6209,44 @@ type BridgeDestination<TAdapterCapabilities extends AdapterCapabilities = Adapte
6133
6209
  useForwarder?: boolean;
6134
6210
  }) | ForwarderDestination<TChainIdentifier>;
6135
6211
 
6212
+ /** Token metadata for one side of a swap route step. */
6213
+ interface SwapRouteToken {
6214
+ readonly symbol: string;
6215
+ readonly address: string;
6216
+ readonly decimals: number;
6217
+ }
6218
+ /** Amount estimates for a swap route step, expressed in base units. */
6219
+ interface SwapRouteStepEstimate {
6220
+ readonly fromAmount: string;
6221
+ readonly toAmount: string;
6222
+ readonly gasCostUSD?: string;
6223
+ }
6224
+ /** A single swap or bridge hop selected by the route provider. */
6225
+ interface SwapRouteStep {
6226
+ /** Hop kind, for example `swap` or `bridge`. */
6227
+ readonly type: string;
6228
+ /** Protocol identifier, for example `cctp-v2`. */
6229
+ readonly tool: string;
6230
+ /** Display name for {@link SwapRouteStep.tool}. */
6231
+ readonly toolName: string;
6232
+ readonly fromToken: SwapRouteToken;
6233
+ readonly toToken: SwapRouteToken;
6234
+ readonly estimate: SwapRouteStepEstimate;
6235
+ /** Provider-specific details that are not part of the stable step shape. */
6236
+ readonly metadata?: Readonly<Record<string, unknown>>;
6237
+ }
6238
+ /** Provider and executable hops selected for a swap. */
6239
+ interface SwapRoute {
6240
+ /**
6241
+ * Provider that routed the swap, for example `lifi` or `circle`. Treat as
6242
+ * an opaque identifier; new providers can appear without an SDK release.
6243
+ */
6244
+ readonly provider: string;
6245
+ readonly steps: readonly SwapRouteStep[];
6246
+ /** Provider-specific details that are not part of the stable route shape. */
6247
+ readonly metadata?: Readonly<Record<string, unknown>>;
6248
+ }
6249
+
6136
6250
  /**
6137
6251
  * Represents a token amount with its symbol and value.
6138
6252
  *
@@ -6331,7 +6445,7 @@ interface ServiceSwapConfig {
6331
6445
  *
6332
6446
  * @defaultValue true
6333
6447
  */
6334
- batchTransactions?: boolean;
6448
+ batchTransactions?: boolean | undefined;
6335
6449
  }
6336
6450
  /**
6337
6451
  * Parameters for initiating a swap operation through the Stablecoin Service.
@@ -6484,6 +6598,14 @@ interface ServiceSwapFee {
6484
6598
  * addresses are not available from the proxy response.
6485
6599
  */
6486
6600
  readonly recipientAddress?: string;
6601
+ /** Provider-defined fee component (for example `FORWARD`). */
6602
+ readonly component?: string;
6603
+ /**
6604
+ * Chain on which the fee is charged, as reported by the service
6605
+ * (a `Blockchain` value such as `'Ethereum'`). Not validated
6606
+ * against the `Blockchain` enum.
6607
+ */
6608
+ readonly chain?: string;
6487
6609
  }
6488
6610
 
6489
6611
  /**
@@ -6848,6 +6970,33 @@ interface SwapConfig {
6848
6970
  * `apiKey` is omitted, and `apiKey` takes precedence when both are set.
6849
6971
  */
6850
6972
  kitKey?: string;
6973
+ /**
6974
+ * Enable or disable atomic batched execution of the approval and swap.
6975
+ *
6976
+ * When `true` (or omitted), an EVM swap that needs an on-chain ERC-20
6977
+ * approval submits the approval and the swap as one atomic batch if the
6978
+ * connected wallet supports it (EIP-5792, or a signing strategy that
6979
+ * declares atomic batching). Set to `false` to force the sequential
6980
+ * approve-then-swap flow.
6981
+ *
6982
+ * @remarks
6983
+ * Has no effect on the gasless permit path, native-token swaps, or Solana,
6984
+ * which already execute as a single transaction. USDT input always uses the
6985
+ * sequential path because its allowance must be reset to zero first. The
6986
+ * batched path relies on the wallet's own gas estimation for the swap call;
6987
+ * set `false` if your wallet under-estimates gas for complex routes or
6988
+ * rejects batched calls.
6989
+ *
6990
+ * @defaultValue `undefined` (batching attempted when the wallet supports it)
6991
+ *
6992
+ * @example
6993
+ * ```typescript
6994
+ * const config: SwapConfig = {
6995
+ * batchTransactions: false, // force sequential approve → swap
6996
+ * }
6997
+ * ```
6998
+ */
6999
+ batchTransactions?: boolean | undefined;
6851
7000
  }
6852
7001
  /**
6853
7002
  * Estimation result for a swap operation.
@@ -6960,6 +7109,8 @@ interface SwapEstimate {
6960
7109
  * and kit fees (if configured). Amounts are in decimal format for display.
6961
7110
  */
6962
7111
  readonly fees?: readonly ServiceSwapFee[];
7112
+ /** Provider and executable hops selected for the swap. */
7113
+ readonly route?: SwapRoute;
6963
7114
  }
6964
7115
  /**
6965
7116
  * Resolved parameters for swap operations after validation and normalization.
@@ -8293,8 +8444,8 @@ interface AppKitContext {
8293
8444
  *
8294
8445
  * This property stores event handlers that are registered via the AppKit's
8295
8446
  * `on()` method. Handlers are grouped by operation type. The runtime buckets
8296
- * are `bridge` and `earn`; the context can add more operation buckets as
8297
- * AppKit wires action handlers for additional kits.
8447
+ * are `bridge`, `earn`, and `borrow`; the context can add more operation
8448
+ * buckets as AppKit wires action handlers for additional kits.
8298
8449
  *
8299
8450
  * Within each operation bucket, handlers are keyed by action name (for
8300
8451
  * example, `bridge.approve` or `earn.deposit`) or `*` for wildcard handlers.
@@ -8313,13 +8464,13 @@ interface AppKitContext {
8313
8464
  * // Earn handlers are registered with EarnKit when earn operations run
8314
8465
  * ```
8315
8466
  */
8316
- actions: Record<'bridge' | 'earn', Record<string, ((payload: unknown) => void)[]>>;
8467
+ actions: Record<'bridge' | 'earn' | 'borrow', Record<string, ((payload: unknown) => void)[]>>;
8317
8468
  /**
8318
- * Disable success analytics for the underlying EarnKit, SwapKit, and
8319
- * UnifiedBalanceKit.
8469
+ * Disable success analytics for the underlying EarnKit, SwapKit,
8470
+ * BorrowKit, and UnifiedBalanceKit.
8320
8471
  *
8321
- * When `true`, completed earn, swap, and unified balance operations will not
8322
- * POST analytics events. This does not disable error reporting; use
8472
+ * When `true`, completed earn, swap, borrow, and unified balance operations
8473
+ * will not POST analytics events. This does not disable error reporting; use
8323
8474
  * {@link AppKitContext.disableErrorReporting} for that. Defaults to `false`.
8324
8475
  *
8325
8476
  * @defaultValue false
@@ -8329,7 +8480,7 @@ interface AppKitContext {
8329
8480
  * Disable error telemetry for all sub-kits.
8330
8481
  *
8331
8482
  * When `true`, none of the underlying kits (BridgeKit, SwapKit, EarnKit,
8332
- * UnifiedBalanceKit) will POST error details to the telemetry
8483
+ * BorrowKit, UnifiedBalanceKit) will POST error details to the telemetry
8333
8484
  * endpoint when operations throw. Defaults to `false` (enabled).
8334
8485
  *
8335
8486
  * @defaultValue false