11import { useState , useEffect , useMemo , useCallback } from "react" ;
22
33import { Address , erc20Abi } from "viem" ;
4- import { readContract } from "@wagmi/core" ;
4+ import { readContract , readContracts } from "@wagmi/core" ;
55
66import { TablePagination , PriceCell , Dashboard } from "./components" ;
77
@@ -19,6 +19,8 @@ import {
1919
2020import { wagmiConfig , RamsesV3PoolABI } from "@web3" ;
2121
22+ import { chains } from "@stabilitydao/stability" ;
23+
2224import { GetPriceReturn , PriceCache , Token } from "./types" ;
2325
2426const 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