@hyperbridge/sdk 1.9.0 → 1.9.2
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.d.ts +14 -6
- package/dist/browser/index.js +35 -14
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.d.ts +14 -6
- package/dist/node/index.js +35 -14
- package/dist/node/index.js.map +1 -1
- package/package.json +1 -1
package/dist/node/index.d.ts
CHANGED
|
@@ -2898,6 +2898,7 @@ declare const IntentOrderStatus: Readonly<{
|
|
|
2898
2898
|
ORDER_PLACED: "ORDER_PLACED";
|
|
2899
2899
|
ORDER_CONFIRMED: "ORDER_CONFIRMED";
|
|
2900
2900
|
AWAITING_BIDS: "AWAITING_BIDS";
|
|
2901
|
+
NEW_BID: "NEW_BID";
|
|
2901
2902
|
BIDS_RECEIVED: "BIDS_RECEIVED";
|
|
2902
2903
|
BID_SELECTED: "BID_SELECTED";
|
|
2903
2904
|
FILLED: "FILLED";
|
|
@@ -2923,6 +2924,11 @@ type IntentOrderStatusUpdate = {
|
|
|
2923
2924
|
commitment: HexString;
|
|
2924
2925
|
totalFilledAssets: TokenInfo[];
|
|
2925
2926
|
remainingAssets: TokenInfo[];
|
|
2927
|
+
} | {
|
|
2928
|
+
status: "NEW_BID";
|
|
2929
|
+
commitment: HexString;
|
|
2930
|
+
bidCount: number;
|
|
2931
|
+
bids: FillerBid[];
|
|
2926
2932
|
} | {
|
|
2927
2933
|
status: "BIDS_RECEIVED";
|
|
2928
2934
|
commitment: HexString;
|
|
@@ -2980,7 +2986,8 @@ interface SelectBidResult {
|
|
|
2980
2986
|
interface ExecuteIntentOrderOptions {
|
|
2981
2987
|
order: Order;
|
|
2982
2988
|
sessionPrivateKey?: HexString;
|
|
2983
|
-
|
|
2989
|
+
/** Duration in ms to collect bids before selecting the best one. */
|
|
2990
|
+
auctionTimeMs: number;
|
|
2984
2991
|
pollIntervalMs?: number;
|
|
2985
2992
|
/**
|
|
2986
2993
|
* If set, bids are restricted to the given solver until `timeoutMs` elapses,
|
|
@@ -2996,7 +3003,8 @@ interface ExecuteIntentOrderOptions {
|
|
|
2996
3003
|
/** Options for resuming execution of a previously placed intent order */
|
|
2997
3004
|
interface ResumeIntentOrderOptions {
|
|
2998
3005
|
sessionPrivateKey?: HexString;
|
|
2999
|
-
|
|
3006
|
+
/** Duration in ms to collect bids before selecting the best one. */
|
|
3007
|
+
auctionTimeMs: number;
|
|
3000
3008
|
pollIntervalMs?: number;
|
|
3001
3009
|
solver?: {
|
|
3002
3010
|
address: HexString;
|
|
@@ -3986,16 +3994,16 @@ declare class IntentGateway {
|
|
|
3986
3994
|
* @param options - Optional tuning parameters:
|
|
3987
3995
|
* - `maxPriorityFeePerGasBumpPercent` — bump % for the priority fee estimate (default 8).
|
|
3988
3996
|
* - `maxFeePerGasBumpPercent` — bump % for the max fee estimate (default 10).
|
|
3989
|
-
* - `
|
|
3997
|
+
* - `auctionTimeMs` — duration in ms to collect bids before selecting the best one.
|
|
3990
3998
|
* - `pollIntervalMs` — interval between bid-polling attempts.
|
|
3991
3999
|
* @yields {@link IntentOrderStatusUpdate} at each lifecycle stage.
|
|
3992
4000
|
* @throws If the `placeOrder` generator behaves unexpectedly, or if gas
|
|
3993
4001
|
* estimation returns zero.
|
|
3994
4002
|
*/
|
|
3995
|
-
execute(order: Order, graffiti
|
|
4003
|
+
execute(order: Order, graffiti: HexString | undefined, options: {
|
|
4004
|
+
auctionTimeMs: number;
|
|
3996
4005
|
maxPriorityFeePerGasBumpPercent?: number;
|
|
3997
4006
|
maxFeePerGasBumpPercent?: number;
|
|
3998
|
-
minBids?: number;
|
|
3999
4007
|
pollIntervalMs?: number;
|
|
4000
4008
|
solver?: {
|
|
4001
4009
|
address: HexString;
|
|
@@ -4029,7 +4037,7 @@ declare class IntentGateway {
|
|
|
4029
4037
|
* @yields {@link IntentOrderStatusUpdate} at each execution stage.
|
|
4030
4038
|
* @throws If the order is missing required fields for resumption.
|
|
4031
4039
|
*/
|
|
4032
|
-
resume(order: Order, options
|
|
4040
|
+
resume(order: Order, options: ResumeIntentOrderOptions): AsyncGenerator<IntentOrderStatusUpdate, void>;
|
|
4033
4041
|
/**
|
|
4034
4042
|
* Returns both the native token cost and the relayer fee for cancelling an
|
|
4035
4043
|
* order. Use `relayerFee` to approve the ERC-20 spend before submitting.
|
package/dist/node/index.js
CHANGED
|
@@ -554,6 +554,7 @@ var IntentOrderStatus = Object.freeze({
|
|
|
554
554
|
ORDER_PLACED: "ORDER_PLACED",
|
|
555
555
|
ORDER_CONFIRMED: "ORDER_CONFIRMED",
|
|
556
556
|
AWAITING_BIDS: "AWAITING_BIDS",
|
|
557
|
+
NEW_BID: "NEW_BID",
|
|
557
558
|
BIDS_RECEIVED: "BIDS_RECEIVED",
|
|
558
559
|
BID_SELECTED: "BID_SELECTED",
|
|
559
560
|
FILLED: "FILLED",
|
|
@@ -15267,12 +15268,12 @@ var OrderExecutor = class {
|
|
|
15267
15268
|
*/
|
|
15268
15269
|
async *deadlineStream(deadline, commitment) {
|
|
15269
15270
|
const client = this.ctx.dest.client;
|
|
15270
|
-
const
|
|
15271
|
+
const blockTimeMs = client.chain?.blockTime ?? 2e3;
|
|
15271
15272
|
while (true) {
|
|
15272
15273
|
const currentBlock = await client.getBlockNumber();
|
|
15273
15274
|
if (currentBlock >= deadline) break;
|
|
15274
15275
|
const blocksRemaining = Number(deadline - currentBlock);
|
|
15275
|
-
const sleepMs = blocksRemaining *
|
|
15276
|
+
const sleepMs = Math.min(blocksRemaining * blockTimeMs, 6e4);
|
|
15276
15277
|
await sleep(sleepMs);
|
|
15277
15278
|
}
|
|
15278
15279
|
yield {
|
|
@@ -15416,7 +15417,7 @@ var OrderExecutor = class {
|
|
|
15416
15417
|
* (terminates — settlement is confirmed async via Hyperbridge)
|
|
15417
15418
|
*/
|
|
15418
15419
|
async *executeOrder(options) {
|
|
15419
|
-
const { order, sessionPrivateKey,
|
|
15420
|
+
const { order, sessionPrivateKey, auctionTimeMs, pollIntervalMs = DEFAULT_POLL_INTERVAL, solver } = options;
|
|
15420
15421
|
const commitment = order.id;
|
|
15421
15422
|
const isSameChain = order.source === order.destination;
|
|
15422
15423
|
if (!this.ctx.intentsCoprocessor) {
|
|
@@ -15436,7 +15437,7 @@ var OrderExecutor = class {
|
|
|
15436
15437
|
order,
|
|
15437
15438
|
sessionPrivateKey,
|
|
15438
15439
|
commitment,
|
|
15439
|
-
|
|
15440
|
+
auctionTimeMs,
|
|
15440
15441
|
pollIntervalMs,
|
|
15441
15442
|
solver,
|
|
15442
15443
|
usedUserOps,
|
|
@@ -15463,7 +15464,7 @@ var OrderExecutor = class {
|
|
|
15463
15464
|
order,
|
|
15464
15465
|
sessionPrivateKey,
|
|
15465
15466
|
commitment,
|
|
15466
|
-
|
|
15467
|
+
auctionTimeMs,
|
|
15467
15468
|
pollIntervalMs,
|
|
15468
15469
|
solver,
|
|
15469
15470
|
usedUserOps,
|
|
@@ -15474,6 +15475,26 @@ var OrderExecutor = class {
|
|
|
15474
15475
|
const solverLockStartTime = Date.now();
|
|
15475
15476
|
yield { status: "AWAITING_BIDS", commitment, totalFilledAssets, remainingAssets };
|
|
15476
15477
|
try {
|
|
15478
|
+
const auctionEnd = Date.now() + auctionTimeMs;
|
|
15479
|
+
const auctionSeenBids = /* @__PURE__ */ new Set();
|
|
15480
|
+
while (Date.now() < auctionEnd) {
|
|
15481
|
+
try {
|
|
15482
|
+
const bids = await this.fetchBids({ commitment, solver, solverLockStartTime });
|
|
15483
|
+
const freshBids = bids.filter((bid) => !usedUserOps.has(userOpHashKey(bid.userOp)));
|
|
15484
|
+
const newBids = freshBids.filter((bid) => !auctionSeenBids.has(userOpHashKey(bid.userOp)));
|
|
15485
|
+
if (newBids.length > 0) {
|
|
15486
|
+
for (const bid of newBids) {
|
|
15487
|
+
auctionSeenBids.add(userOpHashKey(bid.userOp));
|
|
15488
|
+
}
|
|
15489
|
+
yield { status: "NEW_BID", commitment, bidCount: freshBids.length, bids: freshBids };
|
|
15490
|
+
}
|
|
15491
|
+
} catch {
|
|
15492
|
+
}
|
|
15493
|
+
const remaining = auctionEnd - Date.now();
|
|
15494
|
+
if (remaining > 0) {
|
|
15495
|
+
await sleep(Math.min(pollIntervalMs, remaining));
|
|
15496
|
+
}
|
|
15497
|
+
}
|
|
15477
15498
|
while (true) {
|
|
15478
15499
|
let freshBids;
|
|
15479
15500
|
try {
|
|
@@ -15483,7 +15504,7 @@ var OrderExecutor = class {
|
|
|
15483
15504
|
await sleep(pollIntervalMs);
|
|
15484
15505
|
continue;
|
|
15485
15506
|
}
|
|
15486
|
-
if (freshBids.length
|
|
15507
|
+
if (freshBids.length === 0) {
|
|
15487
15508
|
await sleep(pollIntervalMs);
|
|
15488
15509
|
continue;
|
|
15489
15510
|
}
|
|
@@ -18714,7 +18735,7 @@ var IntentGateway = class _IntentGateway {
|
|
|
18714
18735
|
* @param options - Optional tuning parameters:
|
|
18715
18736
|
* - `maxPriorityFeePerGasBumpPercent` — bump % for the priority fee estimate (default 8).
|
|
18716
18737
|
* - `maxFeePerGasBumpPercent` — bump % for the max fee estimate (default 10).
|
|
18717
|
-
* - `
|
|
18738
|
+
* - `auctionTimeMs` — duration in ms to collect bids before selecting the best one.
|
|
18718
18739
|
* - `pollIntervalMs` — interval between bid-polling attempts.
|
|
18719
18740
|
* @yields {@link IntentOrderStatusUpdate} at each lifecycle stage.
|
|
18720
18741
|
* @throws If the `placeOrder` generator behaves unexpectedly, or if gas
|
|
@@ -18750,9 +18771,9 @@ var IntentGateway = class _IntentGateway {
|
|
|
18750
18771
|
for await (const status of this.orderExecutor.executeOrder({
|
|
18751
18772
|
order: finalizedOrder,
|
|
18752
18773
|
sessionPrivateKey,
|
|
18753
|
-
|
|
18754
|
-
pollIntervalMs: options
|
|
18755
|
-
solver: options
|
|
18774
|
+
auctionTimeMs: options.auctionTimeMs,
|
|
18775
|
+
pollIntervalMs: options.pollIntervalMs,
|
|
18776
|
+
solver: options.solver
|
|
18756
18777
|
})) {
|
|
18757
18778
|
yield status;
|
|
18758
18779
|
}
|
|
@@ -18796,10 +18817,10 @@ var IntentGateway = class _IntentGateway {
|
|
|
18796
18817
|
this.assertOrderCanResume(order);
|
|
18797
18818
|
for await (const status of this.orderExecutor.executeOrder({
|
|
18798
18819
|
order,
|
|
18799
|
-
sessionPrivateKey: options
|
|
18800
|
-
|
|
18801
|
-
pollIntervalMs: options
|
|
18802
|
-
solver: options
|
|
18820
|
+
sessionPrivateKey: options.sessionPrivateKey,
|
|
18821
|
+
auctionTimeMs: options.auctionTimeMs,
|
|
18822
|
+
pollIntervalMs: options.pollIntervalMs,
|
|
18823
|
+
solver: options.solver
|
|
18803
18824
|
})) {
|
|
18804
18825
|
yield status;
|
|
18805
18826
|
}
|