Skip to content

Commit

Permalink
Merge branch 'main' into ff-prod-deploys
Browse files Browse the repository at this point in the history
  • Loading branch information
sophialittlejohn authored Sep 26, 2023
2 parents 115d08d + 0a38bea commit 4c894d4
Showing 8 changed files with 79 additions and 15 deletions.
12 changes: 10 additions & 2 deletions centrifuge-app/src/components/InvestRedeem/InvestRedeem.tsx
Original file line number Diff line number Diff line change
@@ -534,7 +534,11 @@ function InvestForm({ onCancel, hasInvestment, autoFocus, investLabel = 'Invest'
</Stack>
</Stack>
) : changeOrderFormShown ? (
renderInput(() => setChangeOrderFormShown(false))
state.needsPoolCurrencyApproval ? (
renderInput(onCancel, { onClick: actions.approvePoolCurrency, loading: isApproving })
) : (
renderInput(onCancel)
)
) : hasPendingOrder ? (
<PendingOrder
type="invest"
@@ -705,7 +709,11 @@ function RedeemForm({ onCancel, autoFocus }: RedeemFormProps) {
</Stack>
</Stack>
) : changeOrderFormShown ? (
renderInput(() => setChangeOrderFormShown(false))
state.needsTrancheTokenApproval ? (
renderInput(onCancel, { onClick: actions.approveTrancheToken, loading: isApproving })
) : (
renderInput(onCancel)
)
) : hasPendingOrder ? (
<PendingOrder
type="redeem"
3 changes: 2 additions & 1 deletion centrifuge-app/src/components/PoolCard/PoolStatus.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { StatusChip, StatusChipProps } from '@centrifuge/fabric'
import * as React from 'react'

export type PoolStatusKey = 'Maker Pool' | 'Open for investments' | 'Closed'
export type PoolStatusKey = 'Maker Pool' | 'Open for investments' | 'Closed' | 'Upcoming'

const statusColor: { [key in PoolStatusKey]: StatusChipProps['status'] } = {
'Maker Pool': 'ok',
'Open for investments': 'info',
Closed: 'default',
Upcoming: 'default',
}

export function PoolStatus({ status }: { status?: PoolStatusKey }) {
7 changes: 4 additions & 3 deletions centrifuge-app/src/components/PoolCard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Rate } from '@centrifuge/centrifuge-js'
import { Box, Grid, TextWithPlaceholder, Thumbnail } from '@centrifuge/fabric'
import { Box, Grid, Text, TextWithPlaceholder, Thumbnail } from '@centrifuge/fabric'
import Decimal from 'decimal.js-light'
import * as React from 'react'
import { useRouteMatch } from 'react-router'
@@ -70,7 +70,7 @@ export function PoolCard({
variant="body1"
color="textPrimary"
fontWeight={500}
textAlign="right"
textAlign="left"
isLoading={isLoading}
maxLines={1}
>
@@ -82,14 +82,15 @@ export function PoolCard({
})
: '—'}
</Ellipsis>
{status === 'Upcoming' && apr ? <Text variant="body3"> target</Text> : ''}
</TextWithPlaceholder>

<Box>
<PoolStatus status={status} />
</Box>
</Grid>

<Anchor to={`${basePath}/${poolId}`} aria-label="Go to pool details" />
{status === 'Upcoming' ? null : <Anchor to={`${basePath}/${poolId}`} aria-label="Go to pool details" />}
</Root>
)
}
7 changes: 4 additions & 3 deletions centrifuge-app/src/components/PoolFilter/SortButton.tsx
Original file line number Diff line number Diff line change
@@ -9,14 +9,15 @@ export type SortButtonProps = {
label: string
searchKey: SortBy
tooltip?: string
justifySelf?: 'start' | 'end'
}

type Sorting = {
isActive: boolean
direction: string | null
}

export function SortButton({ label, searchKey, tooltip }: SortButtonProps) {
export function SortButton({ label, searchKey, tooltip, justifySelf = 'end' }: SortButtonProps) {
const history = useHistory()
const { pathname, search } = useLocation()

@@ -58,7 +59,7 @@ export function SortButton({ label, searchKey, tooltip }: SortButtonProps) {
: `Sort ${label} ascending`
}
aria-live

Check warning on line 61 in centrifuge-app/src/components/PoolFilter/SortButton.tsx

GitHub Actions / deploy-ff-prod / webapp / build-app

The value for aria-live must be a single token from the following: assertive,off,polite

Check warning on line 61 in centrifuge-app/src/components/PoolFilter/SortButton.tsx

GitHub Actions / deploy-development / webapp / build-app

The value for aria-live must be a single token from the following: assertive,off,polite

Check warning on line 61 in centrifuge-app/src/components/PoolFilter/SortButton.tsx

GitHub Actions / deploy-moonbeam-alpha / webapp / build-app

The value for aria-live must be a single token from the following: assertive,off,polite

Check warning on line 61 in centrifuge-app/src/components/PoolFilter/SortButton.tsx

GitHub Actions / build-app

The value for aria-live must be a single token from the following: assertive,off,polite
style={{ justifySelf: 'end' }}
style={{ justifySelf }}
>
<FilterButton forwardedAs="span" variant="body3">
{label}
@@ -82,7 +83,7 @@ export function SortButton({ label, searchKey, tooltip }: SortButtonProps) {
: `Sort ${label} ascending`
}
aria-live

Check warning on line 85 in centrifuge-app/src/components/PoolFilter/SortButton.tsx

GitHub Actions / deploy-ff-prod / webapp / build-app

The value for aria-live must be a single token from the following: assertive,off,polite

Check warning on line 85 in centrifuge-app/src/components/PoolFilter/SortButton.tsx

GitHub Actions / deploy-development / webapp / build-app

The value for aria-live must be a single token from the following: assertive,off,polite

Check warning on line 85 in centrifuge-app/src/components/PoolFilter/SortButton.tsx

GitHub Actions / deploy-moonbeam-alpha / webapp / build-app

The value for aria-live must be a single token from the following: assertive,off,polite

Check warning on line 85 in centrifuge-app/src/components/PoolFilter/SortButton.tsx

GitHub Actions / build-app

The value for aria-live must be a single token from the following: assertive,off,polite
style={{ justifySelf: 'end' }}
style={{ justifySelf }}
>
{label}

2 changes: 1 addition & 1 deletion centrifuge-app/src/components/PoolFilter/index.tsx
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ export function PoolFilter({ pools }: PoolFilterProps) {
tooltip="Value locked represents the current total value of pool tokens."
/>

<SortButton {...poolFilterConfig.apr} />
<SortButton {...poolFilterConfig.apr} justifySelf="start" />

<FilterMenu
{...poolFilterConfig.poolStatus}
12 changes: 10 additions & 2 deletions centrifuge-app/src/components/PoolList.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import { Box, Stack } from '@centrifuge/fabric'
import * as React from 'react'
import styled from 'styled-components'
import { PoolCard, PoolCardProps } from './PoolCard'
import { PoolStatusKey } from './PoolCard/PoolStatus'

type PoolListProps = {
pools: PoolCardProps[]
isLoading?: boolean
}

const PoolCardBox = styled<typeof Box & { status?: PoolStatusKey }>(Box)`
&:hover {
cursor: ${(props) => (props.status === 'Upcoming' ? 'not-allowed' : 'default')};
}
`

export function PoolList({ pools, isLoading }: PoolListProps) {
return (
<Stack as="ul" role="list" gap={1} minWidth={970} py={1}>
@@ -19,9 +27,9 @@ export function PoolList({ pools, isLoading }: PoolListProps) {
</Box>
))
: pools.map((pool) => (
<Box as="li" key={pool.poolId}>
<PoolCardBox as="li" key={pool.poolId} status={pool.status}>
<PoolCard {...pool} />
</Box>
</PoolCardBox>
))}
</Stack>
)
46 changes: 43 additions & 3 deletions centrifuge-app/src/pages/Pools.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Centrifuge, { Pool, PoolMetadata } from '@centrifuge/centrifuge-js'
import Centrifuge, { Pool, PoolMetadata, Rate } from '@centrifuge/centrifuge-js'
import { useCentrifuge } from '@centrifuge/centrifuge-react'
import { Box, InlineFeedback, Shelf, Stack, Text } from '@centrifuge/fabric'
import * as React from 'react'
@@ -31,15 +31,55 @@ export function PoolsPage() {
function Pools() {
const cent = useCentrifuge()
const { search } = useLocation()
const [listedPools, _listedTokens, metadataIsLoading] = useListedPools()
const [listedPools, , metadataIsLoading] = useListedPools()

const centPools = listedPools.filter(({ id }) => !id.startsWith('0x')) as Pool[]
const centPoolsMetaData: PoolMetaDataPartial[] = useMetadataMulti<PoolMetadata>(
centPools?.map((p) => p.metadata) ?? []
).map((q) => q.data)
const centPoolsMetaDataById = getMetasById(centPools, centPoolsMetaData)

const pools = !!listedPools?.length ? poolsToPoolCardProps(listedPools, centPoolsMetaDataById, cent) : []
const upcomingPools = [
{
apr: Rate.fromApr(0.08),
assetClass: 'Real Estate Bridge Loans',
iconUri: 'https://storage.googleapis.com/tinlake/pool-media/new-silver-2/icon.svg',
name: 'New Silver Series 3',
status: 'Upcoming' as PoolStatusKey,
},
{
apr: Rate.fromApr(0.15),
assetClass: 'Voluntary Carbon Offsets',
iconUri: 'https://storage.googleapis.com/tinlake/pool-media/flowcarbon-1/FlowcarbonBadge.svg',
name: 'Flowcarbon Nature Offsets Series 2',
status: 'Upcoming' as PoolStatusKey,
},
]

const pools = !!listedPools?.length
? [
...upcomingPools,
...poolsToPoolCardProps(listedPools, centPoolsMetaDataById, cent).map((pool) => {
if (pool.name?.includes('Anemoy Liquid Treasury Fund')) {
return {
...pool,
status: 'Upcoming' as PoolStatusKey,
apr: Rate.fromApr(0.05),
}
}

return pool
}),
].sort((a, b) => {
if (a.status === 'Upcoming') {
return -1
}
if (b.status === 'Upcoming') {
return 1
}
return 0
})
: [...upcomingPools]
const filteredPools = !!pools?.length ? filterPools(pools, new URLSearchParams(search)) : []

if (!listedPools.length) {
5 changes: 5 additions & 0 deletions centrifuge-js/src/modules/pools.ts
Original file line number Diff line number Diff line change
@@ -1623,6 +1623,11 @@ export function getPoolsModule(inst: Centrifuge) {
const epochExecution = epochExecutionMap[poolId]
const currency = findCurrency(currencies, pool.currency)!

// TODO: remove, temporary UI fix
if (currency.symbol === 'LpEthUSDC') {
currency.symbol = 'USDC'
}

const poolValue = new CurrencyBalance(
pool.tranches.tranches.reduce((prev: BN, tranche: TrancheDetailsData) => {
return new BN(prev.add(new BN(hexToBN(tranche.debt))).add(new BN(hexToBN(tranche.reserve))))

0 comments on commit 4c894d4

Please sign in to comment.