From 41ab3da9d6ccc0f3ce07d100b155b39a11a154f8 Mon Sep 17 00:00:00 2001 From: Thomas Gehrmann Date: Thu, 19 Oct 2023 18:34:28 +0200 Subject: [PATCH] Show yield router and offset bridge balances --- packages/app/src/yield/YieldApp.tsx | 44 +++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/packages/app/src/yield/YieldApp.tsx b/packages/app/src/yield/YieldApp.tsx index 30dbd336..006501b7 100644 --- a/packages/app/src/yield/YieldApp.tsx +++ b/packages/app/src/yield/YieldApp.tsx @@ -1,9 +1,16 @@ -import { forwardRef, type ForwardRefRenderFunction } from "react"; +import { + forwardRef, + useEffect, + type ForwardRefRenderFunction, + useState, +} from "react"; import AccountBalance from "./AccountBalance"; import { useSunriseStake } from "../common/context/sunriseStakeContext"; import { type Details } from "@sunrisestake/client"; import BN from "bn.js"; import { lamportsToDisplay } from "../common/utils"; +import { useConnection } from "@solana/wallet-adapter-react"; +import { PublicKey } from "@solana/web3.js"; const _YieldApp: ForwardRefRenderFunction< HTMLDivElement, @@ -15,6 +22,27 @@ const _YieldApp: ForwardRefRenderFunction< details: Details | undefined; } = useSunriseStake(); + const [yieldRouterBalance, setYieldRouterBalance] = useState(0); + const [offsetBridgeBalance, setOffsetBridgeBalance] = useState(0); + + const { connection } = useConnection(); + + useEffect(() => { + const getBalances = async (): Promise => { + const yieldControllerBal = await connection.getBalance( + new PublicKey("6HQrvpMJFqMj35JqMReyhnUrRXNucAAB6FywdDu7xPKA") + ); + const offsetBridgeBal = await connection.getBalance( + new PublicKey("4XTLzYF3kteTbb3a9NYYjeDAYwNoEGSkjoqJYkiLCnmm") + ); + + setYieldRouterBalance(yieldControllerBal); + setOffsetBridgeBalance(offsetBridgeBal); + }; + + getBalances().catch(console.error); + }, [connection]); + if (details == null) return <>Loading...; const extractableYield = new BN( @@ -27,13 +55,19 @@ const _YieldApp: ForwardRefRenderFunction< title="Sunrise Stake" balance={lamportsToDisplay(extractableYield)} /> - +
- - + +
- +
);