Skip to content

Commit

Permalink
Merge branch 'main' into bump-cent-js-version
Browse files Browse the repository at this point in the history
  • Loading branch information
sophialittlejohn authored Aug 16, 2024
2 parents 5f8163f + 912403e commit 26937b2
Show file tree
Hide file tree
Showing 19 changed files with 261 additions and 152 deletions.
6 changes: 3 additions & 3 deletions centrifuge-app/src/components/Identity.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isSameAddress } from '@centrifuge/centrifuge-js'
import { isEvm, isSameAddress } from '@centrifuge/centrifuge-js'
import { useCentrifugeUtils, useWallet } from '@centrifuge/centrifuge-react'
import { Flex, Shelf, Text, TextProps } from '@centrifuge/fabric'
import Identicon from '@polkadot/react-identicon'
Expand Down Expand Up @@ -31,7 +31,7 @@ export function Identity({ showIcon, address, clickToCopy, labelForConnectedAddr

const addr = utils.formatAddress(address)
const isMe = React.useMemo(() => isSameAddress(addr, myAddress), [addr, myAddress])
const truncated = truncate(utils.formatAddress(address))
const truncated = isEvm(address) ? truncate(address.substring(0, 42)) : truncate(utils.formatAddress(address))
const display = identity?.display || truncated
const meLabel =
!isMe || !labelForConnectedAddress
Expand Down Expand Up @@ -59,7 +59,7 @@ export function Identity({ showIcon, address, clickToCopy, labelForConnectedAddr
return (
<Shelf gap={2}>
<IdenticonWrapper>
<Identicon value={address} size={24} theme="polkadot" />
<Identicon value={address} size={24} theme={isEvm(address) ? 'ethereum' : 'polkadot'} />
</IdenticonWrapper>
{label}
</Shelf>
Expand Down
38 changes: 35 additions & 3 deletions centrifuge-app/src/components/PoolOverview/TransactionHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type Row = {
toAssetName?: string
amount: CurrencyBalance | undefined
hash: string
netFlow?: 'positive' | 'negative' | 'neutral'
}

const getTransactionTypeStatus = (type: string): 'default' | 'info' | 'ok' | 'warning' | 'critical' => {
Expand Down Expand Up @@ -60,38 +61,65 @@ export const TransactionHistoryTable = ({
}) => {
const basePath = useBasePath('/pools')
const getLabelAndAmount = (transaction: AssetTransaction) => {
const netFlow = activeAssetId
? activeAssetId === transaction.toAsset?.id.split('-')[1]
? 'positive'
: 'negative'
: 'neutral'

if (transaction.type === 'CASH_TRANSFER') {
return {
label: 'Cash transfer',
amount: transaction.amount,
netFlow,
}
}

if (transaction.type === 'DEPOSIT_FROM_INVESTMENTS') {
return {
label: 'Deposit from investments',
amount: transaction.amount,
netFlow: 'positive',
}
}

if (transaction.type === 'WITHDRAWAL_FOR_REDEMPTIONS') {
return {
label: 'Withdrawal for redemptions',
amount: transaction.amount,
netFlow: 'negative',
}
}

if (transaction.type === 'WITHDRAWAL_FOR_FEES') {
return {
label: 'Withdrawal for fees',
amount: transaction.amount,
netFlow: 'negative',
}
}

if (transaction.type === 'BORROWED') {
return {
label: 'Purchase',
amount: transaction.amount,
netFlow,
}
}

if (transaction.type === 'INCREASE_DEBT') {
return {
label: 'Correction',
amount: transaction.amount,
netFlow: 'positive',
}
}

if (transaction.type === 'DECREASE_DEBT') {
return {
label: 'Correction',
amount: transaction.amount,
netFlow: 'negative',
}
}

Expand All @@ -107,6 +135,7 @@ export const TransactionHistoryTable = ({
new BN(transaction.principalAmount || 0).add(new BN(transaction.interestAmount || 0)),
transaction.principalAmount!.decimals
),
netFlow,
}
}

Expand All @@ -118,12 +147,14 @@ export const TransactionHistoryTable = ({
return {
label: 'Interest payment',
amount: transaction.interestAmount,
netFlow,
}
}

return {
label: 'Principal payment',
amount: transaction.principalAmount,
netFlow,
}
}

Expand Down Expand Up @@ -167,9 +198,10 @@ export const TransactionHistoryTable = ({

const tableData =
transformedTransactions.slice(0, preview ? 8 : Infinity).map((transaction) => {
const { label, amount } = getLabelAndAmount(transaction)
const { label, amount, netFlow } = getLabelAndAmount(transaction)
return {
activeAssetId,
netFlow,
type: label,
transactionDate: transaction.timestamp,
assetId: transaction.asset.id,
Expand Down Expand Up @@ -235,9 +267,9 @@ export const TransactionHistoryTable = ({
{
align: 'right',
header: <SortableTableHeader label="Amount" />,
cell: ({ amount }: Row) => (
cell: ({ amount, netFlow }: Row) => (
<Text as="span" variant="body3">
{amount ? formatBalance(amount, 'USD', 2, 2) : ''}
{amount ? `${activeAssetId && netFlow === 'negative' ? '-' : ''}${formatBalance(amount, 'USD', 2, 2)}` : ''}
</Text>
),
sortKey: 'amount',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const status = {
DEPOSIT_FROM_INVESTMENTS: 'default',
WITHDRAWAL_FOR_REDEMPTIONS: 'default',
WITHDRAWAL_FOR_FEES: 'default',
INCREASE_DEBT: 'default',
DECREASE_DEBT: 'default',
} as const

export function TransactionTypeChip(props: TransactionTypeProps) {
Expand Down
20 changes: 20 additions & 0 deletions centrifuge-app/src/components/Report/TokenPrice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,26 @@ export function TokenPrice({ pool }: { pool: Pool }) {
formatter: (v: any) => formatPercentage(v * 100, true, {}, 2),
}))
: []),
...(!!showTokenYields
? [
{
name: '7d APY',
value: poolStates?.map(() => '' as any) || [],
heading: false,
},
]
: []),
...(!!showTokenYields
? pool?.tranches
.slice()
.reverse()
.map((token) => ({
name: `\u00A0 \u00A0 ${token.currency.displayName} token`,
value: poolStates?.map((state) => state.tranches[token.id].yield7DaysAnnualized.toFloat()) || [],
heading: false,
formatter: (v: any) => formatPercentage(v * 100, true, {}, 2),
}))
: []),
...(!!showTokenYields
? [
{
Expand Down
2 changes: 2 additions & 0 deletions centrifuge-app/src/components/Report/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ const assetTransactionTypes: {
DEPOSIT_FROM_INVESTMENTS: 'Deposit from investments',
WITHDRAWAL_FOR_REDEMPTIONS: 'Withdrawal for redemptions',
WITHDRAWAL_FOR_FEES: 'Withdrawal for fees',
INCREASE_DEBT: 'Correction (increase)',
DECREASE_DEBT: 'Correction (decrease)',
}

export function formatAssetTransactionType(type: AssetTransactionType) {
Expand Down
4 changes: 4 additions & 0 deletions centrifuge-app/src/components/Tooltips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@ export const tooltipText = {
label: 'Available balance',
body: 'Unlimited because this is a virtual accounting process.',
},
linearAccrual: {
label: 'Linear accrual',
body: 'If enabled, the price of the asset is updated continuously based on linear accrual from the latest known market price to the value at maturity.',
},
}

export type TooltipsProps = {
Expand Down
57 changes: 9 additions & 48 deletions centrifuge-app/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import assetHubLogo from '@centrifuge/fabric/assets/logos/assethub.svg'
import baseLogo from '@centrifuge/fabric/assets/logos/base.svg'
import celoLogo from '@centrifuge/fabric/assets/logos/celo.svg'
import ethereumLogo from '@centrifuge/fabric/assets/logos/ethereum.svg'
import goerliLogo from '@centrifuge/fabric/assets/logos/goerli.svg'
import sepoliaLogo from '@centrifuge/fabric/assets/logos/sepolia.png'
import * as React from 'react'
import { DefaultTheme } from 'styled-components'
Expand Down Expand Up @@ -121,32 +120,20 @@ const CENTRIFUGE: EnvironmentConfig = {
},
poolCreationType,
}

const ethNetwork = import.meta.env.REACT_APP_TINLAKE_NETWORK || 'mainnet'

const alchemyKey = import.meta.env.REACT_APP_ALCHEMY_KEY

const goerliConfig = {
rpcUrl: `https://eth-sepolia.g.alchemy.com/v2/${alchemyKey}`,
chainId: 5,
poolRegistryAddress: '0x5ba1e12693dc8f9c48aad8770482f4739beed696',
tinlakeUrl: 'https://goerli.staging.tinlake.cntrfg.com/',
poolsHash: 'QmQe9NTiVJnVcb4srw6sBpHefhYieubR7v3J8ZriULQ8vB', // TODO: add registry to config and fetch poolHash
blockExplorerUrl: 'https://goerli.etherscan.io',
}
const mainnetConfig = {
export const ethConfig = {
rpcUrl: `https://eth-mainnet.g.alchemy.com/v2/${alchemyKey}`,
chainId: 1,
poolRegistryAddress: '0x5ba1e12693dc8f9c48aad8770482f4739beed696',
poolRegistryAddress: '0xcA11bde05977b3631167028862bE2a173976CA11',
tinlakeUrl: 'https://tinlake.centrifuge.io',
poolsHash: 'QmaMA1VYSKuuYhBcQCyf5Ek4VoiiEG6oLGp3iGbsQPGpkS', // TODO: add registry to config and fetch poolHash
blockExplorerUrl: 'https://etherscan.io',
}

export const ethConfig = {
network: ethNetwork,
multicallContractAddress: '0x5ba1e12693dc8f9c48aad8770482f4739beed696', // Same for all networks
multicallContractAddress: '0xcA11bde05977b3631167028862bE2a173976CA11', // Same for all networks
remarkerAddress: '0x3E39db43035981c2C31F7Ffa4392f25231bE4477', // Same for all networks
...(ethNetwork === 'goerli' ? goerliConfig : mainnetConfig),
}

export const config = import.meta.env.REACT_APP_NETWORK === 'altair' ? ALTAIR : CENTRIFUGE
Expand All @@ -160,8 +147,6 @@ export const parachainIcons: Record<number, string> = {
[assetHubChainId]: assetHubLogo,
}

const infuraKey = import.meta.env.REACT_APP_INFURA_KEY

export const evmChains: EvmChains = {
1: {
name: 'Ethereum',
Expand All @@ -175,18 +160,6 @@ export const evmChains: EvmChains = {
iconUrl: ethereumLogo,
isTestnet: false,
},
5: {
name: 'Ethereum Goerli',
nativeCurrency: {
name: 'Görli Ether',
symbol: 'görETH',
decimals: 18,
},
blockExplorerUrl: 'https://goerli.etherscan.io/',
urls: [`https://eth-sepolia.g.alchemy.com/v2/${alchemyKey}`],
iconUrl: goerliLogo,
isTestnet: true,
},
11155111: {
name: 'Ethereum Sepolia',
nativeCurrency: { name: 'Sepolia Ether', symbol: 'sepETH', decimals: 18 },
Expand All @@ -203,11 +176,11 @@ export const evmChains: EvmChains = {
iconUrl: baseLogo,
isTestnet: false,
},
84531: {
name: 'Base Goerli',
nativeCurrency: { name: 'Base Goerli Ether', symbol: 'gbETH', decimals: 18 },
blockExplorerUrl: 'https://goerli.basescan.org/',
urls: [`https://goerli.base.org`],
84532: {
name: 'Base Sepolia',
nativeCurrency: { name: 'Base Sepolia Ether', symbol: 'sbETH', decimals: 18 },
blockExplorerUrl: 'https://sepolia.basescan.org/',
urls: [`https://sepolia.base.org`],
iconUrl: baseLogo,
isTestnet: true,
},
Expand All @@ -223,18 +196,6 @@ export const evmChains: EvmChains = {
iconUrl: arbitrumLogo,
isTestnet: false,
},
421613: {
name: 'Arbitrum Goerli',
nativeCurrency: {
name: 'Ether',
symbol: 'ETH',
decimals: 18,
},
blockExplorerUrl: 'https://goerli.arbiscan.io/',
urls: [`https://arbitrum-goerli.infura.io/v3/${infuraKey}`],
iconUrl: arbitrumLogo,
isTestnet: true,
},
42220: {
name: 'Celo',
nativeCurrency: {
Expand Down
2 changes: 2 additions & 0 deletions centrifuge-app/src/pages/IssuerPool/Configuration/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { LayoutBase } from '../../../components/LayoutBase'
import { LoadBoundary } from '../../../components/LoadBoundary'
import { useCanBorrow, usePoolAdmin } from '../../../utils/usePermissions'
import { IssuerPoolHeader } from '../Header'
import { OnboardingSettings } from '../Investors/OnboardingSettings'
import { Details } from './Details'
import { EpochAndTranches } from './EpochAndTranches'
import { Issuer } from './Issuer'
Expand Down Expand Up @@ -39,6 +40,7 @@ function IssuerPoolConfiguration() {
<Issuer />
<EpochAndTranches />
<LoanTemplates />
{isPoolAdmin && <OnboardingSettings />}
{editPoolConfig && <PoolConfig poolId={poolId} />}
</>
)}
Expand Down
Loading

0 comments on commit 26937b2

Please sign in to comment.