@tokemak/queries 0.0.12 → 0.0.13
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 +213 -176
- package/dist/index.d.ts +66 -13
- package/dist/index.js +110 -78
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -3147,8 +3147,11 @@ __export(queries_exports, {
|
|
|
3147
3147
|
getAutopools: () => getAutopools,
|
|
3148
3148
|
getAutopoolsHistory: () => getAutopoolsHistory,
|
|
3149
3149
|
getAutopoolsRebalances: () => getAutopoolsRebalances,
|
|
3150
|
+
getBlobData: () => getBlobData,
|
|
3151
|
+
getBlobHistoricalTokenPrices: () => getBlobHistoricalTokenPrices,
|
|
3150
3152
|
getBridgeFee: () => getBridgeFee,
|
|
3151
3153
|
getChainAutopools: () => getChainAutopools,
|
|
3154
|
+
getChainAutopoolsApr: () => getChainAutopoolsApr,
|
|
3152
3155
|
getChainCycleRolloverBlockNumber: () => getChainCycleRolloverBlockNumber,
|
|
3153
3156
|
getChainSToke: () => getChainSToke,
|
|
3154
3157
|
getChainSTokeRewards: () => getChainSTokeRewards,
|
|
@@ -3168,6 +3171,7 @@ __export(queries_exports, {
|
|
|
3168
3171
|
getEthPriceAtBlock: () => getEthPriceAtBlock,
|
|
3169
3172
|
getExchangeNames: () => getExchangeNames,
|
|
3170
3173
|
getGenStratAprs: () => getGenStratAprs,
|
|
3174
|
+
getHistoricalTokenPrices: () => getHistoricalTokenPrices,
|
|
3171
3175
|
getLayerzeroStatus: () => getLayerzeroStatus,
|
|
3172
3176
|
getMutlipleAutopoolRebalances: () => getMutlipleAutopoolRebalances,
|
|
3173
3177
|
getPoolStats: () => getPoolStats,
|
|
@@ -3788,6 +3792,28 @@ var getGenStratAprs = async ({
|
|
|
3788
3792
|
}
|
|
3789
3793
|
};
|
|
3790
3794
|
|
|
3795
|
+
// functions/getChainAutopoolsApr.ts
|
|
3796
|
+
var import_constants5 = require("@tokemak/constants");
|
|
3797
|
+
var getChainAutopoolsApr = async (chainId) => {
|
|
3798
|
+
try {
|
|
3799
|
+
const response = await fetch(`${import_constants5.AUTOPOOLS_APR_URL}/${chainId}/gen3`, {
|
|
3800
|
+
method: "GET",
|
|
3801
|
+
headers: {
|
|
3802
|
+
"Content-Type": "application/json"
|
|
3803
|
+
}
|
|
3804
|
+
});
|
|
3805
|
+
if (!response.ok) {
|
|
3806
|
+
throw new Error(
|
|
3807
|
+
`Failed to fetch getChainAutopoolsApr: ${response.status}`
|
|
3808
|
+
);
|
|
3809
|
+
}
|
|
3810
|
+
return await response.json();
|
|
3811
|
+
} catch (e) {
|
|
3812
|
+
console.error("Failed to fetch getChainAutopoolsApr:", e);
|
|
3813
|
+
return void 0;
|
|
3814
|
+
}
|
|
3815
|
+
};
|
|
3816
|
+
|
|
3791
3817
|
// functions/getChainAutopools.ts
|
|
3792
3818
|
var import_tokenlist3 = require("@tokemak/tokenlist");
|
|
3793
3819
|
var import_graph_cli = require("@tokemak/graph-cli");
|
|
@@ -3846,8 +3872,10 @@ var getChainAutopools = async (wagmiConfig, {
|
|
|
3846
3872
|
const { GetVaultAddeds, GetAutopoolsInactiveDestinations } = (0, import_graph_cli.getSdkByChainId)(chainId);
|
|
3847
3873
|
try {
|
|
3848
3874
|
const { vaultAddeds } = await GetVaultAddeds();
|
|
3875
|
+
const autopoolsAprResponse = await getChainAutopoolsApr(chainId);
|
|
3876
|
+
const autopoolsApr = autopoolsAprResponse?.autopools || [];
|
|
3849
3877
|
const { GetAutopoolsApr } = (0, import_graph_cli.getSdkByChainId)(chainId);
|
|
3850
|
-
const { autopools:
|
|
3878
|
+
const { autopools: autopoolsDenomination } = await GetAutopoolsApr();
|
|
3851
3879
|
const genStratAprs = await getGenStratAprs({
|
|
3852
3880
|
chainId
|
|
3853
3881
|
});
|
|
@@ -4017,35 +4045,9 @@ var getChainAutopools = async (wagmiConfig, {
|
|
|
4017
4045
|
const aprs = autopoolsApr.find(
|
|
4018
4046
|
(autopoolApr) => (0, import_viem2.getAddress)(autopoolApr.id) === (0, import_viem2.getAddress)(autopool.poolAddress)
|
|
4019
4047
|
);
|
|
4020
|
-
let baseApr = aprs?.
|
|
4021
|
-
let boostedApr = 0;
|
|
4048
|
+
let baseApr = aprs?.baseApy !== void 0 ? aprs.baseApy / 100 : void 0;
|
|
4022
4049
|
let extraApr = 0;
|
|
4023
|
-
|
|
4024
|
-
BigInt(Number(aprs?.rewarder?.day7MAApy) || 0)
|
|
4025
|
-
);
|
|
4026
|
-
const formattedRewarder30DayMAApy = (0, import_utils6.formatEtherNum)(
|
|
4027
|
-
BigInt(Number(aprs?.rewarder?.day30MAApy) || 0)
|
|
4028
|
-
);
|
|
4029
|
-
if (formattedRewarder7DayMAApy > 0) {
|
|
4030
|
-
boostedApr = formattedRewarder7DayMAApy;
|
|
4031
|
-
}
|
|
4032
|
-
if (formattedRewarder30DayMAApy > 0) {
|
|
4033
|
-
boostedApr = formattedRewarder30DayMAApy;
|
|
4034
|
-
}
|
|
4035
|
-
if (!baseApr) {
|
|
4036
|
-
const weightedCrNum = destinations.reduce((acc, cur) => {
|
|
4037
|
-
return acc + cur.debtValueHeldByVaultAllocation * cur.compositeReturn;
|
|
4038
|
-
}, 0);
|
|
4039
|
-
const periodicFeeBps = autopool.periodicFeeBps || 0n;
|
|
4040
|
-
const streamingFeeBps = autopool.streamingFeeBps || 0n;
|
|
4041
|
-
baseApr = (weightedCrNum / (1 - totalIdleAssets / totalAssets) - Number((0, import_viem2.formatUnits)(periodicFeeBps, 4))) * (1 - Number((0, import_viem2.formatUnits)(streamingFeeBps, 4)));
|
|
4042
|
-
} else {
|
|
4043
|
-
baseApr = Number((0, import_viem2.formatUnits)(BigInt(baseApr), baseAsset.decimals));
|
|
4044
|
-
}
|
|
4045
|
-
if (!baseApr) {
|
|
4046
|
-
baseApr = 0;
|
|
4047
|
-
}
|
|
4048
|
-
if (baseApr === 0) {
|
|
4050
|
+
if (baseApr === void 0) {
|
|
4049
4051
|
try {
|
|
4050
4052
|
const backupApr = await getBackupApr(chainId, autopool.poolAddress);
|
|
4051
4053
|
if (backupApr) {
|
|
@@ -4057,27 +4059,26 @@ var getChainAutopools = async (wagmiConfig, {
|
|
|
4057
4059
|
console.log("unable to retrieve backup apr");
|
|
4058
4060
|
}
|
|
4059
4061
|
}
|
|
4060
|
-
if (baseApr === 0 && autopool.symbol.toLowerCase() === "baseusd") {
|
|
4061
|
-
baseApr = 0.0914;
|
|
4062
|
-
}
|
|
4063
4062
|
let extraRewards = [];
|
|
4064
|
-
if (aprs?.
|
|
4065
|
-
extraRewards = aprs
|
|
4066
|
-
const token = (0, import_utils6.getToken)(reward
|
|
4063
|
+
if (aprs?.rewards && aprs.rewards.length > 0) {
|
|
4064
|
+
extraRewards = aprs.rewards.map((reward) => {
|
|
4065
|
+
const token = (0, import_utils6.getToken)(reward.rewardToken, chainId);
|
|
4067
4066
|
return {
|
|
4068
4067
|
...token,
|
|
4069
|
-
apr:
|
|
4068
|
+
apr: reward.rewardApy / 100
|
|
4070
4069
|
};
|
|
4071
4070
|
});
|
|
4072
4071
|
}
|
|
4073
|
-
if (autopool?.symbol?.toLowerCase() === "plasmausd") {
|
|
4074
|
-
boostedApr = 0;
|
|
4075
|
-
}
|
|
4076
4072
|
extraApr = extraRewards.reduce((acc, reward) => acc + reward.apr, 0);
|
|
4077
|
-
|
|
4073
|
+
if (baseApr === void 0)
|
|
4074
|
+
baseApr = 0;
|
|
4075
|
+
const combinedApr = baseApr + extraApr;
|
|
4078
4076
|
let denominatedToken = import_tokenlist3.ETH_TOKEN;
|
|
4079
4077
|
let useDenominatedValues = false;
|
|
4080
|
-
const
|
|
4078
|
+
const denominationData = autopoolsDenomination.find(
|
|
4079
|
+
(autopoolDenom) => (0, import_viem2.getAddress)(autopoolDenom.id) === (0, import_viem2.getAddress)(autopool.poolAddress)
|
|
4080
|
+
);
|
|
4081
|
+
const denominatedIn = denominationData?.denominatedIn;
|
|
4081
4082
|
if (denominatedIn?.symbol?.toLowerCase() === "weth") {
|
|
4082
4083
|
denominatedToken = import_tokenlist3.ETH_TOKEN;
|
|
4083
4084
|
} else {
|
|
@@ -4218,7 +4219,8 @@ var getChainAutopools = async (wagmiConfig, {
|
|
|
4218
4219
|
exchanges: groupedExchanges,
|
|
4219
4220
|
timestamp,
|
|
4220
4221
|
isNew,
|
|
4221
|
-
extraRewarders:
|
|
4222
|
+
extraRewarders: denominationData?.rewarder?.extraRewarders,
|
|
4223
|
+
autopoolRewarderDisabled: aprs?.autopoolRewarderDisabled ?? false,
|
|
4222
4224
|
createdAt: new Date(timestamp * 1e3),
|
|
4223
4225
|
baseAsset: {
|
|
4224
4226
|
...baseAsset,
|
|
@@ -4236,10 +4238,8 @@ var getChainAutopools = async (wagmiConfig, {
|
|
|
4236
4238
|
chain: (0, import_utils6.getNetwork)(chainId),
|
|
4237
4239
|
apr: {
|
|
4238
4240
|
base: baseApr,
|
|
4239
|
-
boosted: boostedApr,
|
|
4240
4241
|
extraAprs: extraRewards,
|
|
4241
4242
|
combined: combinedApr,
|
|
4242
|
-
hasBoostedApr: boostedApr > 1e-4,
|
|
4243
4243
|
hasExtraAprs: extraRewards.length > 0
|
|
4244
4244
|
},
|
|
4245
4245
|
dailyEarnings: {
|
|
@@ -4408,7 +4408,7 @@ var getAutopoolsHistory = async (autopools, days, includeTestnet = false) => {
|
|
|
4408
4408
|
|
|
4409
4409
|
// functions/getCurveLP.ts
|
|
4410
4410
|
var import_config3 = require("@tokemak/config");
|
|
4411
|
-
var
|
|
4411
|
+
var import_constants6 = require("@tokemak/constants");
|
|
4412
4412
|
var getCurveLP = async () => {
|
|
4413
4413
|
let curveData;
|
|
4414
4414
|
const { curveRewardsUrl } = (0, import_config3.getMainnetConfig)();
|
|
@@ -4425,10 +4425,10 @@ var getCurveLP = async () => {
|
|
|
4425
4425
|
console.error(e);
|
|
4426
4426
|
}
|
|
4427
4427
|
try {
|
|
4428
|
-
const curvePoolsResponse = await fetch(
|
|
4428
|
+
const curvePoolsResponse = await fetch(import_constants6.CURVE_API_URL);
|
|
4429
4429
|
const curvePoolsData = await curvePoolsResponse.json();
|
|
4430
4430
|
const curveTOKEPool = curvePoolsData?.data?.poolData.find(
|
|
4431
|
-
(pool) => pool.id ===
|
|
4431
|
+
(pool) => pool.id === import_constants6.TOKE_CURVE_POOL_ID
|
|
4432
4432
|
);
|
|
4433
4433
|
if (curveData) {
|
|
4434
4434
|
curveData.curveTvl = curveTOKEPool?.usdTotal;
|
|
@@ -4499,9 +4499,18 @@ var import_graph_cli5 = require("@tokemak/graph-cli");
|
|
|
4499
4499
|
var getChainUserActivity = async (address, chainId = 1) => {
|
|
4500
4500
|
const { GetUserBalanceChangeHistory } = (0, import_graph_cli5.getSdkByChainId)(chainId);
|
|
4501
4501
|
try {
|
|
4502
|
-
const
|
|
4503
|
-
|
|
4504
|
-
|
|
4502
|
+
const userAutopoolBalanceChanges = await paginateQuery(
|
|
4503
|
+
(vars) => GetUserBalanceChangeHistory({
|
|
4504
|
+
userAddress: address,
|
|
4505
|
+
first: vars?.first || 1e3,
|
|
4506
|
+
skip: vars?.skip || 0
|
|
4507
|
+
}),
|
|
4508
|
+
"userAutopoolBalanceChanges",
|
|
4509
|
+
{
|
|
4510
|
+
first: 1e3,
|
|
4511
|
+
maxPages: 100
|
|
4512
|
+
}
|
|
4513
|
+
);
|
|
4505
4514
|
let userActivityTotals = {};
|
|
4506
4515
|
let events = [];
|
|
4507
4516
|
userAutopoolBalanceChanges.forEach((activity) => {
|
|
@@ -4515,29 +4524,37 @@ var getChainUserActivity = async (address, chainId = 1) => {
|
|
|
4515
4524
|
};
|
|
4516
4525
|
}
|
|
4517
4526
|
activity.items.forEach((item) => {
|
|
4527
|
+
let eventType;
|
|
4518
4528
|
if (item.staked && item.assetChange > 0n) {
|
|
4519
4529
|
userActivityTotals[activity.vaultAddress].totalStakes += BigInt(
|
|
4520
4530
|
item.assetChange
|
|
4521
4531
|
);
|
|
4532
|
+
eventType = "Stake";
|
|
4522
4533
|
} else if (item.staked && item.assetChange < 0n) {
|
|
4523
4534
|
userActivityTotals[activity.vaultAddress].totalUnstakes += BigInt(
|
|
4524
4535
|
BigInt(item.assetChange) * -1n
|
|
4525
4536
|
);
|
|
4537
|
+
eventType = "Unstake";
|
|
4526
4538
|
} else if (!item.staked && item.assetChange > 0n) {
|
|
4527
4539
|
userActivityTotals[activity.vaultAddress].totalDeposits += BigInt(
|
|
4528
4540
|
item.assetChange
|
|
4529
4541
|
);
|
|
4542
|
+
eventType = "Deposit";
|
|
4530
4543
|
} else if (!item.staked && item.assetChange < 0n) {
|
|
4531
4544
|
userActivityTotals[activity.vaultAddress].totalWithdrawals += BigInt(
|
|
4532
4545
|
BigInt(item.assetChange) * -1n
|
|
4533
4546
|
);
|
|
4547
|
+
eventType = "Withdrawal";
|
|
4548
|
+
} else {
|
|
4549
|
+
eventType = "Unknown";
|
|
4534
4550
|
}
|
|
4535
4551
|
if (!item.staked) {
|
|
4536
4552
|
events.push({
|
|
4537
4553
|
timestamp: activity.timestamp,
|
|
4538
4554
|
shareChange: item.shareChange,
|
|
4539
4555
|
assetChange: item.assetChange,
|
|
4540
|
-
vaultAddress: activity.vaultAddress
|
|
4556
|
+
vaultAddress: activity.vaultAddress,
|
|
4557
|
+
eventType
|
|
4541
4558
|
// staked: item.staked,
|
|
4542
4559
|
});
|
|
4543
4560
|
}
|
|
@@ -4546,6 +4563,7 @@ var getChainUserActivity = async (address, chainId = 1) => {
|
|
|
4546
4563
|
return { events, totals: userActivityTotals };
|
|
4547
4564
|
} catch (e) {
|
|
4548
4565
|
console.log(e);
|
|
4566
|
+
return { events: [], totals: {} };
|
|
4549
4567
|
}
|
|
4550
4568
|
};
|
|
4551
4569
|
|
|
@@ -4568,7 +4586,7 @@ var getRewardsPayloadV1 = async (cycleHash, account, rewardsV1Url) => {
|
|
|
4568
4586
|
// functions/getUserAutoEthRewards.ts
|
|
4569
4587
|
var import_abis3 = require("@tokemak/abis");
|
|
4570
4588
|
var import_core3 = require("@wagmi/core");
|
|
4571
|
-
var
|
|
4589
|
+
var import_utils11 = require("@tokemak/utils");
|
|
4572
4590
|
var getAutoEthRewards = async (wagmiConfig, {
|
|
4573
4591
|
account,
|
|
4574
4592
|
currentCycleIndex,
|
|
@@ -4606,7 +4624,7 @@ var getAutoEthRewards = async (wagmiConfig, {
|
|
|
4606
4624
|
const currentAmount = Number(drippingHashPayload?.summary?.currentAmount);
|
|
4607
4625
|
const previousAmount = Number(drippingHashPayload?.summary?.previousAmount);
|
|
4608
4626
|
const cycleDuration = 604800;
|
|
4609
|
-
const lastCycleStart = (0,
|
|
4627
|
+
const lastCycleStart = (0, import_utils11.convertChainCycleToUnix)(Number(currentCycleIndex));
|
|
4610
4628
|
const timeSinceCycleStart = Date.now() / 1e3 - lastCycleStart;
|
|
4611
4629
|
const currentUserRewards = currentAmount * Math.min(timeSinceCycleStart, cycleDuration) / cycleDuration + previousAmount;
|
|
4612
4630
|
const lastWeekRewards = Number(lastWeekHashPayload?.summary?.currentAmount);
|
|
@@ -4627,7 +4645,7 @@ var getUserAutoEthRewards = async (wagmiConfig, rewardsV1Url, rewardsHash, addre
|
|
|
4627
4645
|
rewardsHash,
|
|
4628
4646
|
chainId
|
|
4629
4647
|
});
|
|
4630
|
-
const currentUserRewardsUsd = (0,
|
|
4648
|
+
const currentUserRewardsUsd = (0, import_utils11.formatCurrency)(
|
|
4631
4649
|
ethPrice * (autoETHRewards?.currentUserRewards || 0)
|
|
4632
4650
|
);
|
|
4633
4651
|
return { ...autoETHRewards, currentUserRewardsUsd };
|
|
@@ -4793,17 +4811,17 @@ var getUserV1 = async (wagmiConfig, {
|
|
|
4793
4811
|
|
|
4794
4812
|
// functions/getChainUserAutopoolsHistory.tsx
|
|
4795
4813
|
var import_graph_cli6 = require("@tokemak/graph-cli");
|
|
4814
|
+
var import_constants7 = require("@tokemak/constants");
|
|
4796
4815
|
var getChainUserAutopoolsHistory = async ({
|
|
4797
4816
|
address,
|
|
4798
4817
|
chainId = 1
|
|
4799
4818
|
}) => {
|
|
4800
4819
|
const { GetUserVaultsDayData } = (0, import_graph_cli6.getSdkByChainId)(chainId);
|
|
4801
|
-
const oneYearAgoTimestamp = Math.floor(Date.now() / 1e3) - 365 * 24 * 60 * 60;
|
|
4802
4820
|
try {
|
|
4803
4821
|
if (address) {
|
|
4804
4822
|
const { userVaultDayDatas } = await GetUserVaultsDayData({
|
|
4805
4823
|
address,
|
|
4806
|
-
timestamp:
|
|
4824
|
+
timestamp: import_constants7.TOKEMAK_LAUNCH_TIMESTAMP
|
|
4807
4825
|
});
|
|
4808
4826
|
return userVaultDayDatas;
|
|
4809
4827
|
}
|
|
@@ -4815,11 +4833,11 @@ var getChainUserAutopoolsHistory = async ({
|
|
|
4815
4833
|
};
|
|
4816
4834
|
|
|
4817
4835
|
// functions/getUserAutopoolsHistory.ts
|
|
4818
|
-
var
|
|
4836
|
+
var import_utils15 = require("@tokemak/utils");
|
|
4819
4837
|
|
|
4820
4838
|
// functions/getTokenValueDayDatas.ts
|
|
4821
4839
|
var import_chains5 = require("viem/chains");
|
|
4822
|
-
var
|
|
4840
|
+
var import_utils12 = require("@tokemak/utils");
|
|
4823
4841
|
var import_viem6 = require("viem");
|
|
4824
4842
|
var import_graph_cli7 = require("@tokemak/graph-cli");
|
|
4825
4843
|
var getTokenValueDayDatas = async (tokenAddress, chainId = import_chains5.mainnet.id) => {
|
|
@@ -4829,7 +4847,7 @@ var getTokenValueDayDatas = async (tokenAddress, chainId = import_chains5.mainne
|
|
|
4829
4847
|
tokenAddress: tokenAddress.toLowerCase()
|
|
4830
4848
|
});
|
|
4831
4849
|
const historicalPrice = tokenValueDayDatas.map((tokenValueDayData) => {
|
|
4832
|
-
const date = (0,
|
|
4850
|
+
const date = (0, import_utils12.convertTimestampToDate)(
|
|
4833
4851
|
tokenValueDayData.lastSnapshotTimestamp
|
|
4834
4852
|
);
|
|
4835
4853
|
const usdPrice = (0, import_viem6.formatUnits)(tokenValueDayData.priceInUsd, 8);
|
|
@@ -4847,7 +4865,7 @@ var getTokenValueDayDatas = async (tokenAddress, chainId = import_chains5.mainne
|
|
|
4847
4865
|
|
|
4848
4866
|
// functions/getTokenPrices.ts
|
|
4849
4867
|
var import_tokenlist4 = require("@tokemak/tokenlist");
|
|
4850
|
-
var
|
|
4868
|
+
var import_constants8 = require("@tokemak/constants");
|
|
4851
4869
|
|
|
4852
4870
|
// functions/getBackupTokenPrices.ts
|
|
4853
4871
|
var getBackupTokenPrices = async () => {
|
|
@@ -4899,7 +4917,7 @@ var getTokenPrices = async (isCronJob = false) => {
|
|
|
4899
4917
|
timeoutMS: 5 * 1e3
|
|
4900
4918
|
}))
|
|
4901
4919
|
};
|
|
4902
|
-
const response = await fetch(`${
|
|
4920
|
+
const response = await fetch(`${import_constants8.TOKEMAK_PRICES_STAGING_URL}`, {
|
|
4903
4921
|
method: "POST",
|
|
4904
4922
|
headers: {
|
|
4905
4923
|
"Content-Type": "application/json"
|
|
@@ -5084,10 +5102,8 @@ var getUserAutopoolsHistory = async (address, autopoolsHistory, events, includeT
|
|
|
5084
5102
|
const userHistory2 = filledDataByVault[vaultId];
|
|
5085
5103
|
userHistory2.sort((a, b) => a.date.getTime() - b.date.getTime());
|
|
5086
5104
|
const mergedData = autopoolHistory.reduce((result2, dayData) => {
|
|
5087
|
-
const userHistoryData =
|
|
5088
|
-
|
|
5089
|
-
dayData.date,
|
|
5090
|
-
ONE_DAY_IN_MS
|
|
5105
|
+
const userHistoryData = userHistory2.find(
|
|
5106
|
+
(userHistory3) => userHistory3.date.toDateString() === dayData.date.toDateString()
|
|
5091
5107
|
);
|
|
5092
5108
|
if (userHistoryData) {
|
|
5093
5109
|
const DECIMALS = BigInt(dayData.baseAsset.decimals);
|
|
@@ -5097,7 +5113,7 @@ var getUserAutopoolsHistory = async (address, autopoolsHistory, events, includeT
|
|
|
5097
5113
|
Math.floor(sharesRatio * Number(SCALE))
|
|
5098
5114
|
);
|
|
5099
5115
|
const navBigInt = sharesRatioBigInt * BigInt(dayData.nav) / SCALE;
|
|
5100
|
-
const navNum = (0,
|
|
5116
|
+
const navNum = (0, import_utils15.formatUnitsNum)(
|
|
5101
5117
|
navBigInt,
|
|
5102
5118
|
dayData.baseAsset.decimals
|
|
5103
5119
|
);
|
|
@@ -5168,7 +5184,7 @@ var getUserAutopoolsHistory = async (address, autopoolsHistory, events, includeT
|
|
|
5168
5184
|
let finalAggregatedHistoryArray = Object.keys(aggregatedHistoryArray).map(
|
|
5169
5185
|
(dateKey) => ({
|
|
5170
5186
|
date: aggregatedHistoryArray[dateKey].date,
|
|
5171
|
-
formattedDate: (0,
|
|
5187
|
+
formattedDate: (0, import_utils15.formatDateToReadable)(aggregatedHistoryArray[dateKey].date),
|
|
5172
5188
|
nav: {
|
|
5173
5189
|
ETH: aggregatedHistoryArray[dateKey].nav.ETH,
|
|
5174
5190
|
USD: aggregatedHistoryArray[dateKey].nav.USD,
|
|
@@ -5200,12 +5216,28 @@ var getUserAutopoolsHistory = async (address, autopoolsHistory, events, includeT
|
|
|
5200
5216
|
(dayData) => {
|
|
5201
5217
|
const eventsForDay = events?.filter((event) => {
|
|
5202
5218
|
const eventDate = new Date(Number(event.timestamp) * 1e3);
|
|
5203
|
-
|
|
5219
|
+
const windowStart = new Date(
|
|
5220
|
+
dayData.date.getTime() - 24 * 60 * 60 * 1e3
|
|
5221
|
+
);
|
|
5222
|
+
const windowEnd = dayData.date;
|
|
5223
|
+
const matches = eventDate.getTime() > windowStart.getTime() && eventDate.getTime() <= windowEnd.getTime();
|
|
5224
|
+
return matches;
|
|
5204
5225
|
});
|
|
5205
|
-
const differential = eventsForDay.reduce(
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5226
|
+
const differential = eventsForDay.reduce((sum, event) => {
|
|
5227
|
+
const vault = dayData.autopools.find(
|
|
5228
|
+
(autopool) => autopool.vaultAddress.toLowerCase() === event.vaultAddress.toLowerCase()
|
|
5229
|
+
);
|
|
5230
|
+
if (!vault) {
|
|
5231
|
+
console.warn("Event for unknown vault:", event.vaultAddress);
|
|
5232
|
+
return sum;
|
|
5233
|
+
}
|
|
5234
|
+
const decimals = vault.baseAsset.decimals;
|
|
5235
|
+
const assetChangeNum = (0, import_utils15.formatUnitsNum)(
|
|
5236
|
+
BigInt(event.assetChange || 0n),
|
|
5237
|
+
decimals
|
|
5238
|
+
);
|
|
5239
|
+
return sum + assetChangeNum;
|
|
5240
|
+
}, 0);
|
|
5209
5241
|
return {
|
|
5210
5242
|
...dayData,
|
|
5211
5243
|
events: eventsForDay,
|
|
@@ -5383,10 +5415,10 @@ var getMutlipleAutopoolRebalances = async (ids, chainId = 1) => {
|
|
|
5383
5415
|
|
|
5384
5416
|
// functions/getAutopoolDayData.ts
|
|
5385
5417
|
var import_viem7 = require("viem");
|
|
5386
|
-
var
|
|
5387
|
-
var
|
|
5418
|
+
var import_utils17 = require("@tokemak/utils");
|
|
5419
|
+
var import_constants9 = require("@tokemak/constants");
|
|
5388
5420
|
var import_graph_cli9 = require("@tokemak/graph-cli");
|
|
5389
|
-
var getAutopoolDayData = async (address, chainId = 1, startTimestamp =
|
|
5421
|
+
var getAutopoolDayData = async (address, chainId = 1, startTimestamp = import_constants9.TOKEMAK_LAUNCH_TIMESTAMP) => {
|
|
5390
5422
|
try {
|
|
5391
5423
|
const { GetAutopoolDayData } = (0, import_graph_cli9.getSdkByChainId)(chainId);
|
|
5392
5424
|
const { autopoolDayDatas } = await GetAutopoolDayData({
|
|
@@ -5397,10 +5429,10 @@ var getAutopoolDayData = async (address, chainId = 1, startTimestamp = import_co
|
|
|
5397
5429
|
const navPerShare = autoPoolDayData.nav / autoPoolDayData.totalSupply;
|
|
5398
5430
|
let baseApy = autoPoolDayData.autopoolApy;
|
|
5399
5431
|
let rewarderApy = 0;
|
|
5400
|
-
const formattedRewarder7DayMAApy = (0,
|
|
5432
|
+
const formattedRewarder7DayMAApy = (0, import_utils17.formatEtherNum)(
|
|
5401
5433
|
BigInt(Number(autoPoolDayData.rewarderDay7MAApy) || 0)
|
|
5402
5434
|
);
|
|
5403
|
-
const formattedRewarder30DayMAApy = (0,
|
|
5435
|
+
const formattedRewarder30DayMAApy = (0, import_utils17.formatEtherNum)(
|
|
5404
5436
|
BigInt(Number(autoPoolDayData.rewarderDay30MAApy) || 0)
|
|
5405
5437
|
);
|
|
5406
5438
|
if (formattedRewarder7DayMAApy) {
|
|
@@ -5500,13 +5532,13 @@ var getChainUserAutopools = async ({
|
|
|
5500
5532
|
};
|
|
5501
5533
|
|
|
5502
5534
|
// functions/getUserAutopools.ts
|
|
5503
|
-
var
|
|
5535
|
+
var import_utils19 = require("@tokemak/utils");
|
|
5504
5536
|
var import_tokenlist6 = require("@tokemak/tokenlist");
|
|
5505
5537
|
|
|
5506
5538
|
// functions/getUserAutopool.tsx
|
|
5507
5539
|
var import_viem8 = require("viem");
|
|
5508
5540
|
var import_core9 = require("@wagmi/core");
|
|
5509
|
-
var
|
|
5541
|
+
var import_utils18 = require("@tokemak/utils");
|
|
5510
5542
|
var import_abis9 = require("@tokemak/abis");
|
|
5511
5543
|
var getUserAutopool = async (wagmiConfig, {
|
|
5512
5544
|
address,
|
|
@@ -5555,10 +5587,10 @@ var getUserAutopool = async (wagmiConfig, {
|
|
|
5555
5587
|
args: [address],
|
|
5556
5588
|
chainId: autopool?.chain?.chainId
|
|
5557
5589
|
});
|
|
5558
|
-
const stakedShares = (0,
|
|
5590
|
+
const stakedShares = (0, import_utils18.formatEtherNum)(stakedPoolShares);
|
|
5559
5591
|
const stakedNav = stakedShares * (autopool?.navPerShare.baseAsset || 0);
|
|
5560
5592
|
const stakedNavUsd = stakedShares * (autopool?.navPerShare.USD || 0);
|
|
5561
|
-
const unstakedShares = (0,
|
|
5593
|
+
const unstakedShares = (0, import_utils18.formatEtherNum)(unstakedPoolShares || 0n);
|
|
5562
5594
|
const unstakedNav = unstakedShares * (autopool?.navPerShare.USD || 0);
|
|
5563
5595
|
const unstakedNavUsd = unstakedShares * (autopool?.navPerShare.USD || 0);
|
|
5564
5596
|
const totalShares = unstakedShares + stakedShares;
|
|
@@ -5579,7 +5611,7 @@ var getUserAutopool = async (wagmiConfig, {
|
|
|
5579
5611
|
});
|
|
5580
5612
|
pastRewarderBalances = pastRewards.map(({ result }, index) => {
|
|
5581
5613
|
const balance = result;
|
|
5582
|
-
const shares = (0,
|
|
5614
|
+
const shares = (0, import_utils18.formatEtherNum)(result);
|
|
5583
5615
|
const nav = shares * (autopool?.navPerShare.baseAsset || 0);
|
|
5584
5616
|
const navUsd = shares * (autopool?.navPerShare.USD || 0);
|
|
5585
5617
|
return {
|
|
@@ -5697,14 +5729,14 @@ var getUserAutopools = async ({
|
|
|
5697
5729
|
);
|
|
5698
5730
|
if (autopoolData) {
|
|
5699
5731
|
const isDOLA = autopoolData.symbol === "autoDOLA" && userAutoDOLA;
|
|
5700
|
-
const userShares = isDOLA ? userAutoDOLA?.totalShares : (0,
|
|
5701
|
-
const totalVaultShares = (0,
|
|
5732
|
+
const userShares = isDOLA ? userAutoDOLA?.totalShares : (0, import_utils19.formatEtherNum)(userAutopool?.totalShares);
|
|
5733
|
+
const totalVaultShares = (0, import_utils19.formatEtherNum)(autopoolData?.totalSupply);
|
|
5702
5734
|
const userShareOfVault = userShares / totalVaultShares;
|
|
5703
|
-
const totalDeposits = (0,
|
|
5735
|
+
const totalDeposits = (0, import_utils19.formatUnitsNum)(
|
|
5704
5736
|
userActivity?.totals[userAutopool.vaultAddress]?.totalDeposits || 0n,
|
|
5705
5737
|
autopoolData?.baseAsset.decimals
|
|
5706
5738
|
);
|
|
5707
|
-
const totalWithdrawals = (0,
|
|
5739
|
+
const totalWithdrawals = (0, import_utils19.formatUnitsNum)(
|
|
5708
5740
|
userActivity?.totals[userAutopool.vaultAddress]?.totalWithdrawals || 0n,
|
|
5709
5741
|
autopoolData?.baseAsset.decimals
|
|
5710
5742
|
);
|
|
@@ -5713,7 +5745,7 @@ var getUserAutopools = async ({
|
|
|
5713
5745
|
);
|
|
5714
5746
|
let lastDeposit;
|
|
5715
5747
|
if (poolEvents && poolEvents?.length > 0) {
|
|
5716
|
-
lastDeposit = (0,
|
|
5748
|
+
lastDeposit = (0, import_utils19.convertTimestampToDate)(
|
|
5717
5749
|
poolEvents[poolEvents.length - 1].timestamp
|
|
5718
5750
|
).toLocaleDateString("en-US", {
|
|
5719
5751
|
day: "2-digit",
|
|
@@ -5813,7 +5845,7 @@ var getUserAutopools = async ({
|
|
|
5813
5845
|
totalWithdrawals: prev.totalWithdrawals + totalWithdrawals
|
|
5814
5846
|
};
|
|
5815
5847
|
const stakedBalance = isDOLA ? userAutoDOLA?.staked.balance : BigInt(userAutopool?.stakedShares);
|
|
5816
|
-
const stakedShares = isDOLA ? userAutoDOLA?.staked.shares : (0,
|
|
5848
|
+
const stakedShares = isDOLA ? userAutoDOLA?.staked.shares : (0, import_utils19.formatEtherNum)(stakedBalance);
|
|
5817
5849
|
const stakedNav = stakedShares * (autopoolData?.navPerShare.baseAsset || 0);
|
|
5818
5850
|
const staked = convertBaseAssetToTokenPrices(
|
|
5819
5851
|
stakedNav,
|
|
@@ -5821,7 +5853,7 @@ var getUserAutopools = async ({
|
|
|
5821
5853
|
prices
|
|
5822
5854
|
);
|
|
5823
5855
|
const unstakedBalance = isDOLA ? userAutoDOLA?.unstaked.balance : BigInt(userAutopool?.walletShares);
|
|
5824
|
-
const unstakedShares = isDOLA ? userAutoDOLA?.unstaked.shares : (0,
|
|
5856
|
+
const unstakedShares = isDOLA ? userAutoDOLA?.unstaked.shares : (0, import_utils19.formatEtherNum)(unstakedBalance);
|
|
5825
5857
|
const unstakedNav = unstakedShares * (autopoolData?.navPerShare.baseAsset || 0);
|
|
5826
5858
|
const unstaked = convertBaseAssetToTokenPrices(
|
|
5827
5859
|
unstakedNav,
|
|
@@ -5830,10 +5862,7 @@ var getUserAutopools = async ({
|
|
|
5830
5862
|
);
|
|
5831
5863
|
const stakedRatio = stakedShares / userShares;
|
|
5832
5864
|
const unstakedRatio = 1 - stakedRatio;
|
|
5833
|
-
const
|
|
5834
|
-
const baseApr = autopoolData?.apr?.base ?? 0;
|
|
5835
|
-
const stakedAprForBlend = isSilo ? baseApr : autopoolData?.apr?.combined ?? 0;
|
|
5836
|
-
const blendedApr = stakedRatio * stakedAprForBlend + unstakedRatio * baseApr;
|
|
5865
|
+
const blendedApr = stakedRatio * autopoolData?.apr?.combined + unstakedRatio * autopoolData?.apr?.base;
|
|
5837
5866
|
return {
|
|
5838
5867
|
name: autopoolData?.name,
|
|
5839
5868
|
symbol: autopoolData?.symbol,
|
|
@@ -5856,7 +5885,6 @@ var getUserAutopools = async ({
|
|
|
5856
5885
|
nav: unstaked
|
|
5857
5886
|
},
|
|
5858
5887
|
useDenomination: autopoolData?.useDenomination,
|
|
5859
|
-
baseApr,
|
|
5860
5888
|
blendedApr,
|
|
5861
5889
|
rewardsClaimed: userAutopool?.rewardsClaimed,
|
|
5862
5890
|
lastDeposit,
|
|
@@ -6200,7 +6228,7 @@ var getChainUserAutopoolsRewards = async (wagmiConfig, {
|
|
|
6200
6228
|
};
|
|
6201
6229
|
|
|
6202
6230
|
// functions/getUserAutopoolsRewards.ts
|
|
6203
|
-
var
|
|
6231
|
+
var import_utils23 = require("@tokemak/utils");
|
|
6204
6232
|
var import_tokenlist8 = require("@tokemak/tokenlist");
|
|
6205
6233
|
var import_chains7 = require("viem/chains");
|
|
6206
6234
|
var getUserAutopoolsRewards = async (wagmiConfig, {
|
|
@@ -6232,7 +6260,7 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
|
|
|
6232
6260
|
return [];
|
|
6233
6261
|
}
|
|
6234
6262
|
return autopool.extraRewarders.map((extraRewards2) => {
|
|
6235
|
-
const rewarderToken = (0,
|
|
6263
|
+
const rewarderToken = (0, import_utils23.getToken)(
|
|
6236
6264
|
extraRewards2.rewardToken?.id,
|
|
6237
6265
|
autopool.chain?.chainId
|
|
6238
6266
|
);
|
|
@@ -6241,7 +6269,7 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
|
|
|
6241
6269
|
if (rewarderToken.symbol === "XSILO") {
|
|
6242
6270
|
price = tokenPrices[import_tokenlist8.SILO_TOKEN.symbol] || 0;
|
|
6243
6271
|
}
|
|
6244
|
-
const formattedAmount = (0,
|
|
6272
|
+
const formattedAmount = (0, import_utils23.formatUnitsNum)(
|
|
6245
6273
|
claimableAmount,
|
|
6246
6274
|
rewarderToken.decimals || 18
|
|
6247
6275
|
);
|
|
@@ -6259,7 +6287,7 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
|
|
|
6259
6287
|
const tokenRewards = {};
|
|
6260
6288
|
Object.values(chainUserRewards).forEach((autopoolRewards) => {
|
|
6261
6289
|
Object.entries(autopoolRewards).forEach(([tokenAddress, amount]) => {
|
|
6262
|
-
const token = (0,
|
|
6290
|
+
const token = (0, import_utils23.getToken)(tokenAddress, chainId);
|
|
6263
6291
|
const tokenSymbol = token.symbol;
|
|
6264
6292
|
if (!tokenRewards[tokenSymbol]) {
|
|
6265
6293
|
tokenRewards[tokenSymbol] = {
|
|
@@ -6279,7 +6307,7 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
|
|
|
6279
6307
|
if (tokenSymbol === "XSILO") {
|
|
6280
6308
|
price = tokenPrices[import_tokenlist8.SILO_TOKEN.symbol] || 0;
|
|
6281
6309
|
}
|
|
6282
|
-
const formattedAmount = (0,
|
|
6310
|
+
const formattedAmount = (0, import_utils23.formatUnitsNum)(amount, decimals || 18);
|
|
6283
6311
|
tokenRewards[tokenSymbol] = {
|
|
6284
6312
|
amount,
|
|
6285
6313
|
formattedAmount,
|
|
@@ -6350,10 +6378,10 @@ var getUserAutopoolsRewards = async (wagmiConfig, {
|
|
|
6350
6378
|
|
|
6351
6379
|
// functions/getAmountWithdrawn.ts
|
|
6352
6380
|
var import_viem13 = require("viem");
|
|
6353
|
-
var
|
|
6381
|
+
var import_utils25 = require("@tokemak/utils");
|
|
6354
6382
|
|
|
6355
6383
|
// functions/getSwapQuote.ts
|
|
6356
|
-
var
|
|
6384
|
+
var import_constants10 = require("@tokemak/constants");
|
|
6357
6385
|
|
|
6358
6386
|
// functions/getAddressFromSystemRegistry.ts
|
|
6359
6387
|
var import_core12 = require("@wagmi/core");
|
|
@@ -6398,7 +6426,7 @@ var getSwapQuote = async (config, { chainId, ...params }) => {
|
|
|
6398
6426
|
}
|
|
6399
6427
|
const sellAmount = params.sellAmount.toString();
|
|
6400
6428
|
const taker = await getAutopilotRouter(config, { chainId });
|
|
6401
|
-
const response = await fetch(
|
|
6429
|
+
const response = await fetch(import_constants10.TOKEMAK_SWAP_QUOTE_URL, {
|
|
6402
6430
|
method: "POST",
|
|
6403
6431
|
headers: {
|
|
6404
6432
|
"Content-Type": "application/json"
|
|
@@ -6429,7 +6457,7 @@ var import_abis12 = require("@tokemak/abis");
|
|
|
6429
6457
|
var import_config11 = require("@tokemak/config");
|
|
6430
6458
|
var import_autopilot_swap_route_calc = require("@tokemak/autopilot-swap-route-calc");
|
|
6431
6459
|
var import_viem12 = require("viem");
|
|
6432
|
-
var
|
|
6460
|
+
var import_constants11 = require("@tokemak/constants");
|
|
6433
6461
|
var placeholderAddress = "0x8b4334d4812c530574bd4f2763fcd22de94a969b";
|
|
6434
6462
|
var getDynamicSwap = async ({
|
|
6435
6463
|
address,
|
|
@@ -6474,12 +6502,13 @@ var getDynamicSwap = async ({
|
|
|
6474
6502
|
body: JSON.stringify({
|
|
6475
6503
|
chainId,
|
|
6476
6504
|
systemName: "gen3",
|
|
6477
|
-
slippageBps: Math.floor(slippage *
|
|
6505
|
+
// slippageBps: Math.floor(slippage * 10000),
|
|
6506
|
+
slippageBps: 2e3,
|
|
6478
6507
|
tokensToLiquidate,
|
|
6479
6508
|
sellAllOnlyCompatible: true
|
|
6480
6509
|
})
|
|
6481
6510
|
};
|
|
6482
|
-
dynamicSwaps = await (await fetch(
|
|
6511
|
+
dynamicSwaps = await (await fetch(import_constants11.TOKEMAK_DYNAMIC_SWAP_ROUTES_URL, requestInit)).json();
|
|
6483
6512
|
if (dynamicSwaps?.success) {
|
|
6484
6513
|
const autopoolRouter = await getAutopilotRouter(config, { chainId });
|
|
6485
6514
|
if (!autopoolRouter) {
|
|
@@ -6564,7 +6593,7 @@ var getAmountWithdrawn = async ({
|
|
|
6564
6593
|
let quote;
|
|
6565
6594
|
let convertedAssets;
|
|
6566
6595
|
if (!!dynamicSwap?.previewRedeem) {
|
|
6567
|
-
const minAmountWithSlippage = (0,
|
|
6596
|
+
const minAmountWithSlippage = (0, import_utils25.calculateMinAmountWithSlippage)(
|
|
6568
6597
|
dynamicSwap?.previewRedeem,
|
|
6569
6598
|
slippage
|
|
6570
6599
|
);
|
|
@@ -6588,7 +6617,7 @@ var getAmountWithdrawn = async ({
|
|
|
6588
6617
|
buyToken,
|
|
6589
6618
|
sellToken,
|
|
6590
6619
|
sellAmount: dynamicSwap?.previewRedeem,
|
|
6591
|
-
slippageBps: (0,
|
|
6620
|
+
slippageBps: (0, import_utils25.convertNumToBps)(slippage),
|
|
6592
6621
|
chainId,
|
|
6593
6622
|
includeSources: "0xV2",
|
|
6594
6623
|
sellAll: true
|
|
@@ -6616,7 +6645,7 @@ var getAmountWithdrawn = async ({
|
|
|
6616
6645
|
// functions/getAmountDeposited.ts
|
|
6617
6646
|
var import_core15 = require("@wagmi/core");
|
|
6618
6647
|
var import_abis14 = require("@tokemak/abis");
|
|
6619
|
-
var
|
|
6648
|
+
var import_utils26 = require("@tokemak/utils");
|
|
6620
6649
|
var getAmountDeposited = async ({
|
|
6621
6650
|
address,
|
|
6622
6651
|
chainId,
|
|
@@ -6637,13 +6666,13 @@ var getAmountDeposited = async ({
|
|
|
6637
6666
|
chainId
|
|
6638
6667
|
});
|
|
6639
6668
|
if (!isSwap) {
|
|
6640
|
-
let minAmountWithSlippage = (0,
|
|
6669
|
+
let minAmountWithSlippage = (0, import_utils26.calculateMinAmountWithSlippage)(
|
|
6641
6670
|
previewDeposit,
|
|
6642
6671
|
slippage
|
|
6643
6672
|
);
|
|
6644
|
-
return (0,
|
|
6673
|
+
return (0, import_utils26.formatEtherNum)(minAmountWithSlippage);
|
|
6645
6674
|
} else {
|
|
6646
|
-
return (0,
|
|
6675
|
+
return (0, import_utils26.formatEtherNum)(previewDeposit);
|
|
6647
6676
|
}
|
|
6648
6677
|
} catch (e) {
|
|
6649
6678
|
console.error(e);
|
|
@@ -7505,7 +7534,7 @@ var waitForMessageReceived = async ({
|
|
|
7505
7534
|
// functions/getChainUserSToke.ts
|
|
7506
7535
|
var import_abis17 = require("@tokemak/abis");
|
|
7507
7536
|
var import_config13 = require("@tokemak/config");
|
|
7508
|
-
var
|
|
7537
|
+
var import_utils27 = require("@tokemak/utils");
|
|
7509
7538
|
var import_core18 = require("@wagmi/core");
|
|
7510
7539
|
var import_viem15 = require("viem");
|
|
7511
7540
|
var import_chains9 = require("viem/chains");
|
|
@@ -7581,8 +7610,8 @@ var getChainUserSToke = async (wagmiConfig, {
|
|
|
7581
7610
|
if (withdrawalAmount > 0n && cycleIndex >= withdrawalMinCycle) {
|
|
7582
7611
|
balanceExcludingWithdrawal = balanceExcludingWithdrawal - withdrawalAmount;
|
|
7583
7612
|
}
|
|
7584
|
-
const withdrawalAmountUsd = (0,
|
|
7585
|
-
(0,
|
|
7613
|
+
const withdrawalAmountUsd = (0, import_utils27.formatCurrency)(
|
|
7614
|
+
(0, import_utils27.formatEtherNum)(withdrawalAmount) * tokePrice
|
|
7586
7615
|
);
|
|
7587
7616
|
const lockDuration = Number(depositLockDuration);
|
|
7588
7617
|
const lockCycle = Number(depositLockCycle);
|
|
@@ -7603,16 +7632,16 @@ var getChainUserSToke = async (wagmiConfig, {
|
|
|
7603
7632
|
const withdrawAvailable = lockRenew - 1;
|
|
7604
7633
|
const hasAddedLockedToke = depositAmount > 0n && depositAmount > rolloverDepositAmount;
|
|
7605
7634
|
const addedLockedToke = depositAmount - rolloverDepositAmount;
|
|
7606
|
-
const balanceUSD = (0,
|
|
7635
|
+
const balanceUSD = (0, import_utils27.formatCurrency)(
|
|
7607
7636
|
Number((0, import_viem15.formatEther)(balanceExcludingWithdrawal)) * tokePrice
|
|
7608
7637
|
);
|
|
7609
|
-
const balanceExcludingWithdrawalUsd = (0,
|
|
7610
|
-
(0,
|
|
7638
|
+
const balanceExcludingWithdrawalUsd = (0, import_utils27.formatCurrency)(
|
|
7639
|
+
(0, import_utils27.formatEtherNum)(balanceExcludingWithdrawal) * tokePrice
|
|
7611
7640
|
);
|
|
7612
7641
|
const isUnlockRequestAvailable = currentCycle === withdrawAvailable;
|
|
7613
7642
|
const hasRequestedUnlock = withdrawalAmount > 0n;
|
|
7614
|
-
const unlockRequestPeriodStartUnix = (0,
|
|
7615
|
-
const unlockRequestPeriodEndUnix = (0,
|
|
7643
|
+
const unlockRequestPeriodStartUnix = (0, import_utils27.convertChainCycleToUnix)(withdrawAvailable, chainId) - Date.now() / 1e3;
|
|
7644
|
+
const unlockRequestPeriodEndUnix = (0, import_utils27.convertChainCycleToUnix)(lockRenew, chainId) - Date.now() / 1e3;
|
|
7616
7645
|
const hasBalance = balance > 0n;
|
|
7617
7646
|
const hasBalanceExcludingWithdrawal = balanceExcludingWithdrawal > 0n;
|
|
7618
7647
|
const hasUnlockableBalance = withdrawalMinCycle <= currentCycle && withdrawalAmount > 0n;
|
|
@@ -7622,8 +7651,8 @@ var getChainUserSToke = async (wagmiConfig, {
|
|
|
7622
7651
|
lockDurationInMonths = lockDuration - 1;
|
|
7623
7652
|
}
|
|
7624
7653
|
const unlockPeriodDateRangeArray = [
|
|
7625
|
-
new Date((0,
|
|
7626
|
-
new Date((0,
|
|
7654
|
+
new Date((0, import_utils27.convertChainCycleToUnix)(withdrawAvailable, chainId) * 1e3),
|
|
7655
|
+
new Date((0, import_utils27.convertChainCycleToUnix)(lockRenew, chainId) * 1e3)
|
|
7627
7656
|
];
|
|
7628
7657
|
const {
|
|
7629
7658
|
unlockPeriodDateRange,
|
|
@@ -7635,18 +7664,18 @@ var getChainUserSToke = async (wagmiConfig, {
|
|
|
7635
7664
|
unlockPeriodDateRangeArray,
|
|
7636
7665
|
chainId === import_chains9.sepolia.id ? "time" : "date"
|
|
7637
7666
|
);
|
|
7638
|
-
const totalActiveUserCredits = (0,
|
|
7639
|
-
const totalUserCredits = (0,
|
|
7667
|
+
const totalActiveUserCredits = (0, import_utils27.formatEtherNum)(balanceExcludingWithdrawal) * lockDurationInMonths;
|
|
7668
|
+
const totalUserCredits = (0, import_utils27.formatEtherNum)(balance) * lockDurationInMonths;
|
|
7640
7669
|
return {
|
|
7641
7670
|
balance,
|
|
7642
7671
|
balanceUSD,
|
|
7643
7672
|
balanceExcludingWithdrawal: hasBalance ? (0, import_viem15.formatEther)(balanceExcludingWithdrawal) : "0.00",
|
|
7644
7673
|
balanceExcludingWithdrawalUsd,
|
|
7645
7674
|
hasBalanceExcludingWithdrawal,
|
|
7646
|
-
timeLeftBeforeUnlockRequestAvailable: (0,
|
|
7675
|
+
timeLeftBeforeUnlockRequestAvailable: (0, import_utils27.convertSecondsToRemainingTime)(
|
|
7647
7676
|
unlockRequestPeriodStartUnix
|
|
7648
7677
|
),
|
|
7649
|
-
timeLeftBeforeUnlockRequestUnavailable: (0,
|
|
7678
|
+
timeLeftBeforeUnlockRequestUnavailable: (0, import_utils27.convertSecondsToRemainingTime)(
|
|
7650
7679
|
unlockRequestPeriodEndUnix
|
|
7651
7680
|
),
|
|
7652
7681
|
withdrawalAmount,
|
|
@@ -7663,7 +7692,7 @@ var getChainUserSToke = async (wagmiConfig, {
|
|
|
7663
7692
|
unlockRenewalDate,
|
|
7664
7693
|
lockDurationInMonths,
|
|
7665
7694
|
boost: lockDuration,
|
|
7666
|
-
points: (0,
|
|
7695
|
+
points: (0, import_utils27.formatEtherNum)(balanceExcludingWithdrawal) * lockDuration,
|
|
7667
7696
|
totalActiveCredits: totalActiveUserCredits,
|
|
7668
7697
|
totalCredits: totalUserCredits
|
|
7669
7698
|
};
|
|
@@ -7675,7 +7704,7 @@ var getChainUserSToke = async (wagmiConfig, {
|
|
|
7675
7704
|
};
|
|
7676
7705
|
|
|
7677
7706
|
// functions/getUserSToke.ts
|
|
7678
|
-
var
|
|
7707
|
+
var import_utils29 = require("@tokemak/utils");
|
|
7679
7708
|
var getUserSToke = async (wagmiConfig, {
|
|
7680
7709
|
address,
|
|
7681
7710
|
tokePrice,
|
|
@@ -7702,8 +7731,8 @@ var getUserSToke = async (wagmiConfig, {
|
|
|
7702
7731
|
}
|
|
7703
7732
|
return acc;
|
|
7704
7733
|
}, 0n);
|
|
7705
|
-
const totalBalance = (0,
|
|
7706
|
-
const totalBalanceUsd = (0,
|
|
7734
|
+
const totalBalance = (0, import_utils29.formatEtherNum)(totalBalanceRaw || 0n);
|
|
7735
|
+
const totalBalanceUsd = (0, import_utils29.formatCurrency)(totalBalance * tokePrice);
|
|
7707
7736
|
const hasBalance = totalBalance > 0;
|
|
7708
7737
|
return {
|
|
7709
7738
|
chains: { ...userSToke },
|
|
@@ -7720,9 +7749,9 @@ var getUserSToke = async (wagmiConfig, {
|
|
|
7720
7749
|
var import_viem16 = require("viem");
|
|
7721
7750
|
var import_core19 = require("@wagmi/core");
|
|
7722
7751
|
var import_abis18 = require("@tokemak/abis");
|
|
7723
|
-
var import_utils30 = require("@tokemak/utils");
|
|
7724
|
-
var import_config14 = require("@tokemak/config");
|
|
7725
7752
|
var import_utils31 = require("@tokemak/utils");
|
|
7753
|
+
var import_config14 = require("@tokemak/config");
|
|
7754
|
+
var import_utils32 = require("@tokemak/utils");
|
|
7726
7755
|
var getChainSToke = async (wagmiConfig, {
|
|
7727
7756
|
tokePrice,
|
|
7728
7757
|
chainId
|
|
@@ -7748,15 +7777,15 @@ var getChainSToke = async (wagmiConfig, {
|
|
|
7748
7777
|
]
|
|
7749
7778
|
});
|
|
7750
7779
|
const tvl = Number((0, import_viem16.formatEther)(totalSupply || 0n)) * tokePrice;
|
|
7751
|
-
const secondsLeftBeforeNextCycle = (0,
|
|
7780
|
+
const secondsLeftBeforeNextCycle = (0, import_utils31.convertChainCycleToUnix)(Number(currentCycle) + 1, chainId) - Date.now() / 1e3;
|
|
7752
7781
|
return {
|
|
7753
7782
|
rawTotalSupply: totalSupply,
|
|
7754
|
-
totalSupply: (0,
|
|
7755
|
-
tvl: (0,
|
|
7783
|
+
totalSupply: (0, import_utils31.formatLargeNumber)((0, import_viem16.formatEther)(totalSupply || 0n)),
|
|
7784
|
+
tvl: (0, import_utils31.formatTVL)(tvl),
|
|
7756
7785
|
rawTVL: tvl,
|
|
7757
7786
|
currentCycle,
|
|
7758
|
-
chain: (0,
|
|
7759
|
-
timeBeforeNextCycle: (0,
|
|
7787
|
+
chain: (0, import_utils32.getNetwork)(chainId),
|
|
7788
|
+
timeBeforeNextCycle: (0, import_utils31.convertSecondsToRemainingTime)(
|
|
7760
7789
|
secondsLeftBeforeNextCycle
|
|
7761
7790
|
)
|
|
7762
7791
|
};
|
|
@@ -7767,7 +7796,7 @@ var getChainSToke = async (wagmiConfig, {
|
|
|
7767
7796
|
};
|
|
7768
7797
|
|
|
7769
7798
|
// functions/getSToke.ts
|
|
7770
|
-
var
|
|
7799
|
+
var import_utils33 = require("@tokemak/utils");
|
|
7771
7800
|
var import_viem17 = require("viem");
|
|
7772
7801
|
var getSToke = async (wagmiConfig, {
|
|
7773
7802
|
tokePrice,
|
|
@@ -7787,14 +7816,14 @@ var getSToke = async (wagmiConfig, {
|
|
|
7787
7816
|
}
|
|
7788
7817
|
return acc;
|
|
7789
7818
|
}, 0n);
|
|
7790
|
-
const totalSupply = (0,
|
|
7819
|
+
const totalSupply = (0, import_utils33.formatLargeNumber)((0, import_viem17.formatEther)(totalSupplyBigInt || 0n));
|
|
7791
7820
|
let tvlNum = Object.values(sToke).reduce((acc, item) => {
|
|
7792
7821
|
if (item && item.rawTVL) {
|
|
7793
7822
|
return acc + item.rawTVL;
|
|
7794
7823
|
}
|
|
7795
7824
|
return acc;
|
|
7796
7825
|
}, 0);
|
|
7797
|
-
const tvl = (0,
|
|
7826
|
+
const tvl = (0, import_utils33.formatTVL)(tvlNum);
|
|
7798
7827
|
return { totalSupply, tvl, rawTVL: tvlNum, chains: { ...sToke } };
|
|
7799
7828
|
} catch (e) {
|
|
7800
7829
|
console.error(e);
|
|
@@ -7846,7 +7875,7 @@ var getChainCycleRolloverBlockNumber = async (wagmiConfig, {
|
|
|
7846
7875
|
};
|
|
7847
7876
|
|
|
7848
7877
|
// functions/getChainUserSTokeVotes.ts
|
|
7849
|
-
var
|
|
7878
|
+
var import_utils36 = require("@tokemak/utils");
|
|
7850
7879
|
var import_graph_cli13 = require("@tokemak/graph-cli");
|
|
7851
7880
|
var getChainUserSTokeVotes = async ({
|
|
7852
7881
|
address,
|
|
@@ -7869,10 +7898,10 @@ var getChainUserSTokeVotes = async ({
|
|
|
7869
7898
|
subgraphUserVotesData?.pools || [],
|
|
7870
7899
|
subgraphUserVotesData?.weights || []
|
|
7871
7900
|
);
|
|
7872
|
-
const stakedToke = (0,
|
|
7901
|
+
const stakedToke = (0, import_utils36.formatEtherNum)(
|
|
7873
7902
|
BigInt(subgraphAccountVotesBalance?.amount || 0n)
|
|
7874
7903
|
);
|
|
7875
|
-
const totalUserVotes = (0,
|
|
7904
|
+
const totalUserVotes = (0, import_utils36.formatEtherNum)(
|
|
7876
7905
|
BigInt(subgraphAccountVotesBalance?.points || 0n)
|
|
7877
7906
|
);
|
|
7878
7907
|
const autopools = {};
|
|
@@ -7960,7 +7989,7 @@ var getUserSTokeVotes = async ({
|
|
|
7960
7989
|
|
|
7961
7990
|
// functions/getChainSTokeVotes.ts
|
|
7962
7991
|
var import_config15 = require("@tokemak/config");
|
|
7963
|
-
var
|
|
7992
|
+
var import_utils39 = require("@tokemak/utils");
|
|
7964
7993
|
var import_viem18 = require("viem");
|
|
7965
7994
|
var import_graph_cli14 = require("@tokemak/graph-cli");
|
|
7966
7995
|
var getChainSTokeVotes = async ({
|
|
@@ -7991,13 +8020,13 @@ var getChainSTokeVotes = async ({
|
|
|
7991
8020
|
updatedPoints
|
|
7992
8021
|
);
|
|
7993
8022
|
const globalSystemVotes = globalVoted + globalNotVoted;
|
|
7994
|
-
const totalSystemVotesNum = (0,
|
|
8023
|
+
const totalSystemVotesNum = (0, import_utils39.formatEtherNum)(globalSystemVotes);
|
|
7995
8024
|
const formattedAutopoolVotes = Object.fromEntries(
|
|
7996
8025
|
Object.entries(autopoolVotes).filter(
|
|
7997
8026
|
([poolAddress]) => includeTestnet ? true : whitelistedPools.includes(poolAddress)
|
|
7998
8027
|
).map(([poolAddress, rawVote]) => {
|
|
7999
|
-
const formattedVote = (0,
|
|
8000
|
-
(0,
|
|
8028
|
+
const formattedVote = (0, import_utils39.formatLargeNumber)(
|
|
8029
|
+
(0, import_utils39.formatEtherNum)(BigInt(rawVote))
|
|
8001
8030
|
);
|
|
8002
8031
|
return [
|
|
8003
8032
|
poolAddress,
|
|
@@ -8012,7 +8041,7 @@ var getChainSTokeVotes = async ({
|
|
|
8012
8041
|
globalSystemVotes
|
|
8013
8042
|
},
|
|
8014
8043
|
totalSystemVotesNum,
|
|
8015
|
-
totalSystemVotes: (0,
|
|
8044
|
+
totalSystemVotes: (0, import_utils39.formatLargeNumber)(totalSystemVotesNum),
|
|
8016
8045
|
autopoolVotes: formattedAutopoolVotes
|
|
8017
8046
|
};
|
|
8018
8047
|
};
|
|
@@ -8038,7 +8067,7 @@ var getSTokeVotes = async ({
|
|
|
8038
8067
|
// functions/getChainSTokeRewards.ts
|
|
8039
8068
|
var import_config16 = require("@tokemak/config");
|
|
8040
8069
|
var import_viem19 = require("viem");
|
|
8041
|
-
var
|
|
8070
|
+
var import_utils41 = require("@tokemak/utils");
|
|
8042
8071
|
var import_graph_cli15 = require("@tokemak/graph-cli");
|
|
8043
8072
|
var getChainSTokeRewards = async ({
|
|
8044
8073
|
chainId
|
|
@@ -8062,9 +8091,9 @@ var getChainSTokeRewards = async ({
|
|
|
8062
8091
|
if (!whitelistedPools.includes(pool.id.toLowerCase())) {
|
|
8063
8092
|
continue;
|
|
8064
8093
|
}
|
|
8065
|
-
const convertedBalance = (0,
|
|
8094
|
+
const convertedBalance = (0, import_utils41.formatEtherNum)(pool.balance);
|
|
8066
8095
|
const convertedBalanceUSD = Number((0, import_viem19.formatUnits)(pool.balanceUSD, 8));
|
|
8067
|
-
const convertedApr = (0,
|
|
8096
|
+
const convertedApr = (0, import_utils41.formatEtherNum)(pool.currentAprPerCredit);
|
|
8068
8097
|
if (minApr === null || convertedApr < minApr) {
|
|
8069
8098
|
minApr = convertedApr;
|
|
8070
8099
|
}
|
|
@@ -8137,7 +8166,7 @@ var getSTokeRewards = async ({
|
|
|
8137
8166
|
|
|
8138
8167
|
// functions/getChainUserSTokeRewards.ts
|
|
8139
8168
|
var import_config17 = require("@tokemak/config");
|
|
8140
|
-
var
|
|
8169
|
+
var import_utils44 = require("@tokemak/utils");
|
|
8141
8170
|
var getChainUserSTokeRewards = async (wagmiConfig, {
|
|
8142
8171
|
address,
|
|
8143
8172
|
chainId,
|
|
@@ -8188,14 +8217,14 @@ var getChainUserSTokeRewards = async (wagmiConfig, {
|
|
|
8188
8217
|
throw fallbackError;
|
|
8189
8218
|
}
|
|
8190
8219
|
}
|
|
8191
|
-
const claimableNum = (0,
|
|
8220
|
+
const claimableNum = (0, import_utils44.formatEtherNum)(tokeRewards?.claimable || 0n);
|
|
8192
8221
|
const claimableUsd = tokePrice * claimableNum;
|
|
8193
8222
|
const hasClaimable = claimableNum > 0n;
|
|
8194
|
-
const pendingRewards = (0,
|
|
8223
|
+
const pendingRewards = (0, import_utils44.formatEtherNum)(
|
|
8195
8224
|
tokeRewards?.rewardsPayload.breakdown?.totalRewardAmount || 0n
|
|
8196
8225
|
);
|
|
8197
8226
|
const pendingRewardsUsd = tokePrice * pendingRewards;
|
|
8198
|
-
const totalRewardsReceived = (0,
|
|
8227
|
+
const totalRewardsReceived = (0, import_utils44.formatEtherNum)(
|
|
8199
8228
|
tokeRewards.rewardsPayload.payload.amount || 0n
|
|
8200
8229
|
);
|
|
8201
8230
|
const totalRewardsReceivedUsd = tokePrice * totalRewardsReceived;
|
|
@@ -8271,7 +8300,7 @@ var getSubgraphStatus = async (includeTestnet = false) => {
|
|
|
8271
8300
|
var import_core21 = require("@wagmi/core");
|
|
8272
8301
|
var import_abis20 = require("@tokemak/abis");
|
|
8273
8302
|
var import_viem20 = require("viem");
|
|
8274
|
-
var
|
|
8303
|
+
var import_utils46 = require("@tokemak/utils");
|
|
8275
8304
|
var import_config18 = require("@tokemak/config");
|
|
8276
8305
|
var import_chains10 = require("viem/chains");
|
|
8277
8306
|
var publicClient = (0, import_viem20.createPublicClient)({
|
|
@@ -8305,11 +8334,11 @@ var getCycleV1 = async (wagmiConfig, {
|
|
|
8305
8334
|
});
|
|
8306
8335
|
const rolloverEvents = await publicClient.getFilterLogs({ filter });
|
|
8307
8336
|
const cycleRolloverBlockNumber = chainId === 1 ? rolloverEvents[rolloverEvents.length - 1]?.blockNumber : rolloverEvents[rolloverEvents.length - 1]?.blockNumber || currentBlockNumber;
|
|
8308
|
-
const secondsLeftBeforeNextCycle = (0,
|
|
8337
|
+
const secondsLeftBeforeNextCycle = (0, import_utils46.convertChainCycleToUnix)(Number(currentCycleIndex) + 1) - Date.now() / 1e3;
|
|
8309
8338
|
return {
|
|
8310
8339
|
currentCycleIndex,
|
|
8311
8340
|
cycleRolloverBlockNumber,
|
|
8312
|
-
timeBeforeNextCycle: (0,
|
|
8341
|
+
timeBeforeNextCycle: (0, import_utils46.convertSecondsToRemainingTime)(
|
|
8313
8342
|
secondsLeftBeforeNextCycle
|
|
8314
8343
|
)
|
|
8315
8344
|
};
|
|
@@ -8320,7 +8349,7 @@ var getCycleV1 = async (wagmiConfig, {
|
|
|
8320
8349
|
};
|
|
8321
8350
|
|
|
8322
8351
|
// functions/getProtocolStats.ts
|
|
8323
|
-
var
|
|
8352
|
+
var import_utils47 = require("@tokemak/utils");
|
|
8324
8353
|
var getProtocolStats = async (autopools, stoke, sushiLP) => {
|
|
8325
8354
|
try {
|
|
8326
8355
|
if (!autopools || !stoke || !sushiLP) {
|
|
@@ -8350,12 +8379,12 @@ var getProtocolStats = async (autopools, stoke, sushiLP) => {
|
|
|
8350
8379
|
Object.entries(categories).map(([key, value]) => [
|
|
8351
8380
|
key,
|
|
8352
8381
|
{
|
|
8353
|
-
tvl: (0,
|
|
8354
|
-
supply: (0,
|
|
8382
|
+
tvl: (0, import_utils47.formatTVL)(value.tvl),
|
|
8383
|
+
supply: (0, import_utils47.formatLargeNumber)(value.supply || 0)
|
|
8355
8384
|
}
|
|
8356
8385
|
])
|
|
8357
8386
|
);
|
|
8358
|
-
const tvl = (0,
|
|
8387
|
+
const tvl = (0, import_utils47.formatTVL)(autopoolTVL + stoke.rawTVL + (sushiLP?.tvl || 0));
|
|
8359
8388
|
const vaultAddresses = autopools?.flatMap(
|
|
8360
8389
|
(pool) => pool.destinations.map((destination) => destination.vaultAddress)
|
|
8361
8390
|
);
|
|
@@ -8363,16 +8392,16 @@ var getProtocolStats = async (autopools, stoke, sushiLP) => {
|
|
|
8363
8392
|
const totalDestinations = uniqueVaultAddresses.length;
|
|
8364
8393
|
return {
|
|
8365
8394
|
autopools: {
|
|
8366
|
-
tvl: (0,
|
|
8395
|
+
tvl: (0, import_utils47.formatTVL)(autopoolTVL),
|
|
8367
8396
|
tvlNum: autopoolTVL,
|
|
8368
8397
|
categories: formattedCategories
|
|
8369
8398
|
},
|
|
8370
8399
|
stoke: {
|
|
8371
|
-
tvl: (0,
|
|
8400
|
+
tvl: (0, import_utils47.formatTVL)(stoke.rawTVL),
|
|
8372
8401
|
totalSupply: `${stoke.totalSupply} TOKE`
|
|
8373
8402
|
},
|
|
8374
8403
|
sushiLP: {
|
|
8375
|
-
tvl: (0,
|
|
8404
|
+
tvl: (0, import_utils47.formatTVL)(sushiLP?.tvl || 0),
|
|
8376
8405
|
totalSupply: sushiLP?.totalSupply || 0
|
|
8377
8406
|
},
|
|
8378
8407
|
tvl,
|
|
@@ -8409,7 +8438,7 @@ var getEthPriceAtBlock = async (wagmiConfig, blockNumber, chainId) => {
|
|
|
8409
8438
|
};
|
|
8410
8439
|
|
|
8411
8440
|
// functions/getRebalanceStats.ts
|
|
8412
|
-
var
|
|
8441
|
+
var import_utils49 = require("@tokemak/utils");
|
|
8413
8442
|
var import_tokenlist12 = require("@tokemak/tokenlist");
|
|
8414
8443
|
var import_chains11 = require("viem/chains");
|
|
8415
8444
|
var BATCH_SIZE = 500;
|
|
@@ -8443,8 +8472,8 @@ var getRebalanceValueUsd = async (rebalance, chainId, wagmiConfig) => {
|
|
|
8443
8472
|
BigInt(rebalance.blockNumber),
|
|
8444
8473
|
chainId
|
|
8445
8474
|
);
|
|
8446
|
-
const ethUsd = Number((0,
|
|
8447
|
-
const ethAmt = Number((0,
|
|
8475
|
+
const ethUsd = Number((0, import_utils49.formatUnitsNum)(price, import_tokenlist12.USDC_TOKEN.decimals));
|
|
8476
|
+
const ethAmt = Number((0, import_utils49.formatEtherNum)(ethWei));
|
|
8448
8477
|
const usd = ethAmt * ethUsd;
|
|
8449
8478
|
return usd;
|
|
8450
8479
|
} catch (e) {
|
|
@@ -8453,6 +8482,13 @@ var getRebalanceValueUsd = async (rebalance, chainId, wagmiConfig) => {
|
|
|
8453
8482
|
}
|
|
8454
8483
|
};
|
|
8455
8484
|
var processRebalance = async (rebalance, chainId, wagmiConfig) => {
|
|
8485
|
+
const baseDecimals = inferBaseAssetDecimals(rebalance, chainId);
|
|
8486
|
+
const baseAssetAmount = Number(
|
|
8487
|
+
(0, import_utils49.formatUnitsNum)(
|
|
8488
|
+
BigInt(rebalance.tokenOutValueBaseAsset || "0"),
|
|
8489
|
+
baseDecimals
|
|
8490
|
+
)
|
|
8491
|
+
);
|
|
8456
8492
|
const ethPathUsd = await getRebalanceValueUsd(
|
|
8457
8493
|
rebalance,
|
|
8458
8494
|
chainId,
|
|
@@ -8460,24 +8496,21 @@ var processRebalance = async (rebalance, chainId, wagmiConfig) => {
|
|
|
8460
8496
|
);
|
|
8461
8497
|
if (ethPathUsd != null) {
|
|
8462
8498
|
return {
|
|
8499
|
+
autopool: rebalance.autopool,
|
|
8463
8500
|
timestamp: rebalance.timestamp,
|
|
8464
8501
|
blockNumber: rebalance.blockNumber,
|
|
8465
8502
|
chainId,
|
|
8466
|
-
valueInUsd: ethPathUsd
|
|
8503
|
+
valueInUsd: ethPathUsd,
|
|
8504
|
+
valueInAsset: baseAssetAmount
|
|
8467
8505
|
};
|
|
8468
8506
|
}
|
|
8469
|
-
const baseDecimals = inferBaseAssetDecimals(rebalance, chainId);
|
|
8470
|
-
const baseUsd = Number(
|
|
8471
|
-
(0, import_utils48.formatUnitsNum)(
|
|
8472
|
-
BigInt(rebalance.tokenOutValueBaseAsset || "0"),
|
|
8473
|
-
baseDecimals
|
|
8474
|
-
)
|
|
8475
|
-
);
|
|
8476
8507
|
return {
|
|
8508
|
+
autopool: rebalance.autopool,
|
|
8477
8509
|
timestamp: rebalance.timestamp,
|
|
8478
8510
|
blockNumber: rebalance.blockNumber,
|
|
8479
8511
|
chainId,
|
|
8480
|
-
valueInUsd:
|
|
8512
|
+
valueInUsd: baseAssetAmount,
|
|
8513
|
+
valueInAsset: baseAssetAmount
|
|
8481
8514
|
};
|
|
8482
8515
|
};
|
|
8483
8516
|
var processRebalancesInBatches = async (rebalances, chainId, wagmiConfig) => {
|
|
@@ -8590,8 +8623,11 @@ var updateRebalanceStats = async (wagmiConfig, {
|
|
|
8590
8623
|
getAutopools,
|
|
8591
8624
|
getAutopoolsHistory,
|
|
8592
8625
|
getAutopoolsRebalances,
|
|
8626
|
+
getBlobData,
|
|
8627
|
+
getBlobHistoricalTokenPrices,
|
|
8593
8628
|
getBridgeFee,
|
|
8594
8629
|
getChainAutopools,
|
|
8630
|
+
getChainAutopoolsApr,
|
|
8595
8631
|
getChainCycleRolloverBlockNumber,
|
|
8596
8632
|
getChainSToke,
|
|
8597
8633
|
getChainSTokeRewards,
|
|
@@ -8611,6 +8647,7 @@ var updateRebalanceStats = async (wagmiConfig, {
|
|
|
8611
8647
|
getEthPriceAtBlock,
|
|
8612
8648
|
getExchangeNames,
|
|
8613
8649
|
getGenStratAprs,
|
|
8650
|
+
getHistoricalTokenPrices,
|
|
8614
8651
|
getLayerzeroStatus,
|
|
8615
8652
|
getMutlipleAutopoolRebalances,
|
|
8616
8653
|
getPoolStats,
|