@tokemak/queries 0.0.17 → 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 +54 -17
- package/dist/index.d.ts +20 -34
- package/dist/index.js +54 -17
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -8633,7 +8633,7 @@ var getAutopoolUserActivity = async ({
|
|
|
8633
8633
|
first: vars?.first || 1e3,
|
|
8634
8634
|
skip: vars?.skip || 0
|
|
8635
8635
|
}),
|
|
8636
|
-
"
|
|
8636
|
+
"userSpecificAutopoolBalanceChanges",
|
|
8637
8637
|
{
|
|
8638
8638
|
first: 1e3,
|
|
8639
8639
|
maxPages: 100
|
|
@@ -8850,20 +8850,14 @@ var getAutopoolHistory = async (autopool) => {
|
|
|
8850
8850
|
address: autopool?.poolAddress,
|
|
8851
8851
|
timestamp: import_constants12.TOKEMAK_LAUNCH_TIMESTAMP
|
|
8852
8852
|
});
|
|
8853
|
-
const vaultId = autopool?.poolAddress.toLowerCase();
|
|
8854
8853
|
const formattedData = autopoolDayDatas.map((dayData) => {
|
|
8855
8854
|
return {
|
|
8856
8855
|
...dayData,
|
|
8857
|
-
|
|
8858
|
-
vault: {
|
|
8859
|
-
id: vaultId
|
|
8860
|
-
},
|
|
8861
|
-
date: new Date(dayData.timestamp * 1e3),
|
|
8862
|
-
baseAsset: autopool?.baseAsset
|
|
8856
|
+
date: new Date(dayData.timestamp * 1e3)
|
|
8863
8857
|
};
|
|
8864
8858
|
});
|
|
8865
8859
|
const filledData = fillMissingDates(formattedData);
|
|
8866
|
-
return
|
|
8860
|
+
return filledData;
|
|
8867
8861
|
} catch (e) {
|
|
8868
8862
|
console.log(e);
|
|
8869
8863
|
}
|
|
@@ -8885,17 +8879,60 @@ var getAutopoolUserHistory = async ({
|
|
|
8885
8879
|
timestamp: import_constants13.TOKEMAK_LAUNCH_TIMESTAMP,
|
|
8886
8880
|
vaultAddress: autopool?.poolAddress
|
|
8887
8881
|
});
|
|
8888
|
-
const
|
|
8889
|
-
if (!
|
|
8882
|
+
const autopoolDayData = await getAutopoolHistory(autopool);
|
|
8883
|
+
if (!autopoolDayData) {
|
|
8890
8884
|
throw new Error("No autopool history found");
|
|
8891
8885
|
}
|
|
8892
|
-
const
|
|
8893
|
-
|
|
8894
|
-
|
|
8895
|
-
|
|
8896
|
-
|
|
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
|
+
};
|
|
8897
8934
|
});
|
|
8898
|
-
return
|
|
8935
|
+
return matchedData;
|
|
8899
8936
|
}
|
|
8900
8937
|
return [];
|
|
8901
8938
|
} catch (e) {
|
package/dist/index.d.ts
CHANGED
|
@@ -3318,42 +3318,28 @@ declare const getAutopoolUserHistory: ({ userAddress, autopool, userActivity, }:
|
|
|
3318
3318
|
userAddress: Address;
|
|
3319
3319
|
autopool: IAutopool;
|
|
3320
3320
|
userActivity: IUserActivity;
|
|
3321
|
-
}) => Promise<
|
|
3321
|
+
}) => Promise<{
|
|
3322
|
+
date: Date;
|
|
3323
|
+
timestamp: any;
|
|
3324
|
+
baseAsset: string;
|
|
3325
|
+
nav: number;
|
|
3326
|
+
events: {
|
|
3327
|
+
timestamp: number;
|
|
3328
|
+
shareChange: string;
|
|
3329
|
+
assetChange: string;
|
|
3330
|
+
vaultAddress: string;
|
|
3331
|
+
eventType: EventType;
|
|
3332
|
+
}[];
|
|
3333
|
+
}[]>;
|
|
3322
3334
|
|
|
3323
3335
|
declare const getAutopoolHistory: (autopool: IAutopool) => Promise<{
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
price: number;
|
|
3332
|
-
address: viem.Address;
|
|
3333
|
-
chainId: number;
|
|
3334
|
-
decimals: number;
|
|
3335
|
-
logoURI: string;
|
|
3336
|
-
name: string;
|
|
3337
|
-
symbol: string;
|
|
3338
|
-
audits?: string;
|
|
3339
|
-
extensions?: {
|
|
3340
|
-
bridgeMainnetAdapter?: viem.Address;
|
|
3341
|
-
bridgeInfo?: {
|
|
3342
|
-
[chainId: number]: {
|
|
3343
|
-
tokenAddress: viem.Address;
|
|
3344
|
-
};
|
|
3345
|
-
};
|
|
3346
|
-
rebasing?: boolean;
|
|
3347
|
-
parentAsset?: string;
|
|
3348
|
-
};
|
|
3349
|
-
};
|
|
3350
|
-
__typename?: "AutopoolDayData";
|
|
3351
|
-
totalSupply: any;
|
|
3352
|
-
nav: any;
|
|
3353
|
-
timestamp: any;
|
|
3354
|
-
id: string;
|
|
3355
|
-
}[];
|
|
3356
|
-
} | undefined>;
|
|
3336
|
+
date: Date;
|
|
3337
|
+
__typename?: "AutopoolDayData";
|
|
3338
|
+
totalSupply: any;
|
|
3339
|
+
nav: any;
|
|
3340
|
+
timestamp: any;
|
|
3341
|
+
id: string;
|
|
3342
|
+
}[] | undefined>;
|
|
3357
3343
|
type IAutopoolHistory = Awaited<ReturnType<typeof getAutopoolHistory>>;
|
|
3358
3344
|
|
|
3359
3345
|
export { AggregatedDayData, AutopoolCategory, AutopoolsApr, BASE_ASSETS, BATCH_SIZE, BaseAsset, BaseAssetWithUsd, BaseDataEntry, ChainAutopoolsAprResponse, ChainSTokeRewardsType, ChainSTokeType, ChainSTokeVotes, Currencies, CurveLP, ETH_BASE_ASSETS, EUR_BASE_ASSETS, EnhancedUserHistoryEntry, EventType, ExtraReward, FillData, GetLayerzeroStatusConfig, HistoricalTokenPrices, IAutopool, IAutopoolHistory, IAutopools, IAutopoolsHistory, IRebalance, IStoke, IStokeRewards, ISushiLP, ITopAutopoolHolder, ITopAutopoolHolders, IUserActivity, IUserAutopool, IUserAutopools, IUserAutopoolsRewards, IUserExtraRewards, IUserReward, LayerzeroStatus, MessageStatus, Order, PRICED_TOKENS, PoolRewardsBalanceDayData, QuoteAndPriceBaseConfig, QuoteAndPriceBaseResult, QuoteResult, RawRebalance, Reward, RewardDetails, STokeVotes, SendParam, SwapQuoteParams, SwapQuoteResponse, TokenPrices, USD_BASE_ASSETS, UserActivity, UserActivityTotalsType, UserAutopoolsVotes, UserDayDataEntry, UserSTokeVotes, VaultAddedMapping, aggregateSTokeRewardsDayData, arraysToObject, calculateRebalanceStats, convertBaseAssetToTokenPrices, convertBaseAssetToTokenPricesAndDenom, fetchChainDataMap, fetchChainRebalances, fillMissingDates, findClosestDateEntry, findClosestEntry, findClosestTimestampEntry, formatDateRange, getAddressFromSystemRegistry, getAllowance, getAmountDeposited, getAmountWithdrawn, getAutopilotRouter, getAutopoolCategory, getAutopoolDayData, getAutopoolHistory, getAutopoolInfo, getAutopoolRebalances, getAutopoolUser, getAutopoolUserActivity, getAutopoolUserHistory, getAutopools, getAutopoolsHistory, getAutopoolsRebalances, getBlobData, getBlobHistoricalTokenPrices, getBridgeFee, getChainAutopools, getChainAutopoolsApr, getChainCycleRolloverBlockNumber, getChainSToke, getChainSTokeRewards, getChainSubgraphStatus, getChainUserActivity, getChainUserAutopools, getChainUserSToke, getChainUserSTokeRewards, getChainUserSTokeVotes, getChainsForEnv, getCurrentCycleId, getCurveLP, getCycleV1, getDefillamaPrice, getDynamicSwap, getEthPrice, getEthPriceAtBlock, getExchangeNames, getGenStratAprs, getHistoricalTokenPrices, getLayerzeroStatus, getMutlipleAutopoolRebalances, getPoolStats, getPoolsAndDestinations, getPoolsAndDestinationsReturnType, getProtocolStats, getRebalanceStats, getRebalanceValueUsd, getRewardsPayloadV1, getSToke, getSTokeChainsForEnv, getSTokeRewards, getSTokeVotes, getSubgraphStatus, getSushiLP, getSwapQuote, getSystemConfig, getTimestampDaysFromStart, getTokePrice, getTokenList, getTokenPrice, getTokenPrices, getTopAutopoolHolders, getUserActivity, getUserAutoEthRewards, getUserAutopool, getUserAutopools, getUserAutopoolsHistory, getUserAutopoolsRewards, getUserCurveLP, getUserRewardsV1, getUserSToke, getUserSTokeVotes, getUserSushiLP, getUserTokenBalances, getUserV1, mergeArrays, mergeArraysWithKey, mergeStringArrays, minAmountDepositedBaseConfig, minAmountDepositedFunctionConfig, minAmountWithdrawnBaseConfig, minAmountWithdrawnFunctionConfig, modifyAutopoolName, nestedArrayToObject, paginateQuery, processRebalance, processRebalancesInBatches, rewardsData, systemRegistryFunctionNames, updateRebalanceStats, waitForMessageReceived };
|
package/dist/index.js
CHANGED
|
@@ -8592,7 +8592,7 @@ var getAutopoolUserActivity = async ({
|
|
|
8592
8592
|
first: vars?.first || 1e3,
|
|
8593
8593
|
skip: vars?.skip || 0
|
|
8594
8594
|
}),
|
|
8595
|
-
"
|
|
8595
|
+
"userSpecificAutopoolBalanceChanges",
|
|
8596
8596
|
{
|
|
8597
8597
|
first: 1e3,
|
|
8598
8598
|
maxPages: 100
|
|
@@ -8813,20 +8813,14 @@ var getAutopoolHistory = async (autopool) => {
|
|
|
8813
8813
|
address: autopool?.poolAddress,
|
|
8814
8814
|
timestamp: TOKEMAK_LAUNCH_TIMESTAMP3
|
|
8815
8815
|
});
|
|
8816
|
-
const vaultId = autopool?.poolAddress.toLowerCase();
|
|
8817
8816
|
const formattedData = autopoolDayDatas.map((dayData) => {
|
|
8818
8817
|
return {
|
|
8819
8818
|
...dayData,
|
|
8820
|
-
|
|
8821
|
-
vault: {
|
|
8822
|
-
id: vaultId
|
|
8823
|
-
},
|
|
8824
|
-
date: new Date(dayData.timestamp * 1e3),
|
|
8825
|
-
baseAsset: autopool?.baseAsset
|
|
8819
|
+
date: new Date(dayData.timestamp * 1e3)
|
|
8826
8820
|
};
|
|
8827
8821
|
});
|
|
8828
8822
|
const filledData = fillMissingDates(formattedData);
|
|
8829
|
-
return
|
|
8823
|
+
return filledData;
|
|
8830
8824
|
} catch (e) {
|
|
8831
8825
|
console.log(e);
|
|
8832
8826
|
}
|
|
@@ -8848,17 +8842,60 @@ var getAutopoolUserHistory = async ({
|
|
|
8848
8842
|
timestamp: TOKEMAK_LAUNCH_TIMESTAMP4,
|
|
8849
8843
|
vaultAddress: autopool?.poolAddress
|
|
8850
8844
|
});
|
|
8851
|
-
const
|
|
8852
|
-
if (!
|
|
8845
|
+
const autopoolDayData = await getAutopoolHistory(autopool);
|
|
8846
|
+
if (!autopoolDayData) {
|
|
8853
8847
|
throw new Error("No autopool history found");
|
|
8854
8848
|
}
|
|
8855
|
-
const
|
|
8856
|
-
|
|
8857
|
-
|
|
8858
|
-
|
|
8859
|
-
|
|
8849
|
+
const formattedUserVaultDayDatas = userVaultDayDatas.map((dayData) => {
|
|
8850
|
+
if (!dayData.timestamp) {
|
|
8851
|
+
throw new Error("Missing timestamp in userVaultDayData");
|
|
8852
|
+
}
|
|
8853
|
+
return {
|
|
8854
|
+
...dayData,
|
|
8855
|
+
date: new Date(Number(dayData.timestamp) * 1e3),
|
|
8856
|
+
timestamp: dayData.timestamp.toString()
|
|
8857
|
+
};
|
|
8858
|
+
});
|
|
8859
|
+
const filledMissingDates = fillMissingDates(formattedUserVaultDayDatas);
|
|
8860
|
+
if (filledMissingDates.length > 0) {
|
|
8861
|
+
const firstEntry = filledMissingDates[0];
|
|
8862
|
+
const dayBefore = new Date(firstEntry.date);
|
|
8863
|
+
dayBefore.setDate(dayBefore.getDate() - 1);
|
|
8864
|
+
const dayBeforeTimestamp = Math.floor(
|
|
8865
|
+
dayBefore.getTime() / 1e3
|
|
8866
|
+
).toString();
|
|
8867
|
+
const dayBeforeEntry = {
|
|
8868
|
+
...firstEntry,
|
|
8869
|
+
date: dayBefore,
|
|
8870
|
+
timestamp: dayBeforeTimestamp,
|
|
8871
|
+
totalShares: 0
|
|
8872
|
+
};
|
|
8873
|
+
filledMissingDates.unshift(dayBeforeEntry);
|
|
8874
|
+
}
|
|
8875
|
+
const matchedData = filledMissingDates.map((userVaultDayData) => {
|
|
8876
|
+
const matchingAutopoolDayData = autopoolDayData.find(
|
|
8877
|
+
(autopoolDay) => autopoolDay.date.toDateString() === userVaultDayData.date.toDateString()
|
|
8878
|
+
);
|
|
8879
|
+
const userPortionOfVault = userVaultDayData.totalShares / matchingAutopoolDayData?.totalSupply;
|
|
8880
|
+
const userNav = userPortionOfVault * matchingAutopoolDayData?.nav;
|
|
8881
|
+
const eventsForDay = userActivity.events?.filter((event) => {
|
|
8882
|
+
const eventDate = new Date(Number(event.timestamp) * 1e3);
|
|
8883
|
+
const windowStart = new Date(
|
|
8884
|
+
userVaultDayData.date.getTime() - 24 * 60 * 60 * 1e3
|
|
8885
|
+
);
|
|
8886
|
+
const windowEnd = userVaultDayData.date;
|
|
8887
|
+
const matches = eventDate.getTime() > windowStart.getTime() && eventDate.getTime() <= windowEnd.getTime();
|
|
8888
|
+
return matches;
|
|
8889
|
+
});
|
|
8890
|
+
return {
|
|
8891
|
+
date: userVaultDayData.date,
|
|
8892
|
+
timestamp: userVaultDayData.timestamp,
|
|
8893
|
+
baseAsset: autopool?.baseAsset.symbol,
|
|
8894
|
+
nav: userNav,
|
|
8895
|
+
events: eventsForDay
|
|
8896
|
+
};
|
|
8860
8897
|
});
|
|
8861
|
-
return
|
|
8898
|
+
return matchedData;
|
|
8862
8899
|
}
|
|
8863
8900
|
return [];
|
|
8864
8901
|
} catch (e) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokemak/queries",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"main": "./dist/index.cjs",
|
|
5
5
|
"module": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"@wagmi/core": "2.x",
|
|
27
27
|
"wagmi": "2.x",
|
|
28
28
|
"@tokemak/abis": "0.0.3",
|
|
29
|
+
"@tokemak/constants": "0.0.4",
|
|
30
|
+
"@tokemak/graph-cli": "0.0.10",
|
|
29
31
|
"@tokemak/config": "0.0.4",
|
|
30
|
-
"@tokemak/graph-cli": "0.0.9",
|
|
31
32
|
"@tokemak/tokenlist": "0.0.3",
|
|
32
|
-
"@tokemak/constants": "0.0.4",
|
|
33
33
|
"@tokemak/utils": "0.0.5"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|