@tokemak/queries 0.0.9 → 0.0.11

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.cjs CHANGED
@@ -1,4 +1,16 @@
1
- "use strict";
1
+ 'use strict';
2
+
3
+ var chains = require('viem/chains');
4
+ var constants = require('@tokemak/constants');
5
+ var tokenlist = require('@tokemak/tokenlist');
6
+ var viem = require('viem');
7
+ var utils = require('@tokemak/utils');
8
+ var graphCli = require('@tokemak/graph-cli');
9
+ var config = require('@tokemak/config');
10
+ var core = require('@wagmi/core');
11
+ var abis = require('@tokemak/abis');
12
+ var autopilotSwapRouteCalc = require('@tokemak/autopilot-swap-route-calc');
13
+
2
14
  var __create = Object.create;
3
15
  var __defProp = Object.defineProperty;
4
16
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -8,33 +20,1905 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
20
  var __commonJS = (cb, mod) => function __require() {
9
21
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
22
  };
11
- var __export = (target, all) => {
12
- for (var name in all)
13
- __defProp(target, name, { get: all[name], enumerable: true });
14
- };
15
23
  var __copyProps = (to, from, except, desc) => {
16
24
  if (from && typeof from === "object" || typeof from === "function") {
17
25
  for (let key of __getOwnPropNames(from))
18
26
  if (!__hasOwnProp.call(to, key) && key !== except)
19
27
  __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
28
  }
21
- return to;
22
- };
23
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
- // If the importer is in node compatibility mode or this is not an ESM
25
- // file that has been converted to a CommonJS file using a Babel-
26
- // compatible transform (i.e. "__esModule" has not been set), then set
27
- // "default" to the CommonJS "module.exports" for node compatibility.
28
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
- mod
30
- ));
31
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ return to;
30
+ };
31
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
32
+ // If the importer is in node compatibility mode or this is not an ESM
33
+ // file that has been converted to a CommonJS file using a Babel-
34
+ // compatible transform (i.e. "__esModule" has not been set), then set
35
+ // "default" to the CommonJS "module.exports" for node compatibility.
36
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
37
+ mod
38
+ ));
39
+
40
+ // ../../node_modules/base64-js/index.js
41
+ var require_base64_js = __commonJS({
42
+ "../../node_modules/base64-js/index.js"(exports) {
43
+ exports.byteLength = byteLength;
44
+ exports.toByteArray = toByteArray;
45
+ exports.fromByteArray = fromByteArray;
46
+ var lookup = [];
47
+ var revLookup = [];
48
+ var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
49
+ var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
50
+ for (i = 0, len = code.length; i < len; ++i) {
51
+ lookup[i] = code[i];
52
+ revLookup[code.charCodeAt(i)] = i;
53
+ }
54
+ var i;
55
+ var len;
56
+ revLookup["-".charCodeAt(0)] = 62;
57
+ revLookup["_".charCodeAt(0)] = 63;
58
+ function getLens(b64) {
59
+ var len2 = b64.length;
60
+ if (len2 % 4 > 0) {
61
+ throw new Error("Invalid string. Length must be a multiple of 4");
62
+ }
63
+ var validLen = b64.indexOf("=");
64
+ if (validLen === -1)
65
+ validLen = len2;
66
+ var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4;
67
+ return [validLen, placeHoldersLen];
68
+ }
69
+ function byteLength(b64) {
70
+ var lens = getLens(b64);
71
+ var validLen = lens[0];
72
+ var placeHoldersLen = lens[1];
73
+ return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
74
+ }
75
+ function _byteLength(b64, validLen, placeHoldersLen) {
76
+ return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
77
+ }
78
+ function toByteArray(b64) {
79
+ var tmp;
80
+ var lens = getLens(b64);
81
+ var validLen = lens[0];
82
+ var placeHoldersLen = lens[1];
83
+ var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
84
+ var curByte = 0;
85
+ var len2 = placeHoldersLen > 0 ? validLen - 4 : validLen;
86
+ var i2;
87
+ for (i2 = 0; i2 < len2; i2 += 4) {
88
+ tmp = revLookup[b64.charCodeAt(i2)] << 18 | revLookup[b64.charCodeAt(i2 + 1)] << 12 | revLookup[b64.charCodeAt(i2 + 2)] << 6 | revLookup[b64.charCodeAt(i2 + 3)];
89
+ arr[curByte++] = tmp >> 16 & 255;
90
+ arr[curByte++] = tmp >> 8 & 255;
91
+ arr[curByte++] = tmp & 255;
92
+ }
93
+ if (placeHoldersLen === 2) {
94
+ tmp = revLookup[b64.charCodeAt(i2)] << 2 | revLookup[b64.charCodeAt(i2 + 1)] >> 4;
95
+ arr[curByte++] = tmp & 255;
96
+ }
97
+ if (placeHoldersLen === 1) {
98
+ tmp = revLookup[b64.charCodeAt(i2)] << 10 | revLookup[b64.charCodeAt(i2 + 1)] << 4 | revLookup[b64.charCodeAt(i2 + 2)] >> 2;
99
+ arr[curByte++] = tmp >> 8 & 255;
100
+ arr[curByte++] = tmp & 255;
101
+ }
102
+ return arr;
103
+ }
104
+ function tripletToBase64(num) {
105
+ return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
106
+ }
107
+ function encodeChunk(uint8, start, end) {
108
+ var tmp;
109
+ var output = [];
110
+ for (var i2 = start; i2 < end; i2 += 3) {
111
+ tmp = (uint8[i2] << 16 & 16711680) + (uint8[i2 + 1] << 8 & 65280) + (uint8[i2 + 2] & 255);
112
+ output.push(tripletToBase64(tmp));
113
+ }
114
+ return output.join("");
115
+ }
116
+ function fromByteArray(uint8) {
117
+ var tmp;
118
+ var len2 = uint8.length;
119
+ var extraBytes = len2 % 3;
120
+ var parts = [];
121
+ var maxChunkLength = 16383;
122
+ for (var i2 = 0, len22 = len2 - extraBytes; i2 < len22; i2 += maxChunkLength) {
123
+ parts.push(encodeChunk(uint8, i2, i2 + maxChunkLength > len22 ? len22 : i2 + maxChunkLength));
124
+ }
125
+ if (extraBytes === 1) {
126
+ tmp = uint8[len2 - 1];
127
+ parts.push(
128
+ lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "=="
129
+ );
130
+ } else if (extraBytes === 2) {
131
+ tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1];
132
+ parts.push(
133
+ lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "="
134
+ );
135
+ }
136
+ return parts.join("");
137
+ }
138
+ }
139
+ });
140
+
141
+ // ../../node_modules/ieee754/index.js
142
+ var require_ieee754 = __commonJS({
143
+ "../../node_modules/ieee754/index.js"(exports) {
144
+ exports.read = function(buffer, offset, isLE, mLen, nBytes) {
145
+ var e, m;
146
+ var eLen = nBytes * 8 - mLen - 1;
147
+ var eMax = (1 << eLen) - 1;
148
+ var eBias = eMax >> 1;
149
+ var nBits = -7;
150
+ var i = isLE ? nBytes - 1 : 0;
151
+ var d = isLE ? -1 : 1;
152
+ var s = buffer[offset + i];
153
+ i += d;
154
+ e = s & (1 << -nBits) - 1;
155
+ s >>= -nBits;
156
+ nBits += eLen;
157
+ for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {
158
+ }
159
+ m = e & (1 << -nBits) - 1;
160
+ e >>= -nBits;
161
+ nBits += mLen;
162
+ for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {
163
+ }
164
+ if (e === 0) {
165
+ e = 1 - eBias;
166
+ } else if (e === eMax) {
167
+ return m ? NaN : (s ? -1 : 1) * Infinity;
168
+ } else {
169
+ m = m + Math.pow(2, mLen);
170
+ e = e - eBias;
171
+ }
172
+ return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
173
+ };
174
+ exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
175
+ var e, m, c;
176
+ var eLen = nBytes * 8 - mLen - 1;
177
+ var eMax = (1 << eLen) - 1;
178
+ var eBias = eMax >> 1;
179
+ var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
180
+ var i = isLE ? 0 : nBytes - 1;
181
+ var d = isLE ? 1 : -1;
182
+ var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
183
+ value = Math.abs(value);
184
+ if (isNaN(value) || value === Infinity) {
185
+ m = isNaN(value) ? 1 : 0;
186
+ e = eMax;
187
+ } else {
188
+ e = Math.floor(Math.log(value) / Math.LN2);
189
+ if (value * (c = Math.pow(2, -e)) < 1) {
190
+ e--;
191
+ c *= 2;
192
+ }
193
+ if (e + eBias >= 1) {
194
+ value += rt / c;
195
+ } else {
196
+ value += rt * Math.pow(2, 1 - eBias);
197
+ }
198
+ if (value * c >= 2) {
199
+ e++;
200
+ c /= 2;
201
+ }
202
+ if (e + eBias >= eMax) {
203
+ m = 0;
204
+ e = eMax;
205
+ } else if (e + eBias >= 1) {
206
+ m = (value * c - 1) * Math.pow(2, mLen);
207
+ e = e + eBias;
208
+ } else {
209
+ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
210
+ e = 0;
211
+ }
212
+ }
213
+ for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
214
+ }
215
+ e = e << mLen | m;
216
+ eLen += mLen;
217
+ for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
218
+ }
219
+ buffer[offset + i - d] |= s * 128;
220
+ };
221
+ }
222
+ });
223
+
224
+ // ../../node_modules/buffer/index.js
225
+ var require_buffer = __commonJS({
226
+ "../../node_modules/buffer/index.js"(exports) {
227
+ var base64 = require_base64_js();
228
+ var ieee754 = require_ieee754();
229
+ var customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null;
230
+ exports.Buffer = Buffer2;
231
+ exports.SlowBuffer = SlowBuffer;
232
+ exports.INSPECT_MAX_BYTES = 50;
233
+ var K_MAX_LENGTH = 2147483647;
234
+ exports.kMaxLength = K_MAX_LENGTH;
235
+ Buffer2.TYPED_ARRAY_SUPPORT = typedArraySupport();
236
+ if (!Buffer2.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") {
237
+ console.error(
238
+ "This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."
239
+ );
240
+ }
241
+ function typedArraySupport() {
242
+ try {
243
+ const arr = new Uint8Array(1);
244
+ const proto = { foo: function() {
245
+ return 42;
246
+ } };
247
+ Object.setPrototypeOf(proto, Uint8Array.prototype);
248
+ Object.setPrototypeOf(arr, proto);
249
+ return arr.foo() === 42;
250
+ } catch (e) {
251
+ return false;
252
+ }
253
+ }
254
+ Object.defineProperty(Buffer2.prototype, "parent", {
255
+ enumerable: true,
256
+ get: function() {
257
+ if (!Buffer2.isBuffer(this))
258
+ return void 0;
259
+ return this.buffer;
260
+ }
261
+ });
262
+ Object.defineProperty(Buffer2.prototype, "offset", {
263
+ enumerable: true,
264
+ get: function() {
265
+ if (!Buffer2.isBuffer(this))
266
+ return void 0;
267
+ return this.byteOffset;
268
+ }
269
+ });
270
+ function createBuffer(length) {
271
+ if (length > K_MAX_LENGTH) {
272
+ throw new RangeError('The value "' + length + '" is invalid for option "size"');
273
+ }
274
+ const buf = new Uint8Array(length);
275
+ Object.setPrototypeOf(buf, Buffer2.prototype);
276
+ return buf;
277
+ }
278
+ function Buffer2(arg, encodingOrOffset, length) {
279
+ if (typeof arg === "number") {
280
+ if (typeof encodingOrOffset === "string") {
281
+ throw new TypeError(
282
+ 'The "string" argument must be of type string. Received type number'
283
+ );
284
+ }
285
+ return allocUnsafe(arg);
286
+ }
287
+ return from(arg, encodingOrOffset, length);
288
+ }
289
+ Buffer2.poolSize = 8192;
290
+ function from(value, encodingOrOffset, length) {
291
+ if (typeof value === "string") {
292
+ return fromString(value, encodingOrOffset);
293
+ }
294
+ if (ArrayBuffer.isView(value)) {
295
+ return fromArrayView(value);
296
+ }
297
+ if (value == null) {
298
+ throw new TypeError(
299
+ "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value
300
+ );
301
+ }
302
+ if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) {
303
+ return fromArrayBuffer(value, encodingOrOffset, length);
304
+ }
305
+ if (typeof SharedArrayBuffer !== "undefined" && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) {
306
+ return fromArrayBuffer(value, encodingOrOffset, length);
307
+ }
308
+ if (typeof value === "number") {
309
+ throw new TypeError(
310
+ 'The "value" argument must not be of type number. Received type number'
311
+ );
312
+ }
313
+ const valueOf = value.valueOf && value.valueOf();
314
+ if (valueOf != null && valueOf !== value) {
315
+ return Buffer2.from(valueOf, encodingOrOffset, length);
316
+ }
317
+ const b = fromObject(value);
318
+ if (b)
319
+ return b;
320
+ if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") {
321
+ return Buffer2.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length);
322
+ }
323
+ throw new TypeError(
324
+ "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value
325
+ );
326
+ }
327
+ Buffer2.from = function(value, encodingOrOffset, length) {
328
+ return from(value, encodingOrOffset, length);
329
+ };
330
+ Object.setPrototypeOf(Buffer2.prototype, Uint8Array.prototype);
331
+ Object.setPrototypeOf(Buffer2, Uint8Array);
332
+ function assertSize(size) {
333
+ if (typeof size !== "number") {
334
+ throw new TypeError('"size" argument must be of type number');
335
+ } else if (size < 0) {
336
+ throw new RangeError('The value "' + size + '" is invalid for option "size"');
337
+ }
338
+ }
339
+ function alloc(size, fill, encoding) {
340
+ assertSize(size);
341
+ if (size <= 0) {
342
+ return createBuffer(size);
343
+ }
344
+ if (fill !== void 0) {
345
+ return typeof encoding === "string" ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill);
346
+ }
347
+ return createBuffer(size);
348
+ }
349
+ Buffer2.alloc = function(size, fill, encoding) {
350
+ return alloc(size, fill, encoding);
351
+ };
352
+ function allocUnsafe(size) {
353
+ assertSize(size);
354
+ return createBuffer(size < 0 ? 0 : checked(size) | 0);
355
+ }
356
+ Buffer2.allocUnsafe = function(size) {
357
+ return allocUnsafe(size);
358
+ };
359
+ Buffer2.allocUnsafeSlow = function(size) {
360
+ return allocUnsafe(size);
361
+ };
362
+ function fromString(string, encoding) {
363
+ if (typeof encoding !== "string" || encoding === "") {
364
+ encoding = "utf8";
365
+ }
366
+ if (!Buffer2.isEncoding(encoding)) {
367
+ throw new TypeError("Unknown encoding: " + encoding);
368
+ }
369
+ const length = byteLength(string, encoding) | 0;
370
+ let buf = createBuffer(length);
371
+ const actual = buf.write(string, encoding);
372
+ if (actual !== length) {
373
+ buf = buf.slice(0, actual);
374
+ }
375
+ return buf;
376
+ }
377
+ function fromArrayLike(array) {
378
+ const length = array.length < 0 ? 0 : checked(array.length) | 0;
379
+ const buf = createBuffer(length);
380
+ for (let i = 0; i < length; i += 1) {
381
+ buf[i] = array[i] & 255;
382
+ }
383
+ return buf;
384
+ }
385
+ function fromArrayView(arrayView) {
386
+ if (isInstance(arrayView, Uint8Array)) {
387
+ const copy = new Uint8Array(arrayView);
388
+ return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength);
389
+ }
390
+ return fromArrayLike(arrayView);
391
+ }
392
+ function fromArrayBuffer(array, byteOffset, length) {
393
+ if (byteOffset < 0 || array.byteLength < byteOffset) {
394
+ throw new RangeError('"offset" is outside of buffer bounds');
395
+ }
396
+ if (array.byteLength < byteOffset + (length || 0)) {
397
+ throw new RangeError('"length" is outside of buffer bounds');
398
+ }
399
+ let buf;
400
+ if (byteOffset === void 0 && length === void 0) {
401
+ buf = new Uint8Array(array);
402
+ } else if (length === void 0) {
403
+ buf = new Uint8Array(array, byteOffset);
404
+ } else {
405
+ buf = new Uint8Array(array, byteOffset, length);
406
+ }
407
+ Object.setPrototypeOf(buf, Buffer2.prototype);
408
+ return buf;
409
+ }
410
+ function fromObject(obj) {
411
+ if (Buffer2.isBuffer(obj)) {
412
+ const len = checked(obj.length) | 0;
413
+ const buf = createBuffer(len);
414
+ if (buf.length === 0) {
415
+ return buf;
416
+ }
417
+ obj.copy(buf, 0, 0, len);
418
+ return buf;
419
+ }
420
+ if (obj.length !== void 0) {
421
+ if (typeof obj.length !== "number" || numberIsNaN(obj.length)) {
422
+ return createBuffer(0);
423
+ }
424
+ return fromArrayLike(obj);
425
+ }
426
+ if (obj.type === "Buffer" && Array.isArray(obj.data)) {
427
+ return fromArrayLike(obj.data);
428
+ }
429
+ }
430
+ function checked(length) {
431
+ if (length >= K_MAX_LENGTH) {
432
+ throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + K_MAX_LENGTH.toString(16) + " bytes");
433
+ }
434
+ return length | 0;
435
+ }
436
+ function SlowBuffer(length) {
437
+ if (+length != length) {
438
+ length = 0;
439
+ }
440
+ return Buffer2.alloc(+length);
441
+ }
442
+ Buffer2.isBuffer = function isBuffer(b) {
443
+ return b != null && b._isBuffer === true && b !== Buffer2.prototype;
444
+ };
445
+ Buffer2.compare = function compare(a, b) {
446
+ if (isInstance(a, Uint8Array))
447
+ a = Buffer2.from(a, a.offset, a.byteLength);
448
+ if (isInstance(b, Uint8Array))
449
+ b = Buffer2.from(b, b.offset, b.byteLength);
450
+ if (!Buffer2.isBuffer(a) || !Buffer2.isBuffer(b)) {
451
+ throw new TypeError(
452
+ 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
453
+ );
454
+ }
455
+ if (a === b)
456
+ return 0;
457
+ let x = a.length;
458
+ let y = b.length;
459
+ for (let i = 0, len = Math.min(x, y); i < len; ++i) {
460
+ if (a[i] !== b[i]) {
461
+ x = a[i];
462
+ y = b[i];
463
+ break;
464
+ }
465
+ }
466
+ if (x < y)
467
+ return -1;
468
+ if (y < x)
469
+ return 1;
470
+ return 0;
471
+ };
472
+ Buffer2.isEncoding = function isEncoding(encoding) {
473
+ switch (String(encoding).toLowerCase()) {
474
+ case "hex":
475
+ case "utf8":
476
+ case "utf-8":
477
+ case "ascii":
478
+ case "latin1":
479
+ case "binary":
480
+ case "base64":
481
+ case "ucs2":
482
+ case "ucs-2":
483
+ case "utf16le":
484
+ case "utf-16le":
485
+ return true;
486
+ default:
487
+ return false;
488
+ }
489
+ };
490
+ Buffer2.concat = function concat(list, length) {
491
+ if (!Array.isArray(list)) {
492
+ throw new TypeError('"list" argument must be an Array of Buffers');
493
+ }
494
+ if (list.length === 0) {
495
+ return Buffer2.alloc(0);
496
+ }
497
+ let i;
498
+ if (length === void 0) {
499
+ length = 0;
500
+ for (i = 0; i < list.length; ++i) {
501
+ length += list[i].length;
502
+ }
503
+ }
504
+ const buffer = Buffer2.allocUnsafe(length);
505
+ let pos = 0;
506
+ for (i = 0; i < list.length; ++i) {
507
+ let buf = list[i];
508
+ if (isInstance(buf, Uint8Array)) {
509
+ if (pos + buf.length > buffer.length) {
510
+ if (!Buffer2.isBuffer(buf))
511
+ buf = Buffer2.from(buf);
512
+ buf.copy(buffer, pos);
513
+ } else {
514
+ Uint8Array.prototype.set.call(
515
+ buffer,
516
+ buf,
517
+ pos
518
+ );
519
+ }
520
+ } else if (!Buffer2.isBuffer(buf)) {
521
+ throw new TypeError('"list" argument must be an Array of Buffers');
522
+ } else {
523
+ buf.copy(buffer, pos);
524
+ }
525
+ pos += buf.length;
526
+ }
527
+ return buffer;
528
+ };
529
+ function byteLength(string, encoding) {
530
+ if (Buffer2.isBuffer(string)) {
531
+ return string.length;
532
+ }
533
+ if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
534
+ return string.byteLength;
535
+ }
536
+ if (typeof string !== "string") {
537
+ throw new TypeError(
538
+ 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof string
539
+ );
540
+ }
541
+ const len = string.length;
542
+ const mustMatch = arguments.length > 2 && arguments[2] === true;
543
+ if (!mustMatch && len === 0)
544
+ return 0;
545
+ let loweredCase = false;
546
+ for (; ; ) {
547
+ switch (encoding) {
548
+ case "ascii":
549
+ case "latin1":
550
+ case "binary":
551
+ return len;
552
+ case "utf8":
553
+ case "utf-8":
554
+ return utf8ToBytes(string).length;
555
+ case "ucs2":
556
+ case "ucs-2":
557
+ case "utf16le":
558
+ case "utf-16le":
559
+ return len * 2;
560
+ case "hex":
561
+ return len >>> 1;
562
+ case "base64":
563
+ return base64ToBytes(string).length;
564
+ default:
565
+ if (loweredCase) {
566
+ return mustMatch ? -1 : utf8ToBytes(string).length;
567
+ }
568
+ encoding = ("" + encoding).toLowerCase();
569
+ loweredCase = true;
570
+ }
571
+ }
572
+ }
573
+ Buffer2.byteLength = byteLength;
574
+ function slowToString(encoding, start, end) {
575
+ let loweredCase = false;
576
+ if (start === void 0 || start < 0) {
577
+ start = 0;
578
+ }
579
+ if (start > this.length) {
580
+ return "";
581
+ }
582
+ if (end === void 0 || end > this.length) {
583
+ end = this.length;
584
+ }
585
+ if (end <= 0) {
586
+ return "";
587
+ }
588
+ end >>>= 0;
589
+ start >>>= 0;
590
+ if (end <= start) {
591
+ return "";
592
+ }
593
+ if (!encoding)
594
+ encoding = "utf8";
595
+ while (true) {
596
+ switch (encoding) {
597
+ case "hex":
598
+ return hexSlice(this, start, end);
599
+ case "utf8":
600
+ case "utf-8":
601
+ return utf8Slice(this, start, end);
602
+ case "ascii":
603
+ return asciiSlice(this, start, end);
604
+ case "latin1":
605
+ case "binary":
606
+ return latin1Slice(this, start, end);
607
+ case "base64":
608
+ return base64Slice(this, start, end);
609
+ case "ucs2":
610
+ case "ucs-2":
611
+ case "utf16le":
612
+ case "utf-16le":
613
+ return utf16leSlice(this, start, end);
614
+ default:
615
+ if (loweredCase)
616
+ throw new TypeError("Unknown encoding: " + encoding);
617
+ encoding = (encoding + "").toLowerCase();
618
+ loweredCase = true;
619
+ }
620
+ }
621
+ }
622
+ Buffer2.prototype._isBuffer = true;
623
+ function swap(b, n, m) {
624
+ const i = b[n];
625
+ b[n] = b[m];
626
+ b[m] = i;
627
+ }
628
+ Buffer2.prototype.swap16 = function swap16() {
629
+ const len = this.length;
630
+ if (len % 2 !== 0) {
631
+ throw new RangeError("Buffer size must be a multiple of 16-bits");
632
+ }
633
+ for (let i = 0; i < len; i += 2) {
634
+ swap(this, i, i + 1);
635
+ }
636
+ return this;
637
+ };
638
+ Buffer2.prototype.swap32 = function swap32() {
639
+ const len = this.length;
640
+ if (len % 4 !== 0) {
641
+ throw new RangeError("Buffer size must be a multiple of 32-bits");
642
+ }
643
+ for (let i = 0; i < len; i += 4) {
644
+ swap(this, i, i + 3);
645
+ swap(this, i + 1, i + 2);
646
+ }
647
+ return this;
648
+ };
649
+ Buffer2.prototype.swap64 = function swap64() {
650
+ const len = this.length;
651
+ if (len % 8 !== 0) {
652
+ throw new RangeError("Buffer size must be a multiple of 64-bits");
653
+ }
654
+ for (let i = 0; i < len; i += 8) {
655
+ swap(this, i, i + 7);
656
+ swap(this, i + 1, i + 6);
657
+ swap(this, i + 2, i + 5);
658
+ swap(this, i + 3, i + 4);
659
+ }
660
+ return this;
661
+ };
662
+ Buffer2.prototype.toString = function toString() {
663
+ const length = this.length;
664
+ if (length === 0)
665
+ return "";
666
+ if (arguments.length === 0)
667
+ return utf8Slice(this, 0, length);
668
+ return slowToString.apply(this, arguments);
669
+ };
670
+ Buffer2.prototype.toLocaleString = Buffer2.prototype.toString;
671
+ Buffer2.prototype.equals = function equals(b) {
672
+ if (!Buffer2.isBuffer(b))
673
+ throw new TypeError("Argument must be a Buffer");
674
+ if (this === b)
675
+ return true;
676
+ return Buffer2.compare(this, b) === 0;
677
+ };
678
+ Buffer2.prototype.inspect = function inspect() {
679
+ let str = "";
680
+ const max = exports.INSPECT_MAX_BYTES;
681
+ str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim();
682
+ if (this.length > max)
683
+ str += " ... ";
684
+ return "<Buffer " + str + ">";
685
+ };
686
+ if (customInspectSymbol) {
687
+ Buffer2.prototype[customInspectSymbol] = Buffer2.prototype.inspect;
688
+ }
689
+ Buffer2.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
690
+ if (isInstance(target, Uint8Array)) {
691
+ target = Buffer2.from(target, target.offset, target.byteLength);
692
+ }
693
+ if (!Buffer2.isBuffer(target)) {
694
+ throw new TypeError(
695
+ 'The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target
696
+ );
697
+ }
698
+ if (start === void 0) {
699
+ start = 0;
700
+ }
701
+ if (end === void 0) {
702
+ end = target ? target.length : 0;
703
+ }
704
+ if (thisStart === void 0) {
705
+ thisStart = 0;
706
+ }
707
+ if (thisEnd === void 0) {
708
+ thisEnd = this.length;
709
+ }
710
+ if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
711
+ throw new RangeError("out of range index");
712
+ }
713
+ if (thisStart >= thisEnd && start >= end) {
714
+ return 0;
715
+ }
716
+ if (thisStart >= thisEnd) {
717
+ return -1;
718
+ }
719
+ if (start >= end) {
720
+ return 1;
721
+ }
722
+ start >>>= 0;
723
+ end >>>= 0;
724
+ thisStart >>>= 0;
725
+ thisEnd >>>= 0;
726
+ if (this === target)
727
+ return 0;
728
+ let x = thisEnd - thisStart;
729
+ let y = end - start;
730
+ const len = Math.min(x, y);
731
+ const thisCopy = this.slice(thisStart, thisEnd);
732
+ const targetCopy = target.slice(start, end);
733
+ for (let i = 0; i < len; ++i) {
734
+ if (thisCopy[i] !== targetCopy[i]) {
735
+ x = thisCopy[i];
736
+ y = targetCopy[i];
737
+ break;
738
+ }
739
+ }
740
+ if (x < y)
741
+ return -1;
742
+ if (y < x)
743
+ return 1;
744
+ return 0;
745
+ };
746
+ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
747
+ if (buffer.length === 0)
748
+ return -1;
749
+ if (typeof byteOffset === "string") {
750
+ encoding = byteOffset;
751
+ byteOffset = 0;
752
+ } else if (byteOffset > 2147483647) {
753
+ byteOffset = 2147483647;
754
+ } else if (byteOffset < -2147483648) {
755
+ byteOffset = -2147483648;
756
+ }
757
+ byteOffset = +byteOffset;
758
+ if (numberIsNaN(byteOffset)) {
759
+ byteOffset = dir ? 0 : buffer.length - 1;
760
+ }
761
+ if (byteOffset < 0)
762
+ byteOffset = buffer.length + byteOffset;
763
+ if (byteOffset >= buffer.length) {
764
+ if (dir)
765
+ return -1;
766
+ else
767
+ byteOffset = buffer.length - 1;
768
+ } else if (byteOffset < 0) {
769
+ if (dir)
770
+ byteOffset = 0;
771
+ else
772
+ return -1;
773
+ }
774
+ if (typeof val === "string") {
775
+ val = Buffer2.from(val, encoding);
776
+ }
777
+ if (Buffer2.isBuffer(val)) {
778
+ if (val.length === 0) {
779
+ return -1;
780
+ }
781
+ return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
782
+ } else if (typeof val === "number") {
783
+ val = val & 255;
784
+ if (typeof Uint8Array.prototype.indexOf === "function") {
785
+ if (dir) {
786
+ return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
787
+ } else {
788
+ return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
789
+ }
790
+ }
791
+ return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
792
+ }
793
+ throw new TypeError("val must be string, number or Buffer");
794
+ }
795
+ function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
796
+ let indexSize = 1;
797
+ let arrLength = arr.length;
798
+ let valLength = val.length;
799
+ if (encoding !== void 0) {
800
+ encoding = String(encoding).toLowerCase();
801
+ if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
802
+ if (arr.length < 2 || val.length < 2) {
803
+ return -1;
804
+ }
805
+ indexSize = 2;
806
+ arrLength /= 2;
807
+ valLength /= 2;
808
+ byteOffset /= 2;
809
+ }
810
+ }
811
+ function read(buf, i2) {
812
+ if (indexSize === 1) {
813
+ return buf[i2];
814
+ } else {
815
+ return buf.readUInt16BE(i2 * indexSize);
816
+ }
817
+ }
818
+ let i;
819
+ if (dir) {
820
+ let foundIndex = -1;
821
+ for (i = byteOffset; i < arrLength; i++) {
822
+ if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
823
+ if (foundIndex === -1)
824
+ foundIndex = i;
825
+ if (i - foundIndex + 1 === valLength)
826
+ return foundIndex * indexSize;
827
+ } else {
828
+ if (foundIndex !== -1)
829
+ i -= i - foundIndex;
830
+ foundIndex = -1;
831
+ }
832
+ }
833
+ } else {
834
+ if (byteOffset + valLength > arrLength)
835
+ byteOffset = arrLength - valLength;
836
+ for (i = byteOffset; i >= 0; i--) {
837
+ let found = true;
838
+ for (let j = 0; j < valLength; j++) {
839
+ if (read(arr, i + j) !== read(val, j)) {
840
+ found = false;
841
+ break;
842
+ }
843
+ }
844
+ if (found)
845
+ return i;
846
+ }
847
+ }
848
+ return -1;
849
+ }
850
+ Buffer2.prototype.includes = function includes(val, byteOffset, encoding) {
851
+ return this.indexOf(val, byteOffset, encoding) !== -1;
852
+ };
853
+ Buffer2.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
854
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
855
+ };
856
+ Buffer2.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
857
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
858
+ };
859
+ function hexWrite(buf, string, offset, length) {
860
+ offset = Number(offset) || 0;
861
+ const remaining = buf.length - offset;
862
+ if (!length) {
863
+ length = remaining;
864
+ } else {
865
+ length = Number(length);
866
+ if (length > remaining) {
867
+ length = remaining;
868
+ }
869
+ }
870
+ const strLen = string.length;
871
+ if (length > strLen / 2) {
872
+ length = strLen / 2;
873
+ }
874
+ let i;
875
+ for (i = 0; i < length; ++i) {
876
+ const parsed = parseInt(string.substr(i * 2, 2), 16);
877
+ if (numberIsNaN(parsed))
878
+ return i;
879
+ buf[offset + i] = parsed;
880
+ }
881
+ return i;
882
+ }
883
+ function utf8Write(buf, string, offset, length) {
884
+ return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
885
+ }
886
+ function asciiWrite(buf, string, offset, length) {
887
+ return blitBuffer(asciiToBytes(string), buf, offset, length);
888
+ }
889
+ function base64Write(buf, string, offset, length) {
890
+ return blitBuffer(base64ToBytes(string), buf, offset, length);
891
+ }
892
+ function ucs2Write(buf, string, offset, length) {
893
+ return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
894
+ }
895
+ Buffer2.prototype.write = function write(string, offset, length, encoding) {
896
+ if (offset === void 0) {
897
+ encoding = "utf8";
898
+ length = this.length;
899
+ offset = 0;
900
+ } else if (length === void 0 && typeof offset === "string") {
901
+ encoding = offset;
902
+ length = this.length;
903
+ offset = 0;
904
+ } else if (isFinite(offset)) {
905
+ offset = offset >>> 0;
906
+ if (isFinite(length)) {
907
+ length = length >>> 0;
908
+ if (encoding === void 0)
909
+ encoding = "utf8";
910
+ } else {
911
+ encoding = length;
912
+ length = void 0;
913
+ }
914
+ } else {
915
+ throw new Error(
916
+ "Buffer.write(string, encoding, offset[, length]) is no longer supported"
917
+ );
918
+ }
919
+ const remaining = this.length - offset;
920
+ if (length === void 0 || length > remaining)
921
+ length = remaining;
922
+ if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) {
923
+ throw new RangeError("Attempt to write outside buffer bounds");
924
+ }
925
+ if (!encoding)
926
+ encoding = "utf8";
927
+ let loweredCase = false;
928
+ for (; ; ) {
929
+ switch (encoding) {
930
+ case "hex":
931
+ return hexWrite(this, string, offset, length);
932
+ case "utf8":
933
+ case "utf-8":
934
+ return utf8Write(this, string, offset, length);
935
+ case "ascii":
936
+ case "latin1":
937
+ case "binary":
938
+ return asciiWrite(this, string, offset, length);
939
+ case "base64":
940
+ return base64Write(this, string, offset, length);
941
+ case "ucs2":
942
+ case "ucs-2":
943
+ case "utf16le":
944
+ case "utf-16le":
945
+ return ucs2Write(this, string, offset, length);
946
+ default:
947
+ if (loweredCase)
948
+ throw new TypeError("Unknown encoding: " + encoding);
949
+ encoding = ("" + encoding).toLowerCase();
950
+ loweredCase = true;
951
+ }
952
+ }
953
+ };
954
+ Buffer2.prototype.toJSON = function toJSON() {
955
+ return {
956
+ type: "Buffer",
957
+ data: Array.prototype.slice.call(this._arr || this, 0)
958
+ };
959
+ };
960
+ function base64Slice(buf, start, end) {
961
+ if (start === 0 && end === buf.length) {
962
+ return base64.fromByteArray(buf);
963
+ } else {
964
+ return base64.fromByteArray(buf.slice(start, end));
965
+ }
966
+ }
967
+ function utf8Slice(buf, start, end) {
968
+ end = Math.min(buf.length, end);
969
+ const res = [];
970
+ let i = start;
971
+ while (i < end) {
972
+ const firstByte = buf[i];
973
+ let codePoint = null;
974
+ let bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
975
+ if (i + bytesPerSequence <= end) {
976
+ let secondByte, thirdByte, fourthByte, tempCodePoint;
977
+ switch (bytesPerSequence) {
978
+ case 1:
979
+ if (firstByte < 128) {
980
+ codePoint = firstByte;
981
+ }
982
+ break;
983
+ case 2:
984
+ secondByte = buf[i + 1];
985
+ if ((secondByte & 192) === 128) {
986
+ tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
987
+ if (tempCodePoint > 127) {
988
+ codePoint = tempCodePoint;
989
+ }
990
+ }
991
+ break;
992
+ case 3:
993
+ secondByte = buf[i + 1];
994
+ thirdByte = buf[i + 2];
995
+ if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
996
+ tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
997
+ if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) {
998
+ codePoint = tempCodePoint;
999
+ }
1000
+ }
1001
+ break;
1002
+ case 4:
1003
+ secondByte = buf[i + 1];
1004
+ thirdByte = buf[i + 2];
1005
+ fourthByte = buf[i + 3];
1006
+ if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
1007
+ tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
1008
+ if (tempCodePoint > 65535 && tempCodePoint < 1114112) {
1009
+ codePoint = tempCodePoint;
1010
+ }
1011
+ }
1012
+ }
1013
+ }
1014
+ if (codePoint === null) {
1015
+ codePoint = 65533;
1016
+ bytesPerSequence = 1;
1017
+ } else if (codePoint > 65535) {
1018
+ codePoint -= 65536;
1019
+ res.push(codePoint >>> 10 & 1023 | 55296);
1020
+ codePoint = 56320 | codePoint & 1023;
1021
+ }
1022
+ res.push(codePoint);
1023
+ i += bytesPerSequence;
1024
+ }
1025
+ return decodeCodePointsArray(res);
1026
+ }
1027
+ var MAX_ARGUMENTS_LENGTH = 4096;
1028
+ function decodeCodePointsArray(codePoints) {
1029
+ const len = codePoints.length;
1030
+ if (len <= MAX_ARGUMENTS_LENGTH) {
1031
+ return String.fromCharCode.apply(String, codePoints);
1032
+ }
1033
+ let res = "";
1034
+ let i = 0;
1035
+ while (i < len) {
1036
+ res += String.fromCharCode.apply(
1037
+ String,
1038
+ codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
1039
+ );
1040
+ }
1041
+ return res;
1042
+ }
1043
+ function asciiSlice(buf, start, end) {
1044
+ let ret = "";
1045
+ end = Math.min(buf.length, end);
1046
+ for (let i = start; i < end; ++i) {
1047
+ ret += String.fromCharCode(buf[i] & 127);
1048
+ }
1049
+ return ret;
1050
+ }
1051
+ function latin1Slice(buf, start, end) {
1052
+ let ret = "";
1053
+ end = Math.min(buf.length, end);
1054
+ for (let i = start; i < end; ++i) {
1055
+ ret += String.fromCharCode(buf[i]);
1056
+ }
1057
+ return ret;
1058
+ }
1059
+ function hexSlice(buf, start, end) {
1060
+ const len = buf.length;
1061
+ if (!start || start < 0)
1062
+ start = 0;
1063
+ if (!end || end < 0 || end > len)
1064
+ end = len;
1065
+ let out = "";
1066
+ for (let i = start; i < end; ++i) {
1067
+ out += hexSliceLookupTable[buf[i]];
1068
+ }
1069
+ return out;
1070
+ }
1071
+ function utf16leSlice(buf, start, end) {
1072
+ const bytes = buf.slice(start, end);
1073
+ let res = "";
1074
+ for (let i = 0; i < bytes.length - 1; i += 2) {
1075
+ res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
1076
+ }
1077
+ return res;
1078
+ }
1079
+ Buffer2.prototype.slice = function slice(start, end) {
1080
+ const len = this.length;
1081
+ start = ~~start;
1082
+ end = end === void 0 ? len : ~~end;
1083
+ if (start < 0) {
1084
+ start += len;
1085
+ if (start < 0)
1086
+ start = 0;
1087
+ } else if (start > len) {
1088
+ start = len;
1089
+ }
1090
+ if (end < 0) {
1091
+ end += len;
1092
+ if (end < 0)
1093
+ end = 0;
1094
+ } else if (end > len) {
1095
+ end = len;
1096
+ }
1097
+ if (end < start)
1098
+ end = start;
1099
+ const newBuf = this.subarray(start, end);
1100
+ Object.setPrototypeOf(newBuf, Buffer2.prototype);
1101
+ return newBuf;
1102
+ };
1103
+ function checkOffset(offset, ext, length) {
1104
+ if (offset % 1 !== 0 || offset < 0)
1105
+ throw new RangeError("offset is not uint");
1106
+ if (offset + ext > length)
1107
+ throw new RangeError("Trying to access beyond buffer length");
1108
+ }
1109
+ Buffer2.prototype.readUintLE = Buffer2.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) {
1110
+ offset = offset >>> 0;
1111
+ byteLength2 = byteLength2 >>> 0;
1112
+ if (!noAssert)
1113
+ checkOffset(offset, byteLength2, this.length);
1114
+ let val = this[offset];
1115
+ let mul = 1;
1116
+ let i = 0;
1117
+ while (++i < byteLength2 && (mul *= 256)) {
1118
+ val += this[offset + i] * mul;
1119
+ }
1120
+ return val;
1121
+ };
1122
+ Buffer2.prototype.readUintBE = Buffer2.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) {
1123
+ offset = offset >>> 0;
1124
+ byteLength2 = byteLength2 >>> 0;
1125
+ if (!noAssert) {
1126
+ checkOffset(offset, byteLength2, this.length);
1127
+ }
1128
+ let val = this[offset + --byteLength2];
1129
+ let mul = 1;
1130
+ while (byteLength2 > 0 && (mul *= 256)) {
1131
+ val += this[offset + --byteLength2] * mul;
1132
+ }
1133
+ return val;
1134
+ };
1135
+ Buffer2.prototype.readUint8 = Buffer2.prototype.readUInt8 = function readUInt8(offset, noAssert) {
1136
+ offset = offset >>> 0;
1137
+ if (!noAssert)
1138
+ checkOffset(offset, 1, this.length);
1139
+ return this[offset];
1140
+ };
1141
+ Buffer2.prototype.readUint16LE = Buffer2.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
1142
+ offset = offset >>> 0;
1143
+ if (!noAssert)
1144
+ checkOffset(offset, 2, this.length);
1145
+ return this[offset] | this[offset + 1] << 8;
1146
+ };
1147
+ Buffer2.prototype.readUint16BE = Buffer2.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
1148
+ offset = offset >>> 0;
1149
+ if (!noAssert)
1150
+ checkOffset(offset, 2, this.length);
1151
+ return this[offset] << 8 | this[offset + 1];
1152
+ };
1153
+ Buffer2.prototype.readUint32LE = Buffer2.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
1154
+ offset = offset >>> 0;
1155
+ if (!noAssert)
1156
+ checkOffset(offset, 4, this.length);
1157
+ return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
1158
+ };
1159
+ Buffer2.prototype.readUint32BE = Buffer2.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
1160
+ offset = offset >>> 0;
1161
+ if (!noAssert)
1162
+ checkOffset(offset, 4, this.length);
1163
+ return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
1164
+ };
1165
+ Buffer2.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE(offset) {
1166
+ offset = offset >>> 0;
1167
+ validateNumber(offset, "offset");
1168
+ const first = this[offset];
1169
+ const last = this[offset + 7];
1170
+ if (first === void 0 || last === void 0) {
1171
+ boundsError(offset, this.length - 8);
1172
+ }
1173
+ const lo = first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24;
1174
+ const hi = this[++offset] + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + last * 2 ** 24;
1175
+ return BigInt(lo) + (BigInt(hi) << BigInt(32));
1176
+ });
1177
+ Buffer2.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE(offset) {
1178
+ offset = offset >>> 0;
1179
+ validateNumber(offset, "offset");
1180
+ const first = this[offset];
1181
+ const last = this[offset + 7];
1182
+ if (first === void 0 || last === void 0) {
1183
+ boundsError(offset, this.length - 8);
1184
+ }
1185
+ const hi = first * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
1186
+ const lo = this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last;
1187
+ return (BigInt(hi) << BigInt(32)) + BigInt(lo);
1188
+ });
1189
+ Buffer2.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) {
1190
+ offset = offset >>> 0;
1191
+ byteLength2 = byteLength2 >>> 0;
1192
+ if (!noAssert)
1193
+ checkOffset(offset, byteLength2, this.length);
1194
+ let val = this[offset];
1195
+ let mul = 1;
1196
+ let i = 0;
1197
+ while (++i < byteLength2 && (mul *= 256)) {
1198
+ val += this[offset + i] * mul;
1199
+ }
1200
+ mul *= 128;
1201
+ if (val >= mul)
1202
+ val -= Math.pow(2, 8 * byteLength2);
1203
+ return val;
1204
+ };
1205
+ Buffer2.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) {
1206
+ offset = offset >>> 0;
1207
+ byteLength2 = byteLength2 >>> 0;
1208
+ if (!noAssert)
1209
+ checkOffset(offset, byteLength2, this.length);
1210
+ let i = byteLength2;
1211
+ let mul = 1;
1212
+ let val = this[offset + --i];
1213
+ while (i > 0 && (mul *= 256)) {
1214
+ val += this[offset + --i] * mul;
1215
+ }
1216
+ mul *= 128;
1217
+ if (val >= mul)
1218
+ val -= Math.pow(2, 8 * byteLength2);
1219
+ return val;
1220
+ };
1221
+ Buffer2.prototype.readInt8 = function readInt8(offset, noAssert) {
1222
+ offset = offset >>> 0;
1223
+ if (!noAssert)
1224
+ checkOffset(offset, 1, this.length);
1225
+ if (!(this[offset] & 128))
1226
+ return this[offset];
1227
+ return (255 - this[offset] + 1) * -1;
1228
+ };
1229
+ Buffer2.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
1230
+ offset = offset >>> 0;
1231
+ if (!noAssert)
1232
+ checkOffset(offset, 2, this.length);
1233
+ const val = this[offset] | this[offset + 1] << 8;
1234
+ return val & 32768 ? val | 4294901760 : val;
1235
+ };
1236
+ Buffer2.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
1237
+ offset = offset >>> 0;
1238
+ if (!noAssert)
1239
+ checkOffset(offset, 2, this.length);
1240
+ const val = this[offset + 1] | this[offset] << 8;
1241
+ return val & 32768 ? val | 4294901760 : val;
1242
+ };
1243
+ Buffer2.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
1244
+ offset = offset >>> 0;
1245
+ if (!noAssert)
1246
+ checkOffset(offset, 4, this.length);
1247
+ return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
1248
+ };
1249
+ Buffer2.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
1250
+ offset = offset >>> 0;
1251
+ if (!noAssert)
1252
+ checkOffset(offset, 4, this.length);
1253
+ return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
1254
+ };
1255
+ Buffer2.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE(offset) {
1256
+ offset = offset >>> 0;
1257
+ validateNumber(offset, "offset");
1258
+ const first = this[offset];
1259
+ const last = this[offset + 7];
1260
+ if (first === void 0 || last === void 0) {
1261
+ boundsError(offset, this.length - 8);
1262
+ }
1263
+ const val = this[offset + 4] + this[offset + 5] * 2 ** 8 + this[offset + 6] * 2 ** 16 + (last << 24);
1264
+ return (BigInt(val) << BigInt(32)) + BigInt(first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24);
1265
+ });
1266
+ Buffer2.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE(offset) {
1267
+ offset = offset >>> 0;
1268
+ validateNumber(offset, "offset");
1269
+ const first = this[offset];
1270
+ const last = this[offset + 7];
1271
+ if (first === void 0 || last === void 0) {
1272
+ boundsError(offset, this.length - 8);
1273
+ }
1274
+ const val = (first << 24) + // Overflow
1275
+ this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
1276
+ return (BigInt(val) << BigInt(32)) + BigInt(this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last);
1277
+ });
1278
+ Buffer2.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
1279
+ offset = offset >>> 0;
1280
+ if (!noAssert)
1281
+ checkOffset(offset, 4, this.length);
1282
+ return ieee754.read(this, offset, true, 23, 4);
1283
+ };
1284
+ Buffer2.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
1285
+ offset = offset >>> 0;
1286
+ if (!noAssert)
1287
+ checkOffset(offset, 4, this.length);
1288
+ return ieee754.read(this, offset, false, 23, 4);
1289
+ };
1290
+ Buffer2.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
1291
+ offset = offset >>> 0;
1292
+ if (!noAssert)
1293
+ checkOffset(offset, 8, this.length);
1294
+ return ieee754.read(this, offset, true, 52, 8);
1295
+ };
1296
+ Buffer2.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
1297
+ offset = offset >>> 0;
1298
+ if (!noAssert)
1299
+ checkOffset(offset, 8, this.length);
1300
+ return ieee754.read(this, offset, false, 52, 8);
1301
+ };
1302
+ function checkInt(buf, value, offset, ext, max, min) {
1303
+ if (!Buffer2.isBuffer(buf))
1304
+ throw new TypeError('"buffer" argument must be a Buffer instance');
1305
+ if (value > max || value < min)
1306
+ throw new RangeError('"value" argument is out of bounds');
1307
+ if (offset + ext > buf.length)
1308
+ throw new RangeError("Index out of range");
1309
+ }
1310
+ Buffer2.prototype.writeUintLE = Buffer2.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) {
1311
+ value = +value;
1312
+ offset = offset >>> 0;
1313
+ byteLength2 = byteLength2 >>> 0;
1314
+ if (!noAssert) {
1315
+ const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
1316
+ checkInt(this, value, offset, byteLength2, maxBytes, 0);
1317
+ }
1318
+ let mul = 1;
1319
+ let i = 0;
1320
+ this[offset] = value & 255;
1321
+ while (++i < byteLength2 && (mul *= 256)) {
1322
+ this[offset + i] = value / mul & 255;
1323
+ }
1324
+ return offset + byteLength2;
1325
+ };
1326
+ Buffer2.prototype.writeUintBE = Buffer2.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) {
1327
+ value = +value;
1328
+ offset = offset >>> 0;
1329
+ byteLength2 = byteLength2 >>> 0;
1330
+ if (!noAssert) {
1331
+ const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
1332
+ checkInt(this, value, offset, byteLength2, maxBytes, 0);
1333
+ }
1334
+ let i = byteLength2 - 1;
1335
+ let mul = 1;
1336
+ this[offset + i] = value & 255;
1337
+ while (--i >= 0 && (mul *= 256)) {
1338
+ this[offset + i] = value / mul & 255;
1339
+ }
1340
+ return offset + byteLength2;
1341
+ };
1342
+ Buffer2.prototype.writeUint8 = Buffer2.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
1343
+ value = +value;
1344
+ offset = offset >>> 0;
1345
+ if (!noAssert)
1346
+ checkInt(this, value, offset, 1, 255, 0);
1347
+ this[offset] = value & 255;
1348
+ return offset + 1;
1349
+ };
1350
+ Buffer2.prototype.writeUint16LE = Buffer2.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
1351
+ value = +value;
1352
+ offset = offset >>> 0;
1353
+ if (!noAssert)
1354
+ checkInt(this, value, offset, 2, 65535, 0);
1355
+ this[offset] = value & 255;
1356
+ this[offset + 1] = value >>> 8;
1357
+ return offset + 2;
1358
+ };
1359
+ Buffer2.prototype.writeUint16BE = Buffer2.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
1360
+ value = +value;
1361
+ offset = offset >>> 0;
1362
+ if (!noAssert)
1363
+ checkInt(this, value, offset, 2, 65535, 0);
1364
+ this[offset] = value >>> 8;
1365
+ this[offset + 1] = value & 255;
1366
+ return offset + 2;
1367
+ };
1368
+ Buffer2.prototype.writeUint32LE = Buffer2.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
1369
+ value = +value;
1370
+ offset = offset >>> 0;
1371
+ if (!noAssert)
1372
+ checkInt(this, value, offset, 4, 4294967295, 0);
1373
+ this[offset + 3] = value >>> 24;
1374
+ this[offset + 2] = value >>> 16;
1375
+ this[offset + 1] = value >>> 8;
1376
+ this[offset] = value & 255;
1377
+ return offset + 4;
1378
+ };
1379
+ Buffer2.prototype.writeUint32BE = Buffer2.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
1380
+ value = +value;
1381
+ offset = offset >>> 0;
1382
+ if (!noAssert)
1383
+ checkInt(this, value, offset, 4, 4294967295, 0);
1384
+ this[offset] = value >>> 24;
1385
+ this[offset + 1] = value >>> 16;
1386
+ this[offset + 2] = value >>> 8;
1387
+ this[offset + 3] = value & 255;
1388
+ return offset + 4;
1389
+ };
1390
+ function wrtBigUInt64LE(buf, value, offset, min, max) {
1391
+ checkIntBI(value, min, max, buf, offset, 7);
1392
+ let lo = Number(value & BigInt(4294967295));
1393
+ buf[offset++] = lo;
1394
+ lo = lo >> 8;
1395
+ buf[offset++] = lo;
1396
+ lo = lo >> 8;
1397
+ buf[offset++] = lo;
1398
+ lo = lo >> 8;
1399
+ buf[offset++] = lo;
1400
+ let hi = Number(value >> BigInt(32) & BigInt(4294967295));
1401
+ buf[offset++] = hi;
1402
+ hi = hi >> 8;
1403
+ buf[offset++] = hi;
1404
+ hi = hi >> 8;
1405
+ buf[offset++] = hi;
1406
+ hi = hi >> 8;
1407
+ buf[offset++] = hi;
1408
+ return offset;
1409
+ }
1410
+ function wrtBigUInt64BE(buf, value, offset, min, max) {
1411
+ checkIntBI(value, min, max, buf, offset, 7);
1412
+ let lo = Number(value & BigInt(4294967295));
1413
+ buf[offset + 7] = lo;
1414
+ lo = lo >> 8;
1415
+ buf[offset + 6] = lo;
1416
+ lo = lo >> 8;
1417
+ buf[offset + 5] = lo;
1418
+ lo = lo >> 8;
1419
+ buf[offset + 4] = lo;
1420
+ let hi = Number(value >> BigInt(32) & BigInt(4294967295));
1421
+ buf[offset + 3] = hi;
1422
+ hi = hi >> 8;
1423
+ buf[offset + 2] = hi;
1424
+ hi = hi >> 8;
1425
+ buf[offset + 1] = hi;
1426
+ hi = hi >> 8;
1427
+ buf[offset] = hi;
1428
+ return offset + 8;
1429
+ }
1430
+ Buffer2.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) {
1431
+ return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
1432
+ });
1433
+ Buffer2.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) {
1434
+ return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
1435
+ });
1436
+ Buffer2.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) {
1437
+ value = +value;
1438
+ offset = offset >>> 0;
1439
+ if (!noAssert) {
1440
+ const limit = Math.pow(2, 8 * byteLength2 - 1);
1441
+ checkInt(this, value, offset, byteLength2, limit - 1, -limit);
1442
+ }
1443
+ let i = 0;
1444
+ let mul = 1;
1445
+ let sub = 0;
1446
+ this[offset] = value & 255;
1447
+ while (++i < byteLength2 && (mul *= 256)) {
1448
+ if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
1449
+ sub = 1;
1450
+ }
1451
+ this[offset + i] = (value / mul >> 0) - sub & 255;
1452
+ }
1453
+ return offset + byteLength2;
1454
+ };
1455
+ Buffer2.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) {
1456
+ value = +value;
1457
+ offset = offset >>> 0;
1458
+ if (!noAssert) {
1459
+ const limit = Math.pow(2, 8 * byteLength2 - 1);
1460
+ checkInt(this, value, offset, byteLength2, limit - 1, -limit);
1461
+ }
1462
+ let i = byteLength2 - 1;
1463
+ let mul = 1;
1464
+ let sub = 0;
1465
+ this[offset + i] = value & 255;
1466
+ while (--i >= 0 && (mul *= 256)) {
1467
+ if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
1468
+ sub = 1;
1469
+ }
1470
+ this[offset + i] = (value / mul >> 0) - sub & 255;
1471
+ }
1472
+ return offset + byteLength2;
1473
+ };
1474
+ Buffer2.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
1475
+ value = +value;
1476
+ offset = offset >>> 0;
1477
+ if (!noAssert)
1478
+ checkInt(this, value, offset, 1, 127, -128);
1479
+ if (value < 0)
1480
+ value = 255 + value + 1;
1481
+ this[offset] = value & 255;
1482
+ return offset + 1;
1483
+ };
1484
+ Buffer2.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
1485
+ value = +value;
1486
+ offset = offset >>> 0;
1487
+ if (!noAssert)
1488
+ checkInt(this, value, offset, 2, 32767, -32768);
1489
+ this[offset] = value & 255;
1490
+ this[offset + 1] = value >>> 8;
1491
+ return offset + 2;
1492
+ };
1493
+ Buffer2.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
1494
+ value = +value;
1495
+ offset = offset >>> 0;
1496
+ if (!noAssert)
1497
+ checkInt(this, value, offset, 2, 32767, -32768);
1498
+ this[offset] = value >>> 8;
1499
+ this[offset + 1] = value & 255;
1500
+ return offset + 2;
1501
+ };
1502
+ Buffer2.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
1503
+ value = +value;
1504
+ offset = offset >>> 0;
1505
+ if (!noAssert)
1506
+ checkInt(this, value, offset, 4, 2147483647, -2147483648);
1507
+ this[offset] = value & 255;
1508
+ this[offset + 1] = value >>> 8;
1509
+ this[offset + 2] = value >>> 16;
1510
+ this[offset + 3] = value >>> 24;
1511
+ return offset + 4;
1512
+ };
1513
+ Buffer2.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
1514
+ value = +value;
1515
+ offset = offset >>> 0;
1516
+ if (!noAssert)
1517
+ checkInt(this, value, offset, 4, 2147483647, -2147483648);
1518
+ if (value < 0)
1519
+ value = 4294967295 + value + 1;
1520
+ this[offset] = value >>> 24;
1521
+ this[offset + 1] = value >>> 16;
1522
+ this[offset + 2] = value >>> 8;
1523
+ this[offset + 3] = value & 255;
1524
+ return offset + 4;
1525
+ };
1526
+ Buffer2.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) {
1527
+ return wrtBigUInt64LE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
1528
+ });
1529
+ Buffer2.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset = 0) {
1530
+ return wrtBigUInt64BE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
1531
+ });
1532
+ function checkIEEE754(buf, value, offset, ext, max, min) {
1533
+ if (offset + ext > buf.length)
1534
+ throw new RangeError("Index out of range");
1535
+ if (offset < 0)
1536
+ throw new RangeError("Index out of range");
1537
+ }
1538
+ function writeFloat(buf, value, offset, littleEndian, noAssert) {
1539
+ value = +value;
1540
+ offset = offset >>> 0;
1541
+ if (!noAssert) {
1542
+ checkIEEE754(buf, value, offset, 4);
1543
+ }
1544
+ ieee754.write(buf, value, offset, littleEndian, 23, 4);
1545
+ return offset + 4;
1546
+ }
1547
+ Buffer2.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
1548
+ return writeFloat(this, value, offset, true, noAssert);
1549
+ };
1550
+ Buffer2.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
1551
+ return writeFloat(this, value, offset, false, noAssert);
1552
+ };
1553
+ function writeDouble(buf, value, offset, littleEndian, noAssert) {
1554
+ value = +value;
1555
+ offset = offset >>> 0;
1556
+ if (!noAssert) {
1557
+ checkIEEE754(buf, value, offset, 8);
1558
+ }
1559
+ ieee754.write(buf, value, offset, littleEndian, 52, 8);
1560
+ return offset + 8;
1561
+ }
1562
+ Buffer2.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
1563
+ return writeDouble(this, value, offset, true, noAssert);
1564
+ };
1565
+ Buffer2.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
1566
+ return writeDouble(this, value, offset, false, noAssert);
1567
+ };
1568
+ Buffer2.prototype.copy = function copy(target, targetStart, start, end) {
1569
+ if (!Buffer2.isBuffer(target))
1570
+ throw new TypeError("argument should be a Buffer");
1571
+ if (!start)
1572
+ start = 0;
1573
+ if (!end && end !== 0)
1574
+ end = this.length;
1575
+ if (targetStart >= target.length)
1576
+ targetStart = target.length;
1577
+ if (!targetStart)
1578
+ targetStart = 0;
1579
+ if (end > 0 && end < start)
1580
+ end = start;
1581
+ if (end === start)
1582
+ return 0;
1583
+ if (target.length === 0 || this.length === 0)
1584
+ return 0;
1585
+ if (targetStart < 0) {
1586
+ throw new RangeError("targetStart out of bounds");
1587
+ }
1588
+ if (start < 0 || start >= this.length)
1589
+ throw new RangeError("Index out of range");
1590
+ if (end < 0)
1591
+ throw new RangeError("sourceEnd out of bounds");
1592
+ if (end > this.length)
1593
+ end = this.length;
1594
+ if (target.length - targetStart < end - start) {
1595
+ end = target.length - targetStart + start;
1596
+ }
1597
+ const len = end - start;
1598
+ if (this === target && typeof Uint8Array.prototype.copyWithin === "function") {
1599
+ this.copyWithin(targetStart, start, end);
1600
+ } else {
1601
+ Uint8Array.prototype.set.call(
1602
+ target,
1603
+ this.subarray(start, end),
1604
+ targetStart
1605
+ );
1606
+ }
1607
+ return len;
1608
+ };
1609
+ Buffer2.prototype.fill = function fill(val, start, end, encoding) {
1610
+ if (typeof val === "string") {
1611
+ if (typeof start === "string") {
1612
+ encoding = start;
1613
+ start = 0;
1614
+ end = this.length;
1615
+ } else if (typeof end === "string") {
1616
+ encoding = end;
1617
+ end = this.length;
1618
+ }
1619
+ if (encoding !== void 0 && typeof encoding !== "string") {
1620
+ throw new TypeError("encoding must be a string");
1621
+ }
1622
+ if (typeof encoding === "string" && !Buffer2.isEncoding(encoding)) {
1623
+ throw new TypeError("Unknown encoding: " + encoding);
1624
+ }
1625
+ if (val.length === 1) {
1626
+ const code = val.charCodeAt(0);
1627
+ if (encoding === "utf8" && code < 128 || encoding === "latin1") {
1628
+ val = code;
1629
+ }
1630
+ }
1631
+ } else if (typeof val === "number") {
1632
+ val = val & 255;
1633
+ } else if (typeof val === "boolean") {
1634
+ val = Number(val);
1635
+ }
1636
+ if (start < 0 || this.length < start || this.length < end) {
1637
+ throw new RangeError("Out of range index");
1638
+ }
1639
+ if (end <= start) {
1640
+ return this;
1641
+ }
1642
+ start = start >>> 0;
1643
+ end = end === void 0 ? this.length : end >>> 0;
1644
+ if (!val)
1645
+ val = 0;
1646
+ let i;
1647
+ if (typeof val === "number") {
1648
+ for (i = start; i < end; ++i) {
1649
+ this[i] = val;
1650
+ }
1651
+ } else {
1652
+ const bytes = Buffer2.isBuffer(val) ? val : Buffer2.from(val, encoding);
1653
+ const len = bytes.length;
1654
+ if (len === 0) {
1655
+ throw new TypeError('The value "' + val + '" is invalid for argument "value"');
1656
+ }
1657
+ for (i = 0; i < end - start; ++i) {
1658
+ this[i + start] = bytes[i % len];
1659
+ }
1660
+ }
1661
+ return this;
1662
+ };
1663
+ var errors = {};
1664
+ function E(sym, getMessage, Base) {
1665
+ errors[sym] = class NodeError extends Base {
1666
+ constructor() {
1667
+ super();
1668
+ Object.defineProperty(this, "message", {
1669
+ value: getMessage.apply(this, arguments),
1670
+ writable: true,
1671
+ configurable: true
1672
+ });
1673
+ this.name = `${this.name} [${sym}]`;
1674
+ this.stack;
1675
+ delete this.name;
1676
+ }
1677
+ get code() {
1678
+ return sym;
1679
+ }
1680
+ set code(value) {
1681
+ Object.defineProperty(this, "code", {
1682
+ configurable: true,
1683
+ enumerable: true,
1684
+ value,
1685
+ writable: true
1686
+ });
1687
+ }
1688
+ toString() {
1689
+ return `${this.name} [${sym}]: ${this.message}`;
1690
+ }
1691
+ };
1692
+ }
1693
+ E(
1694
+ "ERR_BUFFER_OUT_OF_BOUNDS",
1695
+ function(name) {
1696
+ if (name) {
1697
+ return `${name} is outside of buffer bounds`;
1698
+ }
1699
+ return "Attempt to access memory outside buffer bounds";
1700
+ },
1701
+ RangeError
1702
+ );
1703
+ E(
1704
+ "ERR_INVALID_ARG_TYPE",
1705
+ function(name, actual) {
1706
+ return `The "${name}" argument must be of type number. Received type ${typeof actual}`;
1707
+ },
1708
+ TypeError
1709
+ );
1710
+ E(
1711
+ "ERR_OUT_OF_RANGE",
1712
+ function(str, range, input) {
1713
+ let msg = `The value of "${str}" is out of range.`;
1714
+ let received = input;
1715
+ if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
1716
+ received = addNumericalSeparator(String(input));
1717
+ } else if (typeof input === "bigint") {
1718
+ received = String(input);
1719
+ if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
1720
+ received = addNumericalSeparator(received);
1721
+ }
1722
+ received += "n";
1723
+ }
1724
+ msg += ` It must be ${range}. Received ${received}`;
1725
+ return msg;
1726
+ },
1727
+ RangeError
1728
+ );
1729
+ function addNumericalSeparator(val) {
1730
+ let res = "";
1731
+ let i = val.length;
1732
+ const start = val[0] === "-" ? 1 : 0;
1733
+ for (; i >= start + 4; i -= 3) {
1734
+ res = `_${val.slice(i - 3, i)}${res}`;
1735
+ }
1736
+ return `${val.slice(0, i)}${res}`;
1737
+ }
1738
+ function checkBounds(buf, offset, byteLength2) {
1739
+ validateNumber(offset, "offset");
1740
+ if (buf[offset] === void 0 || buf[offset + byteLength2] === void 0) {
1741
+ boundsError(offset, buf.length - (byteLength2 + 1));
1742
+ }
1743
+ }
1744
+ function checkIntBI(value, min, max, buf, offset, byteLength2) {
1745
+ if (value > max || value < min) {
1746
+ const n = typeof min === "bigint" ? "n" : "";
1747
+ let range;
1748
+ if (byteLength2 > 3) {
1749
+ if (min === 0 || min === BigInt(0)) {
1750
+ range = `>= 0${n} and < 2${n} ** ${(byteLength2 + 1) * 8}${n}`;
1751
+ } else {
1752
+ range = `>= -(2${n} ** ${(byteLength2 + 1) * 8 - 1}${n}) and < 2 ** ${(byteLength2 + 1) * 8 - 1}${n}`;
1753
+ }
1754
+ } else {
1755
+ range = `>= ${min}${n} and <= ${max}${n}`;
1756
+ }
1757
+ throw new errors.ERR_OUT_OF_RANGE("value", range, value);
1758
+ }
1759
+ checkBounds(buf, offset, byteLength2);
1760
+ }
1761
+ function validateNumber(value, name) {
1762
+ if (typeof value !== "number") {
1763
+ throw new errors.ERR_INVALID_ARG_TYPE(name, "number", value);
1764
+ }
1765
+ }
1766
+ function boundsError(value, length, type) {
1767
+ if (Math.floor(value) !== value) {
1768
+ validateNumber(value, type);
1769
+ throw new errors.ERR_OUT_OF_RANGE(type || "offset", "an integer", value);
1770
+ }
1771
+ if (length < 0) {
1772
+ throw new errors.ERR_BUFFER_OUT_OF_BOUNDS();
1773
+ }
1774
+ throw new errors.ERR_OUT_OF_RANGE(
1775
+ type || "offset",
1776
+ `>= ${type ? 1 : 0} and <= ${length}`,
1777
+ value
1778
+ );
1779
+ }
1780
+ var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
1781
+ function base64clean(str) {
1782
+ str = str.split("=")[0];
1783
+ str = str.trim().replace(INVALID_BASE64_RE, "");
1784
+ if (str.length < 2)
1785
+ return "";
1786
+ while (str.length % 4 !== 0) {
1787
+ str = str + "=";
1788
+ }
1789
+ return str;
1790
+ }
1791
+ function utf8ToBytes(string, units) {
1792
+ units = units || Infinity;
1793
+ let codePoint;
1794
+ const length = string.length;
1795
+ let leadSurrogate = null;
1796
+ const bytes = [];
1797
+ for (let i = 0; i < length; ++i) {
1798
+ codePoint = string.charCodeAt(i);
1799
+ if (codePoint > 55295 && codePoint < 57344) {
1800
+ if (!leadSurrogate) {
1801
+ if (codePoint > 56319) {
1802
+ if ((units -= 3) > -1)
1803
+ bytes.push(239, 191, 189);
1804
+ continue;
1805
+ } else if (i + 1 === length) {
1806
+ if ((units -= 3) > -1)
1807
+ bytes.push(239, 191, 189);
1808
+ continue;
1809
+ }
1810
+ leadSurrogate = codePoint;
1811
+ continue;
1812
+ }
1813
+ if (codePoint < 56320) {
1814
+ if ((units -= 3) > -1)
1815
+ bytes.push(239, 191, 189);
1816
+ leadSurrogate = codePoint;
1817
+ continue;
1818
+ }
1819
+ codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
1820
+ } else if (leadSurrogate) {
1821
+ if ((units -= 3) > -1)
1822
+ bytes.push(239, 191, 189);
1823
+ }
1824
+ leadSurrogate = null;
1825
+ if (codePoint < 128) {
1826
+ if ((units -= 1) < 0)
1827
+ break;
1828
+ bytes.push(codePoint);
1829
+ } else if (codePoint < 2048) {
1830
+ if ((units -= 2) < 0)
1831
+ break;
1832
+ bytes.push(
1833
+ codePoint >> 6 | 192,
1834
+ codePoint & 63 | 128
1835
+ );
1836
+ } else if (codePoint < 65536) {
1837
+ if ((units -= 3) < 0)
1838
+ break;
1839
+ bytes.push(
1840
+ codePoint >> 12 | 224,
1841
+ codePoint >> 6 & 63 | 128,
1842
+ codePoint & 63 | 128
1843
+ );
1844
+ } else if (codePoint < 1114112) {
1845
+ if ((units -= 4) < 0)
1846
+ break;
1847
+ bytes.push(
1848
+ codePoint >> 18 | 240,
1849
+ codePoint >> 12 & 63 | 128,
1850
+ codePoint >> 6 & 63 | 128,
1851
+ codePoint & 63 | 128
1852
+ );
1853
+ } else {
1854
+ throw new Error("Invalid code point");
1855
+ }
1856
+ }
1857
+ return bytes;
1858
+ }
1859
+ function asciiToBytes(str) {
1860
+ const byteArray = [];
1861
+ for (let i = 0; i < str.length; ++i) {
1862
+ byteArray.push(str.charCodeAt(i) & 255);
1863
+ }
1864
+ return byteArray;
1865
+ }
1866
+ function utf16leToBytes(str, units) {
1867
+ let c, hi, lo;
1868
+ const byteArray = [];
1869
+ for (let i = 0; i < str.length; ++i) {
1870
+ if ((units -= 2) < 0)
1871
+ break;
1872
+ c = str.charCodeAt(i);
1873
+ hi = c >> 8;
1874
+ lo = c % 256;
1875
+ byteArray.push(lo);
1876
+ byteArray.push(hi);
1877
+ }
1878
+ return byteArray;
1879
+ }
1880
+ function base64ToBytes(str) {
1881
+ return base64.toByteArray(base64clean(str));
1882
+ }
1883
+ function blitBuffer(src, dst, offset, length) {
1884
+ let i;
1885
+ for (i = 0; i < length; ++i) {
1886
+ if (i + offset >= dst.length || i >= src.length)
1887
+ break;
1888
+ dst[i + offset] = src[i];
1889
+ }
1890
+ return i;
1891
+ }
1892
+ function isInstance(obj, type) {
1893
+ return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name;
1894
+ }
1895
+ function numberIsNaN(obj) {
1896
+ return obj !== obj;
1897
+ }
1898
+ var hexSliceLookupTable = function() {
1899
+ const alphabet = "0123456789abcdef";
1900
+ const table = new Array(256);
1901
+ for (let i = 0; i < 16; ++i) {
1902
+ const i16 = i * 16;
1903
+ for (let j = 0; j < 16; ++j) {
1904
+ table[i16 + j] = alphabet[i] + alphabet[j];
1905
+ }
1906
+ }
1907
+ return table;
1908
+ }();
1909
+ function defineBigIntMethod(fn) {
1910
+ return typeof BigInt === "undefined" ? BufferBigIntNotDefined : fn;
1911
+ }
1912
+ function BufferBigIntNotDefined() {
1913
+ throw new Error("BigInt not supported");
1914
+ }
1915
+ }
1916
+ });
32
1917
 
33
1918
  // ../../node_modules/bn.js/lib/bn.js
34
1919
  var require_bn = __commonJS({
35
- "../../node_modules/bn.js/lib/bn.js"(exports, module2) {
36
- (function(module3, exports2) {
37
- "use strict";
1920
+ "../../node_modules/bn.js/lib/bn.js"(exports, module) {
1921
+ (function(module2, exports2) {
38
1922
  function assert(val, msg) {
39
1923
  if (!val)
40
1924
  throw new Error(msg || "Assertion failed");
@@ -63,8 +1947,8 @@ var require_bn = __commonJS({
63
1947
  this._init(number || 0, base2 || 10, endian || "be");
64
1948
  }
65
1949
  }
66
- if (typeof module3 === "object") {
67
- module3.exports = BN2;
1950
+ if (typeof module2 === "object") {
1951
+ module2.exports = BN2;
68
1952
  } else {
69
1953
  exports2.BN = BN2;
70
1954
  }
@@ -75,7 +1959,7 @@ var require_bn = __commonJS({
75
1959
  if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") {
76
1960
  Buffer2 = window.Buffer;
77
1961
  } else {
78
- Buffer2 = require("buffer").Buffer;
1962
+ Buffer2 = require_buffer().Buffer;
79
1963
  }
80
1964
  } catch (e) {
81
1965
  }
@@ -1593,149 +3477,6 @@ var require_bn = __commonJS({
1593
3477
  }
1594
3478
  return res;
1595
3479
  };
1596
- function FFTM(x, y) {
1597
- this.x = x;
1598
- this.y = y;
1599
- }
1600
- FFTM.prototype.makeRBT = function makeRBT(N) {
1601
- var t = new Array(N);
1602
- var l = BN2.prototype._countBits(N) - 1;
1603
- for (var i = 0; i < N; i++) {
1604
- t[i] = this.revBin(i, l, N);
1605
- }
1606
- return t;
1607
- };
1608
- FFTM.prototype.revBin = function revBin(x, l, N) {
1609
- if (x === 0 || x === N - 1)
1610
- return x;
1611
- var rb = 0;
1612
- for (var i = 0; i < l; i++) {
1613
- rb |= (x & 1) << l - i - 1;
1614
- x >>= 1;
1615
- }
1616
- return rb;
1617
- };
1618
- FFTM.prototype.permute = function permute(rbt, rws, iws, rtws, itws, N) {
1619
- for (var i = 0; i < N; i++) {
1620
- rtws[i] = rws[rbt[i]];
1621
- itws[i] = iws[rbt[i]];
1622
- }
1623
- };
1624
- FFTM.prototype.transform = function transform(rws, iws, rtws, itws, N, rbt) {
1625
- this.permute(rbt, rws, iws, rtws, itws, N);
1626
- for (var s = 1; s < N; s <<= 1) {
1627
- var l = s << 1;
1628
- var rtwdf = Math.cos(2 * Math.PI / l);
1629
- var itwdf = Math.sin(2 * Math.PI / l);
1630
- for (var p = 0; p < N; p += l) {
1631
- var rtwdf_ = rtwdf;
1632
- var itwdf_ = itwdf;
1633
- for (var j = 0; j < s; j++) {
1634
- var re = rtws[p + j];
1635
- var ie = itws[p + j];
1636
- var ro = rtws[p + j + s];
1637
- var io = itws[p + j + s];
1638
- var rx = rtwdf_ * ro - itwdf_ * io;
1639
- io = rtwdf_ * io + itwdf_ * ro;
1640
- ro = rx;
1641
- rtws[p + j] = re + ro;
1642
- itws[p + j] = ie + io;
1643
- rtws[p + j + s] = re - ro;
1644
- itws[p + j + s] = ie - io;
1645
- if (j !== l) {
1646
- rx = rtwdf * rtwdf_ - itwdf * itwdf_;
1647
- itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
1648
- rtwdf_ = rx;
1649
- }
1650
- }
1651
- }
1652
- }
1653
- };
1654
- FFTM.prototype.guessLen13b = function guessLen13b(n, m) {
1655
- var N = Math.max(m, n) | 1;
1656
- var odd = N & 1;
1657
- var i = 0;
1658
- for (N = N / 2 | 0; N; N = N >>> 1) {
1659
- i++;
1660
- }
1661
- return 1 << i + 1 + odd;
1662
- };
1663
- FFTM.prototype.conjugate = function conjugate(rws, iws, N) {
1664
- if (N <= 1)
1665
- return;
1666
- for (var i = 0; i < N / 2; i++) {
1667
- var t = rws[i];
1668
- rws[i] = rws[N - i - 1];
1669
- rws[N - i - 1] = t;
1670
- t = iws[i];
1671
- iws[i] = -iws[N - i - 1];
1672
- iws[N - i - 1] = -t;
1673
- }
1674
- };
1675
- FFTM.prototype.normalize13b = function normalize13b(ws, N) {
1676
- var carry = 0;
1677
- for (var i = 0; i < N / 2; i++) {
1678
- var w = Math.round(ws[2 * i + 1] / N) * 8192 + Math.round(ws[2 * i] / N) + carry;
1679
- ws[i] = w & 67108863;
1680
- if (w < 67108864) {
1681
- carry = 0;
1682
- } else {
1683
- carry = w / 67108864 | 0;
1684
- }
1685
- }
1686
- return ws;
1687
- };
1688
- FFTM.prototype.convert13b = function convert13b(ws, len, rws, N) {
1689
- var carry = 0;
1690
- for (var i = 0; i < len; i++) {
1691
- carry = carry + (ws[i] | 0);
1692
- rws[2 * i] = carry & 8191;
1693
- carry = carry >>> 13;
1694
- rws[2 * i + 1] = carry & 8191;
1695
- carry = carry >>> 13;
1696
- }
1697
- for (i = 2 * len; i < N; ++i) {
1698
- rws[i] = 0;
1699
- }
1700
- assert(carry === 0);
1701
- assert((carry & ~8191) === 0);
1702
- };
1703
- FFTM.prototype.stub = function stub(N) {
1704
- var ph = new Array(N);
1705
- for (var i = 0; i < N; i++) {
1706
- ph[i] = 0;
1707
- }
1708
- return ph;
1709
- };
1710
- FFTM.prototype.mulp = function mulp(x, y, out) {
1711
- var N = 2 * this.guessLen13b(x.length, y.length);
1712
- var rbt = this.makeRBT(N);
1713
- var _ = this.stub(N);
1714
- var rws = new Array(N);
1715
- var rwst = new Array(N);
1716
- var iwst = new Array(N);
1717
- var nrws = new Array(N);
1718
- var nrwst = new Array(N);
1719
- var niwst = new Array(N);
1720
- var rmws = out.words;
1721
- rmws.length = N;
1722
- this.convert13b(x.words, x.length, rws, N);
1723
- this.convert13b(y.words, y.length, nrws, N);
1724
- this.transform(rws, _, rwst, iwst, N, rbt);
1725
- this.transform(nrws, _, nrwst, niwst, N, rbt);
1726
- for (var i = 0; i < N; i++) {
1727
- var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
1728
- iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
1729
- rwst[i] = rx;
1730
- }
1731
- this.conjugate(rwst, iwst, N);
1732
- this.transform(rwst, iwst, rmws, _, N, rbt);
1733
- this.conjugate(rmws, _, N);
1734
- this.normalize13b(rmws, N);
1735
- out.negative = x.negative ^ y.negative;
1736
- out.length = x.length + y.length;
1737
- return out._strip();
1738
- };
1739
3480
  BN2.prototype.mul = function mul(num) {
1740
3481
  var out = new BN2(null);
1741
3482
  out.words = new Array(this.length + num.length);
@@ -1852,8 +3593,7 @@ var require_bn = __commonJS({
1852
3593
  }
1853
3594
  maskedWords.length = s;
1854
3595
  }
1855
- if (s === 0) {
1856
- } else if (this.length > s) {
3596
+ if (s === 0) ; else if (this.length > s) {
1857
3597
  this.length -= s;
1858
3598
  for (i = 0; i < this.length; i++) {
1859
3599
  this.words[i] = this.words[i + s];
@@ -2963,14 +4703,13 @@ var require_bn = __commonJS({
2963
4703
  var res = this.imod(a._invmp(this.m).mul(this.r2));
2964
4704
  return res._forceRed(this);
2965
4705
  };
2966
- })(typeof module2 === "undefined" || module2, exports);
4706
+ })(typeof module === "undefined" || module, exports);
2967
4707
  }
2968
4708
  });
2969
4709
 
2970
4710
  // ../../node_modules/@layerzerolabs/lz-v2-utilities/node_modules/base-x/src/index.js
2971
4711
  var require_src = __commonJS({
2972
- "../../node_modules/@layerzerolabs/lz-v2-utilities/node_modules/base-x/src/index.js"(exports, module2) {
2973
- "use strict";
4712
+ "../../node_modules/@layerzerolabs/lz-v2-utilities/node_modules/base-x/src/index.js"(exports, module) {
2974
4713
  function base2(ALPHABET) {
2975
4714
  if (ALPHABET.length >= 255) {
2976
4715
  throw new TypeError("Alphabet too long");
@@ -2992,8 +4731,7 @@ var require_src = __commonJS({
2992
4731
  var FACTOR = Math.log(BASE) / Math.log(256);
2993
4732
  var iFACTOR = Math.log(256) / Math.log(BASE);
2994
4733
  function encode(source) {
2995
- if (source instanceof Uint8Array) {
2996
- } else if (ArrayBuffer.isView(source)) {
4734
+ if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {
2997
4735
  source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
2998
4736
  } else if (Array.isArray(source)) {
2999
4737
  source = Uint8Array.from(source);
@@ -3099,130 +4837,19 @@ var require_src = __commonJS({
3099
4837
  decode
3100
4838
  };
3101
4839
  }
3102
- module2.exports = base2;
4840
+ module.exports = base2;
3103
4841
  }
3104
4842
  });
3105
4843
 
3106
4844
  // ../../node_modules/@layerzerolabs/lz-v2-utilities/node_modules/bs58/index.js
3107
4845
  var require_bs58 = __commonJS({
3108
- "../../node_modules/@layerzerolabs/lz-v2-utilities/node_modules/bs58/index.js"(exports, module2) {
4846
+ "../../node_modules/@layerzerolabs/lz-v2-utilities/node_modules/bs58/index.js"(exports, module) {
3109
4847
  var basex = require_src();
3110
4848
  var ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
3111
- module2.exports = basex(ALPHABET);
4849
+ module.exports = basex(ALPHABET);
3112
4850
  }
3113
4851
  });
3114
4852
 
3115
- // index.ts
3116
- var queries_exports = {};
3117
- __export(queries_exports, {
3118
- AutopoolCategory: () => AutopoolCategory,
3119
- BASE_ASSETS: () => BASE_ASSETS,
3120
- BATCH_SIZE: () => BATCH_SIZE,
3121
- ETH_BASE_ASSETS: () => ETH_BASE_ASSETS,
3122
- EUR_BASE_ASSETS: () => EUR_BASE_ASSETS,
3123
- MessageStatus: () => MessageStatus,
3124
- PRICED_TOKENS: () => PRICED_TOKENS,
3125
- USD_BASE_ASSETS: () => USD_BASE_ASSETS,
3126
- aggregateSTokeRewardsDayData: () => aggregateSTokeRewardsDayData,
3127
- arraysToObject: () => arraysToObject,
3128
- calculateRebalanceStats: () => calculateRebalanceStats,
3129
- convertBaseAssetToTokenPrices: () => convertBaseAssetToTokenPrices,
3130
- convertBaseAssetToTokenPricesAndDenom: () => convertBaseAssetToTokenPricesAndDenom,
3131
- fetchChainDataMap: () => fetchChainDataMap,
3132
- fetchChainRebalances: () => fetchChainRebalances,
3133
- fillMissingDates: () => fillMissingDates,
3134
- findClosestDateEntry: () => findClosestDateEntry,
3135
- findClosestEntry: () => findClosestEntry,
3136
- findClosestTimestampEntry: () => findClosestTimestampEntry,
3137
- formatDateRange: () => formatDateRange,
3138
- getAddressFromSystemRegistry: () => getAddressFromSystemRegistry,
3139
- getAllowance: () => getAllowance,
3140
- getAmountDeposited: () => getAmountDeposited,
3141
- getAmountWithdrawn: () => getAmountWithdrawn,
3142
- getAutopilotRouter: () => getAutopilotRouter,
3143
- getAutopoolCategory: () => getAutopoolCategory,
3144
- getAutopoolDayData: () => getAutopoolDayData,
3145
- getAutopoolInfo: () => getAutopoolInfo,
3146
- getAutopoolRebalances: () => getAutopoolRebalances,
3147
- getAutopools: () => getAutopools,
3148
- getAutopoolsHistory: () => getAutopoolsHistory,
3149
- getAutopoolsRebalances: () => getAutopoolsRebalances,
3150
- getBridgeFee: () => getBridgeFee,
3151
- getChainAutopools: () => getChainAutopools,
3152
- getChainCycleRolloverBlockNumber: () => getChainCycleRolloverBlockNumber,
3153
- getChainSToke: () => getChainSToke,
3154
- getChainSTokeRewards: () => getChainSTokeRewards,
3155
- getChainSubgraphStatus: () => getChainSubgraphStatus,
3156
- getChainUserActivity: () => getChainUserActivity,
3157
- getChainUserAutopools: () => getChainUserAutopools,
3158
- getChainUserSToke: () => getChainUserSToke,
3159
- getChainUserSTokeRewards: () => getChainUserSTokeRewards,
3160
- getChainUserSTokeVotes: () => getChainUserSTokeVotes,
3161
- getChainsForEnv: () => getChainsForEnv,
3162
- getCurrentCycleId: () => getCurrentCycleId,
3163
- getCurveLP: () => getCurveLP,
3164
- getCycleV1: () => getCycleV1,
3165
- getDefillamaPrice: () => getDefillamaPrice,
3166
- getDynamicSwap: () => getDynamicSwap,
3167
- getEthPrice: () => getEthPrice,
3168
- getEthPriceAtBlock: () => getEthPriceAtBlock,
3169
- getExchangeNames: () => getExchangeNames,
3170
- getGenStratAprs: () => getGenStratAprs,
3171
- getLayerzeroStatus: () => getLayerzeroStatus,
3172
- getMutlipleAutopoolRebalances: () => getMutlipleAutopoolRebalances,
3173
- getPoolStats: () => getPoolStats,
3174
- getPoolsAndDestinations: () => getPoolsAndDestinations,
3175
- getProtocolStats: () => getProtocolStats,
3176
- getRebalanceStats: () => getRebalanceStats,
3177
- getRebalanceValueUsd: () => getRebalanceValueUsd,
3178
- getRewardsPayloadV1: () => getRewardsPayloadV1,
3179
- getSToke: () => getSToke,
3180
- getSTokeChainsForEnv: () => getSTokeChainsForEnv,
3181
- getSTokeRewards: () => getSTokeRewards,
3182
- getSTokeVotes: () => getSTokeVotes,
3183
- getSubgraphStatus: () => getSubgraphStatus,
3184
- getSushiLP: () => getSushiLP,
3185
- getSwapQuote: () => getSwapQuote,
3186
- getSystemConfig: () => getSystemConfig,
3187
- getTimestampDaysFromStart: () => getTimestampDaysFromStart,
3188
- getTokePrice: () => getTokePrice,
3189
- getTokenList: () => getTokenList,
3190
- getTokenPrice: () => getTokenPrice,
3191
- getTokenPrices: () => getTokenPrices,
3192
- getTopAutopoolHolders: () => getTopAutopoolHolders,
3193
- getUserActivity: () => getUserActivity,
3194
- getUserAutoEthRewards: () => getUserAutoEthRewards,
3195
- getUserAutopool: () => getUserAutopool,
3196
- getUserAutopools: () => getUserAutopools,
3197
- getUserAutopoolsHistory: () => getUserAutopoolsHistory,
3198
- getUserAutopoolsRewards: () => getUserAutopoolsRewards,
3199
- getUserCurveLP: () => getUserCurveLP,
3200
- getUserRewardsV1: () => getUserRewardsV1,
3201
- getUserSToke: () => getUserSToke,
3202
- getUserSTokeVotes: () => getUserSTokeVotes,
3203
- getUserSushiLP: () => getUserSushiLP,
3204
- getUserTokenBalances: () => getUserTokenBalances,
3205
- getUserV1: () => getUserV1,
3206
- mergeArrays: () => mergeArrays,
3207
- mergeArraysWithKey: () => mergeArraysWithKey,
3208
- mergeStringArrays: () => mergeStringArrays,
3209
- modifyAutopoolName: () => modifyAutopoolName,
3210
- nestedArrayToObject: () => nestedArrayToObject,
3211
- paginateQuery: () => paginateQuery,
3212
- processRebalance: () => processRebalance,
3213
- processRebalancesInBatches: () => processRebalancesInBatches,
3214
- systemRegistryFunctionNames: () => systemRegistryFunctionNames,
3215
- updateRebalanceStats: () => updateRebalanceStats,
3216
- waitForMessageReceived: () => waitForMessageReceived
3217
- });
3218
- module.exports = __toCommonJS(queries_exports);
3219
-
3220
- // functions/getEthPrice.ts
3221
- var import_chains = require("viem/chains");
3222
-
3223
- // functions/getTokenPrice.ts
3224
- var import_constants = require("@tokemak/constants");
3225
-
3226
4853
  // functions/getDefillamaPrice.ts
3227
4854
  var getDefillamaPrice = async (tokenAddress) => {
3228
4855
  const response = await fetch(
@@ -3251,7 +4878,7 @@ var getTokenPrice = async ({
3251
4878
  if (excludedSources) {
3252
4879
  params.set("excludedSources", excludedSources.join(","));
3253
4880
  }
3254
- const response = await fetch(`${import_constants.TOKEMAK_SWAP_PRICING_URL}?${params}`);
4881
+ const response = await fetch(`${constants.TOKEMAK_SWAP_PRICING_URL}?${params}`);
3255
4882
  const data = await response.json();
3256
4883
  return data.price;
3257
4884
  } catch (error) {
@@ -3295,7 +4922,7 @@ async function getTokenPriceFallback(tokenSymbol) {
3295
4922
  var getEthPrice = async () => {
3296
4923
  try {
3297
4924
  return await getTokenPrice({
3298
- chainId: import_chains.sepolia.id,
4925
+ chainId: chains.sepolia.id,
3299
4926
  tokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
3300
4927
  });
3301
4928
  } catch (error) {
@@ -3309,12 +4936,9 @@ var getEthPrice = async () => {
3309
4936
  }
3310
4937
  }
3311
4938
  };
3312
-
3313
- // functions/getTokePrice.ts
3314
- var import_tokenlist = require("@tokemak/tokenlist");
3315
4939
  var getTokePrice = async () => {
3316
4940
  try {
3317
- return await getTokenPrice({ tokenAddress: import_tokenlist.TOKE_TOKEN.address });
4941
+ return await getTokenPrice({ tokenAddress: tokenlist.TOKE_TOKEN.address });
3318
4942
  } catch (error) {
3319
4943
  console.warn("Primary price fetch failed. Attempting fallback...", error);
3320
4944
  try {
@@ -3489,14 +5113,11 @@ function mergeStringArrays(keys, values) {
3489
5113
  }
3490
5114
  return result;
3491
5115
  }
3492
-
3493
- // utils/getChainsForEnv.ts
3494
- var import_constants2 = require("@tokemak/constants");
3495
5116
  function getChainsForEnv({
3496
5117
  includeTestnet = false
3497
5118
  }) {
3498
5119
  let chains;
3499
- chains = includeTestnet ? [...import_constants2.SUPPORTED_DEV_CHAINS] : [...import_constants2.SUPPORTED_PROD_CHAINS];
5120
+ chains = includeTestnet ? [...constants.SUPPORTED_DEV_CHAINS] : [...constants.SUPPORTED_PROD_CHAINS];
3500
5121
  return chains;
3501
5122
  }
3502
5123
 
@@ -3508,10 +5129,6 @@ async function fetchChainDataMap(chains, fetchFn) {
3508
5129
  return acc;
3509
5130
  }, {});
3510
5131
  }
3511
-
3512
- // utils/aggregateSTokeRewardsDayData.ts
3513
- var import_viem = require("viem");
3514
- var import_utils = require("@tokemak/utils");
3515
5132
  function aggregateSTokeRewardsDayData(dayDatas) {
3516
5133
  const byTs = {};
3517
5134
  for (const item of dayDatas) {
@@ -3519,8 +5136,8 @@ function aggregateSTokeRewardsDayData(dayDatas) {
3519
5136
  const dateStr = matchDate ? matchDate[0] : item.id;
3520
5137
  const ts = item.timestamp;
3521
5138
  if (!byTs[ts]) {
3522
- const date = (0, import_utils.convertTimestampToDate)(Number(ts));
3523
- const formattedDate = (0, import_utils.formatDateToReadable)(date);
5139
+ const date = utils.convertTimestampToDate(Number(ts));
5140
+ const formattedDate = utils.formatDateToReadable(date);
3524
5141
  byTs[ts] = {
3525
5142
  id: dateStr,
3526
5143
  formattedDate,
@@ -3532,10 +5149,10 @@ function aggregateSTokeRewardsDayData(dayDatas) {
3532
5149
  };
3533
5150
  }
3534
5151
  if (typeof item.balance === "string" && typeof item.balanceUSD === "string" && typeof item.earned === "string" && typeof item.earnedUSD === "string") {
3535
- byTs[ts].balance += Number((0, import_utils.formatEtherNum)(item.balance));
3536
- byTs[ts].balanceUSD += Number((0, import_viem.formatUnits)(item.balanceUSD, 8));
3537
- byTs[ts].earned += Number((0, import_utils.formatEtherNum)(item.earned));
3538
- byTs[ts].earnedUSD += Number((0, import_viem.formatUnits)(item.earnedUSD, 8));
5152
+ byTs[ts].balance += Number(utils.formatEtherNum(item.balance));
5153
+ byTs[ts].balanceUSD += Number(viem.formatUnits(item.balanceUSD, 8));
5154
+ byTs[ts].earned += Number(utils.formatEtherNum(item.earned));
5155
+ byTs[ts].earnedUSD += Number(viem.formatUnits(item.earnedUSD, 8));
3539
5156
  } else if (typeof item.balance === "number" && typeof item.balanceUSD === "number" && typeof item.earned === "number" && typeof item.earnedUSD === "number") {
3540
5157
  byTs[ts].balance += item.balance;
3541
5158
  byTs[ts].balanceUSD += item.balanceUSD;
@@ -3546,14 +5163,11 @@ function aggregateSTokeRewardsDayData(dayDatas) {
3546
5163
  const result = Object.values(byTs).filter((day) => day.earned !== 0);
3547
5164
  return result;
3548
5165
  }
3549
-
3550
- // utils/getSTokeChainsForEnv.ts
3551
- var import_constants3 = require("@tokemak/constants");
3552
5166
  function getSTokeChainsForEnv({
3553
5167
  includeTestnet = false
3554
5168
  }) {
3555
5169
  let chains;
3556
- chains = includeTestnet ? [...import_constants3.SUPPORTED_STOKE_DEV_CHAINS] : [...import_constants3.SUPPORTED_STOKE_PROD_CHAINS];
5170
+ chains = includeTestnet ? [...constants.SUPPORTED_STOKE_DEV_CHAINS] : [...constants.SUPPORTED_STOKE_PROD_CHAINS];
3557
5171
  return chains;
3558
5172
  }
3559
5173
 
@@ -3605,11 +5219,8 @@ var convertBaseAssetToTokenPricesAndDenom = (baseAsset, baseAssetPrice, denomPri
3605
5219
  denom: baseAsset * baseAssetToDenom
3606
5220
  };
3607
5221
  };
3608
-
3609
- // utils/getAutopoolInfo.ts
3610
- var import_tokenlist2 = require("@tokemak/tokenlist");
3611
5222
  var getAutopoolInfo = (symbol) => {
3612
- const autopool = import_tokenlist2.ALL_AUTOPOOLS.find((pool) => pool.symbol === symbol);
5223
+ const autopool = tokenlist.ALL_AUTOPOOLS.find((pool) => pool.symbol === symbol);
3613
5224
  return autopool;
3614
5225
  };
3615
5226
 
@@ -3679,9 +5290,6 @@ async function paginateQuery(queryFn, arrayKey, options = {}) {
3679
5290
  return results;
3680
5291
  }
3681
5292
 
3682
- // functions/getPoolsAndDestinationsBackup.ts
3683
- var import_utils2 = require("@tokemak/utils");
3684
-
3685
5293
  // functions/getBlobData.ts
3686
5294
  var getBlobData = async (blobName) => {
3687
5295
  try {
@@ -3704,7 +5312,7 @@ var getBlobData = async (blobName) => {
3704
5312
  // functions/getPoolsAndDestinationsBackup.ts
3705
5313
  var getPoolsAndDestinationsBackup = async (chainId) => {
3706
5314
  try {
3707
- const networkName = (0, import_utils2.getNetwork)(chainId)?.name.toLowerCase();
5315
+ const networkName = utils.getNetwork(chainId)?.name.toLowerCase();
3708
5316
  const backupData = await getBlobData(
3709
5317
  `${networkName}-getPoolsAndDestinations-latest-success.json`
3710
5318
  );
@@ -3714,10 +5322,6 @@ var getPoolsAndDestinationsBackup = async (chainId) => {
3714
5322
  }
3715
5323
  };
3716
5324
 
3717
- // functions/getChainAutopools.ts
3718
- var import_utils6 = require("@tokemak/utils");
3719
- var import_viem2 = require("viem");
3720
-
3721
5325
  // constants/tokenOrders.ts
3722
5326
  var UITokenOrder = [
3723
5327
  "ETH",
@@ -3753,9 +5357,6 @@ var protocolOrder = [
3753
5357
  "Morpho",
3754
5358
  "Fluid"
3755
5359
  ];
3756
-
3757
- // functions/getGenStratAprs.ts
3758
- var import_constants4 = require("@tokemak/constants");
3759
5360
  var getGenStratAprs = async ({
3760
5361
  chainId = 1
3761
5362
  }) => {
@@ -3764,7 +5365,7 @@ var getGenStratAprs = async ({
3764
5365
  chainId: chainId.toString(),
3765
5366
  systemName: "gen3"
3766
5367
  });
3767
- const response = await fetch(`${import_constants4.TOKEMAK_GENSTRAT_APRS_API_URL}?${params}`);
5368
+ const response = await fetch(`${constants.TOKEMAK_GENSTRAT_APRS_API_URL}?${params}`);
3768
5369
  const data = await response.json();
3769
5370
  if (data && data.success) {
3770
5371
  return data.aprs.reduce((p, c) => {
@@ -3787,22 +5388,12 @@ var getGenStratAprs = async ({
3787
5388
  return void 0;
3788
5389
  }
3789
5390
  };
3790
-
3791
- // functions/getChainAutopools.ts
3792
- var import_tokenlist3 = require("@tokemak/tokenlist");
3793
- var import_graph_cli = require("@tokemak/graph-cli");
3794
- var import_chains2 = require("viem/chains");
3795
-
3796
- // functions/getPoolsAndDestinations.ts
3797
- var import_config = require("@tokemak/config");
3798
- var import_core = require("@wagmi/core");
3799
- var import_abis = require("@tokemak/abis");
3800
5391
  var getPoolsAndDestinations = async (wagmiConfig, { chainId }) => {
3801
5392
  try {
3802
- const { lens } = (0, import_config.getCoreConfig)(chainId);
3803
- const { autoPools, destinations } = await (0, import_core.readContract)(wagmiConfig, {
5393
+ const { lens } = config.getCoreConfig(chainId);
5394
+ const { autoPools, destinations } = await core.readContract(wagmiConfig, {
3804
5395
  address: lens,
3805
- abi: import_abis.lensAbi,
5396
+ abi: abis.lensAbi,
3806
5397
  functionName: "getPoolsAndDestinations",
3807
5398
  chainId
3808
5399
  });
@@ -3816,12 +5407,9 @@ var getPoolsAndDestinations = async (wagmiConfig, { chainId }) => {
3816
5407
  console.error(`Error on ${chainId} in getPoolsAndDestinations:`, error);
3817
5408
  }
3818
5409
  };
3819
-
3820
- // functions/getBackupApr.ts
3821
- var import_utils4 = require("@tokemak/utils");
3822
5410
  var getBackupApr = async (chainId, poolAddress) => {
3823
5411
  try {
3824
- const networkName = (0, import_utils4.getNetwork)(chainId)?.name.toLowerCase();
5412
+ const networkName = utils.getNetwork(chainId)?.name.toLowerCase();
3825
5413
  const backupData = await getBlobData(
3826
5414
  `${networkName}-getChainAutopools-latest-success.json`
3827
5415
  );
@@ -3843,10 +5431,10 @@ var getChainAutopools = async (wagmiConfig, {
3843
5431
  chainId,
3844
5432
  prices
3845
5433
  }) => {
3846
- const { GetVaultAddeds, GetAutopoolsInactiveDestinations } = (0, import_graph_cli.getSdkByChainId)(chainId);
5434
+ const { GetVaultAddeds, GetAutopoolsInactiveDestinations } = graphCli.getSdkByChainId(chainId);
3847
5435
  try {
3848
5436
  const { vaultAddeds } = await GetVaultAddeds();
3849
- const { GetAutopoolsApr } = (0, import_graph_cli.getSdkByChainId)(chainId);
5437
+ const { GetAutopoolsApr } = graphCli.getSdkByChainId(chainId);
3850
5438
  const { autopools: autopoolsApr } = await GetAutopoolsApr();
3851
5439
  const genStratAprs = await getGenStratAprs({
3852
5440
  chainId
@@ -3868,7 +5456,7 @@ var getChainAutopools = async (wagmiConfig, {
3868
5456
  }, {});
3869
5457
  const autopools = await Promise.all(
3870
5458
  autopoolsAndDestinations.map(async (autopool) => {
3871
- let baseAsset = (0, import_utils6.getToken)(autopool.baseAsset);
5459
+ let baseAsset = utils.getToken(autopool.baseAsset);
3872
5460
  if (!baseAsset?.symbol) {
3873
5461
  console.error(
3874
5462
  "FIX THIS BEFORE PROD: base asset not found",
@@ -3883,18 +5471,18 @@ var getChainAutopools = async (wagmiConfig, {
3883
5471
  }) || 0;
3884
5472
  }
3885
5473
  const timestamp = vaultAddedMapping[autopool.poolAddress.toLowerCase()];
3886
- const totalAssets = (0, import_utils6.formatUnitsNum)(
5474
+ const totalAssets = utils.formatUnitsNum(
3887
5475
  autopool.totalAssets,
3888
5476
  baseAsset.decimals
3889
5477
  );
3890
5478
  const tvl = totalAssets * baseAssetPrice;
3891
- const totalIdleAssets = (0, import_utils6.formatUnitsNum)(
5479
+ const totalIdleAssets = utils.formatUnitsNum(
3892
5480
  autopool.totalIdle,
3893
5481
  baseAsset.decimals
3894
5482
  );
3895
5483
  const exchangeValues = {};
3896
5484
  const destinations = autopool.destinations.map((destination) => {
3897
- const debtValueHeldByVaultEth = (0, import_utils6.formatUnitsNum)(
5485
+ const debtValueHeldByVaultEth = utils.formatUnitsNum(
3898
5486
  destination.debtValueHeldByVault,
3899
5487
  baseAsset.decimals
3900
5488
  );
@@ -3907,8 +5495,8 @@ var getChainAutopools = async (wagmiConfig, {
3907
5495
  destination.underlyingTokenValueHeld
3908
5496
  );
3909
5497
  let underlyingTokens = tokensWithValue.map((token) => {
3910
- const tokenDetails = (0, import_utils6.getToken)(token.tokenAddress);
3911
- let value = (0, import_utils6.formatUnitsNum)(
5498
+ const tokenDetails = utils.getToken(token.tokenAddress);
5499
+ let value = utils.formatUnitsNum(
3912
5500
  token.valueHeldInEth,
3913
5501
  baseAsset.decimals
3914
5502
  );
@@ -3924,7 +5512,7 @@ var getChainAutopools = async (wagmiConfig, {
3924
5512
  if (underlyingTokenAddress) {
3925
5513
  underlyingTokens = [
3926
5514
  {
3927
- ...(0, import_utils6.getToken)(underlyingTokenAddress, chainId),
5515
+ ...utils.getToken(underlyingTokenAddress, chainId),
3928
5516
  valueUsd: debtValueHeldByVaultEth * baseAssetPrice,
3929
5517
  value: debtValueHeldByVaultEth
3930
5518
  }
@@ -3936,25 +5524,25 @@ var getChainAutopools = async (wagmiConfig, {
3936
5524
  ...destination,
3937
5525
  debtValueHeldByVaultUsd: debtValueHeldByVaultEth * baseAssetPrice,
3938
5526
  debtValueHeldByVaultEth,
3939
- compositeReturn: isGenStrat ? genStratAprs?.[autopool.poolAddress]?.[destination.vaultAddress]?.apr || 0 : (0, import_utils6.formatEtherNum)(destination.compositeReturn),
5527
+ compositeReturn: isGenStrat ? genStratAprs?.[autopool.poolAddress]?.[destination.vaultAddress]?.apr || 0 : utils.formatEtherNum(destination.compositeReturn),
3940
5528
  debtValueHeldByVaultAllocation: debtValueHeldByVaultEth / totalAssets,
3941
5529
  underlyingTokens,
3942
- poolName: (0, import_utils6.formatPoolName)(destination.lpTokenName),
3943
- exchange: (0, import_utils6.getProtocol)(destination.exchangeName)
5530
+ poolName: utils.formatPoolName(destination.lpTokenName),
5531
+ exchange: utils.getProtocol(destination.exchangeName)
3944
5532
  };
3945
5533
  });
3946
5534
  const uniqueExchanges = Array.from(
3947
5535
  new Set(
3948
- destinations.map((d) => (0, import_utils6.getProtocol)(d.exchangeName)).filter(Boolean)
5536
+ destinations.map((d) => utils.getProtocol(d.exchangeName)).filter(Boolean)
3949
5537
  )
3950
5538
  );
3951
5539
  const uniqueExchangesWithValueHeld = uniqueExchanges.map((exchange) => {
3952
5540
  const exchangeName = exchange.name.toLowerCase();
3953
5541
  let exchangeInfo = exchange;
3954
5542
  const value = exchangeValues[exchangeName];
3955
- if (chainId === import_chains2.sonic.id) {
5543
+ if (chainId === chains.sonic.id) {
3956
5544
  if (exchangeName === "balancerv3" || exchangeName === "balancer") {
3957
- exchangeInfo = import_tokenlist3.BEETS_PROTOCOL;
5545
+ exchangeInfo = tokenlist.BEETS_PROTOCOL;
3958
5546
  }
3959
5547
  }
3960
5548
  return {
@@ -4004,26 +5592,26 @@ var getChainAutopools = async (wagmiConfig, {
4004
5592
  }
4005
5593
  );
4006
5594
  let UIBaseAsset = baseAsset;
4007
- if (baseAsset.symbol?.toLowerCase() === import_tokenlist3.WETH_TOKEN.symbol.toLowerCase()) {
4008
- UIBaseAsset = import_tokenlist3.ETH_TOKEN;
5595
+ if (baseAsset.symbol?.toLowerCase() === tokenlist.WETH_TOKEN.symbol.toLowerCase()) {
5596
+ UIBaseAsset = tokenlist.ETH_TOKEN;
4009
5597
  }
4010
- if (baseAsset.symbol?.toLowerCase() === import_tokenlist3.WS_TOKEN.symbol.toLowerCase()) {
4011
- UIBaseAsset = import_tokenlist3.S_TOKEN;
5598
+ if (baseAsset.symbol?.toLowerCase() === tokenlist.WS_TOKEN.symbol.toLowerCase()) {
5599
+ UIBaseAsset = tokenlist.S_TOKEN;
4012
5600
  }
4013
- if (baseAsset.symbol?.toLowerCase() === import_tokenlist3.WXPL_TOKEN.symbol.toLowerCase()) {
4014
- UIBaseAsset = import_tokenlist3.XPL_TOKEN;
5601
+ if (baseAsset.symbol?.toLowerCase() === tokenlist.WXPL_TOKEN.symbol.toLowerCase()) {
5602
+ UIBaseAsset = tokenlist.XPL_TOKEN;
4015
5603
  }
4016
5604
  const isNew = (Date.now() / 1e3 - timestamp) / 60 / 60 / 24 < 45;
4017
5605
  const aprs = autopoolsApr.find(
4018
- (autopoolApr) => (0, import_viem2.getAddress)(autopoolApr.id) === (0, import_viem2.getAddress)(autopool.poolAddress)
5606
+ (autopoolApr) => viem.getAddress(autopoolApr.id) === viem.getAddress(autopool.poolAddress)
4019
5607
  );
4020
5608
  let baseApr = aprs?.currentApy;
4021
5609
  let boostedApr = 0;
4022
5610
  let extraApr = 0;
4023
- const formattedRewarder7DayMAApy = (0, import_utils6.formatEtherNum)(
5611
+ const formattedRewarder7DayMAApy = utils.formatEtherNum(
4024
5612
  BigInt(Number(aprs?.rewarder?.day7MAApy) || 0)
4025
5613
  );
4026
- const formattedRewarder30DayMAApy = (0, import_utils6.formatEtherNum)(
5614
+ const formattedRewarder30DayMAApy = utils.formatEtherNum(
4027
5615
  BigInt(Number(aprs?.rewarder?.day30MAApy) || 0)
4028
5616
  );
4029
5617
  if (formattedRewarder7DayMAApy > 0) {
@@ -4038,9 +5626,9 @@ var getChainAutopools = async (wagmiConfig, {
4038
5626
  }, 0);
4039
5627
  const periodicFeeBps = autopool.periodicFeeBps || 0n;
4040
5628
  const streamingFeeBps = autopool.streamingFeeBps || 0n;
4041
- baseApr = (weightedCrNum / (1 - totalIdleAssets / totalAssets) - Number((0, import_viem2.formatUnits)(periodicFeeBps, 4))) * (1 - Number((0, import_viem2.formatUnits)(streamingFeeBps, 4)));
5629
+ baseApr = (weightedCrNum / (1 - totalIdleAssets / totalAssets) - Number(viem.formatUnits(periodicFeeBps, 4))) * (1 - Number(viem.formatUnits(streamingFeeBps, 4)));
4042
5630
  } else {
4043
- baseApr = Number((0, import_viem2.formatUnits)(BigInt(baseApr), baseAsset.decimals));
5631
+ baseApr = Number(viem.formatUnits(BigInt(baseApr), baseAsset.decimals));
4044
5632
  }
4045
5633
  if (!baseApr) {
4046
5634
  baseApr = 0;
@@ -4063,10 +5651,10 @@ var getChainAutopools = async (wagmiConfig, {
4063
5651
  let extraRewards = [];
4064
5652
  if (aprs?.rewarder?.extraRewarders?.length && aprs?.rewarder?.extraRewarders?.length > 0) {
4065
5653
  extraRewards = aprs?.rewarder?.extraRewarders.map((reward) => {
4066
- const token = (0, import_utils6.getToken)(reward?.rewardToken?.id, chainId);
5654
+ const token = utils.getToken(reward?.rewardToken?.id, chainId);
4067
5655
  return {
4068
5656
  ...token,
4069
- apr: (0, import_utils6.formatEtherNum)(BigInt(reward.currentApy || 0))
5657
+ apr: utils.formatEtherNum(BigInt(reward.currentApy || 0))
4070
5658
  };
4071
5659
  });
4072
5660
  }
@@ -4075,13 +5663,13 @@ var getChainAutopools = async (wagmiConfig, {
4075
5663
  }
4076
5664
  extraApr = extraRewards.reduce((acc, reward) => acc + reward.apr, 0);
4077
5665
  const combinedApr = baseApr + boostedApr + extraApr;
4078
- let denominatedToken = import_tokenlist3.ETH_TOKEN;
5666
+ let denominatedToken = tokenlist.ETH_TOKEN;
4079
5667
  let useDenominatedValues = false;
4080
5668
  const denominatedIn = aprs?.denominatedIn;
4081
5669
  if (denominatedIn?.symbol?.toLowerCase() === "weth") {
4082
- denominatedToken = import_tokenlist3.ETH_TOKEN;
5670
+ denominatedToken = tokenlist.ETH_TOKEN;
4083
5671
  } else {
4084
- denominatedToken = (0, import_utils6.getToken)(denominatedIn?.id);
5672
+ denominatedToken = utils.getToken(denominatedIn?.id);
4085
5673
  if (denominatedToken) {
4086
5674
  useDenominatedValues = true;
4087
5675
  }
@@ -4096,12 +5684,12 @@ var getChainAutopools = async (wagmiConfig, {
4096
5684
  tokenAddress: denominatedToken.address
4097
5685
  }) || 0;
4098
5686
  }
4099
- const navPerShareBaseAsset = (0, import_utils6.formatUnitsNum)(
5687
+ const navPerShareBaseAsset = utils.formatUnitsNum(
4100
5688
  autopool.navPerShare,
4101
5689
  baseAsset.decimals
4102
5690
  );
4103
5691
  const assets = convertBaseAssetToTokenPricesAndDenom(
4104
- (0, import_utils6.formatUnitsNum)(autopool.totalAssets, baseAsset.decimals),
5692
+ utils.formatUnitsNum(autopool.totalAssets, baseAsset.decimals),
4105
5693
  baseAssetPrice,
4106
5694
  denominatedTokenPrice,
4107
5695
  prices
@@ -4138,7 +5726,7 @@ var getChainAutopools = async (wagmiConfig, {
4138
5726
  try {
4139
5727
  const parentAsset = token.extensions?.parentAsset;
4140
5728
  if (parentAsset) {
4141
- const parentToken = import_tokenlist3.ALL_TOKENS.find(
5729
+ const parentToken = tokenlist.ALL_TOKENS.find(
4142
5730
  (t) => t.symbol.toLowerCase() === parentAsset.toLowerCase()
4143
5731
  );
4144
5732
  if (parentToken && !acc.some(
@@ -4208,7 +5796,7 @@ var getChainAutopools = async (wagmiConfig, {
4208
5796
  });
4209
5797
  const autopoolInfo = getAutopoolInfo(autopool.symbol);
4210
5798
  if (autopoolInfo && !autopoolInfo.description) {
4211
- autopoolInfo.description = `Autopool featuring ${UIBaseAsset.symbol} deployed across integrated DEXs and lending protocols on ${(0, import_utils6.getNetwork)(chainId)?.name}.`;
5799
+ autopoolInfo.description = `Autopool featuring ${UIBaseAsset.symbol} deployed across integrated DEXs and lending protocols on ${utils.getNetwork(chainId)?.name}.`;
4212
5800
  }
4213
5801
  return {
4214
5802
  ...autopool,
@@ -4233,7 +5821,7 @@ var getChainAutopools = async (wagmiConfig, {
4233
5821
  UITokens,
4234
5822
  UIExchanges: finalUIExchanges,
4235
5823
  tokens: uniqueTokens,
4236
- chain: (0, import_utils6.getNetwork)(chainId),
5824
+ chain: utils.getNetwork(chainId),
4237
5825
  apr: {
4238
5826
  base: baseApr,
4239
5827
  boosted: boostedApr,
@@ -4263,10 +5851,6 @@ var getChainAutopools = async (wagmiConfig, {
4263
5851
  return [];
4264
5852
  }
4265
5853
  };
4266
-
4267
- // functions/getAutopools.ts
4268
- var import_config2 = require("@tokemak/config");
4269
- var import_viem3 = require("viem");
4270
5854
  var getAutopools = async (wagmiConfig, {
4271
5855
  prices,
4272
5856
  includeTestnet = false
@@ -4288,18 +5872,15 @@ var getAutopools = async (wagmiConfig, {
4288
5872
  return sortedAutopoolsByTimestamp;
4289
5873
  } else {
4290
5874
  return sortedAutopoolsByTimestamp.filter((pool) => {
4291
- return import_config2.AUTOPOOLS_WHITELIST_PROD.includes((0, import_viem3.getAddress)(pool.poolAddress));
5875
+ return config.AUTOPOOLS_WHITELIST_PROD.includes(viem.getAddress(pool.poolAddress));
4292
5876
  });
4293
5877
  }
4294
5878
  } catch (e) {
4295
5879
  console.error(e);
4296
5880
  }
4297
5881
  };
4298
-
4299
- // functions/getAutopoolRebalances.ts
4300
- var import_graph_cli2 = require("@tokemak/graph-cli");
4301
5882
  var getAutopoolRebalances = async (id, chainId = 1, options) => {
4302
- const { GetAutopoolRebalances } = (0, import_graph_cli2.getSdkByChainId)(chainId);
5883
+ const { GetAutopoolRebalances } = graphCli.getSdkByChainId(chainId);
4303
5884
  const first = options?.first ?? 1e3;
4304
5885
  const maxPages = options?.maxPages ?? 100;
4305
5886
  const queryFn = ({ first: first2, skip }) => GetAutopoolRebalances({ address: id, first: first2, skip });
@@ -4314,23 +5895,14 @@ var getAutopoolRebalances = async (id, chainId = 1, options) => {
4314
5895
  ix: length - index
4315
5896
  }));
4316
5897
  };
4317
-
4318
- // functions/getAutopoolsRebalances.ts
4319
- var import_graph_cli3 = require("@tokemak/graph-cli");
4320
5898
  var getAutopoolsRebalances = async (chainId = 1) => {
4321
- const { GetAutopoolsRebalances } = (0, import_graph_cli3.getSdkByChainId)(chainId);
5899
+ const { GetAutopoolsRebalances } = graphCli.getSdkByChainId(chainId);
4322
5900
  const { autopools } = await GetAutopoolsRebalances();
4323
5901
  const rebalances = autopools.map(({ rebalances: rebalances2 }) => rebalances2);
4324
5902
  return rebalances.flat().sort((a, b) => b.timestamp - a.timestamp);
4325
5903
  };
4326
-
4327
- // functions/getAutopoolsHistory.ts
4328
- var import_viem4 = require("viem");
4329
-
4330
- // functions/getAutopoolsDayData.ts
4331
- var import_graph_cli4 = require("@tokemak/graph-cli");
4332
5904
  var getAutopoolsDayData = async (chainId, timestamp) => {
4333
- const { GetAutopoolsDayData } = (0, import_graph_cli4.getSdkByChainId)(chainId);
5905
+ const { GetAutopoolsDayData } = graphCli.getSdkByChainId(chainId);
4334
5906
  const PAGE_SIZE = 1e3;
4335
5907
  let allResults = [];
4336
5908
  let hasMore = true;
@@ -4387,7 +5959,7 @@ var getAutopoolsHistory = async (autopools, days, includeTestnet = false) => {
4387
5959
  ...data,
4388
5960
  date: new Date(data.timestamp * 1e3),
4389
5961
  baseAsset: autopools.find(
4390
- (pool) => (0, import_viem4.getAddress)(pool.poolAddress) === (0, import_viem4.getAddress)(vaultId)
5962
+ (pool) => viem.getAddress(pool.poolAddress) === viem.getAddress(vaultId)
4391
5963
  )?.baseAsset
4392
5964
  });
4393
5965
  }
@@ -4405,13 +5977,9 @@ var getAutopoolsHistory = async (autopools, days, includeTestnet = false) => {
4405
5977
  console.log(e);
4406
5978
  }
4407
5979
  };
4408
-
4409
- // functions/getCurveLP.ts
4410
- var import_config3 = require("@tokemak/config");
4411
- var import_constants5 = require("@tokemak/constants");
4412
5980
  var getCurveLP = async () => {
4413
5981
  let curveData;
4414
- const { curveRewardsUrl } = (0, import_config3.getMainnetConfig)();
5982
+ const { curveRewardsUrl } = config.getMainnetConfig();
4415
5983
  try {
4416
5984
  const curveRewardsResponse = await fetch(curveRewardsUrl);
4417
5985
  const curveRewardsData = await curveRewardsResponse.json();
@@ -4425,10 +5993,10 @@ var getCurveLP = async () => {
4425
5993
  console.error(e);
4426
5994
  }
4427
5995
  try {
4428
- const curvePoolsResponse = await fetch(import_constants5.CURVE_API_URL);
5996
+ const curvePoolsResponse = await fetch(constants.CURVE_API_URL);
4429
5997
  const curvePoolsData = await curvePoolsResponse.json();
4430
5998
  const curveTOKEPool = curvePoolsData?.data?.poolData.find(
4431
- (pool) => pool.id === import_constants5.TOKE_CURVE_POOL_ID
5999
+ (pool) => pool.id === constants.TOKE_CURVE_POOL_ID
4432
6000
  );
4433
6001
  if (curveData) {
4434
6002
  curveData.curveTvl = curveTOKEPool?.usdTotal;
@@ -4439,33 +6007,26 @@ var getCurveLP = async () => {
4439
6007
  }
4440
6008
  return curveData;
4441
6009
  };
4442
-
4443
- // functions/getSushiLP.ts
4444
- var import_abis2 = require("@tokemak/abis");
4445
- var import_config4 = require("@tokemak/config");
4446
- var import_core2 = require("@wagmi/core");
4447
- var import_viem5 = require("viem");
4448
- var import_chains3 = require("viem/chains");
4449
6010
  var getSushiLP = async (wagmiConfig, { ethPrice }) => {
4450
- const { sushiPool, lpRewardsV1Url } = (0, import_config4.getMainnetConfig)();
6011
+ const { sushiPool, lpRewardsV1Url } = config.getMainnetConfig();
4451
6012
  const sushiPoolContract = {
4452
6013
  address: sushiPool,
4453
- abi: import_abis2.sushiPoolAbi
6014
+ abi: abis.sushiPoolAbi
4454
6015
  };
4455
6016
  try {
4456
- const [{ result: reserves }, { result: totalSupply }] = await (0, import_core2.readContracts)(
6017
+ const [{ result: reserves }, { result: totalSupply }] = await core.readContracts(
4457
6018
  wagmiConfig,
4458
6019
  {
4459
6020
  contracts: [
4460
6021
  {
4461
6022
  ...sushiPoolContract,
4462
6023
  functionName: "getReserves",
4463
- chainId: import_chains3.mainnet.id
6024
+ chainId: chains.mainnet.id
4464
6025
  },
4465
6026
  {
4466
6027
  ...sushiPoolContract,
4467
6028
  functionName: "totalSupply",
4468
- chainId: import_chains3.mainnet.id
6029
+ chainId: chains.mainnet.id
4469
6030
  }
4470
6031
  ]
4471
6032
  }
@@ -4477,8 +6038,8 @@ var getSushiLP = async (wagmiConfig, { ethPrice }) => {
4477
6038
  );
4478
6039
  if (reserves && totalSupply && ethPrice) {
4479
6040
  const lpReserve = reserves[1] * 2n;
4480
- const tvl = Number((0, import_viem5.formatEther)(lpReserve)) * ethPrice;
4481
- const valueOf1LP = tvl / Number((0, import_viem5.formatEther)(totalSupply));
6041
+ const tvl = Number(viem.formatEther(lpReserve)) * ethPrice;
6042
+ const valueOf1LP = tvl / Number(viem.formatEther(totalSupply));
4482
6043
  return {
4483
6044
  tvl,
4484
6045
  lpReserve,
@@ -4493,11 +6054,8 @@ var getSushiLP = async (wagmiConfig, { ethPrice }) => {
4493
6054
  console.log(e);
4494
6055
  }
4495
6056
  };
4496
-
4497
- // functions/getChainUserActivity.ts
4498
- var import_graph_cli5 = require("@tokemak/graph-cli");
4499
6057
  var getChainUserActivity = async (address, chainId = 1) => {
4500
- const { GetUserBalanceChangeHistory } = (0, import_graph_cli5.getSdkByChainId)(chainId);
6058
+ const { GetUserBalanceChangeHistory } = graphCli.getSdkByChainId(chainId);
4501
6059
  try {
4502
6060
  const { userAutopoolBalanceChanges } = await GetUserBalanceChangeHistory({
4503
6061
  userAddress: address
@@ -4564,11 +6122,6 @@ var getRewardsPayloadV1 = async (cycleHash, account, rewardsV1Url) => {
4564
6122
  return null;
4565
6123
  }
4566
6124
  };
4567
-
4568
- // functions/getUserAutoEthRewards.ts
4569
- var import_abis3 = require("@tokemak/abis");
4570
- var import_core3 = require("@wagmi/core");
4571
- var import_utils10 = require("@tokemak/utils");
4572
6125
  var getAutoEthRewards = async (wagmiConfig, {
4573
6126
  account,
4574
6127
  currentCycleIndex,
@@ -4577,16 +6130,16 @@ var getAutoEthRewards = async (wagmiConfig, {
4577
6130
  chainId
4578
6131
  }) => {
4579
6132
  try {
4580
- const [, drippingHash] = await (0, import_core3.readContract)(wagmiConfig, {
6133
+ const [, drippingHash] = await core.readContract(wagmiConfig, {
4581
6134
  address: rewardsHash,
4582
- abi: import_abis3.autoEthRewardsHashAbi,
6135
+ abi: abis.autoEthRewardsHashAbi,
4583
6136
  functionName: "cycleHashes",
4584
6137
  args: [currentCycleIndex - 306n],
4585
6138
  chainId
4586
6139
  });
4587
- const [, lastWeekHash] = await (0, import_core3.readContract)(wagmiConfig, {
6140
+ const [, lastWeekHash] = await core.readContract(wagmiConfig, {
4588
6141
  address: rewardsHash,
4589
- abi: import_abis3.autoEthRewardsHashAbi,
6142
+ abi: abis.autoEthRewardsHashAbi,
4590
6143
  functionName: "cycleHashes",
4591
6144
  // -1 to get the previous cycle
4592
6145
  args: [currentCycleIndex - 306n - 1n],
@@ -4606,7 +6159,7 @@ var getAutoEthRewards = async (wagmiConfig, {
4606
6159
  const currentAmount = Number(drippingHashPayload?.summary?.currentAmount);
4607
6160
  const previousAmount = Number(drippingHashPayload?.summary?.previousAmount);
4608
6161
  const cycleDuration = 604800;
4609
- const lastCycleStart = (0, import_utils10.convertChainCycleToUnix)(Number(currentCycleIndex));
6162
+ const lastCycleStart = utils.convertChainCycleToUnix(Number(currentCycleIndex));
4610
6163
  const timeSinceCycleStart = Date.now() / 1e3 - lastCycleStart;
4611
6164
  const currentUserRewards = currentAmount * Math.min(timeSinceCycleStart, cycleDuration) / cycleDuration + previousAmount;
4612
6165
  const lastWeekRewards = Number(lastWeekHashPayload?.summary?.currentAmount);
@@ -4627,15 +6180,11 @@ var getUserAutoEthRewards = async (wagmiConfig, rewardsV1Url, rewardsHash, addre
4627
6180
  rewardsHash,
4628
6181
  chainId
4629
6182
  });
4630
- const currentUserRewardsUsd = (0, import_utils10.formatCurrency)(
6183
+ const currentUserRewardsUsd = utils.formatCurrency(
4631
6184
  ethPrice * (autoETHRewards?.currentUserRewards || 0)
4632
6185
  );
4633
6186
  return { ...autoETHRewards, currentUserRewardsUsd };
4634
6187
  };
4635
-
4636
- // functions/getUserRewardsV1.ts
4637
- var import_abis4 = require("@tokemak/abis");
4638
- var import_core4 = require("@wagmi/core");
4639
6188
  var getUserRewardsV1 = async (wagmiConfig, {
4640
6189
  address,
4641
6190
  rewardsCycleIndex,
@@ -4645,11 +6194,11 @@ var getUserRewardsV1 = async (wagmiConfig, {
4645
6194
  chainId
4646
6195
  }) => {
4647
6196
  try {
4648
- const [latestClaimableHash, cycleRewardsHash] = await (0, import_core4.readContract)(
6197
+ const [latestClaimableHash, cycleRewardsHash] = await core.readContract(
4649
6198
  wagmiConfig,
4650
6199
  {
4651
6200
  address: rewardsV1Hash,
4652
- abi: import_abis4.rewardsV1HashAbi,
6201
+ abi: abis.rewardsV1HashAbi,
4653
6202
  functionName: "cycleHashes",
4654
6203
  args: [rewardsCycleIndex],
4655
6204
  chainId
@@ -4669,9 +6218,9 @@ var getUserRewardsV1 = async (wagmiConfig, {
4669
6218
  const {
4670
6219
  payload: { chainId: payloadChainId, cycle, wallet, amount }
4671
6220
  } = latestClaimablePayload;
4672
- const claimable = await (0, import_core4.readContract)(wagmiConfig, {
6221
+ const claimable = await core.readContract(wagmiConfig, {
4673
6222
  address: rewardsV1,
4674
- abi: import_abis4.rewardsV1Abi,
6223
+ abi: abis.rewardsV1Abi,
4675
6224
  functionName: "getClaimableAmount",
4676
6225
  args: [{ chainId: payloadChainId, cycle, wallet, amount }],
4677
6226
  chainId
@@ -4683,12 +6232,6 @@ var getUserRewardsV1 = async (wagmiConfig, {
4683
6232
  console.log(e);
4684
6233
  }
4685
6234
  };
4686
-
4687
- // functions/getUserV1.ts
4688
- var import_abis5 = require("@tokemak/abis");
4689
- var import_core5 = require("@wagmi/core");
4690
- var import_config5 = require("@tokemak/config");
4691
- var import_chains4 = require("viem/chains");
4692
6235
  var getUserV1 = async (wagmiConfig, {
4693
6236
  currentCycleIndex,
4694
6237
  address,
@@ -4703,14 +6246,14 @@ var getUserV1 = async (wagmiConfig, {
4703
6246
  autoEthGuardedRewards,
4704
6247
  rewardsV1,
4705
6248
  missedTokeRewards
4706
- } = (0, import_config5.getMainnetConfig)(import_chains4.mainnet.id);
6249
+ } = config.getMainnetConfig(chains.mainnet.id);
4707
6250
  try {
4708
- const userStakedTokeV1 = await (0, import_core5.readContract)(wagmiConfig, {
6251
+ const userStakedTokeV1 = await core.readContract(wagmiConfig, {
4709
6252
  address: stakingV1,
4710
- abi: import_abis5.stakingV1Abi,
6253
+ abi: abis.stakingV1Abi,
4711
6254
  functionName: "availableForWithdrawal",
4712
6255
  args: [address, 0n],
4713
- chainId: import_chains4.mainnet.id
6256
+ chainId: chains.mainnet.id
4714
6257
  });
4715
6258
  const tokeRewards = await getUserRewardsV1(wagmiConfig, {
4716
6259
  address,
@@ -4737,9 +6280,9 @@ var getUserV1 = async (wagmiConfig, {
4737
6280
  const cycle = autoEthGuardedRewardsPayload?.payload?.cycle;
4738
6281
  const wallet = autoEthGuardedRewardsPayload?.payload?.wallet;
4739
6282
  const amount = autoEthGuardedRewardsPayload?.payload?.amount;
4740
- const claimableAutoEth = await (0, import_core5.readContract)(wagmiConfig, {
6283
+ const claimableAutoEth = await core.readContract(wagmiConfig, {
4741
6284
  address: autoEthGuardedRewards,
4742
- abi: import_abis5.rewardsV1Abi,
6285
+ abi: abis.rewardsV1Abi,
4743
6286
  functionName: "getClaimableAmount",
4744
6287
  args: [
4745
6288
  {
@@ -4761,9 +6304,9 @@ var getUserV1 = async (wagmiConfig, {
4761
6304
  const {
4762
6305
  payload: { chainId: payloadChainId2, cycle: cycle2, wallet: wallet2, amount: amount2 }
4763
6306
  } = missedTokeRewardsPayload;
4764
- claimableMissedToke = await (0, import_core5.readContract)(wagmiConfig, {
6307
+ claimableMissedToke = await core.readContract(wagmiConfig, {
4765
6308
  address: missedTokeRewards,
4766
- abi: import_abis5.rewardsV1Abi,
6309
+ abi: abis.rewardsV1Abi,
4767
6310
  functionName: "getClaimableAmount",
4768
6311
  args: [
4769
6312
  {
@@ -4790,14 +6333,11 @@ var getUserV1 = async (wagmiConfig, {
4790
6333
  } catch (e) {
4791
6334
  }
4792
6335
  };
4793
-
4794
- // functions/getChainUserAutopoolsHistory.tsx
4795
- var import_graph_cli6 = require("@tokemak/graph-cli");
4796
6336
  var getChainUserAutopoolsHistory = async ({
4797
6337
  address,
4798
6338
  chainId = 1
4799
6339
  }) => {
4800
- const { GetUserVaultsDayData } = (0, import_graph_cli6.getSdkByChainId)(chainId);
6340
+ const { GetUserVaultsDayData } = graphCli.getSdkByChainId(chainId);
4801
6341
  const oneYearAgoTimestamp = Math.floor(Date.now() / 1e3) - 365 * 24 * 60 * 60;
4802
6342
  try {
4803
6343
  if (address) {
@@ -4813,26 +6353,17 @@ var getChainUserAutopoolsHistory = async ({
4813
6353
  return [];
4814
6354
  }
4815
6355
  };
4816
-
4817
- // functions/getUserAutopoolsHistory.ts
4818
- var import_utils14 = require("@tokemak/utils");
4819
-
4820
- // functions/getTokenValueDayDatas.ts
4821
- var import_chains5 = require("viem/chains");
4822
- var import_utils11 = require("@tokemak/utils");
4823
- var import_viem6 = require("viem");
4824
- var import_graph_cli7 = require("@tokemak/graph-cli");
4825
- var getTokenValueDayDatas = async (tokenAddress, chainId = import_chains5.mainnet.id) => {
4826
- const { GetTokenValueDayDatas } = (0, import_graph_cli7.getSdkByChainId)(chainId);
6356
+ var getTokenValueDayDatas = async (tokenAddress, chainId = chains.mainnet.id) => {
6357
+ const { GetTokenValueDayDatas } = graphCli.getSdkByChainId(chainId);
4827
6358
  try {
4828
6359
  const { tokenValueDayDatas } = await GetTokenValueDayDatas({
4829
6360
  tokenAddress: tokenAddress.toLowerCase()
4830
6361
  });
4831
6362
  const historicalPrice = tokenValueDayDatas.map((tokenValueDayData) => {
4832
- const date = (0, import_utils11.convertTimestampToDate)(
6363
+ const date = utils.convertTimestampToDate(
4833
6364
  tokenValueDayData.lastSnapshotTimestamp
4834
6365
  );
4835
- const usdPrice = (0, import_viem6.formatUnits)(tokenValueDayData.priceInUsd, 8);
6366
+ const usdPrice = viem.formatUnits(tokenValueDayData.priceInUsd, 8);
4836
6367
  return {
4837
6368
  timestamp: Number(tokenValueDayData.lastSnapshotTimestamp),
4838
6369
  date,
@@ -4845,10 +6376,6 @@ var getTokenValueDayDatas = async (tokenAddress, chainId = import_chains5.mainne
4845
6376
  }
4846
6377
  };
4847
6378
 
4848
- // functions/getTokenPrices.ts
4849
- var import_tokenlist4 = require("@tokemak/tokenlist");
4850
- var import_constants6 = require("@tokemak/constants");
4851
-
4852
6379
  // functions/getBackupTokenPrices.ts
4853
6380
  var getBackupTokenPrices = async () => {
4854
6381
  try {
@@ -4865,26 +6392,26 @@ var getBackupTokenPrices = async () => {
4865
6392
 
4866
6393
  // functions/getTokenPrices.ts
4867
6394
  var BASE_ASSETS = [
4868
- { ...import_tokenlist4.ETH_TOKEN, symbol: "ETH", coinGeckoId: "ethereum" },
4869
- { ...import_tokenlist4.PXETH_TOKEN, symbol: "PXETH", coinGeckoId: "dinero-staked-eth" },
4870
- { ...import_tokenlist4.USDC_TOKEN, symbol: "USDC", coinGeckoId: "usd-coin" },
4871
- { ...import_tokenlist4.DOLA_TOKEN, symbol: "DOLA", coinGeckoId: "dola-usd" },
4872
- { ...import_tokenlist4.S_TOKEN, symbol: "S" },
4873
- { ...import_tokenlist4.EURC_TOKEN, symbol: "EURC", coinGeckoId: "euro-coin" },
4874
- { ...import_tokenlist4.USDT_TOKEN, symbol: "USDT", coinGeckoId: "tether" },
4875
- { ...import_tokenlist4.USDT0_TOKEN, symbol: "USDT0", coinGeckoId: "tether" }
6395
+ { ...tokenlist.ETH_TOKEN, symbol: "ETH", coinGeckoId: "ethereum" },
6396
+ { ...tokenlist.PXETH_TOKEN, symbol: "PXETH", coinGeckoId: "dinero-staked-eth" },
6397
+ { ...tokenlist.USDC_TOKEN, symbol: "USDC", coinGeckoId: "usd-coin" },
6398
+ { ...tokenlist.DOLA_TOKEN, symbol: "DOLA", coinGeckoId: "dola-usd" },
6399
+ { ...tokenlist.S_TOKEN, symbol: "S" },
6400
+ { ...tokenlist.EURC_TOKEN, symbol: "EURC", coinGeckoId: "euro-coin" },
6401
+ { ...tokenlist.USDT_TOKEN, symbol: "USDT", coinGeckoId: "tether" },
6402
+ { ...tokenlist.USDT0_TOKEN, symbol: "USDT0", coinGeckoId: "tether" }
4876
6403
  ];
4877
6404
  var PRICED_TOKENS = [
4878
6405
  ...BASE_ASSETS,
4879
- { ...import_tokenlist4.TOKE_TOKEN, symbol: "TOKE" },
4880
- { ...import_tokenlist4.SILO_TOKEN, symbol: "SILO" },
4881
- { ...import_tokenlist4.XPL_TOKEN, address: import_tokenlist4.WXPL_TOKEN.address, symbol: "XPL" },
4882
- { ...import_tokenlist4.USDT0_TOKEN, symbol: "USDT0" }
6406
+ { ...tokenlist.TOKE_TOKEN, symbol: "TOKE" },
6407
+ { ...tokenlist.SILO_TOKEN, symbol: "SILO" },
6408
+ { ...tokenlist.XPL_TOKEN, address: tokenlist.WXPL_TOKEN.address, symbol: "XPL" },
6409
+ { ...tokenlist.USDT0_TOKEN, symbol: "USDT0" }
4883
6410
  ];
4884
- var WRAPPED_TOKENS = [
4885
- { ...import_tokenlist4.WETH_TOKEN, symbol: "WETH" },
4886
- { ...import_tokenlist4.WS_TOKEN, symbol: "WS" },
4887
- { ...import_tokenlist4.WXPL_TOKEN, symbol: "WXPL" }
6411
+ [
6412
+ { ...tokenlist.WETH_TOKEN, symbol: "WETH" },
6413
+ { ...tokenlist.WS_TOKEN, symbol: "WS" },
6414
+ { ...tokenlist.WXPL_TOKEN, symbol: "WXPL" }
4888
6415
  ];
4889
6416
  var isStale = (timestamp) => {
4890
6417
  return timestamp - Math.floor(Date.now() / 1e3) > 5 * 60;
@@ -4899,7 +6426,7 @@ var getTokenPrices = async (isCronJob = false) => {
4899
6426
  timeoutMS: 5 * 1e3
4900
6427
  }))
4901
6428
  };
4902
- const response = await fetch(`${import_constants6.TOKEMAK_PRICES_STAGING_URL}`, {
6429
+ const response = await fetch(`${constants.TOKEMAK_PRICES_STAGING_URL}`, {
4903
6430
  method: "POST",
4904
6431
  headers: {
4905
6432
  "Content-Type": "application/json"
@@ -4949,9 +6476,6 @@ var getTokenPrices = async (isCronJob = false) => {
4949
6476
  }
4950
6477
  }
4951
6478
  };
4952
-
4953
- // functions/getHistoricalTokenPrices.ts
4954
- var import_tokenlist5 = require("@tokemak/tokenlist");
4955
6479
  var hasCoinGeckoId = (asset) => typeof asset?.coinGeckoId === "string" && asset.coinGeckoId.length > 0;
4956
6480
  var getBlobHistoricalTokenPrices = async (tokenSymbol) => {
4957
6481
  const blobName = `historical_v2/${tokenSymbol}-latest-success.json`;
@@ -4969,7 +6493,7 @@ var getHistoricalTokenPrices = async () => {
4969
6493
  const historicalBaseAssetPrices = await Promise.all(
4970
6494
  BASE_ASSETS.map(async (baseAsset) => {
4971
6495
  if (!hasCoinGeckoId(baseAsset)) {
4972
- const address = baseAsset.address === import_tokenlist5.ETH_TOKEN.address ? ETH_ADDRESS_IN_SUBGRAPH : baseAsset.address;
6496
+ const address = baseAsset.address === tokenlist.ETH_TOKEN.address ? ETH_ADDRESS_IN_SUBGRAPH : baseAsset.address;
4973
6497
  const prices2 = await getTokenValueDayDatas(
4974
6498
  address,
4975
6499
  baseAsset.chainId
@@ -5097,7 +6621,7 @@ var getUserAutopoolsHistory = async (address, autopoolsHistory, events, includeT
5097
6621
  Math.floor(sharesRatio * Number(SCALE))
5098
6622
  );
5099
6623
  const navBigInt = sharesRatioBigInt * BigInt(dayData.nav) / SCALE;
5100
- const navNum = (0, import_utils14.formatUnitsNum)(
6624
+ const navNum = utils.formatUnitsNum(
5101
6625
  navBigInt,
5102
6626
  dayData.baseAsset.decimals
5103
6627
  );
@@ -5168,7 +6692,7 @@ var getUserAutopoolsHistory = async (address, autopoolsHistory, events, includeT
5168
6692
  let finalAggregatedHistoryArray = Object.keys(aggregatedHistoryArray).map(
5169
6693
  (dateKey) => ({
5170
6694
  date: aggregatedHistoryArray[dateKey].date,
5171
- formattedDate: (0, import_utils14.formatDateToReadable)(aggregatedHistoryArray[dateKey].date),
6695
+ formattedDate: utils.formatDateToReadable(aggregatedHistoryArray[dateKey].date),
5172
6696
  nav: {
5173
6697
  ETH: aggregatedHistoryArray[dateKey].nav.ETH,
5174
6698
  USD: aggregatedHistoryArray[dateKey].nav.USD,
@@ -5203,7 +6727,7 @@ var getUserAutopoolsHistory = async (address, autopoolsHistory, events, includeT
5203
6727
  return eventDate.getTime() >= dayData.date.getTime() && eventDate.getTime() < dayData.date.getTime() + 24 * 60 * 60 * 1e3;
5204
6728
  });
5205
6729
  const differential = eventsForDay.reduce(
5206
- (sum, event) => sum + (0, import_utils14.formatEtherNum)(BigInt(event?.assetChange || 0n)),
6730
+ (sum, event) => sum + utils.formatEtherNum(BigInt(event?.assetChange || 0n)),
5207
6731
  0
5208
6732
  );
5209
6733
  return {
@@ -5222,11 +6746,6 @@ var getUserAutopoolsHistory = async (address, autopoolsHistory, events, includeT
5222
6746
  }
5223
6747
  return result;
5224
6748
  };
5225
-
5226
- // functions/getUserSushiLP.ts
5227
- var import_core6 = require("@wagmi/core");
5228
- var import_abis6 = require("@tokemak/abis");
5229
- var import_config6 = require("@tokemak/config");
5230
6749
  var getUserSushiLP = async (wagmiConfig, {
5231
6750
  sushiLP,
5232
6751
  currentCycleIndex,
@@ -5234,32 +6753,32 @@ var getUserSushiLP = async (wagmiConfig, {
5234
6753
  cycleRolloverBlockNumber,
5235
6754
  chainId
5236
6755
  }) => {
5237
- const { tSushiLP, sushiPool } = (0, import_config6.getMainnetConfig)();
6756
+ const { tSushiLP, sushiPool } = config.getMainnetConfig();
5238
6757
  try {
5239
6758
  if (address && currentCycleIndex && sushiLP) {
5240
6759
  const [
5241
6760
  { result: sushiLPBalance },
5242
6761
  { result: tSushiLPBalance },
5243
6762
  { result: tSushiLPRequested }
5244
- ] = await (0, import_core6.readContracts)(wagmiConfig, {
6763
+ ] = await core.readContracts(wagmiConfig, {
5245
6764
  contracts: [
5246
6765
  {
5247
6766
  address: sushiPool,
5248
- abi: import_abis6.sushiPoolAbi,
6767
+ abi: abis.sushiPoolAbi,
5249
6768
  functionName: "balanceOf",
5250
6769
  args: [address],
5251
6770
  chainId
5252
6771
  },
5253
6772
  {
5254
6773
  address: tSushiLP,
5255
- abi: import_abis6.poolV1Abi,
6774
+ abi: abis.poolV1Abi,
5256
6775
  functionName: "balanceOf",
5257
6776
  args: [address],
5258
6777
  chainId
5259
6778
  },
5260
6779
  {
5261
6780
  address: tSushiLP,
5262
- abi: import_abis6.poolV1Abi,
6781
+ abi: abis.poolV1Abi,
5263
6782
  functionName: "requestedWithdrawals",
5264
6783
  args: [address],
5265
6784
  chainId
@@ -5269,18 +6788,18 @@ var getUserSushiLP = async (wagmiConfig, {
5269
6788
  const [
5270
6789
  { result: startTSushiLPBalance },
5271
6790
  { result: startTSushiLPRequested }
5272
- ] = await (0, import_core6.readContracts)(wagmiConfig, {
6791
+ ] = await core.readContracts(wagmiConfig, {
5273
6792
  contracts: [
5274
6793
  {
5275
6794
  address: tSushiLP,
5276
- abi: import_abis6.poolV1Abi,
6795
+ abi: abis.poolV1Abi,
5277
6796
  functionName: "balanceOf",
5278
6797
  args: [address],
5279
6798
  chainId
5280
6799
  },
5281
6800
  {
5282
6801
  address: tSushiLP,
5283
- abi: import_abis6.poolV1Abi,
6802
+ abi: abis.poolV1Abi,
5284
6803
  functionName: "requestedWithdrawals",
5285
6804
  args: [address],
5286
6805
  chainId
@@ -5321,31 +6840,26 @@ var getUserSushiLP = async (wagmiConfig, {
5321
6840
  console.log(e);
5322
6841
  }
5323
6842
  };
5324
-
5325
- // functions/getUserCurveLP.ts
5326
- var import_core7 = require("@wagmi/core");
5327
- var import_abis7 = require("@tokemak/abis");
5328
- var import_config7 = require("@tokemak/config");
5329
6843
  var getUserCurveLP = async (wagmiConfig, {
5330
6844
  curveLP,
5331
6845
  address,
5332
6846
  chainId
5333
6847
  }) => {
5334
6848
  try {
5335
- const { curvePool, convexRewarder } = (0, import_config7.getMainnetConfig)();
6849
+ const { curvePool, convexRewarder } = config.getMainnetConfig();
5336
6850
  if (address && curveLP && curvePool && convexRewarder) {
5337
- const [{ result: userCurveLPBalance }, { result: userConvexLPBalance }] = await (0, import_core7.readContracts)(wagmiConfig, {
6851
+ const [{ result: userCurveLPBalance }, { result: userConvexLPBalance }] = await core.readContracts(wagmiConfig, {
5338
6852
  contracts: [
5339
6853
  {
5340
6854
  address: curvePool,
5341
- abi: import_abis7.poolV1Abi,
6855
+ abi: abis.poolV1Abi,
5342
6856
  functionName: "balanceOf",
5343
6857
  args: [address],
5344
6858
  chainId
5345
6859
  },
5346
6860
  {
5347
6861
  address: convexRewarder,
5348
- abi: import_abis7.poolV1Abi,
6862
+ abi: abis.poolV1Abi,
5349
6863
  functionName: "balanceOf",
5350
6864
  args: [address],
5351
6865
  chainId
@@ -5369,26 +6883,17 @@ var getUserCurveLP = async (wagmiConfig, {
5369
6883
  console.log(e);
5370
6884
  }
5371
6885
  };
5372
-
5373
- // functions/getMultipleAutopoolRebalances.ts
5374
- var import_graph_cli8 = require("@tokemak/graph-cli");
5375
6886
  var getMutlipleAutopoolRebalances = async (ids, chainId = 1) => {
5376
- const { GetMutlipleAutopoolRebalances } = (0, import_graph_cli8.getSdkByChainId)(chainId);
6887
+ const { GetMutlipleAutopoolRebalances } = graphCli.getSdkByChainId(chainId);
5377
6888
  const { autopools } = await GetMutlipleAutopoolRebalances({
5378
6889
  addresses: ids
5379
6890
  });
5380
6891
  const rebalances = autopools.map(({ rebalances: rebalances2 }) => rebalances2);
5381
6892
  return rebalances.flat().sort((a, b) => b.timestamp - a.timestamp);
5382
6893
  };
5383
-
5384
- // functions/getAutopoolDayData.ts
5385
- var import_viem7 = require("viem");
5386
- var import_utils16 = require("@tokemak/utils");
5387
- var import_constants7 = require("@tokemak/constants");
5388
- var import_graph_cli9 = require("@tokemak/graph-cli");
5389
- var getAutopoolDayData = async (address, chainId = 1, startTimestamp = import_constants7.TOKEMAK_LAUNCH_TIMESTAMP) => {
6894
+ var getAutopoolDayData = async (address, chainId = 1, startTimestamp = constants.TOKEMAK_LAUNCH_TIMESTAMP) => {
5390
6895
  try {
5391
- const { GetAutopoolDayData } = (0, import_graph_cli9.getSdkByChainId)(chainId);
6896
+ const { GetAutopoolDayData } = graphCli.getSdkByChainId(chainId);
5392
6897
  const { autopoolDayDatas } = await GetAutopoolDayData({
5393
6898
  address,
5394
6899
  timestamp: startTimestamp
@@ -5397,10 +6902,10 @@ var getAutopoolDayData = async (address, chainId = 1, startTimestamp = import_co
5397
6902
  const navPerShare = autoPoolDayData.nav / autoPoolDayData.totalSupply;
5398
6903
  let baseApy = autoPoolDayData.autopoolApy;
5399
6904
  let rewarderApy = 0;
5400
- const formattedRewarder7DayMAApy = (0, import_utils16.formatEtherNum)(
6905
+ const formattedRewarder7DayMAApy = utils.formatEtherNum(
5401
6906
  BigInt(Number(autoPoolDayData.rewarderDay7MAApy) || 0)
5402
6907
  );
5403
- const formattedRewarder30DayMAApy = (0, import_utils16.formatEtherNum)(
6908
+ const formattedRewarder30DayMAApy = utils.formatEtherNum(
5404
6909
  BigInt(Number(autoPoolDayData.rewarderDay30MAApy) || 0)
5405
6910
  );
5406
6911
  if (formattedRewarder7DayMAApy) {
@@ -5413,7 +6918,7 @@ var getAutopoolDayData = async (address, chainId = 1, startTimestamp = import_co
5413
6918
  baseApy = 0;
5414
6919
  } else {
5415
6920
  baseApy = Number(
5416
- (0, import_viem7.formatUnits)(BigInt(baseApy), autoPoolDayData.baseAsset.decimals)
6921
+ viem.formatUnits(BigInt(baseApy), autoPoolDayData.baseAsset.decimals)
5417
6922
  );
5418
6923
  }
5419
6924
  if (baseApy < 0) {
@@ -5436,10 +6941,6 @@ var getAutopoolDayData = async (address, chainId = 1, startTimestamp = import_co
5436
6941
  return [];
5437
6942
  }
5438
6943
  };
5439
-
5440
- // functions/getSystemConfig.ts
5441
- var import_core8 = require("@wagmi/core");
5442
- var import_abis8 = require("@tokemak/abis");
5443
6944
  var systemRegistryFunctionNames = [
5444
6945
  "asyncSwapperRegistry",
5445
6946
  "autoPoolRouter",
@@ -5450,7 +6951,7 @@ var systemRegistryFunctionNames = [
5450
6951
  var getSystemConfig = async (wagmiConfig, { systemRegistry }) => {
5451
6952
  const systemRegistryContract = {
5452
6953
  address: systemRegistry,
5453
- abi: import_abis8.systemRegistryAbi
6954
+ abi: abis.systemRegistryAbi
5454
6955
  };
5455
6956
  const systemRegistryCalls = systemRegistryFunctionNames.map(
5456
6957
  (functionName) => ({
@@ -5464,7 +6965,7 @@ var getSystemConfig = async (wagmiConfig, { systemRegistry }) => {
5464
6965
  { result: autopoolRouter },
5465
6966
  { result: autopoolRegistry },
5466
6967
  { result: swapRouter }
5467
- ] = await (0, import_core8.readContracts)(wagmiConfig, {
6968
+ ] = await core.readContracts(wagmiConfig, {
5468
6969
  contracts: systemRegistryCalls
5469
6970
  });
5470
6971
  return {
@@ -5477,14 +6978,11 @@ var getSystemConfig = async (wagmiConfig, { systemRegistry }) => {
5477
6978
  console.log(e);
5478
6979
  }
5479
6980
  };
5480
-
5481
- // functions/getChainUserAutopools.tsx
5482
- var import_graph_cli10 = require("@tokemak/graph-cli");
5483
6981
  var getChainUserAutopools = async ({
5484
6982
  address,
5485
6983
  chainId = 1
5486
6984
  }) => {
5487
- const { GetUserVaultInfo } = (0, import_graph_cli10.getSdkByChainId)(chainId);
6985
+ const { GetUserVaultInfo } = graphCli.getSdkByChainId(chainId);
5488
6986
  try {
5489
6987
  if (address) {
5490
6988
  const { userInfo } = await GetUserVaultInfo({
@@ -5498,16 +6996,6 @@ var getChainUserAutopools = async ({
5498
6996
  return [];
5499
6997
  }
5500
6998
  };
5501
-
5502
- // functions/getUserAutopools.ts
5503
- var import_utils18 = require("@tokemak/utils");
5504
- var import_tokenlist6 = require("@tokemak/tokenlist");
5505
-
5506
- // functions/getUserAutopool.tsx
5507
- var import_viem8 = require("viem");
5508
- var import_core9 = require("@wagmi/core");
5509
- var import_utils17 = require("@tokemak/utils");
5510
- var import_abis9 = require("@tokemak/abis");
5511
6999
  var getUserAutopool = async (wagmiConfig, {
5512
7000
  address,
5513
7001
  autopool
@@ -5516,14 +7004,14 @@ var getUserAutopool = async (wagmiConfig, {
5516
7004
  if (autopool && address) {
5517
7005
  const autopoolContract = {
5518
7006
  address: autopool?.poolAddress,
5519
- abi: import_abis9.autopoolEthAbi,
7007
+ abi: abis.autopoolEthAbi,
5520
7008
  chainId: autopool?.chain?.chainId
5521
7009
  };
5522
7010
  const [
5523
7011
  { result: autopoolRewarderContract },
5524
7012
  { result: pastRewarders },
5525
7013
  { result: unstakedPoolShares, error: unstakedPoolSharesError }
5526
- ] = await (0, import_core9.readContracts)(wagmiConfig, {
7014
+ ] = await core.readContracts(wagmiConfig, {
5527
7015
  contracts: [
5528
7016
  {
5529
7017
  ...autopoolContract,
@@ -5548,17 +7036,17 @@ var getUserAutopool = async (wagmiConfig, {
5548
7036
  if (unstakedPoolSharesError) {
5549
7037
  throw new Error("Error fetching unstaked pool shares");
5550
7038
  }
5551
- const stakedPoolShares = await (0, import_core9.readContract)(wagmiConfig, {
7039
+ const stakedPoolShares = await core.readContract(wagmiConfig, {
5552
7040
  address: autopoolRewarderContract,
5553
- abi: import_viem8.erc20Abi,
7041
+ abi: viem.erc20Abi,
5554
7042
  functionName: "balanceOf",
5555
7043
  args: [address],
5556
7044
  chainId: autopool?.chain?.chainId
5557
7045
  });
5558
- const stakedShares = (0, import_utils17.formatEtherNum)(stakedPoolShares);
7046
+ const stakedShares = utils.formatEtherNum(stakedPoolShares);
5559
7047
  const stakedNav = stakedShares * (autopool?.navPerShare.baseAsset || 0);
5560
7048
  const stakedNavUsd = stakedShares * (autopool?.navPerShare.USD || 0);
5561
- const unstakedShares = (0, import_utils17.formatEtherNum)(unstakedPoolShares || 0n);
7049
+ const unstakedShares = utils.formatEtherNum(unstakedPoolShares || 0n);
5562
7050
  const unstakedNav = unstakedShares * (autopool?.navPerShare.USD || 0);
5563
7051
  const unstakedNavUsd = unstakedShares * (autopool?.navPerShare.USD || 0);
5564
7052
  const totalShares = unstakedShares + stakedShares;
@@ -5569,17 +7057,17 @@ var getUserAutopool = async (wagmiConfig, {
5569
7057
  if (pastRewarders && pastRewarders?.length > 0) {
5570
7058
  const pastRewardBalances = pastRewarders.map((rewarder) => ({
5571
7059
  address: rewarder,
5572
- abi: import_viem8.erc20Abi,
7060
+ abi: viem.erc20Abi,
5573
7061
  functionName: "balanceOf",
5574
7062
  args: [address],
5575
7063
  chainId: autopool?.chain?.chainId
5576
7064
  }));
5577
- const pastRewards = await (0, import_core9.readContracts)(wagmiConfig, {
7065
+ const pastRewards = await core.readContracts(wagmiConfig, {
5578
7066
  contracts: pastRewardBalances
5579
7067
  });
5580
7068
  pastRewarderBalances = pastRewards.map(({ result }, index) => {
5581
7069
  const balance = result;
5582
- const shares = (0, import_utils17.formatEtherNum)(result);
7070
+ const shares = utils.formatEtherNum(result);
5583
7071
  const nav = shares * (autopool?.navPerShare.baseAsset || 0);
5584
7072
  const navUsd = shares * (autopool?.navPerShare.USD || 0);
5585
7073
  return {
@@ -5697,14 +7185,14 @@ var getUserAutopools = async ({
5697
7185
  );
5698
7186
  if (autopoolData) {
5699
7187
  const isDOLA = autopoolData.symbol === "autoDOLA" && userAutoDOLA;
5700
- const userShares = isDOLA ? userAutoDOLA?.totalShares : (0, import_utils18.formatEtherNum)(userAutopool?.totalShares);
5701
- const totalVaultShares = (0, import_utils18.formatEtherNum)(autopoolData?.totalSupply);
7188
+ const userShares = isDOLA ? userAutoDOLA?.totalShares : utils.formatEtherNum(userAutopool?.totalShares);
7189
+ const totalVaultShares = utils.formatEtherNum(autopoolData?.totalSupply);
5702
7190
  const userShareOfVault = userShares / totalVaultShares;
5703
- const totalDeposits = (0, import_utils18.formatUnitsNum)(
7191
+ const totalDeposits = utils.formatUnitsNum(
5704
7192
  userActivity?.totals[userAutopool.vaultAddress]?.totalDeposits || 0n,
5705
7193
  autopoolData?.baseAsset.decimals
5706
7194
  );
5707
- const totalWithdrawals = (0, import_utils18.formatUnitsNum)(
7195
+ const totalWithdrawals = utils.formatUnitsNum(
5708
7196
  userActivity?.totals[userAutopool.vaultAddress]?.totalWithdrawals || 0n,
5709
7197
  autopoolData?.baseAsset.decimals
5710
7198
  );
@@ -5713,7 +7201,7 @@ var getUserAutopools = async ({
5713
7201
  );
5714
7202
  let lastDeposit;
5715
7203
  if (poolEvents && poolEvents?.length > 0) {
5716
- lastDeposit = (0, import_utils18.convertTimestampToDate)(
7204
+ lastDeposit = utils.convertTimestampToDate(
5717
7205
  poolEvents[poolEvents.length - 1].timestamp
5718
7206
  ).toLocaleDateString("en-US", {
5719
7207
  day: "2-digit",
@@ -5813,7 +7301,7 @@ var getUserAutopools = async ({
5813
7301
  totalWithdrawals: prev.totalWithdrawals + totalWithdrawals
5814
7302
  };
5815
7303
  const stakedBalance = isDOLA ? userAutoDOLA?.staked.balance : BigInt(userAutopool?.stakedShares);
5816
- const stakedShares = isDOLA ? userAutoDOLA?.staked.shares : (0, import_utils18.formatEtherNum)(stakedBalance);
7304
+ const stakedShares = isDOLA ? userAutoDOLA?.staked.shares : utils.formatEtherNum(stakedBalance);
5817
7305
  const stakedNav = stakedShares * (autopoolData?.navPerShare.baseAsset || 0);
5818
7306
  const staked = convertBaseAssetToTokenPrices(
5819
7307
  stakedNav,
@@ -5821,7 +7309,7 @@ var getUserAutopools = async ({
5821
7309
  prices
5822
7310
  );
5823
7311
  const unstakedBalance = isDOLA ? userAutoDOLA?.unstaked.balance : BigInt(userAutopool?.walletShares);
5824
- const unstakedShares = isDOLA ? userAutoDOLA?.unstaked.shares : (0, import_utils18.formatEtherNum)(unstakedBalance);
7312
+ const unstakedShares = isDOLA ? userAutoDOLA?.unstaked.shares : utils.formatEtherNum(unstakedBalance);
5825
7313
  const unstakedNav = unstakedShares * (autopoolData?.navPerShare.baseAsset || 0);
5826
7314
  const unstaked = convertBaseAssetToTokenPrices(
5827
7315
  unstakedNav,
@@ -5866,7 +7354,7 @@ var getUserAutopools = async ({
5866
7354
  };
5867
7355
  }
5868
7356
  });
5869
- let denominatedToken = import_tokenlist6.ETH_TOKEN;
7357
+ let denominatedToken = tokenlist.ETH_TOKEN;
5870
7358
  const useDenomination = userAutopoolsWithData.filter((autopool) => autopool?.useDenomination).length === 1 && userAutopoolsWithData.length === 1;
5871
7359
  if (useDenomination) {
5872
7360
  const autopoolWithDenomination = userAutopoolsWithData.find(
@@ -6018,17 +7506,13 @@ var getUserAutopools = async ({
6018
7506
  console.log(e);
6019
7507
  }
6020
7508
  };
6021
-
6022
- // functions/getUserTokenBalances.ts
6023
- var import_viem9 = require("viem");
6024
- var import_chains6 = require("viem/chains");
6025
7509
  var networkToAlchemyUrl = (chainId, apiKey) => {
6026
7510
  switch (chainId) {
6027
- case import_chains6.mainnet.id:
7511
+ case chains.mainnet.id:
6028
7512
  return `https://eth-mainnet.g.alchemy.com/v2/${apiKey}`;
6029
- case import_chains6.base.id:
7513
+ case chains.base.id:
6030
7514
  return `https://base-mainnet.g.alchemy.com/v2/${apiKey}`;
6031
- case import_chains6.sonic.id:
7515
+ case chains.sonic.id:
6032
7516
  return `https://sonic-mainnet.g.alchemy.com/v2/${apiKey}`;
6033
7517
  default:
6034
7518
  throw new Error("Unsupported network");
@@ -6064,7 +7548,7 @@ var getUserTokenBalances = async ({
6064
7548
  const tokenBalances = data.result.tokenBalances.reduce(
6065
7549
  (acc, balance) => {
6066
7550
  if (balance.tokenBalance && BigInt(balance.tokenBalance) !== BigInt(0)) {
6067
- acc[balance.contractAddress] = (0, import_viem9.hexToBigInt)(
7551
+ acc[balance.contractAddress] = viem.hexToBigInt(
6068
7552
  balance.tokenBalance
6069
7553
  );
6070
7554
  }
@@ -6074,12 +7558,9 @@ var getUserTokenBalances = async ({
6074
7558
  );
6075
7559
  return tokenBalances;
6076
7560
  };
6077
-
6078
- // functions/getTokenList.ts
6079
- var import_tokenlist7 = require("@tokemak/tokenlist");
6080
7561
  var getTokenList = async () => {
6081
7562
  try {
6082
- let url = `${import_tokenlist7.TOKEMAK_LISTS_URL}/swap_enabled.json`;
7563
+ let url = `${tokenlist.TOKEMAK_LISTS_URL}/swap_enabled.json`;
6083
7564
  const listResponse = await fetch(url);
6084
7565
  const { tokens: tokenList } = await listResponse.json();
6085
7566
  return tokenList;
@@ -6088,12 +7569,9 @@ var getTokenList = async () => {
6088
7569
  return [];
6089
7570
  }
6090
7571
  };
6091
-
6092
- // functions/getTopAutopoolHolders.ts
6093
- var import_graph_cli11 = require("@tokemak/graph-cli");
6094
7572
  var getTopAutopoolHolders = async (autopoolAddress, chainId = 1) => {
6095
7573
  try {
6096
- const { GetTopAutopoolHolders } = (0, import_graph_cli11.getSdkByChainId)(chainId);
7574
+ const { GetTopAutopoolHolders } = graphCli.getSdkByChainId(chainId);
6097
7575
  const { holders } = await GetTopAutopoolHolders({
6098
7576
  address: autopoolAddress
6099
7577
  });
@@ -6103,19 +7581,15 @@ var getTopAutopoolHolders = async (autopoolAddress, chainId = 1) => {
6103
7581
  return [];
6104
7582
  }
6105
7583
  };
6106
-
6107
- // functions/getAllowance.ts
6108
- var import_core10 = require("@wagmi/core");
6109
- var import_viem10 = require("viem");
6110
7584
  var getAllowance = async (wagmiConfig, {
6111
7585
  token,
6112
7586
  address,
6113
7587
  spender
6114
7588
  }) => {
6115
7589
  try {
6116
- const allowance = await (0, import_core10.readContract)(wagmiConfig, {
7590
+ const allowance = await core.readContract(wagmiConfig, {
6117
7591
  address: token,
6118
- abi: import_viem10.erc20Abi,
7592
+ abi: viem.erc20Abi,
6119
7593
  functionName: "allowance",
6120
7594
  args: [address || "0x0", spender]
6121
7595
  });
@@ -6154,23 +7628,15 @@ var getUserActivity = async ({
6154
7628
  mergedActivity.events.sort((a, b) => a.timestamp - b.timestamp);
6155
7629
  return mergedActivity;
6156
7630
  };
6157
-
6158
- // functions/getUserAutopoolsRewards.ts
6159
- var import_viem11 = require("viem");
6160
-
6161
- // functions/getChainUserAutopoolsRewards.ts
6162
- var import_config8 = require("@tokemak/config");
6163
- var import_core11 = require("@wagmi/core");
6164
- var import_abis10 = require("@tokemak/abis");
6165
7631
  var getChainUserAutopoolsRewards = async (wagmiConfig, {
6166
7632
  chainId,
6167
7633
  address
6168
7634
  }) => {
6169
7635
  try {
6170
- const coreConfig = (0, import_config8.getCoreConfig)(chainId);
6171
- const userRewardsInfo = await (0, import_core11.readContract)(wagmiConfig, {
7636
+ const coreConfig = config.getCoreConfig(chainId);
7637
+ const userRewardsInfo = await core.readContract(wagmiConfig, {
6172
7638
  address: coreConfig.lens,
6173
- abi: import_abis10.lensAbi,
7639
+ abi: abis.lensAbi,
6174
7640
  functionName: "getUserRewardInfo",
6175
7641
  args: [address],
6176
7642
  chainId: coreConfig.id
@@ -6198,55 +7664,50 @@ var getChainUserAutopoolsRewards = async (wagmiConfig, {
6198
7664
  console.log(e);
6199
7665
  }
6200
7666
  };
6201
-
6202
- // functions/getUserAutopoolsRewards.ts
6203
- var import_utils22 = require("@tokemak/utils");
6204
- var import_tokenlist8 = require("@tokemak/tokenlist");
6205
- var import_chains7 = require("viem/chains");
6206
7667
  var getUserAutopoolsRewards = async (wagmiConfig, {
6207
7668
  address,
6208
7669
  tokenPrices,
6209
7670
  autopools,
6210
7671
  includeTestnet = false
6211
7672
  }) => {
6212
- const chains = getChainsForEnv({ includeTestnet });
7673
+ const chains$1 = getChainsForEnv({ includeTestnet });
6213
7674
  try {
6214
7675
  if (!autopools)
6215
7676
  throw new Error("No autopools found");
6216
7677
  const userRewards = await Promise.all(
6217
- chains.map(
7678
+ chains$1.map(
6218
7679
  (chain) => getChainUserAutopoolsRewards(wagmiConfig, {
6219
7680
  chainId: chain.chainId,
6220
7681
  address
6221
7682
  })
6222
7683
  )
6223
7684
  );
6224
- const rewardsData = chains.map(({ chainId }, index) => {
7685
+ const rewardsData = chains$1.map(({ chainId }, index) => {
6225
7686
  const chainUserRewards = userRewards[index] || {};
6226
7687
  const extraRewardsArray = Object.entries(chainUserRewards).flatMap(
6227
7688
  ([autopoolAddress, rewards]) => {
6228
7689
  const autopool = autopools.find(
6229
- (autopool2) => (0, import_viem11.getAddress)(autopool2.poolAddress) === (0, import_viem11.getAddress)(autopoolAddress)
7690
+ (autopool2) => viem.getAddress(autopool2.poolAddress) === viem.getAddress(autopoolAddress)
6230
7691
  );
6231
7692
  if (!autopool || !autopool.extraRewarders) {
6232
7693
  return [];
6233
7694
  }
6234
7695
  return autopool.extraRewarders.map((extraRewards2) => {
6235
- const rewarderToken = (0, import_utils22.getToken)(
7696
+ const rewarderToken = utils.getToken(
6236
7697
  extraRewards2.rewardToken?.id,
6237
7698
  autopool.chain?.chainId
6238
7699
  );
6239
- const claimableAmount = rewards ? rewards[(0, import_viem11.getAddress)(extraRewards2.rewardToken?.id)] : 0n;
7700
+ const claimableAmount = rewards ? rewards[viem.getAddress(extraRewards2.rewardToken?.id)] : 0n;
6240
7701
  let price = tokenPrices[rewarderToken.symbol] || 0;
6241
7702
  if (rewarderToken.symbol === "XSILO") {
6242
- price = tokenPrices[import_tokenlist8.SILO_TOKEN.symbol] || 0;
7703
+ price = tokenPrices[tokenlist.SILO_TOKEN.symbol] || 0;
6243
7704
  }
6244
- const formattedAmount = (0, import_utils22.formatUnitsNum)(
7705
+ const formattedAmount = utils.formatUnitsNum(
6245
7706
  claimableAmount,
6246
7707
  rewarderToken.decimals || 18
6247
7708
  );
6248
7709
  return {
6249
- address: (0, import_viem11.getAddress)(extraRewards2?.id),
7710
+ address: viem.getAddress(extraRewards2?.id),
6250
7711
  chainId,
6251
7712
  token: rewarderToken,
6252
7713
  amount: claimableAmount,
@@ -6259,7 +7720,7 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
6259
7720
  const tokenRewards = {};
6260
7721
  Object.values(chainUserRewards).forEach((autopoolRewards) => {
6261
7722
  Object.entries(autopoolRewards).forEach(([tokenAddress, amount]) => {
6262
- const token = (0, import_utils22.getToken)(tokenAddress, chainId);
7723
+ const token = utils.getToken(tokenAddress, chainId);
6263
7724
  const tokenSymbol = token.symbol;
6264
7725
  if (!tokenRewards[tokenSymbol]) {
6265
7726
  tokenRewards[tokenSymbol] = {
@@ -6277,9 +7738,9 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
6277
7738
  ([tokenSymbol, { amount, decimals }]) => {
6278
7739
  let price = tokenPrices[tokenSymbol] || 0;
6279
7740
  if (tokenSymbol === "XSILO") {
6280
- price = tokenPrices[import_tokenlist8.SILO_TOKEN.symbol] || 0;
7741
+ price = tokenPrices[tokenlist.SILO_TOKEN.symbol] || 0;
6281
7742
  }
6282
- const formattedAmount = (0, import_utils22.formatUnitsNum)(amount, decimals || 18);
7743
+ const formattedAmount = utils.formatUnitsNum(amount, decimals || 18);
6283
7744
  tokenRewards[tokenSymbol] = {
6284
7745
  amount,
6285
7746
  formattedAmount,
@@ -6288,13 +7749,13 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
6288
7749
  };
6289
7750
  }
6290
7751
  );
6291
- if (Object.keys(tokenRewards).includes("undefined") && chainId === import_chains7.plasma.id) {
7752
+ if (Object.keys(tokenRewards).includes("undefined") && chainId === chains.plasma.id) {
6292
7753
  const undefinedToken = tokenRewards["undefined"];
6293
7754
  let price = tokenPrices.TOKE || 0;
6294
7755
  tokenRewards["TOKE"] = {
6295
7756
  ...undefinedToken,
6296
7757
  USD: undefinedToken.formattedAmount * price,
6297
- logoURI: import_tokenlist8.TOKE_TOKEN.logoURI
7758
+ logoURI: tokenlist.TOKE_TOKEN.logoURI
6298
7759
  };
6299
7760
  delete tokenRewards["undefined"];
6300
7761
  }
@@ -6347,26 +7808,14 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
6347
7808
  console.error(e);
6348
7809
  }
6349
7810
  };
6350
-
6351
- // functions/getAmountWithdrawn.ts
6352
- var import_viem13 = require("viem");
6353
- var import_utils24 = require("@tokemak/utils");
6354
-
6355
- // functions/getSwapQuote.ts
6356
- var import_constants8 = require("@tokemak/constants");
6357
-
6358
- // functions/getAddressFromSystemRegistry.ts
6359
- var import_core12 = require("@wagmi/core");
6360
- var import_config9 = require("@tokemak/config");
6361
- var import_abis11 = require("@tokemak/abis");
6362
7811
  var getAddressFromSystemRegistry = async (wagmiConfig, {
6363
7812
  chainId,
6364
7813
  functionName
6365
7814
  }) => {
6366
- const { systemRegistry } = (0, import_config9.getCoreConfig)(chainId);
6367
- return await (0, import_core12.readContract)(wagmiConfig, {
7815
+ const { systemRegistry } = config.getCoreConfig(chainId);
7816
+ return await core.readContract(wagmiConfig, {
6368
7817
  address: systemRegistry,
6369
- abi: import_abis11.systemRegistryAbi,
7818
+ abi: abis.systemRegistryAbi,
6370
7819
  functionName,
6371
7820
  chainId
6372
7821
  });
@@ -6377,28 +7826,23 @@ var getAutopilotRouter = async (wagmiConfig, { chainId }) => await getAddressFro
6377
7826
  chainId,
6378
7827
  functionName: "autoPoolRouter"
6379
7828
  });
6380
-
6381
- // functions/getSwapQuote.ts
6382
- var import_config10 = require("@tokemak/config");
6383
- var import_tokenlist9 = require("@tokemak/tokenlist");
6384
- var import_chains8 = require("viem/chains");
6385
- var getSwapQuote = async (config, { chainId, ...params }) => {
7829
+ var getSwapQuote = async (config$1, { chainId, ...params }) => {
6386
7830
  try {
6387
7831
  if (!params.sellToken || !params.buyToken) {
6388
7832
  throw new Error("Sell token and buy token are required");
6389
7833
  }
6390
- if (params.sellToken === import_tokenlist9.ETH_TOKEN.address) {
6391
- params.sellToken = (0, import_config10.getCoreConfig)(chainId).weth;
6392
- if (chainId === import_chains8.sonic.id) {
6393
- params.sellToken = import_tokenlist9.WS_TOKEN.address;
7834
+ if (params.sellToken === tokenlist.ETH_TOKEN.address) {
7835
+ params.sellToken = config.getCoreConfig(chainId).weth;
7836
+ if (chainId === chains.sonic.id) {
7837
+ params.sellToken = tokenlist.WS_TOKEN.address;
6394
7838
  }
6395
- if (chainId === import_chains8.plasma.id) {
6396
- params.sellToken = import_tokenlist9.WXPL_TOKEN.address;
7839
+ if (chainId === chains.plasma.id) {
7840
+ params.sellToken = tokenlist.WXPL_TOKEN.address;
6397
7841
  }
6398
7842
  }
6399
7843
  const sellAmount = params.sellAmount.toString();
6400
- const taker = await getAutopilotRouter(config, { chainId });
6401
- const response = await fetch(import_constants8.TOKEMAK_SWAP_QUOTE_URL, {
7844
+ const taker = await getAutopilotRouter(config$1, { chainId });
7845
+ const response = await fetch(constants.TOKEMAK_SWAP_QUOTE_URL, {
6402
7846
  method: "POST",
6403
7847
  headers: {
6404
7848
  "Content-Type": "application/json"
@@ -6422,20 +7866,12 @@ var getSwapQuote = async (config, { chainId, ...params }) => {
6422
7866
  return void 0;
6423
7867
  }
6424
7868
  };
6425
-
6426
- // functions/getDynamicSwap.ts
6427
- var import_core13 = require("@wagmi/core");
6428
- var import_abis12 = require("@tokemak/abis");
6429
- var import_config11 = require("@tokemak/config");
6430
- var import_autopilot_swap_route_calc = require("@tokemak/autopilot-swap-route-calc");
6431
- var import_viem12 = require("viem");
6432
- var import_constants9 = require("@tokemak/constants");
6433
7869
  var placeholderAddress = "0x8b4334d4812c530574bd4f2763fcd22de94a969b";
6434
7870
  var getDynamicSwap = async ({
6435
7871
  address,
6436
7872
  amount,
6437
7873
  chainId,
6438
- config,
7874
+ config: config$1,
6439
7875
  slippage,
6440
7876
  user
6441
7877
  }) => {
@@ -6443,12 +7879,12 @@ var getDynamicSwap = async ({
6443
7879
  let previewRedeem = 0n;
6444
7880
  let dynamicSwaps;
6445
7881
  let standardPreviewRedeem = false;
6446
- const client = await (0, import_core13.getPublicClient)(config, { chainId });
7882
+ const client = await core.getPublicClient(config$1, { chainId });
6447
7883
  try {
6448
- const { systemRegistry } = (0, import_config11.getCoreConfig)(chainId);
7884
+ const { systemRegistry } = config.getCoreConfig(chainId);
6449
7885
  client.transport.retryCount = 0;
6450
7886
  client.transport.transports = [client.transport.transports[0]];
6451
- const liquidations = await (0, import_autopilot_swap_route_calc.getLiquidations)(
7887
+ const liquidations = await autopilotSwapRouteCalc.getLiquidations(
6452
7888
  chainId,
6453
7889
  systemRegistry,
6454
7890
  client.transport.transports[0].value.url,
@@ -6479,16 +7915,16 @@ var getDynamicSwap = async ({
6479
7915
  sellAllOnlyCompatible: true
6480
7916
  })
6481
7917
  };
6482
- dynamicSwaps = await (await fetch(import_constants9.TOKEMAK_DYNAMIC_SWAP_ROUTES_URL, requestInit)).json();
7918
+ dynamicSwaps = await (await fetch(constants.TOKEMAK_DYNAMIC_SWAP_ROUTES_URL, requestInit)).json();
6483
7919
  if (dynamicSwaps?.success) {
6484
- const autopoolRouter = await getAutopilotRouter(config, { chainId });
7920
+ const autopoolRouter = await getAutopilotRouter(config$1, { chainId });
6485
7921
  if (!autopoolRouter) {
6486
7922
  throw new Error("No autopool router found");
6487
7923
  }
6488
7924
  try {
6489
7925
  await client?.simulateContract({
6490
7926
  address: autopoolRouter,
6491
- abi: import_abis12.autopilotRouterAbi,
7927
+ abi: abis.autopilotRouterAbi,
6492
7928
  functionName: "previewRedeemWithRoutes",
6493
7929
  args: [
6494
7930
  address,
@@ -6503,7 +7939,7 @@ var getDynamicSwap = async ({
6503
7939
  account: user || placeholderAddress
6504
7940
  });
6505
7941
  } catch (e) {
6506
- if (e instanceof import_viem12.ContractFunctionExecutionError && e.cause instanceof import_viem12.ContractFunctionRevertedError && e.cause.data?.errorName === "PreviewRedeemWithRoutesResult") {
7942
+ if (e instanceof viem.ContractFunctionExecutionError && e.cause instanceof viem.ContractFunctionRevertedError && e.cause.data?.errorName === "PreviewRedeemWithRoutesResult") {
6507
7943
  previewRedeem = e.cause.data?.args?.[0];
6508
7944
  }
6509
7945
  }
@@ -6512,9 +7948,9 @@ var getDynamicSwap = async ({
6512
7948
  console.log(e);
6513
7949
  }
6514
7950
  }
6515
- const previewRedeemOnChain = await (0, import_core13.readContract)(config, {
7951
+ const previewRedeemOnChain = await core.readContract(config$1, {
6516
7952
  address,
6517
- abi: import_abis12.autopoolEthAbi,
7953
+ abi: abis.autopoolEthAbi,
6518
7954
  functionName: "previewRedeem",
6519
7955
  args: [amount],
6520
7956
  chainId,
@@ -6530,12 +7966,6 @@ var getDynamicSwap = async ({
6530
7966
  previewRedeem
6531
7967
  };
6532
7968
  };
6533
-
6534
- // functions/getAmountWithdrawn.ts
6535
- var import_tokenlist10 = require("@tokemak/tokenlist");
6536
- var import_config12 = require("@tokemak/config");
6537
- var import_core14 = require("@wagmi/core");
6538
- var import_abis13 = require("@tokemak/abis");
6539
7969
  var getAmountWithdrawn = async ({
6540
7970
  address,
6541
7971
  slippage,
@@ -6545,7 +7975,7 @@ var getAmountWithdrawn = async ({
6545
7975
  decimals = 18,
6546
7976
  buyToken,
6547
7977
  isSwap,
6548
- config,
7978
+ config: config$1,
6549
7979
  sellToken,
6550
7980
  autopool
6551
7981
  }) => {
@@ -6558,25 +7988,25 @@ var getAmountWithdrawn = async ({
6558
7988
  user,
6559
7989
  amount,
6560
7990
  chainId,
6561
- config,
7991
+ config: config$1,
6562
7992
  slippage
6563
7993
  });
6564
7994
  let quote;
6565
7995
  let convertedAssets;
6566
7996
  if (!!dynamicSwap?.previewRedeem) {
6567
- const minAmountWithSlippage = (0, import_utils24.calculateMinAmountWithSlippage)(
7997
+ const minAmountWithSlippage = utils.calculateMinAmountWithSlippage(
6568
7998
  dynamicSwap?.previewRedeem,
6569
7999
  slippage
6570
8000
  );
6571
- let minAmount = (0, import_viem13.formatUnits)(minAmountWithSlippage, decimals);
8001
+ let minAmount = viem.formatUnits(minAmountWithSlippage, decimals);
6572
8002
  if (isSwap) {
6573
- if (buyToken === import_tokenlist10.ETH_TOKEN.address) {
6574
- const weth = (0, import_config12.getCoreConfig)(chainId).weth;
8003
+ if (buyToken === tokenlist.ETH_TOKEN.address) {
8004
+ const weth = config.getCoreConfig(chainId).weth;
6575
8005
  buyToken = weth;
6576
8006
  }
6577
- convertedAssets = await (0, import_core14.readContract)(config, {
8007
+ convertedAssets = await core.readContract(config$1, {
6578
8008
  address: autopool,
6579
- abi: import_abis13.autopoolEthAbi,
8009
+ abi: abis.autopoolEthAbi,
6580
8010
  functionName: "convertToAssets",
6581
8011
  args: [amount],
6582
8012
  chainId
@@ -6584,17 +8014,17 @@ var getAmountWithdrawn = async ({
6584
8014
  if (!convertedAssets) {
6585
8015
  throw new Error("No converted assets");
6586
8016
  }
6587
- quote = await getSwapQuote(config, {
8017
+ quote = await getSwapQuote(config$1, {
6588
8018
  buyToken,
6589
8019
  sellToken,
6590
8020
  sellAmount: dynamicSwap?.previewRedeem,
6591
- slippageBps: (0, import_utils24.convertNumToBps)(slippage),
8021
+ slippageBps: utils.convertNumToBps(slippage),
6592
8022
  chainId,
6593
8023
  includeSources: "0xV2",
6594
8024
  sellAll: true
6595
8025
  });
6596
8026
  if (quote) {
6597
- minAmount = (0, import_viem13.formatUnits)(BigInt(quote?.minBuyAmount), decimals);
8027
+ minAmount = viem.formatUnits(BigInt(quote?.minBuyAmount), decimals);
6598
8028
  } else {
6599
8029
  throw new Error("No quote found");
6600
8030
  }
@@ -6612,11 +8042,6 @@ var getAmountWithdrawn = async ({
6612
8042
  };
6613
8043
  }
6614
8044
  };
6615
-
6616
- // functions/getAmountDeposited.ts
6617
- var import_core15 = require("@wagmi/core");
6618
- var import_abis14 = require("@tokemak/abis");
6619
- var import_utils25 = require("@tokemak/utils");
6620
8045
  var getAmountDeposited = async ({
6621
8046
  address,
6622
8047
  chainId,
@@ -6629,21 +8054,21 @@ var getAmountDeposited = async ({
6629
8054
  if (!address || !chainId || !amount || typeof slippage !== "number") {
6630
8055
  throw new Error("Invalid parameters");
6631
8056
  }
6632
- const previewDeposit = await (0, import_core15.readContract)(config, {
8057
+ const previewDeposit = await core.readContract(config, {
6633
8058
  address,
6634
- abi: import_abis14.autopoolEthAbi,
8059
+ abi: abis.autopoolEthAbi,
6635
8060
  functionName: "previewDeposit",
6636
8061
  args: [amount],
6637
8062
  chainId
6638
8063
  });
6639
8064
  if (!isSwap) {
6640
- let minAmountWithSlippage = (0, import_utils25.calculateMinAmountWithSlippage)(
8065
+ let minAmountWithSlippage = utils.calculateMinAmountWithSlippage(
6641
8066
  previewDeposit,
6642
8067
  slippage
6643
8068
  );
6644
- return (0, import_utils25.formatEtherNum)(minAmountWithSlippage);
8069
+ return utils.formatEtherNum(minAmountWithSlippage);
6645
8070
  } else {
6646
- return (0, import_utils25.formatEtherNum)(previewDeposit);
8071
+ return utils.formatEtherNum(previewDeposit);
6647
8072
  }
6648
8073
  } catch (e) {
6649
8074
  console.error(e);
@@ -6652,11 +8077,6 @@ var getAmountDeposited = async ({
6652
8077
  }
6653
8078
  };
6654
8079
 
6655
- // functions/getBridgeFee.ts
6656
- var import_core16 = require("@wagmi/core");
6657
- var import_abis15 = require("@tokemak/abis");
6658
- var import_viem14 = require("viem");
6659
-
6660
8080
  // ../../node_modules/@ethersproject/logger/lib.esm/_version.js
6661
8081
  var version = "logger/5.8.0";
6662
8082
 
@@ -6847,9 +8267,6 @@ var Logger = class {
6847
8267
  this.throwArgumentError(message, name, value);
6848
8268
  }
6849
8269
  checkNormalize(message) {
6850
- if (message == null) {
6851
- message = "platform missing String.prototype.normalize";
6852
- }
6853
8270
  if (_normalizeError) {
6854
8271
  this.throwError("platform missing String.prototype.normalize", Logger.errors.UNSUPPORTED_OPERATION, {
6855
8272
  operation: "String.prototype.normalize",
@@ -7380,7 +8797,7 @@ function throwFault(fault, operation, value) {
7380
8797
  var import_bs58 = __toESM(require_bs58(), 1);
7381
8798
 
7382
8799
  // ../../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
7383
- var isProduction = process.env.NODE_ENV === "production";
8800
+ process.env.NODE_ENV === "production";
7384
8801
 
7385
8802
  // ../../node_modules/@layerzerolabs/lz-v2-utilities/dist/index.mjs
7386
8803
  function hexZeroPadTo32(addr) {
@@ -7398,7 +8815,7 @@ var solanaAddressRegex = /^([1-9A-HJ-NP-Za-km-z]{32,44})$/;
7398
8815
  function isSolanaAddress(address) {
7399
8816
  return solanaAddressRegex.test(address);
7400
8817
  }
7401
- var MAX_UINT_128 = BigNumber.from("0xffffffffffffffffffffffffffffffff");
8818
+ BigNumber.from("0xffffffffffffffffffffffffffffffff");
7402
8819
 
7403
8820
  // functions/getBridgeFee.ts
7404
8821
  var getBridgeFee = async (wagmiConfig, {
@@ -7410,15 +8827,15 @@ var getBridgeFee = async (wagmiConfig, {
7410
8827
  from
7411
8828
  }) => {
7412
8829
  try {
7413
- const endpoint = await (0, import_core16.readContract)(wagmiConfig, {
8830
+ const endpoint = await core.readContract(wagmiConfig, {
7414
8831
  address: destAddress,
7415
- abi: import_abis15.oftAdapterAbi,
8832
+ abi: abis.oftAdapterAbi,
7416
8833
  functionName: "endpoint",
7417
8834
  chainId: destChainId
7418
8835
  });
7419
- const eid = await (0, import_core16.readContract)(wagmiConfig, {
8836
+ const eid = await core.readContract(wagmiConfig, {
7420
8837
  address: endpoint,
7421
- abi: import_abis15.layerZeroEndpointAbi,
8838
+ abi: abis.layerZeroEndpointAbi,
7422
8839
  functionName: "eid",
7423
8840
  chainId: destChainId
7424
8841
  });
@@ -7427,16 +8844,16 @@ var getBridgeFee = async (wagmiConfig, {
7427
8844
  const minAmountLD = amount / factor * factor;
7428
8845
  const sendParams = {
7429
8846
  dstEid: eid,
7430
- to: (0, import_viem14.toHex)(addressToBytes32(from)),
8847
+ to: viem.toHex(addressToBytes32(from)),
7431
8848
  amountLD: amount,
7432
8849
  minAmountLD,
7433
8850
  extraOptions: "0x",
7434
8851
  composeMsg: "0x",
7435
8852
  oftCmd: "0x"
7436
8853
  };
7437
- const feeQuote = await (0, import_core16.readContract)(wagmiConfig, {
8854
+ const feeQuote = await core.readContract(wagmiConfig, {
7438
8855
  address: sourceAddress,
7439
- abi: import_abis15.oftAdapterAbi,
8856
+ abi: abis.oftAdapterAbi,
7440
8857
  functionName: "quoteSend",
7441
8858
  args: [sendParams, false],
7442
8859
  chainId: sourceChainId
@@ -7501,42 +8918,27 @@ var waitForMessageReceived = async ({
7501
8918
  }
7502
8919
  throw new Error(`Timeout reached after 20 minutes for message: ${txHash}`);
7503
8920
  };
7504
-
7505
- // functions/getChainUserSToke.ts
7506
- var import_abis17 = require("@tokemak/abis");
7507
- var import_config13 = require("@tokemak/config");
7508
- var import_utils26 = require("@tokemak/utils");
7509
- var import_core18 = require("@wagmi/core");
7510
- var import_viem15 = require("viem");
7511
- var import_chains9 = require("viem/chains");
7512
-
7513
- // functions/getCurrentCycleId.ts
7514
- var import_abis16 = require("@tokemak/abis");
7515
- var import_core17 = require("@wagmi/core");
7516
8921
  var getCurrentCycleId = async (wagmiConfig, {
7517
8922
  stoke,
7518
8923
  chainId
7519
8924
  }) => {
7520
- return (0, import_core17.readContract)(wagmiConfig, {
8925
+ return core.readContract(wagmiConfig, {
7521
8926
  address: stoke,
7522
- abi: import_abis16.accTokeV1Abi,
8927
+ abi: abis.accTokeV1Abi,
7523
8928
  chainId,
7524
8929
  functionName: "getCurrentCycleID"
7525
8930
  });
7526
8931
  };
7527
-
7528
- // functions/getChainUserSToke.ts
7529
- var import_graph_cli12 = require("@tokemak/graph-cli");
7530
8932
  var getChainUserSToke = async (wagmiConfig, {
7531
8933
  address,
7532
8934
  tokePrice,
7533
8935
  chainId
7534
8936
  }) => {
7535
8937
  try {
7536
- const { stoke } = (0, import_config13.getCoreConfig)(chainId);
8938
+ const { stoke } = config.getCoreConfig(chainId);
7537
8939
  const cycleIndex = await getCurrentCycleId(wagmiConfig, { chainId, stoke });
7538
8940
  if (address && cycleIndex && stoke && tokePrice) {
7539
- const { GetUserSTokeBalance } = (0, import_graph_cli12.getSdkByChainId)(
8941
+ const { GetUserSTokeBalance } = graphCli.getSdkByChainId(
7540
8942
  chainId
7541
8943
  );
7542
8944
  const { accountBalanceV1S } = await GetUserSTokeBalance({
@@ -7545,13 +8947,13 @@ var getChainUserSToke = async (wagmiConfig, {
7545
8947
  const cycleStartBalance = accountBalanceV1S[0]?.cycleStartBalance || 0n;
7546
8948
  const stokeContract = {
7547
8949
  address: stoke,
7548
- abi: import_abis17.accTokeV1Abi
8950
+ abi: abis.accTokeV1Abi
7549
8951
  };
7550
8952
  const [
7551
8953
  { result: balance },
7552
8954
  { result: depositInfoResult },
7553
8955
  { result: withdrawalInfoResult }
7554
- ] = await (0, import_core18.readContracts)(wagmiConfig, {
8956
+ ] = await core.readContracts(wagmiConfig, {
7555
8957
  contracts: [
7556
8958
  {
7557
8959
  ...stokeContract,
@@ -7581,8 +8983,8 @@ var getChainUserSToke = async (wagmiConfig, {
7581
8983
  if (withdrawalAmount > 0n && cycleIndex >= withdrawalMinCycle) {
7582
8984
  balanceExcludingWithdrawal = balanceExcludingWithdrawal - withdrawalAmount;
7583
8985
  }
7584
- const withdrawalAmountUsd = (0, import_utils26.formatCurrency)(
7585
- (0, import_utils26.formatEtherNum)(withdrawalAmount) * tokePrice
8986
+ const withdrawalAmountUsd = utils.formatCurrency(
8987
+ utils.formatEtherNum(withdrawalAmount) * tokePrice
7586
8988
  );
7587
8989
  const lockDuration = Number(depositLockDuration);
7588
8990
  const lockCycle = Number(depositLockCycle);
@@ -7603,27 +9005,27 @@ var getChainUserSToke = async (wagmiConfig, {
7603
9005
  const withdrawAvailable = lockRenew - 1;
7604
9006
  const hasAddedLockedToke = depositAmount > 0n && depositAmount > rolloverDepositAmount;
7605
9007
  const addedLockedToke = depositAmount - rolloverDepositAmount;
7606
- const balanceUSD = (0, import_utils26.formatCurrency)(
7607
- Number((0, import_viem15.formatEther)(balanceExcludingWithdrawal)) * tokePrice
9008
+ const balanceUSD = utils.formatCurrency(
9009
+ Number(viem.formatEther(balanceExcludingWithdrawal)) * tokePrice
7608
9010
  );
7609
- const balanceExcludingWithdrawalUsd = (0, import_utils26.formatCurrency)(
7610
- (0, import_utils26.formatEtherNum)(balanceExcludingWithdrawal) * tokePrice
9011
+ const balanceExcludingWithdrawalUsd = utils.formatCurrency(
9012
+ utils.formatEtherNum(balanceExcludingWithdrawal) * tokePrice
7611
9013
  );
7612
9014
  const isUnlockRequestAvailable = currentCycle === withdrawAvailable;
7613
9015
  const hasRequestedUnlock = withdrawalAmount > 0n;
7614
- const unlockRequestPeriodStartUnix = (0, import_utils26.convertChainCycleToUnix)(withdrawAvailable, chainId) - Date.now() / 1e3;
7615
- const unlockRequestPeriodEndUnix = (0, import_utils26.convertChainCycleToUnix)(lockRenew, chainId) - Date.now() / 1e3;
9016
+ const unlockRequestPeriodStartUnix = utils.convertChainCycleToUnix(withdrawAvailable, chainId) - Date.now() / 1e3;
9017
+ const unlockRequestPeriodEndUnix = utils.convertChainCycleToUnix(lockRenew, chainId) - Date.now() / 1e3;
7616
9018
  const hasBalance = balance > 0n;
7617
9019
  const hasBalanceExcludingWithdrawal = balanceExcludingWithdrawal > 0n;
7618
9020
  const hasUnlockableBalance = withdrawalMinCycle <= currentCycle && withdrawalAmount > 0n;
7619
9021
  let cyclesInAMonth = 4;
7620
9022
  let lockDurationInMonths = lockDuration / cyclesInAMonth;
7621
- if (chainId === import_chains9.sepolia.id) {
9023
+ if (chainId === chains.sepolia.id) {
7622
9024
  lockDurationInMonths = lockDuration - 1;
7623
9025
  }
7624
9026
  const unlockPeriodDateRangeArray = [
7625
- new Date((0, import_utils26.convertChainCycleToUnix)(withdrawAvailable, chainId) * 1e3),
7626
- new Date((0, import_utils26.convertChainCycleToUnix)(lockRenew, chainId) * 1e3)
9027
+ new Date(utils.convertChainCycleToUnix(withdrawAvailable, chainId) * 1e3),
9028
+ new Date(utils.convertChainCycleToUnix(lockRenew, chainId) * 1e3)
7627
9029
  ];
7628
9030
  const {
7629
9031
  unlockPeriodDateRange,
@@ -7633,20 +9035,20 @@ var getChainUserSToke = async (wagmiConfig, {
7633
9035
  unlockRenewalDate
7634
9036
  } = formatDateRange(
7635
9037
  unlockPeriodDateRangeArray,
7636
- chainId === import_chains9.sepolia.id ? "time" : "date"
9038
+ chainId === chains.sepolia.id ? "time" : "date"
7637
9039
  );
7638
- const totalActiveUserCredits = (0, import_utils26.formatEtherNum)(balanceExcludingWithdrawal) * lockDurationInMonths;
7639
- const totalUserCredits = (0, import_utils26.formatEtherNum)(balance) * lockDurationInMonths;
9040
+ const totalActiveUserCredits = utils.formatEtherNum(balanceExcludingWithdrawal) * lockDurationInMonths;
9041
+ const totalUserCredits = utils.formatEtherNum(balance) * lockDurationInMonths;
7640
9042
  return {
7641
9043
  balance,
7642
9044
  balanceUSD,
7643
- balanceExcludingWithdrawal: hasBalance ? (0, import_viem15.formatEther)(balanceExcludingWithdrawal) : "0.00",
9045
+ balanceExcludingWithdrawal: hasBalance ? viem.formatEther(balanceExcludingWithdrawal) : "0.00",
7644
9046
  balanceExcludingWithdrawalUsd,
7645
9047
  hasBalanceExcludingWithdrawal,
7646
- timeLeftBeforeUnlockRequestAvailable: (0, import_utils26.convertSecondsToRemainingTime)(
9048
+ timeLeftBeforeUnlockRequestAvailable: utils.convertSecondsToRemainingTime(
7647
9049
  unlockRequestPeriodStartUnix
7648
9050
  ),
7649
- timeLeftBeforeUnlockRequestUnavailable: (0, import_utils26.convertSecondsToRemainingTime)(
9051
+ timeLeftBeforeUnlockRequestUnavailable: utils.convertSecondsToRemainingTime(
7650
9052
  unlockRequestPeriodEndUnix
7651
9053
  ),
7652
9054
  withdrawalAmount,
@@ -7663,7 +9065,7 @@ var getChainUserSToke = async (wagmiConfig, {
7663
9065
  unlockRenewalDate,
7664
9066
  lockDurationInMonths,
7665
9067
  boost: lockDuration,
7666
- points: (0, import_utils26.formatEtherNum)(balanceExcludingWithdrawal) * lockDuration,
9068
+ points: utils.formatEtherNum(balanceExcludingWithdrawal) * lockDuration,
7667
9069
  totalActiveCredits: totalActiveUserCredits,
7668
9070
  totalCredits: totalUserCredits
7669
9071
  };
@@ -7673,9 +9075,6 @@ var getChainUserSToke = async (wagmiConfig, {
7673
9075
  console.error(error);
7674
9076
  }
7675
9077
  };
7676
-
7677
- // functions/getUserSToke.ts
7678
- var import_utils28 = require("@tokemak/utils");
7679
9078
  var getUserSToke = async (wagmiConfig, {
7680
9079
  address,
7681
9080
  tokePrice,
@@ -7702,8 +9101,8 @@ var getUserSToke = async (wagmiConfig, {
7702
9101
  }
7703
9102
  return acc;
7704
9103
  }, 0n);
7705
- const totalBalance = (0, import_utils28.formatEtherNum)(totalBalanceRaw || 0n);
7706
- const totalBalanceUsd = (0, import_utils28.formatCurrency)(totalBalance * tokePrice);
9104
+ const totalBalance = utils.formatEtherNum(totalBalanceRaw || 0n);
9105
+ const totalBalanceUsd = utils.formatCurrency(totalBalance * tokePrice);
7707
9106
  const hasBalance = totalBalance > 0;
7708
9107
  return {
7709
9108
  chains: { ...userSToke },
@@ -7715,27 +9114,19 @@ var getUserSToke = async (wagmiConfig, {
7715
9114
  console.error(e);
7716
9115
  }
7717
9116
  };
7718
-
7719
- // functions/getChainSToke.ts
7720
- var import_viem16 = require("viem");
7721
- var import_core19 = require("@wagmi/core");
7722
- var import_abis18 = require("@tokemak/abis");
7723
- var import_utils30 = require("@tokemak/utils");
7724
- var import_config14 = require("@tokemak/config");
7725
- var import_utils31 = require("@tokemak/utils");
7726
9117
  var getChainSToke = async (wagmiConfig, {
7727
9118
  tokePrice,
7728
9119
  chainId
7729
9120
  }) => {
7730
9121
  try {
7731
- const { stoke } = (0, import_config14.getCoreConfig)(chainId);
9122
+ const { stoke } = config.getCoreConfig(chainId);
7732
9123
  const baseConfig = {
7733
9124
  address: stoke,
7734
- abi: import_abis18.accTokeV1Abi,
9125
+ abi: abis.accTokeV1Abi,
7735
9126
  chainId
7736
9127
  };
7737
9128
  if (stoke && tokePrice) {
7738
- const [{ result: totalSupply }, { result: currentCycle }] = await (0, import_core19.readContracts)(wagmiConfig, {
9129
+ const [{ result: totalSupply }, { result: currentCycle }] = await core.readContracts(wagmiConfig, {
7739
9130
  contracts: [
7740
9131
  {
7741
9132
  ...baseConfig,
@@ -7747,16 +9138,16 @@ var getChainSToke = async (wagmiConfig, {
7747
9138
  }
7748
9139
  ]
7749
9140
  });
7750
- const tvl = Number((0, import_viem16.formatEther)(totalSupply || 0n)) * tokePrice;
7751
- const secondsLeftBeforeNextCycle = (0, import_utils30.convertChainCycleToUnix)(Number(currentCycle) + 1, chainId) - Date.now() / 1e3;
9141
+ const tvl = Number(viem.formatEther(totalSupply || 0n)) * tokePrice;
9142
+ const secondsLeftBeforeNextCycle = utils.convertChainCycleToUnix(Number(currentCycle) + 1, chainId) - Date.now() / 1e3;
7752
9143
  return {
7753
9144
  rawTotalSupply: totalSupply,
7754
- totalSupply: (0, import_utils30.formatLargeNumber)((0, import_viem16.formatEther)(totalSupply || 0n)),
7755
- tvl: (0, import_utils30.formatTVL)(tvl),
9145
+ totalSupply: utils.formatLargeNumber(viem.formatEther(totalSupply || 0n)),
9146
+ tvl: utils.formatTVL(tvl),
7756
9147
  rawTVL: tvl,
7757
9148
  currentCycle,
7758
- chain: (0, import_utils31.getNetwork)(chainId),
7759
- timeBeforeNextCycle: (0, import_utils30.convertSecondsToRemainingTime)(
9149
+ chain: utils.getNetwork(chainId),
9150
+ timeBeforeNextCycle: utils.convertSecondsToRemainingTime(
7760
9151
  secondsLeftBeforeNextCycle
7761
9152
  )
7762
9153
  };
@@ -7765,10 +9156,6 @@ var getChainSToke = async (wagmiConfig, {
7765
9156
  console.error(error);
7766
9157
  }
7767
9158
  };
7768
-
7769
- // functions/getSToke.ts
7770
- var import_utils32 = require("@tokemak/utils");
7771
- var import_viem17 = require("viem");
7772
9159
  var getSToke = async (wagmiConfig, {
7773
9160
  tokePrice,
7774
9161
  includeTestnet = false
@@ -7787,24 +9174,20 @@ var getSToke = async (wagmiConfig, {
7787
9174
  }
7788
9175
  return acc;
7789
9176
  }, 0n);
7790
- const totalSupply = (0, import_utils32.formatLargeNumber)((0, import_viem17.formatEther)(totalSupplyBigInt || 0n));
9177
+ const totalSupply = utils.formatLargeNumber(viem.formatEther(totalSupplyBigInt || 0n));
7791
9178
  let tvlNum = Object.values(sToke).reduce((acc, item) => {
7792
9179
  if (item && item.rawTVL) {
7793
9180
  return acc + item.rawTVL;
7794
9181
  }
7795
9182
  return acc;
7796
9183
  }, 0);
7797
- const tvl = (0, import_utils32.formatTVL)(tvlNum);
9184
+ const tvl = utils.formatTVL(tvlNum);
7798
9185
  return { totalSupply, tvl, rawTVL: tvlNum, chains: { ...sToke } };
7799
9186
  } catch (e) {
7800
9187
  console.error(e);
7801
9188
  throw e;
7802
9189
  }
7803
9190
  };
7804
-
7805
- // functions/getChainCycleRolloverBlockNumber.ts
7806
- var import_abis19 = require("@tokemak/abis");
7807
- var import_core20 = require("@wagmi/core");
7808
9191
  var getChainCycleRolloverBlockNumber = async (wagmiConfig, {
7809
9192
  stoke,
7810
9193
  chainId
@@ -7812,15 +9195,15 @@ var getChainCycleRolloverBlockNumber = async (wagmiConfig, {
7812
9195
  const scanPeriodInDays = 8;
7813
9196
  const blockTime = 12;
7814
9197
  try {
7815
- const client = (0, import_core20.getPublicClient)(wagmiConfig, { chainId });
9198
+ const client = core.getPublicClient(wagmiConfig, { chainId });
7816
9199
  if (!!client) {
7817
- const blockNumber = await (0, import_core20.getBlockNumber)(wagmiConfig, {
9200
+ const blockNumber = await core.getBlockNumber(wagmiConfig, {
7818
9201
  chainId
7819
9202
  });
7820
- const manager = await (0, import_core20.readContract)(wagmiConfig, {
9203
+ const manager = await core.readContract(wagmiConfig, {
7821
9204
  functionName: "manager",
7822
9205
  address: stoke,
7823
- abi: import_abis19.accTokeV1Abi,
9206
+ abi: abis.accTokeV1Abi,
7824
9207
  chainId
7825
9208
  });
7826
9209
  if (!manager) {
@@ -7833,7 +9216,7 @@ var getChainCycleRolloverBlockNumber = async (wagmiConfig, {
7833
9216
  Number(blockNumber) - 86400 / blockTime * scanPeriodInDays
7834
9217
  )
7835
9218
  ),
7836
- abi: import_abis19.managerV1Abi,
9219
+ abi: abis.managerV1Abi,
7837
9220
  eventName: "CycleRolloverComplete"
7838
9221
  });
7839
9222
  const rolloverEvents = await client.getFilterLogs({ filter });
@@ -7844,10 +9227,6 @@ var getChainCycleRolloverBlockNumber = async (wagmiConfig, {
7844
9227
  console.error(error);
7845
9228
  }
7846
9229
  };
7847
-
7848
- // functions/getChainUserSTokeVotes.ts
7849
- var import_utils35 = require("@tokemak/utils");
7850
- var import_graph_cli13 = require("@tokemak/graph-cli");
7851
9230
  var getChainUserSTokeVotes = async ({
7852
9231
  address,
7853
9232
  chainId = 1,
@@ -7856,7 +9235,7 @@ var getChainUserSTokeVotes = async ({
7856
9235
  }) => {
7857
9236
  try {
7858
9237
  if (address && stokeVotes) {
7859
- const { GetUserSTokeVotes, GetUserSTokeBalance } = (0, import_graph_cli13.getSdkByChainId)(chainId);
9238
+ const { GetUserSTokeVotes, GetUserSTokeBalance } = graphCli.getSdkByChainId(chainId);
7860
9239
  const { userVotes } = await GetUserSTokeVotes({
7861
9240
  address: address.toLowerCase()
7862
9241
  });
@@ -7869,10 +9248,10 @@ var getChainUserSTokeVotes = async ({
7869
9248
  subgraphUserVotesData?.pools || [],
7870
9249
  subgraphUserVotesData?.weights || []
7871
9250
  );
7872
- const stakedToke = (0, import_utils35.formatEtherNum)(
9251
+ const stakedToke = utils.formatEtherNum(
7873
9252
  BigInt(subgraphAccountVotesBalance?.amount || 0n)
7874
9253
  );
7875
- const totalUserVotes = (0, import_utils35.formatEtherNum)(
9254
+ const totalUserVotes = utils.formatEtherNum(
7876
9255
  BigInt(subgraphAccountVotesBalance?.points || 0n)
7877
9256
  );
7878
9257
  const autopools = {};
@@ -7957,24 +9336,18 @@ var getUserSTokeVotes = async ({
7957
9336
  console.error(e);
7958
9337
  }
7959
9338
  };
7960
-
7961
- // functions/getChainSTokeVotes.ts
7962
- var import_config15 = require("@tokemak/config");
7963
- var import_utils38 = require("@tokemak/utils");
7964
- var import_viem18 = require("viem");
7965
- var import_graph_cli14 = require("@tokemak/graph-cli");
7966
9339
  var getChainSTokeVotes = async ({
7967
9340
  chainId,
7968
9341
  includeTestnet = false
7969
9342
  }) => {
7970
- const { GetSTokeVotes } = (0, import_graph_cli14.getSdkByChainId)(chainId);
9343
+ const { GetSTokeVotes } = graphCli.getSdkByChainId(chainId);
7971
9344
  const { accTokeVoteWeights, voteStatuses } = await GetSTokeVotes();
7972
9345
  const autopoolRawVotes = voteStatuses[0];
7973
9346
  const globalVotes = accTokeVoteWeights[0];
7974
9347
  const globalVoted = BigInt(globalVotes.voted);
7975
9348
  const globalNotVoted = BigInt(globalVotes.notVoted);
7976
9349
  const whitelistedPools = includeTestnet ? autopoolRawVotes?.pools || [] : (autopoolRawVotes?.pools || []).filter(
7977
- (pool) => import_config15.AUTOPOOLS_WHITELIST_PROD.includes((0, import_viem18.getAddress)(pool))
9350
+ (pool) => config.AUTOPOOLS_WHITELIST_PROD.includes(viem.getAddress(pool))
7978
9351
  );
7979
9352
  const poolCount = whitelistedPools.length;
7980
9353
  const perPoolNotVoted = !!poolCount ? globalNotVoted / BigInt(poolCount) : 0n;
@@ -7991,13 +9364,13 @@ var getChainSTokeVotes = async ({
7991
9364
  updatedPoints
7992
9365
  );
7993
9366
  const globalSystemVotes = globalVoted + globalNotVoted;
7994
- const totalSystemVotesNum = (0, import_utils38.formatEtherNum)(globalSystemVotes);
9367
+ const totalSystemVotesNum = utils.formatEtherNum(globalSystemVotes);
7995
9368
  const formattedAutopoolVotes = Object.fromEntries(
7996
9369
  Object.entries(autopoolVotes).filter(
7997
9370
  ([poolAddress]) => includeTestnet ? true : whitelistedPools.includes(poolAddress)
7998
9371
  ).map(([poolAddress, rawVote]) => {
7999
- const formattedVote = (0, import_utils38.formatLargeNumber)(
8000
- (0, import_utils38.formatEtherNum)(BigInt(rawVote))
9372
+ const formattedVote = utils.formatLargeNumber(
9373
+ utils.formatEtherNum(BigInt(rawVote))
8001
9374
  );
8002
9375
  return [
8003
9376
  poolAddress,
@@ -8012,7 +9385,7 @@ var getChainSTokeVotes = async ({
8012
9385
  globalSystemVotes
8013
9386
  },
8014
9387
  totalSystemVotesNum,
8015
- totalSystemVotes: (0, import_utils38.formatLargeNumber)(totalSystemVotesNum),
9388
+ totalSystemVotes: utils.formatLargeNumber(totalSystemVotesNum),
8016
9389
  autopoolVotes: formattedAutopoolVotes
8017
9390
  };
8018
9391
  };
@@ -8034,17 +9407,11 @@ var getSTokeVotes = async ({
8034
9407
  console.error(e);
8035
9408
  }
8036
9409
  };
8037
-
8038
- // functions/getChainSTokeRewards.ts
8039
- var import_config16 = require("@tokemak/config");
8040
- var import_viem19 = require("viem");
8041
- var import_utils40 = require("@tokemak/utils");
8042
- var import_graph_cli15 = require("@tokemak/graph-cli");
8043
9410
  var getChainSTokeRewards = async ({
8044
9411
  chainId
8045
9412
  }) => {
8046
9413
  try {
8047
- const { GetSTokeRewards } = (0, import_graph_cli15.getSdkByChainId)(chainId);
9414
+ const { GetSTokeRewards } = graphCli.getSdkByChainId(chainId);
8048
9415
  const { poolRewardsBalances } = await GetSTokeRewards();
8049
9416
  const allPoolRewardsBalanceDayDatas = await paginateQuery(
8050
9417
  GetSTokeRewards,
@@ -8056,15 +9423,15 @@ var getChainSTokeRewards = async ({
8056
9423
  let minApr = null;
8057
9424
  let maxApr = null;
8058
9425
  for (const pool of poolRewardsBalances) {
8059
- const whitelistedPools = import_config16.AUTOPOOLS_WHITELIST_PROD.map(
9426
+ const whitelistedPools = config.AUTOPOOLS_WHITELIST_PROD.map(
8060
9427
  (address) => address.toLowerCase()
8061
9428
  );
8062
9429
  if (!whitelistedPools.includes(pool.id.toLowerCase())) {
8063
9430
  continue;
8064
9431
  }
8065
- const convertedBalance = (0, import_utils40.formatEtherNum)(pool.balance);
8066
- const convertedBalanceUSD = Number((0, import_viem19.formatUnits)(pool.balanceUSD, 8));
8067
- const convertedApr = (0, import_utils40.formatEtherNum)(pool.currentAprPerCredit);
9432
+ const convertedBalance = utils.formatEtherNum(pool.balance);
9433
+ const convertedBalanceUSD = Number(viem.formatUnits(pool.balanceUSD, 8));
9434
+ const convertedApr = utils.formatEtherNum(pool.currentAprPerCredit);
8068
9435
  if (minApr === null || convertedApr < minApr) {
8069
9436
  minApr = convertedApr;
8070
9437
  }
@@ -8134,17 +9501,13 @@ var getSTokeRewards = async ({
8134
9501
  throw e;
8135
9502
  }
8136
9503
  };
8137
-
8138
- // functions/getChainUserSTokeRewards.ts
8139
- var import_config17 = require("@tokemak/config");
8140
- var import_utils43 = require("@tokemak/utils");
8141
9504
  var getChainUserSTokeRewards = async (wagmiConfig, {
8142
9505
  address,
8143
9506
  chainId,
8144
9507
  tokePrice
8145
9508
  }) => {
8146
- const { rewardsV1Url, stokeRewardsHash, stokeRewards } = (0, import_config17.getMainnetConfig)(1);
8147
- const { stoke } = (0, import_config17.getCoreConfig)(chainId);
9509
+ const { rewardsV1Url, stokeRewardsHash, stokeRewards } = config.getMainnetConfig(1);
9510
+ const { stoke } = config.getCoreConfig(chainId);
8148
9511
  const currentCycle = await getCurrentCycleId(wagmiConfig, {
8149
9512
  stoke,
8150
9513
  chainId
@@ -8188,14 +9551,14 @@ var getChainUserSTokeRewards = async (wagmiConfig, {
8188
9551
  throw fallbackError;
8189
9552
  }
8190
9553
  }
8191
- const claimableNum = (0, import_utils43.formatEtherNum)(tokeRewards?.claimable || 0n);
9554
+ const claimableNum = utils.formatEtherNum(tokeRewards?.claimable || 0n);
8192
9555
  const claimableUsd = tokePrice * claimableNum;
8193
9556
  const hasClaimable = claimableNum > 0n;
8194
- const pendingRewards = (0, import_utils43.formatEtherNum)(
9557
+ const pendingRewards = utils.formatEtherNum(
8195
9558
  tokeRewards?.rewardsPayload.breakdown?.totalRewardAmount || 0n
8196
9559
  );
8197
9560
  const pendingRewardsUsd = tokePrice * pendingRewards;
8198
- const totalRewardsReceived = (0, import_utils43.formatEtherNum)(
9561
+ const totalRewardsReceived = utils.formatEtherNum(
8199
9562
  tokeRewards.rewardsPayload.payload.amount || 0n
8200
9563
  );
8201
9564
  const totalRewardsReceivedUsd = tokePrice * totalRewardsReceived;
@@ -8210,13 +9573,10 @@ var getChainUserSTokeRewards = async (wagmiConfig, {
8210
9573
  ...tokeRewards
8211
9574
  };
8212
9575
  };
8213
-
8214
- // functions/getChainSubgraphStatus.ts
8215
- var import_graph_cli16 = require("@tokemak/graph-cli");
8216
9576
  var getChainSubgraphStatus = async (chain) => {
8217
9577
  const currentTimestamp = Math.floor(Date.now() / 1e3);
8218
9578
  try {
8219
- const { GetLatestSubgraphTimestamp } = (0, import_graph_cli16.getSdkByChainId)(
9579
+ const { GetLatestSubgraphTimestamp } = graphCli.getSdkByChainId(
8220
9580
  chain.chainId
8221
9581
  );
8222
9582
  const { _meta } = await GetLatestSubgraphTimestamp();
@@ -8266,17 +9626,9 @@ var getSubgraphStatus = async (includeTestnet = false) => {
8266
9626
  }
8267
9627
  return { isOutOfSync, errorMessage };
8268
9628
  };
8269
-
8270
- // functions/getCycleV1.ts
8271
- var import_core21 = require("@wagmi/core");
8272
- var import_abis20 = require("@tokemak/abis");
8273
- var import_viem20 = require("viem");
8274
- var import_utils45 = require("@tokemak/utils");
8275
- var import_config18 = require("@tokemak/config");
8276
- var import_chains10 = require("viem/chains");
8277
- var publicClient = (0, import_viem20.createPublicClient)({
8278
- chain: import_chains10.mainnet,
8279
- transport: (0, import_viem20.http)("https://mainnet.infura.io/v3/2BtQ5D1QEPHvwgZwKwnZC7WQVhr")
9629
+ var publicClient = viem.createPublicClient({
9630
+ chain: chains.mainnet,
9631
+ transport: viem.http("https://mainnet.infura.io/v3/2BtQ5D1QEPHvwgZwKwnZC7WQVhr")
8280
9632
  });
8281
9633
  var getCycleV1 = async (wagmiConfig, {
8282
9634
  currentBlockNumber,
@@ -8284,12 +9636,12 @@ var getCycleV1 = async (wagmiConfig, {
8284
9636
  }) => {
8285
9637
  const scanPeriodInDays = 8;
8286
9638
  const blockTime = 12;
8287
- const { managerV1 } = (0, import_config18.getMainnetConfig)();
9639
+ const { managerV1 } = config.getMainnetConfig();
8288
9640
  try {
8289
9641
  if (currentBlockNumber && managerV1) {
8290
- const currentCycleIndex = await (0, import_core21.readContract)(wagmiConfig, {
9642
+ const currentCycleIndex = await core.readContract(wagmiConfig, {
8291
9643
  address: managerV1,
8292
- abi: import_abis20.managerV1Abi,
9644
+ abi: abis.managerV1Abi,
8293
9645
  functionName: "getCurrentCycleIndex",
8294
9646
  chainId
8295
9647
  });
@@ -8300,16 +9652,16 @@ var getCycleV1 = async (wagmiConfig, {
8300
9652
  Number(currentBlockNumber) - 86400 / blockTime * scanPeriodInDays
8301
9653
  )
8302
9654
  ),
8303
- abi: import_abis20.managerV1Abi,
9655
+ abi: abis.managerV1Abi,
8304
9656
  eventName: "CycleRolloverComplete"
8305
9657
  });
8306
9658
  const rolloverEvents = await publicClient.getFilterLogs({ filter });
8307
9659
  const cycleRolloverBlockNumber = chainId === 1 ? rolloverEvents[rolloverEvents.length - 1]?.blockNumber : rolloverEvents[rolloverEvents.length - 1]?.blockNumber || currentBlockNumber;
8308
- const secondsLeftBeforeNextCycle = (0, import_utils45.convertChainCycleToUnix)(Number(currentCycleIndex) + 1) - Date.now() / 1e3;
9660
+ const secondsLeftBeforeNextCycle = utils.convertChainCycleToUnix(Number(currentCycleIndex) + 1) - Date.now() / 1e3;
8309
9661
  return {
8310
9662
  currentCycleIndex,
8311
9663
  cycleRolloverBlockNumber,
8312
- timeBeforeNextCycle: (0, import_utils45.convertSecondsToRemainingTime)(
9664
+ timeBeforeNextCycle: utils.convertSecondsToRemainingTime(
8313
9665
  secondsLeftBeforeNextCycle
8314
9666
  )
8315
9667
  };
@@ -8318,9 +9670,6 @@ var getCycleV1 = async (wagmiConfig, {
8318
9670
  console.error(error);
8319
9671
  }
8320
9672
  };
8321
-
8322
- // functions/getProtocolStats.ts
8323
- var import_utils46 = require("@tokemak/utils");
8324
9673
  var getProtocolStats = async (autopools, stoke, sushiLP) => {
8325
9674
  try {
8326
9675
  if (!autopools || !stoke || !sushiLP) {
@@ -8350,12 +9699,12 @@ var getProtocolStats = async (autopools, stoke, sushiLP) => {
8350
9699
  Object.entries(categories).map(([key, value]) => [
8351
9700
  key,
8352
9701
  {
8353
- tvl: (0, import_utils46.formatTVL)(value.tvl),
8354
- supply: (0, import_utils46.formatLargeNumber)(value.supply || 0)
9702
+ tvl: utils.formatTVL(value.tvl),
9703
+ supply: utils.formatLargeNumber(value.supply || 0)
8355
9704
  }
8356
9705
  ])
8357
9706
  );
8358
- const tvl = (0, import_utils46.formatTVL)(autopoolTVL + stoke.rawTVL + (sushiLP?.tvl || 0));
9707
+ const tvl = utils.formatTVL(autopoolTVL + stoke.rawTVL + (sushiLP?.tvl || 0));
8359
9708
  const vaultAddresses = autopools?.flatMap(
8360
9709
  (pool) => pool.destinations.map((destination) => destination.vaultAddress)
8361
9710
  );
@@ -8363,16 +9712,16 @@ var getProtocolStats = async (autopools, stoke, sushiLP) => {
8363
9712
  const totalDestinations = uniqueVaultAddresses.length;
8364
9713
  return {
8365
9714
  autopools: {
8366
- tvl: (0, import_utils46.formatTVL)(autopoolTVL),
9715
+ tvl: utils.formatTVL(autopoolTVL),
8367
9716
  tvlNum: autopoolTVL,
8368
9717
  categories: formattedCategories
8369
9718
  },
8370
9719
  stoke: {
8371
- tvl: (0, import_utils46.formatTVL)(stoke.rawTVL),
9720
+ tvl: utils.formatTVL(stoke.rawTVL),
8372
9721
  totalSupply: `${stoke.totalSupply} TOKE`
8373
9722
  },
8374
9723
  sushiLP: {
8375
- tvl: (0, import_utils46.formatTVL)(sushiLP?.tvl || 0),
9724
+ tvl: utils.formatTVL(sushiLP?.tvl || 0),
8376
9725
  totalSupply: sushiLP?.totalSupply || 0
8377
9726
  },
8378
9727
  tvl,
@@ -8383,23 +9732,14 @@ var getProtocolStats = async (autopools, stoke, sushiLP) => {
8383
9732
  return null;
8384
9733
  }
8385
9734
  };
8386
-
8387
- // functions/getRebalanceStats.ts
8388
- var import_graph_cli17 = require("@tokemak/graph-cli");
8389
-
8390
- // functions/getEthPriceAtBlock.ts
8391
- var import_config19 = require("@tokemak/config");
8392
- var import_core22 = require("@wagmi/core");
8393
- var import_abis21 = require("@tokemak/abis");
8394
- var import_tokenlist11 = require("@tokemak/tokenlist");
8395
9735
  var getEthPriceAtBlock = async (wagmiConfig, blockNumber, chainId) => {
8396
- const config = (0, import_config19.getCoreConfig)(chainId);
8397
- const rootPriceOracle = config.rootPriceOracle;
8398
- const weth = config.weth;
8399
- const usdc = import_tokenlist11.USDC_TOKEN.extensions?.bridgeInfo?.[chainId]?.tokenAddress || import_tokenlist11.USDC_TOKEN.address;
8400
- const priceAtBlock = await (0, import_core22.readContract)(wagmiConfig, {
9736
+ const config$1 = config.getCoreConfig(chainId);
9737
+ const rootPriceOracle = config$1.rootPriceOracle;
9738
+ const weth = config$1.weth;
9739
+ const usdc = tokenlist.USDC_TOKEN.extensions?.bridgeInfo?.[chainId]?.tokenAddress || tokenlist.USDC_TOKEN.address;
9740
+ const priceAtBlock = await core.readContract(wagmiConfig, {
8401
9741
  address: rootPriceOracle,
8402
- abi: import_abis21.rootPriceOracleAbi,
9742
+ abi: abis.rootPriceOracleAbi,
8403
9743
  functionName: "getPriceInQuote",
8404
9744
  args: [weth, usdc],
8405
9745
  blockNumber,
@@ -8407,14 +9747,9 @@ var getEthPriceAtBlock = async (wagmiConfig, blockNumber, chainId) => {
8407
9747
  });
8408
9748
  return priceAtBlock;
8409
9749
  };
8410
-
8411
- // functions/getRebalanceStats.ts
8412
- var import_utils48 = require("@tokemak/utils");
8413
- var import_tokenlist12 = require("@tokemak/tokenlist");
8414
- var import_chains11 = require("viem/chains");
8415
9750
  var BATCH_SIZE = 500;
8416
9751
  var fetchChainRebalances = async (chainId) => {
8417
- const { GetAllAutopoolRebalances } = (0, import_graph_cli17.getSdkByChainId)(chainId);
9752
+ const { GetAllAutopoolRebalances } = graphCli.getSdkByChainId(chainId);
8418
9753
  const allRebalances = await paginateQuery(
8419
9754
  GetAllAutopoolRebalances,
8420
9755
  "autopoolRebalances"
@@ -8428,10 +9763,10 @@ function inferBaseAssetDecimals(rebalance, chainId) {
8428
9763
  if (BigInt(rebalance.tokenOutValueBaseAsset) === BigInt(rebalance.tokenOutValueInEth)) {
8429
9764
  return 18;
8430
9765
  }
8431
- if (chainId === import_chains11.sonic.id) {
9766
+ if (chainId === chains.sonic.id) {
8432
9767
  return rebalance.tokenOut.decimals;
8433
9768
  }
8434
- return import_tokenlist12.USDC_TOKEN.decimals;
9769
+ return tokenlist.USDC_TOKEN.decimals;
8435
9770
  }
8436
9771
  var getRebalanceValueUsd = async (rebalance, chainId, wagmiConfig) => {
8437
9772
  const ethWei = BigInt(rebalance.tokenOutValueInEth || "0");
@@ -8443,8 +9778,8 @@ var getRebalanceValueUsd = async (rebalance, chainId, wagmiConfig) => {
8443
9778
  BigInt(rebalance.blockNumber),
8444
9779
  chainId
8445
9780
  );
8446
- const ethUsd = Number((0, import_utils48.formatUnitsNum)(price, import_tokenlist12.USDC_TOKEN.decimals));
8447
- const ethAmt = Number((0, import_utils48.formatEtherNum)(ethWei));
9781
+ const ethUsd = Number(utils.formatUnitsNum(price, tokenlist.USDC_TOKEN.decimals));
9782
+ const ethAmt = Number(utils.formatEtherNum(ethWei));
8448
9783
  const usd = ethAmt * ethUsd;
8449
9784
  return usd;
8450
9785
  } catch (e) {
@@ -8468,7 +9803,7 @@ var processRebalance = async (rebalance, chainId, wagmiConfig) => {
8468
9803
  }
8469
9804
  const baseDecimals = inferBaseAssetDecimals(rebalance, chainId);
8470
9805
  const baseUsd = Number(
8471
- (0, import_utils48.formatUnitsNum)(
9806
+ utils.formatUnitsNum(
8472
9807
  BigInt(rebalance.tokenOutValueBaseAsset || "0"),
8473
9808
  baseDecimals
8474
9809
  )
@@ -8556,105 +9891,116 @@ var updateRebalanceStats = async (wagmiConfig, {
8556
9891
  const allRebalances = [...currentRebalances, ...allNewRebalances];
8557
9892
  return calculateRebalanceStats(allRebalances);
8558
9893
  };
8559
- // Annotate the CommonJS export names for ESM import in node:
8560
- 0 && (module.exports = {
8561
- AutopoolCategory,
8562
- BASE_ASSETS,
8563
- BATCH_SIZE,
8564
- ETH_BASE_ASSETS,
8565
- EUR_BASE_ASSETS,
8566
- MessageStatus,
8567
- PRICED_TOKENS,
8568
- USD_BASE_ASSETS,
8569
- aggregateSTokeRewardsDayData,
8570
- arraysToObject,
8571
- calculateRebalanceStats,
8572
- convertBaseAssetToTokenPrices,
8573
- convertBaseAssetToTokenPricesAndDenom,
8574
- fetchChainDataMap,
8575
- fetchChainRebalances,
8576
- fillMissingDates,
8577
- findClosestDateEntry,
8578
- findClosestEntry,
8579
- findClosestTimestampEntry,
8580
- formatDateRange,
8581
- getAddressFromSystemRegistry,
8582
- getAllowance,
8583
- getAmountDeposited,
8584
- getAmountWithdrawn,
8585
- getAutopilotRouter,
8586
- getAutopoolCategory,
8587
- getAutopoolDayData,
8588
- getAutopoolInfo,
8589
- getAutopoolRebalances,
8590
- getAutopools,
8591
- getAutopoolsHistory,
8592
- getAutopoolsRebalances,
8593
- getBridgeFee,
8594
- getChainAutopools,
8595
- getChainCycleRolloverBlockNumber,
8596
- getChainSToke,
8597
- getChainSTokeRewards,
8598
- getChainSubgraphStatus,
8599
- getChainUserActivity,
8600
- getChainUserAutopools,
8601
- getChainUserSToke,
8602
- getChainUserSTokeRewards,
8603
- getChainUserSTokeVotes,
8604
- getChainsForEnv,
8605
- getCurrentCycleId,
8606
- getCurveLP,
8607
- getCycleV1,
8608
- getDefillamaPrice,
8609
- getDynamicSwap,
8610
- getEthPrice,
8611
- getEthPriceAtBlock,
8612
- getExchangeNames,
8613
- getGenStratAprs,
8614
- getLayerzeroStatus,
8615
- getMutlipleAutopoolRebalances,
8616
- getPoolStats,
8617
- getPoolsAndDestinations,
8618
- getProtocolStats,
8619
- getRebalanceStats,
8620
- getRebalanceValueUsd,
8621
- getRewardsPayloadV1,
8622
- getSToke,
8623
- getSTokeChainsForEnv,
8624
- getSTokeRewards,
8625
- getSTokeVotes,
8626
- getSubgraphStatus,
8627
- getSushiLP,
8628
- getSwapQuote,
8629
- getSystemConfig,
8630
- getTimestampDaysFromStart,
8631
- getTokePrice,
8632
- getTokenList,
8633
- getTokenPrice,
8634
- getTokenPrices,
8635
- getTopAutopoolHolders,
8636
- getUserActivity,
8637
- getUserAutoEthRewards,
8638
- getUserAutopool,
8639
- getUserAutopools,
8640
- getUserAutopoolsHistory,
8641
- getUserAutopoolsRewards,
8642
- getUserCurveLP,
8643
- getUserRewardsV1,
8644
- getUserSToke,
8645
- getUserSTokeVotes,
8646
- getUserSushiLP,
8647
- getUserTokenBalances,
8648
- getUserV1,
8649
- mergeArrays,
8650
- mergeArraysWithKey,
8651
- mergeStringArrays,
8652
- modifyAutopoolName,
8653
- nestedArrayToObject,
8654
- paginateQuery,
8655
- processRebalance,
8656
- processRebalancesInBatches,
8657
- systemRegistryFunctionNames,
8658
- updateRebalanceStats,
8659
- waitForMessageReceived
8660
- });
9894
+ /*! Bundled license information:
9895
+
9896
+ ieee754/index.js:
9897
+ (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
9898
+
9899
+ buffer/index.js:
9900
+ (*!
9901
+ * The buffer module from node.js, for the browser.
9902
+ *
9903
+ * @author Feross Aboukhadijeh <https://feross.org>
9904
+ * @license MIT
9905
+ *)
9906
+ */
9907
+
9908
+ exports.AutopoolCategory = AutopoolCategory;
9909
+ exports.BASE_ASSETS = BASE_ASSETS;
9910
+ exports.BATCH_SIZE = BATCH_SIZE;
9911
+ exports.ETH_BASE_ASSETS = ETH_BASE_ASSETS;
9912
+ exports.EUR_BASE_ASSETS = EUR_BASE_ASSETS;
9913
+ exports.MessageStatus = MessageStatus;
9914
+ exports.PRICED_TOKENS = PRICED_TOKENS;
9915
+ exports.USD_BASE_ASSETS = USD_BASE_ASSETS;
9916
+ exports.aggregateSTokeRewardsDayData = aggregateSTokeRewardsDayData;
9917
+ exports.arraysToObject = arraysToObject;
9918
+ exports.calculateRebalanceStats = calculateRebalanceStats;
9919
+ exports.convertBaseAssetToTokenPrices = convertBaseAssetToTokenPrices;
9920
+ exports.convertBaseAssetToTokenPricesAndDenom = convertBaseAssetToTokenPricesAndDenom;
9921
+ exports.fetchChainDataMap = fetchChainDataMap;
9922
+ exports.fetchChainRebalances = fetchChainRebalances;
9923
+ exports.fillMissingDates = fillMissingDates;
9924
+ exports.findClosestDateEntry = findClosestDateEntry;
9925
+ exports.findClosestEntry = findClosestEntry;
9926
+ exports.findClosestTimestampEntry = findClosestTimestampEntry;
9927
+ exports.formatDateRange = formatDateRange;
9928
+ exports.getAddressFromSystemRegistry = getAddressFromSystemRegistry;
9929
+ exports.getAllowance = getAllowance;
9930
+ exports.getAmountDeposited = getAmountDeposited;
9931
+ exports.getAmountWithdrawn = getAmountWithdrawn;
9932
+ exports.getAutopilotRouter = getAutopilotRouter;
9933
+ exports.getAutopoolCategory = getAutopoolCategory;
9934
+ exports.getAutopoolDayData = getAutopoolDayData;
9935
+ exports.getAutopoolInfo = getAutopoolInfo;
9936
+ exports.getAutopoolRebalances = getAutopoolRebalances;
9937
+ exports.getAutopools = getAutopools;
9938
+ exports.getAutopoolsHistory = getAutopoolsHistory;
9939
+ exports.getAutopoolsRebalances = getAutopoolsRebalances;
9940
+ exports.getBridgeFee = getBridgeFee;
9941
+ exports.getChainAutopools = getChainAutopools;
9942
+ exports.getChainCycleRolloverBlockNumber = getChainCycleRolloverBlockNumber;
9943
+ exports.getChainSToke = getChainSToke;
9944
+ exports.getChainSTokeRewards = getChainSTokeRewards;
9945
+ exports.getChainSubgraphStatus = getChainSubgraphStatus;
9946
+ exports.getChainUserActivity = getChainUserActivity;
9947
+ exports.getChainUserAutopools = getChainUserAutopools;
9948
+ exports.getChainUserSToke = getChainUserSToke;
9949
+ exports.getChainUserSTokeRewards = getChainUserSTokeRewards;
9950
+ exports.getChainUserSTokeVotes = getChainUserSTokeVotes;
9951
+ exports.getChainsForEnv = getChainsForEnv;
9952
+ exports.getCurrentCycleId = getCurrentCycleId;
9953
+ exports.getCurveLP = getCurveLP;
9954
+ exports.getCycleV1 = getCycleV1;
9955
+ exports.getDefillamaPrice = getDefillamaPrice;
9956
+ exports.getDynamicSwap = getDynamicSwap;
9957
+ exports.getEthPrice = getEthPrice;
9958
+ exports.getEthPriceAtBlock = getEthPriceAtBlock;
9959
+ exports.getExchangeNames = getExchangeNames;
9960
+ exports.getGenStratAprs = getGenStratAprs;
9961
+ exports.getLayerzeroStatus = getLayerzeroStatus;
9962
+ exports.getMutlipleAutopoolRebalances = getMutlipleAutopoolRebalances;
9963
+ exports.getPoolStats = getPoolStats;
9964
+ exports.getPoolsAndDestinations = getPoolsAndDestinations;
9965
+ exports.getProtocolStats = getProtocolStats;
9966
+ exports.getRebalanceStats = getRebalanceStats;
9967
+ exports.getRebalanceValueUsd = getRebalanceValueUsd;
9968
+ exports.getRewardsPayloadV1 = getRewardsPayloadV1;
9969
+ exports.getSToke = getSToke;
9970
+ exports.getSTokeChainsForEnv = getSTokeChainsForEnv;
9971
+ exports.getSTokeRewards = getSTokeRewards;
9972
+ exports.getSTokeVotes = getSTokeVotes;
9973
+ exports.getSubgraphStatus = getSubgraphStatus;
9974
+ exports.getSushiLP = getSushiLP;
9975
+ exports.getSwapQuote = getSwapQuote;
9976
+ exports.getSystemConfig = getSystemConfig;
9977
+ exports.getTimestampDaysFromStart = getTimestampDaysFromStart;
9978
+ exports.getTokePrice = getTokePrice;
9979
+ exports.getTokenList = getTokenList;
9980
+ exports.getTokenPrice = getTokenPrice;
9981
+ exports.getTokenPrices = getTokenPrices;
9982
+ exports.getTopAutopoolHolders = getTopAutopoolHolders;
9983
+ exports.getUserActivity = getUserActivity;
9984
+ exports.getUserAutoEthRewards = getUserAutoEthRewards;
9985
+ exports.getUserAutopool = getUserAutopool;
9986
+ exports.getUserAutopools = getUserAutopools;
9987
+ exports.getUserAutopoolsHistory = getUserAutopoolsHistory;
9988
+ exports.getUserAutopoolsRewards = getUserAutopoolsRewards;
9989
+ exports.getUserCurveLP = getUserCurveLP;
9990
+ exports.getUserRewardsV1 = getUserRewardsV1;
9991
+ exports.getUserSToke = getUserSToke;
9992
+ exports.getUserSTokeVotes = getUserSTokeVotes;
9993
+ exports.getUserSushiLP = getUserSushiLP;
9994
+ exports.getUserTokenBalances = getUserTokenBalances;
9995
+ exports.getUserV1 = getUserV1;
9996
+ exports.mergeArrays = mergeArrays;
9997
+ exports.mergeArraysWithKey = mergeArraysWithKey;
9998
+ exports.mergeStringArrays = mergeStringArrays;
9999
+ exports.modifyAutopoolName = modifyAutopoolName;
10000
+ exports.nestedArrayToObject = nestedArrayToObject;
10001
+ exports.paginateQuery = paginateQuery;
10002
+ exports.processRebalance = processRebalance;
10003
+ exports.processRebalancesInBatches = processRebalancesInBatches;
10004
+ exports.systemRegistryFunctionNames = systemRegistryFunctionNames;
10005
+ exports.updateRebalanceStats = updateRebalanceStats;
10006
+ exports.waitForMessageReceived = waitForMessageReceived;