@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.js CHANGED
@@ -1,17 +1,21 @@
1
+ import { mainnet, sepolia, sonic, plasma, base } from 'viem/chains';
2
+ import { TOKEMAK_SWAP_PRICING_URL, SUPPORTED_DEV_CHAINS, SUPPORTED_PROD_CHAINS, SUPPORTED_STOKE_DEV_CHAINS, SUPPORTED_STOKE_PROD_CHAINS, TOKEMAK_GENSTRAT_APRS_API_URL, CURVE_API_URL, TOKE_CURVE_POOL_ID, TOKEMAK_PRICES_STAGING_URL, TOKEMAK_LAUNCH_TIMESTAMP, TOKEMAK_SWAP_QUOTE_URL, TOKEMAK_DYNAMIC_SWAP_ROUTES_URL } from '@tokemak/constants';
3
+ import { ETH_TOKEN, PXETH_TOKEN, USDC_TOKEN, DOLA_TOKEN, S_TOKEN, EURC_TOKEN, USDT_TOKEN, USDT0_TOKEN, TOKE_TOKEN, SILO_TOKEN, XPL_TOKEN, WXPL_TOKEN, WETH_TOKEN, WS_TOKEN, ALL_AUTOPOOLS, BEETS_PROTOCOL, ALL_TOKENS, TOKEMAK_LISTS_URL } from '@tokemak/tokenlist';
4
+ import { createPublicClient, http, formatUnits, getAddress, formatEther, erc20Abi, hexToBigInt, ContractFunctionExecutionError, ContractFunctionRevertedError, toHex as toHex$1 } from 'viem';
5
+ import { convertTimestampToDate, formatDateToReadable, formatEtherNum, getToken, formatUnitsNum, formatPoolName, getProtocol, getNetwork, formatCurrency, calculateMinAmountWithSlippage, convertNumToBps, convertChainCycleToUnix, convertSecondsToRemainingTime, formatLargeNumber, formatTVL } from '@tokemak/utils';
6
+ import { getSdkByChainId } from '@tokemak/graph-cli';
7
+ import { getCoreConfig, AUTOPOOLS_WHITELIST_PROD, getMainnetConfig } from '@tokemak/config';
8
+ import { readContract, readContracts, getPublicClient, getBlockNumber } from '@wagmi/core';
9
+ import { lensAbi, rewardsV1HashAbi, rewardsV1Abi, stakingV1Abi, sushiPoolAbi, poolV1Abi, autopoolEthAbi, systemRegistryAbi, autopilotRouterAbi, oftAdapterAbi, layerZeroEndpointAbi, accTokeV1Abi, managerV1Abi, rootPriceOracleAbi, autoEthRewardsHashAbi } from '@tokemak/abis';
10
+ import { getLiquidations } from '@tokemak/autopilot-swap-route-calc';
11
+
1
12
  var __create = Object.create;
2
13
  var __defProp = Object.defineProperty;
3
14
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
15
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
16
  var __getProtoOf = Object.getPrototypeOf;
6
17
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
- }) : x)(function(x) {
10
- if (typeof require !== "undefined")
11
- return require.apply(this, arguments);
12
- throw new Error('Dynamic require of "' + x + '" is not supported');
13
- });
14
- var __commonJS = (cb, mod) => function __require2() {
18
+ var __commonJS = (cb, mod) => function __require() {
15
19
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
16
20
  };
17
21
  var __copyProps = (to, from, except, desc) => {
@@ -20,22 +24,1899 @@ var __copyProps = (to, from, except, desc) => {
20
24
  if (!__hasOwnProp.call(to, key) && key !== except)
21
25
  __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22
26
  }
23
- return to;
24
- };
25
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26
- // If the importer is in node compatibility mode or this is not an ESM
27
- // file that has been converted to a CommonJS file using a Babel-
28
- // compatible transform (i.e. "__esModule" has not been set), then set
29
- // "default" to the CommonJS "module.exports" for node compatibility.
30
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
31
- mod
32
- ));
27
+ return to;
28
+ };
29
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
30
+ // If the importer is in node compatibility mode or this is not an ESM
31
+ // file that has been converted to a CommonJS file using a Babel-
32
+ // compatible transform (i.e. "__esModule" has not been set), then set
33
+ // "default" to the CommonJS "module.exports" for node compatibility.
34
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
+ mod
36
+ ));
37
+
38
+ // ../../node_modules/base64-js/index.js
39
+ var require_base64_js = __commonJS({
40
+ "../../node_modules/base64-js/index.js"(exports) {
41
+ exports.byteLength = byteLength;
42
+ exports.toByteArray = toByteArray;
43
+ exports.fromByteArray = fromByteArray;
44
+ var lookup = [];
45
+ var revLookup = [];
46
+ var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
47
+ var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
48
+ for (i = 0, len = code.length; i < len; ++i) {
49
+ lookup[i] = code[i];
50
+ revLookup[code.charCodeAt(i)] = i;
51
+ }
52
+ var i;
53
+ var len;
54
+ revLookup["-".charCodeAt(0)] = 62;
55
+ revLookup["_".charCodeAt(0)] = 63;
56
+ function getLens(b64) {
57
+ var len2 = b64.length;
58
+ if (len2 % 4 > 0) {
59
+ throw new Error("Invalid string. Length must be a multiple of 4");
60
+ }
61
+ var validLen = b64.indexOf("=");
62
+ if (validLen === -1)
63
+ validLen = len2;
64
+ var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4;
65
+ return [validLen, placeHoldersLen];
66
+ }
67
+ function byteLength(b64) {
68
+ var lens = getLens(b64);
69
+ var validLen = lens[0];
70
+ var placeHoldersLen = lens[1];
71
+ return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
72
+ }
73
+ function _byteLength(b64, validLen, placeHoldersLen) {
74
+ return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
75
+ }
76
+ function toByteArray(b64) {
77
+ var tmp;
78
+ var lens = getLens(b64);
79
+ var validLen = lens[0];
80
+ var placeHoldersLen = lens[1];
81
+ var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
82
+ var curByte = 0;
83
+ var len2 = placeHoldersLen > 0 ? validLen - 4 : validLen;
84
+ var i2;
85
+ for (i2 = 0; i2 < len2; i2 += 4) {
86
+ tmp = revLookup[b64.charCodeAt(i2)] << 18 | revLookup[b64.charCodeAt(i2 + 1)] << 12 | revLookup[b64.charCodeAt(i2 + 2)] << 6 | revLookup[b64.charCodeAt(i2 + 3)];
87
+ arr[curByte++] = tmp >> 16 & 255;
88
+ arr[curByte++] = tmp >> 8 & 255;
89
+ arr[curByte++] = tmp & 255;
90
+ }
91
+ if (placeHoldersLen === 2) {
92
+ tmp = revLookup[b64.charCodeAt(i2)] << 2 | revLookup[b64.charCodeAt(i2 + 1)] >> 4;
93
+ arr[curByte++] = tmp & 255;
94
+ }
95
+ if (placeHoldersLen === 1) {
96
+ tmp = revLookup[b64.charCodeAt(i2)] << 10 | revLookup[b64.charCodeAt(i2 + 1)] << 4 | revLookup[b64.charCodeAt(i2 + 2)] >> 2;
97
+ arr[curByte++] = tmp >> 8 & 255;
98
+ arr[curByte++] = tmp & 255;
99
+ }
100
+ return arr;
101
+ }
102
+ function tripletToBase64(num) {
103
+ return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
104
+ }
105
+ function encodeChunk(uint8, start, end) {
106
+ var tmp;
107
+ var output = [];
108
+ for (var i2 = start; i2 < end; i2 += 3) {
109
+ tmp = (uint8[i2] << 16 & 16711680) + (uint8[i2 + 1] << 8 & 65280) + (uint8[i2 + 2] & 255);
110
+ output.push(tripletToBase64(tmp));
111
+ }
112
+ return output.join("");
113
+ }
114
+ function fromByteArray(uint8) {
115
+ var tmp;
116
+ var len2 = uint8.length;
117
+ var extraBytes = len2 % 3;
118
+ var parts = [];
119
+ var maxChunkLength = 16383;
120
+ for (var i2 = 0, len22 = len2 - extraBytes; i2 < len22; i2 += maxChunkLength) {
121
+ parts.push(encodeChunk(uint8, i2, i2 + maxChunkLength > len22 ? len22 : i2 + maxChunkLength));
122
+ }
123
+ if (extraBytes === 1) {
124
+ tmp = uint8[len2 - 1];
125
+ parts.push(
126
+ lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "=="
127
+ );
128
+ } else if (extraBytes === 2) {
129
+ tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1];
130
+ parts.push(
131
+ lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "="
132
+ );
133
+ }
134
+ return parts.join("");
135
+ }
136
+ }
137
+ });
138
+
139
+ // ../../node_modules/ieee754/index.js
140
+ var require_ieee754 = __commonJS({
141
+ "../../node_modules/ieee754/index.js"(exports) {
142
+ exports.read = function(buffer, offset, isLE, mLen, nBytes) {
143
+ var e, m;
144
+ var eLen = nBytes * 8 - mLen - 1;
145
+ var eMax = (1 << eLen) - 1;
146
+ var eBias = eMax >> 1;
147
+ var nBits = -7;
148
+ var i = isLE ? nBytes - 1 : 0;
149
+ var d = isLE ? -1 : 1;
150
+ var s = buffer[offset + i];
151
+ i += d;
152
+ e = s & (1 << -nBits) - 1;
153
+ s >>= -nBits;
154
+ nBits += eLen;
155
+ for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {
156
+ }
157
+ m = e & (1 << -nBits) - 1;
158
+ e >>= -nBits;
159
+ nBits += mLen;
160
+ for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {
161
+ }
162
+ if (e === 0) {
163
+ e = 1 - eBias;
164
+ } else if (e === eMax) {
165
+ return m ? NaN : (s ? -1 : 1) * Infinity;
166
+ } else {
167
+ m = m + Math.pow(2, mLen);
168
+ e = e - eBias;
169
+ }
170
+ return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
171
+ };
172
+ exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
173
+ var e, m, c;
174
+ var eLen = nBytes * 8 - mLen - 1;
175
+ var eMax = (1 << eLen) - 1;
176
+ var eBias = eMax >> 1;
177
+ var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
178
+ var i = isLE ? 0 : nBytes - 1;
179
+ var d = isLE ? 1 : -1;
180
+ var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
181
+ value = Math.abs(value);
182
+ if (isNaN(value) || value === Infinity) {
183
+ m = isNaN(value) ? 1 : 0;
184
+ e = eMax;
185
+ } else {
186
+ e = Math.floor(Math.log(value) / Math.LN2);
187
+ if (value * (c = Math.pow(2, -e)) < 1) {
188
+ e--;
189
+ c *= 2;
190
+ }
191
+ if (e + eBias >= 1) {
192
+ value += rt / c;
193
+ } else {
194
+ value += rt * Math.pow(2, 1 - eBias);
195
+ }
196
+ if (value * c >= 2) {
197
+ e++;
198
+ c /= 2;
199
+ }
200
+ if (e + eBias >= eMax) {
201
+ m = 0;
202
+ e = eMax;
203
+ } else if (e + eBias >= 1) {
204
+ m = (value * c - 1) * Math.pow(2, mLen);
205
+ e = e + eBias;
206
+ } else {
207
+ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
208
+ e = 0;
209
+ }
210
+ }
211
+ for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
212
+ }
213
+ e = e << mLen | m;
214
+ eLen += mLen;
215
+ for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
216
+ }
217
+ buffer[offset + i - d] |= s * 128;
218
+ };
219
+ }
220
+ });
221
+
222
+ // ../../node_modules/buffer/index.js
223
+ var require_buffer = __commonJS({
224
+ "../../node_modules/buffer/index.js"(exports) {
225
+ var base64 = require_base64_js();
226
+ var ieee754 = require_ieee754();
227
+ var customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null;
228
+ exports.Buffer = Buffer2;
229
+ exports.SlowBuffer = SlowBuffer;
230
+ exports.INSPECT_MAX_BYTES = 50;
231
+ var K_MAX_LENGTH = 2147483647;
232
+ exports.kMaxLength = K_MAX_LENGTH;
233
+ Buffer2.TYPED_ARRAY_SUPPORT = typedArraySupport();
234
+ if (!Buffer2.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") {
235
+ console.error(
236
+ "This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."
237
+ );
238
+ }
239
+ function typedArraySupport() {
240
+ try {
241
+ const arr = new Uint8Array(1);
242
+ const proto = { foo: function() {
243
+ return 42;
244
+ } };
245
+ Object.setPrototypeOf(proto, Uint8Array.prototype);
246
+ Object.setPrototypeOf(arr, proto);
247
+ return arr.foo() === 42;
248
+ } catch (e) {
249
+ return false;
250
+ }
251
+ }
252
+ Object.defineProperty(Buffer2.prototype, "parent", {
253
+ enumerable: true,
254
+ get: function() {
255
+ if (!Buffer2.isBuffer(this))
256
+ return void 0;
257
+ return this.buffer;
258
+ }
259
+ });
260
+ Object.defineProperty(Buffer2.prototype, "offset", {
261
+ enumerable: true,
262
+ get: function() {
263
+ if (!Buffer2.isBuffer(this))
264
+ return void 0;
265
+ return this.byteOffset;
266
+ }
267
+ });
268
+ function createBuffer(length) {
269
+ if (length > K_MAX_LENGTH) {
270
+ throw new RangeError('The value "' + length + '" is invalid for option "size"');
271
+ }
272
+ const buf = new Uint8Array(length);
273
+ Object.setPrototypeOf(buf, Buffer2.prototype);
274
+ return buf;
275
+ }
276
+ function Buffer2(arg, encodingOrOffset, length) {
277
+ if (typeof arg === "number") {
278
+ if (typeof encodingOrOffset === "string") {
279
+ throw new TypeError(
280
+ 'The "string" argument must be of type string. Received type number'
281
+ );
282
+ }
283
+ return allocUnsafe(arg);
284
+ }
285
+ return from(arg, encodingOrOffset, length);
286
+ }
287
+ Buffer2.poolSize = 8192;
288
+ function from(value, encodingOrOffset, length) {
289
+ if (typeof value === "string") {
290
+ return fromString(value, encodingOrOffset);
291
+ }
292
+ if (ArrayBuffer.isView(value)) {
293
+ return fromArrayView(value);
294
+ }
295
+ if (value == null) {
296
+ throw new TypeError(
297
+ "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value
298
+ );
299
+ }
300
+ if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) {
301
+ return fromArrayBuffer(value, encodingOrOffset, length);
302
+ }
303
+ if (typeof SharedArrayBuffer !== "undefined" && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) {
304
+ return fromArrayBuffer(value, encodingOrOffset, length);
305
+ }
306
+ if (typeof value === "number") {
307
+ throw new TypeError(
308
+ 'The "value" argument must not be of type number. Received type number'
309
+ );
310
+ }
311
+ const valueOf = value.valueOf && value.valueOf();
312
+ if (valueOf != null && valueOf !== value) {
313
+ return Buffer2.from(valueOf, encodingOrOffset, length);
314
+ }
315
+ const b = fromObject(value);
316
+ if (b)
317
+ return b;
318
+ if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") {
319
+ return Buffer2.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length);
320
+ }
321
+ throw new TypeError(
322
+ "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value
323
+ );
324
+ }
325
+ Buffer2.from = function(value, encodingOrOffset, length) {
326
+ return from(value, encodingOrOffset, length);
327
+ };
328
+ Object.setPrototypeOf(Buffer2.prototype, Uint8Array.prototype);
329
+ Object.setPrototypeOf(Buffer2, Uint8Array);
330
+ function assertSize(size) {
331
+ if (typeof size !== "number") {
332
+ throw new TypeError('"size" argument must be of type number');
333
+ } else if (size < 0) {
334
+ throw new RangeError('The value "' + size + '" is invalid for option "size"');
335
+ }
336
+ }
337
+ function alloc(size, fill, encoding) {
338
+ assertSize(size);
339
+ if (size <= 0) {
340
+ return createBuffer(size);
341
+ }
342
+ if (fill !== void 0) {
343
+ return typeof encoding === "string" ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill);
344
+ }
345
+ return createBuffer(size);
346
+ }
347
+ Buffer2.alloc = function(size, fill, encoding) {
348
+ return alloc(size, fill, encoding);
349
+ };
350
+ function allocUnsafe(size) {
351
+ assertSize(size);
352
+ return createBuffer(size < 0 ? 0 : checked(size) | 0);
353
+ }
354
+ Buffer2.allocUnsafe = function(size) {
355
+ return allocUnsafe(size);
356
+ };
357
+ Buffer2.allocUnsafeSlow = function(size) {
358
+ return allocUnsafe(size);
359
+ };
360
+ function fromString(string, encoding) {
361
+ if (typeof encoding !== "string" || encoding === "") {
362
+ encoding = "utf8";
363
+ }
364
+ if (!Buffer2.isEncoding(encoding)) {
365
+ throw new TypeError("Unknown encoding: " + encoding);
366
+ }
367
+ const length = byteLength(string, encoding) | 0;
368
+ let buf = createBuffer(length);
369
+ const actual = buf.write(string, encoding);
370
+ if (actual !== length) {
371
+ buf = buf.slice(0, actual);
372
+ }
373
+ return buf;
374
+ }
375
+ function fromArrayLike(array) {
376
+ const length = array.length < 0 ? 0 : checked(array.length) | 0;
377
+ const buf = createBuffer(length);
378
+ for (let i = 0; i < length; i += 1) {
379
+ buf[i] = array[i] & 255;
380
+ }
381
+ return buf;
382
+ }
383
+ function fromArrayView(arrayView) {
384
+ if (isInstance(arrayView, Uint8Array)) {
385
+ const copy = new Uint8Array(arrayView);
386
+ return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength);
387
+ }
388
+ return fromArrayLike(arrayView);
389
+ }
390
+ function fromArrayBuffer(array, byteOffset, length) {
391
+ if (byteOffset < 0 || array.byteLength < byteOffset) {
392
+ throw new RangeError('"offset" is outside of buffer bounds');
393
+ }
394
+ if (array.byteLength < byteOffset + (length || 0)) {
395
+ throw new RangeError('"length" is outside of buffer bounds');
396
+ }
397
+ let buf;
398
+ if (byteOffset === void 0 && length === void 0) {
399
+ buf = new Uint8Array(array);
400
+ } else if (length === void 0) {
401
+ buf = new Uint8Array(array, byteOffset);
402
+ } else {
403
+ buf = new Uint8Array(array, byteOffset, length);
404
+ }
405
+ Object.setPrototypeOf(buf, Buffer2.prototype);
406
+ return buf;
407
+ }
408
+ function fromObject(obj) {
409
+ if (Buffer2.isBuffer(obj)) {
410
+ const len = checked(obj.length) | 0;
411
+ const buf = createBuffer(len);
412
+ if (buf.length === 0) {
413
+ return buf;
414
+ }
415
+ obj.copy(buf, 0, 0, len);
416
+ return buf;
417
+ }
418
+ if (obj.length !== void 0) {
419
+ if (typeof obj.length !== "number" || numberIsNaN(obj.length)) {
420
+ return createBuffer(0);
421
+ }
422
+ return fromArrayLike(obj);
423
+ }
424
+ if (obj.type === "Buffer" && Array.isArray(obj.data)) {
425
+ return fromArrayLike(obj.data);
426
+ }
427
+ }
428
+ function checked(length) {
429
+ if (length >= K_MAX_LENGTH) {
430
+ throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + K_MAX_LENGTH.toString(16) + " bytes");
431
+ }
432
+ return length | 0;
433
+ }
434
+ function SlowBuffer(length) {
435
+ if (+length != length) {
436
+ length = 0;
437
+ }
438
+ return Buffer2.alloc(+length);
439
+ }
440
+ Buffer2.isBuffer = function isBuffer(b) {
441
+ return b != null && b._isBuffer === true && b !== Buffer2.prototype;
442
+ };
443
+ Buffer2.compare = function compare(a, b) {
444
+ if (isInstance(a, Uint8Array))
445
+ a = Buffer2.from(a, a.offset, a.byteLength);
446
+ if (isInstance(b, Uint8Array))
447
+ b = Buffer2.from(b, b.offset, b.byteLength);
448
+ if (!Buffer2.isBuffer(a) || !Buffer2.isBuffer(b)) {
449
+ throw new TypeError(
450
+ 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
451
+ );
452
+ }
453
+ if (a === b)
454
+ return 0;
455
+ let x = a.length;
456
+ let y = b.length;
457
+ for (let i = 0, len = Math.min(x, y); i < len; ++i) {
458
+ if (a[i] !== b[i]) {
459
+ x = a[i];
460
+ y = b[i];
461
+ break;
462
+ }
463
+ }
464
+ if (x < y)
465
+ return -1;
466
+ if (y < x)
467
+ return 1;
468
+ return 0;
469
+ };
470
+ Buffer2.isEncoding = function isEncoding(encoding) {
471
+ switch (String(encoding).toLowerCase()) {
472
+ case "hex":
473
+ case "utf8":
474
+ case "utf-8":
475
+ case "ascii":
476
+ case "latin1":
477
+ case "binary":
478
+ case "base64":
479
+ case "ucs2":
480
+ case "ucs-2":
481
+ case "utf16le":
482
+ case "utf-16le":
483
+ return true;
484
+ default:
485
+ return false;
486
+ }
487
+ };
488
+ Buffer2.concat = function concat(list, length) {
489
+ if (!Array.isArray(list)) {
490
+ throw new TypeError('"list" argument must be an Array of Buffers');
491
+ }
492
+ if (list.length === 0) {
493
+ return Buffer2.alloc(0);
494
+ }
495
+ let i;
496
+ if (length === void 0) {
497
+ length = 0;
498
+ for (i = 0; i < list.length; ++i) {
499
+ length += list[i].length;
500
+ }
501
+ }
502
+ const buffer = Buffer2.allocUnsafe(length);
503
+ let pos = 0;
504
+ for (i = 0; i < list.length; ++i) {
505
+ let buf = list[i];
506
+ if (isInstance(buf, Uint8Array)) {
507
+ if (pos + buf.length > buffer.length) {
508
+ if (!Buffer2.isBuffer(buf))
509
+ buf = Buffer2.from(buf);
510
+ buf.copy(buffer, pos);
511
+ } else {
512
+ Uint8Array.prototype.set.call(
513
+ buffer,
514
+ buf,
515
+ pos
516
+ );
517
+ }
518
+ } else if (!Buffer2.isBuffer(buf)) {
519
+ throw new TypeError('"list" argument must be an Array of Buffers');
520
+ } else {
521
+ buf.copy(buffer, pos);
522
+ }
523
+ pos += buf.length;
524
+ }
525
+ return buffer;
526
+ };
527
+ function byteLength(string, encoding) {
528
+ if (Buffer2.isBuffer(string)) {
529
+ return string.length;
530
+ }
531
+ if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
532
+ return string.byteLength;
533
+ }
534
+ if (typeof string !== "string") {
535
+ throw new TypeError(
536
+ 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof string
537
+ );
538
+ }
539
+ const len = string.length;
540
+ const mustMatch = arguments.length > 2 && arguments[2] === true;
541
+ if (!mustMatch && len === 0)
542
+ return 0;
543
+ let loweredCase = false;
544
+ for (; ; ) {
545
+ switch (encoding) {
546
+ case "ascii":
547
+ case "latin1":
548
+ case "binary":
549
+ return len;
550
+ case "utf8":
551
+ case "utf-8":
552
+ return utf8ToBytes(string).length;
553
+ case "ucs2":
554
+ case "ucs-2":
555
+ case "utf16le":
556
+ case "utf-16le":
557
+ return len * 2;
558
+ case "hex":
559
+ return len >>> 1;
560
+ case "base64":
561
+ return base64ToBytes(string).length;
562
+ default:
563
+ if (loweredCase) {
564
+ return mustMatch ? -1 : utf8ToBytes(string).length;
565
+ }
566
+ encoding = ("" + encoding).toLowerCase();
567
+ loweredCase = true;
568
+ }
569
+ }
570
+ }
571
+ Buffer2.byteLength = byteLength;
572
+ function slowToString(encoding, start, end) {
573
+ let loweredCase = false;
574
+ if (start === void 0 || start < 0) {
575
+ start = 0;
576
+ }
577
+ if (start > this.length) {
578
+ return "";
579
+ }
580
+ if (end === void 0 || end > this.length) {
581
+ end = this.length;
582
+ }
583
+ if (end <= 0) {
584
+ return "";
585
+ }
586
+ end >>>= 0;
587
+ start >>>= 0;
588
+ if (end <= start) {
589
+ return "";
590
+ }
591
+ if (!encoding)
592
+ encoding = "utf8";
593
+ while (true) {
594
+ switch (encoding) {
595
+ case "hex":
596
+ return hexSlice(this, start, end);
597
+ case "utf8":
598
+ case "utf-8":
599
+ return utf8Slice(this, start, end);
600
+ case "ascii":
601
+ return asciiSlice(this, start, end);
602
+ case "latin1":
603
+ case "binary":
604
+ return latin1Slice(this, start, end);
605
+ case "base64":
606
+ return base64Slice(this, start, end);
607
+ case "ucs2":
608
+ case "ucs-2":
609
+ case "utf16le":
610
+ case "utf-16le":
611
+ return utf16leSlice(this, start, end);
612
+ default:
613
+ if (loweredCase)
614
+ throw new TypeError("Unknown encoding: " + encoding);
615
+ encoding = (encoding + "").toLowerCase();
616
+ loweredCase = true;
617
+ }
618
+ }
619
+ }
620
+ Buffer2.prototype._isBuffer = true;
621
+ function swap(b, n, m) {
622
+ const i = b[n];
623
+ b[n] = b[m];
624
+ b[m] = i;
625
+ }
626
+ Buffer2.prototype.swap16 = function swap16() {
627
+ const len = this.length;
628
+ if (len % 2 !== 0) {
629
+ throw new RangeError("Buffer size must be a multiple of 16-bits");
630
+ }
631
+ for (let i = 0; i < len; i += 2) {
632
+ swap(this, i, i + 1);
633
+ }
634
+ return this;
635
+ };
636
+ Buffer2.prototype.swap32 = function swap32() {
637
+ const len = this.length;
638
+ if (len % 4 !== 0) {
639
+ throw new RangeError("Buffer size must be a multiple of 32-bits");
640
+ }
641
+ for (let i = 0; i < len; i += 4) {
642
+ swap(this, i, i + 3);
643
+ swap(this, i + 1, i + 2);
644
+ }
645
+ return this;
646
+ };
647
+ Buffer2.prototype.swap64 = function swap64() {
648
+ const len = this.length;
649
+ if (len % 8 !== 0) {
650
+ throw new RangeError("Buffer size must be a multiple of 64-bits");
651
+ }
652
+ for (let i = 0; i < len; i += 8) {
653
+ swap(this, i, i + 7);
654
+ swap(this, i + 1, i + 6);
655
+ swap(this, i + 2, i + 5);
656
+ swap(this, i + 3, i + 4);
657
+ }
658
+ return this;
659
+ };
660
+ Buffer2.prototype.toString = function toString() {
661
+ const length = this.length;
662
+ if (length === 0)
663
+ return "";
664
+ if (arguments.length === 0)
665
+ return utf8Slice(this, 0, length);
666
+ return slowToString.apply(this, arguments);
667
+ };
668
+ Buffer2.prototype.toLocaleString = Buffer2.prototype.toString;
669
+ Buffer2.prototype.equals = function equals(b) {
670
+ if (!Buffer2.isBuffer(b))
671
+ throw new TypeError("Argument must be a Buffer");
672
+ if (this === b)
673
+ return true;
674
+ return Buffer2.compare(this, b) === 0;
675
+ };
676
+ Buffer2.prototype.inspect = function inspect() {
677
+ let str = "";
678
+ const max = exports.INSPECT_MAX_BYTES;
679
+ str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim();
680
+ if (this.length > max)
681
+ str += " ... ";
682
+ return "<Buffer " + str + ">";
683
+ };
684
+ if (customInspectSymbol) {
685
+ Buffer2.prototype[customInspectSymbol] = Buffer2.prototype.inspect;
686
+ }
687
+ Buffer2.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
688
+ if (isInstance(target, Uint8Array)) {
689
+ target = Buffer2.from(target, target.offset, target.byteLength);
690
+ }
691
+ if (!Buffer2.isBuffer(target)) {
692
+ throw new TypeError(
693
+ 'The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target
694
+ );
695
+ }
696
+ if (start === void 0) {
697
+ start = 0;
698
+ }
699
+ if (end === void 0) {
700
+ end = target ? target.length : 0;
701
+ }
702
+ if (thisStart === void 0) {
703
+ thisStart = 0;
704
+ }
705
+ if (thisEnd === void 0) {
706
+ thisEnd = this.length;
707
+ }
708
+ if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
709
+ throw new RangeError("out of range index");
710
+ }
711
+ if (thisStart >= thisEnd && start >= end) {
712
+ return 0;
713
+ }
714
+ if (thisStart >= thisEnd) {
715
+ return -1;
716
+ }
717
+ if (start >= end) {
718
+ return 1;
719
+ }
720
+ start >>>= 0;
721
+ end >>>= 0;
722
+ thisStart >>>= 0;
723
+ thisEnd >>>= 0;
724
+ if (this === target)
725
+ return 0;
726
+ let x = thisEnd - thisStart;
727
+ let y = end - start;
728
+ const len = Math.min(x, y);
729
+ const thisCopy = this.slice(thisStart, thisEnd);
730
+ const targetCopy = target.slice(start, end);
731
+ for (let i = 0; i < len; ++i) {
732
+ if (thisCopy[i] !== targetCopy[i]) {
733
+ x = thisCopy[i];
734
+ y = targetCopy[i];
735
+ break;
736
+ }
737
+ }
738
+ if (x < y)
739
+ return -1;
740
+ if (y < x)
741
+ return 1;
742
+ return 0;
743
+ };
744
+ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
745
+ if (buffer.length === 0)
746
+ return -1;
747
+ if (typeof byteOffset === "string") {
748
+ encoding = byteOffset;
749
+ byteOffset = 0;
750
+ } else if (byteOffset > 2147483647) {
751
+ byteOffset = 2147483647;
752
+ } else if (byteOffset < -2147483648) {
753
+ byteOffset = -2147483648;
754
+ }
755
+ byteOffset = +byteOffset;
756
+ if (numberIsNaN(byteOffset)) {
757
+ byteOffset = dir ? 0 : buffer.length - 1;
758
+ }
759
+ if (byteOffset < 0)
760
+ byteOffset = buffer.length + byteOffset;
761
+ if (byteOffset >= buffer.length) {
762
+ if (dir)
763
+ return -1;
764
+ else
765
+ byteOffset = buffer.length - 1;
766
+ } else if (byteOffset < 0) {
767
+ if (dir)
768
+ byteOffset = 0;
769
+ else
770
+ return -1;
771
+ }
772
+ if (typeof val === "string") {
773
+ val = Buffer2.from(val, encoding);
774
+ }
775
+ if (Buffer2.isBuffer(val)) {
776
+ if (val.length === 0) {
777
+ return -1;
778
+ }
779
+ return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
780
+ } else if (typeof val === "number") {
781
+ val = val & 255;
782
+ if (typeof Uint8Array.prototype.indexOf === "function") {
783
+ if (dir) {
784
+ return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
785
+ } else {
786
+ return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
787
+ }
788
+ }
789
+ return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
790
+ }
791
+ throw new TypeError("val must be string, number or Buffer");
792
+ }
793
+ function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
794
+ let indexSize = 1;
795
+ let arrLength = arr.length;
796
+ let valLength = val.length;
797
+ if (encoding !== void 0) {
798
+ encoding = String(encoding).toLowerCase();
799
+ if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
800
+ if (arr.length < 2 || val.length < 2) {
801
+ return -1;
802
+ }
803
+ indexSize = 2;
804
+ arrLength /= 2;
805
+ valLength /= 2;
806
+ byteOffset /= 2;
807
+ }
808
+ }
809
+ function read(buf, i2) {
810
+ if (indexSize === 1) {
811
+ return buf[i2];
812
+ } else {
813
+ return buf.readUInt16BE(i2 * indexSize);
814
+ }
815
+ }
816
+ let i;
817
+ if (dir) {
818
+ let foundIndex = -1;
819
+ for (i = byteOffset; i < arrLength; i++) {
820
+ if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
821
+ if (foundIndex === -1)
822
+ foundIndex = i;
823
+ if (i - foundIndex + 1 === valLength)
824
+ return foundIndex * indexSize;
825
+ } else {
826
+ if (foundIndex !== -1)
827
+ i -= i - foundIndex;
828
+ foundIndex = -1;
829
+ }
830
+ }
831
+ } else {
832
+ if (byteOffset + valLength > arrLength)
833
+ byteOffset = arrLength - valLength;
834
+ for (i = byteOffset; i >= 0; i--) {
835
+ let found = true;
836
+ for (let j = 0; j < valLength; j++) {
837
+ if (read(arr, i + j) !== read(val, j)) {
838
+ found = false;
839
+ break;
840
+ }
841
+ }
842
+ if (found)
843
+ return i;
844
+ }
845
+ }
846
+ return -1;
847
+ }
848
+ Buffer2.prototype.includes = function includes(val, byteOffset, encoding) {
849
+ return this.indexOf(val, byteOffset, encoding) !== -1;
850
+ };
851
+ Buffer2.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
852
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
853
+ };
854
+ Buffer2.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
855
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
856
+ };
857
+ function hexWrite(buf, string, offset, length) {
858
+ offset = Number(offset) || 0;
859
+ const remaining = buf.length - offset;
860
+ if (!length) {
861
+ length = remaining;
862
+ } else {
863
+ length = Number(length);
864
+ if (length > remaining) {
865
+ length = remaining;
866
+ }
867
+ }
868
+ const strLen = string.length;
869
+ if (length > strLen / 2) {
870
+ length = strLen / 2;
871
+ }
872
+ let i;
873
+ for (i = 0; i < length; ++i) {
874
+ const parsed = parseInt(string.substr(i * 2, 2), 16);
875
+ if (numberIsNaN(parsed))
876
+ return i;
877
+ buf[offset + i] = parsed;
878
+ }
879
+ return i;
880
+ }
881
+ function utf8Write(buf, string, offset, length) {
882
+ return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
883
+ }
884
+ function asciiWrite(buf, string, offset, length) {
885
+ return blitBuffer(asciiToBytes(string), buf, offset, length);
886
+ }
887
+ function base64Write(buf, string, offset, length) {
888
+ return blitBuffer(base64ToBytes(string), buf, offset, length);
889
+ }
890
+ function ucs2Write(buf, string, offset, length) {
891
+ return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
892
+ }
893
+ Buffer2.prototype.write = function write(string, offset, length, encoding) {
894
+ if (offset === void 0) {
895
+ encoding = "utf8";
896
+ length = this.length;
897
+ offset = 0;
898
+ } else if (length === void 0 && typeof offset === "string") {
899
+ encoding = offset;
900
+ length = this.length;
901
+ offset = 0;
902
+ } else if (isFinite(offset)) {
903
+ offset = offset >>> 0;
904
+ if (isFinite(length)) {
905
+ length = length >>> 0;
906
+ if (encoding === void 0)
907
+ encoding = "utf8";
908
+ } else {
909
+ encoding = length;
910
+ length = void 0;
911
+ }
912
+ } else {
913
+ throw new Error(
914
+ "Buffer.write(string, encoding, offset[, length]) is no longer supported"
915
+ );
916
+ }
917
+ const remaining = this.length - offset;
918
+ if (length === void 0 || length > remaining)
919
+ length = remaining;
920
+ if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) {
921
+ throw new RangeError("Attempt to write outside buffer bounds");
922
+ }
923
+ if (!encoding)
924
+ encoding = "utf8";
925
+ let loweredCase = false;
926
+ for (; ; ) {
927
+ switch (encoding) {
928
+ case "hex":
929
+ return hexWrite(this, string, offset, length);
930
+ case "utf8":
931
+ case "utf-8":
932
+ return utf8Write(this, string, offset, length);
933
+ case "ascii":
934
+ case "latin1":
935
+ case "binary":
936
+ return asciiWrite(this, string, offset, length);
937
+ case "base64":
938
+ return base64Write(this, string, offset, length);
939
+ case "ucs2":
940
+ case "ucs-2":
941
+ case "utf16le":
942
+ case "utf-16le":
943
+ return ucs2Write(this, string, offset, length);
944
+ default:
945
+ if (loweredCase)
946
+ throw new TypeError("Unknown encoding: " + encoding);
947
+ encoding = ("" + encoding).toLowerCase();
948
+ loweredCase = true;
949
+ }
950
+ }
951
+ };
952
+ Buffer2.prototype.toJSON = function toJSON() {
953
+ return {
954
+ type: "Buffer",
955
+ data: Array.prototype.slice.call(this._arr || this, 0)
956
+ };
957
+ };
958
+ function base64Slice(buf, start, end) {
959
+ if (start === 0 && end === buf.length) {
960
+ return base64.fromByteArray(buf);
961
+ } else {
962
+ return base64.fromByteArray(buf.slice(start, end));
963
+ }
964
+ }
965
+ function utf8Slice(buf, start, end) {
966
+ end = Math.min(buf.length, end);
967
+ const res = [];
968
+ let i = start;
969
+ while (i < end) {
970
+ const firstByte = buf[i];
971
+ let codePoint = null;
972
+ let bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
973
+ if (i + bytesPerSequence <= end) {
974
+ let secondByte, thirdByte, fourthByte, tempCodePoint;
975
+ switch (bytesPerSequence) {
976
+ case 1:
977
+ if (firstByte < 128) {
978
+ codePoint = firstByte;
979
+ }
980
+ break;
981
+ case 2:
982
+ secondByte = buf[i + 1];
983
+ if ((secondByte & 192) === 128) {
984
+ tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
985
+ if (tempCodePoint > 127) {
986
+ codePoint = tempCodePoint;
987
+ }
988
+ }
989
+ break;
990
+ case 3:
991
+ secondByte = buf[i + 1];
992
+ thirdByte = buf[i + 2];
993
+ if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
994
+ tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
995
+ if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) {
996
+ codePoint = tempCodePoint;
997
+ }
998
+ }
999
+ break;
1000
+ case 4:
1001
+ secondByte = buf[i + 1];
1002
+ thirdByte = buf[i + 2];
1003
+ fourthByte = buf[i + 3];
1004
+ if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
1005
+ tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
1006
+ if (tempCodePoint > 65535 && tempCodePoint < 1114112) {
1007
+ codePoint = tempCodePoint;
1008
+ }
1009
+ }
1010
+ }
1011
+ }
1012
+ if (codePoint === null) {
1013
+ codePoint = 65533;
1014
+ bytesPerSequence = 1;
1015
+ } else if (codePoint > 65535) {
1016
+ codePoint -= 65536;
1017
+ res.push(codePoint >>> 10 & 1023 | 55296);
1018
+ codePoint = 56320 | codePoint & 1023;
1019
+ }
1020
+ res.push(codePoint);
1021
+ i += bytesPerSequence;
1022
+ }
1023
+ return decodeCodePointsArray(res);
1024
+ }
1025
+ var MAX_ARGUMENTS_LENGTH = 4096;
1026
+ function decodeCodePointsArray(codePoints) {
1027
+ const len = codePoints.length;
1028
+ if (len <= MAX_ARGUMENTS_LENGTH) {
1029
+ return String.fromCharCode.apply(String, codePoints);
1030
+ }
1031
+ let res = "";
1032
+ let i = 0;
1033
+ while (i < len) {
1034
+ res += String.fromCharCode.apply(
1035
+ String,
1036
+ codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
1037
+ );
1038
+ }
1039
+ return res;
1040
+ }
1041
+ function asciiSlice(buf, start, end) {
1042
+ let ret = "";
1043
+ end = Math.min(buf.length, end);
1044
+ for (let i = start; i < end; ++i) {
1045
+ ret += String.fromCharCode(buf[i] & 127);
1046
+ }
1047
+ return ret;
1048
+ }
1049
+ function latin1Slice(buf, start, end) {
1050
+ let ret = "";
1051
+ end = Math.min(buf.length, end);
1052
+ for (let i = start; i < end; ++i) {
1053
+ ret += String.fromCharCode(buf[i]);
1054
+ }
1055
+ return ret;
1056
+ }
1057
+ function hexSlice(buf, start, end) {
1058
+ const len = buf.length;
1059
+ if (!start || start < 0)
1060
+ start = 0;
1061
+ if (!end || end < 0 || end > len)
1062
+ end = len;
1063
+ let out = "";
1064
+ for (let i = start; i < end; ++i) {
1065
+ out += hexSliceLookupTable[buf[i]];
1066
+ }
1067
+ return out;
1068
+ }
1069
+ function utf16leSlice(buf, start, end) {
1070
+ const bytes = buf.slice(start, end);
1071
+ let res = "";
1072
+ for (let i = 0; i < bytes.length - 1; i += 2) {
1073
+ res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
1074
+ }
1075
+ return res;
1076
+ }
1077
+ Buffer2.prototype.slice = function slice(start, end) {
1078
+ const len = this.length;
1079
+ start = ~~start;
1080
+ end = end === void 0 ? len : ~~end;
1081
+ if (start < 0) {
1082
+ start += len;
1083
+ if (start < 0)
1084
+ start = 0;
1085
+ } else if (start > len) {
1086
+ start = len;
1087
+ }
1088
+ if (end < 0) {
1089
+ end += len;
1090
+ if (end < 0)
1091
+ end = 0;
1092
+ } else if (end > len) {
1093
+ end = len;
1094
+ }
1095
+ if (end < start)
1096
+ end = start;
1097
+ const newBuf = this.subarray(start, end);
1098
+ Object.setPrototypeOf(newBuf, Buffer2.prototype);
1099
+ return newBuf;
1100
+ };
1101
+ function checkOffset(offset, ext, length) {
1102
+ if (offset % 1 !== 0 || offset < 0)
1103
+ throw new RangeError("offset is not uint");
1104
+ if (offset + ext > length)
1105
+ throw new RangeError("Trying to access beyond buffer length");
1106
+ }
1107
+ Buffer2.prototype.readUintLE = Buffer2.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) {
1108
+ offset = offset >>> 0;
1109
+ byteLength2 = byteLength2 >>> 0;
1110
+ if (!noAssert)
1111
+ checkOffset(offset, byteLength2, this.length);
1112
+ let val = this[offset];
1113
+ let mul = 1;
1114
+ let i = 0;
1115
+ while (++i < byteLength2 && (mul *= 256)) {
1116
+ val += this[offset + i] * mul;
1117
+ }
1118
+ return val;
1119
+ };
1120
+ Buffer2.prototype.readUintBE = Buffer2.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) {
1121
+ offset = offset >>> 0;
1122
+ byteLength2 = byteLength2 >>> 0;
1123
+ if (!noAssert) {
1124
+ checkOffset(offset, byteLength2, this.length);
1125
+ }
1126
+ let val = this[offset + --byteLength2];
1127
+ let mul = 1;
1128
+ while (byteLength2 > 0 && (mul *= 256)) {
1129
+ val += this[offset + --byteLength2] * mul;
1130
+ }
1131
+ return val;
1132
+ };
1133
+ Buffer2.prototype.readUint8 = Buffer2.prototype.readUInt8 = function readUInt8(offset, noAssert) {
1134
+ offset = offset >>> 0;
1135
+ if (!noAssert)
1136
+ checkOffset(offset, 1, this.length);
1137
+ return this[offset];
1138
+ };
1139
+ Buffer2.prototype.readUint16LE = Buffer2.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
1140
+ offset = offset >>> 0;
1141
+ if (!noAssert)
1142
+ checkOffset(offset, 2, this.length);
1143
+ return this[offset] | this[offset + 1] << 8;
1144
+ };
1145
+ Buffer2.prototype.readUint16BE = Buffer2.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
1146
+ offset = offset >>> 0;
1147
+ if (!noAssert)
1148
+ checkOffset(offset, 2, this.length);
1149
+ return this[offset] << 8 | this[offset + 1];
1150
+ };
1151
+ Buffer2.prototype.readUint32LE = Buffer2.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
1152
+ offset = offset >>> 0;
1153
+ if (!noAssert)
1154
+ checkOffset(offset, 4, this.length);
1155
+ return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
1156
+ };
1157
+ Buffer2.prototype.readUint32BE = Buffer2.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
1158
+ offset = offset >>> 0;
1159
+ if (!noAssert)
1160
+ checkOffset(offset, 4, this.length);
1161
+ return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
1162
+ };
1163
+ Buffer2.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE(offset) {
1164
+ offset = offset >>> 0;
1165
+ validateNumber(offset, "offset");
1166
+ const first = this[offset];
1167
+ const last = this[offset + 7];
1168
+ if (first === void 0 || last === void 0) {
1169
+ boundsError(offset, this.length - 8);
1170
+ }
1171
+ const lo = first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24;
1172
+ const hi = this[++offset] + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + last * 2 ** 24;
1173
+ return BigInt(lo) + (BigInt(hi) << BigInt(32));
1174
+ });
1175
+ Buffer2.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE(offset) {
1176
+ offset = offset >>> 0;
1177
+ validateNumber(offset, "offset");
1178
+ const first = this[offset];
1179
+ const last = this[offset + 7];
1180
+ if (first === void 0 || last === void 0) {
1181
+ boundsError(offset, this.length - 8);
1182
+ }
1183
+ const hi = first * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
1184
+ const lo = this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last;
1185
+ return (BigInt(hi) << BigInt(32)) + BigInt(lo);
1186
+ });
1187
+ Buffer2.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) {
1188
+ offset = offset >>> 0;
1189
+ byteLength2 = byteLength2 >>> 0;
1190
+ if (!noAssert)
1191
+ checkOffset(offset, byteLength2, this.length);
1192
+ let val = this[offset];
1193
+ let mul = 1;
1194
+ let i = 0;
1195
+ while (++i < byteLength2 && (mul *= 256)) {
1196
+ val += this[offset + i] * mul;
1197
+ }
1198
+ mul *= 128;
1199
+ if (val >= mul)
1200
+ val -= Math.pow(2, 8 * byteLength2);
1201
+ return val;
1202
+ };
1203
+ Buffer2.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) {
1204
+ offset = offset >>> 0;
1205
+ byteLength2 = byteLength2 >>> 0;
1206
+ if (!noAssert)
1207
+ checkOffset(offset, byteLength2, this.length);
1208
+ let i = byteLength2;
1209
+ let mul = 1;
1210
+ let val = this[offset + --i];
1211
+ while (i > 0 && (mul *= 256)) {
1212
+ val += this[offset + --i] * mul;
1213
+ }
1214
+ mul *= 128;
1215
+ if (val >= mul)
1216
+ val -= Math.pow(2, 8 * byteLength2);
1217
+ return val;
1218
+ };
1219
+ Buffer2.prototype.readInt8 = function readInt8(offset, noAssert) {
1220
+ offset = offset >>> 0;
1221
+ if (!noAssert)
1222
+ checkOffset(offset, 1, this.length);
1223
+ if (!(this[offset] & 128))
1224
+ return this[offset];
1225
+ return (255 - this[offset] + 1) * -1;
1226
+ };
1227
+ Buffer2.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
1228
+ offset = offset >>> 0;
1229
+ if (!noAssert)
1230
+ checkOffset(offset, 2, this.length);
1231
+ const val = this[offset] | this[offset + 1] << 8;
1232
+ return val & 32768 ? val | 4294901760 : val;
1233
+ };
1234
+ Buffer2.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
1235
+ offset = offset >>> 0;
1236
+ if (!noAssert)
1237
+ checkOffset(offset, 2, this.length);
1238
+ const val = this[offset + 1] | this[offset] << 8;
1239
+ return val & 32768 ? val | 4294901760 : val;
1240
+ };
1241
+ Buffer2.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
1242
+ offset = offset >>> 0;
1243
+ if (!noAssert)
1244
+ checkOffset(offset, 4, this.length);
1245
+ return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
1246
+ };
1247
+ Buffer2.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
1248
+ offset = offset >>> 0;
1249
+ if (!noAssert)
1250
+ checkOffset(offset, 4, this.length);
1251
+ return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
1252
+ };
1253
+ Buffer2.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE(offset) {
1254
+ offset = offset >>> 0;
1255
+ validateNumber(offset, "offset");
1256
+ const first = this[offset];
1257
+ const last = this[offset + 7];
1258
+ if (first === void 0 || last === void 0) {
1259
+ boundsError(offset, this.length - 8);
1260
+ }
1261
+ const val = this[offset + 4] + this[offset + 5] * 2 ** 8 + this[offset + 6] * 2 ** 16 + (last << 24);
1262
+ return (BigInt(val) << BigInt(32)) + BigInt(first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24);
1263
+ });
1264
+ Buffer2.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE(offset) {
1265
+ offset = offset >>> 0;
1266
+ validateNumber(offset, "offset");
1267
+ const first = this[offset];
1268
+ const last = this[offset + 7];
1269
+ if (first === void 0 || last === void 0) {
1270
+ boundsError(offset, this.length - 8);
1271
+ }
1272
+ const val = (first << 24) + // Overflow
1273
+ this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
1274
+ return (BigInt(val) << BigInt(32)) + BigInt(this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last);
1275
+ });
1276
+ Buffer2.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
1277
+ offset = offset >>> 0;
1278
+ if (!noAssert)
1279
+ checkOffset(offset, 4, this.length);
1280
+ return ieee754.read(this, offset, true, 23, 4);
1281
+ };
1282
+ Buffer2.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
1283
+ offset = offset >>> 0;
1284
+ if (!noAssert)
1285
+ checkOffset(offset, 4, this.length);
1286
+ return ieee754.read(this, offset, false, 23, 4);
1287
+ };
1288
+ Buffer2.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
1289
+ offset = offset >>> 0;
1290
+ if (!noAssert)
1291
+ checkOffset(offset, 8, this.length);
1292
+ return ieee754.read(this, offset, true, 52, 8);
1293
+ };
1294
+ Buffer2.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
1295
+ offset = offset >>> 0;
1296
+ if (!noAssert)
1297
+ checkOffset(offset, 8, this.length);
1298
+ return ieee754.read(this, offset, false, 52, 8);
1299
+ };
1300
+ function checkInt(buf, value, offset, ext, max, min) {
1301
+ if (!Buffer2.isBuffer(buf))
1302
+ throw new TypeError('"buffer" argument must be a Buffer instance');
1303
+ if (value > max || value < min)
1304
+ throw new RangeError('"value" argument is out of bounds');
1305
+ if (offset + ext > buf.length)
1306
+ throw new RangeError("Index out of range");
1307
+ }
1308
+ Buffer2.prototype.writeUintLE = Buffer2.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) {
1309
+ value = +value;
1310
+ offset = offset >>> 0;
1311
+ byteLength2 = byteLength2 >>> 0;
1312
+ if (!noAssert) {
1313
+ const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
1314
+ checkInt(this, value, offset, byteLength2, maxBytes, 0);
1315
+ }
1316
+ let mul = 1;
1317
+ let i = 0;
1318
+ this[offset] = value & 255;
1319
+ while (++i < byteLength2 && (mul *= 256)) {
1320
+ this[offset + i] = value / mul & 255;
1321
+ }
1322
+ return offset + byteLength2;
1323
+ };
1324
+ Buffer2.prototype.writeUintBE = Buffer2.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) {
1325
+ value = +value;
1326
+ offset = offset >>> 0;
1327
+ byteLength2 = byteLength2 >>> 0;
1328
+ if (!noAssert) {
1329
+ const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
1330
+ checkInt(this, value, offset, byteLength2, maxBytes, 0);
1331
+ }
1332
+ let i = byteLength2 - 1;
1333
+ let mul = 1;
1334
+ this[offset + i] = value & 255;
1335
+ while (--i >= 0 && (mul *= 256)) {
1336
+ this[offset + i] = value / mul & 255;
1337
+ }
1338
+ return offset + byteLength2;
1339
+ };
1340
+ Buffer2.prototype.writeUint8 = Buffer2.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
1341
+ value = +value;
1342
+ offset = offset >>> 0;
1343
+ if (!noAssert)
1344
+ checkInt(this, value, offset, 1, 255, 0);
1345
+ this[offset] = value & 255;
1346
+ return offset + 1;
1347
+ };
1348
+ Buffer2.prototype.writeUint16LE = Buffer2.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
1349
+ value = +value;
1350
+ offset = offset >>> 0;
1351
+ if (!noAssert)
1352
+ checkInt(this, value, offset, 2, 65535, 0);
1353
+ this[offset] = value & 255;
1354
+ this[offset + 1] = value >>> 8;
1355
+ return offset + 2;
1356
+ };
1357
+ Buffer2.prototype.writeUint16BE = Buffer2.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
1358
+ value = +value;
1359
+ offset = offset >>> 0;
1360
+ if (!noAssert)
1361
+ checkInt(this, value, offset, 2, 65535, 0);
1362
+ this[offset] = value >>> 8;
1363
+ this[offset + 1] = value & 255;
1364
+ return offset + 2;
1365
+ };
1366
+ Buffer2.prototype.writeUint32LE = Buffer2.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
1367
+ value = +value;
1368
+ offset = offset >>> 0;
1369
+ if (!noAssert)
1370
+ checkInt(this, value, offset, 4, 4294967295, 0);
1371
+ this[offset + 3] = value >>> 24;
1372
+ this[offset + 2] = value >>> 16;
1373
+ this[offset + 1] = value >>> 8;
1374
+ this[offset] = value & 255;
1375
+ return offset + 4;
1376
+ };
1377
+ Buffer2.prototype.writeUint32BE = Buffer2.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
1378
+ value = +value;
1379
+ offset = offset >>> 0;
1380
+ if (!noAssert)
1381
+ checkInt(this, value, offset, 4, 4294967295, 0);
1382
+ this[offset] = value >>> 24;
1383
+ this[offset + 1] = value >>> 16;
1384
+ this[offset + 2] = value >>> 8;
1385
+ this[offset + 3] = value & 255;
1386
+ return offset + 4;
1387
+ };
1388
+ function wrtBigUInt64LE(buf, value, offset, min, max) {
1389
+ checkIntBI(value, min, max, buf, offset, 7);
1390
+ let lo = Number(value & BigInt(4294967295));
1391
+ buf[offset++] = lo;
1392
+ lo = lo >> 8;
1393
+ buf[offset++] = lo;
1394
+ lo = lo >> 8;
1395
+ buf[offset++] = lo;
1396
+ lo = lo >> 8;
1397
+ buf[offset++] = lo;
1398
+ let hi = Number(value >> BigInt(32) & BigInt(4294967295));
1399
+ buf[offset++] = hi;
1400
+ hi = hi >> 8;
1401
+ buf[offset++] = hi;
1402
+ hi = hi >> 8;
1403
+ buf[offset++] = hi;
1404
+ hi = hi >> 8;
1405
+ buf[offset++] = hi;
1406
+ return offset;
1407
+ }
1408
+ function wrtBigUInt64BE(buf, value, offset, min, max) {
1409
+ checkIntBI(value, min, max, buf, offset, 7);
1410
+ let lo = Number(value & BigInt(4294967295));
1411
+ buf[offset + 7] = lo;
1412
+ lo = lo >> 8;
1413
+ buf[offset + 6] = lo;
1414
+ lo = lo >> 8;
1415
+ buf[offset + 5] = lo;
1416
+ lo = lo >> 8;
1417
+ buf[offset + 4] = lo;
1418
+ let hi = Number(value >> BigInt(32) & BigInt(4294967295));
1419
+ buf[offset + 3] = hi;
1420
+ hi = hi >> 8;
1421
+ buf[offset + 2] = hi;
1422
+ hi = hi >> 8;
1423
+ buf[offset + 1] = hi;
1424
+ hi = hi >> 8;
1425
+ buf[offset] = hi;
1426
+ return offset + 8;
1427
+ }
1428
+ Buffer2.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) {
1429
+ return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
1430
+ });
1431
+ Buffer2.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) {
1432
+ return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
1433
+ });
1434
+ Buffer2.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) {
1435
+ value = +value;
1436
+ offset = offset >>> 0;
1437
+ if (!noAssert) {
1438
+ const limit = Math.pow(2, 8 * byteLength2 - 1);
1439
+ checkInt(this, value, offset, byteLength2, limit - 1, -limit);
1440
+ }
1441
+ let i = 0;
1442
+ let mul = 1;
1443
+ let sub = 0;
1444
+ this[offset] = value & 255;
1445
+ while (++i < byteLength2 && (mul *= 256)) {
1446
+ if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
1447
+ sub = 1;
1448
+ }
1449
+ this[offset + i] = (value / mul >> 0) - sub & 255;
1450
+ }
1451
+ return offset + byteLength2;
1452
+ };
1453
+ Buffer2.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) {
1454
+ value = +value;
1455
+ offset = offset >>> 0;
1456
+ if (!noAssert) {
1457
+ const limit = Math.pow(2, 8 * byteLength2 - 1);
1458
+ checkInt(this, value, offset, byteLength2, limit - 1, -limit);
1459
+ }
1460
+ let i = byteLength2 - 1;
1461
+ let mul = 1;
1462
+ let sub = 0;
1463
+ this[offset + i] = value & 255;
1464
+ while (--i >= 0 && (mul *= 256)) {
1465
+ if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
1466
+ sub = 1;
1467
+ }
1468
+ this[offset + i] = (value / mul >> 0) - sub & 255;
1469
+ }
1470
+ return offset + byteLength2;
1471
+ };
1472
+ Buffer2.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
1473
+ value = +value;
1474
+ offset = offset >>> 0;
1475
+ if (!noAssert)
1476
+ checkInt(this, value, offset, 1, 127, -128);
1477
+ if (value < 0)
1478
+ value = 255 + value + 1;
1479
+ this[offset] = value & 255;
1480
+ return offset + 1;
1481
+ };
1482
+ Buffer2.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
1483
+ value = +value;
1484
+ offset = offset >>> 0;
1485
+ if (!noAssert)
1486
+ checkInt(this, value, offset, 2, 32767, -32768);
1487
+ this[offset] = value & 255;
1488
+ this[offset + 1] = value >>> 8;
1489
+ return offset + 2;
1490
+ };
1491
+ Buffer2.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
1492
+ value = +value;
1493
+ offset = offset >>> 0;
1494
+ if (!noAssert)
1495
+ checkInt(this, value, offset, 2, 32767, -32768);
1496
+ this[offset] = value >>> 8;
1497
+ this[offset + 1] = value & 255;
1498
+ return offset + 2;
1499
+ };
1500
+ Buffer2.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
1501
+ value = +value;
1502
+ offset = offset >>> 0;
1503
+ if (!noAssert)
1504
+ checkInt(this, value, offset, 4, 2147483647, -2147483648);
1505
+ this[offset] = value & 255;
1506
+ this[offset + 1] = value >>> 8;
1507
+ this[offset + 2] = value >>> 16;
1508
+ this[offset + 3] = value >>> 24;
1509
+ return offset + 4;
1510
+ };
1511
+ Buffer2.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
1512
+ value = +value;
1513
+ offset = offset >>> 0;
1514
+ if (!noAssert)
1515
+ checkInt(this, value, offset, 4, 2147483647, -2147483648);
1516
+ if (value < 0)
1517
+ value = 4294967295 + value + 1;
1518
+ this[offset] = value >>> 24;
1519
+ this[offset + 1] = value >>> 16;
1520
+ this[offset + 2] = value >>> 8;
1521
+ this[offset + 3] = value & 255;
1522
+ return offset + 4;
1523
+ };
1524
+ Buffer2.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) {
1525
+ return wrtBigUInt64LE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
1526
+ });
1527
+ Buffer2.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset = 0) {
1528
+ return wrtBigUInt64BE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
1529
+ });
1530
+ function checkIEEE754(buf, value, offset, ext, max, min) {
1531
+ if (offset + ext > buf.length)
1532
+ throw new RangeError("Index out of range");
1533
+ if (offset < 0)
1534
+ throw new RangeError("Index out of range");
1535
+ }
1536
+ function writeFloat(buf, value, offset, littleEndian, noAssert) {
1537
+ value = +value;
1538
+ offset = offset >>> 0;
1539
+ if (!noAssert) {
1540
+ checkIEEE754(buf, value, offset, 4);
1541
+ }
1542
+ ieee754.write(buf, value, offset, littleEndian, 23, 4);
1543
+ return offset + 4;
1544
+ }
1545
+ Buffer2.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
1546
+ return writeFloat(this, value, offset, true, noAssert);
1547
+ };
1548
+ Buffer2.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
1549
+ return writeFloat(this, value, offset, false, noAssert);
1550
+ };
1551
+ function writeDouble(buf, value, offset, littleEndian, noAssert) {
1552
+ value = +value;
1553
+ offset = offset >>> 0;
1554
+ if (!noAssert) {
1555
+ checkIEEE754(buf, value, offset, 8);
1556
+ }
1557
+ ieee754.write(buf, value, offset, littleEndian, 52, 8);
1558
+ return offset + 8;
1559
+ }
1560
+ Buffer2.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
1561
+ return writeDouble(this, value, offset, true, noAssert);
1562
+ };
1563
+ Buffer2.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
1564
+ return writeDouble(this, value, offset, false, noAssert);
1565
+ };
1566
+ Buffer2.prototype.copy = function copy(target, targetStart, start, end) {
1567
+ if (!Buffer2.isBuffer(target))
1568
+ throw new TypeError("argument should be a Buffer");
1569
+ if (!start)
1570
+ start = 0;
1571
+ if (!end && end !== 0)
1572
+ end = this.length;
1573
+ if (targetStart >= target.length)
1574
+ targetStart = target.length;
1575
+ if (!targetStart)
1576
+ targetStart = 0;
1577
+ if (end > 0 && end < start)
1578
+ end = start;
1579
+ if (end === start)
1580
+ return 0;
1581
+ if (target.length === 0 || this.length === 0)
1582
+ return 0;
1583
+ if (targetStart < 0) {
1584
+ throw new RangeError("targetStart out of bounds");
1585
+ }
1586
+ if (start < 0 || start >= this.length)
1587
+ throw new RangeError("Index out of range");
1588
+ if (end < 0)
1589
+ throw new RangeError("sourceEnd out of bounds");
1590
+ if (end > this.length)
1591
+ end = this.length;
1592
+ if (target.length - targetStart < end - start) {
1593
+ end = target.length - targetStart + start;
1594
+ }
1595
+ const len = end - start;
1596
+ if (this === target && typeof Uint8Array.prototype.copyWithin === "function") {
1597
+ this.copyWithin(targetStart, start, end);
1598
+ } else {
1599
+ Uint8Array.prototype.set.call(
1600
+ target,
1601
+ this.subarray(start, end),
1602
+ targetStart
1603
+ );
1604
+ }
1605
+ return len;
1606
+ };
1607
+ Buffer2.prototype.fill = function fill(val, start, end, encoding) {
1608
+ if (typeof val === "string") {
1609
+ if (typeof start === "string") {
1610
+ encoding = start;
1611
+ start = 0;
1612
+ end = this.length;
1613
+ } else if (typeof end === "string") {
1614
+ encoding = end;
1615
+ end = this.length;
1616
+ }
1617
+ if (encoding !== void 0 && typeof encoding !== "string") {
1618
+ throw new TypeError("encoding must be a string");
1619
+ }
1620
+ if (typeof encoding === "string" && !Buffer2.isEncoding(encoding)) {
1621
+ throw new TypeError("Unknown encoding: " + encoding);
1622
+ }
1623
+ if (val.length === 1) {
1624
+ const code = val.charCodeAt(0);
1625
+ if (encoding === "utf8" && code < 128 || encoding === "latin1") {
1626
+ val = code;
1627
+ }
1628
+ }
1629
+ } else if (typeof val === "number") {
1630
+ val = val & 255;
1631
+ } else if (typeof val === "boolean") {
1632
+ val = Number(val);
1633
+ }
1634
+ if (start < 0 || this.length < start || this.length < end) {
1635
+ throw new RangeError("Out of range index");
1636
+ }
1637
+ if (end <= start) {
1638
+ return this;
1639
+ }
1640
+ start = start >>> 0;
1641
+ end = end === void 0 ? this.length : end >>> 0;
1642
+ if (!val)
1643
+ val = 0;
1644
+ let i;
1645
+ if (typeof val === "number") {
1646
+ for (i = start; i < end; ++i) {
1647
+ this[i] = val;
1648
+ }
1649
+ } else {
1650
+ const bytes = Buffer2.isBuffer(val) ? val : Buffer2.from(val, encoding);
1651
+ const len = bytes.length;
1652
+ if (len === 0) {
1653
+ throw new TypeError('The value "' + val + '" is invalid for argument "value"');
1654
+ }
1655
+ for (i = 0; i < end - start; ++i) {
1656
+ this[i + start] = bytes[i % len];
1657
+ }
1658
+ }
1659
+ return this;
1660
+ };
1661
+ var errors = {};
1662
+ function E(sym, getMessage, Base) {
1663
+ errors[sym] = class NodeError extends Base {
1664
+ constructor() {
1665
+ super();
1666
+ Object.defineProperty(this, "message", {
1667
+ value: getMessage.apply(this, arguments),
1668
+ writable: true,
1669
+ configurable: true
1670
+ });
1671
+ this.name = `${this.name} [${sym}]`;
1672
+ this.stack;
1673
+ delete this.name;
1674
+ }
1675
+ get code() {
1676
+ return sym;
1677
+ }
1678
+ set code(value) {
1679
+ Object.defineProperty(this, "code", {
1680
+ configurable: true,
1681
+ enumerable: true,
1682
+ value,
1683
+ writable: true
1684
+ });
1685
+ }
1686
+ toString() {
1687
+ return `${this.name} [${sym}]: ${this.message}`;
1688
+ }
1689
+ };
1690
+ }
1691
+ E(
1692
+ "ERR_BUFFER_OUT_OF_BOUNDS",
1693
+ function(name) {
1694
+ if (name) {
1695
+ return `${name} is outside of buffer bounds`;
1696
+ }
1697
+ return "Attempt to access memory outside buffer bounds";
1698
+ },
1699
+ RangeError
1700
+ );
1701
+ E(
1702
+ "ERR_INVALID_ARG_TYPE",
1703
+ function(name, actual) {
1704
+ return `The "${name}" argument must be of type number. Received type ${typeof actual}`;
1705
+ },
1706
+ TypeError
1707
+ );
1708
+ E(
1709
+ "ERR_OUT_OF_RANGE",
1710
+ function(str, range, input) {
1711
+ let msg = `The value of "${str}" is out of range.`;
1712
+ let received = input;
1713
+ if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
1714
+ received = addNumericalSeparator(String(input));
1715
+ } else if (typeof input === "bigint") {
1716
+ received = String(input);
1717
+ if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
1718
+ received = addNumericalSeparator(received);
1719
+ }
1720
+ received += "n";
1721
+ }
1722
+ msg += ` It must be ${range}. Received ${received}`;
1723
+ return msg;
1724
+ },
1725
+ RangeError
1726
+ );
1727
+ function addNumericalSeparator(val) {
1728
+ let res = "";
1729
+ let i = val.length;
1730
+ const start = val[0] === "-" ? 1 : 0;
1731
+ for (; i >= start + 4; i -= 3) {
1732
+ res = `_${val.slice(i - 3, i)}${res}`;
1733
+ }
1734
+ return `${val.slice(0, i)}${res}`;
1735
+ }
1736
+ function checkBounds(buf, offset, byteLength2) {
1737
+ validateNumber(offset, "offset");
1738
+ if (buf[offset] === void 0 || buf[offset + byteLength2] === void 0) {
1739
+ boundsError(offset, buf.length - (byteLength2 + 1));
1740
+ }
1741
+ }
1742
+ function checkIntBI(value, min, max, buf, offset, byteLength2) {
1743
+ if (value > max || value < min) {
1744
+ const n = typeof min === "bigint" ? "n" : "";
1745
+ let range;
1746
+ if (byteLength2 > 3) {
1747
+ if (min === 0 || min === BigInt(0)) {
1748
+ range = `>= 0${n} and < 2${n} ** ${(byteLength2 + 1) * 8}${n}`;
1749
+ } else {
1750
+ range = `>= -(2${n} ** ${(byteLength2 + 1) * 8 - 1}${n}) and < 2 ** ${(byteLength2 + 1) * 8 - 1}${n}`;
1751
+ }
1752
+ } else {
1753
+ range = `>= ${min}${n} and <= ${max}${n}`;
1754
+ }
1755
+ throw new errors.ERR_OUT_OF_RANGE("value", range, value);
1756
+ }
1757
+ checkBounds(buf, offset, byteLength2);
1758
+ }
1759
+ function validateNumber(value, name) {
1760
+ if (typeof value !== "number") {
1761
+ throw new errors.ERR_INVALID_ARG_TYPE(name, "number", value);
1762
+ }
1763
+ }
1764
+ function boundsError(value, length, type) {
1765
+ if (Math.floor(value) !== value) {
1766
+ validateNumber(value, type);
1767
+ throw new errors.ERR_OUT_OF_RANGE(type || "offset", "an integer", value);
1768
+ }
1769
+ if (length < 0) {
1770
+ throw new errors.ERR_BUFFER_OUT_OF_BOUNDS();
1771
+ }
1772
+ throw new errors.ERR_OUT_OF_RANGE(
1773
+ type || "offset",
1774
+ `>= ${type ? 1 : 0} and <= ${length}`,
1775
+ value
1776
+ );
1777
+ }
1778
+ var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
1779
+ function base64clean(str) {
1780
+ str = str.split("=")[0];
1781
+ str = str.trim().replace(INVALID_BASE64_RE, "");
1782
+ if (str.length < 2)
1783
+ return "";
1784
+ while (str.length % 4 !== 0) {
1785
+ str = str + "=";
1786
+ }
1787
+ return str;
1788
+ }
1789
+ function utf8ToBytes(string, units) {
1790
+ units = units || Infinity;
1791
+ let codePoint;
1792
+ const length = string.length;
1793
+ let leadSurrogate = null;
1794
+ const bytes = [];
1795
+ for (let i = 0; i < length; ++i) {
1796
+ codePoint = string.charCodeAt(i);
1797
+ if (codePoint > 55295 && codePoint < 57344) {
1798
+ if (!leadSurrogate) {
1799
+ if (codePoint > 56319) {
1800
+ if ((units -= 3) > -1)
1801
+ bytes.push(239, 191, 189);
1802
+ continue;
1803
+ } else if (i + 1 === length) {
1804
+ if ((units -= 3) > -1)
1805
+ bytes.push(239, 191, 189);
1806
+ continue;
1807
+ }
1808
+ leadSurrogate = codePoint;
1809
+ continue;
1810
+ }
1811
+ if (codePoint < 56320) {
1812
+ if ((units -= 3) > -1)
1813
+ bytes.push(239, 191, 189);
1814
+ leadSurrogate = codePoint;
1815
+ continue;
1816
+ }
1817
+ codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
1818
+ } else if (leadSurrogate) {
1819
+ if ((units -= 3) > -1)
1820
+ bytes.push(239, 191, 189);
1821
+ }
1822
+ leadSurrogate = null;
1823
+ if (codePoint < 128) {
1824
+ if ((units -= 1) < 0)
1825
+ break;
1826
+ bytes.push(codePoint);
1827
+ } else if (codePoint < 2048) {
1828
+ if ((units -= 2) < 0)
1829
+ break;
1830
+ bytes.push(
1831
+ codePoint >> 6 | 192,
1832
+ codePoint & 63 | 128
1833
+ );
1834
+ } else if (codePoint < 65536) {
1835
+ if ((units -= 3) < 0)
1836
+ break;
1837
+ bytes.push(
1838
+ codePoint >> 12 | 224,
1839
+ codePoint >> 6 & 63 | 128,
1840
+ codePoint & 63 | 128
1841
+ );
1842
+ } else if (codePoint < 1114112) {
1843
+ if ((units -= 4) < 0)
1844
+ break;
1845
+ bytes.push(
1846
+ codePoint >> 18 | 240,
1847
+ codePoint >> 12 & 63 | 128,
1848
+ codePoint >> 6 & 63 | 128,
1849
+ codePoint & 63 | 128
1850
+ );
1851
+ } else {
1852
+ throw new Error("Invalid code point");
1853
+ }
1854
+ }
1855
+ return bytes;
1856
+ }
1857
+ function asciiToBytes(str) {
1858
+ const byteArray = [];
1859
+ for (let i = 0; i < str.length; ++i) {
1860
+ byteArray.push(str.charCodeAt(i) & 255);
1861
+ }
1862
+ return byteArray;
1863
+ }
1864
+ function utf16leToBytes(str, units) {
1865
+ let c, hi, lo;
1866
+ const byteArray = [];
1867
+ for (let i = 0; i < str.length; ++i) {
1868
+ if ((units -= 2) < 0)
1869
+ break;
1870
+ c = str.charCodeAt(i);
1871
+ hi = c >> 8;
1872
+ lo = c % 256;
1873
+ byteArray.push(lo);
1874
+ byteArray.push(hi);
1875
+ }
1876
+ return byteArray;
1877
+ }
1878
+ function base64ToBytes(str) {
1879
+ return base64.toByteArray(base64clean(str));
1880
+ }
1881
+ function blitBuffer(src, dst, offset, length) {
1882
+ let i;
1883
+ for (i = 0; i < length; ++i) {
1884
+ if (i + offset >= dst.length || i >= src.length)
1885
+ break;
1886
+ dst[i + offset] = src[i];
1887
+ }
1888
+ return i;
1889
+ }
1890
+ function isInstance(obj, type) {
1891
+ return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name;
1892
+ }
1893
+ function numberIsNaN(obj) {
1894
+ return obj !== obj;
1895
+ }
1896
+ var hexSliceLookupTable = function() {
1897
+ const alphabet = "0123456789abcdef";
1898
+ const table = new Array(256);
1899
+ for (let i = 0; i < 16; ++i) {
1900
+ const i16 = i * 16;
1901
+ for (let j = 0; j < 16; ++j) {
1902
+ table[i16 + j] = alphabet[i] + alphabet[j];
1903
+ }
1904
+ }
1905
+ return table;
1906
+ }();
1907
+ function defineBigIntMethod(fn) {
1908
+ return typeof BigInt === "undefined" ? BufferBigIntNotDefined : fn;
1909
+ }
1910
+ function BufferBigIntNotDefined() {
1911
+ throw new Error("BigInt not supported");
1912
+ }
1913
+ }
1914
+ });
33
1915
 
34
1916
  // ../../node_modules/bn.js/lib/bn.js
35
1917
  var require_bn = __commonJS({
36
1918
  "../../node_modules/bn.js/lib/bn.js"(exports, module) {
37
1919
  (function(module2, exports2) {
38
- "use strict";
39
1920
  function assert(val, msg) {
40
1921
  if (!val)
41
1922
  throw new Error(msg || "Assertion failed");
@@ -76,7 +1957,7 @@ var require_bn = __commonJS({
76
1957
  if (typeof window !== "undefined" && typeof window.Buffer !== "undefined") {
77
1958
  Buffer2 = window.Buffer;
78
1959
  } else {
79
- Buffer2 = __require("buffer").Buffer;
1960
+ Buffer2 = require_buffer().Buffer;
80
1961
  }
81
1962
  } catch (e) {
82
1963
  }
@@ -1594,149 +3475,6 @@ var require_bn = __commonJS({
1594
3475
  }
1595
3476
  return res;
1596
3477
  };
1597
- function FFTM(x, y) {
1598
- this.x = x;
1599
- this.y = y;
1600
- }
1601
- FFTM.prototype.makeRBT = function makeRBT(N) {
1602
- var t = new Array(N);
1603
- var l = BN2.prototype._countBits(N) - 1;
1604
- for (var i = 0; i < N; i++) {
1605
- t[i] = this.revBin(i, l, N);
1606
- }
1607
- return t;
1608
- };
1609
- FFTM.prototype.revBin = function revBin(x, l, N) {
1610
- if (x === 0 || x === N - 1)
1611
- return x;
1612
- var rb = 0;
1613
- for (var i = 0; i < l; i++) {
1614
- rb |= (x & 1) << l - i - 1;
1615
- x >>= 1;
1616
- }
1617
- return rb;
1618
- };
1619
- FFTM.prototype.permute = function permute(rbt, rws, iws, rtws, itws, N) {
1620
- for (var i = 0; i < N; i++) {
1621
- rtws[i] = rws[rbt[i]];
1622
- itws[i] = iws[rbt[i]];
1623
- }
1624
- };
1625
- FFTM.prototype.transform = function transform(rws, iws, rtws, itws, N, rbt) {
1626
- this.permute(rbt, rws, iws, rtws, itws, N);
1627
- for (var s = 1; s < N; s <<= 1) {
1628
- var l = s << 1;
1629
- var rtwdf = Math.cos(2 * Math.PI / l);
1630
- var itwdf = Math.sin(2 * Math.PI / l);
1631
- for (var p = 0; p < N; p += l) {
1632
- var rtwdf_ = rtwdf;
1633
- var itwdf_ = itwdf;
1634
- for (var j = 0; j < s; j++) {
1635
- var re = rtws[p + j];
1636
- var ie = itws[p + j];
1637
- var ro = rtws[p + j + s];
1638
- var io = itws[p + j + s];
1639
- var rx = rtwdf_ * ro - itwdf_ * io;
1640
- io = rtwdf_ * io + itwdf_ * ro;
1641
- ro = rx;
1642
- rtws[p + j] = re + ro;
1643
- itws[p + j] = ie + io;
1644
- rtws[p + j + s] = re - ro;
1645
- itws[p + j + s] = ie - io;
1646
- if (j !== l) {
1647
- rx = rtwdf * rtwdf_ - itwdf * itwdf_;
1648
- itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;
1649
- rtwdf_ = rx;
1650
- }
1651
- }
1652
- }
1653
- }
1654
- };
1655
- FFTM.prototype.guessLen13b = function guessLen13b(n, m) {
1656
- var N = Math.max(m, n) | 1;
1657
- var odd = N & 1;
1658
- var i = 0;
1659
- for (N = N / 2 | 0; N; N = N >>> 1) {
1660
- i++;
1661
- }
1662
- return 1 << i + 1 + odd;
1663
- };
1664
- FFTM.prototype.conjugate = function conjugate(rws, iws, N) {
1665
- if (N <= 1)
1666
- return;
1667
- for (var i = 0; i < N / 2; i++) {
1668
- var t = rws[i];
1669
- rws[i] = rws[N - i - 1];
1670
- rws[N - i - 1] = t;
1671
- t = iws[i];
1672
- iws[i] = -iws[N - i - 1];
1673
- iws[N - i - 1] = -t;
1674
- }
1675
- };
1676
- FFTM.prototype.normalize13b = function normalize13b(ws, N) {
1677
- var carry = 0;
1678
- for (var i = 0; i < N / 2; i++) {
1679
- var w = Math.round(ws[2 * i + 1] / N) * 8192 + Math.round(ws[2 * i] / N) + carry;
1680
- ws[i] = w & 67108863;
1681
- if (w < 67108864) {
1682
- carry = 0;
1683
- } else {
1684
- carry = w / 67108864 | 0;
1685
- }
1686
- }
1687
- return ws;
1688
- };
1689
- FFTM.prototype.convert13b = function convert13b(ws, len, rws, N) {
1690
- var carry = 0;
1691
- for (var i = 0; i < len; i++) {
1692
- carry = carry + (ws[i] | 0);
1693
- rws[2 * i] = carry & 8191;
1694
- carry = carry >>> 13;
1695
- rws[2 * i + 1] = carry & 8191;
1696
- carry = carry >>> 13;
1697
- }
1698
- for (i = 2 * len; i < N; ++i) {
1699
- rws[i] = 0;
1700
- }
1701
- assert(carry === 0);
1702
- assert((carry & ~8191) === 0);
1703
- };
1704
- FFTM.prototype.stub = function stub(N) {
1705
- var ph = new Array(N);
1706
- for (var i = 0; i < N; i++) {
1707
- ph[i] = 0;
1708
- }
1709
- return ph;
1710
- };
1711
- FFTM.prototype.mulp = function mulp(x, y, out) {
1712
- var N = 2 * this.guessLen13b(x.length, y.length);
1713
- var rbt = this.makeRBT(N);
1714
- var _ = this.stub(N);
1715
- var rws = new Array(N);
1716
- var rwst = new Array(N);
1717
- var iwst = new Array(N);
1718
- var nrws = new Array(N);
1719
- var nrwst = new Array(N);
1720
- var niwst = new Array(N);
1721
- var rmws = out.words;
1722
- rmws.length = N;
1723
- this.convert13b(x.words, x.length, rws, N);
1724
- this.convert13b(y.words, y.length, nrws, N);
1725
- this.transform(rws, _, rwst, iwst, N, rbt);
1726
- this.transform(nrws, _, nrwst, niwst, N, rbt);
1727
- for (var i = 0; i < N; i++) {
1728
- var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];
1729
- iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];
1730
- rwst[i] = rx;
1731
- }
1732
- this.conjugate(rwst, iwst, N);
1733
- this.transform(rwst, iwst, rmws, _, N, rbt);
1734
- this.conjugate(rmws, _, N);
1735
- this.normalize13b(rmws, N);
1736
- out.negative = x.negative ^ y.negative;
1737
- out.length = x.length + y.length;
1738
- return out._strip();
1739
- };
1740
3478
  BN2.prototype.mul = function mul(num) {
1741
3479
  var out = new BN2(null);
1742
3480
  out.words = new Array(this.length + num.length);
@@ -1853,8 +3591,7 @@ var require_bn = __commonJS({
1853
3591
  }
1854
3592
  maskedWords.length = s;
1855
3593
  }
1856
- if (s === 0) {
1857
- } else if (this.length > s) {
3594
+ if (s === 0) ; else if (this.length > s) {
1858
3595
  this.length -= s;
1859
3596
  for (i = 0; i < this.length; i++) {
1860
3597
  this.words[i] = this.words[i + s];
@@ -2971,7 +4708,6 @@ var require_bn = __commonJS({
2971
4708
  // ../../node_modules/@layerzerolabs/lz-v2-utilities/node_modules/base-x/src/index.js
2972
4709
  var require_src = __commonJS({
2973
4710
  "../../node_modules/@layerzerolabs/lz-v2-utilities/node_modules/base-x/src/index.js"(exports, module) {
2974
- "use strict";
2975
4711
  function base2(ALPHABET) {
2976
4712
  if (ALPHABET.length >= 255) {
2977
4713
  throw new TypeError("Alphabet too long");
@@ -2993,8 +4729,7 @@ var require_src = __commonJS({
2993
4729
  var FACTOR = Math.log(BASE) / Math.log(256);
2994
4730
  var iFACTOR = Math.log(256) / Math.log(BASE);
2995
4731
  function encode(source) {
2996
- if (source instanceof Uint8Array) {
2997
- } else if (ArrayBuffer.isView(source)) {
4732
+ if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {
2998
4733
  source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
2999
4734
  } else if (Array.isArray(source)) {
3000
4735
  source = Uint8Array.from(source);
@@ -3113,12 +4848,6 @@ var require_bs58 = __commonJS({
3113
4848
  }
3114
4849
  });
3115
4850
 
3116
- // functions/getEthPrice.ts
3117
- import { sepolia } from "viem/chains";
3118
-
3119
- // functions/getTokenPrice.ts
3120
- import { TOKEMAK_SWAP_PRICING_URL } from "@tokemak/constants";
3121
-
3122
4851
  // functions/getDefillamaPrice.ts
3123
4852
  var getDefillamaPrice = async (tokenAddress) => {
3124
4853
  const response = await fetch(
@@ -3205,9 +4934,6 @@ var getEthPrice = async () => {
3205
4934
  }
3206
4935
  }
3207
4936
  };
3208
-
3209
- // functions/getTokePrice.ts
3210
- import { TOKE_TOKEN } from "@tokemak/tokenlist";
3211
4937
  var getTokePrice = async () => {
3212
4938
  try {
3213
4939
  return await getTokenPrice({ tokenAddress: TOKE_TOKEN.address });
@@ -3385,12 +5111,6 @@ function mergeStringArrays(keys, values) {
3385
5111
  }
3386
5112
  return result;
3387
5113
  }
3388
-
3389
- // utils/getChainsForEnv.ts
3390
- import {
3391
- SUPPORTED_DEV_CHAINS,
3392
- SUPPORTED_PROD_CHAINS
3393
- } from "@tokemak/constants";
3394
5114
  function getChainsForEnv({
3395
5115
  includeTestnet = false
3396
5116
  }) {
@@ -3407,14 +5127,6 @@ async function fetchChainDataMap(chains, fetchFn) {
3407
5127
  return acc;
3408
5128
  }, {});
3409
5129
  }
3410
-
3411
- // utils/aggregateSTokeRewardsDayData.ts
3412
- import { formatUnits } from "viem";
3413
- import {
3414
- convertTimestampToDate,
3415
- formatDateToReadable,
3416
- formatEtherNum
3417
- } from "@tokemak/utils";
3418
5130
  function aggregateSTokeRewardsDayData(dayDatas) {
3419
5131
  const byTs = {};
3420
5132
  for (const item of dayDatas) {
@@ -3449,12 +5161,6 @@ function aggregateSTokeRewardsDayData(dayDatas) {
3449
5161
  const result = Object.values(byTs).filter((day) => day.earned !== 0);
3450
5162
  return result;
3451
5163
  }
3452
-
3453
- // utils/getSTokeChainsForEnv.ts
3454
- import {
3455
- SUPPORTED_STOKE_DEV_CHAINS,
3456
- SUPPORTED_STOKE_PROD_CHAINS
3457
- } from "@tokemak/constants";
3458
5164
  function getSTokeChainsForEnv({
3459
5165
  includeTestnet = false
3460
5166
  }) {
@@ -3511,9 +5217,6 @@ var convertBaseAssetToTokenPricesAndDenom = (baseAsset, baseAssetPrice, denomPri
3511
5217
  denom: baseAsset * baseAssetToDenom
3512
5218
  };
3513
5219
  };
3514
-
3515
- // utils/getAutopoolInfo.ts
3516
- import { ALL_AUTOPOOLS } from "@tokemak/tokenlist";
3517
5220
  var getAutopoolInfo = (symbol) => {
3518
5221
  const autopool = ALL_AUTOPOOLS.find((pool) => pool.symbol === symbol);
3519
5222
  return autopool;
@@ -3585,9 +5288,6 @@ async function paginateQuery(queryFn, arrayKey, options = {}) {
3585
5288
  return results;
3586
5289
  }
3587
5290
 
3588
- // functions/getPoolsAndDestinationsBackup.ts
3589
- import { getNetwork } from "@tokemak/utils";
3590
-
3591
5291
  // functions/getBlobData.ts
3592
5292
  var getBlobData = async (blobName) => {
3593
5293
  try {
@@ -3620,17 +5320,6 @@ var getPoolsAndDestinationsBackup = async (chainId) => {
3620
5320
  }
3621
5321
  };
3622
5322
 
3623
- // functions/getChainAutopools.ts
3624
- import {
3625
- formatEtherNum as formatEtherNum2,
3626
- formatPoolName,
3627
- formatUnitsNum,
3628
- getNetwork as getNetwork3,
3629
- getProtocol,
3630
- getToken
3631
- } from "@tokemak/utils";
3632
- import { formatUnits as formatUnits2, getAddress } from "viem";
3633
-
3634
5323
  // constants/tokenOrders.ts
3635
5324
  var UITokenOrder = [
3636
5325
  "ETH",
@@ -3666,9 +5355,6 @@ var protocolOrder = [
3666
5355
  "Morpho",
3667
5356
  "Fluid"
3668
5357
  ];
3669
-
3670
- // functions/getGenStratAprs.ts
3671
- import { TOKEMAK_GENSTRAT_APRS_API_URL } from "@tokemak/constants";
3672
5358
  var getGenStratAprs = async ({
3673
5359
  chainId = 1
3674
5360
  }) => {
@@ -3700,25 +5386,6 @@ var getGenStratAprs = async ({
3700
5386
  return void 0;
3701
5387
  }
3702
5388
  };
3703
-
3704
- // functions/getChainAutopools.ts
3705
- import {
3706
- ALL_TOKENS,
3707
- BEETS_PROTOCOL,
3708
- ETH_TOKEN,
3709
- S_TOKEN,
3710
- WETH_TOKEN,
3711
- WS_TOKEN,
3712
- WXPL_TOKEN,
3713
- XPL_TOKEN
3714
- } from "@tokemak/tokenlist";
3715
- import { getSdkByChainId } from "@tokemak/graph-cli";
3716
- import { sonic } from "viem/chains";
3717
-
3718
- // functions/getPoolsAndDestinations.ts
3719
- import { getCoreConfig } from "@tokemak/config";
3720
- import { readContract } from "@wagmi/core";
3721
- import { lensAbi } from "@tokemak/abis";
3722
5389
  var getPoolsAndDestinations = async (wagmiConfig, { chainId }) => {
3723
5390
  try {
3724
5391
  const { lens } = getCoreConfig(chainId);
@@ -3738,12 +5405,9 @@ var getPoolsAndDestinations = async (wagmiConfig, { chainId }) => {
3738
5405
  console.error(`Error on ${chainId} in getPoolsAndDestinations:`, error);
3739
5406
  }
3740
5407
  };
3741
-
3742
- // functions/getBackupApr.ts
3743
- import { getNetwork as getNetwork2 } from "@tokemak/utils";
3744
5408
  var getBackupApr = async (chainId, poolAddress) => {
3745
5409
  try {
3746
- const networkName = getNetwork2(chainId)?.name.toLowerCase();
5410
+ const networkName = getNetwork(chainId)?.name.toLowerCase();
3747
5411
  const backupData = await getBlobData(
3748
5412
  `${networkName}-getChainAutopools-latest-success.json`
3749
5413
  );
@@ -3858,7 +5522,7 @@ var getChainAutopools = async (wagmiConfig, {
3858
5522
  ...destination,
3859
5523
  debtValueHeldByVaultUsd: debtValueHeldByVaultEth * baseAssetPrice,
3860
5524
  debtValueHeldByVaultEth,
3861
- compositeReturn: isGenStrat ? genStratAprs?.[autopool.poolAddress]?.[destination.vaultAddress]?.apr || 0 : formatEtherNum2(destination.compositeReturn),
5525
+ compositeReturn: isGenStrat ? genStratAprs?.[autopool.poolAddress]?.[destination.vaultAddress]?.apr || 0 : formatEtherNum(destination.compositeReturn),
3862
5526
  debtValueHeldByVaultAllocation: debtValueHeldByVaultEth / totalAssets,
3863
5527
  underlyingTokens,
3864
5528
  poolName: formatPoolName(destination.lpTokenName),
@@ -3942,10 +5606,10 @@ var getChainAutopools = async (wagmiConfig, {
3942
5606
  let baseApr = aprs?.currentApy;
3943
5607
  let boostedApr = 0;
3944
5608
  let extraApr = 0;
3945
- const formattedRewarder7DayMAApy = formatEtherNum2(
5609
+ const formattedRewarder7DayMAApy = formatEtherNum(
3946
5610
  BigInt(Number(aprs?.rewarder?.day7MAApy) || 0)
3947
5611
  );
3948
- const formattedRewarder30DayMAApy = formatEtherNum2(
5612
+ const formattedRewarder30DayMAApy = formatEtherNum(
3949
5613
  BigInt(Number(aprs?.rewarder?.day30MAApy) || 0)
3950
5614
  );
3951
5615
  if (formattedRewarder7DayMAApy > 0) {
@@ -3960,9 +5624,9 @@ var getChainAutopools = async (wagmiConfig, {
3960
5624
  }, 0);
3961
5625
  const periodicFeeBps = autopool.periodicFeeBps || 0n;
3962
5626
  const streamingFeeBps = autopool.streamingFeeBps || 0n;
3963
- baseApr = (weightedCrNum / (1 - totalIdleAssets / totalAssets) - Number(formatUnits2(periodicFeeBps, 4))) * (1 - Number(formatUnits2(streamingFeeBps, 4)));
5627
+ baseApr = (weightedCrNum / (1 - totalIdleAssets / totalAssets) - Number(formatUnits(periodicFeeBps, 4))) * (1 - Number(formatUnits(streamingFeeBps, 4)));
3964
5628
  } else {
3965
- baseApr = Number(formatUnits2(BigInt(baseApr), baseAsset.decimals));
5629
+ baseApr = Number(formatUnits(BigInt(baseApr), baseAsset.decimals));
3966
5630
  }
3967
5631
  if (!baseApr) {
3968
5632
  baseApr = 0;
@@ -3988,7 +5652,7 @@ var getChainAutopools = async (wagmiConfig, {
3988
5652
  const token = getToken(reward?.rewardToken?.id, chainId);
3989
5653
  return {
3990
5654
  ...token,
3991
- apr: formatEtherNum2(BigInt(reward.currentApy || 0))
5655
+ apr: formatEtherNum(BigInt(reward.currentApy || 0))
3992
5656
  };
3993
5657
  });
3994
5658
  }
@@ -4130,7 +5794,7 @@ var getChainAutopools = async (wagmiConfig, {
4130
5794
  });
4131
5795
  const autopoolInfo = getAutopoolInfo(autopool.symbol);
4132
5796
  if (autopoolInfo && !autopoolInfo.description) {
4133
- autopoolInfo.description = `Autopool featuring ${UIBaseAsset.symbol} deployed across integrated DEXs and lending protocols on ${getNetwork3(chainId)?.name}.`;
5797
+ autopoolInfo.description = `Autopool featuring ${UIBaseAsset.symbol} deployed across integrated DEXs and lending protocols on ${getNetwork(chainId)?.name}.`;
4134
5798
  }
4135
5799
  return {
4136
5800
  ...autopool,
@@ -4155,7 +5819,7 @@ var getChainAutopools = async (wagmiConfig, {
4155
5819
  UITokens,
4156
5820
  UIExchanges: finalUIExchanges,
4157
5821
  tokens: uniqueTokens,
4158
- chain: getNetwork3(chainId),
5822
+ chain: getNetwork(chainId),
4159
5823
  apr: {
4160
5824
  base: baseApr,
4161
5825
  boosted: boostedApr,
@@ -4185,10 +5849,6 @@ var getChainAutopools = async (wagmiConfig, {
4185
5849
  return [];
4186
5850
  }
4187
5851
  };
4188
-
4189
- // functions/getAutopools.ts
4190
- import { AUTOPOOLS_WHITELIST_PROD } from "@tokemak/config";
4191
- import { getAddress as getAddress2 } from "viem";
4192
5852
  var getAutopools = async (wagmiConfig, {
4193
5853
  prices,
4194
5854
  includeTestnet = false
@@ -4210,18 +5870,15 @@ var getAutopools = async (wagmiConfig, {
4210
5870
  return sortedAutopoolsByTimestamp;
4211
5871
  } else {
4212
5872
  return sortedAutopoolsByTimestamp.filter((pool) => {
4213
- return AUTOPOOLS_WHITELIST_PROD.includes(getAddress2(pool.poolAddress));
5873
+ return AUTOPOOLS_WHITELIST_PROD.includes(getAddress(pool.poolAddress));
4214
5874
  });
4215
5875
  }
4216
5876
  } catch (e) {
4217
5877
  console.error(e);
4218
5878
  }
4219
5879
  };
4220
-
4221
- // functions/getAutopoolRebalances.ts
4222
- import { getSdkByChainId as getSdkByChainId2 } from "@tokemak/graph-cli";
4223
5880
  var getAutopoolRebalances = async (id, chainId = 1, options) => {
4224
- const { GetAutopoolRebalances } = getSdkByChainId2(chainId);
5881
+ const { GetAutopoolRebalances } = getSdkByChainId(chainId);
4225
5882
  const first = options?.first ?? 1e3;
4226
5883
  const maxPages = options?.maxPages ?? 100;
4227
5884
  const queryFn = ({ first: first2, skip }) => GetAutopoolRebalances({ address: id, first: first2, skip });
@@ -4236,23 +5893,14 @@ var getAutopoolRebalances = async (id, chainId = 1, options) => {
4236
5893
  ix: length - index
4237
5894
  }));
4238
5895
  };
4239
-
4240
- // functions/getAutopoolsRebalances.ts
4241
- import { getSdkByChainId as getSdkByChainId3 } from "@tokemak/graph-cli";
4242
5896
  var getAutopoolsRebalances = async (chainId = 1) => {
4243
- const { GetAutopoolsRebalances } = getSdkByChainId3(chainId);
5897
+ const { GetAutopoolsRebalances } = getSdkByChainId(chainId);
4244
5898
  const { autopools } = await GetAutopoolsRebalances();
4245
5899
  const rebalances = autopools.map(({ rebalances: rebalances2 }) => rebalances2);
4246
5900
  return rebalances.flat().sort((a, b) => b.timestamp - a.timestamp);
4247
5901
  };
4248
-
4249
- // functions/getAutopoolsHistory.ts
4250
- import { getAddress as getAddress3 } from "viem";
4251
-
4252
- // functions/getAutopoolsDayData.ts
4253
- import { getSdkByChainId as getSdkByChainId4 } from "@tokemak/graph-cli";
4254
5902
  var getAutopoolsDayData = async (chainId, timestamp) => {
4255
- const { GetAutopoolsDayData } = getSdkByChainId4(chainId);
5903
+ const { GetAutopoolsDayData } = getSdkByChainId(chainId);
4256
5904
  const PAGE_SIZE = 1e3;
4257
5905
  let allResults = [];
4258
5906
  let hasMore = true;
@@ -4309,7 +5957,7 @@ var getAutopoolsHistory = async (autopools, days, includeTestnet = false) => {
4309
5957
  ...data,
4310
5958
  date: new Date(data.timestamp * 1e3),
4311
5959
  baseAsset: autopools.find(
4312
- (pool) => getAddress3(pool.poolAddress) === getAddress3(vaultId)
5960
+ (pool) => getAddress(pool.poolAddress) === getAddress(vaultId)
4313
5961
  )?.baseAsset
4314
5962
  });
4315
5963
  }
@@ -4327,10 +5975,6 @@ var getAutopoolsHistory = async (autopools, days, includeTestnet = false) => {
4327
5975
  console.log(e);
4328
5976
  }
4329
5977
  };
4330
-
4331
- // functions/getCurveLP.ts
4332
- import { getMainnetConfig } from "@tokemak/config";
4333
- import { CURVE_API_URL, TOKE_CURVE_POOL_ID } from "@tokemak/constants";
4334
5978
  var getCurveLP = async () => {
4335
5979
  let curveData;
4336
5980
  const { curveRewardsUrl } = getMainnetConfig();
@@ -4361,15 +6005,8 @@ var getCurveLP = async () => {
4361
6005
  }
4362
6006
  return curveData;
4363
6007
  };
4364
-
4365
- // functions/getSushiLP.ts
4366
- import { sushiPoolAbi } from "@tokemak/abis";
4367
- import { getMainnetConfig as getMainnetConfig2 } from "@tokemak/config";
4368
- import { readContracts } from "@wagmi/core";
4369
- import { formatEther } from "viem";
4370
- import { mainnet } from "viem/chains";
4371
6008
  var getSushiLP = async (wagmiConfig, { ethPrice }) => {
4372
- const { sushiPool, lpRewardsV1Url } = getMainnetConfig2();
6009
+ const { sushiPool, lpRewardsV1Url } = getMainnetConfig();
4373
6010
  const sushiPoolContract = {
4374
6011
  address: sushiPool,
4375
6012
  abi: sushiPoolAbi
@@ -4415,11 +6052,8 @@ var getSushiLP = async (wagmiConfig, { ethPrice }) => {
4415
6052
  console.log(e);
4416
6053
  }
4417
6054
  };
4418
-
4419
- // functions/getChainUserActivity.ts
4420
- import { getSdkByChainId as getSdkByChainId5 } from "@tokemak/graph-cli";
4421
6055
  var getChainUserActivity = async (address, chainId = 1) => {
4422
- const { GetUserBalanceChangeHistory } = getSdkByChainId5(chainId);
6056
+ const { GetUserBalanceChangeHistory } = getSdkByChainId(chainId);
4423
6057
  try {
4424
6058
  const { userAutopoolBalanceChanges } = await GetUserBalanceChangeHistory({
4425
6059
  userAddress: address
@@ -4486,11 +6120,6 @@ var getRewardsPayloadV1 = async (cycleHash, account, rewardsV1Url) => {
4486
6120
  return null;
4487
6121
  }
4488
6122
  };
4489
-
4490
- // functions/getUserAutoEthRewards.ts
4491
- import { autoEthRewardsHashAbi } from "@tokemak/abis";
4492
- import { readContract as readContract2 } from "@wagmi/core";
4493
- import { convertChainCycleToUnix, formatCurrency } from "@tokemak/utils";
4494
6123
  var getAutoEthRewards = async (wagmiConfig, {
4495
6124
  account,
4496
6125
  currentCycleIndex,
@@ -4499,14 +6128,14 @@ var getAutoEthRewards = async (wagmiConfig, {
4499
6128
  chainId
4500
6129
  }) => {
4501
6130
  try {
4502
- const [, drippingHash] = await readContract2(wagmiConfig, {
6131
+ const [, drippingHash] = await readContract(wagmiConfig, {
4503
6132
  address: rewardsHash,
4504
6133
  abi: autoEthRewardsHashAbi,
4505
6134
  functionName: "cycleHashes",
4506
6135
  args: [currentCycleIndex - 306n],
4507
6136
  chainId
4508
6137
  });
4509
- const [, lastWeekHash] = await readContract2(wagmiConfig, {
6138
+ const [, lastWeekHash] = await readContract(wagmiConfig, {
4510
6139
  address: rewardsHash,
4511
6140
  abi: autoEthRewardsHashAbi,
4512
6141
  functionName: "cycleHashes",
@@ -4554,10 +6183,6 @@ var getUserAutoEthRewards = async (wagmiConfig, rewardsV1Url, rewardsHash, addre
4554
6183
  );
4555
6184
  return { ...autoETHRewards, currentUserRewardsUsd };
4556
6185
  };
4557
-
4558
- // functions/getUserRewardsV1.ts
4559
- import { rewardsV1Abi, rewardsV1HashAbi } from "@tokemak/abis";
4560
- import { readContract as readContract3 } from "@wagmi/core";
4561
6186
  var getUserRewardsV1 = async (wagmiConfig, {
4562
6187
  address,
4563
6188
  rewardsCycleIndex,
@@ -4567,7 +6192,7 @@ var getUserRewardsV1 = async (wagmiConfig, {
4567
6192
  chainId
4568
6193
  }) => {
4569
6194
  try {
4570
- const [latestClaimableHash, cycleRewardsHash] = await readContract3(
6195
+ const [latestClaimableHash, cycleRewardsHash] = await readContract(
4571
6196
  wagmiConfig,
4572
6197
  {
4573
6198
  address: rewardsV1Hash,
@@ -4591,7 +6216,7 @@ var getUserRewardsV1 = async (wagmiConfig, {
4591
6216
  const {
4592
6217
  payload: { chainId: payloadChainId, cycle, wallet, amount }
4593
6218
  } = latestClaimablePayload;
4594
- const claimable = await readContract3(wagmiConfig, {
6219
+ const claimable = await readContract(wagmiConfig, {
4595
6220
  address: rewardsV1,
4596
6221
  abi: rewardsV1Abi,
4597
6222
  functionName: "getClaimableAmount",
@@ -4605,12 +6230,6 @@ var getUserRewardsV1 = async (wagmiConfig, {
4605
6230
  console.log(e);
4606
6231
  }
4607
6232
  };
4608
-
4609
- // functions/getUserV1.ts
4610
- import { rewardsV1Abi as rewardsV1Abi2, stakingV1Abi } from "@tokemak/abis";
4611
- import { readContract as readContract4 } from "@wagmi/core";
4612
- import { getMainnetConfig as getMainnetConfig3 } from "@tokemak/config";
4613
- import { mainnet as mainnet2 } from "viem/chains";
4614
6233
  var getUserV1 = async (wagmiConfig, {
4615
6234
  currentCycleIndex,
4616
6235
  address,
@@ -4625,14 +6244,14 @@ var getUserV1 = async (wagmiConfig, {
4625
6244
  autoEthGuardedRewards,
4626
6245
  rewardsV1,
4627
6246
  missedTokeRewards
4628
- } = getMainnetConfig3(mainnet2.id);
6247
+ } = getMainnetConfig(mainnet.id);
4629
6248
  try {
4630
- const userStakedTokeV1 = await readContract4(wagmiConfig, {
6249
+ const userStakedTokeV1 = await readContract(wagmiConfig, {
4631
6250
  address: stakingV1,
4632
6251
  abi: stakingV1Abi,
4633
6252
  functionName: "availableForWithdrawal",
4634
6253
  args: [address, 0n],
4635
- chainId: mainnet2.id
6254
+ chainId: mainnet.id
4636
6255
  });
4637
6256
  const tokeRewards = await getUserRewardsV1(wagmiConfig, {
4638
6257
  address,
@@ -4659,9 +6278,9 @@ var getUserV1 = async (wagmiConfig, {
4659
6278
  const cycle = autoEthGuardedRewardsPayload?.payload?.cycle;
4660
6279
  const wallet = autoEthGuardedRewardsPayload?.payload?.wallet;
4661
6280
  const amount = autoEthGuardedRewardsPayload?.payload?.amount;
4662
- const claimableAutoEth = await readContract4(wagmiConfig, {
6281
+ const claimableAutoEth = await readContract(wagmiConfig, {
4663
6282
  address: autoEthGuardedRewards,
4664
- abi: rewardsV1Abi2,
6283
+ abi: rewardsV1Abi,
4665
6284
  functionName: "getClaimableAmount",
4666
6285
  args: [
4667
6286
  {
@@ -4683,9 +6302,9 @@ var getUserV1 = async (wagmiConfig, {
4683
6302
  const {
4684
6303
  payload: { chainId: payloadChainId2, cycle: cycle2, wallet: wallet2, amount: amount2 }
4685
6304
  } = missedTokeRewardsPayload;
4686
- claimableMissedToke = await readContract4(wagmiConfig, {
6305
+ claimableMissedToke = await readContract(wagmiConfig, {
4687
6306
  address: missedTokeRewards,
4688
- abi: rewardsV1Abi2,
6307
+ abi: rewardsV1Abi,
4689
6308
  functionName: "getClaimableAmount",
4690
6309
  args: [
4691
6310
  {
@@ -4712,14 +6331,11 @@ var getUserV1 = async (wagmiConfig, {
4712
6331
  } catch (e) {
4713
6332
  }
4714
6333
  };
4715
-
4716
- // functions/getChainUserAutopoolsHistory.tsx
4717
- import { getSdkByChainId as getSdkByChainId6 } from "@tokemak/graph-cli";
4718
6334
  var getChainUserAutopoolsHistory = async ({
4719
6335
  address,
4720
6336
  chainId = 1
4721
6337
  }) => {
4722
- const { GetUserVaultsDayData } = getSdkByChainId6(chainId);
6338
+ const { GetUserVaultsDayData } = getSdkByChainId(chainId);
4723
6339
  const oneYearAgoTimestamp = Math.floor(Date.now() / 1e3) - 365 * 24 * 60 * 60;
4724
6340
  try {
4725
6341
  if (address) {
@@ -4735,30 +6351,17 @@ var getChainUserAutopoolsHistory = async ({
4735
6351
  return [];
4736
6352
  }
4737
6353
  };
4738
-
4739
- // functions/getUserAutopoolsHistory.ts
4740
- import {
4741
- formatDateToReadable as formatDateToReadable2,
4742
- formatEtherNum as formatEtherNum3,
4743
- formatUnitsNum as formatUnitsNum2
4744
- } from "@tokemak/utils";
4745
-
4746
- // functions/getTokenValueDayDatas.ts
4747
- import { mainnet as mainnet3 } from "viem/chains";
4748
- import { convertTimestampToDate as convertTimestampToDate2 } from "@tokemak/utils";
4749
- import { formatUnits as formatUnits3 } from "viem";
4750
- import { getSdkByChainId as getSdkByChainId7 } from "@tokemak/graph-cli";
4751
- var getTokenValueDayDatas = async (tokenAddress, chainId = mainnet3.id) => {
4752
- const { GetTokenValueDayDatas } = getSdkByChainId7(chainId);
6354
+ var getTokenValueDayDatas = async (tokenAddress, chainId = mainnet.id) => {
6355
+ const { GetTokenValueDayDatas } = getSdkByChainId(chainId);
4753
6356
  try {
4754
6357
  const { tokenValueDayDatas } = await GetTokenValueDayDatas({
4755
6358
  tokenAddress: tokenAddress.toLowerCase()
4756
6359
  });
4757
6360
  const historicalPrice = tokenValueDayDatas.map((tokenValueDayData) => {
4758
- const date = convertTimestampToDate2(
6361
+ const date = convertTimestampToDate(
4759
6362
  tokenValueDayData.lastSnapshotTimestamp
4760
6363
  );
4761
- const usdPrice = formatUnits3(tokenValueDayData.priceInUsd, 8);
6364
+ const usdPrice = formatUnits(tokenValueDayData.priceInUsd, 8);
4762
6365
  return {
4763
6366
  timestamp: Number(tokenValueDayData.lastSnapshotTimestamp),
4764
6367
  date,
@@ -4771,25 +6374,6 @@ var getTokenValueDayDatas = async (tokenAddress, chainId = mainnet3.id) => {
4771
6374
  }
4772
6375
  };
4773
6376
 
4774
- // functions/getTokenPrices.ts
4775
- import {
4776
- ETH_TOKEN as ETH_TOKEN2,
4777
- PXETH_TOKEN,
4778
- TOKE_TOKEN as TOKE_TOKEN2,
4779
- USDC_TOKEN,
4780
- S_TOKEN as S_TOKEN2,
4781
- DOLA_TOKEN,
4782
- WETH_TOKEN as WETH_TOKEN2,
4783
- WS_TOKEN as WS_TOKEN2,
4784
- EURC_TOKEN,
4785
- SILO_TOKEN,
4786
- WXPL_TOKEN as WXPL_TOKEN2,
4787
- USDT_TOKEN,
4788
- XPL_TOKEN as XPL_TOKEN2,
4789
- USDT0_TOKEN
4790
- } from "@tokemak/tokenlist";
4791
- import { TOKEMAK_PRICES_STAGING_URL } from "@tokemak/constants";
4792
-
4793
6377
  // functions/getBackupTokenPrices.ts
4794
6378
  var getBackupTokenPrices = async () => {
4795
6379
  try {
@@ -4806,26 +6390,26 @@ var getBackupTokenPrices = async () => {
4806
6390
 
4807
6391
  // functions/getTokenPrices.ts
4808
6392
  var BASE_ASSETS = [
4809
- { ...ETH_TOKEN2, symbol: "ETH", coinGeckoId: "ethereum" },
6393
+ { ...ETH_TOKEN, symbol: "ETH", coinGeckoId: "ethereum" },
4810
6394
  { ...PXETH_TOKEN, symbol: "PXETH", coinGeckoId: "dinero-staked-eth" },
4811
6395
  { ...USDC_TOKEN, symbol: "USDC", coinGeckoId: "usd-coin" },
4812
6396
  { ...DOLA_TOKEN, symbol: "DOLA", coinGeckoId: "dola-usd" },
4813
- { ...S_TOKEN2, symbol: "S" },
6397
+ { ...S_TOKEN, symbol: "S" },
4814
6398
  { ...EURC_TOKEN, symbol: "EURC", coinGeckoId: "euro-coin" },
4815
6399
  { ...USDT_TOKEN, symbol: "USDT", coinGeckoId: "tether" },
4816
6400
  { ...USDT0_TOKEN, symbol: "USDT0", coinGeckoId: "tether" }
4817
6401
  ];
4818
6402
  var PRICED_TOKENS = [
4819
6403
  ...BASE_ASSETS,
4820
- { ...TOKE_TOKEN2, symbol: "TOKE" },
6404
+ { ...TOKE_TOKEN, symbol: "TOKE" },
4821
6405
  { ...SILO_TOKEN, symbol: "SILO" },
4822
- { ...XPL_TOKEN2, address: WXPL_TOKEN2.address, symbol: "XPL" },
6406
+ { ...XPL_TOKEN, address: WXPL_TOKEN.address, symbol: "XPL" },
4823
6407
  { ...USDT0_TOKEN, symbol: "USDT0" }
4824
6408
  ];
4825
- var WRAPPED_TOKENS = [
4826
- { ...WETH_TOKEN2, symbol: "WETH" },
4827
- { ...WS_TOKEN2, symbol: "WS" },
4828
- { ...WXPL_TOKEN2, symbol: "WXPL" }
6409
+ [
6410
+ { ...WETH_TOKEN, symbol: "WETH" },
6411
+ { ...WS_TOKEN, symbol: "WS" },
6412
+ { ...WXPL_TOKEN, symbol: "WXPL" }
4829
6413
  ];
4830
6414
  var isStale = (timestamp) => {
4831
6415
  return timestamp - Math.floor(Date.now() / 1e3) > 5 * 60;
@@ -4890,9 +6474,6 @@ var getTokenPrices = async (isCronJob = false) => {
4890
6474
  }
4891
6475
  }
4892
6476
  };
4893
-
4894
- // functions/getHistoricalTokenPrices.ts
4895
- import { ETH_TOKEN as ETH_TOKEN3 } from "@tokemak/tokenlist";
4896
6477
  var hasCoinGeckoId = (asset) => typeof asset?.coinGeckoId === "string" && asset.coinGeckoId.length > 0;
4897
6478
  var getBlobHistoricalTokenPrices = async (tokenSymbol) => {
4898
6479
  const blobName = `historical_v2/${tokenSymbol}-latest-success.json`;
@@ -4910,7 +6491,7 @@ var getHistoricalTokenPrices = async () => {
4910
6491
  const historicalBaseAssetPrices = await Promise.all(
4911
6492
  BASE_ASSETS.map(async (baseAsset) => {
4912
6493
  if (!hasCoinGeckoId(baseAsset)) {
4913
- const address = baseAsset.address === ETH_TOKEN3.address ? ETH_ADDRESS_IN_SUBGRAPH : baseAsset.address;
6494
+ const address = baseAsset.address === ETH_TOKEN.address ? ETH_ADDRESS_IN_SUBGRAPH : baseAsset.address;
4914
6495
  const prices2 = await getTokenValueDayDatas(
4915
6496
  address,
4916
6497
  baseAsset.chainId
@@ -5038,7 +6619,7 @@ var getUserAutopoolsHistory = async (address, autopoolsHistory, events, includeT
5038
6619
  Math.floor(sharesRatio * Number(SCALE))
5039
6620
  );
5040
6621
  const navBigInt = sharesRatioBigInt * BigInt(dayData.nav) / SCALE;
5041
- const navNum = formatUnitsNum2(
6622
+ const navNum = formatUnitsNum(
5042
6623
  navBigInt,
5043
6624
  dayData.baseAsset.decimals
5044
6625
  );
@@ -5109,7 +6690,7 @@ var getUserAutopoolsHistory = async (address, autopoolsHistory, events, includeT
5109
6690
  let finalAggregatedHistoryArray = Object.keys(aggregatedHistoryArray).map(
5110
6691
  (dateKey) => ({
5111
6692
  date: aggregatedHistoryArray[dateKey].date,
5112
- formattedDate: formatDateToReadable2(aggregatedHistoryArray[dateKey].date),
6693
+ formattedDate: formatDateToReadable(aggregatedHistoryArray[dateKey].date),
5113
6694
  nav: {
5114
6695
  ETH: aggregatedHistoryArray[dateKey].nav.ETH,
5115
6696
  USD: aggregatedHistoryArray[dateKey].nav.USD,
@@ -5144,7 +6725,7 @@ var getUserAutopoolsHistory = async (address, autopoolsHistory, events, includeT
5144
6725
  return eventDate.getTime() >= dayData.date.getTime() && eventDate.getTime() < dayData.date.getTime() + 24 * 60 * 60 * 1e3;
5145
6726
  });
5146
6727
  const differential = eventsForDay.reduce(
5147
- (sum, event) => sum + formatEtherNum3(BigInt(event?.assetChange || 0n)),
6728
+ (sum, event) => sum + formatEtherNum(BigInt(event?.assetChange || 0n)),
5148
6729
  0
5149
6730
  );
5150
6731
  return {
@@ -5163,11 +6744,6 @@ var getUserAutopoolsHistory = async (address, autopoolsHistory, events, includeT
5163
6744
  }
5164
6745
  return result;
5165
6746
  };
5166
-
5167
- // functions/getUserSushiLP.ts
5168
- import { readContracts as readContracts2 } from "@wagmi/core";
5169
- import { poolV1Abi, sushiPoolAbi as sushiPoolAbi2 } from "@tokemak/abis";
5170
- import { getMainnetConfig as getMainnetConfig4 } from "@tokemak/config";
5171
6747
  var getUserSushiLP = async (wagmiConfig, {
5172
6748
  sushiLP,
5173
6749
  currentCycleIndex,
@@ -5175,18 +6751,18 @@ var getUserSushiLP = async (wagmiConfig, {
5175
6751
  cycleRolloverBlockNumber,
5176
6752
  chainId
5177
6753
  }) => {
5178
- const { tSushiLP, sushiPool } = getMainnetConfig4();
6754
+ const { tSushiLP, sushiPool } = getMainnetConfig();
5179
6755
  try {
5180
6756
  if (address && currentCycleIndex && sushiLP) {
5181
6757
  const [
5182
6758
  { result: sushiLPBalance },
5183
6759
  { result: tSushiLPBalance },
5184
6760
  { result: tSushiLPRequested }
5185
- ] = await readContracts2(wagmiConfig, {
6761
+ ] = await readContracts(wagmiConfig, {
5186
6762
  contracts: [
5187
6763
  {
5188
6764
  address: sushiPool,
5189
- abi: sushiPoolAbi2,
6765
+ abi: sushiPoolAbi,
5190
6766
  functionName: "balanceOf",
5191
6767
  args: [address],
5192
6768
  chainId
@@ -5210,7 +6786,7 @@ var getUserSushiLP = async (wagmiConfig, {
5210
6786
  const [
5211
6787
  { result: startTSushiLPBalance },
5212
6788
  { result: startTSushiLPRequested }
5213
- ] = await readContracts2(wagmiConfig, {
6789
+ ] = await readContracts(wagmiConfig, {
5214
6790
  contracts: [
5215
6791
  {
5216
6792
  address: tSushiLP,
@@ -5262,31 +6838,26 @@ var getUserSushiLP = async (wagmiConfig, {
5262
6838
  console.log(e);
5263
6839
  }
5264
6840
  };
5265
-
5266
- // functions/getUserCurveLP.ts
5267
- import { readContracts as readContracts3 } from "@wagmi/core";
5268
- import { poolV1Abi as poolV1Abi2 } from "@tokemak/abis";
5269
- import { getMainnetConfig as getMainnetConfig5 } from "@tokemak/config";
5270
6841
  var getUserCurveLP = async (wagmiConfig, {
5271
6842
  curveLP,
5272
6843
  address,
5273
6844
  chainId
5274
6845
  }) => {
5275
6846
  try {
5276
- const { curvePool, convexRewarder } = getMainnetConfig5();
6847
+ const { curvePool, convexRewarder } = getMainnetConfig();
5277
6848
  if (address && curveLP && curvePool && convexRewarder) {
5278
- const [{ result: userCurveLPBalance }, { result: userConvexLPBalance }] = await readContracts3(wagmiConfig, {
6849
+ const [{ result: userCurveLPBalance }, { result: userConvexLPBalance }] = await readContracts(wagmiConfig, {
5279
6850
  contracts: [
5280
6851
  {
5281
6852
  address: curvePool,
5282
- abi: poolV1Abi2,
6853
+ abi: poolV1Abi,
5283
6854
  functionName: "balanceOf",
5284
6855
  args: [address],
5285
6856
  chainId
5286
6857
  },
5287
6858
  {
5288
6859
  address: convexRewarder,
5289
- abi: poolV1Abi2,
6860
+ abi: poolV1Abi,
5290
6861
  functionName: "balanceOf",
5291
6862
  args: [address],
5292
6863
  chainId
@@ -5310,26 +6881,17 @@ var getUserCurveLP = async (wagmiConfig, {
5310
6881
  console.log(e);
5311
6882
  }
5312
6883
  };
5313
-
5314
- // functions/getMultipleAutopoolRebalances.ts
5315
- import { getSdkByChainId as getSdkByChainId8 } from "@tokemak/graph-cli";
5316
6884
  var getMutlipleAutopoolRebalances = async (ids, chainId = 1) => {
5317
- const { GetMutlipleAutopoolRebalances } = getSdkByChainId8(chainId);
6885
+ const { GetMutlipleAutopoolRebalances } = getSdkByChainId(chainId);
5318
6886
  const { autopools } = await GetMutlipleAutopoolRebalances({
5319
6887
  addresses: ids
5320
6888
  });
5321
6889
  const rebalances = autopools.map(({ rebalances: rebalances2 }) => rebalances2);
5322
6890
  return rebalances.flat().sort((a, b) => b.timestamp - a.timestamp);
5323
6891
  };
5324
-
5325
- // functions/getAutopoolDayData.ts
5326
- import { formatUnits as formatUnits4 } from "viem";
5327
- import { formatEtherNum as formatEtherNum4 } from "@tokemak/utils";
5328
- import { TOKEMAK_LAUNCH_TIMESTAMP } from "@tokemak/constants";
5329
- import { getSdkByChainId as getSdkByChainId9 } from "@tokemak/graph-cli";
5330
6892
  var getAutopoolDayData = async (address, chainId = 1, startTimestamp = TOKEMAK_LAUNCH_TIMESTAMP) => {
5331
6893
  try {
5332
- const { GetAutopoolDayData } = getSdkByChainId9(chainId);
6894
+ const { GetAutopoolDayData } = getSdkByChainId(chainId);
5333
6895
  const { autopoolDayDatas } = await GetAutopoolDayData({
5334
6896
  address,
5335
6897
  timestamp: startTimestamp
@@ -5338,10 +6900,10 @@ var getAutopoolDayData = async (address, chainId = 1, startTimestamp = TOKEMAK_L
5338
6900
  const navPerShare = autoPoolDayData.nav / autoPoolDayData.totalSupply;
5339
6901
  let baseApy = autoPoolDayData.autopoolApy;
5340
6902
  let rewarderApy = 0;
5341
- const formattedRewarder7DayMAApy = formatEtherNum4(
6903
+ const formattedRewarder7DayMAApy = formatEtherNum(
5342
6904
  BigInt(Number(autoPoolDayData.rewarderDay7MAApy) || 0)
5343
6905
  );
5344
- const formattedRewarder30DayMAApy = formatEtherNum4(
6906
+ const formattedRewarder30DayMAApy = formatEtherNum(
5345
6907
  BigInt(Number(autoPoolDayData.rewarderDay30MAApy) || 0)
5346
6908
  );
5347
6909
  if (formattedRewarder7DayMAApy) {
@@ -5354,7 +6916,7 @@ var getAutopoolDayData = async (address, chainId = 1, startTimestamp = TOKEMAK_L
5354
6916
  baseApy = 0;
5355
6917
  } else {
5356
6918
  baseApy = Number(
5357
- formatUnits4(BigInt(baseApy), autoPoolDayData.baseAsset.decimals)
6919
+ formatUnits(BigInt(baseApy), autoPoolDayData.baseAsset.decimals)
5358
6920
  );
5359
6921
  }
5360
6922
  if (baseApy < 0) {
@@ -5377,10 +6939,6 @@ var getAutopoolDayData = async (address, chainId = 1, startTimestamp = TOKEMAK_L
5377
6939
  return [];
5378
6940
  }
5379
6941
  };
5380
-
5381
- // functions/getSystemConfig.ts
5382
- import { readContracts as readContracts4 } from "@wagmi/core";
5383
- import { systemRegistryAbi } from "@tokemak/abis";
5384
6942
  var systemRegistryFunctionNames = [
5385
6943
  "asyncSwapperRegistry",
5386
6944
  "autoPoolRouter",
@@ -5405,7 +6963,7 @@ var getSystemConfig = async (wagmiConfig, { systemRegistry }) => {
5405
6963
  { result: autopoolRouter },
5406
6964
  { result: autopoolRegistry },
5407
6965
  { result: swapRouter }
5408
- ] = await readContracts4(wagmiConfig, {
6966
+ ] = await readContracts(wagmiConfig, {
5409
6967
  contracts: systemRegistryCalls
5410
6968
  });
5411
6969
  return {
@@ -5418,14 +6976,11 @@ var getSystemConfig = async (wagmiConfig, { systemRegistry }) => {
5418
6976
  console.log(e);
5419
6977
  }
5420
6978
  };
5421
-
5422
- // functions/getChainUserAutopools.tsx
5423
- import { getSdkByChainId as getSdkByChainId10 } from "@tokemak/graph-cli";
5424
6979
  var getChainUserAutopools = async ({
5425
6980
  address,
5426
6981
  chainId = 1
5427
6982
  }) => {
5428
- const { GetUserVaultInfo } = getSdkByChainId10(chainId);
6983
+ const { GetUserVaultInfo } = getSdkByChainId(chainId);
5429
6984
  try {
5430
6985
  if (address) {
5431
6986
  const { userInfo } = await GetUserVaultInfo({
@@ -5439,20 +6994,6 @@ var getChainUserAutopools = async ({
5439
6994
  return [];
5440
6995
  }
5441
6996
  };
5442
-
5443
- // functions/getUserAutopools.ts
5444
- import {
5445
- convertTimestampToDate as convertTimestampToDate3,
5446
- formatEtherNum as formatEtherNum6,
5447
- formatUnitsNum as formatUnitsNum3
5448
- } from "@tokemak/utils";
5449
- import { ETH_TOKEN as ETH_TOKEN4 } from "@tokemak/tokenlist";
5450
-
5451
- // functions/getUserAutopool.tsx
5452
- import { erc20Abi } from "viem";
5453
- import { readContract as readContract5, readContracts as readContracts5 } from "@wagmi/core";
5454
- import { formatEtherNum as formatEtherNum5 } from "@tokemak/utils";
5455
- import { autopoolEthAbi } from "@tokemak/abis";
5456
6997
  var getUserAutopool = async (wagmiConfig, {
5457
6998
  address,
5458
6999
  autopool
@@ -5468,7 +7009,7 @@ var getUserAutopool = async (wagmiConfig, {
5468
7009
  { result: autopoolRewarderContract },
5469
7010
  { result: pastRewarders },
5470
7011
  { result: unstakedPoolShares, error: unstakedPoolSharesError }
5471
- ] = await readContracts5(wagmiConfig, {
7012
+ ] = await readContracts(wagmiConfig, {
5472
7013
  contracts: [
5473
7014
  {
5474
7015
  ...autopoolContract,
@@ -5493,17 +7034,17 @@ var getUserAutopool = async (wagmiConfig, {
5493
7034
  if (unstakedPoolSharesError) {
5494
7035
  throw new Error("Error fetching unstaked pool shares");
5495
7036
  }
5496
- const stakedPoolShares = await readContract5(wagmiConfig, {
7037
+ const stakedPoolShares = await readContract(wagmiConfig, {
5497
7038
  address: autopoolRewarderContract,
5498
7039
  abi: erc20Abi,
5499
7040
  functionName: "balanceOf",
5500
7041
  args: [address],
5501
7042
  chainId: autopool?.chain?.chainId
5502
7043
  });
5503
- const stakedShares = formatEtherNum5(stakedPoolShares);
7044
+ const stakedShares = formatEtherNum(stakedPoolShares);
5504
7045
  const stakedNav = stakedShares * (autopool?.navPerShare.baseAsset || 0);
5505
7046
  const stakedNavUsd = stakedShares * (autopool?.navPerShare.USD || 0);
5506
- const unstakedShares = formatEtherNum5(unstakedPoolShares || 0n);
7047
+ const unstakedShares = formatEtherNum(unstakedPoolShares || 0n);
5507
7048
  const unstakedNav = unstakedShares * (autopool?.navPerShare.USD || 0);
5508
7049
  const unstakedNavUsd = unstakedShares * (autopool?.navPerShare.USD || 0);
5509
7050
  const totalShares = unstakedShares + stakedShares;
@@ -5519,12 +7060,12 @@ var getUserAutopool = async (wagmiConfig, {
5519
7060
  args: [address],
5520
7061
  chainId: autopool?.chain?.chainId
5521
7062
  }));
5522
- const pastRewards = await readContracts5(wagmiConfig, {
7063
+ const pastRewards = await readContracts(wagmiConfig, {
5523
7064
  contracts: pastRewardBalances
5524
7065
  });
5525
7066
  pastRewarderBalances = pastRewards.map(({ result }, index) => {
5526
7067
  const balance = result;
5527
- const shares = formatEtherNum5(result);
7068
+ const shares = formatEtherNum(result);
5528
7069
  const nav = shares * (autopool?.navPerShare.baseAsset || 0);
5529
7070
  const navUsd = shares * (autopool?.navPerShare.USD || 0);
5530
7071
  return {
@@ -5642,14 +7183,14 @@ var getUserAutopools = async ({
5642
7183
  );
5643
7184
  if (autopoolData) {
5644
7185
  const isDOLA = autopoolData.symbol === "autoDOLA" && userAutoDOLA;
5645
- const userShares = isDOLA ? userAutoDOLA?.totalShares : formatEtherNum6(userAutopool?.totalShares);
5646
- const totalVaultShares = formatEtherNum6(autopoolData?.totalSupply);
7186
+ const userShares = isDOLA ? userAutoDOLA?.totalShares : formatEtherNum(userAutopool?.totalShares);
7187
+ const totalVaultShares = formatEtherNum(autopoolData?.totalSupply);
5647
7188
  const userShareOfVault = userShares / totalVaultShares;
5648
- const totalDeposits = formatUnitsNum3(
7189
+ const totalDeposits = formatUnitsNum(
5649
7190
  userActivity?.totals[userAutopool.vaultAddress]?.totalDeposits || 0n,
5650
7191
  autopoolData?.baseAsset.decimals
5651
7192
  );
5652
- const totalWithdrawals = formatUnitsNum3(
7193
+ const totalWithdrawals = formatUnitsNum(
5653
7194
  userActivity?.totals[userAutopool.vaultAddress]?.totalWithdrawals || 0n,
5654
7195
  autopoolData?.baseAsset.decimals
5655
7196
  );
@@ -5658,7 +7199,7 @@ var getUserAutopools = async ({
5658
7199
  );
5659
7200
  let lastDeposit;
5660
7201
  if (poolEvents && poolEvents?.length > 0) {
5661
- lastDeposit = convertTimestampToDate3(
7202
+ lastDeposit = convertTimestampToDate(
5662
7203
  poolEvents[poolEvents.length - 1].timestamp
5663
7204
  ).toLocaleDateString("en-US", {
5664
7205
  day: "2-digit",
@@ -5758,7 +7299,7 @@ var getUserAutopools = async ({
5758
7299
  totalWithdrawals: prev.totalWithdrawals + totalWithdrawals
5759
7300
  };
5760
7301
  const stakedBalance = isDOLA ? userAutoDOLA?.staked.balance : BigInt(userAutopool?.stakedShares);
5761
- const stakedShares = isDOLA ? userAutoDOLA?.staked.shares : formatEtherNum6(stakedBalance);
7302
+ const stakedShares = isDOLA ? userAutoDOLA?.staked.shares : formatEtherNum(stakedBalance);
5762
7303
  const stakedNav = stakedShares * (autopoolData?.navPerShare.baseAsset || 0);
5763
7304
  const staked = convertBaseAssetToTokenPrices(
5764
7305
  stakedNav,
@@ -5766,7 +7307,7 @@ var getUserAutopools = async ({
5766
7307
  prices
5767
7308
  );
5768
7309
  const unstakedBalance = isDOLA ? userAutoDOLA?.unstaked.balance : BigInt(userAutopool?.walletShares);
5769
- const unstakedShares = isDOLA ? userAutoDOLA?.unstaked.shares : formatEtherNum6(unstakedBalance);
7310
+ const unstakedShares = isDOLA ? userAutoDOLA?.unstaked.shares : formatEtherNum(unstakedBalance);
5770
7311
  const unstakedNav = unstakedShares * (autopoolData?.navPerShare.baseAsset || 0);
5771
7312
  const unstaked = convertBaseAssetToTokenPrices(
5772
7313
  unstakedNav,
@@ -5811,7 +7352,7 @@ var getUserAutopools = async ({
5811
7352
  };
5812
7353
  }
5813
7354
  });
5814
- let denominatedToken = ETH_TOKEN4;
7355
+ let denominatedToken = ETH_TOKEN;
5815
7356
  const useDenomination = userAutopoolsWithData.filter((autopool) => autopool?.useDenomination).length === 1 && userAutopoolsWithData.length === 1;
5816
7357
  if (useDenomination) {
5817
7358
  const autopoolWithDenomination = userAutopoolsWithData.find(
@@ -5963,17 +7504,13 @@ var getUserAutopools = async ({
5963
7504
  console.log(e);
5964
7505
  }
5965
7506
  };
5966
-
5967
- // functions/getUserTokenBalances.ts
5968
- import { hexToBigInt } from "viem";
5969
- import { base, mainnet as mainnet4, sonic as sonic2 } from "viem/chains";
5970
7507
  var networkToAlchemyUrl = (chainId, apiKey) => {
5971
7508
  switch (chainId) {
5972
- case mainnet4.id:
7509
+ case mainnet.id:
5973
7510
  return `https://eth-mainnet.g.alchemy.com/v2/${apiKey}`;
5974
7511
  case base.id:
5975
7512
  return `https://base-mainnet.g.alchemy.com/v2/${apiKey}`;
5976
- case sonic2.id:
7513
+ case sonic.id:
5977
7514
  return `https://sonic-mainnet.g.alchemy.com/v2/${apiKey}`;
5978
7515
  default:
5979
7516
  throw new Error("Unsupported network");
@@ -6019,9 +7556,6 @@ var getUserTokenBalances = async ({
6019
7556
  );
6020
7557
  return tokenBalances;
6021
7558
  };
6022
-
6023
- // functions/getTokenList.ts
6024
- import { TOKEMAK_LISTS_URL } from "@tokemak/tokenlist";
6025
7559
  var getTokenList = async () => {
6026
7560
  try {
6027
7561
  let url = `${TOKEMAK_LISTS_URL}/swap_enabled.json`;
@@ -6033,12 +7567,9 @@ var getTokenList = async () => {
6033
7567
  return [];
6034
7568
  }
6035
7569
  };
6036
-
6037
- // functions/getTopAutopoolHolders.ts
6038
- import { getSdkByChainId as getSdkByChainId11 } from "@tokemak/graph-cli";
6039
7570
  var getTopAutopoolHolders = async (autopoolAddress, chainId = 1) => {
6040
7571
  try {
6041
- const { GetTopAutopoolHolders } = getSdkByChainId11(chainId);
7572
+ const { GetTopAutopoolHolders } = getSdkByChainId(chainId);
6042
7573
  const { holders } = await GetTopAutopoolHolders({
6043
7574
  address: autopoolAddress
6044
7575
  });
@@ -6048,19 +7579,15 @@ var getTopAutopoolHolders = async (autopoolAddress, chainId = 1) => {
6048
7579
  return [];
6049
7580
  }
6050
7581
  };
6051
-
6052
- // functions/getAllowance.ts
6053
- import { readContract as readContract6 } from "@wagmi/core";
6054
- import { erc20Abi as erc20Abi2 } from "viem";
6055
7582
  var getAllowance = async (wagmiConfig, {
6056
7583
  token,
6057
7584
  address,
6058
7585
  spender
6059
7586
  }) => {
6060
7587
  try {
6061
- const allowance = await readContract6(wagmiConfig, {
7588
+ const allowance = await readContract(wagmiConfig, {
6062
7589
  address: token,
6063
- abi: erc20Abi2,
7590
+ abi: erc20Abi,
6064
7591
  functionName: "allowance",
6065
7592
  args: [address || "0x0", spender]
6066
7593
  });
@@ -6099,23 +7626,15 @@ var getUserActivity = async ({
6099
7626
  mergedActivity.events.sort((a, b) => a.timestamp - b.timestamp);
6100
7627
  return mergedActivity;
6101
7628
  };
6102
-
6103
- // functions/getUserAutopoolsRewards.ts
6104
- import { getAddress as getAddress4 } from "viem";
6105
-
6106
- // functions/getChainUserAutopoolsRewards.ts
6107
- import { getCoreConfig as getCoreConfig2 } from "@tokemak/config";
6108
- import { readContract as readContract7 } from "@wagmi/core";
6109
- import { lensAbi as lensAbi2 } from "@tokemak/abis";
6110
7629
  var getChainUserAutopoolsRewards = async (wagmiConfig, {
6111
7630
  chainId,
6112
7631
  address
6113
7632
  }) => {
6114
7633
  try {
6115
- const coreConfig = getCoreConfig2(chainId);
6116
- const userRewardsInfo = await readContract7(wagmiConfig, {
7634
+ const coreConfig = getCoreConfig(chainId);
7635
+ const userRewardsInfo = await readContract(wagmiConfig, {
6117
7636
  address: coreConfig.lens,
6118
- abi: lensAbi2,
7637
+ abi: lensAbi,
6119
7638
  functionName: "getUserRewardInfo",
6120
7639
  args: [address],
6121
7640
  chainId: coreConfig.id
@@ -6143,11 +7662,6 @@ var getChainUserAutopoolsRewards = async (wagmiConfig, {
6143
7662
  console.log(e);
6144
7663
  }
6145
7664
  };
6146
-
6147
- // functions/getUserAutopoolsRewards.ts
6148
- import { formatUnitsNum as formatUnitsNum4, getToken as getToken2 } from "@tokemak/utils";
6149
- import { SILO_TOKEN as SILO_TOKEN2, TOKE_TOKEN as TOKE_TOKEN3 } from "@tokemak/tokenlist";
6150
- import { plasma } from "viem/chains";
6151
7665
  var getUserAutopoolsRewards = async (wagmiConfig, {
6152
7666
  address,
6153
7667
  tokenPrices,
@@ -6171,27 +7685,27 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
6171
7685
  const extraRewardsArray = Object.entries(chainUserRewards).flatMap(
6172
7686
  ([autopoolAddress, rewards]) => {
6173
7687
  const autopool = autopools.find(
6174
- (autopool2) => getAddress4(autopool2.poolAddress) === getAddress4(autopoolAddress)
7688
+ (autopool2) => getAddress(autopool2.poolAddress) === getAddress(autopoolAddress)
6175
7689
  );
6176
7690
  if (!autopool || !autopool.extraRewarders) {
6177
7691
  return [];
6178
7692
  }
6179
7693
  return autopool.extraRewarders.map((extraRewards2) => {
6180
- const rewarderToken = getToken2(
7694
+ const rewarderToken = getToken(
6181
7695
  extraRewards2.rewardToken?.id,
6182
7696
  autopool.chain?.chainId
6183
7697
  );
6184
- const claimableAmount = rewards ? rewards[getAddress4(extraRewards2.rewardToken?.id)] : 0n;
7698
+ const claimableAmount = rewards ? rewards[getAddress(extraRewards2.rewardToken?.id)] : 0n;
6185
7699
  let price = tokenPrices[rewarderToken.symbol] || 0;
6186
7700
  if (rewarderToken.symbol === "XSILO") {
6187
- price = tokenPrices[SILO_TOKEN2.symbol] || 0;
7701
+ price = tokenPrices[SILO_TOKEN.symbol] || 0;
6188
7702
  }
6189
- const formattedAmount = formatUnitsNum4(
7703
+ const formattedAmount = formatUnitsNum(
6190
7704
  claimableAmount,
6191
7705
  rewarderToken.decimals || 18
6192
7706
  );
6193
7707
  return {
6194
- address: getAddress4(extraRewards2?.id),
7708
+ address: getAddress(extraRewards2?.id),
6195
7709
  chainId,
6196
7710
  token: rewarderToken,
6197
7711
  amount: claimableAmount,
@@ -6204,7 +7718,7 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
6204
7718
  const tokenRewards = {};
6205
7719
  Object.values(chainUserRewards).forEach((autopoolRewards) => {
6206
7720
  Object.entries(autopoolRewards).forEach(([tokenAddress, amount]) => {
6207
- const token = getToken2(tokenAddress, chainId);
7721
+ const token = getToken(tokenAddress, chainId);
6208
7722
  const tokenSymbol = token.symbol;
6209
7723
  if (!tokenRewards[tokenSymbol]) {
6210
7724
  tokenRewards[tokenSymbol] = {
@@ -6222,9 +7736,9 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
6222
7736
  ([tokenSymbol, { amount, decimals }]) => {
6223
7737
  let price = tokenPrices[tokenSymbol] || 0;
6224
7738
  if (tokenSymbol === "XSILO") {
6225
- price = tokenPrices[SILO_TOKEN2.symbol] || 0;
7739
+ price = tokenPrices[SILO_TOKEN.symbol] || 0;
6226
7740
  }
6227
- const formattedAmount = formatUnitsNum4(amount, decimals || 18);
7741
+ const formattedAmount = formatUnitsNum(amount, decimals || 18);
6228
7742
  tokenRewards[tokenSymbol] = {
6229
7743
  amount,
6230
7744
  formattedAmount,
@@ -6239,7 +7753,7 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
6239
7753
  tokenRewards["TOKE"] = {
6240
7754
  ...undefinedToken,
6241
7755
  USD: undefinedToken.formattedAmount * price,
6242
- logoURI: TOKE_TOKEN3.logoURI
7756
+ logoURI: TOKE_TOKEN.logoURI
6243
7757
  };
6244
7758
  delete tokenRewards["undefined"];
6245
7759
  }
@@ -6292,29 +7806,14 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
6292
7806
  console.error(e);
6293
7807
  }
6294
7808
  };
6295
-
6296
- // functions/getAmountWithdrawn.ts
6297
- import { formatUnits as formatUnits5 } from "viem";
6298
- import {
6299
- calculateMinAmountWithSlippage,
6300
- convertNumToBps
6301
- } from "@tokemak/utils";
6302
-
6303
- // functions/getSwapQuote.ts
6304
- import { TOKEMAK_SWAP_QUOTE_URL } from "@tokemak/constants";
6305
-
6306
- // functions/getAddressFromSystemRegistry.ts
6307
- import { readContract as readContract8 } from "@wagmi/core";
6308
- import { getCoreConfig as getCoreConfig3 } from "@tokemak/config";
6309
- import { systemRegistryAbi as systemRegistryAbi2 } from "@tokemak/abis";
6310
7809
  var getAddressFromSystemRegistry = async (wagmiConfig, {
6311
7810
  chainId,
6312
7811
  functionName
6313
7812
  }) => {
6314
- const { systemRegistry } = getCoreConfig3(chainId);
6315
- return await readContract8(wagmiConfig, {
7813
+ const { systemRegistry } = getCoreConfig(chainId);
7814
+ return await readContract(wagmiConfig, {
6316
7815
  address: systemRegistry,
6317
- abi: systemRegistryAbi2,
7816
+ abi: systemRegistryAbi,
6318
7817
  functionName,
6319
7818
  chainId
6320
7819
  });
@@ -6325,23 +7824,18 @@ var getAutopilotRouter = async (wagmiConfig, { chainId }) => await getAddressFro
6325
7824
  chainId,
6326
7825
  functionName: "autoPoolRouter"
6327
7826
  });
6328
-
6329
- // functions/getSwapQuote.ts
6330
- import { getCoreConfig as getCoreConfig4 } from "@tokemak/config";
6331
- import { ETH_TOKEN as ETH_TOKEN5, WS_TOKEN as WS_TOKEN3, WXPL_TOKEN as WXPL_TOKEN3 } from "@tokemak/tokenlist";
6332
- import { plasma as plasma2, sonic as sonic3 } from "viem/chains";
6333
7827
  var getSwapQuote = async (config, { chainId, ...params }) => {
6334
7828
  try {
6335
7829
  if (!params.sellToken || !params.buyToken) {
6336
7830
  throw new Error("Sell token and buy token are required");
6337
7831
  }
6338
- if (params.sellToken === ETH_TOKEN5.address) {
6339
- params.sellToken = getCoreConfig4(chainId).weth;
6340
- if (chainId === sonic3.id) {
6341
- params.sellToken = WS_TOKEN3.address;
7832
+ if (params.sellToken === ETH_TOKEN.address) {
7833
+ params.sellToken = getCoreConfig(chainId).weth;
7834
+ if (chainId === sonic.id) {
7835
+ params.sellToken = WS_TOKEN.address;
6342
7836
  }
6343
- if (chainId === plasma2.id) {
6344
- params.sellToken = WXPL_TOKEN3.address;
7837
+ if (chainId === plasma.id) {
7838
+ params.sellToken = WXPL_TOKEN.address;
6345
7839
  }
6346
7840
  }
6347
7841
  const sellAmount = params.sellAmount.toString();
@@ -6370,17 +7864,6 @@ var getSwapQuote = async (config, { chainId, ...params }) => {
6370
7864
  return void 0;
6371
7865
  }
6372
7866
  };
6373
-
6374
- // functions/getDynamicSwap.ts
6375
- import { getPublicClient, readContract as readContract9 } from "@wagmi/core";
6376
- import { autopilotRouterAbi, autopoolEthAbi as autopoolEthAbi2 } from "@tokemak/abis";
6377
- import { getCoreConfig as getCoreConfig5 } from "@tokemak/config";
6378
- import { getLiquidations } from "@tokemak/autopilot-swap-route-calc";
6379
- import {
6380
- ContractFunctionExecutionError,
6381
- ContractFunctionRevertedError
6382
- } from "viem";
6383
- import { TOKEMAK_DYNAMIC_SWAP_ROUTES_URL } from "@tokemak/constants";
6384
7867
  var placeholderAddress = "0x8b4334d4812c530574bd4f2763fcd22de94a969b";
6385
7868
  var getDynamicSwap = async ({
6386
7869
  address,
@@ -6396,7 +7879,7 @@ var getDynamicSwap = async ({
6396
7879
  let standardPreviewRedeem = false;
6397
7880
  const client = await getPublicClient(config, { chainId });
6398
7881
  try {
6399
- const { systemRegistry } = getCoreConfig5(chainId);
7882
+ const { systemRegistry } = getCoreConfig(chainId);
6400
7883
  client.transport.retryCount = 0;
6401
7884
  client.transport.transports = [client.transport.transports[0]];
6402
7885
  const liquidations = await getLiquidations(
@@ -6463,9 +7946,9 @@ var getDynamicSwap = async ({
6463
7946
  console.log(e);
6464
7947
  }
6465
7948
  }
6466
- const previewRedeemOnChain = await readContract9(config, {
7949
+ const previewRedeemOnChain = await readContract(config, {
6467
7950
  address,
6468
- abi: autopoolEthAbi2,
7951
+ abi: autopoolEthAbi,
6469
7952
  functionName: "previewRedeem",
6470
7953
  args: [amount],
6471
7954
  chainId,
@@ -6481,12 +7964,6 @@ var getDynamicSwap = async ({
6481
7964
  previewRedeem
6482
7965
  };
6483
7966
  };
6484
-
6485
- // functions/getAmountWithdrawn.ts
6486
- import { ETH_TOKEN as ETH_TOKEN6 } from "@tokemak/tokenlist";
6487
- import { getCoreConfig as getCoreConfig6 } from "@tokemak/config";
6488
- import { readContract as readContract10 } from "@wagmi/core";
6489
- import { autopoolEthAbi as autopoolEthAbi3 } from "@tokemak/abis";
6490
7967
  var getAmountWithdrawn = async ({
6491
7968
  address,
6492
7969
  slippage,
@@ -6519,15 +7996,15 @@ var getAmountWithdrawn = async ({
6519
7996
  dynamicSwap?.previewRedeem,
6520
7997
  slippage
6521
7998
  );
6522
- let minAmount = formatUnits5(minAmountWithSlippage, decimals);
7999
+ let minAmount = formatUnits(minAmountWithSlippage, decimals);
6523
8000
  if (isSwap) {
6524
- if (buyToken === ETH_TOKEN6.address) {
6525
- const weth = getCoreConfig6(chainId).weth;
8001
+ if (buyToken === ETH_TOKEN.address) {
8002
+ const weth = getCoreConfig(chainId).weth;
6526
8003
  buyToken = weth;
6527
8004
  }
6528
- convertedAssets = await readContract10(config, {
8005
+ convertedAssets = await readContract(config, {
6529
8006
  address: autopool,
6530
- abi: autopoolEthAbi3,
8007
+ abi: autopoolEthAbi,
6531
8008
  functionName: "convertToAssets",
6532
8009
  args: [amount],
6533
8010
  chainId
@@ -6545,7 +8022,7 @@ var getAmountWithdrawn = async ({
6545
8022
  sellAll: true
6546
8023
  });
6547
8024
  if (quote) {
6548
- minAmount = formatUnits5(BigInt(quote?.minBuyAmount), decimals);
8025
+ minAmount = formatUnits(BigInt(quote?.minBuyAmount), decimals);
6549
8026
  } else {
6550
8027
  throw new Error("No quote found");
6551
8028
  }
@@ -6563,11 +8040,6 @@ var getAmountWithdrawn = async ({
6563
8040
  };
6564
8041
  }
6565
8042
  };
6566
-
6567
- // functions/getAmountDeposited.ts
6568
- import { readContract as readContract11 } from "@wagmi/core";
6569
- import { autopoolEthAbi as autopoolEthAbi4 } from "@tokemak/abis";
6570
- import { calculateMinAmountWithSlippage as calculateMinAmountWithSlippage2, formatEtherNum as formatEtherNum7 } from "@tokemak/utils";
6571
8043
  var getAmountDeposited = async ({
6572
8044
  address,
6573
8045
  chainId,
@@ -6580,21 +8052,21 @@ var getAmountDeposited = async ({
6580
8052
  if (!address || !chainId || !amount || typeof slippage !== "number") {
6581
8053
  throw new Error("Invalid parameters");
6582
8054
  }
6583
- const previewDeposit = await readContract11(config, {
8055
+ const previewDeposit = await readContract(config, {
6584
8056
  address,
6585
- abi: autopoolEthAbi4,
8057
+ abi: autopoolEthAbi,
6586
8058
  functionName: "previewDeposit",
6587
8059
  args: [amount],
6588
8060
  chainId
6589
8061
  });
6590
8062
  if (!isSwap) {
6591
- let minAmountWithSlippage = calculateMinAmountWithSlippage2(
8063
+ let minAmountWithSlippage = calculateMinAmountWithSlippage(
6592
8064
  previewDeposit,
6593
8065
  slippage
6594
8066
  );
6595
- return formatEtherNum7(minAmountWithSlippage);
8067
+ return formatEtherNum(minAmountWithSlippage);
6596
8068
  } else {
6597
- return formatEtherNum7(previewDeposit);
8069
+ return formatEtherNum(previewDeposit);
6598
8070
  }
6599
8071
  } catch (e) {
6600
8072
  console.error(e);
@@ -6603,11 +8075,6 @@ var getAmountDeposited = async ({
6603
8075
  }
6604
8076
  };
6605
8077
 
6606
- // functions/getBridgeFee.ts
6607
- import { readContract as readContract12 } from "@wagmi/core";
6608
- import { layerZeroEndpointAbi, oftAdapterAbi } from "@tokemak/abis";
6609
- import { toHex as toHex2 } from "viem";
6610
-
6611
8078
  // ../../node_modules/@ethersproject/logger/lib.esm/_version.js
6612
8079
  var version = "logger/5.8.0";
6613
8080
 
@@ -6798,9 +8265,6 @@ var Logger = class {
6798
8265
  this.throwArgumentError(message, name, value);
6799
8266
  }
6800
8267
  checkNormalize(message) {
6801
- if (message == null) {
6802
- message = "platform missing String.prototype.normalize";
6803
- }
6804
8268
  if (_normalizeError) {
6805
8269
  this.throwError("platform missing String.prototype.normalize", Logger.errors.UNSUPPORTED_OPERATION, {
6806
8270
  operation: "String.prototype.normalize",
@@ -7331,7 +8795,7 @@ function throwFault(fault, operation, value) {
7331
8795
  var import_bs58 = __toESM(require_bs58(), 1);
7332
8796
 
7333
8797
  // ../../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
7334
- var isProduction = process.env.NODE_ENV === "production";
8798
+ process.env.NODE_ENV === "production";
7335
8799
 
7336
8800
  // ../../node_modules/@layerzerolabs/lz-v2-utilities/dist/index.mjs
7337
8801
  function hexZeroPadTo32(addr) {
@@ -7349,7 +8813,7 @@ var solanaAddressRegex = /^([1-9A-HJ-NP-Za-km-z]{32,44})$/;
7349
8813
  function isSolanaAddress(address) {
7350
8814
  return solanaAddressRegex.test(address);
7351
8815
  }
7352
- var MAX_UINT_128 = BigNumber.from("0xffffffffffffffffffffffffffffffff");
8816
+ BigNumber.from("0xffffffffffffffffffffffffffffffff");
7353
8817
 
7354
8818
  // functions/getBridgeFee.ts
7355
8819
  var getBridgeFee = async (wagmiConfig, {
@@ -7361,13 +8825,13 @@ var getBridgeFee = async (wagmiConfig, {
7361
8825
  from
7362
8826
  }) => {
7363
8827
  try {
7364
- const endpoint = await readContract12(wagmiConfig, {
8828
+ const endpoint = await readContract(wagmiConfig, {
7365
8829
  address: destAddress,
7366
8830
  abi: oftAdapterAbi,
7367
8831
  functionName: "endpoint",
7368
8832
  chainId: destChainId
7369
8833
  });
7370
- const eid = await readContract12(wagmiConfig, {
8834
+ const eid = await readContract(wagmiConfig, {
7371
8835
  address: endpoint,
7372
8836
  abi: layerZeroEndpointAbi,
7373
8837
  functionName: "eid",
@@ -7378,14 +8842,14 @@ var getBridgeFee = async (wagmiConfig, {
7378
8842
  const minAmountLD = amount / factor * factor;
7379
8843
  const sendParams = {
7380
8844
  dstEid: eid,
7381
- to: toHex2(addressToBytes32(from)),
8845
+ to: toHex$1(addressToBytes32(from)),
7382
8846
  amountLD: amount,
7383
8847
  minAmountLD,
7384
8848
  extraOptions: "0x",
7385
8849
  composeMsg: "0x",
7386
8850
  oftCmd: "0x"
7387
8851
  };
7388
- const feeQuote = await readContract12(wagmiConfig, {
8852
+ const feeQuote = await readContract(wagmiConfig, {
7389
8853
  address: sourceAddress,
7390
8854
  abi: oftAdapterAbi,
7391
8855
  functionName: "quoteSend",
@@ -7452,47 +8916,27 @@ var waitForMessageReceived = async ({
7452
8916
  }
7453
8917
  throw new Error(`Timeout reached after 20 minutes for message: ${txHash}`);
7454
8918
  };
7455
-
7456
- // functions/getChainUserSToke.ts
7457
- import { accTokeV1Abi as accTokeV1Abi2 } from "@tokemak/abis";
7458
- import { getCoreConfig as getCoreConfig7 } from "@tokemak/config";
7459
- import {
7460
- convertChainCycleToUnix as convertChainCycleToUnix2,
7461
- convertSecondsToRemainingTime,
7462
- formatCurrency as formatCurrency2,
7463
- formatEtherNum as formatEtherNum8
7464
- } from "@tokemak/utils";
7465
- import { readContracts as readContracts6 } from "@wagmi/core";
7466
- import { formatEther as formatEther2 } from "viem";
7467
- import { sepolia as sepolia2 } from "viem/chains";
7468
-
7469
- // functions/getCurrentCycleId.ts
7470
- import { accTokeV1Abi } from "@tokemak/abis";
7471
- import { readContract as readContract13 } from "@wagmi/core";
7472
8919
  var getCurrentCycleId = async (wagmiConfig, {
7473
8920
  stoke,
7474
8921
  chainId
7475
8922
  }) => {
7476
- return readContract13(wagmiConfig, {
8923
+ return readContract(wagmiConfig, {
7477
8924
  address: stoke,
7478
8925
  abi: accTokeV1Abi,
7479
8926
  chainId,
7480
8927
  functionName: "getCurrentCycleID"
7481
8928
  });
7482
8929
  };
7483
-
7484
- // functions/getChainUserSToke.ts
7485
- import { getSdkByChainId as getSdkByChainId12 } from "@tokemak/graph-cli";
7486
8930
  var getChainUserSToke = async (wagmiConfig, {
7487
8931
  address,
7488
8932
  tokePrice,
7489
8933
  chainId
7490
8934
  }) => {
7491
8935
  try {
7492
- const { stoke } = getCoreConfig7(chainId);
8936
+ const { stoke } = getCoreConfig(chainId);
7493
8937
  const cycleIndex = await getCurrentCycleId(wagmiConfig, { chainId, stoke });
7494
8938
  if (address && cycleIndex && stoke && tokePrice) {
7495
- const { GetUserSTokeBalance } = getSdkByChainId12(
8939
+ const { GetUserSTokeBalance } = getSdkByChainId(
7496
8940
  chainId
7497
8941
  );
7498
8942
  const { accountBalanceV1S } = await GetUserSTokeBalance({
@@ -7501,13 +8945,13 @@ var getChainUserSToke = async (wagmiConfig, {
7501
8945
  const cycleStartBalance = accountBalanceV1S[0]?.cycleStartBalance || 0n;
7502
8946
  const stokeContract = {
7503
8947
  address: stoke,
7504
- abi: accTokeV1Abi2
8948
+ abi: accTokeV1Abi
7505
8949
  };
7506
8950
  const [
7507
8951
  { result: balance },
7508
8952
  { result: depositInfoResult },
7509
8953
  { result: withdrawalInfoResult }
7510
- ] = await readContracts6(wagmiConfig, {
8954
+ ] = await readContracts(wagmiConfig, {
7511
8955
  contracts: [
7512
8956
  {
7513
8957
  ...stokeContract,
@@ -7537,8 +8981,8 @@ var getChainUserSToke = async (wagmiConfig, {
7537
8981
  if (withdrawalAmount > 0n && cycleIndex >= withdrawalMinCycle) {
7538
8982
  balanceExcludingWithdrawal = balanceExcludingWithdrawal - withdrawalAmount;
7539
8983
  }
7540
- const withdrawalAmountUsd = formatCurrency2(
7541
- formatEtherNum8(withdrawalAmount) * tokePrice
8984
+ const withdrawalAmountUsd = formatCurrency(
8985
+ formatEtherNum(withdrawalAmount) * tokePrice
7542
8986
  );
7543
8987
  const lockDuration = Number(depositLockDuration);
7544
8988
  const lockCycle = Number(depositLockCycle);
@@ -7559,27 +9003,27 @@ var getChainUserSToke = async (wagmiConfig, {
7559
9003
  const withdrawAvailable = lockRenew - 1;
7560
9004
  const hasAddedLockedToke = depositAmount > 0n && depositAmount > rolloverDepositAmount;
7561
9005
  const addedLockedToke = depositAmount - rolloverDepositAmount;
7562
- const balanceUSD = formatCurrency2(
7563
- Number(formatEther2(balanceExcludingWithdrawal)) * tokePrice
9006
+ const balanceUSD = formatCurrency(
9007
+ Number(formatEther(balanceExcludingWithdrawal)) * tokePrice
7564
9008
  );
7565
- const balanceExcludingWithdrawalUsd = formatCurrency2(
7566
- formatEtherNum8(balanceExcludingWithdrawal) * tokePrice
9009
+ const balanceExcludingWithdrawalUsd = formatCurrency(
9010
+ formatEtherNum(balanceExcludingWithdrawal) * tokePrice
7567
9011
  );
7568
9012
  const isUnlockRequestAvailable = currentCycle === withdrawAvailable;
7569
9013
  const hasRequestedUnlock = withdrawalAmount > 0n;
7570
- const unlockRequestPeriodStartUnix = convertChainCycleToUnix2(withdrawAvailable, chainId) - Date.now() / 1e3;
7571
- const unlockRequestPeriodEndUnix = convertChainCycleToUnix2(lockRenew, chainId) - Date.now() / 1e3;
9014
+ const unlockRequestPeriodStartUnix = convertChainCycleToUnix(withdrawAvailable, chainId) - Date.now() / 1e3;
9015
+ const unlockRequestPeriodEndUnix = convertChainCycleToUnix(lockRenew, chainId) - Date.now() / 1e3;
7572
9016
  const hasBalance = balance > 0n;
7573
9017
  const hasBalanceExcludingWithdrawal = balanceExcludingWithdrawal > 0n;
7574
9018
  const hasUnlockableBalance = withdrawalMinCycle <= currentCycle && withdrawalAmount > 0n;
7575
9019
  let cyclesInAMonth = 4;
7576
9020
  let lockDurationInMonths = lockDuration / cyclesInAMonth;
7577
- if (chainId === sepolia2.id) {
9021
+ if (chainId === sepolia.id) {
7578
9022
  lockDurationInMonths = lockDuration - 1;
7579
9023
  }
7580
9024
  const unlockPeriodDateRangeArray = [
7581
- new Date(convertChainCycleToUnix2(withdrawAvailable, chainId) * 1e3),
7582
- new Date(convertChainCycleToUnix2(lockRenew, chainId) * 1e3)
9025
+ new Date(convertChainCycleToUnix(withdrawAvailable, chainId) * 1e3),
9026
+ new Date(convertChainCycleToUnix(lockRenew, chainId) * 1e3)
7583
9027
  ];
7584
9028
  const {
7585
9029
  unlockPeriodDateRange,
@@ -7589,14 +9033,14 @@ var getChainUserSToke = async (wagmiConfig, {
7589
9033
  unlockRenewalDate
7590
9034
  } = formatDateRange(
7591
9035
  unlockPeriodDateRangeArray,
7592
- chainId === sepolia2.id ? "time" : "date"
9036
+ chainId === sepolia.id ? "time" : "date"
7593
9037
  );
7594
- const totalActiveUserCredits = formatEtherNum8(balanceExcludingWithdrawal) * lockDurationInMonths;
7595
- const totalUserCredits = formatEtherNum8(balance) * lockDurationInMonths;
9038
+ const totalActiveUserCredits = formatEtherNum(balanceExcludingWithdrawal) * lockDurationInMonths;
9039
+ const totalUserCredits = formatEtherNum(balance) * lockDurationInMonths;
7596
9040
  return {
7597
9041
  balance,
7598
9042
  balanceUSD,
7599
- balanceExcludingWithdrawal: hasBalance ? formatEther2(balanceExcludingWithdrawal) : "0.00",
9043
+ balanceExcludingWithdrawal: hasBalance ? formatEther(balanceExcludingWithdrawal) : "0.00",
7600
9044
  balanceExcludingWithdrawalUsd,
7601
9045
  hasBalanceExcludingWithdrawal,
7602
9046
  timeLeftBeforeUnlockRequestAvailable: convertSecondsToRemainingTime(
@@ -7619,7 +9063,7 @@ var getChainUserSToke = async (wagmiConfig, {
7619
9063
  unlockRenewalDate,
7620
9064
  lockDurationInMonths,
7621
9065
  boost: lockDuration,
7622
- points: formatEtherNum8(balanceExcludingWithdrawal) * lockDuration,
9066
+ points: formatEtherNum(balanceExcludingWithdrawal) * lockDuration,
7623
9067
  totalActiveCredits: totalActiveUserCredits,
7624
9068
  totalCredits: totalUserCredits
7625
9069
  };
@@ -7629,9 +9073,6 @@ var getChainUserSToke = async (wagmiConfig, {
7629
9073
  console.error(error);
7630
9074
  }
7631
9075
  };
7632
-
7633
- // functions/getUserSToke.ts
7634
- import { formatCurrency as formatCurrency3, formatEtherNum as formatEtherNum9 } from "@tokemak/utils";
7635
9076
  var getUserSToke = async (wagmiConfig, {
7636
9077
  address,
7637
9078
  tokePrice,
@@ -7658,8 +9099,8 @@ var getUserSToke = async (wagmiConfig, {
7658
9099
  }
7659
9100
  return acc;
7660
9101
  }, 0n);
7661
- const totalBalance = formatEtherNum9(totalBalanceRaw || 0n);
7662
- const totalBalanceUsd = formatCurrency3(totalBalance * tokePrice);
9102
+ const totalBalance = formatEtherNum(totalBalanceRaw || 0n);
9103
+ const totalBalanceUsd = formatCurrency(totalBalance * tokePrice);
7663
9104
  const hasBalance = totalBalance > 0;
7664
9105
  return {
7665
9106
  chains: { ...userSToke },
@@ -7671,32 +9112,19 @@ var getUserSToke = async (wagmiConfig, {
7671
9112
  console.error(e);
7672
9113
  }
7673
9114
  };
7674
-
7675
- // functions/getChainSToke.ts
7676
- import { formatEther as formatEther3 } from "viem";
7677
- import { readContracts as readContracts7 } from "@wagmi/core";
7678
- import { accTokeV1Abi as accTokeV1Abi3 } from "@tokemak/abis";
7679
- import {
7680
- convertChainCycleToUnix as convertChainCycleToUnix3,
7681
- convertSecondsToRemainingTime as convertSecondsToRemainingTime2,
7682
- formatLargeNumber,
7683
- formatTVL
7684
- } from "@tokemak/utils";
7685
- import { getCoreConfig as getCoreConfig8 } from "@tokemak/config";
7686
- import { getNetwork as getNetwork4 } from "@tokemak/utils";
7687
9115
  var getChainSToke = async (wagmiConfig, {
7688
9116
  tokePrice,
7689
9117
  chainId
7690
9118
  }) => {
7691
9119
  try {
7692
- const { stoke } = getCoreConfig8(chainId);
9120
+ const { stoke } = getCoreConfig(chainId);
7693
9121
  const baseConfig = {
7694
9122
  address: stoke,
7695
- abi: accTokeV1Abi3,
9123
+ abi: accTokeV1Abi,
7696
9124
  chainId
7697
9125
  };
7698
9126
  if (stoke && tokePrice) {
7699
- const [{ result: totalSupply }, { result: currentCycle }] = await readContracts7(wagmiConfig, {
9127
+ const [{ result: totalSupply }, { result: currentCycle }] = await readContracts(wagmiConfig, {
7700
9128
  contracts: [
7701
9129
  {
7702
9130
  ...baseConfig,
@@ -7708,16 +9136,16 @@ var getChainSToke = async (wagmiConfig, {
7708
9136
  }
7709
9137
  ]
7710
9138
  });
7711
- const tvl = Number(formatEther3(totalSupply || 0n)) * tokePrice;
7712
- const secondsLeftBeforeNextCycle = convertChainCycleToUnix3(Number(currentCycle) + 1, chainId) - Date.now() / 1e3;
9139
+ const tvl = Number(formatEther(totalSupply || 0n)) * tokePrice;
9140
+ const secondsLeftBeforeNextCycle = convertChainCycleToUnix(Number(currentCycle) + 1, chainId) - Date.now() / 1e3;
7713
9141
  return {
7714
9142
  rawTotalSupply: totalSupply,
7715
- totalSupply: formatLargeNumber(formatEther3(totalSupply || 0n)),
9143
+ totalSupply: formatLargeNumber(formatEther(totalSupply || 0n)),
7716
9144
  tvl: formatTVL(tvl),
7717
9145
  rawTVL: tvl,
7718
9146
  currentCycle,
7719
- chain: getNetwork4(chainId),
7720
- timeBeforeNextCycle: convertSecondsToRemainingTime2(
9147
+ chain: getNetwork(chainId),
9148
+ timeBeforeNextCycle: convertSecondsToRemainingTime(
7721
9149
  secondsLeftBeforeNextCycle
7722
9150
  )
7723
9151
  };
@@ -7726,10 +9154,6 @@ var getChainSToke = async (wagmiConfig, {
7726
9154
  console.error(error);
7727
9155
  }
7728
9156
  };
7729
-
7730
- // functions/getSToke.ts
7731
- import { formatLargeNumber as formatLargeNumber2, formatTVL as formatTVL2 } from "@tokemak/utils";
7732
- import { formatEther as formatEther4 } from "viem";
7733
9157
  var getSToke = async (wagmiConfig, {
7734
9158
  tokePrice,
7735
9159
  includeTestnet = false
@@ -7748,28 +9172,20 @@ var getSToke = async (wagmiConfig, {
7748
9172
  }
7749
9173
  return acc;
7750
9174
  }, 0n);
7751
- const totalSupply = formatLargeNumber2(formatEther4(totalSupplyBigInt || 0n));
9175
+ const totalSupply = formatLargeNumber(formatEther(totalSupplyBigInt || 0n));
7752
9176
  let tvlNum = Object.values(sToke).reduce((acc, item) => {
7753
9177
  if (item && item.rawTVL) {
7754
9178
  return acc + item.rawTVL;
7755
9179
  }
7756
9180
  return acc;
7757
9181
  }, 0);
7758
- const tvl = formatTVL2(tvlNum);
9182
+ const tvl = formatTVL(tvlNum);
7759
9183
  return { totalSupply, tvl, rawTVL: tvlNum, chains: { ...sToke } };
7760
9184
  } catch (e) {
7761
9185
  console.error(e);
7762
9186
  throw e;
7763
9187
  }
7764
9188
  };
7765
-
7766
- // functions/getChainCycleRolloverBlockNumber.ts
7767
- import { accTokeV1Abi as accTokeV1Abi4, managerV1Abi } from "@tokemak/abis";
7768
- import {
7769
- getBlockNumber,
7770
- getPublicClient as getPublicClient2,
7771
- readContract as readContract14
7772
- } from "@wagmi/core";
7773
9189
  var getChainCycleRolloverBlockNumber = async (wagmiConfig, {
7774
9190
  stoke,
7775
9191
  chainId
@@ -7777,15 +9193,15 @@ var getChainCycleRolloverBlockNumber = async (wagmiConfig, {
7777
9193
  const scanPeriodInDays = 8;
7778
9194
  const blockTime = 12;
7779
9195
  try {
7780
- const client = getPublicClient2(wagmiConfig, { chainId });
9196
+ const client = getPublicClient(wagmiConfig, { chainId });
7781
9197
  if (!!client) {
7782
9198
  const blockNumber = await getBlockNumber(wagmiConfig, {
7783
9199
  chainId
7784
9200
  });
7785
- const manager = await readContract14(wagmiConfig, {
9201
+ const manager = await readContract(wagmiConfig, {
7786
9202
  functionName: "manager",
7787
9203
  address: stoke,
7788
- abi: accTokeV1Abi4,
9204
+ abi: accTokeV1Abi,
7789
9205
  chainId
7790
9206
  });
7791
9207
  if (!manager) {
@@ -7809,10 +9225,6 @@ var getChainCycleRolloverBlockNumber = async (wagmiConfig, {
7809
9225
  console.error(error);
7810
9226
  }
7811
9227
  };
7812
-
7813
- // functions/getChainUserSTokeVotes.ts
7814
- import { formatEtherNum as formatEtherNum10 } from "@tokemak/utils";
7815
- import { getSdkByChainId as getSdkByChainId13 } from "@tokemak/graph-cli";
7816
9228
  var getChainUserSTokeVotes = async ({
7817
9229
  address,
7818
9230
  chainId = 1,
@@ -7821,7 +9233,7 @@ var getChainUserSTokeVotes = async ({
7821
9233
  }) => {
7822
9234
  try {
7823
9235
  if (address && stokeVotes) {
7824
- const { GetUserSTokeVotes, GetUserSTokeBalance } = getSdkByChainId13(chainId);
9236
+ const { GetUserSTokeVotes, GetUserSTokeBalance } = getSdkByChainId(chainId);
7825
9237
  const { userVotes } = await GetUserSTokeVotes({
7826
9238
  address: address.toLowerCase()
7827
9239
  });
@@ -7834,10 +9246,10 @@ var getChainUserSTokeVotes = async ({
7834
9246
  subgraphUserVotesData?.pools || [],
7835
9247
  subgraphUserVotesData?.weights || []
7836
9248
  );
7837
- const stakedToke = formatEtherNum10(
9249
+ const stakedToke = formatEtherNum(
7838
9250
  BigInt(subgraphAccountVotesBalance?.amount || 0n)
7839
9251
  );
7840
- const totalUserVotes = formatEtherNum10(
9252
+ const totalUserVotes = formatEtherNum(
7841
9253
  BigInt(subgraphAccountVotesBalance?.points || 0n)
7842
9254
  );
7843
9255
  const autopools = {};
@@ -7922,24 +9334,18 @@ var getUserSTokeVotes = async ({
7922
9334
  console.error(e);
7923
9335
  }
7924
9336
  };
7925
-
7926
- // functions/getChainSTokeVotes.ts
7927
- import { AUTOPOOLS_WHITELIST_PROD as AUTOPOOLS_WHITELIST_PROD2 } from "@tokemak/config";
7928
- import { formatEtherNum as formatEtherNum11, formatLargeNumber as formatLargeNumber3 } from "@tokemak/utils";
7929
- import { getAddress as getAddress5 } from "viem";
7930
- import { getSdkByChainId as getSdkByChainId14 } from "@tokemak/graph-cli";
7931
9337
  var getChainSTokeVotes = async ({
7932
9338
  chainId,
7933
9339
  includeTestnet = false
7934
9340
  }) => {
7935
- const { GetSTokeVotes } = getSdkByChainId14(chainId);
9341
+ const { GetSTokeVotes } = getSdkByChainId(chainId);
7936
9342
  const { accTokeVoteWeights, voteStatuses } = await GetSTokeVotes();
7937
9343
  const autopoolRawVotes = voteStatuses[0];
7938
9344
  const globalVotes = accTokeVoteWeights[0];
7939
9345
  const globalVoted = BigInt(globalVotes.voted);
7940
9346
  const globalNotVoted = BigInt(globalVotes.notVoted);
7941
9347
  const whitelistedPools = includeTestnet ? autopoolRawVotes?.pools || [] : (autopoolRawVotes?.pools || []).filter(
7942
- (pool) => AUTOPOOLS_WHITELIST_PROD2.includes(getAddress5(pool))
9348
+ (pool) => AUTOPOOLS_WHITELIST_PROD.includes(getAddress(pool))
7943
9349
  );
7944
9350
  const poolCount = whitelistedPools.length;
7945
9351
  const perPoolNotVoted = !!poolCount ? globalNotVoted / BigInt(poolCount) : 0n;
@@ -7956,13 +9362,13 @@ var getChainSTokeVotes = async ({
7956
9362
  updatedPoints
7957
9363
  );
7958
9364
  const globalSystemVotes = globalVoted + globalNotVoted;
7959
- const totalSystemVotesNum = formatEtherNum11(globalSystemVotes);
9365
+ const totalSystemVotesNum = formatEtherNum(globalSystemVotes);
7960
9366
  const formattedAutopoolVotes = Object.fromEntries(
7961
9367
  Object.entries(autopoolVotes).filter(
7962
9368
  ([poolAddress]) => includeTestnet ? true : whitelistedPools.includes(poolAddress)
7963
9369
  ).map(([poolAddress, rawVote]) => {
7964
- const formattedVote = formatLargeNumber3(
7965
- formatEtherNum11(BigInt(rawVote))
9370
+ const formattedVote = formatLargeNumber(
9371
+ formatEtherNum(BigInt(rawVote))
7966
9372
  );
7967
9373
  return [
7968
9374
  poolAddress,
@@ -7977,7 +9383,7 @@ var getChainSTokeVotes = async ({
7977
9383
  globalSystemVotes
7978
9384
  },
7979
9385
  totalSystemVotesNum,
7980
- totalSystemVotes: formatLargeNumber3(totalSystemVotesNum),
9386
+ totalSystemVotes: formatLargeNumber(totalSystemVotesNum),
7981
9387
  autopoolVotes: formattedAutopoolVotes
7982
9388
  };
7983
9389
  };
@@ -7999,17 +9405,11 @@ var getSTokeVotes = async ({
7999
9405
  console.error(e);
8000
9406
  }
8001
9407
  };
8002
-
8003
- // functions/getChainSTokeRewards.ts
8004
- import { AUTOPOOLS_WHITELIST_PROD as AUTOPOOLS_WHITELIST_PROD3 } from "@tokemak/config";
8005
- import { formatUnits as formatUnits6 } from "viem";
8006
- import { formatEtherNum as formatEtherNum12 } from "@tokemak/utils";
8007
- import { getSdkByChainId as getSdkByChainId15 } from "@tokemak/graph-cli";
8008
9408
  var getChainSTokeRewards = async ({
8009
9409
  chainId
8010
9410
  }) => {
8011
9411
  try {
8012
- const { GetSTokeRewards } = getSdkByChainId15(chainId);
9412
+ const { GetSTokeRewards } = getSdkByChainId(chainId);
8013
9413
  const { poolRewardsBalances } = await GetSTokeRewards();
8014
9414
  const allPoolRewardsBalanceDayDatas = await paginateQuery(
8015
9415
  GetSTokeRewards,
@@ -8021,15 +9421,15 @@ var getChainSTokeRewards = async ({
8021
9421
  let minApr = null;
8022
9422
  let maxApr = null;
8023
9423
  for (const pool of poolRewardsBalances) {
8024
- const whitelistedPools = AUTOPOOLS_WHITELIST_PROD3.map(
9424
+ const whitelistedPools = AUTOPOOLS_WHITELIST_PROD.map(
8025
9425
  (address) => address.toLowerCase()
8026
9426
  );
8027
9427
  if (!whitelistedPools.includes(pool.id.toLowerCase())) {
8028
9428
  continue;
8029
9429
  }
8030
- const convertedBalance = formatEtherNum12(pool.balance);
8031
- const convertedBalanceUSD = Number(formatUnits6(pool.balanceUSD, 8));
8032
- const convertedApr = formatEtherNum12(pool.currentAprPerCredit);
9430
+ const convertedBalance = formatEtherNum(pool.balance);
9431
+ const convertedBalanceUSD = Number(formatUnits(pool.balanceUSD, 8));
9432
+ const convertedApr = formatEtherNum(pool.currentAprPerCredit);
8033
9433
  if (minApr === null || convertedApr < minApr) {
8034
9434
  minApr = convertedApr;
8035
9435
  }
@@ -8099,20 +9499,13 @@ var getSTokeRewards = async ({
8099
9499
  throw e;
8100
9500
  }
8101
9501
  };
8102
-
8103
- // functions/getChainUserSTokeRewards.ts
8104
- import {
8105
- getCoreConfig as getCoreConfig9,
8106
- getMainnetConfig as getMainnetConfig6
8107
- } from "@tokemak/config";
8108
- import { formatEtherNum as formatEtherNum13 } from "@tokemak/utils";
8109
9502
  var getChainUserSTokeRewards = async (wagmiConfig, {
8110
9503
  address,
8111
9504
  chainId,
8112
9505
  tokePrice
8113
9506
  }) => {
8114
- const { rewardsV1Url, stokeRewardsHash, stokeRewards } = getMainnetConfig6(1);
8115
- const { stoke } = getCoreConfig9(chainId);
9507
+ const { rewardsV1Url, stokeRewardsHash, stokeRewards } = getMainnetConfig(1);
9508
+ const { stoke } = getCoreConfig(chainId);
8116
9509
  const currentCycle = await getCurrentCycleId(wagmiConfig, {
8117
9510
  stoke,
8118
9511
  chainId
@@ -8156,14 +9549,14 @@ var getChainUserSTokeRewards = async (wagmiConfig, {
8156
9549
  throw fallbackError;
8157
9550
  }
8158
9551
  }
8159
- const claimableNum = formatEtherNum13(tokeRewards?.claimable || 0n);
9552
+ const claimableNum = formatEtherNum(tokeRewards?.claimable || 0n);
8160
9553
  const claimableUsd = tokePrice * claimableNum;
8161
9554
  const hasClaimable = claimableNum > 0n;
8162
- const pendingRewards = formatEtherNum13(
9555
+ const pendingRewards = formatEtherNum(
8163
9556
  tokeRewards?.rewardsPayload.breakdown?.totalRewardAmount || 0n
8164
9557
  );
8165
9558
  const pendingRewardsUsd = tokePrice * pendingRewards;
8166
- const totalRewardsReceived = formatEtherNum13(
9559
+ const totalRewardsReceived = formatEtherNum(
8167
9560
  tokeRewards.rewardsPayload.payload.amount || 0n
8168
9561
  );
8169
9562
  const totalRewardsReceivedUsd = tokePrice * totalRewardsReceived;
@@ -8178,13 +9571,10 @@ var getChainUserSTokeRewards = async (wagmiConfig, {
8178
9571
  ...tokeRewards
8179
9572
  };
8180
9573
  };
8181
-
8182
- // functions/getChainSubgraphStatus.ts
8183
- import { getSdkByChainId as getSdkByChainId16 } from "@tokemak/graph-cli";
8184
9574
  var getChainSubgraphStatus = async (chain) => {
8185
9575
  const currentTimestamp = Math.floor(Date.now() / 1e3);
8186
9576
  try {
8187
- const { GetLatestSubgraphTimestamp } = getSdkByChainId16(
9577
+ const { GetLatestSubgraphTimestamp } = getSdkByChainId(
8188
9578
  chain.chainId
8189
9579
  );
8190
9580
  const { _meta } = await GetLatestSubgraphTimestamp();
@@ -8234,19 +9624,8 @@ var getSubgraphStatus = async (includeTestnet = false) => {
8234
9624
  }
8235
9625
  return { isOutOfSync, errorMessage };
8236
9626
  };
8237
-
8238
- // functions/getCycleV1.ts
8239
- import { readContract as readContract15 } from "@wagmi/core";
8240
- import { managerV1Abi as managerV1Abi2 } from "@tokemak/abis";
8241
- import { createPublicClient, http } from "viem";
8242
- import {
8243
- convertChainCycleToUnix as convertChainCycleToUnix4,
8244
- convertSecondsToRemainingTime as convertSecondsToRemainingTime3
8245
- } from "@tokemak/utils";
8246
- import { getMainnetConfig as getMainnetConfig7 } from "@tokemak/config";
8247
- import { mainnet as mainnet5 } from "viem/chains";
8248
9627
  var publicClient = createPublicClient({
8249
- chain: mainnet5,
9628
+ chain: mainnet,
8250
9629
  transport: http("https://mainnet.infura.io/v3/2BtQ5D1QEPHvwgZwKwnZC7WQVhr")
8251
9630
  });
8252
9631
  var getCycleV1 = async (wagmiConfig, {
@@ -8255,12 +9634,12 @@ var getCycleV1 = async (wagmiConfig, {
8255
9634
  }) => {
8256
9635
  const scanPeriodInDays = 8;
8257
9636
  const blockTime = 12;
8258
- const { managerV1 } = getMainnetConfig7();
9637
+ const { managerV1 } = getMainnetConfig();
8259
9638
  try {
8260
9639
  if (currentBlockNumber && managerV1) {
8261
- const currentCycleIndex = await readContract15(wagmiConfig, {
9640
+ const currentCycleIndex = await readContract(wagmiConfig, {
8262
9641
  address: managerV1,
8263
- abi: managerV1Abi2,
9642
+ abi: managerV1Abi,
8264
9643
  functionName: "getCurrentCycleIndex",
8265
9644
  chainId
8266
9645
  });
@@ -8271,16 +9650,16 @@ var getCycleV1 = async (wagmiConfig, {
8271
9650
  Number(currentBlockNumber) - 86400 / blockTime * scanPeriodInDays
8272
9651
  )
8273
9652
  ),
8274
- abi: managerV1Abi2,
9653
+ abi: managerV1Abi,
8275
9654
  eventName: "CycleRolloverComplete"
8276
9655
  });
8277
9656
  const rolloverEvents = await publicClient.getFilterLogs({ filter });
8278
9657
  const cycleRolloverBlockNumber = chainId === 1 ? rolloverEvents[rolloverEvents.length - 1]?.blockNumber : rolloverEvents[rolloverEvents.length - 1]?.blockNumber || currentBlockNumber;
8279
- const secondsLeftBeforeNextCycle = convertChainCycleToUnix4(Number(currentCycleIndex) + 1) - Date.now() / 1e3;
9658
+ const secondsLeftBeforeNextCycle = convertChainCycleToUnix(Number(currentCycleIndex) + 1) - Date.now() / 1e3;
8280
9659
  return {
8281
9660
  currentCycleIndex,
8282
9661
  cycleRolloverBlockNumber,
8283
- timeBeforeNextCycle: convertSecondsToRemainingTime3(
9662
+ timeBeforeNextCycle: convertSecondsToRemainingTime(
8284
9663
  secondsLeftBeforeNextCycle
8285
9664
  )
8286
9665
  };
@@ -8289,9 +9668,6 @@ var getCycleV1 = async (wagmiConfig, {
8289
9668
  console.error(error);
8290
9669
  }
8291
9670
  };
8292
-
8293
- // functions/getProtocolStats.ts
8294
- import { formatLargeNumber as formatLargeNumber4, formatTVL as formatTVL3 } from "@tokemak/utils";
8295
9671
  var getProtocolStats = async (autopools, stoke, sushiLP) => {
8296
9672
  try {
8297
9673
  if (!autopools || !stoke || !sushiLP) {
@@ -8321,12 +9697,12 @@ var getProtocolStats = async (autopools, stoke, sushiLP) => {
8321
9697
  Object.entries(categories).map(([key, value]) => [
8322
9698
  key,
8323
9699
  {
8324
- tvl: formatTVL3(value.tvl),
8325
- supply: formatLargeNumber4(value.supply || 0)
9700
+ tvl: formatTVL(value.tvl),
9701
+ supply: formatLargeNumber(value.supply || 0)
8326
9702
  }
8327
9703
  ])
8328
9704
  );
8329
- const tvl = formatTVL3(autopoolTVL + stoke.rawTVL + (sushiLP?.tvl || 0));
9705
+ const tvl = formatTVL(autopoolTVL + stoke.rawTVL + (sushiLP?.tvl || 0));
8330
9706
  const vaultAddresses = autopools?.flatMap(
8331
9707
  (pool) => pool.destinations.map((destination) => destination.vaultAddress)
8332
9708
  );
@@ -8334,16 +9710,16 @@ var getProtocolStats = async (autopools, stoke, sushiLP) => {
8334
9710
  const totalDestinations = uniqueVaultAddresses.length;
8335
9711
  return {
8336
9712
  autopools: {
8337
- tvl: formatTVL3(autopoolTVL),
9713
+ tvl: formatTVL(autopoolTVL),
8338
9714
  tvlNum: autopoolTVL,
8339
9715
  categories: formattedCategories
8340
9716
  },
8341
9717
  stoke: {
8342
- tvl: formatTVL3(stoke.rawTVL),
9718
+ tvl: formatTVL(stoke.rawTVL),
8343
9719
  totalSupply: `${stoke.totalSupply} TOKE`
8344
9720
  },
8345
9721
  sushiLP: {
8346
- tvl: formatTVL3(sushiLP?.tvl || 0),
9722
+ tvl: formatTVL(sushiLP?.tvl || 0),
8347
9723
  totalSupply: sushiLP?.totalSupply || 0
8348
9724
  },
8349
9725
  tvl,
@@ -8354,21 +9730,12 @@ var getProtocolStats = async (autopools, stoke, sushiLP) => {
8354
9730
  return null;
8355
9731
  }
8356
9732
  };
8357
-
8358
- // functions/getRebalanceStats.ts
8359
- import { getSdkByChainId as getSdkByChainId17 } from "@tokemak/graph-cli";
8360
-
8361
- // functions/getEthPriceAtBlock.ts
8362
- import { getCoreConfig as getCoreConfig10 } from "@tokemak/config";
8363
- import { readContract as readContract16 } from "@wagmi/core";
8364
- import { rootPriceOracleAbi } from "@tokemak/abis";
8365
- import { USDC_TOKEN as USDC_TOKEN2 } from "@tokemak/tokenlist";
8366
9733
  var getEthPriceAtBlock = async (wagmiConfig, blockNumber, chainId) => {
8367
- const config = getCoreConfig10(chainId);
9734
+ const config = getCoreConfig(chainId);
8368
9735
  const rootPriceOracle = config.rootPriceOracle;
8369
9736
  const weth = config.weth;
8370
- const usdc = USDC_TOKEN2.extensions?.bridgeInfo?.[chainId]?.tokenAddress || USDC_TOKEN2.address;
8371
- const priceAtBlock = await readContract16(wagmiConfig, {
9737
+ const usdc = USDC_TOKEN.extensions?.bridgeInfo?.[chainId]?.tokenAddress || USDC_TOKEN.address;
9738
+ const priceAtBlock = await readContract(wagmiConfig, {
8372
9739
  address: rootPriceOracle,
8373
9740
  abi: rootPriceOracleAbi,
8374
9741
  functionName: "getPriceInQuote",
@@ -8378,14 +9745,9 @@ var getEthPriceAtBlock = async (wagmiConfig, blockNumber, chainId) => {
8378
9745
  });
8379
9746
  return priceAtBlock;
8380
9747
  };
8381
-
8382
- // functions/getRebalanceStats.ts
8383
- import { formatEtherNum as formatEtherNum14, formatUnitsNum as formatUnitsNum5 } from "@tokemak/utils";
8384
- import { USDC_TOKEN as USDC_TOKEN3 } from "@tokemak/tokenlist";
8385
- import { sonic as sonic4 } from "viem/chains";
8386
9748
  var BATCH_SIZE = 500;
8387
9749
  var fetchChainRebalances = async (chainId) => {
8388
- const { GetAllAutopoolRebalances } = getSdkByChainId17(chainId);
9750
+ const { GetAllAutopoolRebalances } = getSdkByChainId(chainId);
8389
9751
  const allRebalances = await paginateQuery(
8390
9752
  GetAllAutopoolRebalances,
8391
9753
  "autopoolRebalances"
@@ -8399,10 +9761,10 @@ function inferBaseAssetDecimals(rebalance, chainId) {
8399
9761
  if (BigInt(rebalance.tokenOutValueBaseAsset) === BigInt(rebalance.tokenOutValueInEth)) {
8400
9762
  return 18;
8401
9763
  }
8402
- if (chainId === sonic4.id) {
9764
+ if (chainId === sonic.id) {
8403
9765
  return rebalance.tokenOut.decimals;
8404
9766
  }
8405
- return USDC_TOKEN3.decimals;
9767
+ return USDC_TOKEN.decimals;
8406
9768
  }
8407
9769
  var getRebalanceValueUsd = async (rebalance, chainId, wagmiConfig) => {
8408
9770
  const ethWei = BigInt(rebalance.tokenOutValueInEth || "0");
@@ -8414,8 +9776,8 @@ var getRebalanceValueUsd = async (rebalance, chainId, wagmiConfig) => {
8414
9776
  BigInt(rebalance.blockNumber),
8415
9777
  chainId
8416
9778
  );
8417
- const ethUsd = Number(formatUnitsNum5(price, USDC_TOKEN3.decimals));
8418
- const ethAmt = Number(formatEtherNum14(ethWei));
9779
+ const ethUsd = Number(formatUnitsNum(price, USDC_TOKEN.decimals));
9780
+ const ethAmt = Number(formatEtherNum(ethWei));
8419
9781
  const usd = ethAmt * ethUsd;
8420
9782
  return usd;
8421
9783
  } catch (e) {
@@ -8439,7 +9801,7 @@ var processRebalance = async (rebalance, chainId, wagmiConfig) => {
8439
9801
  }
8440
9802
  const baseDecimals = inferBaseAssetDecimals(rebalance, chainId);
8441
9803
  const baseUsd = Number(
8442
- formatUnitsNum5(
9804
+ formatUnitsNum(
8443
9805
  BigInt(rebalance.tokenOutValueBaseAsset || "0"),
8444
9806
  baseDecimals
8445
9807
  )
@@ -8527,104 +9889,18 @@ var updateRebalanceStats = async (wagmiConfig, {
8527
9889
  const allRebalances = [...currentRebalances, ...allNewRebalances];
8528
9890
  return calculateRebalanceStats(allRebalances);
8529
9891
  };
8530
- export {
8531
- AutopoolCategory,
8532
- BASE_ASSETS,
8533
- BATCH_SIZE,
8534
- ETH_BASE_ASSETS,
8535
- EUR_BASE_ASSETS,
8536
- MessageStatus,
8537
- PRICED_TOKENS,
8538
- USD_BASE_ASSETS,
8539
- aggregateSTokeRewardsDayData,
8540
- arraysToObject,
8541
- calculateRebalanceStats,
8542
- convertBaseAssetToTokenPrices,
8543
- convertBaseAssetToTokenPricesAndDenom,
8544
- fetchChainDataMap,
8545
- fetchChainRebalances,
8546
- fillMissingDates,
8547
- findClosestDateEntry,
8548
- findClosestEntry,
8549
- findClosestTimestampEntry,
8550
- formatDateRange,
8551
- getAddressFromSystemRegistry,
8552
- getAllowance,
8553
- getAmountDeposited,
8554
- getAmountWithdrawn,
8555
- getAutopilotRouter,
8556
- getAutopoolCategory,
8557
- getAutopoolDayData,
8558
- getAutopoolInfo,
8559
- getAutopoolRebalances,
8560
- getAutopools,
8561
- getAutopoolsHistory,
8562
- getAutopoolsRebalances,
8563
- getBridgeFee,
8564
- getChainAutopools,
8565
- getChainCycleRolloverBlockNumber,
8566
- getChainSToke,
8567
- getChainSTokeRewards,
8568
- getChainSubgraphStatus,
8569
- getChainUserActivity,
8570
- getChainUserAutopools,
8571
- getChainUserSToke,
8572
- getChainUserSTokeRewards,
8573
- getChainUserSTokeVotes,
8574
- getChainsForEnv,
8575
- getCurrentCycleId,
8576
- getCurveLP,
8577
- getCycleV1,
8578
- getDefillamaPrice,
8579
- getDynamicSwap,
8580
- getEthPrice,
8581
- getEthPriceAtBlock,
8582
- getExchangeNames,
8583
- getGenStratAprs,
8584
- getLayerzeroStatus,
8585
- getMutlipleAutopoolRebalances,
8586
- getPoolStats,
8587
- getPoolsAndDestinations,
8588
- getProtocolStats,
8589
- getRebalanceStats,
8590
- getRebalanceValueUsd,
8591
- getRewardsPayloadV1,
8592
- getSToke,
8593
- getSTokeChainsForEnv,
8594
- getSTokeRewards,
8595
- getSTokeVotes,
8596
- getSubgraphStatus,
8597
- getSushiLP,
8598
- getSwapQuote,
8599
- getSystemConfig,
8600
- getTimestampDaysFromStart,
8601
- getTokePrice,
8602
- getTokenList,
8603
- getTokenPrice,
8604
- getTokenPrices,
8605
- getTopAutopoolHolders,
8606
- getUserActivity,
8607
- getUserAutoEthRewards,
8608
- getUserAutopool,
8609
- getUserAutopools,
8610
- getUserAutopoolsHistory,
8611
- getUserAutopoolsRewards,
8612
- getUserCurveLP,
8613
- getUserRewardsV1,
8614
- getUserSToke,
8615
- getUserSTokeVotes,
8616
- getUserSushiLP,
8617
- getUserTokenBalances,
8618
- getUserV1,
8619
- mergeArrays,
8620
- mergeArraysWithKey,
8621
- mergeStringArrays,
8622
- modifyAutopoolName,
8623
- nestedArrayToObject,
8624
- paginateQuery,
8625
- processRebalance,
8626
- processRebalancesInBatches,
8627
- systemRegistryFunctionNames,
8628
- updateRebalanceStats,
8629
- waitForMessageReceived
8630
- };
9892
+ /*! Bundled license information:
9893
+
9894
+ ieee754/index.js:
9895
+ (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
9896
+
9897
+ buffer/index.js:
9898
+ (*!
9899
+ * The buffer module from node.js, for the browser.
9900
+ *
9901
+ * @author Feross Aboukhadijeh <https://feross.org>
9902
+ * @license MIT
9903
+ *)
9904
+ */
9905
+
9906
+ export { AutopoolCategory, BASE_ASSETS, BATCH_SIZE, ETH_BASE_ASSETS, EUR_BASE_ASSETS, MessageStatus, PRICED_TOKENS, USD_BASE_ASSETS, aggregateSTokeRewardsDayData, arraysToObject, calculateRebalanceStats, convertBaseAssetToTokenPrices, convertBaseAssetToTokenPricesAndDenom, fetchChainDataMap, fetchChainRebalances, fillMissingDates, findClosestDateEntry, findClosestEntry, findClosestTimestampEntry, formatDateRange, getAddressFromSystemRegistry, getAllowance, getAmountDeposited, getAmountWithdrawn, getAutopilotRouter, getAutopoolCategory, getAutopoolDayData, getAutopoolInfo, getAutopoolRebalances, getAutopools, getAutopoolsHistory, getAutopoolsRebalances, getBridgeFee, getChainAutopools, getChainCycleRolloverBlockNumber, getChainSToke, getChainSTokeRewards, getChainSubgraphStatus, getChainUserActivity, getChainUserAutopools, getChainUserSToke, getChainUserSTokeRewards, getChainUserSTokeVotes, getChainsForEnv, getCurrentCycleId, getCurveLP, getCycleV1, getDefillamaPrice, getDynamicSwap, getEthPrice, getEthPriceAtBlock, getExchangeNames, getGenStratAprs, getLayerzeroStatus, getMutlipleAutopoolRebalances, getPoolStats, getPoolsAndDestinations, getProtocolStats, getRebalanceStats, getRebalanceValueUsd, getRewardsPayloadV1, getSToke, getSTokeChainsForEnv, getSTokeRewards, getSTokeVotes, getSubgraphStatus, getSushiLP, getSwapQuote, getSystemConfig, getTimestampDaysFromStart, getTokePrice, getTokenList, getTokenPrice, getTokenPrices, getTopAutopoolHolders, getUserActivity, getUserAutoEthRewards, getUserAutopool, getUserAutopools, getUserAutopoolsHistory, getUserAutopoolsRewards, getUserCurveLP, getUserRewardsV1, getUserSToke, getUserSTokeVotes, getUserSushiLP, getUserTokenBalances, getUserV1, mergeArrays, mergeArraysWithKey, mergeStringArrays, modifyAutopoolName, nestedArrayToObject, paginateQuery, processRebalance, processRebalancesInBatches, systemRegistryFunctionNames, updateRebalanceStats, waitForMessageReceived };