From 4a4c212938f3c7c689819e9f41c7aee929adb013 Mon Sep 17 00:00:00 2001 From: Jeff Wu Date: Sun, 21 Apr 2024 14:55:40 -0700 Subject: [PATCH] Bugfix/various fee bugs (#769) * fix: hero stats (#766) * fix: some initial issues * fix: withdraw liquidity bugs --- .../components/hero/components/hero-stats.tsx | 12 ++++++++---- .../src/client/analytics-registry-client.ts | 5 ++++- .../hooks/use-liquidity-details.tsx | 19 ------------------- .../side-drawers/create-increase-position.tsx | 2 +- .../src/side-drawers/convert-asset.tsx | 15 ++------------- .../portfolio/src/side-drawers/roll-debt.tsx | 15 ++------------- .../src/summary/use-trade-summary.tsx | 8 ++++++-- packages/transaction/src/calculate.ts | 11 ++++++++--- 8 files changed, 31 insertions(+), 56 deletions(-) diff --git a/apps/web/src/containers/LandingPageView/components/hero/components/hero-stats.tsx b/apps/web/src/containers/LandingPageView/components/hero/components/hero-stats.tsx index 735f659d2..19340095b 100644 --- a/apps/web/src/containers/LandingPageView/components/hero/components/hero-stats.tsx +++ b/apps/web/src/containers/LandingPageView/components/hero/components/hero-stats.tsx @@ -10,32 +10,36 @@ import statsImg from '../images/stats_overlay.svg'; import { FormattedMessage } from 'react-intl'; import { formatNumber } from '@notional-finance/helpers'; import { useNotionalContext } from '@notional-finance/notionable-hooks'; +import { SupportedNetworks } from '@notional-finance/util'; const oneMillion = 1_000_000; export const HeroStats = () => { const theme = useTheme(); const { - globalState: { heroStats }, + globalState: { heroStats, activeAccounts }, } = useNotionalContext(); + const isReady = SupportedNetworks.every( + (n) => activeAccounts && activeAccounts[n] + ); return ( - {heroStats?.totalAccounts ? ( + {isReady && heroStats ? (
{`$${formatNumber( heroStats.totalValueLocked / oneMillion, - 0 + 2 )}M`} - {`$${formatNumber(heroStats.totalOpenDebt / oneMillion, 0)}M`} + {`$${formatNumber(heroStats.totalOpenDebt / oneMillion, 1)}M`} diff --git a/packages/core-entities/src/client/analytics-registry-client.ts b/packages/core-entities/src/client/analytics-registry-client.ts index c7b718924..0705da670 100644 --- a/packages/core-entities/src/client/analytics-registry-client.ts +++ b/packages/core-entities/src/client/analytics-registry-client.ts @@ -331,7 +331,10 @@ export class AnalyticsRegistryClient extends ClientRegistry { Registry.getTokenRegistry() .getAllTokens(n) .filter( - (t) => t.tokenType === 'PrimeDebt' || t.tokenType === 'PrimeCash' + (t) => + t.tokenType === 'PrimeDebt' || + t.tokenType === 'PrimeCash' || + t.tokenType === 'VaultShare' ) .reduce( (acc, token) => diff --git a/packages/features/liquidity/src/liquidity-leveraged/hooks/use-liquidity-details.tsx b/packages/features/liquidity/src/liquidity-leveraged/hooks/use-liquidity-details.tsx index 803e1fd89..8ddd9611b 100644 --- a/packages/features/liquidity/src/liquidity-leveraged/hooks/use-liquidity-details.tsx +++ b/packages/features/liquidity/src/liquidity-leveraged/hooks/use-liquidity-details.tsx @@ -137,25 +137,6 @@ export const useLiquidityDetails = () => { greenOnArrowUp: true, }, }, - { - label: 'Net Worth', - current: currentHoldings?.presentValue.toDisplayStringWithSymbol() || '-', - updated: { - value: newNetWorth?.toDisplayStringWithSymbol() || '-', - arrowUp: - getChangeType( - currentHoldings?.presentValue.toFloat(), - newNetWorth?.toFloat() - ) === 'increase', - checkmark: - getChangeType( - currentHoldings?.presentValue.toFloat(), - newNetWorth?.toFloat() - ) === 'cleared', - greenOnCheckmark: false, - greenOnArrowUp: true, - }, - }, { label: 'Leverage Ratio', current: currentHoldings?.leverageRatio diff --git a/packages/features/liquidity/src/liquidity-leveraged/side-drawers/create-increase-position.tsx b/packages/features/liquidity/src/liquidity-leveraged/side-drawers/create-increase-position.tsx index 01a4d03ee..a18cf11a5 100644 --- a/packages/features/liquidity/src/liquidity-leveraged/side-drawers/create-increase-position.tsx +++ b/packages/features/liquidity/src/liquidity-leveraged/side-drawers/create-increase-position.tsx @@ -56,7 +56,7 @@ export const CreateOrIncreasePosition = () => { {currentPosition ? ( { - const theme = useTheme(); const context = useTradeContext('ConvertAsset'); const { currencyInputRef } = useCurrencyInputRef(); const { @@ -41,15 +39,6 @@ export const ConvertAsset = () => { {collateral && ( - updateState({ collateral: undefined })} - sx={{ - position: 'absolute', - top: 0, - background: theme.palette.background.paper, - }} - titleText={defineMessage({ defaultMessage: 'Back' })} - /> { - const theme = useTheme(); const context = useTradeContext('RollDebt'); const { currencyInputRef } = useCurrencyInputRef(); const { @@ -44,15 +42,6 @@ export const RollDebt = () => { context={context} enablePrimeBorrow={debt?.tokenType === 'PrimeDebt'} > - updateState({ debt: undefined })} - sx={{ - position: 'absolute', - top: 0, - background: theme.palette.background.paper, - }} - titleText={defineMessage({ defaultMessage: 'Back' })} - />