@hyperbridge/sdk 2.8.2 → 2.8.4

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.
@@ -2,7 +2,7 @@ import { ConsolaInstance } from 'consola';
2
2
  import Decimal from 'decimal.js';
3
3
  import { GraphQLClient } from 'graphql-request';
4
4
  import * as viem from 'viem';
5
- import { PublicClient, TransactionReceipt, Hex, Log, ContractFunctionArgs } from 'viem';
5
+ import { PublicClient, TransactionReceipt, Hex, Log, ContractFunctionArgs, Chain as Chain$1 } from 'viem';
6
6
  import { Chain } from 'viem/chains';
7
7
  import { ApiPromise } from '@polkadot/api';
8
8
  import { KeyringPair } from '@polkadot/keyring/types';
@@ -886,7 +886,9 @@ declare const tronNile: {
886
886
  verifyHash?: ((client: viem.Client, parameters: viem.VerifyHashActionParameters) => Promise<viem.VerifyHashActionReturnType>) | undefined;
887
887
  };
888
888
  declare const tronChainIds: Set<number>;
889
- type ConfiguredAssetSymbol = "WETH" | "DAI" | "USDC" | "USDT" | "cNGN" | "EXT";
889
+ type ConfiguredAssetSymbol = "WETH" | "DAI" | "USDC" | "USDT" | "cNGN" | "EXT" | "ZARP" | "EURC" | "XSGD" | "TRYB" | "USDR";
890
+ /** A configured asset symbol in its canonical, lowercase, or uppercase form. */
891
+ type ConfiguredAssetSymbolInput = ConfiguredAssetSymbol | Lowercase<ConfiguredAssetSymbol> | Uppercase<ConfiguredAssetSymbol>;
890
892
  interface UniswapV4PoolConfigData {
891
893
  tokens: readonly [ConfiguredAssetSymbol, ConfiguredAssetSymbol];
892
894
  fee: number;
@@ -1015,7 +1017,7 @@ interface ChainConfigData {
1015
1017
  layerZeroEid?: number;
1016
1018
  }
1017
1019
  declare const chainConfigs: Record<number, ChainConfigData>;
1018
- declare const getConfigByStateMachineId: (id: Chains) => ChainConfigData | undefined;
1020
+ declare const getConfigByStateMachineId: (id: string) => ChainConfigData | undefined;
1019
1021
  declare const getChainId: (stateMachineId: string) => number | undefined;
1020
1022
  declare const getViemChain: (chainId: number) => Chain | undefined;
1021
1023
  declare const hyperbridgeAddress = "";
@@ -1056,6 +1058,12 @@ declare class ChainConfigService {
1056
1058
  * it, so a new asset is added once in `chain.ts` and nowhere else.
1057
1059
  */
1058
1060
  getAssetBySymbol(chain: string, symbol: string): HexString$1 | undefined;
1061
+ /** Resolves a configured token symbol case-insensitively on a specific chain. */
1062
+ getAssetMetadataBySymbol(chain: string, symbol: string): {
1063
+ symbol: ConfiguredAssetSymbol;
1064
+ address: HexString$1;
1065
+ decimals?: number;
1066
+ } | undefined;
1059
1067
  getCNgnDecimals(chain: string): number | undefined;
1060
1068
  getExtAsset(chain: string): HexString$1 | undefined;
1061
1069
  getExtDecimals(chain: string): number | undefined;
@@ -1372,6 +1380,25 @@ declare function convertCodecToIProof(codec: {
1372
1380
  }): IProof;
1373
1381
  declare function encodeISMPMessage(message: IIsmpMessage): Uint8Array;
1374
1382
 
1383
+ /**
1384
+ * How long a submitted extrinsic has to reach a block before the attempt is treated as stalled.
1385
+ *
1386
+ * Sized against the bid window, not against how long inclusion can conceivably take: a bid is worth
1387
+ * nothing once its window closes, so an extrinsic still sitting in the pool after a few blocks is
1388
+ * better replaced by a higher-tipped copy than waited on.
1389
+ */
1390
+ declare const INCLUSION_TIMEOUT_MS = 20000;
1391
+ /**
1392
+ * Maps a websocket endpoint onto the HTTP endpoint of the same node — substrate serves both on the
1393
+ * same host and port, so the scheme is the only difference. Throws for anything that is not a
1394
+ * `ws(s)://` url rather than guessing at an endpoint.
1395
+ *
1396
+ * The HTTP endpoint is always derived, never configured, because it must be the *same node* as the
1397
+ * websocket: phantom orders are read out of that node's offchain worker storage, which is
1398
+ * node-local and not replicated, so a separately configured host would return nothing for orders
1399
+ * the events said exist.
1400
+ */
1401
+ declare function deriveHttpUrl(wsUrl: string): string;
1375
1402
  /**
1376
1403
  * Encodes a PackedUserOperation using SCALE codec for submission to Hyperbridge.
1377
1404
  * This is the recommended way to encode UserOps for the intents coprocessor.
@@ -1403,8 +1430,41 @@ interface PhantomOrderEvent {
1403
1430
  */
1404
1431
  legs: PhantomOrderLeg[];
1405
1432
  }
1433
+ /** One phantom bid to place, and the bid it replaces on the same chain. */
1434
+ interface PhantomBid {
1435
+ /** The phantom order commitment being bid on. */
1436
+ commitment: HexString$1;
1437
+ /** The SCALE-encoded PackedUserOperation backing the quote. */
1438
+ userOp: HexString$1;
1439
+ /**
1440
+ * A live bid from a previous interval on the same chain, retracted alongside this one to
1441
+ * reclaim its deposit. Best-effort: a retraction that fails never affects the bid.
1442
+ */
1443
+ retractCommitment?: HexString$1;
1444
+ }
1445
+ /** What became of one bid in a batch. */
1446
+ interface PhantomBidOutcome {
1447
+ commitment: HexString$1;
1448
+ success: boolean;
1449
+ /** The dispatch error that rejected this bid, when it failed. */
1450
+ error?: string;
1451
+ }
1452
+ interface PhantomBidBatchResult {
1453
+ /** One entry per submitted bid, in the order they were given. */
1454
+ bids: PhantomBidOutcome[];
1455
+ /** The block and extrinsic the bids landed in. */
1456
+ blockHash?: HexString$1;
1457
+ extrinsicHash?: HexString$1;
1458
+ /**
1459
+ * The batch reached the pool but its inclusion was not observed, so no per-bid outcome is
1460
+ * known. Same contract as {@link BidSubmissionResult.pending}: in flight, do not re-sign.
1461
+ */
1462
+ pending?: boolean;
1463
+ /** Set when the batch never landed at all, or when its item events could not be attributed. */
1464
+ error?: string;
1465
+ }
1406
1466
  interface PollPhantomOrdersOptions {
1407
- /** How often to check for a new head. Defaults to 6s, roughly one block. */
1467
+ /** How often to check for a new head. Defaults to 15s, or 6s when the runtime is Gargantua. */
1408
1468
  intervalMs?: number;
1409
1469
  /**
1410
1470
  * Most blocks scanned in a single poll, so a long outage catches up over several ticks instead of
@@ -1432,6 +1492,8 @@ declare class IntentsCoprocessor {
1432
1492
  private ownsConnection;
1433
1493
  /** Cached result of whether the node exposes intents_* RPC methods */
1434
1494
  private hasIntentsRpc;
1495
+ /** The HTTP-backed api, connected on first use. Cleared after a failed attempt so it retries. */
1496
+ private httpApi;
1435
1497
  private submissionQueue;
1436
1498
  /**
1437
1499
  * Creates and connects an IntentsCoprocessor to a Hyperbridge node.
@@ -1458,11 +1520,44 @@ declare class IntentsCoprocessor {
1458
1520
  */
1459
1521
  static fromApi(api: ApiPromise, substratePrivateKey?: string): IntentsCoprocessor;
1460
1522
  private constructor();
1523
+ /**
1524
+ * The API every RPC query runs on: HTTP, connected to the same node as the websocket. Exposed so
1525
+ * callers query through this connection rather than opening one of their own.
1526
+ *
1527
+ * The split is by what each transport is for. Queries are one-shot request/response, which HTTP
1528
+ * serves without holding any state that can silently rot between calls. The websocket earns its
1529
+ * keep only where subscriptions do — watching a submitted extrinsic to inclusion.
1530
+ */
1531
+ queryApi(): Promise<ApiPromise>;
1532
+ /**
1533
+ * The websocket API, exposed so callers share this one connection instead of opening a second
1534
+ * socket to the same node. Only needed for subscriptions; use {@link queryApi} to read.
1535
+ */
1536
+ get apiConnection(): ApiPromise;
1461
1537
  /**
1462
1538
  * Disconnects the underlying API connection if this instance owns it.
1463
- * Only disconnects if created via `connect()`, not when using shared connections.
1539
+ * Only disconnects the websocket if created via `connect()`, not when using shared connections.
1540
+ * The HTTP api is always created here, so it is always ours to close.
1464
1541
  */
1465
1542
  disconnect(): Promise<void>;
1543
+ /**
1544
+ * The HTTP api for this node, connected on first use. Every coprocessor has one — the endpoint
1545
+ * is derived from the websocket's own endpoint, so there is nothing to configure and nothing to
1546
+ * be absent.
1547
+ *
1548
+ * The connection attempt is bounded on both sides. `isReadyOrError` rejects on a failed
1549
+ * handshake, where plain `isReady` would simply never resolve, and the timeout covers an
1550
+ * endpoint that accepts the request and then goes quiet. An unbounded wait here would hang the
1551
+ * poll tick awaiting it, which is precisely the silent stall that polling exists to avoid. A
1552
+ * failed attempt is not cached, so the next call tries again.
1553
+ */
1554
+ private http;
1555
+ /**
1556
+ * The endpoint the websocket provider is connected to. Read from the provider rather than
1557
+ * remembered from a constructor argument, so it is the one endpoint in use no matter which
1558
+ * factory built this instance.
1559
+ */
1560
+ private wsEndpoint;
1466
1561
  /**
1467
1562
  * Creates a Substrate keypair from the configured private key.
1468
1563
  * Supports hex seed (with or without 0x), mnemonic phrases, and URI derivation paths (//Alice).
@@ -1471,22 +1566,62 @@ declare class IntentsCoprocessor {
1471
1566
  /**
1472
1567
  * Signs and sends an extrinsic. Submissions are serialised through {@link submissionQueue} so
1473
1568
  * concurrent calls never collide on the substrate account nonce — each extrinsic reaches a block
1474
- * (or is confirmed still pooled and returned as `pending`) before the next is signed; auto-nonce
1475
- * via `system.accountNextIndex` counts pooled extrinsics, so a pending one is never re-used.
1569
+ * (or is confirmed still pooled and returned as `pending`) before the next is signed. The
1570
+ * auto-nonce is the account's on-chain nonce, so a still-pooled extrinsic does not advance it: a
1571
+ * submission signed behind a pending one bounces off it (1013/1014) and is reported as pending
1572
+ * too, rather than landing as a second copy.
1573
+ *
1574
+ * The extrinsic is built rather than passed in because the api it is built on decides where it
1575
+ * is signed and sent: a websocket that is down when the queue reaches this submission diverts it
1576
+ * to {@link sendViaHttp}, which needs the call bound to the HTTP api instead.
1476
1577
  */
1477
1578
  private signAndSendExtrinsic;
1579
+ /**
1580
+ * Last-resort submission for when the websocket is down at signing time. A bid is only worth
1581
+ * anything inside its window, so waiting for a reconnect usually means not bidding at all.
1582
+ *
1583
+ * HTTP has no subscriptions, so this is `author_submitExtrinsic`: the node accepts the extrinsic
1584
+ * into its pool and returns its hash, and nothing further is observable from here. That is
1585
+ * exactly the `pending` contract — in flight, outcome unknown, do not re-sign — so the result
1586
+ * says so rather than claiming a success it cannot see.
1587
+ *
1588
+ * Only reached when the socket was already down before signing. A submission that got as far as
1589
+ * the pool over the websocket is never retried here: that is the duplicate-nonce race the
1590
+ * `pending` result exists to prevent.
1591
+ */
1592
+ private sendViaHttp;
1478
1593
  /**
1479
1594
  * Signs and sends an extrinsic, handling status updates and errors.
1480
1595
  * Implements retry logic with progressive tip increases for stuck transactions.
1481
1596
  *
1482
- * A retry only happens when the previous attempt verifiably went nowhere. Once an attempt's
1483
- * extrinsic is known to be pooled (`pending`), re-signing the same call would race our own
1484
- * submission: the copy either bounces off the pool (1014, same nonce below the replacement
1485
- * priority bump) or if the original lands first, freeing the nonce — executes as a duplicate
1486
- * and fails on-chain (e.g. `BidNotFound` for a retraction). Neither can succeed, so the pending
1487
- * result is returned for the caller to confirm later.
1597
+ * Two kinds of failure are retried, and the difference is the nonce.
1598
+ *
1599
+ * An attempt that verifiably went nowhere (rejected before the pool, dropped, invalid) leaves
1600
+ * the account nonce free, so the next attempt simply re-signs with the auto-nonce.
1601
+ *
1602
+ * An attempt that reached the pool and was still there when the watch timed out (`stalled`) is
1603
+ * retried as a *replacement*: the same nonce it was signed with, and double the tip. Substrate's
1604
+ * pool evicts a pooled extrinsic in favour of a higher-priority one at the same (account, nonce),
1605
+ * so exactly one of the two can ever execute. This matters for a bid, which is worth nothing once
1606
+ * its window closes — waiting out a stalled extrinsic usually means not bidding at all.
1607
+ *
1608
+ * Re-signing without pinning the nonce is what must never happen here. The auto-nonce is read
1609
+ * from on-chain state, so it is only the stalled extrinsic's nonce for as long as that extrinsic
1610
+ * stays out of a block — and a stall is precisely the case where it may land at any moment. Once
1611
+ * it does, an unpinned retry takes the *next* nonce and both execute: a duplicate `placeBid` that
1612
+ * fails on-chain, and a second `retractBid` that pulls the bid just placed. When the signed nonce
1613
+ * cannot be read, the stalled result is returned rather than guessed at.
1614
+ *
1615
+ * A rejection that bounced off a copy already pooled (1013/1014) is likewise left alone: that
1616
+ * copy is in flight and its outcome is unknown here, so the `pending` result goes back to the
1617
+ * caller to confirm later.
1488
1618
  */
1489
1619
  private sendExtrinsicWithRetries;
1620
+ /**
1621
+ * The nonce an extrinsic was signed with, or undefined if it carries no readable one — which is
1622
+ * the case before it has ever been signed, and for a stub api in tests.
1623
+ */
1624
+ private signedNonce;
1490
1625
  /**
1491
1626
  * Classifies a submission rejection. Codes 1013 ("already imported") and 1014 ("priority is
1492
1627
  * too low") both mean a copy of this account+nonce is already in the pool — almost always our
@@ -1500,8 +1635,13 @@ declare class IntentsCoprocessor {
1500
1635
  *
1501
1636
  * A timeout is only a failure when the extrinsic never made it into the transaction pool.
1502
1637
  * Once a pool-entry status (Future/Ready/Broadcast/Retracted) has been seen, the extrinsic is
1503
- * in flight and may well execute after the watch is abandoned — the result is then `pending`,
1504
- * telling the caller to confirm the outcome later instead of re-signing the same call.
1638
+ * in flight and may well execute after the watch is abandoned — the result is then `pending`
1639
+ * and `stalled`, telling the caller to replace it under the same nonce or confirm it later,
1640
+ * never to re-sign the same call under a fresh one.
1641
+ *
1642
+ * `nonce` pins the submission to a specific account nonce, which is what makes a retry a pool
1643
+ * replacement rather than a second extrinsic queued behind the first. Left undefined on the
1644
+ * first attempt, where the api's auto-nonce is correct.
1505
1645
  */
1506
1646
  private sendWithTimeout;
1507
1647
  /**
@@ -1542,6 +1682,40 @@ declare class IntentsCoprocessor {
1542
1682
  * @returns BidSubmissionResult with success status and block/extrinsic hash
1543
1683
  */
1544
1684
  submitBidWithRetraction(retractCommitment: HexString$1, bidCommitment: HexString$1, userOp: HexString$1): Promise<BidSubmissionResult>;
1685
+ /**
1686
+ * Places every phantom bid of one interval in a single extrinsic, retracting each chain's
1687
+ * previous bid alongside it.
1688
+ *
1689
+ * The pallet registers one phantom order per configured chain in the same block, so this is the
1690
+ * whole interval's set. Submitting them one at a time costs a block per chain: submissions are
1691
+ * serialised on the account nonce and each waits for inclusion, so the last chain's bid is many
1692
+ * blocks behind the first, against a bid window measured in tens of blocks. Batched, every bid
1693
+ * lands in the same block.
1694
+ *
1695
+ * Uses `utility.force_batch`, not `utility.batch`. `batch` stops at the first failing call, so
1696
+ * one rejected bid — a closed window, a duplicate, an insufficient deposit — would silently
1697
+ * drop every bid after it. `force_batch` runs them all and reports each outcome. It needs no
1698
+ * special origin: any signed account may call it, exactly like `batch`.
1699
+ *
1700
+ * @param bids - The bids to place; an empty list is a no-op
1701
+ * @returns Per-bid outcomes, in the order given
1702
+ */
1703
+ submitPhantomBids(bids: PhantomBid[]): Promise<PhantomBidBatchResult>;
1704
+ /**
1705
+ * Reads one outcome per call out of a force_batch's events.
1706
+ *
1707
+ * `ItemFailed` carries no index — pallet-utility emits exactly one `ItemCompleted` or
1708
+ * `ItemFailed` per call, in call order, so the k-th item event belongs to call k.
1709
+ *
1710
+ * A count that does not match the calls submitted means the events are not the ones assumed
1711
+ * here, and every attribution after the discrepancy would be off by one. The bids are then
1712
+ * reported as placed: a bid wrongly recorded as landed is retracted next interval and the
1713
+ * retraction harmlessly fails with `BidNotFound`, whereas one wrongly recorded as failed is
1714
+ * never retracted at all and leaves its deposit reserved.
1715
+ */
1716
+ private readForceBatchItems;
1717
+ /** Renders a DispatchError as `pallet::Error`, falling back to its raw form. */
1718
+ private describeDispatchError;
1545
1719
  /**
1546
1720
  * Fetches all bid storage entries for a given order commitment.
1547
1721
  * Returns the on-chain data only (filler addresses and deposits).
@@ -1589,7 +1763,13 @@ declare class IntentsCoprocessor {
1589
1763
  */
1590
1764
  getPhantomOrdersInBlock(blockNumber: number): Promise<PhantomOrderEvent[]>;
1591
1765
  /**
1592
- * Polls for newly registered phantom orders, invoking the callback once per order.
1766
+ * Polls for newly registered phantom orders, invoking the callback once per block that carries
1767
+ * any, with all of that block's orders.
1768
+ *
1769
+ * Per block rather than per order because that is how the pallet writes them: one order per
1770
+ * configured chain, all registered in the same `on_initialize`. Delivering them together lets a
1771
+ * caller bid on the whole interval in one extrinsic (see {@link submitPhantomBids}) instead of
1772
+ * one per chain.
1593
1773
  *
1594
1774
  * Each tick reads the current head and scans every block between the last one processed and that
1595
1775
  * head, so the block cursor — not the connection — determines what has been seen. This replaced a
@@ -1602,9 +1782,21 @@ declare class IntentsCoprocessor {
1602
1782
  * cannot drop them, because the cursor only advances past a block whose events were actually
1603
1783
  * read. Recovery replays the backlog.
1604
1784
  *
1785
+ * Every read here goes over HTTP, never the websocket. Polling is a sequence of independent
1786
+ * one-shot requests with no state to lose between them, which is exactly what a stateless
1787
+ * transport does well: a request either answers or fails loudly on this tick, instead of a
1788
+ * socket that looks alive while delivering nothing. It also means a websocket outage does not
1789
+ * pause phantom bidding at all — the two transports fail independently.
1790
+ *
1605
1791
  * Returns a function that stops polling.
1606
1792
  */
1607
- pollPhantomOrders(callback: (event: PhantomOrderEvent) => void, options?: PollPhantomOrdersOptions): () => void;
1793
+ pollPhantomOrders(callback: (events: PhantomOrderEvent[]) => void, options?: PollPhantomOrdersOptions): () => void;
1794
+ /**
1795
+ * The poll cadence for the runtime this instance is connected to: Gargantua polls every block,
1796
+ * everything else every 15s. Falls back to the slower cadence if the runtime cannot be read,
1797
+ * since an unreachable node is the poll's problem to report, not the cadence lookup's.
1798
+ */
1799
+ private phantomPollIntervalMs;
1608
1800
  }
1609
1801
 
1610
1802
  /**
@@ -2473,6 +2665,17 @@ interface FillerConfig {
2473
2665
  * chains"; an empty array declares that no source chain is accepted.
2474
2666
  */
2475
2667
  acceptedSourceChains?: string[];
2668
+ /**
2669
+ * Uniswap V4 position tokenIds this filler holds, per chain (state machine id -> tokenIds as
2670
+ * decimal strings), declared inside its phantom bids' paymasterAndData for the bid's own chain.
2671
+ *
2672
+ * Liquidity parked in a V4 position is invisible to the snapshot's inventory read, which sees
2673
+ * only ERC-20 balances and ERC-4626 vault shares — so without this a venue-funded filler is
2674
+ * weighted at zero and its quotes are discarded. The declaration is only a POINTER: the indexer
2675
+ * reads each position's liquidity on-chain and checks it is owned by the solver that signed the
2676
+ * bid, so naming a position cannot inflate it and naming someone else's achieves nothing.
2677
+ */
2678
+ uniswapV4PositionsByChain?: Record<string, string[]>;
2476
2679
  }
2477
2680
  /**
2478
2681
  * Result of an order execution attempt
@@ -2766,25 +2969,51 @@ interface PhantomOrderPriceSnapshotsResponse {
2766
2969
  }>;
2767
2970
  };
2768
2971
  }
2972
+ /** One independently reported slice of indexed liquidity. */
2973
+ interface LiquiditySlice {
2974
+ totalLiquidity: string;
2975
+ providerCount: number;
2976
+ }
2769
2977
  /**
2770
- * Total solver liquidity measured at one immutable Phantom price snapshot.
2978
+ * Indexed destination capacity and its source-routing slices.
2771
2979
  *
2772
- * Liquidity amounts are decimal strings formatted with the configured decimals
2773
- * for their respective `tokenAddress` and chain.
2980
+ * The SDK reports the indexer's facts separately and does not decide whether a
2981
+ * source chain is covered by the legacy unrestricted-bidder policy.
2774
2982
  */
2775
- interface AvailableLiquiditySnapshot {
2776
- totalLiquidity: string;
2777
- providerCount: number;
2983
+ interface AvailableLiquidity {
2984
+ sourceChain: Chains;
2985
+ destinationChain: Chains;
2778
2986
  tokenAddress: HexString$1;
2779
- snapshotTime: Date;
2780
- liquidityByChain: AvailableLiquidityByChain[];
2987
+ updatedAt: Date;
2988
+ destination: LiquiditySlice;
2989
+ unrestricted: LiquiditySlice;
2990
+ explicitRoute: (LiquiditySlice & {
2991
+ updatedAt: Date;
2992
+ }) | null;
2781
2993
  }
2782
- /** Liquidity for one chain/token balance group in an availability snapshot. */
2783
- interface AvailableLiquidityByChain {
2784
- chain: string;
2785
- tokenAddress: HexString$1;
2786
- totalLiquidity: string;
2787
- providerCount: number;
2994
+ /**
2995
+ * Chain-specific buy and sell rates expressed as quote-token units per one
2996
+ * base token. The quote token is the less valuable currency when the indexed
2997
+ * rates establish an ordering (for example, cNGN in a USDC/cNGN pair).
2998
+ */
2999
+ interface BuyAndSellRates {
3000
+ baseTokenSymbol: ConfiguredAssetSymbol;
3001
+ quoteTokenSymbol: ConfiguredAssetSymbol;
3002
+ sourceChain: Chains;
3003
+ destinationChain: Chains;
3004
+ /** Quote-token units received when buying the quote token with one base token. */
3005
+ buyRate: string | null;
3006
+ /** Quote-token units sold to receive one base token. */
3007
+ sellRate: string | null;
3008
+ buyRateUpdatedAt: Date | null;
3009
+ sellRateUpdatedAt: Date | null;
3010
+ }
3011
+ /** Symbol-only input for querying an indexed pool's rates. */
3012
+ interface QueryBuyAndSellRatesParams {
3013
+ tokenInSymbol: ConfiguredAssetSymbolInput;
3014
+ tokenOutSymbol: ConfiguredAssetSymbolInput;
3015
+ sourceChainId: Chain$1["id"];
3016
+ destinationChainId: Chain$1["id"];
2788
3017
  }
2789
3018
  interface TokenPrice {
2790
3019
  symbol: string;
@@ -3230,6 +3459,16 @@ type ERC7821Call = {
3230
3459
  data: `0x${string}`;
3231
3460
  };
3232
3461
 
3462
+ /**
3463
+ * Canonical symbol order used by the SDK and indexer pool IDs.
3464
+ *
3465
+ * Plain code-unit comparison, never locale-sensitive collation — the result is
3466
+ * a persisted primary key and must sort identically everywhere.
3467
+ */
3468
+ declare function sortPoolSymbols<Symbol extends string>(symbolA: Symbol, symbolB: Symbol): [Symbol, Symbol];
3469
+ /** Canonical indexer pool ID for a pair of canonical token symbols. */
3470
+ declare function poolSlug(symbolA: string, symbolB: string): string;
3471
+
3233
3472
  declare function encodeERC7821ExecuteBatch(calls: ERC7821Call[]): HexString$1;
3234
3473
  declare function decodeERC7821ExecuteBatch(callData: HexString$1): ERC7821Call[] | null;
3235
3474
 
@@ -4649,16 +4888,38 @@ declare const FILL_ORDER_ABI: readonly [{
4649
4888
  readonly name: "WrongChain";
4650
4889
  readonly inputs: readonly [];
4651
4890
  }];
4891
+ /** What a phantom bid's paymasterAndData declares about the solver behind it. */
4892
+ interface PhantomBidDeclaration {
4893
+ /**
4894
+ * Source chains the solver accepts payment from. Null when the bid carries no parseable
4895
+ * declaration (the legacy default: the solver has not restricted its sources); an empty array
4896
+ * is an explicit accepts-nothing. Callers must preserve that distinction.
4897
+ */
4898
+ acceptedSources: string[] | null;
4899
+ /**
4900
+ * Uniswap V4 position tokenIds the solver declares as backing this bid, on the order's own
4901
+ * chain. Empty when none are declared — including for every v1 bid, which predates the field.
4902
+ */
4903
+ uniswapV4Positions: bigint[];
4904
+ }
4652
4905
  /**
4653
- * Encodes the accepted source chains (state machine ids, e.g. "EVM-8453") into the
4654
- * paymasterAndData declaration blob.
4906
+ * Encodes a phantom bid's declaration into the paymasterAndData blob. Emits the v1 layout when no
4907
+ * positions are declared, so a solver that only names source chains produces exactly the bytes it
4908
+ * produced before positions existed.
4655
4909
  */
4656
- declare function encodeAcceptedSourceChains(chains: string[]): HexString;
4910
+ declare function encodePhantomBidDeclaration(declaration: {
4911
+ acceptedSourceChains?: string[];
4912
+ uniswapV4Positions?: bigint[];
4913
+ }): HexString;
4657
4914
  /**
4658
- * Decodes a phantom bid's paymasterAndData into its declared source chains. Returns null for an
4659
- * absent, unversioned or malformed blob the legacy default and an empty array only for an
4660
- * explicit zero-entry declaration. Callers must preserve that distinction.
4915
+ * Decodes a phantom bid's paymasterAndData. Understands both layout versions, so bids placed
4916
+ * before positions existed keep decoding unchanged. Anything absent, unversioned or malformed
4917
+ * yields a null `acceptedSources` with no positions — never a partial read.
4661
4918
  */
4919
+ declare function decodePhantomBidDeclaration(paymasterAndData: string | undefined | null): PhantomBidDeclaration;
4920
+ /** Back-compat wrapper: the source-chain half of {@link encodePhantomBidDeclaration}. */
4921
+ declare function encodeAcceptedSourceChains(chains: string[]): HexString;
4922
+ /** Back-compat wrapper: the source-chain half of {@link decodePhantomBidDeclaration}. */
4662
4923
  declare function decodeAcceptedSourceChains(paymasterAndData: string | undefined | null): string[] | null;
4663
4924
  /** ERC-4626 vaults per chain, keyed by chain id then lowercase underlying token address. */
4664
4925
  type YieldVaultMap = Record<string, Record<string, string[]>>;
@@ -4695,6 +4956,15 @@ interface LpBalance {
4695
4956
  /** State machine id of the chain the balance was measured on (e.g. EVM-8453). */
4696
4957
  chain: string;
4697
4958
  tokenAddress: HexString;
4959
+ /**
4960
+ * Wallet ERC-20, redeemable ERC-4626 vault shares, and the withdrawable amount held in the
4961
+ * solver's declared Uniswap V4 positions — the same total the leg weights are built from, so a
4962
+ * provider's reported inventory and the depth attributed to it cannot disagree.
4963
+ *
4964
+ * The V4 share is only ever included on the chain whose bid declared the positions: a bid is
4965
+ * per chain, so no other chain's sweep can know about them. Consumers must therefore treat the
4966
+ * larger of two readings for the same (chain, token, block) as the complete one.
4967
+ */
4698
4968
  balance: bigint;
4699
4969
  }
4700
4970
  /** One verified solver behind a leg's quote, holding inventory to deliver it. */
@@ -4771,7 +5041,14 @@ type RecoverBidSigner = (userOp: PackedUserOperation, entryPoint: HexString, cha
4771
5041
  * indexer injects an ethers equivalent (see the note at the top of this file).
4772
5042
  */
4773
5043
  declare const recoverBidSignerViem: RecoverBidSigner;
5044
+ /** Promise-caching delegation reader produced by {@link memoizedDelegationCheck}. */
5045
+ type DelegationReader = (evmRpcUrl: string, account: string, solverAccount: string) => Promise<boolean>;
4774
5046
  declare function fetchBidsForOrder(nodeUrl: string, commitment: string): Promise<RpcBidInfo[]>;
5047
+ /** PositionManager + StateView addresses for a chain's Uniswap V4 deployment. */
5048
+ interface UniswapV4Contracts {
5049
+ positionManager: string;
5050
+ stateView: string;
5051
+ }
4775
5052
  /** Promise-caching balance reader produced by [`memoizedSolverBalance`]. */
4776
5053
  type SolverBalanceReader = (evmRpcUrl: string, chain: string, token: string, solver: string) => Promise<bigint>;
4777
5054
  declare function memoizedSolverBalance(yieldVaults: YieldVaultMap): SolverBalanceReader;
@@ -4791,8 +5068,15 @@ declare function memoizedSolverBalance(yieldVaults: YieldVaultMap): SolverBalanc
4791
5068
  * `extractFill` decodes a bid's ERC-7821 calldata into the fill's order/output and `recoverSigner`
4792
5069
  * recovers its solver signature; both default to the viem implementations, but the indexer injects
4793
5070
  * VM2-safe variants (viem's keccak throws in the SubQuery sandbox).
5071
+ *
5072
+ * The whole run is retried up to {@link AGGREGATION_ATTEMPTS} times on any error, because every
5073
+ * error that escapes the per-bid handling means some input could not be read, and a snapshot
5074
+ * computed from a partial bid set is worse than none: it publishes a confident price and zeroes
5075
+ * depth that exists. Throws if every attempt fails, leaving the window unsnapshotted — consumers
5076
+ * see the previous rate with a stale lastUpdatedBlock, which is a state they can already detect.
4794
5077
  */
4795
- declare function aggregatePhantomBids(params: {
5078
+ declare function aggregatePhantomBids(params: Parameters<typeof runAggregation>[0]): Promise<PhantomAggregation | null>;
5079
+ declare function runAggregation(params: {
4796
5080
  nodeUrl: string;
4797
5081
  /** RPC URL per supported EVM chain (stateMachineId -> url); must include the destination chain. */
4798
5082
  evmRpcUrls: Record<string, string>;
@@ -4812,8 +5096,16 @@ declare function aggregatePhantomBids(params: {
4812
5096
  * same `yieldVaults` passed here — the memo bakes in the vault map its balances include.
4813
5097
  */
4814
5098
  getBalance?: SolverBalanceReader;
5099
+ /**
5100
+ * Uniswap V4 deployment per chain. Supply it to let bids that declare positions have those
5101
+ * positions counted; without it a declaration is simply ignored, and the weight stays the
5102
+ * plain balance as before.
5103
+ */
5104
+ uniswapV4?: Record<string, UniswapV4Contracts>;
5105
+ /** keccak256 over hex; defaults to viem's, which the VM2 sandbox must replace. */
5106
+ keccak?: (hex: HexString) => HexString;
4815
5107
  logger?: AggregationLogger;
4816
- }): Promise<PhantomAggregation | null>;
5108
+ }, isDelegated: DelegationReader): Promise<PhantomAggregation | null>;
4817
5109
 
4818
5110
  declare const ABI: readonly [{
4819
5111
  readonly type: "constructor";
@@ -7626,4 +7918,4 @@ declare const _default: {
7626
7918
  }];
7627
7919
  };
7628
7920
 
7629
- export { type BidStorageEntry as $, type AssetTeleported as A, type Bid as B, ChainConfigService as C, type EstimateFillOrderParams as D, type EstimateGasCallData as E, type FillerBid as F, type GetRequestWithStatus as G, type HexString$1 as H, type IChain as I, type FillOrderEstimate as J, type OrderFeesQuote as K, type ERC7821Call as L, type OrderWithStatus as M, OrderStatus as N, type Order as O, type PostRequestWithStatus as P, type TokenGatewayAssetTeleportedWithStatus as Q, type RetryConfig as R, type StateMachineIdParams as S, type Transaction as T, TeleportStatus as U, type DecodedOrderPlacedLog as V, type DecodedPostRequestEvent as W, type DecodedPostResponseEvent as X, type AllStatusKey as Y, type AssetTeleportedResponse as Z, type AvailableLiquidityByChain as _, type IEvmConfig as a, type TokenPrice as a$, type BidSubmissionResult as a0, type BlockMetadata as a1, type BytesLikeHex as a2, type CancelOptions as a3, type ChainConfig as a4, type ChainConfigData as a5, Chains as a6, type ConfiguredAssetSymbol as a7, type Deployment as a8, type DispatchGet as a9, IntentOrderStatus as aA, type IntentOrderStatusKey as aB, type IsmpRequest as aC, type OrderResponse as aD, type OrderStatusMetadata as aE, type PaymentInfo as aF, type PhantomOrderEvent as aG, type PhantomOrderLeg as aH, type PhantomOrderPriceSnapshot as aI, type PhantomOrderPriceSnapshotsResponse as aJ, type PollPhantomOrdersOptions as aK, type PostRequestStatus as aL, type RequestBody as aM, type RequestCommitment as aN, RequestKind as aO, type RequestResponse as aP, RequestStatus as aQ, type RequestStatusKey as aR, type SelectOptions as aS, type SigningAccount as aT, type StateMachineId as aU, type StateMachineResponse as aV, type StorageFacade as aW, TimeoutStatus as aX, type TimeoutStatusKey as aY, type TokenGatewayAssetTeleportedResponse as aZ, type TokenInfo as a_, type DispatchInfo as aa, type DispatchPost as ab, type Erc4626VaultConfigData as ac, type ExecuteIntentOrderOptions as ad, type ExecutionResult as ae, type FillOptions as af, type FillerConfig as ag, type GetRequestResponse as ah, type GetResponseByRequestIdResponse as ai, type GetResponseStorageValues as aj, type HostParams as ak, HyperClientStatus as al, type IBatchConsensusAndGetResponseMessage as am, type IBatchConsensusAndPostRequestMessage as an, type IConfig as ao, type IConsensusMessage as ap, type IGetRequestMessage as aq, type IGetResponse as ar, type IGetResponseMessage as as, type IHyperbridgeConfig as at, type IPostResponse as au, type IRequestMessage as av, type ISubstrateConfig as aw, type ITimeoutPostRequestMessage as ax, ABI as ay, type IntentGatewayParams as az, type IMessage as b, type TokenPricesResponse as b0, type UniswapV4PoolConfigData as b1, chainConfigs as b2, convertCodecToIGetRequest as b3, convertCodecToIProof as b4, convertIGetRequestToCodec as b5, convertIProofToCodec as b6, convertStateIdToStateMachineId as b7, convertStateMachineEnumToString as b8, convertStateMachineIdToEnum as b9, type LpBalance as bA, type OrderCommitmentFn as bB, type PhantomAggregation as bC, type PhantomLegAggregation as bD, type PhantomLegBidder as bE, type RecoverBidSigner as bF, type RpcBidInfo as bG, type SolverBalanceReader as bH, type YieldVaultMap as bI, aggregatePhantomBids as bJ, extractFillData as bK, fetchBidsForOrder as bL, memoizedSolverBalance as bM, orderCommitmentFromDecoded as bN, recoverBidSignerViem as bO, setAggregationFetch as bP, splitBidSignature as bQ, weightedMedian as bR, zipFillLegs as bS, decodeAcceptedSourceChains as ba, decodeERC7821ExecuteBatch as bb, decodeUserOpScale as bc, encodeAcceptedSourceChains as bd, encodeERC7821ExecuteBatch as be, encodeISMPMessage as bf, encodeUserOpScale as bg, getChainId as bh, getConfigByStateMachineId as bi, getViemChain as bj, hyperbridgeAddress as bk, pharosAtlantic as bl, pharosMainnet as bm, polkadotAssetHubPaseo as bn, polkadotHubMainnet as bo, tronChainIds as bp, tronNile as bq, type AggregationLogger as br, type BidNonceKeyFn as bs, type BidSignature as bt, ENTRY_POINT_V08_ADDRESS as bu, FILL_ORDER_ABI as bv, type FetchLike as bw, type FillData as bx, type HexString as by, _default as bz, type StateMachineHeight as c, type IIsmpMessage as d, type IPostRequest as e, type IGetRequest as f, type IPolkadotHubConfig as g, type IPharosConfig as h, type StateMachineUpdate as i, type ResponseCommitmentWithValues as j, type RequestStatusWithMetadata as k, type PostRequestTimeoutStatus as l, SubstrateChain as m, type ClientConfig as n, type IndexerQueryClient as o, type IProof as p, type IEvmChain as q, IntentsCoprocessor as r, type AvailableLiquiditySnapshot as s, type IntentOrderStatusUpdate as t, type SelectBidResult as u, type ResumeIntentOrderOptions as v, type CancelOrderOptions as w, type CancelQuote as x, type SubmitBidOptions as y, type PackedUserOperation as z };
7921
+ export { type AssetTeleportedResponse as $, type AssetTeleported as A, type BuyAndSellRates as B, ChainConfigService as C, type Bid as D, type EstimateGasCallData as E, type FillerBid as F, type GetRequestWithStatus as G, type HexString$1 as H, type IChain as I, type EstimateFillOrderParams as J, type FillOrderEstimate as K, type OrderFeesQuote as L, type ERC7821Call as M, type OrderWithStatus as N, type Order as O, type PostRequestWithStatus as P, type QueryBuyAndSellRatesParams as Q, type RetryConfig as R, type StateMachineIdParams as S, type Transaction as T, OrderStatus as U, type TokenGatewayAssetTeleportedWithStatus as V, TeleportStatus as W, type DecodedOrderPlacedLog as X, type DecodedPostRequestEvent as Y, type DecodedPostResponseEvent as Z, type AllStatusKey as _, type IEvmConfig as a, type SigningAccount as a$, type BidStorageEntry as a0, type BidSubmissionResult as a1, type BlockMetadata as a2, type BytesLikeHex as a3, type CancelOptions as a4, type ChainConfig as a5, type ChainConfigData as a6, Chains as a7, type ConfiguredAssetSymbol as a8, type ConfiguredAssetSymbolInput as a9, type ITimeoutPostRequestMessage as aA, ABI as aB, type IntentGatewayParams as aC, IntentOrderStatus as aD, type IntentOrderStatusKey as aE, type IsmpRequest as aF, type LiquiditySlice as aG, type OrderResponse as aH, type OrderStatusMetadata as aI, type PaymentInfo as aJ, type PhantomBid as aK, type PhantomBidBatchResult as aL, type PhantomBidDeclaration as aM, type PhantomBidOutcome as aN, type PhantomOrderEvent as aO, type PhantomOrderLeg as aP, type PhantomOrderPriceSnapshot as aQ, type PhantomOrderPriceSnapshotsResponse as aR, type PollPhantomOrdersOptions as aS, type PostRequestStatus as aT, type RequestBody as aU, type RequestCommitment as aV, RequestKind as aW, type RequestResponse as aX, RequestStatus as aY, type RequestStatusKey as aZ, type SelectOptions as a_, type Deployment as aa, type DispatchGet as ab, type DispatchInfo as ac, type DispatchPost as ad, type Erc4626VaultConfigData as ae, type ExecuteIntentOrderOptions as af, type ExecutionResult as ag, type FillOptions as ah, type FillerConfig as ai, type GetRequestResponse as aj, type GetResponseByRequestIdResponse as ak, type GetResponseStorageValues as al, type HostParams as am, HyperClientStatus as an, type IBatchConsensusAndGetResponseMessage as ao, type IBatchConsensusAndPostRequestMessage as ap, type IConfig as aq, type IConsensusMessage as ar, type IGetRequestMessage as as, type IGetResponse as at, type IGetResponseMessage as au, type IHyperbridgeConfig as av, INCLUSION_TIMEOUT_MS as aw, type IPostResponse as ax, type IRequestMessage as ay, type ISubstrateConfig as az, type IMessage as b, recoverBidSignerViem as b$, type StateMachineId as b0, type StateMachineResponse as b1, type StorageFacade as b2, TimeoutStatus as b3, type TimeoutStatusKey as b4, type TokenGatewayAssetTeleportedResponse as b5, type TokenInfo as b6, type TokenPrice as b7, type TokenPricesResponse as b8, type UniswapV4PoolConfigData as b9, poolSlug as bA, sortPoolSymbols as bB, tronChainIds as bC, tronNile as bD, type AggregationLogger as bE, type BidNonceKeyFn as bF, type BidSignature as bG, ENTRY_POINT_V08_ADDRESS as bH, FILL_ORDER_ABI as bI, type FetchLike as bJ, type FillData as bK, type HexString as bL, _default as bM, type LpBalance as bN, type OrderCommitmentFn as bO, type PhantomAggregation as bP, type PhantomLegAggregation as bQ, type PhantomLegBidder as bR, type RecoverBidSigner as bS, type RpcBidInfo as bT, type SolverBalanceReader as bU, type YieldVaultMap as bV, aggregatePhantomBids as bW, extractFillData as bX, fetchBidsForOrder as bY, memoizedSolverBalance as bZ, orderCommitmentFromDecoded as b_, chainConfigs as ba, convertCodecToIGetRequest as bb, convertCodecToIProof as bc, convertIGetRequestToCodec as bd, convertIProofToCodec as be, convertStateIdToStateMachineId as bf, convertStateMachineEnumToString as bg, convertStateMachineIdToEnum as bh, decodeAcceptedSourceChains as bi, decodeERC7821ExecuteBatch as bj, decodePhantomBidDeclaration as bk, decodeUserOpScale as bl, deriveHttpUrl as bm, encodeAcceptedSourceChains as bn, encodeERC7821ExecuteBatch as bo, encodeISMPMessage as bp, encodePhantomBidDeclaration as bq, encodeUserOpScale as br, getChainId as bs, getConfigByStateMachineId as bt, getViemChain as bu, hyperbridgeAddress as bv, pharosAtlantic as bw, pharosMainnet as bx, polkadotAssetHubPaseo as by, polkadotHubMainnet as bz, type StateMachineHeight as c, setAggregationFetch as c0, splitBidSignature as c1, weightedMedian as c2, zipFillLegs as c3, type IIsmpMessage as d, type IPostRequest as e, type IGetRequest as f, type IPolkadotHubConfig as g, type IPharosConfig as h, type StateMachineUpdate as i, type ResponseCommitmentWithValues as j, type RequestStatusWithMetadata as k, type PostRequestTimeoutStatus as l, SubstrateChain as m, type ClientConfig as n, type IndexerQueryClient as o, type IProof as p, type IEvmChain as q, IntentsCoprocessor as r, type AvailableLiquidity as s, type IntentOrderStatusUpdate as t, type SelectBidResult as u, type ResumeIntentOrderOptions as v, type CancelOrderOptions as w, type CancelQuote as x, type SubmitBidOptions as y, type PackedUserOperation as z };