@moonwell-fi/moonwell-sdk
Version:
TypeScript Interface for Moonwell
40 lines • 1.17 kB
JavaScript
import axios from "axios";
import { getEnvironmentFromArgs } from "../../common/index.js";
export async function getStakingSnapshots(client, args) {
const environment = getEnvironmentFromArgs(client, args);
if (!environment) {
return [];
}
try {
const response = await axios.post(environment.indexerUrl, {
query: `
query {
stakingDailySnapshots(
limit: 365,
orderBy: "timestamp"
orderDirection: "desc"
where: {chainId: ${environment.chainId}}
) {
items {
chainId
totalStaked
totalStakedUSD
timestamp
}
}
}
`,
});
if (response.status === 200 && response.data?.data?.stakingDailySnapshots) {
return response.data?.data?.stakingDailySnapshots.items;
}
else {
return [];
}
}
catch (ex) {
console.error("An error occured while fetching getStakingSnapshots...", ex);
return [];
}
}
//# sourceMappingURL=getStakingSnapshots.js.map