UNPKG

@moonwell-fi/moonwell-sdk

Version:

TypeScript Interface for Moonwell

52 lines 1.87 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getCirculatingSupplySnapshots = getCirculatingSupplySnapshots; const axios_1 = __importDefault(require("axios")); const index_js_1 = require("../../common/index.js"); async function getCirculatingSupplySnapshots(client, args) { const environment = (0, index_js_1.getEnvironmentFromArgs)(client, args); if (!environment) { return []; } try { const response = await axios_1.default.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