@circle-fin/app-kit 1.4.0 β†’ 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @circle-fin/app-kit
2
2
 
3
+ ## 1.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Improved README documentation with corrected code examples and updated architecture diagrams
8
+
3
9
  ## 1.4.0
4
10
 
5
11
  ### Minor Changes
package/README.md CHANGED
@@ -7,9 +7,9 @@
7
7
  [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
8
8
  [![Discord](https://img.shields.io/discord/473781666251538452?label=Discord&logo=discord)](https://discord.com/invite/buildoncircle)
9
9
 
10
- **A one-stop Circle SDK for building stablecoin (e.g. USDC) applications, providing a unified set of on-chain tools for bridging, swapping, and other stablecoin operations.**
10
+ **A one-stop Circle SDK for building stablecoin (e.g. USDC) applications, providing a unified set of on-chain tools for bridging, swapping, unified balance management, and other stablecoin operations.**
11
11
 
12
- _Making cross-chain transfers, same-chain swaps, and token sends as simple as a single function call_
12
+ _Making cross-chain transfers, same-chain swaps, unified balance management, and token sends as simple as a single function call_
13
13
 
14
14
  </div>
15
15
 
@@ -27,6 +27,7 @@ _Making cross-chain transfers, same-chain swaps, and token sends as simple as a
27
27
  - [πŸ”„ Same-Chain Swap](#-same-chain-swap)
28
28
  - [πŸ“Š Estimate Operations](#-estimate-operations)
29
29
  - [πŸ” Query Supported Chains](#-query-supported-chains)
30
+ - [πŸ’° Unified Balance](#-unified-balance)
30
31
  - [Configuration](#configuration)
31
32
  - [Send Parameters](#send-parameters)
32
33
  - [Swap Parameters](#swap-parameters)
@@ -53,11 +54,11 @@ _Making cross-chain transfers, same-chain swaps, and token sends as simple as a
53
54
 
54
55
  The App Kit ecosystem is Circle's open-source effort to streamline stablecoin development with SDKs that are easy to use correctly and hard to misuse. Kits are cross-framework (viem, ethers, @solana/web3) and integrate cleanly into any stack. They're opinionated with sensible defaults, but offer escape hatches for full control. A pluggable architecture makes implementation flexible, and all kits are interoperable, so they can be composed to suit a wide range of use cases.
55
56
 
56
- The App Kit provides a **unified interface** for both cross-chain transfers and same-chain swaps, abstracting away the complexity of choosing between bridging and swapping operations. It combines the power of Bridge Kit and Swap Kit into a single, cohesive API.
57
+ The App Kit provides a **unified interface** for cross-chain transfers, same-chain swaps, and unified balance management, abstracting away the complexity of choosing between operations. It combines the power of Bridge Kit, Swap Kit, and Unified Balance Kit into a single, cohesive API.
57
58
 
58
59
  ### Why App Kit?
59
60
 
60
- - **🎯 Unified interface**: Single API for both bridge and swap operations
61
+ - **🎯 Unified interface**: Single API for bridge, swap, and unified balance operations
61
62
  - **πŸ€– Smart routing**: Automatically selects the appropriate operation (bridge vs swap)
62
63
  - **⚑ Zero-config defaults**: Built-in reliable RPC endpoints - start building right away
63
64
  - **πŸ”§ Bring your own infrastructure**: Seamlessly integrate with your existing setup when needed
@@ -78,39 +79,40 @@ The App Kit provides a **unified interface** for both cross-chain transfers and
78
79
 
79
80
  ## Architecture Flow
80
81
 
81
- The App Kit follows a composable architecture that integrates Bridge Kit and Swap Kit:
82
+ The App Kit follows a composable architecture that integrates Bridge Kit, Swap Kit, and Unified Balance Kit:
82
83
 
83
84
  ```text
84
85
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
85
- β”‚ App Kit β”‚
86
+ β”‚ App Kit β”‚
86
87
  β”‚ (Unified Interface) β”‚
87
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
88
- β”‚
89
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
90
- β”‚ β”‚
91
- β–Ό β–Ό
92
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
93
- β”‚ Bridge Kit β”‚ β”‚ Swap Kit β”‚
94
- β”‚ (Cross-Chain) β”‚ β”‚ (Same-Chain) β”‚
95
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
96
- β”‚ β”‚
97
- β–Ό β–Ό
98
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
99
- β”‚ Provider β”‚ β”‚ Provider β”‚
100
- β”‚ (CCTPv2) β”‚ β”‚ (Service) β”‚
101
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
102
- β”‚ β”‚
103
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
104
- β–Ό
105
- β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
106
- β”‚ Adapter β”‚
107
- β”‚ (Blockchain) β”‚
108
- β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
88
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
89
+ β”‚
90
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
91
+ β”‚ β”‚ β”‚
92
+ β–Ό β–Ό β–Ό
93
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
94
+ β”‚ Bridge Kit β”‚ β”‚ Swap Kit β”‚ β”‚ Unified Balance Kit β”‚
95
+ β”‚ (Cross-Chain) β”‚ β”‚ (Same-Chain) β”‚ β”‚ (Cross-Chain) β”‚
96
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
97
+ β”‚ β”‚ β”‚
98
+ β–Ό β–Ό β–Ό
99
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
100
+ β”‚ Provider β”‚ β”‚ Provider β”‚ β”‚ Provider β”‚
101
+ β”‚ (CCTPv2) β”‚ β”‚ (Service) β”‚ β”‚ (Gateway v1) β”‚
102
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
103
+ β”‚ β”‚ β”‚
104
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
105
+ β”‚
106
+ β–Ό
107
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
108
+ β”‚ Adapter β”‚
109
+ β”‚ (Blockchain) β”‚
110
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
109
111
  ```
110
112
 
111
113
  1. **Adapter**: Handles blockchain-specific operations (wallets, transactions, gas)
112
- 2. **Provider**: Implements protocols (CCTPv2 for bridging, Circle Service for swaps)
113
- 3. **Bridge/Swap Kit**: Specialized kits for each operation type
114
+ 2. **Provider**: Implements protocols (CCTPv2 for bridging, Circle Service for swaps, Gateway for unified balance)
115
+ 3. **Bridge/Swap/Unified Balance Kit**: Specialized kits for each operation type
114
116
  4. **App Kit**: Unified orchestration layer providing a consistent API
115
117
 
116
118
  This separation ensures that each component has a single responsibility while maintaining seamless integration across the entire stablecoin operation lifecycle.
@@ -262,16 +264,75 @@ console.log(
262
264
  Check which chains support specific operations:
263
265
 
264
266
  ```typescript
267
+ // Get all chains (bridge, swap, and unified balance)
268
+ const allChains = kit.getSupportedChains()
269
+
265
270
  // Get all chains that support bridging
266
271
  const bridgeChains = kit.getSupportedChains('bridge')
267
272
 
268
273
  // Get all chains that support swapping
269
274
  const swapChains = kit.getSupportedChains('swap')
270
275
 
271
- // Get all chains (both bridge and swap)
272
- const allChains = kit.getSupportedChains()
276
+ // Get chains that support unified balance operations
277
+ const ubChains = kit.getSupportedChains('unifiedBalance')
278
+ ```
279
+
280
+ ### πŸ’° Unified Balance
281
+
282
+ Manage a unified, cross-chain USDC balance β€” deposit on any chain, spend on any other, query balances, and manage delegates:
283
+
284
+ ```typescript
285
+ import { AppKit } from '@circle-fin/app-kit'
286
+ import { createViemAdapterFromPrivateKey } from '@circle-fin/adapter-viem-v2'
287
+
288
+ const kit = new AppKit()
289
+ const adapter = createViemAdapterFromPrivateKey({
290
+ privateKey: process.env.PRIVATE_KEY as string,
291
+ })
292
+
293
+ // Query balances across all chains
294
+ const balances = await kit.unifiedBalance.getBalances({
295
+ token: 'USDC',
296
+ sources: { adapter },
297
+ })
298
+
299
+ // Deposit USDC into unified balance
300
+ const deposit = await kit.unifiedBalance.deposit({
301
+ from: { adapter, chain: 'Ethereum' },
302
+ amount: '100',
303
+ token: 'USDC',
304
+ })
305
+
306
+ // Spend from unified balance on a different chain
307
+ const spend = await kit.unifiedBalance.spend({
308
+ amount: '50',
309
+ token: 'USDC',
310
+ from: { adapter, allocations: [{ amount: '50', chain: 'Ethereum' }] },
311
+ to: { adapter, chain: 'Base' },
312
+ })
313
+
314
+ // Estimate spend fees before executing
315
+ const estimate = await kit.unifiedBalance.estimateSpend({
316
+ amount: '50',
317
+ token: 'USDC',
318
+ from: { adapter, allocations: [{ amount: '50', chain: 'Ethereum' }] },
319
+ to: { adapter, chain: 'Base' },
320
+ })
321
+
322
+ // Manage delegates
323
+ await kit.unifiedBalance.addDelegate({
324
+ from: { adapter, chain: 'Ethereum' },
325
+ delegateAddress: '0xDelegate…',
326
+ })
327
+
328
+ // Listen to unified balance events
329
+ kit.on('unifiedBalance.gateway.spend.succeeded', (payload) => {
330
+ console.log('Spend succeeded:', payload)
331
+ })
273
332
  ```
274
333
 
334
+ For the full Unified Balance API, see the [`@circle-fin/unified-balance-kit` README](../unified-balance-kit/README.md).
335
+
275
336
  ## Configuration
276
337
 
277
338
  ### Send Parameters
@@ -611,10 +672,11 @@ await kit.bridge({
611
672
  - `kit.estimateBridge(params)` - Get cost estimates for bridging
612
673
  - `kit.estimateSwap(params)` - Get cost estimates for swapping
613
674
  - `kit.estimateSend(params)` - Get cost estimates for send operation
614
- - `kit.getSupportedChains(operationType?)` - Query supported chains by operation type
675
+ - `kit.getSupportedChains(operationType?)` - Query supported chains by operation type (`'bridge'`, `'swap'`, `'unifiedBalance'`)
615
676
  - `kit.setCustomFeePolicy(policy)` - Set kit-level custom fee policy
616
677
  - `kit.on(event, handler)` - Listen to operation events
617
678
  - `kit.off(event, handler)` - Remove event listener
679
+ - `kit.unifiedBalance.*` - Unified balance operations (deposit, spend, getBalances, estimateSpend, delegates, and more). See the [`@circle-fin/unified-balance-kit` README](../unified-balance-kit/README.md) for the full API.
618
680
 
619
681
  ## Development
620
682
 
package/index.cjs CHANGED
@@ -29143,7 +29143,7 @@ const getSupportedChains$2 = (context, operationType, unifiedBalance) => {
29143
29143
  };
29144
29144
 
29145
29145
  var name = "@circle-fin/unified-balance-kit";
29146
- var version = "1.0.0";
29146
+ var version = "1.0.1";
29147
29147
  var pkg = {
29148
29148
  name: name,
29149
29149
  version: version};
package/index.mjs CHANGED
@@ -29136,7 +29136,7 @@ const getSupportedChains$2 = (context, operationType, unifiedBalance) => {
29136
29136
  };
29137
29137
 
29138
29138
  var name = "@circle-fin/unified-balance-kit";
29139
- var version = "1.0.0";
29139
+ var version = "1.0.1";
29140
29140
  var pkg = {
29141
29141
  name: name,
29142
29142
  version: version};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@circle-fin/app-kit",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "A one-stop Circle SDK solution for building stablecoin (e.g. USDC) applications, with bridging, swapping, and more on-chain operations",
5
5
  "keywords": [
6
6
  "circle",
@@ -36,8 +36,8 @@
36
36
  "module": "./index.mjs",
37
37
  "types": "./index.d.ts",
38
38
  "dependencies": {
39
- "@circle-fin/unified-balance-kit": "1.0.0",
40
- "@circle-fin/provider-gateway-v1": "1.0.0",
39
+ "@circle-fin/unified-balance-kit": "1.0.1",
40
+ "@circle-fin/provider-gateway-v1": "1.0.1",
41
41
  "@circle-fin/bridge-kit": "1.8.3",
42
42
  "@circle-fin/swap-kit": "1.1.0",
43
43
  "zod": "3.25.67",