import { BigNumber } from 'ethers'; import { BigNumber as DecimalBigNumber } from 'bignumber.js'; import { getUfogeesHolders, getPresaleHolders, getNFTHolders, getPublicHolders, getUfogeesByHolder, getBreedingNFT, getLockedBreedingNFT, getAvailableBreedingNFT, } from './ufogeesNFT'; interface APR { apr: string; lastUpdatedAt: number; } interface Weight { poolIndex: string; lockInWeeks: string; weight: string; } const exponent = new DecimalBigNumber(10).pow(18); export class Subgraph { private subgraphUrl; private initialized: boolean = false; private keyTokensPriceLastUpdatedAt: number; private production: boolean; constructor(subgraphUrl: string, production: boolean) { this.subgraphUrl = subgraphUrl; this.keyTokensPriceLastUpdatedAt = 0; this.production = production; } public async initSubgraph(): Promise { if (this.initialized) { return this; } return this; } public isInitialized(): boolean { return this.initialized; } public async getUfogeesHolders(): Promise { if (!this.initialized) { await this.initSubgraph(); } const data = await getUfogeesHolders(this.subgraphUrl); return data; } public async getUfogeesCount(address: string): Promise { if (!this.initialized) { await this.initSubgraph(); } const data = await getUfogeesByHolder(this.subgraphUrl, address); return data.length.toString(); } public async getUfogeesNFTByHolder(address: string): Promise { if (!this.initialized) { await this.initSubgraph(); } const data = await getUfogeesByHolder(this.subgraphUrl, address); return data; } public async getNFTHolders(): Promise { if (!this.initialized) { await this.initSubgraph(); } const data = await getNFTHolders(this.subgraphUrl); return data; } public async getPresaleHolders(): Promise { if (!this.initialized) { await this.initSubgraph(); } const data = await getPresaleHolders(this.subgraphUrl); return data; } public async getPublicHolders(): Promise { if (!this.initialized) { await this.initSubgraph(); } const data = await getPublicHolders(this.subgraphUrl); return data; } public async getBreedingNFT(address: string): Promise { if (!this.initialized) { await this.initSubgraph(); } const data = await getBreedingNFT(this.subgraphUrl, address); return data; } public async getLockedBreedingNFT(address: string): Promise { if (!this.initialized) { await this.initSubgraph(); } let timestamp = BigInt(Date.now()); const data = await getLockedBreedingNFT(this.subgraphUrl, address, timestamp); return data; } public async getAvailableBreedingNFT(address: string): Promise { if (!this.initialized) { await this.initSubgraph(); } let timestamp = BigInt(Date.now()); const data = await getAvailableBreedingNFT(this.subgraphUrl, address, timestamp); return data; } }