@strkfarm/sdk 1.1.60 → 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.
@@ -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, from, except, desc) => {
27
- if (from && typeof from === "object" || typeof from === "function") {
28
- for (let key of __getOwnPropNames(from))
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: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
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, from, noIndent) {
1780
- if (from) {
1779
+ function inspect2(value, from2, noIndent) {
1780
+ if (from2) {
1781
1781
  seen = $arrSlice.call(seen);
1782
- seen.push(from);
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: (from) => {
5077
- if (!Array.isArray(from) || from.length && typeof from[0] !== "string")
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 from)
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 from.join(separator);
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: (from) => from, decode: (to) => fn(to) };
5128
+ return { encode: (from2) => from2, decode: (to) => fn(to) };
5129
5129
  }
5130
5130
  // @__NO_SIDE_EFFECTS__
5131
- function convertRadix(data, from, to) {
5132
- if (from < 2)
5133
- throw new Error(`convertRadix: wrong from=${from}, base cannot be less than 2`);
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 >= from)
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 = from * carry + digit;
5154
- if (!Number.isSafeInteger(digitBase) || from * carry / from !== carry || digitBase - digit !== from * carry) {
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__ */ (from, to) => from + (to - /* @__PURE__ */ gcd2(from, to));
5178
+ var radix2carry2 = /* @__NO_SIDE_EFFECTS__ */ (from2, to) => from2 + (to - /* @__PURE__ */ gcd2(from2, to));
5179
5179
  // @__NO_SIDE_EFFECTS__
5180
- function convertRadix22(data, from, to, padding3) {
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 (from <= 0 || from > 32)
5184
- throw new Error(`convertRadix2: wrong from=${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(from, to) > 32) {
5188
- throw new Error(`convertRadix2: carry overflow from=${from} to=${to} carryBits=${/* @__PURE__ */ radix2carry2(from, to)}`);
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 ** from)
5197
- throw new Error(`convertRadix2: invalid data word=${n} from=${from}`);
5198
- carry = carry << from | n;
5199
- if (pos + from > 32)
5200
- throw new Error(`convertRadix2: carry overflow pos=${pos} from=${from}`);
5201
- pos += from;
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 >= from)
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, from, to) => ut.bytesToNumberBE(b.slice(from, to));
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, from, to) => ut.bytesToNumberBE(b.slice(from, to));
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 from;
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
- from = 0;
13345
+ from2 = 0;
13346
13346
  from_source = s_window;
13347
13347
  if (wnext === 0) {
13348
- from += wsize - op;
13348
+ from2 += wsize - op;
13349
13349
  if (op < len) {
13350
13350
  len -= op;
13351
13351
  do {
13352
- output[_out++] = s_window[from++];
13352
+ output[_out++] = s_window[from2++];
13353
13353
  } while (--op);
13354
- from = _out - dist;
13354
+ from2 = _out - dist;
13355
13355
  from_source = output;
13356
13356
  }
13357
13357
  } else if (wnext < op) {
13358
- from += wsize + wnext - op;
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[from++];
13363
+ output[_out++] = s_window[from2++];
13364
13364
  } while (--op);
13365
- from = 0;
13365
+ from2 = 0;
13366
13366
  if (wnext < len) {
13367
13367
  op = wnext;
13368
13368
  len -= op;
13369
13369
  do {
13370
- output[_out++] = s_window[from++];
13370
+ output[_out++] = s_window[from2++];
13371
13371
  } while (--op);
13372
- from = _out - dist;
13372
+ from2 = _out - dist;
13373
13373
  from_source = output;
13374
13374
  }
13375
13375
  }
13376
13376
  } else {
13377
- from += wnext - op;
13377
+ from2 += wnext - op;
13378
13378
  if (op < len) {
13379
13379
  len -= op;
13380
13380
  do {
13381
- output[_out++] = s_window[from++];
13381
+ output[_out++] = s_window[from2++];
13382
13382
  } while (--op);
13383
- from = _out - dist;
13383
+ from2 = _out - dist;
13384
13384
  from_source = output;
13385
13385
  }
13386
13386
  }
13387
13387
  while (len > 2) {
13388
- output[_out++] = from_source[from++];
13389
- output[_out++] = from_source[from++];
13390
- output[_out++] = from_source[from++];
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[from++];
13394
+ output[_out++] = from_source[from2++];
13395
13395
  if (len > 1) {
13396
- output[_out++] = from_source[from++];
13396
+ output[_out++] = from_source[from2++];
13397
13397
  }
13398
13398
  }
13399
13399
  } else {
13400
- from = _out - dist;
13400
+ from2 = _out - dist;
13401
13401
  do {
13402
- output[_out++] = output[from++];
13403
- output[_out++] = output[from++];
13404
- output[_out++] = output[from++];
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[from++];
13408
+ output[_out++] = output[from2++];
13409
13409
  if (len > 1) {
13410
- output[_out++] = output[from++];
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 from;
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
- from = state.wsize - copy;
14831
+ from2 = state.wsize - copy;
14832
14832
  } else {
14833
- from = state.wnext - copy;
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
- from = put - state.offset;
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[from++];
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, from, except, desc) => {
18874
- if (from && typeof from === "object" || typeof from === "function") {
18875
- for (let key of __getOwnPropNames3(from))
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: () => from[key], enumerable: !(desc = __getOwnPropDesc3(from, key)) || desc.enumerable });
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, from, except, desc) => {
19680
- if (from && typeof from === "object" || typeof from === "function") {
19681
- for (let key of __getOwnPropNames3(from))
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: () => from[key], enumerable: !(desc = __getOwnPropDesc3(from, key)) || desc.enumerable });
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: (from) => {
31853
- astrArr("join.decode", from);
31854
- return from.join(separator);
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__ */ (from, to) => from + (to - gcd(from, to));
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, from, to, padding2) {
31896
+ function convertRadix2(data, from2, to, padding2) {
31897
31897
  aArr(data);
31898
- if (from <= 0 || from > 32)
31899
- throw new Error(`convertRadix2: wrong from=${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(from, to) > 32) {
31903
- throw new Error(`convertRadix2: carry overflow from=${from} to=${to} carryBits=${/* @__PURE__ */ radix2carry(from, to)}`);
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[from];
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=${from}`);
31914
- carry = carry << from | n;
31915
- if (pos + from > 32)
31916
- throw new Error(`convertRadix2: carry overflow pos=${pos} from=${from}`);
31917
- pos += from;
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 >= from)
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, from, to) => bytesToNumberBE(b.slice(from, to));
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 from;
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
- from = 0;
37667
+ from2 = 0;
37668
37668
  from_source = s_window;
37669
37669
  if (wnext === 0) {
37670
- from += wsize - op;
37670
+ from2 += wsize - op;
37671
37671
  if (op < len) {
37672
37672
  len -= op;
37673
37673
  do {
37674
- output[_out++] = s_window[from++];
37674
+ output[_out++] = s_window[from2++];
37675
37675
  } while (--op);
37676
- from = _out - dist;
37676
+ from2 = _out - dist;
37677
37677
  from_source = output;
37678
37678
  }
37679
37679
  } else if (wnext < op) {
37680
- from += wsize + wnext - op;
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[from++];
37685
+ output[_out++] = s_window[from2++];
37686
37686
  } while (--op);
37687
- from = 0;
37687
+ from2 = 0;
37688
37688
  if (wnext < len) {
37689
37689
  op = wnext;
37690
37690
  len -= op;
37691
37691
  do {
37692
- output[_out++] = s_window[from++];
37692
+ output[_out++] = s_window[from2++];
37693
37693
  } while (--op);
37694
- from = _out - dist;
37694
+ from2 = _out - dist;
37695
37695
  from_source = output;
37696
37696
  }
37697
37697
  }
37698
37698
  } else {
37699
- from += wnext - op;
37699
+ from2 += wnext - op;
37700
37700
  if (op < len) {
37701
37701
  len -= op;
37702
37702
  do {
37703
- output[_out++] = s_window[from++];
37703
+ output[_out++] = s_window[from2++];
37704
37704
  } while (--op);
37705
- from = _out - dist;
37705
+ from2 = _out - dist;
37706
37706
  from_source = output;
37707
37707
  }
37708
37708
  }
37709
37709
  while (len > 2) {
37710
- output[_out++] = from_source[from++];
37711
- output[_out++] = from_source[from++];
37712
- output[_out++] = from_source[from++];
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[from++];
37716
+ output[_out++] = from_source[from2++];
37717
37717
  if (len > 1) {
37718
- output[_out++] = from_source[from++];
37718
+ output[_out++] = from_source[from2++];
37719
37719
  }
37720
37720
  }
37721
37721
  } else {
37722
- from = _out - dist;
37722
+ from2 = _out - dist;
37723
37723
  do {
37724
- output[_out++] = output[from++];
37725
- output[_out++] = output[from++];
37726
- output[_out++] = output[from++];
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[from++];
37730
+ output[_out++] = output[from2++];
37731
37731
  if (len > 1) {
37732
- output[_out++] = output[from++];
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 from;
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
- from = state.wsize - copy;
39135
+ from2 = state.wsize - copy;
39136
39136
  } else {
39137
- from = state.wnext - copy;
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
- from = put - state.offset;
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[from++];
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, from, except, desc) => {
39604
- if (from && typeof from === "object" || typeof from === "function") {
39605
- for (let key of __getOwnPropNames2(from))
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: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
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, from, pack) {
67171
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
67172
- if (ar || !(i in from)) {
67173
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
67174
- ar[i] = from[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(from));
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 from(x) {
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, from = options.from, _a21 = options.optimistic, optimistic = _a21 === void 0 ? true : _a21, otherOptions = __rest(options, ["fragment", "fragmentName", "from", "optimistic"]);
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 from === "undefined" || typeof from === "string" ? from : this.identify(from)
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, from) {
74611
+ readField: function(fieldNameOrOptions, from2) {
74612
74612
  return _this.policies.readField(typeof fieldNameOrOptions === "string" ? {
74613
74613
  fieldName: fieldNameOrOptions,
74614
- from: from || makeReference(dataId)
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(from, key) {
75441
- return context.readField(key, from);
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], from = readFieldArgs[1], argc = readFieldArgs.length;
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 ? from : objectOrReference
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(from, name) {
76291
- return isArray2(from) ? typeof name === "number" ? from[name] : void 0 : context.store.getFieldValue(from, String(name));
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)) {
@@ -80424,14 +80431,22 @@ spurious results.`);
80424
80431
  * @param retry - Current retry attempt number (default 0)
80425
80432
  * @param adjustmentFactor - Percentage to adjust swap amount by (default 1)
80426
80433
  * @param isToken0Deficit - Whether token0 balance needs increasing (default true)
80434
+ * @param MAX_RETRIES - Maximum number of retries (default 40)
80435
+ * @param sameErrorCount - For certain errors, we just retry with same amount again. This is the count of such retries (default { count: 0, error: null })
80436
+ * @param MAX_SAME_ERROR_COUNT - For certain errors, we just retry with same amount again. This limits such retries (default 10)
80427
80437
  * @returns Array of contract calls needed for rebalancing
80428
- * @throws Error if max retries reached without successful rebalance
80438
+ * @throws Error if max retries reached without successful rebalance or max same errors reached
80429
80439
  */
80430
- async rebalanceIter(swapInfo, acc, estimateCall, isSellTokenToken0 = true, retry = 0, lowerLimit = 0n, upperLimit = 0n, MAX_RETRIES = 40) {
80440
+ async rebalanceIter(swapInfo, acc, estimateCall, isSellTokenToken0 = true, retry = 0, lowerLimit = 0n, upperLimit = 0n, MAX_RETRIES = 40, sameErrorCount = { count: 0, error: null }, MAX_SAME_ERROR_COUNT = 10) {
80431
80441
  logger2.verbose(
80432
- `Rebalancing ${this.metadata.name}: retry=${retry}, lowerLimit=${lowerLimit}, upperLimit=${upperLimit}, isSellTokenToken0=${isSellTokenToken0}`
80442
+ `Rebalancing ${this.metadata.name}: retry=${retry}, lowerLimit=${lowerLimit}, upperLimit=${upperLimit}, isSellTokenToken0=${isSellTokenToken0}, MAX_RETRIES=${MAX_RETRIES}, sameErrorCount=${sameErrorCount.error} (${sameErrorCount.count})`
80433
80443
  );
80444
+ if (sameErrorCount.count >= MAX_SAME_ERROR_COUNT) {
80445
+ logger2.error(`Rebalance failed after ${MAX_SAME_ERROR_COUNT} same errors`);
80446
+ throw new Error(`Rebalance failed after ${MAX_SAME_ERROR_COUNT} same errors`);
80447
+ }
80434
80448
  const fromAmount = uint256_exports.uint256ToBN(swapInfo.token_from_amount);
80449
+ const fromTokenInfo = await Global.getTokenInfoFromAddr(ContractAddr.from(swapInfo.token_from_address));
80435
80450
  logger2.verbose(
80436
80451
  `Selling ${fromAmount.toString()} of token ${swapInfo.token_from_address}`
80437
80452
  );
@@ -80448,8 +80463,8 @@ spurious results.`);
80448
80463
  `Rebalance attempt ${retry + 1} failed, adjusting swap amount...`
80449
80464
  );
80450
80465
  const newSwapInfo = { ...swapInfo };
80451
- const currentAmount = Web3Number.fromWei(fromAmount.toString(), 18);
80452
- logger2.verbose(`Current amount: ${currentAmount.toString()}`);
80466
+ const currentAmount = Web3Number.fromWei(fromAmount.toString(), fromTokenInfo.decimals);
80467
+ logger2.verbose(`Current amount: ${currentAmount.toString()}, lowerLimit: ${lowerLimit.toString()}, upperLimit: ${upperLimit.toString()}`);
80453
80468
  if (err2.message.includes("invalid token0 balance") || err2.message.includes("invalid token0 amount")) {
80454
80469
  if (!isSellTokenToken0) {
80455
80470
  logger2.verbose("Reducing swap amount - excess token0");
@@ -80496,6 +80511,30 @@ spurious results.`);
80496
80511
  }
80497
80512
  newSwapInfo.token_from_amount = uint256_exports.bnToUint256(nextAmount);
80498
80513
  }
80514
+ } else if (err2.message.includes("Residual tokens")) {
80515
+ logger2.error("Residual tokens");
80516
+ if (sameErrorCount.error == "Residual tokens") {
80517
+ sameErrorCount.count++;
80518
+ } else {
80519
+ sameErrorCount.error = "Residual tokens";
80520
+ sameErrorCount.count = 1;
80521
+ }
80522
+ } else if (err2.message.includes("Insufficient tokens received")) {
80523
+ logger2.error("Insufficient tokens received");
80524
+ if (sameErrorCount.error == "Insufficient tokens received") {
80525
+ sameErrorCount.count++;
80526
+ } else {
80527
+ sameErrorCount.error = "Insufficient tokens received";
80528
+ sameErrorCount.count = 1;
80529
+ }
80530
+ } else if (err2.message.includes("Could not reach the end of the program")) {
80531
+ logger2.error("Could not reach the end of the program, may be the block is full (could be a temp/permanent gas issue)");
80532
+ if (sameErrorCount.error == "Could not reach the end of the program") {
80533
+ sameErrorCount.count++;
80534
+ } else {
80535
+ sameErrorCount.error = "Could not reach the end of the program";
80536
+ sameErrorCount.count = 1;
80537
+ }
80499
80538
  } else {
80500
80539
  logger2.error("Unexpected error:", err2);
80501
80540
  throw err2;
@@ -80508,7 +80547,10 @@ spurious results.`);
80508
80547
  isSellTokenToken0,
80509
80548
  retry + 1,
80510
80549
  lowerLimit,
80511
- upperLimit
80550
+ upperLimit,
80551
+ MAX_RETRIES,
80552
+ sameErrorCount,
80553
+ MAX_SAME_ERROR_COUNT
80512
80554
  );
80513
80555
  }
80514
80556
  }
@@ -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)) {
@@ -16501,14 +16508,22 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
16501
16508
  * @param retry - Current retry attempt number (default 0)
16502
16509
  * @param adjustmentFactor - Percentage to adjust swap amount by (default 1)
16503
16510
  * @param isToken0Deficit - Whether token0 balance needs increasing (default true)
16511
+ * @param MAX_RETRIES - Maximum number of retries (default 40)
16512
+ * @param sameErrorCount - For certain errors, we just retry with same amount again. This is the count of such retries (default { count: 0, error: null })
16513
+ * @param MAX_SAME_ERROR_COUNT - For certain errors, we just retry with same amount again. This limits such retries (default 10)
16504
16514
  * @returns Array of contract calls needed for rebalancing
16505
- * @throws Error if max retries reached without successful rebalance
16515
+ * @throws Error if max retries reached without successful rebalance or max same errors reached
16506
16516
  */
16507
- async rebalanceIter(swapInfo, acc, estimateCall, isSellTokenToken0 = true, retry = 0, lowerLimit = 0n, upperLimit = 0n, MAX_RETRIES = 40) {
16517
+ async rebalanceIter(swapInfo, acc, estimateCall, isSellTokenToken0 = true, retry = 0, lowerLimit = 0n, upperLimit = 0n, MAX_RETRIES = 40, sameErrorCount = { count: 0, error: null }, MAX_SAME_ERROR_COUNT = 10) {
16508
16518
  logger.verbose(
16509
- `Rebalancing ${this.metadata.name}: retry=${retry}, lowerLimit=${lowerLimit}, upperLimit=${upperLimit}, isSellTokenToken0=${isSellTokenToken0}`
16519
+ `Rebalancing ${this.metadata.name}: retry=${retry}, lowerLimit=${lowerLimit}, upperLimit=${upperLimit}, isSellTokenToken0=${isSellTokenToken0}, MAX_RETRIES=${MAX_RETRIES}, sameErrorCount=${sameErrorCount.error} (${sameErrorCount.count})`
16510
16520
  );
16521
+ if (sameErrorCount.count >= MAX_SAME_ERROR_COUNT) {
16522
+ logger.error(`Rebalance failed after ${MAX_SAME_ERROR_COUNT} same errors`);
16523
+ throw new Error(`Rebalance failed after ${MAX_SAME_ERROR_COUNT} same errors`);
16524
+ }
16511
16525
  const fromAmount = uint2564.uint256ToBN(swapInfo.token_from_amount);
16526
+ const fromTokenInfo = await Global.getTokenInfoFromAddr(ContractAddr.from(swapInfo.token_from_address));
16512
16527
  logger.verbose(
16513
16528
  `Selling ${fromAmount.toString()} of token ${swapInfo.token_from_address}`
16514
16529
  );
@@ -16525,8 +16540,8 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
16525
16540
  `Rebalance attempt ${retry + 1} failed, adjusting swap amount...`
16526
16541
  );
16527
16542
  const newSwapInfo = { ...swapInfo };
16528
- const currentAmount = Web3Number.fromWei(fromAmount.toString(), 18);
16529
- logger.verbose(`Current amount: ${currentAmount.toString()}`);
16543
+ const currentAmount = Web3Number.fromWei(fromAmount.toString(), fromTokenInfo.decimals);
16544
+ logger.verbose(`Current amount: ${currentAmount.toString()}, lowerLimit: ${lowerLimit.toString()}, upperLimit: ${upperLimit.toString()}`);
16530
16545
  if (err.message.includes("invalid token0 balance") || err.message.includes("invalid token0 amount")) {
16531
16546
  if (!isSellTokenToken0) {
16532
16547
  logger.verbose("Reducing swap amount - excess token0");
@@ -16573,6 +16588,30 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
16573
16588
  }
16574
16589
  newSwapInfo.token_from_amount = uint2564.bnToUint256(nextAmount);
16575
16590
  }
16591
+ } else if (err.message.includes("Residual tokens")) {
16592
+ logger.error("Residual tokens");
16593
+ if (sameErrorCount.error == "Residual tokens") {
16594
+ sameErrorCount.count++;
16595
+ } else {
16596
+ sameErrorCount.error = "Residual tokens";
16597
+ sameErrorCount.count = 1;
16598
+ }
16599
+ } else if (err.message.includes("Insufficient tokens received")) {
16600
+ logger.error("Insufficient tokens received");
16601
+ if (sameErrorCount.error == "Insufficient tokens received") {
16602
+ sameErrorCount.count++;
16603
+ } else {
16604
+ sameErrorCount.error = "Insufficient tokens received";
16605
+ sameErrorCount.count = 1;
16606
+ }
16607
+ } else if (err.message.includes("Could not reach the end of the program")) {
16608
+ logger.error("Could not reach the end of the program, may be the block is full (could be a temp/permanent gas issue)");
16609
+ if (sameErrorCount.error == "Could not reach the end of the program") {
16610
+ sameErrorCount.count++;
16611
+ } else {
16612
+ sameErrorCount.error = "Could not reach the end of the program";
16613
+ sameErrorCount.count = 1;
16614
+ }
16576
16615
  } else {
16577
16616
  logger.error("Unexpected error:", err);
16578
16617
  throw err;
@@ -16585,7 +16624,10 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
16585
16624
  isSellTokenToken0,
16586
16625
  retry + 1,
16587
16626
  lowerLimit,
16588
- upperLimit
16627
+ upperLimit,
16628
+ MAX_RETRIES,
16629
+ sameErrorCount,
16630
+ MAX_SAME_ERROR_COUNT
16589
16631
  );
16590
16632
  }
16591
16633
  }
package/dist/index.d.ts CHANGED
@@ -813,10 +813,16 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
813
813
  * @param retry - Current retry attempt number (default 0)
814
814
  * @param adjustmentFactor - Percentage to adjust swap amount by (default 1)
815
815
  * @param isToken0Deficit - Whether token0 balance needs increasing (default true)
816
+ * @param MAX_RETRIES - Maximum number of retries (default 40)
817
+ * @param sameErrorCount - For certain errors, we just retry with same amount again. This is the count of such retries (default { count: 0, error: null })
818
+ * @param MAX_SAME_ERROR_COUNT - For certain errors, we just retry with same amount again. This limits such retries (default 10)
816
819
  * @returns Array of contract calls needed for rebalancing
817
- * @throws Error if max retries reached without successful rebalance
820
+ * @throws Error if max retries reached without successful rebalance or max same errors reached
818
821
  */
819
- rebalanceIter(swapInfo: SwapInfo, acc: Account, estimateCall: (swapInfo: SwapInfo) => Promise<Call[]>, isSellTokenToken0?: boolean, retry?: number, lowerLimit?: bigint, upperLimit?: bigint, MAX_RETRIES?: number): Promise<Call[]>;
822
+ rebalanceIter(swapInfo: SwapInfo, acc: Account, estimateCall: (swapInfo: SwapInfo) => Promise<Call[]>, isSellTokenToken0?: boolean, retry?: number, lowerLimit?: bigint, upperLimit?: bigint, MAX_RETRIES?: number, sameErrorCount?: {
823
+ count: number;
824
+ error: null | string;
825
+ }, MAX_SAME_ERROR_COUNT?: number): Promise<Call[]>;
820
826
  static tickToi129(tick: number): {
821
827
  mag: number;
822
828
  sign: number;
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, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
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: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
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)) {
@@ -16501,14 +16508,22 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
16501
16508
  * @param retry - Current retry attempt number (default 0)
16502
16509
  * @param adjustmentFactor - Percentage to adjust swap amount by (default 1)
16503
16510
  * @param isToken0Deficit - Whether token0 balance needs increasing (default true)
16511
+ * @param MAX_RETRIES - Maximum number of retries (default 40)
16512
+ * @param sameErrorCount - For certain errors, we just retry with same amount again. This is the count of such retries (default { count: 0, error: null })
16513
+ * @param MAX_SAME_ERROR_COUNT - For certain errors, we just retry with same amount again. This limits such retries (default 10)
16504
16514
  * @returns Array of contract calls needed for rebalancing
16505
- * @throws Error if max retries reached without successful rebalance
16515
+ * @throws Error if max retries reached without successful rebalance or max same errors reached
16506
16516
  */
16507
- async rebalanceIter(swapInfo, acc, estimateCall, isSellTokenToken0 = true, retry = 0, lowerLimit = 0n, upperLimit = 0n, MAX_RETRIES = 40) {
16517
+ async rebalanceIter(swapInfo, acc, estimateCall, isSellTokenToken0 = true, retry = 0, lowerLimit = 0n, upperLimit = 0n, MAX_RETRIES = 40, sameErrorCount = { count: 0, error: null }, MAX_SAME_ERROR_COUNT = 10) {
16508
16518
  logger.verbose(
16509
- `Rebalancing ${this.metadata.name}: retry=${retry}, lowerLimit=${lowerLimit}, upperLimit=${upperLimit}, isSellTokenToken0=${isSellTokenToken0}`
16519
+ `Rebalancing ${this.metadata.name}: retry=${retry}, lowerLimit=${lowerLimit}, upperLimit=${upperLimit}, isSellTokenToken0=${isSellTokenToken0}, MAX_RETRIES=${MAX_RETRIES}, sameErrorCount=${sameErrorCount.error} (${sameErrorCount.count})`
16510
16520
  );
16521
+ if (sameErrorCount.count >= MAX_SAME_ERROR_COUNT) {
16522
+ logger.error(`Rebalance failed after ${MAX_SAME_ERROR_COUNT} same errors`);
16523
+ throw new Error(`Rebalance failed after ${MAX_SAME_ERROR_COUNT} same errors`);
16524
+ }
16511
16525
  const fromAmount = import_starknet11.uint256.uint256ToBN(swapInfo.token_from_amount);
16526
+ const fromTokenInfo = await Global.getTokenInfoFromAddr(ContractAddr.from(swapInfo.token_from_address));
16512
16527
  logger.verbose(
16513
16528
  `Selling ${fromAmount.toString()} of token ${swapInfo.token_from_address}`
16514
16529
  );
@@ -16525,8 +16540,8 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
16525
16540
  `Rebalance attempt ${retry + 1} failed, adjusting swap amount...`
16526
16541
  );
16527
16542
  const newSwapInfo = { ...swapInfo };
16528
- const currentAmount = Web3Number.fromWei(fromAmount.toString(), 18);
16529
- logger.verbose(`Current amount: ${currentAmount.toString()}`);
16543
+ const currentAmount = Web3Number.fromWei(fromAmount.toString(), fromTokenInfo.decimals);
16544
+ logger.verbose(`Current amount: ${currentAmount.toString()}, lowerLimit: ${lowerLimit.toString()}, upperLimit: ${upperLimit.toString()}`);
16530
16545
  if (err.message.includes("invalid token0 balance") || err.message.includes("invalid token0 amount")) {
16531
16546
  if (!isSellTokenToken0) {
16532
16547
  logger.verbose("Reducing swap amount - excess token0");
@@ -16573,6 +16588,30 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
16573
16588
  }
16574
16589
  newSwapInfo.token_from_amount = import_starknet11.uint256.bnToUint256(nextAmount);
16575
16590
  }
16591
+ } else if (err.message.includes("Residual tokens")) {
16592
+ logger.error("Residual tokens");
16593
+ if (sameErrorCount.error == "Residual tokens") {
16594
+ sameErrorCount.count++;
16595
+ } else {
16596
+ sameErrorCount.error = "Residual tokens";
16597
+ sameErrorCount.count = 1;
16598
+ }
16599
+ } else if (err.message.includes("Insufficient tokens received")) {
16600
+ logger.error("Insufficient tokens received");
16601
+ if (sameErrorCount.error == "Insufficient tokens received") {
16602
+ sameErrorCount.count++;
16603
+ } else {
16604
+ sameErrorCount.error = "Insufficient tokens received";
16605
+ sameErrorCount.count = 1;
16606
+ }
16607
+ } else if (err.message.includes("Could not reach the end of the program")) {
16608
+ logger.error("Could not reach the end of the program, may be the block is full (could be a temp/permanent gas issue)");
16609
+ if (sameErrorCount.error == "Could not reach the end of the program") {
16610
+ sameErrorCount.count++;
16611
+ } else {
16612
+ sameErrorCount.error = "Could not reach the end of the program";
16613
+ sameErrorCount.count = 1;
16614
+ }
16576
16615
  } else {
16577
16616
  logger.error("Unexpected error:", err);
16578
16617
  throw err;
@@ -16585,7 +16624,10 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
16585
16624
  isSellTokenToken0,
16586
16625
  retry + 1,
16587
16626
  lowerLimit,
16588
- upperLimit
16627
+ upperLimit,
16628
+ MAX_RETRIES,
16629
+ sameErrorCount,
16630
+ MAX_SAME_ERROR_COUNT
16589
16631
  );
16590
16632
  }
16591
16633
  }
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)) {
@@ -16399,14 +16406,22 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
16399
16406
  * @param retry - Current retry attempt number (default 0)
16400
16407
  * @param adjustmentFactor - Percentage to adjust swap amount by (default 1)
16401
16408
  * @param isToken0Deficit - Whether token0 balance needs increasing (default true)
16409
+ * @param MAX_RETRIES - Maximum number of retries (default 40)
16410
+ * @param sameErrorCount - For certain errors, we just retry with same amount again. This is the count of such retries (default { count: 0, error: null })
16411
+ * @param MAX_SAME_ERROR_COUNT - For certain errors, we just retry with same amount again. This limits such retries (default 10)
16402
16412
  * @returns Array of contract calls needed for rebalancing
16403
- * @throws Error if max retries reached without successful rebalance
16413
+ * @throws Error if max retries reached without successful rebalance or max same errors reached
16404
16414
  */
16405
- async rebalanceIter(swapInfo, acc, estimateCall, isSellTokenToken0 = true, retry = 0, lowerLimit = 0n, upperLimit = 0n, MAX_RETRIES = 40) {
16415
+ async rebalanceIter(swapInfo, acc, estimateCall, isSellTokenToken0 = true, retry = 0, lowerLimit = 0n, upperLimit = 0n, MAX_RETRIES = 40, sameErrorCount = { count: 0, error: null }, MAX_SAME_ERROR_COUNT = 10) {
16406
16416
  logger.verbose(
16407
- `Rebalancing ${this.metadata.name}: retry=${retry}, lowerLimit=${lowerLimit}, upperLimit=${upperLimit}, isSellTokenToken0=${isSellTokenToken0}`
16417
+ `Rebalancing ${this.metadata.name}: retry=${retry}, lowerLimit=${lowerLimit}, upperLimit=${upperLimit}, isSellTokenToken0=${isSellTokenToken0}, MAX_RETRIES=${MAX_RETRIES}, sameErrorCount=${sameErrorCount.error} (${sameErrorCount.count})`
16408
16418
  );
16419
+ if (sameErrorCount.count >= MAX_SAME_ERROR_COUNT) {
16420
+ logger.error(`Rebalance failed after ${MAX_SAME_ERROR_COUNT} same errors`);
16421
+ throw new Error(`Rebalance failed after ${MAX_SAME_ERROR_COUNT} same errors`);
16422
+ }
16409
16423
  const fromAmount = uint2564.uint256ToBN(swapInfo.token_from_amount);
16424
+ const fromTokenInfo = await Global.getTokenInfoFromAddr(ContractAddr.from(swapInfo.token_from_address));
16410
16425
  logger.verbose(
16411
16426
  `Selling ${fromAmount.toString()} of token ${swapInfo.token_from_address}`
16412
16427
  );
@@ -16423,8 +16438,8 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
16423
16438
  `Rebalance attempt ${retry + 1} failed, adjusting swap amount...`
16424
16439
  );
16425
16440
  const newSwapInfo = { ...swapInfo };
16426
- const currentAmount = Web3Number.fromWei(fromAmount.toString(), 18);
16427
- logger.verbose(`Current amount: ${currentAmount.toString()}`);
16441
+ const currentAmount = Web3Number.fromWei(fromAmount.toString(), fromTokenInfo.decimals);
16442
+ logger.verbose(`Current amount: ${currentAmount.toString()}, lowerLimit: ${lowerLimit.toString()}, upperLimit: ${upperLimit.toString()}`);
16428
16443
  if (err.message.includes("invalid token0 balance") || err.message.includes("invalid token0 amount")) {
16429
16444
  if (!isSellTokenToken0) {
16430
16445
  logger.verbose("Reducing swap amount - excess token0");
@@ -16471,6 +16486,30 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
16471
16486
  }
16472
16487
  newSwapInfo.token_from_amount = uint2564.bnToUint256(nextAmount);
16473
16488
  }
16489
+ } else if (err.message.includes("Residual tokens")) {
16490
+ logger.error("Residual tokens");
16491
+ if (sameErrorCount.error == "Residual tokens") {
16492
+ sameErrorCount.count++;
16493
+ } else {
16494
+ sameErrorCount.error = "Residual tokens";
16495
+ sameErrorCount.count = 1;
16496
+ }
16497
+ } else if (err.message.includes("Insufficient tokens received")) {
16498
+ logger.error("Insufficient tokens received");
16499
+ if (sameErrorCount.error == "Insufficient tokens received") {
16500
+ sameErrorCount.count++;
16501
+ } else {
16502
+ sameErrorCount.error = "Insufficient tokens received";
16503
+ sameErrorCount.count = 1;
16504
+ }
16505
+ } else if (err.message.includes("Could not reach the end of the program")) {
16506
+ logger.error("Could not reach the end of the program, may be the block is full (could be a temp/permanent gas issue)");
16507
+ if (sameErrorCount.error == "Could not reach the end of the program") {
16508
+ sameErrorCount.count++;
16509
+ } else {
16510
+ sameErrorCount.error = "Could not reach the end of the program";
16511
+ sameErrorCount.count = 1;
16512
+ }
16474
16513
  } else {
16475
16514
  logger.error("Unexpected error:", err);
16476
16515
  throw err;
@@ -16483,7 +16522,10 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
16483
16522
  isSellTokenToken0,
16484
16523
  retry + 1,
16485
16524
  lowerLimit,
16486
- upperLimit
16525
+ upperLimit,
16526
+ MAX_RETRIES,
16527
+ sameErrorCount,
16528
+ MAX_SAME_ERROR_COUNT
16487
16529
  );
16488
16530
  }
16489
16531
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strkfarm/sdk",
3
- "version": "1.1.60",
3
+ "version": "1.1.62",
4
4
  "description": "STRKFarm TS SDK (Meant for our internal use, but feel free to use it)",
5
5
  "typings": "dist/index.d.ts",
6
6
  "types": "dist/index.d.ts",
@@ -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;
@@ -1402,8 +1409,11 @@ export class EkuboCLVault extends BaseStrategy<
1402
1409
  * @param retry - Current retry attempt number (default 0)
1403
1410
  * @param adjustmentFactor - Percentage to adjust swap amount by (default 1)
1404
1411
  * @param isToken0Deficit - Whether token0 balance needs increasing (default true)
1412
+ * @param MAX_RETRIES - Maximum number of retries (default 40)
1413
+ * @param sameErrorCount - For certain errors, we just retry with same amount again. This is the count of such retries (default { count: 0, error: null })
1414
+ * @param MAX_SAME_ERROR_COUNT - For certain errors, we just retry with same amount again. This limits such retries (default 10)
1405
1415
  * @returns Array of contract calls needed for rebalancing
1406
- * @throws Error if max retries reached without successful rebalance
1416
+ * @throws Error if max retries reached without successful rebalance or max same errors reached
1407
1417
  */
1408
1418
  async rebalanceIter(
1409
1419
  swapInfo: SwapInfo,
@@ -1413,15 +1423,23 @@ export class EkuboCLVault extends BaseStrategy<
1413
1423
  retry = 0,
1414
1424
  lowerLimit = 0n,
1415
1425
  upperLimit = 0n,
1416
- MAX_RETRIES = 40
1426
+ MAX_RETRIES = 40,
1427
+ sameErrorCount: { count: number, error: null | string } = { count: 0, error: null },
1428
+ MAX_SAME_ERROR_COUNT = 10
1417
1429
  ): Promise<Call[]> {
1418
1430
 
1419
1431
  logger.verbose(
1420
1432
  `Rebalancing ${this.metadata.name}: ` +
1421
- `retry=${retry}, lowerLimit=${lowerLimit}, upperLimit=${upperLimit}, isSellTokenToken0=${isSellTokenToken0}`
1433
+ `retry=${retry}, lowerLimit=${lowerLimit}, upperLimit=${upperLimit}, isSellTokenToken0=${isSellTokenToken0}, MAX_RETRIES=${MAX_RETRIES}, sameErrorCount=${sameErrorCount.error} (${sameErrorCount.count})`
1422
1434
  );
1423
1435
 
1436
+ if (sameErrorCount.count >= MAX_SAME_ERROR_COUNT) {
1437
+ logger.error(`Rebalance failed after ${MAX_SAME_ERROR_COUNT} same errors`);
1438
+ throw new Error(`Rebalance failed after ${MAX_SAME_ERROR_COUNT} same errors`);
1439
+ }
1440
+
1424
1441
  const fromAmount = uint256.uint256ToBN(swapInfo.token_from_amount);
1442
+ const fromTokenInfo = await Global.getTokenInfoFromAddr(ContractAddr.from(swapInfo.token_from_address));
1425
1443
  logger.verbose(
1426
1444
  `Selling ${fromAmount.toString()} of token ${swapInfo.token_from_address}`
1427
1445
  );
@@ -1441,8 +1459,8 @@ export class EkuboCLVault extends BaseStrategy<
1441
1459
  );
1442
1460
 
1443
1461
  const newSwapInfo = { ...swapInfo };
1444
- const currentAmount = Web3Number.fromWei(fromAmount.toString(), 18); // 18 is ok, as its toWei eventually anyways
1445
- logger.verbose(`Current amount: ${currentAmount.toString()}`);
1462
+ const currentAmount = Web3Number.fromWei(fromAmount.toString(), fromTokenInfo.decimals);
1463
+ logger.verbose(`Current amount: ${currentAmount.toString()}, lowerLimit: ${lowerLimit.toString()}, upperLimit: ${upperLimit.toString()}`);
1446
1464
  if (
1447
1465
  err.message.includes("invalid token0 balance") ||
1448
1466
  err.message.includes("invalid token0 amount")
@@ -1495,11 +1513,43 @@ export class EkuboCLVault extends BaseStrategy<
1495
1513
  }
1496
1514
  newSwapInfo.token_from_amount = uint256.bnToUint256(nextAmount);
1497
1515
  }
1516
+ } else if (err.message.includes("Residual tokens")) {
1517
+ logger.error("Residual tokens");
1518
+ if (sameErrorCount.error == "Residual tokens") {
1519
+ sameErrorCount.count++;
1520
+ } else {
1521
+ sameErrorCount.error = "Residual tokens";
1522
+ sameErrorCount.count = 1;
1523
+ }
1524
+ // dont do anything, just try again.
1525
+ } else if (err.message.includes("Insufficient tokens received")) {
1526
+ logger.error("Insufficient tokens received");
1527
+ if (sameErrorCount.error == "Insufficient tokens received") {
1528
+ sameErrorCount.count++;
1529
+ } else {
1530
+ sameErrorCount.error = "Insufficient tokens received";
1531
+ sameErrorCount.count = 1;
1532
+ }
1533
+ // dont do anything, just try again.
1534
+ } else if (err.message.includes("Could not reach the end of the program")) {
1535
+ logger.error("Could not reach the end of the program, may be the block is full (could be a temp/permanent gas issue)");
1536
+ if (sameErrorCount.error == "Could not reach the end of the program") {
1537
+ sameErrorCount.count++;
1538
+ } else {
1539
+ sameErrorCount.error = "Could not reach the end of the program";
1540
+ sameErrorCount.count = 1;
1541
+ }
1542
+ // just try again.
1498
1543
  } else {
1499
1544
  logger.error("Unexpected error:", err);
1500
1545
  throw err;
1501
1546
  }
1502
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
+ // }
1503
1553
  return this.rebalanceIter(
1504
1554
  newSwapInfo,
1505
1555
  acc,
@@ -1507,7 +1557,10 @@ export class EkuboCLVault extends BaseStrategy<
1507
1557
  isSellTokenToken0,
1508
1558
  retry + 1,
1509
1559
  lowerLimit,
1510
- upperLimit
1560
+ upperLimit,
1561
+ MAX_RETRIES,
1562
+ sameErrorCount,
1563
+ MAX_SAME_ERROR_COUNT
1511
1564
  );
1512
1565
  }
1513
1566
  }