@hyperbridge/sdk 2.8.0 → 2.8.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 +61 -2
- package/dist/browser/index.js +111 -42
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +111 -42
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +2 -2
- package/dist/node/index.d.ts +2 -2
- package/dist/node/index.js +111 -42
- package/dist/node/index.js.map +1 -1
- package/dist/node/{intents-helpers-gyGREuyu.d.cts → intents-helpers-D_km9I2f.d.cts} +74 -6
- package/dist/node/{intents-helpers-gyGREuyu.d.ts → intents-helpers-D_km9I2f.d.ts} +74 -6
- package/dist/node/intents-helpers.cjs +22 -11
- package/dist/node/intents-helpers.cjs.map +1 -1
- package/dist/node/intents-helpers.d.cts +1 -1
- package/dist/node/intents-helpers.d.ts +1 -1
- package/dist/node/intents-helpers.js +22 -11
- package/dist/node/intents-helpers.js.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.d.ts
CHANGED
|
@@ -929,6 +929,11 @@ interface ChainConfigData {
|
|
|
929
929
|
USDT: number;
|
|
930
930
|
cNGN?: number;
|
|
931
931
|
EXT?: number;
|
|
932
|
+
ZARP?: number;
|
|
933
|
+
EURC?: number;
|
|
934
|
+
XSGD?: number;
|
|
935
|
+
TRYB?: number;
|
|
936
|
+
USDR?: number;
|
|
932
937
|
};
|
|
933
938
|
tokenStorageSlots?: {
|
|
934
939
|
USDT?: {
|
|
@@ -947,6 +952,30 @@ interface ChainConfigData {
|
|
|
947
952
|
balanceSlot: number;
|
|
948
953
|
allowanceSlot: number;
|
|
949
954
|
};
|
|
955
|
+
cNGN?: {
|
|
956
|
+
balanceSlot: number;
|
|
957
|
+
allowanceSlot: number;
|
|
958
|
+
};
|
|
959
|
+
ZARP?: {
|
|
960
|
+
balanceSlot: number;
|
|
961
|
+
allowanceSlot: number;
|
|
962
|
+
};
|
|
963
|
+
EURC?: {
|
|
964
|
+
balanceSlot: number;
|
|
965
|
+
allowanceSlot: number;
|
|
966
|
+
};
|
|
967
|
+
XSGD?: {
|
|
968
|
+
balanceSlot: number;
|
|
969
|
+
allowanceSlot: number;
|
|
970
|
+
};
|
|
971
|
+
TRYB?: {
|
|
972
|
+
balanceSlot: number;
|
|
973
|
+
allowanceSlot: number;
|
|
974
|
+
};
|
|
975
|
+
USDR?: {
|
|
976
|
+
balanceSlot: number;
|
|
977
|
+
allowanceSlot: number;
|
|
978
|
+
};
|
|
950
979
|
};
|
|
951
980
|
addresses: {
|
|
952
981
|
IntentGateway?: `0x${string}`;
|
|
@@ -1987,16 +2016,37 @@ declare class IntentsCoprocessor {
|
|
|
1987
2016
|
/**
|
|
1988
2017
|
* Signs and sends an extrinsic. Submissions are serialised through {@link submissionQueue} so
|
|
1989
2018
|
* concurrent calls never collide on the substrate account nonce — each extrinsic reaches a block
|
|
1990
|
-
* before the next is signed
|
|
2019
|
+
* (or is confirmed still pooled and returned as `pending`) before the next is signed; auto-nonce
|
|
2020
|
+
* via `system.accountNextIndex` counts pooled extrinsics, so a pending one is never re-used.
|
|
1991
2021
|
*/
|
|
1992
2022
|
private signAndSendExtrinsic;
|
|
1993
2023
|
/**
|
|
1994
2024
|
* Signs and sends an extrinsic, handling status updates and errors.
|
|
1995
2025
|
* Implements retry logic with progressive tip increases for stuck transactions.
|
|
2026
|
+
*
|
|
2027
|
+
* A retry only happens when the previous attempt verifiably went nowhere. Once an attempt's
|
|
2028
|
+
* extrinsic is known to be pooled (`pending`), re-signing the same call would race our own
|
|
2029
|
+
* submission: the copy either bounces off the pool (1014, same nonce below the replacement
|
|
2030
|
+
* priority bump) or — if the original lands first, freeing the nonce — executes as a duplicate
|
|
2031
|
+
* and fails on-chain (e.g. `BidNotFound` for a retraction). Neither can succeed, so the pending
|
|
2032
|
+
* result is returned for the caller to confirm later.
|
|
1996
2033
|
*/
|
|
1997
2034
|
private sendExtrinsicWithRetries;
|
|
1998
2035
|
/**
|
|
1999
|
-
*
|
|
2036
|
+
* Classifies a submission rejection. Codes 1013 ("already imported") and 1014 ("priority is
|
|
2037
|
+
* too low") both mean a copy of this account+nonce is already in the pool — almost always our
|
|
2038
|
+
* own earlier attempt whose watch handle didn't confirm cleanly. That extrinsic is in flight;
|
|
2039
|
+
* resubmitting can only bounce again or land a duplicate, so these are surfaced as `pending`
|
|
2040
|
+
* rather than failure.
|
|
2041
|
+
*/
|
|
2042
|
+
private classifySubmissionError;
|
|
2043
|
+
/**
|
|
2044
|
+
* Sends an extrinsic with a timeout.
|
|
2045
|
+
*
|
|
2046
|
+
* A timeout is only a failure when the extrinsic never made it into the transaction pool.
|
|
2047
|
+
* Once a pool-entry status (Future/Ready/Broadcast/Retracted) has been seen, the extrinsic is
|
|
2048
|
+
* in flight and may well execute after the watch is abandoned — the result is then `pending`,
|
|
2049
|
+
* telling the caller to confirm the outcome later instead of re-signing the same call.
|
|
2000
2050
|
*/
|
|
2001
2051
|
private sendWithTimeout;
|
|
2002
2052
|
/**
|
|
@@ -3706,6 +3756,15 @@ interface BidSubmissionResult {
|
|
|
3706
3756
|
* Error message if submission failed
|
|
3707
3757
|
*/
|
|
3708
3758
|
error?: string;
|
|
3759
|
+
/**
|
|
3760
|
+
* The extrinsic is (or may still be) in the transaction pool: it was accepted but its
|
|
3761
|
+
* inclusion was not observed before the watch timed out, or a resubmission bounced off an
|
|
3762
|
+
* earlier copy already pooled (RPC 1013/1014). Only meaningful when `success` is false —
|
|
3763
|
+
* the operation is in flight, not failed, and must not be re-signed with the same nonce.
|
|
3764
|
+
* Callers should confirm the outcome later (e.g. re-check on-chain state) instead of
|
|
3765
|
+
* treating this as a terminal failure.
|
|
3766
|
+
*/
|
|
3767
|
+
pending?: boolean;
|
|
3709
3768
|
}
|
|
3710
3769
|
/**
|
|
3711
3770
|
* Represents a storage entry from pallet-intents Bids storage
|
package/dist/browser/index.js
CHANGED
|
@@ -2738,13 +2738,26 @@ var chainConfigs = {
|
|
|
2738
2738
|
tokenDecimals: {
|
|
2739
2739
|
USDC: 6,
|
|
2740
2740
|
USDT: 6,
|
|
2741
|
-
cNGN: 6
|
|
2741
|
+
cNGN: 6,
|
|
2742
|
+
ZARP: 18,
|
|
2743
|
+
EURC: 6,
|
|
2744
|
+
XSGD: 6,
|
|
2745
|
+
TRYB: 6,
|
|
2746
|
+
USDR: 6
|
|
2742
2747
|
},
|
|
2743
2748
|
tokenStorageSlots: {
|
|
2744
2749
|
USDT: { balanceSlot: 2, allowanceSlot: 5 },
|
|
2745
2750
|
USDC: { balanceSlot: 9, allowanceSlot: 10 },
|
|
2746
2751
|
WETH: { balanceSlot: 3, allowanceSlot: 4 },
|
|
2747
|
-
DAI: { balanceSlot: 0, allowanceSlot: 0 }
|
|
2752
|
+
DAI: { balanceSlot: 0, allowanceSlot: 0 },
|
|
2753
|
+
cNGN: { balanceSlot: 201, allowanceSlot: 202 },
|
|
2754
|
+
// custom upgradeable layout
|
|
2755
|
+
ZARP: { balanceSlot: 51, allowanceSlot: 52 },
|
|
2756
|
+
EURC: { balanceSlot: 9, allowanceSlot: 10 },
|
|
2757
|
+
// Circle FiatToken layout
|
|
2758
|
+
XSGD: { balanceSlot: 7, allowanceSlot: 8 },
|
|
2759
|
+
TRYB: { balanceSlot: 9, allowanceSlot: 10 },
|
|
2760
|
+
USDR: { balanceSlot: 51, allowanceSlot: 52 }
|
|
2748
2761
|
},
|
|
2749
2762
|
addresses: {
|
|
2750
2763
|
IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
|
|
@@ -2924,13 +2937,22 @@ var chainConfigs = {
|
|
|
2924
2937
|
USDC: 6,
|
|
2925
2938
|
USDT: 6,
|
|
2926
2939
|
cNGN: 6,
|
|
2927
|
-
EXT: 18
|
|
2940
|
+
EXT: 18,
|
|
2941
|
+
ZARP: 18,
|
|
2942
|
+
EURC: 6,
|
|
2943
|
+
USDR: 6
|
|
2928
2944
|
},
|
|
2929
2945
|
tokenStorageSlots: {
|
|
2930
2946
|
USDT: { balanceSlot: 0, allowanceSlot: 1 },
|
|
2931
2947
|
USDC: { balanceSlot: 9, allowanceSlot: 10 },
|
|
2932
2948
|
WETH: { balanceSlot: 3, allowanceSlot: 4 },
|
|
2933
|
-
DAI: { balanceSlot: 0, allowanceSlot: 0 }
|
|
2949
|
+
DAI: { balanceSlot: 0, allowanceSlot: 0 },
|
|
2950
|
+
cNGN: { balanceSlot: 201, allowanceSlot: 202 },
|
|
2951
|
+
// custom upgradeable layout
|
|
2952
|
+
ZARP: { balanceSlot: 51, allowanceSlot: 52 },
|
|
2953
|
+
EURC: { balanceSlot: 9, allowanceSlot: 10 },
|
|
2954
|
+
// Circle FiatToken layout
|
|
2955
|
+
USDR: { balanceSlot: 51, allowanceSlot: 52 }
|
|
2934
2956
|
},
|
|
2935
2957
|
addresses: {
|
|
2936
2958
|
IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
|
|
@@ -2991,13 +3013,21 @@ var chainConfigs = {
|
|
|
2991
3013
|
USDC: 6,
|
|
2992
3014
|
USDT: 6,
|
|
2993
3015
|
EXT: 18,
|
|
2994
|
-
cNGN: 6
|
|
3016
|
+
cNGN: 6,
|
|
3017
|
+
ZARP: 18,
|
|
3018
|
+
XSGD: 6,
|
|
3019
|
+
USDR: 6
|
|
2995
3020
|
},
|
|
2996
3021
|
tokenStorageSlots: {
|
|
2997
3022
|
USDT: { balanceSlot: 0, allowanceSlot: 1 },
|
|
2998
3023
|
USDC: { balanceSlot: 9, allowanceSlot: 10 },
|
|
2999
3024
|
WETH: { balanceSlot: 3, allowanceSlot: 4 },
|
|
3000
|
-
DAI: { balanceSlot: 0, allowanceSlot: 0 }
|
|
3025
|
+
DAI: { balanceSlot: 0, allowanceSlot: 0 },
|
|
3026
|
+
cNGN: { balanceSlot: 201, allowanceSlot: 202 },
|
|
3027
|
+
// custom upgradeable layout
|
|
3028
|
+
ZARP: { balanceSlot: 51, allowanceSlot: 52 },
|
|
3029
|
+
XSGD: { balanceSlot: 7, allowanceSlot: 8 },
|
|
3030
|
+
USDR: { balanceSlot: 51, allowanceSlot: 52 }
|
|
3001
3031
|
},
|
|
3002
3032
|
addresses: {
|
|
3003
3033
|
IntentGateway: "0xAe041F7B0CB581876832830baeB6a2Aa2a3C9716",
|
|
@@ -3298,8 +3328,9 @@ var chainConfigs = {
|
|
|
3298
3328
|
assets: {
|
|
3299
3329
|
WETH: "0x0000000000000000000000000000000000000000",
|
|
3300
3330
|
DAI: "0x0000000000000000000000000000000000000000",
|
|
3331
|
+
// Asset Hub assets at their asset-id precompile addresses: 0x539 = 1337, 0x7c0 = 1984.
|
|
3301
3332
|
USDC: "0x0000053900000000000000000000000001200000",
|
|
3302
|
-
USDT: "
|
|
3333
|
+
USDT: "0x000007c000000000000000000000000001200000"
|
|
3303
3334
|
},
|
|
3304
3335
|
tokenDecimals: {
|
|
3305
3336
|
USDC: 6,
|
|
@@ -7956,15 +7987,25 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
|
|
|
7956
7987
|
/**
|
|
7957
7988
|
* Signs and sends an extrinsic. Submissions are serialised through {@link submissionQueue} so
|
|
7958
7989
|
* concurrent calls never collide on the substrate account nonce — each extrinsic reaches a block
|
|
7959
|
-
* before the next is signed
|
|
7990
|
+
* (or is confirmed still pooled and returned as `pending`) before the next is signed; auto-nonce
|
|
7991
|
+
* via `system.accountNextIndex` counts pooled extrinsics, so a pending one is never re-used.
|
|
7960
7992
|
*/
|
|
7961
7993
|
async signAndSendExtrinsic(extrinsic, maxRetries = 3, timeoutMs = 3e4) {
|
|
7962
|
-
const result = await this.submissionQueue.add(
|
|
7994
|
+
const result = await this.submissionQueue.add(
|
|
7995
|
+
() => this.sendExtrinsicWithRetries(extrinsic, maxRetries, timeoutMs)
|
|
7996
|
+
);
|
|
7963
7997
|
return result ?? { success: false, error: "Submission queue returned no result" };
|
|
7964
7998
|
}
|
|
7965
7999
|
/**
|
|
7966
8000
|
* Signs and sends an extrinsic, handling status updates and errors.
|
|
7967
8001
|
* Implements retry logic with progressive tip increases for stuck transactions.
|
|
8002
|
+
*
|
|
8003
|
+
* A retry only happens when the previous attempt verifiably went nowhere. Once an attempt's
|
|
8004
|
+
* extrinsic is known to be pooled (`pending`), re-signing the same call would race our own
|
|
8005
|
+
* submission: the copy either bounces off the pool (1014, same nonce below the replacement
|
|
8006
|
+
* priority bump) or — if the original lands first, freeing the nonce — executes as a duplicate
|
|
8007
|
+
* and fails on-chain (e.g. `BidNotFound` for a retraction). Neither can succeed, so the pending
|
|
8008
|
+
* result is returned for the caller to confirm later.
|
|
7968
8009
|
*/
|
|
7969
8010
|
async sendExtrinsicWithRetries(extrinsic, maxRetries, timeoutMs) {
|
|
7970
8011
|
const keyPair = this.getKeyPair();
|
|
@@ -7975,7 +8016,7 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
|
|
|
7975
8016
|
attempt++;
|
|
7976
8017
|
try {
|
|
7977
8018
|
const result = await this.sendWithTimeout(extrinsic, keyPair, currentTip, timeoutMs);
|
|
7978
|
-
if (result.success || result.error?.includes("Dispatch error")) {
|
|
8019
|
+
if (result.success || result.pending || result.error?.includes("Dispatch error")) {
|
|
7979
8020
|
return result;
|
|
7980
8021
|
}
|
|
7981
8022
|
} catch (err) {
|
|
@@ -7991,12 +8032,30 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
|
|
|
7991
8032
|
};
|
|
7992
8033
|
}
|
|
7993
8034
|
/**
|
|
7994
|
-
*
|
|
8035
|
+
* Classifies a submission rejection. Codes 1013 ("already imported") and 1014 ("priority is
|
|
8036
|
+
* too low") both mean a copy of this account+nonce is already in the pool — almost always our
|
|
8037
|
+
* own earlier attempt whose watch handle didn't confirm cleanly. That extrinsic is in flight;
|
|
8038
|
+
* resubmitting can only bounce again or land a duplicate, so these are surfaced as `pending`
|
|
8039
|
+
* rather than failure.
|
|
8040
|
+
*/
|
|
8041
|
+
classifySubmissionError(err) {
|
|
8042
|
+
const code = err.code;
|
|
8043
|
+
const inFlight = code === 1013 || code === 1014 || /already imported|already in the pool|priority is too low/i.test(err.message);
|
|
8044
|
+
return { success: false, pending: inFlight || void 0, error: err.message };
|
|
8045
|
+
}
|
|
8046
|
+
/**
|
|
8047
|
+
* Sends an extrinsic with a timeout.
|
|
8048
|
+
*
|
|
8049
|
+
* A timeout is only a failure when the extrinsic never made it into the transaction pool.
|
|
8050
|
+
* Once a pool-entry status (Future/Ready/Broadcast/Retracted) has been seen, the extrinsic is
|
|
8051
|
+
* in flight and may well execute after the watch is abandoned — the result is then `pending`,
|
|
8052
|
+
* telling the caller to confirm the outcome later instead of re-signing the same call.
|
|
7995
8053
|
*/
|
|
7996
8054
|
async sendWithTimeout(extrinsic, keyPair, tip, timeoutMs) {
|
|
7997
8055
|
return new Promise((resolve) => {
|
|
7998
8056
|
let resolved = false;
|
|
7999
8057
|
let unsubscribe = null;
|
|
8058
|
+
let enteredPool = false;
|
|
8000
8059
|
const timeoutId = setTimeout(() => {
|
|
8001
8060
|
if (!resolved) {
|
|
8002
8061
|
resolved = true;
|
|
@@ -8005,12 +8064,17 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
|
|
|
8005
8064
|
}
|
|
8006
8065
|
resolve({
|
|
8007
8066
|
success: false,
|
|
8008
|
-
|
|
8067
|
+
pending: enteredPool || void 0,
|
|
8068
|
+
extrinsicHash: enteredPool ? extrinsic.hash.toHex() : void 0,
|
|
8069
|
+
error: `Transaction timed out after ${timeoutMs}ms${enteredPool ? " while in the transaction pool" : ""}`
|
|
8009
8070
|
});
|
|
8010
8071
|
}
|
|
8011
8072
|
}, timeoutMs);
|
|
8012
8073
|
extrinsic.signAndSend(keyPair, { tip }, (result) => {
|
|
8013
8074
|
if (resolved) return;
|
|
8075
|
+
if (result.status.isFuture || result.status.isReady || result.status.isBroadcast || result.status.isRetracted) {
|
|
8076
|
+
enteredPool = true;
|
|
8077
|
+
}
|
|
8014
8078
|
if (result.dispatchError && (result.status.isInBlock || result.status.isFinalized)) {
|
|
8015
8079
|
resolved = true;
|
|
8016
8080
|
clearTimeout(timeoutId);
|
|
@@ -8068,7 +8132,7 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
|
|
|
8068
8132
|
if (!resolved) {
|
|
8069
8133
|
resolved = true;
|
|
8070
8134
|
clearTimeout(timeoutId);
|
|
8071
|
-
resolve(
|
|
8135
|
+
resolve(this.classifySubmissionError(err));
|
|
8072
8136
|
}
|
|
8073
8137
|
});
|
|
8074
8138
|
});
|
|
@@ -8242,9 +8306,7 @@ var IntentsCoprocessor = class _IntentsCoprocessor {
|
|
|
8242
8306
|
if (!result || result.isNone) return null;
|
|
8243
8307
|
const rawHex = result.unwrap().toHex();
|
|
8244
8308
|
if (rawHex === "0x" || rawHex === "0x00") return null;
|
|
8245
|
-
const placeOrderAbi = IntentGatewayV2_default.ABI.find(
|
|
8246
|
-
(item) => item.type === "function" && item.name === "placeOrder"
|
|
8247
|
-
);
|
|
8309
|
+
const placeOrderAbi = IntentGatewayV2_default.ABI.find((item) => item.type === "function" && item.name === "placeOrder");
|
|
8248
8310
|
const orderType = placeOrderAbi?.inputs?.[0];
|
|
8249
8311
|
if (!orderType) return null;
|
|
8250
8312
|
const [decoded] = decodeAbiParameters([orderType], rawHex);
|
|
@@ -17043,14 +17105,14 @@ var BidManager = class {
|
|
|
17043
17105
|
}
|
|
17044
17106
|
/**
|
|
17045
17107
|
* Autopilot bid selection: sorts the given bids by output value, simulates
|
|
17046
|
-
* each in order
|
|
17047
|
-
*
|
|
17108
|
+
* each in order and attempts execution. Any bid that fails simulation or
|
|
17109
|
+
* execution is skipped once so the next ranked bid can be attempted in the
|
|
17110
|
+
* same round. For consumers that do not need custom selection logic.
|
|
17048
17111
|
*
|
|
17049
17112
|
* @param order - The placed order to fill.
|
|
17050
17113
|
* @param bids - Candidate bids (from {@link buildBids}).
|
|
17051
17114
|
* @returns A {@link SelectBidResult} for the executed bid.
|
|
17052
|
-
* @throws If no valid bids exist
|
|
17053
|
-
* the UserOperation.
|
|
17115
|
+
* @throws If no valid bids exist or every bid fails simulation/execution.
|
|
17054
17116
|
*/
|
|
17055
17117
|
async selectAndExecuteBest(order, bids) {
|
|
17056
17118
|
const commitment = order.id;
|
|
@@ -17067,22 +17129,34 @@ var BidManager = class {
|
|
|
17067
17129
|
throw new Error("No valid bids found");
|
|
17068
17130
|
}
|
|
17069
17131
|
console.log(`[BidManager] Simulating ${sortedBids.length} sorted bid(s) to find a valid one`);
|
|
17132
|
+
let simulationFailures = 0;
|
|
17133
|
+
let executionFailures = 0;
|
|
17070
17134
|
for (let idx = 0; idx < sortedBids.length; idx++) {
|
|
17071
17135
|
const bid = sortedBids[idx];
|
|
17072
17136
|
console.log(`[BidManager] Simulating bid ${idx + 1}/${sortedBids.length} from solver=${bid.solverAddress}`);
|
|
17073
17137
|
try {
|
|
17074
17138
|
await bid.simulate();
|
|
17075
17139
|
} catch (err) {
|
|
17140
|
+
simulationFailures += 1;
|
|
17076
17141
|
console.warn(
|
|
17077
17142
|
`[BidManager] Bid ${idx + 1} from solver=${bid.solverAddress}: simulation FAILED: ${err instanceof Error ? err.message : String(err)}`
|
|
17078
17143
|
);
|
|
17079
17144
|
continue;
|
|
17080
17145
|
}
|
|
17081
17146
|
console.log(`[BidManager] Bid ${idx + 1} from solver=${bid.solverAddress}: simulation PASSED`);
|
|
17082
|
-
|
|
17147
|
+
try {
|
|
17148
|
+
return await bid.execute();
|
|
17149
|
+
} catch (err) {
|
|
17150
|
+
executionFailures += 1;
|
|
17151
|
+
console.warn(
|
|
17152
|
+
`[BidManager] Bid ${idx + 1} from solver=${bid.solverAddress}: execution FAILED: ${err instanceof Error ? err.message : String(err)}; trying next bid`
|
|
17153
|
+
);
|
|
17154
|
+
}
|
|
17083
17155
|
}
|
|
17084
|
-
console.error(
|
|
17085
|
-
|
|
17156
|
+
console.error(
|
|
17157
|
+
`[BidManager] No executable bids for commitment=${commitment}: ${simulationFailures} simulation failure(s), ${executionFailures} execution failure(s)`
|
|
17158
|
+
);
|
|
17159
|
+
throw new Error("No bids passed simulation and execution");
|
|
17086
17160
|
}
|
|
17087
17161
|
/**
|
|
17088
17162
|
* Sorts a list of bids for the given order by output value.
|
|
@@ -17422,6 +17496,10 @@ var BidManager = class {
|
|
|
17422
17496
|
}
|
|
17423
17497
|
};
|
|
17424
17498
|
var RELAYER_MESSAGE_GAS = 1000000n;
|
|
17499
|
+
var NO_BUNDLER_FILL_GAS_BASE = 700000n;
|
|
17500
|
+
var NO_BUNDLER_FILL_GAS_PER_OUTPUT = 150000n;
|
|
17501
|
+
var NO_BUNDLER_PAYMASTER_VERIFICATION_GAS = 250000n;
|
|
17502
|
+
var NO_BUNDLER_PAYMASTER_POST_OP_GAS = 100000n;
|
|
17425
17503
|
var GasEstimator = class {
|
|
17426
17504
|
/**
|
|
17427
17505
|
* @param ctx - Shared IntentsV2 context providing the source and destination
|
|
@@ -17455,8 +17533,10 @@ var GasEstimator = class {
|
|
|
17455
17533
|
* headroom. If the bundler is Pimlico, gas prices are refined with
|
|
17456
17534
|
* `pimlico_getUserOperationGasPrice`.
|
|
17457
17535
|
*
|
|
17458
|
-
* **Fallback path (no bundler):**
|
|
17459
|
-
*
|
|
17536
|
+
* **Fallback path (no bundler):** uses a fixed budget
|
|
17537
|
+
* ({@link NO_BUNDLER_FILL_GAS_BASE} plus {@link NO_BUNDLER_FILL_GAS_PER_OUTPUT}
|
|
17538
|
+
* per output leg) — public RPCs don't reliably support estimation with
|
|
17539
|
+
* state overrides.
|
|
17460
17540
|
*
|
|
17461
17541
|
* @param params - Parameters including the order to estimate and optional
|
|
17462
17542
|
* percentage bumps for `maxPriorityFeePerGas` and `maxFeePerGas`.
|
|
@@ -17491,14 +17571,14 @@ var GasEstimator = class {
|
|
|
17491
17571
|
}
|
|
17492
17572
|
const isSameChain = souceStateMachineId === destStateMachineId;
|
|
17493
17573
|
const [stateOverridesResult, crossChainFees] = await Promise.all([
|
|
17494
|
-
this.buildStateOverride({
|
|
17574
|
+
this.ctx.bundlerUrl ? this.buildStateOverride({
|
|
17495
17575
|
accountAddress: solverAccountAddress,
|
|
17496
17576
|
chain: destStateMachineId,
|
|
17497
17577
|
outputAssets: assetsForOverrides,
|
|
17498
17578
|
spenderAddress: intentGatewayV2Address,
|
|
17499
17579
|
intentGatewayV2Address,
|
|
17500
17580
|
entryPointAddress
|
|
17501
|
-
}),
|
|
17581
|
+
}) : Promise.resolve({ viem: [], bundler: {} }),
|
|
17502
17582
|
isSameChain ? Promise.resolve({ postRequestFee: 0n, relayerFeeInSourceFeeToken: 0n }) : this.estimateCrossChainFees(
|
|
17503
17583
|
sourceFeeToken,
|
|
17504
17584
|
destFeeToken,
|
|
@@ -17506,7 +17586,7 @@ var GasEstimator = class {
|
|
|
17506
17586
|
orderFeeGasPriceBumpPercent
|
|
17507
17587
|
)
|
|
17508
17588
|
]);
|
|
17509
|
-
const {
|
|
17589
|
+
const { bundler: bundlerStateOverrides } = stateOverridesResult;
|
|
17510
17590
|
const fillOptions = {
|
|
17511
17591
|
relayerFee: crossChainFees.postRequestFee,
|
|
17512
17592
|
// Always dispatch with the fee token (see the method docs).
|
|
@@ -17647,20 +17727,9 @@ var GasEstimator = class {
|
|
|
17647
17727
|
console.warn("Bundler gas estimation failed, using fallback values:", e);
|
|
17648
17728
|
}
|
|
17649
17729
|
} else {
|
|
17650
|
-
|
|
17651
|
-
|
|
17652
|
-
|
|
17653
|
-
address: intentGatewayV2Address,
|
|
17654
|
-
functionName: "fillOrder",
|
|
17655
|
-
args: [transformOrderForContract(order), fillOptions],
|
|
17656
|
-
account: solverAccountAddress,
|
|
17657
|
-
value: totalNativeValue,
|
|
17658
|
-
stateOverride: stateOverrides
|
|
17659
|
-
});
|
|
17660
|
-
callGasLimit = estimatedGas * 105n / 100n;
|
|
17661
|
-
} catch (e) {
|
|
17662
|
-
console.warn("fillOrder gas estimation failed, using fallback:", e);
|
|
17663
|
-
}
|
|
17730
|
+
callGasLimit = NO_BUNDLER_FILL_GAS_BASE + NO_BUNDLER_FILL_GAS_PER_OUTPUT * BigInt(order.output.assets.length);
|
|
17731
|
+
paymasterVerificationGasLimit = NO_BUNDLER_PAYMASTER_VERIFICATION_GAS;
|
|
17732
|
+
paymasterPostOpGasLimit = NO_BUNDLER_PAYMASTER_POST_OP_GAS;
|
|
17664
17733
|
}
|
|
17665
17734
|
const totalGas = callGasLimit + verificationGasLimit + preVerificationGas + paymasterVerificationGasLimit + paymasterPostOpGasLimit;
|
|
17666
17735
|
const rawTotalGasCostWei = totalGas * maxFeePerGas;
|