From bd01efd2bb75063de368cf73377d616e90cdac1f Mon Sep 17 00:00:00 2001 From: sharad-s Date: Wed, 16 Mar 2022 10:51:24 -0500 Subject: [PATCH 01/19] migrate cvx positions --- .../Modals/PluginModal/PluginRewardsModal.tsx | 18 +- src/components/shared/Layout/Layout.tsx | 28 +++ src/components/shared/SwitchNetworkMenu.tsx | 1 - src/constants/convex.ts | 7 +- src/context/BalancesContext.tsx | 15 +- src/context/RariContext.tsx | 4 + src/contracts/abi/ConvexBaseRewardPool.json | 1 + .../convex/useConvexPoolSuppliedCTokens.ts | 4 +- src/hooks/convex/useStakedConvexBalances.ts | 61 ++++++ src/utils/convex/migratePositions.ts | 188 ++++++++++++++++++ src/utils/multicall.ts | 25 ++- 11 files changed, 328 insertions(+), 24 deletions(-) create mode 100644 src/contracts/abi/ConvexBaseRewardPool.json create mode 100644 src/hooks/convex/useStakedConvexBalances.ts create mode 100644 src/utils/convex/migratePositions.ts diff --git a/src/components/pages/Fuse/Modals/PluginModal/PluginRewardsModal.tsx b/src/components/pages/Fuse/Modals/PluginModal/PluginRewardsModal.tsx index 4e31b450..6d06cfda 100644 --- a/src/components/pages/Fuse/Modals/PluginModal/PluginRewardsModal.tsx +++ b/src/components/pages/Fuse/Modals/PluginModal/PluginRewardsModal.tsx @@ -21,7 +21,7 @@ import { USDPricedFuseAsset } from "utils/fetchFusePoolData" import { InfoIcon } from "@chakra-ui/icons" import AppLink from "components/shared/AppLink" import { CTokenAvatarGroup } from "components/shared/Icons/CTokenIcon" -import { eligibleTokens, tokenInfo } from "constants/convex" +import { eligibleTokens, CONVEX_CTOKEN_INFO } from "constants/convex" export const PluginRewardsModal = ({ market, @@ -61,10 +61,10 @@ export const PluginRewardsModal = ({ This market streams rewards - from the {tokenInfo[market.underlyingSymbol].convexPoolName} Convex pool - to suppliers of {tokenInfo[market.underlyingSymbol].curvePoolName} Curve LPs. - {/* Deposit your {tokenInfo[market.underlyingSymbol].curvePoolName} Curve LP tokens into Fuse to borrow against it while earning all the same rewards from Convex. */} - {/* View reward rates for {tokenInfo[market.underlyingSymbol].convexPoolName} on Convex */} + from the {CONVEX_CTOKEN_INFO[market.underlyingSymbol].convexPoolName} Convex pool + to suppliers of {CONVEX_CTOKEN_INFO[market.underlyingSymbol].curvePoolName} Curve LPs. + {/* Deposit your {CONVEX_CTOKEN_INFO[market.underlyingSymbol].curvePoolName} Curve LP tokens into Fuse to borrow against it while earning all the same rewards from Convex. */} + {/* View reward rates for {CONVEX_CTOKEN_INFO[market.underlyingSymbol].convexPoolName} on Convex */} {/* */} @@ -73,9 +73,9 @@ export const PluginRewardsModal = ({ Info - - - + + + } @@ -83,7 +83,7 @@ export const PluginRewardsModal = ({ diff --git a/src/components/shared/Layout/Layout.tsx b/src/components/shared/Layout/Layout.tsx index 9d2be4b8..a142a9f0 100644 --- a/src/components/shared/Layout/Layout.tsx +++ b/src/components/shared/Layout/Layout.tsx @@ -7,6 +7,14 @@ import { useMemo, useState, useEffect } from "react"; import NewHeader from "../Header2/NewHeader"; import Footer from "./Footer"; +import { Button, Image } from "@chakra-ui/react" + +//CVX +import { useAccountBalances } from "context/BalancesContext" +import { useDisclosure } from "@chakra-ui/react"; +import CVXMigrateModal from "components/pages/Fuse/Modals/CVXMigrateModal"; + + const Layout = ({ children }) => { const { chainId } = useRari() @@ -37,6 +45,16 @@ const Layout = ({ children }) => { return () => document.removeEventListener("keydown", handler); }, []); + const [_, __, cvxBalances] = useAccountBalances() + const hasCvxBalances = !!Object.keys(cvxBalances ?? {}).length + const { isOpen, onOpen, onClose } = useDisclosure() + + console.log({cvxBalances}) + + useEffect(() => { + console.log({ hasCvxBalances }) + if (!!hasCvxBalances) onOpen() + }, [hasCvxBalances]) return ( { {children} + {!!hasCvxBalances && } + {!!hasCvxBalances && }