Skip to content

Commit

Permalink
ST-558: Update circulation supply, update chart to unbounding
Browse files Browse the repository at this point in the history
  • Loading branch information
BoThe1K committed Nov 1, 2024
1 parent b6adda2 commit e06a411
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
10 changes: 2 additions & 8 deletions apps/web-stratos/src/pages/api/circulating-supply.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@ import { getMetrics } from '@/screens/home/components/tokenomics/queries';
import { bigToNativeDecimals } from '@/screens/home/components/tokenomics/utils';

type MetricsData = {
total_supply: string;
total_mining_supply: string;
total_mined_tokens: string;
circulation_supply: string;
};

export default async function handler(req: NextApiRequest, res: NextApiResponse<string>) {
try {
const result: MetricsData = await getMetrics();
const total_supply = ethers.utils.parseUnits(result.total_supply, 'wei');
const to_be_mined = ethers.utils
.parseUnits(result.total_mining_supply, 'wei')
.sub(ethers.utils.parseUnits(result.total_mined_tokens, 'wei'));
res.status(200).send(bigToNativeDecimals(total_supply.sub(to_be_mined).toString()));
res.status(200).send(bigToNativeDecimals(result.circulation_supply));
} catch (err) {
res.status(400).json({ error: 'failed to load data' });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type TokenomicsState = {
unbonding: ethers.BigNumber;
totalMiningSupply: ethers.BigNumber;
totalMinedTokens: ethers.BigNumber;
totalResourceNodesDeposit: ethers.BigNumber;
toBeMined: ethers.BigNumber;
circulationSupply: ethers.BigNumber;
miningReward: ethers.BigNumber;
Expand All @@ -32,10 +33,11 @@ export const useTokenomics = () => {
unbonding: ethers.utils.parseUnits(data.total_unbonding_delegation, 'wei'),
totalMiningSupply: ethers.utils.parseUnits(data.total_mining_supply, 'wei'),
totalMinedTokens: ethers.utils.parseUnits(data.total_mined_tokens, 'wei'),
totalResourceNodesDeposit: ethers.utils.parseUnits(data.total_resource_nodes_deposit, 'wei'),
toBeMined: ethers.utils.parseUnits('0', 'wei'),
circulationSupply: ethers.utils.parseUnits(data.circulation_supply, 'wei'),
miningReward: ethers.utils.parseUnits(data.chain_mining_reward, 'wei'),
resourceNodesDeposit: ethers.utils.parseUnits(data.total_resource_nodes_deposit, 'wei'),
resourceNodesDeposit: ethers.utils.parseUnits(data.resource_node_deposit, 'wei'),
} as TokenomicsState;
metrics.toBeMined = metrics.totalMiningSupply.sub(metrics.totalMinedTokens);
return metrics;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ const Tokenomics: FC<ComponentDefault> = ({ className }) => {
fill: theme.palette.custom.tokenomics.three,
},
{
legendKey: t('unbonded'),
percentKey: 'unbondedPercent',
value: prettyFormat(tokenomics.unbonded, 18, 2),
percent: `${prettyFormat(tokenomics.unbonded.mul(1_000_000).div(tokenomics.total), 4, 6)}%`,
legendKey: t('unbonding'),
percentKey: 'unbondingPercent',
value: prettyFormat(tokenomics.unbonding, 18, 2),
percent: `${prettyFormat(tokenomics.unbonding.mul(1_000_000).div(tokenomics.total), 4, 6)}%`,
fill: theme.palette.custom.tokenomics.four,
},
{
Expand Down

0 comments on commit e06a411

Please sign in to comment.