@strkfarm/sdk 1.1.61 → 1.1.62
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 +146 -138
- package/dist/index.browser.mjs +9 -1
- package/dist/index.js +13 -5
- package/dist/index.mjs +9 -1
- package/package.json +1 -1
- package/src/strategies/ekubo-cl-vault.tsx +15 -2
|
@@ -23,11 +23,11 @@ var strkfarm_risk_engine = (() => {
|
|
|
23
23
|
for (var name in all3)
|
|
24
24
|
__defProp(target, name, { get: all3[name], enumerable: true });
|
|
25
25
|
};
|
|
26
|
-
var __copyProps = (to,
|
|
27
|
-
if (
|
|
28
|
-
for (let key of __getOwnPropNames(
|
|
26
|
+
var __copyProps = (to, from2, except, desc) => {
|
|
27
|
+
if (from2 && typeof from2 === "object" || typeof from2 === "function") {
|
|
28
|
+
for (let key of __getOwnPropNames(from2))
|
|
29
29
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
30
|
-
__defProp(to, key, { get: () =>
|
|
30
|
+
__defProp(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc(from2, key)) || desc.enumerable });
|
|
31
31
|
}
|
|
32
32
|
return to;
|
|
33
33
|
};
|
|
@@ -1776,10 +1776,10 @@ var strkfarm_risk_engine = (() => {
|
|
|
1776
1776
|
} else if (indexOf(seen, obj) >= 0) {
|
|
1777
1777
|
return "[Circular]";
|
|
1778
1778
|
}
|
|
1779
|
-
function inspect2(value,
|
|
1780
|
-
if (
|
|
1779
|
+
function inspect2(value, from2, noIndent) {
|
|
1780
|
+
if (from2) {
|
|
1781
1781
|
seen = $arrSlice.call(seen);
|
|
1782
|
-
seen.push(
|
|
1782
|
+
seen.push(from2);
|
|
1783
1783
|
}
|
|
1784
1784
|
if (noIndent) {
|
|
1785
1785
|
var newOpts = {
|
|
@@ -5073,13 +5073,13 @@ var strkfarm_risk_engine = (() => {
|
|
|
5073
5073
|
if (typeof separator !== "string")
|
|
5074
5074
|
throw new Error("join separator should be string");
|
|
5075
5075
|
return {
|
|
5076
|
-
encode: (
|
|
5077
|
-
if (!Array.isArray(
|
|
5076
|
+
encode: (from2) => {
|
|
5077
|
+
if (!Array.isArray(from2) || from2.length && typeof from2[0] !== "string")
|
|
5078
5078
|
throw new Error("join.encode input should be array of strings");
|
|
5079
|
-
for (let i of
|
|
5079
|
+
for (let i of from2)
|
|
5080
5080
|
if (typeof i !== "string")
|
|
5081
5081
|
throw new Error(`join.encode: non-string input=${i}`);
|
|
5082
|
-
return
|
|
5082
|
+
return from2.join(separator);
|
|
5083
5083
|
},
|
|
5084
5084
|
decode: (to) => {
|
|
5085
5085
|
if (typeof to !== "string")
|
|
@@ -5125,12 +5125,12 @@ var strkfarm_risk_engine = (() => {
|
|
|
5125
5125
|
function normalize3(fn) {
|
|
5126
5126
|
if (typeof fn !== "function")
|
|
5127
5127
|
throw new Error("normalize fn should be function");
|
|
5128
|
-
return { encode: (
|
|
5128
|
+
return { encode: (from2) => from2, decode: (to) => fn(to) };
|
|
5129
5129
|
}
|
|
5130
5130
|
// @__NO_SIDE_EFFECTS__
|
|
5131
|
-
function convertRadix(data,
|
|
5132
|
-
if (
|
|
5133
|
-
throw new Error(`convertRadix: wrong from=${
|
|
5131
|
+
function convertRadix(data, from2, to) {
|
|
5132
|
+
if (from2 < 2)
|
|
5133
|
+
throw new Error(`convertRadix: wrong from=${from2}, base cannot be less than 2`);
|
|
5134
5134
|
if (to < 2)
|
|
5135
5135
|
throw new Error(`convertRadix: wrong to=${to}, base cannot be less than 2`);
|
|
5136
5136
|
if (!Array.isArray(data))
|
|
@@ -5142,7 +5142,7 @@ var strkfarm_risk_engine = (() => {
|
|
|
5142
5142
|
const digits = Array.from(data);
|
|
5143
5143
|
digits.forEach((d) => {
|
|
5144
5144
|
/* @__PURE__ */ assertNumber(d);
|
|
5145
|
-
if (d < 0 || d >=
|
|
5145
|
+
if (d < 0 || d >= from2)
|
|
5146
5146
|
throw new Error(`Wrong integer: ${d}`);
|
|
5147
5147
|
});
|
|
5148
5148
|
while (true) {
|
|
@@ -5150,8 +5150,8 @@ var strkfarm_risk_engine = (() => {
|
|
|
5150
5150
|
let done = true;
|
|
5151
5151
|
for (let i = pos; i < digits.length; i++) {
|
|
5152
5152
|
const digit = digits[i];
|
|
5153
|
-
const digitBase =
|
|
5154
|
-
if (!Number.isSafeInteger(digitBase) ||
|
|
5153
|
+
const digitBase = from2 * carry + digit;
|
|
5154
|
+
if (!Number.isSafeInteger(digitBase) || from2 * carry / from2 !== carry || digitBase - digit !== from2 * carry) {
|
|
5155
5155
|
throw new Error("convertRadix: carry overflow");
|
|
5156
5156
|
}
|
|
5157
5157
|
carry = digitBase % to;
|
|
@@ -5175,17 +5175,17 @@ var strkfarm_risk_engine = (() => {
|
|
|
5175
5175
|
return res.reverse();
|
|
5176
5176
|
}
|
|
5177
5177
|
var gcd2 = /* @__NO_SIDE_EFFECTS__ */ (a, b) => !b ? a : /* @__PURE__ */ gcd2(b, a % b);
|
|
5178
|
-
var radix2carry2 = /* @__NO_SIDE_EFFECTS__ */ (
|
|
5178
|
+
var radix2carry2 = /* @__NO_SIDE_EFFECTS__ */ (from2, to) => from2 + (to - /* @__PURE__ */ gcd2(from2, to));
|
|
5179
5179
|
// @__NO_SIDE_EFFECTS__
|
|
5180
|
-
function convertRadix22(data,
|
|
5180
|
+
function convertRadix22(data, from2, to, padding3) {
|
|
5181
5181
|
if (!Array.isArray(data))
|
|
5182
5182
|
throw new Error("convertRadix2: data should be array");
|
|
5183
|
-
if (
|
|
5184
|
-
throw new Error(`convertRadix2: wrong from=${
|
|
5183
|
+
if (from2 <= 0 || from2 > 32)
|
|
5184
|
+
throw new Error(`convertRadix2: wrong from=${from2}`);
|
|
5185
5185
|
if (to <= 0 || to > 32)
|
|
5186
5186
|
throw new Error(`convertRadix2: wrong to=${to}`);
|
|
5187
|
-
if (/* @__PURE__ */ radix2carry2(
|
|
5188
|
-
throw new Error(`convertRadix2: carry overflow from=${
|
|
5187
|
+
if (/* @__PURE__ */ radix2carry2(from2, to) > 32) {
|
|
5188
|
+
throw new Error(`convertRadix2: carry overflow from=${from2} to=${to} carryBits=${/* @__PURE__ */ radix2carry2(from2, to)}`);
|
|
5189
5189
|
}
|
|
5190
5190
|
let carry = 0;
|
|
5191
5191
|
let pos = 0;
|
|
@@ -5193,18 +5193,18 @@ var strkfarm_risk_engine = (() => {
|
|
|
5193
5193
|
const res = [];
|
|
5194
5194
|
for (const n of data) {
|
|
5195
5195
|
/* @__PURE__ */ assertNumber(n);
|
|
5196
|
-
if (n >= 2 **
|
|
5197
|
-
throw new Error(`convertRadix2: invalid data word=${n} from=${
|
|
5198
|
-
carry = carry <<
|
|
5199
|
-
if (pos +
|
|
5200
|
-
throw new Error(`convertRadix2: carry overflow pos=${pos} from=${
|
|
5201
|
-
pos +=
|
|
5196
|
+
if (n >= 2 ** from2)
|
|
5197
|
+
throw new Error(`convertRadix2: invalid data word=${n} from=${from2}`);
|
|
5198
|
+
carry = carry << from2 | n;
|
|
5199
|
+
if (pos + from2 > 32)
|
|
5200
|
+
throw new Error(`convertRadix2: carry overflow pos=${pos} from=${from2}`);
|
|
5201
|
+
pos += from2;
|
|
5202
5202
|
for (; pos >= to; pos -= to)
|
|
5203
5203
|
res.push((carry >> pos - to & mask2) >>> 0);
|
|
5204
5204
|
carry &= 2 ** pos - 1;
|
|
5205
5205
|
}
|
|
5206
5206
|
carry = carry << to - pos & mask2;
|
|
5207
|
-
if (!padding3 && pos >=
|
|
5207
|
+
if (!padding3 && pos >= from2)
|
|
5208
5208
|
throw new Error("Excess padding");
|
|
5209
5209
|
if (!padding3 && carry)
|
|
5210
5210
|
throw new Error(`Non-zero padding: ${carry}`);
|
|
@@ -8424,7 +8424,7 @@ var strkfarm_risk_engine = (() => {
|
|
|
8424
8424
|
function normalizeS(s) {
|
|
8425
8425
|
return isBiggerThanHalfOrder(s) ? modN(-s) : s;
|
|
8426
8426
|
}
|
|
8427
|
-
const slcNum = (b,
|
|
8427
|
+
const slcNum = (b, from2, to) => ut.bytesToNumberBE(b.slice(from2, to));
|
|
8428
8428
|
class Signature3 {
|
|
8429
8429
|
constructor(r, s, recovery) {
|
|
8430
8430
|
this.r = r;
|
|
@@ -10302,7 +10302,7 @@ var strkfarm_risk_engine = (() => {
|
|
|
10302
10302
|
function normalizeS(s) {
|
|
10303
10303
|
return isBiggerThanHalfOrder(s) ? modN(-s) : s;
|
|
10304
10304
|
}
|
|
10305
|
-
const slcNum = (b,
|
|
10305
|
+
const slcNum = (b, from2, to) => ut.bytesToNumberBE(b.slice(from2, to));
|
|
10306
10306
|
class Signature3 {
|
|
10307
10307
|
constructor(r, s, recovery) {
|
|
10308
10308
|
this.r = r;
|
|
@@ -13249,7 +13249,7 @@ ${r2}}` : "}", l2;
|
|
|
13249
13249
|
let op;
|
|
13250
13250
|
let len;
|
|
13251
13251
|
let dist;
|
|
13252
|
-
let
|
|
13252
|
+
let from2;
|
|
13253
13253
|
let from_source;
|
|
13254
13254
|
let input, output;
|
|
13255
13255
|
const state = strm.state;
|
|
@@ -13342,72 +13342,72 @@ ${r2}}` : "}", l2;
|
|
|
13342
13342
|
break top;
|
|
13343
13343
|
}
|
|
13344
13344
|
}
|
|
13345
|
-
|
|
13345
|
+
from2 = 0;
|
|
13346
13346
|
from_source = s_window;
|
|
13347
13347
|
if (wnext === 0) {
|
|
13348
|
-
|
|
13348
|
+
from2 += wsize - op;
|
|
13349
13349
|
if (op < len) {
|
|
13350
13350
|
len -= op;
|
|
13351
13351
|
do {
|
|
13352
|
-
output[_out++] = s_window[
|
|
13352
|
+
output[_out++] = s_window[from2++];
|
|
13353
13353
|
} while (--op);
|
|
13354
|
-
|
|
13354
|
+
from2 = _out - dist;
|
|
13355
13355
|
from_source = output;
|
|
13356
13356
|
}
|
|
13357
13357
|
} else if (wnext < op) {
|
|
13358
|
-
|
|
13358
|
+
from2 += wsize + wnext - op;
|
|
13359
13359
|
op -= wnext;
|
|
13360
13360
|
if (op < len) {
|
|
13361
13361
|
len -= op;
|
|
13362
13362
|
do {
|
|
13363
|
-
output[_out++] = s_window[
|
|
13363
|
+
output[_out++] = s_window[from2++];
|
|
13364
13364
|
} while (--op);
|
|
13365
|
-
|
|
13365
|
+
from2 = 0;
|
|
13366
13366
|
if (wnext < len) {
|
|
13367
13367
|
op = wnext;
|
|
13368
13368
|
len -= op;
|
|
13369
13369
|
do {
|
|
13370
|
-
output[_out++] = s_window[
|
|
13370
|
+
output[_out++] = s_window[from2++];
|
|
13371
13371
|
} while (--op);
|
|
13372
|
-
|
|
13372
|
+
from2 = _out - dist;
|
|
13373
13373
|
from_source = output;
|
|
13374
13374
|
}
|
|
13375
13375
|
}
|
|
13376
13376
|
} else {
|
|
13377
|
-
|
|
13377
|
+
from2 += wnext - op;
|
|
13378
13378
|
if (op < len) {
|
|
13379
13379
|
len -= op;
|
|
13380
13380
|
do {
|
|
13381
|
-
output[_out++] = s_window[
|
|
13381
|
+
output[_out++] = s_window[from2++];
|
|
13382
13382
|
} while (--op);
|
|
13383
|
-
|
|
13383
|
+
from2 = _out - dist;
|
|
13384
13384
|
from_source = output;
|
|
13385
13385
|
}
|
|
13386
13386
|
}
|
|
13387
13387
|
while (len > 2) {
|
|
13388
|
-
output[_out++] = from_source[
|
|
13389
|
-
output[_out++] = from_source[
|
|
13390
|
-
output[_out++] = from_source[
|
|
13388
|
+
output[_out++] = from_source[from2++];
|
|
13389
|
+
output[_out++] = from_source[from2++];
|
|
13390
|
+
output[_out++] = from_source[from2++];
|
|
13391
13391
|
len -= 3;
|
|
13392
13392
|
}
|
|
13393
13393
|
if (len) {
|
|
13394
|
-
output[_out++] = from_source[
|
|
13394
|
+
output[_out++] = from_source[from2++];
|
|
13395
13395
|
if (len > 1) {
|
|
13396
|
-
output[_out++] = from_source[
|
|
13396
|
+
output[_out++] = from_source[from2++];
|
|
13397
13397
|
}
|
|
13398
13398
|
}
|
|
13399
13399
|
} else {
|
|
13400
|
-
|
|
13400
|
+
from2 = _out - dist;
|
|
13401
13401
|
do {
|
|
13402
|
-
output[_out++] = output[
|
|
13403
|
-
output[_out++] = output[
|
|
13404
|
-
output[_out++] = output[
|
|
13402
|
+
output[_out++] = output[from2++];
|
|
13403
|
+
output[_out++] = output[from2++];
|
|
13404
|
+
output[_out++] = output[from2++];
|
|
13405
13405
|
len -= 3;
|
|
13406
13406
|
} while (len > 2);
|
|
13407
13407
|
if (len) {
|
|
13408
|
-
output[_out++] = output[
|
|
13408
|
+
output[_out++] = output[from2++];
|
|
13409
13409
|
if (len > 1) {
|
|
13410
|
-
output[_out++] = output[
|
|
13410
|
+
output[_out++] = output[from2++];
|
|
13411
13411
|
}
|
|
13412
13412
|
}
|
|
13413
13413
|
}
|
|
@@ -14029,7 +14029,7 @@ ${r2}}` : "}", l2;
|
|
|
14029
14029
|
let bits;
|
|
14030
14030
|
let _in, _out;
|
|
14031
14031
|
let copy;
|
|
14032
|
-
let
|
|
14032
|
+
let from2;
|
|
14033
14033
|
let from_source;
|
|
14034
14034
|
let here = 0;
|
|
14035
14035
|
let here_bits, here_op, here_val;
|
|
@@ -14828,9 +14828,9 @@ ${r2}}` : "}", l2;
|
|
|
14828
14828
|
}
|
|
14829
14829
|
if (copy > state.wnext) {
|
|
14830
14830
|
copy -= state.wnext;
|
|
14831
|
-
|
|
14831
|
+
from2 = state.wsize - copy;
|
|
14832
14832
|
} else {
|
|
14833
|
-
|
|
14833
|
+
from2 = state.wnext - copy;
|
|
14834
14834
|
}
|
|
14835
14835
|
if (copy > state.length) {
|
|
14836
14836
|
copy = state.length;
|
|
@@ -14838,7 +14838,7 @@ ${r2}}` : "}", l2;
|
|
|
14838
14838
|
from_source = state.window;
|
|
14839
14839
|
} else {
|
|
14840
14840
|
from_source = output;
|
|
14841
|
-
|
|
14841
|
+
from2 = put - state.offset;
|
|
14842
14842
|
copy = state.length;
|
|
14843
14843
|
}
|
|
14844
14844
|
if (copy > left) {
|
|
@@ -14847,7 +14847,7 @@ ${r2}}` : "}", l2;
|
|
|
14847
14847
|
left -= copy;
|
|
14848
14848
|
state.length -= copy;
|
|
14849
14849
|
do {
|
|
14850
|
-
output[put++] = from_source[
|
|
14850
|
+
output[put++] = from_source[from2++];
|
|
14851
14851
|
} while (--copy);
|
|
14852
14852
|
if (state.length === 0) {
|
|
14853
14853
|
state.mode = LEN2;
|
|
@@ -18870,11 +18870,11 @@ ${r2}}` : "}", l2;
|
|
|
18870
18870
|
for (var name in all3)
|
|
18871
18871
|
__defProp3(target, name, { get: all3[name], enumerable: true });
|
|
18872
18872
|
};
|
|
18873
|
-
var __copyProps3 = (to,
|
|
18874
|
-
if (
|
|
18875
|
-
for (let key of __getOwnPropNames3(
|
|
18873
|
+
var __copyProps3 = (to, from2, except, desc) => {
|
|
18874
|
+
if (from2 && typeof from2 === "object" || typeof from2 === "function") {
|
|
18875
|
+
for (let key of __getOwnPropNames3(from2))
|
|
18876
18876
|
if (!__hasOwnProp3.call(to, key) && key !== except)
|
|
18877
|
-
__defProp3(to, key, { get: () =>
|
|
18877
|
+
__defProp3(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc3(from2, key)) || desc.enumerable });
|
|
18878
18878
|
}
|
|
18879
18879
|
return to;
|
|
18880
18880
|
};
|
|
@@ -19676,11 +19676,11 @@ ${r2}}` : "}", l2;
|
|
|
19676
19676
|
for (var name in all3)
|
|
19677
19677
|
__defProp3(target, name, { get: all3[name], enumerable: true });
|
|
19678
19678
|
};
|
|
19679
|
-
var __copyProps3 = (to,
|
|
19680
|
-
if (
|
|
19681
|
-
for (let key of __getOwnPropNames3(
|
|
19679
|
+
var __copyProps3 = (to, from2, except, desc) => {
|
|
19680
|
+
if (from2 && typeof from2 === "object" || typeof from2 === "function") {
|
|
19681
|
+
for (let key of __getOwnPropNames3(from2))
|
|
19682
19682
|
if (!__hasOwnProp3.call(to, key) && key !== except)
|
|
19683
|
-
__defProp3(to, key, { get: () =>
|
|
19683
|
+
__defProp3(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc3(from2, key)) || desc.enumerable });
|
|
19684
19684
|
}
|
|
19685
19685
|
return to;
|
|
19686
19686
|
};
|
|
@@ -31849,9 +31849,9 @@ ${r2}}` : "}", l2;
|
|
|
31849
31849
|
function join(separator = "") {
|
|
31850
31850
|
astr("join", separator);
|
|
31851
31851
|
return {
|
|
31852
|
-
encode: (
|
|
31853
|
-
astrArr("join.decode",
|
|
31854
|
-
return
|
|
31852
|
+
encode: (from2) => {
|
|
31853
|
+
astrArr("join.decode", from2);
|
|
31854
|
+
return from2.join(separator);
|
|
31855
31855
|
},
|
|
31856
31856
|
decode: (to) => {
|
|
31857
31857
|
astr("join.decode", to);
|
|
@@ -31886,35 +31886,35 @@ ${r2}}` : "}", l2;
|
|
|
31886
31886
|
};
|
|
31887
31887
|
}
|
|
31888
31888
|
var gcd = (a, b) => b === 0 ? a : gcd(b, a % b);
|
|
31889
|
-
var radix2carry = /* @__NO_SIDE_EFFECTS__ */ (
|
|
31889
|
+
var radix2carry = /* @__NO_SIDE_EFFECTS__ */ (from2, to) => from2 + (to - gcd(from2, to));
|
|
31890
31890
|
var powers = /* @__PURE__ */ (() => {
|
|
31891
31891
|
let res = [];
|
|
31892
31892
|
for (let i = 0; i < 40; i++)
|
|
31893
31893
|
res.push(2 ** i);
|
|
31894
31894
|
return res;
|
|
31895
31895
|
})();
|
|
31896
|
-
function convertRadix2(data,
|
|
31896
|
+
function convertRadix2(data, from2, to, padding2) {
|
|
31897
31897
|
aArr(data);
|
|
31898
|
-
if (
|
|
31899
|
-
throw new Error(`convertRadix2: wrong from=${
|
|
31898
|
+
if (from2 <= 0 || from2 > 32)
|
|
31899
|
+
throw new Error(`convertRadix2: wrong from=${from2}`);
|
|
31900
31900
|
if (to <= 0 || to > 32)
|
|
31901
31901
|
throw new Error(`convertRadix2: wrong to=${to}`);
|
|
31902
|
-
if (/* @__PURE__ */ radix2carry(
|
|
31903
|
-
throw new Error(`convertRadix2: carry overflow from=${
|
|
31902
|
+
if (/* @__PURE__ */ radix2carry(from2, to) > 32) {
|
|
31903
|
+
throw new Error(`convertRadix2: carry overflow from=${from2} to=${to} carryBits=${/* @__PURE__ */ radix2carry(from2, to)}`);
|
|
31904
31904
|
}
|
|
31905
31905
|
let carry = 0;
|
|
31906
31906
|
let pos = 0;
|
|
31907
|
-
const max = powers[
|
|
31907
|
+
const max = powers[from2];
|
|
31908
31908
|
const mask2 = powers[to] - 1;
|
|
31909
31909
|
const res = [];
|
|
31910
31910
|
for (const n of data) {
|
|
31911
31911
|
anumber(n);
|
|
31912
31912
|
if (n >= max)
|
|
31913
|
-
throw new Error(`convertRadix2: invalid data word=${n} from=${
|
|
31914
|
-
carry = carry <<
|
|
31915
|
-
if (pos +
|
|
31916
|
-
throw new Error(`convertRadix2: carry overflow pos=${pos} from=${
|
|
31917
|
-
pos +=
|
|
31913
|
+
throw new Error(`convertRadix2: invalid data word=${n} from=${from2}`);
|
|
31914
|
+
carry = carry << from2 | n;
|
|
31915
|
+
if (pos + from2 > 32)
|
|
31916
|
+
throw new Error(`convertRadix2: carry overflow pos=${pos} from=${from2}`);
|
|
31917
|
+
pos += from2;
|
|
31918
31918
|
for (; pos >= to; pos -= to)
|
|
31919
31919
|
res.push((carry >> pos - to & mask2) >>> 0);
|
|
31920
31920
|
const pow3 = powers[pos];
|
|
@@ -31923,7 +31923,7 @@ ${r2}}` : "}", l2;
|
|
|
31923
31923
|
carry &= pow3 - 1;
|
|
31924
31924
|
}
|
|
31925
31925
|
carry = carry << to - pos & mask2;
|
|
31926
|
-
if (!padding2 && pos >=
|
|
31926
|
+
if (!padding2 && pos >= from2)
|
|
31927
31927
|
throw new Error("Excess padding");
|
|
31928
31928
|
if (!padding2 && carry > 0)
|
|
31929
31929
|
throw new Error(`Non-zero padding: ${carry}`);
|
|
@@ -34625,7 +34625,7 @@ ${indent2}}` : "}";
|
|
|
34625
34625
|
function normalizeS(s) {
|
|
34626
34626
|
return isBiggerThanHalfOrder(s) ? modN(-s) : s;
|
|
34627
34627
|
}
|
|
34628
|
-
const slcNum = (b,
|
|
34628
|
+
const slcNum = (b, from2, to) => bytesToNumberBE(b.slice(from2, to));
|
|
34629
34629
|
class Signature3 {
|
|
34630
34630
|
constructor(r, s, recovery) {
|
|
34631
34631
|
this.r = r;
|
|
@@ -37571,7 +37571,7 @@ ${indent2}}` : "}";
|
|
|
37571
37571
|
let op;
|
|
37572
37572
|
let len;
|
|
37573
37573
|
let dist;
|
|
37574
|
-
let
|
|
37574
|
+
let from2;
|
|
37575
37575
|
let from_source;
|
|
37576
37576
|
let input, output;
|
|
37577
37577
|
const state = strm.state;
|
|
@@ -37664,72 +37664,72 @@ ${indent2}}` : "}";
|
|
|
37664
37664
|
break top;
|
|
37665
37665
|
}
|
|
37666
37666
|
}
|
|
37667
|
-
|
|
37667
|
+
from2 = 0;
|
|
37668
37668
|
from_source = s_window;
|
|
37669
37669
|
if (wnext === 0) {
|
|
37670
|
-
|
|
37670
|
+
from2 += wsize - op;
|
|
37671
37671
|
if (op < len) {
|
|
37672
37672
|
len -= op;
|
|
37673
37673
|
do {
|
|
37674
|
-
output[_out++] = s_window[
|
|
37674
|
+
output[_out++] = s_window[from2++];
|
|
37675
37675
|
} while (--op);
|
|
37676
|
-
|
|
37676
|
+
from2 = _out - dist;
|
|
37677
37677
|
from_source = output;
|
|
37678
37678
|
}
|
|
37679
37679
|
} else if (wnext < op) {
|
|
37680
|
-
|
|
37680
|
+
from2 += wsize + wnext - op;
|
|
37681
37681
|
op -= wnext;
|
|
37682
37682
|
if (op < len) {
|
|
37683
37683
|
len -= op;
|
|
37684
37684
|
do {
|
|
37685
|
-
output[_out++] = s_window[
|
|
37685
|
+
output[_out++] = s_window[from2++];
|
|
37686
37686
|
} while (--op);
|
|
37687
|
-
|
|
37687
|
+
from2 = 0;
|
|
37688
37688
|
if (wnext < len) {
|
|
37689
37689
|
op = wnext;
|
|
37690
37690
|
len -= op;
|
|
37691
37691
|
do {
|
|
37692
|
-
output[_out++] = s_window[
|
|
37692
|
+
output[_out++] = s_window[from2++];
|
|
37693
37693
|
} while (--op);
|
|
37694
|
-
|
|
37694
|
+
from2 = _out - dist;
|
|
37695
37695
|
from_source = output;
|
|
37696
37696
|
}
|
|
37697
37697
|
}
|
|
37698
37698
|
} else {
|
|
37699
|
-
|
|
37699
|
+
from2 += wnext - op;
|
|
37700
37700
|
if (op < len) {
|
|
37701
37701
|
len -= op;
|
|
37702
37702
|
do {
|
|
37703
|
-
output[_out++] = s_window[
|
|
37703
|
+
output[_out++] = s_window[from2++];
|
|
37704
37704
|
} while (--op);
|
|
37705
|
-
|
|
37705
|
+
from2 = _out - dist;
|
|
37706
37706
|
from_source = output;
|
|
37707
37707
|
}
|
|
37708
37708
|
}
|
|
37709
37709
|
while (len > 2) {
|
|
37710
|
-
output[_out++] = from_source[
|
|
37711
|
-
output[_out++] = from_source[
|
|
37712
|
-
output[_out++] = from_source[
|
|
37710
|
+
output[_out++] = from_source[from2++];
|
|
37711
|
+
output[_out++] = from_source[from2++];
|
|
37712
|
+
output[_out++] = from_source[from2++];
|
|
37713
37713
|
len -= 3;
|
|
37714
37714
|
}
|
|
37715
37715
|
if (len) {
|
|
37716
|
-
output[_out++] = from_source[
|
|
37716
|
+
output[_out++] = from_source[from2++];
|
|
37717
37717
|
if (len > 1) {
|
|
37718
|
-
output[_out++] = from_source[
|
|
37718
|
+
output[_out++] = from_source[from2++];
|
|
37719
37719
|
}
|
|
37720
37720
|
}
|
|
37721
37721
|
} else {
|
|
37722
|
-
|
|
37722
|
+
from2 = _out - dist;
|
|
37723
37723
|
do {
|
|
37724
|
-
output[_out++] = output[
|
|
37725
|
-
output[_out++] = output[
|
|
37726
|
-
output[_out++] = output[
|
|
37724
|
+
output[_out++] = output[from2++];
|
|
37725
|
+
output[_out++] = output[from2++];
|
|
37726
|
+
output[_out++] = output[from2++];
|
|
37727
37727
|
len -= 3;
|
|
37728
37728
|
} while (len > 2);
|
|
37729
37729
|
if (len) {
|
|
37730
|
-
output[_out++] = output[
|
|
37730
|
+
output[_out++] = output[from2++];
|
|
37731
37731
|
if (len > 1) {
|
|
37732
|
-
output[_out++] = output[
|
|
37732
|
+
output[_out++] = output[from2++];
|
|
37733
37733
|
}
|
|
37734
37734
|
}
|
|
37735
37735
|
}
|
|
@@ -38333,7 +38333,7 @@ ${indent2}}` : "}";
|
|
|
38333
38333
|
let bits;
|
|
38334
38334
|
let _in, _out;
|
|
38335
38335
|
let copy;
|
|
38336
|
-
let
|
|
38336
|
+
let from2;
|
|
38337
38337
|
let from_source;
|
|
38338
38338
|
let here = 0;
|
|
38339
38339
|
let here_bits, here_op, here_val;
|
|
@@ -39132,9 +39132,9 @@ ${indent2}}` : "}";
|
|
|
39132
39132
|
}
|
|
39133
39133
|
if (copy > state.wnext) {
|
|
39134
39134
|
copy -= state.wnext;
|
|
39135
|
-
|
|
39135
|
+
from2 = state.wsize - copy;
|
|
39136
39136
|
} else {
|
|
39137
|
-
|
|
39137
|
+
from2 = state.wnext - copy;
|
|
39138
39138
|
}
|
|
39139
39139
|
if (copy > state.length) {
|
|
39140
39140
|
copy = state.length;
|
|
@@ -39142,7 +39142,7 @@ ${indent2}}` : "}";
|
|
|
39142
39142
|
from_source = state.window;
|
|
39143
39143
|
} else {
|
|
39144
39144
|
from_source = output;
|
|
39145
|
-
|
|
39145
|
+
from2 = put - state.offset;
|
|
39146
39146
|
copy = state.length;
|
|
39147
39147
|
}
|
|
39148
39148
|
if (copy > left) {
|
|
@@ -39151,7 +39151,7 @@ ${indent2}}` : "}";
|
|
|
39151
39151
|
left -= copy;
|
|
39152
39152
|
state.length -= copy;
|
|
39153
39153
|
do {
|
|
39154
|
-
output[put++] = from_source[
|
|
39154
|
+
output[put++] = from_source[from2++];
|
|
39155
39155
|
} while (--copy);
|
|
39156
39156
|
if (state.length === 0) {
|
|
39157
39157
|
state.mode = LEN;
|
|
@@ -39600,11 +39600,11 @@ ${indent2}}` : "}";
|
|
|
39600
39600
|
for (var name in all3)
|
|
39601
39601
|
__defProp2(target, name, { get: all3[name], enumerable: true });
|
|
39602
39602
|
};
|
|
39603
|
-
var __copyProps2 = (to,
|
|
39604
|
-
if (
|
|
39605
|
-
for (let key of __getOwnPropNames2(
|
|
39603
|
+
var __copyProps2 = (to, from2, except, desc) => {
|
|
39604
|
+
if (from2 && typeof from2 === "object" || typeof from2 === "function") {
|
|
39605
|
+
for (let key of __getOwnPropNames2(from2))
|
|
39606
39606
|
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
39607
|
-
__defProp2(to, key, { get: () =>
|
|
39607
|
+
__defProp2(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc2(from2, key)) || desc.enumerable });
|
|
39608
39608
|
}
|
|
39609
39609
|
return to;
|
|
39610
39610
|
};
|
|
@@ -67167,14 +67167,14 @@ ${JSON.stringify(data, null, 2)}`;
|
|
|
67167
67167
|
return { value: op[0] ? op[1] : void 0, done: true };
|
|
67168
67168
|
}
|
|
67169
67169
|
}
|
|
67170
|
-
function __spreadArray(to,
|
|
67171
|
-
if (pack || arguments.length === 2) for (var i = 0, l =
|
|
67172
|
-
if (ar || !(i in
|
|
67173
|
-
if (!ar) ar = Array.prototype.slice.call(
|
|
67174
|
-
ar[i] =
|
|
67170
|
+
function __spreadArray(to, from2, pack) {
|
|
67171
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from2.length, ar; i < l; i++) {
|
|
67172
|
+
if (ar || !(i in from2)) {
|
|
67173
|
+
if (!ar) ar = Array.prototype.slice.call(from2, 0, i);
|
|
67174
|
+
ar[i] = from2[i];
|
|
67175
67175
|
}
|
|
67176
67176
|
}
|
|
67177
|
-
return to.concat(ar || Array.prototype.slice.call(
|
|
67177
|
+
return to.concat(ar || Array.prototype.slice.call(from2));
|
|
67178
67178
|
}
|
|
67179
67179
|
|
|
67180
67180
|
// node_modules/.pnpm/ts-invariant@0.10.3/node_modules/ts-invariant/lib/invariant.js
|
|
@@ -72722,7 +72722,7 @@ spurious results.`);
|
|
|
72722
72722
|
_proto3[SymbolObservable] = function() {
|
|
72723
72723
|
return this;
|
|
72724
72724
|
};
|
|
72725
|
-
Observable2.from = function
|
|
72725
|
+
Observable2.from = function from2(x) {
|
|
72726
72726
|
var C = typeof this === "function" ? this : Observable2;
|
|
72727
72727
|
if (x == null) throw new TypeError(x + " is not an object");
|
|
72728
72728
|
var method = getMethod(x, SymbolObservable);
|
|
@@ -74288,7 +74288,7 @@ spurious results.`);
|
|
|
74288
74288
|
};
|
|
74289
74289
|
ApolloCache2.prototype.watchFragment = function(options) {
|
|
74290
74290
|
var _this = this;
|
|
74291
|
-
var fragment = options.fragment, fragmentName = options.fragmentName,
|
|
74291
|
+
var fragment = options.fragment, fragmentName = options.fragmentName, from2 = options.from, _a21 = options.optimistic, optimistic = _a21 === void 0 ? true : _a21, otherOptions = __rest(options, ["fragment", "fragmentName", "from", "optimistic"]);
|
|
74292
74292
|
var query = this.getFragmentDoc(fragment, fragmentName);
|
|
74293
74293
|
var diffOptions = __assign(__assign({}, otherOptions), { returnPartialData: true, id: (
|
|
74294
74294
|
// While our TypeScript types do not allow for `undefined` as a valid
|
|
@@ -74297,7 +74297,7 @@ spurious results.`);
|
|
|
74297
74297
|
// adding this fix here however to ensure those using plain JavaScript
|
|
74298
74298
|
// and using `cache.identify` themselves will avoid seeing the obscure
|
|
74299
74299
|
// warning.
|
|
74300
|
-
typeof
|
|
74300
|
+
typeof from2 === "undefined" || typeof from2 === "string" ? from2 : this.identify(from2)
|
|
74301
74301
|
), query, optimistic });
|
|
74302
74302
|
var latestDiff;
|
|
74303
74303
|
return new Observable(function(observer) {
|
|
@@ -74608,10 +74608,10 @@ spurious results.`);
|
|
|
74608
74608
|
isReference,
|
|
74609
74609
|
toReference: this.toReference,
|
|
74610
74610
|
canRead: this.canRead,
|
|
74611
|
-
readField: function(fieldNameOrOptions,
|
|
74611
|
+
readField: function(fieldNameOrOptions, from2) {
|
|
74612
74612
|
return _this.policies.readField(typeof fieldNameOrOptions === "string" ? {
|
|
74613
74613
|
fieldName: fieldNameOrOptions,
|
|
74614
|
-
from:
|
|
74614
|
+
from: from2 || makeReference(dataId)
|
|
74615
74615
|
} : fieldNameOrOptions, { store: _this });
|
|
74616
74616
|
}
|
|
74617
74617
|
};
|
|
@@ -75437,8 +75437,8 @@ spurious results.`);
|
|
|
75437
75437
|
function keyFieldsFnFromSpecifier(specifier) {
|
|
75438
75438
|
var info = lookupSpecifierInfo(specifier);
|
|
75439
75439
|
return info.keyFieldsFn || (info.keyFieldsFn = function(object, context) {
|
|
75440
|
-
var extract = function(
|
|
75441
|
-
return context.readField(key,
|
|
75440
|
+
var extract = function(from2, key) {
|
|
75441
|
+
return context.readField(key, from2);
|
|
75442
75442
|
};
|
|
75443
75443
|
var keyObject = context.keyObject = collectSpecifierPaths(specifier, function(schemaKeyPath) {
|
|
75444
75444
|
var extracted = extractKeyPath(
|
|
@@ -75944,7 +75944,7 @@ spurious results.`);
|
|
|
75944
75944
|
};
|
|
75945
75945
|
}
|
|
75946
75946
|
function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables) {
|
|
75947
|
-
var fieldNameOrOptions = readFieldArgs[0],
|
|
75947
|
+
var fieldNameOrOptions = readFieldArgs[0], from2 = readFieldArgs[1], argc = readFieldArgs.length;
|
|
75948
75948
|
var options;
|
|
75949
75949
|
if (typeof fieldNameOrOptions === "string") {
|
|
75950
75950
|
options = {
|
|
@@ -75952,7 +75952,7 @@ spurious results.`);
|
|
|
75952
75952
|
// Default to objectOrReference only when no second argument was
|
|
75953
75953
|
// passed for the from parameter, not when undefined is explicitly
|
|
75954
75954
|
// passed as the second argument.
|
|
75955
|
-
from: argc > 1 ?
|
|
75955
|
+
from: argc > 1 ? from2 : objectOrReference
|
|
75956
75956
|
};
|
|
75957
75957
|
} else {
|
|
75958
75958
|
options = __assign({}, fieldNameOrOptions);
|
|
@@ -76287,8 +76287,8 @@ spurious results.`);
|
|
|
76287
76287
|
getStorageArgs = [isReference(e_1) ? e_1.__ref : e_1];
|
|
76288
76288
|
}
|
|
76289
76289
|
var changedFields_1;
|
|
76290
|
-
var getValue_1 = function(
|
|
76291
|
-
return isArray2(
|
|
76290
|
+
var getValue_1 = function(from2, name) {
|
|
76291
|
+
return isArray2(from2) ? typeof name === "number" ? from2[name] : void 0 : context.store.getFieldValue(from2, String(name));
|
|
76292
76292
|
};
|
|
76293
76293
|
mergeTree.map.forEach(function(childTree, storeFieldName) {
|
|
76294
76294
|
var eVal = getValue_1(e_1, storeFieldName);
|
|
@@ -80178,6 +80178,12 @@ spurious results.`);
|
|
|
80178
80178
|
amount1: availableAmount1.minus(y),
|
|
80179
80179
|
ratio: 0
|
|
80180
80180
|
};
|
|
80181
|
+
} else if (ratio.eq(Infinity)) {
|
|
80182
|
+
return {
|
|
80183
|
+
amount0: availableAmount0,
|
|
80184
|
+
amount1: Web3Number.fromWei("0", availableAmount1.decimals),
|
|
80185
|
+
ratio: Infinity
|
|
80186
|
+
};
|
|
80181
80187
|
}
|
|
80182
80188
|
return {
|
|
80183
80189
|
amount0: availableAmount0.plus(x),
|
|
@@ -80285,6 +80291,7 @@ spurious results.`);
|
|
|
80285
80291
|
// Helper to determine which token to sell, which to buy, and the amounts to use
|
|
80286
80292
|
getSwapParams(expectedAmounts, poolKey, token0Bal, token1Bal) {
|
|
80287
80293
|
const tokenToSell = expectedAmounts.amount0.lessThan(token0Bal) ? poolKey.token0 : poolKey.token1;
|
|
80294
|
+
logger2.verbose(`getSwapParams => tokenToSell: ${tokenToSell.address}, expectedAmounts: ${expectedAmounts.amount0.toString()}, bal0: ${token0Bal.toString()}`);
|
|
80288
80295
|
const tokenToBuy = tokenToSell == poolKey.token0 ? poolKey.token1 : poolKey.token0;
|
|
80289
80296
|
const amountToSell = tokenToSell == poolKey.token0 ? token0Bal.minus(expectedAmounts.amount0) : token1Bal.minus(expectedAmounts.amount1);
|
|
80290
80297
|
if (amountToSell.eq(0)) {
|
|
@@ -80439,6 +80446,7 @@ spurious results.`);
|
|
|
80439
80446
|
throw new Error(`Rebalance failed after ${MAX_SAME_ERROR_COUNT} same errors`);
|
|
80440
80447
|
}
|
|
80441
80448
|
const fromAmount = uint256_exports.uint256ToBN(swapInfo.token_from_amount);
|
|
80449
|
+
const fromTokenInfo = await Global.getTokenInfoFromAddr(ContractAddr.from(swapInfo.token_from_address));
|
|
80442
80450
|
logger2.verbose(
|
|
80443
80451
|
`Selling ${fromAmount.toString()} of token ${swapInfo.token_from_address}`
|
|
80444
80452
|
);
|
|
@@ -80455,7 +80463,7 @@ spurious results.`);
|
|
|
80455
80463
|
`Rebalance attempt ${retry + 1} failed, adjusting swap amount...`
|
|
80456
80464
|
);
|
|
80457
80465
|
const newSwapInfo = { ...swapInfo };
|
|
80458
|
-
const currentAmount = Web3Number.fromWei(fromAmount.toString(),
|
|
80466
|
+
const currentAmount = Web3Number.fromWei(fromAmount.toString(), fromTokenInfo.decimals);
|
|
80459
80467
|
logger2.verbose(`Current amount: ${currentAmount.toString()}, lowerLimit: ${lowerLimit.toString()}, upperLimit: ${upperLimit.toString()}`);
|
|
80460
80468
|
if (err2.message.includes("invalid token0 balance") || err2.message.includes("invalid token0 amount")) {
|
|
80461
80469
|
if (!isSellTokenToken0) {
|
package/dist/index.browser.mjs
CHANGED
|
@@ -16255,6 +16255,12 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16255
16255
|
amount1: availableAmount1.minus(y),
|
|
16256
16256
|
ratio: 0
|
|
16257
16257
|
};
|
|
16258
|
+
} else if (ratio.eq(Infinity)) {
|
|
16259
|
+
return {
|
|
16260
|
+
amount0: availableAmount0,
|
|
16261
|
+
amount1: Web3Number.fromWei("0", availableAmount1.decimals),
|
|
16262
|
+
ratio: Infinity
|
|
16263
|
+
};
|
|
16258
16264
|
}
|
|
16259
16265
|
return {
|
|
16260
16266
|
amount0: availableAmount0.plus(x),
|
|
@@ -16362,6 +16368,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16362
16368
|
// Helper to determine which token to sell, which to buy, and the amounts to use
|
|
16363
16369
|
getSwapParams(expectedAmounts, poolKey, token0Bal, token1Bal) {
|
|
16364
16370
|
const tokenToSell = expectedAmounts.amount0.lessThan(token0Bal) ? poolKey.token0 : poolKey.token1;
|
|
16371
|
+
logger.verbose(`getSwapParams => tokenToSell: ${tokenToSell.address}, expectedAmounts: ${expectedAmounts.amount0.toString()}, bal0: ${token0Bal.toString()}`);
|
|
16365
16372
|
const tokenToBuy = tokenToSell == poolKey.token0 ? poolKey.token1 : poolKey.token0;
|
|
16366
16373
|
const amountToSell = tokenToSell == poolKey.token0 ? token0Bal.minus(expectedAmounts.amount0) : token1Bal.minus(expectedAmounts.amount1);
|
|
16367
16374
|
if (amountToSell.eq(0)) {
|
|
@@ -16516,6 +16523,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16516
16523
|
throw new Error(`Rebalance failed after ${MAX_SAME_ERROR_COUNT} same errors`);
|
|
16517
16524
|
}
|
|
16518
16525
|
const fromAmount = uint2564.uint256ToBN(swapInfo.token_from_amount);
|
|
16526
|
+
const fromTokenInfo = await Global.getTokenInfoFromAddr(ContractAddr.from(swapInfo.token_from_address));
|
|
16519
16527
|
logger.verbose(
|
|
16520
16528
|
`Selling ${fromAmount.toString()} of token ${swapInfo.token_from_address}`
|
|
16521
16529
|
);
|
|
@@ -16532,7 +16540,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16532
16540
|
`Rebalance attempt ${retry + 1} failed, adjusting swap amount...`
|
|
16533
16541
|
);
|
|
16534
16542
|
const newSwapInfo = { ...swapInfo };
|
|
16535
|
-
const currentAmount = Web3Number.fromWei(fromAmount.toString(),
|
|
16543
|
+
const currentAmount = Web3Number.fromWei(fromAmount.toString(), fromTokenInfo.decimals);
|
|
16536
16544
|
logger.verbose(`Current amount: ${currentAmount.toString()}, lowerLimit: ${lowerLimit.toString()}, upperLimit: ${upperLimit.toString()}`);
|
|
16537
16545
|
if (err.message.includes("invalid token0 balance") || err.message.includes("invalid token0 amount")) {
|
|
16538
16546
|
if (!isSellTokenToken0) {
|
package/dist/index.js
CHANGED
|
@@ -9,11 +9,11 @@ var __export = (target, all) => {
|
|
|
9
9
|
for (var name in all)
|
|
10
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
11
|
};
|
|
12
|
-
var __copyProps = (to,
|
|
13
|
-
if (
|
|
14
|
-
for (let key of __getOwnPropNames(
|
|
12
|
+
var __copyProps = (to, from2, except, desc) => {
|
|
13
|
+
if (from2 && typeof from2 === "object" || typeof from2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from2))
|
|
15
15
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () =>
|
|
16
|
+
__defProp(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc(from2, key)) || desc.enumerable });
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
@@ -16255,6 +16255,12 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16255
16255
|
amount1: availableAmount1.minus(y),
|
|
16256
16256
|
ratio: 0
|
|
16257
16257
|
};
|
|
16258
|
+
} else if (ratio.eq(Infinity)) {
|
|
16259
|
+
return {
|
|
16260
|
+
amount0: availableAmount0,
|
|
16261
|
+
amount1: Web3Number.fromWei("0", availableAmount1.decimals),
|
|
16262
|
+
ratio: Infinity
|
|
16263
|
+
};
|
|
16258
16264
|
}
|
|
16259
16265
|
return {
|
|
16260
16266
|
amount0: availableAmount0.plus(x),
|
|
@@ -16362,6 +16368,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16362
16368
|
// Helper to determine which token to sell, which to buy, and the amounts to use
|
|
16363
16369
|
getSwapParams(expectedAmounts, poolKey, token0Bal, token1Bal) {
|
|
16364
16370
|
const tokenToSell = expectedAmounts.amount0.lessThan(token0Bal) ? poolKey.token0 : poolKey.token1;
|
|
16371
|
+
logger.verbose(`getSwapParams => tokenToSell: ${tokenToSell.address}, expectedAmounts: ${expectedAmounts.amount0.toString()}, bal0: ${token0Bal.toString()}`);
|
|
16365
16372
|
const tokenToBuy = tokenToSell == poolKey.token0 ? poolKey.token1 : poolKey.token0;
|
|
16366
16373
|
const amountToSell = tokenToSell == poolKey.token0 ? token0Bal.minus(expectedAmounts.amount0) : token1Bal.minus(expectedAmounts.amount1);
|
|
16367
16374
|
if (amountToSell.eq(0)) {
|
|
@@ -16516,6 +16523,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16516
16523
|
throw new Error(`Rebalance failed after ${MAX_SAME_ERROR_COUNT} same errors`);
|
|
16517
16524
|
}
|
|
16518
16525
|
const fromAmount = import_starknet11.uint256.uint256ToBN(swapInfo.token_from_amount);
|
|
16526
|
+
const fromTokenInfo = await Global.getTokenInfoFromAddr(ContractAddr.from(swapInfo.token_from_address));
|
|
16519
16527
|
logger.verbose(
|
|
16520
16528
|
`Selling ${fromAmount.toString()} of token ${swapInfo.token_from_address}`
|
|
16521
16529
|
);
|
|
@@ -16532,7 +16540,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16532
16540
|
`Rebalance attempt ${retry + 1} failed, adjusting swap amount...`
|
|
16533
16541
|
);
|
|
16534
16542
|
const newSwapInfo = { ...swapInfo };
|
|
16535
|
-
const currentAmount = Web3Number.fromWei(fromAmount.toString(),
|
|
16543
|
+
const currentAmount = Web3Number.fromWei(fromAmount.toString(), fromTokenInfo.decimals);
|
|
16536
16544
|
logger.verbose(`Current amount: ${currentAmount.toString()}, lowerLimit: ${lowerLimit.toString()}, upperLimit: ${upperLimit.toString()}`);
|
|
16537
16545
|
if (err.message.includes("invalid token0 balance") || err.message.includes("invalid token0 amount")) {
|
|
16538
16546
|
if (!isSellTokenToken0) {
|
package/dist/index.mjs
CHANGED
|
@@ -16153,6 +16153,12 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16153
16153
|
amount1: availableAmount1.minus(y),
|
|
16154
16154
|
ratio: 0
|
|
16155
16155
|
};
|
|
16156
|
+
} else if (ratio.eq(Infinity)) {
|
|
16157
|
+
return {
|
|
16158
|
+
amount0: availableAmount0,
|
|
16159
|
+
amount1: Web3Number.fromWei("0", availableAmount1.decimals),
|
|
16160
|
+
ratio: Infinity
|
|
16161
|
+
};
|
|
16156
16162
|
}
|
|
16157
16163
|
return {
|
|
16158
16164
|
amount0: availableAmount0.plus(x),
|
|
@@ -16260,6 +16266,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16260
16266
|
// Helper to determine which token to sell, which to buy, and the amounts to use
|
|
16261
16267
|
getSwapParams(expectedAmounts, poolKey, token0Bal, token1Bal) {
|
|
16262
16268
|
const tokenToSell = expectedAmounts.amount0.lessThan(token0Bal) ? poolKey.token0 : poolKey.token1;
|
|
16269
|
+
logger.verbose(`getSwapParams => tokenToSell: ${tokenToSell.address}, expectedAmounts: ${expectedAmounts.amount0.toString()}, bal0: ${token0Bal.toString()}`);
|
|
16263
16270
|
const tokenToBuy = tokenToSell == poolKey.token0 ? poolKey.token1 : poolKey.token0;
|
|
16264
16271
|
const amountToSell = tokenToSell == poolKey.token0 ? token0Bal.minus(expectedAmounts.amount0) : token1Bal.minus(expectedAmounts.amount1);
|
|
16265
16272
|
if (amountToSell.eq(0)) {
|
|
@@ -16414,6 +16421,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16414
16421
|
throw new Error(`Rebalance failed after ${MAX_SAME_ERROR_COUNT} same errors`);
|
|
16415
16422
|
}
|
|
16416
16423
|
const fromAmount = uint2564.uint256ToBN(swapInfo.token_from_amount);
|
|
16424
|
+
const fromTokenInfo = await Global.getTokenInfoFromAddr(ContractAddr.from(swapInfo.token_from_address));
|
|
16417
16425
|
logger.verbose(
|
|
16418
16426
|
`Selling ${fromAmount.toString()} of token ${swapInfo.token_from_address}`
|
|
16419
16427
|
);
|
|
@@ -16430,7 +16438,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16430
16438
|
`Rebalance attempt ${retry + 1} failed, adjusting swap amount...`
|
|
16431
16439
|
);
|
|
16432
16440
|
const newSwapInfo = { ...swapInfo };
|
|
16433
|
-
const currentAmount = Web3Number.fromWei(fromAmount.toString(),
|
|
16441
|
+
const currentAmount = Web3Number.fromWei(fromAmount.toString(), fromTokenInfo.decimals);
|
|
16434
16442
|
logger.verbose(`Current amount: ${currentAmount.toString()}, lowerLimit: ${lowerLimit.toString()}, upperLimit: ${upperLimit.toString()}`);
|
|
16435
16443
|
if (err.message.includes("invalid token0 balance") || err.message.includes("invalid token0 amount")) {
|
|
16436
16444
|
if (!isSellTokenToken0) {
|
package/package.json
CHANGED
|
@@ -37,7 +37,7 @@ import { EkuboHarvests, HarvestInfo } from "@/modules/harvests";
|
|
|
37
37
|
import { logger } from "@/utils/logger";
|
|
38
38
|
import { COMMON_CONTRACTS } from "./constants";
|
|
39
39
|
import { DepegRiskLevel, ImpermanentLossLevel, MarketRiskLevel, SmartContractRiskLevel } from "@/interfaces/risks";
|
|
40
|
-
import { gql } from "@apollo/client";
|
|
40
|
+
import { from, gql } from "@apollo/client";
|
|
41
41
|
import apolloClient from "@/modules/apollo-client";
|
|
42
42
|
import { binarySearch } from "@/utils/math-utils";
|
|
43
43
|
import { Quote } from "@avnu/avnu-sdk";
|
|
@@ -1032,6 +1032,12 @@ export class EkuboCLVault extends BaseStrategy<
|
|
|
1032
1032
|
amount1: availableAmount1.minus(y),
|
|
1033
1033
|
ratio: 0,
|
|
1034
1034
|
};
|
|
1035
|
+
} else if (ratio.eq(Infinity)) {
|
|
1036
|
+
return {
|
|
1037
|
+
amount0: availableAmount0,
|
|
1038
|
+
amount1: Web3Number.fromWei("0", availableAmount1.decimals),
|
|
1039
|
+
ratio: Infinity,
|
|
1040
|
+
};
|
|
1035
1041
|
}
|
|
1036
1042
|
return {
|
|
1037
1043
|
amount0: availableAmount0.plus(x),
|
|
@@ -1198,6 +1204,7 @@ export class EkuboCLVault extends BaseStrategy<
|
|
|
1198
1204
|
const tokenToSell = expectedAmounts.amount0.lessThan(token0Bal)
|
|
1199
1205
|
? poolKey.token0
|
|
1200
1206
|
: poolKey.token1;
|
|
1207
|
+
logger.verbose(`getSwapParams => tokenToSell: ${tokenToSell.address}, expectedAmounts: ${expectedAmounts.amount0.toString()}, bal0: ${token0Bal.toString()}`);
|
|
1201
1208
|
// The other token is the one to buy
|
|
1202
1209
|
const tokenToBuy =
|
|
1203
1210
|
tokenToSell == poolKey.token0 ? poolKey.token1 : poolKey.token0;
|
|
@@ -1432,6 +1439,7 @@ export class EkuboCLVault extends BaseStrategy<
|
|
|
1432
1439
|
}
|
|
1433
1440
|
|
|
1434
1441
|
const fromAmount = uint256.uint256ToBN(swapInfo.token_from_amount);
|
|
1442
|
+
const fromTokenInfo = await Global.getTokenInfoFromAddr(ContractAddr.from(swapInfo.token_from_address));
|
|
1435
1443
|
logger.verbose(
|
|
1436
1444
|
`Selling ${fromAmount.toString()} of token ${swapInfo.token_from_address}`
|
|
1437
1445
|
);
|
|
@@ -1451,7 +1459,7 @@ export class EkuboCLVault extends BaseStrategy<
|
|
|
1451
1459
|
);
|
|
1452
1460
|
|
|
1453
1461
|
const newSwapInfo = { ...swapInfo };
|
|
1454
|
-
const currentAmount = Web3Number.fromWei(fromAmount.toString(),
|
|
1462
|
+
const currentAmount = Web3Number.fromWei(fromAmount.toString(), fromTokenInfo.decimals);
|
|
1455
1463
|
logger.verbose(`Current amount: ${currentAmount.toString()}, lowerLimit: ${lowerLimit.toString()}, upperLimit: ${upperLimit.toString()}`);
|
|
1456
1464
|
if (
|
|
1457
1465
|
err.message.includes("invalid token0 balance") ||
|
|
@@ -1537,6 +1545,11 @@ export class EkuboCLVault extends BaseStrategy<
|
|
|
1537
1545
|
throw err;
|
|
1538
1546
|
}
|
|
1539
1547
|
newSwapInfo.token_to_min_amount = uint256.bnToUint256("0");
|
|
1548
|
+
|
|
1549
|
+
// if (uint256.uint256ToBN(newSwapInfo.token_from_amount) == fromAmount && sameErrorCount.error == 'loop-stuck') {
|
|
1550
|
+
// logger.error("Swap amount did not change, cannot proceed");
|
|
1551
|
+
// sameErrorCount = { count: MAX_SAME_ERROR_COUNT, error: null };
|
|
1552
|
+
// }
|
|
1540
1553
|
return this.rebalanceIter(
|
|
1541
1554
|
newSwapInfo,
|
|
1542
1555
|
acc,
|