Skip to content

Commit

Permalink
Fix linter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
kattylucy committed Oct 9, 2024
1 parent b636cf7 commit 178af27
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 73 deletions.
14 changes: 6 additions & 8 deletions centrifuge-app/src/components/Charts/PoolPerformanceChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ function PoolPerformanceChart() {
const [range, setRange] = React.useState<(typeof rangeFilters)[number]>({ value: 'all', label: 'All' })
const rangeNumber = getRangeNumber(range.value, poolAge) ?? 100

const isSingleTranche = pool?.tranches.length === 1

// querying chain for more accurate data, since data for today from subquery is not necessarily up to date
const todayAssetValue = pool?.nav.total.toDecimal().toNumber() || 0
const todayPrice = pool?.tranches
Expand Down Expand Up @@ -169,7 +167,7 @@ function PoolPerformanceChart() {
isToday: false,
}
}) || [],
[isSingleTranche, truncatedPoolStates, todayAssetValue, todayPrice, pool, range]
[truncatedPoolStates, todayAssetValue, pool, range]
)

const todayData = data.find((day) => day.isToday)
Expand Down Expand Up @@ -207,7 +205,7 @@ function PoolPerformanceChart() {
})

return getCSVDownloadUrl(filteredData as any)
}, [chartData, selectedTabIndex])
}, [chartData])

if (truncatedPoolStates && truncatedPoolStates?.length < 1 && poolAge > 0)
return <Text variant="body2">No data available</Text>
Expand Down Expand Up @@ -422,14 +420,14 @@ function CustomLegend({
{
color: 'textGold',
label: 'Junior token price',
value: data.juniorTokenPrice ?? 0,
value: formatBalance(data.juniorTokenPrice ?? 0, '', 3),
type: 'singleTrancheTokenPrice',
show: true,
},
{
color: 'textPrimary',
label: 'Senior token price',
value: data.seniorTokenPrice ?? 0,
value: formatBalance(data.seniorTokenPrice ?? 0, '', 3),
type: 'singleTrancheTokenPrice',
show: !!data.seniorTokenPrice,
},
Expand All @@ -441,7 +439,7 @@ function CustomLegend({
color: 'textGold',
label: 'Junior APY',
value: formatPercentage(juniorAPY),
show: true,
show: !!data.juniorAPY,
},
{
color: 'textPrimary',
Expand All @@ -463,7 +461,7 @@ function CustomLegend({
<Box display="flex" justifyContent="space-between" alignItems="center">
<Box display="flex" justifyContent="space-evenly">
{graphData.map((item: GraphDataItem, index: number) => {
if (!item.show) return
if (!item.show) return null

const hasType = (item: GraphDataItem): item is GraphDataItemWithType => {
return (item as GraphDataItemWithType).type !== undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,12 @@ const TokenPriceChart = React.memo(function TokenPriceChart({
}) {
const pool = usePool(poolId)

const apy = {
'30days': 'yield30DaysAnnualized',
'90days': 'yield90DaysAnnualized',
YTD: 'yieldYTD',
}

const data = React.useMemo(() => {
const apy = {
'30days': 'yield30DaysAnnualized',
'90days': 'yield90DaysAnnualized',
YTD: 'yieldYTD',
}
const tokenData =
dailyPoolStates?.map((state) => {
return {
Expand Down
2 changes: 1 addition & 1 deletion centrifuge-app/src/components/PoolList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function PoolList() {

const sortedPools = [...openInvestmentPools, ...upcomingPools, ...tinlakePools]
return [pools, search ? filterPools([...pools, ...upcomingPools], new URLSearchParams(search)) : sortedPools]
}, [listedPools, search])
}, [listedPools, search, cent, centPoolsMetaDataById])

const archivedPools = pools.filter((pool) => pool?.status?.includes('Archived'))

Expand Down
2 changes: 1 addition & 1 deletion centrifuge-app/src/components/PoolOverview/KeyMetrics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const KeyMetrics = ({ poolId }: Props) => {
const minInv = new CurrencyBalance(item.minInitialInvestment ?? 0, pool.currency.decimals).toDecimal()
return item.minInitialInvestment ? formatBalanceAbbreviated(minInv, '', 0) : null
})
}, [metadata?.tranches])
}, [metadata?.tranches, pool.currency.decimals])

const isBT3BT4 =
poolId.toLowerCase() === '0x90040f96ab8f291b6d43a8972806e977631affde' ||
Expand Down
94 changes: 48 additions & 46 deletions centrifuge-app/src/components/PoolOverview/TrancheTokenCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,55 +20,57 @@ export const TrancheTokenCards = ({ trancheTokens, poolId }: { trancheTokens: To
return 'mezzanine'
}

const calculateApy = (trancheToken: Token) => {
if (isTinlakePool && getTrancheText(trancheToken) === 'senior') return formatPercentage(trancheToken.apy)
if (daysSinceCreation < 30) return 'N/A'
return trancheToken.yield30DaysAnnualized
? formatPercentage(new Perquintill(trancheToken.yield30DaysAnnualized))
: '-'
}
const columnConfig = useMemo(() => {
const calculateApy = (trancheToken: Token) => {
if (isTinlakePool && getTrancheText(trancheToken) === 'senior') return formatPercentage(trancheToken.apy)
if (daysSinceCreation < 30) return 'N/A'
return trancheToken.yield30DaysAnnualized
? formatPercentage(new Perquintill(trancheToken.yield30DaysAnnualized))
: '-'
}

const columnConfig = [
{
header: 'Token',
align: 'left',
formatter: (v: any) => v,
},
{
header: 'APY',
align: 'left',
formatter: (v: any) => (v ? calculateApy(v) : '-'),
},
{
header: `TVL (${pool?.currency.symbol})`,
align: 'left',
formatter: (v: any) => (v ? formatBalance(v) : '-'),
},
{
header: 'Token price',
align: 'left',
formatter: (v: any) => (v ? formatBalance(v, pool?.currency.symbol, pool?.currency.decimals) : '-'),
},
...(pool.tranches.length > 1
? [
{
header: 'Subordination',
align: 'left',
formatter: (_: any, row: any) => {
if (row.value[1].seniority === 0) return '-'
return formatPercentage(row.value[1].protection)
return [
{
header: 'Token',
align: 'left',
formatter: (v: any) => v,
},
{
header: 'APY',
align: 'left',
formatter: (v: any) => (v ? calculateApy(v) : '-'),
},
{
header: `TVL (${pool?.currency.symbol})`,
align: 'left',
formatter: (v: any) => (v ? formatBalance(v) : '-'),
},
{
header: 'Token price',
align: 'left',
formatter: (v: any) => (v ? formatBalance(v, pool?.currency.symbol, pool?.currency.decimals) : '-'),
},
...(pool.tranches.length > 1
? [
{
header: 'Subordination',
align: 'left',
formatter: (_: any, row: any) => {
if (row.value[1].seniority === 0) return '-'
return formatPercentage(row.value[1].protection)
},
},
},
]
: []),
{
header: '',
align: 'left',
formatter: (_: any, row: any) => {
return <InvestButton poolId={poolId} trancheId={row.value[1].id} />
]
: []),
{
header: '',
align: 'left',
formatter: (_: any, row: any) => {
return <InvestButton poolId={poolId} trancheId={row.value[1].id} />
},
},
},
]
]
}, [pool, poolId, isTinlakePool, daysSinceCreation])

const columns = useMemo(() => {
return columnConfig.map((col, index) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ type Row = {
netFlow?: 'positive' | 'negative' | 'neutral'
}

const getTransactionTypeStatus = (type: string): 'default' | 'info' | 'ok' | 'warning' | 'critical' => {
return 'default'
}

export const TransactionHistory = ({
poolId,
activeAssetId,
Expand Down Expand Up @@ -198,7 +194,7 @@ export const TransactionHistoryTable = ({

const tableData =
transformedTransactions.slice(0, preview ? 8 : Infinity).map((transaction) => {
const { label, amount, netFlow } = getLabelAndAmount(transaction)
const { amount, netFlow } = getLabelAndAmount(transaction)
return {
activeAssetId,
netFlow,
Expand Down
2 changes: 1 addition & 1 deletion centrifuge-app/src/components/Report/BalanceSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export function BalanceSheet({ pool }: { pool: Pool }) {
if (poolStates?.length) {
setReportData(poolStates)
}
}, [poolStates])
}, [poolStates, setReportData])

if (!poolStates) {
return <Spinner mt={2} />
Expand Down
2 changes: 1 addition & 1 deletion centrifuge-app/src/components/Report/CashflowStatement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ export function CashflowStatement({ pool }: { pool: Pool }) {

setReportData(fullPoolStates)
}
}, [poolStates])
}, [poolStates, setReportData])

if (!poolStates) {
return <Spinner mt={2} />
Expand Down
2 changes: 1 addition & 1 deletion centrifuge-app/src/components/Report/ProfitAndLoss.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ export function ProfitAndLoss({ pool }: { pool: Pool }) {

setReportData(fullPoolStates)
}
}, [poolStates])
}, [poolStates, setReportData])

if (!poolStates) {
return <Spinner mt={2} />
Expand Down
2 changes: 1 addition & 1 deletion centrifuge-app/src/components/Report/ReportFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export function ReportFilter({ poolId }: ReportFilterProps) {
}
})
}
}, [report, reportData])
}, [report, reportData, metadata?.data?.pool?.asset.class, pool.currency.decimals])

return (
<Shelf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export function NavManagementAssetTable({ poolId }: { poolId: string }) {
pool.currency.decimals
)
}, new CurrencyBalance(0, pool.currency.decimals))
}, [externalLoans, pool?.nav, form.values.feed])
}, [externalLoans, form.values.feed, pool.currency.decimals])

const pendingNav = totalAum.add(changeInValuation.toDecimal()).sub(pendingFees.toDecimal())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type Props = {
}

export const CompleteExternalOnboarding = ({ openNewTab, poolId, poolSymbol }: Props) => {
const { refetchOnboardingUser, isOnboardingExternally } = useOnboarding()
const { refetchOnboardingUser } = useOnboarding()

const onFocus = () => {
refetchOnboardingUser()
Expand Down

0 comments on commit 178af27

Please sign in to comment.