diff --git a/apps/marginfi-v2-ui/src/components/desktop/Points/PointsCheckingUser.tsx b/apps/marginfi-v2-ui/src/components/desktop/Points/PointsCheckingUser.tsx index aca30f0962..9a97da8117 100644 --- a/apps/marginfi-v2-ui/src/components/desktop/Points/PointsCheckingUser.tsx +++ b/apps/marginfi-v2-ui/src/components/desktop/Points/PointsCheckingUser.tsx @@ -5,7 +5,7 @@ interface PointsCheckingUserProps {} export const PointsCheckingUser: FC = ({}) => { return ( - +
diff --git a/apps/marginfi-v2-ui/src/components/desktop/Points/PointsConnectWallet.tsx b/apps/marginfi-v2-ui/src/components/desktop/Points/PointsConnectWallet.tsx index 0ed8b4afb5..cef8667ee3 100644 --- a/apps/marginfi-v2-ui/src/components/desktop/Points/PointsConnectWallet.tsx +++ b/apps/marginfi-v2-ui/src/components/desktop/Points/PointsConnectWallet.tsx @@ -7,7 +7,7 @@ interface PointsConnectWalletProps {} export const PointsConnectWallet: FC = ({}) => { return ( - +
diff --git a/apps/marginfi-v2-ui/src/components/desktop/Points/PointsLeaderBoard.tsx b/apps/marginfi-v2-ui/src/components/desktop/Points/PointsLeaderBoard.tsx index 3d6ecd7d56..248b446672 100644 --- a/apps/marginfi-v2-ui/src/components/desktop/Points/PointsLeaderBoard.tsx +++ b/apps/marginfi-v2-ui/src/components/desktop/Points/PointsLeaderBoard.tsx @@ -6,7 +6,7 @@ import { LeaderboardRow } from "@mrgnlabs/marginfi-v2-ui-state"; interface PointsLeaderBoardProps { leaderboardData: LeaderboardRow[]; - currentUserId: string; + currentUserId?: string; } export const PointsLeaderBoard: FC = ({ leaderboardData, currentUserId }) => { diff --git a/apps/marginfi-v2-ui/src/components/desktop/Points/PointsOverview.tsx b/apps/marginfi-v2-ui/src/components/desktop/Points/PointsOverview.tsx index 350fee3bd1..760f0e4e4e 100644 --- a/apps/marginfi-v2-ui/src/components/desktop/Points/PointsOverview.tsx +++ b/apps/marginfi-v2-ui/src/components/desktop/Points/PointsOverview.tsx @@ -1,26 +1,20 @@ +import React, { FC } from "react"; import Image from "next/image"; -import { MarginfiAccountWrapper } from "@mrgnlabs/marginfi-client-v2"; -import { Card, CardContent, Skeleton, TableCell, TableRow, Typography } from "@mui/material"; -import React, { FC, useCallback, useMemo, useState } from "react"; -import { toast } from "react-toastify"; -import { - groupedNumberFormatter, - uiToNative, - usdFormatter, - numeralFormatter, - groupedNumberFormatterDyn, -} from "@mrgnlabs/mrgn-common"; +import { Card, CardContent, Skeleton, Typography } from "@mui/material"; + +import { numeralFormatter, groupedNumberFormatterDyn } from "@mrgnlabs/mrgn-common"; +import { UserPointsData } from "@mrgnlabs/marginfi-v2-ui-state"; + import { MrgnTooltip } from "~/components/common/MrgnTooltip"; -import { AccountSummary, UserPointsData } from "@mrgnlabs/marginfi-v2-ui-state"; -interface PointsLeaderBoardProps { +interface PointsOverviewProps { userPointsData: UserPointsData; } -export const PointsOverview: FC = ({ userPointsData }) => { +export const PointsOverview: FC = ({ userPointsData }) => { return ( <> -
+
@@ -65,7 +59,7 @@ export const PointsOverview: FC = ({ userPointsData }) =
-
+
diff --git a/apps/marginfi-v2-ui/src/components/desktop/Points/PointsSignIn.tsx b/apps/marginfi-v2-ui/src/components/desktop/Points/PointsSignIn.tsx index 517a06b7e4..1dfff3eed7 100644 --- a/apps/marginfi-v2-ui/src/components/desktop/Points/PointsSignIn.tsx +++ b/apps/marginfi-v2-ui/src/components/desktop/Points/PointsSignIn.tsx @@ -30,7 +30,7 @@ export const PointsSignIn: FC = ({}) => { }, [connection, useAuthTx, walletContextState]); return ( - +
diff --git a/apps/marginfi-v2-ui/src/components/desktop/Points/PointsSignUp.tsx b/apps/marginfi-v2-ui/src/components/desktop/Points/PointsSignUp.tsx index a9559a003e..5f92292d4b 100644 --- a/apps/marginfi-v2-ui/src/components/desktop/Points/PointsSignUp.tsx +++ b/apps/marginfi-v2-ui/src/components/desktop/Points/PointsSignUp.tsx @@ -46,7 +46,7 @@ export const PointsSignUp: FC = ({ referralCode }) => { }, [connection, finalReferralCode, useAuthTx, walletContextState]); return ( - +
diff --git a/apps/marginfi-v2-ui/src/components/mobile/MobileAccountSummary/MobileAccountSummary.tsx b/apps/marginfi-v2-ui/src/components/mobile/MobileAccountSummary/MobileAccountSummary.tsx index a7ab7fac41..c092a55e19 100644 --- a/apps/marginfi-v2-ui/src/components/mobile/MobileAccountSummary/MobileAccountSummary.tsx +++ b/apps/marginfi-v2-ui/src/components/mobile/MobileAccountSummary/MobileAccountSummary.tsx @@ -2,21 +2,13 @@ import React, { FC } from "react"; import dynamic from "next/dynamic"; import { useMrgnlendStore } from "~/store"; -import { useWalletContext } from "~/hooks/useWalletContext"; -import { UserStats } from "~/components/common/AccountSummary"; const GlobalStats = dynamic(async () => (await import("~/components/common/AccountSummary/GlobalStats")).GlobalStats, { ssr: false, }); const AccountSummary: FC = () => { - const [isStoreInitialized, accountSummary, protocolStats, selectedAccount] = useMrgnlendStore((state) => [ - state.initialized, - state.accountSummary, - state.protocolStats, - state.selectedAccount, - ]); - const { connected } = useWalletContext(); + const [protocolStats] = useMrgnlendStore((state) => [state.protocolStats]); return (
@@ -29,7 +21,7 @@ const AccountSummary: FC = () => { borrows={protocolStats.borrows} deposits={protocolStats.deposits} /> -
{" "} +
{/*
diff --git a/apps/marginfi-v2-ui/src/components/mobile/MobileAssetsList/AssetCard/AssetCard.tsx b/apps/marginfi-v2-ui/src/components/mobile/MobileAssetsList/AssetCard/AssetCard.tsx index 764c638a55..427034ee53 100644 --- a/apps/marginfi-v2-ui/src/components/mobile/MobileAssetsList/AssetCard/AssetCard.tsx +++ b/apps/marginfi-v2-ui/src/components/mobile/MobileAssetsList/AssetCard/AssetCard.tsx @@ -21,7 +21,7 @@ export const AssetCard: FC<{ isInLendingMode: boolean; isConnected: boolean; marginfiAccount: MarginfiAccountWrapper | null; - inputRefs: React.MutableRefObject>; + inputRefs?: React.MutableRefObject>; }> = ({ bank, nativeSolBalance, isInLendingMode, marginfiAccount, inputRefs }) => { const { rateAP, assetWeight, isBankFilled, isBankHigh, bankCap } = useAssetItemData({ bank, isInLendingMode }); const [mfiClient, fetchMrgnlendState] = useMrgnlendStore((state) => [state.marginfiClient, state.fetchMrgnlendState]); diff --git a/apps/marginfi-v2-ui/src/components/mobile/MobileAssetsList/AssetCard/AssetCardActions.tsx b/apps/marginfi-v2-ui/src/components/mobile/MobileAssetsList/AssetCard/AssetCardActions.tsx index 2d6be3e2a0..f40a6d6126 100644 --- a/apps/marginfi-v2-ui/src/components/mobile/MobileAssetsList/AssetCard/AssetCardActions.tsx +++ b/apps/marginfi-v2-ui/src/components/mobile/MobileAssetsList/AssetCard/AssetCardActions.tsx @@ -8,10 +8,10 @@ import { useWalletContext } from "~/hooks/useWalletContext"; export const AssetCardActions: FC<{ bank: ExtendedBankInfo; - inputRefs: React.MutableRefObject>; isBankFilled: boolean; isInLendingMode: boolean; currentAction: ActionType | "Connect"; + inputRefs?: React.MutableRefObject>; onCloseBalance: () => void; onBorrowOrLend: (amount: number) => void; }> = ({ bank, inputRefs, isBankFilled, currentAction, onCloseBalance, onBorrowOrLend }) => { diff --git a/apps/marginfi-v2-ui/src/components/mobile/MobileAssetsList/MobileAssetsList.tsx b/apps/marginfi-v2-ui/src/components/mobile/MobileAssetsList/MobileAssetsList.tsx index 40a7b35cd9..8402c4e554 100644 --- a/apps/marginfi-v2-ui/src/components/mobile/MobileAssetsList/MobileAssetsList.tsx +++ b/apps/marginfi-v2-ui/src/components/mobile/MobileAssetsList/MobileAssetsList.tsx @@ -20,11 +20,6 @@ export const MobileAssetsList: FC = () => { state.nativeSolBalance, state.selectedAccount, ]); - const [lendZoomLevel, showBadges, setShowBadges] = useUserProfileStore((state) => [ - state.lendZoomLevel, - state.showBadges, - state.setShowBadges, - ]); const inputRefs = useRef>({}); const [isInLendingMode, setIsInLendingMode] = useState(true); diff --git a/apps/marginfi-v2-ui/src/components/mobile/MobileNavbar/MobileNavbar.tsx b/apps/marginfi-v2-ui/src/components/mobile/MobileNavbar/MobileNavbar.tsx index f2b3d9da95..4f66c07862 100644 --- a/apps/marginfi-v2-ui/src/components/mobile/MobileNavbar/MobileNavbar.tsx +++ b/apps/marginfi-v2-ui/src/components/mobile/MobileNavbar/MobileNavbar.tsx @@ -1,7 +1,7 @@ import { FC, useEffect } from "react"; import Link from "next/link"; import Image from "next/image"; -import AirdropZone from "./AirdropZone"; + import { useUserProfileStore } from "~/store"; import { useRouter } from "next/router"; import { useFirebaseAccount } from "~/hooks/useFirebaseAccount"; @@ -40,11 +40,11 @@ const MobileNavbar: FC = () => { swap wallet icon - bridge + portfolio {/* { - const [ - marginfiClient, - fetchMrgnlendState, - selectedAccount, - accountSummary, - extendedBankInfos, - nativeSolBalance, - protocolStats, - ] = useMrgnlendStore((state) => [ - state.marginfiClient, - state.fetchMrgnlendState, - state.selectedAccount, - state.accountSummary, - state.extendedBankInfos, - state.nativeSolBalance, - state.protocolStats, - ]); - const { wallet } = useWallet(); - const connection = useConnection(); - - useEffect(() => { - fetchMrgnlendState(); - const id = setInterval(() => fetchMrgnlendState().catch(console.error), 30_000); - return () => clearInterval(id); - }, [wallet]); // eslint-disable-line react-hooks/exhaustive-deps - // ^ crucial to omit both `connection` and `fetchMrgnlendState` from the dependency array - // TODO: fix... + const [selectedAccount, accountSummary] = useMrgnlendStore((state) => [state.selectedAccount, state.accountSummary]); const [userPointsData, currentFirebaseUser] = useUserProfileStore((state) => [ state.userPointsData, state.currentFirebaseUser, ]); - console.log({ selectedAccount }); - const healthFactor = useMemo(() => { + console.log({ selectedAccount }); if (selectedAccount) { const { assets, liabilities } = selectedAccount.computeHealthComponents(MarginRequirementType.Maintenance); return assets.isZero() ? 100 : assets.minus(liabilities).dividedBy(assets).toNumber() * 100; @@ -60,10 +27,10 @@ export const MobilePortfolioOverview: FC = () => { }, [selectedAccount]); return ( -
+
Your overview
-
Health factor
+
Health factor
diff --git a/apps/marginfi-v2-ui/src/components/mobile/MobilePortfolioOverview/SemiCircleProgress.tsx b/apps/marginfi-v2-ui/src/components/mobile/MobilePortfolioOverview/SemiCircleProgress.tsx index c167ed3264..9e7a1e57f4 100644 --- a/apps/marginfi-v2-ui/src/components/mobile/MobilePortfolioOverview/SemiCircleProgress.tsx +++ b/apps/marginfi-v2-ui/src/components/mobile/MobilePortfolioOverview/SemiCircleProgress.tsx @@ -1,7 +1,8 @@ +import React, { useEffect, useRef, useState } from "react"; import { keyframes } from "@emotion/react"; import styled from "@emotion/styled"; + import { percentFormatter } from "@mrgnlabs/mrgn-common"; -import React, { useEffect, useRef, useState } from "react"; type Props = { amount: number; @@ -55,7 +56,7 @@ export const SemiCircleProgress = ({ amount }: Props) => { width: "180px", height: "90px", borderRadius: "90px", - backgroundColor: "#171C1F", + backgroundColor: "#131619", top: "10px", marginLeft: "auto", marginRight: "auto", @@ -84,7 +85,7 @@ export const SemiCircleProgress = ({ amount }: Props) => { ".rotatingCircleWrap": { position: "absolute", - backgroundColor: "#171C1F", + backgroundColor: "#131619", left: "0px", width: "200px", height: "100px", @@ -92,7 +93,6 @@ export const SemiCircleProgress = ({ amount }: Props) => { }, ".rotatingCircle": { - // position: "absolute", overflow: "hidden", top: "0px", left: "0px", diff --git a/apps/marginfi-v2-ui/src/components/mobile/MobilePortfolioOverview/index.ts b/apps/marginfi-v2-ui/src/components/mobile/MobilePortfolioOverview/index.ts new file mode 100644 index 0000000000..f872bac67d --- /dev/null +++ b/apps/marginfi-v2-ui/src/components/mobile/MobilePortfolioOverview/index.ts @@ -0,0 +1 @@ +export * from "./MobilePortfolioOverview"; diff --git a/apps/marginfi-v2-ui/src/pages/_app.tsx b/apps/marginfi-v2-ui/src/pages/_app.tsx index 30be73c899..c4c67bc8fb 100644 --- a/apps/marginfi-v2-ui/src/pages/_app.tsx +++ b/apps/marginfi-v2-ui/src/pages/_app.tsx @@ -77,8 +77,10 @@ const MyApp = ({ Component, pageProps }: AppProps) => {