@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.
- package/CHANGELOG.md +91 -0
- package/README.md +5 -2
- package/borrow.cjs +28146 -0
- package/borrow.cjs.map +1 -0
- package/borrow.d.cts +10752 -0
- package/borrow.d.mts +10752 -0
- package/borrow.d.ts +10752 -0
- package/borrow.mjs +28118 -0
- package/borrow.mjs.map +1 -0
- package/bridge.cjs +2084 -328
- package/bridge.d.cts +121 -18
- package/bridge.d.mts +121 -18
- package/bridge.d.ts +121 -18
- package/bridge.mjs +2084 -328
- package/chains.cjs +78 -7
- package/chains.d.cts +2 -0
- package/chains.d.mts +2 -0
- package/chains.d.ts +2 -0
- package/chains.mjs +78 -7
- package/context.cjs +1 -0
- package/context.d.cts +121 -18
- package/context.d.mts +121 -18
- package/context.d.ts +121 -18
- package/context.mjs +1 -0
- package/earn.cjs +5322 -3219
- package/earn.d.cts +1149 -984
- package/earn.d.mts +1149 -984
- package/earn.d.ts +1149 -984
- package/earn.mjs +5322 -3219
- package/estimateBridge.cjs +2082 -326
- package/estimateBridge.d.cts +121 -18
- package/estimateBridge.d.mts +121 -18
- package/estimateBridge.d.ts +121 -18
- package/estimateBridge.mjs +2082 -326
- package/estimateSwap.cjs +8817 -6974
- package/estimateSwap.d.cts +169 -18
- package/estimateSwap.d.mts +169 -18
- package/estimateSwap.d.ts +169 -18
- package/estimateSwap.mjs +8822 -6979
- package/index.cjs +33149 -20719
- package/index.d.cts +23174 -2736
- package/index.d.mts +23174 -2736
- package/index.d.ts +23174 -2736
- package/index.mjs +33090 -20713
- package/package.json +17 -7
- package/server.cjs +133 -12
- package/server.d.cts +29 -10
- package/server.d.mts +29 -10
- package/server.d.ts +29 -10
- package/server.mjs +133 -12
- package/swap.cjs +8817 -6974
- package/swap.d.cts +169 -18
- package/swap.d.mts +169 -18
- package/swap.d.ts +169 -18
- package/swap.mjs +8822 -6979
- package/unifiedBalance.cjs +528 -138
- package/unifiedBalance.d.cts +108 -11
- package/unifiedBalance.d.mts +108 -11
- package/unifiedBalance.d.ts +108 -11
- package/unifiedBalance.mjs +528 -138
package/chains.cjs
CHANGED
|
@@ -154,6 +154,8 @@ var SwapChain;
|
|
|
154
154
|
SwapChain["HyperEVM"] = "HyperEVM";
|
|
155
155
|
SwapChain["Monad"] = "Monad";
|
|
156
156
|
SwapChain["Arc"] = "Arc";
|
|
157
|
+
SwapChain["Cronos"] = "Cronos";
|
|
158
|
+
SwapChain["Morph"] = "Morph";
|
|
157
159
|
// Testnet chains with swap support
|
|
158
160
|
SwapChain["Arc_Testnet"] = "Arc_Testnet";
|
|
159
161
|
})(SwapChain || (SwapChain = {}));
|
|
@@ -285,6 +287,11 @@ var EarnChain;
|
|
|
285
287
|
"Arc",
|
|
286
288
|
"Arc_Testnet"
|
|
287
289
|
];
|
|
290
|
+
var BorrowChain;
|
|
291
|
+
(function(BorrowChain) {
|
|
292
|
+
BorrowChain["Arc"] = "Arc";
|
|
293
|
+
BorrowChain["Arc_Testnet"] = "Arc_Testnet";
|
|
294
|
+
})(BorrowChain || (BorrowChain = {}));
|
|
288
295
|
|
|
289
296
|
/**
|
|
290
297
|
* Helper function to define a chain with proper TypeScript typing.
|
|
@@ -627,6 +634,29 @@ var EarnChain;
|
|
|
627
634
|
* on EVM-compatible testnet chains. Use this address for testnet adapter
|
|
628
635
|
* integrations (e.g., Arc Testnet).
|
|
629
636
|
*/ const ADAPTER_CONTRACT_EVM_TESTNET = '0xBBD70b01a1CAbc96d5b7b129Ae1AAabdf50dd40b';
|
|
637
|
+
/**
|
|
638
|
+
* The sender-preserving batching contract on Arc (`Multicall3From`).
|
|
639
|
+
*
|
|
640
|
+
* This predeploy batches calls like the ubiquitous Multicall3, but routes each
|
|
641
|
+
* subcall through Arc's `CallFrom` precompile
|
|
642
|
+
* (`0x1800000000000000000000000000000000000003`), which executes on behalf of
|
|
643
|
+
* the transaction's original sender. Every target therefore sees the calling
|
|
644
|
+
* EOA as `msg.sender`, which is what makes a plain, un-upgraded EOA capable of
|
|
645
|
+
* an atomic batch on Arc.
|
|
646
|
+
*
|
|
647
|
+
* Deployed at the same address on Arc Testnet and Arc Mainnet.
|
|
648
|
+
*
|
|
649
|
+
* @see https://docs.arc.io/arc/concepts/batched-transactions
|
|
650
|
+
*/ const BATCHER_CONTRACT_ARC_TESTNET = '0x522fAf9A91c41c443c66765030741e4AaCe147D0';
|
|
651
|
+
/**
|
|
652
|
+
* The sender-preserving batching contract on Arc Mainnet (`Multicall3From`).
|
|
653
|
+
*
|
|
654
|
+
* See {@link BATCHER_CONTRACT_ARC_TESTNET} for how this contract works.
|
|
655
|
+
* Requires Arc's Zero7 hardfork, which activates the `CallFrom` precompile
|
|
656
|
+
* this contract depends on.
|
|
657
|
+
*
|
|
658
|
+
* @see https://docs.arc.io/arc/concepts/batched-transactions
|
|
659
|
+
*/ const BATCHER_CONTRACT_ARC_MAINNET = '0x522fAf9A91c41c443c66765030741e4AaCe147D0';
|
|
630
660
|
/**
|
|
631
661
|
* The GatewayWallet contract address for EVM mainnet networks.
|
|
632
662
|
*
|
|
@@ -766,7 +796,10 @@ var EarnChain;
|
|
|
766
796
|
},
|
|
767
797
|
kitContracts: {
|
|
768
798
|
bridge: BRIDGE_CONTRACT_EVM_MAINNET,
|
|
769
|
-
adapter: ADAPTER_CONTRACT_EVM_MAINNET
|
|
799
|
+
adapter: ADAPTER_CONTRACT_EVM_MAINNET,
|
|
800
|
+
// Arc is the only chain with a sender-preserving batcher, because it
|
|
801
|
+
// takes a precompile rather than an ordinary contract to build one.
|
|
802
|
+
senderPreservingBatcher: BATCHER_CONTRACT_ARC_MAINNET
|
|
770
803
|
},
|
|
771
804
|
gateway: {
|
|
772
805
|
domain: 26,
|
|
@@ -837,7 +870,10 @@ var EarnChain;
|
|
|
837
870
|
},
|
|
838
871
|
kitContracts: {
|
|
839
872
|
bridge: BRIDGE_CONTRACT_EVM_TESTNET,
|
|
840
|
-
adapter: ADAPTER_CONTRACT_EVM_TESTNET
|
|
873
|
+
adapter: ADAPTER_CONTRACT_EVM_TESTNET,
|
|
874
|
+
// Arc is the only chain with a sender-preserving batcher, because it
|
|
875
|
+
// takes a precompile rather than an ordinary contract to build one.
|
|
876
|
+
senderPreservingBatcher: BATCHER_CONTRACT_ARC_TESTNET
|
|
841
877
|
},
|
|
842
878
|
gateway: {
|
|
843
879
|
domain: 26,
|
|
@@ -1452,7 +1488,8 @@ var EarnChain;
|
|
|
1452
1488
|
}
|
|
1453
1489
|
},
|
|
1454
1490
|
kitContracts: {
|
|
1455
|
-
bridge: BRIDGE_CONTRACT_EVM_MAINNET
|
|
1491
|
+
bridge: BRIDGE_CONTRACT_EVM_MAINNET,
|
|
1492
|
+
adapter: ADAPTER_CONTRACT_EVM_MAINNET
|
|
1456
1493
|
}
|
|
1457
1494
|
});
|
|
1458
1495
|
|
|
@@ -2321,7 +2358,8 @@ var EarnChain;
|
|
|
2321
2358
|
}
|
|
2322
2359
|
},
|
|
2323
2360
|
kitContracts: {
|
|
2324
|
-
bridge: BRIDGE_CONTRACT_EVM_MAINNET
|
|
2361
|
+
bridge: BRIDGE_CONTRACT_EVM_MAINNET,
|
|
2362
|
+
adapter: ADAPTER_CONTRACT_EVM_MAINNET
|
|
2325
2363
|
}
|
|
2326
2364
|
});
|
|
2327
2365
|
|
|
@@ -4255,7 +4293,8 @@ var EarnChain;
|
|
|
4255
4293
|
cctpx: zod.z.any().optional(),
|
|
4256
4294
|
kitContracts: zod.z.object({
|
|
4257
4295
|
bridge: zod.z.string().optional(),
|
|
4258
|
-
adapter: zod.z.string().optional()
|
|
4296
|
+
adapter: zod.z.string().optional(),
|
|
4297
|
+
senderPreservingBatcher: zod.z.string().optional()
|
|
4259
4298
|
}).optional(),
|
|
4260
4299
|
gateway: gatewayConfigSchema.optional()
|
|
4261
4300
|
});
|
|
@@ -4366,8 +4405,8 @@ var EarnChain;
|
|
|
4366
4405
|
* Zod schema for validating swap-specific chain identifiers.
|
|
4367
4406
|
*
|
|
4368
4407
|
* Validates chains based on:
|
|
4369
|
-
* -
|
|
4370
|
-
* - Mainnet
|
|
4408
|
+
* - Membership in the SwapChain enum
|
|
4409
|
+
* - Mainnet or explicitly allowlisted testnet
|
|
4371
4410
|
* - At least one supported token available
|
|
4372
4411
|
*
|
|
4373
4412
|
*/ zod.z.union([
|
|
@@ -4451,6 +4490,38 @@ var EarnChain;
|
|
|
4451
4490
|
message: `"${chain.chain}" is not a supported earn chain. ` + `Supported chains: ${Object.values(EarnChain).join(', ')}`
|
|
4452
4491
|
}))
|
|
4453
4492
|
]);
|
|
4493
|
+
/**
|
|
4494
|
+
* Zod schema for validating Borrow-specific chain identifiers.
|
|
4495
|
+
*
|
|
4496
|
+
* Validate that the provided chain is supported for Borrow Kit's loan
|
|
4497
|
+
* operations. Unlike {@link earnChainIdentifierSchema}, this includes Arc
|
|
4498
|
+
* mainnet as well as Arc Testnet.
|
|
4499
|
+
*
|
|
4500
|
+
* Accept a BorrowChain enum value, a matching string literal, or a
|
|
4501
|
+
* ChainDefinition for a supported chain.
|
|
4502
|
+
*
|
|
4503
|
+
* @example
|
|
4504
|
+
* ```typescript
|
|
4505
|
+
* import { borrowChainIdentifierSchema } from '@core/chains'
|
|
4506
|
+
* import { Arc, BorrowChain } from '@core/chains'
|
|
4507
|
+
*
|
|
4508
|
+
* // Valid
|
|
4509
|
+
* borrowChainIdentifierSchema.parse(BorrowChain.Arc)
|
|
4510
|
+
* borrowChainIdentifierSchema.parse('Arc')
|
|
4511
|
+
* borrowChainIdentifierSchema.parse(Arc)
|
|
4512
|
+
*
|
|
4513
|
+
* // Invalid (throws ZodError)
|
|
4514
|
+
* borrowChainIdentifierSchema.parse('Solana')
|
|
4515
|
+
* ```
|
|
4516
|
+
*/ zod.z.union([
|
|
4517
|
+
zod.z.string().refine((val)=>val in BorrowChain, (val)=>({
|
|
4518
|
+
message: `"${val}" is not a supported borrow chain. ` + `Supported chains: ${Object.values(BorrowChain).join(', ')}`
|
|
4519
|
+
})),
|
|
4520
|
+
zod.z.nativeEnum(BorrowChain),
|
|
4521
|
+
chainDefinitionSchema.refine((chain)=>chain.chain in BorrowChain, (chain)=>({
|
|
4522
|
+
message: `"${chain.chain}" is not a supported borrow chain. ` + `Supported chains: ${Object.values(BorrowChain).join(', ')}`
|
|
4523
|
+
}))
|
|
4524
|
+
]);
|
|
4454
4525
|
// Widened views so `.includes()` accepts arbitrary strings under strict TS.
|
|
4455
4526
|
const EARN_BRIDGE_SOURCE_CHAIN_VALUES = EARN_BRIDGE_SOURCE_BLOCKCHAINS;
|
|
4456
4527
|
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
|
@@ -152,6 +152,8 @@ var SwapChain;
|
|
|
152
152
|
SwapChain["HyperEVM"] = "HyperEVM";
|
|
153
153
|
SwapChain["Monad"] = "Monad";
|
|
154
154
|
SwapChain["Arc"] = "Arc";
|
|
155
|
+
SwapChain["Cronos"] = "Cronos";
|
|
156
|
+
SwapChain["Morph"] = "Morph";
|
|
155
157
|
// Testnet chains with swap support
|
|
156
158
|
SwapChain["Arc_Testnet"] = "Arc_Testnet";
|
|
157
159
|
})(SwapChain || (SwapChain = {}));
|
|
@@ -283,6 +285,11 @@ var EarnChain;
|
|
|
283
285
|
"Arc",
|
|
284
286
|
"Arc_Testnet"
|
|
285
287
|
];
|
|
288
|
+
var BorrowChain;
|
|
289
|
+
(function(BorrowChain) {
|
|
290
|
+
BorrowChain["Arc"] = "Arc";
|
|
291
|
+
BorrowChain["Arc_Testnet"] = "Arc_Testnet";
|
|
292
|
+
})(BorrowChain || (BorrowChain = {}));
|
|
286
293
|
|
|
287
294
|
/**
|
|
288
295
|
* Helper function to define a chain with proper TypeScript typing.
|
|
@@ -625,6 +632,29 @@ var EarnChain;
|
|
|
625
632
|
* on EVM-compatible testnet chains. Use this address for testnet adapter
|
|
626
633
|
* integrations (e.g., Arc Testnet).
|
|
627
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';
|
|
628
658
|
/**
|
|
629
659
|
* The GatewayWallet contract address for EVM mainnet networks.
|
|
630
660
|
*
|
|
@@ -764,7 +794,10 @@ var EarnChain;
|
|
|
764
794
|
},
|
|
765
795
|
kitContracts: {
|
|
766
796
|
bridge: BRIDGE_CONTRACT_EVM_MAINNET,
|
|
767
|
-
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
|
|
768
801
|
},
|
|
769
802
|
gateway: {
|
|
770
803
|
domain: 26,
|
|
@@ -835,7 +868,10 @@ var EarnChain;
|
|
|
835
868
|
},
|
|
836
869
|
kitContracts: {
|
|
837
870
|
bridge: BRIDGE_CONTRACT_EVM_TESTNET,
|
|
838
|
-
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
|
|
839
875
|
},
|
|
840
876
|
gateway: {
|
|
841
877
|
domain: 26,
|
|
@@ -1450,7 +1486,8 @@ var EarnChain;
|
|
|
1450
1486
|
}
|
|
1451
1487
|
},
|
|
1452
1488
|
kitContracts: {
|
|
1453
|
-
bridge: BRIDGE_CONTRACT_EVM_MAINNET
|
|
1489
|
+
bridge: BRIDGE_CONTRACT_EVM_MAINNET,
|
|
1490
|
+
adapter: ADAPTER_CONTRACT_EVM_MAINNET
|
|
1454
1491
|
}
|
|
1455
1492
|
});
|
|
1456
1493
|
|
|
@@ -2319,7 +2356,8 @@ var EarnChain;
|
|
|
2319
2356
|
}
|
|
2320
2357
|
},
|
|
2321
2358
|
kitContracts: {
|
|
2322
|
-
bridge: BRIDGE_CONTRACT_EVM_MAINNET
|
|
2359
|
+
bridge: BRIDGE_CONTRACT_EVM_MAINNET,
|
|
2360
|
+
adapter: ADAPTER_CONTRACT_EVM_MAINNET
|
|
2323
2361
|
}
|
|
2324
2362
|
});
|
|
2325
2363
|
|
|
@@ -4253,7 +4291,8 @@ var EarnChain;
|
|
|
4253
4291
|
cctpx: z.any().optional(),
|
|
4254
4292
|
kitContracts: z.object({
|
|
4255
4293
|
bridge: z.string().optional(),
|
|
4256
|
-
adapter: z.string().optional()
|
|
4294
|
+
adapter: z.string().optional(),
|
|
4295
|
+
senderPreservingBatcher: z.string().optional()
|
|
4257
4296
|
}).optional(),
|
|
4258
4297
|
gateway: gatewayConfigSchema.optional()
|
|
4259
4298
|
});
|
|
@@ -4364,8 +4403,8 @@ var EarnChain;
|
|
|
4364
4403
|
* Zod schema for validating swap-specific chain identifiers.
|
|
4365
4404
|
*
|
|
4366
4405
|
* Validates chains based on:
|
|
4367
|
-
* -
|
|
4368
|
-
* - Mainnet
|
|
4406
|
+
* - Membership in the SwapChain enum
|
|
4407
|
+
* - Mainnet or explicitly allowlisted testnet
|
|
4369
4408
|
* - At least one supported token available
|
|
4370
4409
|
*
|
|
4371
4410
|
*/ z.union([
|
|
@@ -4449,6 +4488,38 @@ var EarnChain;
|
|
|
4449
4488
|
message: `"${chain.chain}" is not a supported earn chain. ` + `Supported chains: ${Object.values(EarnChain).join(', ')}`
|
|
4450
4489
|
}))
|
|
4451
4490
|
]);
|
|
4491
|
+
/**
|
|
4492
|
+
* Zod schema for validating Borrow-specific chain identifiers.
|
|
4493
|
+
*
|
|
4494
|
+
* Validate that the provided chain is supported for Borrow Kit's loan
|
|
4495
|
+
* operations. Unlike {@link earnChainIdentifierSchema}, this includes Arc
|
|
4496
|
+
* mainnet as well as Arc Testnet.
|
|
4497
|
+
*
|
|
4498
|
+
* Accept a BorrowChain enum value, a matching string literal, or a
|
|
4499
|
+
* ChainDefinition for a supported chain.
|
|
4500
|
+
*
|
|
4501
|
+
* @example
|
|
4502
|
+
* ```typescript
|
|
4503
|
+
* import { borrowChainIdentifierSchema } from '@core/chains'
|
|
4504
|
+
* import { Arc, BorrowChain } from '@core/chains'
|
|
4505
|
+
*
|
|
4506
|
+
* // Valid
|
|
4507
|
+
* borrowChainIdentifierSchema.parse(BorrowChain.Arc)
|
|
4508
|
+
* borrowChainIdentifierSchema.parse('Arc')
|
|
4509
|
+
* borrowChainIdentifierSchema.parse(Arc)
|
|
4510
|
+
*
|
|
4511
|
+
* // Invalid (throws ZodError)
|
|
4512
|
+
* borrowChainIdentifierSchema.parse('Solana')
|
|
4513
|
+
* ```
|
|
4514
|
+
*/ z.union([
|
|
4515
|
+
z.string().refine((val)=>val in BorrowChain, (val)=>({
|
|
4516
|
+
message: `"${val}" is not a supported borrow chain. ` + `Supported chains: ${Object.values(BorrowChain).join(', ')}`
|
|
4517
|
+
})),
|
|
4518
|
+
z.nativeEnum(BorrowChain),
|
|
4519
|
+
chainDefinitionSchema.refine((chain)=>chain.chain in BorrowChain, (chain)=>({
|
|
4520
|
+
message: `"${chain.chain}" is not a supported borrow chain. ` + `Supported chains: ${Object.values(BorrowChain).join(', ')}`
|
|
4521
|
+
}))
|
|
4522
|
+
]);
|
|
4452
4523
|
// Widened views so `.includes()` accepts arbitrary strings under strict TS.
|
|
4453
4524
|
const EARN_BRIDGE_SOURCE_CHAIN_VALUES = EARN_BRIDGE_SOURCE_BLOCKCHAINS;
|
|
4454
4525
|
const EARN_BRIDGE_DESTINATION_CHAIN_VALUES = EARN_BRIDGE_DESTINATION_BLOCKCHAINS;
|
package/context.cjs
CHANGED
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
|
-
|
|
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
|
|
902
|
+
* where Adapter contracts are deployed.
|
|
888
903
|
*
|
|
889
904
|
* Dynamic validation via {@link isSwapSupportedChain} ensures chains
|
|
890
|
-
* automatically work when
|
|
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
|
|
937
|
-
* -
|
|
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
|
-
/**
|
|
1440
|
-
|
|
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
|
*
|
|
@@ -6659,7 +6735,7 @@ interface ServiceSwapConfig {
|
|
|
6659
6735
|
*
|
|
6660
6736
|
* @defaultValue true
|
|
6661
6737
|
*/
|
|
6662
|
-
batchTransactions?: boolean;
|
|
6738
|
+
batchTransactions?: boolean | undefined;
|
|
6663
6739
|
}
|
|
6664
6740
|
/**
|
|
6665
6741
|
* Parameters for initiating a swap operation through the Stablecoin Service.
|
|
@@ -7123,6 +7199,33 @@ interface SwapConfig {
|
|
|
7123
7199
|
* `apiKey` is omitted, and `apiKey` takes precedence when both are set.
|
|
7124
7200
|
*/
|
|
7125
7201
|
kitKey?: string;
|
|
7202
|
+
/**
|
|
7203
|
+
* Enable or disable atomic batched execution of the approval and swap.
|
|
7204
|
+
*
|
|
7205
|
+
* When `true` (or omitted), an EVM swap that needs an on-chain ERC-20
|
|
7206
|
+
* approval submits the approval and the swap as one atomic batch if the
|
|
7207
|
+
* connected wallet supports it (EIP-5792, or a signing strategy that
|
|
7208
|
+
* declares atomic batching). Set to `false` to force the sequential
|
|
7209
|
+
* approve-then-swap flow.
|
|
7210
|
+
*
|
|
7211
|
+
* @remarks
|
|
7212
|
+
* Has no effect on the gasless permit path, native-token swaps, or Solana,
|
|
7213
|
+
* which already execute as a single transaction. USDT input always uses the
|
|
7214
|
+
* sequential path because its allowance must be reset to zero first. The
|
|
7215
|
+
* batched path relies on the wallet's own gas estimation for the swap call;
|
|
7216
|
+
* set `false` if your wallet under-estimates gas for complex routes or
|
|
7217
|
+
* rejects batched calls.
|
|
7218
|
+
*
|
|
7219
|
+
* @defaultValue `undefined` (batching attempted when the wallet supports it)
|
|
7220
|
+
*
|
|
7221
|
+
* @example
|
|
7222
|
+
* ```typescript
|
|
7223
|
+
* const config: SwapConfig = {
|
|
7224
|
+
* batchTransactions: false, // force sequential approve → swap
|
|
7225
|
+
* }
|
|
7226
|
+
* ```
|
|
7227
|
+
*/
|
|
7228
|
+
batchTransactions?: boolean | undefined;
|
|
7126
7229
|
}
|
|
7127
7230
|
/**
|
|
7128
7231
|
* Resolved parameters for swap operations after validation and normalization.
|
|
@@ -8087,8 +8190,8 @@ interface AppKitContext {
|
|
|
8087
8190
|
*
|
|
8088
8191
|
* This property stores event handlers that are registered via the AppKit's
|
|
8089
8192
|
* `on()` method. Handlers are grouped by operation type. The runtime buckets
|
|
8090
|
-
* are `bridge` and `
|
|
8091
|
-
* AppKit wires action handlers for additional kits.
|
|
8193
|
+
* are `bridge`, `earn`, and `borrow`; the context can add more operation
|
|
8194
|
+
* buckets as AppKit wires action handlers for additional kits.
|
|
8092
8195
|
*
|
|
8093
8196
|
* Within each operation bucket, handlers are keyed by action name (for
|
|
8094
8197
|
* example, `bridge.approve` or `earn.deposit`) or `*` for wildcard handlers.
|
|
@@ -8107,13 +8210,13 @@ interface AppKitContext {
|
|
|
8107
8210
|
* // Earn handlers are registered with EarnKit when earn operations run
|
|
8108
8211
|
* ```
|
|
8109
8212
|
*/
|
|
8110
|
-
actions: Record<'bridge' | 'earn', Record<string, ((payload: unknown) => void)[]>>;
|
|
8213
|
+
actions: Record<'bridge' | 'earn' | 'borrow', Record<string, ((payload: unknown) => void)[]>>;
|
|
8111
8214
|
/**
|
|
8112
|
-
* Disable success analytics for the underlying EarnKit, SwapKit,
|
|
8113
|
-
* UnifiedBalanceKit.
|
|
8215
|
+
* Disable success analytics for the underlying EarnKit, SwapKit,
|
|
8216
|
+
* BorrowKit, and UnifiedBalanceKit.
|
|
8114
8217
|
*
|
|
8115
|
-
* When `true`, completed earn, swap, and unified balance operations
|
|
8116
|
-
* POST analytics events. This does not disable error reporting; use
|
|
8218
|
+
* When `true`, completed earn, swap, borrow, and unified balance operations
|
|
8219
|
+
* will not POST analytics events. This does not disable error reporting; use
|
|
8117
8220
|
* {@link AppKitContext.disableErrorReporting} for that. Defaults to `false`.
|
|
8118
8221
|
*
|
|
8119
8222
|
* @defaultValue false
|
|
@@ -8123,7 +8226,7 @@ interface AppKitContext {
|
|
|
8123
8226
|
* Disable error telemetry for all sub-kits.
|
|
8124
8227
|
*
|
|
8125
8228
|
* When `true`, none of the underlying kits (BridgeKit, SwapKit, EarnKit,
|
|
8126
|
-
* UnifiedBalanceKit) will POST error details to the telemetry
|
|
8229
|
+
* BorrowKit, UnifiedBalanceKit) will POST error details to the telemetry
|
|
8127
8230
|
* endpoint when operations throw. Defaults to `false` (enabled).
|
|
8128
8231
|
*
|
|
8129
8232
|
* @defaultValue false
|