Skip to content

Commit

Permalink
Show only deployed LPs Key Metrics and add Centrifuge logo (#2165)
Browse files Browse the repository at this point in the history
* Show only deployed LPs and add Centrifuge chain

* List tranches to click on

* Remove available networks from pool structure

* Change copy if only one tranche

* Link centrifuge to subscan
  • Loading branch information
sophialittlejohn authored May 30, 2024
1 parent 68c71ca commit 6557cff
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 32 deletions.
114 changes: 86 additions & 28 deletions centrifuge-app/src/components/PoolOverview/KeyMetrics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import startCase from 'lodash/startCase'
import { evmChains } from '../../config'
import { daysBetween } from '../../utils/date'
import { useActiveDomains } from '../../utils/useLiquidityPools'
import { usePool } from '../../utils/usePools'
import { Spinner } from '../Spinner'

type Props = {
assetType?: { class: string; subClass: string }
Expand All @@ -15,6 +17,7 @@ type Props = {
}

export const KeyMetrics = ({ assetType, averageMaturity, loans, poolId }: Props) => {
const pool = usePool(poolId)
const ongoingAssetCount =
loans && [...loans].filter((loan) => loan.status === 'Active' && !loan.outstandingDebt.isZero()).length

Expand Down Expand Up @@ -75,25 +78,81 @@ export const KeyMetrics = ({ assetType, averageMaturity, loans, poolId }: Props)
},
]
: []),
...(activeDomains.data?.length
? [
{
metric: 'Available networks',
value: (
<Shelf gap={1}>
{activeDomains.data.map((domain) => {
const chain = (evmChains as any)[domain.chainId]
return (
<Tooltip
bodyWidth="maxContent"
bodyPadding={0}
body={
<Stack p={1} gap={1} backgroundColor="backgroundSecondary">
<Text variant="heading4">{chain.name} chain</Text>

{
metric: 'Available networks',
value: (
<Shelf gap={1}>
{activeDomains.data?.length ? (
<Tooltip
bodyWidth="maxContent"
bodyPadding={0}
delay={300}
body={
<Stack p={1} gap={1} backgroundColor="backgroundSecondary">
<Text variant="heading4">Centrifuge</Text>
{pool.tranches.length > 1 ? (
pool.tranches.map((tranche) => (
<a target="_blank" rel="noopener noreferrer" href={`${import.meta.env.REACT_APP_SUBSCAN_URL}`}>
<Shelf gap={1} alignItems="center">
<Text variant="body2" color="black">
View {tranche.currency.name.split(' ').at(-1)}
</Text>{' '}
<IconExternalLink color="black" size="iconSmall" />
</Shelf>
</a>
))
) : (
<a target="_blank" rel="noopener noreferrer" href={`${import.meta.env.REACT_APP_SUBSCAN_URL}`}>
<Shelf gap={1} alignItems="center">
<Text variant="body2" color="black">
View transactions
</Text>{' '}
<IconExternalLink color="black" size="iconSmall" />
</Shelf>
</a>
)}
</Stack>
}
>
<NetworkIcon size="iconSmall" network={'centrifuge'} />
</Tooltip>
) : (
<Spinner size="iconSmall" />
)}
{activeDomains.data?.length &&
activeDomains.data
.filter((domain) => domain.isActive)
.map((domain) => {
const chain = (evmChains as any)[domain.chainId]
return (
<Tooltip
delay={300}
bodyWidth="maxContent"
bodyPadding={0}
body={
<Stack p={1} gap={1} backgroundColor="backgroundSecondary">
<Text variant="heading4">{chain.name}</Text>
{pool.tranches.length > 1 ? (
pool.tranches.map((tranche) => (
<a
target="_blank"
rel="noopener noreferrer"
href={`${chain.blockExplorerUrl}token/${domain.trancheTokens[tranche.id]}`}
>
<Shelf gap={1} alignItems="center">
<Text variant="body2" color="black">
View {tranche.currency.name.split(' ').at(-1)}
</Text>{' '}
<IconExternalLink color="black" size="iconSmall" />
</Shelf>
</a>
))
) : (
<a
target="_blank"
rel="noopener noreferrer"
href={`${chain.blockExplorerUrl}address/${domain.managerAddress}`}
href={`${chain.blockExplorerUrl}token/${domain.trancheTokens[pool.tranches[0].id]}`}
>
<Shelf gap={1} alignItems="center">
<Text variant="body2" color="black">
Expand All @@ -102,18 +161,17 @@ export const KeyMetrics = ({ assetType, averageMaturity, loans, poolId }: Props)
<IconExternalLink color="black" size="iconSmall" />
</Shelf>
</a>
</Stack>
}
>
<NetworkIcon size="iconSmall" network={domain.chainId} />
</Tooltip>
)
})}
</Shelf>
),
},
]
: []),
)}
</Stack>
}
>
<NetworkIcon size="iconSmall" network={domain.chainId} />
</Tooltip>
)
})}
</Shelf>
),
},
]

return (
Expand Down
4 changes: 0 additions & 4 deletions centrifuge-app/src/components/PoolOverview/PoolStructure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ export const PoolStructure = ({ numOfTranches, poolId, poolStatus, poolFees }: P
// metric: 'First investment',
// value: firstInvestment ? formatDate(firstInvestment) : '-',
// },
{
metric: 'Available networks',
value: `Centrifuge${deployedLpChains.length ? `, ${deployedLpChains.join(', ')}` : ''}`,
},
...poolFees.map((fee) => {
return {
metric: fee.name,
Expand Down

0 comments on commit 6557cff

Please sign in to comment.