Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug on nav management #2463

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions centrifuge-app/src/pages/NavManagement/NavManagementAssetTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@
// 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())

Expand All @@ -209,7 +208,7 @@

const changeInValuation = React.useMemo(() => {
return (externalLoans as ActiveLoan[]).reduce((prev, curr) => {
const price = curr.currentPrice.toDecimal()
const price = curr.currentPrice ? curr.currentPrice.toDecimal() : 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(
Expand All @@ -217,7 +216,7 @@
pool.currency.decimals
)
}, new CurrencyBalance(0, pool.currency.decimals))
}, [externalLoans, pool?.nav, form.values.feed])

Check warning on line 219 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 219 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 pendingNav = totalAum.add(changeInValuation.toDecimal()).sub(pendingFees.toDecimal())

Expand Down Expand Up @@ -324,11 +323,11 @@
<>
<LayoutSection pt={3}>
<NavOverviewCard
poolId={pool.id}
changeInValuation={changeInValuation.toDecimal().toNumber()}
totalAum={totalAum.toNumber()}
pendingFees={pendingFees.toDecimal().toNumber()}
pendingNav={pendingNav.toNumber()}
poolId={pool.id}
changeInValuation={changeInValuation.toDecimal().toNumber()}
totalAum={totalAum.toNumber()}
pendingFees={pendingFees.toDecimal().toNumber()}
pendingNav={pendingNav.toNumber()}
/>
</LayoutSection>

Expand Down Expand Up @@ -421,7 +420,19 @@
)
}

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)
Expand Down
Loading