diff --git a/apps/trading/pages/liquidity/[marketId].page.tsx b/apps/trading/pages/liquidity/[marketId].page.tsx index 757c2ce89..14d62eb9f 100644 --- a/apps/trading/pages/liquidity/[marketId].page.tsx +++ b/apps/trading/pages/liquidity/[marketId].page.tsx @@ -1,3 +1,7 @@ +import type { + LiquidityProvisionFieldsFragment, + LiquidityProvisionsSubscription, +} from '@vegaprotocol/liquidity'; import { marketLiquidityDataProvider } from '@vegaprotocol/liquidity'; import { liquidityProvisionsDataProvider, @@ -25,6 +29,7 @@ import { useRef, useMemo } from 'react'; import { tooltipMapping } from '@vegaprotocol/market-info'; import Link from 'next/link'; import { Schema } from '@vegaprotocol/types'; +import BigNumber from 'bignumber.js'; const LiquidityPage = ({ id }: { id?: string }) => { const { query } = useRouter(); @@ -45,7 +50,10 @@ const LiquidityPage = ({ id }: { id?: string }) => { data: liquidityProviders, loading, error, - } = useDataProvider({ + } = useDataProvider< + LiquidityProvisionFieldsFragment[], + LiquidityProvisionsSubscription['liquidityProvisions'] + >({ dataProvider: liquidityProvisionsDataProvider, update, variables: { marketId, pubKey }, @@ -156,6 +164,7 @@ const LiquidityPage = ({ id }: { id?: string }) => { ref={gridRef} data={myLpEdges} symbol={symbol} + stakeToCcySiskas={new BigNumber(stakeToCcySiska ?? 1)} assetDecimalPlaces={assetDecimalPlaces} /> )} @@ -167,6 +176,7 @@ const LiquidityPage = ({ id }: { id?: string }) => { data={activeEdges} symbol={symbol} assetDecimalPlaces={assetDecimalPlaces} + stakeToCcySiskas={new BigNumber(stakeToCcySiska ?? 1)} /> )} @@ -178,6 +188,7 @@ const LiquidityPage = ({ id }: { id?: string }) => { data={inactiveEdges} symbol={symbol} assetDecimalPlaces={assetDecimalPlaces} + stakeToCcySiskas={new BigNumber(stakeToCcySiska ?? 1)} /> )} diff --git a/libs/liquidity/src/lib/liquidity-data-provider.ts b/libs/liquidity/src/lib/liquidity-data-provider.ts index 087c74a9e..b0e43176f 100644 --- a/libs/liquidity/src/lib/liquidity-data-provider.ts +++ b/libs/liquidity/src/lib/liquidity-data-provider.ts @@ -1,7 +1,11 @@ -import { makeDataProvider } from '@vegaprotocol/react-helpers'; +import { + makeDataProvider, + makeDerivedDataProvider, +} from '@vegaprotocol/react-helpers'; import produce from 'immer'; import type { IterableElement } from 'type-fest'; import type { + LiquidityProviderFeeShareFieldsFragment, LiquidityProvisionFieldsFragment, LiquidityProvisionsSubscription, MarketLiquidityQuery, @@ -97,3 +101,40 @@ export const marketLiquidityDataProvider = makeDataProvider< return delta; }, }); + +export const liquidityFeeShareDataProvider = makeDataProvider< + MarketLiquidityQuery, + LiquidityProviderFeeShareFieldsFragment[], + LiquidityProviderFeeShareFieldsFragment, + LiquidityProviderFeeShareFieldsFragment[] +>({ + query: MarketLiquidityDocument, + subscriptionQuery: LiquidityProvisionsDocument, + update: (data, delta) => { + return delta; + }, + getData: (data) => { + return data.market?.data?.liquidityProviderFeeShare || []; + }, + getDelta: (delta) => { + return [delta]; + }, +}); + +export const lpAggregatedDataProvider = makeDerivedDataProvider< + LiquidityProvisionFieldsFragment[], + never +>( + [ + liquidityProvisionsDataProvider, + marketLiquidityDataProvider, + liquidityFeeShareDataProvider, + ], + (parts) => { + // TODO add fee share and liquidity provision party merge + console.log('liquidityProvisionsDataProvider', parts[0]); + console.log('marketLiquidityDataProvider', parts[1]); + console.log('liquidityFeeShareDataProvider', parts[2]); + return [parts[0], parts[1], parts[2]]; + } +); diff --git a/libs/liquidity/src/lib/liquidity-table.tsx b/libs/liquidity/src/lib/liquidity-table.tsx index 0df713dc6..1e7bb49ce 100644 --- a/libs/liquidity/src/lib/liquidity-table.tsx +++ b/libs/liquidity/src/lib/liquidity-table.tsx @@ -33,10 +33,11 @@ export interface LiquidityTableProps { data?: LiquidityProvisionFieldsFragment[]; symbol?: string; assetDecimalPlaces?: number; + stakeToCcySiskas: BigNumber; } export const LiquidityTable = forwardRef( - ({ data, symbol = '', assetDecimalPlaces }, ref) => { + ({ data, symbol = '', assetDecimalPlaces, stakeToCcySiskas }, ref) => { const assetDecimalsFormatter = ({ value }: ValueFormatterParams) => { if (!value) return '-'; return `${addDecimalsFormatNumber(value, assetDecimalPlaces ?? 0, 5)}`; @@ -61,7 +62,7 @@ export const LiquidityTable = forwardRef( >