@hyperbridge/sdk 1.9.0 → 1.9.1

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.
@@ -2980,7 +2980,8 @@ interface SelectBidResult {
2980
2980
  interface ExecuteIntentOrderOptions {
2981
2981
  order: Order;
2982
2982
  sessionPrivateKey?: HexString;
2983
- minBids?: number;
2983
+ /** Duration in ms to collect bids before selecting the best one. */
2984
+ auctionTimeMs: number;
2984
2985
  pollIntervalMs?: number;
2985
2986
  /**
2986
2987
  * If set, bids are restricted to the given solver until `timeoutMs` elapses,
@@ -2996,7 +2997,8 @@ interface ExecuteIntentOrderOptions {
2996
2997
  /** Options for resuming execution of a previously placed intent order */
2997
2998
  interface ResumeIntentOrderOptions {
2998
2999
  sessionPrivateKey?: HexString;
2999
- minBids?: number;
3000
+ /** Duration in ms to collect bids before selecting the best one. */
3001
+ auctionTimeMs: number;
3000
3002
  pollIntervalMs?: number;
3001
3003
  solver?: {
3002
3004
  address: HexString;
@@ -3986,16 +3988,16 @@ declare class IntentGateway {
3986
3988
  * @param options - Optional tuning parameters:
3987
3989
  * - `maxPriorityFeePerGasBumpPercent` — bump % for the priority fee estimate (default 8).
3988
3990
  * - `maxFeePerGasBumpPercent` — bump % for the max fee estimate (default 10).
3989
- * - `minBids` — minimum bids to collect before selecting (default 1).
3991
+ * - `auctionTimeMs` — duration in ms to collect bids before selecting the best one.
3990
3992
  * - `pollIntervalMs` — interval between bid-polling attempts.
3991
3993
  * @yields {@link IntentOrderStatusUpdate} at each lifecycle stage.
3992
3994
  * @throws If the `placeOrder` generator behaves unexpectedly, or if gas
3993
3995
  * estimation returns zero.
3994
3996
  */
3995
- execute(order: Order, graffiti?: HexString, options?: {
3997
+ execute(order: Order, graffiti: HexString | undefined, options: {
3998
+ auctionTimeMs: number;
3996
3999
  maxPriorityFeePerGasBumpPercent?: number;
3997
4000
  maxFeePerGasBumpPercent?: number;
3998
- minBids?: number;
3999
4001
  pollIntervalMs?: number;
4000
4002
  solver?: {
4001
4003
  address: HexString;
@@ -4029,7 +4031,7 @@ declare class IntentGateway {
4029
4031
  * @yields {@link IntentOrderStatusUpdate} at each execution stage.
4030
4032
  * @throws If the order is missing required fields for resumption.
4031
4033
  */
4032
- resume(order: Order, options?: ResumeIntentOrderOptions): AsyncGenerator<IntentOrderStatusUpdate, void>;
4034
+ resume(order: Order, options: ResumeIntentOrderOptions): AsyncGenerator<IntentOrderStatusUpdate, void>;
4033
4035
  /**
4034
4036
  * Returns both the native token cost and the relayer fee for cancelling an
4035
4037
  * order. Use `relayerFee` to approve the ERC-20 spend before submitting.
@@ -15267,12 +15267,12 @@ var OrderExecutor = class {
15267
15267
  */
15268
15268
  async *deadlineStream(deadline, commitment) {
15269
15269
  const client = this.ctx.dest.client;
15270
- const blockTimeSeconds = client.chain?.blockTime ?? 2;
15270
+ const blockTimeMs = client.chain?.blockTime ?? 2e3;
15271
15271
  while (true) {
15272
15272
  const currentBlock = await client.getBlockNumber();
15273
15273
  if (currentBlock >= deadline) break;
15274
15274
  const blocksRemaining = Number(deadline - currentBlock);
15275
- const sleepMs = blocksRemaining * blockTimeSeconds * 1e3;
15275
+ const sleepMs = blocksRemaining * blockTimeMs;
15276
15276
  await sleep(sleepMs);
15277
15277
  }
15278
15278
  yield {
@@ -15416,7 +15416,7 @@ var OrderExecutor = class {
15416
15416
  * (terminates — settlement is confirmed async via Hyperbridge)
15417
15417
  */
15418
15418
  async *executeOrder(options) {
15419
- const { order, sessionPrivateKey, minBids = 1, pollIntervalMs = DEFAULT_POLL_INTERVAL, solver } = options;
15419
+ const { order, sessionPrivateKey, auctionTimeMs, pollIntervalMs = DEFAULT_POLL_INTERVAL, solver } = options;
15420
15420
  const commitment = order.id;
15421
15421
  const isSameChain = order.source === order.destination;
15422
15422
  if (!this.ctx.intentsCoprocessor) {
@@ -15436,7 +15436,7 @@ var OrderExecutor = class {
15436
15436
  order,
15437
15437
  sessionPrivateKey,
15438
15438
  commitment,
15439
- minBids,
15439
+ auctionTimeMs,
15440
15440
  pollIntervalMs,
15441
15441
  solver,
15442
15442
  usedUserOps,
@@ -15463,7 +15463,7 @@ var OrderExecutor = class {
15463
15463
  order,
15464
15464
  sessionPrivateKey,
15465
15465
  commitment,
15466
- minBids,
15466
+ auctionTimeMs,
15467
15467
  pollIntervalMs,
15468
15468
  solver,
15469
15469
  usedUserOps,
@@ -15474,6 +15474,10 @@ var OrderExecutor = class {
15474
15474
  const solverLockStartTime = Date.now();
15475
15475
  yield { status: "AWAITING_BIDS", commitment, totalFilledAssets, remainingAssets };
15476
15476
  try {
15477
+ const auctionEnd = Date.now() + auctionTimeMs;
15478
+ while (Date.now() < auctionEnd) {
15479
+ await sleep(Math.min(pollIntervalMs, auctionEnd - Date.now()));
15480
+ }
15477
15481
  while (true) {
15478
15482
  let freshBids;
15479
15483
  try {
@@ -15483,7 +15487,7 @@ var OrderExecutor = class {
15483
15487
  await sleep(pollIntervalMs);
15484
15488
  continue;
15485
15489
  }
15486
- if (freshBids.length < minBids) {
15490
+ if (freshBids.length === 0) {
15487
15491
  await sleep(pollIntervalMs);
15488
15492
  continue;
15489
15493
  }
@@ -18714,7 +18718,7 @@ var IntentGateway = class _IntentGateway {
18714
18718
  * @param options - Optional tuning parameters:
18715
18719
  * - `maxPriorityFeePerGasBumpPercent` — bump % for the priority fee estimate (default 8).
18716
18720
  * - `maxFeePerGasBumpPercent` — bump % for the max fee estimate (default 10).
18717
- * - `minBids` — minimum bids to collect before selecting (default 1).
18721
+ * - `auctionTimeMs` — duration in ms to collect bids before selecting the best one.
18718
18722
  * - `pollIntervalMs` — interval between bid-polling attempts.
18719
18723
  * @yields {@link IntentOrderStatusUpdate} at each lifecycle stage.
18720
18724
  * @throws If the `placeOrder` generator behaves unexpectedly, or if gas
@@ -18750,9 +18754,9 @@ var IntentGateway = class _IntentGateway {
18750
18754
  for await (const status of this.orderExecutor.executeOrder({
18751
18755
  order: finalizedOrder,
18752
18756
  sessionPrivateKey,
18753
- minBids: options?.minBids,
18754
- pollIntervalMs: options?.pollIntervalMs,
18755
- solver: options?.solver
18757
+ auctionTimeMs: options.auctionTimeMs,
18758
+ pollIntervalMs: options.pollIntervalMs,
18759
+ solver: options.solver
18756
18760
  })) {
18757
18761
  yield status;
18758
18762
  }
@@ -18796,10 +18800,10 @@ var IntentGateway = class _IntentGateway {
18796
18800
  this.assertOrderCanResume(order);
18797
18801
  for await (const status of this.orderExecutor.executeOrder({
18798
18802
  order,
18799
- sessionPrivateKey: options?.sessionPrivateKey,
18800
- minBids: options?.minBids,
18801
- pollIntervalMs: options?.pollIntervalMs,
18802
- solver: options?.solver
18803
+ sessionPrivateKey: options.sessionPrivateKey,
18804
+ auctionTimeMs: options.auctionTimeMs,
18805
+ pollIntervalMs: options.pollIntervalMs,
18806
+ solver: options.solver
18803
18807
  })) {
18804
18808
  yield status;
18805
18809
  }