@circle-fin/app-kit 1.15.3 → 1.16.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 (57) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.md +5 -2
  3. package/borrow.cjs +28028 -0
  4. package/borrow.cjs.map +1 -0
  5. package/borrow.d.cts +10723 -0
  6. package/borrow.d.mts +10723 -0
  7. package/borrow.d.ts +10723 -0
  8. package/borrow.mjs +28000 -0
  9. package/borrow.mjs.map +1 -0
  10. package/bridge.cjs +1885 -276
  11. package/bridge.d.cts +86 -12
  12. package/bridge.d.mts +86 -12
  13. package/bridge.d.ts +86 -12
  14. package/bridge.mjs +1885 -276
  15. package/chains.cjs +70 -3
  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 +70 -3
  20. package/context.cjs +1 -0
  21. package/context.d.cts +86 -12
  22. package/context.d.mts +86 -12
  23. package/context.d.ts +86 -12
  24. package/context.mjs +1 -0
  25. package/earn.cjs +4981 -3314
  26. package/earn.d.cts +1117 -981
  27. package/earn.d.mts +1117 -981
  28. package/earn.d.ts +1117 -981
  29. package/earn.mjs +4981 -3314
  30. package/estimateBridge.cjs +1883 -274
  31. package/estimateBridge.d.cts +86 -12
  32. package/estimateBridge.d.mts +86 -12
  33. package/estimateBridge.d.ts +86 -12
  34. package/estimateBridge.mjs +1883 -274
  35. package/estimateSwap.cjs +8554 -6931
  36. package/estimateSwap.d.cts +86 -12
  37. package/estimateSwap.d.mts +86 -12
  38. package/estimateSwap.d.ts +86 -12
  39. package/estimateSwap.mjs +8503 -6880
  40. package/index.cjs +30943 -18928
  41. package/index.d.cts +23051 -2742
  42. package/index.d.mts +23051 -2742
  43. package/index.d.ts +23051 -2742
  44. package/index.mjs +30884 -18922
  45. package/package.json +17 -7
  46. package/server.cjs +101 -6
  47. package/server.mjs +101 -6
  48. package/swap.cjs +8554 -6931
  49. package/swap.d.cts +86 -12
  50. package/swap.d.mts +86 -12
  51. package/swap.d.ts +86 -12
  52. package/swap.mjs +8503 -6880
  53. package/unifiedBalance.cjs +457 -128
  54. package/unifiedBalance.d.cts +108 -11
  55. package/unifiedBalance.d.mts +108 -11
  56. package/unifiedBalance.d.ts +108 -11
  57. package/unifiedBalance.mjs +457 -128
package/chains.cjs CHANGED
@@ -285,6 +285,11 @@ var EarnChain;
285
285
  "Arc",
286
286
  "Arc_Testnet"
287
287
  ];
288
+ var BorrowChain;
289
+ (function(BorrowChain) {
290
+ BorrowChain["Arc"] = "Arc";
291
+ BorrowChain["Arc_Testnet"] = "Arc_Testnet";
292
+ })(BorrowChain || (BorrowChain = {}));
288
293
 
289
294
  /**
290
295
  * Helper function to define a chain with proper TypeScript typing.
@@ -627,6 +632,29 @@ var EarnChain;
627
632
  * on EVM-compatible testnet chains. Use this address for testnet adapter
628
633
  * integrations (e.g., Arc Testnet).
629
634
  */ const ADAPTER_CONTRACT_EVM_TESTNET = '0xBBD70b01a1CAbc96d5b7b129Ae1AAabdf50dd40b';
635
+ /**
636
+ * The sender-preserving batching contract on Arc (`Multicall3From`).
637
+ *
638
+ * This predeploy batches calls like the ubiquitous Multicall3, but routes each
639
+ * subcall through Arc's `CallFrom` precompile
640
+ * (`0x1800000000000000000000000000000000000003`), which executes on behalf of
641
+ * the transaction's original sender. Every target therefore sees the calling
642
+ * EOA as `msg.sender`, which is what makes a plain, un-upgraded EOA capable of
643
+ * an atomic batch on Arc.
644
+ *
645
+ * Deployed at the same address on Arc Testnet and Arc Mainnet.
646
+ *
647
+ * @see https://docs.arc.io/arc/concepts/batched-transactions
648
+ */ const BATCHER_CONTRACT_ARC_TESTNET = '0x522fAf9A91c41c443c66765030741e4AaCe147D0';
649
+ /**
650
+ * The sender-preserving batching contract on Arc Mainnet (`Multicall3From`).
651
+ *
652
+ * See {@link BATCHER_CONTRACT_ARC_TESTNET} for how this contract works.
653
+ * Requires Arc's Zero7 hardfork, which activates the `CallFrom` precompile
654
+ * this contract depends on.
655
+ *
656
+ * @see https://docs.arc.io/arc/concepts/batched-transactions
657
+ */ const BATCHER_CONTRACT_ARC_MAINNET = '0x522fAf9A91c41c443c66765030741e4AaCe147D0';
630
658
  /**
631
659
  * The GatewayWallet contract address for EVM mainnet networks.
632
660
  *
@@ -766,7 +794,10 @@ var EarnChain;
766
794
  },
767
795
  kitContracts: {
768
796
  bridge: BRIDGE_CONTRACT_EVM_MAINNET,
769
- adapter: ADAPTER_CONTRACT_EVM_MAINNET
797
+ adapter: ADAPTER_CONTRACT_EVM_MAINNET,
798
+ // Arc is the only chain with a sender-preserving batcher, because it
799
+ // takes a precompile rather than an ordinary contract to build one.
800
+ senderPreservingBatcher: BATCHER_CONTRACT_ARC_MAINNET
770
801
  },
771
802
  gateway: {
772
803
  domain: 26,
@@ -837,7 +868,10 @@ var EarnChain;
837
868
  },
838
869
  kitContracts: {
839
870
  bridge: BRIDGE_CONTRACT_EVM_TESTNET,
840
- adapter: ADAPTER_CONTRACT_EVM_TESTNET
871
+ adapter: ADAPTER_CONTRACT_EVM_TESTNET,
872
+ // Arc is the only chain with a sender-preserving batcher, because it
873
+ // takes a precompile rather than an ordinary contract to build one.
874
+ senderPreservingBatcher: BATCHER_CONTRACT_ARC_TESTNET
841
875
  },
842
876
  gateway: {
843
877
  domain: 26,
@@ -4255,7 +4289,8 @@ var EarnChain;
4255
4289
  cctpx: zod.z.any().optional(),
4256
4290
  kitContracts: zod.z.object({
4257
4291
  bridge: zod.z.string().optional(),
4258
- adapter: zod.z.string().optional()
4292
+ adapter: zod.z.string().optional(),
4293
+ senderPreservingBatcher: zod.z.string().optional()
4259
4294
  }).optional(),
4260
4295
  gateway: gatewayConfigSchema.optional()
4261
4296
  });
@@ -4451,6 +4486,38 @@ var EarnChain;
4451
4486
  message: `"${chain.chain}" is not a supported earn chain. ` + `Supported chains: ${Object.values(EarnChain).join(', ')}`
4452
4487
  }))
4453
4488
  ]);
4489
+ /**
4490
+ * Zod schema for validating Borrow-specific chain identifiers.
4491
+ *
4492
+ * Validate that the provided chain is supported for Borrow Kit's loan
4493
+ * operations. Unlike {@link earnChainIdentifierSchema}, this includes Arc
4494
+ * mainnet as well as Arc Testnet.
4495
+ *
4496
+ * Accept a BorrowChain enum value, a matching string literal, or a
4497
+ * ChainDefinition for a supported chain.
4498
+ *
4499
+ * @example
4500
+ * ```typescript
4501
+ * import { borrowChainIdentifierSchema } from '@core/chains'
4502
+ * import { Arc, BorrowChain } from '@core/chains'
4503
+ *
4504
+ * // Valid
4505
+ * borrowChainIdentifierSchema.parse(BorrowChain.Arc)
4506
+ * borrowChainIdentifierSchema.parse('Arc')
4507
+ * borrowChainIdentifierSchema.parse(Arc)
4508
+ *
4509
+ * // Invalid (throws ZodError)
4510
+ * borrowChainIdentifierSchema.parse('Solana')
4511
+ * ```
4512
+ */ zod.z.union([
4513
+ zod.z.string().refine((val)=>val in BorrowChain, (val)=>({
4514
+ message: `"${val}" is not a supported borrow chain. ` + `Supported chains: ${Object.values(BorrowChain).join(', ')}`
4515
+ })),
4516
+ zod.z.nativeEnum(BorrowChain),
4517
+ chainDefinitionSchema.refine((chain)=>chain.chain in BorrowChain, (chain)=>({
4518
+ message: `"${chain.chain}" is not a supported borrow chain. ` + `Supported chains: ${Object.values(BorrowChain).join(', ')}`
4519
+ }))
4520
+ ]);
4454
4521
  // Widened views so `.includes()` accepts arbitrary strings under strict TS.
4455
4522
  const EARN_BRIDGE_SOURCE_CHAIN_VALUES = EARN_BRIDGE_SOURCE_BLOCKCHAINS;
4456
4523
  const EARN_BRIDGE_DESTINATION_CHAIN_VALUES = EARN_BRIDGE_DESTINATION_BLOCKCHAINS;
package/chains.d.cts CHANGED
@@ -151,6 +151,7 @@ declare const Arc: {
151
151
  readonly kitContracts: {
152
152
  readonly bridge: "0xB3FA262d0fB521cc93bE83d87b322b8A23DAf3F0";
153
153
  readonly adapter: "0x7FB8c7260b63934d8da38aF902f87ae6e284a845";
154
+ readonly senderPreservingBatcher: "0x522fAf9A91c41c443c66765030741e4AaCe147D0";
154
155
  };
155
156
  readonly gateway: {
156
157
  readonly domain: 26;
@@ -218,6 +219,7 @@ declare const ArcTestnet: {
218
219
  readonly kitContracts: {
219
220
  readonly bridge: "0xC5567a5E3370d4DBfB0540025078e283e36A363d";
220
221
  readonly adapter: "0xBBD70b01a1CAbc96d5b7b129Ae1AAabdf50dd40b";
222
+ readonly senderPreservingBatcher: "0x522fAf9A91c41c443c66765030741e4AaCe147D0";
221
223
  };
222
224
  readonly gateway: {
223
225
  readonly domain: 26;
package/chains.d.mts CHANGED
@@ -151,6 +151,7 @@ declare const Arc: {
151
151
  readonly kitContracts: {
152
152
  readonly bridge: "0xB3FA262d0fB521cc93bE83d87b322b8A23DAf3F0";
153
153
  readonly adapter: "0x7FB8c7260b63934d8da38aF902f87ae6e284a845";
154
+ readonly senderPreservingBatcher: "0x522fAf9A91c41c443c66765030741e4AaCe147D0";
154
155
  };
155
156
  readonly gateway: {
156
157
  readonly domain: 26;
@@ -218,6 +219,7 @@ declare const ArcTestnet: {
218
219
  readonly kitContracts: {
219
220
  readonly bridge: "0xC5567a5E3370d4DBfB0540025078e283e36A363d";
220
221
  readonly adapter: "0xBBD70b01a1CAbc96d5b7b129Ae1AAabdf50dd40b";
222
+ readonly senderPreservingBatcher: "0x522fAf9A91c41c443c66765030741e4AaCe147D0";
221
223
  };
222
224
  readonly gateway: {
223
225
  readonly domain: 26;
package/chains.d.ts CHANGED
@@ -151,6 +151,7 @@ declare const Arc: {
151
151
  readonly kitContracts: {
152
152
  readonly bridge: "0xB3FA262d0fB521cc93bE83d87b322b8A23DAf3F0";
153
153
  readonly adapter: "0x7FB8c7260b63934d8da38aF902f87ae6e284a845";
154
+ readonly senderPreservingBatcher: "0x522fAf9A91c41c443c66765030741e4AaCe147D0";
154
155
  };
155
156
  readonly gateway: {
156
157
  readonly domain: 26;
@@ -218,6 +219,7 @@ declare const ArcTestnet: {
218
219
  readonly kitContracts: {
219
220
  readonly bridge: "0xC5567a5E3370d4DBfB0540025078e283e36A363d";
220
221
  readonly adapter: "0xBBD70b01a1CAbc96d5b7b129Ae1AAabdf50dd40b";
222
+ readonly senderPreservingBatcher: "0x522fAf9A91c41c443c66765030741e4AaCe147D0";
221
223
  };
222
224
  readonly gateway: {
223
225
  readonly domain: 26;
package/chains.mjs CHANGED
@@ -283,6 +283,11 @@ var EarnChain;
283
283
  "Arc",
284
284
  "Arc_Testnet"
285
285
  ];
286
+ var BorrowChain;
287
+ (function(BorrowChain) {
288
+ BorrowChain["Arc"] = "Arc";
289
+ BorrowChain["Arc_Testnet"] = "Arc_Testnet";
290
+ })(BorrowChain || (BorrowChain = {}));
286
291
 
287
292
  /**
288
293
  * Helper function to define a chain with proper TypeScript typing.
@@ -625,6 +630,29 @@ var EarnChain;
625
630
  * on EVM-compatible testnet chains. Use this address for testnet adapter
626
631
  * integrations (e.g., Arc Testnet).
627
632
  */ const ADAPTER_CONTRACT_EVM_TESTNET = '0xBBD70b01a1CAbc96d5b7b129Ae1AAabdf50dd40b';
633
+ /**
634
+ * The sender-preserving batching contract on Arc (`Multicall3From`).
635
+ *
636
+ * This predeploy batches calls like the ubiquitous Multicall3, but routes each
637
+ * subcall through Arc's `CallFrom` precompile
638
+ * (`0x1800000000000000000000000000000000000003`), which executes on behalf of
639
+ * the transaction's original sender. Every target therefore sees the calling
640
+ * EOA as `msg.sender`, which is what makes a plain, un-upgraded EOA capable of
641
+ * an atomic batch on Arc.
642
+ *
643
+ * Deployed at the same address on Arc Testnet and Arc Mainnet.
644
+ *
645
+ * @see https://docs.arc.io/arc/concepts/batched-transactions
646
+ */ const BATCHER_CONTRACT_ARC_TESTNET = '0x522fAf9A91c41c443c66765030741e4AaCe147D0';
647
+ /**
648
+ * The sender-preserving batching contract on Arc Mainnet (`Multicall3From`).
649
+ *
650
+ * See {@link BATCHER_CONTRACT_ARC_TESTNET} for how this contract works.
651
+ * Requires Arc's Zero7 hardfork, which activates the `CallFrom` precompile
652
+ * this contract depends on.
653
+ *
654
+ * @see https://docs.arc.io/arc/concepts/batched-transactions
655
+ */ const BATCHER_CONTRACT_ARC_MAINNET = '0x522fAf9A91c41c443c66765030741e4AaCe147D0';
628
656
  /**
629
657
  * The GatewayWallet contract address for EVM mainnet networks.
630
658
  *
@@ -764,7 +792,10 @@ var EarnChain;
764
792
  },
765
793
  kitContracts: {
766
794
  bridge: BRIDGE_CONTRACT_EVM_MAINNET,
767
- adapter: ADAPTER_CONTRACT_EVM_MAINNET
795
+ adapter: ADAPTER_CONTRACT_EVM_MAINNET,
796
+ // Arc is the only chain with a sender-preserving batcher, because it
797
+ // takes a precompile rather than an ordinary contract to build one.
798
+ senderPreservingBatcher: BATCHER_CONTRACT_ARC_MAINNET
768
799
  },
769
800
  gateway: {
770
801
  domain: 26,
@@ -835,7 +866,10 @@ var EarnChain;
835
866
  },
836
867
  kitContracts: {
837
868
  bridge: BRIDGE_CONTRACT_EVM_TESTNET,
838
- adapter: ADAPTER_CONTRACT_EVM_TESTNET
869
+ adapter: ADAPTER_CONTRACT_EVM_TESTNET,
870
+ // Arc is the only chain with a sender-preserving batcher, because it
871
+ // takes a precompile rather than an ordinary contract to build one.
872
+ senderPreservingBatcher: BATCHER_CONTRACT_ARC_TESTNET
839
873
  },
840
874
  gateway: {
841
875
  domain: 26,
@@ -4253,7 +4287,8 @@ var EarnChain;
4253
4287
  cctpx: z.any().optional(),
4254
4288
  kitContracts: z.object({
4255
4289
  bridge: z.string().optional(),
4256
- adapter: z.string().optional()
4290
+ adapter: z.string().optional(),
4291
+ senderPreservingBatcher: z.string().optional()
4257
4292
  }).optional(),
4258
4293
  gateway: gatewayConfigSchema.optional()
4259
4294
  });
@@ -4449,6 +4484,38 @@ var EarnChain;
4449
4484
  message: `"${chain.chain}" is not a supported earn chain. ` + `Supported chains: ${Object.values(EarnChain).join(', ')}`
4450
4485
  }))
4451
4486
  ]);
4487
+ /**
4488
+ * Zod schema for validating Borrow-specific chain identifiers.
4489
+ *
4490
+ * Validate that the provided chain is supported for Borrow Kit's loan
4491
+ * operations. Unlike {@link earnChainIdentifierSchema}, this includes Arc
4492
+ * mainnet as well as Arc Testnet.
4493
+ *
4494
+ * Accept a BorrowChain enum value, a matching string literal, or a
4495
+ * ChainDefinition for a supported chain.
4496
+ *
4497
+ * @example
4498
+ * ```typescript
4499
+ * import { borrowChainIdentifierSchema } from '@core/chains'
4500
+ * import { Arc, BorrowChain } from '@core/chains'
4501
+ *
4502
+ * // Valid
4503
+ * borrowChainIdentifierSchema.parse(BorrowChain.Arc)
4504
+ * borrowChainIdentifierSchema.parse('Arc')
4505
+ * borrowChainIdentifierSchema.parse(Arc)
4506
+ *
4507
+ * // Invalid (throws ZodError)
4508
+ * borrowChainIdentifierSchema.parse('Solana')
4509
+ * ```
4510
+ */ z.union([
4511
+ z.string().refine((val)=>val in BorrowChain, (val)=>({
4512
+ message: `"${val}" is not a supported borrow chain. ` + `Supported chains: ${Object.values(BorrowChain).join(', ')}`
4513
+ })),
4514
+ z.nativeEnum(BorrowChain),
4515
+ chainDefinitionSchema.refine((chain)=>chain.chain in BorrowChain, (chain)=>({
4516
+ message: `"${chain.chain}" is not a supported borrow chain. ` + `Supported chains: ${Object.values(BorrowChain).join(', ')}`
4517
+ }))
4518
+ ]);
4452
4519
  // Widened views so `.includes()` accepts arbitrary strings under strict TS.
4453
4520
  const EARN_BRIDGE_SOURCE_CHAIN_VALUES = EARN_BRIDGE_SOURCE_BLOCKCHAINS;
4454
4521
  const EARN_BRIDGE_DESTINATION_CHAIN_VALUES = EARN_BRIDGE_DESTINATION_BLOCKCHAINS;
package/context.cjs CHANGED
@@ -62,6 +62,7 @@ if (typeof window !== 'undefined' && typeof window.Buffer === 'undefined') {
62
62
  actions: {
63
63
  bridge: {},
64
64
  earn: {},
65
+ borrow: {},
65
66
  ...params.actions
66
67
  }
67
68
  };
package/context.d.cts CHANGED
@@ -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
  *
@@ -1436,8 +1451,13 @@ type PreparedChainRequest = EvmPreparedChainRequest | SolanaPreparedChainRequest
1436
1451
  * Parameters for preparing an EVM contract execution.
1437
1452
  */
1438
1453
  type EvmPreparedChainRequestParams = {
1439
- /** The type of the prepared execution. */
1440
- type: 'evm';
1454
+ /**
1455
+ * The type of the prepared execution. Optional here because EVM is the
1456
+ * only chain type `Adapter.prepare()` implementations narrow their param
1457
+ * type to in practice — callers that only ever prepare EVM requests can
1458
+ * omit it rather than repeat a discriminator that never varies for them.
1459
+ */
1460
+ type?: 'evm';
1441
1461
  /** The ABI of the contract. */
1442
1462
  abi: Abi | string[];
1443
1463
  /** The address of the contract. */
@@ -2716,6 +2736,57 @@ interface EarnActionMap {
2716
2736
  readonly claimRewards: ExecuteEarnParams;
2717
2737
  }
2718
2738
 
2739
+ /** Permit standards accepted by Borrow Adapter executions. */
2740
+ declare enum BorrowPermitType {
2741
+ /** Tokens must be approved separately. */
2742
+ NONE = 0,
2743
+ /** EIP-2612 permit calldata accompanies the token input. */
2744
+ EIP2612 = 1
2745
+ }
2746
+ /** Token input forwarded by Borrow Kit to the Adapter Contract. */
2747
+ interface BorrowTokenInput {
2748
+ readonly permitType: BorrowPermitType;
2749
+ readonly token: `0x${string}`;
2750
+ readonly amount: bigint;
2751
+ readonly permitCalldata: `0x${string}`;
2752
+ }
2753
+ /** A single instruction in a Circle-signed Borrow execution. */
2754
+ interface BorrowInstruction {
2755
+ readonly target: `0x${string}`;
2756
+ readonly data: `0x${string}`;
2757
+ readonly value: string | bigint;
2758
+ readonly tokenIn: `0x${string}`;
2759
+ readonly amountToApprove: string | bigint;
2760
+ readonly tokenOut: `0x${string}`;
2761
+ readonly minTokenOut: string | bigint;
2762
+ }
2763
+ /** A token recipient in a Circle-signed Borrow execution. */
2764
+ interface BorrowTokenRecipient {
2765
+ readonly token: `0x${string}`;
2766
+ readonly beneficiary: `0x${string}`;
2767
+ }
2768
+ /** Circle-signed Borrow parameters forwarded to the Adapter Contract. */
2769
+ interface BorrowExecutionParams {
2770
+ readonly instructions: readonly BorrowInstruction[];
2771
+ readonly tokens: readonly BorrowTokenRecipient[];
2772
+ readonly execId: string | bigint;
2773
+ readonly deadline: string | bigint;
2774
+ readonly metadata: `0x${string}`;
2775
+ }
2776
+ /** Parameters for a service-signed Borrow Adapter execution. */
2777
+ interface ExecuteBorrowParams extends ActionParameters {
2778
+ readonly executeParams: BorrowExecutionParams;
2779
+ readonly tokenInputs: BorrowTokenInput[];
2780
+ readonly signature: `0x${string}`;
2781
+ }
2782
+ /** Borrow actions supported by EVM adapters. */
2783
+ interface BorrowActionMap {
2784
+ /** Execute a Circle-signed partial loan repayment. */
2785
+ readonly repay: ExecuteBorrowParams;
2786
+ /** Execute a Circle-signed borrow. */
2787
+ readonly execute: ExecuteBorrowParams;
2788
+ }
2789
+
2719
2790
  /**
2720
2791
  * Single instruction to execute within the Adapter Contract.
2721
2792
  *
@@ -3672,6 +3743,8 @@ interface NativeActionMap {
3672
3743
  * @see {@link ActionPayload} for extracting payload types
3673
3744
  */
3674
3745
  interface ActionMap {
3746
+ /** Borrow operations that execute service-signed payloads. */
3747
+ readonly borrow: BorrowActionMap;
3675
3748
  /** CCTP-specific operations with automatic address resolution. */
3676
3749
  readonly cctp: CCTPActionMap;
3677
3750
  /** CCTPx operations (CrossChainTokenService) for cross-chain transfers of registered tokens (Circle-issued or otherwise). */
@@ -3691,6 +3764,7 @@ interface ActionMap {
3691
3764
  /** Earn operations that execute service-signed payloads via the adapter contract. */
3692
3765
  readonly earn: EarnActionMap;
3693
3766
  }
3767
+
3694
3768
  /**
3695
3769
  * Determine if a type represents an action parameter object (leaf node).
3696
3770
  *
@@ -8087,8 +8161,8 @@ interface AppKitContext {
8087
8161
  *
8088
8162
  * This property stores event handlers that are registered via the AppKit's
8089
8163
  * `on()` method. Handlers are grouped by operation type. The runtime buckets
8090
- * are `bridge` and `earn`; the context can add more operation buckets as
8091
- * AppKit wires action handlers for additional kits.
8164
+ * are `bridge`, `earn`, and `borrow`; the context can add more operation
8165
+ * buckets as AppKit wires action handlers for additional kits.
8092
8166
  *
8093
8167
  * Within each operation bucket, handlers are keyed by action name (for
8094
8168
  * example, `bridge.approve` or `earn.deposit`) or `*` for wildcard handlers.
@@ -8107,13 +8181,13 @@ interface AppKitContext {
8107
8181
  * // Earn handlers are registered with EarnKit when earn operations run
8108
8182
  * ```
8109
8183
  */
8110
- actions: Record<'bridge' | 'earn', Record<string, ((payload: unknown) => void)[]>>;
8184
+ actions: Record<'bridge' | 'earn' | 'borrow', Record<string, ((payload: unknown) => void)[]>>;
8111
8185
  /**
8112
- * Disable success analytics for the underlying EarnKit, SwapKit, and
8113
- * UnifiedBalanceKit.
8186
+ * Disable success analytics for the underlying EarnKit, SwapKit,
8187
+ * BorrowKit, and UnifiedBalanceKit.
8114
8188
  *
8115
- * When `true`, completed earn, swap, and unified balance operations will not
8116
- * POST analytics events. This does not disable error reporting; use
8189
+ * When `true`, completed earn, swap, borrow, and unified balance operations
8190
+ * will not POST analytics events. This does not disable error reporting; use
8117
8191
  * {@link AppKitContext.disableErrorReporting} for that. Defaults to `false`.
8118
8192
  *
8119
8193
  * @defaultValue false
@@ -8123,7 +8197,7 @@ interface AppKitContext {
8123
8197
  * Disable error telemetry for all sub-kits.
8124
8198
  *
8125
8199
  * When `true`, none of the underlying kits (BridgeKit, SwapKit, EarnKit,
8126
- * UnifiedBalanceKit) will POST error details to the telemetry
8200
+ * BorrowKit, UnifiedBalanceKit) will POST error details to the telemetry
8127
8201
  * endpoint when operations throw. Defaults to `false` (enabled).
8128
8202
  *
8129
8203
  * @defaultValue false
package/context.d.mts CHANGED
@@ -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
  *
@@ -1436,8 +1451,13 @@ type PreparedChainRequest = EvmPreparedChainRequest | SolanaPreparedChainRequest
1436
1451
  * Parameters for preparing an EVM contract execution.
1437
1452
  */
1438
1453
  type EvmPreparedChainRequestParams = {
1439
- /** The type of the prepared execution. */
1440
- type: 'evm';
1454
+ /**
1455
+ * The type of the prepared execution. Optional here because EVM is the
1456
+ * only chain type `Adapter.prepare()` implementations narrow their param
1457
+ * type to in practice — callers that only ever prepare EVM requests can
1458
+ * omit it rather than repeat a discriminator that never varies for them.
1459
+ */
1460
+ type?: 'evm';
1441
1461
  /** The ABI of the contract. */
1442
1462
  abi: Abi | string[];
1443
1463
  /** The address of the contract. */
@@ -2716,6 +2736,57 @@ interface EarnActionMap {
2716
2736
  readonly claimRewards: ExecuteEarnParams;
2717
2737
  }
2718
2738
 
2739
+ /** Permit standards accepted by Borrow Adapter executions. */
2740
+ declare enum BorrowPermitType {
2741
+ /** Tokens must be approved separately. */
2742
+ NONE = 0,
2743
+ /** EIP-2612 permit calldata accompanies the token input. */
2744
+ EIP2612 = 1
2745
+ }
2746
+ /** Token input forwarded by Borrow Kit to the Adapter Contract. */
2747
+ interface BorrowTokenInput {
2748
+ readonly permitType: BorrowPermitType;
2749
+ readonly token: `0x${string}`;
2750
+ readonly amount: bigint;
2751
+ readonly permitCalldata: `0x${string}`;
2752
+ }
2753
+ /** A single instruction in a Circle-signed Borrow execution. */
2754
+ interface BorrowInstruction {
2755
+ readonly target: `0x${string}`;
2756
+ readonly data: `0x${string}`;
2757
+ readonly value: string | bigint;
2758
+ readonly tokenIn: `0x${string}`;
2759
+ readonly amountToApprove: string | bigint;
2760
+ readonly tokenOut: `0x${string}`;
2761
+ readonly minTokenOut: string | bigint;
2762
+ }
2763
+ /** A token recipient in a Circle-signed Borrow execution. */
2764
+ interface BorrowTokenRecipient {
2765
+ readonly token: `0x${string}`;
2766
+ readonly beneficiary: `0x${string}`;
2767
+ }
2768
+ /** Circle-signed Borrow parameters forwarded to the Adapter Contract. */
2769
+ interface BorrowExecutionParams {
2770
+ readonly instructions: readonly BorrowInstruction[];
2771
+ readonly tokens: readonly BorrowTokenRecipient[];
2772
+ readonly execId: string | bigint;
2773
+ readonly deadline: string | bigint;
2774
+ readonly metadata: `0x${string}`;
2775
+ }
2776
+ /** Parameters for a service-signed Borrow Adapter execution. */
2777
+ interface ExecuteBorrowParams extends ActionParameters {
2778
+ readonly executeParams: BorrowExecutionParams;
2779
+ readonly tokenInputs: BorrowTokenInput[];
2780
+ readonly signature: `0x${string}`;
2781
+ }
2782
+ /** Borrow actions supported by EVM adapters. */
2783
+ interface BorrowActionMap {
2784
+ /** Execute a Circle-signed partial loan repayment. */
2785
+ readonly repay: ExecuteBorrowParams;
2786
+ /** Execute a Circle-signed borrow. */
2787
+ readonly execute: ExecuteBorrowParams;
2788
+ }
2789
+
2719
2790
  /**
2720
2791
  * Single instruction to execute within the Adapter Contract.
2721
2792
  *
@@ -3672,6 +3743,8 @@ interface NativeActionMap {
3672
3743
  * @see {@link ActionPayload} for extracting payload types
3673
3744
  */
3674
3745
  interface ActionMap {
3746
+ /** Borrow operations that execute service-signed payloads. */
3747
+ readonly borrow: BorrowActionMap;
3675
3748
  /** CCTP-specific operations with automatic address resolution. */
3676
3749
  readonly cctp: CCTPActionMap;
3677
3750
  /** CCTPx operations (CrossChainTokenService) for cross-chain transfers of registered tokens (Circle-issued or otherwise). */
@@ -3691,6 +3764,7 @@ interface ActionMap {
3691
3764
  /** Earn operations that execute service-signed payloads via the adapter contract. */
3692
3765
  readonly earn: EarnActionMap;
3693
3766
  }
3767
+
3694
3768
  /**
3695
3769
  * Determine if a type represents an action parameter object (leaf node).
3696
3770
  *
@@ -8087,8 +8161,8 @@ interface AppKitContext {
8087
8161
  *
8088
8162
  * This property stores event handlers that are registered via the AppKit's
8089
8163
  * `on()` method. Handlers are grouped by operation type. The runtime buckets
8090
- * are `bridge` and `earn`; the context can add more operation buckets as
8091
- * AppKit wires action handlers for additional kits.
8164
+ * are `bridge`, `earn`, and `borrow`; the context can add more operation
8165
+ * buckets as AppKit wires action handlers for additional kits.
8092
8166
  *
8093
8167
  * Within each operation bucket, handlers are keyed by action name (for
8094
8168
  * example, `bridge.approve` or `earn.deposit`) or `*` for wildcard handlers.
@@ -8107,13 +8181,13 @@ interface AppKitContext {
8107
8181
  * // Earn handlers are registered with EarnKit when earn operations run
8108
8182
  * ```
8109
8183
  */
8110
- actions: Record<'bridge' | 'earn', Record<string, ((payload: unknown) => void)[]>>;
8184
+ actions: Record<'bridge' | 'earn' | 'borrow', Record<string, ((payload: unknown) => void)[]>>;
8111
8185
  /**
8112
- * Disable success analytics for the underlying EarnKit, SwapKit, and
8113
- * UnifiedBalanceKit.
8186
+ * Disable success analytics for the underlying EarnKit, SwapKit,
8187
+ * BorrowKit, and UnifiedBalanceKit.
8114
8188
  *
8115
- * When `true`, completed earn, swap, and unified balance operations will not
8116
- * POST analytics events. This does not disable error reporting; use
8189
+ * When `true`, completed earn, swap, borrow, and unified balance operations
8190
+ * will not POST analytics events. This does not disable error reporting; use
8117
8191
  * {@link AppKitContext.disableErrorReporting} for that. Defaults to `false`.
8118
8192
  *
8119
8193
  * @defaultValue false
@@ -8123,7 +8197,7 @@ interface AppKitContext {
8123
8197
  * Disable error telemetry for all sub-kits.
8124
8198
  *
8125
8199
  * When `true`, none of the underlying kits (BridgeKit, SwapKit, EarnKit,
8126
- * UnifiedBalanceKit) will POST error details to the telemetry
8200
+ * BorrowKit, UnifiedBalanceKit) will POST error details to the telemetry
8127
8201
  * endpoint when operations throw. Defaults to `false` (enabled).
8128
8202
  *
8129
8203
  * @defaultValue false