@circle-fin/app-kit 1.3.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 +12 -0
- package/README.md +95 -33
- package/chains.cjs +555 -2
- package/chains.d.ts +327 -2
- package/chains.mjs +555 -2
- package/index.cjs +18499 -8579
- package/index.d.ts +4469 -268
- package/index.mjs +18500 -8580
- package/package.json +9 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
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
|
+
|
|
9
|
+
## 1.4.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- App Kit now supports unified cross-chain USDC balance management. Import from `@circle-fin/app-kit/unifiedBalance` to deposit, spend, query balances, and manage delegates across chains
|
|
14
|
+
|
|
3
15
|
## 1.3.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
8
8
|
[](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
|
|
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
|
|
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
|
|
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
|
-
β
|
|
86
|
+
β App Kit β
|
|
86
87
|
β (Unified Interface) β
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
βββββββββββββββββββ
|
|
93
|
-
β Bridge Kit β
|
|
94
|
-
β (Cross-Chain) β
|
|
95
|
-
ββββββββββ¬βββββββββ
|
|
96
|
-
β
|
|
97
|
-
βΌ
|
|
98
|
-
βββββββββββββββββββ
|
|
99
|
-
β Provider β
|
|
100
|
-
β
|
|
101
|
-
ββββββββββ¬βββββββββ
|
|
102
|
-
β
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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
|
|
272
|
-
const
|
|
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
|
|