From 045454b484175cbf101e1c3b65a20042566ba577 Mon Sep 17 00:00:00 2001 From: Ciaran McGhie Date: Thu, 10 Nov 2022 14:08:57 +0000 Subject: [PATCH] feat(1355): lp dashboard adding equity like share (#2017) * refactor: use the lpAggregatedDataProvider rather than liquidityProvisionsDataProvider The lpAggregatedDataProvider seems to provide the same data as the liquidityProvisionsDataProvider, but also contains further details that we'll need for other fields on the liquitidy provider details page. * feat: replace GALPS with equity-like share and fetch value from LiquidityProviderFeeShare Updates the type for LiquidityProviders prop to more accurately reflect that we're using the data from lpAggregatedDataProvider, which includes the fee share data. We use the fee share data to display equity-like share % for each LP, and have replaced GALPS, which was previously empty, with this value. --- .../src/app/components/detail/detail.tsx | 8 ++++---- .../components/detail/providers/providers.tsx | 17 ++++++++++++++--- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/apps/liquidity-provision-dashboard/src/app/components/detail/detail.tsx b/apps/liquidity-provision-dashboard/src/app/components/detail/detail.tsx index ac7297b8c..bff248f4c 100644 --- a/apps/liquidity-provision-dashboard/src/app/components/detail/detail.tsx +++ b/apps/liquidity-provision-dashboard/src/app/components/detail/detail.tsx @@ -11,7 +11,7 @@ import { getFeeLevels, sumLiquidityCommitted, marketLiquidityDataProvider, - liquidityProvisionsDataProvider, + lpAggregatedDataProvider, } from '@vegaprotocol/liquidity'; import type { MarketLpQuery } from '@vegaprotocol/liquidity'; @@ -34,10 +34,10 @@ const formatMarket = (data: MarketLpQuery) => { }; export const lpDataProvider = makeDerivedDataProvider( - [marketLiquidityDataProvider, liquidityProvisionsDataProvider], - ([market, providers]) => ({ + [marketLiquidityDataProvider, lpAggregatedDataProvider], + ([market, lpAggregatedData]) => ({ market: { ...formatMarket(market) }, - liquidityProviders: providers || [], + liquidityProviders: lpAggregatedData || [], }) ); diff --git a/apps/liquidity-provision-dashboard/src/app/components/detail/providers/providers.tsx b/apps/liquidity-provision-dashboard/src/app/components/detail/providers/providers.tsx index 942862426..ea9cea89c 100644 --- a/apps/liquidity-provision-dashboard/src/app/components/detail/providers/providers.tsx +++ b/apps/liquidity-provision-dashboard/src/app/components/detail/providers/providers.tsx @@ -4,7 +4,10 @@ import { AgGridColumn } from 'ag-grid-react'; import type { GetRowIdParams } from 'ag-grid-community'; import { t } from '@vegaprotocol/react-helpers'; -import type { LiquidityProvisionFieldsFragment } from '@vegaprotocol/liquidity'; +import type { + LiquidityProviderFeeShareFieldsFragment, + LiquidityProvisionFieldsFragment, +} from '@vegaprotocol/liquidity'; import { formatWithAsset } from '@vegaprotocol/liquidity'; import { Grid } from '../../grid'; @@ -24,7 +27,8 @@ export const LPProvidersGrid = ({ liquidityProviders, settlementAsset, }: { - liquidityProviders: LiquidityProvisionFieldsFragment[]; + liquidityProviders: LiquidityProvisionFieldsFragment & + LiquidityProviderFeeShareFieldsFragment[]; settlementAsset: { decimals?: number; symbol?: string; @@ -55,7 +59,14 @@ export const LPProvidersGrid = ({ valueFormatter={formatToHours} field="createdAt" /> - + { + const valueOr0 = value ? value : ''; + return `${parseInt(valueOr0) * 100}%`; + }} + />