@circle-fin/app-kit 1.8.1 → 1.10.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 +71 -0
- package/README.md +3 -3
- package/bridge.cjs +1102 -260
- package/bridge.d.cts +161 -10
- package/bridge.d.mts +161 -10
- package/bridge.d.ts +161 -10
- package/bridge.mjs +1102 -260
- package/chains.cjs +102 -2
- package/chains.d.cts +3 -0
- package/chains.d.mts +3 -0
- package/chains.d.ts +3 -0
- package/chains.mjs +102 -2
- package/context.cjs +1 -0
- package/context.d.cts +166 -12
- package/context.d.mts +166 -12
- package/context.d.ts +166 -12
- package/context.mjs +1 -0
- package/earn.cjs +1074 -454
- package/earn.d.cts +546 -99
- package/earn.d.mts +546 -99
- package/earn.d.ts +546 -99
- package/earn.mjs +1074 -455
- package/estimateBridge.cjs +1102 -260
- package/estimateBridge.d.cts +161 -10
- package/estimateBridge.d.mts +161 -10
- package/estimateBridge.d.ts +161 -10
- package/estimateBridge.mjs +1102 -260
- package/estimateSwap.cjs +915 -96
- package/estimateSwap.d.cts +161 -10
- package/estimateSwap.d.mts +161 -10
- package/estimateSwap.d.ts +161 -10
- package/estimateSwap.mjs +915 -96
- package/index.cjs +3029 -862
- package/index.d.cts +1277 -143
- package/index.d.mts +1277 -143
- package/index.d.ts +1277 -143
- package/index.mjs +3029 -862
- package/package.json +12 -6
- package/swap.cjs +915 -96
- package/swap.d.cts +161 -10
- package/swap.d.mts +161 -10
- package/swap.d.ts +161 -10
- package/swap.mjs +915 -96
- package/unifiedBalance.cjs +822 -115
- package/unifiedBalance.d.cts +224 -4
- package/unifiedBalance.d.mts +224 -4
- package/unifiedBalance.d.ts +224 -4
- package/unifiedBalance.mjs +822 -115
package/unifiedBalance.d.ts
CHANGED
|
@@ -373,6 +373,14 @@ interface CCTPSplitConfig {
|
|
|
373
373
|
type: 'split';
|
|
374
374
|
tokenMessenger: string;
|
|
375
375
|
messageTransmitter: string;
|
|
376
|
+
/**
|
|
377
|
+
* Address of the `TokenMessengerWithFees` wrapper, when deployed on this chain.
|
|
378
|
+
*
|
|
379
|
+
* Optional. Present only on chains that support the prepaid FORWARD path
|
|
380
|
+
* (source-chain fee collection via `depositForBurnWithHookAndFees`). Resolve
|
|
381
|
+
* it with `resolveCCTPV2ContractAddress(chain, 'tokenMessengerWithFees')`.
|
|
382
|
+
*/
|
|
383
|
+
tokenMessengerWithFees?: string;
|
|
376
384
|
confirmations: number;
|
|
377
385
|
}
|
|
378
386
|
/**
|
|
@@ -393,6 +401,14 @@ interface CCTPSplitConfig {
|
|
|
393
401
|
interface CCTPMergedConfig {
|
|
394
402
|
type: 'merged';
|
|
395
403
|
contract: string;
|
|
404
|
+
/**
|
|
405
|
+
* Address of the `TokenMessengerWithFees` wrapper, when deployed on this chain.
|
|
406
|
+
*
|
|
407
|
+
* Optional. Present only on chains that support the prepaid FORWARD path
|
|
408
|
+
* (source-chain fee collection via `depositForBurnWithHookAndFees`). Resolve
|
|
409
|
+
* it with `resolveCCTPV2ContractAddress(chain, 'tokenMessengerWithFees')`.
|
|
410
|
+
*/
|
|
411
|
+
tokenMessengerWithFees?: string;
|
|
396
412
|
confirmations: number;
|
|
397
413
|
}
|
|
398
414
|
/**
|
|
@@ -527,6 +543,21 @@ interface GatewayV1Contracts {
|
|
|
527
543
|
* @example "0xabcdef1234567890abcdef1234567890abcdef12"
|
|
528
544
|
*/
|
|
529
545
|
minter: string;
|
|
546
|
+
/**
|
|
547
|
+
* The address of the `DepositForHandler` contract.
|
|
548
|
+
*
|
|
549
|
+
* @description Optional. The handler the GenericExecutor calls on this chain
|
|
550
|
+
* to run a fast cross-chain deposit into the {@link GatewayV1Contracts.wallet}.
|
|
551
|
+
* Present only on chains that are fast-deposit destinations; other Gateway
|
|
552
|
+
* chains omit it.
|
|
553
|
+
*
|
|
554
|
+
* Address format varies by blockchain:
|
|
555
|
+
* - EVM chains: 40-character hexadecimal with 0x prefix (e.g., "0x1234...")
|
|
556
|
+
* - Solana: Base58-encoded 32-byte address (e.g., "9WzDX...")
|
|
557
|
+
*
|
|
558
|
+
* @example "0xD05E7D2E7d30b92c5F17d7d0fC575fce231F1A48"
|
|
559
|
+
*/
|
|
560
|
+
depositForHandler?: string;
|
|
530
561
|
}
|
|
531
562
|
/**
|
|
532
563
|
* Versioned map of Gateway contract configurations.
|
|
@@ -658,6 +689,8 @@ declare enum Blockchain {
|
|
|
658
689
|
Celo_Alfajores_Testnet = "Celo_Alfajores_Testnet",
|
|
659
690
|
Codex = "Codex",
|
|
660
691
|
Codex_Testnet = "Codex_Testnet",
|
|
692
|
+
Cronos = "Cronos",
|
|
693
|
+
Cronos_Testnet = "Cronos_Testnet",
|
|
661
694
|
Edge = "Edge",
|
|
662
695
|
Edge_Testnet = "Edge_Testnet",
|
|
663
696
|
Ethereum = "Ethereum",
|
|
@@ -1824,6 +1857,110 @@ interface CCTPv2ActionMap {
|
|
|
1824
1857
|
*/
|
|
1825
1858
|
hookData: string;
|
|
1826
1859
|
};
|
|
1860
|
+
/**
|
|
1861
|
+
* Initiate a prepaid cross-chain USDC transfer through the `TokenMessengerWithFees` wrapper.
|
|
1862
|
+
*
|
|
1863
|
+
* Burn USDC on the source chain while collecting all fees up front against a
|
|
1864
|
+
* signed quote. The wrapper collects the fee via `FeeManager`, then delegates
|
|
1865
|
+
* to the unmodified `TokenMessengerV2`. When `hookData` is provided (the
|
|
1866
|
+
* GenericExecutor FORWARD path) the wrapper's `depositForBurnWithHookAndFees`
|
|
1867
|
+
* contract method is used; otherwise `depositForBurnWithFees` is used.
|
|
1868
|
+
*
|
|
1869
|
+
* @remarks
|
|
1870
|
+
* SDK/contract naming: this SDK action is `depositForBurnWithFees` but, when a
|
|
1871
|
+
* `hookData` is present, it dispatches to the `depositForBurnWithHookAndFees`
|
|
1872
|
+
* contract method on `TokenMessengerWithFees` (NOT on `TokenMessengerV2`).
|
|
1873
|
+
*
|
|
1874
|
+
* Fee payment channel (must match the quote's `feeToken`):
|
|
1875
|
+
* - Native fee (`feeToken` is the zero address): exactly `feeTotalAmount` is
|
|
1876
|
+
* attached as `msg.value`.
|
|
1877
|
+
* - ERC-20 fee (e.g. USDC): no value is attached; the caller must first approve
|
|
1878
|
+
* the wrapper for `feeTotalAmount` (see the provider's fee approval helper).
|
|
1879
|
+
*
|
|
1880
|
+
* @remarks
|
|
1881
|
+
* Unlike `depositForBurn`, the `TokenMessengerWithFees` contract methods do NOT
|
|
1882
|
+
* take `maxFee` or `minFinalityThreshold` — fee and finality behavior are
|
|
1883
|
+
* derived from the signed quote — so those fields are omitted from this action.
|
|
1884
|
+
*
|
|
1885
|
+
* @example
|
|
1886
|
+
* ```typescript
|
|
1887
|
+
* await adapter.action('cctp.v2.depositForBurnWithFees', {
|
|
1888
|
+
* amount: BigInt('1000000'),
|
|
1889
|
+
* mintRecipient: executorAddress, // GenericExecutor (bytes32)
|
|
1890
|
+
* destinationCaller: executorAddress, // GenericExecutor (bytes32)
|
|
1891
|
+
* fromChain: ethereum,
|
|
1892
|
+
* toChain: arc,
|
|
1893
|
+
* hookData: geForwardHookData, // cctp-forward-wrapped GenericExecutor blob
|
|
1894
|
+
* claim: { signedQuote: '0x...', refundAddress: '0x...' },
|
|
1895
|
+
* feeToken: '0x0000000000000000000000000000000000000000', // native
|
|
1896
|
+
* feeTotalAmount: 3500000n,
|
|
1897
|
+
* })
|
|
1898
|
+
* ```
|
|
1899
|
+
*/
|
|
1900
|
+
depositForBurnWithFees: Omit<CCTPv2ActionMap['depositForBurn'], 'maxFee' | 'minFinalityThreshold'> & {
|
|
1901
|
+
/**
|
|
1902
|
+
* Optional hex-encoded hook data for the GenericExecutor FORWARD path.
|
|
1903
|
+
*
|
|
1904
|
+
* When present, the `depositForBurnWithHookAndFees` contract method is used
|
|
1905
|
+
* and the blob must be wrapped in the `cctp-forward` envelope (the wrapper
|
|
1906
|
+
* rejects a FORWARD fee quote whose hook lacks it). When omitted, the plain
|
|
1907
|
+
* `depositForBurnWithFees` contract method is used.
|
|
1908
|
+
*/
|
|
1909
|
+
hookData?: string;
|
|
1910
|
+
/**
|
|
1911
|
+
* Signed fee quote claim passed to the `TokenMessengerWithFees` wrapper.
|
|
1912
|
+
*
|
|
1913
|
+
* `signedQuote` is the `[uint8 0x01][abi.encode(Quote)]` blob returned by the
|
|
1914
|
+
* Fee Quote service; `refundAddress` receives any fee overpayment refund.
|
|
1915
|
+
*/
|
|
1916
|
+
claim: QuoteClaim;
|
|
1917
|
+
/**
|
|
1918
|
+
* Fee token from the signed quote.
|
|
1919
|
+
*
|
|
1920
|
+
* The zero address (`0x000…0`) means the fee is paid in native currency and
|
|
1921
|
+
* is attached as `msg.value`. Any other address (e.g. USDC) means an ERC-20
|
|
1922
|
+
* fee that must be approved to the wrapper beforehand. This is independent of
|
|
1923
|
+
* `burnToken`, which is always USDC.
|
|
1924
|
+
*/
|
|
1925
|
+
feeToken: string;
|
|
1926
|
+
/**
|
|
1927
|
+
* Total fee amount from the signed quote, in `feeToken` minor units.
|
|
1928
|
+
*
|
|
1929
|
+
* Firm only until the quote's `expiresAt`. For a native fee this is the exact
|
|
1930
|
+
* `msg.value`; for an ERC-20 fee this is the amount approved to the wrapper.
|
|
1931
|
+
*/
|
|
1932
|
+
feeTotalAmount: bigint;
|
|
1933
|
+
};
|
|
1934
|
+
}
|
|
1935
|
+
/**
|
|
1936
|
+
* Signed fee quote claim consumed by the `TokenMessengerWithFees` wrapper.
|
|
1937
|
+
*
|
|
1938
|
+
* Mirrors the on-chain `IFeeManager.QuoteClaim` struct.
|
|
1939
|
+
*
|
|
1940
|
+
* @example
|
|
1941
|
+
* ```typescript
|
|
1942
|
+
* const claim: QuoteClaim = {
|
|
1943
|
+
* signedQuote: '0x01...', // [uint8 0x01][abi.encode(Quote)]
|
|
1944
|
+
* refundAddress: '0xUserWallet...',
|
|
1945
|
+
* }
|
|
1946
|
+
* ```
|
|
1947
|
+
*/
|
|
1948
|
+
interface QuoteClaim {
|
|
1949
|
+
/**
|
|
1950
|
+
* Opaque signed quote bytes (`0x` hex) from the fee-quote service
|
|
1951
|
+
* (`SignedFeeQuote.signedQuote` returned by `fetchFeeQuote`). Pass verbatim;
|
|
1952
|
+
* do not decode.
|
|
1953
|
+
*
|
|
1954
|
+
* The quote binds the FORWARD fee item to the on-chain call via `argsHash`;
|
|
1955
|
+
* passing a quote that does not match the burn args reverts `QuoteArgsMismatch`.
|
|
1956
|
+
*/
|
|
1957
|
+
signedQuote: string;
|
|
1958
|
+
/**
|
|
1959
|
+
* Address that receives any refund of overpaid fees.
|
|
1960
|
+
*
|
|
1961
|
+
* Typically the user wallet that authorized the burn.
|
|
1962
|
+
*/
|
|
1963
|
+
refundAddress: string;
|
|
1827
1964
|
}
|
|
1828
1965
|
|
|
1829
1966
|
/**
|
|
@@ -5940,10 +6077,13 @@ interface ResolvedSpendParams<TFromAdapterCapabilities extends AdapterCapabiliti
|
|
|
5940
6077
|
*/
|
|
5941
6078
|
type SpendFeeFunction = (params: ResolvedSpendParams) => Promise<string> | string;
|
|
5942
6079
|
/**
|
|
5943
|
-
* Function that resolves the fee recipient address for a
|
|
5944
|
-
* Called once per
|
|
6080
|
+
* Function that resolves the fee recipient address for a spend.
|
|
6081
|
+
* Called once per spend, against the resolved **destination** chain —
|
|
6082
|
+
* every fee burn intent in a spend mints to that single chain
|
|
6083
|
+
* regardless of which source chain(s) funded it, so only one
|
|
6084
|
+
* recipient address (valid on the destination chain) is ever needed.
|
|
5945
6085
|
*/
|
|
5946
|
-
type SpendFeeRecipientFunction = (
|
|
6086
|
+
type SpendFeeRecipientFunction = (destinationChain: ChainDefinition, params: ResolvedSpendParams) => Promise<string> | string;
|
|
5947
6087
|
/**
|
|
5948
6088
|
* Policy for computing and routing custom developer fees.
|
|
5949
6089
|
*
|
|
@@ -5953,11 +6093,54 @@ type SpendFeeRecipientFunction = (feePayoutChain: ChainDefinition, params: Resol
|
|
|
5953
6093
|
* Fields that only exist after resolution (e.g. per-source allocations)
|
|
5954
6094
|
* may be `undefined`. Implementations should only rely on top-level
|
|
5955
6095
|
* fields such as `to`, `token`, and `amount`.
|
|
6096
|
+
*
|
|
6097
|
+
* @remarks
|
|
6098
|
+
* `resolveFeeRecipientAddress` is optional when you configure
|
|
6099
|
+
* {@link UnifiedBalanceKit.setFeeRecipients} instead — the declarative
|
|
6100
|
+
* map takes priority over this callback when both are present. Provide
|
|
6101
|
+
* exactly one of the two; a policy with neither throws at spend time.
|
|
5956
6102
|
*/
|
|
5957
6103
|
interface CustomFeePolicy {
|
|
5958
6104
|
computeFee: SpendFeeFunction;
|
|
5959
|
-
resolveFeeRecipientAddress
|
|
6105
|
+
resolveFeeRecipientAddress?: SpendFeeRecipientFunction;
|
|
5960
6106
|
}
|
|
6107
|
+
/**
|
|
6108
|
+
* Chain type group used to key {@link FeeRecipientsConfig}.
|
|
6109
|
+
*
|
|
6110
|
+
* @remarks
|
|
6111
|
+
* Only `'evm'` and `'solana'` are live today (the only chain types the
|
|
6112
|
+
* kit's provider currently supports). This is deliberately a narrow
|
|
6113
|
+
* subset of `@core/chains`' broader `ChainType` union rather than a
|
|
6114
|
+
* hardcoded two-field struct, so that support for additional non-EVM
|
|
6115
|
+
* chain types (e.g. Stellar, Starknet) can be added later by adding
|
|
6116
|
+
* new union members here — no restructuring of `FeeRecipientsConfig`
|
|
6117
|
+
* or its consumers required.
|
|
6118
|
+
*/
|
|
6119
|
+
type FeeRecipientChainType = 'evm' | 'solana';
|
|
6120
|
+
/**
|
|
6121
|
+
* Declarative map of fee recipient addresses, keyed by chain type.
|
|
6122
|
+
*
|
|
6123
|
+
* @remarks
|
|
6124
|
+
* Set via {@link UnifiedBalanceKit.setFeeRecipients}. At spend time the
|
|
6125
|
+
* kit resolves the spend's destination chain to its
|
|
6126
|
+
* {@link FeeRecipientChainType} and looks up the matching entry —
|
|
6127
|
+
* exactly one recipient is used per spend (see
|
|
6128
|
+
* {@link SpendFeeRecipientFunction}). Provide entries for every chain
|
|
6129
|
+
* type you expect to spend to; a spend to a destination chain type
|
|
6130
|
+
* with no matching entry throws before any fee collection is
|
|
6131
|
+
* attempted.
|
|
6132
|
+
*
|
|
6133
|
+
* @example
|
|
6134
|
+
* ```typescript
|
|
6135
|
+
* import type { FeeRecipientsConfig } from '@circle-fin/unified-balance-kit'
|
|
6136
|
+
*
|
|
6137
|
+
* const feeRecipients: FeeRecipientsConfig = {
|
|
6138
|
+
* evm: '0x1234567890123456789012345678901234567890',
|
|
6139
|
+
* solana: '9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM',
|
|
6140
|
+
* }
|
|
6141
|
+
* ```
|
|
6142
|
+
*/
|
|
6143
|
+
type FeeRecipientsConfig = Partial<Record<FeeRecipientChainType, string>>;
|
|
5961
6144
|
/**
|
|
5962
6145
|
* Fee category describing the origin of a fee line item.
|
|
5963
6146
|
*
|
|
@@ -7271,6 +7454,43 @@ declare class AppKitUnifiedBalance {
|
|
|
7271
7454
|
* ```
|
|
7272
7455
|
*/
|
|
7273
7456
|
removeCustomFeePolicy(): void;
|
|
7457
|
+
/**
|
|
7458
|
+
* Set a declarative fee recipient map, keyed by chain type.
|
|
7459
|
+
*
|
|
7460
|
+
* Once set, `spend()`/`estimateSpend()` resolve the fee recipient by
|
|
7461
|
+
* looking up the spend's destination chain type in this map — taking
|
|
7462
|
+
* priority over `customFeePolicy`'s `resolveFeeRecipientAddress`
|
|
7463
|
+
* callback.
|
|
7464
|
+
*
|
|
7465
|
+
* @remarks
|
|
7466
|
+
* This only controls which address a fee is sent to — it does not by
|
|
7467
|
+
* itself cause any fee to be charged. You still need
|
|
7468
|
+
* `setCustomFeePolicy`'s `computeFee` to determine the fee amount;
|
|
7469
|
+
* calling `setFeeRecipients` without ever calling `setCustomFeePolicy`
|
|
7470
|
+
* throws at spend time (there is no `computeFee` to determine an
|
|
7471
|
+
* amount).
|
|
7472
|
+
*
|
|
7473
|
+
* @param config - Fee recipient addresses keyed by chain type (e.g.
|
|
7474
|
+
* `{ evm: '0x...', solana: 'Sol...' }`).
|
|
7475
|
+
*
|
|
7476
|
+
* @example
|
|
7477
|
+
* ```typescript
|
|
7478
|
+
* kit.unifiedBalance.setFeeRecipients({
|
|
7479
|
+
* evm: '0x1234567890123456789012345678901234567890',
|
|
7480
|
+
* solana: '9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM',
|
|
7481
|
+
* })
|
|
7482
|
+
* ```
|
|
7483
|
+
*/
|
|
7484
|
+
setFeeRecipients(config: FeeRecipientsConfig): void;
|
|
7485
|
+
/**
|
|
7486
|
+
* Remove the declarative fee recipient map.
|
|
7487
|
+
*
|
|
7488
|
+
* @example
|
|
7489
|
+
* ```typescript
|
|
7490
|
+
* kit.unifiedBalance.removeFeeRecipients()
|
|
7491
|
+
* ```
|
|
7492
|
+
*/
|
|
7493
|
+
removeFeeRecipients(): void;
|
|
7274
7494
|
}
|
|
7275
7495
|
|
|
7276
7496
|
export { AppKitUnifiedBalance };
|