Skip to content

Commit

Permalink
feat: refactor credits page to diamond contract
Browse files Browse the repository at this point in the history
Resolves: #786
  • Loading branch information
gitcoindev committed Oct 2, 2023
1 parent bd43fae commit d9eb49d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/dapp/pages/credits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,26 @@ import DollarPrice from "@/components/redeem/dollar-price";
import UcrRedeem from "@/components/redeem/ucr-redeem";
import UcrNftGenerator from "@/components/redeem/debt-coupon-deposit";
import UcrNftRedeem from "@/components/redeem/ucr-nft-redeem";
import useManagerManaged from "@/components/lib/hooks/contracts/use-manager-managed";
import useProtocolContracts from "@/components/lib/hooks/contracts/use-protocol-contracts";
import useEffectAsync from "@/components/lib/hooks/use-effect-async";
// import DisabledBlurredMessage from "@/components/ui/DisabledBlurredMessage";
import dynamic from "next/dynamic";
const WalletConnectionWall = dynamic(() => import("@/components/ui/wallet-connection-wall"), { ssr: false }); //@note Fix: (Hydration Error)

const PriceStabilization: FC = (): JSX.Element => {
const [twapInteger, setTwapInteger] = useState<number>(0);
const managedContracts = useManagerManaged();
const protocolContracts = useProtocolContracts();

useEffectAsync(async () => {
if (managedContracts) {
const twapPrice = await managedContracts.dollarTwapOracle.consult(managedContracts.dollarToken.address);
if (protocolContracts) {
const dollarTokenAddress = protocolContracts.managerFacet && (await protocolContracts.managerFacet.dollarTokenAddress());
const twapPrice = protocolContracts.twapOracleDollar3poolFacet && (await protocolContracts.twapOracleDollar3poolFacet.consult(dollarTokenAddress));
if (twapPrice) {
const twapPriceInteger = (twapPrice as unknown as number) / 1e18;
setTwapInteger(twapPriceInteger);
}
}
}, [managedContracts]);
}, [protocolContracts]);

return (
<WalletConnectionWall>
Expand Down

0 comments on commit d9eb49d

Please sign in to comment.