@hyperbridge/sdk 2.8.17 → 2.8.18
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 +12 -21
- package/dist/browser/index.js +11 -25
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +10 -25
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +12 -21
- package/dist/node/index.d.ts +12 -21
- package/dist/node/index.js +11 -25
- package/dist/node/index.js.map +1 -1
- package/package.json +1 -1
package/dist/node/index.d.cts
CHANGED
|
@@ -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
|
*/
|
|
@@ -6456,4 +6447,4 @@ declare function teleport(teleport_param: {
|
|
|
6456
6447
|
extrinsics?: Array<SubmittableExtrinsic<"promise", ISubmittableResult>>;
|
|
6457
6448
|
}): Promise<ReadableStream<HyperbridgeTxEvents>>;
|
|
6458
6449
|
|
|
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,
|
|
6450
|
+
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, 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
|
@@ -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
|
*/
|
|
@@ -6456,4 +6447,4 @@ declare function teleport(teleport_param: {
|
|
|
6456
6447
|
extrinsics?: Array<SubmittableExtrinsic<"promise", ISubmittableResult>>;
|
|
6457
6448
|
}): Promise<ReadableStream<HyperbridgeTxEvents>>;
|
|
6458
6449
|
|
|
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,
|
|
6450
|
+
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, 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
|
@@ -18950,18 +18950,6 @@ var OrderbookQuoteNotConvergedError = class extends Error {
|
|
|
18950
18950
|
rounds;
|
|
18951
18951
|
lastAmountIn;
|
|
18952
18952
|
};
|
|
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
18953
|
|
|
18966
18954
|
// src/protocols/intents/orderbook/market.ts
|
|
18967
18955
|
var MAX_EXACT_OUTPUT_ROUNDS = 16;
|
|
@@ -19017,8 +19005,9 @@ var OrderbookMarket = class {
|
|
|
19017
19005
|
};
|
|
19018
19006
|
}
|
|
19019
19007
|
/**
|
|
19020
|
-
* The
|
|
19021
|
-
* exact output, with the assets it trades.
|
|
19008
|
+
* The orderbook's quote for an exact input, or for the input found to deliver
|
|
19009
|
+
* an exact output, with the assets it trades. A route that cannot fill the
|
|
19010
|
+
* trade answers with an unfillable quote rather than an error.
|
|
19022
19011
|
*/
|
|
19023
19012
|
async priceIntent(params, sourceChain, destinationChain, price, totals) {
|
|
19024
19013
|
validateQuoteParams(params);
|
|
@@ -19027,10 +19016,7 @@ var OrderbookMarket = class {
|
|
|
19027
19016
|
const route = toRoute(tokenIn, tokenOut);
|
|
19028
19017
|
if (params.amountIn !== void 0) {
|
|
19029
19018
|
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
|
-
}
|
|
19019
|
+
totals(quote2);
|
|
19034
19020
|
return { quote: quote2, tokenIn, tokenOut };
|
|
19035
19021
|
}
|
|
19036
19022
|
const targetOut = toOrderbookAmount(params.amountOut, tokenOut.decimals);
|
|
@@ -19092,18 +19078,21 @@ var OrderbookMarket = class {
|
|
|
19092
19078
|
* filled better than its worst rate and re-pricing the rest of `targetOut` at
|
|
19093
19079
|
* the input-to-output ratio that part filled at, until a quote delivers it.
|
|
19094
19080
|
* That ratio is the orderbook's own, with the protocol fee already taken off.
|
|
19081
|
+
*
|
|
19082
|
+
* An output the route cannot deliver is answered by quoting an input past its
|
|
19083
|
+
* `maxFillableIn`, which the orderbook serves as unfillable: the smallest such
|
|
19084
|
+
* input guessed from the best rate, or one raw unit when no order serves it.
|
|
19095
19085
|
*/
|
|
19096
19086
|
async quoteExactOutput(route, targetOut, tokenIn, price, totals) {
|
|
19097
19087
|
const liquidity = await this.orderbook().routeLiquidity(route);
|
|
19098
|
-
if (liquidity.bestRate === null) throw this.insufficient(route, 0n, tokenIn);
|
|
19099
19088
|
const inputUnit = toOrderbookAmount(1n, tokenIn.decimals);
|
|
19100
|
-
let amountIn = roundUpTo(requiredInput(liquidity.side, targetOut, liquidity.bestRate), inputUnit);
|
|
19089
|
+
let amountIn = liquidity.bestRate === null ? inputUnit : roundUpTo(requiredInput(liquidity.side, targetOut, liquidity.bestRate), inputUnit);
|
|
19101
19090
|
let lastAmountIn = amountIn;
|
|
19102
19091
|
for (let round = 0; round < MAX_EXACT_OUTPUT_ROUNDS; round++) {
|
|
19103
|
-
if (amountIn > liquidity.maxFillableIn) throw this.insufficient(route, liquidity.maxFillableIn, tokenIn);
|
|
19104
19092
|
const served = await price(route, amountIn);
|
|
19105
19093
|
const quote = totals(served);
|
|
19106
19094
|
if (quote.fillable && quote.amountOut >= targetOut) return served;
|
|
19095
|
+
if (!quote.fillable && amountIn > liquidity.maxFillableIn) return served;
|
|
19107
19096
|
lastAmountIn = amountIn;
|
|
19108
19097
|
const betterIn = quote.amountIn - quote.worstIn;
|
|
19109
19098
|
const betterOut = quote.amountOut - quote.worstOut;
|
|
@@ -19116,9 +19105,6 @@ var OrderbookMarket = class {
|
|
|
19116
19105
|
fromOrderbookAmount(lastAmountIn, tokenIn.decimals)
|
|
19117
19106
|
);
|
|
19118
19107
|
}
|
|
19119
|
-
insufficient(route, maxFillableIn, tokenIn) {
|
|
19120
|
-
return new InsufficientOrderbookLiquidityError(route, fromOrderbookAmount(maxFillableIn, tokenIn.decimals));
|
|
19121
|
-
}
|
|
19122
19108
|
assetByAddress(chain, address) {
|
|
19123
19109
|
const resolvedChain = resolveChain(chain);
|
|
19124
19110
|
return withDecimals(
|
|
@@ -24648,6 +24634,6 @@ async function teleportDot(param_) {
|
|
|
24648
24634
|
return stream;
|
|
24649
24635
|
}
|
|
24650
24636
|
|
|
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,
|
|
24637
|
+
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
24638
|
//# sourceMappingURL=index.js.map
|
|
24653
24639
|
//# sourceMappingURL=index.js.map
|