From a404c103c1138883cf65009ba1a9ffe7e3017a4e Mon Sep 17 00:00:00 2001 From: katty barroso Date: Tue, 14 Jan 2025 15:10:11 +0100 Subject: [PATCH 1/9] Add data table for orders --- .../src/components/Report/DataFilter.tsx | 9 +- .../src/components/Report/Orders.tsx | 111 ++++++++++++++++++ .../src/components/Report/ReportContext.tsx | 1 + .../src/components/Report/index.tsx | 2 + centrifuge-app/src/utils/date.ts | 13 ++ centrifuge-app/src/utils/usePools.ts | 5 + centrifuge-js/src/modules/pools.ts | 89 +++++++++++++- centrifuge-js/src/types/subquery.ts | 26 ++++ 8 files changed, 253 insertions(+), 3 deletions(-) create mode 100644 centrifuge-app/src/components/Report/Orders.tsx diff --git a/centrifuge-app/src/components/Report/DataFilter.tsx b/centrifuge-app/src/components/Report/DataFilter.tsx index 370d983287..0dac1edf63 100644 --- a/centrifuge-app/src/components/Report/DataFilter.tsx +++ b/centrifuge-app/src/components/Report/DataFilter.tsx @@ -60,6 +60,7 @@ export function DataFilter({ poolId }: ReportFilterProps) { { label: 'Token price', value: 'token-price' }, { label: 'Asset list', value: 'asset-list' }, { label: 'Investor list', value: 'investor-list' }, + { label: 'Orders', value: 'orders' }, ] return ( @@ -228,8 +229,12 @@ export function DataFilter({ poolId }: ReportFilterProps) { /> )} - setStartDate(e.target.value)} /> - setEndDate(e.target.value)} /> + {report !== 'orders' && ( + <> + setStartDate(e.target.value)} /> + setEndDate(e.target.value)} /> + + )} diff --git a/centrifuge-app/src/components/Report/Orders.tsx b/centrifuge-app/src/components/Report/Orders.tsx new file mode 100644 index 0000000000..deb3a6bda7 --- /dev/null +++ b/centrifuge-app/src/components/Report/Orders.tsx @@ -0,0 +1,111 @@ +import { Pool } from '@centrifuge/centrifuge-js/dist/modules/pools' +import { Box, Text } from '@centrifuge/fabric' +import { useMemo } from 'react' +import { TableDataRow } from '.' +import { formatDateAndTime } from '../../../src/utils/date' +import { formatBalance } from '../../../src/utils/formatting' +import { usePoolOrdersByPoolId } from '../../../src/utils/usePools' +import { DataTable, SortableTableHeader } from '../DataTable' + +const noop = (v: any) => v + +const Orders = ({ pool }: { pool: Pool }) => { + const orders = usePoolOrdersByPoolId(pool.id) + + const columnsConfig = [ + { + align: 'left', + header: 'Epoch', + sortable: true, + formatter: noop, + }, + { + align: 'left', + header: 'Date & Time', + sortable: true, + formatter: (v: any) => formatDateAndTime(v), + width: '200px', + }, + { + align: 'left', + header: 'NAV', + sortable: true, + formatter: (v: any) => (v ? formatBalance(v, undefined, pool.currency.decimals) : '-'), + }, + { + align: 'left', + header: 'Nav per share', + sortable: true, + formatter: (v: any) => (v ? formatBalance(v, undefined, pool.currency.decimals) : '-'), + }, + { + align: 'left', + header: 'Investments locked', + sortable: true, + formatter: (v: any) => (v ? formatBalance(v, pool.currency.symbol, 2) : '-'), + }, + { + align: 'left', + header: 'Investments executed', + sortable: true, + formatter: (v: any) => (v ? formatBalance(v, pool.currency.symbol, 2) : '-'), + }, + { + align: 'left', + header: 'Redemptions locked', + sortable: true, + formatter: (v: any) => (v ? formatBalance(v, pool.currency.symbol, 2) : '-'), + }, + { + align: 'left', + header: 'Redemptions executed', + sortable: true, + formatter: (v: any) => (v ? formatBalance(v, pool.currency.symbol, 2) : '-'), + }, + { + align: 'left', + header: 'Paid fees', + sortable: true, + formatter: (v: any) => (v ? formatBalance(v, pool.currency.symbol, 2) : '-'), + }, + ] + + const columns = columnsConfig.map((col, index) => ({ + align: col.align, + header: col.sortable ? : col.header, + cell: (row: TableDataRow) => { + return {col.formatter((row.value as any)[index])} + }, + sortKey: col.sortable ? `value[${index}]` : undefined, + width: col.width, + })) + + const data = useMemo(() => { + if (!orders?.length) return [] + else { + return orders.map((order) => ({ + name: '', + value: [ + order.epochId, + order.closedAt, + order.netAssetValue, + order.tokenPrice, + order.sumOutstandingInvestOrders, + order.sumFulfilledInvestOrders, + order.sumOutstandingRedeemOrders, + order.sumFulfilledRedeemOrders, + order.paidFees, + ], + heading: false, + })) + } + }, [orders]) + + return ( + + + + ) +} + +export default Orders diff --git a/centrifuge-app/src/components/Report/ReportContext.tsx b/centrifuge-app/src/components/Report/ReportContext.tsx index 5ef1b8ab6a..a0af7b3c32 100644 --- a/centrifuge-app/src/components/Report/ReportContext.tsx +++ b/centrifuge-app/src/components/Report/ReportContext.tsx @@ -17,6 +17,7 @@ export type Report = | 'balance-sheet' | 'cash-flow-statement' | 'profit-and-loss' + | 'orders' export type ReportContextType = { csvData?: CsvDataProps diff --git a/centrifuge-app/src/components/Report/index.tsx b/centrifuge-app/src/components/Report/index.tsx index 2cb980da04..da842039c9 100644 --- a/centrifuge-app/src/components/Report/index.tsx +++ b/centrifuge-app/src/components/Report/index.tsx @@ -10,6 +10,7 @@ import { FeeTransactions } from './FeeTransactions' import { InvestorList } from './InvestorList' import { InvestorTransactions } from './InvestorTransactions' import { OracleTransactions } from './OracleTransactions' +import Orders from './Orders' import { PoolBalance } from './PoolBalance' import { ProfitAndLoss } from './ProfitAndLoss' import { ReportContext } from './ReportContext' @@ -38,6 +39,7 @@ export function ReportComponent({ pool }: { pool: Pool }) { {report === 'cash-flow-statement' && } {report === 'oracle-tx' && } {report === 'profit-and-loss' && } + {report === 'orders' && } ) diff --git a/centrifuge-app/src/utils/date.ts b/centrifuge-app/src/utils/date.ts index 2df7487773..dfe27a628c 100644 --- a/centrifuge-app/src/utils/date.ts +++ b/centrifuge-app/src/utils/date.ts @@ -8,6 +8,19 @@ export function formatDate(timestamp: number | string | Date, options?: Intl.Dat }) } +export function formatDateAndTime(timestamp: number | string | Date, options?: Intl.DateTimeFormatOptions) { + return new Date(timestamp).toLocaleString('en-US', { + year: 'numeric', + month: 'short', + day: 'numeric', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + timeZone: 'UTC', + ...options, + }) +} + export function formatDateTechnical(timestamp: number | string) { return new Date(timestamp).toLocaleDateString('en-US') } diff --git a/centrifuge-app/src/utils/usePools.ts b/centrifuge-app/src/utils/usePools.ts index f8771a92fe..a7c302ef58 100644 --- a/centrifuge-app/src/utils/usePools.ts +++ b/centrifuge-app/src/utils/usePools.ts @@ -265,6 +265,11 @@ export function usePoolOrders(poolId: string) { return result } +export function usePoolOrdersByPoolId(poolId: string) { + const [result] = useCentrifugeQuery(['poolOrdersByPoolId', poolId], (cent) => cent.pools.getPoolOrdersById([poolId])) + return result +} + export function useOrder(poolId: string, trancheId: string, address?: string) { const [result] = useCentrifugeQuery( ['order', trancheId, address], diff --git a/centrifuge-js/src/modules/pools.ts b/centrifuge-js/src/modules/pools.ts index f2946a11a4..7b9b5debdf 100644 --- a/centrifuge-js/src/modules/pools.ts +++ b/centrifuge-js/src/modules/pools.ts @@ -25,6 +25,7 @@ import { SubqueryPoolAssetSnapshot, SubqueryPoolFeeSnapshot, SubqueryPoolFeeTransaction, + SubqueryPoolOrdersById, SubqueryPoolSnapshot, SubqueryTrancheBalances, SubqueryTrancheSnapshot, @@ -2443,6 +2444,11 @@ export function getPoolsModule(inst: Centrifuge) { tranche { poolId trancheId + pool { + currency{ + decimals + } + } } timestamp tokenSupply @@ -2501,13 +2507,14 @@ export function getPoolsModule(inst: Centrifuge) { map(({ trancheSnapshots }) => { const trancheStates: Record< string, - { timestamp: string; tokenPrice: Price; yield30DaysAnnualized: Perquintill }[] + { timestamp: string; tokenPrice: Price; yield30DaysAnnualized: Perquintill; tokenSupply: TokenBalance }[] > = {} trancheSnapshots?.forEach((state) => { const tid = state.tranche.trancheId const entry = { timestamp: state.timestamp, tokenPrice: new Price(state.tokenPrice), + tokenSupply: new TokenBalance(state.tokenSupply, state.tranche.pool.currency.decimals), pool: state.tranche.poolId, yield30DaysAnnualized: state.yield30DaysAnnualized ? new Perquintill(state.yield30DaysAnnualized) @@ -3941,6 +3948,85 @@ export function getPoolsModule(inst: Centrifuge) { ) } + function getPoolOrdersById(args: [poolId: string]) { + const [poolId] = args + + const $query = inst.getSubqueryObservable<{ + epoches: { nodes: SubqueryPoolOrdersById[] } + }>( + `query($poolId: String!) { + epoches( + filter: { + poolId: { equalTo: $poolId } + } + ) { + nodes { + poolId + id + sumPoolFeesPaidAmount + closedAt + epochStates{ + nodes{ + tokenPrice + sumOutstandingInvestOrders + sumFulfilledInvestOrders + sumOutstandingRedeemOrders + sumFulfilledRedeemOrders + } + } + poolSnapshots{ + nodes{ + netAssetValue + } + } + } + } + } + `, + { + poolId, + }, + false + ) + + return $query.pipe( + combineLatestWith(getPoolCurrency([poolId])), + map(([data, poolCurrency]) => { + return data?.epoches?.nodes.map((order) => { + const index = order.epochStates.nodes.length - 1 + return { + epochId: order.id, + closedAt: order.closedAt, + paidFees: order.sumPoolFeesPaidAmount + ? new CurrencyBalance(order.sumPoolFeesPaidAmount, poolCurrency.decimals) + : null, + tokenPrice: order.epochStates.nodes[index].tokenPrice + ? new CurrencyBalance(order.epochStates.nodes[index].tokenPrice, poolCurrency.decimals) + : null, + sumOutstandingInvestOrders: order.epochStates.nodes[index].sumOutstandingInvestOrders + ? new CurrencyBalance(order.epochStates.nodes[index].sumOutstandingInvestOrders, poolCurrency.decimals) + : null, + sumFulfilledInvestOrders: order.epochStates.nodes[index].sumFulfilledInvestOrders + ? new CurrencyBalance(order.epochStates.nodes[index].sumFulfilledInvestOrders, poolCurrency.decimals) + : null, + sumOutstandingRedeemOrders: order.epochStates.nodes[index].sumOutstandingRedeemOrders + ? new CurrencyBalance(order.epochStates.nodes[index].sumOutstandingRedeemOrders, poolCurrency.decimals) + : null, + sumFulfilledRedeemOrders: order.epochStates.nodes[index].sumFulfilledRedeemOrders + ? new CurrencyBalance(order.epochStates.nodes[index].sumFulfilledRedeemOrders, poolCurrency.decimals) + : null, + netAssetValue: order.poolSnapshots.nodes.length + ? new CurrencyBalance( + order.poolSnapshots.nodes[order.poolSnapshots.nodes.length - 1].netAssetValue, + poolCurrency.decimals + ) + : null, + } + }) + }) + ) + } + function getLoans(args: [poolId: string]) { const [poolId] = args const $api = inst.getApi() @@ -4631,6 +4717,7 @@ export function getPoolsModule(inst: Centrifuge) { getBalances, getOrder, getPoolOrders, + getPoolOrdersById, getPoolAccountOrders, getPortfolio, getLoans, diff --git a/centrifuge-js/src/types/subquery.ts b/centrifuge-js/src/types/subquery.ts index 520f3e28bd..6949de0f45 100644 --- a/centrifuge-js/src/types/subquery.ts +++ b/centrifuge-js/src/types/subquery.ts @@ -38,6 +38,11 @@ export type SubqueryTrancheSnapshot = { tranche: { poolId: string trancheId: string + pool: { + currency: { + decimals: number + } + } } tokenSupply: string sumOutstandingInvestOrdersByPeriod: string @@ -192,6 +197,27 @@ export type SubqueryPoolAssetSnapshot = { totalRepaidUnscheduled: string | undefined } +export type SubqueryPoolOrdersById = { + __typename?: 'Epoches' + id: string + sumPoolFeesPaidAmount: string + closedAt: string + epochStates: { + nodes: { + tokenPrice: string + sumOutstandingInvestOrders: string + sumFulfilledInvestOrders: string + sumOutstandingRedeemOrders: string + sumFulfilledRedeemOrders: string + }[] + } + poolSnapshots: { + nodes: { + netAssetValue: string + }[] + } +} + export type PoolFeeTransactionType = 'PROPOSED' | 'ADDED' | 'REMOVED' | 'CHARGED' | 'UNCHARGED' | 'PAID' | 'ACCRUED' export type SubqueryPoolFeeTransaction = { From 4b62668a3b95dfc15036555da0386984af2d6fa1 Mon Sep 17 00:00:00 2001 From: katty barroso Date: Tue, 14 Jan 2025 15:12:02 +0100 Subject: [PATCH 2/9] Cleanup --- centrifuge-js/src/modules/pools.ts | 8 +------- centrifuge-js/src/types/subquery.ts | 5 ----- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/centrifuge-js/src/modules/pools.ts b/centrifuge-js/src/modules/pools.ts index 7b9b5debdf..eb4ad6afa4 100644 --- a/centrifuge-js/src/modules/pools.ts +++ b/centrifuge-js/src/modules/pools.ts @@ -2444,11 +2444,6 @@ export function getPoolsModule(inst: Centrifuge) { tranche { poolId trancheId - pool { - currency{ - decimals - } - } } timestamp tokenSupply @@ -2507,14 +2502,13 @@ export function getPoolsModule(inst: Centrifuge) { map(({ trancheSnapshots }) => { const trancheStates: Record< string, - { timestamp: string; tokenPrice: Price; yield30DaysAnnualized: Perquintill; tokenSupply: TokenBalance }[] + { timestamp: string; tokenPrice: Price; yield30DaysAnnualized: Perquintill }[] > = {} trancheSnapshots?.forEach((state) => { const tid = state.tranche.trancheId const entry = { timestamp: state.timestamp, tokenPrice: new Price(state.tokenPrice), - tokenSupply: new TokenBalance(state.tokenSupply, state.tranche.pool.currency.decimals), pool: state.tranche.poolId, yield30DaysAnnualized: state.yield30DaysAnnualized ? new Perquintill(state.yield30DaysAnnualized) diff --git a/centrifuge-js/src/types/subquery.ts b/centrifuge-js/src/types/subquery.ts index 6949de0f45..12d4acc139 100644 --- a/centrifuge-js/src/types/subquery.ts +++ b/centrifuge-js/src/types/subquery.ts @@ -38,11 +38,6 @@ export type SubqueryTrancheSnapshot = { tranche: { poolId: string trancheId: string - pool: { - currency: { - decimals: number - } - } } tokenSupply: string sumOutstandingInvestOrdersByPeriod: string From c71198d96d37bbf82395c429b2192578496d7421 Mon Sep 17 00:00:00 2001 From: katty barroso Date: Tue, 14 Jan 2025 15:18:03 +0100 Subject: [PATCH 3/9] Fix nav decimals and add download button --- .../src/components/Report/Orders.tsx | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/centrifuge-app/src/components/Report/Orders.tsx b/centrifuge-app/src/components/Report/Orders.tsx index deb3a6bda7..a317656b84 100644 --- a/centrifuge-app/src/components/Report/Orders.tsx +++ b/centrifuge-app/src/components/Report/Orders.tsx @@ -1,15 +1,19 @@ import { Pool } from '@centrifuge/centrifuge-js/dist/modules/pools' import { Box, Text } from '@centrifuge/fabric' -import { useMemo } from 'react' +import { useContext, useEffect, useMemo } from 'react' import { TableDataRow } from '.' import { formatDateAndTime } from '../../../src/utils/date' import { formatBalance } from '../../../src/utils/formatting' +import { getCSVDownloadUrl } from '../../../src/utils/getCSVDownloadUrl' import { usePoolOrdersByPoolId } from '../../../src/utils/usePools' import { DataTable, SortableTableHeader } from '../DataTable' +import { ReportContext } from './ReportContext' +import { convertCSV } from './utils' const noop = (v: any) => v const Orders = ({ pool }: { pool: Pool }) => { + const { setCsvData } = useContext(ReportContext) const orders = usePoolOrdersByPoolId(pool.id) const columnsConfig = [ @@ -30,13 +34,13 @@ const Orders = ({ pool }: { pool: Pool }) => { align: 'left', header: 'NAV', sortable: true, - formatter: (v: any) => (v ? formatBalance(v, undefined, pool.currency.decimals) : '-'), + formatter: (v: any) => (v ? formatBalance(v) : '-'), }, { align: 'left', header: 'Nav per share', sortable: true, - formatter: (v: any) => (v ? formatBalance(v, undefined, pool.currency.decimals) : '-'), + formatter: (v: any) => (v ? formatBalance(v) : '-'), }, { align: 'left', @@ -101,6 +105,31 @@ const Orders = ({ pool }: { pool: Pool }) => { } }, [orders]) + const dataUrl = useMemo(() => { + if (!data.length) { + return + } + + const formatted = data.map(({ value: values }) => convertCSV(values, columnsConfig)) + + return getCSVDownloadUrl(formatted) + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [data]) + + useEffect(() => { + setCsvData( + dataUrl + ? { + dataUrl, + fileName: `${pool.id}-orders.csv`, + } + : undefined + ) + + return () => setCsvData(undefined) + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [dataUrl, pool.id]) + return ( From d2eede03c3e562425a48cb3b04b7aea06201fdc7 Mon Sep 17 00:00:00 2001 From: katty barroso Date: Tue, 14 Jan 2025 15:20:36 +0100 Subject: [PATCH 4/9] Fix date showing incorrect format --- centrifuge-app/src/components/Report/Orders.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/centrifuge-app/src/components/Report/Orders.tsx b/centrifuge-app/src/components/Report/Orders.tsx index a317656b84..95842156f4 100644 --- a/centrifuge-app/src/components/Report/Orders.tsx +++ b/centrifuge-app/src/components/Report/Orders.tsx @@ -27,7 +27,7 @@ const Orders = ({ pool }: { pool: Pool }) => { align: 'left', header: 'Date & Time', sortable: true, - formatter: (v: any) => formatDateAndTime(v), + formatter: (v: any) => (v ? formatDateAndTime(v) : '-'), width: '200px', }, { From 04bbd2c28be1a5c63e57931ba72db4bc1b947116 Mon Sep 17 00:00:00 2001 From: katty barroso Date: Tue, 14 Jan 2025 15:56:41 +0100 Subject: [PATCH 5/9] Update nav per share format --- centrifuge-app/src/components/Report/Orders.tsx | 2 +- centrifuge-js/src/modules/pools.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/centrifuge-app/src/components/Report/Orders.tsx b/centrifuge-app/src/components/Report/Orders.tsx index 95842156f4..81bd154cb1 100644 --- a/centrifuge-app/src/components/Report/Orders.tsx +++ b/centrifuge-app/src/components/Report/Orders.tsx @@ -40,7 +40,7 @@ const Orders = ({ pool }: { pool: Pool }) => { align: 'left', header: 'Nav per share', sortable: true, - formatter: (v: any) => (v ? formatBalance(v) : '-'), + formatter: (v: any) => (v ? formatBalance(v, undefined, 5, 5) : '-'), }, { align: 'left', diff --git a/centrifuge-js/src/modules/pools.ts b/centrifuge-js/src/modules/pools.ts index eb4ad6afa4..36e96f0cb6 100644 --- a/centrifuge-js/src/modules/pools.ts +++ b/centrifuge-js/src/modules/pools.ts @@ -3995,7 +3995,7 @@ export function getPoolsModule(inst: Centrifuge) { ? new CurrencyBalance(order.sumPoolFeesPaidAmount, poolCurrency.decimals) : null, tokenPrice: order.epochStates.nodes[index].tokenPrice - ? new CurrencyBalance(order.epochStates.nodes[index].tokenPrice, poolCurrency.decimals) + ? new Price(order.epochStates.nodes[index].tokenPrice) : null, sumOutstandingInvestOrders: order.epochStates.nodes[index].sumOutstandingInvestOrders ? new CurrencyBalance(order.epochStates.nodes[index].sumOutstandingInvestOrders, poolCurrency.decimals) From bebd123f160272a3977a9bf890c146dee12a8390 Mon Sep 17 00:00:00 2001 From: katty barroso Date: Tue, 14 Jan 2025 16:04:00 +0100 Subject: [PATCH 6/9] Fix nav index --- centrifuge-js/src/modules/pools.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/centrifuge-js/src/modules/pools.ts b/centrifuge-js/src/modules/pools.ts index 36e96f0cb6..785aedd4bc 100644 --- a/centrifuge-js/src/modules/pools.ts +++ b/centrifuge-js/src/modules/pools.ts @@ -3987,7 +3987,8 @@ export function getPoolsModule(inst: Centrifuge) { combineLatestWith(getPoolCurrency([poolId])), map(([data, poolCurrency]) => { return data?.epoches?.nodes.map((order) => { - const index = order.epochStates.nodes.length - 1 + const index = order.epochStates.nodes.length > 1 ? order.epochStates.nodes.length - 1 : 0 + const snapshotIndex = order.poolSnapshots.nodes.length > 1 ? order.poolSnapshots.nodes.length - 1 : 0 return { epochId: order.id, closedAt: order.closedAt, @@ -4010,10 +4011,7 @@ export function getPoolsModule(inst: Centrifuge) { ? new CurrencyBalance(order.epochStates.nodes[index].sumFulfilledRedeemOrders, poolCurrency.decimals) : null, netAssetValue: order.poolSnapshots.nodes.length - ? new CurrencyBalance( - order.poolSnapshots.nodes[order.poolSnapshots.nodes.length - 1].netAssetValue, - poolCurrency.decimals - ) + ? new CurrencyBalance(order.poolSnapshots.nodes[snapshotIndex].netAssetValue, poolCurrency.decimals) : null, } }) From 068126994e5dc32ef86999a3b558ca8dbd49abcf Mon Sep 17 00:00:00 2001 From: katty barroso Date: Tue, 14 Jan 2025 16:37:03 +0100 Subject: [PATCH 7/9] Fix format and add date header --- centrifuge-app/src/components/Report/Orders.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/centrifuge-app/src/components/Report/Orders.tsx b/centrifuge-app/src/components/Report/Orders.tsx index 81bd154cb1..56ffc48fc3 100644 --- a/centrifuge-app/src/components/Report/Orders.tsx +++ b/centrifuge-app/src/components/Report/Orders.tsx @@ -13,9 +13,17 @@ import { convertCSV } from './utils' const noop = (v: any) => v const Orders = ({ pool }: { pool: Pool }) => { - const { setCsvData } = useContext(ReportContext) + const { setCsvData, setStartDate } = useContext(ReportContext) const orders = usePoolOrdersByPoolId(pool.id) + useEffect(() => { + if (!orders?.length) return + const dateStrings = orders?.map((order) => order.closedAt).filter(Boolean) + const oldestTimestamp = Math.min(...dateStrings.map((date) => new Date(date).getTime())) + const oldestDate = new Date(oldestTimestamp).toISOString().split('T')[0] + setStartDate(oldestDate) + }, []) + const columnsConfig = [ { align: 'left', @@ -34,13 +42,13 @@ const Orders = ({ pool }: { pool: Pool }) => { align: 'left', header: 'NAV', sortable: true, - formatter: (v: any) => (v ? formatBalance(v) : '-'), + formatter: (v: any) => (v ? formatBalance(v, pool.currency.symbol) : '-'), }, { align: 'left', header: 'Nav per share', sortable: true, - formatter: (v: any) => (v ? formatBalance(v, undefined, 5, 5) : '-'), + formatter: (v: any) => (v ? formatBalance(v, pool.currency.symbol, 6, 6) : '-'), }, { align: 'left', From 49b2b32253916e3225e117d6e49d44e87f929455 Mon Sep 17 00:00:00 2001 From: katty barroso Date: Thu, 16 Jan 2025 11:34:26 +0100 Subject: [PATCH 8/9] Fix sorting --- .../src/components/Report/Orders.tsx | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/centrifuge-app/src/components/Report/Orders.tsx b/centrifuge-app/src/components/Report/Orders.tsx index 56ffc48fc3..c9158fba7d 100644 --- a/centrifuge-app/src/components/Report/Orders.tsx +++ b/centrifuge-app/src/components/Report/Orders.tsx @@ -28,8 +28,8 @@ const Orders = ({ pool }: { pool: Pool }) => { { align: 'left', header: 'Epoch', - sortable: true, formatter: noop, + sortable: true, }, { align: 'left', @@ -95,21 +95,24 @@ const Orders = ({ pool }: { pool: Pool }) => { const data = useMemo(() => { if (!orders?.length) return [] else { - return orders.map((order) => ({ - name: '', - value: [ - order.epochId, - order.closedAt, - order.netAssetValue, - order.tokenPrice, - order.sumOutstandingInvestOrders, - order.sumFulfilledInvestOrders, - order.sumOutstandingRedeemOrders, - order.sumFulfilledRedeemOrders, - order.paidFees, - ], - heading: false, - })) + return orders.map((order) => { + const epoch = order.epochId.split('-') + return { + name: '', + value: [ + epoch[1], + order.closedAt, + order.netAssetValue, + order.tokenPrice, + order.sumOutstandingInvestOrders, + order.sumFulfilledInvestOrders, + order.sumOutstandingRedeemOrders, + order.sumFulfilledRedeemOrders, + order.paidFees, + ], + heading: false, + } + }) } }, [orders]) @@ -140,7 +143,7 @@ const Orders = ({ pool }: { pool: Pool }) => { return ( - + ) } From 144d40e8774b8a8c6c9b08f3f9ca3b04dfe10245 Mon Sep 17 00:00:00 2001 From: katty barroso Date: Thu, 16 Jan 2025 11:44:03 +0100 Subject: [PATCH 9/9] Remove date on top --- .../src/components/Report/DataFilter.tsx | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/centrifuge-app/src/components/Report/DataFilter.tsx b/centrifuge-app/src/components/Report/DataFilter.tsx index 0dac1edf63..cbc9e43a47 100644 --- a/centrifuge-app/src/components/Report/DataFilter.tsx +++ b/centrifuge-app/src/components/Report/DataFilter.tsx @@ -236,16 +236,22 @@ export function DataFilter({ poolId }: ReportFilterProps) { )} - - - - {formatDate(startDate)} - - - - - {formatDate(endDate)} - - + + {report !== 'orders' && ( + + + {formatDate(startDate)} + + - + + {formatDate(endDate)} + + + )} Download - + ) }