@moonwell-fi/moonwell-sdk
Version:
TypeScript Interface for Moonwell
46 lines • 1.55 kB
JavaScript
import axios from "axios";
import { getEnvironmentFromArgs } from "../../common/index.js";
export async function getCirculatingSupplySnapshots(client, args) {
const environment = getEnvironmentFromArgs(client, args);
if (!environment) {
return [];
}
try {
const response = await axios.post(environment.indexerUrl, {
query: `
{
circulatingSupplyDailySnapshots(
where: { chainId: ${environment.chainId} }
orderBy: "timestamp"
orderDirection: "desc"
limit: 1000
) {
items {
chainId
tokenAddress
circulatingSupply
timestamp
}
}
}
`,
});
if (response.status === 200 &&
response.data?.data?.circulatingSupplyDailySnapshots) {
return response.data?.data?.circulatingSupplyDailySnapshots.items.map((item) => ({
chainId: item.chainId,
token: Object.values(environment.config.tokens).find((token) => token.address.toLowerCase() === item.tokenAddress.toLowerCase()),
circulatingSupply: item.circulatingSupply,
timestamp: item.timestamp,
}));
}
else {
return [];
}
}
catch (ex) {
console.error("An error occured while fetching getStakingSnapshots...", ex);
return [];
}
}
//# sourceMappingURL=getCirculatingSupplySnapshots.js.map