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

Create pool redesign - feature branch #2537

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions centrifuge-app/src/components/LayoutBase/styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ export const ContentWrapper = styled.div`

@media (min-width: ${({ theme }) => theme.breakpoints['M']}) and (max-width: ${({ theme }) =>
theme.breakpoints['L']}) {
margin-left: 7vw;
width: calc(100% - 7vw);
margin-left: 6vw;
width: calc(100% - 6vw);
margin-top: 10px;
}

Expand Down
1 change: 1 addition & 0 deletions centrifuge-app/src/components/LoanList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ export function LoanList({ loans, snapshots }: Props) {
</Text>
}
onChange={(e) => setShowRepaid(!showRepaid)}
variant="square"
/>
</Box>
<Button
Expand Down
14 changes: 10 additions & 4 deletions centrifuge-app/src/components/Menu/IssuerMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Box, IconChevronDown, IconChevronRight, IconUser, Menu as Panel, Stack } from '@centrifuge/fabric'
import * as React from 'react'
import { useMatch } from 'react-router'
import { useTheme } from 'styled-components'
import styled, { useTheme } from 'styled-components'
import { useIsAboveBreakpoint } from '../../utils/useIsAboveBreakpoint'
import { Toggle } from './Toggle'

Expand All @@ -11,6 +11,12 @@ type IssuerMenuProps = {
children?: React.ReactNode
}

const StyledPanel = styled(Panel)`
& > div {
max-height: 50vh;
}
`

export function IssuerMenu({ defaultOpen = false, children }: IssuerMenuProps) {
const match = useMatch('/issuer/*')
const isActive = !!match
Expand Down Expand Up @@ -56,9 +62,9 @@ export function IssuerMenu({ defaultOpen = false, children }: IssuerMenuProps) {
Issuer
{isLarge &&
(open ? (
<IconChevronDown size={['iconMedium', 'iconMedium', 'iconSmall']} />
<IconChevronDown size={['iconMedium', 'iconMedium', 'iconSmall']} color="white" />
) : (
<IconChevronRight size={['iconMedium', 'iconMedium', 'iconSmall']} />
<IconChevronRight size={['iconMedium', 'iconMedium', 'iconSmall']} color="white" />
))}
</Toggle>

Expand All @@ -81,7 +87,7 @@ export function IssuerMenu({ defaultOpen = false, children }: IssuerMenuProps) {
{children}
</Stack>
) : (
<Panel backgroundColor={theme.colors.backgroundInverted}>{children}</Panel>
<StyledPanel backgroundColor={theme.colors.backgroundInverted}>{children}</StyledPanel>
)}
</Box>
</Box>
Expand Down
2 changes: 1 addition & 1 deletion centrifuge-app/src/components/Menu/PoolLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function PoolLink({ pool, path = 'issuer' }: PoolLinkProps) {
<Root
forwardedAs={Link}
to={to}
variant="interactive1"
variant="body2"
isActive={match && pool.id === match.params.pid}
onMouseOver={() => prefetchRoute(to)}
>
Expand Down
2 changes: 1 addition & 1 deletion centrifuge-app/src/components/Menu/Toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const Toggle = styled(Text)<{ isActive?: boolean; stacked?: boolean }>`
width: 100%;
grid-template-columns: ${({ stacked, theme }) =>
stacked ? '1fr' : `${theme.sizes.iconSmall}px 1fr ${theme.sizes.iconSmall}px`};
color: ${({ isActive, theme }) => (isActive ? theme.colors.textGold : theme.colors.textInverted)};
color: ${({ theme }) => theme.colors.textInverted};
border-radius: 4px;
background-color: ${({ isActive }) => (isActive ? LIGHT_BACKGROUND : 'transparent')};

Expand Down
28 changes: 26 additions & 2 deletions centrifuge-app/src/components/Menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import {
IconGlobe,
IconInvestments,
IconNft,
IconPlus,
IconSwitch,
IconWallet,
MenuItemGroup,
Shelf,
Stack,
} from '@centrifuge/fabric'
import styled from 'styled-components'
import { config } from '../../config'
import { useAddress } from '../../utils/useAddress'
import { useIsAboveBreakpoint } from '../../utils/useIsAboveBreakpoint'
Expand All @@ -23,6 +25,28 @@ import { NavManagementMenu } from './NavManagementMenu'
import { PageLink } from './PageLink'
import { PoolLink } from './PoolLink'

const COLOR = '#7C8085'

const StyledRouterLinkButton = styled(RouterLinkButton)`
width: 100%;
& > span {
background-color: ${COLOR};
border-color: transparent;
color: white;
margin-bottom: 20px;

&:hover {
box-shadow: 0px 0px 0px 3px #7c8085b3;
background-color: ${COLOR};
color: white;
}

&:active {
border-color: transparent;
}
}
`

export function Menu() {
const pools = usePoolsThatAnyConnectedAddressHasPermissionsFor() || []
const isLarge = useIsAboveBreakpoint('L')
Expand Down Expand Up @@ -130,8 +154,8 @@ export function Menu() {

function CreatePool() {
return (
<RouterLinkButton to="/issuer/create-pool" small>
<StyledRouterLinkButton icon={<IconPlus size="iconSmall" />} to="/issuer/create-pool" small variant="inverted">
Create pool
</RouterLinkButton>
</StyledRouterLinkButton>
)
}
2 changes: 1 addition & 1 deletion centrifuge-app/src/components/PoolCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export function PoolCard({
}
})
.reverse()
}, [isTinlakePool, metaData?.tranches, tinlakeKey, tranches])
}, [isTinlakePool, metaData?.tranches, tinlakeKey, tranches, createdAt, poolId])

return (
<RouterTextLink to={`${poolId}`} style={{ textDecoration: 'none' }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ export const TrancheTokenCards = ({
return 'mezzanine'
}

const getTarget = (tranche: Token) =>
(isTinlakePool && tranche.seniority === 0) || poolId === DYF_POOL_ID || poolId === NS3_POOL_ID

const columns = useMemo(() => {
return [
{
Expand Down Expand Up @@ -121,6 +118,8 @@ export const TrancheTokenCards = ({
}, [pool.tranches, metadata, poolId, pool?.currency.symbol])

const dataTable = useMemo(() => {
const getTarget = (tranche: Token) =>
(isTinlakePool && tranche.seniority === 0) || poolId === DYF_POOL_ID || poolId === NS3_POOL_ID
return trancheTokens.map((tranche) => {
const calculateApy = (trancheToken: Token) => {
if (isTinlakePool && getTrancheText(trancheToken) === 'senior') return formatPercentage(trancheToken.apy)
Expand All @@ -145,7 +144,7 @@ export const TrancheTokenCards = ({
isTarget: getTarget(tranche),
}
})
}, [trancheTokens, getTarget])
}, [trancheTokens, daysSinceCreation, isTinlakePool, poolId])

return (
<Shelf gap={3}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ export const TransactionHistoryTable = ({
View all
</AnchorButton>
)}
{transactions?.length && (
{transactions?.length ? (
<AnchorButton
href={csvUrl}
download={`pool-transaction-history-${poolId}.csv`}
Expand All @@ -304,7 +304,7 @@ export const TransactionHistoryTable = ({
>
Download
</AnchorButton>
)}
) : null}
</Shelf>
</Shelf>
<Box overflow="auto">
Expand Down
44 changes: 12 additions & 32 deletions centrifuge-app/src/components/Report/AssetTransactions.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Pool } from '@centrifuge/centrifuge-js'
import { formatBalance, useGetExplorerUrl } from '@centrifuge/centrifuge-react'
import { useGetExplorerUrl } from '@centrifuge/centrifuge-react'
import { Box, IconAnchor, IconExternalLink, Text } from '@centrifuge/fabric'
import * as React from 'react'
import { formatBalance } from '../../../src/utils/formatting'
import { formatDate } from '../../utils/date'
import { getCSVDownloadUrl } from '../../utils/getCSVDownloadUrl'
import { useAssetTransactions } from '../../utils/usePools'
Expand All @@ -21,53 +22,35 @@ export function AssetTransactions({ pool }: { pool: Pool }) {

const columnConfig = [
{
header: 'Asset ID',
align: 'center',
csvOnly: false,
formatter: noop,
width: '80px',
},
{
header: 'Asset name',
align: 'left',
csvOnly: false,
formatter: noop,
},
{
header: 'Epoch',
align: 'center',
csvOnly: false,
formatter: noop,
},
{
header: 'Date',
header: 'Transaction date',
align: 'left',
csvOnly: false,
formatter: formatDate,
},
{
header: 'Transaction type',
header: 'Transaction',
align: 'left',
csvOnly: false,
formatter: noop,
width: '38%',
},
{
header: 'Currency amount',
header: 'Amount',
align: 'left',
csvOnly: false,
formatter: (v: any) => (typeof v === 'number' ? formatBalance(v, pool.currency.symbol, 2) : '-'),
},
{
header: 'Currency',
align: 'left',
csvOnly: true,
header: 'Epoch',
align: 'center',
csvOnly: false,
formatter: noop,
},
{
header: 'Transaction',
header: 'View transaction',
align: 'center',
csvOnly: false,
width: '80px',
width: '120px',
formatter: (v: any) => (
<IconAnchor
href={explorer.tx(v)}
Expand All @@ -90,13 +73,10 @@ export function AssetTransactions({ pool }: { pool: Pool }) {
?.map((tx) => ({
name: '',
value: [
tx.asset.id.split('-').at(-1)!,
tx.asset.name || `Asset ${tx.asset.id.split('-').at(-1)!}`,
tx.epochId.split('-').at(-1)!,
tx.timestamp.toISOString(),
formatAssetTransactionType(tx.type),
tx.amount?.toFloat() ?? '',
pool.currency.symbol,
tx.epochId.split('-').at(-1)!,
tx.hash,
],
heading: false,
Expand Down
32 changes: 32 additions & 0 deletions centrifuge-app/src/components/Tooltips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,38 @@ export const tooltipText = {
label: 'Total NAV',
body: 'Total nav minus accrued fees',
},
oneTranche: {
label: '',
body: 'This pool will only have one investment class where all investors share the same level of risk and return.',
},
twoTranches: {
label: '',
body: 'This pool will have two classes. Senior tranche which has priority in receiving returns. And Junior tranche which is the last to receive returns (after Senior tranche obligations are met) but receives higher yield as compensation for the higher risk.',
},
threeTranches: {
label: '',
body: 'This pool will have three classes. Senior tranche is the safest tranche with priority in repayment. Mezzanine tranche has intermediate risk and receives payment after Senior tranche obligations are met. Junior tranche which only receives returns after both Senior and Mezzanine tranches are paid.',
},
singleMultisign: {
label: '',
body: 'Setup a wallet where only one private key is required to authorise changes to the pool configuration.',
},
multiMultisign: {
label: '',
body: 'Setup a wallet that requires multiple private keys to authorise changes to the pool configuration.',
},
centrifugeOnboarding: {
label: '',
body: 'Investors will go through the Centrifuge onboarding provider, Shuftipro, before they can invest in your pool.',
},
externalOnboarding: {
label: '',
body: 'You can select the provider you want to KYC/onboard your investors.',
},
noneOnboarding: {
label: '',
body: 'You can directly whitelist the addresses that can invest in the pool.',
},
}

export type TooltipsProps = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useWallet } from '@centrifuge/centrifuge-react'
import { Button } from '@centrifuge/fabric'
import { useFormikContext } from 'formik'
import { CreatePoolValues } from '.'
import { PageSection } from '../../components/PageSection'
import { MultisigForm } from '../IssuerPool/Access/MultisigForm'
import { CreatePoolValues } from './types'

export function AdminMultisigSection() {
const form = useFormikContext<CreatePoolValues>()
Expand Down
Loading
Loading