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 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d2f23ff
Fabric changes
kattylucy Nov 21, 2024
d9aae6c
Type updates
kattylucy Nov 21, 2024
560a6aa
Add new create pool index
kattylucy Nov 21, 2024
21142b1
Add pool structure section
kattylucy Nov 21, 2024
b53f4bc
Fix sidebar
kattylucy Nov 21, 2024
88c3425
Add pool details section
kattylucy Nov 21, 2024
f04a656
Add pool setup section
kattylucy Nov 21, 2024
c4de95b
Minor UI fix
kattylucy Nov 21, 2024
1564445
Pool structure - create pool (#2543)
kattylucy Nov 27, 2024
aeebecd
Create pool - functionality (#2545)
kattylucy Dec 4, 2024
fab7442
Create pool bugs and fixes (#2550)
kattylucy Dec 4, 2024
35f034e
Update fabric/src/theme/tokens/colors.ts
kattylucy Dec 5, 2024
a658715
Update centrifuge-app/src/pages/IssuerCreatePool/IssuerCategories.tsx
kattylucy Dec 5, 2024
a2c5b41
Update centrifuge-app/src/pages/IssuerCreatePool/PoolSetupSection.tsx
kattylucy Dec 5, 2024
c95e187
Add feedback
kattylucy Dec 5, 2024
8d23169
feedback
kattylucy Dec 5, 2024
414cb8c
Feedback changes
kattylucy Dec 9, 2024
1465802
Add feeback
kattylucy Dec 10, 2024
4c58801
Fix tranches apy
kattylucy Dec 11, 2024
b000a41
Add feeback
kattylucy Dec 12, 2024
7c64118
Fix placeholder color
kattylucy Dec 12, 2024
7e81904
Replace file upload with image upload
kattylucy Dec 12, 2024
77cda8b
Bug fixes
kattylucy Dec 12, 2024
d11affd
Code review feedback
kattylucy Dec 13, 2024
18794ba
Add jay's feedback and cleanup
kattylucy Dec 13, 2024
9788fdd
Update centrifuge-app/src/components/Menu/IssuerMenu.tsx
kattylucy Dec 16, 2024
f997967
Update centrifuge-app/src/pages/IssuerCreatePool/validate.ts
kattylucy Dec 16, 2024
e54157b
Update centrifuge-app/src/pages/IssuerCreatePool/validate.ts
kattylucy Dec 16, 2024
12542b9
Rebase issue
kattylucy Dec 17, 2024
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
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="textInverted" />
) : (
<IconChevronRight size={['iconMedium', 'iconMedium', 'iconSmall']} />
<IconChevronRight size={['iconMedium', 'iconMedium', 'iconSmall']} color="textInverted" />
))}
</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
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
48 changes: 48 additions & 0 deletions centrifuge-app/src/pages/IssuerCreatePool/FormAddressInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { evmToSubstrateAddress } from '@centrifuge/centrifuge-js'
import { useCentrifugeUtils } from '@centrifuge/centrifuge-react'
import { TextInput } from '@centrifuge/fabric'
import { useField } from 'formik'
import React from 'react'
import { FieldWithErrorMessage } from '../../../src/components/FieldWithErrorMessage'
import { isEvmAddress } from '../../../src/utils/address'
import { truncate } from '../../utils/web3'

interface FormAddressInputProps {
name: string
chainId?: number
placeholder?: string
}

export const FormAddressInput = ({ name, chainId, placeholder }: FormAddressInputProps) => {
const [field, meta, helpers] = useField(name)
const utils = useCentrifugeUtils()

let truncated: string | undefined
try {
truncated = truncate(utils.formatAddress(field.value))
} catch (e) {
truncated = undefined
}

function handleBlur() {
helpers.setTouched(true)

if (!truncated || meta.error) {
helpers.setError('Invalid address')
return
}

helpers.setValue(isEvmAddress(field.value) ? evmToSubstrateAddress(field.value, chainId ?? 0) : field.value)
}

return (
<FieldWithErrorMessage
{...field}
placeholder={placeholder ?? 'Type address...'}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => helpers.setValue(e.target.value)}
onBlur={handleBlur}
errorMessage={meta.touched && meta.error ? meta.error : undefined}
as={TextInput}
/>
)
}
113 changes: 113 additions & 0 deletions centrifuge-app/src/pages/IssuerCreatePool/IssuerCategories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import { PoolMetadataInput } from '@centrifuge/centrifuge-js'
import { Box, Grid, IconButton, IconTrash, Select, Text, TextInput } from '@centrifuge/fabric'
import { Field, FieldArray, FieldProps, useFormikContext } from 'formik'
import { FieldWithErrorMessage } from '../../../src/components/FieldWithErrorMessage'
import { AddButton } from './PoolDetailsSection'
import { StyledGrid } from './PoolStructureSection'

const PROVIDERS = [
{ label: 'Please select...', value: '' },
{ label: 'Fund admin', value: 'fundAdmin' },
{ label: 'Trustee', value: 'trustee' },
{ label: 'Pricing oracle provider', value: 'pricingOracleProvider' },
{ label: 'Auditor', value: 'auditor' },
{ label: 'Custodian', value: 'custodian' },
{ label: 'Investment manager', value: 'investmentManager' },
{ label: 'Sub-advisor', value: 'subadvisor' },
{ label: 'Historical default rate', value: 'historicalDefaultRate' },
{ label: 'Other', value: 'other' },
]

export const LabelWithDeleteButton = ({
onDelete,
hideButton,
label,
}: {
onDelete: () => void
hideButton: boolean
label: string
}) => {
return (
<Box display="flex" justifyContent="space-between" alignItems="center">
<Text variant="heading4">{label}</Text>
{!hideButton && (
<IconButton onClick={onDelete}>
<IconTrash color="textSecondary" />
</IconButton>
)}
</Box>
)
}

export const IssuerCategoriesSection = () => {
const form = useFormikContext<PoolMetadataInput>()
return (
<Box mt={4} mb={3}>
<Text variant="heading2">Service providers</Text>
<StyledGrid gridTemplateColumns={['1fr', '1fr 1fr']} mt={3}>
<FieldArray name="issuerCategories">
{({ push, remove }) => (
<>
{form.values.issuerCategories.map((category, index) => (
<>
<Grid gridTemplateColumns={['1fr', category.type === 'other' ? '1fr 1fr' : '1fr']} gap={2}>
<Field name={`issuerCategories.${index}.type`}>
{({ field, meta }: FieldProps) => (
<Select
name={field.name}
label="Type"
onChange={(event) => form.setFieldValue(field.name, event.target.value)}
onBlur={field.onBlur}
value={field.value}
options={PROVIDERS}
errorMessage={meta.touched && meta.error ? meta.error : undefined}
/>
)}
</Field>
{category.type === 'other' && (
<Field name={`issuerCategories.${index}.description`}>
{({ field, meta }: FieldProps) => (
<FieldWithErrorMessage
{...field}
label="Description"
placeholder="Type here..."
maxLength={100}
as={TextInput}
errorMessage={meta.touched && meta.error ? meta.error : undefined}
onBlur={field.onBlur}
/>
)}
</Field>
)}
</Grid>
<Field name={`issuerCategories.${index}.value`}>
{({ field, meta }: FieldProps) => (
<FieldWithErrorMessage
{...field}
label={
<LabelWithDeleteButton
onDelete={() => remove(index)}
hideButton={form.values.issuerCategories.length === 1}
label="Name of provider"
/>
}
placeholder="Type here..."
maxLength={100}
errorMessage={meta.touched && meta.error ? meta.error : undefined}
onBlur={field.onBlur}
as={TextInput}
/>
)}
</Field>
</>
))}
<Box gridColumn="span 2">
<AddButton onClick={() => push({ type: '', value: '' })} />
</Box>
</>
)}
</FieldArray>
</StyledGrid>
</Box>
)
}
Loading
Loading