fix: #1537 add 3 lp data providers
This commit is contained in:
parent
4bd905d083
commit
c325becce1
@ -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)}
|
||||
/>
|
||||
)}
|
||||
</Tab>
|
||||
@ -178,6 +188,7 @@ const LiquidityPage = ({ id }: { id?: string }) => {
|
||||
data={inactiveEdges}
|
||||
symbol={symbol}
|
||||
assetDecimalPlaces={assetDecimalPlaces}
|
||||
stakeToCcySiskas={new BigNumber(stakeToCcySiska ?? 1)}
|
||||
/>
|
||||
)}
|
||||
</Tab>
|
||||
|
@ -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]];
|
||||
}
|
||||
);
|
||||
|
@ -33,10 +33,11 @@ export interface LiquidityTableProps {
|
||||
data?: LiquidityProvisionFieldsFragment[];
|
||||
symbol?: string;
|
||||
assetDecimalPlaces?: number;
|
||||
stakeToCcySiskas: BigNumber;
|
||||
}
|
||||
|
||||
export const LiquidityTable = forwardRef<AgGridReact, LiquidityTableProps>(
|
||||
({ 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<AgGridReact, LiquidityTableProps>(
|
||||
>
|
||||
<AgGridColumn
|
||||
headerName={t('Party')}
|
||||
field="party"
|
||||
field="party.id"
|
||||
headerTooltip={t(
|
||||
'The public key of the party making this commitment.'
|
||||
)}
|
||||
|
Loading…
Reference in New Issue
Block a user