@hyperbridge/sdk 1.2.0 → 1.2.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 +102 -18
- package/dist/browser/index.js +618 -76
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.d.ts +102 -18
- package/dist/node/index.js +618 -76
- package/dist/node/index.js.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.d.ts
CHANGED
|
@@ -939,6 +939,47 @@ interface OrderResponse {
|
|
|
939
939
|
}>;
|
|
940
940
|
};
|
|
941
941
|
}
|
|
942
|
+
interface TokenPrice {
|
|
943
|
+
symbol: string;
|
|
944
|
+
address?: string;
|
|
945
|
+
currency: string;
|
|
946
|
+
price: string;
|
|
947
|
+
lastUpdatedAt: bigint;
|
|
948
|
+
}
|
|
949
|
+
interface TokenPricesResponse {
|
|
950
|
+
tokenPrices: {
|
|
951
|
+
nodes: Array<{
|
|
952
|
+
id: string;
|
|
953
|
+
symbol: string;
|
|
954
|
+
address: string;
|
|
955
|
+
currency: string;
|
|
956
|
+
price: string;
|
|
957
|
+
lastUpdatedAt: bigint;
|
|
958
|
+
}>;
|
|
959
|
+
};
|
|
960
|
+
}
|
|
961
|
+
interface TokenRegistry {
|
|
962
|
+
id: string;
|
|
963
|
+
name: string;
|
|
964
|
+
symbol: string;
|
|
965
|
+
address?: string;
|
|
966
|
+
updateFrequencySeconds: number;
|
|
967
|
+
lastUpdatedAt: bigint;
|
|
968
|
+
createdAt: Date;
|
|
969
|
+
}
|
|
970
|
+
interface TokenRegistryResponse {
|
|
971
|
+
tokenRegistries: {
|
|
972
|
+
nodes: Array<{
|
|
973
|
+
id: string;
|
|
974
|
+
name: string;
|
|
975
|
+
symbol: string;
|
|
976
|
+
address: string;
|
|
977
|
+
updateFrequencySeconds: number;
|
|
978
|
+
lastUpdatedAt: bigint;
|
|
979
|
+
createdAt: string;
|
|
980
|
+
}>;
|
|
981
|
+
};
|
|
982
|
+
}
|
|
942
983
|
declare class AbortSignalInternal extends Error {
|
|
943
984
|
constructor(message: string);
|
|
944
985
|
static isError(error: unknown): error is AbortSignalInternal;
|
|
@@ -968,6 +1009,8 @@ declare class ChainConfigService {
|
|
|
968
1009
|
getUniswapV3RouterAddress(chain: string): HexString;
|
|
969
1010
|
getUniswapV3FactoryAddress(chain: string): HexString;
|
|
970
1011
|
getUniswapV3QuoterAddress(chain: string): HexString;
|
|
1012
|
+
getUniswapV4PoolManagerAddress(chain: string): HexString;
|
|
1013
|
+
getUniswapV4QuoterAddress(chain: string): HexString;
|
|
971
1014
|
}
|
|
972
1015
|
|
|
973
1016
|
/**
|
|
@@ -1228,6 +1271,15 @@ declare function constructRedeemEscrowRequestBody(order: Order, beneficiary: Hex
|
|
|
1228
1271
|
* @returns The USD price of the token as a number (preserves decimals)
|
|
1229
1272
|
*/
|
|
1230
1273
|
declare function fetchTokenUsdPrice(identifier: string): Promise<number>;
|
|
1274
|
+
/**
|
|
1275
|
+
* ERC20 method signatures used for storage slot detection
|
|
1276
|
+
*/
|
|
1277
|
+
declare enum ERC20Method {
|
|
1278
|
+
/** ERC20 balanceOf(address) method signature */
|
|
1279
|
+
BALANCE_OF = "0x70a08231",
|
|
1280
|
+
/** ERC20 allowance(address,address) method signature */
|
|
1281
|
+
ALLOWANCE = "0xdd62ed3e"
|
|
1282
|
+
}
|
|
1231
1283
|
/**
|
|
1232
1284
|
* Retrieves the storage slot for a contract call using debug_traceCall
|
|
1233
1285
|
*
|
|
@@ -1266,6 +1318,16 @@ declare function fetchTokenUsdPrice(identifier: string): Promise<number>;
|
|
|
1266
1318
|
* ```
|
|
1267
1319
|
*/
|
|
1268
1320
|
declare function getStorageSlot(client: PublicClient, contractAddress: HexString, data: HexString): Promise<string>;
|
|
1321
|
+
/**
|
|
1322
|
+
* Adjusts fee amounts between different decimal precisions.
|
|
1323
|
+
* Handles scaling up or down based on the decimal difference.
|
|
1324
|
+
*
|
|
1325
|
+
* @param feeInFeeToken - The fee amount to adjust
|
|
1326
|
+
* @param fromDecimals - The current decimal precision
|
|
1327
|
+
* @param toDecimals - The target decimal precision
|
|
1328
|
+
* @returns The adjusted fee amount with the target decimal precision
|
|
1329
|
+
*/
|
|
1330
|
+
declare function adjustFeeDecimals(feeInFeeToken: bigint, fromDecimals: number, toDecimals: number): bigint;
|
|
1269
1331
|
|
|
1270
1332
|
interface SubstrateChainParams {
|
|
1271
1333
|
ws: string;
|
|
@@ -1923,13 +1985,12 @@ declare class IntentGateway {
|
|
|
1923
1985
|
* @param tokenIn - The address of the input token
|
|
1924
1986
|
* @param tokenOut - The address of the output token
|
|
1925
1987
|
* @param amountOut - The desired output amount
|
|
1926
|
-
* @returns Object containing the best protocol, required input amount, fee tier (for V3)
|
|
1988
|
+
* @returns Object containing the best protocol, required input amount, and fee tier (for V3)
|
|
1927
1989
|
*/
|
|
1928
1990
|
findBestProtocolWithAmountOut(chain: string, tokenIn: HexString, tokenOut: HexString, amountOut: bigint): Promise<{
|
|
1929
|
-
protocol: "v2" | "v3" | null;
|
|
1991
|
+
protocol: "v2" | "v3" | "v4" | null;
|
|
1930
1992
|
amountIn: bigint;
|
|
1931
1993
|
fee?: number;
|
|
1932
|
-
gasEstimate?: bigint;
|
|
1933
1994
|
}>;
|
|
1934
1995
|
/**
|
|
1935
1996
|
* Finds the best Uniswap protocol (V2 or V3) for swapping tokens given an input amount.
|
|
@@ -1939,13 +2000,12 @@ declare class IntentGateway {
|
|
|
1939
2000
|
* @param tokenIn - The address of the input token
|
|
1940
2001
|
* @param tokenOut - The address of the output token
|
|
1941
2002
|
* @param amountIn - The input amount to swap
|
|
1942
|
-
* @returns Object containing the best protocol, expected output amount, fee tier (for V3)
|
|
2003
|
+
* @returns Object containing the best protocol, expected output amount, and fee tier (for V3)
|
|
1943
2004
|
*/
|
|
1944
2005
|
findBestProtocolWithAmountIn(chain: string, tokenIn: HexString, tokenOut: HexString, amountIn: bigint): Promise<{
|
|
1945
|
-
protocol: "v2" | "v3" | null;
|
|
2006
|
+
protocol: "v2" | "v3" | "v4" | null;
|
|
1946
2007
|
amountOut: bigint;
|
|
1947
2008
|
fee?: number;
|
|
1948
|
-
gasEstimate?: bigint;
|
|
1949
2009
|
}>;
|
|
1950
2010
|
/**
|
|
1951
2011
|
* Converts gas costs to the equivalent amount in the fee token (DAI).
|
|
@@ -1958,16 +2018,6 @@ declare class IntentGateway {
|
|
|
1958
2018
|
* @private
|
|
1959
2019
|
*/
|
|
1960
2020
|
private convertGasToFeeToken;
|
|
1961
|
-
/**
|
|
1962
|
-
* Adjusts fee amounts between different decimal precisions.
|
|
1963
|
-
* Handles scaling up or down based on the decimal difference.
|
|
1964
|
-
*
|
|
1965
|
-
* @param feeInFeeToken - The fee amount to adjust
|
|
1966
|
-
* @param fromDecimals - The current decimal precision
|
|
1967
|
-
* @param toDecimals - The target decimal precision
|
|
1968
|
-
* @returns The adjusted fee amount with the target decimal precision
|
|
1969
|
-
*/
|
|
1970
|
-
adjustFeeDecimals(feeInFeeToken: bigint, fromDecimals: number, toDecimals: number): bigint;
|
|
1971
2021
|
/**
|
|
1972
2022
|
* Checks if an order has been filled by verifying the commitment status on-chain.
|
|
1973
2023
|
* Reads the storage slot corresponding to the order's commitment hash.
|
|
@@ -1976,6 +2026,20 @@ declare class IntentGateway {
|
|
|
1976
2026
|
* @returns True if the order has been filled, false otherwise
|
|
1977
2027
|
*/
|
|
1978
2028
|
isOrderFilled(order: Order): Promise<boolean>;
|
|
2029
|
+
/**
|
|
2030
|
+
* Returns the tick spacing for a given fee tier in Uniswap V4
|
|
2031
|
+
* @param fee - The fee tier in basis points
|
|
2032
|
+
* @returns The tick spacing value
|
|
2033
|
+
*/
|
|
2034
|
+
private getTickSpacing;
|
|
2035
|
+
/**
|
|
2036
|
+
* Returns true if candidate <= reference * (1 + thresholdBps/10000)
|
|
2037
|
+
* @param candidate - The candidate amount to compare
|
|
2038
|
+
* @param reference - The reference amount
|
|
2039
|
+
* @param thresholdBps - The threshold in basis points
|
|
2040
|
+
* @returns True if candidate is within threshold of reference
|
|
2041
|
+
*/
|
|
2042
|
+
private isWithinThreshold;
|
|
1979
2043
|
}
|
|
1980
2044
|
|
|
1981
2045
|
type HyperbridgeTxEvents = {
|
|
@@ -2137,7 +2201,9 @@ declare enum Chains {
|
|
|
2137
2201
|
BSC_CHAPEL = "EVM-97",
|
|
2138
2202
|
GNOSIS_CHIADO = "EVM-10200",
|
|
2139
2203
|
HYPERBRIDGE_GARGANTUA = "KUSAMA-4009",
|
|
2140
|
-
SEPOLIA = "EVM-11155111"
|
|
2204
|
+
SEPOLIA = "EVM-11155111",
|
|
2205
|
+
MAINNET = "EVM-1",
|
|
2206
|
+
BSC_MAINNET = "EVM-56"
|
|
2141
2207
|
}
|
|
2142
2208
|
type AddressMap = {
|
|
2143
2209
|
[key: string]: {
|
|
@@ -2150,6 +2216,8 @@ declare const chainIds: {
|
|
|
2150
2216
|
readonly "EVM-10200": 10200;
|
|
2151
2217
|
readonly "KUSAMA-4009": 4009;
|
|
2152
2218
|
readonly "EVM-11155111": 11155111;
|
|
2219
|
+
readonly "EVM-1": 1;
|
|
2220
|
+
readonly "EVM-56": 56;
|
|
2153
2221
|
};
|
|
2154
2222
|
type ChainId = typeof chainIds;
|
|
2155
2223
|
declare const viemChains: Record<string, Chain>;
|
|
@@ -2157,6 +2225,8 @@ declare const WrappedNativeDecimals: {
|
|
|
2157
2225
|
"EVM-97": number;
|
|
2158
2226
|
"EVM-10200": number;
|
|
2159
2227
|
"EVM-11155111": number;
|
|
2228
|
+
"EVM-1": number;
|
|
2229
|
+
"EVM-56": number;
|
|
2160
2230
|
};
|
|
2161
2231
|
declare const assets: {
|
|
2162
2232
|
"EVM-97": {
|
|
@@ -2177,6 +2247,18 @@ declare const assets: {
|
|
|
2177
2247
|
USDT: string;
|
|
2178
2248
|
DAI: string;
|
|
2179
2249
|
};
|
|
2250
|
+
"EVM-1": {
|
|
2251
|
+
WETH: string;
|
|
2252
|
+
DAI: string;
|
|
2253
|
+
USDC: string;
|
|
2254
|
+
USDT: string;
|
|
2255
|
+
};
|
|
2256
|
+
"EVM-56": {
|
|
2257
|
+
WETH: string;
|
|
2258
|
+
DAI: string;
|
|
2259
|
+
USDC: string;
|
|
2260
|
+
USDT: string;
|
|
2261
|
+
};
|
|
2180
2262
|
};
|
|
2181
2263
|
declare const addresses: AddressMap;
|
|
2182
2264
|
declare const createRpcUrls: (env: NodeJS.ProcessEnv) => RpcMap;
|
|
@@ -2185,6 +2267,8 @@ declare const consensusStateIds: {
|
|
|
2185
2267
|
"EVM-10200": string;
|
|
2186
2268
|
"KUSAMA-4009": string;
|
|
2187
2269
|
"EVM-11155111": string;
|
|
2270
|
+
"EVM-1": string;
|
|
2271
|
+
"EVM-56": string;
|
|
2188
2272
|
};
|
|
2189
2273
|
|
|
2190
|
-
export { ADDRESS_ZERO, AbortSignalInternal, 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, 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, WrappedNativeDecimals, type XcmGatewayParams, __test, addresses, 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 };
|
|
2274
|
+
export { ADDRESS_ZERO, AbortSignalInternal, 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, 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 };
|