@hyperbridge/sdk 2.8.8 → 2.8.10

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.
@@ -6,6 +6,7 @@ import { PublicClient, TransactionReceipt, Hex, Log, ContractFunctionArgs, Chain
6
6
  import { Chain } from 'viem/chains';
7
7
  import { ApiPromise } from '@polkadot/api';
8
8
  import { KeyringPair } from '@polkadot/keyring/types';
9
+ import { RuntimeVersion } from '@polkadot/types/interfaces';
9
10
  import * as unstorage from 'unstorage';
10
11
  import { SignerOptions, SubmittableExtrinsic } from '@polkadot/api/types';
11
12
  import { ISubmittableResult } from '@polkadot/types/types';
@@ -1975,6 +1976,20 @@ interface PhantomOrderEvent {
1975
1976
  */
1976
1977
  legs: PhantomOrderLeg[];
1977
1978
  }
1979
+ /** The pallet's phantom order timings, as the chain currently has them. */
1980
+ interface PhantomTimings {
1981
+ /**
1982
+ * Blocks after registration during which the pallet accepts a bid: the `PhantomBidWindow`
1983
+ * storage value, or the `PhantomOrderBidWindowBlocks` runtime constant when that value is zero,
1984
+ * which is the same fallback the pallet's own `phantom_bid_window()` applies.
1985
+ */
1986
+ bidWindowBlocks: number;
1987
+ /**
1988
+ * Blocks between generations (`PhantomOrderInterval`). Zero is meaningful rather than unset —
1989
+ * the pallet generates once and never regenerates — so there is no constant to fall back to.
1990
+ */
1991
+ intervalBlocks: number;
1992
+ }
1978
1993
  /** One phantom bid to place, and the bid it replaces on the same chain. */
1979
1994
  interface PhantomBid {
1980
1995
  /** The phantom order commitment being bid on. */
@@ -2013,17 +2028,22 @@ interface PollPhantomOrdersOptions {
2013
2028
  intervalMs?: number;
2014
2029
  /**
2015
2030
  * Most blocks scanned in a single poll, so a long outage catches up over several ticks instead of
2016
- * one unbounded scan. Defaults to 500.
2031
+ * one burst. Defaults to 10 — several times the rate the chain produces blocks, so recovery is
2032
+ * still quick, but small enough to bound both the work one `state_queryStorage` call asks of the
2033
+ * node and the requests the per-block fallback queues ahead of a bid submission.
2017
2034
  */
2018
2035
  maxBlocksPerPoll?: number;
2019
- /**
2020
- * How many blocks before the current head to start from on the first poll. Defaults to 0 (start
2021
- * at the head). Set this to the runtime's bid window to have a restarting process pick up orders
2022
- * whose window is still open.
2023
- */
2024
- lookbackBlocks?: number;
2025
2036
  /** Notified when a poll fails; polling continues regardless. */
2026
2037
  onError?: (err: unknown) => void;
2038
+ /**
2039
+ * Notified when the cursor was forced forward past a backlog too old to bid on, with the range
2040
+ * that was never scanned. Nothing else reports it, and skipping blocks is worth a line in the log.
2041
+ */
2042
+ onSkip?: (skipped: {
2043
+ from: number;
2044
+ to: number;
2045
+ head: number;
2046
+ }) => void;
2027
2047
  }
2028
2048
  /**
2029
2049
  * Service for interacting with Hyperbridge's pallet-intents coprocessor.
@@ -2037,8 +2057,14 @@ declare class IntentsCoprocessor {
2037
2057
  private ownsConnection;
2038
2058
  /** Cached result of whether the node exposes intents_* RPC methods */
2039
2059
  private hasIntentsRpc;
2060
+ /** The pallet's phantom timings, read once. Cleared on failure so the read retries. */
2061
+ private phantomTimingsRead;
2040
2062
  /** The HTTP-backed api, connected on first use. Cleared after a failed attempt so it retries. */
2041
2063
  private httpApi;
2064
+ /** Last runtime version read from the node, for {@link confirmedRuntimeVersion} to compare against. */
2065
+ private lastRuntimeVersion;
2066
+ /** Set once the node refuses `state_queryStorage`, so the poll stops asking for it. */
2067
+ private rangeQueryUnavailable;
2042
2068
  private submissionQueue;
2043
2069
  /**
2044
2070
  * Creates and connects an IntentsCoprocessor to a Hyperbridge node.
@@ -2305,8 +2331,58 @@ declare class IntentsCoprocessor {
2305
2331
  fetchPhantomOrder(commitment: HexString$1): Promise<Order | null>;
2306
2332
  /**
2307
2333
  * Reads the PhantomOrderRegistered events emitted in a single block.
2334
+ *
2335
+ * Costs two RPCs per block when `knownVersion` is supplied and four without it, which is why the
2336
+ * poll goes to the trouble of establishing one. `api.at(hash)` has to work out which metadata to
2337
+ * decode the block against, and with nothing to go on it fetches the header and then the runtime
2338
+ * version at its parent — every block, forever. Its cheaper paths are a registry already pinned
2339
+ * to this exact hash (only ever the previous block's) or one matching a version the caller
2340
+ * names, so naming the version is the only way out. See `getBlockRegistry` in
2341
+ * `@polkadot/api/base/Init`; the `getUpgradeVersion` shortcut that would otherwise skip the
2342
+ * lookup only covers chains hardcoded in `@polkadot/types-known`, which Hyperbridge is not.
2343
+ *
2344
+ * @param knownVersion - the runtime version this block is known to run, if the caller has
2345
+ * established one. Passing a version the block does not actually run decodes it against the
2346
+ * wrong metadata, so this is for callers that have checked, not a place to pass a guess.
2347
+ */
2348
+ getPhantomOrdersInBlock(blockNumber: number, knownVersion?: RuntimeVersion): Promise<PhantomOrderEvent[]>;
2349
+ /**
2350
+ * The same read, for a caller that already holds the block's hash.
2351
+ *
2352
+ * Split out so the poll can fetch a whole range's hashes in one concurrent wave — which the
2353
+ * provider coalesces into a single batched request — and then read each block's events knowing
2354
+ * its hash. `chain_getBlockHash` is the half of the pair that parallelises safely: it takes no
2355
+ * historic block hash, so it never triggers polkadot-js's per-hash registry resolution, and
2356
+ * concurrent calls cannot race each other's registry state.
2308
2357
  */
2309
- getPhantomOrdersInBlock(blockNumber: number): Promise<PhantomOrderEvent[]>;
2358
+ getPhantomOrdersAtHash(blockHash: HexString$1, knownVersion?: RuntimeVersion): Promise<PhantomOrderEvent[]>;
2359
+ /**
2360
+ * Every block's phantom orders across a whole range, in one `state_queryStorage` call.
2361
+ *
2362
+ * This is the cheap path: the request cost of a scan stops depending on how many blocks it
2363
+ * covers. The events key is the only key queried, and both bounds are block hashes the caller
2364
+ * already holds.
2365
+ *
2366
+ * Two properties of the RPC shape the result.
2367
+ *
2368
+ * It returns *diffs*: `query_storage_unfiltered` in `sc-rpc` pushes a change set for a block only
2369
+ * when the value differs from the previous block in the range (`has_changed`, and the set is
2370
+ * dropped when empty), so a block whose events encode byte-for-byte identically to its
2371
+ * predecessor's is simply absent. That happens on a quiet chain, where consecutive blocks carry
2372
+ * nothing but the timestamp inherent's `ExtrinsicSuccess`. It is safe here because an absent
2373
+ * block provably carries no phantom orders: a `PhantomOrderRegistered` commitment is derived from
2374
+ * the block number (`phantom_order_commitment`), so a block that registered orders can never
2375
+ * encode identically to any other block. Absent therefore means "same as the previous block",
2376
+ * and the previous block having orders would contradict that.
2377
+ *
2378
+ * And it is gated by `--rpc-methods` (`check_if_safe` in `sc-rpc`), which answers a denied call
2379
+ * with `Method not found`. The node this reads from must already run unsafe RPC to serve
2380
+ * `offchain_localStorageGet` for the orders themselves, so this is normally available; the poll
2381
+ * falls back to reading block by block when it is not.
2382
+ *
2383
+ * @returns one entry per block the node reported a change for, in ascending block order.
2384
+ */
2385
+ getPhantomOrdersInRange(fromBlockHash: HexString$1, toBlockHash: HexString$1): Promise<PhantomOrderEvent[][]>;
2310
2386
  /**
2311
2387
  * Polls for newly registered phantom orders, invoking the callback once per block that carries
2312
2388
  * any, with all of that block's orders.
@@ -2333,9 +2409,87 @@ declare class IntentsCoprocessor {
2333
2409
  * socket that looks alive while delivering nothing. It also means a websocket outage does not
2334
2410
  * pause phantom bidding at all — the two transports fail independently.
2335
2411
  *
2412
+ * What the cadence does *not* describe is the request rate, which is what rate limiters police.
2413
+ * A tick costs four requests whatever the range covers — the head, the runtime version, the two
2414
+ * bounding block hashes as one batched request, and one `state_queryStorage` for every block's
2415
+ * events — and they go out back-to-back, so an interval well under any per-second limit could
2416
+ * still arrive as a burst over it. Three things keep that in bounds: the provider coalesces
2417
+ * concurrent calls into one request and paces requests through the endpoint's token bucket (see
2418
+ * `http`), and `maxBlocksPerPoll` bounds the range. A 429 that gets through anyway backs the
2419
+ * poll off for a doubling number of ticks, so a limiter that is already shedding load is not
2420
+ * handed the next window's budget in rejections too.
2421
+ *
2422
+ * Where the node will not serve `state_queryStorage` the poll reads block by block instead, at
2423
+ * three requests plus one per block; see {@link scanRangeAtOnce}.
2424
+ *
2336
2425
  * Returns a function that stops polling.
2337
2426
  */
2338
2427
  pollPhantomOrders(callback: (events: PhantomOrderEvent[]) => void, options?: PollPhantomOrdersOptions): () => void;
2428
+ /**
2429
+ * The Hyperbridge head, over HTTP like every other read here.
2430
+ *
2431
+ * Exposed for callers that have to know how old something is: a phantom order carries the block
2432
+ * it was registered at, and only against the head does that become "still biddable" or "long
2433
+ * expired".
2434
+ */
2435
+ latestBlockNumber(): Promise<number>;
2436
+ /**
2437
+ * The pallet's phantom timings, read from chain state.
2438
+ *
2439
+ * Both are governance-settable and neither is derivable: on Nexus today the window is 15 while
2440
+ * the runtime constant behind it is 25, so anything hard-coded is wrong in one direction or the
2441
+ * other — too tight and live orders are dropped, too loose and bids are sent into a closed
2442
+ * window for the pallet to reject.
2443
+ *
2444
+ * Read once per instance and cached, because a governance change to either is rare and a read
2445
+ * per poll tick would be a request per tick forever. The cost is that a change is picked up on
2446
+ * the next restart rather than immediately. A failed read is not cached, so it retries.
2447
+ */
2448
+ phantomTimings(): Promise<PhantomTimings>;
2449
+ private readPhantomTimings;
2450
+ /**
2451
+ * A whole range of blocks in one `state_queryStorage` call, or `null` when that is not available
2452
+ * and the caller should read block by block.
2453
+ *
2454
+ * Two conditions have to hold, and both are about decoding rather than the range itself.
2455
+ *
2456
+ * The version must be confirmed for this tick — an upgrade inside the range means blocks decode
2457
+ * against different metadata, and one call cannot do that.
2458
+ *
2459
+ * And that confirmed version must still be the one the api's own registry was built for.
2460
+ * `state_queryStorage` declares no historic block hash, so rpc-core skips its registry swap and
2461
+ * decodes the reply against the default registry — fixed at connect, with no
2462
+ * `subscribeRuntimeVersion` on an HTTP api to refresh it. After an upgrade the two diverge, and
2463
+ * the per-block path takes over for good: `api.at(hash, version)` resolves, and builds, the right
2464
+ * registry. That costs a restart to get the cheap path back, which is the correct direction to
2465
+ * fail in.
2466
+ */
2467
+ private scanRangeAtOnce;
2468
+ /**
2469
+ * The runtime version this tick's blocks may be decoded against, or `undefined` when that cannot
2470
+ * be established and each block must resolve its own.
2471
+ *
2472
+ * Naming a version to `api.at` is what removes two of the four RPCs a block scan costs, and it
2473
+ * is only sound while the version is actually the block's. Getting that wrong is not a loud
2474
+ * failure: events decoded against the wrong metadata come back as a shape the scan does not
2475
+ * recognise, so the block reads as carrying no phantom orders and the cursor advances past it —
2476
+ * exactly the silent miss the block cursor exists to rule out.
2477
+ *
2478
+ * So the version is read fresh each tick and only used when it matches the previous reading.
2479
+ * `specVersion` only ever increases, and this read happens *after* the head read, so two equal
2480
+ * readings mean no upgrade landed anywhere in between — and therefore none in the range about to
2481
+ * be scanned. A reading that differs means an upgrade landed inside the range: that tick falls
2482
+ * back to per-block resolution, which is exact, and the version is used from the next tick on
2483
+ * once it has been seen twice.
2484
+ *
2485
+ * The gap this leaves is a backlog reaching back past an upgrade, whose oldest blocks predate
2486
+ * even the previous reading. Recovering from an outage that long means those bid windows closed
2487
+ * many upgrades ago, so nothing is lost that was still winnable.
2488
+ *
2489
+ * A version that cannot be read at all yields `undefined` rather than an error: the scan is
2490
+ * about to make the same request against the same endpoint and is the better place to report it.
2491
+ */
2492
+ private confirmedRuntimeVersion;
2339
2493
  /**
2340
2494
  * The poll cadence for the runtime this instance is connected to: Gargantua polls every block,
2341
2495
  * everything else every 15s. Falls back to the slower cadence if the runtime cannot be read,
@@ -3846,6 +4000,18 @@ interface CancelOrderOptions {
3846
4000
  interface FillOptions {
3847
4001
  relayerFee: bigint;
3848
4002
  nativeDispatchFee: bigint;
4003
+ /**
4004
+ * Last block number at which this fill may execute. `0n` means no bound.
4005
+ *
4006
+ * A solver bidding through the coprocessor signs this calldata and then has no further
4007
+ * say in when it is used: the order's `deadline` is placer-chosen with no ceiling, and
4008
+ * retracting the bid on Hyperbridge does not reach the destination chain. Without a bound
4009
+ * the placer can sit on a signed bid and execute it once the price has moved their way.
4010
+ *
4011
+ * In blocks, matching `order.deadline`, so both read against the same clock. Dropped when
4012
+ * encoding against a gateway whose implementation predates the field.
4013
+ */
4014
+ validUntil: bigint;
3849
4015
  outputs: TokenInfo[];
3850
4016
  }
3851
4017
  interface PackedUserOperation {
@@ -3944,8 +4110,9 @@ interface OrderFeesQuote {
3944
4110
  /**
3945
4111
  * The amount to set as `Order.fees`, denominated in the source-chain fee
3946
4112
  * token. Same-chain fills carry a 2x margin over the estimated fill gas without
3947
- * a gas-price bump. Cross-chain gas is priced with 10% SDK-only headroom before
3948
- * adding the settlement relayer fee and a further 5% buffer over the whole sum.
4113
+ * a gas-price bump. Cross-chain orders originating on Ethereum mainnet use 50%
4114
+ * SDK-only gas-price headroom; other source chains use 10%. The settlement
4115
+ * relayer fee is then added with a further 5% buffer over the whole sum.
3949
4116
  */
3950
4117
  fees: bigint;
3951
4118
  /**
@@ -5404,8 +5571,9 @@ declare class IntentGateway {
5404
5571
  * **Yield/receive protocol:**
5405
5572
  * 1. If `order.fees` is unset or zero, prices the fee on an internal copy
5406
5573
  * via {@link quoteOrderFees}: same-chain fees are twice the fill-gas
5407
- * estimate without a gas-price bump; cross-chain gas is priced 10% above
5408
- * the live price before attaching (fill gas + the settlement relayer fee)
5574
+ * estimate without a gas-price bump; cross-chain order fees originating on
5575
+ * Ethereum price gas 50% above the live price, while other source chains use
5576
+ * 10%, before attaching (fill gas + the settlement relayer fee)
5409
5577
  * with a further 5% buffer over the whole sum — strictly above the solver's
5410
5578
  * unpadded requirement. Direct solver estimates remain unbumped. The wei
5411
5579
  * cost used for the `value` field receives a 2% buffer.
@@ -5641,7 +5809,8 @@ declare class IntentGateway {
5641
5809
  * transaction (check the native balance).
5642
5810
  *
5643
5811
  * @param order - The order to quote. `order.fees` is ignored and not mutated.
5644
- * Gas prices used to derive cross-chain `fees` receive 10% SDK-only headroom.
5812
+ * Gas prices used to derive cross-chain `fees` receive 50% SDK-only headroom
5813
+ * when the source chain is Ethereum mainnet and 10% for other source chains.
5645
5814
  * Same-chain quotes and direct calls to {@link estimateFillOrder}, including
5646
5815
  * Simplex solver estimates, remain unbumped.
5647
5816
  *
@@ -6125,6 +6294,210 @@ declare class CryptoUtils {
6125
6294
  decodeERC7821Execute(callData: HexString$1): ERC7821Call[] | null;
6126
6295
  }
6127
6296
 
6297
+ /**
6298
+ * `FillOptions` gained a `validUntil` field. Adding a field to a struct changes the
6299
+ * enclosing function's selector, so `fillOrder` has two incompatible shapes in the wild:
6300
+ *
6301
+ * v1 fillOrder(Order, (uint256 relayerFee, uint256 nativeDispatchFee, TokenInfo[] outputs))
6302
+ * v2 fillOrder(Order, (uint256 relayerFee, uint256 nativeDispatchFee, uint256 validUntil, TokenInfo[] outputs))
6303
+ *
6304
+ * The selectors differ (`0x5cfb1ea5` vs `0xa5470064`), so a v2 payload sent to a v1
6305
+ * deployment finds no matching function and reverts rather than mis-decoding — which is the
6306
+ * safe failure, but it does mean callers have to know which shape a gateway speaks.
6307
+ */
6308
+ type FillOptionsVersion = 1 | 2;
6309
+ /**
6310
+ * The v1 `fillOrder`, kept only so we can still talk to deployments that predate `validUntil`.
6311
+ *
6312
+ * Exported because consumers that cannot use {@link decodeFillOrder} still have to accept both
6313
+ * shapes. The indexer decodes bid calldata with ethers rather than viem (viem's byte handling
6314
+ * throws inside SubQuery's VM2 sandbox), so it rebuilds this decode itself and needs the same
6315
+ * definition rather than a second copy that can drift out of step with this one.
6316
+ */
6317
+ declare const FILL_ORDER_V1_ABI: readonly [{
6318
+ readonly type: "function";
6319
+ readonly name: "fillOrder";
6320
+ readonly stateMutability: "payable";
6321
+ readonly outputs: readonly [];
6322
+ readonly inputs: readonly [{
6323
+ readonly name: "order";
6324
+ readonly type: "tuple";
6325
+ readonly internalType: "struct Order";
6326
+ readonly components: readonly [{
6327
+ readonly name: "user";
6328
+ readonly type: "bytes32";
6329
+ readonly internalType: "bytes32";
6330
+ }, {
6331
+ readonly name: "source";
6332
+ readonly type: "bytes";
6333
+ readonly internalType: "bytes";
6334
+ }, {
6335
+ readonly name: "destination";
6336
+ readonly type: "bytes";
6337
+ readonly internalType: "bytes";
6338
+ }, {
6339
+ readonly name: "deadline";
6340
+ readonly type: "uint256";
6341
+ readonly internalType: "uint256";
6342
+ }, {
6343
+ readonly name: "nonce";
6344
+ readonly type: "uint256";
6345
+ readonly internalType: "uint256";
6346
+ }, {
6347
+ readonly name: "fees";
6348
+ readonly type: "uint256";
6349
+ readonly internalType: "uint256";
6350
+ }, {
6351
+ readonly name: "session";
6352
+ readonly type: "address";
6353
+ readonly internalType: "address";
6354
+ }, {
6355
+ readonly name: "predispatch";
6356
+ readonly type: "tuple";
6357
+ readonly internalType: "struct DispatchInfo";
6358
+ readonly components: readonly [{
6359
+ readonly name: "assets";
6360
+ readonly type: "tuple[]";
6361
+ readonly internalType: "struct TokenInfo[]";
6362
+ readonly components: readonly [{
6363
+ readonly name: "token";
6364
+ readonly type: "bytes32";
6365
+ readonly internalType: "bytes32";
6366
+ }, {
6367
+ readonly name: "amount";
6368
+ readonly type: "uint256";
6369
+ readonly internalType: "uint256";
6370
+ }];
6371
+ }, {
6372
+ readonly name: "call";
6373
+ readonly type: "bytes";
6374
+ readonly internalType: "bytes";
6375
+ }];
6376
+ }, {
6377
+ readonly name: "inputs";
6378
+ readonly type: "tuple[]";
6379
+ readonly internalType: "struct TokenInfo[]";
6380
+ readonly components: readonly [{
6381
+ readonly name: "token";
6382
+ readonly type: "bytes32";
6383
+ readonly internalType: "bytes32";
6384
+ }, {
6385
+ readonly name: "amount";
6386
+ readonly type: "uint256";
6387
+ readonly internalType: "uint256";
6388
+ }];
6389
+ }, {
6390
+ readonly name: "output";
6391
+ readonly type: "tuple";
6392
+ readonly internalType: "struct PaymentInfo";
6393
+ readonly components: readonly [{
6394
+ readonly name: "beneficiary";
6395
+ readonly type: "bytes32";
6396
+ readonly internalType: "bytes32";
6397
+ }, {
6398
+ readonly name: "assets";
6399
+ readonly type: "tuple[]";
6400
+ readonly internalType: "struct TokenInfo[]";
6401
+ readonly components: readonly [{
6402
+ readonly name: "token";
6403
+ readonly type: "bytes32";
6404
+ readonly internalType: "bytes32";
6405
+ }, {
6406
+ readonly name: "amount";
6407
+ readonly type: "uint256";
6408
+ readonly internalType: "uint256";
6409
+ }];
6410
+ }, {
6411
+ readonly name: "call";
6412
+ readonly type: "bytes";
6413
+ readonly internalType: "bytes";
6414
+ }];
6415
+ }];
6416
+ }, {
6417
+ readonly name: "options";
6418
+ readonly type: "tuple";
6419
+ readonly internalType: "struct FillOptions";
6420
+ readonly components: readonly [{
6421
+ readonly name: "relayerFee";
6422
+ readonly type: "uint256";
6423
+ readonly internalType: "uint256";
6424
+ }, {
6425
+ readonly name: "nativeDispatchFee";
6426
+ readonly type: "uint256";
6427
+ readonly internalType: "uint256";
6428
+ }, {
6429
+ readonly name: "outputs";
6430
+ readonly type: "tuple[]";
6431
+ readonly internalType: "struct TokenInfo[]";
6432
+ readonly components: readonly [{
6433
+ readonly name: "token";
6434
+ readonly type: "bytes32";
6435
+ readonly internalType: "bytes32";
6436
+ }, {
6437
+ readonly name: "amount";
6438
+ readonly type: "uint256";
6439
+ readonly internalType: "uint256";
6440
+ }];
6441
+ }];
6442
+ }];
6443
+ }];
6444
+ /**
6445
+ * IntentGateway implementations deployed before `FillOptions.validUntil` existed.
6446
+ *
6447
+ * The list is of *legacy* implementations rather than current ones, so the default is v2 and
6448
+ * nothing has to be added here when a new implementation ships — only when an old one is
6449
+ * discovered. Once every deployment is upgraded this set is vestigial and still correct.
6450
+ *
6451
+ * The alternative, listing known-good implementations, would be the version constant this
6452
+ * replaced wearing a different hat: a value someone must remember to update on every upgrade,
6453
+ * where forgetting breaks every fill on the chain.
6454
+ */
6455
+ declare const LEGACY_FILL_OPTIONS_IMPLEMENTATIONS: Set<string>;
6456
+ /**
6457
+ * Chains whose IntentGateway has not been redeployed with `FillOptions.validUntil` yet.
6458
+ *
6459
+ * A blunter instrument than {@link LEGACY_FILL_OPTIONS_IMPLEMENTATIONS} and used for the same
6460
+ * reason: those chains run a pre-`validUntil` implementation whose address is not tracked here,
6461
+ * so the address check would wrongly read them as current and every fill would revert on a
6462
+ * selector that does not exist.
6463
+ *
6464
+ * Delete a chain from this set when its gateway is redeployed. Once the set is empty the
6465
+ * implementation-address check covers everything on its own.
6466
+ */
6467
+ declare const CHAINS_WITHOUT_VALID_UNTIL: Set<number>;
6468
+ /** Test seam: drop memoised detection results. */
6469
+ declare function resetFillOptionsVersionCache(): void;
6470
+ /**
6471
+ * Works out which `FillOptions` shape a gateway accepts from the implementation it delegates to.
6472
+ *
6473
+ * EIP-1967 standardises three slots, all holding addresses — there is no version field to read,
6474
+ * and the contract deliberately does not carry one either: a hand-maintained version constant is
6475
+ * a second source of truth that has to be bumped on the right upgrade. The implementation address
6476
+ * is the value the proxy already updates, so it is what identifies the deployed code.
6477
+ */
6478
+ declare function getFillOptionsVersion(client: PublicClient, gateway: HexString$1): Promise<FillOptionsVersion>;
6479
+ /**
6480
+ * ABI-encodes a `fillOrder` call in the shape the target gateway understands.
6481
+ *
6482
+ * On a v1 gateway `validUntil` is dropped — there is nowhere to put it and no check on the
6483
+ * other side. That is a real loss of protection, so callers that rely on the bound should
6484
+ * surface it rather than assume it took effect.
6485
+ */
6486
+ declare function encodeFillOrder(order: Order, options: FillOptions, version: FillOptionsVersion): HexString$1;
6487
+ /**
6488
+ * Decodes a `fillOrder` call of either shape.
6489
+ *
6490
+ * v2 is tried first and v1 is the fallback; the selectors differ, so there is no shape a
6491
+ * decode could silently get wrong. `validUntil` reads as `0n` for a v1 payload, which is the
6492
+ * same value that means "no bound" in v2 — accurate, since a v1 fill genuinely has none.
6493
+ *
6494
+ * @returns The decoded order and options, or `null` if the calldata is not a `fillOrder`.
6495
+ */
6496
+ declare function decodeFillOrder(data: HexString$1): {
6497
+ order: Order;
6498
+ options: FillOptions;
6499
+ } | null;
6500
+
6128
6501
  type HexString = `0x${string}`;
6129
6502
  /** What a phantom bid's paymasterAndData declares about the solver behind it. */
6130
6503
  interface PhantomBidDeclaration {
@@ -6164,13 +6537,24 @@ declare function decodeAcceptedSourceChains(paymasterAndData: string | undefined
6164
6537
  *
6165
6538
  * A bid that declares V4 positions is quoting off those pools, and a pool price is what a trade
6166
6539
  * gets BEFORE the pool takes its fee — so the amount such a bid names is more than the solver
6167
- * would actually be left holding once the swap that sources it clears. 30bps is the fee tier the
6168
- * pools these positions sit in charge, so netting it out here is what makes a pool-priced quote
6169
- * comparable to a wallet-funded one, whose inventory has already paid its cost of goods.
6540
+ * would actually be left holding once the swap that sources it clears. Netting that cost out here
6541
+ * is what makes a pool-priced quote comparable to a wallet-funded one, whose inventory has already
6542
+ * paid its cost of goods.
6170
6543
  */
6171
- declare const UNISWAP_QUOTE_HAIRCUT_BPS = 30n;
6544
+ declare const UNISWAP_QUOTE_HAIRCUT_BPS = 10n;
6545
+ /**
6546
+ * Haircut applied to every phantom quote that is NOT priced off a Uniswap V4 pool, in basis points.
6547
+ *
6548
+ * A wallet-funded quote is still the best case the solver sees at bid time; the published rate is
6549
+ * what the protocol tells takers they can trade against, so it is shaded by this margin rather
6550
+ * than being the most optimistic number any bidder named. Pool-priced quotes pay
6551
+ * {@link UNISWAP_QUOTE_HAIRCUT_BPS} instead of this — not on top of it.
6552
+ */
6553
+ declare const PHANTOM_QUOTE_HAIRCUT_BPS = 5n;
6172
6554
  /** Applies {@link UNISWAP_QUOTE_HAIRCUT_BPS} to a quoted output amount, rounding down. */
6173
6555
  declare function applyUniswapQuoteHaircut(amount: bigint): bigint;
6556
+ /** Applies {@link PHANTOM_QUOTE_HAIRCUT_BPS} to a quoted output amount, rounding down. */
6557
+ declare function applyPhantomQuoteHaircut(amount: bigint): bigint;
6174
6558
 
6175
6559
  declare const ABI$1: readonly [{
6176
6560
  readonly type: "constructor";
@@ -6561,6 +6945,10 @@ declare const ABI$1: readonly [{
6561
6945
  readonly name: "nativeDispatchFee";
6562
6946
  readonly type: "uint256";
6563
6947
  readonly internalType: "uint256";
6948
+ }, {
6949
+ readonly name: "validUntil";
6950
+ readonly type: "uint256";
6951
+ readonly internalType: "uint256";
6564
6952
  }, {
6565
6953
  readonly name: "outputs";
6566
6954
  readonly type: "tuple[]";
@@ -11055,4 +11443,4 @@ declare function teleport(teleport_param: {
11055
11443
  extrinsics?: Array<SubmittableExtrinsic<"promise", ISubmittableResult>>;
11056
11444
  }): Promise<ReadableStream<HyperbridgeTxEvents>>;
11057
11445
 
11058
- export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type AvailableLiquidity, type Bid, type BidStorageEntry, type BidSubmissionResult, type BlockMetadata, type BridgeParams, type BridgeStep, type BundlerGasEstimate, BundlerMethod, type BuyAndSellRates, type BytesLikeHex, type CancelEvent, type CancelOptions, type CancelOrderOptions, type CancelQuote, type ChainConfig, type ChainConfigData, ChainConfigService, Chains, type ClientConfig, type ConfiguredAssetSymbol, type ConfiguredAssetSymbolInput, CryptoUtils, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, type DecodedOrderPlacedLog, type DecodedPostRequestEvent, type DecodedPostResponseEvent, type Deployment, type DispatchGet, type DispatchInfo, type DispatchPost, ERC20Method, type ERC7821Call, ERC7821_BATCH_MODE, type Erc4626VaultConfigData, type EstimateFillOrderParams, type EstimateGasCallData, EvmChain, type EvmChainParams, ABI as EvmHostABI, EvmLanguage, type ExecuteIntentOrderOptions, type ExecutionResult, type FillOptions, type FillOrderEstimate, type FillerBid, type FillerConfig, type GetRequestResponse, type GetRequestWithStatus, type GetResponseByRequestIdResponse, type GetResponseStorageValues, type HexString$1 as HexString, type HostParams, HyperClientStatus, HyperFungibleToken, HyperFungibleTokenABI, type HyperbridgeTxEvents, type IBatchConsensusAndGetResponseMessage, type IBatchConsensusAndPostRequestMessage, type IChain, type IConfig, type IConsensusMessage, type IEvmChain, type IEvmConfig, type IGetRequest, type IGetRequestMessage, type IGetResponse, type IGetResponseMessage, type IHyperbridgeConfig, type IIsmpMessage, type IMessage, INCLUSION_TIMEOUT_MS, type IPharosConfig, type IPolkadotHubConfig, type IPostRequest, type IPostResponse, type IProof, type IRequestMessage, type ISubstrateConfig, type ITimeoutPostRequestMessage, type IndexedRateIntentQuoteMetadata, type IndexedRateQuoteIntentResult, type IndexedRateSide, IndexedRateUnavailableError, type IndexerQueryClient, IntentGateway, ABI$1 as IntentGatewayABI, type IntentGatewayContext, type IntentGatewayParams, IntentOrderStatus, type IntentOrderStatusKey, type IntentOrderStatusUpdate, type IntentQuoteStrategy, type IntentQuoteTradeType, IntentsCoprocessor, InvalidIndexedRateError, InvalidLiquidityIndexerResponseError, InvalidPhantomSnapshotError, IsmpClient, type IsmpRequest, type LiquiditySlice, MOCK_ADDRESS, ORDER_V2_PARAM_TYPE, type Order, type OrderFeesQuote, type OrderResponse, OrderStatus, OrderStatusChecker, type OrderStatusMetadata, type OrderWithStatus, PACKED_USEROP_TYPEHASH, PLACE_ORDER_SELECTOR, type PackedUserOperation, type Params, type PaymentInfo, type PhantomBid, type PhantomBidBatchResult, type PhantomBidDeclaration, type PhantomBidOutcome, type PhantomOrderEvent, type PhantomOrderLeg, type PhantomOrderPriceSnapshot, type PhantomOrderPriceSnapshotsResponse, type PhantomSnapshotIntentQuoteMetadata, type PhantomSnapshotQuoteIntentResult, PhantomSnapshotUnavailableError, PharosChain, type PharosChainParams, PolkadotHubChain, type PolkadotHubChainParams, type PollPhantomOrdersOptions, type PostRequestStatus, type PostRequestTimeoutStatus, type PostRequestWithStatus, type QueryBuyAndSellRatesParams, type QuoteIntentParams, type QuoteIntentResult, type QuoteNativeResult, type QuoteResult, type QuoteUniswapParams, type QuoteUniswapResult, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, type RequestBody, type RequestCommitment, RequestKind, type RequestResponse, RequestStatus, type RequestStatusKey, type RequestStatusWithMetadata, type ResponseCommitmentWithValues, type ResumeIntentOrderOptions, type RetryConfig, SELECT_SOLVER_TYPEHASH, STATE_COMMITMENTS_SLOT, type SelectBidResult, type SelectOptions, type SigningAccount, type StateMachineHeight, type StateMachineId, type StateMachineIdParams, type StateMachineResponse, type StateMachineUpdate, type StorageFacade, type SubmitBidOptions, SubstrateChain, Swap, TESTNET_CHAINS, type TeleportParams, TeleportStatus, TimeoutStatus, type TimeoutStatusKey, TokenGateway, type TokenGatewayAssetTeleportedResponse, type TokenGatewayAssetTeleportedWithStatus, type TokenInfo, type TokenPrice, type TokenPricesResponse, type Transaction, TronChain, type TronChainParams, UNISWAP_QUOTE_HAIRCUT_BPS, USE_ETHERSCAN_CHAINS, type UniswapProtocol, type UniswapQuote, type UniswapQuoteToken, type UniswapTradeType, type UniswapV4IntentQuoteMetadata, type UniswapV4IntentQuoteOptions, type UniswapV4PoolConfigData, type UniswapV4PoolKey, type UniswapV4QuoteIntentResult, UnsupportedIntentQuotePairError, UnsupportedIntentQuoteStrategyError, UnsupportedLiquidityAssetError, UnsupportedLiquidityChainError, WrappedHyperFungibleTokenABI, type XcmGatewayParams, __test, adjustDecimals, applyUniswapQuoteHaircut, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, chainConfigs, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createEvmChain, createQueryClient, decodeAcceptedSourceChains, decodeERC7821ExecuteBatch, decodePhantomBidDeclaration, decodeUserOpScale, deriveHttpUrl, encodeAcceptedSourceChains, encodeERC7821ExecuteBatch, encodeISMPMessage, encodePhantomBidDeclaration, encodeStateMachineId, encodeUserOpScale, encodeWithdrawalRequest, estimateGasForPost, fetchPrice, fetchSourceProof, generateRootWithProof, getChainId, getConfigByStateMachineId, getContractCallInput, getContractCallInputs, getGasPriceFromEtherscan, getOrFetchStorageSlot, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, getViemChain, hexToString, hyperbridgeAddress, maxBigInt, normalizeAddressForEvmBytes32, normalizeAddressForStateMachine, normalizeEvmAddress, normalizeEvmChainId, normalizeStateMachineId, orderCommitment, parseStateMachineId, pharosAtlantic, pharosMainnet, polkadotAssetHubPaseo, polkadotHubMainnet, poolSlug, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, quoteUniswap, requestCommitmentKey, responseCommitmentKey, retryPromise, sortPoolSymbols, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };
11446
+ export { ADDRESS_ZERO, type AllStatusKey, type AssetTeleported, type AssetTeleportedResponse, type AvailableLiquidity, type Bid, type BidStorageEntry, type BidSubmissionResult, type BlockMetadata, type BridgeParams, type BridgeStep, type BundlerGasEstimate, BundlerMethod, type BuyAndSellRates, type BytesLikeHex, CHAINS_WITHOUT_VALID_UNTIL, type CancelEvent, type CancelOptions, type CancelOrderOptions, type CancelQuote, type ChainConfig, type ChainConfigData, ChainConfigService, Chains, type ClientConfig, type ConfiguredAssetSymbol, type ConfiguredAssetSymbolInput, CryptoUtils, DEFAULT_ADDRESS, DEFAULT_GRAFFITI, DOMAIN_TYPEHASH, DUMMY_PRIVATE_KEY, type DecodedOrderPlacedLog, type DecodedPostRequestEvent, type DecodedPostResponseEvent, type Deployment, type DispatchGet, type DispatchInfo, type DispatchPost, ERC20Method, type ERC7821Call, ERC7821_BATCH_MODE, type Erc4626VaultConfigData, type EstimateFillOrderParams, type EstimateGasCallData, EvmChain, type EvmChainParams, ABI as EvmHostABI, EvmLanguage, type ExecuteIntentOrderOptions, type ExecutionResult, FILL_ORDER_V1_ABI, type FillOptions, type FillOptionsVersion, type FillOrderEstimate, type FillerBid, type FillerConfig, type GetRequestResponse, type GetRequestWithStatus, type GetResponseByRequestIdResponse, type GetResponseStorageValues, type HexString$1 as HexString, type HostParams, HyperClientStatus, HyperFungibleToken, HyperFungibleTokenABI, type HyperbridgeTxEvents, type IBatchConsensusAndGetResponseMessage, type IBatchConsensusAndPostRequestMessage, type IChain, type IConfig, type IConsensusMessage, type IEvmChain, type IEvmConfig, type IGetRequest, type IGetRequestMessage, type IGetResponse, type IGetResponseMessage, type IHyperbridgeConfig, type IIsmpMessage, type IMessage, INCLUSION_TIMEOUT_MS, type IPharosConfig, type IPolkadotHubConfig, type IPostRequest, type IPostResponse, type IProof, type IRequestMessage, type ISubstrateConfig, type ITimeoutPostRequestMessage, type IndexedRateIntentQuoteMetadata, type IndexedRateQuoteIntentResult, type IndexedRateSide, IndexedRateUnavailableError, type IndexerQueryClient, IntentGateway, ABI$1 as IntentGatewayABI, type IntentGatewayContext, type IntentGatewayParams, IntentOrderStatus, type IntentOrderStatusKey, type IntentOrderStatusUpdate, type IntentQuoteStrategy, type IntentQuoteTradeType, IntentsCoprocessor, InvalidIndexedRateError, InvalidLiquidityIndexerResponseError, InvalidPhantomSnapshotError, IsmpClient, type IsmpRequest, LEGACY_FILL_OPTIONS_IMPLEMENTATIONS, type LiquiditySlice, MOCK_ADDRESS, ORDER_V2_PARAM_TYPE, type Order, type OrderFeesQuote, type OrderResponse, OrderStatus, OrderStatusChecker, type OrderStatusMetadata, type OrderWithStatus, PACKED_USEROP_TYPEHASH, PHANTOM_QUOTE_HAIRCUT_BPS, PLACE_ORDER_SELECTOR, type PackedUserOperation, type Params, type PaymentInfo, type PhantomBid, type PhantomBidBatchResult, type PhantomBidDeclaration, type PhantomBidOutcome, type PhantomOrderEvent, type PhantomOrderLeg, type PhantomOrderPriceSnapshot, type PhantomOrderPriceSnapshotsResponse, type PhantomSnapshotIntentQuoteMetadata, type PhantomSnapshotQuoteIntentResult, PhantomSnapshotUnavailableError, type PhantomTimings, PharosChain, type PharosChainParams, PolkadotHubChain, type PolkadotHubChainParams, type PollPhantomOrdersOptions, type PostRequestStatus, type PostRequestTimeoutStatus, type PostRequestWithStatus, type QueryBuyAndSellRatesParams, type QuoteIntentParams, type QuoteIntentResult, type QuoteNativeResult, type QuoteResult, type QuoteUniswapParams, type QuoteUniswapResult, REQUEST_COMMITMENTS_SLOT, REQUEST_RECEIPTS_SLOT, RESPONSE_COMMITMENTS_SLOT, RESPONSE_RECEIPTS_SLOT, type RequestBody, type RequestCommitment, RequestKind, type RequestResponse, RequestStatus, type RequestStatusKey, type RequestStatusWithMetadata, type ResponseCommitmentWithValues, type ResumeIntentOrderOptions, type RetryConfig, SELECT_SOLVER_TYPEHASH, STATE_COMMITMENTS_SLOT, type SelectBidResult, type SelectOptions, type SigningAccount, type StateMachineHeight, type StateMachineId, type StateMachineIdParams, type StateMachineResponse, type StateMachineUpdate, type StorageFacade, type SubmitBidOptions, SubstrateChain, Swap, TESTNET_CHAINS, type TeleportParams, TeleportStatus, TimeoutStatus, type TimeoutStatusKey, TokenGateway, type TokenGatewayAssetTeleportedResponse, type TokenGatewayAssetTeleportedWithStatus, type TokenInfo, type TokenPrice, type TokenPricesResponse, type Transaction, TronChain, type TronChainParams, UNISWAP_QUOTE_HAIRCUT_BPS, USE_ETHERSCAN_CHAINS, type UniswapProtocol, type UniswapQuote, type UniswapQuoteToken, type UniswapTradeType, type UniswapV4IntentQuoteMetadata, type UniswapV4IntentQuoteOptions, type UniswapV4PoolConfigData, type UniswapV4PoolKey, type UniswapV4QuoteIntentResult, UnsupportedIntentQuotePairError, UnsupportedIntentQuoteStrategyError, UnsupportedLiquidityAssetError, UnsupportedLiquidityChainError, WrappedHyperFungibleTokenABI, type XcmGatewayParams, __test, adjustDecimals, applyPhantomQuoteHaircut, applyUniswapQuoteHaircut, bytes20ToBytes32, bytes32ToBytes20, calculateAllowanceMappingLocation, calculateBalanceMappingLocation, chainConfigs, constructRedeemEscrowRequestBody, constructRefundEscrowRequestBody, convertCodecToIGetRequest, convertCodecToIProof, convertIGetRequestToCodec, convertIProofToCodec, convertStateIdToStateMachineId, convertStateMachineEnumToString, convertStateMachineIdToEnum, createEvmChain, createQueryClient, decodeAcceptedSourceChains, decodeERC7821ExecuteBatch, decodeFillOrder, decodePhantomBidDeclaration, decodeUserOpScale, deriveHttpUrl, encodeAcceptedSourceChains, encodeERC7821ExecuteBatch, encodeFillOrder, encodeISMPMessage, encodePhantomBidDeclaration, encodeStateMachineId, encodeUserOpScale, encodeWithdrawalRequest, estimateGasForPost, fetchPrice, fetchSourceProof, generateRootWithProof, getChainId, getConfigByStateMachineId, getContractCallInput, getContractCallInputs, getFillOptionsVersion, getGasPriceFromEtherscan, getOrFetchStorageSlot, getOrderPlacedFromTx, getPostRequestEventFromTx, getPostResponseEventFromTx, getRequestCommitment, getStateCommitmentFieldSlot, getStateCommitmentSlot, getStorageSlot, getViemChain, hexToString, hyperbridgeAddress, maxBigInt, normalizeAddressForEvmBytes32, normalizeAddressForStateMachine, normalizeEvmAddress, normalizeEvmChainId, normalizeStateMachineId, orderCommitment, parseStateMachineId, pharosAtlantic, pharosMainnet, polkadotAssetHubPaseo, polkadotHubMainnet, poolSlug, postRequestCommitment, queryAssetTeleported, queryGetRequest, queryPostRequest, quoteUniswap, requestCommitmentKey, resetFillOptionsVersionCache, responseCommitmentKey, retryPromise, sortPoolSymbols, teleport, teleportDot, transformOrderForContract, tronChainIds, tronNile };