@circle-fin/app-kit 1.5.0 → 1.6.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 +12 -0
- package/README.md +81 -33
- package/chains.cjs +8 -10
- package/chains.mjs +8 -10
- package/earn.cjs +14828 -0
- package/earn.cjs.map +1 -0
- package/earn.d.ts +7438 -0
- package/earn.mjs +14819 -0
- package/earn.mjs.map +1 -0
- package/index.cjs +3857 -261
- package/index.d.ts +6750 -2849
- package/index.mjs +3831 -255
- package/package.json +12 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @circle-fin/app-kit
|
|
2
2
|
|
|
3
|
+
## 1.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- AppKit now exposes Earn operations through `kit.earn`, including supported-chain discovery and re-exports of Earn-related types.
|
|
8
|
+
|
|
9
|
+
## 1.5.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Improves the error you get when attempting a Gateway spend with a smart-contract account (SCA) as the signer. The failure previously surfaced as a confusing `invalid integer value <nil>/<nil> for type uint256` response from the Circle Wallets backend; you now get a clear `INPUT_UNSUPPORTED_ACTION` error up front that points at the delegate workflow (`kit.unifiedBalance.addDelegate` + `kit.unifiedBalance.spend` with the delegate EOA as `from.address` and the SCA as `from.sourceAccount`).
|
|
14
|
+
|
|
3
15
|
## 1.5.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -28,6 +28,7 @@ _Making cross-chain transfers, same-chain swaps, unified balance management, and
|
|
|
28
28
|
- [📊 Estimate Operations](#-estimate-operations)
|
|
29
29
|
- [🔍 Query Supported Chains](#-query-supported-chains)
|
|
30
30
|
- [💰 Unified Balance](#-unified-balance)
|
|
31
|
+
- [🏦 Earn](#-earn)
|
|
31
32
|
- [Configuration](#configuration)
|
|
32
33
|
- [Send Parameters](#send-parameters)
|
|
33
34
|
- [Swap Parameters](#swap-parameters)
|
|
@@ -54,11 +55,11 @@ _Making cross-chain transfers, same-chain swaps, unified balance management, and
|
|
|
54
55
|
|
|
55
56
|
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.
|
|
56
57
|
|
|
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.
|
|
58
|
+
The App Kit provides a **unified interface** for cross-chain transfers, same-chain swaps, earn vault operations, and unified balance management, abstracting away the complexity of choosing between operations. It combines the power of Bridge Kit, Swap Kit, Earn Kit, and Unified Balance Kit into a single, cohesive API.
|
|
58
59
|
|
|
59
60
|
### Why App Kit?
|
|
60
61
|
|
|
61
|
-
- **🎯 Unified interface**: Single API for bridge, swap, and unified balance operations
|
|
62
|
+
- **🎯 Unified interface**: Single API for bridge, swap, earn, and unified balance operations
|
|
62
63
|
- **🤖 Smart routing**: Automatically selects the appropriate operation (bridge vs swap)
|
|
63
64
|
- **⚡ Zero-config defaults**: Built-in reliable RPC endpoints - start building right away
|
|
64
65
|
- **🔧 Bring your own infrastructure**: Seamlessly integrate with your existing setup when needed
|
|
@@ -68,6 +69,7 @@ The App Kit provides a **unified interface** for cross-chain transfers, same-cha
|
|
|
68
69
|
- **Mainnet (22 chains)**: Arbitrum, Avalanche, Base, Codex, Edge, Ethereum, HyperEVM, Injective, Ink, Linea, Monad, Morph, OP Mainnet, Pharos, Plume, Polygon PoS, Sei, Solana, Sonic, Unichain, World Chain, XDC
|
|
69
70
|
- **Testnet (23 chains)**: Arc Testnet, Arbitrum Sepolia, Avalanche Fuji, Base Sepolia, Codex Testnet, Edge Testnet, Ethereum Sepolia, HyperEVM Testnet, Injective Testnet, Ink Testnet, Linea Sepolia, Monad Testnet, Morph Testnet, OP Sepolia, Pharos Atlantic, Plume Testnet, Polygon PoS Amoy, Sei Testnet, Solana Devnet, Sonic Testnet, Unichain Sepolia, World Chain Sepolia, XDC Apothem
|
|
70
71
|
- **🔄 Swap support**: Same-chain token swaps powered by Circle's Stablecoin Service
|
|
72
|
+
- **🏦 Earn support**: DeFi lending vault deposits, withdrawals, and reward claims via `kit.earn`
|
|
71
73
|
- **🎯 Flexible adapters**: Supporting EVM (Viem, Ethers) and Solana (@solana/web3)
|
|
72
74
|
- **📡 Real-time event monitoring**: Track progress throughout the operation lifecycle
|
|
73
75
|
- **🛡️ Robust error handling**: Graceful partial success recovery
|
|
@@ -79,40 +81,40 @@ The App Kit provides a **unified interface** for cross-chain transfers, same-cha
|
|
|
79
81
|
|
|
80
82
|
## Architecture Flow
|
|
81
83
|
|
|
82
|
-
The App Kit follows a composable architecture that integrates Bridge Kit, Swap Kit,
|
|
84
|
+
The App Kit follows a composable architecture that integrates Bridge Kit, Swap Kit, Unified Balance Kit, and Earn Kit:
|
|
83
85
|
|
|
84
86
|
```text
|
|
85
|
-
|
|
86
|
-
│
|
|
87
|
-
│
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
│
|
|
92
|
-
▼
|
|
93
|
-
|
|
94
|
-
│
|
|
95
|
-
│ (Cross-Chain)
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
│
|
|
101
|
-
│
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
87
|
+
┌──────────────────────────────────────────────────────────────────────────┐
|
|
88
|
+
│ App Kit │
|
|
89
|
+
│ (Unified Interface) │
|
|
90
|
+
└───────────────────────────────────┬──────────────────────────────────────┘
|
|
91
|
+
│
|
|
92
|
+
┌────────────────┬───────────┴──────┬──────────────────┐
|
|
93
|
+
│ │ │ │
|
|
94
|
+
▼ ▼ ▼ ▼
|
|
95
|
+
┌──────────────┐ ┌──────────────┐ ┌──────────────────┐ ┌──────────────┐
|
|
96
|
+
│ Bridge Kit │ │ Swap Kit │ │ Unified Balance │ │ Earn Kit │
|
|
97
|
+
│ (Cross-Chain)│ │ (Same-Chain) │ │ Kit │ │ (Vaults) │
|
|
98
|
+
└──────┬───────┘ └──────┬───────┘ └────────┬─────────┘ └──────┬───────┘
|
|
99
|
+
│ │ │ │
|
|
100
|
+
▼ ▼ ▼ ▼
|
|
101
|
+
┌──────────────┐ ┌──────────────┐ ┌──────────────────┐ ┌──────────────┐
|
|
102
|
+
│ Provider │ │ Provider │ │ Provider │ │ Provider │
|
|
103
|
+
│ (CCTPv2) │ │ (Service) │ │ (Gateway v1) │ │ (Earn) │
|
|
104
|
+
└──────┬───────┘ └──────┬───────┘ └────────┬─────────┘ └──────┬───────┘
|
|
105
|
+
│ │ │ │
|
|
106
|
+
└────────────────┴───────────┬──────┴──────────────────┘
|
|
107
|
+
│
|
|
108
|
+
▼
|
|
109
|
+
┌─────────────────┐
|
|
110
|
+
│ Adapter │
|
|
111
|
+
│ (Blockchain) │
|
|
112
|
+
└─────────────────┘
|
|
111
113
|
```
|
|
112
114
|
|
|
113
115
|
1. **Adapter**: Handles blockchain-specific operations (wallets, transactions, gas)
|
|
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
|
|
116
|
+
2. **Provider**: Implements protocols (CCTPv2 for bridging, Circle Service for swaps, Gateway for unified balance, Earn for vaults)
|
|
117
|
+
3. **Bridge/Swap/Unified Balance/Earn Kit**: Specialized kits for each operation type
|
|
116
118
|
4. **App Kit**: Unified orchestration layer providing a consistent API
|
|
117
119
|
|
|
118
120
|
This separation ensures that each component has a single responsibility while maintaining seamless integration across the entire stablecoin operation lifecycle.
|
|
@@ -264,7 +266,7 @@ console.log(
|
|
|
264
266
|
Check which chains support specific operations:
|
|
265
267
|
|
|
266
268
|
```typescript
|
|
267
|
-
// Get all chains (bridge, swap, and unified balance)
|
|
269
|
+
// Get all chains (bridge, swap, earn, and unified balance)
|
|
268
270
|
const allChains = kit.getSupportedChains()
|
|
269
271
|
|
|
270
272
|
// Get all chains that support bridging
|
|
@@ -273,6 +275,9 @@ const bridgeChains = kit.getSupportedChains('bridge')
|
|
|
273
275
|
// Get all chains that support swapping
|
|
274
276
|
const swapChains = kit.getSupportedChains('swap')
|
|
275
277
|
|
|
278
|
+
// Get chains that support earn vault operations
|
|
279
|
+
const earnChains = kit.getSupportedChains('earn')
|
|
280
|
+
|
|
276
281
|
// Get chains that support unified balance operations
|
|
277
282
|
const ubChains = kit.getSupportedChains('unifiedBalance')
|
|
278
283
|
```
|
|
@@ -333,6 +338,48 @@ kit.on('unifiedBalance.gateway.spend.succeeded', (payload) => {
|
|
|
333
338
|
|
|
334
339
|
For the full Unified Balance API, see the [`@circle-fin/unified-balance-kit` README](../unified-balance-kit/README.md).
|
|
335
340
|
|
|
341
|
+
### 🏦 Earn
|
|
342
|
+
|
|
343
|
+
Deposit into and withdraw from DeFi lending vaults, claim rewards, and query positions:
|
|
344
|
+
|
|
345
|
+
```typescript
|
|
346
|
+
import { AppKit, EarnChain } from '@circle-fin/app-kit'
|
|
347
|
+
import { createViemAdapterFromPrivateKey } from '@circle-fin/adapter-viem-v2'
|
|
348
|
+
|
|
349
|
+
const kit = new AppKit()
|
|
350
|
+
const adapter = createViemAdapterFromPrivateKey({
|
|
351
|
+
privateKey: process.env.PRIVATE_KEY as string,
|
|
352
|
+
})
|
|
353
|
+
|
|
354
|
+
// Preview a deposit
|
|
355
|
+
const quote = await kit.earn.getDepositQuote({
|
|
356
|
+
from: { adapter, chain: EarnChain.Arc_Testnet },
|
|
357
|
+
vaultAddress: '0x1234567890abcdef1234567890abcdef12345678',
|
|
358
|
+
amount: '100.50',
|
|
359
|
+
})
|
|
360
|
+
|
|
361
|
+
// Execute the deposit
|
|
362
|
+
await kit.earn.deposit({
|
|
363
|
+
from: { adapter, chain: EarnChain.Arc_Testnet },
|
|
364
|
+
vaultAddress: '0x1234567890abcdef1234567890abcdef12345678',
|
|
365
|
+
amount: '100.50',
|
|
366
|
+
})
|
|
367
|
+
|
|
368
|
+
// Query a vault position
|
|
369
|
+
const position = await kit.earn.getPosition({
|
|
370
|
+
from: { adapter, chain: EarnChain.Arc_Testnet },
|
|
371
|
+
vaultAddress: '0x1234567890abcdef1234567890abcdef12345678',
|
|
372
|
+
})
|
|
373
|
+
|
|
374
|
+
// Claim accrued rewards
|
|
375
|
+
await kit.earn.claimRewards({
|
|
376
|
+
from: { adapter, chain: EarnChain.Arc_Testnet },
|
|
377
|
+
vaultAddress: '0x1234567890abcdef1234567890abcdef12345678',
|
|
378
|
+
})
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
For the full Earn API, see the [`@circle-fin/earn-kit` README](../earn-kit/README.md).
|
|
382
|
+
|
|
336
383
|
## Configuration
|
|
337
384
|
|
|
338
385
|
### Send Parameters
|
|
@@ -672,11 +719,12 @@ await kit.bridge({
|
|
|
672
719
|
- `kit.estimateBridge(params)` - Get cost estimates for bridging
|
|
673
720
|
- `kit.estimateSwap(params)` - Get cost estimates for swapping
|
|
674
721
|
- `kit.estimateSend(params)` - Get cost estimates for send operation
|
|
675
|
-
- `kit.getSupportedChains(operationType?)` - Query supported chains by operation type (`'bridge'`, `'swap'`, `'unifiedBalance'`)
|
|
722
|
+
- `kit.getSupportedChains(operationType?)` - Query supported chains by operation type (`'bridge'`, `'swap'`, `'earn'`, `'unifiedBalance'`)
|
|
676
723
|
- `kit.setCustomFeePolicy(policy)` - Set kit-level custom fee policy
|
|
677
724
|
- `kit.on(event, handler)` - Listen to operation events
|
|
678
725
|
- `kit.off(event, handler)` - Remove event listener
|
|
679
726
|
- `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.
|
|
727
|
+
- `kit.earn.*` - Earn vault operations (deposit, withdraw, claimRewards, getVaults, getPosition, and quote helpers). See the [`@circle-fin/earn-kit` README](../earn-kit/README.md) for the full API.
|
|
680
728
|
|
|
681
729
|
## Development
|
|
682
730
|
|
package/chains.cjs
CHANGED
|
@@ -379,23 +379,21 @@ var UnifiedBalanceChain;
|
|
|
379
379
|
* Enumeration of blockchains that support earn (vault deposit/withdraw)
|
|
380
380
|
* operations through the Earn Kit.
|
|
381
381
|
*
|
|
382
|
-
* Currently only Ethereum mainnet is supported. Additional chains
|
|
383
|
-
* will be added as vault protocol support expands.
|
|
384
|
-
*
|
|
385
382
|
* @example
|
|
386
383
|
* ```typescript
|
|
387
384
|
* import { EarnChain } from '@core/chains'
|
|
388
385
|
*
|
|
389
386
|
* const result = await earnKit.deposit({
|
|
390
|
-
* from: { adapter, chain: EarnChain.
|
|
387
|
+
* from: { adapter, chain: EarnChain.Arc_Testnet },
|
|
391
388
|
* vaultAddress: '0x...',
|
|
392
389
|
* amount: '100',
|
|
393
390
|
* })
|
|
394
391
|
* ```
|
|
395
392
|
*/
|
|
393
|
+
// Values must match Blockchain enum members exactly.
|
|
396
394
|
var EarnChain;
|
|
397
395
|
(function (EarnChain) {
|
|
398
|
-
EarnChain["
|
|
396
|
+
EarnChain["Arc_Testnet"] = "Arc_Testnet";
|
|
399
397
|
})(EarnChain || (EarnChain = {}));
|
|
400
398
|
|
|
401
399
|
/**
|
|
@@ -3931,7 +3929,7 @@ zod.z.union([
|
|
|
3931
3929
|
* Zod schema for validating earn-specific chain identifiers.
|
|
3932
3930
|
*
|
|
3933
3931
|
* Validate that the provided chain is supported for earn (vault
|
|
3934
|
-
* deposit/withdraw) operations. Currently only
|
|
3932
|
+
* deposit/withdraw) operations. Currently only Arc Testnet is
|
|
3935
3933
|
* supported.
|
|
3936
3934
|
*
|
|
3937
3935
|
* Accept an EarnChain enum value, a matching string literal, or
|
|
@@ -3940,12 +3938,12 @@ zod.z.union([
|
|
|
3940
3938
|
* @example
|
|
3941
3939
|
* ```typescript
|
|
3942
3940
|
* import { earnChainIdentifierSchema } from '@core/chains'
|
|
3943
|
-
* import {
|
|
3941
|
+
* import { ArcTestnet, EarnChain } from '@core/chains'
|
|
3944
3942
|
*
|
|
3945
3943
|
* // Valid
|
|
3946
|
-
* earnChainIdentifierSchema.parse(EarnChain.
|
|
3947
|
-
* earnChainIdentifierSchema.parse('
|
|
3948
|
-
* earnChainIdentifierSchema.parse(
|
|
3944
|
+
* earnChainIdentifierSchema.parse(EarnChain.Arc_Testnet)
|
|
3945
|
+
* earnChainIdentifierSchema.parse('Arc_Testnet')
|
|
3946
|
+
* earnChainIdentifierSchema.parse(ArcTestnet)
|
|
3949
3947
|
*
|
|
3950
3948
|
* // Invalid (throws ZodError)
|
|
3951
3949
|
* earnChainIdentifierSchema.parse('Solana')
|
package/chains.mjs
CHANGED
|
@@ -377,23 +377,21 @@ var UnifiedBalanceChain;
|
|
|
377
377
|
* Enumeration of blockchains that support earn (vault deposit/withdraw)
|
|
378
378
|
* operations through the Earn Kit.
|
|
379
379
|
*
|
|
380
|
-
* Currently only Ethereum mainnet is supported. Additional chains
|
|
381
|
-
* will be added as vault protocol support expands.
|
|
382
|
-
*
|
|
383
380
|
* @example
|
|
384
381
|
* ```typescript
|
|
385
382
|
* import { EarnChain } from '@core/chains'
|
|
386
383
|
*
|
|
387
384
|
* const result = await earnKit.deposit({
|
|
388
|
-
* from: { adapter, chain: EarnChain.
|
|
385
|
+
* from: { adapter, chain: EarnChain.Arc_Testnet },
|
|
389
386
|
* vaultAddress: '0x...',
|
|
390
387
|
* amount: '100',
|
|
391
388
|
* })
|
|
392
389
|
* ```
|
|
393
390
|
*/
|
|
391
|
+
// Values must match Blockchain enum members exactly.
|
|
394
392
|
var EarnChain;
|
|
395
393
|
(function (EarnChain) {
|
|
396
|
-
EarnChain["
|
|
394
|
+
EarnChain["Arc_Testnet"] = "Arc_Testnet";
|
|
397
395
|
})(EarnChain || (EarnChain = {}));
|
|
398
396
|
|
|
399
397
|
/**
|
|
@@ -3929,7 +3927,7 @@ z.union([
|
|
|
3929
3927
|
* Zod schema for validating earn-specific chain identifiers.
|
|
3930
3928
|
*
|
|
3931
3929
|
* Validate that the provided chain is supported for earn (vault
|
|
3932
|
-
* deposit/withdraw) operations. Currently only
|
|
3930
|
+
* deposit/withdraw) operations. Currently only Arc Testnet is
|
|
3933
3931
|
* supported.
|
|
3934
3932
|
*
|
|
3935
3933
|
* Accept an EarnChain enum value, a matching string literal, or
|
|
@@ -3938,12 +3936,12 @@ z.union([
|
|
|
3938
3936
|
* @example
|
|
3939
3937
|
* ```typescript
|
|
3940
3938
|
* import { earnChainIdentifierSchema } from '@core/chains'
|
|
3941
|
-
* import {
|
|
3939
|
+
* import { ArcTestnet, EarnChain } from '@core/chains'
|
|
3942
3940
|
*
|
|
3943
3941
|
* // Valid
|
|
3944
|
-
* earnChainIdentifierSchema.parse(EarnChain.
|
|
3945
|
-
* earnChainIdentifierSchema.parse('
|
|
3946
|
-
* earnChainIdentifierSchema.parse(
|
|
3942
|
+
* earnChainIdentifierSchema.parse(EarnChain.Arc_Testnet)
|
|
3943
|
+
* earnChainIdentifierSchema.parse('Arc_Testnet')
|
|
3944
|
+
* earnChainIdentifierSchema.parse(ArcTestnet)
|
|
3947
3945
|
*
|
|
3948
3946
|
* // Invalid (throws ZodError)
|
|
3949
3947
|
* earnChainIdentifierSchema.parse('Solana')
|