@strkfarm/sdk 1.0.62 → 1.0.64
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.browser.global.js +660 -372
- package/dist/index.browser.mjs +357 -69
- package/dist/index.d.ts +27 -3
- package/dist/index.js +358 -72
- package/dist/index.mjs +360 -74
- package/package.json +1 -1
- package/src/global.ts +19 -1
- package/src/interfaces/common.tsx +1 -0
- package/src/interfaces/risks.ts +175 -0
- package/src/modules/harvests.ts +4 -2
- package/src/notifs/telegram.ts +3 -3
- package/src/strategies/ekubo-cl-vault.tsx +201 -71
- package/src/strategies/universal-adapters/adapter-utils.ts +3 -1
- package/src/strategies/universal-adapters/common-adapter.ts +57 -1
- package/src/strategies/universal-adapters/vesu-adapter.ts +39 -0
- package/src/strategies/universal-strategy.tsx +78 -5
|
@@ -60,7 +60,7 @@ var strkfarm_risk_engine = (() => {
|
|
|
60
60
|
fractionGroupSize: 0
|
|
61
61
|
};
|
|
62
62
|
function BigNumber3(n, b) {
|
|
63
|
-
var c, e, i,
|
|
63
|
+
var c, e, i, num2, len, str, x = this;
|
|
64
64
|
if (!(x instanceof BigNumber3)) {
|
|
65
65
|
if (ERRORS) raise(26, "constructor call without new", n);
|
|
66
66
|
return new BigNumber3(n, b);
|
|
@@ -73,7 +73,7 @@ var strkfarm_risk_engine = (() => {
|
|
|
73
73
|
id = 0;
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
|
-
if ((
|
|
76
|
+
if ((num2 = typeof n == "number") && n * 0 == 0) {
|
|
77
77
|
x.s = 1 / n < 0 ? (n = -n, -1) : 1;
|
|
78
78
|
if (n === ~~n) {
|
|
79
79
|
for (e = 0, i = n; i >= 10; i /= 10, e++) ;
|
|
@@ -84,7 +84,7 @@ var strkfarm_risk_engine = (() => {
|
|
|
84
84
|
}
|
|
85
85
|
str = n + "";
|
|
86
86
|
} else {
|
|
87
|
-
if (!isNumeric.test(str = n + "")) return parseNumeric(x, str,
|
|
87
|
+
if (!isNumeric.test(str = n + "")) return parseNumeric(x, str, num2);
|
|
88
88
|
x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
|
|
89
89
|
}
|
|
90
90
|
} else {
|
|
@@ -94,15 +94,15 @@ var strkfarm_risk_engine = (() => {
|
|
|
94
94
|
x = new BigNumber3(n instanceof BigNumber3 ? n : str);
|
|
95
95
|
return round(x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE);
|
|
96
96
|
}
|
|
97
|
-
if ((
|
|
98
|
-
return parseNumeric(x, str,
|
|
97
|
+
if ((num2 = typeof n == "number") && n * 0 != 0 || !new RegExp("^-?" + (c = "[" + ALPHABET.slice(0, b) + "]+") + "(?:\\." + c + ")?$", b < 37 ? "i" : "").test(str)) {
|
|
98
|
+
return parseNumeric(x, str, num2, b);
|
|
99
99
|
}
|
|
100
|
-
if (
|
|
100
|
+
if (num2) {
|
|
101
101
|
x.s = 1 / n < 0 ? (str = str.slice(1), -1) : 1;
|
|
102
102
|
if (ERRORS && str.replace(/^0\.0*|\./, "").length > 15) {
|
|
103
103
|
raise(id, tooManyDigits, n);
|
|
104
104
|
}
|
|
105
|
-
|
|
105
|
+
num2 = false;
|
|
106
106
|
} else {
|
|
107
107
|
x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
|
|
108
108
|
}
|
|
@@ -121,7 +121,7 @@ var strkfarm_risk_engine = (() => {
|
|
|
121
121
|
str = str.slice(i, len + 1);
|
|
122
122
|
if (str) {
|
|
123
123
|
len = str.length;
|
|
124
|
-
if (
|
|
124
|
+
if (num2 && ERRORS && len > 15 && (n > MAX_SAFE_INTEGER || n !== mathfloor(n))) {
|
|
125
125
|
raise(id, tooManyDigits, x.s * n);
|
|
126
126
|
}
|
|
127
127
|
e = e - i - 1;
|
|
@@ -584,12 +584,12 @@ var strkfarm_risk_engine = (() => {
|
|
|
584
584
|
}
|
|
585
585
|
parseNumeric = /* @__PURE__ */ (function() {
|
|
586
586
|
var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i, dotAfter = /^([^.]+)\.$/, dotBefore = /^\.([^.]+)$/, isInfinityOrNaN = /^-?(Infinity|NaN)$/, whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
|
|
587
|
-
return function(x, str,
|
|
588
|
-
var base2, s =
|
|
587
|
+
return function(x, str, num2, b) {
|
|
588
|
+
var base2, s = num2 ? str : str.replace(whitespaceOrPlus, "");
|
|
589
589
|
if (isInfinityOrNaN.test(s)) {
|
|
590
590
|
x.s = isNaN(s) ? null : s < 0 ? -1 : 1;
|
|
591
591
|
} else {
|
|
592
|
-
if (!
|
|
592
|
+
if (!num2) {
|
|
593
593
|
s = s.replace(basePrefix, function(m, p1, p2) {
|
|
594
594
|
base2 = (p2 = p2.toLowerCase()) == "x" ? 16 : p2 == "b" ? 2 : 8;
|
|
595
595
|
return !b || b == base2 ? p1 : m;
|
|
@@ -2694,18 +2694,18 @@ var strkfarm_risk_engine = (() => {
|
|
|
2694
2694
|
}
|
|
2695
2695
|
for (let i = 0; i < 3; i++) {
|
|
2696
2696
|
const trailingOK = i == 2;
|
|
2697
|
-
const
|
|
2698
|
-
if (
|
|
2697
|
+
const num2 = parseDigits(parts[i], 1, 2, trailingOK);
|
|
2698
|
+
if (num2 === null) {
|
|
2699
2699
|
return null;
|
|
2700
2700
|
}
|
|
2701
|
-
result[i] =
|
|
2701
|
+
result[i] = num2;
|
|
2702
2702
|
}
|
|
2703
2703
|
return result;
|
|
2704
2704
|
}
|
|
2705
2705
|
function parseMonth(token) {
|
|
2706
2706
|
token = String(token).substr(0, 3).toLowerCase();
|
|
2707
|
-
const
|
|
2708
|
-
return
|
|
2707
|
+
const num2 = MONTH_TO_NUM[token];
|
|
2708
|
+
return num2 >= 0 ? num2 : null;
|
|
2709
2709
|
}
|
|
2710
2710
|
function parseDate(str) {
|
|
2711
2711
|
if (!str) {
|
|
@@ -4919,14 +4919,14 @@ var strkfarm_risk_engine = (() => {
|
|
|
4919
4919
|
var gPO = (typeof Reflect === "function" ? Reflect.getPrototypeOf : Object.getPrototypeOf) || ([].__proto__ === Array.prototype ? function(O) {
|
|
4920
4920
|
return O.__proto__;
|
|
4921
4921
|
} : null);
|
|
4922
|
-
function addNumericSeparator(
|
|
4923
|
-
if (
|
|
4922
|
+
function addNumericSeparator(num2, str) {
|
|
4923
|
+
if (num2 === Infinity || num2 === -Infinity || num2 !== num2 || num2 && num2 > -1e3 && num2 < 1e3 || $test.call(/e/, str)) {
|
|
4924
4924
|
return str;
|
|
4925
4925
|
}
|
|
4926
4926
|
var sepRegex = /[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;
|
|
4927
|
-
if (typeof
|
|
4928
|
-
var int =
|
|
4929
|
-
if (int !==
|
|
4927
|
+
if (typeof num2 === "number") {
|
|
4928
|
+
var int = num2 < 0 ? -$floor(-num2) : $floor(num2);
|
|
4929
|
+
if (int !== num2) {
|
|
4930
4930
|
var intStr = String(int);
|
|
4931
4931
|
var dec = $slice.call(str, intStr.length + 1);
|
|
4932
4932
|
return $replace.call(intStr, sepRegex, "$&_") + "." + $replace.call($replace.call(dec, /([0-9]{3})/g, "$&_"), /_$/, "");
|
|
@@ -8439,18 +8439,18 @@ var strkfarm_risk_engine = (() => {
|
|
|
8439
8439
|
return res;
|
|
8440
8440
|
}
|
|
8441
8441
|
// @__NO_SIDE_EFFECTS__
|
|
8442
|
-
function radix(
|
|
8443
|
-
/* @__PURE__ */ assertNumber2(
|
|
8442
|
+
function radix(num2) {
|
|
8443
|
+
/* @__PURE__ */ assertNumber2(num2);
|
|
8444
8444
|
return {
|
|
8445
8445
|
encode: (bytes3) => {
|
|
8446
8446
|
if (!isBytes10(bytes3))
|
|
8447
8447
|
throw new Error("radix.encode input should be Uint8Array");
|
|
8448
|
-
return /* @__PURE__ */ convertRadix(Array.from(bytes3), 2 ** 8,
|
|
8448
|
+
return /* @__PURE__ */ convertRadix(Array.from(bytes3), 2 ** 8, num2);
|
|
8449
8449
|
},
|
|
8450
8450
|
decode: (digits) => {
|
|
8451
8451
|
if (!Array.isArray(digits) || digits.length && typeof digits[0] !== "number")
|
|
8452
8452
|
throw new Error("radix.decode input should be array of numbers");
|
|
8453
|
-
return Uint8Array.from(/* @__PURE__ */ convertRadix(digits,
|
|
8453
|
+
return Uint8Array.from(/* @__PURE__ */ convertRadix(digits, num2, 2 ** 8));
|
|
8454
8454
|
}
|
|
8455
8455
|
};
|
|
8456
8456
|
}
|
|
@@ -8749,8 +8749,8 @@ var strkfarm_risk_engine = (() => {
|
|
|
8749
8749
|
}
|
|
8750
8750
|
return hex;
|
|
8751
8751
|
}
|
|
8752
|
-
function numberToHexUnpadded4(
|
|
8753
|
-
const hex =
|
|
8752
|
+
function numberToHexUnpadded4(num2) {
|
|
8753
|
+
const hex = num2.toString(16);
|
|
8754
8754
|
return hex.length & 1 ? `0${hex}` : hex;
|
|
8755
8755
|
}
|
|
8756
8756
|
function hexToNumber4(hex) {
|
|
@@ -10293,8 +10293,8 @@ var strkfarm_risk_engine = (() => {
|
|
|
10293
10293
|
return hex;
|
|
10294
10294
|
}
|
|
10295
10295
|
exports.bytesToHex = bytesToHex4;
|
|
10296
|
-
function numberToHexUnpadded4(
|
|
10297
|
-
const hex =
|
|
10296
|
+
function numberToHexUnpadded4(num2) {
|
|
10297
|
+
const hex = num2.toString(16);
|
|
10298
10298
|
return hex.length & 1 ? `0${hex}` : hex;
|
|
10299
10299
|
}
|
|
10300
10300
|
exports.numberToHexUnpadded = numberToHexUnpadded4;
|
|
@@ -10530,7 +10530,7 @@ var strkfarm_risk_engine = (() => {
|
|
|
10530
10530
|
return result >= _0n16 ? result : b + result;
|
|
10531
10531
|
}
|
|
10532
10532
|
exports.mod = mod4;
|
|
10533
|
-
function pow3(
|
|
10533
|
+
function pow3(num2, power, modulo) {
|
|
10534
10534
|
if (modulo <= _0n16 || power < _0n16)
|
|
10535
10535
|
throw new Error("Expected power/modulo > 0");
|
|
10536
10536
|
if (modulo === _1n16)
|
|
@@ -10538,8 +10538,8 @@ var strkfarm_risk_engine = (() => {
|
|
|
10538
10538
|
let res = _1n16;
|
|
10539
10539
|
while (power > _0n16) {
|
|
10540
10540
|
if (power & _1n16)
|
|
10541
|
-
res = res *
|
|
10542
|
-
|
|
10541
|
+
res = res * num2 % modulo;
|
|
10542
|
+
num2 = num2 * num2 % modulo;
|
|
10543
10543
|
power >>= _1n16;
|
|
10544
10544
|
}
|
|
10545
10545
|
return res;
|
|
@@ -10645,7 +10645,7 @@ var strkfarm_risk_engine = (() => {
|
|
|
10645
10645
|
return tonelliShanks4(P);
|
|
10646
10646
|
}
|
|
10647
10647
|
exports.FpSqrt = FpSqrt4;
|
|
10648
|
-
var isNegativeLE = (
|
|
10648
|
+
var isNegativeLE = (num2, modulo) => (mod4(num2, modulo) & _1n16) === _1n16;
|
|
10649
10649
|
exports.isNegativeLE = isNegativeLE;
|
|
10650
10650
|
var FIELD_FIELDS4 = [
|
|
10651
10651
|
"create",
|
|
@@ -10680,15 +10680,15 @@ var strkfarm_risk_engine = (() => {
|
|
|
10680
10680
|
return (0, utils_js_1.validateObject)(field, opts);
|
|
10681
10681
|
}
|
|
10682
10682
|
exports.validateField = validateField4;
|
|
10683
|
-
function FpPow4(f,
|
|
10683
|
+
function FpPow4(f, num2, power) {
|
|
10684
10684
|
if (power < _0n16)
|
|
10685
10685
|
throw new Error("Expected power > 0");
|
|
10686
10686
|
if (power === _0n16)
|
|
10687
10687
|
return f.ONE;
|
|
10688
10688
|
if (power === _1n16)
|
|
10689
|
-
return
|
|
10689
|
+
return num2;
|
|
10690
10690
|
let p = f.ONE;
|
|
10691
|
-
let d =
|
|
10691
|
+
let d = num2;
|
|
10692
10692
|
while (power > _0n16) {
|
|
10693
10693
|
if (power & _1n16)
|
|
10694
10694
|
p = f.mul(p, d);
|
|
@@ -10700,18 +10700,18 @@ var strkfarm_risk_engine = (() => {
|
|
|
10700
10700
|
exports.FpPow = FpPow4;
|
|
10701
10701
|
function FpInvertBatch4(f, nums) {
|
|
10702
10702
|
const tmp = new Array(nums.length);
|
|
10703
|
-
const lastMultiplied = nums.reduce((acc,
|
|
10704
|
-
if (f.is0(
|
|
10703
|
+
const lastMultiplied = nums.reduce((acc, num2, i) => {
|
|
10704
|
+
if (f.is0(num2))
|
|
10705
10705
|
return acc;
|
|
10706
10706
|
tmp[i] = acc;
|
|
10707
|
-
return f.mul(acc,
|
|
10707
|
+
return f.mul(acc, num2);
|
|
10708
10708
|
}, f.ONE);
|
|
10709
10709
|
const inverted = f.inv(lastMultiplied);
|
|
10710
|
-
nums.reduceRight((acc,
|
|
10711
|
-
if (f.is0(
|
|
10710
|
+
nums.reduceRight((acc, num2, i) => {
|
|
10711
|
+
if (f.is0(num2))
|
|
10712
10712
|
return acc;
|
|
10713
10713
|
tmp[i] = f.mul(acc, tmp[i]);
|
|
10714
|
-
return f.mul(acc,
|
|
10714
|
+
return f.mul(acc, num2);
|
|
10715
10715
|
}, inverted);
|
|
10716
10716
|
return tmp;
|
|
10717
10717
|
}
|
|
@@ -10748,34 +10748,34 @@ var strkfarm_risk_engine = (() => {
|
|
|
10748
10748
|
MASK: (0, utils_js_1.bitMask)(BITS),
|
|
10749
10749
|
ZERO: _0n16,
|
|
10750
10750
|
ONE: _1n16,
|
|
10751
|
-
create: (
|
|
10752
|
-
isValid: (
|
|
10753
|
-
if (typeof
|
|
10754
|
-
throw new Error(`Invalid field element: expected bigint, got ${typeof
|
|
10755
|
-
return _0n16 <=
|
|
10751
|
+
create: (num2) => mod4(num2, ORDER),
|
|
10752
|
+
isValid: (num2) => {
|
|
10753
|
+
if (typeof num2 !== "bigint")
|
|
10754
|
+
throw new Error(`Invalid field element: expected bigint, got ${typeof num2}`);
|
|
10755
|
+
return _0n16 <= num2 && num2 < ORDER;
|
|
10756
10756
|
},
|
|
10757
|
-
is0: (
|
|
10758
|
-
isOdd: (
|
|
10759
|
-
neg: (
|
|
10757
|
+
is0: (num2) => num2 === _0n16,
|
|
10758
|
+
isOdd: (num2) => (num2 & _1n16) === _1n16,
|
|
10759
|
+
neg: (num2) => mod4(-num2, ORDER),
|
|
10760
10760
|
eql: (lhs, rhs) => lhs === rhs,
|
|
10761
|
-
sqr: (
|
|
10761
|
+
sqr: (num2) => mod4(num2 * num2, ORDER),
|
|
10762
10762
|
add: (lhs, rhs) => mod4(lhs + rhs, ORDER),
|
|
10763
10763
|
sub: (lhs, rhs) => mod4(lhs - rhs, ORDER),
|
|
10764
10764
|
mul: (lhs, rhs) => mod4(lhs * rhs, ORDER),
|
|
10765
|
-
pow: (
|
|
10765
|
+
pow: (num2, power) => FpPow4(f, num2, power),
|
|
10766
10766
|
div: (lhs, rhs) => mod4(lhs * invert4(rhs, ORDER), ORDER),
|
|
10767
10767
|
// Same as above, but doesn't normalize
|
|
10768
|
-
sqrN: (
|
|
10768
|
+
sqrN: (num2) => num2 * num2,
|
|
10769
10769
|
addN: (lhs, rhs) => lhs + rhs,
|
|
10770
10770
|
subN: (lhs, rhs) => lhs - rhs,
|
|
10771
10771
|
mulN: (lhs, rhs) => lhs * rhs,
|
|
10772
|
-
inv: (
|
|
10772
|
+
inv: (num2) => invert4(num2, ORDER),
|
|
10773
10773
|
sqrt: redef.sqrt || ((n) => sqrtP(f, n)),
|
|
10774
10774
|
invertBatch: (lst) => FpInvertBatch4(f, lst),
|
|
10775
10775
|
// TODO: do we really need constant cmov?
|
|
10776
10776
|
// We don't have const-time bigints anyway, so probably will be not very useful
|
|
10777
10777
|
cmov: (a, b, c) => c ? b : a,
|
|
10778
|
-
toBytes: (
|
|
10778
|
+
toBytes: (num2) => isLE4 ? (0, utils_js_1.numberToBytesLE)(num2, BYTES) : (0, utils_js_1.numberToBytesBE)(num2, BYTES),
|
|
10779
10779
|
fromBytes: (bytes3) => {
|
|
10780
10780
|
if (bytes3.length !== BYTES)
|
|
10781
10781
|
throw new Error(`Fp.fromBytes: expected ${BYTES}, got ${bytes3.length}`);
|
|
@@ -10805,8 +10805,8 @@ var strkfarm_risk_engine = (() => {
|
|
|
10805
10805
|
const minLen = nLength4(groupOrder).nByteLength + 8;
|
|
10806
10806
|
if (minLen < 24 || hashLen < minLen || hashLen > 1024)
|
|
10807
10807
|
throw new Error(`hashToPrivateScalar: expected ${minLen}-1024 bytes of input, got ${hashLen}`);
|
|
10808
|
-
const
|
|
10809
|
-
return mod4(
|
|
10808
|
+
const num2 = isLE4 ? (0, utils_js_1.bytesToNumberLE)(hash4) : (0, utils_js_1.bytesToNumberBE)(hash4);
|
|
10809
|
+
return mod4(num2, groupOrder - _1n16) + _1n16;
|
|
10810
10810
|
}
|
|
10811
10811
|
exports.hashToPrivateScalar = hashToPrivateScalar;
|
|
10812
10812
|
function getFieldBytesLength4(fieldOrder) {
|
|
@@ -10827,8 +10827,8 @@ var strkfarm_risk_engine = (() => {
|
|
|
10827
10827
|
const minLen = getMinHashLength4(fieldOrder);
|
|
10828
10828
|
if (len < 16 || len < minLen || len > 1024)
|
|
10829
10829
|
throw new Error(`expected ${minLen}-1024 bytes of input, got ${len}`);
|
|
10830
|
-
const
|
|
10831
|
-
const reduced = mod4(
|
|
10830
|
+
const num2 = isLE4 ? (0, utils_js_1.bytesToNumberBE)(key) : (0, utils_js_1.bytesToNumberLE)(key);
|
|
10831
|
+
const reduced = mod4(num2, fieldOrder - _1n16) + _1n16;
|
|
10832
10832
|
return isLE4 ? (0, utils_js_1.numberToBytesLE)(reduced, fieldLen) : (0, utils_js_1.numberToBytesBE)(reduced, fieldLen);
|
|
10833
10833
|
}
|
|
10834
10834
|
exports.mapHashToField = mapHashToField4;
|
|
@@ -11149,8 +11149,8 @@ var strkfarm_risk_engine = (() => {
|
|
|
11149
11149
|
},
|
|
11150
11150
|
hexFromSig(sig) {
|
|
11151
11151
|
const slice = (s2) => Number.parseInt(s2[0], 16) & 8 ? "00" + s2 : s2;
|
|
11152
|
-
const h = (
|
|
11153
|
-
const hex =
|
|
11152
|
+
const h = (num2) => {
|
|
11153
|
+
const hex = num2.toString(16);
|
|
11154
11154
|
return hex.length & 1 ? `0${hex}` : hex;
|
|
11155
11155
|
};
|
|
11156
11156
|
const s = slice(h(sig.s));
|
|
@@ -11188,11 +11188,11 @@ var strkfarm_risk_engine = (() => {
|
|
|
11188
11188
|
}
|
|
11189
11189
|
if (!Fp2.eql(Fp2.sqr(CURVE2.Gy), weierstrassEquation(CURVE2.Gx)))
|
|
11190
11190
|
throw new Error("bad generator point: equation left != right");
|
|
11191
|
-
function isWithinCurveOrder(
|
|
11192
|
-
return typeof
|
|
11191
|
+
function isWithinCurveOrder(num2) {
|
|
11192
|
+
return typeof num2 === "bigint" && _0n16 < num2 && num2 < CURVE2.n;
|
|
11193
11193
|
}
|
|
11194
|
-
function assertGE(
|
|
11195
|
-
if (!isWithinCurveOrder(
|
|
11194
|
+
function assertGE(num2) {
|
|
11195
|
+
if (!isWithinCurveOrder(num2))
|
|
11196
11196
|
throw new Error("Expected valid bigint: 0 < bigint < curve.n");
|
|
11197
11197
|
}
|
|
11198
11198
|
function normPrivateKeyToScalar(key) {
|
|
@@ -11204,16 +11204,16 @@ var strkfarm_risk_engine = (() => {
|
|
|
11204
11204
|
throw new Error("Invalid key");
|
|
11205
11205
|
key = key.padStart(nByteLength * 2, "0");
|
|
11206
11206
|
}
|
|
11207
|
-
let
|
|
11207
|
+
let num2;
|
|
11208
11208
|
try {
|
|
11209
|
-
|
|
11209
|
+
num2 = typeof key === "bigint" ? key : ut.bytesToNumberBE((0, utils_js_1.ensureBytes)("private key", key, nByteLength));
|
|
11210
11210
|
} catch (error2) {
|
|
11211
11211
|
throw new Error(`private key must be ${nByteLength} bytes, hex or bigint, not ${typeof key}`);
|
|
11212
11212
|
}
|
|
11213
11213
|
if (wrapPrivateKey)
|
|
11214
|
-
|
|
11215
|
-
assertGE(
|
|
11216
|
-
return
|
|
11214
|
+
num2 = mod4.mod(num2, n);
|
|
11215
|
+
assertGE(num2);
|
|
11216
|
+
return num2;
|
|
11217
11217
|
}
|
|
11218
11218
|
const pointPrecomputes2 = /* @__PURE__ */ new Map();
|
|
11219
11219
|
function assertPrjPoint(other) {
|
|
@@ -11575,8 +11575,8 @@ var strkfarm_risk_engine = (() => {
|
|
|
11575
11575
|
const { Fp: Fp2, n: CURVE_ORDER3 } = CURVE2;
|
|
11576
11576
|
const compressedLen = Fp2.BYTES + 1;
|
|
11577
11577
|
const uncompressedLen = 2 * Fp2.BYTES + 1;
|
|
11578
|
-
function isValidFieldElement(
|
|
11579
|
-
return _0n16 <
|
|
11578
|
+
function isValidFieldElement(num2) {
|
|
11579
|
+
return _0n16 < num2 && num2 < Fp2.ORDER;
|
|
11580
11580
|
}
|
|
11581
11581
|
function modN(a) {
|
|
11582
11582
|
return mod4.mod(a, CURVE_ORDER3);
|
|
@@ -11620,7 +11620,7 @@ var strkfarm_risk_engine = (() => {
|
|
|
11620
11620
|
}
|
|
11621
11621
|
}
|
|
11622
11622
|
});
|
|
11623
|
-
const numToNByteStr = (
|
|
11623
|
+
const numToNByteStr = (num2) => ut.bytesToHex(ut.numberToBytesBE(num2, CURVE2.nByteLength));
|
|
11624
11624
|
function isBiggerThanHalfOrder(number3) {
|
|
11625
11625
|
const HALF = CURVE_ORDER3 >> _1n16;
|
|
11626
11626
|
return number3 > HALF;
|
|
@@ -11754,20 +11754,20 @@ var strkfarm_risk_engine = (() => {
|
|
|
11754
11754
|
return b.multiply(normPrivateKeyToScalar(privateA)).toRawBytes(isCompressed);
|
|
11755
11755
|
}
|
|
11756
11756
|
const bits2int3 = CURVE2.bits2int || function(bytes3) {
|
|
11757
|
-
const
|
|
11757
|
+
const num2 = ut.bytesToNumberBE(bytes3);
|
|
11758
11758
|
const delta = bytes3.length * 8 - CURVE2.nBitLength;
|
|
11759
|
-
return delta > 0 ?
|
|
11759
|
+
return delta > 0 ? num2 >> BigInt(delta) : num2;
|
|
11760
11760
|
};
|
|
11761
11761
|
const bits2int_modN = CURVE2.bits2int_modN || function(bytes3) {
|
|
11762
11762
|
return modN(bits2int3(bytes3));
|
|
11763
11763
|
};
|
|
11764
11764
|
const ORDER_MASK = ut.bitMask(CURVE2.nBitLength);
|
|
11765
|
-
function int2octets(
|
|
11766
|
-
if (typeof
|
|
11765
|
+
function int2octets(num2) {
|
|
11766
|
+
if (typeof num2 !== "bigint")
|
|
11767
11767
|
throw new Error("bigint expected");
|
|
11768
|
-
if (!(_0n16 <=
|
|
11768
|
+
if (!(_0n16 <= num2 && num2 < ORDER_MASK))
|
|
11769
11769
|
throw new Error(`bigint expected < 2^${CURVE2.nBitLength}`);
|
|
11770
|
-
return ut.numberToBytesBE(
|
|
11770
|
+
return ut.numberToBytesBE(num2, CURVE2.nByteLength);
|
|
11771
11771
|
}
|
|
11772
11772
|
function prepSig(msgHash, privateKey, opts = defaultSigOpts) {
|
|
11773
11773
|
if (["recovered", "canonical"].some((k) => k in opts))
|
|
@@ -12102,8 +12102,8 @@ var strkfarm_risk_engine = (() => {
|
|
|
12102
12102
|
while (bytes3[0] === 0)
|
|
12103
12103
|
bytes3 = bytes3.subarray(1);
|
|
12104
12104
|
const delta = bytes3.length * 8 - nBitLength3;
|
|
12105
|
-
const
|
|
12106
|
-
return delta > 0 ?
|
|
12105
|
+
const num2 = u.bytesToNumberBE(bytes3);
|
|
12106
|
+
return delta > 0 ? num2 >> BigInt(delta) : num2;
|
|
12107
12107
|
}
|
|
12108
12108
|
function hex0xToBytes3(hex) {
|
|
12109
12109
|
if (typeof hex === "string") {
|
|
@@ -12157,8 +12157,8 @@ var strkfarm_risk_engine = (() => {
|
|
|
12157
12157
|
}
|
|
12158
12158
|
function checkMessage2(msgHash) {
|
|
12159
12159
|
const bytes3 = ensureBytes5(msgHash);
|
|
12160
|
-
const
|
|
12161
|
-
if (
|
|
12160
|
+
const num2 = u.bytesToNumberBE(bytes3);
|
|
12161
|
+
if (num2 >= exports.MAX_VALUE)
|
|
12162
12162
|
throw new Error(`msgHash should be [0, ${exports.MAX_VALUE})`);
|
|
12163
12163
|
return bytes3;
|
|
12164
12164
|
}
|
|
@@ -12420,7 +12420,7 @@ var strkfarm_risk_engine = (() => {
|
|
|
12420
12420
|
const result = a % b;
|
|
12421
12421
|
return result >= _0n16 ? result : b + result;
|
|
12422
12422
|
}
|
|
12423
|
-
function pow3(
|
|
12423
|
+
function pow3(num2, power, modulo) {
|
|
12424
12424
|
if (modulo <= _0n16 || power < _0n16)
|
|
12425
12425
|
throw new Error("Expected power/modulo > 0");
|
|
12426
12426
|
if (modulo === _1n16)
|
|
@@ -12428,8 +12428,8 @@ var strkfarm_risk_engine = (() => {
|
|
|
12428
12428
|
let res = _1n16;
|
|
12429
12429
|
while (power > _0n16) {
|
|
12430
12430
|
if (power & _1n16)
|
|
12431
|
-
res = res *
|
|
12432
|
-
|
|
12431
|
+
res = res * num2 % modulo;
|
|
12432
|
+
num2 = num2 * num2 % modulo;
|
|
12433
12433
|
power >>= _1n16;
|
|
12434
12434
|
}
|
|
12435
12435
|
return res;
|
|
@@ -12530,7 +12530,7 @@ var strkfarm_risk_engine = (() => {
|
|
|
12530
12530
|
}
|
|
12531
12531
|
return tonelliShanks4(P);
|
|
12532
12532
|
}
|
|
12533
|
-
var isNegativeLE = (
|
|
12533
|
+
var isNegativeLE = (num2, modulo) => (mod4(num2, modulo) & _1n16) === _1n16;
|
|
12534
12534
|
exports.isNegativeLE = isNegativeLE;
|
|
12535
12535
|
var FIELD_FIELDS4 = [
|
|
12536
12536
|
"create",
|
|
@@ -12564,15 +12564,15 @@ var strkfarm_risk_engine = (() => {
|
|
|
12564
12564
|
}, initial);
|
|
12565
12565
|
return (0, utils_js_1.validateObject)(field, opts);
|
|
12566
12566
|
}
|
|
12567
|
-
function FpPow4(f,
|
|
12567
|
+
function FpPow4(f, num2, power) {
|
|
12568
12568
|
if (power < _0n16)
|
|
12569
12569
|
throw new Error("Expected power > 0");
|
|
12570
12570
|
if (power === _0n16)
|
|
12571
12571
|
return f.ONE;
|
|
12572
12572
|
if (power === _1n16)
|
|
12573
|
-
return
|
|
12573
|
+
return num2;
|
|
12574
12574
|
let p = f.ONE;
|
|
12575
|
-
let d =
|
|
12575
|
+
let d = num2;
|
|
12576
12576
|
while (power > _0n16) {
|
|
12577
12577
|
if (power & _1n16)
|
|
12578
12578
|
p = f.mul(p, d);
|
|
@@ -12583,18 +12583,18 @@ var strkfarm_risk_engine = (() => {
|
|
|
12583
12583
|
}
|
|
12584
12584
|
function FpInvertBatch4(f, nums) {
|
|
12585
12585
|
const tmp = new Array(nums.length);
|
|
12586
|
-
const lastMultiplied = nums.reduce((acc,
|
|
12587
|
-
if (f.is0(
|
|
12586
|
+
const lastMultiplied = nums.reduce((acc, num2, i) => {
|
|
12587
|
+
if (f.is0(num2))
|
|
12588
12588
|
return acc;
|
|
12589
12589
|
tmp[i] = acc;
|
|
12590
|
-
return f.mul(acc,
|
|
12590
|
+
return f.mul(acc, num2);
|
|
12591
12591
|
}, f.ONE);
|
|
12592
12592
|
const inverted = f.inv(lastMultiplied);
|
|
12593
|
-
nums.reduceRight((acc,
|
|
12594
|
-
if (f.is0(
|
|
12593
|
+
nums.reduceRight((acc, num2, i) => {
|
|
12594
|
+
if (f.is0(num2))
|
|
12595
12595
|
return acc;
|
|
12596
12596
|
tmp[i] = f.mul(acc, tmp[i]);
|
|
12597
|
-
return f.mul(acc,
|
|
12597
|
+
return f.mul(acc, num2);
|
|
12598
12598
|
}, inverted);
|
|
12599
12599
|
return tmp;
|
|
12600
12600
|
}
|
|
@@ -12627,34 +12627,34 @@ var strkfarm_risk_engine = (() => {
|
|
|
12627
12627
|
MASK: (0, utils_js_1.bitMask)(BITS),
|
|
12628
12628
|
ZERO: _0n16,
|
|
12629
12629
|
ONE: _1n16,
|
|
12630
|
-
create: (
|
|
12631
|
-
isValid: (
|
|
12632
|
-
if (typeof
|
|
12633
|
-
throw new Error(`Invalid field element: expected bigint, got ${typeof
|
|
12634
|
-
return _0n16 <=
|
|
12630
|
+
create: (num2) => mod4(num2, ORDER),
|
|
12631
|
+
isValid: (num2) => {
|
|
12632
|
+
if (typeof num2 !== "bigint")
|
|
12633
|
+
throw new Error(`Invalid field element: expected bigint, got ${typeof num2}`);
|
|
12634
|
+
return _0n16 <= num2 && num2 < ORDER;
|
|
12635
12635
|
},
|
|
12636
|
-
is0: (
|
|
12637
|
-
isOdd: (
|
|
12638
|
-
neg: (
|
|
12636
|
+
is0: (num2) => num2 === _0n16,
|
|
12637
|
+
isOdd: (num2) => (num2 & _1n16) === _1n16,
|
|
12638
|
+
neg: (num2) => mod4(-num2, ORDER),
|
|
12639
12639
|
eql: (lhs, rhs) => lhs === rhs,
|
|
12640
|
-
sqr: (
|
|
12640
|
+
sqr: (num2) => mod4(num2 * num2, ORDER),
|
|
12641
12641
|
add: (lhs, rhs) => mod4(lhs + rhs, ORDER),
|
|
12642
12642
|
sub: (lhs, rhs) => mod4(lhs - rhs, ORDER),
|
|
12643
12643
|
mul: (lhs, rhs) => mod4(lhs * rhs, ORDER),
|
|
12644
|
-
pow: (
|
|
12644
|
+
pow: (num2, power) => FpPow4(f, num2, power),
|
|
12645
12645
|
div: (lhs, rhs) => mod4(lhs * invert4(rhs, ORDER), ORDER),
|
|
12646
12646
|
// Same as above, but doesn't normalize
|
|
12647
|
-
sqrN: (
|
|
12647
|
+
sqrN: (num2) => num2 * num2,
|
|
12648
12648
|
addN: (lhs, rhs) => lhs + rhs,
|
|
12649
12649
|
subN: (lhs, rhs) => lhs - rhs,
|
|
12650
12650
|
mulN: (lhs, rhs) => lhs * rhs,
|
|
12651
|
-
inv: (
|
|
12651
|
+
inv: (num2) => invert4(num2, ORDER),
|
|
12652
12652
|
sqrt: redef.sqrt || ((n) => sqrtP(f, n)),
|
|
12653
12653
|
invertBatch: (lst) => FpInvertBatch4(f, lst),
|
|
12654
12654
|
// TODO: do we really need constant cmov?
|
|
12655
12655
|
// We don't have const-time bigints anyway, so probably will be not very useful
|
|
12656
12656
|
cmov: (a, b, c) => c ? b : a,
|
|
12657
|
-
toBytes: (
|
|
12657
|
+
toBytes: (num2) => isLE4 ? (0, utils_js_1.numberToBytesLE)(num2, BYTES) : (0, utils_js_1.numberToBytesBE)(num2, BYTES),
|
|
12658
12658
|
fromBytes: (bytes3) => {
|
|
12659
12659
|
if (bytes3.length !== BYTES)
|
|
12660
12660
|
throw new Error(`Fp.fromBytes: expected ${BYTES}, got ${bytes3.length}`);
|
|
@@ -12681,8 +12681,8 @@ var strkfarm_risk_engine = (() => {
|
|
|
12681
12681
|
const minLen = nLength4(groupOrder).nByteLength + 8;
|
|
12682
12682
|
if (minLen < 24 || hashLen < minLen || hashLen > 1024)
|
|
12683
12683
|
throw new Error(`hashToPrivateScalar: expected ${minLen}-1024 bytes of input, got ${hashLen}`);
|
|
12684
|
-
const
|
|
12685
|
-
return mod4(
|
|
12684
|
+
const num2 = isLE4 ? (0, utils_js_1.bytesToNumberLE)(hash4) : (0, utils_js_1.bytesToNumberBE)(hash4);
|
|
12685
|
+
return mod4(num2, groupOrder - _1n16) + _1n16;
|
|
12686
12686
|
}
|
|
12687
12687
|
function getFieldBytesLength4(fieldOrder) {
|
|
12688
12688
|
if (typeof fieldOrder !== "bigint")
|
|
@@ -12700,8 +12700,8 @@ var strkfarm_risk_engine = (() => {
|
|
|
12700
12700
|
const minLen = getMinHashLength4(fieldOrder);
|
|
12701
12701
|
if (len < 16 || len < minLen || len > 1024)
|
|
12702
12702
|
throw new Error(`expected ${minLen}-1024 bytes of input, got ${len}`);
|
|
12703
|
-
const
|
|
12704
|
-
const reduced = mod4(
|
|
12703
|
+
const num2 = isLE4 ? (0, utils_js_1.bytesToNumberBE)(key) : (0, utils_js_1.bytesToNumberLE)(key);
|
|
12704
|
+
const reduced = mod4(num2, fieldOrder - _1n16) + _1n16;
|
|
12705
12705
|
return isLE4 ? (0, utils_js_1.numberToBytesLE)(reduced, fieldLen) : (0, utils_js_1.numberToBytesBE)(reduced, fieldLen);
|
|
12706
12706
|
}
|
|
12707
12707
|
}
|
|
@@ -13022,8 +13022,8 @@ var strkfarm_risk_engine = (() => {
|
|
|
13022
13022
|
},
|
|
13023
13023
|
hexFromSig(sig) {
|
|
13024
13024
|
const slice = (s2) => Number.parseInt(s2[0], 16) & 8 ? "00" + s2 : s2;
|
|
13025
|
-
const h = (
|
|
13026
|
-
const hex =
|
|
13025
|
+
const h = (num2) => {
|
|
13026
|
+
const hex = num2.toString(16);
|
|
13027
13027
|
return hex.length & 1 ? `0${hex}` : hex;
|
|
13028
13028
|
};
|
|
13029
13029
|
const s = slice(h(sig.s));
|
|
@@ -13061,11 +13061,11 @@ var strkfarm_risk_engine = (() => {
|
|
|
13061
13061
|
}
|
|
13062
13062
|
if (!Fp2.eql(Fp2.sqr(CURVE2.Gy), weierstrassEquation(CURVE2.Gx)))
|
|
13063
13063
|
throw new Error("bad generator point: equation left != right");
|
|
13064
|
-
function isWithinCurveOrder(
|
|
13065
|
-
return typeof
|
|
13064
|
+
function isWithinCurveOrder(num2) {
|
|
13065
|
+
return typeof num2 === "bigint" && _0n16 < num2 && num2 < CURVE2.n;
|
|
13066
13066
|
}
|
|
13067
|
-
function assertGE(
|
|
13068
|
-
if (!isWithinCurveOrder(
|
|
13067
|
+
function assertGE(num2) {
|
|
13068
|
+
if (!isWithinCurveOrder(num2))
|
|
13069
13069
|
throw new Error("Expected valid bigint: 0 < bigint < curve.n");
|
|
13070
13070
|
}
|
|
13071
13071
|
function normPrivateKeyToScalar(key) {
|
|
@@ -13077,16 +13077,16 @@ var strkfarm_risk_engine = (() => {
|
|
|
13077
13077
|
throw new Error("Invalid key");
|
|
13078
13078
|
key = key.padStart(nByteLength * 2, "0");
|
|
13079
13079
|
}
|
|
13080
|
-
let
|
|
13080
|
+
let num2;
|
|
13081
13081
|
try {
|
|
13082
|
-
|
|
13082
|
+
num2 = typeof key === "bigint" ? key : ut.bytesToNumberBE((0, utils_js_1.ensureBytes)("private key", key, nByteLength));
|
|
13083
13083
|
} catch (error2) {
|
|
13084
13084
|
throw new Error(`private key must be ${nByteLength} bytes, hex or bigint, not ${typeof key}`);
|
|
13085
13085
|
}
|
|
13086
13086
|
if (wrapPrivateKey)
|
|
13087
|
-
|
|
13088
|
-
assertGE(
|
|
13089
|
-
return
|
|
13087
|
+
num2 = mod4.mod(num2, n);
|
|
13088
|
+
assertGE(num2);
|
|
13089
|
+
return num2;
|
|
13090
13090
|
}
|
|
13091
13091
|
const pointPrecomputes2 = /* @__PURE__ */ new Map();
|
|
13092
13092
|
function assertPrjPoint(other) {
|
|
@@ -13447,8 +13447,8 @@ var strkfarm_risk_engine = (() => {
|
|
|
13447
13447
|
const { Fp: Fp2, n: CURVE_ORDER3 } = CURVE2;
|
|
13448
13448
|
const compressedLen = Fp2.BYTES + 1;
|
|
13449
13449
|
const uncompressedLen = 2 * Fp2.BYTES + 1;
|
|
13450
|
-
function isValidFieldElement(
|
|
13451
|
-
return _0n16 <
|
|
13450
|
+
function isValidFieldElement(num2) {
|
|
13451
|
+
return _0n16 < num2 && num2 < Fp2.ORDER;
|
|
13452
13452
|
}
|
|
13453
13453
|
function modN(a) {
|
|
13454
13454
|
return mod4.mod(a, CURVE_ORDER3);
|
|
@@ -13498,7 +13498,7 @@ var strkfarm_risk_engine = (() => {
|
|
|
13498
13498
|
}
|
|
13499
13499
|
}
|
|
13500
13500
|
});
|
|
13501
|
-
const numToNByteStr = (
|
|
13501
|
+
const numToNByteStr = (num2) => ut.bytesToHex(ut.numberToBytesBE(num2, CURVE2.nByteLength));
|
|
13502
13502
|
function isBiggerThanHalfOrder(number3) {
|
|
13503
13503
|
const HALF = CURVE_ORDER3 >> _1n16;
|
|
13504
13504
|
return number3 > HALF;
|
|
@@ -13632,20 +13632,20 @@ var strkfarm_risk_engine = (() => {
|
|
|
13632
13632
|
return b.multiply(normPrivateKeyToScalar(privateA)).toRawBytes(isCompressed);
|
|
13633
13633
|
}
|
|
13634
13634
|
const bits2int3 = CURVE2.bits2int || function(bytes3) {
|
|
13635
|
-
const
|
|
13635
|
+
const num2 = ut.bytesToNumberBE(bytes3);
|
|
13636
13636
|
const delta = bytes3.length * 8 - CURVE2.nBitLength;
|
|
13637
|
-
return delta > 0 ?
|
|
13637
|
+
return delta > 0 ? num2 >> BigInt(delta) : num2;
|
|
13638
13638
|
};
|
|
13639
13639
|
const bits2int_modN = CURVE2.bits2int_modN || function(bytes3) {
|
|
13640
13640
|
return modN(bits2int3(bytes3));
|
|
13641
13641
|
};
|
|
13642
13642
|
const ORDER_MASK = ut.bitMask(CURVE2.nBitLength);
|
|
13643
|
-
function int2octets(
|
|
13644
|
-
if (typeof
|
|
13643
|
+
function int2octets(num2) {
|
|
13644
|
+
if (typeof num2 !== "bigint")
|
|
13645
13645
|
throw new Error("bigint expected");
|
|
13646
|
-
if (!(_0n16 <=
|
|
13646
|
+
if (!(_0n16 <= num2 && num2 < ORDER_MASK))
|
|
13647
13647
|
throw new Error(`bigint expected < 2^${CURVE2.nBitLength}`);
|
|
13648
|
-
return ut.numberToBytesBE(
|
|
13648
|
+
return ut.numberToBytesBE(num2, CURVE2.nByteLength);
|
|
13649
13649
|
}
|
|
13650
13650
|
function prepSig(msgHash, privateKey, opts = defaultSigOpts) {
|
|
13651
13651
|
if (["recovered", "canonical"].some((k) => k in opts))
|
|
@@ -21543,8 +21543,8 @@ ${r2}}` : "}", l2;
|
|
|
21543
21543
|
}
|
|
21544
21544
|
if (enums && element.type in enums && enums[element.type]) {
|
|
21545
21545
|
const variantNum = Number(responseIterator.next().value);
|
|
21546
|
-
const rawEnum = enums[element.type].variants.reduce((acc, variant,
|
|
21547
|
-
if (
|
|
21546
|
+
const rawEnum = enums[element.type].variants.reduce((acc, variant, num2) => {
|
|
21547
|
+
if (num2 === variantNum) {
|
|
21548
21548
|
acc[variant.name] = parseResponseValue2(
|
|
21549
21549
|
responseIterator,
|
|
21550
21550
|
{ name: "", type: variant.type },
|
|
@@ -22458,8 +22458,8 @@ ${r2}}` : "}", l2;
|
|
|
22458
22458
|
var parseIntAsNumberOrBigInt2 = (str) => {
|
|
22459
22459
|
if (!json.isInteger(str))
|
|
22460
22460
|
return parseFloat(str);
|
|
22461
|
-
const
|
|
22462
|
-
return Number.isSafeInteger(
|
|
22461
|
+
const num2 = parseInt(str, 10);
|
|
22462
|
+
return Number.isSafeInteger(num2) ? num2 : BigInt(str);
|
|
22463
22463
|
};
|
|
22464
22464
|
var parse22 = (str) => json.parse(String(str), void 0, parseIntAsNumberOrBigInt2);
|
|
22465
22465
|
var parseAlwaysAsBig2 = (str) => json.parse(String(str), void 0, json.parseNumberAndBigInt);
|
|
@@ -31580,8 +31580,8 @@ ${r2}}` : "}", l2;
|
|
|
31580
31580
|
}
|
|
31581
31581
|
return hex;
|
|
31582
31582
|
}
|
|
31583
|
-
function numberToHexUnpadded(
|
|
31584
|
-
const hex =
|
|
31583
|
+
function numberToHexUnpadded(num2) {
|
|
31584
|
+
const hex = num2.toString(16);
|
|
31585
31585
|
return hex.length & 1 ? `0${hex}` : hex;
|
|
31586
31586
|
}
|
|
31587
31587
|
function hexToNumber(hex) {
|
|
@@ -32682,8 +32682,8 @@ ${r2}}` : "}", l2;
|
|
|
32682
32682
|
}
|
|
32683
32683
|
return hex;
|
|
32684
32684
|
}
|
|
32685
|
-
function numberToHexUnpadded2(
|
|
32686
|
-
const hex =
|
|
32685
|
+
function numberToHexUnpadded2(num2) {
|
|
32686
|
+
const hex = num2.toString(16);
|
|
32687
32687
|
return hex.length & 1 ? `0${hex}` : hex;
|
|
32688
32688
|
}
|
|
32689
32689
|
function hexToNumber2(hex) {
|
|
@@ -32892,7 +32892,7 @@ ${r2}}` : "}", l2;
|
|
|
32892
32892
|
const result = a % b;
|
|
32893
32893
|
return result >= _0n5 ? result : b + result;
|
|
32894
32894
|
}
|
|
32895
|
-
function pow(
|
|
32895
|
+
function pow(num2, power, modulo) {
|
|
32896
32896
|
if (modulo <= _0n5 || power < _0n5)
|
|
32897
32897
|
throw new Error("Expected power/modulo > 0");
|
|
32898
32898
|
if (modulo === _1n5)
|
|
@@ -32900,8 +32900,8 @@ ${r2}}` : "}", l2;
|
|
|
32900
32900
|
let res = _1n5;
|
|
32901
32901
|
while (power > _0n5) {
|
|
32902
32902
|
if (power & _1n5)
|
|
32903
|
-
res = res *
|
|
32904
|
-
|
|
32903
|
+
res = res * num2 % modulo;
|
|
32904
|
+
num2 = num2 * num2 % modulo;
|
|
32905
32905
|
power >>= _1n5;
|
|
32906
32906
|
}
|
|
32907
32907
|
return res;
|
|
@@ -33026,15 +33026,15 @@ ${r2}}` : "}", l2;
|
|
|
33026
33026
|
}, initial);
|
|
33027
33027
|
return validateObject2(field, opts);
|
|
33028
33028
|
}
|
|
33029
|
-
function FpPow(f,
|
|
33029
|
+
function FpPow(f, num2, power) {
|
|
33030
33030
|
if (power < _0n5)
|
|
33031
33031
|
throw new Error("Expected power > 0");
|
|
33032
33032
|
if (power === _0n5)
|
|
33033
33033
|
return f.ONE;
|
|
33034
33034
|
if (power === _1n5)
|
|
33035
|
-
return
|
|
33035
|
+
return num2;
|
|
33036
33036
|
let p = f.ONE;
|
|
33037
|
-
let d =
|
|
33037
|
+
let d = num2;
|
|
33038
33038
|
while (power > _0n5) {
|
|
33039
33039
|
if (power & _1n5)
|
|
33040
33040
|
p = f.mul(p, d);
|
|
@@ -33045,18 +33045,18 @@ ${r2}}` : "}", l2;
|
|
|
33045
33045
|
}
|
|
33046
33046
|
function FpInvertBatch(f, nums) {
|
|
33047
33047
|
const tmp = new Array(nums.length);
|
|
33048
|
-
const lastMultiplied = nums.reduce((acc,
|
|
33049
|
-
if (f.is0(
|
|
33048
|
+
const lastMultiplied = nums.reduce((acc, num2, i) => {
|
|
33049
|
+
if (f.is0(num2))
|
|
33050
33050
|
return acc;
|
|
33051
33051
|
tmp[i] = acc;
|
|
33052
|
-
return f.mul(acc,
|
|
33052
|
+
return f.mul(acc, num2);
|
|
33053
33053
|
}, f.ONE);
|
|
33054
33054
|
const inverted = f.inv(lastMultiplied);
|
|
33055
|
-
nums.reduceRight((acc,
|
|
33056
|
-
if (f.is0(
|
|
33055
|
+
nums.reduceRight((acc, num2, i) => {
|
|
33056
|
+
if (f.is0(num2))
|
|
33057
33057
|
return acc;
|
|
33058
33058
|
tmp[i] = f.mul(acc, tmp[i]);
|
|
33059
|
-
return f.mul(acc,
|
|
33059
|
+
return f.mul(acc, num2);
|
|
33060
33060
|
}, inverted);
|
|
33061
33061
|
return tmp;
|
|
33062
33062
|
}
|
|
@@ -33079,34 +33079,34 @@ ${r2}}` : "}", l2;
|
|
|
33079
33079
|
MASK: bitMask2(BITS),
|
|
33080
33080
|
ZERO: _0n5,
|
|
33081
33081
|
ONE: _1n5,
|
|
33082
|
-
create: (
|
|
33083
|
-
isValid: (
|
|
33084
|
-
if (typeof
|
|
33085
|
-
throw new Error(`Invalid field element: expected bigint, got ${typeof
|
|
33086
|
-
return _0n5 <=
|
|
33082
|
+
create: (num2) => mod(num2, ORDER),
|
|
33083
|
+
isValid: (num2) => {
|
|
33084
|
+
if (typeof num2 !== "bigint")
|
|
33085
|
+
throw new Error(`Invalid field element: expected bigint, got ${typeof num2}`);
|
|
33086
|
+
return _0n5 <= num2 && num2 < ORDER;
|
|
33087
33087
|
},
|
|
33088
|
-
is0: (
|
|
33089
|
-
isOdd: (
|
|
33090
|
-
neg: (
|
|
33088
|
+
is0: (num2) => num2 === _0n5,
|
|
33089
|
+
isOdd: (num2) => (num2 & _1n5) === _1n5,
|
|
33090
|
+
neg: (num2) => mod(-num2, ORDER),
|
|
33091
33091
|
eql: (lhs, rhs) => lhs === rhs,
|
|
33092
|
-
sqr: (
|
|
33092
|
+
sqr: (num2) => mod(num2 * num2, ORDER),
|
|
33093
33093
|
add: (lhs, rhs) => mod(lhs + rhs, ORDER),
|
|
33094
33094
|
sub: (lhs, rhs) => mod(lhs - rhs, ORDER),
|
|
33095
33095
|
mul: (lhs, rhs) => mod(lhs * rhs, ORDER),
|
|
33096
|
-
pow: (
|
|
33096
|
+
pow: (num2, power) => FpPow(f, num2, power),
|
|
33097
33097
|
div: (lhs, rhs) => mod(lhs * invert(rhs, ORDER), ORDER),
|
|
33098
33098
|
// Same as above, but doesn't normalize
|
|
33099
|
-
sqrN: (
|
|
33099
|
+
sqrN: (num2) => num2 * num2,
|
|
33100
33100
|
addN: (lhs, rhs) => lhs + rhs,
|
|
33101
33101
|
subN: (lhs, rhs) => lhs - rhs,
|
|
33102
33102
|
mulN: (lhs, rhs) => lhs * rhs,
|
|
33103
|
-
inv: (
|
|
33103
|
+
inv: (num2) => invert(num2, ORDER),
|
|
33104
33104
|
sqrt: redef.sqrt || ((n) => sqrtP(f, n)),
|
|
33105
33105
|
invertBatch: (lst) => FpInvertBatch(f, lst),
|
|
33106
33106
|
// TODO: do we really need constant cmov?
|
|
33107
33107
|
// We don't have const-time bigints anyway, so probably will be not very useful
|
|
33108
33108
|
cmov: (a, b, c) => c ? b : a,
|
|
33109
|
-
toBytes: (
|
|
33109
|
+
toBytes: (num2) => isLE4 ? numberToBytesLE2(num2, BYTES) : numberToBytesBE2(num2, BYTES),
|
|
33110
33110
|
fromBytes: (bytes3) => {
|
|
33111
33111
|
if (bytes3.length !== BYTES)
|
|
33112
33112
|
throw new Error(`Fp.fromBytes: expected ${BYTES}, got ${bytes3.length}`);
|
|
@@ -33131,8 +33131,8 @@ ${r2}}` : "}", l2;
|
|
|
33131
33131
|
const minLen = getMinHashLength(fieldOrder);
|
|
33132
33132
|
if (len < 16 || len < minLen || len > 1024)
|
|
33133
33133
|
throw new Error(`expected ${minLen}-1024 bytes of input, got ${len}`);
|
|
33134
|
-
const
|
|
33135
|
-
const reduced = mod(
|
|
33134
|
+
const num2 = isLE4 ? bytesToNumberBE2(key) : bytesToNumberLE2(key);
|
|
33135
|
+
const reduced = mod(num2, fieldOrder - _1n5) + _1n5;
|
|
33136
33136
|
return isLE4 ? numberToBytesLE2(reduced, fieldLen) : numberToBytesBE2(reduced, fieldLen);
|
|
33137
33137
|
}
|
|
33138
33138
|
|
|
@@ -33403,8 +33403,8 @@ ${r2}}` : "}", l2;
|
|
|
33403
33403
|
},
|
|
33404
33404
|
hexFromSig(sig) {
|
|
33405
33405
|
const slice = (s2) => Number.parseInt(s2[0], 16) & 8 ? "00" + s2 : s2;
|
|
33406
|
-
const h = (
|
|
33407
|
-
const hex =
|
|
33406
|
+
const h = (num2) => {
|
|
33407
|
+
const hex = num2.toString(16);
|
|
33408
33408
|
return hex.length & 1 ? `0${hex}` : hex;
|
|
33409
33409
|
};
|
|
33410
33410
|
const s = slice(h(sig.s));
|
|
@@ -33442,11 +33442,11 @@ ${r2}}` : "}", l2;
|
|
|
33442
33442
|
}
|
|
33443
33443
|
if (!Fp2.eql(Fp2.sqr(CURVE2.Gy), weierstrassEquation(CURVE2.Gx)))
|
|
33444
33444
|
throw new Error("bad generator point: equation left != right");
|
|
33445
|
-
function isWithinCurveOrder(
|
|
33446
|
-
return typeof
|
|
33445
|
+
function isWithinCurveOrder(num2) {
|
|
33446
|
+
return typeof num2 === "bigint" && _0n7 < num2 && num2 < CURVE2.n;
|
|
33447
33447
|
}
|
|
33448
|
-
function assertGE(
|
|
33449
|
-
if (!isWithinCurveOrder(
|
|
33448
|
+
function assertGE(num2) {
|
|
33449
|
+
if (!isWithinCurveOrder(num2))
|
|
33450
33450
|
throw new Error("Expected valid bigint: 0 < bigint < curve.n");
|
|
33451
33451
|
}
|
|
33452
33452
|
function normPrivateKeyToScalar(key) {
|
|
@@ -33458,16 +33458,16 @@ ${r2}}` : "}", l2;
|
|
|
33458
33458
|
throw new Error("Invalid key");
|
|
33459
33459
|
key = key.padStart(nByteLength * 2, "0");
|
|
33460
33460
|
}
|
|
33461
|
-
let
|
|
33461
|
+
let num2;
|
|
33462
33462
|
try {
|
|
33463
|
-
|
|
33463
|
+
num2 = typeof key === "bigint" ? key : bytesToNumberBE2(ensureBytes2("private key", key, nByteLength));
|
|
33464
33464
|
} catch (error2) {
|
|
33465
33465
|
throw new Error(`private key must be ${nByteLength} bytes, hex or bigint, not ${typeof key}`);
|
|
33466
33466
|
}
|
|
33467
33467
|
if (wrapPrivateKey)
|
|
33468
|
-
|
|
33469
|
-
assertGE(
|
|
33470
|
-
return
|
|
33468
|
+
num2 = mod(num2, n);
|
|
33469
|
+
assertGE(num2);
|
|
33470
|
+
return num2;
|
|
33471
33471
|
}
|
|
33472
33472
|
const pointPrecomputes2 = /* @__PURE__ */ new Map();
|
|
33473
33473
|
function assertPrjPoint(other) {
|
|
@@ -33828,8 +33828,8 @@ ${r2}}` : "}", l2;
|
|
|
33828
33828
|
const { Fp: Fp2, n: CURVE_ORDER3 } = CURVE2;
|
|
33829
33829
|
const compressedLen = Fp2.BYTES + 1;
|
|
33830
33830
|
const uncompressedLen = 2 * Fp2.BYTES + 1;
|
|
33831
|
-
function isValidFieldElement(
|
|
33832
|
-
return _0n7 <
|
|
33831
|
+
function isValidFieldElement(num2) {
|
|
33832
|
+
return _0n7 < num2 && num2 < Fp2.ORDER;
|
|
33833
33833
|
}
|
|
33834
33834
|
function modN(a) {
|
|
33835
33835
|
return mod(a, CURVE_ORDER3);
|
|
@@ -33873,7 +33873,7 @@ ${r2}}` : "}", l2;
|
|
|
33873
33873
|
}
|
|
33874
33874
|
}
|
|
33875
33875
|
});
|
|
33876
|
-
const numToNByteStr = (
|
|
33876
|
+
const numToNByteStr = (num2) => bytesToHex2(numberToBytesBE2(num2, CURVE2.nByteLength));
|
|
33877
33877
|
function isBiggerThanHalfOrder(number3) {
|
|
33878
33878
|
const HALF = CURVE_ORDER3 >> _1n7;
|
|
33879
33879
|
return number3 > HALF;
|
|
@@ -34007,20 +34007,20 @@ ${r2}}` : "}", l2;
|
|
|
34007
34007
|
return b.multiply(normPrivateKeyToScalar(privateA)).toRawBytes(isCompressed);
|
|
34008
34008
|
}
|
|
34009
34009
|
const bits2int3 = CURVE2.bits2int || function(bytes3) {
|
|
34010
|
-
const
|
|
34010
|
+
const num2 = bytesToNumberBE2(bytes3);
|
|
34011
34011
|
const delta = bytes3.length * 8 - CURVE2.nBitLength;
|
|
34012
|
-
return delta > 0 ?
|
|
34012
|
+
return delta > 0 ? num2 >> BigInt(delta) : num2;
|
|
34013
34013
|
};
|
|
34014
34014
|
const bits2int_modN = CURVE2.bits2int_modN || function(bytes3) {
|
|
34015
34015
|
return modN(bits2int3(bytes3));
|
|
34016
34016
|
};
|
|
34017
34017
|
const ORDER_MASK = bitMask2(CURVE2.nBitLength);
|
|
34018
|
-
function int2octets(
|
|
34019
|
-
if (typeof
|
|
34018
|
+
function int2octets(num2) {
|
|
34019
|
+
if (typeof num2 !== "bigint")
|
|
34020
34020
|
throw new Error("bigint expected");
|
|
34021
|
-
if (!(_0n7 <=
|
|
34021
|
+
if (!(_0n7 <= num2 && num2 < ORDER_MASK))
|
|
34022
34022
|
throw new Error(`bigint expected < 2^${CURVE2.nBitLength}`);
|
|
34023
|
-
return numberToBytesBE2(
|
|
34023
|
+
return numberToBytesBE2(num2, CURVE2.nByteLength);
|
|
34024
34024
|
}
|
|
34025
34025
|
function prepSig(msgHash, privateKey, opts = defaultSigOpts) {
|
|
34026
34026
|
if (["recovered", "canonical"].some((k) => k in opts))
|
|
@@ -34211,8 +34211,8 @@ ${r2}}` : "}", l2;
|
|
|
34211
34211
|
while (bytes3[0] === 0)
|
|
34212
34212
|
bytes3 = bytes3.subarray(1);
|
|
34213
34213
|
const delta = bytes3.length * 8 - nBitLength;
|
|
34214
|
-
const
|
|
34215
|
-
return delta > 0 ?
|
|
34214
|
+
const num2 = bytesToNumberBE2(bytes3);
|
|
34215
|
+
return delta > 0 ? num2 >> BigInt(delta) : num2;
|
|
34216
34216
|
}
|
|
34217
34217
|
function hex0xToBytes(hex) {
|
|
34218
34218
|
if (typeof hex === "string") {
|
|
@@ -34264,8 +34264,8 @@ ${r2}}` : "}", l2;
|
|
|
34264
34264
|
}
|
|
34265
34265
|
function checkMessage(msgHash) {
|
|
34266
34266
|
const bytes3 = ensureBytes3(msgHash);
|
|
34267
|
-
const
|
|
34268
|
-
if (
|
|
34267
|
+
const num2 = bytesToNumberBE2(bytes3);
|
|
34268
|
+
if (num2 >= MAX_VALUE)
|
|
34269
34269
|
throw new Error(`msgHash should be [0, ${MAX_VALUE})`);
|
|
34270
34270
|
return bytes3;
|
|
34271
34271
|
}
|
|
@@ -34488,7 +34488,7 @@ ${r2}}` : "}", l2;
|
|
|
34488
34488
|
const result = a % b;
|
|
34489
34489
|
return result >= _0n8 ? result : b + result;
|
|
34490
34490
|
}
|
|
34491
|
-
function pow2(
|
|
34491
|
+
function pow2(num2, power, modulo) {
|
|
34492
34492
|
if (modulo <= _0n8 || power < _0n8)
|
|
34493
34493
|
throw new Error("Expected power/modulo > 0");
|
|
34494
34494
|
if (modulo === _1n8)
|
|
@@ -34496,8 +34496,8 @@ ${r2}}` : "}", l2;
|
|
|
34496
34496
|
let res = _1n8;
|
|
34497
34497
|
while (power > _0n8) {
|
|
34498
34498
|
if (power & _1n8)
|
|
34499
|
-
res = res *
|
|
34500
|
-
|
|
34499
|
+
res = res * num2 % modulo;
|
|
34500
|
+
num2 = num2 * num2 % modulo;
|
|
34501
34501
|
power >>= _1n8;
|
|
34502
34502
|
}
|
|
34503
34503
|
return res;
|
|
@@ -34630,15 +34630,15 @@ ${r2}}` : "}", l2;
|
|
|
34630
34630
|
}, initial);
|
|
34631
34631
|
return validateObject(field, opts);
|
|
34632
34632
|
}
|
|
34633
|
-
function FpPow2(f,
|
|
34633
|
+
function FpPow2(f, num2, power) {
|
|
34634
34634
|
if (power < _0n8)
|
|
34635
34635
|
throw new Error("Expected power > 0");
|
|
34636
34636
|
if (power === _0n8)
|
|
34637
34637
|
return f.ONE;
|
|
34638
34638
|
if (power === _1n8)
|
|
34639
|
-
return
|
|
34639
|
+
return num2;
|
|
34640
34640
|
let p = f.ONE;
|
|
34641
|
-
let d =
|
|
34641
|
+
let d = num2;
|
|
34642
34642
|
while (power > _0n8) {
|
|
34643
34643
|
if (power & _1n8)
|
|
34644
34644
|
p = f.mul(p, d);
|
|
@@ -34649,18 +34649,18 @@ ${r2}}` : "}", l2;
|
|
|
34649
34649
|
}
|
|
34650
34650
|
function FpInvertBatch2(f, nums) {
|
|
34651
34651
|
const tmp = new Array(nums.length);
|
|
34652
|
-
const lastMultiplied = nums.reduce((acc,
|
|
34653
|
-
if (f.is0(
|
|
34652
|
+
const lastMultiplied = nums.reduce((acc, num2, i) => {
|
|
34653
|
+
if (f.is0(num2))
|
|
34654
34654
|
return acc;
|
|
34655
34655
|
tmp[i] = acc;
|
|
34656
|
-
return f.mul(acc,
|
|
34656
|
+
return f.mul(acc, num2);
|
|
34657
34657
|
}, f.ONE);
|
|
34658
34658
|
const inverted = f.inv(lastMultiplied);
|
|
34659
|
-
nums.reduceRight((acc,
|
|
34660
|
-
if (f.is0(
|
|
34659
|
+
nums.reduceRight((acc, num2, i) => {
|
|
34660
|
+
if (f.is0(num2))
|
|
34661
34661
|
return acc;
|
|
34662
34662
|
tmp[i] = f.mul(acc, tmp[i]);
|
|
34663
|
-
return f.mul(acc,
|
|
34663
|
+
return f.mul(acc, num2);
|
|
34664
34664
|
}, inverted);
|
|
34665
34665
|
return tmp;
|
|
34666
34666
|
}
|
|
@@ -34683,34 +34683,34 @@ ${r2}}` : "}", l2;
|
|
|
34683
34683
|
MASK: bitMask(BITS),
|
|
34684
34684
|
ZERO: _0n8,
|
|
34685
34685
|
ONE: _1n8,
|
|
34686
|
-
create: (
|
|
34687
|
-
isValid: (
|
|
34688
|
-
if (typeof
|
|
34689
|
-
throw new Error(`Invalid field element: expected bigint, got ${typeof
|
|
34690
|
-
return _0n8 <=
|
|
34686
|
+
create: (num2) => mod2(num2, ORDER),
|
|
34687
|
+
isValid: (num2) => {
|
|
34688
|
+
if (typeof num2 !== "bigint")
|
|
34689
|
+
throw new Error(`Invalid field element: expected bigint, got ${typeof num2}`);
|
|
34690
|
+
return _0n8 <= num2 && num2 < ORDER;
|
|
34691
34691
|
},
|
|
34692
|
-
is0: (
|
|
34693
|
-
isOdd: (
|
|
34694
|
-
neg: (
|
|
34692
|
+
is0: (num2) => num2 === _0n8,
|
|
34693
|
+
isOdd: (num2) => (num2 & _1n8) === _1n8,
|
|
34694
|
+
neg: (num2) => mod2(-num2, ORDER),
|
|
34695
34695
|
eql: (lhs, rhs) => lhs === rhs,
|
|
34696
|
-
sqr: (
|
|
34696
|
+
sqr: (num2) => mod2(num2 * num2, ORDER),
|
|
34697
34697
|
add: (lhs, rhs) => mod2(lhs + rhs, ORDER),
|
|
34698
34698
|
sub: (lhs, rhs) => mod2(lhs - rhs, ORDER),
|
|
34699
34699
|
mul: (lhs, rhs) => mod2(lhs * rhs, ORDER),
|
|
34700
|
-
pow: (
|
|
34700
|
+
pow: (num2, power) => FpPow2(f, num2, power),
|
|
34701
34701
|
div: (lhs, rhs) => mod2(lhs * invert2(rhs, ORDER), ORDER),
|
|
34702
34702
|
// Same as above, but doesn't normalize
|
|
34703
|
-
sqrN: (
|
|
34703
|
+
sqrN: (num2) => num2 * num2,
|
|
34704
34704
|
addN: (lhs, rhs) => lhs + rhs,
|
|
34705
34705
|
subN: (lhs, rhs) => lhs - rhs,
|
|
34706
34706
|
mulN: (lhs, rhs) => lhs * rhs,
|
|
34707
|
-
inv: (
|
|
34707
|
+
inv: (num2) => invert2(num2, ORDER),
|
|
34708
34708
|
sqrt: redef.sqrt || ((n) => sqrtP(f, n)),
|
|
34709
34709
|
invertBatch: (lst) => FpInvertBatch2(f, lst),
|
|
34710
34710
|
// TODO: do we really need constant cmov?
|
|
34711
34711
|
// We don't have const-time bigints anyway, so probably will be not very useful
|
|
34712
34712
|
cmov: (a, b, c) => c ? b : a,
|
|
34713
|
-
toBytes: (
|
|
34713
|
+
toBytes: (num2) => isLE4 ? numberToBytesLE(num2, BYTES) : numberToBytesBE(num2, BYTES),
|
|
34714
34714
|
fromBytes: (bytes3) => {
|
|
34715
34715
|
if (bytes3.length !== BYTES)
|
|
34716
34716
|
throw new Error(`Fp.fromBytes: expected ${BYTES}, got ${bytes3.length}`);
|
|
@@ -34735,8 +34735,8 @@ ${r2}}` : "}", l2;
|
|
|
34735
34735
|
const minLen = getMinHashLength2(fieldOrder);
|
|
34736
34736
|
if (len < 16 || len < minLen || len > 1024)
|
|
34737
34737
|
throw new Error(`expected ${minLen}-1024 bytes of input, got ${len}`);
|
|
34738
|
-
const
|
|
34739
|
-
const reduced = mod2(
|
|
34738
|
+
const num2 = isLE4 ? bytesToNumberBE(key) : bytesToNumberLE(key);
|
|
34739
|
+
const reduced = mod2(num2, fieldOrder - _1n8) + _1n8;
|
|
34740
34740
|
return isLE4 ? numberToBytesLE(reduced, fieldLen) : numberToBytesBE(reduced, fieldLen);
|
|
34741
34741
|
}
|
|
34742
34742
|
|
|
@@ -35032,8 +35032,8 @@ ${r2}}` : "}", l2;
|
|
|
35032
35032
|
},
|
|
35033
35033
|
hexFromSig(sig) {
|
|
35034
35034
|
const slice = (s2) => Number.parseInt(s2[0], 16) & 8 ? "00" + s2 : s2;
|
|
35035
|
-
const h = (
|
|
35036
|
-
const hex =
|
|
35035
|
+
const h = (num2) => {
|
|
35036
|
+
const hex = num2.toString(16);
|
|
35037
35037
|
return hex.length & 1 ? `0${hex}` : hex;
|
|
35038
35038
|
};
|
|
35039
35039
|
const s = slice(h(sig.s));
|
|
@@ -35071,11 +35071,11 @@ ${r2}}` : "}", l2;
|
|
|
35071
35071
|
}
|
|
35072
35072
|
if (!Fp2.eql(Fp2.sqr(CURVE2.Gy), weierstrassEquation(CURVE2.Gx)))
|
|
35073
35073
|
throw new Error("bad generator point: equation left != right");
|
|
35074
|
-
function isWithinCurveOrder(
|
|
35075
|
-
return typeof
|
|
35074
|
+
function isWithinCurveOrder(num2) {
|
|
35075
|
+
return typeof num2 === "bigint" && _0n10 < num2 && num2 < CURVE2.n;
|
|
35076
35076
|
}
|
|
35077
|
-
function assertGE(
|
|
35078
|
-
if (!isWithinCurveOrder(
|
|
35077
|
+
function assertGE(num2) {
|
|
35078
|
+
if (!isWithinCurveOrder(num2))
|
|
35079
35079
|
throw new Error("Expected valid bigint: 0 < bigint < curve.n");
|
|
35080
35080
|
}
|
|
35081
35081
|
function normPrivateKeyToScalar(key) {
|
|
@@ -35087,16 +35087,16 @@ ${r2}}` : "}", l2;
|
|
|
35087
35087
|
throw new Error("Invalid key");
|
|
35088
35088
|
key = key.padStart(nByteLength * 2, "0");
|
|
35089
35089
|
}
|
|
35090
|
-
let
|
|
35090
|
+
let num2;
|
|
35091
35091
|
try {
|
|
35092
|
-
|
|
35092
|
+
num2 = typeof key === "bigint" ? key : bytesToNumberBE(ensureBytes("private key", key, nByteLength));
|
|
35093
35093
|
} catch (error2) {
|
|
35094
35094
|
throw new Error(`private key must be ${nByteLength} bytes, hex or bigint, not ${typeof key}`);
|
|
35095
35095
|
}
|
|
35096
35096
|
if (wrapPrivateKey)
|
|
35097
|
-
|
|
35098
|
-
assertGE(
|
|
35099
|
-
return
|
|
35097
|
+
num2 = mod2(num2, n);
|
|
35098
|
+
assertGE(num2);
|
|
35099
|
+
return num2;
|
|
35100
35100
|
}
|
|
35101
35101
|
const pointPrecomputes2 = /* @__PURE__ */ new Map();
|
|
35102
35102
|
function assertPrjPoint(other) {
|
|
@@ -35457,8 +35457,8 @@ ${r2}}` : "}", l2;
|
|
|
35457
35457
|
const { Fp: Fp2, n: CURVE_ORDER3 } = CURVE2;
|
|
35458
35458
|
const compressedLen = Fp2.BYTES + 1;
|
|
35459
35459
|
const uncompressedLen = 2 * Fp2.BYTES + 1;
|
|
35460
|
-
function isValidFieldElement(
|
|
35461
|
-
return _0n10 <
|
|
35460
|
+
function isValidFieldElement(num2) {
|
|
35461
|
+
return _0n10 < num2 && num2 < Fp2.ORDER;
|
|
35462
35462
|
}
|
|
35463
35463
|
function modN(a) {
|
|
35464
35464
|
return mod2(a, CURVE_ORDER3);
|
|
@@ -35508,7 +35508,7 @@ ${r2}}` : "}", l2;
|
|
|
35508
35508
|
}
|
|
35509
35509
|
}
|
|
35510
35510
|
});
|
|
35511
|
-
const numToNByteStr = (
|
|
35511
|
+
const numToNByteStr = (num2) => bytesToHex(numberToBytesBE(num2, CURVE2.nByteLength));
|
|
35512
35512
|
function isBiggerThanHalfOrder(number3) {
|
|
35513
35513
|
const HALF = CURVE_ORDER3 >> _1n10;
|
|
35514
35514
|
return number3 > HALF;
|
|
@@ -35642,20 +35642,20 @@ ${r2}}` : "}", l2;
|
|
|
35642
35642
|
return b.multiply(normPrivateKeyToScalar(privateA)).toRawBytes(isCompressed);
|
|
35643
35643
|
}
|
|
35644
35644
|
const bits2int3 = CURVE2.bits2int || function(bytes3) {
|
|
35645
|
-
const
|
|
35645
|
+
const num2 = bytesToNumberBE(bytes3);
|
|
35646
35646
|
const delta = bytes3.length * 8 - CURVE2.nBitLength;
|
|
35647
|
-
return delta > 0 ?
|
|
35647
|
+
return delta > 0 ? num2 >> BigInt(delta) : num2;
|
|
35648
35648
|
};
|
|
35649
35649
|
const bits2int_modN = CURVE2.bits2int_modN || function(bytes3) {
|
|
35650
35650
|
return modN(bits2int3(bytes3));
|
|
35651
35651
|
};
|
|
35652
35652
|
const ORDER_MASK = bitMask(CURVE2.nBitLength);
|
|
35653
|
-
function int2octets(
|
|
35654
|
-
if (typeof
|
|
35653
|
+
function int2octets(num2) {
|
|
35654
|
+
if (typeof num2 !== "bigint")
|
|
35655
35655
|
throw new Error("bigint expected");
|
|
35656
|
-
if (!(_0n10 <=
|
|
35656
|
+
if (!(_0n10 <= num2 && num2 < ORDER_MASK))
|
|
35657
35657
|
throw new Error(`bigint expected < 2^${CURVE2.nBitLength}`);
|
|
35658
|
-
return numberToBytesBE(
|
|
35658
|
+
return numberToBytesBE(num2, CURVE2.nByteLength);
|
|
35659
35659
|
}
|
|
35660
35660
|
function prepSig(msgHash, privateKey, opts = defaultSigOpts) {
|
|
35661
35661
|
if (["recovered", "canonical"].some((k) => k in opts))
|
|
@@ -35873,8 +35873,8 @@ ${r2}}` : "}", l2;
|
|
|
35873
35873
|
}
|
|
35874
35874
|
var NUMBER_REGEX = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;
|
|
35875
35875
|
function isSafeNumber(value, config2) {
|
|
35876
|
-
const
|
|
35877
|
-
const parsed = String(
|
|
35876
|
+
const num2 = Number.parseFloat(value);
|
|
35877
|
+
const parsed = String(num2);
|
|
35878
35878
|
if (value === parsed) {
|
|
35879
35879
|
return true;
|
|
35880
35880
|
}
|
|
@@ -35907,11 +35907,11 @@ ${r2}}` : "}", l2;
|
|
|
35907
35907
|
if (isInteger(value)) {
|
|
35908
35908
|
return UnsafeNumberReason.truncate_integer;
|
|
35909
35909
|
}
|
|
35910
|
-
const
|
|
35911
|
-
if (!Number.isFinite(
|
|
35910
|
+
const num2 = Number.parseFloat(value);
|
|
35911
|
+
if (!Number.isFinite(num2)) {
|
|
35912
35912
|
return UnsafeNumberReason.overflow;
|
|
35913
35913
|
}
|
|
35914
|
-
if (
|
|
35914
|
+
if (num2 === 0) {
|
|
35915
35915
|
return UnsafeNumberReason.underflow;
|
|
35916
35916
|
}
|
|
35917
35917
|
return UnsafeNumberReason.truncate_float;
|
|
@@ -43049,8 +43049,8 @@ ${indent}}` : "}";
|
|
|
43049
43049
|
}
|
|
43050
43050
|
if (enums && element.type in enums && enums[element.type]) {
|
|
43051
43051
|
const variantNum = Number(responseIterator.next().value);
|
|
43052
|
-
const rawEnum = enums[element.type].variants.reduce((acc, variant,
|
|
43053
|
-
if (
|
|
43052
|
+
const rawEnum = enums[element.type].variants.reduce((acc, variant, num2) => {
|
|
43053
|
+
if (num2 === variantNum) {
|
|
43054
43054
|
acc[variant.name] = parseResponseValue(
|
|
43055
43055
|
responseIterator,
|
|
43056
43056
|
{ name: "", type: variant.type },
|
|
@@ -43958,8 +43958,8 @@ ${indent}}` : "}";
|
|
|
43958
43958
|
var parseIntAsNumberOrBigInt = (str) => {
|
|
43959
43959
|
if (!isInteger(str))
|
|
43960
43960
|
return parseFloat(str);
|
|
43961
|
-
const
|
|
43962
|
-
return Number.isSafeInteger(
|
|
43961
|
+
const num2 = parseInt(str, 10);
|
|
43962
|
+
return Number.isSafeInteger(num2) ? num2 : BigInt(str);
|
|
43963
43963
|
};
|
|
43964
43964
|
var parse2 = (str) => parse(String(str), void 0, parseIntAsNumberOrBigInt);
|
|
43965
43965
|
var parseAlwaysAsBig = (str) => parse(String(str), void 0, parseNumberAndBigInt);
|
|
@@ -47435,7 +47435,7 @@ ${indent}}` : "}";
|
|
|
47435
47435
|
name: "WBTC",
|
|
47436
47436
|
symbol: "WBTC",
|
|
47437
47437
|
logo: "https://assets.troves.fi/integrations/tokens/wbtc.svg",
|
|
47438
|
-
address: ContractAddr.from("
|
|
47438
|
+
address: ContractAddr.from("0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac"),
|
|
47439
47439
|
decimals: 8,
|
|
47440
47440
|
coingeckId: void 0,
|
|
47441
47441
|
displayDecimals: 6,
|
|
@@ -47451,6 +47451,26 @@ ${indent}}` : "}";
|
|
|
47451
47451
|
displayDecimals: 6,
|
|
47452
47452
|
priceCheckAmount: 1e-4
|
|
47453
47453
|
// 112000 * 0.0001 = $11.2
|
|
47454
|
+
}, {
|
|
47455
|
+
name: "solvBTC",
|
|
47456
|
+
symbol: "solvBTC",
|
|
47457
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/solvbtc.svg",
|
|
47458
|
+
address: ContractAddr.from("0x0593e034dda23eea82d2ba9a30960ed42cf4a01502cc2351dc9b9881f9931a68"),
|
|
47459
|
+
decimals: 18,
|
|
47460
|
+
coingeckId: void 0,
|
|
47461
|
+
displayDecimals: 6,
|
|
47462
|
+
priceCheckAmount: 1e-4
|
|
47463
|
+
// 112000 * 0.0001 = $11.2
|
|
47464
|
+
}, {
|
|
47465
|
+
name: "LBTC",
|
|
47466
|
+
symbol: "LBTC",
|
|
47467
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/lbtc.svg",
|
|
47468
|
+
address: ContractAddr.from("0x036834a40984312f7f7de8d31e3f6305b325389eaeea5b1c0664b2fb936461a4"),
|
|
47469
|
+
decimals: 8,
|
|
47470
|
+
coingeckId: void 0,
|
|
47471
|
+
displayDecimals: 6,
|
|
47472
|
+
priceCheckAmount: 1e-4
|
|
47473
|
+
// 112000 * 0.0001 = $11.2
|
|
47454
47474
|
}];
|
|
47455
47475
|
var tokens = defaultTokens;
|
|
47456
47476
|
var _Global = class _Global {
|
|
@@ -49667,8 +49687,8 @@ ${indent}}` : "}";
|
|
|
49667
49687
|
throw new Error(prefix + "expected safe integer, got type=" + typeof value);
|
|
49668
49688
|
}
|
|
49669
49689
|
}
|
|
49670
|
-
function numberToHexUnpadded3(
|
|
49671
|
-
const hex = abignumber(
|
|
49690
|
+
function numberToHexUnpadded3(num2) {
|
|
49691
|
+
const hex = abignumber(num2).toString(16);
|
|
49672
49692
|
return hex.length & 1 ? "0" + hex : hex;
|
|
49673
49693
|
}
|
|
49674
49694
|
function hexToNumber3(hex) {
|
|
@@ -49956,15 +49976,15 @@ ${indent}}` : "}";
|
|
|
49956
49976
|
validateObject3(field, opts);
|
|
49957
49977
|
return field;
|
|
49958
49978
|
}
|
|
49959
|
-
function FpPow3(Fp2,
|
|
49979
|
+
function FpPow3(Fp2, num2, power) {
|
|
49960
49980
|
if (power < _0n13)
|
|
49961
49981
|
throw new Error("invalid exponent, negatives unsupported");
|
|
49962
49982
|
if (power === _0n13)
|
|
49963
49983
|
return Fp2.ONE;
|
|
49964
49984
|
if (power === _1n13)
|
|
49965
|
-
return
|
|
49985
|
+
return num2;
|
|
49966
49986
|
let p = Fp2.ONE;
|
|
49967
|
-
let d =
|
|
49987
|
+
let d = num2;
|
|
49968
49988
|
while (power > _0n13) {
|
|
49969
49989
|
if (power & _1n13)
|
|
49970
49990
|
p = Fp2.mul(p, d);
|
|
@@ -49975,18 +49995,18 @@ ${indent}}` : "}";
|
|
|
49975
49995
|
}
|
|
49976
49996
|
function FpInvertBatch3(Fp2, nums, passZero = false) {
|
|
49977
49997
|
const inverted = new Array(nums.length).fill(passZero ? Fp2.ZERO : void 0);
|
|
49978
|
-
const multipliedAcc = nums.reduce((acc,
|
|
49979
|
-
if (Fp2.is0(
|
|
49998
|
+
const multipliedAcc = nums.reduce((acc, num2, i) => {
|
|
49999
|
+
if (Fp2.is0(num2))
|
|
49980
50000
|
return acc;
|
|
49981
50001
|
inverted[i] = acc;
|
|
49982
|
-
return Fp2.mul(acc,
|
|
50002
|
+
return Fp2.mul(acc, num2);
|
|
49983
50003
|
}, Fp2.ONE);
|
|
49984
50004
|
const invertedAcc = Fp2.inv(multipliedAcc);
|
|
49985
|
-
nums.reduceRight((acc,
|
|
49986
|
-
if (Fp2.is0(
|
|
50005
|
+
nums.reduceRight((acc, num2, i) => {
|
|
50006
|
+
if (Fp2.is0(num2))
|
|
49987
50007
|
return acc;
|
|
49988
50008
|
inverted[i] = Fp2.mul(acc, inverted[i]);
|
|
49989
|
-
return Fp2.mul(acc,
|
|
50009
|
+
return Fp2.mul(acc, num2);
|
|
49990
50010
|
}, invertedAcc);
|
|
49991
50011
|
return inverted;
|
|
49992
50012
|
}
|
|
@@ -50044,32 +50064,32 @@ ${indent}}` : "}";
|
|
|
50044
50064
|
this._sqrt = void 0;
|
|
50045
50065
|
Object.preventExtensions(this);
|
|
50046
50066
|
}
|
|
50047
|
-
create(
|
|
50048
|
-
return mod3(
|
|
50067
|
+
create(num2) {
|
|
50068
|
+
return mod3(num2, this.ORDER);
|
|
50049
50069
|
}
|
|
50050
|
-
isValid(
|
|
50051
|
-
if (typeof
|
|
50052
|
-
throw new Error("invalid field element: expected bigint, got " + typeof
|
|
50053
|
-
return _0n13 <=
|
|
50070
|
+
isValid(num2) {
|
|
50071
|
+
if (typeof num2 !== "bigint")
|
|
50072
|
+
throw new Error("invalid field element: expected bigint, got " + typeof num2);
|
|
50073
|
+
return _0n13 <= num2 && num2 < this.ORDER;
|
|
50054
50074
|
}
|
|
50055
|
-
is0(
|
|
50056
|
-
return
|
|
50075
|
+
is0(num2) {
|
|
50076
|
+
return num2 === _0n13;
|
|
50057
50077
|
}
|
|
50058
50078
|
// is valid and invertible
|
|
50059
|
-
isValidNot0(
|
|
50060
|
-
return !this.is0(
|
|
50079
|
+
isValidNot0(num2) {
|
|
50080
|
+
return !this.is0(num2) && this.isValid(num2);
|
|
50061
50081
|
}
|
|
50062
|
-
isOdd(
|
|
50063
|
-
return (
|
|
50082
|
+
isOdd(num2) {
|
|
50083
|
+
return (num2 & _1n13) === _1n13;
|
|
50064
50084
|
}
|
|
50065
|
-
neg(
|
|
50066
|
-
return mod3(-
|
|
50085
|
+
neg(num2) {
|
|
50086
|
+
return mod3(-num2, this.ORDER);
|
|
50067
50087
|
}
|
|
50068
50088
|
eql(lhs, rhs) {
|
|
50069
50089
|
return lhs === rhs;
|
|
50070
50090
|
}
|
|
50071
|
-
sqr(
|
|
50072
|
-
return mod3(
|
|
50091
|
+
sqr(num2) {
|
|
50092
|
+
return mod3(num2 * num2, this.ORDER);
|
|
50073
50093
|
}
|
|
50074
50094
|
add(lhs, rhs) {
|
|
50075
50095
|
return mod3(lhs + rhs, this.ORDER);
|
|
@@ -50080,15 +50100,15 @@ ${indent}}` : "}";
|
|
|
50080
50100
|
mul(lhs, rhs) {
|
|
50081
50101
|
return mod3(lhs * rhs, this.ORDER);
|
|
50082
50102
|
}
|
|
50083
|
-
pow(
|
|
50084
|
-
return FpPow3(this,
|
|
50103
|
+
pow(num2, power) {
|
|
50104
|
+
return FpPow3(this, num2, power);
|
|
50085
50105
|
}
|
|
50086
50106
|
div(lhs, rhs) {
|
|
50087
50107
|
return mod3(lhs * invert3(rhs, this.ORDER), this.ORDER);
|
|
50088
50108
|
}
|
|
50089
50109
|
// Same as above, but doesn't normalize
|
|
50090
|
-
sqrN(
|
|
50091
|
-
return
|
|
50110
|
+
sqrN(num2) {
|
|
50111
|
+
return num2 * num2;
|
|
50092
50112
|
}
|
|
50093
50113
|
addN(lhs, rhs) {
|
|
50094
50114
|
return lhs + rhs;
|
|
@@ -50099,16 +50119,16 @@ ${indent}}` : "}";
|
|
|
50099
50119
|
mulN(lhs, rhs) {
|
|
50100
50120
|
return lhs * rhs;
|
|
50101
50121
|
}
|
|
50102
|
-
inv(
|
|
50103
|
-
return invert3(
|
|
50122
|
+
inv(num2) {
|
|
50123
|
+
return invert3(num2, this.ORDER);
|
|
50104
50124
|
}
|
|
50105
|
-
sqrt(
|
|
50125
|
+
sqrt(num2) {
|
|
50106
50126
|
if (!this._sqrt)
|
|
50107
50127
|
this._sqrt = FpSqrt3(this.ORDER);
|
|
50108
|
-
return this._sqrt(this,
|
|
50128
|
+
return this._sqrt(this, num2);
|
|
50109
50129
|
}
|
|
50110
|
-
toBytes(
|
|
50111
|
-
return this.isLE ? numberToBytesLE3(
|
|
50130
|
+
toBytes(num2) {
|
|
50131
|
+
return this.isLE ? numberToBytesLE3(num2, this.BYTES) : numberToBytesBE3(num2, this.BYTES);
|
|
50112
50132
|
}
|
|
50113
50133
|
fromBytes(bytes3, skipValidation = false) {
|
|
50114
50134
|
abytes3(bytes3);
|
|
@@ -50162,8 +50182,8 @@ ${indent}}` : "}";
|
|
|
50162
50182
|
const minLen = getMinHashLength3(fieldOrder);
|
|
50163
50183
|
if (len < 16 || len < minLen || len > 1024)
|
|
50164
50184
|
throw new Error("expected " + minLen + "-1024 bytes of input, got " + len);
|
|
50165
|
-
const
|
|
50166
|
-
const reduced = mod3(
|
|
50185
|
+
const num2 = isLE4 ? bytesToNumberLE3(key) : bytesToNumberBE3(key);
|
|
50186
|
+
const reduced = mod3(num2, fieldOrder - _1n13) + _1n13;
|
|
50167
50187
|
return isLE4 ? numberToBytesLE3(reduced, fieldLen) : numberToBytesBE3(reduced, fieldLen);
|
|
50168
50188
|
}
|
|
50169
50189
|
|
|
@@ -50569,7 +50589,7 @@ ${indent}}` : "}";
|
|
|
50569
50589
|
}
|
|
50570
50590
|
|
|
50571
50591
|
// node_modules/.pnpm/@noble+curves@2.0.0/node_modules/@noble/curves/abstract/weierstrass.js
|
|
50572
|
-
var divNearest2 = (
|
|
50592
|
+
var divNearest2 = (num2, den) => (num2 + (num2 >= 0 ? den : -den) / _2n11) / den;
|
|
50573
50593
|
function _splitEndoScalar(k, basis, n) {
|
|
50574
50594
|
const [[a1, b1], [a2, b2]] = basis;
|
|
50575
50595
|
const c1 = divNearest2(b2 * k, n);
|
|
@@ -50669,11 +50689,11 @@ ${indent}}` : "}";
|
|
|
50669
50689
|
// - add zero byte if exists
|
|
50670
50690
|
// - if next byte doesn't have a flag, leading zero is not allowed (minimal encoding)
|
|
50671
50691
|
_int: {
|
|
50672
|
-
encode(
|
|
50692
|
+
encode(num2) {
|
|
50673
50693
|
const { Err: E } = DER3;
|
|
50674
|
-
if (
|
|
50694
|
+
if (num2 < _0n15)
|
|
50675
50695
|
throw new E("integer: negative integers are not allowed");
|
|
50676
|
-
let hex = numberToHexUnpadded3(
|
|
50696
|
+
let hex = numberToHexUnpadded3(num2);
|
|
50677
50697
|
if (Number.parseInt(hex[0], 16) & 8)
|
|
50678
50698
|
hex = "00" + hex;
|
|
50679
50699
|
if (hex.length & 1)
|
|
@@ -51157,8 +51177,8 @@ ${indent}}` : "}";
|
|
|
51157
51177
|
const lengths = Object.assign(getWLengths(Point3.Fp, Fn), { seed: getMinHashLength3(Fn.ORDER) });
|
|
51158
51178
|
function isValidSecretKey(secretKey) {
|
|
51159
51179
|
try {
|
|
51160
|
-
const
|
|
51161
|
-
return Fn.isValidNot0(
|
|
51180
|
+
const num2 = Fn.fromBytes(secretKey);
|
|
51181
|
+
return Fn.isValidNot0(num2);
|
|
51162
51182
|
} catch (error2) {
|
|
51163
51183
|
return false;
|
|
51164
51184
|
}
|
|
@@ -51234,10 +51254,10 @@ ${indent}}` : "}";
|
|
|
51234
51254
|
const HALF = CURVE_ORDER3 >> _1n15;
|
|
51235
51255
|
return number3 > HALF;
|
|
51236
51256
|
}
|
|
51237
|
-
function validateRS(title,
|
|
51238
|
-
if (!Fn.isValidNot0(
|
|
51257
|
+
function validateRS(title, num2) {
|
|
51258
|
+
if (!Fn.isValidNot0(num2))
|
|
51239
51259
|
throw new Error(`invalid signature ${title}: out of range 1..Point.Fn.ORDER`);
|
|
51240
|
-
return
|
|
51260
|
+
return num2;
|
|
51241
51261
|
}
|
|
51242
51262
|
function assertSmallCofactor() {
|
|
51243
51263
|
if (hasLargeCofactor)
|
|
@@ -51335,17 +51355,17 @@ ${indent}}` : "}";
|
|
|
51335
51355
|
const bits2int3 = ecdsaOpts.bits2int || function bits2int_def(bytes3) {
|
|
51336
51356
|
if (bytes3.length > 8192)
|
|
51337
51357
|
throw new Error("input is too large");
|
|
51338
|
-
const
|
|
51358
|
+
const num2 = bytesToNumberBE3(bytes3);
|
|
51339
51359
|
const delta = bytes3.length * 8 - fnBits;
|
|
51340
|
-
return delta > 0 ?
|
|
51360
|
+
return delta > 0 ? num2 >> BigInt(delta) : num2;
|
|
51341
51361
|
};
|
|
51342
51362
|
const bits2int_modN = ecdsaOpts.bits2int_modN || function bits2int_modN_def(bytes3) {
|
|
51343
51363
|
return Fn.create(bits2int3(bytes3));
|
|
51344
51364
|
};
|
|
51345
51365
|
const ORDER_MASK = bitMask3(fnBits);
|
|
51346
|
-
function int2octets(
|
|
51347
|
-
aInRange("num < 2^" + fnBits,
|
|
51348
|
-
return Fn.toBytes(
|
|
51366
|
+
function int2octets(num2) {
|
|
51367
|
+
aInRange("num < 2^" + fnBits, num2, _0n15, ORDER_MASK);
|
|
51368
|
+
return Fn.toBytes(num2);
|
|
51349
51369
|
}
|
|
51350
51370
|
function validateMsgAndHash(message, prehash) {
|
|
51351
51371
|
abytes3(message, void 0, "message");
|
|
@@ -51712,8 +51732,8 @@ ${indent}}` : "}";
|
|
|
51712
51732
|
while (bytes3[0] === 0)
|
|
51713
51733
|
bytes3 = bytes3.subarray(1);
|
|
51714
51734
|
const delta = bytes3.length * 8 - nBitLength2;
|
|
51715
|
-
const
|
|
51716
|
-
return delta > 0 ?
|
|
51735
|
+
const num2 = bytesToNumberBE3(bytes3);
|
|
51736
|
+
return delta > 0 ? num2 >> BigInt(delta) : num2;
|
|
51717
51737
|
}
|
|
51718
51738
|
function hex0xToBytes2(hex) {
|
|
51719
51739
|
if (typeof hex === "string") {
|
|
@@ -53786,11 +53806,12 @@ ${indent}}` : "}";
|
|
|
53786
53806
|
return rewards.sort((a, b) => b.endDate.getTime() - a.endDate.getTime());
|
|
53787
53807
|
}
|
|
53788
53808
|
};
|
|
53809
|
+
var VESU_REWARDS_CONTRACT = ContractAddr.from("0x0387f3eb1d98632fbe3440a9f1385Aec9d87b6172491d3Dd81f1c35A7c61048F");
|
|
53789
53810
|
var VesuHarvests = class _VesuHarvests extends Harvests {
|
|
53790
53811
|
async getHarvests(addr) {
|
|
53791
53812
|
const result = await fetch(`https://api.vesu.xyz/users/${addr.address}/strk-rewards/calldata`);
|
|
53792
53813
|
const data = await result.json();
|
|
53793
|
-
const rewardsContract =
|
|
53814
|
+
const rewardsContract = VESU_REWARDS_CONTRACT;
|
|
53794
53815
|
const cls = await this.config.provider.getClassAt(rewardsContract.address);
|
|
53795
53816
|
const contract = new Contract(cls.abi, rewardsContract.address, this.config.provider);
|
|
53796
53817
|
const _claimed_amount = await contract.call("amount_already_claimed", [addr.address]);
|
|
@@ -65440,8 +65461,8 @@ ${indent}}` : "}";
|
|
|
65440
65461
|
upperTick: _EkuboCLVault.i129ToNumber(result.bounds.upper)
|
|
65441
65462
|
};
|
|
65442
65463
|
}
|
|
65443
|
-
static div2Power128(
|
|
65444
|
-
return Number(BigInt(
|
|
65464
|
+
static div2Power128(num2) {
|
|
65465
|
+
return Number(BigInt(num2.toString()) * BigInt(1e18) / BigInt(2 ** 128)) / 1e18;
|
|
65445
65466
|
}
|
|
65446
65467
|
static priceToTick(price, isRoundDown, tickSpacing) {
|
|
65447
65468
|
const value = isRoundDown ? Math.floor(Math.log(price) / Math.log(1.000001)) : Math.ceil(Math.log(price) / Math.log(1.000001));
|
|
@@ -66148,14 +66169,31 @@ ${indent}}` : "}";
|
|
|
66148
66169
|
name: "Ekubo",
|
|
66149
66170
|
logo: "https://app.ekubo.org/favicon.ico"
|
|
66150
66171
|
};
|
|
66151
|
-
var
|
|
66152
|
-
{ type: "Smart Contract Risk" /* SMART_CONTRACT_RISK */, value:
|
|
66153
|
-
{ type: "Impermanent Loss Risk" /* IMPERMANENT_LOSS */, value:
|
|
66154
|
-
{ type: "Market Risk" /* MARKET_RISK */, value:
|
|
66172
|
+
var _corelatedPoolRiskFactors = [
|
|
66173
|
+
{ type: "Smart Contract Risk" /* SMART_CONTRACT_RISK */, value: 2 /* WELL_AUDITED */, weight: 34, reason: "Audited smart contracts" },
|
|
66174
|
+
{ type: "Impermanent Loss Risk" /* IMPERMANENT_LOSS */, value: 1 /* HIGHLY_CORRELATED */, weight: 33, reason: "Low risk due to co-related assets" },
|
|
66175
|
+
{ type: "Market Risk" /* MARKET_RISK */, value: 1 /* VERY_LOW_VOLATILITY */, weight: 33, reason: "Low risk due to co-related assets" }
|
|
66176
|
+
];
|
|
66177
|
+
var mediumVolatilityPoolRiskFactors = [
|
|
66178
|
+
{ type: "Smart Contract Risk" /* SMART_CONTRACT_RISK */, value: 2 /* WELL_AUDITED */, weight: 34, reason: "Audited smart contracts" },
|
|
66179
|
+
{ type: "Impermanent Loss Risk" /* IMPERMANENT_LOSS */, value: 3 /* NON_CORRELATED */, weight: 33, reason: "Low risk due to co-related assets" },
|
|
66180
|
+
{ type: "Market Risk" /* MARKET_RISK */, value: 3 /* MODERATE_VOLATILITY */, weight: 33, reason: "Low risk due to co-related assets" }
|
|
66155
66181
|
];
|
|
66156
|
-
var
|
|
66157
|
-
{ type: "Smart Contract Risk" /* SMART_CONTRACT_RISK */, value:
|
|
66182
|
+
var highVolatilityPoolRiskFactors = [
|
|
66183
|
+
{ type: "Smart Contract Risk" /* SMART_CONTRACT_RISK */, value: 2 /* WELL_AUDITED */, weight: 34, reason: "Audited smart contracts" },
|
|
66184
|
+
{ type: "Impermanent Loss Risk" /* IMPERMANENT_LOSS */, value: 3 /* NON_CORRELATED */, weight: 33, reason: "Low risk due to co-related assets" },
|
|
66185
|
+
{ type: "Market Risk" /* MARKET_RISK */, value: 4 /* HIGH_VOLATILITY */, weight: 33, reason: "Low risk due to co-related assets" }
|
|
66158
66186
|
];
|
|
66187
|
+
var mediumRisk = {
|
|
66188
|
+
riskFactor: mediumVolatilityPoolRiskFactors,
|
|
66189
|
+
netRisk: mediumVolatilityPoolRiskFactors.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / mediumVolatilityPoolRiskFactors.reduce((acc, curr) => acc + curr.weight, 0),
|
|
66190
|
+
notARisks: getNoRiskTags(mediumVolatilityPoolRiskFactors)
|
|
66191
|
+
};
|
|
66192
|
+
var highRisk = {
|
|
66193
|
+
riskFactor: highVolatilityPoolRiskFactors,
|
|
66194
|
+
netRisk: highVolatilityPoolRiskFactors.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / highVolatilityPoolRiskFactors.reduce((acc, curr) => acc + curr.weight, 0),
|
|
66195
|
+
notARisks: getNoRiskTags(highVolatilityPoolRiskFactors)
|
|
66196
|
+
};
|
|
66159
66197
|
var AUDIT_URL2 = "https://assets.troves.fi/strkfarm/audit_report_vesu_and_ekubo_strats.pdf";
|
|
66160
66198
|
var faqs2 = [
|
|
66161
66199
|
{
|
|
@@ -66170,6 +66208,10 @@ ${indent}}` : "}";
|
|
|
66170
66208
|
question: "What happens during withdrawal?",
|
|
66171
66209
|
answer: "During withdrawal, you may receive either or both tokens depending on market conditions and prevailing prices."
|
|
66172
66210
|
},
|
|
66211
|
+
{
|
|
66212
|
+
question: "Are there any deposit/withdrawal fees?",
|
|
66213
|
+
answer: "No, there are no deposit/withdrawal fees. However, there is a performance fee varying between 10-20% of the fees and rewards generated. The exact fee is determined by the strategy and the APY shown is net of this fee."
|
|
66214
|
+
},
|
|
66173
66215
|
{
|
|
66174
66216
|
question: "Is the strategy audited?",
|
|
66175
66217
|
answer: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
|
|
@@ -66204,9 +66246,9 @@ ${indent}}` : "}";
|
|
|
66204
66246
|
auditUrl: AUDIT_URL2,
|
|
66205
66247
|
maxTVL: Web3Number.fromWei("0", 18),
|
|
66206
66248
|
risk: {
|
|
66207
|
-
riskFactor:
|
|
66208
|
-
netRisk:
|
|
66209
|
-
notARisks: getNoRiskTags(
|
|
66249
|
+
riskFactor: _corelatedPoolRiskFactors,
|
|
66250
|
+
netRisk: _corelatedPoolRiskFactors.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _corelatedPoolRiskFactors.reduce((acc, curr) => acc + curr.weight, 0),
|
|
66251
|
+
notARisks: getNoRiskTags(_corelatedPoolRiskFactors)
|
|
66210
66252
|
},
|
|
66211
66253
|
apyMethodology: "APY based on 7-day historical performance, including fees and rewards.",
|
|
66212
66254
|
additionalInfo: {
|
|
@@ -66222,7 +66264,8 @@ ${indent}}` : "}";
|
|
|
66222
66264
|
customShouldRebalance: async (currentPrice) => true,
|
|
66223
66265
|
minWaitHours: 24,
|
|
66224
66266
|
direction: "uponly"
|
|
66225
|
-
}
|
|
66267
|
+
},
|
|
66268
|
+
quoteAsset: Global.getDefaultTokens().find((t) => t.symbol === "STRK")
|
|
66226
66269
|
},
|
|
66227
66270
|
faqs: [
|
|
66228
66271
|
...faqs2,
|
|
@@ -66239,68 +66282,165 @@ ${indent}}` : "}";
|
|
|
66239
66282
|
contractDetails: [],
|
|
66240
66283
|
investmentSteps: []
|
|
66241
66284
|
};
|
|
66242
|
-
var
|
|
66243
|
-
xSTRKSTRK,
|
|
66285
|
+
var ETHUSDCRe7Strategy = {
|
|
66286
|
+
...xSTRKSTRK,
|
|
66287
|
+
name: "Ekubo ETH/USDC",
|
|
66288
|
+
description: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, {}),
|
|
66289
|
+
address: ContractAddr.from(
|
|
66290
|
+
"0x160d8fa4569ef6a12e6bf47cb943d7b5ebba8a41a69a14c1d943050ba5ff947"
|
|
66291
|
+
),
|
|
66292
|
+
launchBlock: 1501761,
|
|
66293
|
+
// must be same order as poolKey token0 and token1
|
|
66294
|
+
depositTokens: [
|
|
66295
|
+
Global.getDefaultTokens().find((t) => t.symbol === "ETH"),
|
|
66296
|
+
Global.getDefaultTokens().find((t) => t.symbol === "USDC")
|
|
66297
|
+
],
|
|
66298
|
+
additionalInfo: {
|
|
66299
|
+
newBounds: "Managed by Re7",
|
|
66300
|
+
truePrice: 1,
|
|
66301
|
+
feeBps: 1e3,
|
|
66302
|
+
rebalanceConditions: {
|
|
66303
|
+
customShouldRebalance: async (currentPrice) => currentPrice > 0.99 && currentPrice < 1.01,
|
|
66304
|
+
minWaitHours: 6,
|
|
66305
|
+
direction: "any"
|
|
66306
|
+
},
|
|
66307
|
+
quoteAsset: Global.getDefaultTokens().find((t) => t.symbol === "USDC")
|
|
66308
|
+
},
|
|
66309
|
+
faqs: [
|
|
66310
|
+
...faqs2,
|
|
66311
|
+
{
|
|
66312
|
+
question: "Who is the curator of this strategy?",
|
|
66313
|
+
answer: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
|
|
66314
|
+
"Re7 Labs is the curator of this strategy. Re7 Labs is a well-known Web3 asset management firm. This strategy is completely managed by them, including ownership of the vault. Troves is developer of the smart contracts and maintains infrastructure to help users access these strategies. You can find more information about them on their website ",
|
|
66315
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("a", { href: "https://www.re7labs.xyz", style: { textDecoration: "underline", marginLeft: "2px" }, target: "_blank", children: "here" }),
|
|
66316
|
+
"."
|
|
66317
|
+
] })
|
|
66318
|
+
}
|
|
66319
|
+
],
|
|
66320
|
+
risk: highRisk,
|
|
66321
|
+
points: [],
|
|
66322
|
+
curator: { name: "Re7 Labs", logo: "https://www.re7labs.xyz/favicon.ico" }
|
|
66323
|
+
};
|
|
66324
|
+
var RE7Strategies = [
|
|
66325
|
+
ETHUSDCRe7Strategy,
|
|
66244
66326
|
{
|
|
66245
|
-
...
|
|
66327
|
+
...ETHUSDCRe7Strategy,
|
|
66246
66328
|
name: "Ekubo USDC/USDT",
|
|
66247
66329
|
description: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, {}),
|
|
66248
66330
|
address: ContractAddr.from(
|
|
66249
|
-
"
|
|
66331
|
+
"0x3a4f8debaf12af97bb911099bc011d63d6c208d4c5ba8e15d7f437785b0aaa2"
|
|
66250
66332
|
),
|
|
66251
|
-
launchBlock:
|
|
66333
|
+
launchBlock: 1501761,
|
|
66252
66334
|
// must be same order as poolKey token0 and token1
|
|
66253
66335
|
depositTokens: [
|
|
66254
66336
|
Global.getDefaultTokens().find((t) => t.symbol === "USDC"),
|
|
66255
66337
|
Global.getDefaultTokens().find((t) => t.symbol === "USDT")
|
|
66256
66338
|
],
|
|
66257
|
-
|
|
66258
|
-
newBounds: {
|
|
66259
|
-
lower: -1,
|
|
66260
|
-
upper: 1
|
|
66261
|
-
},
|
|
66262
|
-
truePrice: 1,
|
|
66263
|
-
feeBps: 1e3,
|
|
66264
|
-
rebalanceConditions: {
|
|
66265
|
-
customShouldRebalance: async (currentPrice) => currentPrice > 0.99 && currentPrice < 1.01,
|
|
66266
|
-
minWaitHours: 6,
|
|
66267
|
-
direction: "any"
|
|
66268
|
-
}
|
|
66269
|
-
}
|
|
66339
|
+
risk: xSTRKSTRK.risk
|
|
66270
66340
|
},
|
|
66271
66341
|
{
|
|
66272
|
-
...
|
|
66342
|
+
...ETHUSDCRe7Strategy,
|
|
66273
66343
|
name: "Ekubo STRK/USDC",
|
|
66274
66344
|
description: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, {}),
|
|
66275
66345
|
address: ContractAddr.from(
|
|
66276
|
-
"
|
|
66346
|
+
"0x351b36d0d9d8b40010658825adeeddb1397436cd41acd0ff6c6e23aaa8b5b30"
|
|
66277
66347
|
),
|
|
66278
|
-
launchBlock:
|
|
66348
|
+
launchBlock: 1501762,
|
|
66279
66349
|
// must be same order as poolKey token0 and token1
|
|
66280
66350
|
depositTokens: [
|
|
66281
66351
|
Global.getDefaultTokens().find((t) => t.symbol === "STRK"),
|
|
66282
66352
|
Global.getDefaultTokens().find((t) => t.symbol === "USDC")
|
|
66283
66353
|
],
|
|
66284
|
-
|
|
66285
|
-
|
|
66286
|
-
|
|
66287
|
-
|
|
66288
|
-
|
|
66289
|
-
|
|
66290
|
-
|
|
66291
|
-
|
|
66292
|
-
|
|
66293
|
-
|
|
66354
|
+
risk: highRisk
|
|
66355
|
+
},
|
|
66356
|
+
{
|
|
66357
|
+
...ETHUSDCRe7Strategy,
|
|
66358
|
+
name: "Ekubo STRK/ETH",
|
|
66359
|
+
description: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, {}),
|
|
66360
|
+
address: ContractAddr.from(
|
|
66361
|
+
"0x4ce3024b0ee879009112d7b0e073f8a87153dd35b029347d4247ffe48d28f51"
|
|
66362
|
+
),
|
|
66363
|
+
launchBlock: 1501763,
|
|
66364
|
+
// must be same order as poolKey token0 and token1
|
|
66365
|
+
depositTokens: [
|
|
66366
|
+
Global.getDefaultTokens().find((t) => t.symbol === "STRK"),
|
|
66367
|
+
Global.getDefaultTokens().find((t) => t.symbol === "ETH")
|
|
66368
|
+
],
|
|
66369
|
+
risk: highRisk
|
|
66370
|
+
},
|
|
66371
|
+
{
|
|
66372
|
+
...ETHUSDCRe7Strategy,
|
|
66373
|
+
name: "Ekubo WBTC/USDC",
|
|
66374
|
+
description: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, {}),
|
|
66375
|
+
address: ContractAddr.from(
|
|
66376
|
+
"0x2bcaef2eb7706875a5fdc6853dd961a0590f850bc3a031c59887189b5e84ba1"
|
|
66377
|
+
),
|
|
66378
|
+
launchBlock: 1501764,
|
|
66379
|
+
// must be same order as poolKey token0 and token1
|
|
66380
|
+
depositTokens: [
|
|
66381
|
+
Global.getDefaultTokens().find((t) => t.symbol === "WBTC"),
|
|
66382
|
+
Global.getDefaultTokens().find((t) => t.symbol === "USDC")
|
|
66383
|
+
],
|
|
66384
|
+
risk: mediumRisk
|
|
66385
|
+
},
|
|
66386
|
+
{
|
|
66387
|
+
...ETHUSDCRe7Strategy,
|
|
66388
|
+
name: "Ekubo tBTC/USDC",
|
|
66389
|
+
description: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, {}),
|
|
66390
|
+
address: ContractAddr.from(
|
|
66391
|
+
"0x4aad891a2d4432fba06b6558631bb13f6bbd7f6f33ab8c3111e344889ea4456"
|
|
66392
|
+
),
|
|
66393
|
+
launchBlock: 1501764,
|
|
66394
|
+
// must be same order as poolKey token0 and token1
|
|
66395
|
+
depositTokens: [
|
|
66396
|
+
Global.getDefaultTokens().find((t) => t.symbol === "tBTC"),
|
|
66397
|
+
Global.getDefaultTokens().find((t) => t.symbol === "USDC")
|
|
66398
|
+
],
|
|
66399
|
+
risk: mediumRisk
|
|
66400
|
+
},
|
|
66401
|
+
{
|
|
66402
|
+
...ETHUSDCRe7Strategy,
|
|
66403
|
+
name: "Ekubo WBTC/ETH",
|
|
66404
|
+
description: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, {}),
|
|
66405
|
+
address: ContractAddr.from(
|
|
66406
|
+
"0x1c9232b8186d9317652f05055615f18a120c2ad9e5ee96c39e031c257fb945b"
|
|
66407
|
+
),
|
|
66408
|
+
launchBlock: 1501765,
|
|
66409
|
+
// must be same order as poolKey token0 and token1
|
|
66410
|
+
depositTokens: [
|
|
66411
|
+
Global.getDefaultTokens().find((t) => t.symbol === "WBTC"),
|
|
66412
|
+
Global.getDefaultTokens().find((t) => t.symbol === "ETH")
|
|
66413
|
+
],
|
|
66414
|
+
risk: mediumRisk
|
|
66415
|
+
},
|
|
66416
|
+
{
|
|
66417
|
+
...ETHUSDCRe7Strategy,
|
|
66418
|
+
name: "Ekubo WBTC/STRK",
|
|
66419
|
+
description: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, {}),
|
|
66420
|
+
address: ContractAddr.from(
|
|
66421
|
+
"0x1248e385c23a929a015ec298a26560fa7745bbd6e41a886550e337b02714b1b"
|
|
66422
|
+
),
|
|
66423
|
+
launchBlock: 1501766,
|
|
66424
|
+
// must be same order as poolKey token0 and token1
|
|
66425
|
+
depositTokens: [
|
|
66426
|
+
Global.getDefaultTokens().find((t) => t.symbol === "WBTC"),
|
|
66427
|
+
Global.getDefaultTokens().find((t) => t.symbol === "STRK")
|
|
66428
|
+
],
|
|
66429
|
+
risk: highRisk
|
|
66294
66430
|
}
|
|
66295
66431
|
];
|
|
66432
|
+
var EkuboCLVaultStrategies = [
|
|
66433
|
+
xSTRKSTRK,
|
|
66434
|
+
...RE7Strategies
|
|
66435
|
+
];
|
|
66296
66436
|
EkuboCLVaultStrategies.forEach((s) => {
|
|
66297
66437
|
s.contractDetails = [
|
|
66298
66438
|
{
|
|
66299
66439
|
address: s.address,
|
|
66300
66440
|
name: "Vault",
|
|
66301
66441
|
sourceCodeUrl: "https://github.com/strkfarm/strkfarm-contracts/tree/main/src/strategies/cl_vault"
|
|
66302
|
-
}
|
|
66303
|
-
...COMMON_CONTRACTS
|
|
66442
|
+
}
|
|
66443
|
+
// ...COMMON_CONTRACTS
|
|
66304
66444
|
];
|
|
66305
66445
|
s.docs = "https://docs.troves.fi/p/ekubo-cl-vaults";
|
|
66306
66446
|
s.description = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
|
|
@@ -68268,7 +68408,7 @@ ${indent}}` : "}";
|
|
|
68268
68408
|
name: "Endur",
|
|
68269
68409
|
logo: "https://app.endur.fi/logo.png"
|
|
68270
68410
|
};
|
|
68271
|
-
var
|
|
68411
|
+
var _riskFactor2 = [
|
|
68272
68412
|
{ type: "Smart Contract Risk" /* SMART_CONTRACT_RISK */, value: 0.5, weight: 25, reason: "Audited by CSC" },
|
|
68273
68413
|
{ type: "Depeg Risk" /* DEPEG_RISK */, value: 0.25, weight: 25, reason: "Depending on prevailing market conditions and trading activity, xSTRK may lose its peg to the underlying asset." },
|
|
68274
68414
|
{ type: "Liquidation Risk" /* LIQUIDATION_RISK */, value: 0.1, weight: 10, reason: "Liquidation risk is low due to the nature of the Re7 Pool on Vesu" },
|
|
@@ -68343,9 +68483,9 @@ ${indent}}` : "}";
|
|
|
68343
68483
|
protocols: [endurProtocol, vesuProtocol],
|
|
68344
68484
|
maxTVL: new Web3Number("1500000", 18),
|
|
68345
68485
|
risk: {
|
|
68346
|
-
riskFactor:
|
|
68347
|
-
netRisk:
|
|
68348
|
-
notARisks: getNoRiskTags(
|
|
68486
|
+
riskFactor: _riskFactor2,
|
|
68487
|
+
netRisk: _riskFactor2.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor2.reduce((acc, curr) => acc + curr.weight, 0),
|
|
68488
|
+
notARisks: getNoRiskTags(_riskFactor2)
|
|
68349
68489
|
},
|
|
68350
68490
|
additionalInfo: {
|
|
68351
68491
|
mainToken: Global.getDefaultTokens().find((t) => t.symbol === "STRK"),
|
|
@@ -68369,7 +68509,9 @@ ${indent}}` : "}";
|
|
|
68369
68509
|
];
|
|
68370
68510
|
|
|
68371
68511
|
// src/strategies/universal-adapters/adapter-utils.ts
|
|
68372
|
-
var SIMPLE_SANITIZER = ContractAddr.from("
|
|
68512
|
+
var SIMPLE_SANITIZER = ContractAddr.from("0x5a2e3ceb3da368b983a8717898427ab7b6daf04014b70f321e777f9aad940b4");
|
|
68513
|
+
var PRICE_ROUTER = ContractAddr.from("0x05e83Fa38D791d2dba8E6f487758A9687FfEe191A6Cf8a6c5761ab0a110DB837");
|
|
68514
|
+
var AVNU_MIDDLEWARE = ContractAddr.from("0x4a7972ed3f5d1e74a6d6c4a8f467666953d081c8f2270390cc169d50d17cb0d");
|
|
68373
68515
|
function toBigInt3(value) {
|
|
68374
68516
|
if (typeof value === "string") {
|
|
68375
68517
|
return BigInt(value);
|
|
@@ -68512,6 +68654,66 @@ ${indent}}` : "}";
|
|
|
68512
68654
|
};
|
|
68513
68655
|
};
|
|
68514
68656
|
}
|
|
68657
|
+
getAvnuAdapter(fromToken, toToken, id) {
|
|
68658
|
+
return () => ({
|
|
68659
|
+
leaf: this.constructSimpleLeafData({
|
|
68660
|
+
id,
|
|
68661
|
+
target: AVNU_MIDDLEWARE,
|
|
68662
|
+
method: "multi_route_swap",
|
|
68663
|
+
packedArguments: [
|
|
68664
|
+
fromToken.toBigInt(),
|
|
68665
|
+
toToken.toBigInt(),
|
|
68666
|
+
this.config.vaultAllocator.toBigInt()
|
|
68667
|
+
]
|
|
68668
|
+
}),
|
|
68669
|
+
callConstructor: this.getAvnuCall(fromToken, toToken).bind(this)
|
|
68670
|
+
});
|
|
68671
|
+
}
|
|
68672
|
+
getAvnuCall(fromToken, toToken) {
|
|
68673
|
+
return (params) => {
|
|
68674
|
+
return {
|
|
68675
|
+
sanitizer: SIMPLE_SANITIZER,
|
|
68676
|
+
call: {
|
|
68677
|
+
contractAddress: AVNU_MIDDLEWARE,
|
|
68678
|
+
selector: hash_exports.getSelectorFromName("multi_route_swap"),
|
|
68679
|
+
calldata: [
|
|
68680
|
+
fromToken.toBigInt(),
|
|
68681
|
+
// sell_token_address
|
|
68682
|
+
toBigInt3(params.props.token_from_amount.low.toString()),
|
|
68683
|
+
// sell_token_amount low
|
|
68684
|
+
toBigInt3(params.props.token_from_amount.high.toString()),
|
|
68685
|
+
// sell_token_amount high
|
|
68686
|
+
toToken.toBigInt(),
|
|
68687
|
+
// buy_token_address
|
|
68688
|
+
toBigInt3(params.props.token_to_amount.low.toString()),
|
|
68689
|
+
// buy_token_amount low
|
|
68690
|
+
toBigInt3(params.props.token_to_amount.high.toString()),
|
|
68691
|
+
// buy_token_amount high
|
|
68692
|
+
toBigInt3(params.props.token_to_min_amount.low.toString()),
|
|
68693
|
+
// buy_token_min_amount low
|
|
68694
|
+
toBigInt3(params.props.token_to_min_amount.high.toString()),
|
|
68695
|
+
// buy_token_min_amount high
|
|
68696
|
+
this.config.vaultAllocator.toBigInt(),
|
|
68697
|
+
// beneficiary
|
|
68698
|
+
toBigInt3(0),
|
|
68699
|
+
// integrator_fee_amount_bps
|
|
68700
|
+
this.config.vaultAllocator.toBigInt(),
|
|
68701
|
+
// integrator_fee_recipient
|
|
68702
|
+
// unpack routes
|
|
68703
|
+
BigInt(params.props.routes.length),
|
|
68704
|
+
...params.props.routes.map((r) => [
|
|
68705
|
+
BigInt(num_exports.hexToDecimalString(r.token_from)),
|
|
68706
|
+
BigInt(num_exports.hexToDecimalString(r.token_to)),
|
|
68707
|
+
BigInt(num_exports.hexToDecimalString(r.exchange_address)),
|
|
68708
|
+
BigInt(r.percent),
|
|
68709
|
+
BigInt(r.additional_swap_params.length),
|
|
68710
|
+
...r.additional_swap_params.map((p) => BigInt(num_exports.hexToDecimalString(p)))
|
|
68711
|
+
]).flat()
|
|
68712
|
+
]
|
|
68713
|
+
}
|
|
68714
|
+
};
|
|
68715
|
+
};
|
|
68716
|
+
}
|
|
68515
68717
|
};
|
|
68516
68718
|
|
|
68517
68719
|
// src/data/vesu-singleton.abi.json
|
|
@@ -70845,6 +71047,40 @@ ${indent}}` : "}";
|
|
|
70845
71047
|
}
|
|
70846
71048
|
};
|
|
70847
71049
|
};
|
|
71050
|
+
this.getDefispringRewardsAdapter = (id) => {
|
|
71051
|
+
return () => {
|
|
71052
|
+
const packedArguments = [];
|
|
71053
|
+
const output3 = {
|
|
71054
|
+
id: BigInt(num_exports.getDecimalString(shortString_exports.encodeShortString(id))),
|
|
71055
|
+
readableId: id,
|
|
71056
|
+
data: [
|
|
71057
|
+
SIMPLE_SANITIZER.toBigInt(),
|
|
71058
|
+
// sanitizer address
|
|
71059
|
+
VESU_REWARDS_CONTRACT.toBigInt(),
|
|
71060
|
+
// contract
|
|
71061
|
+
toBigInt3(hash_exports.getSelectorFromName("claim")),
|
|
71062
|
+
// method name
|
|
71063
|
+
BigInt(packedArguments.length),
|
|
71064
|
+
...packedArguments
|
|
71065
|
+
]
|
|
71066
|
+
};
|
|
71067
|
+
return { leaf: output3, callConstructor: this.getDefiSpringClaimCall().bind(this) };
|
|
71068
|
+
};
|
|
71069
|
+
};
|
|
71070
|
+
this.getDefiSpringClaimCall = () => {
|
|
71071
|
+
return (params) => ({
|
|
71072
|
+
sanitizer: SIMPLE_SANITIZER,
|
|
71073
|
+
call: {
|
|
71074
|
+
contractAddress: VESU_REWARDS_CONTRACT,
|
|
71075
|
+
selector: hash_exports.getSelectorFromName("claim"),
|
|
71076
|
+
calldata: [
|
|
71077
|
+
BigInt(params.amount.toWei()),
|
|
71078
|
+
BigInt(params.proofs.length),
|
|
71079
|
+
...params.proofs.map((proof) => BigInt(num_exports.hexToDecimalString(proof)))
|
|
71080
|
+
]
|
|
71081
|
+
}
|
|
71082
|
+
});
|
|
71083
|
+
};
|
|
70848
71084
|
this.config = config2;
|
|
70849
71085
|
}
|
|
70850
71086
|
static getDefaultModifyPositionCallParams(params) {
|
|
@@ -73471,7 +73707,7 @@ ${indent}}` : "}";
|
|
|
73471
73707
|
const aumToken = vesuAum.plus(balance.amount);
|
|
73472
73708
|
logger.verbose(`${this.getTag()} Actual AUM: ${aumToken}`);
|
|
73473
73709
|
const netAPY = await this.netAPY();
|
|
73474
|
-
const defispringAPY = netAPY.splits.find((s) => s.id === "defispring")?.apy || 0;
|
|
73710
|
+
const defispringAPY = (netAPY.splits.find((s) => s.id === "defispring")?.apy || 0) * 0.8;
|
|
73475
73711
|
if (!defispringAPY) throw new Error("DefiSpring APY not found");
|
|
73476
73712
|
const timeDiff = Math.round(Date.now() / 1e3) - Number(lastReportTime);
|
|
73477
73713
|
const growthRate = timeDiff * defispringAPY / (365 * 24 * 60 * 60);
|
|
@@ -73714,6 +73950,51 @@ ${indent}}` : "}";
|
|
|
73714
73950
|
const manageCall = this.getManageCall(["approve_bring_liquidity" /* APPROVE_BRING_LIQUIDITY */, "bring_liquidity" /* BRING_LIQUIDITY */], [manageCall1, manageCall2]);
|
|
73715
73951
|
return manageCall;
|
|
73716
73952
|
}
|
|
73953
|
+
async getHarvestCall() {
|
|
73954
|
+
const vesuHarvest = new VesuHarvests(this.config);
|
|
73955
|
+
const harvestInfo = await vesuHarvest.getUnHarvestedRewards(this.metadata.additionalInfo.vaultAllocator);
|
|
73956
|
+
if (harvestInfo.length != 1) {
|
|
73957
|
+
throw new Error(`Expected 1 harvest info, got ${harvestInfo.length}`);
|
|
73958
|
+
}
|
|
73959
|
+
const amount = harvestInfo[0].claim.amount;
|
|
73960
|
+
const actualReward = harvestInfo[0].actualReward;
|
|
73961
|
+
const proofs = harvestInfo[0].proof;
|
|
73962
|
+
if (actualReward.isZero()) {
|
|
73963
|
+
throw new Error(`Expected non-zero actual reward, got ${harvestInfo[0].actualReward}`);
|
|
73964
|
+
}
|
|
73965
|
+
const manage1Info = this.getProofs("defispring_rewards" /* DEFISPRING_REWARDS */);
|
|
73966
|
+
const manageCall1 = manage1Info.callConstructor({
|
|
73967
|
+
amount,
|
|
73968
|
+
proofs
|
|
73969
|
+
});
|
|
73970
|
+
const proofIds = ["defispring_rewards" /* DEFISPRING_REWARDS */];
|
|
73971
|
+
const manageCalls = [manageCall1];
|
|
73972
|
+
const STRK2 = Global.getDefaultTokens().find((t) => t.symbol === "STRK");
|
|
73973
|
+
if (this.asset().symbol != "STRK") {
|
|
73974
|
+
const manage2Info = this.getProofs("approve_swap_token1" /* APPROVE_SWAP_TOKEN1 */);
|
|
73975
|
+
const manageCall2 = manage2Info.callConstructor({
|
|
73976
|
+
amount: actualReward
|
|
73977
|
+
});
|
|
73978
|
+
const avnuModule = new AvnuWrapper();
|
|
73979
|
+
const quote = await avnuModule.getQuotes(
|
|
73980
|
+
STRK2.address.address,
|
|
73981
|
+
this.asset().address.address,
|
|
73982
|
+
actualReward.toWei(),
|
|
73983
|
+
this.address.address
|
|
73984
|
+
);
|
|
73985
|
+
const swapInfo = await avnuModule.getSwapInfo(quote, this.address.address, 0, this.address.address);
|
|
73986
|
+
const manage3Info = this.getProofs("avnu_swap_rewards" /* AVNU_SWAP_REWARDS */);
|
|
73987
|
+
const manageCall3 = manage3Info.callConstructor({
|
|
73988
|
+
props: swapInfo
|
|
73989
|
+
});
|
|
73990
|
+
proofIds.push("approve_swap_token1" /* APPROVE_SWAP_TOKEN1 */);
|
|
73991
|
+
proofIds.push("avnu_swap_rewards" /* AVNU_SWAP_REWARDS */);
|
|
73992
|
+
manageCalls.push(manageCall2);
|
|
73993
|
+
manageCalls.push(manageCall3);
|
|
73994
|
+
}
|
|
73995
|
+
const manageCall = this.getManageCall(proofIds, manageCalls);
|
|
73996
|
+
return { call: manageCall, reward: actualReward, tokenInfo: STRK2 };
|
|
73997
|
+
}
|
|
73717
73998
|
async getRebalanceCall(params) {
|
|
73718
73999
|
let callSet1 = this.getVesuModifyPositionCalls({
|
|
73719
74000
|
isLeg1: true,
|
|
@@ -73750,6 +74031,9 @@ ${indent}}` : "}";
|
|
|
73750
74031
|
UNIVERSAL_MANAGE_IDS2["APPROVE_TOKEN2"] = "approve_token2";
|
|
73751
74032
|
UNIVERSAL_MANAGE_IDS2["APPROVE_BRING_LIQUIDITY"] = "approve_bring_liquidity";
|
|
73752
74033
|
UNIVERSAL_MANAGE_IDS2["BRING_LIQUIDITY"] = "bring_liquidity";
|
|
74034
|
+
UNIVERSAL_MANAGE_IDS2["DEFISPRING_REWARDS"] = "defispring_rewards";
|
|
74035
|
+
UNIVERSAL_MANAGE_IDS2["APPROVE_SWAP_TOKEN1"] = "approve_swap_token1";
|
|
74036
|
+
UNIVERSAL_MANAGE_IDS2["AVNU_SWAP_REWARDS"] = "avnu_swap_rewards";
|
|
73753
74037
|
return UNIVERSAL_MANAGE_IDS2;
|
|
73754
74038
|
})(UNIVERSAL_MANAGE_IDS || {});
|
|
73755
74039
|
var UNIVERSAL_ADAPTERS = /* @__PURE__ */ ((UNIVERSAL_ADAPTERS2) => {
|
|
@@ -73799,9 +74083,13 @@ ${indent}}` : "}";
|
|
|
73799
74083
|
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(ETHToken.address, vesuAdapterETHUSDC.VESU_SINGLETON, "approve_token2" /* APPROVE_TOKEN2 */).bind(commonAdapter));
|
|
73800
74084
|
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(USDCToken.address, vaultSettings.vaultAddress, "approve_bring_liquidity" /* APPROVE_BRING_LIQUIDITY */).bind(commonAdapter));
|
|
73801
74085
|
vaultSettings.leafAdapters.push(commonAdapter.getBringLiquidityAdapter("bring_liquidity" /* BRING_LIQUIDITY */).bind(commonAdapter));
|
|
74086
|
+
vaultSettings.leafAdapters.push(vesuAdapterUSDCETH.getDefispringRewardsAdapter("defispring_rewards" /* DEFISPRING_REWARDS */).bind(vesuAdapterUSDCETH));
|
|
74087
|
+
const STRKToken = Global.getDefaultTokens().find((token) => token.symbol === "STRK");
|
|
74088
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(STRKToken.address, AVNU_MIDDLEWARE, "approve_swap_token1" /* APPROVE_SWAP_TOKEN1 */).bind(commonAdapter));
|
|
74089
|
+
vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(STRKToken.address, USDCToken.address, "avnu_swap_rewards" /* AVNU_SWAP_REWARDS */).bind(commonAdapter));
|
|
73802
74090
|
return vaultSettings;
|
|
73803
74091
|
}
|
|
73804
|
-
var
|
|
74092
|
+
var _riskFactor3 = [
|
|
73805
74093
|
{ type: "Smart Contract Risk" /* SMART_CONTRACT_RISK */, value: 0.5, weight: 25, reason: "Audited by Zellic" },
|
|
73806
74094
|
{ type: "Liquidation Risk" /* LIQUIDATION_RISK */, value: 1.5, weight: 50, reason: "Liquidation risk is mitigated by stable price feed on Starknet" },
|
|
73807
74095
|
{ type: "Technical Risk" /* TECHNICAL_RISK */, value: 1, weight: 50, reason: "Technical failures like risk monitoring failures" }
|
|
@@ -74005,9 +74293,9 @@ ${indent}}` : "}";
|
|
|
74005
74293
|
depositTokens: [Global.getDefaultTokens().find((token) => token.symbol === "USDC")],
|
|
74006
74294
|
additionalInfo: getLooperSettings("USDC", "ETH", usdcVaultSettings, VesuPools.Genesis, VesuPools.Genesis),
|
|
74007
74295
|
risk: {
|
|
74008
|
-
riskFactor:
|
|
74009
|
-
netRisk:
|
|
74010
|
-
notARisks: getNoRiskTags(
|
|
74296
|
+
riskFactor: _riskFactor3,
|
|
74297
|
+
netRisk: _riskFactor3.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor3.reduce((acc, curr) => acc + curr.weight, 0),
|
|
74298
|
+
notARisks: getNoRiskTags(_riskFactor3)
|
|
74011
74299
|
},
|
|
74012
74300
|
protocols: [Protocols.VESU],
|
|
74013
74301
|
maxTVL: Web3Number.fromWei(0, 6),
|
|
@@ -74024,9 +74312,9 @@ ${indent}}` : "}";
|
|
|
74024
74312
|
depositTokens: [Global.getDefaultTokens().find((token) => token.symbol === "WBTC")],
|
|
74025
74313
|
additionalInfo: getLooperSettings("WBTC", "ETH", wbtcVaultSettings, VesuPools.Genesis, VesuPools.Genesis),
|
|
74026
74314
|
risk: {
|
|
74027
|
-
riskFactor:
|
|
74028
|
-
netRisk:
|
|
74029
|
-
notARisks: getNoRiskTags(
|
|
74315
|
+
riskFactor: _riskFactor3,
|
|
74316
|
+
netRisk: _riskFactor3.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor3.reduce((acc, curr) => acc + curr.weight, 0),
|
|
74317
|
+
notARisks: getNoRiskTags(_riskFactor3)
|
|
74030
74318
|
},
|
|
74031
74319
|
protocols: [Protocols.VESU],
|
|
74032
74320
|
maxTVL: Web3Number.fromWei(0, 8),
|
|
@@ -74043,9 +74331,9 @@ ${indent}}` : "}";
|
|
|
74043
74331
|
depositTokens: [Global.getDefaultTokens().find((token) => token.symbol === "ETH")],
|
|
74044
74332
|
additionalInfo: getLooperSettings("ETH", "WBTC", ethVaultSettings, VesuPools.Genesis, VesuPools.Genesis),
|
|
74045
74333
|
risk: {
|
|
74046
|
-
riskFactor:
|
|
74047
|
-
netRisk:
|
|
74048
|
-
notARisks: getNoRiskTags(
|
|
74334
|
+
riskFactor: _riskFactor3,
|
|
74335
|
+
netRisk: _riskFactor3.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor3.reduce((acc, curr) => acc + curr.weight, 0),
|
|
74336
|
+
notARisks: getNoRiskTags(_riskFactor3)
|
|
74049
74337
|
},
|
|
74050
74338
|
protocols: [Protocols.VESU],
|
|
74051
74339
|
maxTVL: Web3Number.fromWei(0, 18),
|
|
@@ -74062,9 +74350,9 @@ ${indent}}` : "}";
|
|
|
74062
74350
|
depositTokens: [Global.getDefaultTokens().find((token) => token.symbol === "STRK")],
|
|
74063
74351
|
additionalInfo: getLooperSettings("STRK", "ETH", strkVaultSettings, VesuPools.Genesis, VesuPools.Genesis),
|
|
74064
74352
|
risk: {
|
|
74065
|
-
riskFactor:
|
|
74066
|
-
netRisk:
|
|
74067
|
-
notARisks: getNoRiskTags(
|
|
74353
|
+
riskFactor: _riskFactor3,
|
|
74354
|
+
netRisk: _riskFactor3.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor3.reduce((acc, curr) => acc + curr.weight, 0),
|
|
74355
|
+
notARisks: getNoRiskTags(_riskFactor3)
|
|
74068
74356
|
},
|
|
74069
74357
|
protocols: [Protocols.VESU],
|
|
74070
74358
|
maxTVL: Web3Number.fromWei(0, 18),
|
|
@@ -74081,9 +74369,9 @@ ${indent}}` : "}";
|
|
|
74081
74369
|
depositTokens: [Global.getDefaultTokens().find((token) => token.symbol === "USDT")],
|
|
74082
74370
|
additionalInfo: getLooperSettings("USDT", "ETH", usdtVaultSettings, VesuPools.Genesis, VesuPools.Genesis),
|
|
74083
74371
|
risk: {
|
|
74084
|
-
riskFactor:
|
|
74085
|
-
netRisk:
|
|
74086
|
-
notARisks: getNoRiskTags(
|
|
74372
|
+
riskFactor: _riskFactor3,
|
|
74373
|
+
netRisk: _riskFactor3.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor3.reduce((acc, curr) => acc + curr.weight, 0),
|
|
74374
|
+
notARisks: getNoRiskTags(_riskFactor3)
|
|
74087
74375
|
},
|
|
74088
74376
|
protocols: [Protocols.VESU],
|
|
74089
74377
|
maxTVL: Web3Number.fromWei(0, 6),
|