@tokemak/queries 0.0.16 → 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +277 -138
- package/dist/index.d.ts +29 -1
- package/dist/index.js +227 -93
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -47,7 +47,7 @@ var require_bn = __commonJS({
|
|
|
47
47
|
ctor.prototype = new TempCtor();
|
|
48
48
|
ctor.prototype.constructor = ctor;
|
|
49
49
|
}
|
|
50
|
-
function BN2(number,
|
|
50
|
+
function BN2(number, base4, endian) {
|
|
51
51
|
if (BN2.isBN(number)) {
|
|
52
52
|
return number;
|
|
53
53
|
}
|
|
@@ -56,11 +56,11 @@ var require_bn = __commonJS({
|
|
|
56
56
|
this.length = 0;
|
|
57
57
|
this.red = null;
|
|
58
58
|
if (number !== null) {
|
|
59
|
-
if (
|
|
60
|
-
endian =
|
|
61
|
-
|
|
59
|
+
if (base4 === "le" || base4 === "be") {
|
|
60
|
+
endian = base4;
|
|
61
|
+
base4 = 10;
|
|
62
62
|
}
|
|
63
|
-
this._init(number || 0,
|
|
63
|
+
this._init(number || 0, base4 || 10, endian || "be");
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
if (typeof module3 === "object") {
|
|
@@ -95,17 +95,17 @@ var require_bn = __commonJS({
|
|
|
95
95
|
return left;
|
|
96
96
|
return right;
|
|
97
97
|
};
|
|
98
|
-
BN2.prototype._init = function init(number,
|
|
98
|
+
BN2.prototype._init = function init(number, base4, endian) {
|
|
99
99
|
if (typeof number === "number") {
|
|
100
|
-
return this._initNumber(number,
|
|
100
|
+
return this._initNumber(number, base4, endian);
|
|
101
101
|
}
|
|
102
102
|
if (typeof number === "object") {
|
|
103
|
-
return this._initArray(number,
|
|
103
|
+
return this._initArray(number, base4, endian);
|
|
104
104
|
}
|
|
105
|
-
if (
|
|
106
|
-
|
|
105
|
+
if (base4 === "hex") {
|
|
106
|
+
base4 = 16;
|
|
107
107
|
}
|
|
108
|
-
assert(
|
|
108
|
+
assert(base4 === (base4 | 0) && base4 >= 2 && base4 <= 36);
|
|
109
109
|
number = number.toString().replace(/\s+/g, "");
|
|
110
110
|
var start = 0;
|
|
111
111
|
if (number[0] === "-") {
|
|
@@ -113,17 +113,17 @@ var require_bn = __commonJS({
|
|
|
113
113
|
this.negative = 1;
|
|
114
114
|
}
|
|
115
115
|
if (start < number.length) {
|
|
116
|
-
if (
|
|
116
|
+
if (base4 === 16) {
|
|
117
117
|
this._parseHex(number, start, endian);
|
|
118
118
|
} else {
|
|
119
|
-
this._parseBase(number,
|
|
119
|
+
this._parseBase(number, base4, start);
|
|
120
120
|
if (endian === "le") {
|
|
121
|
-
this._initArray(this.toArray(),
|
|
121
|
+
this._initArray(this.toArray(), base4, endian);
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
};
|
|
126
|
-
BN2.prototype._initNumber = function _initNumber(number,
|
|
126
|
+
BN2.prototype._initNumber = function _initNumber(number, base4, endian) {
|
|
127
127
|
if (number < 0) {
|
|
128
128
|
this.negative = 1;
|
|
129
129
|
number = -number;
|
|
@@ -148,9 +148,9 @@ var require_bn = __commonJS({
|
|
|
148
148
|
}
|
|
149
149
|
if (endian !== "le")
|
|
150
150
|
return;
|
|
151
|
-
this._initArray(this.toArray(),
|
|
151
|
+
this._initArray(this.toArray(), base4, endian);
|
|
152
152
|
};
|
|
153
|
-
BN2.prototype._initArray = function _initArray(number,
|
|
153
|
+
BN2.prototype._initArray = function _initArray(number, base4, endian) {
|
|
154
154
|
assert(typeof number.length === "number");
|
|
155
155
|
if (number.length <= 0) {
|
|
156
156
|
this.words = [0];
|
|
@@ -264,20 +264,20 @@ var require_bn = __commonJS({
|
|
|
264
264
|
}
|
|
265
265
|
return r;
|
|
266
266
|
}
|
|
267
|
-
BN2.prototype._parseBase = function _parseBase(number,
|
|
267
|
+
BN2.prototype._parseBase = function _parseBase(number, base4, start) {
|
|
268
268
|
this.words = [0];
|
|
269
269
|
this.length = 1;
|
|
270
|
-
for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *=
|
|
270
|
+
for (var limbLen = 0, limbPow = 1; limbPow <= 67108863; limbPow *= base4) {
|
|
271
271
|
limbLen++;
|
|
272
272
|
}
|
|
273
273
|
limbLen--;
|
|
274
|
-
limbPow = limbPow /
|
|
274
|
+
limbPow = limbPow / base4 | 0;
|
|
275
275
|
var total = number.length - start;
|
|
276
276
|
var mod = total % limbLen;
|
|
277
277
|
var end = Math.min(total, total - mod) + start;
|
|
278
278
|
var word = 0;
|
|
279
279
|
for (var i = start; i < end; i += limbLen) {
|
|
280
|
-
word = parseBase(number, i, i + limbLen,
|
|
280
|
+
word = parseBase(number, i, i + limbLen, base4);
|
|
281
281
|
this.imuln(limbPow);
|
|
282
282
|
if (this.words[0] + word < 67108864) {
|
|
283
283
|
this.words[0] += word;
|
|
@@ -287,9 +287,9 @@ var require_bn = __commonJS({
|
|
|
287
287
|
}
|
|
288
288
|
if (mod !== 0) {
|
|
289
289
|
var pow = 1;
|
|
290
|
-
word = parseBase(number, i, number.length,
|
|
290
|
+
word = parseBase(number, i, number.length, base4);
|
|
291
291
|
for (i = 0; i < mod; i++) {
|
|
292
|
-
pow *=
|
|
292
|
+
pow *= base4;
|
|
293
293
|
}
|
|
294
294
|
this.imuln(pow);
|
|
295
295
|
if (this.words[0] + word < 67108864) {
|
|
@@ -459,11 +459,11 @@ var require_bn = __commonJS({
|
|
|
459
459
|
52521875,
|
|
460
460
|
60466176
|
|
461
461
|
];
|
|
462
|
-
BN2.prototype.toString = function toString(
|
|
463
|
-
|
|
462
|
+
BN2.prototype.toString = function toString(base4, padding) {
|
|
463
|
+
base4 = base4 || 10;
|
|
464
464
|
padding = padding | 0 || 1;
|
|
465
465
|
var out;
|
|
466
|
-
if (
|
|
466
|
+
if (base4 === 16 || base4 === "hex") {
|
|
467
467
|
out = "";
|
|
468
468
|
var off = 0;
|
|
469
469
|
var carry = 0;
|
|
@@ -493,14 +493,14 @@ var require_bn = __commonJS({
|
|
|
493
493
|
}
|
|
494
494
|
return out;
|
|
495
495
|
}
|
|
496
|
-
if (
|
|
497
|
-
var groupSize = groupSizes[
|
|
498
|
-
var groupBase = groupBases[
|
|
496
|
+
if (base4 === (base4 | 0) && base4 >= 2 && base4 <= 36) {
|
|
497
|
+
var groupSize = groupSizes[base4];
|
|
498
|
+
var groupBase = groupBases[base4];
|
|
499
499
|
out = "";
|
|
500
500
|
var c = this.clone();
|
|
501
501
|
c.negative = 0;
|
|
502
502
|
while (!c.isZero()) {
|
|
503
|
-
var r = c.modrn(groupBase).toString(
|
|
503
|
+
var r = c.modrn(groupBase).toString(base4);
|
|
504
504
|
c = c.idivn(groupBase);
|
|
505
505
|
if (!c.isZero()) {
|
|
506
506
|
out = zeros[groupSize - r.length] + r + out;
|
|
@@ -2971,7 +2971,7 @@ var require_bn = __commonJS({
|
|
|
2971
2971
|
var require_src = __commonJS({
|
|
2972
2972
|
"../../node_modules/@layerzerolabs/lz-v2-utilities/node_modules/base-x/src/index.js"(exports, module2) {
|
|
2973
2973
|
"use strict";
|
|
2974
|
-
function
|
|
2974
|
+
function base4(ALPHABET) {
|
|
2975
2975
|
if (ALPHABET.length >= 255) {
|
|
2976
2976
|
throw new TypeError("Alphabet too long");
|
|
2977
2977
|
}
|
|
@@ -3099,7 +3099,7 @@ var require_src = __commonJS({
|
|
|
3099
3099
|
decode
|
|
3100
3100
|
};
|
|
3101
3101
|
}
|
|
3102
|
-
module2.exports =
|
|
3102
|
+
module2.exports = base4;
|
|
3103
3103
|
}
|
|
3104
3104
|
});
|
|
3105
3105
|
|
|
@@ -3142,10 +3142,12 @@ __export(queries_exports, {
|
|
|
3142
3142
|
getAutopilotRouter: () => getAutopilotRouter,
|
|
3143
3143
|
getAutopoolCategory: () => getAutopoolCategory,
|
|
3144
3144
|
getAutopoolDayData: () => getAutopoolDayData,
|
|
3145
|
+
getAutopoolHistory: () => getAutopoolHistory,
|
|
3145
3146
|
getAutopoolInfo: () => getAutopoolInfo,
|
|
3146
3147
|
getAutopoolRebalances: () => getAutopoolRebalances,
|
|
3147
3148
|
getAutopoolUser: () => getAutopoolUser,
|
|
3148
3149
|
getAutopoolUserActivity: () => getAutopoolUserActivity,
|
|
3150
|
+
getAutopoolUserHistory: () => getAutopoolUserHistory,
|
|
3149
3151
|
getAutopools: () => getAutopools,
|
|
3150
3152
|
getAutopoolsHistory: () => getAutopoolsHistory,
|
|
3151
3153
|
getAutopoolsRebalances: () => getAutopoolsRebalances,
|
|
@@ -4834,7 +4836,7 @@ var getChainUserAutopoolsHistory = async ({
|
|
|
4834
4836
|
}
|
|
4835
4837
|
};
|
|
4836
4838
|
|
|
4837
|
-
// functions/
|
|
4839
|
+
// functions/processUserHistory.ts
|
|
4838
4840
|
var import_utils15 = require("@tokemak/utils");
|
|
4839
4841
|
|
|
4840
4842
|
// functions/getTokenValueDayDatas.ts
|
|
@@ -5055,27 +5057,22 @@ var getHistoricalTokenPrices = async () => {
|
|
|
5055
5057
|
return historicalTokenPrices;
|
|
5056
5058
|
};
|
|
5057
5059
|
|
|
5058
|
-
// functions/
|
|
5059
|
-
var ONE_DAY_IN_MS = 24 * 60 * 60 * 1e3;
|
|
5060
|
+
// functions/processUserHistory.ts
|
|
5060
5061
|
function validateEnhancedUserHistoryEntry(entry) {
|
|
5061
5062
|
return entry && typeof entry === "object" && entry.date instanceof Date && typeof entry.timestamp === "string" && Array.isArray(entry.autopools) && entry.nav && typeof entry.nav.ETH === "number" && typeof entry.nav.USD === "number" && typeof entry.nav.PXETH === "number" && typeof entry.nav.USDC === "number" && typeof entry.nav.EURC === "number" && typeof entry.nav.USDT === "number" && Array.isArray(entry.events) && typeof entry.differential === "number";
|
|
5062
5063
|
}
|
|
5063
|
-
var
|
|
5064
|
+
var processUserHistory = async ({
|
|
5065
|
+
address,
|
|
5066
|
+
autopoolsHistory,
|
|
5067
|
+
events,
|
|
5068
|
+
userHistory
|
|
5069
|
+
}) => {
|
|
5064
5070
|
if (!autopoolsHistory) {
|
|
5065
5071
|
throw new Error("No autopools history found");
|
|
5066
5072
|
}
|
|
5067
5073
|
if (!events) {
|
|
5068
5074
|
throw new Error("No events found");
|
|
5069
5075
|
}
|
|
5070
|
-
const chains = getChainsForEnv({ includeTestnet });
|
|
5071
|
-
const userHistory = (await Promise.all(
|
|
5072
|
-
chains.map(
|
|
5073
|
-
(chain) => getChainUserAutopoolsHistory({
|
|
5074
|
-
address,
|
|
5075
|
-
chainId: chain.chainId
|
|
5076
|
-
})
|
|
5077
|
-
)
|
|
5078
|
-
)).flat();
|
|
5079
5076
|
const groupedByVault = userHistory.reduce((acc, data) => {
|
|
5080
5077
|
const vaultId = data.vaultAddress.toLowerCase();
|
|
5081
5078
|
if (!acc[vaultId]) {
|
|
@@ -5257,6 +5254,32 @@ var getUserAutopoolsHistory = async (address, autopoolsHistory, events, includeT
|
|
|
5257
5254
|
return result;
|
|
5258
5255
|
};
|
|
5259
5256
|
|
|
5257
|
+
// functions/getUserAutopoolsHistory.ts
|
|
5258
|
+
var getUserAutopoolsHistory = async (address, autopoolsHistory, events, includeTestnet = false) => {
|
|
5259
|
+
if (!autopoolsHistory) {
|
|
5260
|
+
throw new Error("No autopools history found");
|
|
5261
|
+
}
|
|
5262
|
+
if (!events) {
|
|
5263
|
+
throw new Error("No events found");
|
|
5264
|
+
}
|
|
5265
|
+
const chains = getChainsForEnv({ includeTestnet });
|
|
5266
|
+
const userHistory = (await Promise.all(
|
|
5267
|
+
chains.map(
|
|
5268
|
+
(chain) => getChainUserAutopoolsHistory({
|
|
5269
|
+
address,
|
|
5270
|
+
chainId: chain.chainId
|
|
5271
|
+
})
|
|
5272
|
+
)
|
|
5273
|
+
)).flat();
|
|
5274
|
+
const processedHistory = await processUserHistory({
|
|
5275
|
+
address,
|
|
5276
|
+
autopoolsHistory,
|
|
5277
|
+
events,
|
|
5278
|
+
userHistory
|
|
5279
|
+
});
|
|
5280
|
+
return processedHistory;
|
|
5281
|
+
};
|
|
5282
|
+
|
|
5260
5283
|
// functions/getUserSushiLP.ts
|
|
5261
5284
|
var import_core6 = require("@wagmi/core");
|
|
5262
5285
|
var import_abis6 = require("@tokemak/abis");
|
|
@@ -5417,7 +5440,7 @@ var getMutlipleAutopoolRebalances = async (ids, chainId = 1) => {
|
|
|
5417
5440
|
|
|
5418
5441
|
// functions/getAutopoolDayData.ts
|
|
5419
5442
|
var import_viem7 = require("viem");
|
|
5420
|
-
var
|
|
5443
|
+
var import_utils18 = require("@tokemak/utils");
|
|
5421
5444
|
var import_constants9 = require("@tokemak/constants");
|
|
5422
5445
|
var import_graph_cli9 = require("@tokemak/graph-cli");
|
|
5423
5446
|
var getAutopoolDayData = async (address, chainId = 1, startTimestamp = import_constants9.TOKEMAK_LAUNCH_TIMESTAMP) => {
|
|
@@ -5431,10 +5454,10 @@ var getAutopoolDayData = async (address, chainId = 1, startTimestamp = import_co
|
|
|
5431
5454
|
const navPerShare = autoPoolDayData.nav / autoPoolDayData.totalSupply;
|
|
5432
5455
|
let baseApy = autoPoolDayData.autopoolApy;
|
|
5433
5456
|
let rewarderApy = 0;
|
|
5434
|
-
const formattedRewarder7DayMAApy = (0,
|
|
5457
|
+
const formattedRewarder7DayMAApy = (0, import_utils18.formatEtherNum)(
|
|
5435
5458
|
BigInt(Number(autoPoolDayData.rewarderDay7MAApy) || 0)
|
|
5436
5459
|
);
|
|
5437
|
-
const formattedRewarder30DayMAApy = (0,
|
|
5460
|
+
const formattedRewarder30DayMAApy = (0, import_utils18.formatEtherNum)(
|
|
5438
5461
|
BigInt(Number(autoPoolDayData.rewarderDay30MAApy) || 0)
|
|
5439
5462
|
);
|
|
5440
5463
|
if (formattedRewarder7DayMAApy) {
|
|
@@ -5534,13 +5557,13 @@ var getChainUserAutopools = async ({
|
|
|
5534
5557
|
};
|
|
5535
5558
|
|
|
5536
5559
|
// functions/getUserAutopools.ts
|
|
5537
|
-
var
|
|
5560
|
+
var import_utils20 = require("@tokemak/utils");
|
|
5538
5561
|
var import_tokenlist6 = require("@tokemak/tokenlist");
|
|
5539
5562
|
|
|
5540
5563
|
// functions/getUserAutopool.tsx
|
|
5541
5564
|
var import_viem8 = require("viem");
|
|
5542
5565
|
var import_core9 = require("@wagmi/core");
|
|
5543
|
-
var
|
|
5566
|
+
var import_utils19 = require("@tokemak/utils");
|
|
5544
5567
|
var import_abis9 = require("@tokemak/abis");
|
|
5545
5568
|
var getUserAutopool = async (wagmiConfig, {
|
|
5546
5569
|
address,
|
|
@@ -5589,10 +5612,10 @@ var getUserAutopool = async (wagmiConfig, {
|
|
|
5589
5612
|
args: [address],
|
|
5590
5613
|
chainId: autopool?.chain?.chainId
|
|
5591
5614
|
});
|
|
5592
|
-
const stakedShares = (0,
|
|
5615
|
+
const stakedShares = (0, import_utils19.formatEtherNum)(stakedPoolShares);
|
|
5593
5616
|
const stakedNav = stakedShares * (autopool?.navPerShare.baseAsset || 0);
|
|
5594
5617
|
const stakedNavUsd = stakedShares * (autopool?.navPerShare.USD || 0);
|
|
5595
|
-
const unstakedShares = (0,
|
|
5618
|
+
const unstakedShares = (0, import_utils19.formatEtherNum)(unstakedPoolShares || 0n);
|
|
5596
5619
|
const unstakedNav = unstakedShares * (autopool?.navPerShare.USD || 0);
|
|
5597
5620
|
const unstakedNavUsd = unstakedShares * (autopool?.navPerShare.USD || 0);
|
|
5598
5621
|
const totalShares = unstakedShares + stakedShares;
|
|
@@ -5613,7 +5636,7 @@ var getUserAutopool = async (wagmiConfig, {
|
|
|
5613
5636
|
});
|
|
5614
5637
|
pastRewarderBalances = pastRewards.map(({ result }, index) => {
|
|
5615
5638
|
const balance = result;
|
|
5616
|
-
const shares = (0,
|
|
5639
|
+
const shares = (0, import_utils19.formatEtherNum)(result);
|
|
5617
5640
|
const nav = shares * (autopool?.navPerShare.baseAsset || 0);
|
|
5618
5641
|
const navUsd = shares * (autopool?.navPerShare.USD || 0);
|
|
5619
5642
|
return {
|
|
@@ -5731,14 +5754,14 @@ var getUserAutopools = async ({
|
|
|
5731
5754
|
);
|
|
5732
5755
|
if (autopoolData) {
|
|
5733
5756
|
const isDOLA = autopoolData.symbol === "autoDOLA" && userAutoDOLA;
|
|
5734
|
-
const userShares = isDOLA ? userAutoDOLA?.totalShares : (0,
|
|
5735
|
-
const totalVaultShares = (0,
|
|
5757
|
+
const userShares = isDOLA ? userAutoDOLA?.totalShares : (0, import_utils20.formatEtherNum)(userAutopool?.totalShares);
|
|
5758
|
+
const totalVaultShares = (0, import_utils20.formatEtherNum)(autopoolData?.totalSupply);
|
|
5736
5759
|
const userShareOfVault = userShares / totalVaultShares;
|
|
5737
|
-
const totalDeposits = (0,
|
|
5760
|
+
const totalDeposits = (0, import_utils20.formatUnitsNum)(
|
|
5738
5761
|
userActivity?.totals[userAutopool.vaultAddress]?.totalDeposits || 0n,
|
|
5739
5762
|
autopoolData?.baseAsset.decimals
|
|
5740
5763
|
);
|
|
5741
|
-
const totalWithdrawals = (0,
|
|
5764
|
+
const totalWithdrawals = (0, import_utils20.formatUnitsNum)(
|
|
5742
5765
|
userActivity?.totals[userAutopool.vaultAddress]?.totalWithdrawals || 0n,
|
|
5743
5766
|
autopoolData?.baseAsset.decimals
|
|
5744
5767
|
);
|
|
@@ -5747,7 +5770,7 @@ var getUserAutopools = async ({
|
|
|
5747
5770
|
);
|
|
5748
5771
|
let lastDeposit;
|
|
5749
5772
|
if (poolEvents && poolEvents?.length > 0) {
|
|
5750
|
-
lastDeposit = (0,
|
|
5773
|
+
lastDeposit = (0, import_utils20.convertTimestampToDate)(
|
|
5751
5774
|
poolEvents[poolEvents.length - 1].timestamp
|
|
5752
5775
|
).toLocaleDateString("en-US", {
|
|
5753
5776
|
day: "2-digit",
|
|
@@ -5792,6 +5815,7 @@ var getUserAutopools = async ({
|
|
|
5792
5815
|
};
|
|
5793
5816
|
}
|
|
5794
5817
|
});
|
|
5818
|
+
console.log(totalWithdrawals, totalDeposits);
|
|
5795
5819
|
const userNav = userShares * autopoolData?.navPerShare.baseAsset;
|
|
5796
5820
|
const userReturns = userNav + totalWithdrawals - totalDeposits;
|
|
5797
5821
|
const userSupplied = totalDeposits - totalWithdrawals;
|
|
@@ -5847,7 +5871,7 @@ var getUserAutopools = async ({
|
|
|
5847
5871
|
totalWithdrawals: prev.totalWithdrawals + totalWithdrawals
|
|
5848
5872
|
};
|
|
5849
5873
|
const stakedBalance = isDOLA ? userAutoDOLA?.staked.balance : BigInt(userAutopool?.stakedShares);
|
|
5850
|
-
const stakedShares = isDOLA ? userAutoDOLA?.staked.shares : (0,
|
|
5874
|
+
const stakedShares = isDOLA ? userAutoDOLA?.staked.shares : (0, import_utils20.formatEtherNum)(stakedBalance);
|
|
5851
5875
|
const stakedNav = stakedShares * (autopoolData?.navPerShare.baseAsset || 0);
|
|
5852
5876
|
const staked = convertBaseAssetToTokenPrices(
|
|
5853
5877
|
stakedNav,
|
|
@@ -5855,7 +5879,7 @@ var getUserAutopools = async ({
|
|
|
5855
5879
|
prices
|
|
5856
5880
|
);
|
|
5857
5881
|
const unstakedBalance = isDOLA ? userAutoDOLA?.unstaked.balance : BigInt(userAutopool?.walletShares);
|
|
5858
|
-
const unstakedShares = isDOLA ? userAutoDOLA?.unstaked.shares : (0,
|
|
5882
|
+
const unstakedShares = isDOLA ? userAutoDOLA?.unstaked.shares : (0, import_utils20.formatEtherNum)(unstakedBalance);
|
|
5859
5883
|
const unstakedNav = unstakedShares * (autopoolData?.navPerShare.baseAsset || 0);
|
|
5860
5884
|
const unstaked = convertBaseAssetToTokenPrices(
|
|
5861
5885
|
unstakedNav,
|
|
@@ -6166,6 +6190,7 @@ var getUserActivity = async ({
|
|
|
6166
6190
|
(chain) => getChainUserActivity(address, chain.chainId)
|
|
6167
6191
|
)
|
|
6168
6192
|
);
|
|
6193
|
+
console.log(userActivities);
|
|
6169
6194
|
const mergedActivity = userActivities.reduce(
|
|
6170
6195
|
(acc, chainActivity) => {
|
|
6171
6196
|
if (chainActivity?.events) {
|
|
@@ -6230,7 +6255,7 @@ var getChainUserAutopoolsRewards = async (wagmiConfig, {
|
|
|
6230
6255
|
};
|
|
6231
6256
|
|
|
6232
6257
|
// functions/getUserAutopoolsRewards.ts
|
|
6233
|
-
var
|
|
6258
|
+
var import_utils24 = require("@tokemak/utils");
|
|
6234
6259
|
var import_tokenlist8 = require("@tokemak/tokenlist");
|
|
6235
6260
|
var import_chains7 = require("viem/chains");
|
|
6236
6261
|
var getUserAutopoolsRewards = async (wagmiConfig, {
|
|
@@ -6262,7 +6287,7 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
|
|
|
6262
6287
|
return [];
|
|
6263
6288
|
}
|
|
6264
6289
|
return autopool.extraRewarders.map((extraRewards2) => {
|
|
6265
|
-
const rewarderToken = (0,
|
|
6290
|
+
const rewarderToken = (0, import_utils24.getToken)(
|
|
6266
6291
|
extraRewards2.rewardToken?.id,
|
|
6267
6292
|
autopool.chain?.chainId
|
|
6268
6293
|
);
|
|
@@ -6271,7 +6296,7 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
|
|
|
6271
6296
|
if (rewarderToken.symbol === "XSILO") {
|
|
6272
6297
|
price = tokenPrices[import_tokenlist8.SILO_TOKEN.symbol] || 0;
|
|
6273
6298
|
}
|
|
6274
|
-
const formattedAmount = (0,
|
|
6299
|
+
const formattedAmount = (0, import_utils24.formatUnitsNum)(
|
|
6275
6300
|
claimableAmount,
|
|
6276
6301
|
rewarderToken.decimals || 18
|
|
6277
6302
|
);
|
|
@@ -6289,7 +6314,7 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
|
|
|
6289
6314
|
const tokenRewards = {};
|
|
6290
6315
|
Object.values(chainUserRewards).forEach((autopoolRewards) => {
|
|
6291
6316
|
Object.entries(autopoolRewards).forEach(([tokenAddress, amount]) => {
|
|
6292
|
-
const token = (0,
|
|
6317
|
+
const token = (0, import_utils24.getToken)(tokenAddress, chainId);
|
|
6293
6318
|
const tokenSymbol = token.symbol;
|
|
6294
6319
|
if (!tokenRewards[tokenSymbol]) {
|
|
6295
6320
|
tokenRewards[tokenSymbol] = {
|
|
@@ -6309,7 +6334,7 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
|
|
|
6309
6334
|
if (tokenSymbol === "XSILO") {
|
|
6310
6335
|
price = tokenPrices[import_tokenlist8.SILO_TOKEN.symbol] || 0;
|
|
6311
6336
|
}
|
|
6312
|
-
const formattedAmount = (0,
|
|
6337
|
+
const formattedAmount = (0, import_utils24.formatUnitsNum)(amount, decimals || 18);
|
|
6313
6338
|
tokenRewards[tokenSymbol] = {
|
|
6314
6339
|
amount,
|
|
6315
6340
|
formattedAmount,
|
|
@@ -6380,7 +6405,7 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
|
|
|
6380
6405
|
|
|
6381
6406
|
// functions/getAmountWithdrawn.ts
|
|
6382
6407
|
var import_viem13 = require("viem");
|
|
6383
|
-
var
|
|
6408
|
+
var import_utils26 = require("@tokemak/utils");
|
|
6384
6409
|
|
|
6385
6410
|
// functions/getSwapQuote.ts
|
|
6386
6411
|
var import_constants10 = require("@tokemak/constants");
|
|
@@ -6595,7 +6620,7 @@ var getAmountWithdrawn = async ({
|
|
|
6595
6620
|
let quote;
|
|
6596
6621
|
let convertedAssets;
|
|
6597
6622
|
if (!!dynamicSwap?.previewRedeem) {
|
|
6598
|
-
const minAmountWithSlippage = (0,
|
|
6623
|
+
const minAmountWithSlippage = (0, import_utils26.calculateMinAmountWithSlippage)(
|
|
6599
6624
|
dynamicSwap?.previewRedeem,
|
|
6600
6625
|
slippage
|
|
6601
6626
|
);
|
|
@@ -6619,7 +6644,7 @@ var getAmountWithdrawn = async ({
|
|
|
6619
6644
|
buyToken,
|
|
6620
6645
|
sellToken,
|
|
6621
6646
|
sellAmount: dynamicSwap?.previewRedeem,
|
|
6622
|
-
slippageBps: (0,
|
|
6647
|
+
slippageBps: (0, import_utils26.convertNumToBps)(slippage),
|
|
6623
6648
|
chainId,
|
|
6624
6649
|
includeSources: "0xV2",
|
|
6625
6650
|
sellAll: true
|
|
@@ -6647,7 +6672,7 @@ var getAmountWithdrawn = async ({
|
|
|
6647
6672
|
// functions/getAmountDeposited.ts
|
|
6648
6673
|
var import_core15 = require("@wagmi/core");
|
|
6649
6674
|
var import_abis14 = require("@tokemak/abis");
|
|
6650
|
-
var
|
|
6675
|
+
var import_utils27 = require("@tokemak/utils");
|
|
6651
6676
|
var getAmountDeposited = async ({
|
|
6652
6677
|
address,
|
|
6653
6678
|
chainId,
|
|
@@ -6668,13 +6693,13 @@ var getAmountDeposited = async ({
|
|
|
6668
6693
|
chainId
|
|
6669
6694
|
});
|
|
6670
6695
|
if (!isSwap) {
|
|
6671
|
-
let minAmountWithSlippage = (0,
|
|
6696
|
+
let minAmountWithSlippage = (0, import_utils27.calculateMinAmountWithSlippage)(
|
|
6672
6697
|
previewDeposit,
|
|
6673
6698
|
slippage
|
|
6674
6699
|
);
|
|
6675
|
-
return (0,
|
|
6700
|
+
return (0, import_utils27.formatEtherNum)(minAmountWithSlippage);
|
|
6676
6701
|
} else {
|
|
6677
|
-
return (0,
|
|
6702
|
+
return (0, import_utils27.formatEtherNum)(previewDeposit);
|
|
6678
6703
|
}
|
|
6679
6704
|
} catch (e) {
|
|
6680
6705
|
console.error(e);
|
|
@@ -7536,7 +7561,7 @@ var waitForMessageReceived = async ({
|
|
|
7536
7561
|
// functions/getChainUserSToke.ts
|
|
7537
7562
|
var import_abis17 = require("@tokemak/abis");
|
|
7538
7563
|
var import_config13 = require("@tokemak/config");
|
|
7539
|
-
var
|
|
7564
|
+
var import_utils28 = require("@tokemak/utils");
|
|
7540
7565
|
var import_core18 = require("@wagmi/core");
|
|
7541
7566
|
var import_viem15 = require("viem");
|
|
7542
7567
|
var import_chains9 = require("viem/chains");
|
|
@@ -7612,8 +7637,8 @@ var getChainUserSToke = async (wagmiConfig, {
|
|
|
7612
7637
|
if (withdrawalAmount > 0n && cycleIndex >= withdrawalMinCycle) {
|
|
7613
7638
|
balanceExcludingWithdrawal = balanceExcludingWithdrawal - withdrawalAmount;
|
|
7614
7639
|
}
|
|
7615
|
-
const withdrawalAmountUsd = (0,
|
|
7616
|
-
(0,
|
|
7640
|
+
const withdrawalAmountUsd = (0, import_utils28.formatCurrency)(
|
|
7641
|
+
(0, import_utils28.formatEtherNum)(withdrawalAmount) * tokePrice
|
|
7617
7642
|
);
|
|
7618
7643
|
const lockDuration = Number(depositLockDuration);
|
|
7619
7644
|
const lockCycle = Number(depositLockCycle);
|
|
@@ -7634,16 +7659,16 @@ var getChainUserSToke = async (wagmiConfig, {
|
|
|
7634
7659
|
const withdrawAvailable = lockRenew - 1;
|
|
7635
7660
|
const hasAddedLockedToke = depositAmount > 0n && depositAmount > rolloverDepositAmount;
|
|
7636
7661
|
const addedLockedToke = depositAmount - rolloverDepositAmount;
|
|
7637
|
-
const balanceUSD = (0,
|
|
7662
|
+
const balanceUSD = (0, import_utils28.formatCurrency)(
|
|
7638
7663
|
Number((0, import_viem15.formatEther)(balanceExcludingWithdrawal)) * tokePrice
|
|
7639
7664
|
);
|
|
7640
|
-
const balanceExcludingWithdrawalUsd = (0,
|
|
7641
|
-
(0,
|
|
7665
|
+
const balanceExcludingWithdrawalUsd = (0, import_utils28.formatCurrency)(
|
|
7666
|
+
(0, import_utils28.formatEtherNum)(balanceExcludingWithdrawal) * tokePrice
|
|
7642
7667
|
);
|
|
7643
7668
|
const isUnlockRequestAvailable = currentCycle === withdrawAvailable;
|
|
7644
7669
|
const hasRequestedUnlock = withdrawalAmount > 0n;
|
|
7645
|
-
const unlockRequestPeriodStartUnix = (0,
|
|
7646
|
-
const unlockRequestPeriodEndUnix = (0,
|
|
7670
|
+
const unlockRequestPeriodStartUnix = (0, import_utils28.convertChainCycleToUnix)(withdrawAvailable, chainId) - Date.now() / 1e3;
|
|
7671
|
+
const unlockRequestPeriodEndUnix = (0, import_utils28.convertChainCycleToUnix)(lockRenew, chainId) - Date.now() / 1e3;
|
|
7647
7672
|
const hasBalance = balance > 0n;
|
|
7648
7673
|
const hasBalanceExcludingWithdrawal = balanceExcludingWithdrawal > 0n;
|
|
7649
7674
|
const hasUnlockableBalance = withdrawalMinCycle <= currentCycle && withdrawalAmount > 0n;
|
|
@@ -7653,8 +7678,8 @@ var getChainUserSToke = async (wagmiConfig, {
|
|
|
7653
7678
|
lockDurationInMonths = lockDuration - 1;
|
|
7654
7679
|
}
|
|
7655
7680
|
const unlockPeriodDateRangeArray = [
|
|
7656
|
-
new Date((0,
|
|
7657
|
-
new Date((0,
|
|
7681
|
+
new Date((0, import_utils28.convertChainCycleToUnix)(withdrawAvailable, chainId) * 1e3),
|
|
7682
|
+
new Date((0, import_utils28.convertChainCycleToUnix)(lockRenew, chainId) * 1e3)
|
|
7658
7683
|
];
|
|
7659
7684
|
const {
|
|
7660
7685
|
unlockPeriodDateRange,
|
|
@@ -7666,18 +7691,18 @@ var getChainUserSToke = async (wagmiConfig, {
|
|
|
7666
7691
|
unlockPeriodDateRangeArray,
|
|
7667
7692
|
chainId === import_chains9.sepolia.id ? "time" : "date"
|
|
7668
7693
|
);
|
|
7669
|
-
const totalActiveUserCredits = (0,
|
|
7670
|
-
const totalUserCredits = (0,
|
|
7694
|
+
const totalActiveUserCredits = (0, import_utils28.formatEtherNum)(balanceExcludingWithdrawal) * lockDurationInMonths;
|
|
7695
|
+
const totalUserCredits = (0, import_utils28.formatEtherNum)(balance) * lockDurationInMonths;
|
|
7671
7696
|
return {
|
|
7672
7697
|
balance,
|
|
7673
7698
|
balanceUSD,
|
|
7674
7699
|
balanceExcludingWithdrawal: hasBalance ? (0, import_viem15.formatEther)(balanceExcludingWithdrawal) : "0.00",
|
|
7675
7700
|
balanceExcludingWithdrawalUsd,
|
|
7676
7701
|
hasBalanceExcludingWithdrawal,
|
|
7677
|
-
timeLeftBeforeUnlockRequestAvailable: (0,
|
|
7702
|
+
timeLeftBeforeUnlockRequestAvailable: (0, import_utils28.convertSecondsToRemainingTime)(
|
|
7678
7703
|
unlockRequestPeriodStartUnix
|
|
7679
7704
|
),
|
|
7680
|
-
timeLeftBeforeUnlockRequestUnavailable: (0,
|
|
7705
|
+
timeLeftBeforeUnlockRequestUnavailable: (0, import_utils28.convertSecondsToRemainingTime)(
|
|
7681
7706
|
unlockRequestPeriodEndUnix
|
|
7682
7707
|
),
|
|
7683
7708
|
withdrawalAmount,
|
|
@@ -7694,7 +7719,7 @@ var getChainUserSToke = async (wagmiConfig, {
|
|
|
7694
7719
|
unlockRenewalDate,
|
|
7695
7720
|
lockDurationInMonths,
|
|
7696
7721
|
boost: lockDuration,
|
|
7697
|
-
points: (0,
|
|
7722
|
+
points: (0, import_utils28.formatEtherNum)(balanceExcludingWithdrawal) * lockDuration,
|
|
7698
7723
|
totalActiveCredits: totalActiveUserCredits,
|
|
7699
7724
|
totalCredits: totalUserCredits
|
|
7700
7725
|
};
|
|
@@ -7706,7 +7731,7 @@ var getChainUserSToke = async (wagmiConfig, {
|
|
|
7706
7731
|
};
|
|
7707
7732
|
|
|
7708
7733
|
// functions/getUserSToke.ts
|
|
7709
|
-
var
|
|
7734
|
+
var import_utils30 = require("@tokemak/utils");
|
|
7710
7735
|
var getUserSToke = async (wagmiConfig, {
|
|
7711
7736
|
address,
|
|
7712
7737
|
tokePrice,
|
|
@@ -7733,8 +7758,8 @@ var getUserSToke = async (wagmiConfig, {
|
|
|
7733
7758
|
}
|
|
7734
7759
|
return acc;
|
|
7735
7760
|
}, 0n);
|
|
7736
|
-
const totalBalance = (0,
|
|
7737
|
-
const totalBalanceUsd = (0,
|
|
7761
|
+
const totalBalance = (0, import_utils30.formatEtherNum)(totalBalanceRaw || 0n);
|
|
7762
|
+
const totalBalanceUsd = (0, import_utils30.formatCurrency)(totalBalance * tokePrice);
|
|
7738
7763
|
const hasBalance = totalBalance > 0;
|
|
7739
7764
|
return {
|
|
7740
7765
|
chains: { ...userSToke },
|
|
@@ -7751,9 +7776,9 @@ var getUserSToke = async (wagmiConfig, {
|
|
|
7751
7776
|
var import_viem16 = require("viem");
|
|
7752
7777
|
var import_core19 = require("@wagmi/core");
|
|
7753
7778
|
var import_abis18 = require("@tokemak/abis");
|
|
7754
|
-
var import_utils31 = require("@tokemak/utils");
|
|
7755
|
-
var import_config14 = require("@tokemak/config");
|
|
7756
7779
|
var import_utils32 = require("@tokemak/utils");
|
|
7780
|
+
var import_config14 = require("@tokemak/config");
|
|
7781
|
+
var import_utils33 = require("@tokemak/utils");
|
|
7757
7782
|
var getChainSToke = async (wagmiConfig, {
|
|
7758
7783
|
tokePrice,
|
|
7759
7784
|
chainId
|
|
@@ -7779,15 +7804,15 @@ var getChainSToke = async (wagmiConfig, {
|
|
|
7779
7804
|
]
|
|
7780
7805
|
});
|
|
7781
7806
|
const tvl = Number((0, import_viem16.formatEther)(totalSupply || 0n)) * tokePrice;
|
|
7782
|
-
const secondsLeftBeforeNextCycle = (0,
|
|
7807
|
+
const secondsLeftBeforeNextCycle = (0, import_utils32.convertChainCycleToUnix)(Number(currentCycle) + 1, chainId) - Date.now() / 1e3;
|
|
7783
7808
|
return {
|
|
7784
7809
|
rawTotalSupply: totalSupply,
|
|
7785
|
-
totalSupply: (0,
|
|
7786
|
-
tvl: (0,
|
|
7810
|
+
totalSupply: (0, import_utils32.formatLargeNumber)((0, import_viem16.formatEther)(totalSupply || 0n)),
|
|
7811
|
+
tvl: (0, import_utils32.formatTVL)(tvl),
|
|
7787
7812
|
rawTVL: tvl,
|
|
7788
7813
|
currentCycle,
|
|
7789
|
-
chain: (0,
|
|
7790
|
-
timeBeforeNextCycle: (0,
|
|
7814
|
+
chain: (0, import_utils33.getNetwork)(chainId),
|
|
7815
|
+
timeBeforeNextCycle: (0, import_utils32.convertSecondsToRemainingTime)(
|
|
7791
7816
|
secondsLeftBeforeNextCycle
|
|
7792
7817
|
)
|
|
7793
7818
|
};
|
|
@@ -7798,7 +7823,7 @@ var getChainSToke = async (wagmiConfig, {
|
|
|
7798
7823
|
};
|
|
7799
7824
|
|
|
7800
7825
|
// functions/getSToke.ts
|
|
7801
|
-
var
|
|
7826
|
+
var import_utils34 = require("@tokemak/utils");
|
|
7802
7827
|
var import_viem17 = require("viem");
|
|
7803
7828
|
var getSToke = async (wagmiConfig, {
|
|
7804
7829
|
tokePrice,
|
|
@@ -7818,14 +7843,14 @@ var getSToke = async (wagmiConfig, {
|
|
|
7818
7843
|
}
|
|
7819
7844
|
return acc;
|
|
7820
7845
|
}, 0n);
|
|
7821
|
-
const totalSupply = (0,
|
|
7846
|
+
const totalSupply = (0, import_utils34.formatLargeNumber)((0, import_viem17.formatEther)(totalSupplyBigInt || 0n));
|
|
7822
7847
|
let tvlNum = Object.values(sToke).reduce((acc, item) => {
|
|
7823
7848
|
if (item && item.rawTVL) {
|
|
7824
7849
|
return acc + item.rawTVL;
|
|
7825
7850
|
}
|
|
7826
7851
|
return acc;
|
|
7827
7852
|
}, 0);
|
|
7828
|
-
const tvl = (0,
|
|
7853
|
+
const tvl = (0, import_utils34.formatTVL)(tvlNum);
|
|
7829
7854
|
return { totalSupply, tvl, rawTVL: tvlNum, chains: { ...sToke } };
|
|
7830
7855
|
} catch (e) {
|
|
7831
7856
|
console.error(e);
|
|
@@ -7877,7 +7902,7 @@ var getChainCycleRolloverBlockNumber = async (wagmiConfig, {
|
|
|
7877
7902
|
};
|
|
7878
7903
|
|
|
7879
7904
|
// functions/getChainUserSTokeVotes.ts
|
|
7880
|
-
var
|
|
7905
|
+
var import_utils37 = require("@tokemak/utils");
|
|
7881
7906
|
var import_graph_cli13 = require("@tokemak/graph-cli");
|
|
7882
7907
|
var getChainUserSTokeVotes = async ({
|
|
7883
7908
|
address,
|
|
@@ -7900,10 +7925,10 @@ var getChainUserSTokeVotes = async ({
|
|
|
7900
7925
|
subgraphUserVotesData?.pools || [],
|
|
7901
7926
|
subgraphUserVotesData?.weights || []
|
|
7902
7927
|
);
|
|
7903
|
-
const stakedToke = (0,
|
|
7928
|
+
const stakedToke = (0, import_utils37.formatEtherNum)(
|
|
7904
7929
|
BigInt(subgraphAccountVotesBalance?.amount || 0n)
|
|
7905
7930
|
);
|
|
7906
|
-
const totalUserVotes = (0,
|
|
7931
|
+
const totalUserVotes = (0, import_utils37.formatEtherNum)(
|
|
7907
7932
|
BigInt(subgraphAccountVotesBalance?.points || 0n)
|
|
7908
7933
|
);
|
|
7909
7934
|
const autopools = {};
|
|
@@ -7991,7 +8016,7 @@ var getUserSTokeVotes = async ({
|
|
|
7991
8016
|
|
|
7992
8017
|
// functions/getChainSTokeVotes.ts
|
|
7993
8018
|
var import_config15 = require("@tokemak/config");
|
|
7994
|
-
var
|
|
8019
|
+
var import_utils40 = require("@tokemak/utils");
|
|
7995
8020
|
var import_viem18 = require("viem");
|
|
7996
8021
|
var import_graph_cli14 = require("@tokemak/graph-cli");
|
|
7997
8022
|
var getChainSTokeVotes = async ({
|
|
@@ -8022,13 +8047,13 @@ var getChainSTokeVotes = async ({
|
|
|
8022
8047
|
updatedPoints
|
|
8023
8048
|
);
|
|
8024
8049
|
const globalSystemVotes = globalVoted + globalNotVoted;
|
|
8025
|
-
const totalSystemVotesNum = (0,
|
|
8050
|
+
const totalSystemVotesNum = (0, import_utils40.formatEtherNum)(globalSystemVotes);
|
|
8026
8051
|
const formattedAutopoolVotes = Object.fromEntries(
|
|
8027
8052
|
Object.entries(autopoolVotes).filter(
|
|
8028
8053
|
([poolAddress]) => includeTestnet ? true : whitelistedPools.includes(poolAddress)
|
|
8029
8054
|
).map(([poolAddress, rawVote]) => {
|
|
8030
|
-
const formattedVote = (0,
|
|
8031
|
-
(0,
|
|
8055
|
+
const formattedVote = (0, import_utils40.formatLargeNumber)(
|
|
8056
|
+
(0, import_utils40.formatEtherNum)(BigInt(rawVote))
|
|
8032
8057
|
);
|
|
8033
8058
|
return [
|
|
8034
8059
|
poolAddress,
|
|
@@ -8043,7 +8068,7 @@ var getChainSTokeVotes = async ({
|
|
|
8043
8068
|
globalSystemVotes
|
|
8044
8069
|
},
|
|
8045
8070
|
totalSystemVotesNum,
|
|
8046
|
-
totalSystemVotes: (0,
|
|
8071
|
+
totalSystemVotes: (0, import_utils40.formatLargeNumber)(totalSystemVotesNum),
|
|
8047
8072
|
autopoolVotes: formattedAutopoolVotes
|
|
8048
8073
|
};
|
|
8049
8074
|
};
|
|
@@ -8069,7 +8094,7 @@ var getSTokeVotes = async ({
|
|
|
8069
8094
|
// functions/getChainSTokeRewards.ts
|
|
8070
8095
|
var import_config16 = require("@tokemak/config");
|
|
8071
8096
|
var import_viem19 = require("viem");
|
|
8072
|
-
var
|
|
8097
|
+
var import_utils42 = require("@tokemak/utils");
|
|
8073
8098
|
var import_graph_cli15 = require("@tokemak/graph-cli");
|
|
8074
8099
|
var getChainSTokeRewards = async ({
|
|
8075
8100
|
chainId
|
|
@@ -8093,9 +8118,9 @@ var getChainSTokeRewards = async ({
|
|
|
8093
8118
|
if (!whitelistedPools.includes(pool.id.toLowerCase())) {
|
|
8094
8119
|
continue;
|
|
8095
8120
|
}
|
|
8096
|
-
const convertedBalance = (0,
|
|
8121
|
+
const convertedBalance = (0, import_utils42.formatEtherNum)(pool.balance);
|
|
8097
8122
|
const convertedBalanceUSD = Number((0, import_viem19.formatUnits)(pool.balanceUSD, 8));
|
|
8098
|
-
const convertedApr = (0,
|
|
8123
|
+
const convertedApr = (0, import_utils42.formatEtherNum)(pool.currentAprPerCredit);
|
|
8099
8124
|
if (minApr === null || convertedApr < minApr) {
|
|
8100
8125
|
minApr = convertedApr;
|
|
8101
8126
|
}
|
|
@@ -8168,7 +8193,7 @@ var getSTokeRewards = async ({
|
|
|
8168
8193
|
|
|
8169
8194
|
// functions/getChainUserSTokeRewards.ts
|
|
8170
8195
|
var import_config17 = require("@tokemak/config");
|
|
8171
|
-
var
|
|
8196
|
+
var import_utils45 = require("@tokemak/utils");
|
|
8172
8197
|
var getChainUserSTokeRewards = async (wagmiConfig, {
|
|
8173
8198
|
address,
|
|
8174
8199
|
chainId,
|
|
@@ -8219,14 +8244,14 @@ var getChainUserSTokeRewards = async (wagmiConfig, {
|
|
|
8219
8244
|
throw fallbackError;
|
|
8220
8245
|
}
|
|
8221
8246
|
}
|
|
8222
|
-
const claimableNum = (0,
|
|
8247
|
+
const claimableNum = (0, import_utils45.formatEtherNum)(tokeRewards?.claimable || 0n);
|
|
8223
8248
|
const claimableUsd = tokePrice * claimableNum;
|
|
8224
8249
|
const hasClaimable = claimableNum > 0n;
|
|
8225
|
-
const pendingRewards = (0,
|
|
8250
|
+
const pendingRewards = (0, import_utils45.formatEtherNum)(
|
|
8226
8251
|
tokeRewards?.rewardsPayload.breakdown?.totalRewardAmount || 0n
|
|
8227
8252
|
);
|
|
8228
8253
|
const pendingRewardsUsd = tokePrice * pendingRewards;
|
|
8229
|
-
const totalRewardsReceived = (0,
|
|
8254
|
+
const totalRewardsReceived = (0, import_utils45.formatEtherNum)(
|
|
8230
8255
|
tokeRewards.rewardsPayload.payload.amount || 0n
|
|
8231
8256
|
);
|
|
8232
8257
|
const totalRewardsReceivedUsd = tokePrice * totalRewardsReceived;
|
|
@@ -8302,7 +8327,7 @@ var getSubgraphStatus = async (includeTestnet = false) => {
|
|
|
8302
8327
|
var import_core21 = require("@wagmi/core");
|
|
8303
8328
|
var import_abis20 = require("@tokemak/abis");
|
|
8304
8329
|
var import_viem20 = require("viem");
|
|
8305
|
-
var
|
|
8330
|
+
var import_utils47 = require("@tokemak/utils");
|
|
8306
8331
|
var import_config18 = require("@tokemak/config");
|
|
8307
8332
|
var import_chains10 = require("viem/chains");
|
|
8308
8333
|
var publicClient = (0, import_viem20.createPublicClient)({
|
|
@@ -8336,11 +8361,11 @@ var getCycleV1 = async (wagmiConfig, {
|
|
|
8336
8361
|
});
|
|
8337
8362
|
const rolloverEvents = await publicClient.getFilterLogs({ filter });
|
|
8338
8363
|
const cycleRolloverBlockNumber = chainId === 1 ? rolloverEvents[rolloverEvents.length - 1]?.blockNumber : rolloverEvents[rolloverEvents.length - 1]?.blockNumber || currentBlockNumber;
|
|
8339
|
-
const secondsLeftBeforeNextCycle = (0,
|
|
8364
|
+
const secondsLeftBeforeNextCycle = (0, import_utils47.convertChainCycleToUnix)(Number(currentCycleIndex) + 1) - Date.now() / 1e3;
|
|
8340
8365
|
return {
|
|
8341
8366
|
currentCycleIndex,
|
|
8342
8367
|
cycleRolloverBlockNumber,
|
|
8343
|
-
timeBeforeNextCycle: (0,
|
|
8368
|
+
timeBeforeNextCycle: (0, import_utils47.convertSecondsToRemainingTime)(
|
|
8344
8369
|
secondsLeftBeforeNextCycle
|
|
8345
8370
|
)
|
|
8346
8371
|
};
|
|
@@ -8351,7 +8376,7 @@ var getCycleV1 = async (wagmiConfig, {
|
|
|
8351
8376
|
};
|
|
8352
8377
|
|
|
8353
8378
|
// functions/getProtocolStats.ts
|
|
8354
|
-
var
|
|
8379
|
+
var import_utils48 = require("@tokemak/utils");
|
|
8355
8380
|
var getProtocolStats = async (autopools, stoke, sushiLP) => {
|
|
8356
8381
|
try {
|
|
8357
8382
|
if (!autopools || !stoke || !sushiLP) {
|
|
@@ -8381,12 +8406,12 @@ var getProtocolStats = async (autopools, stoke, sushiLP) => {
|
|
|
8381
8406
|
Object.entries(categories).map(([key, value]) => [
|
|
8382
8407
|
key,
|
|
8383
8408
|
{
|
|
8384
|
-
tvl: (0,
|
|
8385
|
-
supply: (0,
|
|
8409
|
+
tvl: (0, import_utils48.formatTVL)(value.tvl),
|
|
8410
|
+
supply: (0, import_utils48.formatLargeNumber)(value.supply || 0)
|
|
8386
8411
|
}
|
|
8387
8412
|
])
|
|
8388
8413
|
);
|
|
8389
|
-
const tvl = (0,
|
|
8414
|
+
const tvl = (0, import_utils48.formatTVL)(autopoolTVL + stoke.rawTVL + (sushiLP?.tvl || 0));
|
|
8390
8415
|
const vaultAddresses = autopools?.flatMap(
|
|
8391
8416
|
(pool) => pool.destinations.map((destination) => destination.vaultAddress)
|
|
8392
8417
|
);
|
|
@@ -8394,16 +8419,16 @@ var getProtocolStats = async (autopools, stoke, sushiLP) => {
|
|
|
8394
8419
|
const totalDestinations = uniqueVaultAddresses.length;
|
|
8395
8420
|
return {
|
|
8396
8421
|
autopools: {
|
|
8397
|
-
tvl: (0,
|
|
8422
|
+
tvl: (0, import_utils48.formatTVL)(autopoolTVL),
|
|
8398
8423
|
tvlNum: autopoolTVL,
|
|
8399
8424
|
categories: formattedCategories
|
|
8400
8425
|
},
|
|
8401
8426
|
stoke: {
|
|
8402
|
-
tvl: (0,
|
|
8427
|
+
tvl: (0, import_utils48.formatTVL)(stoke.rawTVL),
|
|
8403
8428
|
totalSupply: `${stoke.totalSupply} TOKE`
|
|
8404
8429
|
},
|
|
8405
8430
|
sushiLP: {
|
|
8406
|
-
tvl: (0,
|
|
8431
|
+
tvl: (0, import_utils48.formatTVL)(sushiLP?.tvl || 0),
|
|
8407
8432
|
totalSupply: sushiLP?.totalSupply || 0
|
|
8408
8433
|
},
|
|
8409
8434
|
tvl,
|
|
@@ -8440,7 +8465,7 @@ var getEthPriceAtBlock = async (wagmiConfig, blockNumber, chainId) => {
|
|
|
8440
8465
|
};
|
|
8441
8466
|
|
|
8442
8467
|
// functions/getRebalanceStats.ts
|
|
8443
|
-
var
|
|
8468
|
+
var import_utils50 = require("@tokemak/utils");
|
|
8444
8469
|
var import_tokenlist12 = require("@tokemak/tokenlist");
|
|
8445
8470
|
var import_chains11 = require("viem/chains");
|
|
8446
8471
|
var BATCH_SIZE = 500;
|
|
@@ -8474,8 +8499,8 @@ var getRebalanceValueUsd = async (rebalance, chainId, wagmiConfig) => {
|
|
|
8474
8499
|
BigInt(rebalance.blockNumber),
|
|
8475
8500
|
chainId
|
|
8476
8501
|
);
|
|
8477
|
-
const ethUsd = Number((0,
|
|
8478
|
-
const ethAmt = Number((0,
|
|
8502
|
+
const ethUsd = Number((0, import_utils50.formatUnitsNum)(price, import_tokenlist12.USDC_TOKEN.decimals));
|
|
8503
|
+
const ethAmt = Number((0, import_utils50.formatEtherNum)(ethWei));
|
|
8479
8504
|
const usd = ethAmt * ethUsd;
|
|
8480
8505
|
return usd;
|
|
8481
8506
|
} catch (e) {
|
|
@@ -8486,7 +8511,7 @@ var getRebalanceValueUsd = async (rebalance, chainId, wagmiConfig) => {
|
|
|
8486
8511
|
var processRebalance = async (rebalance, chainId, wagmiConfig) => {
|
|
8487
8512
|
const baseDecimals = inferBaseAssetDecimals(rebalance, chainId);
|
|
8488
8513
|
const baseAssetAmount = Number(
|
|
8489
|
-
(0,
|
|
8514
|
+
(0, import_utils50.formatUnitsNum)(
|
|
8490
8515
|
BigInt(rebalance.tokenOutValueBaseAsset || "0"),
|
|
8491
8516
|
baseDecimals
|
|
8492
8517
|
)
|
|
@@ -8599,16 +8624,16 @@ var getAutopoolUserActivity = async ({
|
|
|
8599
8624
|
userAddress,
|
|
8600
8625
|
chainId = 1
|
|
8601
8626
|
}) => {
|
|
8602
|
-
const {
|
|
8627
|
+
const { GetUserAutopoolBalanceChangeHistory } = (0, import_graph_cli18.getSdkByChainId)(chainId);
|
|
8603
8628
|
try {
|
|
8604
8629
|
const userAutopoolBalanceChanges = await paginateQuery(
|
|
8605
|
-
(vars) =>
|
|
8630
|
+
(vars) => GetUserAutopoolBalanceChangeHistory({
|
|
8606
8631
|
userAddress,
|
|
8607
8632
|
vaultAddress: autopoolAddress,
|
|
8608
8633
|
first: vars?.first || 1e3,
|
|
8609
8634
|
skip: vars?.skip || 0
|
|
8610
8635
|
}),
|
|
8611
|
-
"
|
|
8636
|
+
"userSpecificAutopoolBalanceChanges",
|
|
8612
8637
|
{
|
|
8613
8638
|
first: 1e3,
|
|
8614
8639
|
maxPages: 100
|
|
@@ -8674,7 +8699,7 @@ var getAutopoolUserActivity = async ({
|
|
|
8674
8699
|
var import_viem21 = require("viem");
|
|
8675
8700
|
var import_core23 = require("@wagmi/core");
|
|
8676
8701
|
var import_abis22 = require("@tokemak/abis");
|
|
8677
|
-
var
|
|
8702
|
+
var import_utils53 = require("@tokemak/utils");
|
|
8678
8703
|
var getAutopoolUser = async (config, {
|
|
8679
8704
|
autopool,
|
|
8680
8705
|
address,
|
|
@@ -8716,14 +8741,14 @@ var getAutopoolUser = async (config, {
|
|
|
8716
8741
|
args: [address],
|
|
8717
8742
|
chainId: autopool?.chain?.chainId
|
|
8718
8743
|
});
|
|
8719
|
-
const stakedShares = (0,
|
|
8744
|
+
const stakedShares = (0, import_utils53.formatEtherNum)(stakedPoolShares);
|
|
8720
8745
|
const staked = convertBaseAssetToTokenPricesAndDenom(
|
|
8721
8746
|
stakedShares * (autopool?.navPerShare.baseAsset || 0),
|
|
8722
8747
|
autopool?.baseAsset.price,
|
|
8723
8748
|
autopool?.denomination.price,
|
|
8724
8749
|
prices
|
|
8725
8750
|
);
|
|
8726
|
-
const unstakedShares = (0,
|
|
8751
|
+
const unstakedShares = (0, import_utils53.formatEtherNum)(unstakedPoolShares || 0n);
|
|
8727
8752
|
const unstaked = convertBaseAssetToTokenPricesAndDenom(
|
|
8728
8753
|
unstakedShares * (autopool?.navPerShare.baseAsset || 0),
|
|
8729
8754
|
autopool?.baseAsset.price,
|
|
@@ -8738,7 +8763,7 @@ var getAutopoolUser = async (config, {
|
|
|
8738
8763
|
prices
|
|
8739
8764
|
);
|
|
8740
8765
|
const totalDeposits = convertBaseAssetToTokenPricesAndDenom(
|
|
8741
|
-
(0,
|
|
8766
|
+
(0, import_utils53.formatUnitsNum)(
|
|
8742
8767
|
userActivity?.totals[autopool?.poolAddress]?.totalDeposits || 0n,
|
|
8743
8768
|
autopool?.baseAsset.decimals
|
|
8744
8769
|
),
|
|
@@ -8747,7 +8772,7 @@ var getAutopoolUser = async (config, {
|
|
|
8747
8772
|
prices
|
|
8748
8773
|
);
|
|
8749
8774
|
const totalWithdrawals = convertBaseAssetToTokenPricesAndDenom(
|
|
8750
|
-
(0,
|
|
8775
|
+
(0, import_utils53.formatUnitsNum)(
|
|
8751
8776
|
userActivity?.totals[autopool?.poolAddress]?.totalWithdrawals || 0n,
|
|
8752
8777
|
autopool?.baseAsset.decimals
|
|
8753
8778
|
),
|
|
@@ -8772,7 +8797,7 @@ var getAutopoolUser = async (config, {
|
|
|
8772
8797
|
);
|
|
8773
8798
|
let lastDeposit;
|
|
8774
8799
|
if (poolEvents && poolEvents?.length > 0) {
|
|
8775
|
-
lastDeposit = (0,
|
|
8800
|
+
lastDeposit = (0, import_utils53.convertTimestampToDate)(
|
|
8776
8801
|
poolEvents[poolEvents.length - 1].timestamp
|
|
8777
8802
|
).toLocaleDateString("en-US", {
|
|
8778
8803
|
day: "2-digit",
|
|
@@ -8803,6 +8828,118 @@ var getAutopoolUser = async (config, {
|
|
|
8803
8828
|
}
|
|
8804
8829
|
};
|
|
8805
8830
|
};
|
|
8831
|
+
|
|
8832
|
+
// functions/getAutopoolUserHistory.ts
|
|
8833
|
+
var import_graph_cli20 = require("@tokemak/graph-cli");
|
|
8834
|
+
var import_constants13 = require("@tokemak/constants");
|
|
8835
|
+
var import_chains13 = require("viem/chains");
|
|
8836
|
+
|
|
8837
|
+
// functions/getAutopoolHistory.ts
|
|
8838
|
+
var import_graph_cli19 = require("@tokemak/graph-cli");
|
|
8839
|
+
var import_chains12 = require("viem/chains");
|
|
8840
|
+
var import_constants12 = require("@tokemak/constants");
|
|
8841
|
+
var getAutopoolHistory = async (autopool) => {
|
|
8842
|
+
try {
|
|
8843
|
+
if (!autopool) {
|
|
8844
|
+
throw new Error("No autopools found");
|
|
8845
|
+
}
|
|
8846
|
+
const { GetAutopoolDayNav } = (0, import_graph_cli19.getSdkByChainId)(
|
|
8847
|
+
autopool?.chain?.chainId || import_chains12.base.id
|
|
8848
|
+
);
|
|
8849
|
+
const { autopoolDayDatas } = await GetAutopoolDayNav({
|
|
8850
|
+
address: autopool?.poolAddress,
|
|
8851
|
+
timestamp: import_constants12.TOKEMAK_LAUNCH_TIMESTAMP
|
|
8852
|
+
});
|
|
8853
|
+
const formattedData = autopoolDayDatas.map((dayData) => {
|
|
8854
|
+
return {
|
|
8855
|
+
...dayData,
|
|
8856
|
+
date: new Date(dayData.timestamp * 1e3)
|
|
8857
|
+
};
|
|
8858
|
+
});
|
|
8859
|
+
const filledData = fillMissingDates(formattedData);
|
|
8860
|
+
return filledData;
|
|
8861
|
+
} catch (e) {
|
|
8862
|
+
console.log(e);
|
|
8863
|
+
}
|
|
8864
|
+
};
|
|
8865
|
+
|
|
8866
|
+
// functions/getAutopoolUserHistory.ts
|
|
8867
|
+
var getAutopoolUserHistory = async ({
|
|
8868
|
+
userAddress,
|
|
8869
|
+
autopool,
|
|
8870
|
+
userActivity
|
|
8871
|
+
}) => {
|
|
8872
|
+
const { GetUserVaultDayData } = (0, import_graph_cli20.getSdkByChainId)(
|
|
8873
|
+
autopool?.chain?.chainId || import_chains13.base.id
|
|
8874
|
+
);
|
|
8875
|
+
try {
|
|
8876
|
+
if (userAddress) {
|
|
8877
|
+
const { userVaultDayDatas } = await GetUserVaultDayData({
|
|
8878
|
+
address: userAddress,
|
|
8879
|
+
timestamp: import_constants13.TOKEMAK_LAUNCH_TIMESTAMP,
|
|
8880
|
+
vaultAddress: autopool?.poolAddress
|
|
8881
|
+
});
|
|
8882
|
+
const autopoolDayData = await getAutopoolHistory(autopool);
|
|
8883
|
+
if (!autopoolDayData) {
|
|
8884
|
+
throw new Error("No autopool history found");
|
|
8885
|
+
}
|
|
8886
|
+
const formattedUserVaultDayDatas = userVaultDayDatas.map((dayData) => {
|
|
8887
|
+
if (!dayData.timestamp) {
|
|
8888
|
+
throw new Error("Missing timestamp in userVaultDayData");
|
|
8889
|
+
}
|
|
8890
|
+
return {
|
|
8891
|
+
...dayData,
|
|
8892
|
+
date: new Date(Number(dayData.timestamp) * 1e3),
|
|
8893
|
+
timestamp: dayData.timestamp.toString()
|
|
8894
|
+
};
|
|
8895
|
+
});
|
|
8896
|
+
const filledMissingDates = fillMissingDates(formattedUserVaultDayDatas);
|
|
8897
|
+
if (filledMissingDates.length > 0) {
|
|
8898
|
+
const firstEntry = filledMissingDates[0];
|
|
8899
|
+
const dayBefore = new Date(firstEntry.date);
|
|
8900
|
+
dayBefore.setDate(dayBefore.getDate() - 1);
|
|
8901
|
+
const dayBeforeTimestamp = Math.floor(
|
|
8902
|
+
dayBefore.getTime() / 1e3
|
|
8903
|
+
).toString();
|
|
8904
|
+
const dayBeforeEntry = {
|
|
8905
|
+
...firstEntry,
|
|
8906
|
+
date: dayBefore,
|
|
8907
|
+
timestamp: dayBeforeTimestamp,
|
|
8908
|
+
totalShares: 0
|
|
8909
|
+
};
|
|
8910
|
+
filledMissingDates.unshift(dayBeforeEntry);
|
|
8911
|
+
}
|
|
8912
|
+
const matchedData = filledMissingDates.map((userVaultDayData) => {
|
|
8913
|
+
const matchingAutopoolDayData = autopoolDayData.find(
|
|
8914
|
+
(autopoolDay) => autopoolDay.date.toDateString() === userVaultDayData.date.toDateString()
|
|
8915
|
+
);
|
|
8916
|
+
const userPortionOfVault = userVaultDayData.totalShares / matchingAutopoolDayData?.totalSupply;
|
|
8917
|
+
const userNav = userPortionOfVault * matchingAutopoolDayData?.nav;
|
|
8918
|
+
const eventsForDay = userActivity.events?.filter((event) => {
|
|
8919
|
+
const eventDate = new Date(Number(event.timestamp) * 1e3);
|
|
8920
|
+
const windowStart = new Date(
|
|
8921
|
+
userVaultDayData.date.getTime() - 24 * 60 * 60 * 1e3
|
|
8922
|
+
);
|
|
8923
|
+
const windowEnd = userVaultDayData.date;
|
|
8924
|
+
const matches = eventDate.getTime() > windowStart.getTime() && eventDate.getTime() <= windowEnd.getTime();
|
|
8925
|
+
return matches;
|
|
8926
|
+
});
|
|
8927
|
+
return {
|
|
8928
|
+
date: userVaultDayData.date,
|
|
8929
|
+
timestamp: userVaultDayData.timestamp,
|
|
8930
|
+
baseAsset: autopool?.baseAsset.symbol,
|
|
8931
|
+
nav: userNav,
|
|
8932
|
+
events: eventsForDay
|
|
8933
|
+
};
|
|
8934
|
+
});
|
|
8935
|
+
return matchedData;
|
|
8936
|
+
}
|
|
8937
|
+
return [];
|
|
8938
|
+
} catch (e) {
|
|
8939
|
+
console.error(e);
|
|
8940
|
+
return [];
|
|
8941
|
+
}
|
|
8942
|
+
};
|
|
8806
8943
|
// Annotate the CommonJS export names for ESM import in node:
|
|
8807
8944
|
0 && (module.exports = {
|
|
8808
8945
|
AutopoolCategory,
|
|
@@ -8832,10 +8969,12 @@ var getAutopoolUser = async (config, {
|
|
|
8832
8969
|
getAutopilotRouter,
|
|
8833
8970
|
getAutopoolCategory,
|
|
8834
8971
|
getAutopoolDayData,
|
|
8972
|
+
getAutopoolHistory,
|
|
8835
8973
|
getAutopoolInfo,
|
|
8836
8974
|
getAutopoolRebalances,
|
|
8837
8975
|
getAutopoolUser,
|
|
8838
8976
|
getAutopoolUserActivity,
|
|
8977
|
+
getAutopoolUserHistory,
|
|
8839
8978
|
getAutopools,
|
|
8840
8979
|
getAutopoolsHistory,
|
|
8841
8980
|
getAutopoolsRebalances,
|