From 906640c732c9b1ba392fca17186a57d83075f51e Mon Sep 17 00:00:00 2001 From: saml33 Date: Wed, 17 Aug 2022 22:09:40 +1000 Subject: [PATCH] add health impact component --- components/modals/BorrowModal.tsx | 26 ++--------- components/modals/WithdrawModal.tsx | 25 ++-------- components/shared/HealthImpact.tsx | 71 +++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 41 deletions(-) create mode 100644 components/shared/HealthImpact.tsx diff --git a/components/modals/BorrowModal.tsx b/components/modals/BorrowModal.tsx index e417dc0d..99bfc6d6 100644 --- a/components/modals/BorrowModal.tsx +++ b/components/modals/BorrowModal.tsx @@ -13,6 +13,7 @@ import Input from '../forms/Input' import Label from '../forms/Label' import Button, { LinkButton } from '../shared/Button' import DepositTokenList from '../shared/DepositTokenList' +import HealthImpact from '../shared/HealthImpact' import Loading from '../shared/Loading' import Modal from '../shared/Modal' import { EnterBottomExitBottom, FadeInFadeOut } from '../shared/Transitions' @@ -39,17 +40,6 @@ function BorrowModal({ isOpen, onClose, token }: ModalCombinedProps) { return group?.banksMap.get(selectedToken) }, [selectedToken]) - const healthImpact = useMemo(() => { - const group = mangoStore.getState().group - if (!group || !bank || !mangoAccount) return 0 - - return mangoAccount - .simHealthRatioWithTokenPositionChanges(group, [ - { tokenName: bank.name, tokenAmount: parseFloat(inputAmount) * -1 }, - ]) - .toNumber() - }, [mangoAccount, bank, inputAmount]) - const tokenMax = useMemo(() => { const group = mangoStore.getState().group if (!group || !bank) return 0 @@ -191,16 +181,10 @@ function BorrowModal({ isOpen, onClose, token }: ModalCombinedProps) { /> -
-
-

{t('health-impact')}

-

{healthImpact}

-
- {/*
-

{t('borrow-value')}

-

$1,000.00

-
*/} -
+