@hyperbridge/sdk 1.9.4 → 1.9.5

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.
@@ -15496,7 +15496,7 @@ var OrderExecutor = class {
15496
15496
  async *executeOrder(options) {
15497
15497
  const { order, sessionPrivateKey, auctionTimeMs, pollIntervalMs = DEFAULT_POLL_INTERVAL, solver } = options;
15498
15498
  const commitment = order.id;
15499
- const isSameChain = order.source === order.destination;
15499
+ order.source === order.destination;
15500
15500
  if (!this.ctx.intentsCoprocessor) {
15501
15501
  yield { status: "FAILED", error: "IntentsCoprocessor required for order execution" };
15502
15502
  return;
@@ -15525,10 +15525,15 @@ var OrderExecutor = class {
15525
15525
  });
15526
15526
  const deadlineTimeout = this.deadlineStream(order.deadline, commitment);
15527
15527
  const combined = mergeRace(deadlineTimeout, executionStream);
15528
- for await (const update of combined) {
15529
- yield update;
15530
- if (update.status === "EXPIRED" || update.status === "FILLED") return;
15531
- if (update.status === "BID_SELECTED" && !isSameChain) return;
15528
+ try {
15529
+ for await (const update of combined) {
15530
+ yield update;
15531
+ if (update.status === "EXPIRED" || update.status === "FILLED") return;
15532
+ }
15533
+ } finally {
15534
+ console.log(`[OrderExecutor] Tearing down streams for commitment=${commitment}`);
15535
+ await executionStream.return(void 0);
15536
+ await deadlineTimeout.return(void 0);
15532
15537
  }
15533
15538
  }
15534
15539
  /**
@@ -15549,6 +15554,12 @@ var OrderExecutor = class {
15549
15554
  targetAssets
15550
15555
  } = params;
15551
15556
  let { totalFilledAssets, remainingAssets } = params;
15557
+ const MAX_BID_ATTEMPTS = 2;
15558
+ const bidFailCounts = /* @__PURE__ */ new Map();
15559
+ const isFreshBid = (bid) => {
15560
+ const key = userOpHashKey(bid.userOp);
15561
+ return !usedUserOps.has(key) && (bidFailCounts.get(key) ?? 0) < MAX_BID_ATTEMPTS;
15562
+ };
15552
15563
  const solverLockStartTime = Date.now();
15553
15564
  yield { status: "AWAITING_BIDS", commitment, totalFilledAssets, remainingAssets };
15554
15565
  try {
@@ -15576,7 +15587,7 @@ var OrderExecutor = class {
15576
15587
  let freshBids;
15577
15588
  try {
15578
15589
  const bids = await this.fetchBids({ commitment, solver, solverLockStartTime });
15579
- freshBids = bids.filter((bid) => !usedUserOps.has(userOpHashKey(bid.userOp)));
15590
+ freshBids = bids.filter(isFreshBid);
15580
15591
  } catch {
15581
15592
  await sleep(pollIntervalMs);
15582
15593
  continue;
@@ -15604,6 +15615,14 @@ var OrderExecutor = class {
15604
15615
  remainingAssets,
15605
15616
  error: `Failed to select bid and submit: ${err instanceof Error ? err.message : String(err)}`
15606
15617
  };
15618
+ try {
15619
+ const sorted = await this.bidManager.validateAndSortBids(freshBids, order);
15620
+ if (sorted.length > 0) {
15621
+ const key = userOpHashKey(sorted[0].bid.userOp);
15622
+ bidFailCounts.set(key, (bidFailCounts.get(key) ?? 0) + 1);
15623
+ }
15624
+ } catch {
15625
+ }
15607
15626
  await sleep(pollIntervalMs);
15608
15627
  continue;
15609
15628
  }