@@ -6,7 +6,7 @@ import { Button } from "@/components/ui/button"
66import { Input } from "@/components/ui/input"
77import { Nav } from "@/components/component/nav" ;
88// import { useSearchParams } from 'next/navigation'
9- import { deposit , withdraw , wethAllowance , wethbalance , approveWeth , getTvlOfWstheth } from "../../web3Functions/erc4626Vault"
9+ import { susdeVaultSharesOf , deposit , withdraw , wethAllowance , wethbalance , approveWeth , getTvlOfSUSDE } from "../../web3Functions/erc4626Vault"
1010import { getConnectedWalletAddress } from "../../web3Functions/wallet"
1111import React , { Suspense , useEffect , useState } from "react" ;
1212import { ethers } from "ethers"
@@ -146,7 +146,7 @@ export default function Game() {
146146 const signer = await provider . getSigner ( ) ;
147147
148148 const address = await signer . getAddress ( ) ;
149- const val = await getTvlOfWstheth ( provider )
149+ const val = await getTvlOfSUSDE ( provider )
150150 console . log ( "TVL " , val )
151151 setTVL ( val )
152152 }
@@ -158,6 +158,25 @@ export default function Game() {
158158 return ( ) => clearInterval ( intervalId ) ; // Cleanup function to clear the interval
159159 } , [ ] ) ;
160160
161+ const [ vaultShares , setVaultShares ] = React . useState ( "0" ) ;
162+
163+ React . useEffect ( ( ) => {
164+ const checkVaultShares = async ( ) => {
165+ const provider = new ethers . providers . Web3Provider ( window . ethereum ) ;
166+ const signer = await provider . getSigner ( ) ;
167+
168+ const address = await signer . getAddress ( ) ;
169+ const shares = await susdeVaultSharesOf ( provider , address ) ;
170+ setVaultShares ( shares ) ;
171+ }
172+
173+ checkVaultShares ( ) ; // Initial check
174+
175+ const intervalId = setInterval ( checkVaultShares , 3000 ) ; // Check every 3 seconds
176+
177+ return ( ) => clearInterval ( intervalId ) ; // Cleanup
178+ } , [ ] ) ;
179+
161180 return (
162181 ( < div className = "flex flex-col min-h-[100dvh] bg-background" >
163182 < Nav />
@@ -196,6 +215,10 @@ export default function Game() {
196215 < p className = "text-muted-foreground" > Your Balance</ p >
197216 < p className = "text-2xl font-bold" > { parseFloat ( wethBal ) . toFixed ( 2 ) } sUSDe</ p >
198217 </ div >
218+ < div >
219+ < p className = "text-muted-foreground" > Your Vault Shares</ p >
220+ < p className = "text-2xl font-bold" > { parseFloat ( vaultShares ) . toFixed ( 2 ) } sUSDeV</ p >
221+ </ div >
199222 < div className = "flex gap-2" >
200223 < Input type = "number" placeholder = "Amount"
201224 value = { amount }
0 commit comments