@circle-fin/adapter-ethers-v6 1.4.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/index.d.ts CHANGED
@@ -35,7 +35,6 @@ import { TransactionInstruction, Signer, AddressLookupTableAccount } from '@sola
35
35
  */
36
36
  /**
37
37
  * Represents basic information about a currency or token.
38
- * @interface Currency
39
38
  * @category Types
40
39
  * @description Provides the essential properties of a cryptocurrency or token.
41
40
  * @example
@@ -67,7 +66,6 @@ interface Currency {
67
66
  }
68
67
  /**
69
68
  * Base information that all chain definitions must include.
70
- * @interface BaseChainDefinition
71
69
  * @category Types
72
70
  * @description Provides the common properties shared by all blockchain definitions.
73
71
  * @example
@@ -127,6 +125,11 @@ interface BaseChainDefinition {
127
125
  * @description Its presence indicates that USDC is supported.
128
126
  */
129
127
  usdcAddress: string | null;
128
+ /**
129
+ * The contract address for USDT.
130
+ * @description Its presence indicates that USDT is supported.
131
+ */
132
+ usdtAddress: string | null;
130
133
  /**
131
134
  * Optional CCTP configuration.
132
135
  * @description If provided, the chain supports CCTP.
@@ -168,7 +171,6 @@ interface BaseChainDefinition {
168
171
  }
169
172
  /**
170
173
  * Represents chain definitions for Ethereum Virtual Machine (EVM) compatible blockchains.
171
- * @interface EVMChainDefinition
172
174
  * @extends BaseChainDefinition
173
175
  * @category Types
174
176
  * @description Adds properties specific to EVM chains.
@@ -200,7 +202,6 @@ interface EVMChainDefinition extends BaseChainDefinition {
200
202
  }
201
203
  /**
202
204
  * Represents chain definitions for non-EVM blockchains.
203
- * @interface NonEVMChainDefinition
204
205
  * @extends BaseChainDefinition
205
206
  * @category Types
206
207
  * @description Contains properties for blockchains that do not use the EVM.
@@ -253,6 +254,7 @@ type ChainType = EVMChainDefinition['type'] | NonEVMChainDefinition['type'];
253
254
  * rpcEndpoints: ['https://eth.example.com'],
254
255
  * eurcAddress: null,
255
256
  * usdcAddress: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
257
+ * usdtAddress: '0xdac17f958d2ee523a2206206994597c13d831ec7',
256
258
  * cctp: {
257
259
  * domain: 0,
258
260
  * contracts: {
@@ -316,17 +318,74 @@ type ChainDefinitionWithCCTPv2 = ChainDefinition & {
316
318
  * - A string literal of the blockchain value (e.g., "Ethereum")
317
319
  */
318
320
  type ChainIdentifier = ChainDefinition | Blockchain | `${Blockchain}`;
321
+ /**
322
+ * Split CCTP contract configuration.
323
+ *
324
+ * Used by chains that deploy separate TokenMessenger and MessageTransmitter contracts.
325
+ * This is the traditional CCTP architecture used by most EVM chains.
326
+ *
327
+ * @example
328
+ * ```typescript
329
+ * const splitConfig: CCTPSplitConfig = {
330
+ * type: 'split',
331
+ * tokenMessenger: '0x1234567890abcdef1234567890abcdef12345678',
332
+ * messageTransmitter: '0xabcdef1234567890abcdef1234567890abcdef12',
333
+ * confirmations: 12
334
+ * }
335
+ * ```
336
+ */
319
337
  interface CCTPSplitConfig {
320
338
  type: 'split';
321
339
  tokenMessenger: string;
322
340
  messageTransmitter: string;
323
341
  confirmations: number;
324
342
  }
343
+ /**
344
+ * Merged CCTP contract configuration.
345
+ *
346
+ * Used by chains that deploy a single unified CCTP contract.
347
+ * This simplified architecture is used by newer chain integrations.
348
+ *
349
+ * @example
350
+ * ```typescript
351
+ * const mergedConfig: CCTPMergedConfig = {
352
+ * type: 'merged',
353
+ * contract: '0x9876543210fedcba9876543210fedcba98765432',
354
+ * confirmations: 1
355
+ * }
356
+ * ```
357
+ */
325
358
  interface CCTPMergedConfig {
326
359
  type: 'merged';
327
360
  contract: string;
328
361
  confirmations: number;
329
362
  }
363
+ /**
364
+ * Version configuration for CCTP contracts.
365
+ *
366
+ * Defines whether the chain uses split or merged CCTP contract architecture.
367
+ * Split configuration uses separate TokenMessenger and MessageTransmitter contracts,
368
+ * while merged configuration uses a single unified contract.
369
+ *
370
+ * @example Split configuration (most EVM chains)
371
+ * ```typescript
372
+ * const splitConfig: VersionConfig = {
373
+ * type: 'split',
374
+ * tokenMessenger: '0x1234567890abcdef1234567890abcdef12345678',
375
+ * messageTransmitter: '0xabcdef1234567890abcdef1234567890abcdef12',
376
+ * confirmations: 12
377
+ * }
378
+ * ```
379
+ *
380
+ * @example Merged configuration (newer chains)
381
+ * ```typescript
382
+ * const mergedConfig: VersionConfig = {
383
+ * type: 'merged',
384
+ * contract: '0x9876543210fedcba9876543210fedcba98765432',
385
+ * confirmations: 1
386
+ * }
387
+ * ```
388
+ */
330
389
  type VersionConfig = CCTPSplitConfig | CCTPMergedConfig;
331
390
  type CCTPContracts = Partial<{
332
391
  v1: VersionConfig;
@@ -336,7 +395,6 @@ type CCTPContracts = Partial<{
336
395
  }>;
337
396
  /**
338
397
  * Configuration for the Cross-Chain Transfer Protocol (CCTP).
339
- * @interface CCTPConfig
340
398
  * @category Types
341
399
  * @description Contains the domain and required contract addresses for CCTP support.
342
400
  * @example
@@ -359,6 +417,22 @@ interface CCTPConfig {
359
417
  * The contracts required for CCTP.
360
418
  */
361
419
  contracts: CCTPContracts;
420
+ /**
421
+ * Indicates whether the chain supports forwarder for source and destination.
422
+ * @example
423
+ * ```typescript
424
+ * const chainWithForwarderSupported: ChainDefinition = {
425
+ * forwarderSupported: {
426
+ * source: true,
427
+ * destination: true,
428
+ * },
429
+ * }
430
+ * ```
431
+ */
432
+ forwarderSupported: {
433
+ source: boolean;
434
+ destination: boolean;
435
+ };
362
436
  }
363
437
  /**
364
438
  * Available kit contract types for enhanced chain functionality.
@@ -374,7 +448,7 @@ interface CCTPConfig {
374
448
  * const invalidType: KitContractType = 'invalid' // TypeScript error
375
449
  * ```
376
450
  */
377
- type KitContractType = 'bridge';
451
+ type KitContractType = 'bridge' | 'adapter';
378
452
  /**
379
453
  * Kit-specific contract addresses for enhanced chain functionality.
380
454
  *
@@ -645,8 +719,20 @@ type EvmPreparedChainRequestParams = {
645
719
  interface SolanaPreparedChainRequestParams {
646
720
  /**
647
721
  * The array of instructions to include in the transaction.
722
+ *
723
+ * @remarks
724
+ * Used for instruction-based transaction building. Mutually exclusive with
725
+ * `serializedTransaction`.
648
726
  */
649
- instructions: TransactionInstruction[];
727
+ instructions?: TransactionInstruction[];
728
+ /**
729
+ * A pre-serialized transaction as a Uint8Array (e.g., from a service like Jupiter).
730
+ *
731
+ * @remarks
732
+ * Used for executing pre-built transactions from external services.
733
+ * The transaction may be partially signed. Mutually exclusive with `instructions`.
734
+ */
735
+ serializedTransaction?: Uint8Array;
650
736
  /**
651
737
  * Additional signers besides the Adapter's wallet (e.g. program-derived authorities).
652
738
  */
@@ -1324,6 +1410,99 @@ interface CCTPv2ActionMap {
1324
1410
  */
1325
1411
  permitParams?: PermitParams;
1326
1412
  };
1413
+ /**
1414
+ * Initiate a cross-chain USDC transfer using a custom bridge contract with hook data for CCTP forwarding.
1415
+ *
1416
+ * This action combines the custom bridge functionality with CCTP forwarding hookData.
1417
+ * It uses either `bridgeWithPreapprovalAndHook` or `bridgeWithPermitAndHook` contract
1418
+ * functions depending on whether permit parameters are provided.
1419
+ *
1420
+ * @remarks
1421
+ * When CCTP forwarding is enabled with custom burn, Circle's relay infrastructure will:
1422
+ * 1. Watch for the burn transaction with forwarding hookData
1423
+ * 2. Fetch the attestation automatically
1424
+ * 3. Submit the destination mint transaction on behalf of the user
1425
+ * 4. Deduct the relay fee from the minted USDC
1426
+ *
1427
+ * The hookData must be formatted with the CCTP forwarding magic bytes prefix
1428
+ * followed by version and length fields. Use the `buildForwardingHookData`
1429
+ * utility to construct properly formatted hookData.
1430
+ *
1431
+ * @example
1432
+ * ```typescript
1433
+ * import { buildForwardingHookData } from '@core/utils'
1434
+ * import { hasCustomContractSupport } from '@core/chains'
1435
+ *
1436
+ * if (hasCustomContractSupport(sourceChain, 'bridge')) {
1437
+ * await adapter.action('cctp.v2.customBurnWithHook', {
1438
+ * amount: BigInt('1000000'),
1439
+ * mintRecipient: '0x...',
1440
+ * maxFee: BigInt('50000'),
1441
+ * minFinalityThreshold: 1000,
1442
+ * fromChain: ethereum,
1443
+ * toChain: base,
1444
+ * hookData: buildForwardingHookData()
1445
+ * })
1446
+ * }
1447
+ * ```
1448
+ */
1449
+ customBurnWithHook: CCTPv2ActionMap['customBurn'] & {
1450
+ /**
1451
+ * Hex-encoded hook data for CCTP forwarding.
1452
+ *
1453
+ * The hookData signals to Circle's Orbit relayer that forwarding is requested.
1454
+ * Must be formatted with the CCTP forwarding magic bytes prefix ("cctp-forward"
1455
+ * right-padded to 24 bytes) followed by uint32 version and uint32 length fields.
1456
+ *
1457
+ * Use the `buildForwardingHookData` utility to construct properly formatted hookData.
1458
+ */
1459
+ hookData: string;
1460
+ };
1461
+ /**
1462
+ * Initiate a cross-chain USDC transfer with hook data for CCTP forwarding.
1463
+ *
1464
+ * This action extends the standard `depositForBurn` with an additional `hookData`
1465
+ * parameter that signals to Circle's Orbit relayer that the user wants automated
1466
+ * attestation fetching and destination mint execution.
1467
+ *
1468
+ * @remarks
1469
+ * When CCTP forwarding is enabled, Circle's relay infrastructure will:
1470
+ * 1. Watch for the burn transaction with forwarding hookData
1471
+ * 2. Fetch the attestation automatically
1472
+ * 3. Submit the destination mint transaction on behalf of the user
1473
+ * 4. Deduct the relay fee from the minted USDC
1474
+ *
1475
+ * The hookData must be formatted with the CCTP forwarding magic bytes prefix
1476
+ * followed by version and length fields. Use the `buildForwardingHookData`
1477
+ * utility to construct properly formatted hookData.
1478
+ *
1479
+ * @example
1480
+ * ```typescript
1481
+ * import { buildForwardingHookData } from '@core/utils'
1482
+ *
1483
+ * await adapter.action('cctp.v2.depositForBurnWithHook', {
1484
+ * amount: BigInt('1000000'),
1485
+ * mintRecipient: '0x...',
1486
+ * maxFee: BigInt('50000'), // Must cover burn fee + forwarding fee
1487
+ * minFinalityThreshold: 1000,
1488
+ * fromChain: ethereum,
1489
+ * toChain: base,
1490
+ * hookData: buildForwardingHookData()
1491
+ * })
1492
+ * ```
1493
+ */
1494
+ depositForBurnWithHook: CCTPv2ActionMap['depositForBurn'] & {
1495
+ /**
1496
+ * Hex-encoded hook data for CCTP forwarding.
1497
+ *
1498
+ * The hookData signals to Circle's Orbit relayer that forwarding is requested.
1499
+ * Must be formatted with the CCTP forwarding magic bytes prefix ("cctp-forward"
1500
+ * right-padded to 24 bytes) followed by uint32 version and uint32 length fields.
1501
+ *
1502
+ * Use the `buildForwardingHookData` utility to construct properly formatted hookData.
1503
+ */
1504
+ hookData: string;
1505
+ };
1327
1506
  }
1328
1507
 
1329
1508
  /**
@@ -1350,31 +1529,443 @@ interface CCTPActionMap {
1350
1529
  }
1351
1530
 
1352
1531
  /**
1353
- * Action map for native token operations (ETH, SOL, MATIC, etc.).
1532
+ * Permit signature standards for gasless token approvals.
1354
1533
  *
1355
- * Native tokens are the primary currency of each blockchain network,
1356
- * used for paying transaction fees and as a store of value.
1357
- * These actions operate on the native token without requiring
1358
- * a separate token contract address.
1534
+ * Defines the permit types that can be used to approve token spending
1535
+ * without requiring a separate approval transaction.
1359
1536
  *
1360
1537
  * @remarks
1361
- * Native token operations differ from ERC-20/SPL token operations
1362
- * in that they don't require contract interactions for basic transfers
1363
- * and balance checks.
1538
+ * - NONE: No permit, tokens must be pre-approved via separate transaction
1539
+ * - EIP2612: Standard ERC-20 permit (USDC, DAI v2, and most modern tokens)
1540
+ */
1541
+ declare enum PermitType {
1542
+ /** No permit required - tokens must be pre-approved */
1543
+ NONE = 0,
1544
+ /** EIP-2612 standard permit */
1545
+ EIP2612 = 1
1546
+ }
1547
+ /**
1548
+ * Token input with permit signature for gasless approval.
1549
+ *
1550
+ * The Adapter Contract uses this to pull tokens from the user's wallet
1551
+ * using permit signatures instead of requiring separate approval transactions.
1364
1552
  *
1365
- * @see {@link ActionMap} for the complete action structure
1553
+ * @example
1554
+ * ```typescript
1555
+ * const tokenInput: TokenInput = {
1556
+ * permitType: PermitType.EIP2612,
1557
+ * token: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // USDC
1558
+ * from: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',
1559
+ * amount: 1000000n, // 1 USDC
1560
+ * permitCalldata: '0x...' // Encoded permit(value, deadline, v, r, s)
1561
+ * }
1562
+ * ```
1366
1563
  */
1367
- interface NativeActionMap {
1564
+ interface TokenInput {
1368
1565
  /**
1369
- * Get the native token balance (SOL, ETH, etc.) for a wallet address.
1566
+ * Type of permit to execute.
1370
1567
  */
1371
- balanceOf: ActionParameters & {
1372
- /**
1373
- * The address to check the native balance for. If not provided, it will be
1374
- * automatically derived from the adapter context.
1375
- */
1376
- walletAddress?: string | undefined;
1377
- };
1568
+ permitType: PermitType;
1569
+ /**
1570
+ * Token contract address to pull from user.
1571
+ */
1572
+ token: `0x${string}`;
1573
+ /**
1574
+ * Amount of tokens to pull via permit.
1575
+ */
1576
+ amount: bigint;
1577
+ /**
1578
+ * ABI-encoded permit calldata.
1579
+ *
1580
+ * For EIP-2612: encode(value, deadline, v, r, s)
1581
+ * For Permit2: encode(permit, signature)
1582
+ *
1583
+ * @example '0x0000000000000000000000000000000000000000000000000000000000989680...'
1584
+ */
1585
+ permitCalldata: `0x${string}`;
1586
+ }
1587
+ /**
1588
+ * Single instruction to execute within the Adapter Contract.
1589
+ *
1590
+ * Each instruction represents a contract call (swap, fee collection, etc.)
1591
+ * with pre-execution approval and post-execution validation.
1592
+ *
1593
+ * @example
1594
+ * ```typescript
1595
+ * const swapInstruction: Instruction = {
1596
+ * target: '0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE', // LiFi Diamond
1597
+ * data: '0x...', // LiFi swap calldata
1598
+ * value: 0n,
1599
+ * tokenIn: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // USDC
1600
+ * amountToApprove: 1000000000n, // 1000 USDC to approve
1601
+ * tokenOut: '0xdAC17F958D2ee523a2206206994597C13D831ec7', // USDT
1602
+ * minTokenOut: 995000000n // 995 USDT minimum (0.5% slippage)
1603
+ * }
1604
+ * ```
1605
+ */
1606
+ interface Instruction {
1607
+ /**
1608
+ * Target contract address to call.
1609
+ *
1610
+ * Can be a DEX router, fee taker contract, or token contract.
1611
+ */
1612
+ target: `0x${string}`;
1613
+ /**
1614
+ * ABI-encoded calldata for the target contract.
1615
+ */
1616
+ data: `0x${string}`;
1617
+ /**
1618
+ * ETH value to send with the call (for native token operations).
1619
+ *
1620
+ * @defaultValue 0n
1621
+ */
1622
+ value: bigint;
1623
+ /**
1624
+ * Token to approve to target before executing instruction.
1625
+ *
1626
+ * Set to zero address (0x00...00) to disable pre-approval.
1627
+ */
1628
+ tokenIn: `0x${string}`;
1629
+ /**
1630
+ * Amount of tokenIn to approve to target before executing instruction.
1631
+ *
1632
+ * @remarks
1633
+ * Field name matches the adapter contract's `amountToApprove` parameter exactly.
1634
+ *
1635
+ * @defaultValue 0n if tokenIn is zero address
1636
+ */
1637
+ amountToApprove: bigint;
1638
+ /**
1639
+ * Token to validate minimum balance after instruction.
1640
+ *
1641
+ * Set to zero address (0x00...00) to disable post-validation.
1642
+ */
1643
+ tokenOut: `0x${string}`;
1644
+ /**
1645
+ * Minimum required balance of tokenOut after instruction.
1646
+ *
1647
+ * @defaultValue 0n if tokenOut is zero address
1648
+ */
1649
+ minTokenOut: bigint;
1650
+ }
1651
+ /**
1652
+ * Token recipient for residual sweep.
1653
+ *
1654
+ * After all instructions complete, the Adapter Contract sweeps
1655
+ * any remaining balances to the specified beneficiaries.
1656
+ */
1657
+ interface TokenRecipient {
1658
+ /**
1659
+ * Token contract address to sweep.
1660
+ */
1661
+ token: `0x${string}`;
1662
+ /**
1663
+ * Address to receive swept tokens.
1664
+ */
1665
+ beneficiary: `0x${string}`;
1666
+ }
1667
+ /**
1668
+ * Execution parameters for the Adapter Contract.
1669
+ *
1670
+ * This struct is signed via EIP-712 by the Circle proxy and verified
1671
+ * on-chain to ensure the execution is authorized.
1672
+ *
1673
+ * @remarks
1674
+ * The executeParams are provided by the stablecoin-service and must be
1675
+ * passed to the Adapter Contract exactly as received (no modification).
1676
+ *
1677
+ * @example
1678
+ * ```typescript
1679
+ * const executeParams: ExecuteParams = {
1680
+ * instructions: [
1681
+ * { target: dexRouter, data: swapCalldata, ... }
1682
+ * ],
1683
+ * tokens: [
1684
+ * { token: USDC, beneficiary: userAddress },
1685
+ * { token: USDT, beneficiary: userAddress }
1686
+ * ],
1687
+ * execId: 123456789n,
1688
+ * deadline: BigInt(Math.floor(Date.now() / 1000) + 1800),
1689
+ * metadata: '0x'
1690
+ * }
1691
+ * ```
1692
+ */
1693
+ interface ExecuteParams {
1694
+ /**
1695
+ * Array of instructions to execute sequentially.
1696
+ *
1697
+ * Each instruction can be a swap, fee collection, or other contract call.
1698
+ */
1699
+ instructions: Instruction[];
1700
+ /**
1701
+ * Token recipients for residual sweep.
1702
+ *
1703
+ * Typically a 2-tuple: [tokenIn recipient, tokenOut recipient]
1704
+ */
1705
+ tokens: TokenRecipient[];
1706
+ /**
1707
+ * Unique execution identifier for replay protection.
1708
+ *
1709
+ * Must be globally unique and is marked as used after execution.
1710
+ */
1711
+ execId: bigint;
1712
+ /**
1713
+ * Execution deadline timestamp (Unix seconds).
1714
+ *
1715
+ * Transaction reverts if block.timestamp is greater than deadline.
1716
+ */
1717
+ deadline: bigint;
1718
+ /**
1719
+ * Optional metadata for tracking and analytics.
1720
+ */
1721
+ metadata: `0x${string}`;
1722
+ }
1723
+ /**
1724
+ * Parameters for executing a swap transaction via the Adapter smart contract.
1725
+ *
1726
+ * This action executes swap transactions through the Adapter Contract, which
1727
+ * handles token approvals via permits (EIP-2612, Permit2, etc.) and executes
1728
+ * multi-step swap instructions atomically on-chain.
1729
+ *
1730
+ * @remarks
1731
+ * The swap flow uses the Adapter Contract pattern:
1732
+ * 1. Service provides `executeParams` and `signature` (proxy-signed EIP-712)
1733
+ * 2. SDK builds `tokenInputs` with permit signatures for gasless approvals
1734
+ * 3. SDK calls AdapterContract.execute(executeParams, tokenInputs, signature)
1735
+ * 4. Adapter Contract pulls tokens via permits, executes swaps, validates outputs
1736
+ *
1737
+ * This enables:
1738
+ * - Single atomic transaction (permit + swap in one tx)
1739
+ * - Gasless approvals via EIP-2612/Permit2
1740
+ * - Slippage protection enforced on-chain
1741
+ * - Multi-step instructions (swap + fees) atomically
1742
+ *
1743
+ * **Permit Support**: The SDK constructs `TokenInput` with `permitCalldata`
1744
+ * containing the encoded permit signature. The Adapter Contract executes
1745
+ * the permit on-chain before pulling tokens.
1746
+ *
1747
+ * @example
1748
+ * ```typescript
1749
+ * import type { ExecuteSwapParams } from '@core/adapter'
1750
+ * import { createSwap } from '@core/service-client'
1751
+ * import { PermitType } from '@core/adapter'
1752
+ *
1753
+ * // Get swap transaction from service
1754
+ * const swapResponse = await createSwap({
1755
+ * tokenInAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
1756
+ * tokenOutAddress: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
1757
+ * tokenInChain: 'Ethereum',
1758
+ * fromAddress: '0x...',
1759
+ * toAddress: '0x...',
1760
+ * amount: '1000000',
1761
+ * apiKey: 'KIT_KEY:...',
1762
+ * })
1763
+ *
1764
+ * // Build token inputs with permit
1765
+ * const tokenInputs: TokenInput[] = [{
1766
+ * permitType: PermitType.EIP2612,
1767
+ * token: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
1768
+ * from: userAddress,
1769
+ * amount: 1000000n,
1770
+ * permitCalldata: '0x...' // Encoded permit signature
1771
+ * }]
1772
+ *
1773
+ * // Prepare action parameters
1774
+ * const params: ExecuteSwapParams = {
1775
+ * executeParams: swapResponse.transaction.executeParams,
1776
+ * tokenInputs,
1777
+ * signature: swapResponse.transaction.signature,
1778
+ * inputAmount: BigInt(swapResponse.amount),
1779
+ * tokenInAddress: swapResponse.tokenInAddress as `0x${string}`
1780
+ * }
1781
+ * ```
1782
+ */
1783
+ interface ExecuteSwapEVMParams extends ActionParameters {
1784
+ /**
1785
+ * Execution parameters from the stablecoin-service.
1786
+ *
1787
+ * Contains instructions, token recipients, execution ID, deadline, and metadata.
1788
+ * This is an EIP-712 signed struct that the Adapter Contract validates.
1789
+ *
1790
+ * Provided by the service - do not modify.
1791
+ */
1792
+ executeParams: ExecuteParams;
1793
+ /**
1794
+ * Token inputs with permit signatures for gasless approvals.
1795
+ *
1796
+ * The SDK constructs this array with permit data for each token that needs
1797
+ * to be pulled from the user's wallet. The Adapter Contract executes these
1798
+ * permits on-chain before executing swap instructions.
1799
+ *
1800
+ * @remarks
1801
+ * For EIP-2612 permits, the SDK must:
1802
+ * 1. Build typed data with token, spender (Adapter), amount, nonce, deadline
1803
+ * 2. Get user signature via `adapter.signTypedData()`
1804
+ * 3. Encode as permitCalldata: encode(value, deadline, v, r, s)
1805
+ *
1806
+ * @example
1807
+ * ```typescript
1808
+ * [{
1809
+ * permitType: PermitType.EIP2612,
1810
+ * token: '0xUSDC',
1811
+ * from: userAddress,
1812
+ * amount: 1000000n,
1813
+ * permitCalldata: '0x...'
1814
+ * }]
1815
+ * ```
1816
+ */
1817
+ tokenInputs: TokenInput[];
1818
+ /**
1819
+ * EIP-712 signature from the Circle proxy service.
1820
+ *
1821
+ * The service signs the executeParams to authorize the execution.
1822
+ * The Adapter Contract verifies this signature on-chain.
1823
+ *
1824
+ * Provided by the service - do not modify.
1825
+ */
1826
+ signature: `0x${string}`;
1827
+ /**
1828
+ * Swap input amount in base units.
1829
+ *
1830
+ * @remarks
1831
+ * The amount of tokens being swapped, provided in the token's base units (e.g., wei for ETH,
1832
+ * smallest denomination for ERC20 tokens). This value should be extracted from the service
1833
+ * response, as it represents the authoritative swap amount for the operation.
1834
+ *
1835
+ * For native currency swaps (ETH → USDC), this amount is sent as the transaction `value`.
1836
+ * For ERC20 swaps (USDC → USDT), this amount determines the permit or approval quantity.
1837
+ *
1838
+ * @see CreateSwapResponse.amount - Service response field containing this value
1839
+ *
1840
+ * @example
1841
+ * ```typescript
1842
+ * import { createSwap } from '@core/service-client'
1843
+ *
1844
+ * // Get swap transaction from service
1845
+ * const response = await createSwap({
1846
+ * tokenInAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
1847
+ * amount: '1000000', // 1 USDC (6 decimals)
1848
+ * ...
1849
+ * })
1850
+ *
1851
+ * // Prepare swap execution using service response amount
1852
+ * await adapter.prepareAction('swap.execute', {
1853
+ * executeParams: response.transaction.executeParams,
1854
+ * tokenInputs,
1855
+ * signature: response.transaction.signature,
1856
+ * inputAmount: BigInt(response.amount),
1857
+ * tokenInAddress: response.tokenInAddress,
1858
+ * }, context)
1859
+ * ```
1860
+ */
1861
+ inputAmount: bigint;
1862
+ /**
1863
+ * Token address being swapped from.
1864
+ *
1865
+ * @remarks
1866
+ * Used to determine if the swap involves native currency (ETH, MATIC, etc.) or ERC20 tokens.
1867
+ * When tokenInAddress is NATIVE_TOKEN_ADDRESS (0xEeee...), the inputAmount is sent as tx.value.
1868
+ *
1869
+ * @see CreateSwapResponse.tokenInAddress - Service response field containing this value
1870
+ *
1871
+ * @example '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE' for ETH
1872
+ * @example '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48' for USDC
1873
+ */
1874
+ tokenInAddress: `0x${string}`;
1875
+ }
1876
+ /**
1877
+ * Parameters for executing a swap transaction on Solana.
1878
+ *
1879
+ * This action executes swap transactions on Solana chains by deserializing
1880
+ * and executing a pre-built transaction provided by the stablecoin-service.
1881
+ *
1882
+ * @remarks
1883
+ * Unlike EVM chains that use the Adapter Contract pattern, Solana swaps
1884
+ * execute a fully serialized transaction provided by the service. The
1885
+ * transaction is base64-encoded and contains all necessary instructions
1886
+ * for the swap operation.
1887
+ *
1888
+ * The service handles:
1889
+ * - DEX aggregator routing (Jupiter, etc.)
1890
+ * - Fee collection
1891
+ * - Slippage protection
1892
+ * - Token account management
1893
+ *
1894
+ * @example
1895
+ * ```typescript
1896
+ * import type { ExecuteSwapSolanaParams } from '@core/adapter'
1897
+ * import { createSwap } from '@core/service-client'
1898
+ *
1899
+ * // Get swap transaction from service
1900
+ * const swapResponse = await createSwap({
1901
+ * tokenInAddress: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
1902
+ * tokenOutAddress: 'HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr',
1903
+ * tokenInChain: 'Solana',
1904
+ * fromAddress: 'YubQzu18FDqJRyNfG8JqHmsdbxhnoQqcKUHBdUkN6tP',
1905
+ * toAddress: 'YubQzu18FDqJRyNfG8JqHmsdbxhnoQqcKUHBdUkN6tP',
1906
+ * amount: '1000000',
1907
+ * apiKey: 'KIT_KEY:...',
1908
+ * })
1909
+ *
1910
+ * // Prepare action parameters
1911
+ * const params: ExecuteSwapSolanaParams = {
1912
+ * serializedTransaction: swapResponse.transaction.data
1913
+ * }
1914
+ * ```
1915
+ */
1916
+ interface ExecuteSwapSolanaParams extends ActionParameters {
1917
+ /**
1918
+ * Base64-encoded serialized Solana transaction.
1919
+ *
1920
+ * This transaction is fully constructed by the stablecoin-service and
1921
+ * contains all swap instructions, fee payments, and token account setup.
1922
+ * The transaction must be deserialized, signed, and submitted to the network.
1923
+ *
1924
+ * Provided by the service - do not modify.
1925
+ *
1926
+ * @example 'AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAQAJFQg...'
1927
+ */
1928
+ serializedTransaction: string;
1929
+ }
1930
+ /**
1931
+ * Parameters accepted by the swap.execute action, supporting both EVM and Solana chains.
1932
+ *
1933
+ * @remarks
1934
+ * This union type covers all chain-specific swap execution parameter interfaces
1935
+ * currently supported by the App Kit. Extend this union to support
1936
+ * additional blockchains as needed. Each member provides all fields required
1937
+ * to prepare and execute a pre-built swap transaction on its respective chain.
1938
+ *
1939
+ * **Type Narrowing**: The correct parameter type is inferred from the chain type
1940
+ * in the `OperationContext` passed to `adapter.prepareAction()`. Action handlers
1941
+ * use property-based type guards (checking for `executeParams`/`tokenInputs` for EVM
1942
+ * or `serializedTransaction` for Solana) to narrow the union type at runtime.
1943
+ *
1944
+ * - {@link ExecuteSwapEVMParams} - For EVM chains (has `executeParams` and `tokenInputs`)
1945
+ * - {@link ExecuteSwapSolanaParams} - For Solana chains (has `serializedTransaction`)
1946
+ */
1947
+ type ExecuteSwapParams = ExecuteSwapEVMParams | ExecuteSwapSolanaParams;
1948
+ /**
1949
+ * Action map for swap operations on EVM chains.
1950
+ *
1951
+ * This namespace contains actions related to token swapping operations.
1952
+ * These actions handle the execution of pre-built swap transactions from
1953
+ * DEX aggregators and routing services.
1954
+ *
1955
+ * @remarks
1956
+ * The swap namespace is designed to be extensible for future swap-related
1957
+ * operations such as multi-hop swaps, batched swaps, or swap-and-bridge
1958
+ * compositions.
1959
+ */
1960
+ interface SwapActionMap {
1961
+ /**
1962
+ * Execute a pre-built swap transaction.
1963
+ *
1964
+ * This action prepares and executes swap transactions constructed by the
1965
+ * stablecoin-service API. It accepts transaction parameters (to, data, value)
1966
+ * and returns a prepared chain request suitable for gas estimation or execution.
1967
+ */
1968
+ readonly execute: ExecuteSwapParams;
1378
1969
  }
1379
1970
 
1380
1971
  interface TokenActionMap {
@@ -1589,6 +2180,81 @@ interface USDCActionMap {
1589
2180
  balanceOf: Omit<BaseUSDCActions['balanceOf'], 'tokenAddress'>;
1590
2181
  }
1591
2182
 
2183
+ /**
2184
+ * USDT-specific operations that automatically resolve the token address.
2185
+ *
2186
+ * These include standard ERC20 operations. The interface provides the same core
2187
+ * operations as {@link TokenActionMap} but without requiring a `tokenAddress`
2188
+ * parameter.
2189
+ *
2190
+ * @example
2191
+ * ```typescript
2192
+ * // USDT operations (address auto-resolved)
2193
+ * await adapter.action('usdt.transfer', {
2194
+ * to: '0x1234...',
2195
+ * amount: '1000000' // 1 USDT
2196
+ * })
2197
+ *
2198
+ * // vs. general token operations (address required)
2199
+ * await adapter.action('token.transfer', {
2200
+ * tokenAddress: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
2201
+ * to: '0x1234...',
2202
+ * amount: '1000000'
2203
+ * })
2204
+ * ```
2205
+ */
2206
+ type BaseUSDTActions = {
2207
+ [K in keyof TokenActionMap]: Omit<TokenActionMap[K], 'tokenAddress'>;
2208
+ };
2209
+ /**
2210
+ * USDT action map with standard ERC20 operations.
2211
+ *
2212
+ * This provides standard token operations for USDT transfers.
2213
+ */
2214
+ interface USDTActionMap {
2215
+ /**
2216
+ * Transfer USDT tokens directly from the wallet to another address.
2217
+ *
2218
+ * Automatically uses the USDT contract address for the current chain.
2219
+ */
2220
+ transfer: BaseUSDTActions['transfer'];
2221
+ }
2222
+
2223
+ /**
2224
+ * Native token-related action maps for the bridge kit.
2225
+ *
2226
+ * This module provides action definitions for native token operations.
2227
+ */
2228
+ interface NativeActionMap {
2229
+ /**
2230
+ * Transfer native tokens directly from the wallet to another address.
2231
+ */
2232
+ transfer: ActionParameters & {
2233
+ /**
2234
+ * The chain to transfer the native tokens on.
2235
+ */
2236
+ chain?: ChainIdentifier;
2237
+ /**
2238
+ * The address to send the native tokens to.
2239
+ */
2240
+ to: string;
2241
+ /**
2242
+ * The amount of native tokens to transfer.
2243
+ */
2244
+ amount: bigint;
2245
+ };
2246
+ /**
2247
+ * Get the native token balance (SOL, ETH, etc.) for a wallet address.
2248
+ */
2249
+ balanceOf: ActionParameters & {
2250
+ /**
2251
+ * The address to check the native balance for. If not provided, it will be
2252
+ * automatically derived from the adapter context.
2253
+ */
2254
+ walletAddress?: string | undefined;
2255
+ };
2256
+ }
2257
+
1592
2258
  /**
1593
2259
  * Central registry of all available action namespaces and their operations.
1594
2260
  *
@@ -1608,12 +2274,16 @@ interface USDCActionMap {
1608
2274
  interface ActionMap {
1609
2275
  /** CCTP-specific operations with automatic address resolution. */
1610
2276
  readonly cctp: CCTPActionMap;
1611
- /** Native token operations (ETH, SOL, MATIC, etc.). */
1612
- readonly native: NativeActionMap;
1613
2277
  /** General token operations requiring explicit token addresses. */
1614
2278
  readonly token: TokenActionMap;
1615
2279
  /** USDC-specific operations with automatic address resolution. */
1616
2280
  readonly usdc: USDCActionMap;
2281
+ /** USDT-specific operations with automatic address resolution. */
2282
+ readonly usdt: USDTActionMap;
2283
+ /** Native token operations. */
2284
+ readonly native: NativeActionMap;
2285
+ /** Swap operations for DEX aggregator integrations. */
2286
+ readonly swap: SwapActionMap;
1617
2287
  }
1618
2288
  /**
1619
2289
  * Determine if a type represents an action parameter object (leaf node).
@@ -1752,7 +2422,7 @@ type ActionHandler<TActionKey extends ActionKeys> = (params: ActionPayload<TActi
1752
2422
  * This type defines a registry object where each key is a valid action key
1753
2423
  * (as defined by {@link ActionKeys}) and each value is an {@link ActionHandler}
1754
2424
  * capable of processing the payload for that action. This enables strongly-typed
1755
- * handler registration and lookup for all supported actions in the Stablecoin Kits.
2425
+ * handler registration and lookup for all supported actions in the App Kits.
1756
2426
  *
1757
2427
  * @remarks
1758
2428
  * Each handler is typed as {@link ActionHandler}, which means the handler
@@ -2014,11 +2684,11 @@ interface AdapterCapabilities {
2014
2684
  /**
2015
2685
  * Abstract class defining the standard interface for an adapter that interacts with a specific blockchain.
2016
2686
  *
2017
- * A `Adapter` is responsible for encapsulating chain-specific logic necessary to
2687
+ * An `Adapter` is responsible for encapsulating chain-specific logic necessary to
2018
2688
  * perform operations like sending transactions, querying balances, or interacting with smart contracts.
2019
2689
  * Implementations of this class will provide concrete logic for a particular blockchain protocol.
2020
2690
  *
2021
- * This abstraction allows the Stablecoin Kits to work with multiple blockchains in a uniform way.
2691
+ * This abstraction allows the App Kit to work with multiple blockchains in a uniform way.
2022
2692
  *
2023
2693
  * @typeParam TAdapterCapabilities - The adapter capabilities type for compile-time address validation.
2024
2694
  * When provided, enables strict typing of operation context based on the adapter's address control model.
@@ -2279,6 +2949,134 @@ declare abstract class Adapter<TAdapterCapabilities extends AdapterCapabilities
2279
2949
  * @returns A promise that resolves to the total transaction fee as a bigint.
2280
2950
  */
2281
2951
  abstract calculateTransactionFee(baseComputeUnits: bigint, bufferBasisPoints: bigint | undefined, chain: ChainDefinition): Promise<EstimatedGas>;
2952
+ /**
2953
+ * Get the decimal places for a token address on a given chain.
2954
+ *
2955
+ * This method fetches the number of decimal places from a token contract.
2956
+ * Different chain types implement this differently:
2957
+ * - EVM: Calls the `decimals()` function on ERC-20 contracts
2958
+ * - Solana: Reads the `decimals` field from the SPL token mint account
2959
+ *
2960
+ * @param tokenAddress - The token contract address (EVM) or mint address (Solana)
2961
+ * @param chain - The chain definition where the token is deployed
2962
+ * @returns Promise resolving to the number of decimal places for the token
2963
+ * @throws Error when the token contract doesn't exist or decimals cannot be fetched
2964
+ *
2965
+ * @example
2966
+ * ```typescript
2967
+ * import { EthersAdapter } from '@circle-fin/adapter-ethers-v6'
2968
+ * import { Ethereum } from '@core/chains'
2969
+ *
2970
+ * const adapter = new EthersAdapter({ signer })
2971
+ *
2972
+ * // Fetch decimals for DAI token
2973
+ * const decimals = await adapter.getTokenDecimals(
2974
+ * '0x6B175474E89094C44Da98b954EedeAC495271d0F',
2975
+ * Ethereum
2976
+ * )
2977
+ * console.log(decimals) // 18
2978
+ * ```
2979
+ */
2980
+ abstract getTokenDecimals(tokenAddress: string, chain: ChainDefinition): Promise<number>;
2981
+ }
2982
+
2983
+ /**
2984
+ * Module augmentation to register known token symbols.
2985
+ *
2986
+ * @remarks
2987
+ * This file augments the `TokenSymbolRegistry` interface to provide
2988
+ * type-safe autocomplete for built-in tokens.
2989
+ *
2990
+ * When imported, TypeScript will recognize 'USDC' as a valid
2991
+ * `TokenSymbol` value with autocomplete support.
2992
+ *
2993
+ * Other packages or applications can create their own augmentations
2994
+ * to add additional tokens.
2995
+ *
2996
+ * @example
2997
+ * ```typescript
2998
+ * import '@core/tokens' // Automatically includes this augmentation
2999
+ *
3000
+ * const symbol: TokenSymbol = 'USDC' // ✓ Autocomplete shows USDC
3001
+ * ```
3002
+ */
3003
+ declare module './types' {
3004
+ /**
3005
+ * Module augmentation: Adds known token symbols as valid keys
3006
+ * to the TokenSymbolRegistry interface.
3007
+ *
3008
+ * Keys are explicitly listed to ensure IDE autocomplete works properly.
3009
+ */
3010
+ interface TokenSymbolRegistry {
3011
+ USDC: true;
3012
+ USDT: true;
3013
+ EURC: true;
3014
+ DAI: true;
3015
+ USDE: true;
3016
+ PYUSD: true;
3017
+ WETH: true;
3018
+ WBTC: true;
3019
+ WSOL: true;
3020
+ WAVAX: true;
3021
+ WPOL: true;
3022
+ ETH: true;
3023
+ POL: true;
3024
+ PLUME: true;
3025
+ MON: true;
3026
+ }
3027
+ }
3028
+
3029
+ /**
3030
+ * Module augmentation to register Blockchain enum values as ChainIdentifiers.
3031
+ *
3032
+ * @remarks
3033
+ * This file augments the `ChainRegistry` interface to provide type-safe
3034
+ * autocomplete for all `Blockchain` enum values from `@core/chains`.
3035
+ *
3036
+ * When this augmentation is imported (via `@core/tokens`), TypeScript will
3037
+ * recognize all blockchain identifiers as valid `ChainIdentifier` values
3038
+ * with IDE autocomplete support.
3039
+ *
3040
+ * The `Blockchain` enum values are converted to their string representations,
3041
+ * enabling both enum values and string literals to be accepted as chain identifiers.
3042
+ *
3043
+ * @example
3044
+ * ```typescript
3045
+ * import { Blockchain } from '@core/chains'
3046
+ * import type { ChainIdentifier } from '@core/tokens'
3047
+ *
3048
+ * // Using enum value
3049
+ * const chain1: ChainIdentifier = Blockchain.Ethereum
3050
+ *
3051
+ * // Using string literal (with autocomplete!)
3052
+ * const chain2: ChainIdentifier = 'Base'
3053
+ *
3054
+ * // Arbitrary strings also work (escape hatch for custom chains)
3055
+ * const chain3: ChainIdentifier = 'my-custom-chain'
3056
+ * ```
3057
+ */
3058
+
3059
+ declare module './types' {
3060
+ /**
3061
+ * Module augmentation: Adds all Blockchain enum values as valid keys
3062
+ * to the ChainRegistry interface for type-safe chain identifier support.
3063
+ *
3064
+ * This ensures both enum property access (e.g., Blockchain.Ethereum) and plain
3065
+ * string literals (e.g., 'Ethereum') are accepted by TypeScript as chain keys,
3066
+ * providing robust autocomplete and error checking.
3067
+ *
3068
+ * NOTE:
3069
+ * - This interface intentionally has no body. It merges a mapped Record type
3070
+ * into ChainRegistry solely for type augmentation.
3071
+ * - This empty-body construct is a necessary TypeScript idiom for module
3072
+ * augmentation with Record types—directly listing mapped keys is not
3073
+ * feasible in interface extensions.
3074
+ *
3075
+ * eslint-disable-next-line directives below suppress linter complaints about
3076
+ * the empty interface/mapping, which are benign and required for this pattern.
3077
+ */
3078
+ interface ChainRegistry extends Record<`${Blockchain}`, true> {
3079
+ }
2282
3080
  }
2283
3081
 
2284
3082
  /**
@@ -2725,18 +3523,65 @@ interface EIP2612Options extends Record<string, unknown> {
2725
3523
  /** Optional deadline - will default to 1 hour from now if not provided */
2726
3524
  deadline?: bigint;
2727
3525
  }
3526
+ /**
3527
+ * Minimal adapter interface for EIP-2612 nonce fetching.
3528
+ *
3529
+ * @remarks
3530
+ * This interface represents the minimal contract an adapter must fulfill to
3531
+ * work with `buildEIP2612TypedData`. It's intentionally minimal - only requiring
3532
+ * nonce fetching capability. Signing is handled separately via the adapter's
3533
+ * `signTypedData` method.
3534
+ *
3535
+ * This enables separation of concerns: nonce fetching (read operation) is
3536
+ * independent from signing (write operation).
3537
+ *
3538
+ * @example
3539
+ * ```typescript
3540
+ * import type { EIP2612Adapter } from '@core/adapter-evm'
3541
+ *
3542
+ * // An adapter that implements the minimal interface
3543
+ * class MyAdapter implements EIP2612Adapter {
3544
+ * async fetchEIP2612Nonce(
3545
+ * tokenAddress: `0x${string}`,
3546
+ * ownerAddress: `0x${string}`,
3547
+ * ctx: OperationContext
3548
+ * ): Promise<bigint> {
3549
+ * // Query token contract for nonce
3550
+ * return await this.readContract({
3551
+ * address: tokenAddress,
3552
+ * abi: [{ name: 'nonces', type: 'function', inputs: [...], outputs: [...] }],
3553
+ * functionName: 'nonces',
3554
+ * args: [ownerAddress]
3555
+ * })
3556
+ * }
3557
+ * }
3558
+ * ```
3559
+ */
3560
+ interface EIP2612Adapter {
3561
+ /**
3562
+ * Fetch the current nonce for EIP-2612 permit signatures.
3563
+ *
3564
+ * Queries the token contract's `nonces(address owner)` function to get
3565
+ * the current nonce value for permit signatures.
3566
+ *
3567
+ * @param tokenAddress - The token contract address
3568
+ * @param ownerAddress - The token owner's address
3569
+ * @param ctx - Operation context containing chain and address information
3570
+ * @returns Promise resolving to the current nonce
3571
+ * @throws Error when the contract call fails or token doesn't support EIP-2612
3572
+ */
3573
+ fetchEIP2612Nonce(tokenAddress: `0x${string}`, ownerAddress: `0x${string}`, ctx: OperationContext): Promise<bigint>;
3574
+ }
2728
3575
  /**
2729
3576
  * Function type for fetching nonces from EIP-2612 compatible tokens.
2730
3577
  *
2731
- * @param owner - Token owner address
3578
+ * This type will be deprecated, use {@link EIP2612Adapter} interface instead for better type safety
2732
3579
  * @param token - Token contract address
3580
+ * @param owner - Token owner address
2733
3581
  * @returns Promise resolving to current nonce
2734
3582
  */
2735
3583
  type EIP2612NonceFetcher = (token: `0x${string}`, owner: `0x${string}`) => Promise<bigint>;
2736
3584
 
2737
- interface EIP2612Adapter {
2738
- fetchEIP2612Nonce(tokenAddress: `0x${string}`, ownerAddress: `0x${string}`, ctx: OperationContext): Promise<bigint>;
2739
- }
2740
3585
  /**
2741
3586
  * Build EIP-2612 typed data for permit signing.
2742
3587
  *
@@ -2994,6 +3839,22 @@ declare class EthersAdapter<TAdapterCapabilities extends AdapterCapabilities = A
2994
3839
  * @throws When transaction execution fails after retry attempts.
2995
3840
  */
2996
3841
  private executeTransaction;
3842
+ /**
3843
+ * Common transaction sending logic with nonce management and retry logic.
3844
+ *
3845
+ * This method handles the complete transaction lifecycle:
3846
+ * - Nonce allocation and management via {@link ethersNonceManager}
3847
+ * - Automatic retry on nonce-related errors (up to 3 attempts)
3848
+ * - Graceful handling of user-provided nonces (no retry)
3849
+ * - Proper error handling and wrapping
3850
+ *
3851
+ * @param txRequest - Populated transaction request
3852
+ * @param fromAddress - The address sending the transaction
3853
+ * @param chain - The chain definition for context
3854
+ * @param overrides - Optional transaction overrides
3855
+ * @returns Transaction hash
3856
+ */
3857
+ private sendTransactionWithNonceManagement;
2997
3858
  /**
2998
3859
  * Prepares a contract function call for gas estimation and execution with OperationContext.
2999
3860
  *
@@ -3296,6 +4157,35 @@ declare class EthersAdapter<TAdapterCapabilities extends AdapterCapabilities = A
3296
4157
  * @returns A prepared chain request for read-only function execution.
3297
4158
  */
3298
4159
  private handleReadOnlyFunction;
4160
+ /**
4161
+ * Prepares a native token transfer (ETH, MATIC, etc.) for gas estimation and execution.
4162
+ *
4163
+ * Native transfers are simple value transfers that don't require contract ABI or function calls.
4164
+ * This method reuses the existing transaction execution flow but skips contract-specific logic.
4165
+ *
4166
+ * @param address - The recipient address for the native token transfer
4167
+ * @param value - The amount of native tokens to send (in wei)
4168
+ * @param targetChain - The target chain definition
4169
+ * @param resolvedAddress - The resolved sender address from operation context
4170
+ * @returns Prepared chain request for native transfer
4171
+ * @throws Error when gas estimation fails without fallback
4172
+ * @throws Error when gas price retrieval fails
4173
+ * @throws Error when transaction execution fails
4174
+ *
4175
+ * @example
4176
+ * ```typescript
4177
+ * // Internal usage - called by prepare() when native transfer is detected
4178
+ * const prepared = this.prepareNativeTransfer(
4179
+ * '0x1234567890123456789012345678901234567890',
4180
+ * BigInt(1000000000000000000), // 1 ETH
4181
+ * Ethereum,
4182
+ * '0xsenderAddress'
4183
+ * );
4184
+ * const estimate = await prepared.estimate();
4185
+ * const txHash = await prepared.execute();
4186
+ * ```
4187
+ */
4188
+ private prepareNativeTransfer;
3299
4189
  /**
3300
4190
  * Reads a contract function using Ethers v6.
3301
4191
  *
@@ -3305,6 +4195,39 @@ declare class EthersAdapter<TAdapterCapabilities extends AdapterCapabilities = A
3305
4195
  * @throws Error when contract read fails.
3306
4196
  */
3307
4197
  readContract<TReturnType = unknown>(params: ReadContractParams, chain: EVMChainDefinition): Promise<TReturnType>;
4198
+ /**
4199
+ * Get the decimal places for an ERC-20 token on an EVM chain.
4200
+ *
4201
+ * This method calls the `decimals()` function on the ERC-20 token contract
4202
+ * to fetch the number of decimal places. Ethers v6 returns decimals as bigint,
4203
+ * which is validated and converted to a number.
4204
+ *
4205
+ * @param tokenAddress - The ERC-20 token contract address
4206
+ * @param chain - The EVM chain definition where the token is deployed
4207
+ * @returns Promise resolving to the number of decimal places
4208
+ * @throws Error when the contract doesn't exist, doesn't support decimals(), or returns invalid data
4209
+ *
4210
+ * @remarks
4211
+ * - Ethers v6 returns decimals as bigint
4212
+ * - Validates that decimals are within 0-255 range (ERC-20 uint8 standard)
4213
+ * - Converts bigint to number for consistent API
4214
+ *
4215
+ * @example
4216
+ * ```typescript
4217
+ * import { EthersAdapter } from '@circle-fin/adapter-ethers-v6'
4218
+ * import { Ethereum } from '@core/chains'
4219
+ *
4220
+ * const adapter = new EthersAdapter({ signer })
4221
+ *
4222
+ * // Fetch decimals for DAI token
4223
+ * const decimals = await adapter.getTokenDecimals(
4224
+ * '0x6B175474E89094C44Da98b954EedeAC495271d0F',
4225
+ * Ethereum
4226
+ * )
4227
+ * console.log(decimals) // 18
4228
+ * ```
4229
+ */
4230
+ getTokenDecimals(tokenAddress: string, chain: EVMChainDefinition): Promise<number>;
3308
4231
  }
3309
4232
 
3310
4233
  /**