@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/context.d.mts CHANGED
@@ -740,6 +740,8 @@ declare enum Blockchain {
740
740
  World_Chain_Sepolia = "World_Chain_Sepolia",
741
741
  XDC = "XDC",
742
742
  XDC_Apothem = "XDC_Apothem",
743
+ X_Layer = "X_Layer",
744
+ X_Layer_Testnet = "X_Layer_Testnet",
743
745
  ZKSync_Era = "ZKSync_Era",
744
746
  ZKSync_Sepolia = "ZKSync_Sepolia"
745
747
  }
@@ -952,6 +954,7 @@ declare enum BridgeChain {
952
954
  Unichain = "Unichain",
953
955
  World_Chain = "World_Chain",
954
956
  XDC = "XDC",
957
+ X_Layer = "X_Layer",
955
958
  Arc_Testnet = "Arc_Testnet",
956
959
  Arbitrum_Sepolia = "Arbitrum_Sepolia",
957
960
  Avalanche_Fuji = "Avalanche_Fuji",
@@ -975,7 +978,8 @@ declare enum BridgeChain {
975
978
  Sonic_Testnet = "Sonic_Testnet",
976
979
  Unichain_Sepolia = "Unichain_Sepolia",
977
980
  World_Chain_Sepolia = "World_Chain_Sepolia",
978
- XDC_Apothem = "XDC_Apothem"
981
+ XDC_Apothem = "XDC_Apothem",
982
+ X_Layer_Testnet = "X_Layer_Testnet"
979
983
  }
980
984
  /**
981
985
  * Type representing valid bridge chain identifiers.
@@ -2953,6 +2957,18 @@ interface TokenActionMap {
2953
2957
  */
2954
2958
  walletAddress?: string | undefined;
2955
2959
  };
2960
+ /**
2961
+ * Get the on-chain name of the token contract.
2962
+ *
2963
+ * This is a read-only operation. For USDC the value is also the EIP-712
2964
+ * domain name, which permit and authorize signing flows need.
2965
+ */
2966
+ name: ActionParameters & {
2967
+ /**
2968
+ * The contract address of the token.
2969
+ */
2970
+ tokenAddress: string;
2971
+ };
2956
2972
  }
2957
2973
 
2958
2974
  /**
@@ -3782,6 +3798,30 @@ declare class ActionRegistry {
3782
3798
  executeAction<TActionKey extends ActionKeys>(action: TActionKey, params: ActionPayload<TActionKey>, context: ResolvedOperationContext): Promise<PreparedChainRequest>;
3783
3799
  }
3784
3800
 
3801
+ /**
3802
+ * Canonical list of actions that do not prepare or submit transactions.
3803
+ *
3804
+ * @internal
3805
+ */
3806
+ declare const READ_ACTION_KEYS: readonly ["token.allowance", "token.balanceOf", "token.name", "native.balanceOf", "usdc.allowance", "usdc.balanceOf", "usdc.name", "gateway.v1.isDelegate", "gateway.v1.withdrawingBalance", "gateway.v1.withdrawalBlock", "gateway.v1.signBurnIntents"];
3807
+ /**
3808
+ * Action keys that execute without preparing or submitting a transaction.
3809
+ *
3810
+ * @remarks
3811
+ * Derive this type from the canonical runtime list so compile-time and runtime
3812
+ * classification cannot drift. `gateway.v1.signBurnIntents` is included
3813
+ * because the action system models off-chain signing as a read action: it does
3814
+ * not prepare a chain request.
3815
+ *
3816
+ * @example
3817
+ * ```typescript
3818
+ * import type { ReadActionKey } from '@core/adapter'
3819
+ *
3820
+ * const action: ReadActionKey = 'token.allowance'
3821
+ * ```
3822
+ */
3823
+ type ReadActionKey = (typeof READ_ACTION_KEYS)[number];
3824
+
3785
3825
  /**
3786
3826
  * Defines the capabilities of an adapter, including address handling patterns and supported chains.
3787
3827
  *
@@ -3950,6 +3990,69 @@ declare abstract class Adapter<TAdapterCapabilities extends AdapterCapabilities
3950
3990
  * ```
3951
3991
  */
3952
3992
  prepareAction<TActionKey extends ActionKeys>(action: TActionKey, params: ActionPayload<TActionKey>, ctx: OperationContext<TAdapterCapabilities>): Promise<PreparedChainRequest>;
3993
+ /**
3994
+ * Execute a non-transaction action without routing through transaction preparation.
3995
+ *
3996
+ * @remarks
3997
+ * Use this seam for balance, allowance, contract-state, and other actions
3998
+ * classified as reads. It never calls {@link Adapter.prepareAction}, so
3999
+ * transaction authorization wrappers only observe actions that can produce a
4000
+ * signable chain request.
4001
+ *
4002
+ * @typeParam TActionKey - The read action key.
4003
+ * @param action - The read action to execute.
4004
+ * @param params - The parameters for the read action.
4005
+ * @param ctx - The operation context.
4006
+ * @returns The raw action response.
4007
+ * @throws {KitError} When the key is not a read action or no handler is registered.
4008
+ * @throws Error When the operation context or action handler fails.
4009
+ *
4010
+ * @example
4011
+ * ```typescript
4012
+ * import { Ethereum } from '@core/chains'
4013
+ *
4014
+ * const balance = await adapter.readAction(
4015
+ * 'token.balanceOf',
4016
+ * { tokenAddress, walletAddress },
4017
+ * { chain: Ethereum },
4018
+ * )
4019
+ * ```
4020
+ *
4021
+ * @internal
4022
+ */
4023
+ readAction<TActionKey extends ReadActionKey>(action: TActionKey, params: ActionPayload<TActionKey>, ctx: OperationContext<TAdapterCapabilities>): Promise<unknown>;
4024
+ /**
4025
+ * Read the current token allowance a delegate holds over an owner's tokens.
4026
+ *
4027
+ * @remarks
4028
+ * Perform a network read through {@link Adapter.readAction}. This method
4029
+ * never routes through {@link Adapter.prepareAction}. On chains without an
4030
+ * allowance model, such as Solana, return the maximum uint256 value.
4031
+ *
4032
+ * @param params - The token to query and the delegate whose allowance is being read.
4033
+ * @param ctx - Operation context with compile-time validated address requirements.
4034
+ * @returns A promise resolving to the current allowance in the token's base units.
4035
+ * @throws {KitError} When the adapter does not register a `token.allowance` handler.
4036
+ * @throws Error When the operation context or action handler fails.
4037
+ *
4038
+ * @example
4039
+ * ```typescript
4040
+ * import type { Adapter } from '@core/adapter'
4041
+ * import { Ethereum } from '@core/chains'
4042
+ *
4043
+ * declare const adapter: Adapter
4044
+ *
4045
+ * const allowance = await adapter.getTokenAllowance(
4046
+ * {
4047
+ * tokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
4048
+ * delegate: '0x1111111111111111111111111111111111111111',
4049
+ * },
4050
+ * { chain: Ethereum },
4051
+ * )
4052
+ * console.log(allowance) // 1000000n
4053
+ * ```
4054
+ */
4055
+ getTokenAllowance(params: ActionPayload<'token.allowance'>, ctx: OperationContext<TAdapterCapabilities>): Promise<bigint>;
3953
4056
  /**
3954
4057
  * Prepares a transaction for future gas estimation and execution.
3955
4058
  *
@@ -5260,6 +5363,132 @@ declare enum TransferSpeed {
5260
5363
  /** Standard burn mode - normal transfer time with standard fees */
5261
5364
  SLOW = "SLOW"
5262
5365
  }
5366
+ /**
5367
+ * Context object representing a wallet and signing authority on a specific blockchain network.
5368
+ *
5369
+ * Combines a wallet or contract address, the blockchain it resides on, and the adapter (signer)
5370
+ * responsible for authorizing transactions. Used to specify the source or destination in cross-chain
5371
+ * transfer operations.
5372
+ *
5373
+ * @remarks
5374
+ * The `adapter` (signer) and `address` do not always have to belong to the same entity. For example,
5375
+ * in minting or withdrawal scenarios, the signing adapter may authorize a transaction that credits
5376
+ * funds to a different recipient address. This context is essential for cross-chain operations,
5377
+ * ensuring that both the address and the associated adapter are correctly paired with the intended
5378
+ * blockchain, but not necessarily with each other.
5379
+ *
5380
+ * @example
5381
+ * ```typescript
5382
+ * import type { WalletContext } from '@core/provider'
5383
+ * import { adapter, blockchain } from './setup'
5384
+ *
5385
+ * const wallet: WalletContext = {
5386
+ * adapter,
5387
+ * address: '0x1234...abcd',
5388
+ * chain: blockchain,
5389
+ * }
5390
+ * ```
5391
+ */
5392
+ interface WalletContext<TAdapterCapabilities extends AdapterCapabilities = AdapterCapabilities,
5393
+ /**
5394
+ * The chain definition type to use for the wallet context.
5395
+ *
5396
+ * @defaultValue ChainDefinition
5397
+ */
5398
+ TChainDefinition extends ChainDefinition = ChainDefinition> {
5399
+ /**
5400
+ * The adapter (signer) for the wallet on the specified chain.
5401
+ *
5402
+ * Responsible for authorizing transactions and signing messages on behalf of the wallet or
5403
+ * for a different recipient, depending on the use case.
5404
+ */
5405
+ adapter: Adapter<TAdapterCapabilities>;
5406
+ /**
5407
+ * The wallet or contract address.
5408
+ *
5409
+ * Must be a valid address format for the specified blockchain. May differ from the adapter's
5410
+ * own address in scenarios such as relayed transactions or third-party minting.
5411
+ */
5412
+ address: string;
5413
+ /**
5414
+ * The blockchain network where the wallet or contract address resides.
5415
+ *
5416
+ * Determines the context and format for the address and adapter.
5417
+ */
5418
+ chain: TChainDefinition;
5419
+ }
5420
+ /**
5421
+ * Wallet context for bridge destinations with optional custom recipient.
5422
+ *
5423
+ * Extends WalletContext to support scenarios where the recipient address
5424
+ * differs from the signer address (e.g., bridging to a third-party wallet).
5425
+ * The signer address is used for transaction authorization, while the
5426
+ * recipient address specifies where the minted funds should be sent.
5427
+ *
5428
+ * @typeParam TAdapterCapabilities - The adapter capabilities type to use for the wallet context.
5429
+ * @typeParam TChainDefinition - The chain definition type to use for the wallet context.
5430
+ *
5431
+ * @example
5432
+ * ```typescript
5433
+ * import type { DestinationWalletContext } from '@core/provider'
5434
+ * import { adapter, blockchain } from './setup'
5435
+ *
5436
+ * // Bridge to a custom recipient address
5437
+ * const destination: DestinationWalletContext = {
5438
+ * adapter,
5439
+ * address: '0x1234...abcd', // Signer address
5440
+ * chain: blockchain,
5441
+ * recipientAddress: '0x9876...fedc' // Custom recipient
5442
+ * }
5443
+ * ```
5444
+ */
5445
+ interface DestinationWalletContext<TAdapterCapabilities extends AdapterCapabilities = AdapterCapabilities,
5446
+ /**
5447
+ * The chain definition type to use for the wallet context.
5448
+ *
5449
+ * @defaultValue ChainDefinition
5450
+ */
5451
+ TChainDefinition extends ChainDefinition = ChainDefinition> extends WalletContext<TAdapterCapabilities, TChainDefinition> {
5452
+ /**
5453
+ * Optional custom recipient address for minted funds.
5454
+ *
5455
+ * When provided, minted tokens will be sent to this address instead of
5456
+ * the address specified in the wallet context. The wallet context address
5457
+ * is still used for transaction signing and authorization.
5458
+ *
5459
+ * Must be a valid address format for the specified blockchain.
5460
+ */
5461
+ recipientAddress?: string;
5462
+ }
5463
+ /**
5464
+ * Parameters for executing a cross-chain bridge operation.
5465
+ */
5466
+ interface BridgeParams$1<TFromCapabilities extends AdapterCapabilities = AdapterCapabilities, TToCapabilities extends AdapterCapabilities = AdapterCapabilities,
5467
+ /**
5468
+ * The chain definition type to use for the wallet context.
5469
+ *
5470
+ * @defaultValue ChainDefinition
5471
+ */
5472
+ TChainDefinition extends ChainDefinition = ChainDefinition> {
5473
+ /** The source adapter containing wallet and chain information */
5474
+ source: WalletContext<TFromCapabilities, TChainDefinition>;
5475
+ /** The destination adapter containing wallet and chain information */
5476
+ destination: DestinationWalletContext<TToCapabilities, TChainDefinition>;
5477
+ /** The amount to transfer (as a string to avoid precision issues) */
5478
+ amount: string;
5479
+ /** The token to transfer (currently only USDC is supported) */
5480
+ token: 'USDC';
5481
+ /** Bridge configuration (e.g., fast burn settings) */
5482
+ config: BridgeConfig;
5483
+ /**
5484
+ * Optional invocation metadata for tracing and correlation.
5485
+ *
5486
+ * When provided, the `traceId` is used to correlate all events emitted during
5487
+ * the bridge operation. If not provided, an OpenTelemetry-compatible traceId
5488
+ * will be auto-generated.
5489
+ */
5490
+ invocationMeta?: InvocationMeta;
5491
+ }
5263
5492
  /**
5264
5493
  * Configuration options for customizing bridge behavior.
5265
5494
  *
@@ -5567,6 +5796,91 @@ type BridgeDestination<TAdapterCapabilities extends AdapterCapabilities = Adapte
5567
5796
  useForwarder?: boolean;
5568
5797
  }) | ForwarderDestination<TChainIdentifier>;
5569
5798
 
5799
+ type FeeFunction<TFromAdapterCapabilities extends AdapterCapabilities, TToAdapterCapabilities extends AdapterCapabilities> = (params: BridgeParams$1<TFromAdapterCapabilities, TToAdapterCapabilities>) => Promise<string> | string;
5800
+ type FeeRecipientFunction<TFromAdapterCapabilities extends AdapterCapabilities, TToAdapterCapabilities extends AdapterCapabilities> = (feePayoutChain: ChainDefinition, params: BridgeParams$1<TFromAdapterCapabilities, TToAdapterCapabilities>) => Promise<string> | string;
5801
+ /**
5802
+ * Custom fee policy for BridgeKit.
5803
+ *
5804
+ * Provides hooks to calculate an absolute custom fee and resolve the fee recipient address
5805
+ * on the source chain. The returned fee is **added on top of the transfer amount** (the wallet signs for
5806
+ * `amount + customFee`). Once collected, the custom fee is split:
5807
+ *
5808
+ * - **10%** automatically routes to Circle.
5809
+ * - **90%** routes to your supplied `recipientAddress`.
5810
+ *
5811
+ * The entire transfer amount still flows through CCTPv2, which then charges its own protocol fee.
5812
+ *
5813
+ * Use `computeFee` (recommended) for human-readable amounts, or `calculateFee` (deprecated)
5814
+ * for smallest-unit amounts. Only one should be provided.
5815
+ *
5816
+ * @example
5817
+ * ```typescript
5818
+ * import type { CustomFeePolicy, BridgeParams } from '@circle-fin/bridge-kit'
5819
+ *
5820
+ * const policy: CustomFeePolicy = {
5821
+ * // computeFee receives human-readable amounts (e.g., '100' for 100 USDC)
5822
+ * computeFee: (params: BridgeParams) => {
5823
+ * const amount = parseFloat(params.amount)
5824
+ *
5825
+ * // 1% fee, capped between 5-50 USDC
5826
+ * const fee = Math.min(Math.max(amount * 0.01, 5), 50)
5827
+ * return fee.toFixed(6)
5828
+ * },
5829
+ * resolveFeeRecipientAddress: (feePayoutChain) =>
5830
+ * feePayoutChain.type === 'solana'
5831
+ * ? 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
5832
+ * : '0x1234567890123456789012345678901234567890',
5833
+ * }
5834
+ * ```
5835
+ */
5836
+ type CustomFeePolicy$2 = {
5837
+ /**
5838
+ * A function that returns the fee to charge for the bridge transfer.
5839
+ * The value returned from the function represents an absolute fee.
5840
+ * The returned fee is **added on top of the transfer amount**. For example, returning
5841
+ * `'5'` (5 USDC) for a 100 USDC transfer causes the wallet to debit 105 USDC total.
5842
+ * CCTPv2 still processes the full 100 USDC transfer amount, while the custom fee is split
5843
+ * 10%/90% between Circle and your fee recipient.
5844
+ *
5845
+ * @example
5846
+ * ```typescript
5847
+ * computeFee: (params) => {
5848
+ * const amount = parseFloat(params.amount)
5849
+ * return (amount * 0.01).toString() // 1% fee
5850
+ * }
5851
+ * ```
5852
+ */
5853
+ computeFee: FeeFunction<AdapterCapabilities, AdapterCapabilities>;
5854
+ calculateFee?: never;
5855
+ /**
5856
+ * A function that returns the fee recipient for a bridge transfer.
5857
+ * The value returned from the function represents the address that will receive the fee on the source chain of the bridge transfer.
5858
+ * The fee recipient address **must be a valid address for the source chain** of the bridge transfer.
5859
+ *
5860
+ * For example: if you are bridging from Ethereum to Solana you would return `'0x1234567890123456789012345678901234567890'`,
5861
+ * because the source chain of the bridge transfer is Ethereum.
5862
+ */
5863
+ resolveFeeRecipientAddress: FeeRecipientFunction<AdapterCapabilities, AdapterCapabilities>;
5864
+ } | {
5865
+ computeFee?: never;
5866
+ /**
5867
+ * Calculate the fee to charge for the bridge transfer using smallest-unit amounts.
5868
+ *
5869
+ * @deprecated Use `computeFee` instead, which receives human-readable amounts.
5870
+ *
5871
+ * The `params.amount` is in smallest units (e.g., `'100000000'` for 100 USDC).
5872
+ */
5873
+ calculateFee: FeeFunction<AdapterCapabilities, AdapterCapabilities>;
5874
+ /**
5875
+ * A function that returns the fee recipient for a bridge transfer.
5876
+ * The value returned from the function represents the address that will receive the fee on the source chain of the bridge transfer.
5877
+ * The fee recipient address **must be a valid address for the source chain** of the bridge transfer.
5878
+ *
5879
+ * For example: if you are bridging from Ethereum to Solana you would return `'0x1234567890123456789012345678901234567890'`,
5880
+ * because the source chain of the bridge transfer is Ethereum.
5881
+ */
5882
+ resolveFeeRecipientAddress: FeeRecipientFunction<AdapterCapabilities, AdapterCapabilities>;
5883
+ };
5570
5884
  /**
5571
5885
  * Parameters for initiating a cross-chain USDC bridge transfer.
5572
5886
  *
@@ -5671,6 +5985,463 @@ interface BridgeParams<TFromAdapterCapabilities extends AdapterCapabilities = Ad
5671
5985
  invocationMeta?: InvocationMeta;
5672
5986
  }
5673
5987
 
5988
+ /**
5989
+ * Allowance strategy for token approvals during swap operations.
5990
+ *
5991
+ * Defines how token allowances should be granted to the swap contract:
5992
+ * - `permit`: Use EIP-2612 permit signature (gas-efficient, no approval transaction)
5993
+ * - `approve`: Traditional approval transaction
5994
+ *
5995
+ * The default strategy is `permit` with fallback to `approve` if permit is not supported.
5996
+ */
5997
+ type AllowanceStrategy$1 = 'permit' | 'approve';
5998
+ /**
5999
+ * Configuration options for swap operations.
6000
+ *
6001
+ * Controls swap behavior including allowance strategy, slippage tolerance,
6002
+ * minimum output amounts, custom fees, and kit identification.
6003
+ *
6004
+ * @example
6005
+ * ```typescript
6006
+ * import type { ServiceSwapConfig } from '@circle-fin/provider-stablecoin-service-swap'
6007
+ *
6008
+ * // Percentage-based fee
6009
+ * const config: ServiceSwapConfig = {
6010
+ * allowanceStrategy: 'permit',
6011
+ * slippageBps: 300, // 3%
6012
+ * stopLimit: '950000', // Minimum 0.95 USDC output
6013
+ * customFee: {
6014
+ * percentageBps: 1000, // 10% fee
6015
+ * recipientAddress: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e'
6016
+ * }
6017
+ * }
6018
+ * ```
6019
+ *
6020
+ * @example
6021
+ * ```typescript
6022
+ * // Absolute amount fee (from callback)
6023
+ * const config: ServiceSwapConfig = {
6024
+ * allowanceStrategy: 'permit',
6025
+ * customFee: {
6026
+ * amount: '10000', // 0.01 USDC fee (absolute)
6027
+ * recipientAddress: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e'
6028
+ * }
6029
+ * }
6030
+ * ```
6031
+ */
6032
+ interface ServiceSwapConfig {
6033
+ /**
6034
+ * Strategy for granting token allowances to the swap contract.
6035
+ *
6036
+ * Defaults to 'permit' with fallback to 'approve'.
6037
+ */
6038
+ allowanceStrategy?: AllowanceStrategy$1;
6039
+ /**
6040
+ * Maximum acceptable slippage in basis points (BPS).
6041
+ *
6042
+ * 1 BPS = 0.01%, so 300 BPS = 3% slippage.
6043
+ * Defaults to 300 BPS (3%).
6044
+ */
6045
+ slippageBps?: number;
6046
+ /**
6047
+ * Minimum acceptable output amount in smallest units (stop-limit).
6048
+ *
6049
+ * If the estimated output falls below this value, the swap will fail.
6050
+ * Expressed as a string to avoid precision issues.
6051
+ */
6052
+ stopLimit?: string;
6053
+ /**
6054
+ * Custom fee configuration for this swap.
6055
+ *
6056
+ * Supports two mutually exclusive approaches:
6057
+ * 1. Percentage-based: Use `percentageBps` field (simple)
6058
+ * 2. Absolute amount: Use `amount` field (from callback)
6059
+ *
6060
+ * If both are set, validation will fail. Transaction-level percentage
6061
+ * takes precedence over kit-level callback policy.
6062
+ */
6063
+ customFee?: {
6064
+ /**
6065
+ * Fee percentage in basis points (NEW).
6066
+ *
6067
+ * 100 bps = 1%, 1000 bps = 10%, 10000 bps = 100%
6068
+ *
6069
+ * Service calculates fee using `estimatedAmount` for same-chain output fees
6070
+ * and the input amount for cross-chain swaps.
6071
+ * Must be greater than 0 and less than or equal to 10000 (maximum 100%).
6072
+ * Mutually exclusive with `amount`.
6073
+ *
6074
+ * @example 1000 // 10% fee
6075
+ */
6076
+ percentageBps?: number;
6077
+ /**
6078
+ * Fee amount in smallest units (for callback results).
6079
+ *
6080
+ * Absolute fee amount calculated by callback function.
6081
+ * Mutually exclusive with `percentageBps`.
6082
+ *
6083
+ * @example '10000' // 0.01 USDC (6 decimals)
6084
+ */
6085
+ amount?: string;
6086
+ /**
6087
+ * Address that will receive the developer's 90% fee share.
6088
+ *
6089
+ * Required whenever a custom fee is submitted to the provider. Optional at
6090
+ * the type level so SDK callback flows can represent partial fee state
6091
+ * before final validation.
6092
+ *
6093
+ * Must be valid on the fee payout chain: source chain for input-side fees
6094
+ * and cross-chain swaps, destination chain for same-chain output-side fees.
6095
+ *
6096
+ * @example '0x742d35Cc6634C0532925a3b844Bc454e4438f44e'
6097
+ */
6098
+ recipientAddress?: string;
6099
+ };
6100
+ /**
6101
+ * Stablecoin Service Kit Key used to authenticate service-backed swap
6102
+ * requests.
6103
+ *
6104
+ * Treat this value as a credential. Do not log it, embed it in client-side
6105
+ * source, or expose it in telemetry.
6106
+ */
6107
+ kitKey?: string;
6108
+ /**
6109
+ * DEX aggregator identifier used to source the swap route.
6110
+ *
6111
+ * @example 'lifi', 'paraswap'
6112
+ */
6113
+ provider?: string;
6114
+ /**
6115
+ * Whether to fuse the ERC-20 approval and the swap into a single atomic
6116
+ * batch when the adapter supports it (EIP-5792, or a signing strategy that
6117
+ * declares atomic batching).
6118
+ *
6119
+ * @remarks
6120
+ * Defaults to `true`. When batching is available this collapses the two
6121
+ * sequential transactions of the on-chain approval path into one atomic
6122
+ * submission — a single signing challenge for a smart-contract wallet. Set
6123
+ * to `false` to force the sequential approve-then-swap path. Has no effect on
6124
+ * the gasless permit path (already a single transaction) or on native-token
6125
+ * swaps (no approval needed).
6126
+ *
6127
+ * The batch path relies on the wallet's own gas estimation for the swap call:
6128
+ * the service-provided gas floor and pre-flight simulation that the sequential
6129
+ * path applies are not conveyed through the batch. For a complex/multi-hop
6130
+ * swap whose wallet-side estimate under-shoots, this can out-of-gas-revert the
6131
+ * atomic batch where the sequential path would succeed — set `false` to fall
6132
+ * back to the service-floored sequential path if you hit this.
6133
+ *
6134
+ * @defaultValue true
6135
+ */
6136
+ batchTransactions?: boolean;
6137
+ }
6138
+ /**
6139
+ * Parameters for initiating a swap operation through the Stablecoin Service.
6140
+ *
6141
+ * This type is used as the primary input to provider swap operations, allowing users to specify
6142
+ * the source context, input/output tokens, swap amount, destination address, and optional configuration.
6143
+ *
6144
+ * @typeParam TFromAdapterCapabilities - The adapter capabilities type for the source adapter.
6145
+ *
6146
+ * @example
6147
+ * ```typescript
6148
+ * import type { ServiceSwapParams } from '@circle-fin/provider-stablecoin-service-swap'
6149
+ * import { createAdapterFromPrivateKey } from '@circle-fin/adapter-viem-v2'
6150
+ * import { Ethereum } from '@core/chains'
6151
+ *
6152
+ * const adapter = createAdapterFromPrivateKey({
6153
+ * privateKey: process.env.PRIVATE_KEY,
6154
+ * })
6155
+ *
6156
+ * const params: ServiceSwapParams = {
6157
+ * from: { adapter, chain: Ethereum },
6158
+ * tokenIn: 'USDC', // Alias resolves to chain-specific address
6159
+ * tokenOut: 'USDT', // Alias resolves to chain-specific address
6160
+ * amountIn: '100500000', // 100.50 USDC in base units
6161
+ * to: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',
6162
+ * config: {
6163
+ * slippageBps: 300, // 3% slippage
6164
+ * allowanceStrategy: 'permit'
6165
+ * }
6166
+ * }
6167
+ * ```
6168
+ */
6169
+ interface ServiceSwapParams<TFromAdapterCapabilities extends AdapterCapabilities = AdapterCapabilities,
6170
+ /**
6171
+ * The chain definition type to use for the wallet context.
6172
+ *
6173
+ * @defaultValue ChainDefinition
6174
+ */
6175
+ TChainDefinition extends ChainDefinition = ChainDefinition> {
6176
+ /**
6177
+ * The source adapter context (wallet and chain) for the swap.
6178
+ */
6179
+ from: WalletContext<TFromAdapterCapabilities, TChainDefinition>;
6180
+ /**
6181
+ * The input token address or alias to swap from.
6182
+ *
6183
+ * **Supported formats:**
6184
+ * - Token alias: `"USDC"`, `"USDT"`, `"NATIVE"` (case-insensitive)
6185
+ * - EVM address: `'0x'` prefixed hex (e.g., `'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'`)
6186
+ * - Solana address: Base58-encoded (e.g., `'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'`)
6187
+ *
6188
+ * Token aliases are automatically resolved to the chain-specific contract address.
6189
+ *
6190
+ * @example 'USDC' // Recommended: use alias
6191
+ * @example '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48' // Or full address
6192
+ */
6193
+ tokenIn: string;
6194
+ /**
6195
+ * The output token address or alias to swap to.
6196
+ *
6197
+ * **Supported formats:**
6198
+ * - Token alias: `"USDC"`, `"USDT"`, `"NATIVE"` (case-insensitive)
6199
+ * - EVM address: `'0x'` prefixed hex (e.g., `'0xdAC17F958D2ee523a2206206994597C13D831ec7'`)
6200
+ * - Solana address: Base58-encoded (e.g., `'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB'`)
6201
+ *
6202
+ * Token aliases are automatically resolved to the chain-specific contract address.
6203
+ *
6204
+ * @example 'USDT' // Recommended: use alias
6205
+ * @example '0xdAC17F958D2ee523a2206206994597C13D831ec7' // Or full address
6206
+ */
6207
+ tokenOut: string;
6208
+ /**
6209
+ * The amount of input token to swap in base units.
6210
+ *
6211
+ * SwapKit converts human-readable amounts to base units before passing to the provider.
6212
+ *
6213
+ * @example '100500000' for 100.50 USDC (6 decimals)
6214
+ */
6215
+ amountIn: string;
6216
+ /**
6217
+ * The destination address where the swapped tokens will be sent.
6218
+ *
6219
+ * @example '0x742d35Cc6634C0532925a3b844Bc454e4438f44e'
6220
+ */
6221
+ to: string;
6222
+ /**
6223
+ * Optional destination chain for cross-chain swaps.
6224
+ *
6225
+ * Defaults to `from.chain` for same-chain swaps.
6226
+ */
6227
+ toChain?: TChainDefinition;
6228
+ /**
6229
+ * Optional configuration for swap behavior.
6230
+ *
6231
+ * If omitted, defaults will be used:
6232
+ * - allowanceStrategy: 'permit' (fallback to 'approve')
6233
+ * - slippageBps: 300 (3%)
6234
+ */
6235
+ config?: ServiceSwapConfig;
6236
+ }
6237
+
6238
+ /**
6239
+ * Fee context when fee is taken from INPUT token.
6240
+ *
6241
+ * Used for swaps where the fee is collected from the input token, including
6242
+ * all cross-chain swaps.
6243
+ * Extends the resolved swap parameters with a discriminator to indicate input fee scenario.
6244
+ *
6245
+ * @typeParam TFromAdapterCapabilities - The adapter capabilities type for the source adapter
6246
+ *
6247
+ * @example
6248
+ * ```typescript
6249
+ * // USDC → RandomToken swap (fee from input)
6250
+ * const context: SwapInputFeeContext = {
6251
+ * type: 'input',
6252
+ * from: {
6253
+ * adapter: viemAdapter,
6254
+ * chain: Ethereum,
6255
+ * address: '0x...'
6256
+ * },
6257
+ * tokenIn: 'USDC',
6258
+ * tokenOut: 'RandomToken',
6259
+ * amountIn: '100000000', // 100 USDC in base units
6260
+ * to: '0x...'
6261
+ * }
6262
+ * ```
6263
+ */
6264
+ interface SwapInputFeeContext<TFromAdapterCapabilities extends AdapterCapabilities = AdapterCapabilities> extends ResolvedSwapParams<TFromAdapterCapabilities> {
6265
+ /**
6266
+ * Fee source discriminator - input token.
6267
+ */
6268
+ type: 'input';
6269
+ }
6270
+ /**
6271
+ * Fee context when fee is taken from OUTPUT token.
6272
+ *
6273
+ * Used for swaps where the output token is supported for fee collection.
6274
+ * Extends the resolved swap parameters with output amounts and discriminator.
6275
+ *
6276
+ * @typeParam TFromAdapterCapabilities - The adapter capabilities type for the source adapter
6277
+ *
6278
+ * @remarks
6279
+ * If using `estimatedAmount` in callback and quote cache expires,
6280
+ * calculated fee may not match fresh quote. Use `minAmount` for
6281
+ * predictability at the cost of potentially lower fees.
6282
+ *
6283
+ * @example
6284
+ * ```typescript
6285
+ * // RandomToken → USDC swap (fee from output)
6286
+ * const context: SwapOutputFeeContext = {
6287
+ * type: 'output',
6288
+ * from: {
6289
+ * adapter: viemAdapter,
6290
+ * chain: Ethereum,
6291
+ * address: '0x...'
6292
+ * },
6293
+ * tokenIn: 'RandomToken',
6294
+ * tokenOut: 'USDC',
6295
+ * amountIn: '100000000',
6296
+ * to: '0x...',
6297
+ * minAmount: '50000000', // 50 USDC guaranteed minimum
6298
+ * estimatedAmount: '55000000' // 55 USDC expected output
6299
+ * }
6300
+ * ```
6301
+ */
6302
+ interface SwapOutputFeeContext<TFromAdapterCapabilities extends AdapterCapabilities = AdapterCapabilities> extends ResolvedSwapParams<TFromAdapterCapabilities> {
6303
+ /**
6304
+ * Fee source discriminator - output token.
6305
+ */
6306
+ type: 'output';
6307
+ /**
6308
+ * Guaranteed minimum output amount in base units.
6309
+ *
6310
+ * More stable but lower than estimatedAmount. Use this for
6311
+ * predictable fee calculations.
6312
+ */
6313
+ minAmount: string;
6314
+ /**
6315
+ * Estimated output amount in base units.
6316
+ *
6317
+ * Expected output based on current market conditions. May be
6318
+ * higher than minAmount. Subject to change if quote expires.
6319
+ */
6320
+ estimatedAmount: string;
6321
+ }
6322
+ /**
6323
+ * Discriminated union for swap fee contexts.
6324
+ *
6325
+ * Provides different context based on whether fee is from input or output token.
6326
+ * Discriminated by the `type` field: 'input' for fees from input token, 'output' for output token.
6327
+ *
6328
+ * Includes full swap parameters (adapter, chain, tokens, amounts) for maximum flexibility
6329
+ * in fee calculation logic.
6330
+ *
6331
+ * @typeParam TFromAdapterCapabilities - The adapter capabilities type for the source adapter
6332
+ */
6333
+ type SwapFeeContext<TFromAdapterCapabilities extends AdapterCapabilities = AdapterCapabilities> = SwapInputFeeContext<TFromAdapterCapabilities> | SwapOutputFeeContext<TFromAdapterCapabilities>;
6334
+ /**
6335
+ * Custom fee policy for SwapKit (callback-based approach).
6336
+ *
6337
+ * Provides hooks to calculate an absolute fee amount and resolve the fee
6338
+ * recipient address. The callback receives a discriminated context with
6339
+ * different fields based on operation type (bridge vs swap) and fee source
6340
+ * (input vs output).
6341
+ *
6342
+ * @remarks
6343
+ * This is mutually exclusive with transaction-level percentage fees.
6344
+ * If both are set, the transaction-level percentage takes precedence.
6345
+ *
6346
+ * The callback approach makes two API calls for same-chain output fees:
6347
+ * 1. GET /quote - retrieve fee context and quote
6348
+ * 2. POST /swap - execute with calculated fee
6349
+ *
6350
+ * Cross-chain swaps always use input fees on the source chain, so callbacks
6351
+ * receive `type: 'input'` for those routes.
6352
+ *
6353
+ * @example
6354
+ * ```typescript
6355
+ * import type { CustomFeePolicy } from '@circle-fin/swap-kit'
6356
+ *
6357
+ * const policy: CustomFeePolicy = {
6358
+ * computeFee: async (ctx) => {
6359
+ * // Discriminate by fee source (input vs output)
6360
+ * if (ctx.type === 'input') {
6361
+ * // Simple percentage for input fees
6362
+ * return (parseFloat(ctx.amountIn) * 0.1).toString()
6363
+ * } else {
6364
+ * // Complex logic for output fees (VIP tiers, etc.)
6365
+ * const user = await database.getUser(...)
6366
+ * if (user.isVIP) {
6367
+ * return (parseFloat(ctx.minAmount) * 0.05).toString()
6368
+ * }
6369
+ * return (parseFloat(ctx.estimatedAmount) * 0.1).toString()
6370
+ * }
6371
+ * },
6372
+ * resolveFeeRecipientAddress: (chain) => {
6373
+ * return chain.type === 'solana'
6374
+ * ? 'SolanaAddress...'
6375
+ * : '0xEVMAddress...'
6376
+ * },
6377
+ * }
6378
+ * ```
6379
+ */
6380
+ interface CustomFeePolicy$1 {
6381
+ /**
6382
+ * Calculate custom fee amount based on swap context.
6383
+ *
6384
+ * Receives full swap parameters including adapter, chain, tokens, and amounts.
6385
+ * Context is discriminated by `type` field:
6386
+ * - 'input': Fee from input token (OK → Any swaps and all cross-chain swaps)
6387
+ * - 'output': Fee from output token (same-chain Any → OK swaps), includes minAmount and estimatedAmount
6388
+ *
6389
+ * The wrapper automatically converts amounts to/from base units, so your
6390
+ * callback works with human-readable numbers (e.g., '0.1' for 0.1 USDC).
6391
+ *
6392
+ * @typeParam TFromAdapterCapabilities - The adapter capabilities type for the source adapter
6393
+ * @param context - Discriminated swap fee context with full swap parameters
6394
+ * @returns Absolute fee amount as string in human-readable format
6395
+ *
6396
+ * @example
6397
+ * ```typescript
6398
+ * computeFee: async (ctx) => {
6399
+ * if (ctx.type === 'output') {
6400
+ * // Output fee scenario
6401
+ * // Use estimatedAmount or minAmount for calculation
6402
+ * return (parseFloat(ctx.estimatedAmount) * 0.01).toString()
6403
+ * }
6404
+ * // Input fee scenario
6405
+ * return (parseFloat(ctx.amountIn) * 0.01).toString()
6406
+ * }
6407
+ * ```
6408
+ *
6409
+ * @example
6410
+ * ```typescript
6411
+ * computeFee: async (ctx) => {
6412
+ * if (ctx.type === 'output') {
6413
+ * // Use minAmount for predictable fees
6414
+ * return (parseFloat(ctx.minAmount) * 0.01).toString()
6415
+ * }
6416
+ * return (parseFloat(ctx.amountIn) * 0.01).toString()
6417
+ * }
6418
+ * ```
6419
+ */
6420
+ computeFee: <TFromAdapterCapabilities extends AdapterCapabilities>(context: SwapFeeContext<TFromAdapterCapabilities>) => Promise<string> | string;
6421
+ /**
6422
+ * Resolve fee recipient address for the chain where fee is collected.
6423
+ *
6424
+ * Called with the chain where fee will be paid. For cross-chain swaps this
6425
+ * is always the source chain. Must return a valid address format for that
6426
+ * chain type (EVM or Solana).
6427
+ *
6428
+ * @param feePayoutChain - Chain definition where fee is collected
6429
+ * @param context - The swap fee context with full parameters
6430
+ * @returns Fee recipient address for the chain
6431
+ *
6432
+ * @example
6433
+ * ```typescript
6434
+ * resolveFeeRecipientAddress: (chain, ctx) => {
6435
+ * // Chain-based routing
6436
+ * if (chain.type === 'solana') {
6437
+ * return 'SolanaAddress...'
6438
+ * }
6439
+ * return '0xEVMAddress...'
6440
+ * }
6441
+ * ```
6442
+ */
6443
+ resolveFeeRecipientAddress: <TFromAdapterCapabilities extends AdapterCapabilities>(feePayoutChain: ChainDefinition, context: SwapFeeContext<TFromAdapterCapabilities>) => Promise<string> | string;
6444
+ }
5674
6445
  /**
5675
6446
  * Adapter context constrained to swap-supported chains.
5676
6447
  */
@@ -5818,6 +6589,45 @@ interface SwapConfig {
5818
6589
  */
5819
6590
  kitKey?: string;
5820
6591
  }
6592
+ /**
6593
+ * Resolved parameters for swap operations after validation and normalization.
6594
+ *
6595
+ * Internal type used by SwapKit operations after `resolveSwapParams()` has:
6596
+ * - Validated the input parameters
6597
+ * - Resolved chain identifiers to full ChainDefinition objects
6598
+ * - Extracted and validated wallet addresses
6599
+ *
6600
+ * Note: Raw user input is validated first, then `tokenIn` and `tokenOut` may
6601
+ * be canonicalized for downstream routing (for example, Arc Testnet
6602
+ * `NATIVE` → `USDC`). Address resolution is handled by the provider layer.
6603
+ *
6604
+ * This type is consumed by swap providers and internal operations but is not
6605
+ * exposed to end users. It extends ServiceSwapParams which is the format expected
6606
+ * by the StablecoinServiceSwapProvider.
6607
+ *
6608
+ * @typeParam TFromAdapterCapabilities - The adapter capabilities type for the source adapter.
6609
+ *
6610
+ * @example
6611
+ * ```typescript
6612
+ * // After resolution, SwapParams becomes ResolvedSwapParams:
6613
+ * const resolved: ResolvedSwapParams = {
6614
+ * from: {
6615
+ * adapter: viemAdapter,
6616
+ * chain: Ethereum, // Full chain definition
6617
+ * address: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e'
6618
+ * },
6619
+ * tokenIn: 'USDC', // Canonicalized for provider routing
6620
+ * tokenOut: 'USDT', // Canonicalized for provider routing
6621
+ * amountIn: '100500000', // Converted to base units (100.5 USDC with 6 decimals)
6622
+ * to: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',
6623
+ * config: {
6624
+ * slippageBps: 300,
6625
+ * allowanceStrategy: 'permit'
6626
+ * }
6627
+ * }
6628
+ * ```
6629
+ */
6630
+ type ResolvedSwapParams<TFromAdapterCapabilities extends AdapterCapabilities = AdapterCapabilities> = ServiceSwapParams<TFromAdapterCapabilities>;
5821
6631
  interface SwapParams<TFromAdapterCapabilities extends AdapterCapabilities = AdapterCapabilities> {
5822
6632
  /**
5823
6633
  * The source adapter context (wallet and chain) for the swap.
@@ -5930,6 +6740,24 @@ interface EarnConfig {
5930
6740
  * Format: `KIT_KEY:<keyId>:<keySecret>`
5931
6741
  */
5932
6742
  readonly kitKey?: string | undefined;
6743
+ /**
6744
+ * Optional base URL override for the Earn Service API.
6745
+ *
6746
+ * Defaults to `https://api.circle.com` when omitted. Override for testing
6747
+ * against staging or local environments.
6748
+ */
6749
+ readonly baseUrl?: string | undefined;
6750
+ /**
6751
+ * Enable or disable atomic batched transaction execution.
6752
+ *
6753
+ * When `true` (or `undefined` / omitted), same-chain deposit and withdraw
6754
+ * bundle the approve and execute calls into one adapter-native atomic batch
6755
+ * when the connected wallet supports it. Set to `false` to force the
6756
+ * sequential approve → execute flow.
6757
+ *
6758
+ * @defaultValue `undefined` (batching attempted when the wallet supports it)
6759
+ */
6760
+ readonly batchTransactions?: boolean | undefined;
5933
6761
  }
5934
6762
  /**
5935
6763
  * Parameters for fetching vault information.
@@ -6362,6 +7190,122 @@ interface GetClaimRewardsQuoteParams<TFromAdapterCapabilities extends AdapterCap
6362
7190
  */
6363
7191
  type EarnOperationParams = AnyDepositParams | WithdrawParams | ClaimRewardsParams | GetVaultsParams | ExploreVaultsParams | ExploreVaultsIteratorParams | GetPositionParams | GetDepositQuoteParams | GetWithdrawalQuoteParams | GetClaimRewardsQuoteParams;
6364
7192
 
7193
+ interface CustomFeeConfig {
7194
+ recipientAddress: string;
7195
+ value: string;
7196
+ }
7197
+ /**
7198
+ * Data needed to retry a mint that failed after the transfer was
7199
+ * already committed (funds locked).
7200
+ *
7201
+ * Obtain these values from the KitError (TRANSACTION_REVERTED) thrown when
7202
+ * the on-chain mint step fails. The attestation and signature are available
7203
+ * in `error.cause.trace`.
7204
+ */
7205
+ interface RetryMintConfig {
7206
+ /** The attestation hex string returned by the Gateway `/v1/transfer` API. */
7207
+ attestation: string;
7208
+ /** The attestation signature hex string returned by `/v1/transfer`. */
7209
+ signature: string;
7210
+ }
7211
+ interface SpendConfig {
7212
+ customFee?: CustomFeeConfig;
7213
+ /**
7214
+ * When provided, skips the estimate/sign/transfer steps and proceeds
7215
+ * directly to the on-chain mint using a previously obtained attestation.
7216
+ *
7217
+ * Use this to retry a mint that failed due to an RPC or network issue
7218
+ * after the transfer was already committed.
7219
+ *
7220
+ * @remarks
7221
+ * The `useForwarder` flag on the destination is ignored during retry
7222
+ * because the attestation was already issued — the Forwarding Service
7223
+ * is only involved in the initial transfer, not re-mints.
7224
+ */
7225
+ retry?: RetryMintConfig;
7226
+ }
7227
+ interface ResolvedAllocation {
7228
+ amount: string;
7229
+ chain: ChainDefinition;
7230
+ }
7231
+ interface ResolvedSpendSource<TAdapterCapabilities extends AdapterCapabilities = AdapterCapabilities> {
7232
+ adapter: Adapter<TAdapterCapabilities>;
7233
+ allocations: ResolvedAllocation[];
7234
+ address?: string;
7235
+ sourceAccount?: string;
7236
+ }
7237
+ interface ResolvedSpendDestination<TAdapterCapabilities extends AdapterCapabilities = AdapterCapabilities> {
7238
+ adapter?: Adapter<TAdapterCapabilities>;
7239
+ chain: ChainDefinition;
7240
+ recipientAddress?: string;
7241
+ address?: string;
7242
+ useForwarder?: boolean;
7243
+ }
7244
+ interface ResolvedSpendParams<TFromAdapterCapabilities extends AdapterCapabilities = AdapterCapabilities, TToAdapterCapabilities extends AdapterCapabilities = AdapterCapabilities> {
7245
+ from: ResolvedSpendSource<TFromAdapterCapabilities>[];
7246
+ to: ResolvedSpendDestination<TToAdapterCapabilities>;
7247
+ token: SupportedToken;
7248
+ config?: SpendConfig;
7249
+ }
7250
+ /**
7251
+ * Function that computes the fee amount (in human-readable units, e.g. "10.5")
7252
+ * given the resolved spend parameters.
7253
+ */
7254
+ type SpendFeeFunction = (params: ResolvedSpendParams) => Promise<string> | string;
7255
+ /**
7256
+ * Function that resolves the fee recipient address for a spend.
7257
+ * Called once per spend, against the resolved **destination** chain —
7258
+ * every fee burn intent in a spend mints to that single chain
7259
+ * regardless of which source chain(s) funded it, so only one
7260
+ * recipient address (valid on the destination chain) is ever needed.
7261
+ */
7262
+ type SpendFeeRecipientFunction = (destinationChain: ChainDefinition, params: ResolvedSpendParams) => Promise<string> | string;
7263
+ /**
7264
+ * Policy for computing and routing custom developer fees.
7265
+ *
7266
+ * **Important:** When the kit invokes `computeFee` and
7267
+ * `resolveFeeRecipientAddress`, the `params` argument may be the
7268
+ * **raw, unresolved** `SpendParams` (cast to `ResolvedSpendParams`).
7269
+ * Fields that only exist after resolution (e.g. per-source allocations)
7270
+ * may be `undefined`. Implementations should only rely on top-level
7271
+ * fields such as `to`, `token`, and `amount`.
7272
+ *
7273
+ * @remarks
7274
+ * `resolveFeeRecipientAddress` is optional when you configure
7275
+ * {@link UnifiedBalanceKit.setFeeRecipients} instead — the declarative
7276
+ * map takes priority over this callback when both are present. Provide
7277
+ * exactly one of the two; a policy with neither throws at spend time.
7278
+ */
7279
+ interface CustomFeePolicy {
7280
+ computeFee: SpendFeeFunction;
7281
+ resolveFeeRecipientAddress?: SpendFeeRecipientFunction;
7282
+ }
7283
+
7284
+ /**
7285
+ * Runtime array of token identifiers supported by the unified-balance-kit.
7286
+ *
7287
+ * @example
7288
+ * ```typescript
7289
+ * import { SUPPORTED_TOKENS } from '@circle-fin/unified-balance-kit'
7290
+ *
7291
+ * if (SUPPORTED_TOKENS.includes('USDC')) {
7292
+ * console.log('USDC is supported')
7293
+ * }
7294
+ * ```
7295
+ */
7296
+ declare const SUPPORTED_TOKENS: readonly ["USDC"];
7297
+ /**
7298
+ * Token identifiers supported by the unified-balance-kit.
7299
+ *
7300
+ * @example
7301
+ * ```typescript
7302
+ * import type { SupportedToken } from '@circle-fin/unified-balance-kit'
7303
+ *
7304
+ * const token: SupportedToken = 'USDC'
7305
+ * ```
7306
+ */
7307
+ type SupportedToken = (typeof SUPPORTED_TOKENS)[number];
7308
+
6365
7309
  /**
6366
7310
  * Operation types that support the `getFee`/`getFeeRecipient` hooks.
6367
7311
  */
@@ -6392,6 +7336,31 @@ interface OperationParamsMap {
6392
7336
  swap: SwapParams;
6393
7337
  earn: EarnOperationParams;
6394
7338
  }
7339
+ /**
7340
+ * Operation-scoped custom fee policies configured at the AppKit level.
7341
+ *
7342
+ * Each property is optional so consumers can enable custom fees only for the
7343
+ * operation they use. AppKit forwards the supplied policy to the matching
7344
+ * underlying kit when that operation runs.
7345
+ *
7346
+ * @example
7347
+ * ```typescript
7348
+ * const policy: AppKitCustomFeePolicy = {
7349
+ * bridge: {
7350
+ * computeFee: () => '1.00',
7351
+ * resolveFeeRecipientAddress: () => '0x1234567890123456789012345678901234567890',
7352
+ * },
7353
+ * }
7354
+ * ```
7355
+ */
7356
+ interface AppKitCustomFeePolicy {
7357
+ /** Custom fee policy forwarded to BridgeKit bridge operations. */
7358
+ bridge?: CustomFeePolicy$2;
7359
+ /** Custom fee policy forwarded to SwapKit swap operations. */
7360
+ swap?: CustomFeePolicy$1;
7361
+ /** Custom fee policy forwarded to UnifiedBalanceKit spend operations. */
7362
+ unifiedBalance?: CustomFeePolicy;
7363
+ }
6395
7364
  /**
6396
7365
  * Context interface for the AppKit with strongly typed getFee method.
6397
7366
  *
@@ -6479,6 +7448,14 @@ interface AppKitContext {
6479
7448
  chain: ChainDefinition;
6480
7449
  params: OperationParamsMap[T];
6481
7450
  }): Promise<string>;
7451
+ /**
7452
+ * Operation-scoped custom fee policies.
7453
+ *
7454
+ * Prefer {@link AppKit.setCustomFeePolicy} for runtime configuration. This
7455
+ * context property is read by the internal kit factories when AppKit creates
7456
+ * BridgeKit and SwapKit instances for each operation.
7457
+ */
7458
+ customFeePolicy?: AppKitCustomFeePolicy;
6482
7459
  /**
6483
7460
  * Event handlers registered for AppKit operations.
6484
7461
  *