diff --git a/apps/web-api/src/circulating/circulating-supply.service.ts b/apps/web-api/src/circulating/circulating-supply.service.ts index 5e7e229..e2b4c90 100644 --- a/apps/web-api/src/circulating/circulating-supply.service.ts +++ b/apps/web-api/src/circulating/circulating-supply.service.ts @@ -1,4 +1,4 @@ -import { forwardRef, Inject, Injectable, Logger } from '@nestjs/common'; +import { Injectable, Logger } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { Repository } from 'typeorm'; import { Total } from '@entities/Total'; @@ -19,11 +19,13 @@ export class CirculatingSupplyService { const circulating = await this.repo.findOne({ where: { name: 'circulating_supply' }, }); + const staked = await this.sdkService.getTotalStaked(); + const circulatingTotal = BigInt(circulating.count) + BigInt(staked.json); const total = await this.sdkService.getTotalSupply(); const count = BigInt(total.json).toString(); - this.logger.log({ request: 'circulating supply', count, total }); + this.logger.log({ request: 'circulating supply', count, total, staked }); return { - circulatingSupply: Number(circulating.count), + circulatingSupply: Number(getAmount(circulatingTotal.toString())), totalSupply: Number(getAmount(count)), }; } diff --git a/common/sdk/sdk.service.ts b/common/sdk/sdk.service.ts index eaac384..85952e2 100644 --- a/common/sdk/sdk.service.ts +++ b/common/sdk/sdk.service.ts @@ -194,4 +194,13 @@ export class SdkService { method: 'totalIssuance', }); } + + @SdkCache('getTotalStaked') + async getTotalStaked(): Promise { + return await this.sdk.stateQueries.execute({ + endpoint: 'query', + module: 'appPromotion', + method: 'totalStaked', + }); + } } diff --git a/package-lock.json b/package-lock.json index 9bcc22a..1b4f3bd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "polkastats-backend-uniquenetwork", - "version": "2.0.69", + "version": "2.0.71", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "polkastats-backend-uniquenetwork", - "version": "2.0.69", + "version": "2.0.71", "license": "UNLICENSED", "dependencies": { "@nestjs/apollo": "^10.1.7", diff --git a/package.json b/package.json index 28e48e7..a7c1df6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "polkastats-backend-uniquenetwork", - "version": "2.0.69", + "version": "2.0.71", "description": "", "author": "Unique Network Team", "private": true,