@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/browser/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/browser/index.js
CHANGED
|
@@ -604,6 +604,7 @@ var IntentOrderStatus = Object.freeze({
|
|
|
604
604
|
ORDER_PLACED: "ORDER_PLACED",
|
|
605
605
|
ORDER_CONFIRMED: "ORDER_CONFIRMED",
|
|
606
606
|
AWAITING_BIDS: "AWAITING_BIDS",
|
|
607
|
+
NEW_BID: "NEW_BID",
|
|
607
608
|
BIDS_RECEIVED: "BIDS_RECEIVED",
|
|
608
609
|
BID_SELECTED: "BID_SELECTED",
|
|
609
610
|
FILLED: "FILLED",
|
|
@@ -15327,12 +15328,12 @@ var OrderExecutor = class {
|
|
|
15327
15328
|
*/
|
|
15328
15329
|
async *deadlineStream(deadline, commitment) {
|
|
15329
15330
|
const client = this.ctx.dest.client;
|
|
15330
|
-
const
|
|
15331
|
+
const blockTimeMs = client.chain?.blockTime ?? 2e3;
|
|
15331
15332
|
while (true) {
|
|
15332
15333
|
const currentBlock = await client.getBlockNumber();
|
|
15333
15334
|
if (currentBlock >= deadline) break;
|
|
15334
15335
|
const blocksRemaining = Number(deadline - currentBlock);
|
|
15335
|
-
const sleepMs = blocksRemaining *
|
|
15336
|
+
const sleepMs = Math.min(blocksRemaining * blockTimeMs, 6e4);
|
|
15336
15337
|
await sleep(sleepMs);
|
|
15337
15338
|
}
|
|
15338
15339
|
yield {
|
|
@@ -15476,7 +15477,7 @@ var OrderExecutor = class {
|
|
|
15476
15477
|
* (terminates — settlement is confirmed async via Hyperbridge)
|
|
15477
15478
|
*/
|
|
15478
15479
|
async *executeOrder(options) {
|
|
15479
|
-
const { order, sessionPrivateKey,
|
|
15480
|
+
const { order, sessionPrivateKey, auctionTimeMs, pollIntervalMs = DEFAULT_POLL_INTERVAL, solver } = options;
|
|
15480
15481
|
const commitment = order.id;
|
|
15481
15482
|
const isSameChain = order.source === order.destination;
|
|
15482
15483
|
if (!this.ctx.intentsCoprocessor) {
|
|
@@ -15496,7 +15497,7 @@ var OrderExecutor = class {
|
|
|
15496
15497
|
order,
|
|
15497
15498
|
sessionPrivateKey,
|
|
15498
15499
|
commitment,
|
|
15499
|
-
|
|
15500
|
+
auctionTimeMs,
|
|
15500
15501
|
pollIntervalMs,
|
|
15501
15502
|
solver,
|
|
15502
15503
|
usedUserOps,
|
|
@@ -15523,7 +15524,7 @@ var OrderExecutor = class {
|
|
|
15523
15524
|
order,
|
|
15524
15525
|
sessionPrivateKey,
|
|
15525
15526
|
commitment,
|
|
15526
|
-
|
|
15527
|
+
auctionTimeMs,
|
|
15527
15528
|
pollIntervalMs,
|
|
15528
15529
|
solver,
|
|
15529
15530
|
usedUserOps,
|
|
@@ -15534,6 +15535,26 @@ var OrderExecutor = class {
|
|
|
15534
15535
|
const solverLockStartTime = Date.now();
|
|
15535
15536
|
yield { status: "AWAITING_BIDS", commitment, totalFilledAssets, remainingAssets };
|
|
15536
15537
|
try {
|
|
15538
|
+
const auctionEnd = Date.now() + auctionTimeMs;
|
|
15539
|
+
const auctionSeenBids = /* @__PURE__ */ new Set();
|
|
15540
|
+
while (Date.now() < auctionEnd) {
|
|
15541
|
+
try {
|
|
15542
|
+
const bids = await this.fetchBids({ commitment, solver, solverLockStartTime });
|
|
15543
|
+
const freshBids = bids.filter((bid) => !usedUserOps.has(userOpHashKey(bid.userOp)));
|
|
15544
|
+
const newBids = freshBids.filter((bid) => !auctionSeenBids.has(userOpHashKey(bid.userOp)));
|
|
15545
|
+
if (newBids.length > 0) {
|
|
15546
|
+
for (const bid of newBids) {
|
|
15547
|
+
auctionSeenBids.add(userOpHashKey(bid.userOp));
|
|
15548
|
+
}
|
|
15549
|
+
yield { status: "NEW_BID", commitment, bidCount: freshBids.length, bids: freshBids };
|
|
15550
|
+
}
|
|
15551
|
+
} catch {
|
|
15552
|
+
}
|
|
15553
|
+
const remaining = auctionEnd - Date.now();
|
|
15554
|
+
if (remaining > 0) {
|
|
15555
|
+
await sleep(Math.min(pollIntervalMs, remaining));
|
|
15556
|
+
}
|
|
15557
|
+
}
|
|
15537
15558
|
while (true) {
|
|
15538
15559
|
let freshBids;
|
|
15539
15560
|
try {
|
|
@@ -15543,7 +15564,7 @@ var OrderExecutor = class {
|
|
|
15543
15564
|
await sleep(pollIntervalMs);
|
|
15544
15565
|
continue;
|
|
15545
15566
|
}
|
|
15546
|
-
if (freshBids.length
|
|
15567
|
+
if (freshBids.length === 0) {
|
|
15547
15568
|
await sleep(pollIntervalMs);
|
|
15548
15569
|
continue;
|
|
15549
15570
|
}
|
|
@@ -18774,7 +18795,7 @@ var IntentGateway = class _IntentGateway {
|
|
|
18774
18795
|
* @param options - Optional tuning parameters:
|
|
18775
18796
|
* - `maxPriorityFeePerGasBumpPercent` — bump % for the priority fee estimate (default 8).
|
|
18776
18797
|
* - `maxFeePerGasBumpPercent` — bump % for the max fee estimate (default 10).
|
|
18777
|
-
* - `
|
|
18798
|
+
* - `auctionTimeMs` — duration in ms to collect bids before selecting the best one.
|
|
18778
18799
|
* - `pollIntervalMs` — interval between bid-polling attempts.
|
|
18779
18800
|
* @yields {@link IntentOrderStatusUpdate} at each lifecycle stage.
|
|
18780
18801
|
* @throws If the `placeOrder` generator behaves unexpectedly, or if gas
|
|
@@ -18810,9 +18831,9 @@ var IntentGateway = class _IntentGateway {
|
|
|
18810
18831
|
for await (const status of this.orderExecutor.executeOrder({
|
|
18811
18832
|
order: finalizedOrder,
|
|
18812
18833
|
sessionPrivateKey,
|
|
18813
|
-
|
|
18814
|
-
pollIntervalMs: options
|
|
18815
|
-
solver: options
|
|
18834
|
+
auctionTimeMs: options.auctionTimeMs,
|
|
18835
|
+
pollIntervalMs: options.pollIntervalMs,
|
|
18836
|
+
solver: options.solver
|
|
18816
18837
|
})) {
|
|
18817
18838
|
yield status;
|
|
18818
18839
|
}
|
|
@@ -18856,10 +18877,10 @@ var IntentGateway = class _IntentGateway {
|
|
|
18856
18877
|
this.assertOrderCanResume(order);
|
|
18857
18878
|
for await (const status of this.orderExecutor.executeOrder({
|
|
18858
18879
|
order,
|
|
18859
|
-
sessionPrivateKey: options
|
|
18860
|
-
|
|
18861
|
-
pollIntervalMs: options
|
|
18862
|
-
solver: options
|
|
18880
|
+
sessionPrivateKey: options.sessionPrivateKey,
|
|
18881
|
+
auctionTimeMs: options.auctionTimeMs,
|
|
18882
|
+
pollIntervalMs: options.pollIntervalMs,
|
|
18883
|
+
solver: options.solver
|
|
18863
18884
|
})) {
|
|
18864
18885
|
yield status;
|
|
18865
18886
|
}
|