Skip to content

Commit

Permalink
adapt docs and use correct reserve amount
Browse files Browse the repository at this point in the history
  • Loading branch information
mustermeiszer committed Sep 12, 2024
1 parent 10212d1 commit 48d6e53
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions centrifuge-app/src/pages/NavManagement/NavManagementAssetTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ 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())

// NOTE: current pending here in the app does include both pending + disbursed fees
const pendingFees = React.useMemo(() => {
return new CurrencyBalance(
poolFees?.map((f) => f.amounts.pending).reduce((acc, f) => acc.add(f), new BN(0)) ?? new BN(0),
Expand All @@ -214,7 +219,6 @@ export function NavManagementAssetTable({ poolId }: { poolId: string }) {
}, new CurrencyBalance(0, pool.currency.decimals))
}, [externalLoans, pool?.nav, form.values.feed])

Check warning on line 220 in centrifuge-app/src/pages/NavManagement/NavManagementAssetTable.tsx

View workflow job for this annotation

GitHub Actions / build-app

React Hook React.useMemo has a missing dependency: 'pool.currency.decimals'. Either include it or remove the dependency array

Check warning on line 220 in centrifuge-app/src/pages/NavManagement/NavManagementAssetTable.tsx

View workflow job for this annotation

GitHub Actions / ff-prod / build-app

React Hook React.useMemo has a missing dependency: 'pool.currency.decimals'. Either include it or remove the dependency array

const totalAum = pool.nav.aum.toDecimal().add(pool.reserve.available.toDecimal())
const pendingNav = totalAum.add(changeInValuation.toDecimal()).sub(pendingFees.toDecimal())

// Only for single tranche pools
Expand Down Expand Up @@ -319,7 +323,13 @@ export function NavManagementAssetTable({ poolId }: { poolId: string }) {
return (
<>
<LayoutSection pt={3}>
<NavOverviewCard poolId={pool.id} changeInValuation={changeInValuation.toDecimal().toNumber()} />
<NavOverviewCard
poolId={pool.id}
changeInValuation={changeInValuation.toDecimal().toNumber()}
totalAum={totalAum.toNumber()}
pendingFees={pendingFees.toDecimal().toNumber()}
pendingNav={pendingNav.toNumber()}
/>
</LayoutSection>

<Stack pb={8}>
Expand Down Expand Up @@ -411,28 +421,18 @@ export function NavManagementAssetTable({ poolId }: { poolId: string }) {
)
}

export function NavOverviewCard({ poolId, changeInValuation }: { poolId: string; changeInValuation: number }) {
export function NavOverviewCard({ poolId, changeInValuation, totalAum, pendingFees, pendingNav }: { poolId: string; changeInValuation: number; totalAum: number; pendingFees: number; pendingNav: number}) {
const pool = usePool(poolId)
const poolFees = usePoolFees(poolId)
const today = new Date()
today.setHours(0, 0, 0, 0)

const pendingFees = React.useMemo(() => {
return new CurrencyBalance(
poolFees?.map((f) => f.amounts.pending).reduce((acc, f) => acc.add(f), new BN(0)) ?? new BN(0),
pool.currency.decimals
)
}, [poolFees, pool.currency.decimals])

const totalAum = pool.nav.aum.toDecimal().add(pool.reserve.available.toDecimal())

return (
<VisualNavCard
currency={pool.currency}
aum={totalAum.toNumber()}
aum={totalAum ?? 0}
change={changeInValuation ?? 0}
pendingFees={pendingFees.toFloat()}
pendingNav={totalAum.add(changeInValuation).sub(pendingFees.toDecimal()).toNumber()}
pendingFees={pendingFees ?? 0}
pendingNav={pendingNav ?? 0}
/>
)
}
Expand Down

0 comments on commit 48d6e53

Please sign in to comment.