UNPKG

@moonwell-fi/moonwell-sdk

Version:

TypeScript Interface for Moonwell

46 lines 1.47 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getStakingSnapshots = getStakingSnapshots; const axios_1 = __importDefault(require("axios")); const index_js_1 = require("../../common/index.js"); async function getStakingSnapshots(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: ` 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