Skip to content

Commit

Permalink
Fix NAV calc on asset page (#2574)
Browse files Browse the repository at this point in the history
* Subtract pending fees from nav instead of paid fees

* Remove isLoading since it's not defined anymore
  • Loading branch information
sophialittlejohn authored Jan 10, 2025
1 parent f9aba6b commit 214ab90
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion centrifuge-app/src/components/LoanList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export function LoanList({ loans }: Props) {
}, [rows, pool])

const csvUrl = React.useMemo(() => csvData && getCSVDownloadUrl(csvData as any), [csvData])
const filteredData = isLoading ? [] : showRepaid ? rows : rows.filter((row) => !row.marketValue?.isZero())
const filteredData = showRepaid ? rows : rows.filter((row) => !row.marketValue?.isZero())
const pagination = usePagination({ data: filteredData, pageSize: 20 })

return (
Expand Down
4 changes: 2 additions & 2 deletions centrifuge-app/src/pages/Pool/Assets/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function PoolDetailAssets() {
)

const total = isTinlakePool ? pool.nav.total : pool.reserve.total.toDecimal().add(offchainReserve).add(totalAssets)
const totalNAV = isTinlakePool ? pool.nav.total : Dec(total as any).sub(pool.fees.totalPaid.toDecimal())
const totalNAV = isTinlakePool ? pool.nav.total : Dec(total as any).sub(pool.fees.totalPending.toDecimal())

const pageSummaryData: { label: React.ReactNode; value: React.ReactNode; heading?: boolean }[] = [
{
Expand Down Expand Up @@ -117,7 +117,7 @@ export function PoolDetailAssets() {
heading: false,
},
{
label: `Accrued fees (${pool.currency.symbol})`,
label: `Total pending fees (${pool.currency.symbol})`,
value: `${pool.fees.totalPaid.isZero() ? '' : '-'}${formatBalance(pool.fees.totalPaid)}`,
heading: false,
},
Expand Down
7 changes: 6 additions & 1 deletion centrifuge-js/src/modules/pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ export type Pool = {
}
fees: {
totalPaid: CurrencyBalance
totalPending: CurrencyBalance
}
parameters: {
minEpochTime: number
Expand Down Expand Up @@ -2001,14 +2002,17 @@ export function getPoolsModule(inst: Centrifuge) {
)

const $query = inst.getSubqueryObservable<{
pools: { nodes: { id: string; createdAt: string; sumPoolFeesPaidAmount: string }[] }
pools: {
nodes: { id: string; createdAt: string; sumPoolFeesPaidAmount: string; sumPoolFeesPendingAmount: string }[]
}
}>(
`query {
pools {
nodes {
id
createdAt
sumPoolFeesPaidAmount
sumPoolFeesPendingAmount
}
}
}`,
Expand Down Expand Up @@ -2239,6 +2243,7 @@ export function getPoolsModule(inst: Centrifuge) {
createdAt: gqlPool?.createdAt ?? null,
fees: {
totalPaid: new CurrencyBalance(gqlPool?.sumPoolFeesPaidAmount ?? 0, pool.currency.decimals),
totalPending: new CurrencyBalance(gqlPool?.sumPoolFeesPendingAmount ?? 0, pool.currency.decimals),
},
}
return poolWithGqlData
Expand Down

0 comments on commit 214ab90

Please sign in to comment.