feat: add market close datetime to lp dashboard (#2529)

* feat: add proposal data from governance to market liquidity provider

We need data from this API to be able to tell when a market will close,
and when opening auctions will end.

* feat: add closing time to lp-dashboard market list page

Adds a 'closing time' column to the market list page on the dashboard.
This commit is contained in:
Ciaran McGhie 2023-01-05 15:28:30 +00:00 committed by GitHub
parent 4fbd2e5eba
commit 8db3b01284
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 2 deletions

View File

@ -10,6 +10,7 @@ import {
formatNumberPercentage, formatNumberPercentage,
t, t,
toBigNum, toBigNum,
getDateTimeFormat,
} from '@vegaprotocol/react-helpers'; } from '@vegaprotocol/react-helpers';
import type { VegaValueFormatterParams } from '@vegaprotocol/ui-toolkit'; import type { VegaValueFormatterParams } from '@vegaprotocol/ui-toolkit';
import type * as Schema from '@vegaprotocol/types'; import type * as Schema from '@vegaprotocol/types';
@ -296,6 +297,21 @@ export const MarketList = () => {
return value ? formatDistanceToNow(new Date(value)) : '-'; return value ? formatDistanceToNow(new Date(value)) : '-';
}} }}
/> />
<AgGridColumn
headerName={t('Closing Time')}
field="proposal.terms.closingDatetime"
headerTooltip={t('Closing time of the market')}
valueFormatter={({
value,
}: VegaValueFormatterParams<
Market,
'proposal.terms.closingDatetime'
>) => {
return value
? getDateTimeFormat().format(new Date(value).getTime())
: '-';
}}
/>
</Grid> </Grid>
<HealthDialog <HealthDialog

View File

@ -31,6 +31,8 @@ import {
getTargetStake, getTargetStake,
} from './utils/liquidity-utils'; } from './utils/liquidity-utils';
import type { Provider, LiquidityProvisionMarket } from './utils'; import type { Provider, LiquidityProvisionMarket } from './utils';
import { proposalsListDataProvider } from '@vegaprotocol/governance';
import type { Proposal } from '@vegaprotocol/types';
export interface FeeLevels { export interface FeeLevels {
commitmentAmount: number; commitmentAmount: number;
@ -44,6 +46,7 @@ export type Market = MarketWithData &
dayVolume: string; dayVolume: string;
liquidityCommitted: number; liquidityCommitted: number;
volumeChange: string; volumeChange: string;
proposal?: Proposal;
}; };
export interface Markets { export interface Markets {
@ -63,7 +66,8 @@ const getData = (
export const addData = ( export const addData = (
markets: (MarketWithData & MarketWithCandles)[], markets: (MarketWithData & MarketWithCandles)[],
marketsCandles24hAgo: MarketCandles[], marketsCandles24hAgo: MarketCandles[],
marketsLiquidity: LiquidityProvisionMarket[] marketsLiquidity: LiquidityProvisionMarket[],
proposals: Proposal[]
) => { ) => {
return markets.map((market) => { return markets.map((market) => {
const dayVolume = calcDayVolume(market.candles); const dayVolume = calcDayVolume(market.candles);
@ -76,6 +80,9 @@ export const addData = (
marketsLiquidity marketsLiquidity
) as Provider[]; ) as Provider[];
const proposalForMarket =
proposals && proposals.find((p) => p.id === market.id);
return { return {
...market, ...market,
dayVolume, dayVolume,
@ -83,6 +90,7 @@ export const addData = (
liquidityCommitted: sumLiquidityCommitted(liquidityProviders), liquidityCommitted: sumLiquidityCommitted(liquidityProviders),
feeLevels: getFeeLevels(liquidityProviders) || [], feeLevels: getFeeLevels(liquidityProviders) || [],
target: getTargetStake(market.id, marketsLiquidity), target: getTargetStake(market.id, marketsLiquidity),
proposal: proposalForMarket,
}; };
}); });
}; };
@ -106,12 +114,14 @@ const liquidityProvisionProvider = makeDerivedDataProvider<Markets, never>(
interval: Schema.Interval.INTERVAL_I1D, interval: Schema.Interval.INTERVAL_I1D,
}), }),
liquidityMarketsProvider, liquidityMarketsProvider,
proposalsListDataProvider,
], ],
(parts) => { (parts) => {
const data = addData( const data = addData(
parts[0] as (MarketWithData & MarketWithCandles)[], parts[0] as (MarketWithData & MarketWithCandles)[],
parts[1] as MarketCandles[], parts[1] as MarketCandles[],
parts[2] as LiquidityProvisionMarket[] parts[2] as LiquidityProvisionMarket[],
parts[3] as Proposal[]
); );
return { markets: data }; return { markets: data };
} }