Skip to content

Commit

Permalink
remove accrued interest
Browse files Browse the repository at this point in the history
  • Loading branch information
onnovisser committed Oct 4, 2023
1 parent e947f53 commit 150db56
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 29 deletions.
4 changes: 3 additions & 1 deletion centrifuge-app/src/components/PoolsTokensShared.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export function PoolsTokensShared({ title, children }: PoolsTokensSharedProps) {
<LoadBoundary>
<CardTotalValueLocked />
</LoadBoundary>
<PortfolioCta />
<LoadBoundary>
<PortfolioCta />
</LoadBoundary>
</Grid>

<Stack alignItems="end">
Expand Down
13 changes: 0 additions & 13 deletions centrifuge-app/src/components/PortfolioCta/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ActiveLoan } from '@centrifuge/centrifuge-js'
import { useBalances, useCentrifugeConsts, useWallet } from '@centrifuge/centrifuge-react'
import { Box, Button, Shelf, Stack, Text } from '@centrifuge/fabric'
import * as React from 'react'
Expand All @@ -8,7 +7,6 @@ import { Dec } from '../../utils/Decimal'
import { formatBalance, formatBalanceAbbreviated } from '../../utils/formatting'
import { useAddress } from '../../utils/useAddress'
import { useListedPools } from '../../utils/useListedPools'
import { useLoansAcrossPools } from '../../utils/useLoans'
import { useDebugFlags } from '../DebugFlags'
import { useComputeLiquidityRewards } from '../LiquidityRewards/hooks'
import { Cubes } from './Cubes'
Expand All @@ -33,24 +31,13 @@ export function PortfolioCta() {
}) ?? []
const investedValue = [...currencies, ...tranches].reduce((a, b) => a.add(b), Dec(0))

const pools = balances?.tranches.map(({ poolId }) => poolId) ?? []
const loans = useLoansAcrossPools(pools) ?? []
const activeLoans = loans?.filter(({ status }) => status === 'Active') as ActiveLoan[]
const accruedInterest = activeLoans
.map(({ outstandingInterest }) => outstandingInterest.toDecimal())
.reduce((a, b) => a.add(b), Dec(0))

const terms = [
{
title: 'Portfolio value',
value: investedValue.gte(1000)
? formatBalanceAbbreviated(investedValue, config.baseCurrency)
: formatBalance(investedValue, config.baseCurrency),
},
{
title: 'Accrued interest',
value: formatBalance(accruedInterest, config.baseCurrency),
},
{
title: 'CFG rewards',
value: formatBalance(rewards, consts.chainSymbol, 2),
Expand Down
15 changes: 0 additions & 15 deletions centrifuge-app/src/utils/useLoans.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { useCentrifugeQuery } from '@centrifuge/centrifuge-react'
import { combineLatest } from 'rxjs'
import { map } from 'rxjs/operators'
import { Dec } from './Decimal'
import { useTinlakeLoans } from './tinlake/useTinlakePools'

Expand All @@ -16,19 +14,6 @@ export function useLoans(poolId: string) {
return isTinlakePool ? tinlakeLoans : centLoans
}

export function useLoansAcrossPools(poolIds?: string[]) {
const [result] = useCentrifugeQuery(
['loansAcrossPools', poolIds],
(cent) => combineLatest(poolIds!.map((poolId) => cent.pools.getLoans([poolId]))).pipe(map((loans) => loans.flat())),
{
suspense: true,
enabled: poolIds && poolIds.length > 0,
}
)

return result
}

export function useLoan(poolId: string, assetId: string) {
const loans = useLoans(poolId)

Expand Down

0 comments on commit 150db56

Please sign in to comment.