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:
parent
4fbd2e5eba
commit
8db3b01284
@ -10,6 +10,7 @@ import {
|
||||
formatNumberPercentage,
|
||||
t,
|
||||
toBigNum,
|
||||
getDateTimeFormat,
|
||||
} from '@vegaprotocol/react-helpers';
|
||||
import type { VegaValueFormatterParams } from '@vegaprotocol/ui-toolkit';
|
||||
import type * as Schema from '@vegaprotocol/types';
|
||||
@ -296,6 +297,21 @@ export const MarketList = () => {
|
||||
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>
|
||||
|
||||
<HealthDialog
|
||||
|
@ -31,6 +31,8 @@ import {
|
||||
getTargetStake,
|
||||
} from './utils/liquidity-utils';
|
||||
import type { Provider, LiquidityProvisionMarket } from './utils';
|
||||
import { proposalsListDataProvider } from '@vegaprotocol/governance';
|
||||
import type { Proposal } from '@vegaprotocol/types';
|
||||
|
||||
export interface FeeLevels {
|
||||
commitmentAmount: number;
|
||||
@ -44,6 +46,7 @@ export type Market = MarketWithData &
|
||||
dayVolume: string;
|
||||
liquidityCommitted: number;
|
||||
volumeChange: string;
|
||||
proposal?: Proposal;
|
||||
};
|
||||
|
||||
export interface Markets {
|
||||
@ -63,7 +66,8 @@ const getData = (
|
||||
export const addData = (
|
||||
markets: (MarketWithData & MarketWithCandles)[],
|
||||
marketsCandles24hAgo: MarketCandles[],
|
||||
marketsLiquidity: LiquidityProvisionMarket[]
|
||||
marketsLiquidity: LiquidityProvisionMarket[],
|
||||
proposals: Proposal[]
|
||||
) => {
|
||||
return markets.map((market) => {
|
||||
const dayVolume = calcDayVolume(market.candles);
|
||||
@ -76,6 +80,9 @@ export const addData = (
|
||||
marketsLiquidity
|
||||
) as Provider[];
|
||||
|
||||
const proposalForMarket =
|
||||
proposals && proposals.find((p) => p.id === market.id);
|
||||
|
||||
return {
|
||||
...market,
|
||||
dayVolume,
|
||||
@ -83,6 +90,7 @@ export const addData = (
|
||||
liquidityCommitted: sumLiquidityCommitted(liquidityProviders),
|
||||
feeLevels: getFeeLevels(liquidityProviders) || [],
|
||||
target: getTargetStake(market.id, marketsLiquidity),
|
||||
proposal: proposalForMarket,
|
||||
};
|
||||
});
|
||||
};
|
||||
@ -106,12 +114,14 @@ const liquidityProvisionProvider = makeDerivedDataProvider<Markets, never>(
|
||||
interval: Schema.Interval.INTERVAL_I1D,
|
||||
}),
|
||||
liquidityMarketsProvider,
|
||||
proposalsListDataProvider,
|
||||
],
|
||||
(parts) => {
|
||||
const data = addData(
|
||||
parts[0] as (MarketWithData & MarketWithCandles)[],
|
||||
parts[1] as MarketCandles[],
|
||||
parts[2] as LiquidityProvisionMarket[]
|
||||
parts[2] as LiquidityProvisionMarket[],
|
||||
parts[3] as Proposal[]
|
||||
);
|
||||
return { markets: data };
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user