@circle-fin/app-kit 1.11.0 → 1.12.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,58 @@
1
1
  # @circle-fin/app-kit
2
2
 
3
+ ## 1.12.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix same-chain USDT swaps failing before anything reached the chain — no
8
+ approval, no swap, no transaction hash — when you wrap `prepareAction` to
9
+ verify transactions before signing. No integration code change is needed, but
10
+ upgrade the adapter package with the kit so reads use the new seam. `USDC ->
11
+ USDT` and other ERC-20 swaps were unaffected.
12
+
13
+ If you verify approval amounts, USDT requires `approve(0)` before a new non-zero
14
+ allowance. A stale partial allowance therefore emits `token.approve` with
15
+ `amount: 0n` first; accept it alongside the pay amount.
16
+
17
+ ## 1.12.0
18
+
19
+ ### Minor Changes
20
+
21
+ - Add X Layer chain definitions (mainnet and testnet) with CCTP v2 support, USDC token addresses, Viem adapter mappings, Bridge Kit exports.
22
+ - Add App Kit-level operation-scoped custom fee policy configuration and scoped
23
+ custom fee policy removal. Align the README with the current public API,
24
+ including explicit operation methods, supported send and swap tokens, and the
25
+ complete core method list.
26
+
27
+ - Same-chain Earn deposits, withdrawals, and reward claims can now surface a
28
+ verified `earn.execute` review to an adapter `onBeforeAuthorize` hook before
29
+ authorization. Use `isEarnExecuteReview` to inspect the decoded Earn operation
30
+ and exact call data; returning `reject` prevents signing.
31
+ - Support spending a unified balance from a smart contract account via Gateway's
32
+ ERC-1271 programmable authorization.
33
+
34
+ Previously, `spend` rejected any smart contract account (SCA) signer up front
35
+ and told you to register an EOA delegate against the SCA, because Gateway
36
+ validated burn-intent signatures with `ecrecover` only. Gateway now also
37
+ validates contract signatures with ERC-1271, so the SDK detects a contract
38
+ signer from its on-chain bytecode and marks the transfer request
39
+ `contractSigner: true` — multisigs, passkey wallets, Circle SCA wallets, and
40
+ other ERC-1271 accounts can authorize transfers directly.
41
+
42
+ No API change: `spend` takes the same parameters and picks the validation path
43
+ for you. EOA transfers are unaffected, and EIP-7702-delegated EOAs keep using
44
+ the `ecrecover` path since their signatures verify that way.
45
+
46
+ ERC-1271 validation is EVM-only. Solana burn intents are unchanged.
47
+
48
+ ### Patch Changes
49
+
50
+ - Batch same-chain Earn deposits and withdrawals through an adapter's shared
51
+ `supportsAtomicBatch` and `batchExecute` capabilities. Approval and execution
52
+ calls are submitted atomically when supported, with a configuration option to
53
+ force the existing sequential flow. Legacy Viem batches now request atomic
54
+ EIP-5792 execution by default.
55
+
3
56
  ## 1.11.0
4
57
 
5
58
  ### Minor Changes
package/README.md CHANGED
@@ -35,7 +35,7 @@ _Making cross-chain transfers, same-chain swaps, unified balance management, and
35
35
  - [Bridge Parameters](#bridge-parameters)
36
36
  - [Custom Fees](#custom-fees)
37
37
  - [Operation-Level Custom Fees](#operation-level-custom-fees)
38
- - [Kit-Level Fee Policies](#kit-level-fee-policies)
38
+ - [Kit-Level Custom Fee Policies](#kit-level-custom-fee-policies)
39
39
  - [Error Handling](#error-handling)
40
40
  - [Examples](#examples)
41
41
  - [Basic Cross-Chain Transfer](#basic-cross-chain-transfer)
@@ -55,19 +55,19 @@ _Making cross-chain transfers, same-chain swaps, unified balance management, and
55
55
 
56
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.
57
57
 
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
+ The App Kit provides a **unified interface** for cross-chain transfers, same-chain swaps, token sends, earn vault operations, and unified balance management. It combines the power of Bridge Kit, Swap Kit, Earn Kit, and Unified Balance Kit into a single, cohesive API with explicit methods for each operation.
59
59
 
60
60
  ### Why App Kit?
61
61
 
62
- - **🎯 Unified interface**: Single API for bridge, swap, earn, and unified balance operations
63
- - **🤖 Smart routing**: Automatically selects the appropriate operation (bridge vs swap)
62
+ - **🎯 Unified interface**: Single SDK surface for bridge, swap, send, earn, and unified balance operations
63
+ - **🧭 Explicit operation methods**: Choose `bridge`, `swap`, `send`, `earn`, or `unifiedBalance` based on the flow you are building
64
64
  - **⚡ Zero-config defaults**: Built-in reliable RPC endpoints - start building right away
65
65
  - **🔧 Bring your own infrastructure**: Seamlessly integrate with your existing setup when needed
66
66
  - **🔒 Production-ready security**: Leverages Circle's CCTPv2 for bridging and trusted swap providers
67
67
  - **🚀 Developer experience**: Complete TypeScript support, comprehensive validation, and instant connectivity
68
- - **🌍 Multi-chain support**: Bridge across **47 chains** with **1058 total bridge routes** through Circle's CCTPv2
69
- - **Mainnet (23 chains)**: Arbitrum, Avalanche, Base, Codex, Cronos, Edge, Ethereum, HyperEVM, Injective, Ink, Linea, Monad, Morph, OP Mainnet, Pharos, Plume, Polygon PoS, Sei, Solana, Sonic, Unichain, World Chain, XDC
70
- - **Testnet (24 chains)**: Arc Testnet, Arbitrum Sepolia, Avalanche Fuji, Base Sepolia, Codex Testnet, Cronos 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
68
+ - **🌍 Multi-chain support**: Bridge across **49 chains** with **1152 total bridge routes** through Circle's CCTPv2
69
+ - **Mainnet (24 chains)**: Arbitrum, Avalanche, Base, Codex, Cronos, Edge, Ethereum, HyperEVM, Injective, Ink, Linea, Monad, Morph, OP Mainnet, Pharos, Plume, Polygon PoS, Sei, Solana, Sonic, Unichain, World Chain, XDC, X Layer
70
+ - **Testnet (25 chains)**: Arc Testnet, Arbitrum Sepolia, Avalanche Fuji, Base Sepolia, Codex Testnet, Cronos 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, X Layer Testnet
71
71
  - **🔄 Swap support**: Same-chain token swaps powered by Circle's Stablecoin Service
72
72
  - **🏦 Earn support**: DeFi lending vault deposits, withdrawals, and reward claims via `kit.earn`
73
73
  - **🎯 Flexible adapters**: Supporting EVM (Viem, Ethers) and Solana (@solana/web3)
@@ -163,7 +163,7 @@ const result = await kit.bridge({
163
163
  })
164
164
  ```
165
165
 
166
- All 41 CCTPv2-supported chains are available for import.
166
+ A curated subset of 37 CCTPv2-supported chains is available for import from App Kit.
167
167
 
168
168
  ## Quick Start
169
169
 
@@ -429,13 +429,15 @@ The `token` field accepts both known aliases and custom token contract addresses
429
429
  - `'USDC'` - USD Coin (6 decimals)
430
430
  - `'USDT'` - Tether USD (6 decimals)
431
431
  - `'NATIVE'` - Chain's native currency (ETH, SOL, etc.)
432
+ - `'EURC'` - Euro Coin, on chains with `eurcAddress` configured
432
433
 
433
434
  **Custom addresses:**
434
435
 
435
436
  - EVM contract addresses (e.g., `0x6B175474E89094C44Da98b954EedeAC495271d0F`)
436
437
  - Solana SPL mint addresses
437
438
 
438
- **Note**: For swap operations, additional stablecoins (EURC, DAI, USDE, PYUSD) are supported. See [Swap Parameters](#swap-parameters) section below.
439
+ **Note**: For swap operations, additional stablecoins and wrapped assets are
440
+ supported. See [Swap Parameters](#swap-parameters) section below.
439
441
 
440
442
  **Examples**
441
443
 
@@ -498,6 +500,7 @@ interface SwapParams {
498
500
  // SupportedToken includes:
499
501
  // - Stablecoins (6 decimals): 'USDC', 'EURC', 'USDT', 'PYUSD'
500
502
  // - Stablecoins (18 decimals): 'DAI', 'USDE'
503
+ // - Wrapped assets: 'WBTC', 'WETH', 'WSOL', 'WAVAX', 'WPOL', 'CIRBTC'
501
504
  // - Native: 'NATIVE' (chain's native currency)
502
505
  ```
503
506
 
@@ -590,38 +593,61 @@ await kit.swap({
590
593
  })
591
594
  ```
592
595
 
593
- ### Kit-Level Fee Policies
596
+ ### Kit-Level Custom Fee Policies
594
597
 
595
- For dynamic fee calculation across all operations, use kit-level policies:
598
+ For dynamic fee calculation, provide operation-scoped custom fee policies at the
599
+ App Kit level. Configure only the operations that need custom fees.
596
600
 
597
601
  ```typescript
598
602
  import { AppKit } from '@circle-fin/app-kit'
599
- import { formatUnits } from 'viem'
600
603
 
601
604
  const kit = new AppKit()
602
605
 
603
606
  kit.setCustomFeePolicy({
604
- calculateFee: (params) => {
605
- // Calculate fee based on operation type and parameters
606
- const amount = Number(formatUnits(BigInt(params.amount), 6))
607
- const feePercentage = type === 'bridge' ? 0.01 : 0.005 // 1% for bridge, 0.5% for swap
608
-
609
- return (amount * feePercentage).toFixed(6)
607
+ bridge: {
608
+ computeFee: (params) => {
609
+ const amount = Number(params.amount)
610
+ return (amount * 0.01).toFixed(6)
611
+ },
612
+ resolveFeeRecipientAddress: (chain) => {
613
+ return chain.type === 'solana'
614
+ ? 'SolanaAddressBase58...'
615
+ : '0xEvmAddress...'
616
+ },
610
617
  },
611
- resolveFeeRecipientAddress: (type, info) => {
612
- // Return appropriate address based on operation type and chain
613
- return info.chain.type === 'solana'
614
- ? 'SolanaAddressBase58...'
615
- : '0xEvmAddress...'
618
+ swap: {
619
+ computeFee: (params) => {
620
+ const amount = Number(params.amountIn)
621
+ return (amount * 0.005).toFixed(6)
622
+ },
623
+ resolveFeeRecipientAddress: (chain) => {
624
+ return chain.type === 'solana'
625
+ ? 'SolanaAddressBase58...'
626
+ : '0xEvmAddress...'
627
+ },
628
+ },
629
+ unifiedBalance: {
630
+ computeFee: (params) => {
631
+ const amount = Number(params.amount)
632
+ return (amount * 0.01).toFixed(6)
633
+ },
634
+ resolveFeeRecipientAddress: (destinationChain) => {
635
+ return destinationChain.type === 'solana'
636
+ ? 'SolanaAddressBase58...'
637
+ : '0xEvmAddress...'
638
+ },
616
639
  },
617
640
  })
618
641
 
619
- // All subsequent operations will use this policy
642
+ // All subsequent configured operations will use these policies
620
643
  await kit.bridge({
621
644
  from: { adapter, chain: 'Ethereum' },
622
645
  to: { adapter, chain: 'Base' },
623
646
  amount: '1000', // Custom fee calculated automatically
624
647
  })
648
+
649
+ // Remove one operation-scoped policy without affecting the others
650
+ kit.removeCustomFeePolicy('bridge')
625
651
  ```
626
652
 
627
653
  ## Error Handling
@@ -740,12 +766,17 @@ await kit.bridge({
740
766
 
741
767
  - `kit.send(params)` - Send tokens to a recipient on the same chain
742
768
  - `kit.bridge(params)` - Execute cross-chain bridge operation
769
+ - `kit.retryBridge(result, retryContext)` - Retry a failed bridge operation
743
770
  - `kit.swap(params)` - Execute same-chain swap operation
744
771
  - `kit.estimateBridge(params)` - Get cost estimates for bridging
745
772
  - `kit.estimateSwap(params)` - Get cost estimates for swapping
746
773
  - `kit.estimateSend(params)` - Get cost estimates for send operation
774
+ - `kit.getSwapStatus(params)` - Fetch the current status of a swap
775
+ - `kit.waitForSwap(params)` - Poll until a swap reaches a terminal status
776
+ - `kit.getTokenRates(params)` - Fetch cached token USD rates
747
777
  - `kit.getSupportedChains(operationType?)` - Query supported chains by operation type (`'bridge'`, `'swap'`, `'earn'`, `'unifiedBalance'`)
748
- - `kit.setCustomFeePolicy(policy)` - Set kit-level custom fee policy
778
+ - `kit.setCustomFeePolicy(policy)` - Set operation-scoped custom fee policies
779
+ - `kit.removeCustomFeePolicy(operation)` - Remove an operation-scoped custom fee policy
749
780
  - `kit.on(event, handler)` - Listen to operation events
750
781
  - `kit.off(event, handler)` - Remove event listener
751
782
  - `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.