@hyperbridge/sdk 1.3.0 → 1.3.2
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/dist/browser/index.d.ts +62 -22
- package/dist/browser/index.js +223 -100
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.d.ts +62 -22
- package/dist/node/index.js +223 -100
- package/dist/node/index.js.map +1 -1
- package/package.json +1 -1
- package/plugins/vite.js +52 -39
package/dist/browser/index.d.ts
CHANGED
|
@@ -585,7 +585,7 @@ declare const _default: {
|
|
|
585
585
|
}];
|
|
586
586
|
};
|
|
587
587
|
|
|
588
|
-
type EstimateGasCallData = ContractFunctionArgs<typeof _default.ABI,
|
|
588
|
+
type EstimateGasCallData = ContractFunctionArgs<typeof _default.ABI, "nonpayable" | "payable", "handlePostRequests">;
|
|
589
589
|
type HexString = `0x${string}`;
|
|
590
590
|
interface IConfig {
|
|
591
591
|
source: IEvmConfig | ISubstrateConfig;
|
|
@@ -1699,9 +1699,12 @@ declare class EvmChain implements IChain {
|
|
|
1699
1699
|
*
|
|
1700
1700
|
* @param request - The post request to estimate gas for
|
|
1701
1701
|
* @param paraId - The ID of the parachain (Hyperbridge) that will process the request
|
|
1702
|
-
* @returns The estimated gas amount in gas units
|
|
1702
|
+
* @returns The estimated gas amount in gas units and the generated calldata
|
|
1703
1703
|
*/
|
|
1704
|
-
estimateGas(request: IPostRequest): Promise<
|
|
1704
|
+
estimateGas(request: IPostRequest): Promise<{
|
|
1705
|
+
gas: bigint;
|
|
1706
|
+
postRequestCalldata: HexString;
|
|
1707
|
+
}>;
|
|
1705
1708
|
/**
|
|
1706
1709
|
* Gets the fee token address and decimals for the chain.
|
|
1707
1710
|
* This function gets the fee token address and decimals for the chain.
|
|
@@ -1804,6 +1807,7 @@ type IStateMachine = {
|
|
|
1804
1807
|
|
|
1805
1808
|
declare const ADDRESS_ZERO: HexString;
|
|
1806
1809
|
declare const DUMMY_PRIVATE_KEY: HexString;
|
|
1810
|
+
declare const DEFAULT_GRAFFITI: HexString;
|
|
1807
1811
|
/**
|
|
1808
1812
|
* Calculates the commitment hash for a post request.
|
|
1809
1813
|
* @param post The post request to calculate the commitment hash for.
|
|
@@ -2557,18 +2561,45 @@ declare class IntentGateway {
|
|
|
2557
2561
|
* protocol fees, and swap operations.
|
|
2558
2562
|
*
|
|
2559
2563
|
* @param order - The order to estimate fill costs for
|
|
2560
|
-
* @returns
|
|
2564
|
+
* @returns An object containing the estimated cost in both fee token and native token, plus the post request calldata
|
|
2565
|
+
*/
|
|
2566
|
+
estimateFillOrder(order: Order): Promise<{
|
|
2567
|
+
feeTokenAmount: bigint;
|
|
2568
|
+
nativeTokenAmount: bigint;
|
|
2569
|
+
postRequestCalldata: HexString;
|
|
2570
|
+
}>;
|
|
2571
|
+
/**
|
|
2572
|
+
* Converts fee token amounts back to the equivalent amount in native token.
|
|
2573
|
+
* Uses USD pricing to convert between fee token amounts and native token costs.
|
|
2574
|
+
*
|
|
2575
|
+
* @param feeTokenAmount - The amount in fee token (DAI)
|
|
2576
|
+
* @param publicClient - The client for the chain to get native token info
|
|
2577
|
+
* @param feeTokenDecimals - The decimal places of the fee token
|
|
2578
|
+
* @returns The fee token amount converted to native token amount
|
|
2579
|
+
* @private
|
|
2561
2580
|
*/
|
|
2562
|
-
|
|
2581
|
+
private convertFeeTokenToNative;
|
|
2563
2582
|
/**
|
|
2564
|
-
*
|
|
2583
|
+
* Converts gas costs to the equivalent amount in the fee token (DAI).
|
|
2584
|
+
* Uses USD pricing to convert between native token gas costs and fee token amounts.
|
|
2585
|
+
*
|
|
2586
|
+
* @param gasEstimate - The estimated gas units
|
|
2587
|
+
* @param publicClient - The client for the chain to get gas prices
|
|
2588
|
+
* @param targetDecimals - The decimal places of the target fee token
|
|
2589
|
+
* @returns The gas cost converted to fee token amount
|
|
2590
|
+
* @private
|
|
2591
|
+
*/
|
|
2592
|
+
private convertGasToFeeToken;
|
|
2593
|
+
quoteNative(postRequest: IPostRequest, fee: bigint): Promise<bigint>;
|
|
2594
|
+
/**
|
|
2595
|
+
* Finds the best Uniswap protocol (V2, V3, or V4) for swapping tokens given a desired output amount.
|
|
2565
2596
|
* Compares liquidity and pricing across different protocols and fee tiers.
|
|
2566
2597
|
*
|
|
2567
2598
|
* @param chain - The chain identifier where the swap will occur
|
|
2568
2599
|
* @param tokenIn - The address of the input token
|
|
2569
2600
|
* @param tokenOut - The address of the output token
|
|
2570
2601
|
* @param amountOut - The desired output amount
|
|
2571
|
-
* @returns Object containing the best protocol, required input amount, and fee tier (for V3)
|
|
2602
|
+
* @returns Object containing the best protocol, required input amount, and fee tier (for V3/V4)
|
|
2572
2603
|
*/
|
|
2573
2604
|
findBestProtocolWithAmountOut(chain: string, tokenIn: HexString, tokenOut: HexString, amountOut: bigint): Promise<{
|
|
2574
2605
|
protocol: "v2" | "v3" | "v4" | null;
|
|
@@ -2576,31 +2607,20 @@ declare class IntentGateway {
|
|
|
2576
2607
|
fee?: number;
|
|
2577
2608
|
}>;
|
|
2578
2609
|
/**
|
|
2579
|
-
* Finds the best Uniswap protocol (V2 or
|
|
2610
|
+
* Finds the best Uniswap protocol (V2, V3, or V4) for swapping tokens given an input amount.
|
|
2580
2611
|
* Compares liquidity and pricing across different protocols and fee tiers.
|
|
2581
2612
|
*
|
|
2582
2613
|
* @param chain - The chain identifier where the swap will occur
|
|
2583
2614
|
* @param tokenIn - The address of the input token
|
|
2584
2615
|
* @param tokenOut - The address of the output token
|
|
2585
2616
|
* @param amountIn - The input amount to swap
|
|
2586
|
-
* @returns Object containing the best protocol, expected output amount, and fee tier (for V3)
|
|
2617
|
+
* @returns Object containing the best protocol, expected output amount, and fee tier (for V3/V4)
|
|
2587
2618
|
*/
|
|
2588
2619
|
findBestProtocolWithAmountIn(chain: string, tokenIn: HexString, tokenOut: HexString, amountIn: bigint): Promise<{
|
|
2589
2620
|
protocol: "v2" | "v3" | "v4" | null;
|
|
2590
2621
|
amountOut: bigint;
|
|
2591
2622
|
fee?: number;
|
|
2592
2623
|
}>;
|
|
2593
|
-
/**
|
|
2594
|
-
* Converts gas costs to the equivalent amount in the fee token (DAI).
|
|
2595
|
-
* Uses USD pricing to convert between native token gas costs and fee token amounts.
|
|
2596
|
-
*
|
|
2597
|
-
* @param gasEstimate - The estimated gas units
|
|
2598
|
-
* @param publicClient - The client for the chain to get gas prices
|
|
2599
|
-
* @param targetDecimals - The decimal places of the target fee token
|
|
2600
|
-
* @returns The gas cost converted to fee token amount
|
|
2601
|
-
* @private
|
|
2602
|
-
*/
|
|
2603
|
-
private convertGasToFeeToken;
|
|
2604
2624
|
/**
|
|
2605
2625
|
* Checks if an order has been filled by verifying the commitment status on-chain.
|
|
2606
2626
|
* Reads the storage slot corresponding to the order's commitment hash.
|
|
@@ -2786,7 +2806,9 @@ declare enum Chains {
|
|
|
2786
2806
|
HYPERBRIDGE_GARGANTUA = "KUSAMA-4009",
|
|
2787
2807
|
SEPOLIA = "EVM-11155111",
|
|
2788
2808
|
MAINNET = "EVM-1",
|
|
2789
|
-
BSC_MAINNET = "EVM-56"
|
|
2809
|
+
BSC_MAINNET = "EVM-56",
|
|
2810
|
+
ARBITRUM_MAINNET = "EVM-42161",
|
|
2811
|
+
BASE_MAINNET = "EVM-8453"
|
|
2790
2812
|
}
|
|
2791
2813
|
type AddressMap = {
|
|
2792
2814
|
[key: string]: {
|
|
@@ -2801,6 +2823,8 @@ declare const chainIds: {
|
|
|
2801
2823
|
readonly "EVM-11155111": 11155111;
|
|
2802
2824
|
readonly "EVM-1": 1;
|
|
2803
2825
|
readonly "EVM-56": 56;
|
|
2826
|
+
readonly "EVM-42161": 42161;
|
|
2827
|
+
readonly "EVM-8453": 8453;
|
|
2804
2828
|
};
|
|
2805
2829
|
type ChainId = typeof chainIds;
|
|
2806
2830
|
declare const viemChains: Record<string, Chain>;
|
|
@@ -2810,6 +2834,8 @@ declare const WrappedNativeDecimals: {
|
|
|
2810
2834
|
"EVM-11155111": number;
|
|
2811
2835
|
"EVM-1": number;
|
|
2812
2836
|
"EVM-56": number;
|
|
2837
|
+
"EVM-42161": number;
|
|
2838
|
+
"EVM-8453": number;
|
|
2813
2839
|
};
|
|
2814
2840
|
declare const assets: {
|
|
2815
2841
|
"EVM-97": {
|
|
@@ -2842,6 +2868,18 @@ declare const assets: {
|
|
|
2842
2868
|
USDC: string;
|
|
2843
2869
|
USDT: string;
|
|
2844
2870
|
};
|
|
2871
|
+
"EVM-42161": {
|
|
2872
|
+
WETH: string;
|
|
2873
|
+
DAI: string;
|
|
2874
|
+
USDC: string;
|
|
2875
|
+
USDT: string;
|
|
2876
|
+
};
|
|
2877
|
+
"EVM-8453": {
|
|
2878
|
+
WETH: string;
|
|
2879
|
+
DAI: string;
|
|
2880
|
+
USDC: string;
|
|
2881
|
+
USDT: string;
|
|
2882
|
+
};
|
|
2845
2883
|
};
|
|
2846
2884
|
declare const addresses: AddressMap;
|
|
2847
2885
|
declare const createRpcUrls: (env: NodeJS.ProcessEnv) => RpcMap;
|
|
@@ -2852,6 +2890,8 @@ declare const consensusStateIds: {
|
|
|
2852
2890
|
"EVM-11155111": string;
|
|
2853
2891
|
"EVM-1": string;
|
|
2854
2892
|
"EVM-56": string;
|
|
2893
|
+
"EVM-42161": string;
|
|
2894
|
+
"EVM-8453": string;
|
|
2855
2895
|
};
|
|
2856
2896
|
|
|
2857
|
-
export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type BlockMetadata, type CancelOptions, type ChainConfig, ChainConfigService, type ChainId, Chains, type ClientConfig, DEFAULT_ADDRESS, 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, consensusStateIds, constructRedeemEscrowRequestBody, convertStateMachineIdToEnum, createQueryClient, createRpcUrls, encodeISMPMessage, estimateGasForPost, fetchTokenUsdPrice, generateRootWithProof, getChain, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, hexToString, orderCommitment, postRequestCommitment, queryGetRequest, queryPostRequest, teleport, teleportDot, viemChains };
|
|
2897
|
+
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, consensusStateIds, constructRedeemEscrowRequestBody, convertStateMachineIdToEnum, createQueryClient, createRpcUrls, encodeISMPMessage, estimateGasForPost, fetchTokenUsdPrice, generateRootWithProof, getChain, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, hexToString, orderCommitment, postRequestCommitment, queryGetRequest, queryPostRequest, teleport, teleportDot, viemChains };
|