@hyperbridge/sdk 2.8.17 → 2.8.19
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 +25 -21
- package/dist/browser/index.js +148 -35
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +147 -35
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +22 -23
- package/dist/node/index.d.ts +22 -23
- package/dist/node/index.js +148 -35
- package/dist/node/index.js.map +1 -1
- package/dist/node/{intents-helpers-BHl2If1T.d.cts → intents-helpers-D0JcQNDm.d.cts} +6 -1
- package/dist/node/{intents-helpers-BHl2If1T.d.ts → intents-helpers-D0JcQNDm.d.ts} +6 -1
- package/dist/node/intents-helpers.d.cts +1 -1
- package/dist/node/intents-helpers.d.ts +1 -1
- package/package.json +1 -1
package/dist/node/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as IChain, H as HexString, a as IEvmConfig, C as ChainConfigService, b as IMessage, S as StateMachineIdParams, c as StateMachineHeight, d as IIsmpMessage, e as IPostRequest, f as IGetRequest, O as Order, E as EstimateGasCallData, R as RetryConfig, g as IPolkadotHubConfig, h as IPharosConfig, i as StateMachineUpdate, P as PostRequestWithStatus, G as GetRequestWithStatus, j as ResponseCommitmentWithValues, k as RequestStatusWithMetadata, l as PostRequestTimeoutStatus, m as SubstrateChain, n as ClientConfig, o as IndexerQueryClient, A as AssetTeleported, T as Transaction, p as IProof, q as IEvmChain, r as IntentsCoprocessor, s as Chains, t as ConfiguredAssetSymbol, Q as QueryBuyAndSellRatesParams, u as IntentOrderStatusUpdate, v as SelectBidResult, w as ResumeIntentOrderOptions, x as CancelOrderOptions, y as CancelQuote, z as SubmitBidOptions, B as PackedUserOperation, F as FillerBid, D as Bid, J as EstimateFillOrderParams, K as FillOrderEstimate, L as
|
|
2
|
-
export {
|
|
1
|
+
import { I as IChain, H as HexString, a as IEvmConfig, C as ChainConfigService, b as IMessage, S as StateMachineIdParams, c as StateMachineHeight, d as IIsmpMessage, e as IPostRequest, f as IGetRequest, O as Order, E as EstimateGasCallData, R as RetryConfig, g as IPolkadotHubConfig, h as IPharosConfig, i as StateMachineUpdate, P as PostRequestWithStatus, G as GetRequestWithStatus, j as ResponseCommitmentWithValues, k as RequestStatusWithMetadata, l as PostRequestTimeoutStatus, m as SubstrateChain, n as ClientConfig, o as IndexerQueryClient, A as AssetTeleported, T as Transaction, p as IProof, q as IEvmChain, r as IntentsCoprocessor, s as Chains, t as ConfiguredAssetSymbol, Q as QueryBuyAndSellRatesParams, u as IntentOrderStatusUpdate, v as SelectBidResult, w as ResumeIntentOrderOptions, x as CancelOrderOptions, y as CancelQuote, z as SubmitBidOptions, B as PackedUserOperation, F as FillerBid, D as Bid, J as EstimateFillOrderParams, K as FillOrderEstimate, L as BidPreVerificationGasParams, M as OrderFeesQuote, N as ERC7821Call, U as TokenInfo, V as OrderWithStatus, W as OrderStatus, X as FillOptions, Y as TokenGatewayAssetTeleportedWithStatus, Z as TeleportStatus, _ as DecodedOrderPlacedLog, $ as DecodedPostRequestEvent, a0 as DecodedPostResponseEvent } from './intents-helpers-D0JcQNDm.cjs';
|
|
2
|
+
export { a1 as AllStatusKey, a2 as AssetTeleportedResponse, a3 as BidStorageEntry, a4 as BidSubmissionResult, a5 as BlockMetadata, a6 as BytesLikeHex, a7 as CancelOptions, a8 as ChainConfig, a9 as ChainConfigData, aa as ConfiguredAssetSymbolInput, ab as Deployment, ac as DispatchGet, ad as DispatchInfo, ae as DispatchPost, af as Erc4626VaultConfigData, ag as ExecuteIntentOrderOptions, ah as ExecutionResult, ai as FillerConfig, aj as GetRequestResponse, ak as GetResponseByRequestIdResponse, al as GetResponseStorageValues, am as HostParams, an as HyperClientStatus, ao as IBatchConsensusAndGetResponseMessage, ap as IBatchConsensusAndPostRequestMessage, aq as IConfig, ar as IConsensusMessage, as as IGetRequestMessage, at as IGetResponse, au as IGetResponseMessage, av as IHyperbridgeConfig, aw as INCLUSION_TIMEOUT_MS, ax as IPostResponse, ay as IRequestMessage, az as ISubstrateConfig, aA as ITimeoutPostRequestMessage, aB as IntentGatewayABI, aC as IntentGatewayParams, aD as IntentOrderStatus, aE as IntentOrderStatusKey, aF as IsmpRequest, aG as MAX_DECLARED_ENTRIES, aH as OrderResponse, aI as OrderStatusMetadata, aJ as PERMIT2_SPONSORSHIP_BYTES, aK as PaymentInfo, aL as PhantomBidDeclaration, aM as PhantomBidPaymasterAndData, aN as PhantomBidSponsorship, aO as PostRequestStatus, aP as RequestBody, aQ as RequestCommitment, aR as RequestKind, aS as RequestResponse, aT as RequestStatus, aU as RequestStatusKey, aV as RpcBidInfo, aW as SelectOptions, aX as SigningAccount, aY as StateMachineId, aZ as StateMachineResponse, a_ as StorageFacade, a$ as TimeoutStatus, b0 as TimeoutStatusKey, b1 as TokenGatewayAssetTeleportedResponse, b2 as TokenPrice, b3 as TokenPricesResponse, b4 as chainConfigs, b5 as convertCodecToIGetRequest, b6 as convertCodecToIProof, b7 as convertIGetRequestToCodec, b8 as convertIProofToCodec, b9 as convertStateIdToStateMachineId, ba as convertStateMachineEnumToString, bb as convertStateMachineIdToEnum, bc as decodeAcceptedSourceChains, bd as decodeERC7821ExecuteBatch, be as decodePhantomBidDeclaration, bf as decodePhantomBidPaymasterAndData, bg as decodeUserOpScale, bh as deriveHttpUrl, bi as encodeAcceptedSourceChains, bj as encodeERC7821ExecuteBatch, bk as encodeISMPMessage, bl as encodePhantomBidDeclaration, bm as encodePhantomBidPaymasterAndData, bn as encodeUserOpScale, bo as getChainId, bp as getConfigByStateMachineId, bq as getViemChain, br as hyperbridgeAddress, bs as pharosAtlantic, bt as pharosMainnet, bu as polkadotAssetHubPaseo, bv as polkadotHubMainnet, bw as poolSlug, bx as sortPoolSymbols, by as tronChainIds, bz as tronNile } from './intents-helpers-D0JcQNDm.cjs';
|
|
3
3
|
import { ConsolaInstance } from 'consola';
|
|
4
4
|
import { GraphQLClient } from 'graphql-request';
|
|
5
5
|
import { PublicClient, TransactionReceipt, Hex, Address } from 'viem';
|
|
@@ -1899,6 +1899,10 @@ interface QuoteIntentResult {
|
|
|
1899
1899
|
amountIn: bigint;
|
|
1900
1900
|
/** The destination's protocol fee in basis points, already taken off every leg's `amountOut`. */
|
|
1901
1901
|
slippageBps: number;
|
|
1902
|
+
/**
|
|
1903
|
+
* False when the route cannot fill the trade: `legs` is empty and `maxFillableIn` says how much
|
|
1904
|
+
* it could. For an exact output, `amountIn` is then the input the SDK last tried.
|
|
1905
|
+
*/
|
|
1902
1906
|
fillable: boolean;
|
|
1903
1907
|
/** The largest `amountIn` the route's orders could take together, each at its own price. */
|
|
1904
1908
|
maxFillableIn: bigint;
|
|
@@ -1924,6 +1928,11 @@ interface PessimisticQuoteIntentResult {
|
|
|
1924
1928
|
priceBucket: bigint | null;
|
|
1925
1929
|
/** The destination's protocol fee in basis points, already taken off `amountOut`. */
|
|
1926
1930
|
slippageBps: number;
|
|
1931
|
+
/**
|
|
1932
|
+
* False when the route cannot fill the trade: `amountOut` is 0, `rate` and `priceBucket` are
|
|
1933
|
+
* null, and `maxFillableIn` says how much it could. For an exact output, `amountIn` is then the
|
|
1934
|
+
* input the SDK last tried.
|
|
1935
|
+
*/
|
|
1927
1936
|
fillable: boolean;
|
|
1928
1937
|
/** The largest `amountIn` this quote could fill: any one level at its worst price, or the whole route at its worst. */
|
|
1929
1938
|
maxFillableIn: bigint;
|
|
@@ -2005,25 +2014,6 @@ declare class OrderbookQuoteNotConvergedError extends Error {
|
|
|
2005
2014
|
/** The last input quoted, in the source token's raw units. */
|
|
2006
2015
|
lastAmountIn: bigint);
|
|
2007
2016
|
}
|
|
2008
|
-
/** The orderbook cannot fill the requested amount on this route. */
|
|
2009
|
-
declare class InsufficientOrderbookLiquidityError extends Error {
|
|
2010
|
-
readonly route: {
|
|
2011
|
-
tokenIn: string;
|
|
2012
|
-
tokenOut: string;
|
|
2013
|
-
sourceChain: string;
|
|
2014
|
-
destinationChain: string;
|
|
2015
|
-
};
|
|
2016
|
-
/** The largest `amountIn` the route can fill, in the source token's raw units. */
|
|
2017
|
-
readonly maxFillableIn: bigint;
|
|
2018
|
-
constructor(route: {
|
|
2019
|
-
tokenIn: string;
|
|
2020
|
-
tokenOut: string;
|
|
2021
|
-
sourceChain: string;
|
|
2022
|
-
destinationChain: string;
|
|
2023
|
-
},
|
|
2024
|
-
/** The largest `amountIn` the route can fill, in the source token's raw units. */
|
|
2025
|
-
maxFillableIn: bigint);
|
|
2026
|
-
}
|
|
2027
2017
|
|
|
2028
2018
|
/**
|
|
2029
2019
|
* High-level facade for the IntentGatewayV2 protocol.
|
|
@@ -2133,9 +2123,10 @@ declare class IntentGateway {
|
|
|
2133
2123
|
*
|
|
2134
2124
|
* Every `amountOut` already has the destination's protocol fee taken off. For
|
|
2135
2125
|
* an exact output, the quote is for an input that delivers `amountOut`. A
|
|
2126
|
+
* route that cannot fill the trade returns the orderbook's quote with
|
|
2127
|
+
* `fillable: false` and its `maxFillableIn`, rather than throwing. A
|
|
2136
2128
|
* cross-chain route only counts orders whose solvers accept the source chain.
|
|
2137
2129
|
*
|
|
2138
|
-
* @throws {InsufficientOrderbookLiquidityError} When the route cannot fill the amount.
|
|
2139
2130
|
* @throws {OrderbookQuoteNotConvergedError} When an exact-output quote does not settle on an input.
|
|
2140
2131
|
* @throws {OrderbookRequestError} When the orderbook is unreachable or trades no book for the pair.
|
|
2141
2132
|
*/
|
|
@@ -2406,6 +2397,14 @@ declare class IntentGateway {
|
|
|
2406
2397
|
* @returns A {@link FillOrderEstimate} with all gas components.
|
|
2407
2398
|
*/
|
|
2408
2399
|
estimateFillOrder(params: EstimateFillOrderParams): Promise<FillOrderEstimate>;
|
|
2400
|
+
/**
|
|
2401
|
+
* Asks the bundler for the `preVerificationGas` of a bid as it will be signed, priced at
|
|
2402
|
+
* the gas price its bundle pays. Call it with the final calldata and `paymasterAndData`,
|
|
2403
|
+
* before {@link prepareSubmitBid} signs the op.
|
|
2404
|
+
*
|
|
2405
|
+
* Delegates to {@link GasEstimator.estimateBidPreVerificationGas}.
|
|
2406
|
+
*/
|
|
2407
|
+
estimateBidPreVerificationGas(params: BidPreVerificationGasParams): Promise<bigint>;
|
|
2409
2408
|
/**
|
|
2410
2409
|
* Quotes the solver fee for an order using the same policy {@link execute} /
|
|
2411
2410
|
* {@link executeBest} apply when `order.fees` is `0n`.
|
|
@@ -6456,4 +6455,4 @@ declare function teleport(teleport_param: {
|
|
|
6456
6455
|
extrinsics?: Array<SubmittableExtrinsic<"promise", ISubmittableResult>>;
|
|
6457
6456
|
}): Promise<ReadableStream<HyperbridgeTxEvents>>;
|
|
6458
6457
|
|
|
6459
|
-
export { ADDRESS_ZERO, AssetTeleported, type AvailableLiquidity, Bid, type BridgeParams, type BridgeStep, type BundlerGasEstimate, BundlerMethod, type BuyAndSellRates, CONTRACT_VERSION_ABI, type CancelEvent, CancelOrderOptions, CancelQuote, ChainConfigService, Chains, ClientConfig, ConfiguredAssetSymbol, CryptoUtils, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, type DecodedFillOrder, DecodedOrderPlacedLog, DecodedPostRequestEvent, DecodedPostResponseEvent, ERC20Method, ERC7821Call, ERC7821_BATCH_MODE, EstimateFillOrderParams, EstimateGasCallData, EvmChain, type EvmChainParams, ABI as EvmHostABI, EvmLanguage, FILL_ORDER_SELECTOR, FillOptions, FillOrderEstimate, FillerBid, GetRequestWithStatus, HexString, HyperFungibleToken, HyperFungibleTokenABI, HyperFxOrderbook, type HyperbridgeTxEvents, IChain, IEvmChain, IEvmConfig, IGetRequest, IIsmpMessage, IMessage, IPharosConfig, IPolkadotHubConfig, IPostRequest, IProof, IndexerQueryClient,
|
|
6458
|
+
export { ADDRESS_ZERO, AssetTeleported, type AvailableLiquidity, Bid, BidPreVerificationGasParams, type BridgeParams, type BridgeStep, type BundlerGasEstimate, BundlerMethod, type BuyAndSellRates, CONTRACT_VERSION_ABI, type CancelEvent, CancelOrderOptions, CancelQuote, ChainConfigService, Chains, ClientConfig, ConfiguredAssetSymbol, CryptoUtils, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, type DecodedFillOrder, DecodedOrderPlacedLog, DecodedPostRequestEvent, DecodedPostResponseEvent, ERC20Method, ERC7821Call, ERC7821_BATCH_MODE, EstimateFillOrderParams, EstimateGasCallData, EvmChain, type EvmChainParams, ABI as EvmHostABI, EvmLanguage, FILL_ORDER_SELECTOR, FillOptions, FillOrderEstimate, FillerBid, GetRequestWithStatus, HexString, HyperFungibleToken, HyperFungibleTokenABI, HyperFxOrderbook, type HyperbridgeTxEvents, IChain, IEvmChain, IEvmConfig, IGetRequest, IIsmpMessage, IMessage, IPharosConfig, IPolkadotHubConfig, IPostRequest, IProof, IndexerQueryClient, IntentGateway, type IntentGatewayContext, IntentOrderStatusUpdate, type IntentQuoteLeg, IntentsCoprocessor, IsmpClient, MOCK_ADDRESS, ORDERBOOK_DECIMALS, ORDERBOOK_QUERIES, ORDERBOOK_URLS, ORDER_V2_PARAM_TYPE, Order, OrderFeesQuote, OrderStatus, OrderStatusChecker, OrderWithStatus, type OrderbookBook, type OrderbookLevelQuote, type OrderbookQuoteFill, OrderbookQuoteNotConvergedError, type OrderbookRate, OrderbookRequestError, type OrderbookRoute, type OrderbookRouteKind, type OrderbookRouteLiquidity, type OrderbookSide, type OrderbookSwapQuote, type OrderbookTopOfBook, PACKED_USEROP_TYPEHASH, PLACE_ORDER_SELECTOR, PackedUserOperation, type Params, type PessimisticQuoteIntentResult, PharosChain, type PharosChainParams, PolkadotHubChain, type PolkadotHubChainParams, PostRequestTimeoutStatus, PostRequestWithStatus, QueryBuyAndSellRatesParams, type QuoteIntentParams, type QuoteIntentResult, type QuoteNativeResult, type QuoteResult, type QuoteUniswapParams, type QuoteUniswapResult, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, type RateFillPreview, RequestStatusWithMetadata, ResponseCommitmentWithValues, ResumeIntentOrderOptions, RetryConfig, SELECT_SOLVER_TYPEHASH, STATE_COMMITMENTS_SLOT, SUPPORTED_INTENTS_VERSION, SelectBidResult, StateMachineHeight, StateMachineIdParams, StateMachineUpdate, SubmitBidOptions, SubstrateChain, Swap, TESTNET_CHAINS, type TeleportParams, TeleportStatus, TokenGateway, TokenGatewayAssetTeleportedWithStatus, TokenInfo, Transaction, TronChain, type TronChainParams, USE_ETHERSCAN_CHAINS, type UniswapProtocol, type UniswapQuote, type UniswapQuoteToken, type UniswapTradeType, UnsupportedLiquidityAssetError, UnsupportedLiquidityChainError, WrappedHyperFungibleTokenABI, type XcmGatewayParams, __test, adjustDecimals, assertGatewayRelease, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, createEvmChain, createQueryClient, decodeFillOrder, encodeFillOrder, encodeStateMachineId, encodeWithdrawalRequest, estimateGasForPost, fetchPrice, fetchSourceProof, generateRootWithProof, getContractCallInput, getContractCallInputs, getGasPriceFromEtherscan, getOrFetchStorageSlot, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, hexToString, isCanonicalEvmToken, maxBigInt, normalizeAddressForEvmBytes32, normalizeAddressForStateMachine, normalizeEvmAddress, normalizeEvmChainId, normalizeStateMachineId, orderCommitment, orderbookUrlFor, parseStateMachineId, postRequestCommitment, previewRateFill, queryAssetTeleported, queryGetRequest, queryPostRequest, quoteUniswap, readLegEscrow, readLegPartialFill, requestCommitmentKey, responseCommitmentKey, retryPromise, supportsRateFills, teleport, teleportDot, transformOrderForContract };
|
package/dist/node/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as IChain, H as HexString, a as IEvmConfig, C as ChainConfigService, b as IMessage, S as StateMachineIdParams, c as StateMachineHeight, d as IIsmpMessage, e as IPostRequest, f as IGetRequest, O as Order, E as EstimateGasCallData, R as RetryConfig, g as IPolkadotHubConfig, h as IPharosConfig, i as StateMachineUpdate, P as PostRequestWithStatus, G as GetRequestWithStatus, j as ResponseCommitmentWithValues, k as RequestStatusWithMetadata, l as PostRequestTimeoutStatus, m as SubstrateChain, n as ClientConfig, o as IndexerQueryClient, A as AssetTeleported, T as Transaction, p as IProof, q as IEvmChain, r as IntentsCoprocessor, s as Chains, t as ConfiguredAssetSymbol, Q as QueryBuyAndSellRatesParams, u as IntentOrderStatusUpdate, v as SelectBidResult, w as ResumeIntentOrderOptions, x as CancelOrderOptions, y as CancelQuote, z as SubmitBidOptions, B as PackedUserOperation, F as FillerBid, D as Bid, J as EstimateFillOrderParams, K as FillOrderEstimate, L as
|
|
2
|
-
export {
|
|
1
|
+
import { I as IChain, H as HexString, a as IEvmConfig, C as ChainConfigService, b as IMessage, S as StateMachineIdParams, c as StateMachineHeight, d as IIsmpMessage, e as IPostRequest, f as IGetRequest, O as Order, E as EstimateGasCallData, R as RetryConfig, g as IPolkadotHubConfig, h as IPharosConfig, i as StateMachineUpdate, P as PostRequestWithStatus, G as GetRequestWithStatus, j as ResponseCommitmentWithValues, k as RequestStatusWithMetadata, l as PostRequestTimeoutStatus, m as SubstrateChain, n as ClientConfig, o as IndexerQueryClient, A as AssetTeleported, T as Transaction, p as IProof, q as IEvmChain, r as IntentsCoprocessor, s as Chains, t as ConfiguredAssetSymbol, Q as QueryBuyAndSellRatesParams, u as IntentOrderStatusUpdate, v as SelectBidResult, w as ResumeIntentOrderOptions, x as CancelOrderOptions, y as CancelQuote, z as SubmitBidOptions, B as PackedUserOperation, F as FillerBid, D as Bid, J as EstimateFillOrderParams, K as FillOrderEstimate, L as BidPreVerificationGasParams, M as OrderFeesQuote, N as ERC7821Call, U as TokenInfo, V as OrderWithStatus, W as OrderStatus, X as FillOptions, Y as TokenGatewayAssetTeleportedWithStatus, Z as TeleportStatus, _ as DecodedOrderPlacedLog, $ as DecodedPostRequestEvent, a0 as DecodedPostResponseEvent } from './intents-helpers-D0JcQNDm.js';
|
|
2
|
+
export { a1 as AllStatusKey, a2 as AssetTeleportedResponse, a3 as BidStorageEntry, a4 as BidSubmissionResult, a5 as BlockMetadata, a6 as BytesLikeHex, a7 as CancelOptions, a8 as ChainConfig, a9 as ChainConfigData, aa as ConfiguredAssetSymbolInput, ab as Deployment, ac as DispatchGet, ad as DispatchInfo, ae as DispatchPost, af as Erc4626VaultConfigData, ag as ExecuteIntentOrderOptions, ah as ExecutionResult, ai as FillerConfig, aj as GetRequestResponse, ak as GetResponseByRequestIdResponse, al as GetResponseStorageValues, am as HostParams, an as HyperClientStatus, ao as IBatchConsensusAndGetResponseMessage, ap as IBatchConsensusAndPostRequestMessage, aq as IConfig, ar as IConsensusMessage, as as IGetRequestMessage, at as IGetResponse, au as IGetResponseMessage, av as IHyperbridgeConfig, aw as INCLUSION_TIMEOUT_MS, ax as IPostResponse, ay as IRequestMessage, az as ISubstrateConfig, aA as ITimeoutPostRequestMessage, aB as IntentGatewayABI, aC as IntentGatewayParams, aD as IntentOrderStatus, aE as IntentOrderStatusKey, aF as IsmpRequest, aG as MAX_DECLARED_ENTRIES, aH as OrderResponse, aI as OrderStatusMetadata, aJ as PERMIT2_SPONSORSHIP_BYTES, aK as PaymentInfo, aL as PhantomBidDeclaration, aM as PhantomBidPaymasterAndData, aN as PhantomBidSponsorship, aO as PostRequestStatus, aP as RequestBody, aQ as RequestCommitment, aR as RequestKind, aS as RequestResponse, aT as RequestStatus, aU as RequestStatusKey, aV as RpcBidInfo, aW as SelectOptions, aX as SigningAccount, aY as StateMachineId, aZ as StateMachineResponse, a_ as StorageFacade, a$ as TimeoutStatus, b0 as TimeoutStatusKey, b1 as TokenGatewayAssetTeleportedResponse, b2 as TokenPrice, b3 as TokenPricesResponse, b4 as chainConfigs, b5 as convertCodecToIGetRequest, b6 as convertCodecToIProof, b7 as convertIGetRequestToCodec, b8 as convertIProofToCodec, b9 as convertStateIdToStateMachineId, ba as convertStateMachineEnumToString, bb as convertStateMachineIdToEnum, bc as decodeAcceptedSourceChains, bd as decodeERC7821ExecuteBatch, be as decodePhantomBidDeclaration, bf as decodePhantomBidPaymasterAndData, bg as decodeUserOpScale, bh as deriveHttpUrl, bi as encodeAcceptedSourceChains, bj as encodeERC7821ExecuteBatch, bk as encodeISMPMessage, bl as encodePhantomBidDeclaration, bm as encodePhantomBidPaymasterAndData, bn as encodeUserOpScale, bo as getChainId, bp as getConfigByStateMachineId, bq as getViemChain, br as hyperbridgeAddress, bs as pharosAtlantic, bt as pharosMainnet, bu as polkadotAssetHubPaseo, bv as polkadotHubMainnet, bw as poolSlug, bx as sortPoolSymbols, by as tronChainIds, bz as tronNile } from './intents-helpers-D0JcQNDm.js';
|
|
3
3
|
import { ConsolaInstance } from 'consola';
|
|
4
4
|
import { GraphQLClient } from 'graphql-request';
|
|
5
5
|
import { PublicClient, TransactionReceipt, Hex, Address } from 'viem';
|
|
@@ -1899,6 +1899,10 @@ interface QuoteIntentResult {
|
|
|
1899
1899
|
amountIn: bigint;
|
|
1900
1900
|
/** The destination's protocol fee in basis points, already taken off every leg's `amountOut`. */
|
|
1901
1901
|
slippageBps: number;
|
|
1902
|
+
/**
|
|
1903
|
+
* False when the route cannot fill the trade: `legs` is empty and `maxFillableIn` says how much
|
|
1904
|
+
* it could. For an exact output, `amountIn` is then the input the SDK last tried.
|
|
1905
|
+
*/
|
|
1902
1906
|
fillable: boolean;
|
|
1903
1907
|
/** The largest `amountIn` the route's orders could take together, each at its own price. */
|
|
1904
1908
|
maxFillableIn: bigint;
|
|
@@ -1924,6 +1928,11 @@ interface PessimisticQuoteIntentResult {
|
|
|
1924
1928
|
priceBucket: bigint | null;
|
|
1925
1929
|
/** The destination's protocol fee in basis points, already taken off `amountOut`. */
|
|
1926
1930
|
slippageBps: number;
|
|
1931
|
+
/**
|
|
1932
|
+
* False when the route cannot fill the trade: `amountOut` is 0, `rate` and `priceBucket` are
|
|
1933
|
+
* null, and `maxFillableIn` says how much it could. For an exact output, `amountIn` is then the
|
|
1934
|
+
* input the SDK last tried.
|
|
1935
|
+
*/
|
|
1927
1936
|
fillable: boolean;
|
|
1928
1937
|
/** The largest `amountIn` this quote could fill: any one level at its worst price, or the whole route at its worst. */
|
|
1929
1938
|
maxFillableIn: bigint;
|
|
@@ -2005,25 +2014,6 @@ declare class OrderbookQuoteNotConvergedError extends Error {
|
|
|
2005
2014
|
/** The last input quoted, in the source token's raw units. */
|
|
2006
2015
|
lastAmountIn: bigint);
|
|
2007
2016
|
}
|
|
2008
|
-
/** The orderbook cannot fill the requested amount on this route. */
|
|
2009
|
-
declare class InsufficientOrderbookLiquidityError extends Error {
|
|
2010
|
-
readonly route: {
|
|
2011
|
-
tokenIn: string;
|
|
2012
|
-
tokenOut: string;
|
|
2013
|
-
sourceChain: string;
|
|
2014
|
-
destinationChain: string;
|
|
2015
|
-
};
|
|
2016
|
-
/** The largest `amountIn` the route can fill, in the source token's raw units. */
|
|
2017
|
-
readonly maxFillableIn: bigint;
|
|
2018
|
-
constructor(route: {
|
|
2019
|
-
tokenIn: string;
|
|
2020
|
-
tokenOut: string;
|
|
2021
|
-
sourceChain: string;
|
|
2022
|
-
destinationChain: string;
|
|
2023
|
-
},
|
|
2024
|
-
/** The largest `amountIn` the route can fill, in the source token's raw units. */
|
|
2025
|
-
maxFillableIn: bigint);
|
|
2026
|
-
}
|
|
2027
2017
|
|
|
2028
2018
|
/**
|
|
2029
2019
|
* High-level facade for the IntentGatewayV2 protocol.
|
|
@@ -2133,9 +2123,10 @@ declare class IntentGateway {
|
|
|
2133
2123
|
*
|
|
2134
2124
|
* Every `amountOut` already has the destination's protocol fee taken off. For
|
|
2135
2125
|
* an exact output, the quote is for an input that delivers `amountOut`. A
|
|
2126
|
+
* route that cannot fill the trade returns the orderbook's quote with
|
|
2127
|
+
* `fillable: false` and its `maxFillableIn`, rather than throwing. A
|
|
2136
2128
|
* cross-chain route only counts orders whose solvers accept the source chain.
|
|
2137
2129
|
*
|
|
2138
|
-
* @throws {InsufficientOrderbookLiquidityError} When the route cannot fill the amount.
|
|
2139
2130
|
* @throws {OrderbookQuoteNotConvergedError} When an exact-output quote does not settle on an input.
|
|
2140
2131
|
* @throws {OrderbookRequestError} When the orderbook is unreachable or trades no book for the pair.
|
|
2141
2132
|
*/
|
|
@@ -2406,6 +2397,14 @@ declare class IntentGateway {
|
|
|
2406
2397
|
* @returns A {@link FillOrderEstimate} with all gas components.
|
|
2407
2398
|
*/
|
|
2408
2399
|
estimateFillOrder(params: EstimateFillOrderParams): Promise<FillOrderEstimate>;
|
|
2400
|
+
/**
|
|
2401
|
+
* Asks the bundler for the `preVerificationGas` of a bid as it will be signed, priced at
|
|
2402
|
+
* the gas price its bundle pays. Call it with the final calldata and `paymasterAndData`,
|
|
2403
|
+
* before {@link prepareSubmitBid} signs the op.
|
|
2404
|
+
*
|
|
2405
|
+
* Delegates to {@link GasEstimator.estimateBidPreVerificationGas}.
|
|
2406
|
+
*/
|
|
2407
|
+
estimateBidPreVerificationGas(params: BidPreVerificationGasParams): Promise<bigint>;
|
|
2409
2408
|
/**
|
|
2410
2409
|
* Quotes the solver fee for an order using the same policy {@link execute} /
|
|
2411
2410
|
* {@link executeBest} apply when `order.fees` is `0n`.
|
|
@@ -6456,4 +6455,4 @@ declare function teleport(teleport_param: {
|
|
|
6456
6455
|
extrinsics?: Array<SubmittableExtrinsic<"promise", ISubmittableResult>>;
|
|
6457
6456
|
}): Promise<ReadableStream<HyperbridgeTxEvents>>;
|
|
6458
6457
|
|
|
6459
|
-
export { ADDRESS_ZERO, AssetTeleported, type AvailableLiquidity, Bid, type BridgeParams, type BridgeStep, type BundlerGasEstimate, BundlerMethod, type BuyAndSellRates, CONTRACT_VERSION_ABI, type CancelEvent, CancelOrderOptions, CancelQuote, ChainConfigService, Chains, ClientConfig, ConfiguredAssetSymbol, CryptoUtils, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, type DecodedFillOrder, DecodedOrderPlacedLog, DecodedPostRequestEvent, DecodedPostResponseEvent, ERC20Method, ERC7821Call, ERC7821_BATCH_MODE, EstimateFillOrderParams, EstimateGasCallData, EvmChain, type EvmChainParams, ABI as EvmHostABI, EvmLanguage, FILL_ORDER_SELECTOR, FillOptions, FillOrderEstimate, FillerBid, GetRequestWithStatus, HexString, HyperFungibleToken, HyperFungibleTokenABI, HyperFxOrderbook, type HyperbridgeTxEvents, IChain, IEvmChain, IEvmConfig, IGetRequest, IIsmpMessage, IMessage, IPharosConfig, IPolkadotHubConfig, IPostRequest, IProof, IndexerQueryClient,
|
|
6458
|
+
export { ADDRESS_ZERO, AssetTeleported, type AvailableLiquidity, Bid, BidPreVerificationGasParams, type BridgeParams, type BridgeStep, type BundlerGasEstimate, BundlerMethod, type BuyAndSellRates, CONTRACT_VERSION_ABI, type CancelEvent, CancelOrderOptions, CancelQuote, ChainConfigService, Chains, ClientConfig, ConfiguredAssetSymbol, CryptoUtils, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, type DecodedFillOrder, DecodedOrderPlacedLog, DecodedPostRequestEvent, DecodedPostResponseEvent, ERC20Method, ERC7821Call, ERC7821_BATCH_MODE, EstimateFillOrderParams, EstimateGasCallData, EvmChain, type EvmChainParams, ABI as EvmHostABI, EvmLanguage, FILL_ORDER_SELECTOR, FillOptions, FillOrderEstimate, FillerBid, GetRequestWithStatus, HexString, HyperFungibleToken, HyperFungibleTokenABI, HyperFxOrderbook, type HyperbridgeTxEvents, IChain, IEvmChain, IEvmConfig, IGetRequest, IIsmpMessage, IMessage, IPharosConfig, IPolkadotHubConfig, IPostRequest, IProof, IndexerQueryClient, IntentGateway, type IntentGatewayContext, IntentOrderStatusUpdate, type IntentQuoteLeg, IntentsCoprocessor, IsmpClient, MOCK_ADDRESS, ORDERBOOK_DECIMALS, ORDERBOOK_QUERIES, ORDERBOOK_URLS, ORDER_V2_PARAM_TYPE, Order, OrderFeesQuote, OrderStatus, OrderStatusChecker, OrderWithStatus, type OrderbookBook, type OrderbookLevelQuote, type OrderbookQuoteFill, OrderbookQuoteNotConvergedError, type OrderbookRate, OrderbookRequestError, type OrderbookRoute, type OrderbookRouteKind, type OrderbookRouteLiquidity, type OrderbookSide, type OrderbookSwapQuote, type OrderbookTopOfBook, PACKED_USEROP_TYPEHASH, PLACE_ORDER_SELECTOR, PackedUserOperation, type Params, type PessimisticQuoteIntentResult, PharosChain, type PharosChainParams, PolkadotHubChain, type PolkadotHubChainParams, PostRequestTimeoutStatus, PostRequestWithStatus, QueryBuyAndSellRatesParams, type QuoteIntentParams, type QuoteIntentResult, type QuoteNativeResult, type QuoteResult, type QuoteUniswapParams, type QuoteUniswapResult, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, type RateFillPreview, RequestStatusWithMetadata, ResponseCommitmentWithValues, ResumeIntentOrderOptions, RetryConfig, SELECT_SOLVER_TYPEHASH, STATE_COMMITMENTS_SLOT, SUPPORTED_INTENTS_VERSION, SelectBidResult, StateMachineHeight, StateMachineIdParams, StateMachineUpdate, SubmitBidOptions, SubstrateChain, Swap, TESTNET_CHAINS, type TeleportParams, TeleportStatus, TokenGateway, TokenGatewayAssetTeleportedWithStatus, TokenInfo, Transaction, TronChain, type TronChainParams, USE_ETHERSCAN_CHAINS, type UniswapProtocol, type UniswapQuote, type UniswapQuoteToken, type UniswapTradeType, UnsupportedLiquidityAssetError, UnsupportedLiquidityChainError, WrappedHyperFungibleTokenABI, type XcmGatewayParams, __test, adjustDecimals, assertGatewayRelease, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, createEvmChain, createQueryClient, decodeFillOrder, encodeFillOrder, encodeStateMachineId, encodeWithdrawalRequest, estimateGasForPost, fetchPrice, fetchSourceProof, generateRootWithProof, getContractCallInput, getContractCallInputs, getGasPriceFromEtherscan, getOrFetchStorageSlot, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, hexToString, isCanonicalEvmToken, maxBigInt, normalizeAddressForEvmBytes32, normalizeAddressForStateMachine, normalizeEvmAddress, normalizeEvmChainId, normalizeStateMachineId, orderCommitment, orderbookUrlFor, parseStateMachineId, postRequestCommitment, previewRateFill, queryAssetTeleported, queryGetRequest, queryPostRequest, quoteUniswap, readLegEscrow, readLegPartialFill, requestCommitmentKey, responseCommitmentKey, retryPromise, supportsRateFills, teleport, teleportDot, transformOrderForContract };
|
package/dist/node/index.js
CHANGED
|
@@ -18253,6 +18253,16 @@ var NO_BUNDLER_FILL_GAS_BASE = 700000n;
|
|
|
18253
18253
|
var NO_BUNDLER_FILL_GAS_PER_OUTPUT = 150000n;
|
|
18254
18254
|
var NO_BUNDLER_PAYMASTER_VERIFICATION_GAS = 250000n;
|
|
18255
18255
|
var NO_BUNDLER_PAYMASTER_POST_OP_GAS = 100000n;
|
|
18256
|
+
var BID_PVG_ESTIMATION_ACCOUNT_CODE = "0x60003560e01c631626ba7e1460145760206000f35b631626ba7e60e01b60005260206000f3";
|
|
18257
|
+
var SELECTED_BID_SIGNATURE_BYTES = 32 + 65 + 65;
|
|
18258
|
+
var BID_PVG_HEADROOM_PERCENT = 10n;
|
|
18259
|
+
var ESCROW_MAPPING_SLOT = 9n;
|
|
18260
|
+
function escrowSlot(commitment, leg) {
|
|
18261
|
+
const byCommitment = keccak256(
|
|
18262
|
+
encodeAbiParameters([{ type: "bytes32" }, { type: "uint256" }], [commitment, ESCROW_MAPPING_SLOT])
|
|
18263
|
+
);
|
|
18264
|
+
return keccak256(encodeAbiParameters([{ type: "uint256" }, { type: "bytes32" }], [BigInt(leg), byCommitment]));
|
|
18265
|
+
}
|
|
18256
18266
|
var GasEstimator = class {
|
|
18257
18267
|
/**
|
|
18258
18268
|
* @param ctx - Shared IntentsV2 context providing the source and destination
|
|
@@ -18331,6 +18341,7 @@ var GasEstimator = class {
|
|
|
18331
18341
|
assetsForOverrides.push({ token: feeTokenAsBytes32, amount: 0n });
|
|
18332
18342
|
}
|
|
18333
18343
|
const isSameChain = souceStateMachineId === destStateMachineId;
|
|
18344
|
+
const commitment = orderCommitment(order);
|
|
18334
18345
|
const [stateOverridesResult, crossChainFees] = await Promise.all([
|
|
18335
18346
|
this.ctx.bundlerUrl ? this.buildStateOverride({
|
|
18336
18347
|
accountAddress: solverAccountAddress,
|
|
@@ -18338,7 +18349,16 @@ var GasEstimator = class {
|
|
|
18338
18349
|
outputAssets: assetsForOverrides,
|
|
18339
18350
|
spenderAddress: intentGatewayV2Address,
|
|
18340
18351
|
intentGatewayV2Address,
|
|
18341
|
-
entryPointAddress
|
|
18352
|
+
entryPointAddress,
|
|
18353
|
+
// A fee quote runs before the order is placed, so nothing is escrowed under
|
|
18354
|
+
// its commitment yet. Cross-chain fills release escrow on the source chain.
|
|
18355
|
+
escrow: isSameChain ? {
|
|
18356
|
+
commitment,
|
|
18357
|
+
inputs: order.inputs.map((input) => ({
|
|
18358
|
+
token: normalizeAddressForEvmBytes32(input.token),
|
|
18359
|
+
amount: input.amount
|
|
18360
|
+
}))
|
|
18361
|
+
} : void 0
|
|
18342
18362
|
}) : Promise.resolve({ viem: [], bundler: {} }),
|
|
18343
18363
|
isSameChain ? Promise.resolve({ postRequestFee: 0n, relayerFeeInSourceFeeToken: 0n }) : this.estimateCrossChainFees(
|
|
18344
18364
|
sourceFeeToken,
|
|
@@ -18367,10 +18387,8 @@ var GasEstimator = class {
|
|
|
18367
18387
|
const maxFeeBumpPercent = params.maxFeePerGasBumpPercent ?? 10;
|
|
18368
18388
|
let maxPriorityFeePerGas = gasPrice + gasPrice * BigInt(priorityFeeBumpPercent) / 100n;
|
|
18369
18389
|
let maxFeePerGas = gasPrice + gasPrice * BigInt(maxFeeBumpPercent) / 100n;
|
|
18370
|
-
const orderForEstimation = { ...order, session: solverAccountAddress };
|
|
18371
|
-
const commitment = orderCommitment(orderForEstimation);
|
|
18372
18390
|
await assertGatewayRelease(this.ctx.dest.client, intentGatewayV2Address);
|
|
18373
|
-
const fillOrderCalldata = encodeFillOrder(transformOrderForContract(
|
|
18391
|
+
const fillOrderCalldata = encodeFillOrder(transformOrderForContract(order), fillOptions);
|
|
18374
18392
|
let callGasLimit = 500000n;
|
|
18375
18393
|
let verificationGasLimit = 100000n;
|
|
18376
18394
|
let preVerificationGas = 100000n;
|
|
@@ -18382,7 +18400,7 @@ var GasEstimator = class {
|
|
|
18382
18400
|
...params.prependCalls ?? [],
|
|
18383
18401
|
{ target: intentGatewayV2Address, value: totalNativeValue, data: fillOrderCalldata }
|
|
18384
18402
|
]);
|
|
18385
|
-
const accountGasLimits = CryptoUtils.packGasLimits(
|
|
18403
|
+
const accountGasLimits = CryptoUtils.packGasLimits(0n, 0n);
|
|
18386
18404
|
const gasFees = CryptoUtils.packGasFees(maxPriorityFeePerGas, maxFeePerGas);
|
|
18387
18405
|
const nonce = 0n;
|
|
18388
18406
|
const preliminaryUserOp = {
|
|
@@ -18391,7 +18409,7 @@ var GasEstimator = class {
|
|
|
18391
18409
|
initCode: "0x",
|
|
18392
18410
|
callData,
|
|
18393
18411
|
accountGasLimits,
|
|
18394
|
-
preVerificationGas:
|
|
18412
|
+
preVerificationGas: 0n,
|
|
18395
18413
|
gasFees,
|
|
18396
18414
|
paymasterAndData: "0x",
|
|
18397
18415
|
signature: "0x"
|
|
@@ -18521,6 +18539,53 @@ var GasEstimator = class {
|
|
|
18521
18539
|
inputs
|
|
18522
18540
|
};
|
|
18523
18541
|
}
|
|
18542
|
+
/**
|
|
18543
|
+
* Asks the bundler for the `preVerificationGas` of the bid UserOperation that will
|
|
18544
|
+
* actually be signed, with every funding call, approval and signature byte in it.
|
|
18545
|
+
*
|
|
18546
|
+
* On an L2, `preVerificationGas` also pays the L1 data fee for the op's bytes, a fixed
|
|
18547
|
+
* amount of wei that the bundler converts to gas at the price the op pays. A bundler
|
|
18548
|
+
* admits an op priced at its `maxFeePerGas`, but bundles it at the base fee plus its
|
|
18549
|
+
* priority fee, where the same wei costs more gas. An op sized only for admission is
|
|
18550
|
+
* accepted and then skipped in every bundle until it expires. The estimate is taken
|
|
18551
|
+
* at the bundle's price: the latest base fee plus the op's priority fee, capped at its
|
|
18552
|
+
* `maxFeePerGas`.
|
|
18553
|
+
*
|
|
18554
|
+
* The solver account's code is overridden with {@link BID_PVG_ESTIMATION_ACCOUNT_CODE}
|
|
18555
|
+
* for the call, so only the bytes are priced and the fill itself is not simulated.
|
|
18556
|
+
*
|
|
18557
|
+
* @param params - The bid's fields as they will be signed.
|
|
18558
|
+
* @returns The `preVerificationGas` to sign, with {@link BID_PVG_HEADROOM_PERCENT} added.
|
|
18559
|
+
* @throws If no bundler is configured or the bundler rejects the estimate.
|
|
18560
|
+
*/
|
|
18561
|
+
async estimateBidPreVerificationGas(params) {
|
|
18562
|
+
const { solverAccount, maxFeePerGas, maxPriorityFeePerGas } = params;
|
|
18563
|
+
const latestBlock = await this.ctx.dest.client.getBlock({ blockTag: "latest" });
|
|
18564
|
+
const baseFeePerGas = latestBlock.baseFeePerGas;
|
|
18565
|
+
const bundlePrice = baseFeePerGas == null || baseFeePerGas + maxPriorityFeePerGas > maxFeePerGas ? maxFeePerGas : baseFeePerGas + maxPriorityFeePerGas;
|
|
18566
|
+
const priorityFee = maxPriorityFeePerGas < bundlePrice ? maxPriorityFeePerGas : bundlePrice;
|
|
18567
|
+
const userOp = {
|
|
18568
|
+
sender: solverAccount,
|
|
18569
|
+
nonce: params.nonce,
|
|
18570
|
+
initCode: "0x",
|
|
18571
|
+
callData: params.callData,
|
|
18572
|
+
accountGasLimits: CryptoUtils.packGasLimits(params.verificationGasLimit, params.callGasLimit),
|
|
18573
|
+
// Bundlers return a non-zero preVerificationGas as given rather than estimating it.
|
|
18574
|
+
preVerificationGas: 0n,
|
|
18575
|
+
gasFees: CryptoUtils.packGasFees(priorityFee, bundlePrice),
|
|
18576
|
+
paymasterAndData: params.paymasterAndData ?? "0x",
|
|
18577
|
+
signature: `0x${"ff".repeat(SELECTED_BID_SIGNATURE_BYTES)}`
|
|
18578
|
+
};
|
|
18579
|
+
const estimate = await this.crypto.sendBundler(
|
|
18580
|
+
BundlerMethod.ETH_ESTIMATE_USER_OPERATION_GAS,
|
|
18581
|
+
[
|
|
18582
|
+
CryptoUtils.prepareBundlerCall(userOp),
|
|
18583
|
+
params.entryPointAddress,
|
|
18584
|
+
{ [solverAccount]: { code: BID_PVG_ESTIMATION_ACCOUNT_CODE } }
|
|
18585
|
+
]
|
|
18586
|
+
);
|
|
18587
|
+
return BigInt(estimate.preVerificationGas) * (100n + BID_PVG_HEADROOM_PERCENT) / 100n;
|
|
18588
|
+
}
|
|
18524
18589
|
/**
|
|
18525
18590
|
* Estimates the cross-chain ISMP POST request fee (the relayer fee for the
|
|
18526
18591
|
* RedeemEscrow message), in both the source and destination fee tokens.
|
|
@@ -18573,20 +18638,38 @@ var GasEstimator = class {
|
|
|
18573
18638
|
* @returns An object with `viem` and `bundler` state-override collections.
|
|
18574
18639
|
*/
|
|
18575
18640
|
async buildStateOverride(params) {
|
|
18576
|
-
const {
|
|
18577
|
-
|
|
18641
|
+
const {
|
|
18642
|
+
accountAddress,
|
|
18643
|
+
chain,
|
|
18644
|
+
outputAssets,
|
|
18645
|
+
spenderAddress,
|
|
18646
|
+
intentGatewayV2Address,
|
|
18647
|
+
entryPointAddress,
|
|
18648
|
+
escrow
|
|
18649
|
+
} = params;
|
|
18650
|
+
const testValue = toHex(2n ** 128n, { size: 32 });
|
|
18578
18651
|
const viemOverrides = [];
|
|
18579
18652
|
const bundlerOverrides = {};
|
|
18580
18653
|
if (intentGatewayV2Address) {
|
|
18581
18654
|
const paramsSlot5 = pad(toHex(5n), { size: 32 });
|
|
18582
18655
|
const dispatcherAddress = this.ctx.dest.configService.getCalldispatcherAddress(chain);
|
|
18583
18656
|
const newSlot5Value = "0x" + "0".repeat(22) + "00" + dispatcherAddress.slice(2).toLowerCase();
|
|
18657
|
+
const gatewayDiffs = [{ slot: paramsSlot5, value: newSlot5Value }];
|
|
18658
|
+
for (const [leg, input] of (escrow?.inputs ?? []).entries()) {
|
|
18659
|
+
gatewayDiffs.push({
|
|
18660
|
+
slot: escrowSlot(escrow.commitment, leg),
|
|
18661
|
+
value: toHex(input.amount, { size: 32 })
|
|
18662
|
+
});
|
|
18663
|
+
}
|
|
18664
|
+
const releasesNative = escrow?.inputs.some((input) => bytes32ToBytes20(input.token) === ADDRESS_ZERO2);
|
|
18584
18665
|
viemOverrides.push({
|
|
18585
18666
|
address: intentGatewayV2Address,
|
|
18586
|
-
|
|
18667
|
+
...releasesNative ? { balance: 2n ** 128n } : {},
|
|
18668
|
+
stateDiff: gatewayDiffs
|
|
18587
18669
|
});
|
|
18588
18670
|
bundlerOverrides[intentGatewayV2Address] = {
|
|
18589
|
-
|
|
18671
|
+
...releasesNative ? { balance: testValue } : {},
|
|
18672
|
+
stateDiff: Object.fromEntries(gatewayDiffs.map(({ slot, value }) => [slot, value]))
|
|
18590
18673
|
};
|
|
18591
18674
|
}
|
|
18592
18675
|
if (entryPointAddress) {
|
|
@@ -18617,6 +18700,25 @@ var GasEstimator = class {
|
|
|
18617
18700
|
bundlerOverrides[result.address] = { stateDiff: result.bundlerStateDiffs };
|
|
18618
18701
|
}
|
|
18619
18702
|
}
|
|
18703
|
+
if (intentGatewayV2Address && escrow) {
|
|
18704
|
+
const gatewayBalances = await Promise.all(
|
|
18705
|
+
escrow.inputs.map((input) => this.tokenBalanceSlot(input.token, intentGatewayV2Address, chain))
|
|
18706
|
+
);
|
|
18707
|
+
for (const override of gatewayBalances) {
|
|
18708
|
+
if (!override) continue;
|
|
18709
|
+
const existing = viemOverrides.find((entry) => entry.address === override.address && entry.stateDiff);
|
|
18710
|
+
if (existing) existing.stateDiff.push({ slot: override.slot, value: testValue });
|
|
18711
|
+
else
|
|
18712
|
+
viemOverrides.push({
|
|
18713
|
+
address: override.address,
|
|
18714
|
+
stateDiff: [{ slot: override.slot, value: testValue }]
|
|
18715
|
+
});
|
|
18716
|
+
bundlerOverrides[override.address] = {
|
|
18717
|
+
...bundlerOverrides[override.address],
|
|
18718
|
+
stateDiff: { ...bundlerOverrides[override.address]?.stateDiff, [override.slot]: testValue }
|
|
18719
|
+
};
|
|
18720
|
+
}
|
|
18721
|
+
}
|
|
18620
18722
|
const solverAccountContract = this.ctx.dest.configService.getSolverAccountAddress(chain);
|
|
18621
18723
|
if (solverAccountContract) {
|
|
18622
18724
|
try {
|
|
@@ -18639,6 +18741,21 @@ var GasEstimator = class {
|
|
|
18639
18741
|
}
|
|
18640
18742
|
return { viem: viemOverrides, bundler: bundlerOverrides };
|
|
18641
18743
|
}
|
|
18744
|
+
/**
|
|
18745
|
+
* The balance slot of `holder` in an ERC-20 token, for overriding. `null` for the native
|
|
18746
|
+
* token or when the slot cannot be discovered.
|
|
18747
|
+
*/
|
|
18748
|
+
async tokenBalanceSlot(tokenHex, holder, chain) {
|
|
18749
|
+
const tokenAddress = bytes32ToBytes20(tokenHex);
|
|
18750
|
+
if (tokenAddress === ADDRESS_ZERO2) return null;
|
|
18751
|
+
try {
|
|
18752
|
+
const balanceData = "0x70a08231" /* BALANCE_OF */ + bytes20ToBytes32(holder).slice(2);
|
|
18753
|
+
const slot = await getOrFetchStorageSlot(this.ctx.dest.client, chain, tokenAddress, balanceData);
|
|
18754
|
+
return slot ? { address: tokenAddress, slot } : null;
|
|
18755
|
+
} catch {
|
|
18756
|
+
return null;
|
|
18757
|
+
}
|
|
18758
|
+
}
|
|
18642
18759
|
/**
|
|
18643
18760
|
* Resolves the balance and allowance storage slot overrides for a single
|
|
18644
18761
|
* ERC-20 token in parallel. Returns `null` for native-ETH tokens or when
|
|
@@ -18950,18 +19067,6 @@ var OrderbookQuoteNotConvergedError = class extends Error {
|
|
|
18950
19067
|
rounds;
|
|
18951
19068
|
lastAmountIn;
|
|
18952
19069
|
};
|
|
18953
|
-
var InsufficientOrderbookLiquidityError = class extends Error {
|
|
18954
|
-
constructor(route, maxFillableIn) {
|
|
18955
|
-
super(
|
|
18956
|
-
`The HyperFX orderbook cannot fill ${route.tokenIn} -> ${route.tokenOut} on ${route.sourceChain} -> ${route.destinationChain}; max fillable input is ${maxFillableIn} raw units`
|
|
18957
|
-
);
|
|
18958
|
-
this.route = route;
|
|
18959
|
-
this.maxFillableIn = maxFillableIn;
|
|
18960
|
-
this.name = "InsufficientOrderbookLiquidityError";
|
|
18961
|
-
}
|
|
18962
|
-
route;
|
|
18963
|
-
maxFillableIn;
|
|
18964
|
-
};
|
|
18965
19070
|
|
|
18966
19071
|
// src/protocols/intents/orderbook/market.ts
|
|
18967
19072
|
var MAX_EXACT_OUTPUT_ROUNDS = 16;
|
|
@@ -19017,8 +19122,9 @@ var OrderbookMarket = class {
|
|
|
19017
19122
|
};
|
|
19018
19123
|
}
|
|
19019
19124
|
/**
|
|
19020
|
-
* The
|
|
19021
|
-
* exact output, with the assets it trades.
|
|
19125
|
+
* The orderbook's quote for an exact input, or for the input found to deliver
|
|
19126
|
+
* an exact output, with the assets it trades. A route that cannot fill the
|
|
19127
|
+
* trade answers with an unfillable quote rather than an error.
|
|
19022
19128
|
*/
|
|
19023
19129
|
async priceIntent(params, sourceChain, destinationChain, price, totals) {
|
|
19024
19130
|
validateQuoteParams(params);
|
|
@@ -19027,10 +19133,7 @@ var OrderbookMarket = class {
|
|
|
19027
19133
|
const route = toRoute(tokenIn, tokenOut);
|
|
19028
19134
|
if (params.amountIn !== void 0) {
|
|
19029
19135
|
const quote2 = await price(route, toOrderbookAmount(params.amountIn, tokenIn.decimals));
|
|
19030
|
-
|
|
19031
|
-
if (!fillable || fromOrderbookAmount(amountOut, tokenOut.decimals) === 0n) {
|
|
19032
|
-
throw this.insufficient(route, maxFillableIn, tokenIn);
|
|
19033
|
-
}
|
|
19136
|
+
totals(quote2);
|
|
19034
19137
|
return { quote: quote2, tokenIn, tokenOut };
|
|
19035
19138
|
}
|
|
19036
19139
|
const targetOut = toOrderbookAmount(params.amountOut, tokenOut.decimals);
|
|
@@ -19092,18 +19195,21 @@ var OrderbookMarket = class {
|
|
|
19092
19195
|
* filled better than its worst rate and re-pricing the rest of `targetOut` at
|
|
19093
19196
|
* the input-to-output ratio that part filled at, until a quote delivers it.
|
|
19094
19197
|
* That ratio is the orderbook's own, with the protocol fee already taken off.
|
|
19198
|
+
*
|
|
19199
|
+
* An output the route cannot deliver is answered by quoting an input past its
|
|
19200
|
+
* `maxFillableIn`, which the orderbook serves as unfillable: the smallest such
|
|
19201
|
+
* input guessed from the best rate, or one raw unit when no order serves it.
|
|
19095
19202
|
*/
|
|
19096
19203
|
async quoteExactOutput(route, targetOut, tokenIn, price, totals) {
|
|
19097
19204
|
const liquidity = await this.orderbook().routeLiquidity(route);
|
|
19098
|
-
if (liquidity.bestRate === null) throw this.insufficient(route, 0n, tokenIn);
|
|
19099
19205
|
const inputUnit = toOrderbookAmount(1n, tokenIn.decimals);
|
|
19100
|
-
let amountIn = roundUpTo(requiredInput(liquidity.side, targetOut, liquidity.bestRate), inputUnit);
|
|
19206
|
+
let amountIn = liquidity.bestRate === null ? inputUnit : roundUpTo(requiredInput(liquidity.side, targetOut, liquidity.bestRate), inputUnit);
|
|
19101
19207
|
let lastAmountIn = amountIn;
|
|
19102
19208
|
for (let round = 0; round < MAX_EXACT_OUTPUT_ROUNDS; round++) {
|
|
19103
|
-
if (amountIn > liquidity.maxFillableIn) throw this.insufficient(route, liquidity.maxFillableIn, tokenIn);
|
|
19104
19209
|
const served = await price(route, amountIn);
|
|
19105
19210
|
const quote = totals(served);
|
|
19106
19211
|
if (quote.fillable && quote.amountOut >= targetOut) return served;
|
|
19212
|
+
if (!quote.fillable && amountIn > liquidity.maxFillableIn) return served;
|
|
19107
19213
|
lastAmountIn = amountIn;
|
|
19108
19214
|
const betterIn = quote.amountIn - quote.worstIn;
|
|
19109
19215
|
const betterOut = quote.amountOut - quote.worstOut;
|
|
@@ -19116,9 +19222,6 @@ var OrderbookMarket = class {
|
|
|
19116
19222
|
fromOrderbookAmount(lastAmountIn, tokenIn.decimals)
|
|
19117
19223
|
);
|
|
19118
19224
|
}
|
|
19119
|
-
insufficient(route, maxFillableIn, tokenIn) {
|
|
19120
|
-
return new InsufficientOrderbookLiquidityError(route, fromOrderbookAmount(maxFillableIn, tokenIn.decimals));
|
|
19121
|
-
}
|
|
19122
19225
|
assetByAddress(chain, address) {
|
|
19123
19226
|
const resolvedChain = resolveChain(chain);
|
|
19124
19227
|
return withDecimals(
|
|
@@ -19766,6 +19869,16 @@ var IntentGateway = class _IntentGateway {
|
|
|
19766
19869
|
async estimateFillOrder(params) {
|
|
19767
19870
|
return this.gasEstimator.estimateFillOrder(params);
|
|
19768
19871
|
}
|
|
19872
|
+
/**
|
|
19873
|
+
* Asks the bundler for the `preVerificationGas` of a bid as it will be signed, priced at
|
|
19874
|
+
* the gas price its bundle pays. Call it with the final calldata and `paymasterAndData`,
|
|
19875
|
+
* before {@link prepareSubmitBid} signs the op.
|
|
19876
|
+
*
|
|
19877
|
+
* Delegates to {@link GasEstimator.estimateBidPreVerificationGas}.
|
|
19878
|
+
*/
|
|
19879
|
+
async estimateBidPreVerificationGas(params) {
|
|
19880
|
+
return this.gasEstimator.estimateBidPreVerificationGas(params);
|
|
19881
|
+
}
|
|
19769
19882
|
/**
|
|
19770
19883
|
* Quotes the solver fee for an order using the same policy {@link execute} /
|
|
19771
19884
|
* {@link executeBest} apply when `order.fees` is `0n`.
|
|
@@ -24648,6 +24761,6 @@ async function teleportDot(param_) {
|
|
|
24648
24761
|
return stream;
|
|
24649
24762
|
}
|
|
24650
24763
|
|
|
24651
|
-
export { ADDRESS_ZERO2 as ADDRESS_ZERO, BundlerMethod, CONTRACT_VERSION_ABI, ChainConfigService, Chains, CryptoUtils, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, ERC20Method, ERC7821_BATCH_MODE, EvmChain, ABI as EvmHostABI, EvmLanguage, FILL_ORDER_SELECTOR, HyperClientStatus, HyperFungibleToken, HyperFungibleTokenABI, HyperFxOrderbook, INCLUSION_TIMEOUT_MS,
|
|
24764
|
+
export { ADDRESS_ZERO2 as ADDRESS_ZERO, BundlerMethod, CONTRACT_VERSION_ABI, ChainConfigService, Chains, CryptoUtils, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, ERC20Method, ERC7821_BATCH_MODE, EvmChain, ABI as EvmHostABI, EvmLanguage, FILL_ORDER_SELECTOR, HyperClientStatus, HyperFungibleToken, HyperFungibleTokenABI, HyperFxOrderbook, INCLUSION_TIMEOUT_MS, IntentGateway, ABI3 as IntentGatewayABI, IntentOrderStatus, IntentsCoprocessor, IsmpClient, MAX_DECLARED_ENTRIES, MOCK_ADDRESS, ORDERBOOK_DECIMALS, ORDERBOOK_QUERIES, ORDERBOOK_URLS, ORDER_V2_PARAM_TYPE, OrderStatus, OrderStatusChecker, OrderbookQuoteNotConvergedError, OrderbookRequestError, PACKED_USEROP_TYPEHASH, PERMIT2_SPONSORSHIP_BYTES, PLACE_ORDER_SELECTOR, PharosChain, PolkadotHubChain, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, RequestKind, RequestStatus, SELECT_SOLVER_TYPEHASH, STATE_COMMITMENTS_SLOT, SUPPORTED_INTENTS_VERSION, SubstrateChain, Swap, TESTNET_CHAINS, TeleportStatus, TimeoutStatus, TokenGateway, TronChain, USE_ETHERSCAN_CHAINS, UnsupportedLiquidityAssetError, UnsupportedLiquidityChainError, WrappedHyperFungibleTokenABI, __test, adjustDecimals, assertGatewayRelease, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, chainConfigs, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createEvmChain, createQueryClient, decodeAcceptedSourceChains, decodeERC7821ExecuteBatch, decodeFillOrder, decodePhantomBidDeclaration, decodePhantomBidPaymasterAndData, decodeUserOpScale, deriveHttpUrl, encodeAcceptedSourceChains, encodeERC7821ExecuteBatch, encodeFillOrder, encodeISMPMessage, encodePhantomBidDeclaration, encodePhantomBidPaymasterAndData, encodeStateMachineId, encodeUserOpScale, encodeWithdrawalRequest, estimateGasForPost, fetchPrice, fetchSourceProof, generateRootWithProof, getChainId, getConfigByStateMachineId, getContractCallInput, getContractCallInputs, getGasPriceFromEtherscan, getOrFetchStorageSlot, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, getViemChain, hexToString, hyperbridgeAddress, isCanonicalEvmToken, maxBigInt, normalizeAddressForEvmBytes32, normalizeAddressForStateMachine, normalizeEvmAddress, normalizeEvmChainId, normalizeStateMachineId, orderCommitment, orderbookUrlFor, parseStateMachineId, pharosAtlantic, pharosMainnet, polkadotAssetHubPaseo, polkadotHubMainnet, poolSlug, postRequestCommitment, previewRateFill, queryAssetTeleported, queryGetRequest, queryPostRequest, quoteUniswap, readLegEscrow, readLegPartialFill, requestCommitmentKey, responseCommitmentKey, retryPromise, sortPoolSymbols, supportsRateFills, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };
|
|
24652
24765
|
//# sourceMappingURL=index.js.map
|
|
24653
24766
|
//# sourceMappingURL=index.js.map
|