@gearbox-protocol/deploy-tools 5.30.0 → 5.30.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/index.mjs +313 -275
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -4276,7 +4276,7 @@ var init_size = __esm({
|
|
|
4276
4276
|
var version2;
|
|
4277
4277
|
var init_version2 = __esm({
|
|
4278
4278
|
"../../node_modules/viem/_esm/errors/version.js"() {
|
|
4279
|
-
version2 = "2.29.
|
|
4279
|
+
version2 = "2.29.4";
|
|
4280
4280
|
}
|
|
4281
4281
|
});
|
|
4282
4282
|
|
|
@@ -5568,9 +5568,9 @@ var init_getAddress = __esm({
|
|
|
5568
5568
|
// ../../node_modules/viem/_esm/utils/address/isAddress.js
|
|
5569
5569
|
function isAddress(address, options) {
|
|
5570
5570
|
const { strict = true } = options ?? {};
|
|
5571
|
-
const
|
|
5572
|
-
if (isAddressCache.has(
|
|
5573
|
-
return isAddressCache.get(
|
|
5571
|
+
const cacheKey2 = `${address}.${strict}`;
|
|
5572
|
+
if (isAddressCache.has(cacheKey2))
|
|
5573
|
+
return isAddressCache.get(cacheKey2);
|
|
5574
5574
|
const result = (() => {
|
|
5575
5575
|
if (!addressRegex.test(address))
|
|
5576
5576
|
return false;
|
|
@@ -5580,7 +5580,7 @@ function isAddress(address, options) {
|
|
|
5580
5580
|
return checksumAddress(address) === address;
|
|
5581
5581
|
return true;
|
|
5582
5582
|
})();
|
|
5583
|
-
isAddressCache.set(
|
|
5583
|
+
isAddressCache.set(cacheKey2, result);
|
|
5584
5584
|
return result;
|
|
5585
5585
|
}
|
|
5586
5586
|
var addressRegex, isAddressCache;
|
|
@@ -24329,7 +24329,7 @@ var require_common = __commonJS({
|
|
|
24329
24329
|
createDebug.namespaces = namespaces;
|
|
24330
24330
|
createDebug.names = [];
|
|
24331
24331
|
createDebug.skips = [];
|
|
24332
|
-
const split3 = (typeof namespaces === "string" ? namespaces : "").trim().replace(
|
|
24332
|
+
const split3 = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
|
|
24333
24333
|
for (const ns of split3) {
|
|
24334
24334
|
if (ns[0] === "-") {
|
|
24335
24335
|
createDebug.skips.push(ns.slice(1));
|
|
@@ -24547,7 +24547,7 @@ var require_browser = __commonJS({
|
|
|
24547
24547
|
function load() {
|
|
24548
24548
|
let r;
|
|
24549
24549
|
try {
|
|
24550
|
-
r = exports2.storage.getItem("debug");
|
|
24550
|
+
r = exports2.storage.getItem("debug") || exports2.storage.getItem("DEBUG");
|
|
24551
24551
|
} catch (error) {
|
|
24552
24552
|
}
|
|
24553
24553
|
if (!r && typeof process !== "undefined" && "env" in process) {
|
|
@@ -75247,24 +75247,24 @@ var require_memoize = __commonJS({
|
|
|
75247
75247
|
const cache = {};
|
|
75248
75248
|
let iterationCounter = 0;
|
|
75249
75249
|
return async (...args) => {
|
|
75250
|
-
const
|
|
75251
|
-
(0, errors_1.assertWithLog)(
|
|
75250
|
+
const cacheKey2 = await cacheKeyBuilder(...args);
|
|
75251
|
+
(0, errors_1.assertWithLog)(cacheKey2.length < EXPECTED_MAX_CACHE_KEY_LENGTH_PER_FN, `Assumed cache key will not be longer than ${EXPECTED_MAX_CACHE_KEY_LENGTH_PER_FN}. Suspicious key ${cacheKey2}`);
|
|
75252
75252
|
iterationCounter = (iterationCounter + 1) % cleanEveryNIteration;
|
|
75253
75253
|
if (iterationCounter == 0) {
|
|
75254
75254
|
cleanStaleCacheEntries(cache, ttl);
|
|
75255
75255
|
}
|
|
75256
|
-
const isMiss = !cache[
|
|
75256
|
+
const isMiss = !cache[cacheKey2] || Date.now() - cache[cacheKey2].lastSet > ttl;
|
|
75257
75257
|
if (isMiss) {
|
|
75258
|
-
cache[
|
|
75258
|
+
cache[cacheKey2] = {
|
|
75259
75259
|
lastSet: Date.now(),
|
|
75260
75260
|
promise: functionToMemoize(...args).catch((err) => {
|
|
75261
|
-
delete cache[
|
|
75261
|
+
delete cache[cacheKey2];
|
|
75262
75262
|
throw err;
|
|
75263
75263
|
})
|
|
75264
75264
|
};
|
|
75265
75265
|
}
|
|
75266
75266
|
cacheReporter(isMiss);
|
|
75267
|
-
return await cache[
|
|
75267
|
+
return await cache[cacheKey2].promise;
|
|
75268
75268
|
};
|
|
75269
75269
|
}
|
|
75270
75270
|
var cleanStaleCacheEntries = (cache, ttl) => {
|
|
@@ -163871,7 +163871,7 @@ var require_version28 = __commonJS({
|
|
|
163871
163871
|
"use strict";
|
|
163872
163872
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
163873
163873
|
exports2.version = void 0;
|
|
163874
|
-
exports2.version = "2.29.
|
|
163874
|
+
exports2.version = "2.29.4";
|
|
163875
163875
|
}
|
|
163876
163876
|
});
|
|
163877
163877
|
|
|
@@ -165512,9 +165512,9 @@ var require_isAddress = __commonJS({
|
|
|
165512
165512
|
exports2.isAddressCache = new lru_js_1.LruMap(8192);
|
|
165513
165513
|
function isAddress2(address, options) {
|
|
165514
165514
|
const { strict = true } = options ?? {};
|
|
165515
|
-
const
|
|
165516
|
-
if (exports2.isAddressCache.has(
|
|
165517
|
-
return exports2.isAddressCache.get(
|
|
165515
|
+
const cacheKey2 = `${address}.${strict}`;
|
|
165516
|
+
if (exports2.isAddressCache.has(cacheKey2))
|
|
165517
|
+
return exports2.isAddressCache.get(cacheKey2);
|
|
165518
165518
|
const result = (() => {
|
|
165519
165519
|
if (!addressRegex3.test(address))
|
|
165520
165520
|
return false;
|
|
@@ -165524,7 +165524,7 @@ var require_isAddress = __commonJS({
|
|
|
165524
165524
|
return (0, getAddress_js_1.checksumAddress)(address) === address;
|
|
165525
165525
|
return true;
|
|
165526
165526
|
})();
|
|
165527
|
-
exports2.isAddressCache.set(
|
|
165527
|
+
exports2.isAddressCache.set(cacheKey2, result);
|
|
165528
165528
|
return result;
|
|
165529
165529
|
}
|
|
165530
165530
|
}
|
|
@@ -177259,14 +177259,14 @@ var require_withCache = __commonJS({
|
|
|
177259
177259
|
exports2.withCache = withCache2;
|
|
177260
177260
|
exports2.promiseCache = /* @__PURE__ */ new Map();
|
|
177261
177261
|
exports2.responseCache = /* @__PURE__ */ new Map();
|
|
177262
|
-
function getCache2(
|
|
177263
|
-
const buildCache = (
|
|
177264
|
-
clear: () => cache.delete(
|
|
177265
|
-
get: () => cache.get(
|
|
177266
|
-
set: (data) => cache.set(
|
|
177262
|
+
function getCache2(cacheKey2) {
|
|
177263
|
+
const buildCache = (cacheKey3, cache) => ({
|
|
177264
|
+
clear: () => cache.delete(cacheKey3),
|
|
177265
|
+
get: () => cache.get(cacheKey3),
|
|
177266
|
+
set: (data) => cache.set(cacheKey3, data)
|
|
177267
177267
|
});
|
|
177268
|
-
const promise = buildCache(
|
|
177269
|
-
const response = buildCache(
|
|
177268
|
+
const promise = buildCache(cacheKey2, exports2.promiseCache);
|
|
177269
|
+
const response = buildCache(cacheKey2, exports2.responseCache);
|
|
177270
177270
|
return {
|
|
177271
177271
|
clear: () => {
|
|
177272
177272
|
promise.clear();
|
|
@@ -177276,8 +177276,8 @@ var require_withCache = __commonJS({
|
|
|
177276
177276
|
response
|
|
177277
177277
|
};
|
|
177278
177278
|
}
|
|
177279
|
-
async function withCache2(fn, { cacheKey:
|
|
177280
|
-
const cache = getCache2(
|
|
177279
|
+
async function withCache2(fn, { cacheKey: cacheKey2, cacheTime = Number.POSITIVE_INFINITY }) {
|
|
177280
|
+
const cache = getCache2(cacheKey2);
|
|
177281
177281
|
const response = cache.response.get();
|
|
177282
177282
|
if (response && cacheTime > 0) {
|
|
177283
177283
|
const age = (/* @__PURE__ */ new Date()).getTime() - response.created.getTime();
|
|
@@ -177308,14 +177308,14 @@ var require_getBlockNumber = __commonJS({
|
|
|
177308
177308
|
exports2.getBlockNumberCache = getBlockNumberCache;
|
|
177309
177309
|
exports2.getBlockNumber = getBlockNumber2;
|
|
177310
177310
|
var withCache_js_1 = require_withCache();
|
|
177311
|
-
var
|
|
177311
|
+
var cacheKey2 = (id) => `blockNumber.${id}`;
|
|
177312
177312
|
function getBlockNumberCache(id) {
|
|
177313
|
-
return (0, withCache_js_1.getCache)(
|
|
177313
|
+
return (0, withCache_js_1.getCache)(cacheKey2(id));
|
|
177314
177314
|
}
|
|
177315
177315
|
async function getBlockNumber2(client, { cacheTime = client.cacheTime } = {}) {
|
|
177316
177316
|
const blockNumberHex = await (0, withCache_js_1.withCache)(() => client.request({
|
|
177317
177317
|
method: "eth_blockNumber"
|
|
177318
|
-
}), { cacheKey:
|
|
177318
|
+
}), { cacheKey: cacheKey2(client.uid), cacheTime });
|
|
177319
177319
|
return BigInt(blockNumberHex);
|
|
177320
177320
|
}
|
|
177321
177321
|
}
|
|
@@ -185232,8 +185232,8 @@ var require_parseTransaction = __commonJS({
|
|
|
185232
185232
|
transaction.gas = (0, fromHex_js_1.hexToBigInt)(gas);
|
|
185233
185233
|
if ((0, isHex_js_1.isHex)(data) && data !== "0x")
|
|
185234
185234
|
transaction.data = data;
|
|
185235
|
-
if ((0, isHex_js_1.isHex)(nonce)
|
|
185236
|
-
transaction.nonce = (0, fromHex_js_1.hexToNumber)(nonce);
|
|
185235
|
+
if ((0, isHex_js_1.isHex)(nonce))
|
|
185236
|
+
transaction.nonce = nonce === "0x" ? 0 : (0, fromHex_js_1.hexToNumber)(nonce);
|
|
185237
185237
|
if ((0, isHex_js_1.isHex)(value) && value !== "0x")
|
|
185238
185238
|
transaction.value = (0, fromHex_js_1.hexToBigInt)(value);
|
|
185239
185239
|
if ((0, isHex_js_1.isHex)(maxFeePerGas) && maxFeePerGas !== "0x")
|
|
@@ -185287,8 +185287,8 @@ var require_parseTransaction = __commonJS({
|
|
|
185287
185287
|
transaction.gas = (0, fromHex_js_1.hexToBigInt)(gas);
|
|
185288
185288
|
if ((0, isHex_js_1.isHex)(data) && data !== "0x")
|
|
185289
185289
|
transaction.data = data;
|
|
185290
|
-
if ((0, isHex_js_1.isHex)(nonce)
|
|
185291
|
-
transaction.nonce = (0, fromHex_js_1.hexToNumber)(nonce);
|
|
185290
|
+
if ((0, isHex_js_1.isHex)(nonce))
|
|
185291
|
+
transaction.nonce = nonce === "0x" ? 0 : (0, fromHex_js_1.hexToNumber)(nonce);
|
|
185292
185292
|
if ((0, isHex_js_1.isHex)(value) && value !== "0x")
|
|
185293
185293
|
transaction.value = (0, fromHex_js_1.hexToBigInt)(value);
|
|
185294
185294
|
if ((0, isHex_js_1.isHex)(maxFeePerBlobGas) && maxFeePerBlobGas !== "0x")
|
|
@@ -185343,8 +185343,8 @@ var require_parseTransaction = __commonJS({
|
|
|
185343
185343
|
transaction.gas = (0, fromHex_js_1.hexToBigInt)(gas);
|
|
185344
185344
|
if ((0, isHex_js_1.isHex)(data) && data !== "0x")
|
|
185345
185345
|
transaction.data = data;
|
|
185346
|
-
if ((0, isHex_js_1.isHex)(nonce)
|
|
185347
|
-
transaction.nonce = (0, fromHex_js_1.hexToNumber)(nonce);
|
|
185346
|
+
if ((0, isHex_js_1.isHex)(nonce))
|
|
185347
|
+
transaction.nonce = nonce === "0x" ? 0 : (0, fromHex_js_1.hexToNumber)(nonce);
|
|
185348
185348
|
if ((0, isHex_js_1.isHex)(value) && value !== "0x")
|
|
185349
185349
|
transaction.value = (0, fromHex_js_1.hexToBigInt)(value);
|
|
185350
185350
|
if ((0, isHex_js_1.isHex)(maxFeePerGas) && maxFeePerGas !== "0x")
|
|
@@ -185390,8 +185390,8 @@ var require_parseTransaction = __commonJS({
|
|
|
185390
185390
|
transaction.gas = (0, fromHex_js_1.hexToBigInt)(gas);
|
|
185391
185391
|
if ((0, isHex_js_1.isHex)(data) && data !== "0x")
|
|
185392
185392
|
transaction.data = data;
|
|
185393
|
-
if ((0, isHex_js_1.isHex)(nonce)
|
|
185394
|
-
transaction.nonce = (0, fromHex_js_1.hexToNumber)(nonce);
|
|
185393
|
+
if ((0, isHex_js_1.isHex)(nonce))
|
|
185394
|
+
transaction.nonce = nonce === "0x" ? 0 : (0, fromHex_js_1.hexToNumber)(nonce);
|
|
185395
185395
|
if ((0, isHex_js_1.isHex)(value) && value !== "0x")
|
|
185396
185396
|
transaction.value = (0, fromHex_js_1.hexToBigInt)(value);
|
|
185397
185397
|
if ((0, isHex_js_1.isHex)(gasPrice) && gasPrice !== "0x")
|
|
@@ -185432,8 +185432,8 @@ var require_parseTransaction = __commonJS({
|
|
|
185432
185432
|
transaction.gas = (0, fromHex_js_1.hexToBigInt)(gas);
|
|
185433
185433
|
if ((0, isHex_js_1.isHex)(data) && data !== "0x")
|
|
185434
185434
|
transaction.data = data;
|
|
185435
|
-
if ((0, isHex_js_1.isHex)(nonce)
|
|
185436
|
-
transaction.nonce = (0, fromHex_js_1.hexToNumber)(nonce);
|
|
185435
|
+
if ((0, isHex_js_1.isHex)(nonce))
|
|
185436
|
+
transaction.nonce = nonce === "0x" ? 0 : (0, fromHex_js_1.hexToNumber)(nonce);
|
|
185437
185437
|
if ((0, isHex_js_1.isHex)(value) && value !== "0x")
|
|
185438
185438
|
transaction.value = (0, fromHex_js_1.hexToBigInt)(value);
|
|
185439
185439
|
if ((0, isHex_js_1.isHex)(gasPrice) && gasPrice !== "0x")
|
|
@@ -186406,7 +186406,7 @@ var require_multicall2 = __commonJS({
|
|
|
186406
186406
|
var getAction_js_1 = require_getAction();
|
|
186407
186407
|
var readContract_js_1 = require_readContract();
|
|
186408
186408
|
async function multicall2(client, parameters) {
|
|
186409
|
-
const { allowFailure = true, batchSize: batchSize_, blockNumber, blockTag, multicallAddress: multicallAddress_, stateOverride } = parameters;
|
|
186409
|
+
const { account, allowFailure = true, batchSize: batchSize_, blockNumber, blockTag, multicallAddress: multicallAddress_, stateOverride } = parameters;
|
|
186410
186410
|
const contracts2 = parameters.contracts;
|
|
186411
186411
|
const batchSize = batchSize_ ?? (typeof client.batch?.multicall === "object" && client.batch.multicall.batchSize || 1024);
|
|
186412
186412
|
let multicallAddress = multicallAddress_;
|
|
@@ -186446,7 +186446,8 @@ var require_multicall2 = __commonJS({
|
|
|
186446
186446
|
address,
|
|
186447
186447
|
args,
|
|
186448
186448
|
docsPath: "/docs/contract/multicall",
|
|
186449
|
-
functionName
|
|
186449
|
+
functionName,
|
|
186450
|
+
sender: account
|
|
186450
186451
|
});
|
|
186451
186452
|
if (!allowFailure)
|
|
186452
186453
|
throw error;
|
|
@@ -186462,6 +186463,7 @@ var require_multicall2 = __commonJS({
|
|
|
186462
186463
|
}
|
|
186463
186464
|
const aggregate3Results = await Promise.allSettled(chunkedCalls.map((calls) => (0, getAction_js_1.getAction)(client, readContract_js_1.readContract, "readContract")({
|
|
186464
186465
|
abi: abis_js_1.multicall3Abi,
|
|
186466
|
+
account,
|
|
186465
186467
|
address: multicallAddress,
|
|
186466
186468
|
args: [calls],
|
|
186467
186469
|
blockNumber,
|
|
@@ -191957,7 +191959,7 @@ var require_sendCalls = __commonJS({
|
|
|
191957
191959
|
var toHex_js_1 = require_toHex();
|
|
191958
191960
|
var getTransactionError_js_1 = require_getTransactionError();
|
|
191959
191961
|
async function sendCalls2(client, parameters) {
|
|
191960
|
-
const { account: account_ = client.account, chain = client.chain, forceAtomic = false, id, version: version4 = "2.0.0" } = parameters;
|
|
191962
|
+
const { account: account_ = client.account, capabilities, chain = client.chain, forceAtomic = false, id, version: version4 = "2.0.0" } = parameters;
|
|
191961
191963
|
if (typeof account_ === "undefined")
|
|
191962
191964
|
throw new account_js_1.AccountNotFoundError({
|
|
191963
191965
|
docsPath: "/docs/actions/wallet/sendCalls"
|
|
@@ -191983,7 +191985,7 @@ var require_sendCalls = __commonJS({
|
|
|
191983
191985
|
{
|
|
191984
191986
|
atomicRequired: forceAtomic,
|
|
191985
191987
|
calls,
|
|
191986
|
-
capabilities
|
|
191988
|
+
capabilities,
|
|
191987
191989
|
chainId: (0, toHex_js_1.numberToHex)(chain.id),
|
|
191988
191990
|
from: account?.address,
|
|
191989
191991
|
id,
|
|
@@ -192002,18 +192004,6 @@ var require_sendCalls = __commonJS({
|
|
|
192002
192004
|
});
|
|
192003
192005
|
}
|
|
192004
192006
|
}
|
|
192005
|
-
function formatRequestCapabilities2(capabilities) {
|
|
192006
|
-
const paymasterService = capabilities?.paymasterService ? Object.entries(capabilities.paymasterService).reduce((paymasterService2, [chainId, value]) => ({
|
|
192007
|
-
...paymasterService2 ?? {},
|
|
192008
|
-
[(0, toHex_js_1.numberToHex)(Number(chainId))]: value
|
|
192009
|
-
}), {}) : void 0;
|
|
192010
|
-
return {
|
|
192011
|
-
...capabilities,
|
|
192012
|
-
...paymasterService ? {
|
|
192013
|
-
paymasterService
|
|
192014
|
-
} : {}
|
|
192015
|
-
};
|
|
192016
|
-
}
|
|
192017
192007
|
}
|
|
192018
192008
|
});
|
|
192019
192009
|
|
|
@@ -243395,27 +243385,12 @@ var require_modular3 = __commonJS({
|
|
|
243395
243385
|
var _4n3 = /* @__PURE__ */ BigInt(4);
|
|
243396
243386
|
var _5n2 = /* @__PURE__ */ BigInt(5);
|
|
243397
243387
|
var _8n2 = /* @__PURE__ */ BigInt(8);
|
|
243398
|
-
var _9n2 = /* @__PURE__ */ BigInt(9);
|
|
243399
|
-
var _16n2 = /* @__PURE__ */ BigInt(16);
|
|
243400
243388
|
function mod2(a, b) {
|
|
243401
243389
|
const result = a % b;
|
|
243402
243390
|
return result >= _0n8 ? result : b + result;
|
|
243403
243391
|
}
|
|
243404
243392
|
function pow3(num2, power, modulo) {
|
|
243405
|
-
|
|
243406
|
-
throw new Error("invalid exponent, negatives unsupported");
|
|
243407
|
-
if (modulo <= _0n8)
|
|
243408
|
-
throw new Error("invalid modulus");
|
|
243409
|
-
if (modulo === _1n8)
|
|
243410
|
-
return _0n8;
|
|
243411
|
-
let res = _1n8;
|
|
243412
|
-
while (power > _0n8) {
|
|
243413
|
-
if (power & _1n8)
|
|
243414
|
-
res = res * num2 % modulo;
|
|
243415
|
-
num2 = num2 * num2 % modulo;
|
|
243416
|
-
power >>= _1n8;
|
|
243417
|
-
}
|
|
243418
|
-
return res;
|
|
243393
|
+
return FpPow2(Field2(modulo), num2, power);
|
|
243419
243394
|
}
|
|
243420
243395
|
function pow22(x, power, modulo) {
|
|
243421
243396
|
let res = x;
|
|
@@ -243445,7 +243420,27 @@ var require_modular3 = __commonJS({
|
|
|
243445
243420
|
throw new Error("invert: does not exist");
|
|
243446
243421
|
return mod2(x, modulo);
|
|
243447
243422
|
}
|
|
243423
|
+
function sqrt3mod4(Fp, n) {
|
|
243424
|
+
const p1div4 = (Fp.ORDER + _1n8) / _4n3;
|
|
243425
|
+
const root2 = Fp.pow(n, p1div4);
|
|
243426
|
+
if (!Fp.eql(Fp.sqr(root2), n))
|
|
243427
|
+
throw new Error("Cannot find square root");
|
|
243428
|
+
return root2;
|
|
243429
|
+
}
|
|
243430
|
+
function sqrt5mod8(Fp, n) {
|
|
243431
|
+
const p5div8 = (Fp.ORDER - _5n2) / _8n2;
|
|
243432
|
+
const n2 = Fp.mul(n, _2n6);
|
|
243433
|
+
const v = Fp.pow(n2, p5div8);
|
|
243434
|
+
const nv = Fp.mul(n, v);
|
|
243435
|
+
const i = Fp.mul(Fp.mul(nv, _2n6), v);
|
|
243436
|
+
const root2 = Fp.mul(nv, Fp.sub(i, Fp.ONE));
|
|
243437
|
+
if (!Fp.eql(Fp.sqr(root2), n))
|
|
243438
|
+
throw new Error("Cannot find square root");
|
|
243439
|
+
return root2;
|
|
243440
|
+
}
|
|
243448
243441
|
function tonelliShanks2(P) {
|
|
243442
|
+
if (P < BigInt(3))
|
|
243443
|
+
throw new Error("sqrt is not defined for small field");
|
|
243449
243444
|
let Q = P - _1n8;
|
|
243450
243445
|
let S = 0;
|
|
243451
243446
|
while (Q % _2n6 === _0n8) {
|
|
@@ -243454,70 +243449,49 @@ var require_modular3 = __commonJS({
|
|
|
243454
243449
|
}
|
|
243455
243450
|
let Z = _2n6;
|
|
243456
243451
|
const _Fp = Field2(P);
|
|
243457
|
-
while (
|
|
243452
|
+
while (FpLegendre(_Fp, Z) === 1) {
|
|
243458
243453
|
if (Z++ > 1e3)
|
|
243459
243454
|
throw new Error("Cannot find square root: probably non-prime P");
|
|
243460
243455
|
}
|
|
243461
|
-
if (S === 1)
|
|
243462
|
-
|
|
243463
|
-
|
|
243464
|
-
const root2 = Fp.pow(n, p1div4);
|
|
243465
|
-
if (!Fp.eql(Fp.sqr(root2), n))
|
|
243466
|
-
throw new Error("Cannot find square root");
|
|
243467
|
-
return root2;
|
|
243468
|
-
};
|
|
243469
|
-
}
|
|
243456
|
+
if (S === 1)
|
|
243457
|
+
return sqrt3mod4;
|
|
243458
|
+
let cc = _Fp.pow(Z, Q);
|
|
243470
243459
|
const Q1div2 = (Q + _1n8) / _2n6;
|
|
243471
243460
|
return function tonelliSlow(Fp, n) {
|
|
243472
|
-
if (
|
|
243461
|
+
if (Fp.is0(n))
|
|
243462
|
+
return n;
|
|
243463
|
+
if (FpLegendre(Fp, n) !== 1)
|
|
243473
243464
|
throw new Error("Cannot find square root");
|
|
243474
|
-
let
|
|
243475
|
-
let
|
|
243476
|
-
let
|
|
243477
|
-
let
|
|
243478
|
-
while (!Fp.eql(
|
|
243479
|
-
if (Fp.
|
|
243465
|
+
let M = S;
|
|
243466
|
+
let c = Fp.mul(Fp.ONE, cc);
|
|
243467
|
+
let t = Fp.pow(n, Q);
|
|
243468
|
+
let R = Fp.pow(n, Q1div2);
|
|
243469
|
+
while (!Fp.eql(t, Fp.ONE)) {
|
|
243470
|
+
if (Fp.is0(t))
|
|
243480
243471
|
return Fp.ZERO;
|
|
243481
|
-
let
|
|
243482
|
-
|
|
243483
|
-
|
|
243484
|
-
|
|
243485
|
-
|
|
243472
|
+
let i = 1;
|
|
243473
|
+
let t_tmp = Fp.sqr(t);
|
|
243474
|
+
while (!Fp.eql(t_tmp, Fp.ONE)) {
|
|
243475
|
+
i++;
|
|
243476
|
+
t_tmp = Fp.sqr(t_tmp);
|
|
243477
|
+
if (i === M)
|
|
243478
|
+
throw new Error("Cannot find square root");
|
|
243486
243479
|
}
|
|
243487
|
-
const
|
|
243488
|
-
|
|
243489
|
-
|
|
243490
|
-
|
|
243491
|
-
|
|
243480
|
+
const exponent = _1n8 << BigInt(M - i - 1);
|
|
243481
|
+
const b = Fp.pow(c, exponent);
|
|
243482
|
+
M = i;
|
|
243483
|
+
c = Fp.sqr(b);
|
|
243484
|
+
t = Fp.mul(t, c);
|
|
243485
|
+
R = Fp.mul(R, b);
|
|
243492
243486
|
}
|
|
243493
|
-
return
|
|
243487
|
+
return R;
|
|
243494
243488
|
};
|
|
243495
243489
|
}
|
|
243496
243490
|
function FpSqrt2(P) {
|
|
243497
|
-
if (P % _4n3 === _3n3)
|
|
243498
|
-
return
|
|
243499
|
-
|
|
243500
|
-
|
|
243501
|
-
if (!Fp.eql(Fp.sqr(root2), n))
|
|
243502
|
-
throw new Error("Cannot find square root");
|
|
243503
|
-
return root2;
|
|
243504
|
-
};
|
|
243505
|
-
}
|
|
243506
|
-
if (P % _8n2 === _5n2) {
|
|
243507
|
-
return function sqrt5mod8(Fp, n) {
|
|
243508
|
-
const n2 = Fp.mul(n, _2n6);
|
|
243509
|
-
const c1 = (P - _5n2) / _8n2;
|
|
243510
|
-
const v = Fp.pow(n2, c1);
|
|
243511
|
-
const nv = Fp.mul(n, v);
|
|
243512
|
-
const i = Fp.mul(Fp.mul(nv, _2n6), v);
|
|
243513
|
-
const root2 = Fp.mul(nv, Fp.sub(i, Fp.ONE));
|
|
243514
|
-
if (!Fp.eql(Fp.sqr(root2), n))
|
|
243515
|
-
throw new Error("Cannot find square root");
|
|
243516
|
-
return root2;
|
|
243517
|
-
};
|
|
243518
|
-
}
|
|
243519
|
-
if (P % _16n2 === _9n2) {
|
|
243520
|
-
}
|
|
243491
|
+
if (P % _4n3 === _3n3)
|
|
243492
|
+
return sqrt3mod4;
|
|
243493
|
+
if (P % _8n2 === _5n2)
|
|
243494
|
+
return sqrt5mod8;
|
|
243521
243495
|
return tonelliShanks2(P);
|
|
243522
243496
|
}
|
|
243523
243497
|
var isNegativeLE = (num2, modulo) => (mod2(num2, modulo) & _1n8) === _1n8;
|
|
@@ -243592,18 +243566,18 @@ var require_modular3 = __commonJS({
|
|
|
243592
243566
|
return Fp.mul(lhs, typeof rhs === "bigint" ? invert2(rhs, Fp.ORDER) : Fp.inv(rhs));
|
|
243593
243567
|
}
|
|
243594
243568
|
function FpLegendre(Fp, n) {
|
|
243595
|
-
const
|
|
243596
|
-
const powered = Fp.pow(n,
|
|
243569
|
+
const p1mod2 = (Fp.ORDER - _1n8) / _2n6;
|
|
243570
|
+
const powered = Fp.pow(n, p1mod2);
|
|
243597
243571
|
const yes = Fp.eql(powered, Fp.ONE);
|
|
243598
243572
|
const zero = Fp.eql(powered, Fp.ZERO);
|
|
243599
243573
|
const no = Fp.eql(powered, Fp.neg(Fp.ONE));
|
|
243600
243574
|
if (!yes && !zero && !no)
|
|
243601
|
-
throw new Error("
|
|
243575
|
+
throw new Error("invalid Legendre symbol result");
|
|
243602
243576
|
return yes ? 1 : zero ? 0 : -1;
|
|
243603
243577
|
}
|
|
243604
243578
|
function FpIsSquare(Fp, n) {
|
|
243605
243579
|
const l = FpLegendre(Fp, n);
|
|
243606
|
-
return l ===
|
|
243580
|
+
return l === 1;
|
|
243607
243581
|
}
|
|
243608
243582
|
function nLength2(n, nBitLength) {
|
|
243609
243583
|
if (nBitLength !== void 0)
|
|
@@ -243902,18 +243876,26 @@ var require_curve4 = __commonJS({
|
|
|
243902
243876
|
function pippenger2(c, fieldN, points, scalars) {
|
|
243903
243877
|
validateMSMPoints2(points, c);
|
|
243904
243878
|
validateMSMScalars2(scalars, fieldN);
|
|
243905
|
-
|
|
243879
|
+
const plength = points.length;
|
|
243880
|
+
const slength = scalars.length;
|
|
243881
|
+
if (plength !== slength)
|
|
243906
243882
|
throw new Error("arrays of points and scalars must have equal length");
|
|
243907
243883
|
const zero = c.ZERO;
|
|
243908
|
-
const wbits = (0, utils_ts_1.bitLen)(BigInt(
|
|
243909
|
-
|
|
243884
|
+
const wbits = (0, utils_ts_1.bitLen)(BigInt(plength));
|
|
243885
|
+
let windowSize = 1;
|
|
243886
|
+
if (wbits > 12)
|
|
243887
|
+
windowSize = wbits - 3;
|
|
243888
|
+
else if (wbits > 4)
|
|
243889
|
+
windowSize = wbits - 2;
|
|
243890
|
+
else if (wbits > 0)
|
|
243891
|
+
windowSize = 2;
|
|
243910
243892
|
const MASK = (0, utils_ts_1.bitMask)(windowSize);
|
|
243911
243893
|
const buckets = new Array(Number(MASK) + 1).fill(zero);
|
|
243912
243894
|
const lastBits = Math.floor((fieldN.BITS - 1) / windowSize) * windowSize;
|
|
243913
243895
|
let sum = zero;
|
|
243914
243896
|
for (let i = lastBits; i >= 0; i -= windowSize) {
|
|
243915
243897
|
buckets.fill(zero);
|
|
243916
|
-
for (let j = 0; j <
|
|
243898
|
+
for (let j = 0; j < slength; j++) {
|
|
243917
243899
|
const scalar = scalars[j];
|
|
243918
243900
|
const wbits2 = Number(scalar >> BigInt(i) & MASK);
|
|
243919
243901
|
buckets[wbits2] = buckets[wbits2].add(points[j]);
|
|
@@ -244011,21 +243993,21 @@ var require_weierstrass3 = __commonJS({
|
|
|
244011
243993
|
a: "field",
|
|
244012
243994
|
b: "field"
|
|
244013
243995
|
}, {
|
|
243996
|
+
allowInfinityPoint: "boolean",
|
|
244014
243997
|
allowedPrivateKeyLengths: "array",
|
|
244015
|
-
wrapPrivateKey: "boolean",
|
|
244016
|
-
isTorsionFree: "function",
|
|
244017
243998
|
clearCofactor: "function",
|
|
244018
|
-
allowInfinityPoint: "boolean",
|
|
244019
243999
|
fromBytes: "function",
|
|
244020
|
-
|
|
244000
|
+
isTorsionFree: "function",
|
|
244001
|
+
toBytes: "function",
|
|
244002
|
+
wrapPrivateKey: "boolean"
|
|
244021
244003
|
});
|
|
244022
244004
|
const { endo, Fp, a } = opts;
|
|
244023
244005
|
if (endo) {
|
|
244024
244006
|
if (!Fp.eql(a, Fp.ZERO)) {
|
|
244025
|
-
throw new Error("invalid
|
|
244007
|
+
throw new Error("invalid endo: CURVE.a must be 0");
|
|
244026
244008
|
}
|
|
244027
244009
|
if (typeof endo !== "object" || typeof endo.beta !== "bigint" || typeof endo.splitScalar !== "function") {
|
|
244028
|
-
throw new Error(
|
|
244010
|
+
throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function');
|
|
244029
244011
|
}
|
|
244030
244012
|
}
|
|
244031
244013
|
return Object.freeze({ ...opts });
|
|
@@ -244136,6 +244118,9 @@ var require_weierstrass3 = __commonJS({
|
|
|
244136
244118
|
return tlv.encode(48, seq);
|
|
244137
244119
|
}
|
|
244138
244120
|
};
|
|
244121
|
+
function numToSizedHex(num2, size5) {
|
|
244122
|
+
return (0, utils_ts_1.bytesToHex)((0, utils_ts_1.numberToBytesBE)(num2, size5));
|
|
244123
|
+
}
|
|
244139
244124
|
var _0n8 = BigInt(0);
|
|
244140
244125
|
var _1n8 = BigInt(1);
|
|
244141
244126
|
var _2n6 = BigInt(2);
|
|
@@ -244161,8 +244146,17 @@ var require_weierstrass3 = __commonJS({
|
|
|
244161
244146
|
const x3 = Fp.mul(x2, x);
|
|
244162
244147
|
return Fp.add(Fp.add(x3, Fp.mul(x, a)), b);
|
|
244163
244148
|
}
|
|
244164
|
-
|
|
244165
|
-
|
|
244149
|
+
function isValidXY(x, y) {
|
|
244150
|
+
const left = Fp.sqr(y);
|
|
244151
|
+
const right = weierstrassEquation(x);
|
|
244152
|
+
return Fp.eql(left, right);
|
|
244153
|
+
}
|
|
244154
|
+
if (!isValidXY(CURVE.Gx, CURVE.Gy))
|
|
244155
|
+
throw new Error("bad curve params: generator point");
|
|
244156
|
+
const _4a3 = Fp.mul(Fp.pow(CURVE.a, _3n3), _4n3);
|
|
244157
|
+
const _27b2 = Fp.mul(Fp.sqr(CURVE.b), BigInt(27));
|
|
244158
|
+
if (Fp.is0(Fp.add(_4a3, _27b2)))
|
|
244159
|
+
throw new Error("bad curve params: a or b");
|
|
244166
244160
|
function isWithinCurveOrder(num2) {
|
|
244167
244161
|
return (0, utils_ts_1.inRange)(num2, _1n8, CURVE.n);
|
|
244168
244162
|
}
|
|
@@ -244215,9 +244209,7 @@ var require_weierstrass3 = __commonJS({
|
|
|
244215
244209
|
const { x, y } = p.toAffine();
|
|
244216
244210
|
if (!Fp.isValid(x) || !Fp.isValid(y))
|
|
244217
244211
|
throw new Error("bad point: x or y not FE");
|
|
244218
|
-
|
|
244219
|
-
const right = weierstrassEquation(x);
|
|
244220
|
-
if (!Fp.eql(left, right))
|
|
244212
|
+
if (!isValidXY(x, y))
|
|
244221
244213
|
throw new Error("bad point: equation left != right");
|
|
244222
244214
|
if (!p.isTorsionFree())
|
|
244223
244215
|
throw new Error("bad point: not in prime-order subgroup");
|
|
@@ -244423,16 +244415,16 @@ var require_weierstrass3 = __commonJS({
|
|
|
244423
244415
|
* an exposed private key e.g. sig verification, which works over *public* keys.
|
|
244424
244416
|
*/
|
|
244425
244417
|
multiplyUnsafe(sc) {
|
|
244426
|
-
const { endo, n: N } = CURVE;
|
|
244418
|
+
const { endo: endo2, n: N } = CURVE;
|
|
244427
244419
|
(0, utils_ts_1.aInRange)("scalar", sc, _0n8, N);
|
|
244428
244420
|
const I = Point2.ZERO;
|
|
244429
244421
|
if (sc === _0n8)
|
|
244430
244422
|
return I;
|
|
244431
244423
|
if (this.is0() || sc === _1n8)
|
|
244432
244424
|
return this;
|
|
244433
|
-
if (!
|
|
244425
|
+
if (!endo2 || wnaf.hasPrecomputes(this))
|
|
244434
244426
|
return wnaf.wNAFCachedUnsafe(this, sc, Point2.normalizeZ);
|
|
244435
|
-
let { k1neg, k1, k2neg, k2 } =
|
|
244427
|
+
let { k1neg, k1, k2neg, k2 } = endo2.splitScalar(sc);
|
|
244436
244428
|
let k1p = I;
|
|
244437
244429
|
let k2p = I;
|
|
244438
244430
|
let d = this;
|
|
@@ -244449,7 +244441,7 @@ var require_weierstrass3 = __commonJS({
|
|
|
244449
244441
|
k1p = k1p.negate();
|
|
244450
244442
|
if (k2neg)
|
|
244451
244443
|
k2p = k2p.negate();
|
|
244452
|
-
k2p = new Point2(Fp.mul(k2p.px,
|
|
244444
|
+
k2p = new Point2(Fp.mul(k2p.px, endo2.beta), k2p.py, k2p.pz);
|
|
244453
244445
|
return k1p.add(k2p);
|
|
244454
244446
|
}
|
|
244455
244447
|
/**
|
|
@@ -244462,16 +244454,16 @@ var require_weierstrass3 = __commonJS({
|
|
|
244462
244454
|
* @returns New point
|
|
244463
244455
|
*/
|
|
244464
244456
|
multiply(scalar) {
|
|
244465
|
-
const { endo, n: N } = CURVE;
|
|
244457
|
+
const { endo: endo2, n: N } = CURVE;
|
|
244466
244458
|
(0, utils_ts_1.aInRange)("scalar", scalar, _1n8, N);
|
|
244467
244459
|
let point, fake;
|
|
244468
|
-
if (
|
|
244469
|
-
const { k1neg, k1, k2neg, k2 } =
|
|
244460
|
+
if (endo2) {
|
|
244461
|
+
const { k1neg, k1, k2neg, k2 } = endo2.splitScalar(scalar);
|
|
244470
244462
|
let { p: k1p, f: f1p } = this.wNAF(k1);
|
|
244471
244463
|
let { p: k2p, f: f2p } = this.wNAF(k2);
|
|
244472
244464
|
k1p = wnaf.constTimeNegate(k1neg, k1p);
|
|
244473
244465
|
k2p = wnaf.constTimeNegate(k2neg, k2p);
|
|
244474
|
-
k2p = new Point2(Fp.mul(k2p.px,
|
|
244466
|
+
k2p = new Point2(Fp.mul(k2p.px, endo2.beta), k2p.py, k2p.pz);
|
|
244475
244467
|
point = k1p.add(k2p);
|
|
244476
244468
|
fake = f1p.add(f2p);
|
|
244477
244469
|
} else {
|
|
@@ -244527,8 +244519,8 @@ var require_weierstrass3 = __commonJS({
|
|
|
244527
244519
|
}
|
|
244528
244520
|
Point2.BASE = new Point2(CURVE.Gx, CURVE.Gy, Fp.ONE);
|
|
244529
244521
|
Point2.ZERO = new Point2(Fp.ZERO, Fp.ONE, Fp.ZERO);
|
|
244530
|
-
const
|
|
244531
|
-
const wnaf = (0, curve_ts_1.wNAF)(Point2,
|
|
244522
|
+
const { endo, nBitLength } = CURVE;
|
|
244523
|
+
const wnaf = (0, curve_ts_1.wNAF)(Point2, endo ? Math.ceil(nBitLength / 2) : nBitLength);
|
|
244532
244524
|
return {
|
|
244533
244525
|
CURVE,
|
|
244534
244526
|
ProjectivePoint: Point2,
|
|
@@ -244552,7 +244544,7 @@ var require_weierstrass3 = __commonJS({
|
|
|
244552
244544
|
}
|
|
244553
244545
|
function weierstrass2(curveDef) {
|
|
244554
244546
|
const CURVE = validateOpts2(curveDef);
|
|
244555
|
-
const { Fp, n: CURVE_ORDER } = CURVE;
|
|
244547
|
+
const { Fp, n: CURVE_ORDER, nByteLength, nBitLength } = CURVE;
|
|
244556
244548
|
const compressedLen = Fp.BYTES + 1;
|
|
244557
244549
|
const uncompressedLen = 2 * Fp.BYTES + 1;
|
|
244558
244550
|
function modN2(a) {
|
|
@@ -244606,7 +244598,6 @@ var require_weierstrass3 = __commonJS({
|
|
|
244606
244598
|
}
|
|
244607
244599
|
}
|
|
244608
244600
|
});
|
|
244609
|
-
const numToNByteHex = (num2) => (0, utils_ts_1.bytesToHex)((0, utils_ts_1.numberToBytesBE)(num2, CURVE.nByteLength));
|
|
244610
244601
|
function isBiggerThanHalfOrder(number) {
|
|
244611
244602
|
const HALF = CURVE_ORDER >> _1n8;
|
|
244612
244603
|
return number > HALF;
|
|
@@ -244627,7 +244618,7 @@ var require_weierstrass3 = __commonJS({
|
|
|
244627
244618
|
}
|
|
244628
244619
|
// pair (bytes of r, bytes of s)
|
|
244629
244620
|
static fromCompact(hex) {
|
|
244630
|
-
const l =
|
|
244621
|
+
const l = nByteLength;
|
|
244631
244622
|
hex = (0, utils_ts_1.ensureBytes)("compactSignature", hex, l * 2);
|
|
244632
244623
|
return new Signature(slcNum(hex, 0, l), slcNum(hex, l, 2 * l));
|
|
244633
244624
|
}
|
|
@@ -244655,7 +244646,7 @@ var require_weierstrass3 = __commonJS({
|
|
|
244655
244646
|
if (radj >= Fp.ORDER)
|
|
244656
244647
|
throw new Error("recovery id 2 or 3 invalid");
|
|
244657
244648
|
const prefix = (rec & 1) === 0 ? "02" : "03";
|
|
244658
|
-
const R = Point2.fromHex(prefix +
|
|
244649
|
+
const R = Point2.fromHex(prefix + numToSizedHex(radj, Fp.BYTES));
|
|
244659
244650
|
const ir = invN(radj);
|
|
244660
244651
|
const u1 = modN2(-h * ir);
|
|
244661
244652
|
const u2 = modN2(s * ir);
|
|
@@ -244684,7 +244675,8 @@ var require_weierstrass3 = __commonJS({
|
|
|
244684
244675
|
return (0, utils_ts_1.hexToBytes)(this.toCompactHex());
|
|
244685
244676
|
}
|
|
244686
244677
|
toCompactHex() {
|
|
244687
|
-
|
|
244678
|
+
const l = nByteLength;
|
|
244679
|
+
return numToSizedHex(this.r, l) + numToSizedHex(this.s, l);
|
|
244688
244680
|
}
|
|
244689
244681
|
}
|
|
244690
244682
|
const utils = {
|
|
@@ -244723,21 +244715,25 @@ var require_weierstrass3 = __commonJS({
|
|
|
244723
244715
|
return Point2.fromPrivateKey(privateKey).toRawBytes(isCompressed);
|
|
244724
244716
|
}
|
|
244725
244717
|
function isProbPub(item) {
|
|
244726
|
-
|
|
244727
|
-
|
|
244728
|
-
const len = (arr || str) && item.length;
|
|
244729
|
-
if (arr)
|
|
244730
|
-
return len === compressedLen || len === uncompressedLen;
|
|
244731
|
-
if (str)
|
|
244732
|
-
return len === 2 * compressedLen || len === 2 * uncompressedLen;
|
|
244718
|
+
if (typeof item === "bigint")
|
|
244719
|
+
return false;
|
|
244733
244720
|
if (item instanceof Point2)
|
|
244734
244721
|
return true;
|
|
244735
|
-
|
|
244722
|
+
const arr = (0, utils_ts_1.ensureBytes)("key", item);
|
|
244723
|
+
const len = arr.length;
|
|
244724
|
+
const fpl = Fp.BYTES;
|
|
244725
|
+
const compLen = fpl + 1;
|
|
244726
|
+
const uncompLen = 2 * fpl + 1;
|
|
244727
|
+
if (CURVE.allowedPrivateKeyLengths || nByteLength === compLen) {
|
|
244728
|
+
return void 0;
|
|
244729
|
+
} else {
|
|
244730
|
+
return len === compLen || len === uncompLen;
|
|
244731
|
+
}
|
|
244736
244732
|
}
|
|
244737
244733
|
function getSharedSecret(privateA, publicB, isCompressed = true) {
|
|
244738
|
-
if (isProbPub(privateA))
|
|
244734
|
+
if (isProbPub(privateA) === true)
|
|
244739
244735
|
throw new Error("first arg must be private key");
|
|
244740
|
-
if (
|
|
244736
|
+
if (isProbPub(publicB) === false)
|
|
244741
244737
|
throw new Error("second arg must be public key");
|
|
244742
244738
|
const b = Point2.fromHex(publicB);
|
|
244743
244739
|
return b.multiply(normPrivateKeyToScalar(privateA)).toRawBytes(isCompressed);
|
|
@@ -244746,16 +244742,16 @@ var require_weierstrass3 = __commonJS({
|
|
|
244746
244742
|
if (bytes.length > 8192)
|
|
244747
244743
|
throw new Error("input is too large");
|
|
244748
244744
|
const num2 = (0, utils_ts_1.bytesToNumberBE)(bytes);
|
|
244749
|
-
const delta = bytes.length * 8 -
|
|
244745
|
+
const delta = bytes.length * 8 - nBitLength;
|
|
244750
244746
|
return delta > 0 ? num2 >> BigInt(delta) : num2;
|
|
244751
244747
|
};
|
|
244752
244748
|
const bits2int_modN = CURVE.bits2int_modN || function(bytes) {
|
|
244753
244749
|
return modN2(bits2int(bytes));
|
|
244754
244750
|
};
|
|
244755
|
-
const ORDER_MASK = (0, utils_ts_1.bitMask)(
|
|
244751
|
+
const ORDER_MASK = (0, utils_ts_1.bitMask)(nBitLength);
|
|
244756
244752
|
function int2octets(num2) {
|
|
244757
|
-
(0, utils_ts_1.aInRange)("num < 2^" +
|
|
244758
|
-
return (0, utils_ts_1.numberToBytesBE)(num2,
|
|
244753
|
+
(0, utils_ts_1.aInRange)("num < 2^" + nBitLength, num2, _0n8, ORDER_MASK);
|
|
244754
|
+
return (0, utils_ts_1.numberToBytesBE)(num2, nByteLength);
|
|
244759
244755
|
}
|
|
244760
244756
|
function prepSig(msgHash, privateKey, opts = defaultSigOpts) {
|
|
244761
244757
|
if (["recovered", "canonical"].some((k) => k in opts))
|
|
@@ -362126,14 +362122,14 @@ init_stringify();
|
|
|
362126
362122
|
// ../../node_modules/viem/_esm/utils/promise/withCache.js
|
|
362127
362123
|
var promiseCache = /* @__PURE__ */ new Map();
|
|
362128
362124
|
var responseCache = /* @__PURE__ */ new Map();
|
|
362129
|
-
function getCache(
|
|
362130
|
-
const buildCache = (
|
|
362131
|
-
clear: () => cache.delete(
|
|
362132
|
-
get: () => cache.get(
|
|
362133
|
-
set: (data) => cache.set(
|
|
362125
|
+
function getCache(cacheKey2) {
|
|
362126
|
+
const buildCache = (cacheKey3, cache) => ({
|
|
362127
|
+
clear: () => cache.delete(cacheKey3),
|
|
362128
|
+
get: () => cache.get(cacheKey3),
|
|
362129
|
+
set: (data) => cache.set(cacheKey3, data)
|
|
362134
362130
|
});
|
|
362135
|
-
const promise = buildCache(
|
|
362136
|
-
const response = buildCache(
|
|
362131
|
+
const promise = buildCache(cacheKey2, promiseCache);
|
|
362132
|
+
const response = buildCache(cacheKey2, responseCache);
|
|
362137
362133
|
return {
|
|
362138
362134
|
clear: () => {
|
|
362139
362135
|
promise.clear();
|
|
@@ -362143,8 +362139,8 @@ function getCache(cacheKey3) {
|
|
|
362143
362139
|
response
|
|
362144
362140
|
};
|
|
362145
362141
|
}
|
|
362146
|
-
async function withCache(fn, { cacheKey:
|
|
362147
|
-
const cache = getCache(
|
|
362142
|
+
async function withCache(fn, { cacheKey: cacheKey2, cacheTime = Number.POSITIVE_INFINITY }) {
|
|
362143
|
+
const cache = getCache(cacheKey2);
|
|
362148
362144
|
const response = cache.response.get();
|
|
362149
362145
|
if (response && cacheTime > 0) {
|
|
362150
362146
|
const age = (/* @__PURE__ */ new Date()).getTime() - response.created.getTime();
|
|
@@ -365201,7 +365197,7 @@ init_decodeFunctionResult();
|
|
|
365201
365197
|
init_encodeFunctionData();
|
|
365202
365198
|
init_getChainContractAddress();
|
|
365203
365199
|
async function multicall(client, parameters) {
|
|
365204
|
-
const { allowFailure = true, batchSize: batchSize_, blockNumber, blockTag, multicallAddress: multicallAddress_, stateOverride } = parameters;
|
|
365200
|
+
const { account, allowFailure = true, batchSize: batchSize_, blockNumber, blockTag, multicallAddress: multicallAddress_, stateOverride } = parameters;
|
|
365205
365201
|
const contracts2 = parameters.contracts;
|
|
365206
365202
|
const batchSize = batchSize_ ?? (typeof client.batch?.multicall === "object" && client.batch.multicall.batchSize || 1024);
|
|
365207
365203
|
let multicallAddress = multicallAddress_;
|
|
@@ -365246,7 +365242,8 @@ async function multicall(client, parameters) {
|
|
|
365246
365242
|
address,
|
|
365247
365243
|
args,
|
|
365248
365244
|
docsPath: "/docs/contract/multicall",
|
|
365249
|
-
functionName
|
|
365245
|
+
functionName,
|
|
365246
|
+
sender: account
|
|
365250
365247
|
});
|
|
365251
365248
|
if (!allowFailure)
|
|
365252
365249
|
throw error;
|
|
@@ -365262,6 +365259,7 @@ async function multicall(client, parameters) {
|
|
|
365262
365259
|
}
|
|
365263
365260
|
const aggregate3Results = await Promise.allSettled(chunkedCalls.map((calls) => getAction(client, readContract, "readContract")({
|
|
365264
365261
|
abi: multicall3Abi,
|
|
365262
|
+
account,
|
|
365265
365263
|
address: multicallAddress,
|
|
365266
365264
|
args: [calls],
|
|
365267
365265
|
blockNumber,
|
|
@@ -368103,7 +368101,7 @@ init_parseAccount();
|
|
|
368103
368101
|
init_encodeFunctionData();
|
|
368104
368102
|
init_toHex();
|
|
368105
368103
|
async function sendCalls(client, parameters) {
|
|
368106
|
-
const { account: account_ = client.account, chain = client.chain, forceAtomic = false, id, version: version4 = "2.0.0" } = parameters;
|
|
368104
|
+
const { account: account_ = client.account, capabilities, chain = client.chain, forceAtomic = false, id, version: version4 = "2.0.0" } = parameters;
|
|
368107
368105
|
if (typeof account_ === "undefined")
|
|
368108
368106
|
throw new AccountNotFoundError({
|
|
368109
368107
|
docsPath: "/docs/actions/wallet/sendCalls"
|
|
@@ -368129,7 +368127,7 @@ async function sendCalls(client, parameters) {
|
|
|
368129
368127
|
{
|
|
368130
368128
|
atomicRequired: forceAtomic,
|
|
368131
368129
|
calls,
|
|
368132
|
-
capabilities
|
|
368130
|
+
capabilities,
|
|
368133
368131
|
chainId: numberToHex(chain.id),
|
|
368134
368132
|
from: account?.address,
|
|
368135
368133
|
id,
|
|
@@ -368148,18 +368146,6 @@ async function sendCalls(client, parameters) {
|
|
|
368148
368146
|
});
|
|
368149
368147
|
}
|
|
368150
368148
|
}
|
|
368151
|
-
function formatRequestCapabilities(capabilities) {
|
|
368152
|
-
const paymasterService = capabilities?.paymasterService ? Object.entries(capabilities.paymasterService).reduce((paymasterService2, [chainId, value]) => ({
|
|
368153
|
-
...paymasterService2 ?? {},
|
|
368154
|
-
[numberToHex(Number(chainId))]: value
|
|
368155
|
-
}), {}) : void 0;
|
|
368156
|
-
return {
|
|
368157
|
-
...capabilities,
|
|
368158
|
-
...paymasterService ? {
|
|
368159
|
-
paymasterService
|
|
368160
|
-
} : {}
|
|
368161
|
-
};
|
|
368162
|
-
}
|
|
368163
368149
|
|
|
368164
368150
|
// ../../node_modules/viem/_esm/actions/wallet/showCallsStatus.js
|
|
368165
368151
|
async function showCallsStatus(client, parameters) {
|
|
@@ -380714,7 +380700,7 @@ function isVersionRange(version4, range2) {
|
|
|
380714
380700
|
}
|
|
380715
380701
|
|
|
380716
380702
|
// ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/utils/AddressMap.js
|
|
380717
|
-
var AddressMap = class {
|
|
380703
|
+
var AddressMap = class _AddressMap {
|
|
380718
380704
|
#map;
|
|
380719
380705
|
#frozen = false;
|
|
380720
380706
|
#name;
|
|
@@ -380815,6 +380801,12 @@ var AddressMap = class {
|
|
|
380815
380801
|
get name() {
|
|
380816
380802
|
return this.#name;
|
|
380817
380803
|
}
|
|
380804
|
+
static fromRecord(record) {
|
|
380805
|
+
return new _AddressMap(Object.entries(record));
|
|
380806
|
+
}
|
|
380807
|
+
static fromMappedArray(array, mapFn) {
|
|
380808
|
+
return new _AddressMap(array.map((item) => [mapFn(item), item]));
|
|
380809
|
+
}
|
|
380818
380810
|
};
|
|
380819
380811
|
|
|
380820
380812
|
// ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/utils/bytes32ToString.js
|
|
@@ -409255,6 +409247,44 @@ function isRedstone(pf) {
|
|
|
409255
409247
|
// ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/market/pricefeeds/RedstoneUpdater.js
|
|
409256
409248
|
var import_evm_connector = __toESM(require_src5(), 1);
|
|
409257
409249
|
var import_protocol = __toESM(require_src2(), 1);
|
|
409250
|
+
|
|
409251
|
+
// ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/market/pricefeeds/RedstoneCache.js
|
|
409252
|
+
var RedstoneCache = class {
|
|
409253
|
+
#cache = /* @__PURE__ */ new Map();
|
|
409254
|
+
#ttlMs;
|
|
409255
|
+
#historical;
|
|
409256
|
+
constructor(opts) {
|
|
409257
|
+
this.#ttlMs = opts.ttl;
|
|
409258
|
+
this.#historical = opts.historical;
|
|
409259
|
+
}
|
|
409260
|
+
get(dataServiceId, dataFeedId, uniqueSignersCount) {
|
|
409261
|
+
const key = this.#cacheKey(dataServiceId, dataFeedId, uniqueSignersCount);
|
|
409262
|
+
const data = this.#cache.get(key);
|
|
409263
|
+
if (!data) {
|
|
409264
|
+
return void 0;
|
|
409265
|
+
}
|
|
409266
|
+
if (this.#expired(data)) {
|
|
409267
|
+
this.#cache.delete(key);
|
|
409268
|
+
return void 0;
|
|
409269
|
+
}
|
|
409270
|
+
return data;
|
|
409271
|
+
}
|
|
409272
|
+
set(dataServiceId, dataFeedId, uniqueSignersCount, value) {
|
|
409273
|
+
const key = this.#cacheKey(dataServiceId, dataFeedId, uniqueSignersCount);
|
|
409274
|
+
this.#cache.set(key, value);
|
|
409275
|
+
}
|
|
409276
|
+
#expired(value) {
|
|
409277
|
+
if (this.#historical) {
|
|
409278
|
+
return false;
|
|
409279
|
+
}
|
|
409280
|
+
return value.timestamp * 1e3 + this.#ttlMs < Date.now();
|
|
409281
|
+
}
|
|
409282
|
+
#cacheKey(dataServiceId, dataFeedId, uniqueSignersCount) {
|
|
409283
|
+
return `${dataServiceId}:${dataFeedId}:${uniqueSignersCount}`;
|
|
409284
|
+
}
|
|
409285
|
+
};
|
|
409286
|
+
|
|
409287
|
+
// ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/market/pricefeeds/RedstoneUpdater.js
|
|
409258
409288
|
var MAX_DATA_TIMESTAMP_DELAY_SECONDS = 10n * 60n;
|
|
409259
409289
|
var MAX_DATA_TIMESTAMP_AHEAD_SECONDS = 60n;
|
|
409260
409290
|
var RedstoneUpdateTx = class {
|
|
@@ -409282,24 +409312,29 @@ var RedstoneUpdateTx = class {
|
|
|
409282
409312
|
};
|
|
409283
409313
|
var RedstoneUpdater = class extends SDKConstruct {
|
|
409284
409314
|
#logger;
|
|
409285
|
-
#cache
|
|
409315
|
+
#cache;
|
|
409286
409316
|
#historicalTimestampMs;
|
|
409287
409317
|
#gateways;
|
|
409288
|
-
|
|
409318
|
+
#ignoreMissingFeeds;
|
|
409319
|
+
#enableLogging;
|
|
409320
|
+
constructor(sdk, opts = {}) {
|
|
409289
409321
|
super(sdk);
|
|
409290
409322
|
this.#logger = childLogger("RedstoneUpdater", sdk.logger);
|
|
409291
|
-
|
|
409292
|
-
|
|
409293
|
-
|
|
409294
|
-
|
|
409295
|
-
|
|
409296
|
-
|
|
409297
|
-
|
|
409298
|
-
|
|
409299
|
-
|
|
409300
|
-
|
|
409301
|
-
|
|
409302
|
-
|
|
409323
|
+
this.#ignoreMissingFeeds = opts.ignoreMissingFeeds;
|
|
409324
|
+
this.#enableLogging = opts.enableLogging;
|
|
409325
|
+
this.#gateways = opts.gateways?.length ? opts.gateways : void 0;
|
|
409326
|
+
let ts = opts.historicTimestamp;
|
|
409327
|
+
if (ts) {
|
|
409328
|
+
ts = ts === true ? Number(this.sdk.timestamp) * 1e3 : ts;
|
|
409329
|
+
this.#historicalTimestampMs = 6e4 * Math.floor(ts / 6e4);
|
|
409330
|
+
}
|
|
409331
|
+
this.#cache = new RedstoneCache({
|
|
409332
|
+
// currently staleness period is 240 seconds on all networks, add some buffer
|
|
409333
|
+
// this period of 4 minutes is selected based on time that is required for user to sign transaction with wallet
|
|
409334
|
+
// so it's unlikely to decrease
|
|
409335
|
+
ttl: opts.cacheTTL ?? 225 * 1e3,
|
|
409336
|
+
historical: !!ts
|
|
409337
|
+
});
|
|
409303
409338
|
}
|
|
409304
409339
|
async getUpdateTxs(feeds, logContext = {}) {
|
|
409305
409340
|
this.#logger?.debug(
|
|
@@ -409373,14 +409408,12 @@ var RedstoneUpdater = class extends SDKConstruct {
|
|
|
409373
409408
|
const fromCache = [];
|
|
409374
409409
|
const uncached = [];
|
|
409375
409410
|
for (const dataFeedId of dataFeedsIds) {
|
|
409376
|
-
const
|
|
409411
|
+
const cached = this.#cache.get(
|
|
409377
409412
|
dataServiceId,
|
|
409378
409413
|
dataFeedId,
|
|
409379
|
-
uniqueSignersCount
|
|
409380
|
-
this.#historicalTimestampMs
|
|
409414
|
+
uniqueSignersCount
|
|
409381
409415
|
);
|
|
409382
|
-
|
|
409383
|
-
if (this.#historicalTimestampMs && !!cached) {
|
|
409416
|
+
if (cached) {
|
|
409384
409417
|
fromCache.push({ ...cached, cached: true });
|
|
409385
409418
|
} else {
|
|
409386
409419
|
uncached.push(dataFeedId);
|
|
@@ -409391,16 +409424,8 @@ var RedstoneUpdater = class extends SDKConstruct {
|
|
|
409391
409424
|
new Set(uncached),
|
|
409392
409425
|
uniqueSignersCount
|
|
409393
409426
|
);
|
|
409394
|
-
|
|
409395
|
-
|
|
409396
|
-
const key = cacheKey2(
|
|
409397
|
-
dataServiceId,
|
|
409398
|
-
resp.dataFeedId,
|
|
409399
|
-
uniqueSignersCount,
|
|
409400
|
-
this.#historicalTimestampMs
|
|
409401
|
-
);
|
|
409402
|
-
this.#cache.set(key, resp);
|
|
409403
|
-
}
|
|
409427
|
+
for (const resp of fromRedstone) {
|
|
409428
|
+
this.#cache.set(dataServiceId, resp.dataFeedId, uniqueSignersCount, resp);
|
|
409404
409429
|
}
|
|
409405
409430
|
this.#logger?.debug(
|
|
409406
409431
|
`got ${fromRedstone.length} new redstone updates and ${fromCache.length} from cache`
|
|
@@ -409429,7 +409454,9 @@ var RedstoneUpdater = class extends SDKConstruct {
|
|
|
409429
409454
|
dataPackagesIds,
|
|
409430
409455
|
uniqueSignersCount,
|
|
409431
409456
|
historicalTimestamp: this.#historicalTimestampMs,
|
|
409432
|
-
urls: this.#gateways
|
|
409457
|
+
urls: this.#gateways,
|
|
409458
|
+
ignoreMissingFeed: this.#ignoreMissingFeeds,
|
|
409459
|
+
enableEnhancedLogs: this.#enableLogging
|
|
409433
409460
|
});
|
|
409434
409461
|
const dataPayload = await retry(
|
|
409435
409462
|
() => wrapper.prepareRedstonePayload(true),
|
|
@@ -409455,9 +409482,6 @@ var RedstoneUpdater = class extends SDKConstruct {
|
|
|
409455
409482
|
});
|
|
409456
409483
|
}
|
|
409457
409484
|
};
|
|
409458
|
-
function cacheKey2(dataServiceId, dataFeedId, uniqueSignersCount, historicalTimestamp = 0) {
|
|
409459
|
-
return `${dataServiceId}:${dataFeedId}:${uniqueSignersCount}:${historicalTimestamp}`;
|
|
409460
|
-
}
|
|
409461
409485
|
function groupDataPackages(signedDataPackages) {
|
|
409462
409486
|
const packagesByDataFeedId = {};
|
|
409463
409487
|
for (const p of signedDataPackages) {
|
|
@@ -409558,10 +409582,10 @@ var PriceFeedRegister = class extends SDKConstruct {
|
|
|
409558
409582
|
#feeds = new AddressMap(void 0, "priceFeeds");
|
|
409559
409583
|
#latestUpdate;
|
|
409560
409584
|
redstoneUpdater;
|
|
409561
|
-
constructor(sdk) {
|
|
409585
|
+
constructor(sdk, opts = {}) {
|
|
409562
409586
|
super(sdk);
|
|
409563
409587
|
this.logger = childLogger("PriceFeedRegister", sdk.logger);
|
|
409564
|
-
this.redstoneUpdater = new RedstoneUpdater(sdk);
|
|
409588
|
+
this.redstoneUpdater = new RedstoneUpdater(sdk, opts?.redstone);
|
|
409565
409589
|
}
|
|
409566
409590
|
addHook = this.#hooks.addHook.bind(this.#hooks);
|
|
409567
409591
|
removeHook = this.#hooks.removeHook.bind(this.#hooks);
|
|
@@ -409634,12 +409658,11 @@ var PriceFeedRegister = class extends SDKConstruct {
|
|
|
409634
409658
|
* Loads PARTIAL information about all updatable price feeds from MarketCompressor
|
|
409635
409659
|
* This is not saved anywhere in PriceFeedRegister, and can later be used to load price feed updates
|
|
409636
409660
|
*/
|
|
409637
|
-
async getPartialUpdatablePriceFeeds(
|
|
409661
|
+
async getPartialUpdatablePriceFeeds(configurators, pools) {
|
|
409638
409662
|
const [priceFeedCompressorAddress] = this.sdk.addressProvider.mustGetLatest(
|
|
409639
409663
|
AP_PRICE_FEED_COMPRESSOR,
|
|
409640
409664
|
VERSION_RANGE_310
|
|
409641
409665
|
);
|
|
409642
|
-
const configurators = marketConfigurators ?? this.sdk.marketRegister.marketConfigurators.map((mc) => mc.address);
|
|
409643
409666
|
this.logger?.debug(
|
|
409644
409667
|
{ configurators, pools },
|
|
409645
409668
|
`calling getUpdatablePriceFeeds in block ${this.sdk.currentBlock}`
|
|
@@ -409999,9 +410022,7 @@ var PriceOracleBaseContract = class extends BaseContract {
|
|
|
409999
410022
|
}
|
|
410000
410023
|
this.#labelPriceFeed(priceFeed, reserve ? "Reserve" : "Main", token);
|
|
410001
410024
|
}
|
|
410002
|
-
this.
|
|
410003
|
-
`Got ${this.mainPriceFeeds.size} main and ${this.reservePriceFeeds.size} reserve price feeds`
|
|
410004
|
-
);
|
|
410025
|
+
this.dirty = false;
|
|
410005
410026
|
}
|
|
410006
410027
|
#labelPriceFeed(address, usage, token) {
|
|
410007
410028
|
this.sdk.provider.addressLabels.set(address, (oldLabel) => {
|
|
@@ -410781,6 +410802,7 @@ var PoolSuite = class extends SDKConstruct {
|
|
|
410781
410802
|
pqk;
|
|
410782
410803
|
rateKeeper;
|
|
410783
410804
|
interestRateModel;
|
|
410805
|
+
#marketConfigurator;
|
|
410784
410806
|
constructor(sdk, data) {
|
|
410785
410807
|
super(sdk);
|
|
410786
410808
|
this.pool = createPool(sdk, data.pool);
|
|
@@ -410790,6 +410812,7 @@ var PoolSuite = class extends SDKConstruct {
|
|
|
410790
410812
|
sdk,
|
|
410791
410813
|
data.interestRateModel
|
|
410792
410814
|
);
|
|
410815
|
+
this.#marketConfigurator = data.configurator;
|
|
410793
410816
|
}
|
|
410794
410817
|
get gauge() {
|
|
410795
410818
|
if (this.rateKeeper instanceof GaugeContract) {
|
|
@@ -410815,6 +410838,11 @@ var PoolSuite = class extends SDKConstruct {
|
|
|
410815
410838
|
`Interest rate model is not a linear model, but a ${this.interestRateModel.contractType}`
|
|
410816
410839
|
);
|
|
410817
410840
|
}
|
|
410841
|
+
get marketConfigurator() {
|
|
410842
|
+
return this.sdk.contracts.mustGet(
|
|
410843
|
+
this.#marketConfigurator
|
|
410844
|
+
);
|
|
410845
|
+
}
|
|
410818
410846
|
get underlying() {
|
|
410819
410847
|
return this.pool.underlying;
|
|
410820
410848
|
}
|
|
@@ -410873,6 +410901,9 @@ var MarketSuite = class extends SDKConstruct {
|
|
|
410873
410901
|
this.creditManagers.push(new CreditSuite(sdk, marketData, i));
|
|
410874
410902
|
}
|
|
410875
410903
|
this.priceOracle = getOrCreatePriceOracle(sdk, marketData.priceOracle);
|
|
410904
|
+
sdk.logger?.debug(
|
|
410905
|
+
`oracle ${this.labelAddress(this.priceOracle.address)} has ${this.priceOracle.mainPriceFeeds.size} main and ${this.priceOracle.reservePriceFeeds.size} reserve price feeds`
|
|
410906
|
+
);
|
|
410876
410907
|
}
|
|
410877
410908
|
get dirty() {
|
|
410878
410909
|
return this.configurator.dirty || this.pool.dirty || this.priceOracle.dirty || this.creditManagers.some((cm) => cm.dirty);
|
|
@@ -410941,14 +410972,17 @@ var MarketRegister = class extends SDKConstruct {
|
|
|
410941
410972
|
const nonDirtyOracles = [];
|
|
410942
410973
|
for (const m of this.markets) {
|
|
410943
410974
|
if (m.dirty) {
|
|
410944
|
-
dirtyPools.push(m.pool
|
|
410975
|
+
dirtyPools.push(m.pool);
|
|
410945
410976
|
} else {
|
|
410946
410977
|
nonDirtyOracles.push(m.priceOracle.address);
|
|
410947
410978
|
}
|
|
410948
410979
|
}
|
|
410949
410980
|
if (dirtyPools.length) {
|
|
410950
410981
|
this.#logger?.debug(`need to reload ${dirtyPools.length} markets`);
|
|
410951
|
-
await this.#loadMarkets(
|
|
410982
|
+
await this.#loadMarkets(
|
|
410983
|
+
Array.from(new Set(dirtyPools.map((p) => p.marketConfigurator.address))),
|
|
410984
|
+
dirtyPools.map((p) => p.pool.address)
|
|
410985
|
+
);
|
|
410952
410986
|
} else if (!skipPriceUpdate && nonDirtyOracles.length) {
|
|
410953
410987
|
this.#logger?.debug(
|
|
410954
410988
|
`syncing prices on ${nonDirtyOracles.length} oracles`
|
|
@@ -411236,16 +411270,13 @@ var GearboxSDK = class _GearboxSDK {
|
|
|
411236
411270
|
#attachConfig;
|
|
411237
411271
|
// Collection of markets
|
|
411238
411272
|
#marketRegister;
|
|
411273
|
+
#priceFeeds;
|
|
411239
411274
|
logger;
|
|
411240
411275
|
/**
|
|
411241
411276
|
* Interest rate models can be reused across chain (and SDK operates on chain level)
|
|
411242
411277
|
* TODO: use whatever interface is necessary for InterestRateModels
|
|
411243
411278
|
*/
|
|
411244
411279
|
interestRateModels = new AddressMap();
|
|
411245
|
-
/**
|
|
411246
|
-
* All price feeds known to sdk, without oracle-related data (stalenessPeriod, main/reserve, etc.)
|
|
411247
|
-
*/
|
|
411248
|
-
priceFeeds;
|
|
411249
411280
|
/**
|
|
411250
411281
|
* Will throw an error if contract type is not supported, otherwise will try to use generic contract first, if possible
|
|
411251
411282
|
*/
|
|
@@ -411268,9 +411299,10 @@ var GearboxSDK = class _GearboxSDK {
|
|
|
411268
411299
|
logger: logger2,
|
|
411269
411300
|
plugins,
|
|
411270
411301
|
blockNumber,
|
|
411271
|
-
|
|
411302
|
+
redstone,
|
|
411272
411303
|
ignoreUpdateablePrices,
|
|
411273
|
-
marketConfigurators: mcs
|
|
411304
|
+
marketConfigurators: mcs,
|
|
411305
|
+
strictContractTypes
|
|
411274
411306
|
} = options;
|
|
411275
411307
|
let { networkType, addressProvider, chainId } = options;
|
|
411276
411308
|
const attachClient = createPublicClient({
|
|
@@ -411294,28 +411326,33 @@ var GearboxSDK = class _GearboxSDK {
|
|
|
411294
411326
|
return new _GearboxSDK({
|
|
411295
411327
|
provider,
|
|
411296
411328
|
logger: logger2,
|
|
411297
|
-
plugins
|
|
411329
|
+
plugins,
|
|
411330
|
+
strictContractTypes
|
|
411298
411331
|
}).#attach({
|
|
411299
411332
|
addressProvider,
|
|
411300
411333
|
blockNumber,
|
|
411301
|
-
redstoneHistoricTimestamp,
|
|
411302
411334
|
ignoreUpdateablePrices,
|
|
411303
|
-
marketConfigurators
|
|
411335
|
+
marketConfigurators,
|
|
411336
|
+
redstone
|
|
411304
411337
|
});
|
|
411305
411338
|
}
|
|
411306
411339
|
static hydrate(options, state) {
|
|
411307
|
-
const { logger: logger2, plugins, ...rest } = options;
|
|
411340
|
+
const { logger: logger2, plugins, strictContractTypes, ...rest } = options;
|
|
411308
411341
|
const provider = new Provider({
|
|
411309
411342
|
...rest,
|
|
411310
411343
|
chainId: state.chainId,
|
|
411311
411344
|
networkType: state.network
|
|
411312
411345
|
});
|
|
411313
|
-
return new _GearboxSDK({
|
|
411346
|
+
return new _GearboxSDK({
|
|
411347
|
+
provider,
|
|
411348
|
+
plugins,
|
|
411349
|
+
logger: logger2,
|
|
411350
|
+
strictContractTypes
|
|
411351
|
+
}).#hydrate(rest, state);
|
|
411314
411352
|
}
|
|
411315
411353
|
constructor(options) {
|
|
411316
411354
|
this.#provider = options.provider;
|
|
411317
411355
|
this.logger = options.logger;
|
|
411318
|
-
this.priceFeeds = new PriceFeedRegister(this);
|
|
411319
411356
|
this.strictContractTypes = options.strictContractTypes ?? false;
|
|
411320
411357
|
const pluginsInstances = {};
|
|
411321
411358
|
for (const [name, Plugin] of TypedObjectUtils.entries(
|
|
@@ -411329,9 +411366,9 @@ var GearboxSDK = class _GearboxSDK {
|
|
|
411329
411366
|
const {
|
|
411330
411367
|
addressProvider,
|
|
411331
411368
|
blockNumber,
|
|
411332
|
-
redstoneHistoricTimestamp,
|
|
411333
411369
|
ignoreUpdateablePrices,
|
|
411334
|
-
marketConfigurators
|
|
411370
|
+
marketConfigurators,
|
|
411371
|
+
redstone
|
|
411335
411372
|
} = opts;
|
|
411336
411373
|
const re = this.#attachConfig ? "re" : "";
|
|
411337
411374
|
this.logger?.info(
|
|
@@ -411343,7 +411380,7 @@ var GearboxSDK = class _GearboxSDK {
|
|
|
411343
411380
|
},
|
|
411344
411381
|
`${re}attaching gearbox sdk`
|
|
411345
411382
|
);
|
|
411346
|
-
if (!!blockNumber && !
|
|
411383
|
+
if (!!blockNumber && !opts.redstone?.historicTimestamp) {
|
|
411347
411384
|
this.logger?.warn(
|
|
411348
411385
|
`${re}attaching to fixed block number, but redstoneHistoricTimestamp is not set. price updates might fail`
|
|
411349
411386
|
);
|
|
@@ -411357,7 +411394,7 @@ var GearboxSDK = class _GearboxSDK {
|
|
|
411357
411394
|
);
|
|
411358
411395
|
this.#currentBlock = block.number;
|
|
411359
411396
|
this.#timestamp = block.timestamp;
|
|
411360
|
-
this.#
|
|
411397
|
+
this.#priceFeeds = new PriceFeedRegister(this, { redstone });
|
|
411361
411398
|
this.logger?.debug(
|
|
411362
411399
|
`${re}attach block number ${this.currentBlock} timestamp ${this.timestamp}`
|
|
411363
411400
|
);
|
|
@@ -411393,7 +411430,7 @@ var GearboxSDK = class _GearboxSDK {
|
|
|
411393
411430
|
return this;
|
|
411394
411431
|
}
|
|
411395
411432
|
#hydrate(options, state) {
|
|
411396
|
-
const { logger: _logger, ...opts } = options;
|
|
411433
|
+
const { logger: _logger, redstone, ...opts } = options;
|
|
411397
411434
|
if (state.version !== STATE_VERSION) {
|
|
411398
411435
|
throw new Error(
|
|
411399
411436
|
`hydrated state version is ${state.version}, but expected ${STATE_VERSION}`
|
|
@@ -411401,7 +411438,7 @@ var GearboxSDK = class _GearboxSDK {
|
|
|
411401
411438
|
}
|
|
411402
411439
|
this.#currentBlock = state.currentBlock;
|
|
411403
411440
|
this.#timestamp = state.timestamp;
|
|
411404
|
-
this.#
|
|
411441
|
+
this.#priceFeeds = new PriceFeedRegister(this, { redstone });
|
|
411405
411442
|
this.#addressProvider = hydrateAddressProvider(this, state.addressProvider);
|
|
411406
411443
|
this.logger?.debug(
|
|
411407
411444
|
`address provider version: ${this.#addressProvider.version}`
|
|
@@ -411427,15 +411464,6 @@ var GearboxSDK = class _GearboxSDK {
|
|
|
411427
411464
|
}
|
|
411428
411465
|
return this;
|
|
411429
411466
|
}
|
|
411430
|
-
#confugureRedstone(opts) {
|
|
411431
|
-
const { redstoneGateways, redstoneHistoricTimestamp } = opts;
|
|
411432
|
-
if (redstoneHistoricTimestamp) {
|
|
411433
|
-
this.priceFeeds.redstoneUpdater.historicalTimestamp = redstoneHistoricTimestamp === true ? Number(this.timestamp) * 1e3 : redstoneHistoricTimestamp;
|
|
411434
|
-
}
|
|
411435
|
-
if (redstoneGateways?.length) {
|
|
411436
|
-
this.priceFeeds.redstoneUpdater.gateways = redstoneGateways;
|
|
411437
|
-
}
|
|
411438
|
-
}
|
|
411439
411467
|
/**
|
|
411440
411468
|
* Reattach SDK with the same config as before, without re-creating instance. Will load all state from scratch
|
|
411441
411469
|
* Be mindful of block number, for example
|
|
@@ -411537,7 +411565,7 @@ var GearboxSDK = class _GearboxSDK {
|
|
|
411537
411565
|
*/
|
|
411538
411566
|
async syncState(opts) {
|
|
411539
411567
|
let { blockNumber, timestamp, skipPriceUpdate } = opts ?? {};
|
|
411540
|
-
if (this.#attachConfig?.
|
|
411568
|
+
if (this.#attachConfig?.redstone?.historicTimestamp) {
|
|
411541
411569
|
throw new Error(
|
|
411542
411570
|
"syncState is not supported with redstoneHistoricTimestamp"
|
|
411543
411571
|
);
|
|
@@ -411562,11 +411590,12 @@ var GearboxSDK = class _GearboxSDK {
|
|
|
411562
411590
|
...Array.from(this.marketRegister.watchAddresses),
|
|
411563
411591
|
this.addressProvider.address
|
|
411564
411592
|
];
|
|
411593
|
+
const fromBlock = this.currentBlock + 1n;
|
|
411565
411594
|
this.logger?.debug(
|
|
411566
|
-
`getting logs from ${watchAddresses.length} addresses in [${
|
|
411595
|
+
`getting logs from ${watchAddresses.length} addresses in [${fromBlock}:${blockNumber}]`
|
|
411567
411596
|
);
|
|
411568
411597
|
const logs = await getLogsSafe(this.provider.publicClient, {
|
|
411569
|
-
fromBlock
|
|
411598
|
+
fromBlock,
|
|
411570
411599
|
toBlock: blockNumber,
|
|
411571
411600
|
address: watchAddresses
|
|
411572
411601
|
});
|
|
@@ -411620,6 +411649,15 @@ var GearboxSDK = class _GearboxSDK {
|
|
|
411620
411649
|
}
|
|
411621
411650
|
return this.#timestamp;
|
|
411622
411651
|
}
|
|
411652
|
+
/**
|
|
411653
|
+
* All price feeds known to sdk, without oracle-related data (stalenessPeriod, main/reserve, etc.)
|
|
411654
|
+
*/
|
|
411655
|
+
get priceFeeds() {
|
|
411656
|
+
if (this.#priceFeeds === void 0) {
|
|
411657
|
+
throw ERR_NOT_ATTACHED;
|
|
411658
|
+
}
|
|
411659
|
+
return this.#priceFeeds;
|
|
411660
|
+
}
|
|
411623
411661
|
get gear() {
|
|
411624
411662
|
try {
|
|
411625
411663
|
const g = this.addressProvider.getAddress(AP_GEAR_TOKEN, NO_VERSION);
|
|
@@ -439829,7 +439867,7 @@ function getRenderer(opts) {
|
|
|
439829
439867
|
var package_default = {
|
|
439830
439868
|
name: "@gearbox-protocol/deploy-tools",
|
|
439831
439869
|
description: "Gearbox deploy tools",
|
|
439832
|
-
version: "5.30.
|
|
439870
|
+
version: "5.30.2",
|
|
439833
439871
|
homepage: "https://gearbox.fi",
|
|
439834
439872
|
keywords: [
|
|
439835
439873
|
"gearbox"
|
|
@@ -439872,10 +439910,10 @@ var package_default = {
|
|
|
439872
439910
|
"@gearbox-protocol/deploy-tools-node": "0.0.0",
|
|
439873
439911
|
"@gearbox-protocol/deploy-tools-shared": "0.0.0",
|
|
439874
439912
|
"@gearbox-protocol/deploy-tools-types": "0.0.0",
|
|
439875
|
-
"@gearbox-protocol/sdk": "
|
|
439913
|
+
"@gearbox-protocol/sdk": "7.3.1",
|
|
439876
439914
|
"@gearbox-protocol/sdk-gov": "^2.37.0",
|
|
439877
439915
|
"@types/lodash-es": "^4.17.12",
|
|
439878
|
-
"@types/node": "^22.15.
|
|
439916
|
+
"@types/node": "^22.15.18",
|
|
439879
439917
|
"@types/react": "^19.1.4",
|
|
439880
439918
|
"@types/react-dom": "^19.1.5",
|
|
439881
439919
|
abitype: "^1.0.8",
|
|
@@ -439894,8 +439932,8 @@ var package_default = {
|
|
|
439894
439932
|
"react-dom": "^19.1.0",
|
|
439895
439933
|
table: "^6.9.0",
|
|
439896
439934
|
tsx: "^4.19.4",
|
|
439897
|
-
viem: "^2.29.
|
|
439898
|
-
yaml: "^2.
|
|
439935
|
+
viem: "^2.29.4",
|
|
439936
|
+
yaml: "^2.8.0",
|
|
439899
439937
|
zod: "^3.24.4"
|
|
439900
439938
|
},
|
|
439901
439939
|
prettier: "@gearbox-protocol/prettier-config",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gearbox-protocol/deploy-tools",
|
|
3
3
|
"description": "Gearbox deploy tools",
|
|
4
|
-
"version": "5.30.
|
|
4
|
+
"version": "5.30.2",
|
|
5
5
|
"homepage": "https://gearbox.fi",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"gearbox"
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"@gearbox-protocol/deploy-tools-node": "0.0.0",
|
|
45
45
|
"@gearbox-protocol/deploy-tools-shared": "0.0.0",
|
|
46
46
|
"@gearbox-protocol/deploy-tools-types": "0.0.0",
|
|
47
|
-
"@gearbox-protocol/sdk": "
|
|
47
|
+
"@gearbox-protocol/sdk": "7.3.1",
|
|
48
48
|
"@gearbox-protocol/sdk-gov": "^2.37.0",
|
|
49
49
|
"@types/lodash-es": "^4.17.12",
|
|
50
|
-
"@types/node": "^22.15.
|
|
50
|
+
"@types/node": "^22.15.18",
|
|
51
51
|
"@types/react": "^19.1.4",
|
|
52
52
|
"@types/react-dom": "^19.1.5",
|
|
53
53
|
"abitype": "^1.0.8",
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
"react-dom": "^19.1.0",
|
|
67
67
|
"table": "^6.9.0",
|
|
68
68
|
"tsx": "^4.19.4",
|
|
69
|
-
"viem": "^2.29.
|
|
70
|
-
"yaml": "^2.
|
|
69
|
+
"viem": "^2.29.4",
|
|
70
|
+
"yaml": "^2.8.0",
|
|
71
71
|
"zod": "^3.24.4"
|
|
72
72
|
},
|
|
73
73
|
"prettier": "@gearbox-protocol/prettier-config",
|