@hyperbridge/sdk 2.8.16 → 2.8.17

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.
@@ -5012,8 +5012,10 @@ interface OrderbookRouteLiquidity {
5012
5012
  book: OrderbookBook;
5013
5013
  /** `BID` when tokenIn is the book's base, `ASK` when it is the quote. */
5014
5014
  side: OrderbookSide;
5015
- /** Quote per 1 base; null when no order serves the route. */
5015
+ /** Quote per 1 base, before the protocol fee; null when no order serves the route. */
5016
5016
  bestRate: bigint | null;
5017
+ /** The destination chain's protocol fee in basis points, which the gateway takes out of what the orders deliver. */
5018
+ slippageBps: number;
5017
5019
  /** Virtual depth: the serving orders' sizes summed, in tokenIn and tokenOut. */
5018
5020
  depthIn: bigint;
5019
5021
  depthOut: bigint;
@@ -5024,27 +5026,56 @@ interface OrderbookRouteLiquidity {
5024
5026
  orderCount: number;
5025
5027
  solverCount: number;
5026
5028
  }
5027
- /** A quote for an input amount on a route. Amounts and rates at 1e18. */
5029
+ /** One order an optimistic quote takes, at the order's own price. Amounts and rates at 1e18. */
5030
+ interface OrderbookQuoteFill {
5031
+ /** The order's full advertised size, not just the part this fill takes. */
5032
+ advertisedSize: bigint;
5033
+ /** The order's own price, quote per 1 base, before the protocol fee: what this fill settles at. */
5034
+ orderRate: bigint;
5035
+ /** The tokenIn this fill takes, in whole raw units on the source chain. */
5036
+ amountIn: bigint;
5037
+ /** The tokenOut this fill delivers, after the protocol fee, floored to a whole raw unit on the destination chain. */
5038
+ amountOut: bigint;
5039
+ }
5040
+ /**
5041
+ * An optimistic quote for an input amount on a route: the trade split across the route's orders,
5042
+ * best price first, each at its own price. There is no one rate and no total output; the fills are
5043
+ * the quote. Amounts and rates at 1e18.
5044
+ */
5028
5045
  interface OrderbookSwapQuote {
5029
5046
  route: OrderbookRouteKind;
5030
5047
  side: OrderbookSide;
5031
5048
  /** The tokenIn priced, floored to a whole raw unit on the source chain. */
5032
5049
  amountIn: bigint;
5033
- /** The tokenOut delivered, floored to a whole raw unit on the destination chain; 0 when not fillable. */
5050
+ /** The destination chain's protocol fee in basis points, already taken off every fill's `amountOut`. */
5051
+ slippageBps: number;
5052
+ fillable: boolean;
5053
+ /** The largest tokenIn amount the route's orders could take together, each at its own price. */
5054
+ maxFillableIn: bigint;
5055
+ /** The orders used, best price first; empty when not fillable. */
5056
+ fills: OrderbookQuoteFill[];
5057
+ }
5058
+ /**
5059
+ * A pessimistic quote for an input amount on a route: one price, from the first level, best first,
5060
+ * deep enough to fill the whole trade by itself, or else the route's worst price when its levels
5061
+ * together can. Amounts and rates at 1e18.
5062
+ */
5063
+ interface OrderbookLevelQuote {
5064
+ route: OrderbookRouteKind;
5065
+ side: OrderbookSide;
5066
+ /** The tokenIn priced, floored to a whole raw unit on the source chain. */
5067
+ amountIn: bigint;
5068
+ /** The tokenOut delivered at `rate`, after the protocol fee, floored to a whole raw unit on the destination chain; 0 when not fillable. */
5034
5069
  amountOut: bigint;
5035
- /** The clearing price, quote per 1 base; null when the route cannot fill the amount. */
5070
+ /** The worst single-order price in the level that fills it, quote per 1 base, before the protocol fee; null when not fillable. */
5036
5071
  rate: bigint | null;
5072
+ /** The price bucket of that level; null when not fillable. */
5073
+ priceBucket: bigint | null;
5074
+ /** The destination chain's protocol fee in basis points, already taken off `amountOut`. */
5075
+ slippageBps: number;
5037
5076
  fillable: boolean;
5038
- /** The tokenIn the route can absorb at `rate` or better. */
5039
- depth: bigint;
5040
- /** The largest tokenIn amount the route could fill. */
5077
+ /** The largest tokenIn amount this quote could fill: any one level at its worst price, or the whole route at its worst. */
5041
5078
  maxFillableIn: bigint;
5042
- /** The orders used, best first. */
5043
- fills: {
5044
- orderRate: bigint;
5045
- amountOut: bigint;
5046
- advertisedSize: bigint;
5047
- }[];
5048
5079
  }
5049
5080
  /** The best bid and ask a route can reach, with the book that orients them. */
5050
5081
  interface OrderbookTopOfBook {
@@ -5061,8 +5092,9 @@ declare class OrderbookRequestError extends Error {
5061
5092
  /** Every document the client sends, so they can be checked against the orderbook's published schema. */
5062
5093
  declare const ORDERBOOK_QUERIES: {
5063
5094
  readonly topOfBook: "\nquery TopOfBook($tokenA: String!, $tokenB: String!, $fillChain: String!, $sourceChain: String!) {\n books { id base quote }\n aToB: bestRate(tokenIn: $tokenA, tokenOut: $tokenB, fillChain: $fillChain, sourceChain: $sourceChain) { side fillChain rate depthIn depthOut backingLiquidity sourceChains orderCount solverCount }\n bToA: bestRate(tokenIn: $tokenB, tokenOut: $tokenA, fillChain: $fillChain, sourceChain: $sourceChain) { side fillChain rate depthIn depthOut backingLiquidity sourceChains orderCount solverCount }\n}";
5064
- readonly routeLiquidity: "\nquery RouteLiquidity($route: RouteInput!) {\n books { id base quote }\n routeLiquidity(route: $route) {\n route bestRate depthIn depthOut availableLiquidity maxFillableIn orderCount solverCount\n }\n}";
5065
- readonly quote: "\nquery Quote($route: RouteInput!, $amountIn: BigInt!) {\n quote(route: $route, amountIn: $amountIn) {\n route side amountIn amountOut rate fillable depth maxFillableIn\n fills { orderRate amountOut advertisedSize }\n }\n}";
5095
+ readonly routeLiquidity: "\nquery RouteLiquidity($route: RouteInput!) {\n books { id base quote }\n routeLiquidity(route: $route) {\n route bestRate slippageBps depthIn depthOut availableLiquidity maxFillableIn orderCount solverCount\n }\n}";
5096
+ readonly quote: "\nquery Quote($route: RouteInput!, $amountIn: BigInt!) {\n quote(route: $route, amountIn: $amountIn) {\n route side amountIn slippageBps fillable maxFillableIn\n fills { advertisedSize orderRate amountIn amountOut }\n }\n}";
5097
+ readonly quotePessimistic: "\nquery QuotePessimistic($route: RouteInput!, $amountIn: BigInt!) {\n quotePessimistic(route: $route, amountIn: $amountIn) {\n route side amountIn amountOut rate priceBucket slippageBps fillable maxFillableIn\n }\n}";
5066
5098
  };
5067
5099
  /**
5068
5100
  * Read-only client for the HyperFX orderbook's GraphQL API.
@@ -5087,12 +5119,20 @@ declare class HyperFxOrderbook {
5087
5119
  }): Promise<OrderbookTopOfBook>;
5088
5120
  /** Total liquidity on a route, no amount required. */
5089
5121
  routeLiquidity(route: OrderbookRoute): Promise<OrderbookRouteLiquidity>;
5090
- /** The clearing price for `amountIn` (1e18 tokenIn) on a route, which may combine several solvers' orders. */
5122
+ /**
5123
+ * The optimistic quote for `amountIn` (1e18 tokenIn) on a route: the route's orders, best price
5124
+ * first, each taking what it can at its own price. The fills' `amountOut`s sum to the output.
5125
+ */
5091
5126
  quote(route: OrderbookRoute, amountIn: bigint): Promise<OrderbookSwapQuote>;
5127
+ /**
5128
+ * The pessimistic quote for `amountIn` (1e18 tokenIn) on a route: one price, from the first level
5129
+ * deep enough to fill the whole trade by itself, at which every order in it fills; the route's
5130
+ * worst price when no one level can but its levels together can.
5131
+ */
5132
+ quotePessimistic(route: OrderbookRoute, amountIn: bigint): Promise<OrderbookLevelQuote>;
5092
5133
  private request;
5093
5134
  }
5094
5135
 
5095
- type IntentQuoteTradeType = "EXACT_INPUT" | "EXACT_OUTPUT";
5096
5136
  /**
5097
5137
  * Parameters for `IntentGateway.quoteIntent`. The source and destination chains
5098
5138
  * come from the gateway instance itself. `tokenIn` and `tokenOut` are token
@@ -5106,35 +5146,70 @@ interface QuoteIntentParams {
5106
5146
  tokenOut: HexString$1;
5107
5147
  amountIn?: bigint;
5108
5148
  amountOut?: bigint;
5149
+ /**
5150
+ * Return the orderbook's optimistic quote (`QuoteIntentResult`): one leg per
5151
+ * order, each at its own price. Defaults to the pessimistic quote
5152
+ * (`PessimisticQuoteIntentResult`): the whole trade at one price.
5153
+ */
5154
+ optimistic?: boolean;
5109
5155
  }
5110
- interface IntentQuoteMetadata {
5111
- sourceChain: Chains;
5112
- destinationChain: Chains;
5156
+ /**
5157
+ * One order an optimistic intent quote takes, at the order's own price. Amounts
5158
+ * are raw token units; the rate stays at 1e18.
5159
+ */
5160
+ interface IntentQuoteLeg {
5161
+ /** The order's full advertised size in `tokenOut`, not just the part this leg takes. */
5162
+ advertisedSize: bigint;
5163
+ /** The order's own price, quote per 1 base at 1e18, before the protocol fee: what this leg settles at. */
5164
+ orderRate: bigint;
5165
+ /** The `tokenIn` this leg takes. The legs' inputs sum to the quote's `amountIn`. */
5166
+ amountIn: bigint;
5167
+ /** The `tokenOut` this leg delivers, with the destination's protocol fee already taken off. */
5168
+ amountOut: bigint;
5169
+ }
5170
+ /**
5171
+ * `quoteIntent`'s result with `optimistic: true`, the orderbook's optimistic `quote`: the trade split across the
5172
+ * route's orders, best price first, each at its own price. There is no single
5173
+ * rate or total output; the legs are the quote, and their `amountOut`s sum to
5174
+ * what the order should require. Amounts are raw token units.
5175
+ */
5176
+ interface QuoteIntentResult {
5113
5177
  /** `SAME_CHAIN`, or `CROSS_CHAIN` when only orders accepting the source chain can fill it. */
5114
5178
  route: OrderbookRouteKind;
5115
5179
  /** `BID` when the order sells the book's base token, `ASK` when it buys it. */
5116
5180
  side: OrderbookSide;
5117
- baseTokenSymbol: ConfiguredAssetSymbol;
5118
- quoteTokenSymbol: ConfiguredAssetSymbol;
5119
- /** The clearing price the order was quoted at, in quote-token units per one base token. */
5120
- rate: string;
5121
- /** The largest `amountIn` the route can fill right now, in the source token's raw units. */
5181
+ /** The `tokenIn` priced: the requested input, or the input found to deliver the requested output. */
5182
+ amountIn: bigint;
5183
+ /** The destination's protocol fee in basis points, already taken off every leg's `amountOut`. */
5184
+ slippageBps: number;
5185
+ fillable: boolean;
5186
+ /** The largest `amountIn` the route's orders could take together, each at its own price. */
5122
5187
  maxFillableIn: bigint;
5123
- /** How many orders the quote combines. */
5124
- orderCount: number;
5188
+ /** The orders used, best price first. */
5189
+ legs: IntentQuoteLeg[];
5125
5190
  }
5126
5191
  /**
5127
- * A quote priced from the HyperFX orderbook.
5128
- *
5129
- * `amountIn` and `amountOut` are raw token units and can be used directly as
5130
- * the order's `inputs` and `output.assets`. The orderbook's rates already carry
5131
- * the IntentGateway protocol fee, so no further fee adjustment is needed.
5192
+ * `quoteIntent`'s default result, the orderbook's `quotePessimistic`: the whole trade at one
5193
+ * price, the worst single-order price of the first level, best first, deep
5194
+ * enough to fill it by itself, or the route's worst price when no one level
5195
+ * can. Amounts are raw token units; rates stay at 1e18.
5132
5196
  */
5133
- interface QuoteIntentResult {
5134
- tradeType: IntentQuoteTradeType;
5197
+ interface PessimisticQuoteIntentResult {
5198
+ route: OrderbookRouteKind;
5199
+ side: OrderbookSide;
5200
+ /** The `tokenIn` priced: the requested input, or the input found to deliver the requested output. */
5135
5201
  amountIn: bigint;
5202
+ /** The `tokenOut` delivered at `rate`, with the destination's protocol fee already taken off. */
5136
5203
  amountOut: bigint;
5137
- quoteMetadata: IntentQuoteMetadata;
5204
+ /** Quote per 1 base, before the protocol fee: every order in the level fills at it. */
5205
+ rate: bigint | null;
5206
+ /** The price bucket of that level. */
5207
+ priceBucket: bigint | null;
5208
+ /** The destination's protocol fee in basis points, already taken off `amountOut`. */
5209
+ slippageBps: number;
5210
+ fillable: boolean;
5211
+ /** The largest `amountIn` this quote could fill: any one level at its worst price, or the whole route at its worst. */
5212
+ maxFillableIn: bigint;
5138
5213
  }
5139
5214
  /**
5140
5215
  * What the orderbook holds for one route, with no amount given. Amounts are
@@ -5329,20 +5404,31 @@ declare class IntentGateway {
5329
5404
  /**
5330
5405
  * Quotes an intent between this gateway's source and destination chains from
5331
5406
  * the HyperFX orderbook. Provide exactly one of `amountIn` or `amountOut`, in
5332
- * raw token units.
5407
+ * raw token units. The result has the orderbook's shape, in raw token units.
5333
5408
  *
5334
- * An exact-input quote is the orderbook's clearing price for `amountIn`,
5335
- * which may combine several solvers' orders. An exact-output quote finds the
5336
- * smallest input whose clearing price delivers `amountOut`. A cross-chain
5337
- * route only counts orders whose solvers accept the source chain.
5409
+ * By default the quote is pessimistic (`PessimisticQuoteIntentResult`): the
5410
+ * whole trade at one price, the worst single-order price of the first level,
5411
+ * best first, deep enough to fill it by itself, or the route's worst price
5412
+ * when no one level can. With `optimistic: true` it is the orderbook's
5413
+ * optimistic quote (`QuoteIntentResult`): the route's orders, best price
5414
+ * first, each filling what it can of the trade at its own price, one leg per
5415
+ * order. There is no total output; the legs' `amountOut`s sum to it.
5338
5416
  *
5339
- * The orderbook's rates already carry the gateway protocol fee, so the
5340
- * returned amounts can be placed as the order's inputs and outputs directly.
5417
+ * Every `amountOut` already has the destination's protocol fee taken off. For
5418
+ * an exact output, the quote is for an input that delivers `amountOut`. A
5419
+ * cross-chain route only counts orders whose solvers accept the source chain.
5341
5420
  *
5342
5421
  * @throws {InsufficientOrderbookLiquidityError} When the route cannot fill the amount.
5422
+ * @throws {OrderbookQuoteNotConvergedError} When an exact-output quote does not settle on an input.
5343
5423
  * @throws {OrderbookRequestError} When the orderbook is unreachable or trades no book for the pair.
5344
5424
  */
5345
- quoteIntent(params: QuoteIntentParams): Promise<QuoteIntentResult>;
5425
+ quoteIntent(params: QuoteIntentParams & {
5426
+ optimistic: true;
5427
+ }): Promise<QuoteIntentResult>;
5428
+ quoteIntent(params: QuoteIntentParams & {
5429
+ optimistic?: false;
5430
+ }): Promise<PessimisticQuoteIntentResult>;
5431
+ quoteIntent(params: QuoteIntentParams): Promise<QuoteIntentResult | PessimisticQuoteIntentResult>;
5346
5432
  /**
5347
5433
  * Returns the orderbook liquidity serving a swap of `tokenIn` on the source
5348
5434
  * chain for `tokenOut` on the destination chain: the best rate, true and
@@ -11481,4 +11567,4 @@ declare function teleport(teleport_param: {
11481
11567
  extrinsics?: Array<SubmittableExtrinsic<"promise", ISubmittableResult>>;
11482
11568
  }): Promise<ReadableStream<HyperbridgeTxEvents>>;
11483
11569
 
11484
- export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type AvailableLiquidity, type Bid, type BidStorageEntry, type BidSubmissionResult, type BlockMetadata, type BridgeParams, type BridgeStep, type BundlerGasEstimate, BundlerMethod, type BuyAndSellRates, type BytesLikeHex, CONTRACT_VERSION_ABI, type CancelEvent, type CancelOptions, type CancelOrderOptions, type CancelQuote, type ChainConfig, type ChainConfigData, ChainConfigService, Chains, type ClientConfig, type ConfiguredAssetSymbol, type ConfiguredAssetSymbolInput, CryptoUtils, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, type DecodedFillOrder, type DecodedOrderPlacedLog, type DecodedPostRequestEvent, type DecodedPostResponseEvent, type Deployment, type DispatchGet, type DispatchInfo, type DispatchPost, ERC20Method, type ERC7821Call, ERC7821_BATCH_MODE, type Erc4626VaultConfigData, type EstimateFillOrderParams, type EstimateGasCallData, EvmChain, type EvmChainParams, ABI as EvmHostABI, EvmLanguage, type ExecuteIntentOrderOptions, type ExecutionResult, FILL_ORDER_SELECTOR, type FillOptions, type FillOrderEstimate, type FillerBid, type FillerConfig, type GetRequestResponse, type GetRequestWithStatus, type GetResponseByRequestIdResponse, type GetResponseStorageValues, type HexString$1 as HexString, type HostParams, HyperClientStatus, HyperFungibleToken, HyperFungibleTokenABI, HyperFxOrderbook, type HyperbridgeTxEvents, type IBatchConsensusAndGetResponseMessage, type IBatchConsensusAndPostRequestMessage, type IChain, type IConfig, type IConsensusMessage, type IEvmChain, type IEvmConfig, type IGetRequest, type IGetRequestMessage, type IGetResponse, type IGetResponseMessage, type IHyperbridgeConfig, type IIsmpMessage, type IMessage, INCLUSION_TIMEOUT_MS, type IPharosConfig, type IPolkadotHubConfig, type IPostRequest, type IPostResponse, type IProof, type IRequestMessage, type ISubstrateConfig, type ITimeoutPostRequestMessage, type IndexerQueryClient, InsufficientOrderbookLiquidityError, IntentGateway, ABI$1 as IntentGatewayABI, type IntentGatewayContext, type IntentGatewayParams, IntentOrderStatus, type IntentOrderStatusKey, type IntentOrderStatusUpdate, type IntentQuoteMetadata, type IntentQuoteTradeType, IntentsCoprocessor, IsmpClient, type IsmpRequest, MAX_DECLARED_ENTRIES, MOCK_ADDRESS, ORDERBOOK_DECIMALS, ORDERBOOK_QUERIES, ORDERBOOK_URLS, ORDER_V2_PARAM_TYPE, type Order, type OrderFeesQuote, type OrderResponse, OrderStatus, OrderStatusChecker, type OrderStatusMetadata, type OrderWithStatus, type OrderbookBook, OrderbookQuoteNotConvergedError, type OrderbookRate, OrderbookRequestError, type OrderbookRoute, type OrderbookRouteKind, type OrderbookRouteLiquidity, type OrderbookSide, type OrderbookSwapQuote, type OrderbookTopOfBook, PACKED_USEROP_TYPEHASH, PERMIT2_SPONSORSHIP_BYTES, PLACE_ORDER_SELECTOR, type PackedUserOperation, type Params, type PaymentInfo, type PhantomBidDeclaration, type PhantomBidPaymasterAndData, type PhantomBidSponsorship, PharosChain, type PharosChainParams, PolkadotHubChain, type PolkadotHubChainParams, type PostRequestStatus, type PostRequestTimeoutStatus, type PostRequestWithStatus, type 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, type RequestBody, type RequestCommitment, RequestKind, type RequestResponse, RequestStatus, type RequestStatusKey, type RequestStatusWithMetadata, type ResponseCommitmentWithValues, type ResumeIntentOrderOptions, type RetryConfig, type RpcBidInfo, SELECT_SOLVER_TYPEHASH, STATE_COMMITMENTS_SLOT, SUPPORTED_INTENTS_VERSION, type SelectBidResult, type SelectOptions, type SigningAccount, type StateMachineHeight, type StateMachineId, type StateMachineIdParams, type StateMachineResponse, type StateMachineUpdate, type StorageFacade, type SubmitBidOptions, SubstrateChain, Swap, TESTNET_CHAINS, type TeleportParams, TeleportStatus, TimeoutStatus, type TimeoutStatusKey, TokenGateway, type TokenGatewayAssetTeleportedResponse, type TokenGatewayAssetTeleportedWithStatus, type TokenInfo, type TokenPrice, type TokenPricesResponse, type 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, 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 };
11570
+ export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type AvailableLiquidity, type Bid, type BidStorageEntry, type BidSubmissionResult, type BlockMetadata, type BridgeParams, type BridgeStep, type BundlerGasEstimate, BundlerMethod, type BuyAndSellRates, type BytesLikeHex, CONTRACT_VERSION_ABI, type CancelEvent, type CancelOptions, type CancelOrderOptions, type CancelQuote, type ChainConfig, type ChainConfigData, ChainConfigService, Chains, type ClientConfig, type ConfiguredAssetSymbol, type ConfiguredAssetSymbolInput, CryptoUtils, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, type DecodedFillOrder, type DecodedOrderPlacedLog, type DecodedPostRequestEvent, type DecodedPostResponseEvent, type Deployment, type DispatchGet, type DispatchInfo, type DispatchPost, ERC20Method, type ERC7821Call, ERC7821_BATCH_MODE, type Erc4626VaultConfigData, type EstimateFillOrderParams, type EstimateGasCallData, EvmChain, type EvmChainParams, ABI as EvmHostABI, EvmLanguage, type ExecuteIntentOrderOptions, type ExecutionResult, FILL_ORDER_SELECTOR, type FillOptions, type FillOrderEstimate, type FillerBid, type FillerConfig, type GetRequestResponse, type GetRequestWithStatus, type GetResponseByRequestIdResponse, type GetResponseStorageValues, type HexString$1 as HexString, type HostParams, HyperClientStatus, HyperFungibleToken, HyperFungibleTokenABI, HyperFxOrderbook, type HyperbridgeTxEvents, type IBatchConsensusAndGetResponseMessage, type IBatchConsensusAndPostRequestMessage, type IChain, type IConfig, type IConsensusMessage, type IEvmChain, type IEvmConfig, type IGetRequest, type IGetRequestMessage, type IGetResponse, type IGetResponseMessage, type IHyperbridgeConfig, type IIsmpMessage, type IMessage, INCLUSION_TIMEOUT_MS, type IPharosConfig, type IPolkadotHubConfig, type IPostRequest, type IPostResponse, type IProof, type IRequestMessage, type ISubstrateConfig, type ITimeoutPostRequestMessage, type IndexerQueryClient, InsufficientOrderbookLiquidityError, IntentGateway, ABI$1 as IntentGatewayABI, type IntentGatewayContext, type IntentGatewayParams, IntentOrderStatus, type IntentOrderStatusKey, type IntentOrderStatusUpdate, type IntentQuoteLeg, IntentsCoprocessor, IsmpClient, type IsmpRequest, MAX_DECLARED_ENTRIES, MOCK_ADDRESS, ORDERBOOK_DECIMALS, ORDERBOOK_QUERIES, ORDERBOOK_URLS, ORDER_V2_PARAM_TYPE, type Order, type OrderFeesQuote, type OrderResponse, OrderStatus, OrderStatusChecker, type OrderStatusMetadata, type 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, PERMIT2_SPONSORSHIP_BYTES, PLACE_ORDER_SELECTOR, type PackedUserOperation, type Params, type PaymentInfo, type PessimisticQuoteIntentResult, type PhantomBidDeclaration, type PhantomBidPaymasterAndData, type PhantomBidSponsorship, PharosChain, type PharosChainParams, PolkadotHubChain, type PolkadotHubChainParams, type PostRequestStatus, type PostRequestTimeoutStatus, type PostRequestWithStatus, type 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, type RequestBody, type RequestCommitment, RequestKind, type RequestResponse, RequestStatus, type RequestStatusKey, type RequestStatusWithMetadata, type ResponseCommitmentWithValues, type ResumeIntentOrderOptions, type RetryConfig, type RpcBidInfo, SELECT_SOLVER_TYPEHASH, STATE_COMMITMENTS_SLOT, SUPPORTED_INTENTS_VERSION, type SelectBidResult, type SelectOptions, type SigningAccount, type StateMachineHeight, type StateMachineId, type StateMachineIdParams, type StateMachineResponse, type StateMachineUpdate, type StorageFacade, type SubmitBidOptions, SubstrateChain, Swap, TESTNET_CHAINS, type TeleportParams, TeleportStatus, TimeoutStatus, type TimeoutStatusKey, TokenGateway, type TokenGatewayAssetTeleportedResponse, type TokenGatewayAssetTeleportedWithStatus, type TokenInfo, type TokenPrice, type TokenPricesResponse, type 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, 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 };
@@ -18837,20 +18837,27 @@ var ROUTE_LIQUIDITY_QUERY = `
18837
18837
  query RouteLiquidity($route: RouteInput!) {
18838
18838
  books { id base quote }
18839
18839
  routeLiquidity(route: $route) {
18840
- route bestRate depthIn depthOut availableLiquidity maxFillableIn orderCount solverCount
18840
+ route bestRate slippageBps depthIn depthOut availableLiquidity maxFillableIn orderCount solverCount
18841
18841
  }
18842
18842
  }`;
18843
18843
  var QUOTE_QUERY = `
18844
18844
  query Quote($route: RouteInput!, $amountIn: BigInt!) {
18845
18845
  quote(route: $route, amountIn: $amountIn) {
18846
- route side amountIn amountOut rate fillable depth maxFillableIn
18847
- fills { orderRate amountOut advertisedSize }
18846
+ route side amountIn slippageBps fillable maxFillableIn
18847
+ fills { advertisedSize orderRate amountIn amountOut }
18848
+ }
18849
+ }`;
18850
+ var QUOTE_PESSIMISTIC_QUERY = `
18851
+ query QuotePessimistic($route: RouteInput!, $amountIn: BigInt!) {
18852
+ quotePessimistic(route: $route, amountIn: $amountIn) {
18853
+ route side amountIn amountOut rate priceBucket slippageBps fillable maxFillableIn
18848
18854
  }
18849
18855
  }`;
18850
18856
  var ORDERBOOK_QUERIES = {
18851
18857
  topOfBook: TOP_OF_BOOK_QUERY,
18852
18858
  routeLiquidity: ROUTE_LIQUIDITY_QUERY,
18853
- quote: QUOTE_QUERY
18859
+ quote: QUOTE_QUERY,
18860
+ quotePessimistic: QUOTE_PESSIMISTIC_QUERY
18854
18861
  };
18855
18862
  var HyperFxOrderbook = class {
18856
18863
  client;
@@ -18879,8 +18886,9 @@ var HyperFxOrderbook = class {
18879
18886
  return {
18880
18887
  route: raw.route,
18881
18888
  book,
18882
- side: book.base === route.tokenIn ? "BID" : "ASK",
18883
- bestRate: raw.bestRate === null ? null : BigInt(raw.bestRate),
18889
+ side: sameSymbol(book.base, route.tokenIn) ? "BID" : "ASK",
18890
+ bestRate: optionalBigInt(raw.bestRate),
18891
+ slippageBps: raw.slippageBps,
18884
18892
  depthIn: BigInt(raw.depthIn),
18885
18893
  depthOut: BigInt(raw.depthOut),
18886
18894
  availableLiquidity: BigInt(raw.availableLiquidity),
@@ -18889,7 +18897,10 @@ var HyperFxOrderbook = class {
18889
18897
  solverCount: raw.solverCount
18890
18898
  };
18891
18899
  }
18892
- /** The clearing price for `amountIn` (1e18 tokenIn) on a route, which may combine several solvers' orders. */
18900
+ /**
18901
+ * The optimistic quote for `amountIn` (1e18 tokenIn) on a route: the route's orders, best price
18902
+ * first, each taking what it can at its own price. The fills' `amountOut`s sum to the output.
18903
+ */
18893
18904
  async quote(route, amountIn) {
18894
18905
  const { quote: raw } = await this.request(QUOTE_QUERY, {
18895
18906
  route,
@@ -18899,18 +18910,39 @@ var HyperFxOrderbook = class {
18899
18910
  route: raw.route,
18900
18911
  side: raw.side,
18901
18912
  amountIn: BigInt(raw.amountIn),
18902
- amountOut: BigInt(raw.amountOut),
18903
- rate: raw.rate === null ? null : BigInt(raw.rate),
18913
+ slippageBps: raw.slippageBps,
18904
18914
  fillable: raw.fillable,
18905
- depth: BigInt(raw.depth),
18906
18915
  maxFillableIn: BigInt(raw.maxFillableIn),
18907
18916
  fills: raw.fills.map((fill) => ({
18917
+ advertisedSize: BigInt(fill.advertisedSize),
18908
18918
  orderRate: BigInt(fill.orderRate),
18909
- amountOut: BigInt(fill.amountOut),
18910
- advertisedSize: BigInt(fill.advertisedSize)
18919
+ amountIn: BigInt(fill.amountIn),
18920
+ amountOut: BigInt(fill.amountOut)
18911
18921
  }))
18912
18922
  };
18913
18923
  }
18924
+ /**
18925
+ * The pessimistic quote for `amountIn` (1e18 tokenIn) on a route: one price, from the first level
18926
+ * deep enough to fill the whole trade by itself, at which every order in it fills; the route's
18927
+ * worst price when no one level can but its levels together can.
18928
+ */
18929
+ async quotePessimistic(route, amountIn) {
18930
+ const { quotePessimistic: raw } = await this.request(
18931
+ QUOTE_PESSIMISTIC_QUERY,
18932
+ { route, amountIn: amountIn.toString() }
18933
+ );
18934
+ return {
18935
+ route: raw.route,
18936
+ side: raw.side,
18937
+ amountIn: BigInt(raw.amountIn),
18938
+ amountOut: BigInt(raw.amountOut),
18939
+ rate: optionalBigInt(raw.rate),
18940
+ priceBucket: optionalBigInt(raw.priceBucket),
18941
+ slippageBps: raw.slippageBps,
18942
+ fillable: raw.fillable,
18943
+ maxFillableIn: BigInt(raw.maxFillableIn)
18944
+ };
18945
+ }
18914
18946
  async request(query, variables) {
18915
18947
  try {
18916
18948
  return await this.client.request(query, variables);
@@ -18924,13 +18956,19 @@ function describeError(error) {
18924
18956
  if (graphqlErrors?.length) return graphqlErrors.map((e) => e.message).join("; ");
18925
18957
  return error instanceof Error ? error.message : String(error);
18926
18958
  }
18959
+ function sameSymbol(a, b) {
18960
+ return a.toLowerCase() === b.toLowerCase();
18961
+ }
18927
18962
  function findBook(books, tokenA, tokenB) {
18928
18963
  const book = books.find(
18929
- (b) => b.base === tokenA && b.quote === tokenB || b.base === tokenB && b.quote === tokenA
18964
+ (b) => sameSymbol(b.base, tokenA) && sameSymbol(b.quote, tokenB) || sameSymbol(b.base, tokenB) && sameSymbol(b.quote, tokenA)
18930
18965
  );
18931
18966
  if (!book) throw new OrderbookRequestError(`no book trades ${tokenA} for ${tokenB}`);
18932
18967
  return book;
18933
18968
  }
18969
+ function optionalBigInt(value) {
18970
+ return value === null ? null : BigInt(value);
18971
+ }
18934
18972
  function parseRate(raw) {
18935
18973
  return {
18936
18974
  side: raw.side,
@@ -18995,26 +19033,69 @@ var OrderbookMarket = class {
18995
19033
  configService;
18996
19034
  orderbook;
18997
19035
  async quoteIntent(params, sourceChain, destinationChain) {
19036
+ const orderbook = this.orderbook();
19037
+ if (!params.optimistic) {
19038
+ const { quote: quote2, tokenIn: tokenIn2, tokenOut: tokenOut2 } = await this.priceIntent(
19039
+ params,
19040
+ sourceChain,
19041
+ destinationChain,
19042
+ (route, amountIn) => orderbook.quotePessimistic(route, amountIn),
19043
+ levelQuoteTotals
19044
+ );
19045
+ return {
19046
+ route: quote2.route,
19047
+ side: quote2.side,
19048
+ amountIn: fromOrderbookAmount(quote2.amountIn, tokenIn2.decimals),
19049
+ amountOut: fromOrderbookAmount(quote2.amountOut, tokenOut2.decimals),
19050
+ rate: quote2.rate,
19051
+ priceBucket: quote2.priceBucket,
19052
+ slippageBps: quote2.slippageBps,
19053
+ fillable: quote2.fillable,
19054
+ maxFillableIn: fromOrderbookAmount(quote2.maxFillableIn, tokenIn2.decimals)
19055
+ };
19056
+ }
19057
+ const { quote, tokenIn, tokenOut } = await this.priceIntent(
19058
+ params,
19059
+ sourceChain,
19060
+ destinationChain,
19061
+ (route, amountIn) => orderbook.quote(route, amountIn),
19062
+ swapQuoteTotals
19063
+ );
19064
+ return {
19065
+ route: quote.route,
19066
+ side: quote.side,
19067
+ amountIn: fromOrderbookAmount(quote.amountIn, tokenIn.decimals),
19068
+ slippageBps: quote.slippageBps,
19069
+ fillable: quote.fillable,
19070
+ maxFillableIn: fromOrderbookAmount(quote.maxFillableIn, tokenIn.decimals),
19071
+ legs: quote.fills.map((fill) => ({
19072
+ advertisedSize: fromOrderbookAmount(fill.advertisedSize, tokenOut.decimals),
19073
+ orderRate: fill.orderRate,
19074
+ amountIn: fromOrderbookAmount(fill.amountIn, tokenIn.decimals),
19075
+ amountOut: fromOrderbookAmount(fill.amountOut, tokenOut.decimals)
19076
+ }))
19077
+ };
19078
+ }
19079
+ /**
19080
+ * The fillable quote for an exact input, or for the input found to deliver an
19081
+ * exact output, with the assets it trades.
19082
+ */
19083
+ async priceIntent(params, sourceChain, destinationChain, price, totals) {
18998
19084
  validateQuoteParams(params);
18999
19085
  const tokenIn = this.assetByAddress(sourceChain, params.tokenIn);
19000
19086
  const tokenOut = this.assetByAddress(destinationChain, params.tokenOut);
19001
19087
  const route = toRoute(tokenIn, tokenOut);
19002
19088
  if (params.amountIn !== void 0) {
19003
- const quote2 = await this.orderbook().quote(route, toOrderbookAmount(params.amountIn, tokenIn.decimals));
19004
- const amountOut2 = quote2.fillable ? fromOrderbookAmount(quote2.amountOut, tokenOut.decimals) : 0n;
19005
- if (amountOut2 === 0n) throw this.insufficient(route, quote2.maxFillableIn, tokenIn);
19006
- return buildQuote("EXACT_INPUT", params.amountIn, amountOut2, quote2, tokenIn, tokenOut);
19089
+ const quote2 = await price(route, toOrderbookAmount(params.amountIn, tokenIn.decimals));
19090
+ const { fillable, amountOut, maxFillableIn } = totals(quote2);
19091
+ if (!fillable || fromOrderbookAmount(amountOut, tokenOut.decimals) === 0n) {
19092
+ throw this.insufficient(route, maxFillableIn, tokenIn);
19093
+ }
19094
+ return { quote: quote2, tokenIn, tokenOut };
19007
19095
  }
19008
- const amountOut = params.amountOut;
19009
- const quote = await this.quoteExactOutput(route, toOrderbookAmount(amountOut, tokenOut.decimals), tokenIn);
19010
- return buildQuote(
19011
- "EXACT_OUTPUT",
19012
- fromOrderbookAmount(quote.amountIn, tokenIn.decimals),
19013
- amountOut,
19014
- quote,
19015
- tokenIn,
19016
- tokenOut
19017
- );
19096
+ const targetOut = toOrderbookAmount(params.amountOut, tokenOut.decimals);
19097
+ const quote = await this.quoteExactOutput(route, targetOut, tokenIn, price, totals);
19098
+ return { quote, tokenIn, tokenOut };
19018
19099
  }
19019
19100
  async availableLiquidity(params, sourceChain, destinationChain) {
19020
19101
  const tokenIn = this.assetByAddress(sourceChain, params.tokenIn);
@@ -19067,22 +19148,26 @@ var OrderbookMarket = class {
19067
19148
  }
19068
19149
  /**
19069
19150
  * The orderbook only quotes an input amount, so an output is priced by
19070
- * guessing the input from the best rate and raising it at each clearing
19071
- * price until the quote delivers `targetOut`.
19151
+ * guessing the input from the best rate, then keeping the part of each quote
19152
+ * filled better than its worst rate and re-pricing the rest of `targetOut` at
19153
+ * the input-to-output ratio that part filled at, until a quote delivers it.
19154
+ * That ratio is the orderbook's own, with the protocol fee already taken off.
19072
19155
  */
19073
- async quoteExactOutput(route, targetOut, tokenIn) {
19074
- const orderbook = this.orderbook();
19075
- const liquidity = await orderbook.routeLiquidity(route);
19156
+ async quoteExactOutput(route, targetOut, tokenIn, price, totals) {
19157
+ const liquidity = await this.orderbook().routeLiquidity(route);
19076
19158
  if (liquidity.bestRate === null) throw this.insufficient(route, 0n, tokenIn);
19077
19159
  const inputUnit = toOrderbookAmount(1n, tokenIn.decimals);
19078
19160
  let amountIn = roundUpTo(requiredInput(liquidity.side, targetOut, liquidity.bestRate), inputUnit);
19079
19161
  let lastAmountIn = amountIn;
19080
19162
  for (let round = 0; round < MAX_EXACT_OUTPUT_ROUNDS; round++) {
19081
19163
  if (amountIn > liquidity.maxFillableIn) throw this.insufficient(route, liquidity.maxFillableIn, tokenIn);
19082
- const quote = await orderbook.quote(route, amountIn);
19083
- if (quote.fillable && quote.amountOut >= targetOut) return quote;
19164
+ const served = await price(route, amountIn);
19165
+ const quote = totals(served);
19166
+ if (quote.fillable && quote.amountOut >= targetOut) return served;
19084
19167
  lastAmountIn = amountIn;
19085
- const next = quote.rate === null ? amountIn : roundUpTo(requiredInput(quote.side, targetOut, quote.rate), inputUnit);
19168
+ const betterIn = quote.amountIn - quote.worstIn;
19169
+ const betterOut = quote.amountOut - quote.worstOut;
19170
+ const next = quote.fillable && quote.worstOut > 0n ? betterIn + roundUpTo(divCeil((targetOut - betterOut) * quote.worstIn, quote.worstOut), inputUnit) : amountIn;
19086
19171
  amountIn = next > amountIn ? next : amountIn + inputUnit;
19087
19172
  }
19088
19173
  throw new OrderbookQuoteNotConvergedError(
@@ -19138,24 +19223,32 @@ function toRoute(tokenIn, tokenOut) {
19138
19223
  function requiredInput(side, amountOut, rate) {
19139
19224
  return side === "BID" ? divCeil(amountOut * ORDERBOOK_SCALE, rate) : divCeil(amountOut * rate, ORDERBOOK_SCALE);
19140
19225
  }
19141
- function buildQuote(tradeType, amountIn, amountOut, quote, tokenIn, tokenOut) {
19142
- if (quote.rate === null) throw new OrderbookRequestError("the orderbook served a fillable quote with no rate");
19143
- const [base3, quoteToken] = quote.side === "BID" ? [tokenIn, tokenOut] : [tokenOut, tokenIn];
19226
+ function swapQuoteTotals(quote) {
19227
+ const worstFill = quote.fills.at(-1);
19228
+ if (quote.fillable && !worstFill)
19229
+ throw new OrderbookRequestError("the orderbook served a fillable quote with no fills");
19144
19230
  return {
19145
- tradeType,
19146
- amountIn,
19147
- amountOut,
19148
- quoteMetadata: {
19149
- sourceChain: tokenIn.chain,
19150
- destinationChain: tokenOut.chain,
19151
- route: quote.route,
19152
- side: quote.side,
19153
- baseTokenSymbol: base3.symbol,
19154
- quoteTokenSymbol: quoteToken.symbol,
19155
- rate: format(quote.rate),
19156
- maxFillableIn: fromOrderbookAmount(quote.maxFillableIn, tokenIn.decimals),
19157
- orderCount: quote.fills.length
19158
- }
19231
+ side: quote.side,
19232
+ amountIn: quote.amountIn,
19233
+ amountOut: quote.fills.reduce((total, fill) => total + fill.amountOut, 0n),
19234
+ fillable: quote.fillable,
19235
+ maxFillableIn: quote.maxFillableIn,
19236
+ worstIn: worstFill?.amountIn ?? 0n,
19237
+ worstOut: worstFill?.amountOut ?? 0n
19238
+ };
19239
+ }
19240
+ function levelQuoteTotals(quote) {
19241
+ if (quote.fillable && quote.rate === null) {
19242
+ throw new OrderbookRequestError("the orderbook served a fillable quote with no rate");
19243
+ }
19244
+ return {
19245
+ side: quote.side,
19246
+ amountIn: quote.amountIn,
19247
+ amountOut: quote.amountOut,
19248
+ fillable: quote.fillable,
19249
+ maxFillableIn: quote.maxFillableIn,
19250
+ worstIn: quote.amountIn,
19251
+ worstOut: quote.amountOut
19159
19252
  };
19160
19253
  }
19161
19254
  function toOrderbookAmount(amount, decimals) {
@@ -19319,22 +19412,6 @@ var IntentGateway = class _IntentGateway {
19319
19412
  this.orderbook = typeof orderbook === "string" ? new HyperFxOrderbook(orderbook) : orderbook;
19320
19413
  return this;
19321
19414
  }
19322
- /**
19323
- * Quotes an intent between this gateway's source and destination chains from
19324
- * the HyperFX orderbook. Provide exactly one of `amountIn` or `amountOut`, in
19325
- * raw token units.
19326
- *
19327
- * An exact-input quote is the orderbook's clearing price for `amountIn`,
19328
- * which may combine several solvers' orders. An exact-output quote finds the
19329
- * smallest input whose clearing price delivers `amountOut`. A cross-chain
19330
- * route only counts orders whose solvers accept the source chain.
19331
- *
19332
- * The orderbook's rates already carry the gateway protocol fee, so the
19333
- * returned amounts can be placed as the order's inputs and outputs directly.
19334
- *
19335
- * @throws {InsufficientOrderbookLiquidityError} When the route cannot fill the amount.
19336
- * @throws {OrderbookRequestError} When the orderbook is unreachable or trades no book for the pair.
19337
- */
19338
19415
  async quoteIntent(params) {
19339
19416
  return this.market.quoteIntent(params, this.source.config.stateMachineId, this.dest.config.stateMachineId);
19340
19417
  }