Skip to content

Commit 9ecccea

Browse files
committed
upd: recovery dashboard
1 parent 782a3b9 commit 9ecccea

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "stability-ui",
33
"type": "module",
4-
"version": "0.11.45-alpha",
4+
"version": "0.11.46-alpha",
55
"scripts": {
66
"dev": "astro dev",
77
"start": "astro dev",

src/modules/RecoveryDashboard/index.tsx

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useState, useEffect, useMemo, useCallback } from "react";
22

33
import { Address, erc20Abi } from "viem";
4-
import { readContract } from "@wagmi/core";
4+
import { readContract, readContracts } from "@wagmi/core";
55

66
import { TablePagination, PriceCell, Dashboard } from "./components";
77

@@ -19,6 +19,8 @@ import {
1919

2020
import { wagmiConfig, RamsesV3PoolABI } from "@web3";
2121

22+
import { chains } from "@stabilitydao/stability";
23+
2224
import { GetPriceReturn, PriceCache, Token } from "./types";
2325

2426
const RecoveryDashboard = (): JSX.Element => {
@@ -114,14 +116,34 @@ const RecoveryDashboard = (): JSX.Element => {
114116
const getBurnProgressOnChain = useCallback(
115117
async (token: Token): Promise<number> => {
116118
try {
117-
const currentSupply = (await readContract(wagmiConfig, {
118-
address: token.address,
119-
abi: erc20Abi,
120-
functionName: "totalSupply",
121-
})) as bigint;
122-
123-
const amountBurnt = token.initialSupply - currentSupply;
124-
return Number((amountBurnt * 100000n) / token.initialSupply) / 1000;
119+
const [totalSupplyRes, multisigBalanceRes] = await readContracts(
120+
wagmiConfig,
121+
{
122+
contracts: [
123+
{
124+
address: token.address,
125+
abi: erc20Abi,
126+
functionName: "totalSupply",
127+
},
128+
{
129+
address: token.address,
130+
abi: erc20Abi,
131+
functionName: "balanceOf",
132+
args: [chains[146].multisig as Address],
133+
},
134+
],
135+
}
136+
);
137+
138+
const initialSupplyRaw = token.initialSupply as bigint;
139+
const totalSupplyRaw = totalSupplyRes.result as bigint;
140+
const multisigBalanceRaw = multisigBalanceRes.result as bigint;
141+
142+
const burntRaw = initialSupplyRaw - totalSupplyRaw + multisigBalanceRaw;
143+
144+
const percent = Number((burntRaw * 100000n) / initialSupplyRaw) / 1000;
145+
146+
return percent;
125147
} catch {
126148
return 0;
127149
}

0 commit comments

Comments
 (0)