@hyperbridge/sdk 2.4.2 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
- export { bj as IntentGatewayV2, b4 as decodeERC7821ExecuteBatch, b5 as decodeUserOpScale, b6 as encodeERC7821ExecuteBatch, b8 as encodeUserOpScale } from './IntentGatewayV2-PzbhFn_7.cjs';
1
+ import { z as PackedUserOperation } from './IntentGatewayV2-DuSwlT02.cjs';
2
+ export { bm as IntentGatewayV2, b7 as decodeERC7821ExecuteBatch, b8 as decodeUserOpScale, b9 as encodeERC7821ExecuteBatch, bb as encodeUserOpScale } from './IntentGatewayV2-DuSwlT02.cjs';
2
3
  import '@polkadot/api';
3
4
  import '@polkadot/keyring/types';
4
5
  import 'consola';
@@ -8,6 +9,12 @@ import 'viem';
8
9
  import 'viem/chains';
9
10
 
10
11
  type HexString = `0x${string}`;
12
+ /**
13
+ * ERC-4337 v0.8 EntryPoint, the contract whose userOpHash a bid's solver signature is taken over.
14
+ * Canonical across every EVM chain we support, which is why it is a constant here rather than
15
+ * something callers pass in (chain.ts carries the same address per chain as `EntryPointV08`).
16
+ */
17
+ declare const ENTRY_POINT_V08_ADDRESS: "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108";
11
18
  /** Minimal fetch shape used by the JSON-RPC POSTs below. */
12
19
  type FetchLike = (url: string, init: any) => Promise<{
13
20
  json(): Promise<any>;
@@ -1439,20 +1446,50 @@ declare function weightedMedian(entries: {
1439
1446
  weight: bigint;
1440
1447
  }[]): bigint;
1441
1448
  declare function extractFillData(callData: HexString, gatewayAddress: string): FillData | null;
1449
+ /** Derives the 192-bit bid nonce key binding a bid to an (order, sessionKey) pair. */
1450
+ type BidNonceKeyFn = (commitment: HexString, sessionKey: HexString) => bigint;
1451
+ /** Recomputes an order's commitment from the contract-shaped order decoded out of a bid's calldata. */
1452
+ type OrderCommitmentFn = (order: Record<string, unknown>) => HexString | null;
1453
+ /**
1454
+ * Default (viem) {@link OrderCommitmentFn}. The order comes straight out of `fillOrder`'s ABI
1455
+ * decode, so it is already contract-shaped and re-encoding it reproduces `keccak256(abi.encode(order))`
1456
+ * — the same commitment IntentGatewayV2 computes on-chain. Returns null when it cannot be computed,
1457
+ * which callers treat as unverifiable (fail closed).
1458
+ */
1459
+ declare function orderCommitmentFromDecoded(order: Record<string, unknown>): HexString | null;
1460
+ interface BidSignature {
1461
+ /** The order commitment the solver signature is bound to. */
1462
+ commitment: HexString;
1463
+ /** The solver's 65-byte ECDSA signature over the userOpHash. */
1464
+ solverSignature: HexString;
1465
+ }
1466
+ /** Splits a bid userOp's signature into its commitment and solver signature; null if malformed. */
1467
+ declare function splitBidSignature(signature: HexString): BidSignature | null;
1468
+ /** Recovers the address that produced a bid's solver signature, or null if it cannot be recovered. */
1469
+ type RecoverBidSigner = (userOp: PackedUserOperation, entryPoint: HexString, chainId: bigint, solverSignature: HexString) => Promise<HexString | null>;
1470
+ /**
1471
+ * Default {@link RecoverBidSigner}: recovers over the EntryPoint v0.8 userOpHash, the digest
1472
+ * SolverAccount itself validates against. viem-based, so Node consumers get it for free while the
1473
+ * indexer injects an ethers equivalent (see the note at the top of this file).
1474
+ */
1475
+ declare const recoverBidSignerViem: RecoverBidSigner;
1442
1476
  declare function fetchBidsForOrder(nodeUrl: string, commitment: string): Promise<RpcBidInfo[]>;
1443
1477
  /**
1444
1478
  * Aggregates every bid for a phantom order into a single price/liquidity snapshot.
1445
1479
  *
1446
1480
  * Fetches the live bids via `intents_getBidsForOrder` and reads each filler's quoted output amount.
1447
- * The liquidity-weighted median weights every quote by the solver's balance of the output token on
1448
- * the destination chain, so a solver that can't actually deliver size carries little or no weight —
1449
- * which is why no fill simulation is needed to filter unfillable quotes. For each bidding solver it
1450
- * also records a full liquidity sweep every configured yield-vault token on every supported chain
1451
- * (raw ERC-20 + vault positions). Returns `null` when there are no decodable bids.
1481
+ * Only bids that {@link isVerifiedSolverBid} accepts are counted a bid from anyone who is not one
1482
+ * of our delegated solvers, or whose signature was not produced for this order, is dropped rather
1483
+ * than allowed to move the price. The liquidity-weighted median then weights every surviving quote by
1484
+ * the solver's balance of the output token on the destination chain, so a solver that can't actually
1485
+ * deliver size carries little or no weight which is why no fill simulation is needed to filter
1486
+ * unfillable quotes. For each bidding solver it also records a full liquidity sweep — every
1487
+ * configured yield-vault token on every supported chain (raw ERC-20 + vault positions). Returns
1488
+ * `null` when no bid survives verification.
1452
1489
  *
1453
- * `extractFill` decodes a bid's ERC-7821 calldata into the fill's order/output; it defaults to the
1454
- * viem-based {@link extractFillData}, but the indexer injects a VM2-safe variant (viem's
1455
- * decodeFunctionData keccak throws in the SubQuery sandbox).
1490
+ * `extractFill` decodes a bid's ERC-7821 calldata into the fill's order/output and `recoverSigner`
1491
+ * recovers its solver signature; both default to the viem implementations, but the indexer injects
1492
+ * VM2-safe variants (viem's keccak throws in the SubQuery sandbox).
1456
1493
  */
1457
1494
  declare function aggregatePhantomBids(params: {
1458
1495
  nodeUrl: string;
@@ -1462,8 +1499,13 @@ declare function aggregatePhantomBids(params: {
1462
1499
  gatewayAddress: string;
1463
1500
  commitment: string;
1464
1501
  yieldVaults: YieldVaultMap;
1502
+ /** SolverAccount on `chain` that our solvers delegate to; bids from anyone else are dropped. */
1503
+ solverAccount: string;
1465
1504
  extractFill?: (callData: HexString, gatewayAddress: string) => FillData | null;
1505
+ recoverSigner?: RecoverBidSigner;
1506
+ bidNonceKey?: BidNonceKeyFn;
1507
+ orderCommitment?: OrderCommitmentFn;
1466
1508
  logger?: AggregationLogger;
1467
1509
  }): Promise<PhantomAggregation | null>;
1468
1510
 
1469
- export { type AggregationLogger, FILL_ORDER_ABI, type FetchLike, type FillData, type HexString, type LpBalance, type PhantomAggregation, type RpcBidInfo, type YieldVaultMap, aggregatePhantomBids, extractFillData, fetchBidsForOrder, setAggregationFetch, weightedMedian };
1511
+ export { type AggregationLogger, type BidNonceKeyFn, type BidSignature, ENTRY_POINT_V08_ADDRESS, FILL_ORDER_ABI, type FetchLike, type FillData, type HexString, type LpBalance, type OrderCommitmentFn, type PhantomAggregation, type RecoverBidSigner, type RpcBidInfo, type YieldVaultMap, aggregatePhantomBids, extractFillData, fetchBidsForOrder, orderCommitmentFromDecoded, recoverBidSignerViem, setAggregationFetch, splitBidSignature, weightedMedian };
@@ -1,4 +1,5 @@
1
- export { bj as IntentGatewayV2, b4 as decodeERC7821ExecuteBatch, b5 as decodeUserOpScale, b6 as encodeERC7821ExecuteBatch, b8 as encodeUserOpScale } from './IntentGatewayV2-PzbhFn_7.js';
1
+ import { z as PackedUserOperation } from './IntentGatewayV2-DuSwlT02.js';
2
+ export { bm as IntentGatewayV2, b7 as decodeERC7821ExecuteBatch, b8 as decodeUserOpScale, b9 as encodeERC7821ExecuteBatch, bb as encodeUserOpScale } from './IntentGatewayV2-DuSwlT02.js';
2
3
  import '@polkadot/api';
3
4
  import '@polkadot/keyring/types';
4
5
  import 'consola';
@@ -8,6 +9,12 @@ import 'viem';
8
9
  import 'viem/chains';
9
10
 
10
11
  type HexString = `0x${string}`;
12
+ /**
13
+ * ERC-4337 v0.8 EntryPoint, the contract whose userOpHash a bid's solver signature is taken over.
14
+ * Canonical across every EVM chain we support, which is why it is a constant here rather than
15
+ * something callers pass in (chain.ts carries the same address per chain as `EntryPointV08`).
16
+ */
17
+ declare const ENTRY_POINT_V08_ADDRESS: "0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108";
11
18
  /** Minimal fetch shape used by the JSON-RPC POSTs below. */
12
19
  type FetchLike = (url: string, init: any) => Promise<{
13
20
  json(): Promise<any>;
@@ -1439,20 +1446,50 @@ declare function weightedMedian(entries: {
1439
1446
  weight: bigint;
1440
1447
  }[]): bigint;
1441
1448
  declare function extractFillData(callData: HexString, gatewayAddress: string): FillData | null;
1449
+ /** Derives the 192-bit bid nonce key binding a bid to an (order, sessionKey) pair. */
1450
+ type BidNonceKeyFn = (commitment: HexString, sessionKey: HexString) => bigint;
1451
+ /** Recomputes an order's commitment from the contract-shaped order decoded out of a bid's calldata. */
1452
+ type OrderCommitmentFn = (order: Record<string, unknown>) => HexString | null;
1453
+ /**
1454
+ * Default (viem) {@link OrderCommitmentFn}. The order comes straight out of `fillOrder`'s ABI
1455
+ * decode, so it is already contract-shaped and re-encoding it reproduces `keccak256(abi.encode(order))`
1456
+ * — the same commitment IntentGatewayV2 computes on-chain. Returns null when it cannot be computed,
1457
+ * which callers treat as unverifiable (fail closed).
1458
+ */
1459
+ declare function orderCommitmentFromDecoded(order: Record<string, unknown>): HexString | null;
1460
+ interface BidSignature {
1461
+ /** The order commitment the solver signature is bound to. */
1462
+ commitment: HexString;
1463
+ /** The solver's 65-byte ECDSA signature over the userOpHash. */
1464
+ solverSignature: HexString;
1465
+ }
1466
+ /** Splits a bid userOp's signature into its commitment and solver signature; null if malformed. */
1467
+ declare function splitBidSignature(signature: HexString): BidSignature | null;
1468
+ /** Recovers the address that produced a bid's solver signature, or null if it cannot be recovered. */
1469
+ type RecoverBidSigner = (userOp: PackedUserOperation, entryPoint: HexString, chainId: bigint, solverSignature: HexString) => Promise<HexString | null>;
1470
+ /**
1471
+ * Default {@link RecoverBidSigner}: recovers over the EntryPoint v0.8 userOpHash, the digest
1472
+ * SolverAccount itself validates against. viem-based, so Node consumers get it for free while the
1473
+ * indexer injects an ethers equivalent (see the note at the top of this file).
1474
+ */
1475
+ declare const recoverBidSignerViem: RecoverBidSigner;
1442
1476
  declare function fetchBidsForOrder(nodeUrl: string, commitment: string): Promise<RpcBidInfo[]>;
1443
1477
  /**
1444
1478
  * Aggregates every bid for a phantom order into a single price/liquidity snapshot.
1445
1479
  *
1446
1480
  * Fetches the live bids via `intents_getBidsForOrder` and reads each filler's quoted output amount.
1447
- * The liquidity-weighted median weights every quote by the solver's balance of the output token on
1448
- * the destination chain, so a solver that can't actually deliver size carries little or no weight —
1449
- * which is why no fill simulation is needed to filter unfillable quotes. For each bidding solver it
1450
- * also records a full liquidity sweep every configured yield-vault token on every supported chain
1451
- * (raw ERC-20 + vault positions). Returns `null` when there are no decodable bids.
1481
+ * Only bids that {@link isVerifiedSolverBid} accepts are counted a bid from anyone who is not one
1482
+ * of our delegated solvers, or whose signature was not produced for this order, is dropped rather
1483
+ * than allowed to move the price. The liquidity-weighted median then weights every surviving quote by
1484
+ * the solver's balance of the output token on the destination chain, so a solver that can't actually
1485
+ * deliver size carries little or no weight which is why no fill simulation is needed to filter
1486
+ * unfillable quotes. For each bidding solver it also records a full liquidity sweep — every
1487
+ * configured yield-vault token on every supported chain (raw ERC-20 + vault positions). Returns
1488
+ * `null` when no bid survives verification.
1452
1489
  *
1453
- * `extractFill` decodes a bid's ERC-7821 calldata into the fill's order/output; it defaults to the
1454
- * viem-based {@link extractFillData}, but the indexer injects a VM2-safe variant (viem's
1455
- * decodeFunctionData keccak throws in the SubQuery sandbox).
1490
+ * `extractFill` decodes a bid's ERC-7821 calldata into the fill's order/output and `recoverSigner`
1491
+ * recovers its solver signature; both default to the viem implementations, but the indexer injects
1492
+ * VM2-safe variants (viem's keccak throws in the SubQuery sandbox).
1456
1493
  */
1457
1494
  declare function aggregatePhantomBids(params: {
1458
1495
  nodeUrl: string;
@@ -1462,8 +1499,13 @@ declare function aggregatePhantomBids(params: {
1462
1499
  gatewayAddress: string;
1463
1500
  commitment: string;
1464
1501
  yieldVaults: YieldVaultMap;
1502
+ /** SolverAccount on `chain` that our solvers delegate to; bids from anyone else are dropped. */
1503
+ solverAccount: string;
1465
1504
  extractFill?: (callData: HexString, gatewayAddress: string) => FillData | null;
1505
+ recoverSigner?: RecoverBidSigner;
1506
+ bidNonceKey?: BidNonceKeyFn;
1507
+ orderCommitment?: OrderCommitmentFn;
1466
1508
  logger?: AggregationLogger;
1467
1509
  }): Promise<PhantomAggregation | null>;
1468
1510
 
1469
- export { type AggregationLogger, FILL_ORDER_ABI, type FetchLike, type FillData, type HexString, type LpBalance, type PhantomAggregation, type RpcBidInfo, type YieldVaultMap, aggregatePhantomBids, extractFillData, fetchBidsForOrder, setAggregationFetch, weightedMedian };
1511
+ export { type AggregationLogger, type BidNonceKeyFn, type BidSignature, ENTRY_POINT_V08_ADDRESS, FILL_ORDER_ABI, type FetchLike, type FillData, type HexString, type LpBalance, type OrderCommitmentFn, type PhantomAggregation, type RecoverBidSigner, type RpcBidInfo, type YieldVaultMap, aggregatePhantomBids, extractFillData, fetchBidsForOrder, orderCommitmentFromDecoded, recoverBidSignerViem, setAggregationFetch, splitBidSignature, weightedMedian };