@hyperbridge/sdk 1.3.21 → 1.3.25

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.
@@ -1564,6 +1564,23 @@ interface TokenRegistryResponse {
1564
1564
  }>;
1565
1565
  };
1566
1566
  }
1567
+ /**
1568
+ * Represents a complete transaction structure for swap operations
1569
+ */
1570
+ interface Transaction {
1571
+ /**
1572
+ * The address to send the transaction to (typically the Universal Router address)
1573
+ */
1574
+ to: HexString;
1575
+ /**
1576
+ * The value to send with the transaction (in wei)
1577
+ */
1578
+ value: bigint;
1579
+ /**
1580
+ * The calldata for the transaction
1581
+ */
1582
+ data: HexString;
1583
+ }
1567
1584
 
1568
1585
  declare class ChainConfigService {
1569
1586
  private rpcUrls;
@@ -1584,14 +1601,12 @@ declare class ChainConfigService {
1584
1601
  getRpcUrl(chain: string): string;
1585
1602
  getUniswapRouterV2Address(chain: string): HexString;
1586
1603
  getUniswapV2FactoryAddress(chain: string): HexString;
1587
- getBatchExecutorAddress(chain: string): HexString;
1588
1604
  getUniversalRouterAddress(chain: string): HexString;
1589
- getUniswapV3RouterAddress(chain: string): HexString;
1590
- getUniswapV3FactoryAddress(chain: string): HexString;
1591
1605
  getUniswapV3QuoterAddress(chain: string): HexString;
1592
- getUniswapV4PoolManagerAddress(chain: string): HexString;
1593
1606
  getUniswapV4QuoterAddress(chain: string): HexString;
1607
+ getPermit2Address(chain: string): HexString;
1594
1608
  getCoingeckoId(chain: string): string | undefined;
1609
+ getEtherscanApiKey(): string | undefined;
1595
1610
  }
1596
1611
 
1597
1612
  /**
@@ -1840,6 +1855,16 @@ declare function orderCommitment(order: Order): HexString;
1840
1855
  declare function bytes32ToBytes20(bytes32Address: string): HexString;
1841
1856
  declare function bytes20ToBytes32(bytes20Address: string): HexString;
1842
1857
  declare function hexToString(hex: string): string;
1858
+ /**
1859
+ * Retries a promise-returning operation with exponential backoff.
1860
+ * This function will attempt to execute the operation up to maxRetries times,
1861
+ * with an exponential backoff delay between attempts.
1862
+ *
1863
+ * @param operation The async operation to retry
1864
+ * @param retryConfig Configuration object containing retry parameters
1865
+ * @returns Promise that resolves with the operation result or rejects with the last error
1866
+ */
1867
+ declare function retryPromise<T>(operation: () => Promise<T>, retryConfig: RetryConfig): Promise<T>;
1843
1868
  /**
1844
1869
  * Calculates the commitment hash for a get request.
1845
1870
  * @param get The get request to calculate the commitment hash for.
@@ -1867,6 +1892,11 @@ declare function estimateGasForPost(params: {
1867
1892
  */
1868
1893
  declare function constructRedeemEscrowRequestBody(order: Order, beneficiary: HexString): HexString;
1869
1894
  declare function fetchPrice(identifier: string, chainId?: number, apiKey?: string): Promise<number>;
1895
+ /**
1896
+ * Fetches the current network gas price from an Etherscan-family explorer API.
1897
+ * Returns the ProposeGasPrice (in gwei) converted to wei as bigint.
1898
+ */
1899
+ declare function getGasPriceFromEtherscan(chainId: string, apiKey?: string): Promise<bigint>;
1870
1900
  /**
1871
1901
  * ERC20 method signatures used for storage slot detection
1872
1902
  */
@@ -1924,6 +1954,14 @@ declare function getStorageSlot(client: PublicClient, contractAddress: HexString
1924
1954
  * @returns The adjusted fee amount with the target decimal precision
1925
1955
  */
1926
1956
  declare function adjustFeeDecimals(feeInFeeToken: bigint, fromDecimals: number, toDecimals: number): bigint;
1957
+ /**
1958
+ * Chains that should prefer the Etherscan API for gas price lookup
1959
+ */
1960
+ declare const USE_ETHERSCAN_CHAINS: Set<string>;
1961
+ /**
1962
+ * Testnet chains
1963
+ */
1964
+ declare const TESTNET_CHAINS: Set<string>;
1927
1965
 
1928
1966
  interface SubstrateChainParams {
1929
1967
  ws: string;
@@ -2286,6 +2324,16 @@ declare class IndexerClient {
2286
2324
  commitmentTimestamp: bigint;
2287
2325
  chain: string;
2288
2326
  }): Promise<StateMachineUpdate | undefined>;
2327
+ /**
2328
+ * Query for the latest state machine update height
2329
+ * @params statemachineId - ID of the state machine
2330
+ * @params chain - The identifier for the chain where the state machine update should be queried (corresponds to a stateMachineId)
2331
+ * @returns Latest height or undefined if no updates found
2332
+ */
2333
+ queryLatestStateMachineHeight({ statemachineId, chain, }: {
2334
+ statemachineId: string;
2335
+ chain: string;
2336
+ }): Promise<bigint | undefined>;
2289
2337
  /**
2290
2338
  * Queries a request by CommitmentHash
2291
2339
  *
@@ -2648,6 +2696,66 @@ declare class IntentGateway {
2648
2696
  * @returns The native token amount required
2649
2697
  */
2650
2698
  quoteNative(postRequest: IPostRequest, fee: bigint): Promise<bigint>;
2699
+ /**
2700
+ * Gets V2 quote for exact output swap.
2701
+ */
2702
+ getV2QuoteWithAmountOut(getQuoteIn: "source" | "dest", tokenIn: HexString, tokenOut: HexString, amountOut: bigint, evmChainID: string): Promise<bigint>;
2703
+ /**
2704
+ * Gets V2 quote for exact input swap.
2705
+ */
2706
+ getV2QuoteWithAmountIn(getQuoteIn: "source" | "dest", tokenIn: HexString, tokenOut: HexString, amountIn: bigint, evmChainID: string): Promise<bigint>;
2707
+ /**
2708
+ * Gets V3 quote for exact output swap.
2709
+ */
2710
+ getV3QuoteWithAmountOut(getQuoteIn: "source" | "dest", tokenIn: HexString, tokenOut: HexString, amountOut: bigint, evmChainID: string): Promise<{
2711
+ amountIn: bigint;
2712
+ fee: number;
2713
+ }>;
2714
+ /**
2715
+ * Gets V3 quote for exact input swap.
2716
+ */
2717
+ getV3QuoteWithAmountIn(getQuoteIn: "source" | "dest", tokenIn: HexString, tokenOut: HexString, amountIn: bigint, evmChainID: string): Promise<{
2718
+ amountOut: bigint;
2719
+ fee: number;
2720
+ }>;
2721
+ /**
2722
+ * Gets V4 quote for exact output swap.
2723
+ */
2724
+ getV4QuoteWithAmountOut(getQuoteIn: "source" | "dest", tokenIn: HexString, tokenOut: HexString, amountOut: bigint, evmChainID: string): Promise<{
2725
+ amountIn: bigint;
2726
+ fee: number;
2727
+ }>;
2728
+ /**
2729
+ * Gets V4 quote for exact input swap.
2730
+ */
2731
+ getV4QuoteWithAmountIn(getQuoteIn: "source" | "dest", tokenIn: HexString, tokenOut: HexString, amountIn: bigint, evmChainID: string): Promise<{
2732
+ amountOut: bigint;
2733
+ fee: number;
2734
+ }>;
2735
+ /**
2736
+ * Creates transaction structure for V2 exact input swap, including ERC20 transfer if needed.
2737
+ */
2738
+ createV2SwapCalldataExactIn(sourceTokenAddress: HexString, targetTokenAddress: HexString, amountIn: bigint, amountOutMinimum: bigint, recipient: HexString, evmChainID: string, getQuoteIn: "source" | "dest"): Transaction[];
2739
+ /**
2740
+ * Creates transaction structure for V2 exact output swap, including ERC20 transfer if needed.
2741
+ */
2742
+ createV2SwapCalldataExactOut(sourceTokenAddress: HexString, targetTokenAddress: HexString, amountOut: bigint, amountInMax: bigint, recipient: HexString, evmChainID: string, getQuoteIn: "source" | "dest"): Transaction[];
2743
+ /**
2744
+ * Creates transaction structure for V3 exact input swap, including ERC20 transfer if needed.
2745
+ */
2746
+ createV3SwapCalldataExactIn(sourceTokenAddress: HexString, targetTokenAddress: HexString, amountIn: bigint, amountOutMinimum: bigint, fee: number, recipient: HexString, evmChainID: string, getQuoteIn: "source" | "dest"): Transaction[];
2747
+ /**
2748
+ * Creates transaction structure for V3 exact output swap, including ERC20 transfer if needed.
2749
+ */
2750
+ createV3SwapCalldataExactOut(sourceTokenAddress: HexString, targetTokenAddress: HexString, amountOut: bigint, amountInMax: bigint, fee: number, recipient: HexString, evmChainID: string, getQuoteIn: "source" | "dest"): Transaction[];
2751
+ /**
2752
+ * Creates transaction structure for V4 exact input swap, including Permit2 approvals for ERC20 tokens.
2753
+ */
2754
+ createV4SwapCalldataExactIn(sourceTokenAddress: HexString, targetTokenAddress: HexString, amountIn: bigint, amountOutMinimum: bigint, fee: number, evmChainID: string, getQuoteIn: "source" | "dest"): Transaction[];
2755
+ /**
2756
+ * Creates transaction structure for V4 exact output swap, including Permit2 approvals for ERC20 tokens.
2757
+ */
2758
+ createV4SwapCalldataExactOut(sourceTokenAddress: HexString, targetTokenAddress: HexString, amountOut: bigint, amountInMax: bigint, fee: number, evmChainID: string, getQuoteIn: "source" | "dest"): Transaction[];
2651
2759
  /**
2652
2760
  * Finds the best Uniswap protocol (V2, V3, or V4) for swapping tokens given a desired output amount.
2653
2761
  * Compares liquidity and pricing across different protocols and fee tiers.
@@ -2656,12 +2764,17 @@ declare class IntentGateway {
2656
2764
  * @param tokenIn - The address of the input token
2657
2765
  * @param tokenOut - The address of the output token
2658
2766
  * @param amountOut - The desired output amount
2659
- * @returns Object containing the best protocol, required input amount, and fee tier (for V3/V4)
2767
+ * @returns Object containing the best protocol, required input amount, fee tier (for V3/V4), and transaction structure
2660
2768
  */
2661
- findBestProtocolWithAmountOut(getQuoteIn: "source" | "dest", tokenIn: HexString, tokenOut: HexString, amountOut: bigint, evmChainID: string, selectedProtocol?: "v2" | "v3" | "v4"): Promise<{
2769
+ findBestProtocolWithAmountOut(getQuoteIn: "source" | "dest", tokenIn: HexString, tokenOut: HexString, amountOut: bigint, evmChainID: string, options?: {
2770
+ selectedProtocol?: "v2" | "v3" | "v4";
2771
+ generateCalldata?: boolean;
2772
+ recipient?: HexString;
2773
+ }): Promise<{
2662
2774
  protocol: "v2" | "v3" | "v4" | null;
2663
2775
  amountIn: bigint;
2664
2776
  fee?: number;
2777
+ transactions?: Transaction[];
2665
2778
  }>;
2666
2779
  /**
2667
2780
  * Finds the best Uniswap protocol (V2, V3, or V4) for swapping tokens given an input amount.
@@ -2673,12 +2786,17 @@ declare class IntentGateway {
2673
2786
  * @param amountIn - The input amount to swap
2674
2787
  * @param evmChainID - The EVM chain ID in format "EVM-{id}"
2675
2788
  * @param selectedProtocol - Optional specific protocol to use ("v2", "v3", or "v4")
2676
- * @returns Object containing the best protocol, expected output amount, and fee tier (for V3/V4)
2789
+ * @returns Object containing the best protocol, expected output amount, fee tier (for V3/V4), and transaction structure
2677
2790
  */
2678
- findBestProtocolWithAmountIn(getQuoteIn: "source" | "dest", tokenIn: HexString, tokenOut: HexString, amountIn: bigint, evmChainID: string, selectedProtocol?: "v2" | "v3" | "v4"): Promise<{
2791
+ findBestProtocolWithAmountIn(getQuoteIn: "source" | "dest", tokenIn: HexString, tokenOut: HexString, amountIn: bigint, evmChainID: string, options?: {
2792
+ selectedProtocol?: "v2" | "v3" | "v4";
2793
+ generateCalldata?: boolean;
2794
+ recipient?: HexString;
2795
+ }): Promise<{
2679
2796
  protocol: "v2" | "v3" | "v4" | null;
2680
2797
  amountOut: bigint;
2681
2798
  fee?: number;
2799
+ transactions?: Transaction[];
2682
2800
  }>;
2683
2801
  /**
2684
2802
  * Checks if an order has been filled by verifying the commitment status on-chain.
@@ -2817,6 +2935,11 @@ declare class IntentGateway {
2817
2935
  * @returns True if candidate is within threshold of reference
2818
2936
  */
2819
2937
  private isWithinThreshold;
2938
+ /**
2939
+ * Encodes multiple command bytes into packed format
2940
+ * @private
2941
+ */
2942
+ private encodeCommands;
2820
2943
  }
2821
2944
  interface StoredCancellationData {
2822
2945
  destIProof?: IProof;
@@ -3106,4 +3229,4 @@ declare const coingeckoIds: {
3106
3229
  "EVM-130": string;
3107
3230
  };
3108
3231
 
3109
- export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type BlockMetadata, type CancelOptions, type ChainConfig, ChainConfigService, type ChainId, Chains, type ClientConfig, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DUMMY_PRIVATE_KEY, type DecodedOrderPlacedLog, type DispatchGet, type DispatchPost, ERC20Method, type EstimateGasCallData, EvmChain, type EvmChainParams, type ExecutionResult, type FillOptions, type FillerConfig, type GetRequestResponse, type GetRequestWithStatus, type GetResponseByRequestIdResponse, type GetResponseStorageValues, type HexString, type HostParams, HyperClientStatus, type HyperbridgeTxEvents, type IChain, type IConfig, type IEvmConfig, type IGetRequest, type IGetRequestMessage, type IGetResponse, type IGetResponseMessage, type IHyperbridgeConfig, type IIsmpMessage, type IMessage, type IPostRequest, type IPostResponse, type IProof, type IRequestMessage, type ISubstrateConfig, type ITimeoutPostRequestMessage, IndexerClient, type IndexerQueryClient, IntentGateway, type IntentGatewayParams, type IsmpRequest, type NewDeployment, type Order, type OrderResponse, OrderStatus, type OrderStatusMetadata, type OrderWithStatus, type Params, type PaymentInfo, type PostRequestStatus, type PostRequestTimeoutStatus, type PostRequestWithStatus, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, type RequestBody, type RequestCommitment, RequestKind, type RequestResponse, RequestStatus, type RequestStatusKey, type RequestStatusWithMetadata, type ResponseCommitmentWithValues, type RetryConfig, STATE_COMMITMENTS_SLOT, type StateMachineHeight, type StateMachineIdParams, type StateMachineResponse, type StateMachineUpdate, SubstrateChain, type SubstrateChainParams, TeleportStatus, TimeoutStatus, type TimeoutStatusKey, type TokenGatewayAssetTeleportedResponse, type TokenGatewayAssetTeleportedWithStatus, type TokenInfo, type TokenPrice, type TokenPricesResponse, type TokenRegistry, type TokenRegistryResponse, WrappedNativeDecimals, type XcmGatewayParams, __test, addresses, adjustFeeDecimals, assets, bytes20ToBytes32, bytes32ToBytes20, chainIds, coingeckoIds, consensusStateIds, constructRedeemEscrowRequestBody, convertStateIdToStateMachineId, convertStateMachineIdToEnum, createQueryClient, createRpcUrls, encodeISMPMessage, estimateGasForPost, fetchPrice, generateRootWithProof, getChain, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, hexToString, maxBigInt, orderCommitment, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, requestCommitmentKey, teleport, teleportDot, viemChains };
3232
+ export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type BlockMetadata, type CancelOptions, type ChainConfig, ChainConfigService, type ChainId, Chains, type ClientConfig, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DUMMY_PRIVATE_KEY, type DecodedOrderPlacedLog, type DispatchGet, type DispatchPost, ERC20Method, type EstimateGasCallData, EvmChain, type EvmChainParams, type ExecutionResult, type FillOptions, type FillerConfig, type GetRequestResponse, type GetRequestWithStatus, type GetResponseByRequestIdResponse, type GetResponseStorageValues, type HexString, type HostParams, HyperClientStatus, type HyperbridgeTxEvents, type IChain, type IConfig, type IEvmConfig, type IGetRequest, type IGetRequestMessage, type IGetResponse, type IGetResponseMessage, type IHyperbridgeConfig, type IIsmpMessage, type IMessage, type IPostRequest, type IPostResponse, type IProof, type IRequestMessage, type ISubstrateConfig, type ITimeoutPostRequestMessage, IndexerClient, type IndexerQueryClient, IntentGateway, type IntentGatewayParams, type IsmpRequest, type NewDeployment, type Order, type OrderResponse, OrderStatus, type OrderStatusMetadata, type OrderWithStatus, type Params, type PaymentInfo, type PostRequestStatus, type PostRequestTimeoutStatus, type PostRequestWithStatus, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, type RequestBody, type RequestCommitment, RequestKind, type RequestResponse, RequestStatus, type RequestStatusKey, type RequestStatusWithMetadata, type ResponseCommitmentWithValues, type RetryConfig, STATE_COMMITMENTS_SLOT, type StateMachineHeight, type StateMachineIdParams, type StateMachineResponse, type StateMachineUpdate, SubstrateChain, type SubstrateChainParams, TESTNET_CHAINS, TeleportStatus, TimeoutStatus, type TimeoutStatusKey, type TokenGatewayAssetTeleportedResponse, type TokenGatewayAssetTeleportedWithStatus, type TokenInfo, type TokenPrice, type TokenPricesResponse, type TokenRegistry, type TokenRegistryResponse, type Transaction, USE_ETHERSCAN_CHAINS, WrappedNativeDecimals, type XcmGatewayParams, __test, addresses, adjustFeeDecimals, assets, bytes20ToBytes32, bytes32ToBytes20, chainIds, coingeckoIds, consensusStateIds, constructRedeemEscrowRequestBody, convertStateIdToStateMachineId, convertStateMachineIdToEnum, createQueryClient, createRpcUrls, encodeISMPMessage, estimateGasForPost, fetchPrice, generateRootWithProof, getChain, getGasPriceFromEtherscan, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, hexToString, maxBigInt, orderCommitment, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, requestCommitmentKey, retryPromise, teleport, teleportDot, viemChains };