From 7b8b609bcf5d483821d80bf47f2cee1ee7672103 Mon Sep 17 00:00:00 2001 From: Katty Barroso <51223655+kattylucy@users.noreply.github.com> Date: Wed, 2 Oct 2024 17:06:59 +0200 Subject: [PATCH] Fix bug on nav management (#2463) --- .../NavManagement/NavManagementAssetTable.tsx | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/centrifuge-app/src/pages/NavManagement/NavManagementAssetTable.tsx b/centrifuge-app/src/pages/NavManagement/NavManagementAssetTable.tsx index 5189e2c540..dc15c94997 100644 --- a/centrifuge-app/src/pages/NavManagement/NavManagementAssetTable.tsx +++ b/centrifuge-app/src/pages/NavManagement/NavManagementAssetTable.tsx @@ -195,7 +195,6 @@ export function NavManagementAssetTable({ poolId }: { poolId: string }) { // eslint-disable-next-line react-hooks/exhaustive-deps }, [initialValues, isEditing, isLoading]) - // NOTE: This assumes that pool.reserve.total comes from onchain state AND NOT from the runtime-apis const totalAum = pool.nav.aum.toDecimal().add(pool.reserve.total.toDecimal()) @@ -209,7 +208,7 @@ export function NavManagementAssetTable({ poolId }: { poolId: string }) { const changeInValuation = React.useMemo(() => { return (externalLoans as ActiveLoan[]).reduce((prev, curr) => { - const price = curr.currentPrice.toDecimal() + const price = curr.currentPrice ? curr.currentPrice.toDecimal() : Dec(0) const quantity = (curr as ExternalLoan).pricing.outstandingQuantity.toDecimal() const updatedPrice = Dec(form.values.feed.find((p) => p.id === curr.id)?.value || 0) return CurrencyBalance.fromFloat( @@ -324,11 +323,11 @@ export function NavManagementAssetTable({ poolId }: { poolId: string }) { <> @@ -421,7 +420,19 @@ export function NavManagementAssetTable({ poolId }: { poolId: string }) { ) } -export function NavOverviewCard({ poolId, changeInValuation, totalAum, pendingFees, pendingNav }: { poolId: string; changeInValuation: number; totalAum: number; pendingFees: number; pendingNav: number}) { +export function NavOverviewCard({ + poolId, + changeInValuation, + totalAum, + pendingFees, + pendingNav, +}: { + poolId: string + changeInValuation: number + totalAum: number + pendingFees: number + pendingNav: number +}) { const pool = usePool(poolId) const today = new Date() today.setHours(0, 0, 0, 0)