@hyperbridge/sdk 2.8.13 → 2.8.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.d.ts +748 -906
- package/dist/browser/index.js +1357 -2080
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +1377 -2098
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +405 -179
- package/dist/node/index.d.ts +405 -179
- package/dist/node/index.js +1357 -2080
- package/dist/node/index.js.map +1 -1
- package/dist/node/{intents-helpers-fntBuoYM.d.cts → intents-helpers-BHl2If1T.d.cts} +909 -2967
- package/dist/node/{intents-helpers-fntBuoYM.d.ts → intents-helpers-BHl2If1T.d.ts} +909 -2967
- package/dist/node/intents-helpers.cjs +371 -1215
- package/dist/node/intents-helpers.cjs.map +1 -1
- package/dist/node/intents-helpers.d.cts +1 -3
- package/dist/node/intents-helpers.d.ts +1 -3
- package/dist/node/intents-helpers.js +373 -1200
- package/dist/node/intents-helpers.js.map +1 -1
- package/package.json +1 -1
package/dist/node/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as IChain, H as HexString, a as IEvmConfig, C as ChainConfigService, b as IMessage, S as StateMachineIdParams, c as StateMachineHeight, d as IIsmpMessage, e as IPostRequest, f as IGetRequest, O as Order, E as EstimateGasCallData, R as RetryConfig, g as IPolkadotHubConfig, h as IPharosConfig, i as StateMachineUpdate, P as PostRequestWithStatus, G as GetRequestWithStatus, j as ResponseCommitmentWithValues, k as RequestStatusWithMetadata, l as PostRequestTimeoutStatus, m as SubstrateChain, n as ClientConfig, o as IndexerQueryClient, A as AssetTeleported, T as Transaction, p as IProof, q as IEvmChain, r as IntentsCoprocessor, s as Chains, t as ConfiguredAssetSymbol,
|
|
2
|
-
export { a0 as AllStatusKey, a1 as AssetTeleportedResponse, a2 as BidStorageEntry, a3 as BidSubmissionResult, a4 as BlockMetadata, a5 as BytesLikeHex, a6 as
|
|
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,275 @@ interface IntentGatewayContext {
|
|
|
1680
1679
|
swap: Swap;
|
|
1681
1680
|
}
|
|
1682
1681
|
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
*/
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
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;
|
|
1695
1703
|
}
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
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; null when no order serves the route. */
|
|
1733
|
+
bestRate: bigint | null;
|
|
1734
|
+
/** Virtual depth: the serving orders' sizes summed, in tokenIn and tokenOut. */
|
|
1735
|
+
depthIn: bigint;
|
|
1736
|
+
depthOut: bigint;
|
|
1737
|
+
/** True liquidity in tokenOut: each serving solver's largest validated order, summed. */
|
|
1738
|
+
availableLiquidity: bigint;
|
|
1739
|
+
/** The largest tokenIn amount the route could fill with its orders combined. */
|
|
1740
|
+
maxFillableIn: bigint;
|
|
1741
|
+
orderCount: number;
|
|
1742
|
+
solverCount: number;
|
|
1743
|
+
}
|
|
1744
|
+
/** A quote for an input amount on a route. Amounts and rates at 1e18. */
|
|
1745
|
+
interface OrderbookSwapQuote {
|
|
1746
|
+
route: OrderbookRouteKind;
|
|
1747
|
+
side: OrderbookSide;
|
|
1748
|
+
/** The tokenIn priced, floored to a whole raw unit on the source chain. */
|
|
1749
|
+
amountIn: bigint;
|
|
1750
|
+
/** The tokenOut delivered, floored to a whole raw unit on the destination chain; 0 when not fillable. */
|
|
1751
|
+
amountOut: bigint;
|
|
1752
|
+
/** The clearing price, quote per 1 base; null when the route cannot fill the amount. */
|
|
1753
|
+
rate: bigint | null;
|
|
1754
|
+
fillable: boolean;
|
|
1755
|
+
/** The tokenIn the route can absorb at `rate` or better. */
|
|
1756
|
+
depth: bigint;
|
|
1757
|
+
/** The largest tokenIn amount the route could fill. */
|
|
1758
|
+
maxFillableIn: bigint;
|
|
1759
|
+
/** The orders used, best first. */
|
|
1760
|
+
fills: {
|
|
1761
|
+
orderRate: bigint;
|
|
1762
|
+
amountOut: bigint;
|
|
1763
|
+
advertisedSize: bigint;
|
|
1764
|
+
}[];
|
|
1765
|
+
}
|
|
1766
|
+
/** The best bid and ask a route can reach, with the book that orients them. */
|
|
1767
|
+
interface OrderbookTopOfBook {
|
|
1768
|
+
book: OrderbookBook;
|
|
1769
|
+
/** Highest bid: the most quote a seller of 1 base receives. */
|
|
1770
|
+
bid: OrderbookRate | null;
|
|
1771
|
+
/** Lowest ask: the least quote a buyer of 1 base pays. */
|
|
1772
|
+
ask: OrderbookRate | null;
|
|
1773
|
+
}
|
|
1774
|
+
/** The orderbook could not answer: a transport failure, or a GraphQL error such as a pair no book trades. */
|
|
1775
|
+
declare class OrderbookRequestError extends Error {
|
|
1776
|
+
constructor(message: string);
|
|
1708
1777
|
}
|
|
1778
|
+
/** Every document the client sends, so they can be checked against the orderbook's published schema. */
|
|
1779
|
+
declare const ORDERBOOK_QUERIES: {
|
|
1780
|
+
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}";
|
|
1781
|
+
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}";
|
|
1782
|
+
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}";
|
|
1783
|
+
};
|
|
1709
1784
|
/**
|
|
1710
|
-
*
|
|
1711
|
-
* chains come from the gateway instance itself.
|
|
1785
|
+
* Read-only client for the HyperFX orderbook's GraphQL API.
|
|
1712
1786
|
*
|
|
1713
|
-
*
|
|
1714
|
-
*
|
|
1715
|
-
*
|
|
1716
|
-
|
|
1787
|
+
* Tokens are named by symbol and chains by state machine id. Every amount and
|
|
1788
|
+
* rate is a `bigint` at 1e18, as the orderbook serves it; rates are quote per 1
|
|
1789
|
+
* base of the pair's book.
|
|
1790
|
+
*/
|
|
1791
|
+
declare class HyperFxOrderbook {
|
|
1792
|
+
private readonly client;
|
|
1793
|
+
/** @param urlOrClient - The orderbook's GraphQL URL, or a configured `graphql-request` client. */
|
|
1794
|
+
constructor(urlOrClient?: string | GraphQLClient);
|
|
1795
|
+
/**
|
|
1796
|
+
* The best bid and ask on `fillChain` for the pair `tokenA`/`tokenB`, counting
|
|
1797
|
+
* only orders a swap from `sourceChain` can use.
|
|
1798
|
+
*/
|
|
1799
|
+
topOfBook(params: {
|
|
1800
|
+
tokenA: string;
|
|
1801
|
+
tokenB: string;
|
|
1802
|
+
fillChain: string;
|
|
1803
|
+
sourceChain: string;
|
|
1804
|
+
}): Promise<OrderbookTopOfBook>;
|
|
1805
|
+
/** Total liquidity on a route, no amount required. */
|
|
1806
|
+
routeLiquidity(route: OrderbookRoute): Promise<OrderbookRouteLiquidity>;
|
|
1807
|
+
/** The clearing price for `amountIn` (1e18 tokenIn) on a route, which may combine several solvers' orders. */
|
|
1808
|
+
quote(route: OrderbookRoute, amountIn: bigint): Promise<OrderbookSwapQuote>;
|
|
1809
|
+
private request;
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1812
|
+
type IntentQuoteTradeType = "EXACT_INPUT" | "EXACT_OUTPUT";
|
|
1813
|
+
/**
|
|
1814
|
+
* Parameters for `IntentGateway.quoteIntent`. The source and destination chains
|
|
1815
|
+
* come from the gateway instance itself. `tokenIn` and `tokenOut` are token
|
|
1816
|
+
* addresses; the SDK resolves their configured symbols and decimals. Provide
|
|
1817
|
+
* exactly one amount, in the token's raw units.
|
|
1717
1818
|
*/
|
|
1718
1819
|
interface QuoteIntentParams {
|
|
1719
|
-
strategy?: IntentQuoteStrategy;
|
|
1720
1820
|
/** Token address on the source chain. */
|
|
1721
1821
|
tokenIn: HexString;
|
|
1722
1822
|
/** Token address on the destination chain. */
|
|
1723
1823
|
tokenOut: HexString;
|
|
1724
1824
|
amountIn?: bigint;
|
|
1725
1825
|
amountOut?: bigint;
|
|
1726
|
-
uniswapV4?: UniswapV4IntentQuoteOptions;
|
|
1727
1826
|
}
|
|
1728
|
-
interface
|
|
1729
|
-
/** Chain whose Uniswap pool and quoter were used for the quote. */
|
|
1730
|
-
quoteChain: string;
|
|
1731
|
-
poolKey: UniswapV4PoolKey;
|
|
1732
|
-
quoterAddress: HexString;
|
|
1733
|
-
/**
|
|
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.
|
|
1737
|
-
*/
|
|
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 {
|
|
1827
|
+
interface IntentQuoteMetadata {
|
|
1759
1828
|
sourceChain: Chains;
|
|
1760
1829
|
destinationChain: Chains;
|
|
1830
|
+
/** `SAME_CHAIN`, or `CROSS_CHAIN` when only orders accepting the source chain can fill it. */
|
|
1831
|
+
route: OrderbookRouteKind;
|
|
1832
|
+
/** `BID` when the order sells the book's base token, `ASK` when it buys it. */
|
|
1833
|
+
side: OrderbookSide;
|
|
1761
1834
|
baseTokenSymbol: ConfiguredAssetSymbol;
|
|
1762
1835
|
quoteTokenSymbol: ConfiguredAssetSymbol;
|
|
1763
|
-
/**
|
|
1764
|
-
rateSide: IndexedRateSide;
|
|
1765
|
-
/** Quote-token units per one base token. */
|
|
1836
|
+
/** The clearing price the order was quoted at, in quote-token units per one base token. */
|
|
1766
1837
|
rate: string;
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1838
|
+
/** The largest `amountIn` the route can fill right now, in the source token's raw units. */
|
|
1839
|
+
maxFillableIn: bigint;
|
|
1840
|
+
/** How many orders the quote combines. */
|
|
1841
|
+
orderCount: number;
|
|
1770
1842
|
}
|
|
1771
1843
|
/**
|
|
1772
|
-
*
|
|
1844
|
+
* A quote priced from the HyperFX orderbook.
|
|
1773
1845
|
*
|
|
1774
|
-
* `amountIn` and `amountOut`
|
|
1775
|
-
*
|
|
1776
|
-
*
|
|
1846
|
+
* `amountIn` and `amountOut` are raw token units and can be used directly as
|
|
1847
|
+
* the order's `inputs` and `output.assets`. The orderbook's rates already carry
|
|
1848
|
+
* the IntentGateway protocol fee, so no further fee adjustment is needed.
|
|
1777
1849
|
*/
|
|
1778
|
-
interface
|
|
1779
|
-
strategy: "uniswap_v4";
|
|
1780
|
-
tradeType: IntentQuoteTradeType;
|
|
1781
|
-
amountIn: bigint;
|
|
1782
|
-
amountOut: bigint;
|
|
1783
|
-
quoteMetadata: UniswapV4IntentQuoteMetadata;
|
|
1784
|
-
}
|
|
1785
|
-
interface PhantomSnapshotQuoteIntentResult {
|
|
1786
|
-
strategy: "phantom_snapshot";
|
|
1850
|
+
interface QuoteIntentResult {
|
|
1787
1851
|
tradeType: IntentQuoteTradeType;
|
|
1788
1852
|
amountIn: bigint;
|
|
1789
1853
|
amountOut: bigint;
|
|
1790
|
-
quoteMetadata:
|
|
1854
|
+
quoteMetadata: IntentQuoteMetadata;
|
|
1791
1855
|
}
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1856
|
+
/**
|
|
1857
|
+
* What the orderbook holds for one route, with no amount given. Amounts are
|
|
1858
|
+
* decimal strings in whole tokens.
|
|
1859
|
+
*/
|
|
1860
|
+
interface AvailableLiquidity {
|
|
1861
|
+
sourceChain: Chains;
|
|
1862
|
+
destinationChain: Chains;
|
|
1863
|
+
tokenInSymbol: ConfiguredAssetSymbol;
|
|
1864
|
+
tokenOutSymbol: ConfiguredAssetSymbol;
|
|
1865
|
+
/** `tokenOut` on the destination chain. */
|
|
1866
|
+
tokenAddress: HexString;
|
|
1867
|
+
route: OrderbookRouteKind;
|
|
1868
|
+
side: OrderbookSide;
|
|
1869
|
+
baseTokenSymbol: ConfiguredAssetSymbol;
|
|
1870
|
+
quoteTokenSymbol: ConfiguredAssetSymbol;
|
|
1871
|
+
/** The best rate on the route in quote-token units per one base token, or `null` when no order serves it. */
|
|
1872
|
+
bestRate: string | null;
|
|
1873
|
+
/** True liquidity in `tokenOut`: each serving solver's largest balance-checked order, summed. */
|
|
1874
|
+
availableLiquidity: string;
|
|
1875
|
+
/** Virtual depth: every serving order's size summed, in `tokenIn` and `tokenOut`. Can exceed what solvers hold. */
|
|
1876
|
+
depthIn: string;
|
|
1877
|
+
depthOut: string;
|
|
1878
|
+
/** The largest `tokenIn` amount the route could fill with its orders combined. */
|
|
1879
|
+
maxFillableIn: string;
|
|
1880
|
+
orderCount: number;
|
|
1881
|
+
solverCount: number;
|
|
1802
1882
|
}
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1883
|
+
/**
|
|
1884
|
+
* The best bid and ask for a pair on a route, in quote-token units per one base
|
|
1885
|
+
* token, as decimal strings. Either side is `null` while it has no orders.
|
|
1886
|
+
*/
|
|
1887
|
+
interface BuyAndSellRates {
|
|
1888
|
+
baseTokenSymbol: ConfiguredAssetSymbol;
|
|
1889
|
+
quoteTokenSymbol: ConfiguredAssetSymbol;
|
|
1890
|
+
sourceChain: Chains;
|
|
1891
|
+
destinationChain: Chains;
|
|
1892
|
+
/** Highest bid: the quote token a seller receives per one base token. */
|
|
1893
|
+
bid: string | null;
|
|
1894
|
+
/** Lowest ask: the quote token a buyer pays per one base token. */
|
|
1895
|
+
ask: string | null;
|
|
1896
|
+
/** Midpoint of `bid` and `ask`; `null` unless both sides have orders. */
|
|
1897
|
+
mid: string | null;
|
|
1898
|
+
/** `ask - bid`; `null` when a side is empty or the book is crossed. */
|
|
1899
|
+
spread: string | null;
|
|
1900
|
+
/** `spread` over `mid` in basis points, to two decimal places. */
|
|
1901
|
+
spreadBps: number | null;
|
|
1811
1902
|
}
|
|
1812
|
-
declare class
|
|
1813
|
-
constructor(
|
|
1903
|
+
declare class UnsupportedLiquidityAssetError extends Error {
|
|
1904
|
+
constructor(chain: string, asset: string);
|
|
1814
1905
|
}
|
|
1815
|
-
declare class
|
|
1816
|
-
constructor(
|
|
1906
|
+
declare class UnsupportedLiquidityChainError extends Error {
|
|
1907
|
+
constructor(chainId: number | string);
|
|
1817
1908
|
}
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1909
|
+
/**
|
|
1910
|
+
* An exact-output quote did not settle on an input within its rounds: each quoted input's clearing
|
|
1911
|
+
* price still fell short of the output. The route may have the depth; the book moved or its levels
|
|
1912
|
+
* are too steep to converge on in time. Retrying, or quoting an exact input, may succeed.
|
|
1913
|
+
*/
|
|
1914
|
+
declare class OrderbookQuoteNotConvergedError extends Error {
|
|
1915
|
+
readonly route: {
|
|
1916
|
+
tokenIn: string;
|
|
1917
|
+
tokenOut: string;
|
|
1918
|
+
sourceChain: string;
|
|
1919
|
+
destinationChain: string;
|
|
1920
|
+
};
|
|
1921
|
+
readonly rounds: number;
|
|
1922
|
+
/** The last input quoted, in the source token's raw units. */
|
|
1923
|
+
readonly lastAmountIn: bigint;
|
|
1924
|
+
constructor(route: {
|
|
1925
|
+
tokenIn: string;
|
|
1926
|
+
tokenOut: string;
|
|
1927
|
+
sourceChain: string;
|
|
1928
|
+
destinationChain: string;
|
|
1929
|
+
}, rounds: number,
|
|
1930
|
+
/** The last input quoted, in the source token's raw units. */
|
|
1931
|
+
lastAmountIn: bigint);
|
|
1826
1932
|
}
|
|
1827
|
-
|
|
1828
|
-
|
|
1933
|
+
/** The orderbook cannot fill the requested amount on this route. */
|
|
1934
|
+
declare class InsufficientOrderbookLiquidityError extends Error {
|
|
1935
|
+
readonly route: {
|
|
1936
|
+
tokenIn: string;
|
|
1937
|
+
tokenOut: string;
|
|
1938
|
+
sourceChain: string;
|
|
1939
|
+
destinationChain: string;
|
|
1940
|
+
};
|
|
1941
|
+
/** The largest `amountIn` the route can fill, in the source token's raw units. */
|
|
1942
|
+
readonly maxFillableIn: bigint;
|
|
1943
|
+
constructor(route: {
|
|
1944
|
+
tokenIn: string;
|
|
1945
|
+
tokenOut: string;
|
|
1946
|
+
sourceChain: string;
|
|
1947
|
+
destinationChain: string;
|
|
1948
|
+
},
|
|
1949
|
+
/** The largest `amountIn` the route can fill, in the source token's raw units. */
|
|
1950
|
+
maxFillableIn: bigint);
|
|
1829
1951
|
}
|
|
1830
1952
|
|
|
1831
1953
|
/**
|
|
@@ -1833,8 +1955,7 @@ declare class InvalidIndexedRateError extends Error {
|
|
|
1833
1955
|
*
|
|
1834
1956
|
* `IntentGateway` orchestrates the complete lifecycle of an intent-based
|
|
1835
1957
|
* cross-chain swap:
|
|
1836
|
-
* - **Quoting** — prices
|
|
1837
|
-
* indexed pool rates by default, with legacy quote strategies available explicitly.
|
|
1958
|
+
* - **Quoting** — prices orders, liquidity and rates from the HyperFX orderbook.
|
|
1838
1959
|
* - **Order placement** — encodes and yields `placeOrder` calldata; caller
|
|
1839
1960
|
* signs and submits the transaction.
|
|
1840
1961
|
* - **Order execution** — polls the Hyperbridge coprocessor for solver bids,
|
|
@@ -1876,8 +1997,10 @@ declare class IntentGateway {
|
|
|
1876
1997
|
private readonly bidManager;
|
|
1877
1998
|
/** Estimates gas costs for filling an order and converts them to fee-token amounts. */
|
|
1878
1999
|
private readonly gasEstimator;
|
|
1879
|
-
/**
|
|
1880
|
-
private
|
|
2000
|
+
/** The HyperFX orderbook quotes, liquidity and rates are read from. */
|
|
2001
|
+
private orderbook;
|
|
2002
|
+
/** Prices intents, liquidity and rates from {@link orderbook}. */
|
|
2003
|
+
private readonly market;
|
|
1881
2004
|
/**
|
|
1882
2005
|
* Private constructor — use {@link IntentGateway.create} instead.
|
|
1883
2006
|
*
|
|
@@ -1913,42 +2036,46 @@ declare class IntentGateway {
|
|
|
1913
2036
|
*/
|
|
1914
2037
|
private init;
|
|
1915
2038
|
/**
|
|
1916
|
-
*
|
|
2039
|
+
* Points quotes, liquidity and rate reads at a HyperFX orderbook other than
|
|
2040
|
+
* the destination chain's network deployment ({@link ORDERBOOK_URLS}).
|
|
2041
|
+
* Returns `this` for chaining.
|
|
2042
|
+
*
|
|
2043
|
+
* @param orderbook - The orderbook's GraphQL URL, or a configured client.
|
|
2044
|
+
*/
|
|
2045
|
+
withOrderbook(orderbook: string | HyperFxOrderbook): this;
|
|
2046
|
+
/**
|
|
2047
|
+
* Quotes an intent between this gateway's source and destination chains from
|
|
2048
|
+
* the HyperFX orderbook. Provide exactly one of `amountIn` or `amountOut`, in
|
|
2049
|
+
* raw token units.
|
|
1917
2050
|
*
|
|
1918
|
-
*
|
|
1919
|
-
*
|
|
1920
|
-
*
|
|
1921
|
-
*
|
|
2051
|
+
* An exact-input quote is the orderbook's clearing price for `amountIn`,
|
|
2052
|
+
* which may combine several solvers' orders. An exact-output quote finds the
|
|
2053
|
+
* smallest input whose clearing price delivers `amountOut`. A cross-chain
|
|
2054
|
+
* route only counts orders whose solvers accept the source chain.
|
|
1922
2055
|
*
|
|
1923
|
-
* The
|
|
1924
|
-
*
|
|
1925
|
-
* `amountIn`/`amountOut` already account for the gateway's protocol fee
|
|
1926
|
-
* (`quoteMetadata.protocolFeeBps`), which the gateway deducts from order inputs.
|
|
2056
|
+
* The orderbook's rates already carry the gateway protocol fee, so the
|
|
2057
|
+
* returned amounts can be placed as the order's inputs and outputs directly.
|
|
1927
2058
|
*
|
|
1928
|
-
* @
|
|
1929
|
-
* @
|
|
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.
|
|
2059
|
+
* @throws {InsufficientOrderbookLiquidityError} When the route cannot fill the amount.
|
|
2060
|
+
* @throws {OrderbookRequestError} When the orderbook is unreachable or trades no book for the pair.
|
|
1933
2061
|
*/
|
|
1934
2062
|
quoteIntent(params: QuoteIntentParams): Promise<QuoteIntentResult>;
|
|
1935
2063
|
/**
|
|
1936
|
-
* Returns
|
|
2064
|
+
* Returns the orderbook liquidity serving a swap of `tokenIn` on the source
|
|
2065
|
+
* chain for `tokenOut` on the destination chain: the best rate, true and
|
|
2066
|
+
* virtual depth, and the largest input the route can fill.
|
|
1937
2067
|
*
|
|
1938
|
-
*
|
|
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.
|
|
1942
|
-
*
|
|
1943
|
-
* Requires a prior call to {@link withQueryClient}.
|
|
2068
|
+
* Amounts reflect the live book; they are not reservations or fill guarantees.
|
|
1944
2069
|
*/
|
|
1945
|
-
queryAvailableLiquidity(params: Pick<QuoteIntentParams, "tokenIn" | "tokenOut">): Promise<AvailableLiquidity
|
|
2070
|
+
queryAvailableLiquidity(params: Pick<QuoteIntentParams, "tokenIn" | "tokenOut">): Promise<AvailableLiquidity>;
|
|
1946
2071
|
/**
|
|
1947
|
-
* Returns
|
|
1948
|
-
* units
|
|
1949
|
-
*
|
|
2072
|
+
* Returns the orderbook's best bid and ask for a pair, with the mid and
|
|
2073
|
+
* spread, in quote-token units per one base token. Only orders filled on the
|
|
2074
|
+
* destination chain that accept swaps from the source chain are counted.
|
|
2075
|
+
* Symbols are matched case-insensitively; chain IDs resolve configured token
|
|
2076
|
+
* deployments.
|
|
1950
2077
|
*/
|
|
1951
|
-
queryBuyAndSellRates(params: QueryBuyAndSellRatesParams): Promise<BuyAndSellRates
|
|
2078
|
+
queryBuyAndSellRates(params: QueryBuyAndSellRatesParams): Promise<BuyAndSellRates>;
|
|
1952
2079
|
/**
|
|
1953
2080
|
* Bidirectional async generator that orchestrates the full order lifecycle:
|
|
1954
2081
|
* placement, fee estimation, bid collection, and execution.
|
|
@@ -2087,6 +2214,8 @@ declare class IntentGateway {
|
|
|
2087
2214
|
/**
|
|
2088
2215
|
* Returns both the native token cost and the relayer fee for cancelling an
|
|
2089
2216
|
* order. Use `relayerFee` to approve the ERC-20 spend before submitting.
|
|
2217
|
+
* Same-chain orders use the direct local route for either `from` option and
|
|
2218
|
+
* return `{ nativeValue: 0n, relayerFee: 0n }`.
|
|
2090
2219
|
*
|
|
2091
2220
|
* Delegates to {@link OrderCanceller.quoteCancelOrder}.
|
|
2092
2221
|
*
|
|
@@ -2104,9 +2233,17 @@ declare class IntentGateway {
|
|
|
2104
2233
|
*
|
|
2105
2234
|
* Delegates to {@link OrderCanceller.cancelOrder}.
|
|
2106
2235
|
*
|
|
2236
|
+
* Same-chain orders always use the direct source-gateway route. The order
|
|
2237
|
+
* user may call through the deadline; any account may call strictly after
|
|
2238
|
+
* it, pays the transaction gas, and cannot change the refund beneficiary.
|
|
2239
|
+
* The SDK yields unsigned transaction fields and accepts either the caller's
|
|
2240
|
+
* signed raw transaction or its already-broadcast transaction hash.
|
|
2241
|
+
*
|
|
2107
2242
|
* @param order - The order to cancel.
|
|
2108
|
-
* @param indexerClient - Indexer client used for ISMP request
|
|
2109
|
-
*
|
|
2243
|
+
* @param indexerClient - Indexer client used for cross-chain ISMP request
|
|
2244
|
+
* status streaming; the same-chain route does not access it.
|
|
2245
|
+
* @param options - Choose the cross-chain initiation side. Defaults to source;
|
|
2246
|
+
* ignored for routing when source and destination are the same chain.
|
|
2110
2247
|
* @yields {@link CancelEvent} objects describing each cancellation stage.
|
|
2111
2248
|
*/
|
|
2112
2249
|
cancelOrder(order: Order, indexerClient: IsmpClient, options?: CancelOrderOptions): AsyncGenerator<CancelEvent>;
|
|
@@ -2228,15 +2365,23 @@ declare class IntentGateway {
|
|
|
2228
2365
|
*/
|
|
2229
2366
|
decodeERC7821Execute(callData: HexString): ERC7821Call[] | null;
|
|
2230
2367
|
/**
|
|
2231
|
-
* Checks whether an order
|
|
2368
|
+
* Checks whether an order is finalized on the destination chain.
|
|
2232
2369
|
*
|
|
2233
2370
|
* Delegates to {@link OrderStatusChecker.isOrderFilled}.
|
|
2234
2371
|
*
|
|
2235
2372
|
* @param order - The order to check.
|
|
2236
|
-
* @returns `true`
|
|
2237
|
-
*
|
|
2373
|
+
* @returns `true` once a completing fill or a destination-side cancellation
|
|
2374
|
+
* has finalized the order; `false` while it is open or only partly filled.
|
|
2238
2375
|
*/
|
|
2239
2376
|
isOrderFilled(order: Order): Promise<boolean>;
|
|
2377
|
+
/**
|
|
2378
|
+
* Output credited to the order so far, one entry per leg.
|
|
2379
|
+
*
|
|
2380
|
+
* Delegates to {@link OrderStatusChecker.getFillProgress}.
|
|
2381
|
+
*
|
|
2382
|
+
* @param order - The order to check.
|
|
2383
|
+
*/
|
|
2384
|
+
getFillProgress(order: Order): Promise<TokenInfo[]>;
|
|
2240
2385
|
/**
|
|
2241
2386
|
* Checks whether all escrowed inputs for an order have been refunded on the
|
|
2242
2387
|
* source chain.
|
|
@@ -2244,8 +2389,8 @@ declare class IntentGateway {
|
|
|
2244
2389
|
* Delegates to {@link OrderStatusChecker.isOrderRefunded}.
|
|
2245
2390
|
*
|
|
2246
2391
|
* @param order - The order to check.
|
|
2247
|
-
* @returns `true` if every input
|
|
2248
|
-
* in the `_orders` mapping on the source chain.
|
|
2392
|
+
* @returns `true` if every input's escrowed amount has been zeroed out
|
|
2393
|
+
* in the per-leg `_orders` mapping on the source chain.
|
|
2249
2394
|
*/
|
|
2250
2395
|
isOrderRefunded(order: Order): Promise<boolean>;
|
|
2251
2396
|
/**
|
|
@@ -2294,16 +2439,6 @@ declare class IntentGateway {
|
|
|
2294
2439
|
}, void>;
|
|
2295
2440
|
}
|
|
2296
2441
|
|
|
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
2442
|
/**
|
|
2308
2443
|
* Checks the on-chain fill and refund status of IntentGatewayV2 orders.
|
|
2309
2444
|
*
|
|
@@ -2318,20 +2453,28 @@ declare class OrderStatusChecker {
|
|
|
2318
2453
|
*/
|
|
2319
2454
|
constructor(ctx: IntentGatewayContext);
|
|
2320
2455
|
/**
|
|
2321
|
-
*
|
|
2322
|
-
*
|
|
2323
|
-
*
|
|
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).
|
|
2456
|
+
* Whether the order is finalized on the destination chain, read from the gateway's `_filled`
|
|
2457
|
+
* getter. It is set by the completing fill, and by a cancellation, which records the refund
|
|
2458
|
+
* beneficiary there. A partially filled order reads false; see {@link getFillProgress}.
|
|
2326
2459
|
*
|
|
2327
2460
|
* @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
2461
|
*/
|
|
2330
2462
|
isOrderFilled(order: Order): Promise<boolean>;
|
|
2463
|
+
/**
|
|
2464
|
+
* Output credited to the order so far, one entry per leg, read from `_partialFills` on the
|
|
2465
|
+
* destination chain. Several solvers can each fill a slice of a same-chain or cross-chain order,
|
|
2466
|
+
* so this, not {@link isOrderFilled}, says how far along an open order is. Surplus paid above
|
|
2467
|
+
* the order's rate is not counted.
|
|
2468
|
+
*
|
|
2469
|
+
* @param order - The V2 order to check. `order.id` is used as the commitment; if not set it is computed.
|
|
2470
|
+
*/
|
|
2471
|
+
getFillProgress(order: Order): Promise<TokenInfo[]>;
|
|
2331
2472
|
/**
|
|
2332
2473
|
* Checks if a V2 order has been refunded by reading the `_orders` mapping on the source chain.
|
|
2333
2474
|
*
|
|
2334
|
-
* Calls `_orders(commitment,
|
|
2475
|
+
* Calls `_orders(commitment, index)` for each input: escrow is held per leg, keyed by the input's
|
|
2476
|
+
* index, so inputs that repeat a token are read separately. A gateway not yet upgraded to per-leg
|
|
2477
|
+
* escrow is read by token instead, see {@link readLegEscrow}. When the order is placed the
|
|
2335
2478
|
* escrowed amounts are stored there. After a successful refund the contract zeroes them out.
|
|
2336
2479
|
* An order is considered refunded when all escrowed input amounts have been returned (i.e. are 0).
|
|
2337
2480
|
*
|
|
@@ -2341,6 +2484,31 @@ declare class OrderStatusChecker {
|
|
|
2341
2484
|
isOrderRefunded(order: Order): Promise<boolean>;
|
|
2342
2485
|
}
|
|
2343
2486
|
|
|
2487
|
+
type ReadClient = Pick<PublicClient, "readContract">;
|
|
2488
|
+
/**
|
|
2489
|
+
* Escrow held for leg `index` of an order on its source chain: `_orders(commitment, index)`, or
|
|
2490
|
+
* `_orders(commitment, token)` on a gateway that has not been upgraded to per-leg escrow.
|
|
2491
|
+
*
|
|
2492
|
+
* @param client - Public client of the order's source chain.
|
|
2493
|
+
* @param gateway - IntentGatewayV2 address on that chain.
|
|
2494
|
+
* @param commitment - The order commitment.
|
|
2495
|
+
* @param index - Leg index into `order.inputs`.
|
|
2496
|
+
* @param token - `order.inputs[index].token`, as bytes32 or a 20-byte address.
|
|
2497
|
+
*/
|
|
2498
|
+
declare function readLegEscrow(client: ReadClient, gateway: HexString, commitment: HexString, index: number, token: HexString): Promise<bigint>;
|
|
2499
|
+
/**
|
|
2500
|
+
* Output delivered so far for leg `index` of an order on its destination chain:
|
|
2501
|
+
* `_partialFills(commitment, index)`, or `_partialFills(commitment, token)` on a gateway that has not
|
|
2502
|
+
* been upgraded to per-leg escrow.
|
|
2503
|
+
*
|
|
2504
|
+
* @param client - Public client of the order's destination chain.
|
|
2505
|
+
* @param gateway - IntentGatewayV2 address on that chain.
|
|
2506
|
+
* @param commitment - The order commitment.
|
|
2507
|
+
* @param index - Leg index into `order.output.assets`.
|
|
2508
|
+
* @param token - `order.output.assets[index].token` as bytes32.
|
|
2509
|
+
*/
|
|
2510
|
+
declare function readLegPartialFill(client: ReadClient, gateway: HexString, commitment: HexString, index: number, token: HexString): Promise<bigint>;
|
|
2511
|
+
|
|
2344
2512
|
type ContractOrder = Omit<Order, "id" | "source" | "destination"> & {
|
|
2345
2513
|
source: HexString;
|
|
2346
2514
|
destination: HexString;
|
|
@@ -2467,17 +2635,32 @@ declare class CryptoUtils {
|
|
|
2467
2635
|
static computeUserOpHash(userOp: PackedUserOperation, entryPoint: Hex, chainId: bigint): Hex;
|
|
2468
2636
|
/**
|
|
2469
2637
|
* Derives the ERC-4337 nonce key that binds a bid UserOperation to its
|
|
2470
|
-
* order
|
|
2471
|
-
* `keccak256(commitment ‖ sessionKey)`. `SolverAccount`
|
|
2472
|
-
* operations whose nonce key differs — this is what lets the
|
|
2473
|
-
* the plain userOpHash while staying committed to the order and
|
|
2474
|
-
* session key it bid against.
|
|
2638
|
+
* order, session key and calldata: the lower 192 bits of
|
|
2639
|
+
* `keccak256(commitment ‖ sessionKey ‖ keccak256(callData))`. `SolverAccount`
|
|
2640
|
+
* rejects bid operations whose nonce key differs — this is what lets the
|
|
2641
|
+
* solver sign the plain userOpHash while staying committed to the order and
|
|
2642
|
+
* to the session key it bid against.
|
|
2643
|
+
*
|
|
2644
|
+
* The calldata gives every bid its own key. A solver bidding several prices
|
|
2645
|
+
* on one order signs one op per price, and each is sequence 0 of its own key,
|
|
2646
|
+
* so they execute independently rather than in a sequence where one bid that
|
|
2647
|
+
* is never selected blocks the rest.
|
|
2475
2648
|
*
|
|
2476
2649
|
* @param commitment - The order commitment (`order.id`).
|
|
2477
2650
|
* @param sessionKey - The order's session key address (`order.session`).
|
|
2651
|
+
* @param callData - The UserOperation's `callData`.
|
|
2478
2652
|
* @returns The 192-bit nonce key as a bigint (pass to `EntryPoint.getNonce`).
|
|
2479
2653
|
*/
|
|
2480
|
-
static bidNonceKey(commitment: HexString, sessionKey: HexString): bigint;
|
|
2654
|
+
static bidNonceKey(commitment: HexString, sessionKey: HexString, callData: HexString): bigint;
|
|
2655
|
+
/**
|
|
2656
|
+
* The identifier Hyperbridge files a bid under: `keccak256` of the UserOp's
|
|
2657
|
+
* `callData`. It is the same hash {@link bidNonceKey} takes, so a bid's
|
|
2658
|
+
* identifier and its nonce key both follow from the op itself, and one
|
|
2659
|
+
* solver's bids on one order are kept apart for the same reason on both sides.
|
|
2660
|
+
*
|
|
2661
|
+
* @param callData - The UserOperation's `callData`.
|
|
2662
|
+
*/
|
|
2663
|
+
static bidId(callData: HexString): HexString;
|
|
2481
2664
|
/**
|
|
2482
2665
|
* Builds the EIP-712 typed-data payload whose digest is the EntryPoint v0.8
|
|
2483
2666
|
* `userOpHash` (i.e. `hashTypedData(packedUserOpTypedData(...)) ===
|
|
@@ -2666,6 +2849,49 @@ declare class CryptoUtils {
|
|
|
2666
2849
|
decodeERC7821Execute(callData: HexString): ERC7821Call[] | null;
|
|
2667
2850
|
}
|
|
2668
2851
|
|
|
2852
|
+
type DecodedFillOrder = {
|
|
2853
|
+
order: Order;
|
|
2854
|
+
options: FillOptions;
|
|
2855
|
+
};
|
|
2856
|
+
/** `fillOrder(Order, FillOptions)` selector, pinned by codec tests; avoids import-time hashing in VM2. */
|
|
2857
|
+
declare const FILL_ORDER_SELECTOR: "0x68ddf058";
|
|
2858
|
+
/** The gateway release this SDK speaks. SolverAccount carries no version, so only the gateway is read. */
|
|
2859
|
+
declare const SUPPORTED_INTENTS_VERSION = 3n;
|
|
2860
|
+
declare const CONTRACT_VERSION_ABI: readonly [{
|
|
2861
|
+
readonly type: "function";
|
|
2862
|
+
readonly name: "version";
|
|
2863
|
+
readonly stateMutability: "view";
|
|
2864
|
+
readonly inputs: readonly [];
|
|
2865
|
+
readonly outputs: readonly [{
|
|
2866
|
+
readonly name: "";
|
|
2867
|
+
readonly type: "uint64";
|
|
2868
|
+
}];
|
|
2869
|
+
}];
|
|
2870
|
+
/** Whether the gateway reports the supported release. RPC failures propagate. */
|
|
2871
|
+
declare function supportsRateFills(client: PublicClient, gateway: HexString): Promise<boolean>;
|
|
2872
|
+
/** The gateway must report release {@link SUPPORTED_INTENTS_VERSION}; a missing getter or any other release throws. */
|
|
2873
|
+
declare function assertGatewayRelease(client: PublicClient, gateway: HexString): Promise<void>;
|
|
2874
|
+
/** A bytes32 token whose upper 12 bytes are zero, the only form the gateway accepts. */
|
|
2875
|
+
declare function isCanonicalEvmToken(token: string): boolean;
|
|
2876
|
+
/** ABI-encodes a `fillOrder` call. Every leg must carry a validated quote. */
|
|
2877
|
+
declare function encodeFillOrder(order: Order, options: FillOptions): HexString;
|
|
2878
|
+
/**
|
|
2879
|
+
* Decodes a `fillOrder` call.
|
|
2880
|
+
*
|
|
2881
|
+
* @returns The decoded order and options, or `null` if the calldata is not a `fillOrder` call in
|
|
2882
|
+
* the current shape or its quotes do not cover the order's legs.
|
|
2883
|
+
*/
|
|
2884
|
+
declare function decodeFillOrder(data: HexString): DecodedFillOrder | null;
|
|
2885
|
+
|
|
2886
|
+
interface RateFillPreview {
|
|
2887
|
+
credit: bigint;
|
|
2888
|
+
release: bigint;
|
|
2889
|
+
delivered: bigint;
|
|
2890
|
+
surplus: bigint;
|
|
2891
|
+
}
|
|
2892
|
+
/** Estimates settlement at the supplied progress. The signed take/offered amounts remain caps. */
|
|
2893
|
+
declare function previewRateFill(escrow: bigint, required: bigint, filled: bigint, take: bigint, offered: bigint): RateFillPreview;
|
|
2894
|
+
|
|
2669
2895
|
declare const ABI: readonly [{
|
|
2670
2896
|
readonly type: "receive";
|
|
2671
2897
|
readonly stateMutability: "payable";
|
|
@@ -6144,4 +6370,4 @@ declare function teleport(teleport_param: {
|
|
|
6144
6370
|
extrinsics?: Array<SubmittableExtrinsic<"promise", ISubmittableResult>>;
|
|
6145
6371
|
}): Promise<ReadableStream<HyperbridgeTxEvents>>;
|
|
6146
6372
|
|
|
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,
|
|
6373
|
+
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 IntentQuoteMetadata, type IntentQuoteTradeType, IntentsCoprocessor, IsmpClient, MOCK_ADDRESS, ORDERBOOK_DECIMALS, ORDERBOOK_QUERIES, ORDERBOOK_URLS, ORDER_V2_PARAM_TYPE, Order, OrderFeesQuote, OrderStatus, OrderStatusChecker, OrderWithStatus, type OrderbookBook, 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, 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 };
|