diff --git a/api/src/ol/ol.service.ts b/api/src/ol/ol.service.ts index 669e423c..4c6733e0 100644 --- a/api/src/ol/ol.service.ts +++ b/api/src/ol/ol.service.ts @@ -39,12 +39,18 @@ export class OlService { type_arguments: [], arguments: [], }); + const circulatingResult = await this.aptosClient.view({ + function: '0x1::supply::get_circulating', + type_arguments: [], + arguments: [], + }); return { totalSupply: parseFloat(supplyStats[0] as string) / 1e6, slowLockedSupply: parseFloat(supplyStats[1] as string) / 1e6, cwSupply: parseFloat(supplyStats[2] as string) / 1e6, infraEscrowSupply: parseFloat(supplyStats[3] as string) / 1e6, - circulatingSupply: parseFloat(supplyStats[4] as string) / 1e6, + unlockedSupply: parseFloat(supplyStats[4] as string) / 1e6, + circulatingSupply: parseFloat(circulatingResult[0] as string) / 1e6, }; } diff --git a/api/src/ol/types.ts b/api/src/ol/types.ts index 9a60a5cc..fa9c1c3f 100644 --- a/api/src/ol/types.ts +++ b/api/src/ol/types.ts @@ -23,7 +23,8 @@ export interface SupplyStats { slowLockedSupply: number; cwSupply: number; infraEscrowSupply: number; - circulatingSupply: number; + unlockedSupply: number; + circulatingSupply: number; // unlocked supply plus funds available from CWs } export interface ConsensusReward { diff --git a/api/src/stats/interfaces/stats.interface.ts b/api/src/stats/interfaces/stats.interface.ts index 91650b43..d0b3e533 100644 --- a/api/src/stats/interfaces/stats.interface.ts +++ b/api/src/stats/interfaces/stats.interface.ts @@ -14,6 +14,7 @@ export interface SupplyStats { cwSupply: number; infraEscrowSupply: number; circulatingSupply: number; + unlockedSupply: number; } export interface WalletBalance { @@ -60,6 +61,7 @@ export interface Stats { avgTotalVestingTime: BinRange[]; }; circulatingSupply: RelativeValue; + unlockedSupply: RelativeValue; totalBurned: RelativeValue; communityWalletsBalance: RelativeValue; currentSlowWalletsCount: number; diff --git a/api/src/stats/stats.service.ts b/api/src/stats/stats.service.ts index 39be4a2e..aafe0867 100644 --- a/api/src/stats/stats.service.ts +++ b/api/src/stats/stats.service.ts @@ -79,6 +79,11 @@ export class StatsService { percentage: parseFloat(((supplyStats.circulatingSupply / totalSupply) * 100).toFixed(3)), }; + const unlockedSupply = { + nominal: parseFloat(supplyStats.unlockedSupply.toFixed(3)), + percentage: parseFloat(((supplyStats.unlockedSupply / totalSupply) * 100).toFixed(3)), + }; + const communityWalletsBalance = { nominal: parseFloat(supplyStats.cwSupply.toFixed(3)), percentage: parseFloat(((supplyStats.cwSupply / totalSupply) * 100).toFixed(3)), @@ -169,6 +174,7 @@ export class StatsService { // kpis circulatingSupply, + unlockedSupply, totalBurned, communityWalletsBalance, currentSlowWalletsCount: slowWalletsCountOverTime[slowWalletsCountOverTime.length - 1].value, @@ -267,22 +273,26 @@ export class StatsService { communityCapital: NameValue[]; }> { const totalSupply = supplyStats.totalSupply; + const unlocked = supplyStats.unlockedSupply; const circulating = supplyStats.circulatingSupply; + const communityWalletsBalances = supplyStats.cwSupply; const infraEscrowBalance = supplyStats.infraEscrowSupply; const slowLocked = supplyStats.slowLockedSupply; + const cwCredit = circulating - unlocked; try { const supplyAllocation = [ - { name: 'Community Wallets', value: communityWalletsBalances }, + { name: 'Community Wallets net of credit', value: communityWalletsBalances - cwCredit }, { name: 'Locked', value: slowLocked }, { name: 'Infrastructure escrow', value: infraEscrowBalance }, - { name: 'Circulating', value: circulating }, + { name: 'Unlocked', value: unlocked }, + { name: 'CW credit', value: cwCredit }, ]; const individualsCapital = [ { name: 'Locked', value: slowLocked }, - { name: 'Circulating', value: circulating }, + { name: 'Unlocked', value: unlocked }, ]; const communityCapital = [ diff --git a/api/src/stats/utils/stats.utils.ts b/api/src/stats/utils/stats.utils.ts index b60e16a4..5be5f459 100644 --- a/api/src/stats/utils/stats.utils.ts +++ b/api/src/stats/utils/stats.utils.ts @@ -1,9 +1,11 @@ import { Injectable } from '@nestjs/common'; import { ClickhouseService } from '../../clickhouse/clickhouse.service.js'; +import { Logger } from '@nestjs/common'; @Injectable() export class StatsUtils { constructor(private readonly clickhouseService: ClickhouseService) {} + private readonly logger = new Logger("StatsUtils"); chunkArray(array: T[], chunkSize: number): T[][] { const results: T[][] = []; diff --git a/web-app/src/modules/core/routes/Stats/Stats.tsx b/web-app/src/modules/core/routes/Stats/Stats.tsx index dc0208c3..d4dcc4f4 100644 --- a/web-app/src/modules/core/routes/Stats/Stats.tsx +++ b/web-app/src/modules/core/routes/Stats/Stats.tsx @@ -63,7 +63,7 @@ const Coinstats = () => {
diff --git a/web-app/src/modules/ol/index.ts b/web-app/src/modules/ol/index.ts index d8527007..ffbfe4af 100644 --- a/web-app/src/modules/ol/index.ts +++ b/web-app/src/modules/ol/index.ts @@ -114,30 +114,22 @@ export const useTotalSupply = (): Money | undefined => { return value; }; -// Code below copied from api/src/ol/ol.service.ts -// TODO: fold this function into a common library used by both web-app and api export const useCirculatingSupply = (): Money | undefined => { const aptos = useAptos(); const [value, setValue] = useState(); useEffect(() => { const load = async () => { - const supplyStats = await aptos.view({ - function: '0x1::supply::get_stats', + const supplyResponse = await aptos.view({ + function: '0x1::supply::get_circulating', type_arguments: [], arguments: [], }); - const supplyInfo = { - totalSupply: parseFloat(supplyStats[0] as string) / 1e6, - slowLockedSupply: parseFloat(supplyStats[1] as string) / 1e6, - cwSupply: parseFloat(supplyStats[2] as string) / 1e6, - infraEscrowSupply: parseFloat(supplyStats[3] as string) / 1e6, - circulatingSupply: parseFloat(supplyStats[4] as string) / 1e6, - } + const circulatingSupply = parseFloat(supplyResponse[0] as string) / 1e6 setValue({ - amount: supplyInfo.circulatingSupply, + amount: circulatingSupply, symbol: "LIBRA", }); };