@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.
- package/dist/browser/index.js +25 -6
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.js +25 -6
- package/dist/node/index.js.map +1 -1
- package/package.json +1 -1
package/dist/node/index.js
CHANGED
|
@@ -15436,7 +15436,7 @@ var OrderExecutor = class {
|
|
|
15436
15436
|
async *executeOrder(options) {
|
|
15437
15437
|
const { order, sessionPrivateKey, auctionTimeMs, pollIntervalMs = DEFAULT_POLL_INTERVAL, solver } = options;
|
|
15438
15438
|
const commitment = order.id;
|
|
15439
|
-
|
|
15439
|
+
order.source === order.destination;
|
|
15440
15440
|
if (!this.ctx.intentsCoprocessor) {
|
|
15441
15441
|
yield { status: "FAILED", error: "IntentsCoprocessor required for order execution" };
|
|
15442
15442
|
return;
|
|
@@ -15465,10 +15465,15 @@ var OrderExecutor = class {
|
|
|
15465
15465
|
});
|
|
15466
15466
|
const deadlineTimeout = this.deadlineStream(order.deadline, commitment);
|
|
15467
15467
|
const combined = mergeRace(deadlineTimeout, executionStream);
|
|
15468
|
-
|
|
15469
|
-
|
|
15470
|
-
|
|
15471
|
-
|
|
15468
|
+
try {
|
|
15469
|
+
for await (const update of combined) {
|
|
15470
|
+
yield update;
|
|
15471
|
+
if (update.status === "EXPIRED" || update.status === "FILLED") return;
|
|
15472
|
+
}
|
|
15473
|
+
} finally {
|
|
15474
|
+
console.log(`[OrderExecutor] Tearing down streams for commitment=${commitment}`);
|
|
15475
|
+
await executionStream.return(void 0);
|
|
15476
|
+
await deadlineTimeout.return(void 0);
|
|
15472
15477
|
}
|
|
15473
15478
|
}
|
|
15474
15479
|
/**
|
|
@@ -15489,6 +15494,12 @@ var OrderExecutor = class {
|
|
|
15489
15494
|
targetAssets
|
|
15490
15495
|
} = params;
|
|
15491
15496
|
let { totalFilledAssets, remainingAssets } = params;
|
|
15497
|
+
const MAX_BID_ATTEMPTS = 2;
|
|
15498
|
+
const bidFailCounts = /* @__PURE__ */ new Map();
|
|
15499
|
+
const isFreshBid = (bid) => {
|
|
15500
|
+
const key = userOpHashKey(bid.userOp);
|
|
15501
|
+
return !usedUserOps.has(key) && (bidFailCounts.get(key) ?? 0) < MAX_BID_ATTEMPTS;
|
|
15502
|
+
};
|
|
15492
15503
|
const solverLockStartTime = Date.now();
|
|
15493
15504
|
yield { status: "AWAITING_BIDS", commitment, totalFilledAssets, remainingAssets };
|
|
15494
15505
|
try {
|
|
@@ -15516,7 +15527,7 @@ var OrderExecutor = class {
|
|
|
15516
15527
|
let freshBids;
|
|
15517
15528
|
try {
|
|
15518
15529
|
const bids = await this.fetchBids({ commitment, solver, solverLockStartTime });
|
|
15519
|
-
freshBids = bids.filter(
|
|
15530
|
+
freshBids = bids.filter(isFreshBid);
|
|
15520
15531
|
} catch {
|
|
15521
15532
|
await sleep(pollIntervalMs);
|
|
15522
15533
|
continue;
|
|
@@ -15544,6 +15555,14 @@ var OrderExecutor = class {
|
|
|
15544
15555
|
remainingAssets,
|
|
15545
15556
|
error: `Failed to select bid and submit: ${err instanceof Error ? err.message : String(err)}`
|
|
15546
15557
|
};
|
|
15558
|
+
try {
|
|
15559
|
+
const sorted = await this.bidManager.validateAndSortBids(freshBids, order);
|
|
15560
|
+
if (sorted.length > 0) {
|
|
15561
|
+
const key = userOpHashKey(sorted[0].bid.userOp);
|
|
15562
|
+
bidFailCounts.set(key, (bidFailCounts.get(key) ?? 0) + 1);
|
|
15563
|
+
}
|
|
15564
|
+
} catch {
|
|
15565
|
+
}
|
|
15547
15566
|
await sleep(pollIntervalMs);
|
|
15548
15567
|
continue;
|
|
15549
15568
|
}
|