@hyperbridge/sdk 2.8.13 → 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.
@@ -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, u as AvailableLiquidity, Q as QueryBuyAndSellRatesParams, B as BuyAndSellRates, v as IntentOrderStatusUpdate, w as SelectBidResult, x as ResumeIntentOrderOptions, y as CancelOrderOptions, z as CancelQuote, D as SubmitBidOptions, F as PackedUserOperation, J as FillerBid, K as Bid, L as EstimateFillOrderParams, M as FillOrderEstimate, N as OrderFeesQuote, U as ERC7821Call, V as OrderWithStatus, W as OrderStatus, X as TokenGatewayAssetTeleportedWithStatus, Y as TeleportStatus, Z as DecodedOrderPlacedLog, _ as DecodedPostRequestEvent, $ as DecodedPostResponseEvent } from './intents-helpers-fntBuoYM.cjs';
2
- export { a0 as AllStatusKey, a1 as AssetTeleportedResponse, a2 as BidStorageEntry, a3 as BidSubmissionResult, a4 as BlockMetadata, a5 as BytesLikeHex, a6 as CHAINS_WITHOUT_VALID_UNTIL, 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 FILL_ORDER_V1_ABI, aj as FillOptions, ak as FillOptionsVersion, al as FillerConfig, am as GetRequestResponse, an as GetResponseByRequestIdResponse, ao as GetResponseStorageValues, ap as HostParams, aq as HyperClientStatus, ar as IBatchConsensusAndGetResponseMessage, as as IBatchConsensusAndPostRequestMessage, at as IConfig, au as IConsensusMessage, av as IGetRequestMessage, aw as IGetResponse, ax as IGetResponseMessage, ay as IHyperbridgeConfig, az as INCLUSION_TIMEOUT_MS, aA as IPostResponse, aB as IRequestMessage, aC as ISubstrateConfig, aD as ITimeoutPostRequestMessage, aE as IntentGatewayABI, aF as IntentGatewayParams, aG as IntentOrderStatus, aH as IntentOrderStatusKey, aI as IsmpRequest, aJ as LEGACY_FILL_OPTIONS_IMPLEMENTATIONS, aK as LiquiditySlice, aL as OrderResponse, aM as OrderStatusMetadata, aN as PERMIT2_SPONSORSHIP_BYTES, aO as PaymentInfo, aP as PhantomBid, aQ as PhantomBidBatchResult, aR as PhantomBidDeclaration, aS as PhantomBidOutcome, aT as PhantomBidPaymasterAndData, aU as PhantomBidSponsorship, aV as PhantomOrderEvent, aW as PhantomOrderLeg, aX as PhantomOrderPriceSnapshot, aY as PhantomOrderPriceSnapshotsResponse, aZ as PhantomTimings, a_ as PollPhantomOrdersOptions, a$ as PostRequestStatus, b0 as RequestBody, b1 as RequestCommitment, b2 as RequestKind, b3 as RequestResponse, b4 as RequestStatus, b5 as RequestStatusKey, b6 as SelectOptions, b7 as SigningAccount, b8 as StateMachineId, b9 as StateMachineResponse, ba as StorageFacade, bb as TimeoutStatus, bc as TimeoutStatusKey, bd as TokenGatewayAssetTeleportedResponse, be as TokenInfo, bf as TokenPrice, bg as TokenPricesResponse, bh as UNISWAP_QUOTE_HAIRCUT_BPS, bi as UniswapV4PoolConfigData, bj as applyProtocolFeeHaircut, bk as applyUniswapQuoteHaircut, bl as chainConfigs, bm as convertCodecToIGetRequest, bn as convertCodecToIProof, bo as convertIGetRequestToCodec, bp as convertIProofToCodec, bq as convertStateIdToStateMachineId, br as convertStateMachineEnumToString, bs as convertStateMachineIdToEnum, bt as decodeAcceptedSourceChains, bu as decodeERC7821ExecuteBatch, bv as decodeFillOrder, bw as decodePhantomBidDeclaration, bx as decodePhantomBidPaymasterAndData, by as decodeUserOpScale, bz as deriveHttpUrl, bA as encodeAcceptedSourceChains, bB as encodeERC7821ExecuteBatch, bC as encodeFillOrder, bD as encodeISMPMessage, bE as encodePhantomBidDeclaration, bF as encodePhantomBidPaymasterAndData, bG as encodeUserOpScale, bH as getChainId, bI as getConfigByStateMachineId, bJ as getFillOptionsVersion, bK as getViemChain, bL as hyperbridgeAddress, bM as pharosAtlantic, bN as pharosMainnet, bO as polkadotAssetHubPaseo, bP as polkadotHubMainnet, bQ as poolSlug, bR as readProtocolFeeHaircutBps, bS as resetFillOptionsVersionCache, bT as sortPoolSymbols, bU as tronChainIds, bV as tronNile } from './intents-helpers-fntBuoYM.cjs';
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 OrderFeesQuote, M as ERC7821Call, N as TokenInfo, U as OrderWithStatus, V as OrderStatus, W as FillOptions, X as TokenGatewayAssetTeleportedWithStatus, Y as TeleportStatus, Z as DecodedOrderPlacedLog, _ as DecodedPostRequestEvent, $ as DecodedPostResponseEvent } from './intents-helpers-BHl2If1T.cjs';
2
+ export { a0 as AllStatusKey, a1 as AssetTeleportedResponse, a2 as BidStorageEntry, a3 as BidSubmissionResult, a4 as BlockMetadata, a5 as BytesLikeHex, a6 as CancelOptions, a7 as ChainConfig, a8 as ChainConfigData, a9 as ConfiguredAssetSymbolInput, aa as Deployment, ab as DispatchGet, ac as DispatchInfo, ad as DispatchPost, ae as Erc4626VaultConfigData, af as ExecuteIntentOrderOptions, ag as ExecutionResult, ah as FillerConfig, ai as GetRequestResponse, aj as GetResponseByRequestIdResponse, ak as GetResponseStorageValues, al as HostParams, am as HyperClientStatus, an as IBatchConsensusAndGetResponseMessage, ao as IBatchConsensusAndPostRequestMessage, ap as IConfig, aq as IConsensusMessage, ar as IGetRequestMessage, as as IGetResponse, at as IGetResponseMessage, au as IHyperbridgeConfig, av as INCLUSION_TIMEOUT_MS, aw as IPostResponse, ax as IRequestMessage, ay as ISubstrateConfig, az as ITimeoutPostRequestMessage, aA as IntentGatewayABI, aB as IntentGatewayParams, aC as IntentOrderStatus, aD as IntentOrderStatusKey, aE as IsmpRequest, aF as MAX_DECLARED_ENTRIES, aG as OrderResponse, aH as OrderStatusMetadata, aI as PERMIT2_SPONSORSHIP_BYTES, aJ as PaymentInfo, aK as PhantomBidDeclaration, aL as PhantomBidPaymasterAndData, aM as PhantomBidSponsorship, aN as PostRequestStatus, aO as RequestBody, aP as RequestCommitment, aQ as RequestKind, aR as RequestResponse, aS as RequestStatus, aT as RequestStatusKey, aU as RpcBidInfo, aV as SelectOptions, aW as SigningAccount, aX as StateMachineId, aY as StateMachineResponse, aZ as StorageFacade, a_ as TimeoutStatus, a$ as TimeoutStatusKey, b0 as TokenGatewayAssetTeleportedResponse, b1 as TokenPrice, b2 as TokenPricesResponse, b3 as chainConfigs, b4 as convertCodecToIGetRequest, b5 as convertCodecToIProof, b6 as convertIGetRequestToCodec, b7 as convertIProofToCodec, b8 as convertStateIdToStateMachineId, b9 as convertStateMachineEnumToString, ba as convertStateMachineIdToEnum, bb as decodeAcceptedSourceChains, bc as decodeERC7821ExecuteBatch, bd as decodePhantomBidDeclaration, be as decodePhantomBidPaymasterAndData, bf as decodeUserOpScale, bg as deriveHttpUrl, bh as encodeAcceptedSourceChains, bi as encodeERC7821ExecuteBatch, bj as encodeISMPMessage, bk as encodePhantomBidDeclaration, bl as encodePhantomBidPaymasterAndData, bm as encodeUserOpScale, bn as getChainId, bo as getConfigByStateMachineId, bp as getViemChain, bq as hyperbridgeAddress, br as pharosAtlantic, bs as pharosMainnet, bt as polkadotAssetHubPaseo, bu as polkadotHubMainnet, bv as poolSlug, bw as sortPoolSymbols, bx as tronChainIds, by as tronNile } from './intents-helpers-BHl2If1T.cjs';
3
3
  import { ConsolaInstance } from 'consola';
4
4
  import { GraphQLClient } from 'graphql-request';
5
5
  import { PublicClient, TransactionReceipt, Hex, Address } from 'viem';
@@ -12,7 +12,6 @@ export { Account as ViemAccount } from 'viem/accounts';
12
12
  import 'decimal.js';
13
13
  import 'viem/chains';
14
14
  import '@polkadot/keyring/types';
15
- import '@polkadot/types/interfaces';
16
15
 
17
16
  /**
18
17
  * The default address used as fallback when no address is provided.
@@ -1680,152 +1679,350 @@ interface IntentGatewayContext {
1680
1679
  swap: Swap;
1681
1680
  }
1682
1681
 
1683
- type IntentQuoteStrategy = "indexed_rates" | "uniswap_v4" | "phantom_snapshot";
1684
- type IntentQuoteTradeType = "EXACT_INPUT" | "EXACT_OUTPUT";
1685
- type IndexedRateSide = "buy" | "sell";
1682
+ /** The HyperFX orderbook deployments, one per network. */
1683
+ declare const ORDERBOOK_URLS: {
1684
+ readonly mainnet: "https://orderbook.hyperfx.finance/mainnet/graphql";
1685
+ readonly testnet: "https://orderbook.hyperfx.finance/testnet/graphql";
1686
+ };
1687
+ /** The orderbook deployment that serves `stateMachineId`: the testnet book for a testnet chain, else mainnet. */
1688
+ declare function orderbookUrlFor(stateMachineId: string): string;
1689
+ /** Every amount and rate the orderbook takes or returns is fixed-point at 1e18, whatever the token's decimals. */
1690
+ declare const ORDERBOOK_DECIMALS = 18;
1691
+ /** `BID` takes a swap selling the book's base; `ASK` takes a swap buying it. */
1692
+ type OrderbookSide = "BID" | "ASK";
1693
+ /** `SAME_CHAIN` is served by every order on the chain; `CROSS_CHAIN` only by orders declaring the source. */
1694
+ type OrderbookRouteKind = "SAME_CHAIN" | "CROSS_CHAIN";
1695
+ /** A swap route, by token symbol and state machine id (`EVM-8453`). */
1696
+ interface OrderbookRoute {
1697
+ tokenIn: string;
1698
+ tokenOut: string;
1699
+ /** Where the swapper's `tokenIn` is escrowed. */
1700
+ sourceChain: string;
1701
+ /** Where `tokenOut` is delivered, which is the chain the order is filled on. */
1702
+ destinationChain: string;
1703
+ }
1704
+ /** A configured book. Every rate on it is `quote` per 1 `base`. */
1705
+ interface OrderbookBook {
1706
+ id: string;
1707
+ base: string;
1708
+ quote: string;
1709
+ }
1710
+ /** The best price level for one direction on one fill chain. Amounts and rates at 1e18. */
1711
+ interface OrderbookRate {
1712
+ side: OrderbookSide;
1713
+ fillChain: string;
1714
+ /** The level's best single-order price, quote per 1 base. */
1715
+ rate: bigint;
1716
+ /** Virtual depth: the level's summed order sizes, in tokenIn and tokenOut. */
1717
+ depthIn: bigint;
1718
+ depthOut: bigint;
1719
+ /** True liquidity: each solver's largest validated order in the level, summed, in tokenOut. */
1720
+ backingLiquidity: bigint;
1721
+ sourceChains: string[];
1722
+ orderCount: number;
1723
+ solverCount: number;
1724
+ }
1725
+ /** What a route holds, without an amount. Amounts and rates at 1e18. */
1726
+ interface OrderbookRouteLiquidity {
1727
+ route: OrderbookRouteKind;
1728
+ /** The book the route trades on, which names the units of `bestRate`. */
1729
+ book: OrderbookBook;
1730
+ /** `BID` when tokenIn is the book's base, `ASK` when it is the quote. */
1731
+ side: OrderbookSide;
1732
+ /** Quote per 1 base, before the protocol fee; null when no order serves the route. */
1733
+ bestRate: bigint | null;
1734
+ /** The destination chain's protocol fee in basis points, which the gateway takes out of what the orders deliver. */
1735
+ slippageBps: number;
1736
+ /** Virtual depth: the serving orders' sizes summed, in tokenIn and tokenOut. */
1737
+ depthIn: bigint;
1738
+ depthOut: bigint;
1739
+ /** True liquidity in tokenOut: each serving solver's largest validated order, summed. */
1740
+ availableLiquidity: bigint;
1741
+ /** The largest tokenIn amount the route could fill with its orders combined. */
1742
+ maxFillableIn: bigint;
1743
+ orderCount: number;
1744
+ solverCount: number;
1745
+ }
1746
+ /** One order an optimistic quote takes, at the order's own price. Amounts and rates at 1e18. */
1747
+ interface OrderbookQuoteFill {
1748
+ /** The order's full advertised size, not just the part this fill takes. */
1749
+ advertisedSize: bigint;
1750
+ /** The order's own price, quote per 1 base, before the protocol fee: what this fill settles at. */
1751
+ orderRate: bigint;
1752
+ /** The tokenIn this fill takes, in whole raw units on the source chain. */
1753
+ amountIn: bigint;
1754
+ /** The tokenOut this fill delivers, after the protocol fee, floored to a whole raw unit on the destination chain. */
1755
+ amountOut: bigint;
1756
+ }
1686
1757
  /**
1687
- * Full Uniswap V4 PoolKey. V4 pools cannot be discovered from a token pair alone.
1758
+ * An optimistic quote for an input amount on a route: the trade split across the route's orders,
1759
+ * best price first, each at its own price. There is no one rate and no total output; the fills are
1760
+ * the quote. Amounts and rates at 1e18.
1688
1761
  */
1689
- interface UniswapV4PoolKey {
1690
- currency0: HexString;
1691
- currency1: HexString;
1692
- fee: number;
1693
- tickSpacing: number;
1694
- hooks: HexString;
1762
+ interface OrderbookSwapQuote {
1763
+ route: OrderbookRouteKind;
1764
+ side: OrderbookSide;
1765
+ /** The tokenIn priced, floored to a whole raw unit on the source chain. */
1766
+ amountIn: bigint;
1767
+ /** The destination chain's protocol fee in basis points, already taken off every fill's `amountOut`. */
1768
+ slippageBps: number;
1769
+ fillable: boolean;
1770
+ /** The largest tokenIn amount the route's orders could take together, each at its own price. */
1771
+ maxFillableIn: bigint;
1772
+ /** The orders used, best price first; empty when not fillable. */
1773
+ fills: OrderbookQuoteFill[];
1695
1774
  }
1696
- interface UniswapV4IntentQuoteOptions {
1697
- /** Explicit pool override for pairs not yet present in SDK chain config. */
1698
- poolKey?: UniswapV4PoolKey & {
1699
- quoterAddress?: HexString;
1700
- /**
1701
- * Destination-side address of the input currency. Defaults to
1702
- * `tokenIn`, which only works for same-chain quotes; pass this
1703
- * explicitly when source and destination chains differ. Must equal
1704
- * `currency0` or `currency1`.
1705
- */
1706
- currencyIn?: HexString;
1707
- };
1775
+ /**
1776
+ * A pessimistic quote for an input amount on a route: one price, from the first level, best first,
1777
+ * deep enough to fill the whole trade by itself, or else the route's worst price when its levels
1778
+ * together can. Amounts and rates at 1e18.
1779
+ */
1780
+ interface OrderbookLevelQuote {
1781
+ route: OrderbookRouteKind;
1782
+ side: OrderbookSide;
1783
+ /** The tokenIn priced, floored to a whole raw unit on the source chain. */
1784
+ amountIn: bigint;
1785
+ /** The tokenOut delivered at `rate`, after the protocol fee, floored to a whole raw unit on the destination chain; 0 when not fillable. */
1786
+ amountOut: bigint;
1787
+ /** The worst single-order price in the level that fills it, quote per 1 base, before the protocol fee; null when not fillable. */
1788
+ rate: bigint | null;
1789
+ /** The price bucket of that level; null when not fillable. */
1790
+ priceBucket: bigint | null;
1791
+ /** The destination chain's protocol fee in basis points, already taken off `amountOut`. */
1792
+ slippageBps: number;
1793
+ fillable: boolean;
1794
+ /** The largest tokenIn amount this quote could fill: any one level at its worst price, or the whole route at its worst. */
1795
+ maxFillableIn: bigint;
1708
1796
  }
1797
+ /** The best bid and ask a route can reach, with the book that orients them. */
1798
+ interface OrderbookTopOfBook {
1799
+ book: OrderbookBook;
1800
+ /** Highest bid: the most quote a seller of 1 base receives. */
1801
+ bid: OrderbookRate | null;
1802
+ /** Lowest ask: the least quote a buyer of 1 base pays. */
1803
+ ask: OrderbookRate | null;
1804
+ }
1805
+ /** The orderbook could not answer: a transport failure, or a GraphQL error such as a pair no book trades. */
1806
+ declare class OrderbookRequestError extends Error {
1807
+ constructor(message: string);
1808
+ }
1809
+ /** Every document the client sends, so they can be checked against the orderbook's published schema. */
1810
+ declare const ORDERBOOK_QUERIES: {
1811
+ 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}";
1812
+ 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}";
1813
+ 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}";
1814
+ 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}";
1815
+ };
1709
1816
  /**
1710
- * Parameters for `IntentGateway.quoteIntent`. The source and destination
1711
- * chains come from the gateway instance itself.
1817
+ * Read-only client for the HyperFX orderbook's GraphQL API.
1712
1818
  *
1713
- * Quotes default to the aggregate pool's `indexed_rates`. Legacy Phantom
1714
- * snapshots and Uniswap V4 remain available as explicit strategies. `tokenIn`
1715
- * and `tokenOut` are token addresses; the SDK resolves configured token
1716
- * metadata and decimals internally. Provide exactly one amount.
1819
+ * Tokens are named by symbol and chains by state machine id. Every amount and
1820
+ * rate is a `bigint` at 1e18, as the orderbook serves it; rates are quote per 1
1821
+ * base of the pair's book.
1822
+ */
1823
+ declare class HyperFxOrderbook {
1824
+ private readonly client;
1825
+ /** @param urlOrClient - The orderbook's GraphQL URL, or a configured `graphql-request` client. */
1826
+ constructor(urlOrClient?: string | GraphQLClient);
1827
+ /**
1828
+ * The best bid and ask on `fillChain` for the pair `tokenA`/`tokenB`, counting
1829
+ * only orders a swap from `sourceChain` can use.
1830
+ */
1831
+ topOfBook(params: {
1832
+ tokenA: string;
1833
+ tokenB: string;
1834
+ fillChain: string;
1835
+ sourceChain: string;
1836
+ }): Promise<OrderbookTopOfBook>;
1837
+ /** Total liquidity on a route, no amount required. */
1838
+ routeLiquidity(route: OrderbookRoute): Promise<OrderbookRouteLiquidity>;
1839
+ /**
1840
+ * The optimistic quote for `amountIn` (1e18 tokenIn) on a route: the route's orders, best price
1841
+ * first, each taking what it can at its own price. The fills' `amountOut`s sum to the output.
1842
+ */
1843
+ quote(route: OrderbookRoute, amountIn: bigint): Promise<OrderbookSwapQuote>;
1844
+ /**
1845
+ * The pessimistic quote for `amountIn` (1e18 tokenIn) on a route: one price, from the first level
1846
+ * deep enough to fill the whole trade by itself, at which every order in it fills; the route's
1847
+ * worst price when no one level can but its levels together can.
1848
+ */
1849
+ quotePessimistic(route: OrderbookRoute, amountIn: bigint): Promise<OrderbookLevelQuote>;
1850
+ private request;
1851
+ }
1852
+
1853
+ /**
1854
+ * Parameters for `IntentGateway.quoteIntent`. The source and destination chains
1855
+ * come from the gateway instance itself. `tokenIn` and `tokenOut` are token
1856
+ * addresses; the SDK resolves their configured symbols and decimals. Provide
1857
+ * exactly one amount, in the token's raw units.
1717
1858
  */
1718
1859
  interface QuoteIntentParams {
1719
- strategy?: IntentQuoteStrategy;
1720
1860
  /** Token address on the source chain. */
1721
1861
  tokenIn: HexString;
1722
1862
  /** Token address on the destination chain. */
1723
1863
  tokenOut: HexString;
1724
1864
  amountIn?: bigint;
1725
1865
  amountOut?: bigint;
1726
- uniswapV4?: UniswapV4IntentQuoteOptions;
1727
- }
1728
- interface UniswapV4IntentQuoteMetadata {
1729
- /** Chain whose Uniswap pool and quoter were used for the quote. */
1730
- quoteChain: string;
1731
- poolKey: UniswapV4PoolKey;
1732
- quoterAddress: HexString;
1733
1866
  /**
1734
- * IntentGateway protocol fee on the source chain, already applied to the
1735
- * returned amounts. Exposed so callers can reconstruct the swap-side
1736
- * (post-fee) amount if needed.
1867
+ * Return the orderbook's optimistic quote (`QuoteIntentResult`): one leg per
1868
+ * order, each at its own price. Defaults to the pessimistic quote
1869
+ * (`PessimisticQuoteIntentResult`): the whole trade at one price.
1737
1870
  */
1738
- protocolFeeBps: bigint;
1739
- }
1740
- interface PhantomSnapshotIntentQuoteMetadata {
1741
- /** Canonical chain whose directional Phantom pair addresses identify the feed. */
1742
- quoteChain: string;
1743
- /** Phantom order whose bids produced this snapshot. */
1744
- commitment: HexString;
1745
- tokenA: HexString;
1746
- tokenB: HexString;
1747
- /** Benchmark input and liquidity-weighted median output, both in raw token units. */
1748
- standardAmount: bigint;
1749
- medianPrice: bigint;
1750
- lowestPrice?: bigint;
1751
- highestPrice?: bigint;
1752
- blockNumber: bigint;
1753
- snapshotTime: Date;
1754
- bidCount: number;
1755
- /** Source gateway protocol fee already reflected in the returned quote amounts. */
1756
- protocolFeeBps: bigint;
1757
- }
1758
- interface IndexedRateIntentQuoteMetadata {
1759
- sourceChain: Chains;
1760
- destinationChain: Chains;
1761
- baseTokenSymbol: ConfiguredAssetSymbol;
1762
- quoteTokenSymbol: ConfiguredAssetSymbol;
1763
- /** Directional pool rate used for this order. */
1764
- rateSide: IndexedRateSide;
1765
- /** Quote-token units per one base token. */
1766
- rate: string;
1767
- rateUpdatedAt: Date;
1768
- /** Source gateway protocol fee already reflected in the returned quote amounts. */
1769
- protocolFeeBps: bigint;
1871
+ optimistic?: boolean;
1770
1872
  }
1771
1873
  /**
1772
- * Quote data partners need before constructing an IntentGateway V2 order.
1773
- *
1774
- * `amountIn` and `amountOut` already account for the IntentGateway protocol
1775
- * fee that the gateway deducts from order inputs (see `quoteMetadata`). No
1776
- * further fee or slippage adjustment is required before placing the order.
1874
+ * One order an optimistic intent quote takes, at the order's own price. Amounts
1875
+ * are raw token units; the rate stays at 1e18.
1777
1876
  */
1778
- interface UniswapV4QuoteIntentResult {
1779
- strategy: "uniswap_v4";
1780
- tradeType: IntentQuoteTradeType;
1877
+ interface IntentQuoteLeg {
1878
+ /** The order's full advertised size in `tokenOut`, not just the part this leg takes. */
1879
+ advertisedSize: bigint;
1880
+ /** The order's own price, quote per 1 base at 1e18, before the protocol fee: what this leg settles at. */
1881
+ orderRate: bigint;
1882
+ /** The `tokenIn` this leg takes. The legs' inputs sum to the quote's `amountIn`. */
1781
1883
  amountIn: bigint;
1884
+ /** The `tokenOut` this leg delivers, with the destination's protocol fee already taken off. */
1782
1885
  amountOut: bigint;
1783
- quoteMetadata: UniswapV4IntentQuoteMetadata;
1784
1886
  }
1785
- interface PhantomSnapshotQuoteIntentResult {
1786
- strategy: "phantom_snapshot";
1787
- tradeType: IntentQuoteTradeType;
1887
+ /**
1888
+ * `quoteIntent`'s result with `optimistic: true`, the orderbook's optimistic `quote`: the trade split across the
1889
+ * route's orders, best price first, each at its own price. There is no single
1890
+ * rate or total output; the legs are the quote, and their `amountOut`s sum to
1891
+ * what the order should require. Amounts are raw token units.
1892
+ */
1893
+ interface QuoteIntentResult {
1894
+ /** `SAME_CHAIN`, or `CROSS_CHAIN` when only orders accepting the source chain can fill it. */
1895
+ route: OrderbookRouteKind;
1896
+ /** `BID` when the order sells the book's base token, `ASK` when it buys it. */
1897
+ side: OrderbookSide;
1898
+ /** The `tokenIn` priced: the requested input, or the input found to deliver the requested output. */
1788
1899
  amountIn: bigint;
1789
- amountOut: bigint;
1790
- quoteMetadata: PhantomSnapshotIntentQuoteMetadata;
1900
+ /** The destination's protocol fee in basis points, already taken off every leg's `amountOut`. */
1901
+ slippageBps: number;
1902
+ fillable: boolean;
1903
+ /** The largest `amountIn` the route's orders could take together, each at its own price. */
1904
+ maxFillableIn: bigint;
1905
+ /** The orders used, best price first. */
1906
+ legs: IntentQuoteLeg[];
1791
1907
  }
1792
- interface IndexedRateQuoteIntentResult {
1793
- strategy: "indexed_rates";
1794
- tradeType: IntentQuoteTradeType;
1908
+ /**
1909
+ * `quoteIntent`'s default result, the orderbook's `quotePessimistic`: the whole trade at one
1910
+ * price, the worst single-order price of the first level, best first, deep
1911
+ * enough to fill it by itself, or the route's worst price when no one level
1912
+ * can. Amounts are raw token units; rates stay at 1e18.
1913
+ */
1914
+ interface PessimisticQuoteIntentResult {
1915
+ route: OrderbookRouteKind;
1916
+ side: OrderbookSide;
1917
+ /** The `tokenIn` priced: the requested input, or the input found to deliver the requested output. */
1795
1918
  amountIn: bigint;
1919
+ /** The `tokenOut` delivered at `rate`, with the destination's protocol fee already taken off. */
1796
1920
  amountOut: bigint;
1797
- quoteMetadata: IndexedRateIntentQuoteMetadata;
1921
+ /** Quote per 1 base, before the protocol fee: every order in the level fills at it. */
1922
+ rate: bigint | null;
1923
+ /** The price bucket of that level. */
1924
+ priceBucket: bigint | null;
1925
+ /** The destination's protocol fee in basis points, already taken off `amountOut`. */
1926
+ slippageBps: number;
1927
+ fillable: boolean;
1928
+ /** The largest `amountIn` this quote could fill: any one level at its worst price, or the whole route at its worst. */
1929
+ maxFillableIn: bigint;
1798
1930
  }
1799
- type QuoteIntentResult = IndexedRateQuoteIntentResult | UniswapV4QuoteIntentResult | PhantomSnapshotQuoteIntentResult;
1800
- declare class UnsupportedIntentQuoteStrategyError extends Error {
1801
- constructor(strategy: string);
1931
+ /**
1932
+ * What the orderbook holds for one route, with no amount given. Amounts are
1933
+ * decimal strings in whole tokens.
1934
+ */
1935
+ interface AvailableLiquidity {
1936
+ sourceChain: Chains;
1937
+ destinationChain: Chains;
1938
+ tokenInSymbol: ConfiguredAssetSymbol;
1939
+ tokenOutSymbol: ConfiguredAssetSymbol;
1940
+ /** `tokenOut` on the destination chain. */
1941
+ tokenAddress: HexString;
1942
+ route: OrderbookRouteKind;
1943
+ side: OrderbookSide;
1944
+ baseTokenSymbol: ConfiguredAssetSymbol;
1945
+ quoteTokenSymbol: ConfiguredAssetSymbol;
1946
+ /** The best rate on the route in quote-token units per one base token, or `null` when no order serves it. */
1947
+ bestRate: string | null;
1948
+ /** True liquidity in `tokenOut`: each serving solver's largest balance-checked order, summed. */
1949
+ availableLiquidity: string;
1950
+ /** Virtual depth: every serving order's size summed, in `tokenIn` and `tokenOut`. Can exceed what solvers hold. */
1951
+ depthIn: string;
1952
+ depthOut: string;
1953
+ /** The largest `tokenIn` amount the route could fill with its orders combined. */
1954
+ maxFillableIn: string;
1955
+ orderCount: number;
1956
+ solverCount: number;
1802
1957
  }
1803
- declare class UnsupportedIntentQuotePairError extends Error {
1804
- constructor(params: {
1805
- source: string;
1806
- destination: string;
1807
- tokenIn: HexString;
1808
- tokenOut: HexString;
1809
- quoteSource?: string;
1810
- });
1958
+ /**
1959
+ * The best bid and ask for a pair on a route, in quote-token units per one base
1960
+ * token, as decimal strings. Either side is `null` while it has no orders.
1961
+ */
1962
+ interface BuyAndSellRates {
1963
+ baseTokenSymbol: ConfiguredAssetSymbol;
1964
+ quoteTokenSymbol: ConfiguredAssetSymbol;
1965
+ sourceChain: Chains;
1966
+ destinationChain: Chains;
1967
+ /** Highest bid: the quote token a seller receives per one base token. */
1968
+ bid: string | null;
1969
+ /** Lowest ask: the quote token a buyer pays per one base token. */
1970
+ ask: string | null;
1971
+ /** Midpoint of `bid` and `ask`; `null` unless both sides have orders. */
1972
+ mid: string | null;
1973
+ /** `ask - bid`; `null` when a side is empty or the book is crossed. */
1974
+ spread: string | null;
1975
+ /** `spread` over `mid` in basis points, to two decimal places. */
1976
+ spreadBps: number | null;
1811
1977
  }
1812
- declare class PhantomSnapshotUnavailableError extends Error {
1813
- constructor(tokenA: HexString, tokenB: HexString);
1978
+ declare class UnsupportedLiquidityAssetError extends Error {
1979
+ constructor(chain: string, asset: string);
1814
1980
  }
1815
- declare class InvalidPhantomSnapshotError extends Error {
1816
- constructor(commitment: HexString, reason: string);
1981
+ declare class UnsupportedLiquidityChainError extends Error {
1982
+ constructor(chainId: number | string);
1817
1983
  }
1818
- declare class IndexedRateUnavailableError extends Error {
1819
- constructor(params: {
1820
- source?: string;
1821
- destination?: string;
1822
- tokenIn?: string;
1823
- tokenOut?: string;
1824
- side?: IndexedRateSide;
1825
- });
1984
+ /**
1985
+ * An exact-output quote did not settle on an input within its rounds: each quoted input's clearing
1986
+ * price still fell short of the output. The route may have the depth; the book moved or its levels
1987
+ * are too steep to converge on in time. Retrying, or quoting an exact input, may succeed.
1988
+ */
1989
+ declare class OrderbookQuoteNotConvergedError extends Error {
1990
+ readonly route: {
1991
+ tokenIn: string;
1992
+ tokenOut: string;
1993
+ sourceChain: string;
1994
+ destinationChain: string;
1995
+ };
1996
+ readonly rounds: number;
1997
+ /** The last input quoted, in the source token's raw units. */
1998
+ readonly lastAmountIn: bigint;
1999
+ constructor(route: {
2000
+ tokenIn: string;
2001
+ tokenOut: string;
2002
+ sourceChain: string;
2003
+ destinationChain: string;
2004
+ }, rounds: number,
2005
+ /** The last input quoted, in the source token's raw units. */
2006
+ lastAmountIn: bigint);
1826
2007
  }
1827
- declare class InvalidIndexedRateError extends Error {
1828
- constructor(reason: string);
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);
1829
2026
  }
1830
2027
 
1831
2028
  /**
@@ -1833,8 +2030,7 @@ declare class InvalidIndexedRateError extends Error {
1833
2030
  *
1834
2031
  * `IntentGateway` orchestrates the complete lifecycle of an intent-based
1835
2032
  * cross-chain swap:
1836
- * - **Quoting** — prices the order's input/output amounts from aggregate
1837
- * indexed pool rates by default, with legacy quote strategies available explicitly.
2033
+ * - **Quoting** — prices orders, liquidity and rates from the HyperFX orderbook.
1838
2034
  * - **Order placement** — encodes and yields `placeOrder` calldata; caller
1839
2035
  * signs and submits the transaction.
1840
2036
  * - **Order execution** — polls the Hyperbridge coprocessor for solver bids,
@@ -1876,8 +2072,10 @@ declare class IntentGateway {
1876
2072
  private readonly bidManager;
1877
2073
  /** Estimates gas costs for filling an order and converts them to fee-token amounts. */
1878
2074
  private readonly gasEstimator;
1879
- /** Quote strategies for pricing orders before placement, keyed by strategy name. */
1880
- private readonly quoteStrategies;
2075
+ /** The HyperFX orderbook quotes, liquidity and rates are read from. */
2076
+ private orderbook;
2077
+ /** Prices intents, liquidity and rates from {@link orderbook}. */
2078
+ private readonly market;
1881
2079
  /**
1882
2080
  * Private constructor — use {@link IntentGateway.create} instead.
1883
2081
  *
@@ -1913,42 +2111,57 @@ declare class IntentGateway {
1913
2111
  */
1914
2112
  private init;
1915
2113
  /**
1916
- * Quotes an intent between this gateway's source and destination chains.
1917
- *
1918
- * Uses the indexer's latest aggregate directional pool rate by default. Pass
1919
- * `strategy: "phantom_snapshot"` or `strategy: "uniswap_v4"` only when
1920
- * explicitly requesting a legacy quote source. Provide exactly one of
1921
- * `amountIn` or `amountOut`.
1922
- *
1923
- * The gateway's source and destination chains resolve the configured order
1924
- * tokens; the indexer supplies the depth-weighted pool rate. Returned
1925
- * `amountIn`/`amountOut` already account for the gateway's protocol fee
1926
- * (`quoteMetadata.protocolFeeBps`), which the gateway deducts from order inputs.
2114
+ * Points quotes, liquidity and rate reads at a HyperFX orderbook other than
2115
+ * the destination chain's network deployment ({@link ORDERBOOK_URLS}).
2116
+ * Returns `this` for chaining.
1927
2117
  *
1928
- * @param params - Token pair, amount, and optional strategy/pool overrides.
1929
- * @returns The quoted amounts plus strategy-specific metadata.
1930
- * @throws {UnsupportedIntentQuoteStrategyError} For unknown strategies.
1931
- * @throws {UnsupportedIntentQuotePairError} When the selected strategy does not support the pair.
1932
- * @throws {IndexedRateUnavailableError} When the requested direction has no indexed rate.
2118
+ * @param orderbook - The orderbook's GraphQL URL, or a configured client.
1933
2119
  */
1934
- quoteIntent(params: QuoteIntentParams): Promise<QuoteIntentResult>;
2120
+ withOrderbook(orderbook: string | HyperFxOrderbook): this;
1935
2121
  /**
1936
- * Returns indexed destination liquidity and its source-routing slices.
2122
+ * Quotes an intent between this gateway's source and destination chains from
2123
+ * the HyperFX orderbook. Provide exactly one of `amountIn` or `amountOut`, in
2124
+ * raw token units. The result has the orderbook's shape, in raw token units.
1937
2125
  *
1938
- * Destination, unrestricted, and explicit-route capacity come exclusively
1939
- * from the indexer's pair-centric liquidity entities. The SDK does not decide
1940
- * whether unrestricted bidders cover the source chain. Amounts reflect the
1941
- * latest rolling sample; they are not reservations or fill guarantees.
2126
+ * By default the quote is pessimistic (`PessimisticQuoteIntentResult`): the
2127
+ * whole trade at one price, the worst single-order price of the first level,
2128
+ * best first, deep enough to fill it by itself, or the route's worst price
2129
+ * when no one level can. With `optimistic: true` it is the orderbook's
2130
+ * optimistic quote (`QuoteIntentResult`): the route's orders, best price
2131
+ * first, each filling what it can of the trade at its own price, one leg per
2132
+ * order. There is no total output; the legs' `amountOut`s sum to it.
1942
2133
  *
1943
- * Requires a prior call to {@link withQueryClient}.
2134
+ * Every `amountOut` already has the destination's protocol fee taken off. For
2135
+ * an exact output, the quote is for an input that delivers `amountOut`. A
2136
+ * cross-chain route only counts orders whose solvers accept the source chain.
2137
+ *
2138
+ * @throws {InsufficientOrderbookLiquidityError} When the route cannot fill the amount.
2139
+ * @throws {OrderbookQuoteNotConvergedError} When an exact-output quote does not settle on an input.
2140
+ * @throws {OrderbookRequestError} When the orderbook is unreachable or trades no book for the pair.
2141
+ */
2142
+ quoteIntent(params: QuoteIntentParams & {
2143
+ optimistic: true;
2144
+ }): Promise<QuoteIntentResult>;
2145
+ quoteIntent(params: QuoteIntentParams & {
2146
+ optimistic?: false;
2147
+ }): Promise<PessimisticQuoteIntentResult>;
2148
+ quoteIntent(params: QuoteIntentParams): Promise<QuoteIntentResult | PessimisticQuoteIntentResult>;
2149
+ /**
2150
+ * Returns the orderbook liquidity serving a swap of `tokenIn` on the source
2151
+ * chain for `tokenOut` on the destination chain: the best rate, true and
2152
+ * virtual depth, and the largest input the route can fill.
2153
+ *
2154
+ * Amounts reflect the live book; they are not reservations or fill guarantees.
1944
2155
  */
1945
- queryAvailableLiquidity(params: Pick<QuoteIntentParams, "tokenIn" | "tokenOut">): Promise<AvailableLiquidity | undefined>;
2156
+ queryAvailableLiquidity(params: Pick<QuoteIntentParams, "tokenIn" | "tokenOut">): Promise<AvailableLiquidity>;
1946
2157
  /**
1947
- * Returns aggregate indexed pool buy and sell rates in less-valued quote-token
1948
- * units without requiring token addresses. Symbols are matched
1949
- * case-insensitively; chain IDs resolve configured token deployments.
2158
+ * Returns the orderbook's best bid and ask for a pair, with the mid and
2159
+ * spread, in quote-token units per one base token. Only orders filled on the
2160
+ * destination chain that accept swaps from the source chain are counted.
2161
+ * Symbols are matched case-insensitively; chain IDs resolve configured token
2162
+ * deployments.
1950
2163
  */
1951
- queryBuyAndSellRates(params: QueryBuyAndSellRatesParams): Promise<BuyAndSellRates | undefined>;
2164
+ queryBuyAndSellRates(params: QueryBuyAndSellRatesParams): Promise<BuyAndSellRates>;
1952
2165
  /**
1953
2166
  * Bidirectional async generator that orchestrates the full order lifecycle:
1954
2167
  * placement, fee estimation, bid collection, and execution.
@@ -2087,6 +2300,8 @@ declare class IntentGateway {
2087
2300
  /**
2088
2301
  * Returns both the native token cost and the relayer fee for cancelling an
2089
2302
  * order. Use `relayerFee` to approve the ERC-20 spend before submitting.
2303
+ * Same-chain orders use the direct local route for either `from` option and
2304
+ * return `{ nativeValue: 0n, relayerFee: 0n }`.
2090
2305
  *
2091
2306
  * Delegates to {@link OrderCanceller.quoteCancelOrder}.
2092
2307
  *
@@ -2104,9 +2319,17 @@ declare class IntentGateway {
2104
2319
  *
2105
2320
  * Delegates to {@link OrderCanceller.cancelOrder}.
2106
2321
  *
2322
+ * Same-chain orders always use the direct source-gateway route. The order
2323
+ * user may call through the deadline; any account may call strictly after
2324
+ * it, pays the transaction gas, and cannot change the refund beneficiary.
2325
+ * The SDK yields unsigned transaction fields and accepts either the caller's
2326
+ * signed raw transaction or its already-broadcast transaction hash.
2327
+ *
2107
2328
  * @param order - The order to cancel.
2108
- * @param indexerClient - Indexer client used for ISMP request status streaming.
2109
- * @param options - Choose the initiation side. Defaults to source-side cancellation.
2329
+ * @param indexerClient - Indexer client used for cross-chain ISMP request
2330
+ * status streaming; the same-chain route does not access it.
2331
+ * @param options - Choose the cross-chain initiation side. Defaults to source;
2332
+ * ignored for routing when source and destination are the same chain.
2110
2333
  * @yields {@link CancelEvent} objects describing each cancellation stage.
2111
2334
  */
2112
2335
  cancelOrder(order: Order, indexerClient: IsmpClient, options?: CancelOrderOptions): AsyncGenerator<CancelEvent>;
@@ -2228,15 +2451,23 @@ declare class IntentGateway {
2228
2451
  */
2229
2452
  decodeERC7821Execute(callData: HexString): ERC7821Call[] | null;
2230
2453
  /**
2231
- * Checks whether an order has been filled on the destination chain.
2454
+ * Checks whether an order is finalized on the destination chain.
2232
2455
  *
2233
2456
  * Delegates to {@link OrderStatusChecker.isOrderFilled}.
2234
2457
  *
2235
2458
  * @param order - The order to check.
2236
- * @returns `true` if the order's commitment slot on the destination chain is
2237
- * non-zero (i.e. `fillOrder` has been called successfully).
2459
+ * @returns `true` once a completing fill or a destination-side cancellation
2460
+ * has finalized the order; `false` while it is open or only partly filled.
2238
2461
  */
2239
2462
  isOrderFilled(order: Order): Promise<boolean>;
2463
+ /**
2464
+ * Output credited to the order so far, one entry per leg.
2465
+ *
2466
+ * Delegates to {@link OrderStatusChecker.getFillProgress}.
2467
+ *
2468
+ * @param order - The order to check.
2469
+ */
2470
+ getFillProgress(order: Order): Promise<TokenInfo[]>;
2240
2471
  /**
2241
2472
  * Checks whether all escrowed inputs for an order have been refunded on the
2242
2473
  * source chain.
@@ -2244,8 +2475,8 @@ declare class IntentGateway {
2244
2475
  * Delegates to {@link OrderStatusChecker.isOrderRefunded}.
2245
2476
  *
2246
2477
  * @param order - The order to check.
2247
- * @returns `true` if every input token's escrowed amount has been zeroed out
2248
- * in the `_orders` mapping on the source chain.
2478
+ * @returns `true` if every input's escrowed amount has been zeroed out
2479
+ * in the per-leg `_orders` mapping on the source chain.
2249
2480
  */
2250
2481
  isOrderRefunded(order: Order): Promise<boolean>;
2251
2482
  /**
@@ -2294,16 +2525,6 @@ declare class IntentGateway {
2294
2525
  }, void>;
2295
2526
  }
2296
2527
 
2297
- declare class InvalidLiquidityIndexerResponseError extends Error {
2298
- constructor(reason: string);
2299
- }
2300
- declare class UnsupportedLiquidityAssetError extends Error {
2301
- constructor(chain: string, asset: string);
2302
- }
2303
- declare class UnsupportedLiquidityChainError extends Error {
2304
- constructor(chainId: number | string);
2305
- }
2306
-
2307
2528
  /**
2308
2529
  * Checks the on-chain fill and refund status of IntentGatewayV2 orders.
2309
2530
  *
@@ -2318,20 +2539,28 @@ declare class OrderStatusChecker {
2318
2539
  */
2319
2540
  constructor(ctx: IntentGatewayContext);
2320
2541
  /**
2321
- * Checks if a V2 order has been filled by reading the commitment storage slot on the destination chain.
2322
- *
2323
- * Reads the storage slot returned by `calculateCommitmentSlotHash` on the IntentGatewayV2 contract.
2324
- * A non-zero value at that slot means the solver has called `fillOrder` and the order is complete
2325
- * from the user's perspective (the beneficiary has received their tokens).
2542
+ * Whether the order is finalized on the destination chain, read from the gateway's `_filled`
2543
+ * getter. It is set by the completing fill, and by a cancellation, which records the refund
2544
+ * beneficiary there. A partially filled order reads false; see {@link getFillProgress}.
2326
2545
  *
2327
2546
  * @param order - The V2 order to check. `order.id` is used as the commitment; if not set it is computed.
2328
- * @returns True if the order has been filled on the destination chain, false otherwise.
2329
2547
  */
2330
2548
  isOrderFilled(order: Order): Promise<boolean>;
2549
+ /**
2550
+ * Output credited to the order so far, one entry per leg, read from `_partialFills` on the
2551
+ * destination chain. Several solvers can each fill a slice of a same-chain or cross-chain order,
2552
+ * so this, not {@link isOrderFilled}, says how far along an open order is. Surplus paid above
2553
+ * the order's rate is not counted.
2554
+ *
2555
+ * @param order - The V2 order to check. `order.id` is used as the commitment; if not set it is computed.
2556
+ */
2557
+ getFillProgress(order: Order): Promise<TokenInfo[]>;
2331
2558
  /**
2332
2559
  * Checks if a V2 order has been refunded by reading the `_orders` mapping on the source chain.
2333
2560
  *
2334
- * Calls `_orders(commitment, tokenAddress)` for each input token. When the order is placed the
2561
+ * Calls `_orders(commitment, index)` for each input: escrow is held per leg, keyed by the input's
2562
+ * index, so inputs that repeat a token are read separately. A gateway not yet upgraded to per-leg
2563
+ * escrow is read by token instead, see {@link readLegEscrow}. When the order is placed the
2335
2564
  * escrowed amounts are stored there. After a successful refund the contract zeroes them out.
2336
2565
  * An order is considered refunded when all escrowed input amounts have been returned (i.e. are 0).
2337
2566
  *
@@ -2341,6 +2570,31 @@ declare class OrderStatusChecker {
2341
2570
  isOrderRefunded(order: Order): Promise<boolean>;
2342
2571
  }
2343
2572
 
2573
+ type ReadClient = Pick<PublicClient, "readContract">;
2574
+ /**
2575
+ * Escrow held for leg `index` of an order on its source chain: `_orders(commitment, index)`, or
2576
+ * `_orders(commitment, token)` on a gateway that has not been upgraded to per-leg escrow.
2577
+ *
2578
+ * @param client - Public client of the order's source chain.
2579
+ * @param gateway - IntentGatewayV2 address on that chain.
2580
+ * @param commitment - The order commitment.
2581
+ * @param index - Leg index into `order.inputs`.
2582
+ * @param token - `order.inputs[index].token`, as bytes32 or a 20-byte address.
2583
+ */
2584
+ declare function readLegEscrow(client: ReadClient, gateway: HexString, commitment: HexString, index: number, token: HexString): Promise<bigint>;
2585
+ /**
2586
+ * Output delivered so far for leg `index` of an order on its destination chain:
2587
+ * `_partialFills(commitment, index)`, or `_partialFills(commitment, token)` on a gateway that has not
2588
+ * been upgraded to per-leg escrow.
2589
+ *
2590
+ * @param client - Public client of the order's destination chain.
2591
+ * @param gateway - IntentGatewayV2 address on that chain.
2592
+ * @param commitment - The order commitment.
2593
+ * @param index - Leg index into `order.output.assets`.
2594
+ * @param token - `order.output.assets[index].token` as bytes32.
2595
+ */
2596
+ declare function readLegPartialFill(client: ReadClient, gateway: HexString, commitment: HexString, index: number, token: HexString): Promise<bigint>;
2597
+
2344
2598
  type ContractOrder = Omit<Order, "id" | "source" | "destination"> & {
2345
2599
  source: HexString;
2346
2600
  destination: HexString;
@@ -2467,17 +2721,32 @@ declare class CryptoUtils {
2467
2721
  static computeUserOpHash(userOp: PackedUserOperation, entryPoint: Hex, chainId: bigint): Hex;
2468
2722
  /**
2469
2723
  * Derives the ERC-4337 nonce key that binds a bid UserOperation to its
2470
- * order and session key: the lower 192 bits of
2471
- * `keccak256(commitment ‖ sessionKey)`. `SolverAccount` rejects bid
2472
- * operations whose nonce key differs — this is what lets the solver sign
2473
- * the plain userOpHash while staying committed to the order and to the
2474
- * session key it bid against.
2724
+ * order, session key and calldata: the lower 192 bits of
2725
+ * `keccak256(commitment ‖ sessionKey ‖ keccak256(callData))`. `SolverAccount`
2726
+ * rejects bid operations whose nonce key differs — this is what lets the
2727
+ * solver sign the plain userOpHash while staying committed to the order and
2728
+ * to the session key it bid against.
2729
+ *
2730
+ * The calldata gives every bid its own key. A solver bidding several prices
2731
+ * on one order signs one op per price, and each is sequence 0 of its own key,
2732
+ * so they execute independently rather than in a sequence where one bid that
2733
+ * is never selected blocks the rest.
2475
2734
  *
2476
2735
  * @param commitment - The order commitment (`order.id`).
2477
2736
  * @param sessionKey - The order's session key address (`order.session`).
2737
+ * @param callData - The UserOperation's `callData`.
2478
2738
  * @returns The 192-bit nonce key as a bigint (pass to `EntryPoint.getNonce`).
2479
2739
  */
2480
- static bidNonceKey(commitment: HexString, sessionKey: HexString): bigint;
2740
+ static bidNonceKey(commitment: HexString, sessionKey: HexString, callData: HexString): bigint;
2741
+ /**
2742
+ * The identifier Hyperbridge files a bid under: `keccak256` of the UserOp's
2743
+ * `callData`. It is the same hash {@link bidNonceKey} takes, so a bid's
2744
+ * identifier and its nonce key both follow from the op itself, and one
2745
+ * solver's bids on one order are kept apart for the same reason on both sides.
2746
+ *
2747
+ * @param callData - The UserOperation's `callData`.
2748
+ */
2749
+ static bidId(callData: HexString): HexString;
2481
2750
  /**
2482
2751
  * Builds the EIP-712 typed-data payload whose digest is the EntryPoint v0.8
2483
2752
  * `userOpHash` (i.e. `hashTypedData(packedUserOpTypedData(...)) ===
@@ -2666,6 +2935,49 @@ declare class CryptoUtils {
2666
2935
  decodeERC7821Execute(callData: HexString): ERC7821Call[] | null;
2667
2936
  }
2668
2937
 
2938
+ type DecodedFillOrder = {
2939
+ order: Order;
2940
+ options: FillOptions;
2941
+ };
2942
+ /** `fillOrder(Order, FillOptions)` selector, pinned by codec tests; avoids import-time hashing in VM2. */
2943
+ declare const FILL_ORDER_SELECTOR: "0x68ddf058";
2944
+ /** The gateway release this SDK speaks. SolverAccount carries no version, so only the gateway is read. */
2945
+ declare const SUPPORTED_INTENTS_VERSION = 3n;
2946
+ declare const CONTRACT_VERSION_ABI: readonly [{
2947
+ readonly type: "function";
2948
+ readonly name: "version";
2949
+ readonly stateMutability: "view";
2950
+ readonly inputs: readonly [];
2951
+ readonly outputs: readonly [{
2952
+ readonly name: "";
2953
+ readonly type: "uint64";
2954
+ }];
2955
+ }];
2956
+ /** Whether the gateway reports the supported release. RPC failures propagate. */
2957
+ declare function supportsRateFills(client: PublicClient, gateway: HexString): Promise<boolean>;
2958
+ /** The gateway must report release {@link SUPPORTED_INTENTS_VERSION}; a missing getter or any other release throws. */
2959
+ declare function assertGatewayRelease(client: PublicClient, gateway: HexString): Promise<void>;
2960
+ /** A bytes32 token whose upper 12 bytes are zero, the only form the gateway accepts. */
2961
+ declare function isCanonicalEvmToken(token: string): boolean;
2962
+ /** ABI-encodes a `fillOrder` call. Every leg must carry a validated quote. */
2963
+ declare function encodeFillOrder(order: Order, options: FillOptions): HexString;
2964
+ /**
2965
+ * Decodes a `fillOrder` call.
2966
+ *
2967
+ * @returns The decoded order and options, or `null` if the calldata is not a `fillOrder` call in
2968
+ * the current shape or its quotes do not cover the order's legs.
2969
+ */
2970
+ declare function decodeFillOrder(data: HexString): DecodedFillOrder | null;
2971
+
2972
+ interface RateFillPreview {
2973
+ credit: bigint;
2974
+ release: bigint;
2975
+ delivered: bigint;
2976
+ surplus: bigint;
2977
+ }
2978
+ /** Estimates settlement at the supplied progress. The signed take/offered amounts remain caps. */
2979
+ declare function previewRateFill(escrow: bigint, required: bigint, filled: bigint, take: bigint, offered: bigint): RateFillPreview;
2980
+
2669
2981
  declare const ABI: readonly [{
2670
2982
  readonly type: "receive";
2671
2983
  readonly stateMutability: "payable";
@@ -6144,4 +6456,4 @@ declare function teleport(teleport_param: {
6144
6456
  extrinsics?: Array<SubmittableExtrinsic<"promise", ISubmittableResult>>;
6145
6457
  }): Promise<ReadableStream<HyperbridgeTxEvents>>;
6146
6458
 
6147
- export { ADDRESS_ZERO, AssetTeleported, AvailableLiquidity, Bid, type BridgeParams, type BridgeStep, type BundlerGasEstimate, BundlerMethod, BuyAndSellRates, type CancelEvent, CancelOrderOptions, CancelQuote, ChainConfigService, Chains, ClientConfig, ConfiguredAssetSymbol, CryptoUtils, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, DecodedOrderPlacedLog, DecodedPostRequestEvent, DecodedPostResponseEvent, ERC20Method, ERC7821Call, ERC7821_BATCH_MODE, EstimateFillOrderParams, EstimateGasCallData, EvmChain, type EvmChainParams, ABI as EvmHostABI, EvmLanguage, FillOrderEstimate, FillerBid, GetRequestWithStatus, HexString, HyperFungibleToken, HyperFungibleTokenABI, type HyperbridgeTxEvents, IChain, IEvmChain, IEvmConfig, IGetRequest, IIsmpMessage, IMessage, IPharosConfig, IPolkadotHubConfig, IPostRequest, IProof, type IndexedRateIntentQuoteMetadata, type IndexedRateQuoteIntentResult, type IndexedRateSide, IndexedRateUnavailableError, IndexerQueryClient, IntentGateway, type IntentGatewayContext, IntentOrderStatusUpdate, type IntentQuoteStrategy, type IntentQuoteTradeType, IntentsCoprocessor, InvalidIndexedRateError, InvalidLiquidityIndexerResponseError, InvalidPhantomSnapshotError, IsmpClient, MOCK_ADDRESS, ORDER_V2_PARAM_TYPE, Order, OrderFeesQuote, OrderStatus, OrderStatusChecker, OrderWithStatus, PACKED_USEROP_TYPEHASH, PLACE_ORDER_SELECTOR, PackedUserOperation, type Params, type PhantomSnapshotIntentQuoteMetadata, type PhantomSnapshotQuoteIntentResult, PhantomSnapshotUnavailableError, 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, RequestStatusWithMetadata, ResponseCommitmentWithValues, ResumeIntentOrderOptions, RetryConfig, SELECT_SOLVER_TYPEHASH, STATE_COMMITMENTS_SLOT, SelectBidResult, StateMachineHeight, StateMachineIdParams, StateMachineUpdate, SubmitBidOptions, SubstrateChain, Swap, TESTNET_CHAINS, type TeleportParams, TeleportStatus, TokenGateway, TokenGatewayAssetTeleportedWithStatus, Transaction, TronChain, type TronChainParams, USE_ETHERSCAN_CHAINS, type UniswapProtocol, type UniswapQuote, type UniswapQuoteToken, type UniswapTradeType, type UniswapV4IntentQuoteMetadata, type UniswapV4IntentQuoteOptions, type UniswapV4PoolKey, type UniswapV4QuoteIntentResult, UnsupportedIntentQuotePairError, UnsupportedIntentQuoteStrategyError, UnsupportedLiquidityAssetError, UnsupportedLiquidityChainError, WrappedHyperFungibleTokenABI, type XcmGatewayParams, __test, adjustDecimals, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, createEvmChain, createQueryClient, encodeStateMachineId, encodeWithdrawalRequest, estimateGasForPost, fetchPrice, fetchSourceProof, generateRootWithProof, getContractCallInput, getContractCallInputs, getGasPriceFromEtherscan, getOrFetchStorageSlot, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, hexToString, maxBigInt, normalizeAddressForEvmBytes32, normalizeAddressForStateMachine, normalizeEvmAddress, normalizeEvmChainId, normalizeStateMachineId, orderCommitment, parseStateMachineId, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, quoteUniswap, requestCommitmentKey, responseCommitmentKey, retryPromise, teleport, teleportDot, transformOrderForContract };
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, InsufficientOrderbookLiquidityError, 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 };