feat(trading): show oracle spec in index price stats (#6113)
Co-authored-by: Matthew Russell <mattrussell36@gmail.com>
This commit is contained in:
parent
ebb0db3b37
commit
17946ae149
@ -45,6 +45,12 @@ export const MarketHeaderStats = ({ market }: MarketHeaderStatsProps) => {
|
|||||||
const asset = getAsset(market);
|
const asset = getAsset(market);
|
||||||
const quoteUnit = getQuoteName(market);
|
const quoteUnit = getQuoteName(market);
|
||||||
|
|
||||||
|
const dataSourceSpec = market.markPriceConfiguration.dataSourcesSpec?.[1];
|
||||||
|
const sourceType =
|
||||||
|
dataSourceSpec?.sourceType.__typename === 'DataSourceDefinitionExternal' &&
|
||||||
|
dataSourceSpec?.sourceType.sourceType.__typename === 'EthCallSpec' &&
|
||||||
|
dataSourceSpec?.sourceType.sourceType;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<HeaderStat heading={t('Mark Price')} testId="market-price">
|
<HeaderStat heading={t('Mark Price')} testId="market-price">
|
||||||
@ -125,14 +131,25 @@ export const MarketHeaderStats = ({ market }: MarketHeaderStatsProps) => {
|
|||||||
{t(
|
{t(
|
||||||
'The external time weighted average price (TWAP) received from the data source defined in the data sourcing specification.'
|
'The external time weighted average price (TWAP) received from the data source defined in the data sourcing specification.'
|
||||||
)}
|
)}
|
||||||
{DocsLinks && (
|
<div className="flex flex-col gap-1">
|
||||||
<ExternalLink
|
{DocsLinks && (
|
||||||
href={DocsLinks.ETH_DATA_SOURCES}
|
<ExternalLink
|
||||||
className="mt-2"
|
href={DocsLinks.ETH_DATA_SOURCES}
|
||||||
>
|
className="mt-2"
|
||||||
{t('Find out more')}
|
>
|
||||||
</ExternalLink>
|
{t('Find out more')}
|
||||||
)}
|
</ExternalLink>
|
||||||
|
)}
|
||||||
|
{sourceType && (
|
||||||
|
<ExternalLink
|
||||||
|
data-testid="oracle-spec-links"
|
||||||
|
href={`${VEGA_EXPLORER_URL}/markets/${market.id}/oracles#${sourceType.address}`}
|
||||||
|
className="text-xs my-1"
|
||||||
|
>
|
||||||
|
{t('Oracle specification')}
|
||||||
|
</ExternalLink>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
testId="index-price"
|
testId="index-price"
|
||||||
|
@ -17,6 +17,14 @@ export function generateMarket(override?: PartialDeep<Market>): Market {
|
|||||||
close: '',
|
close: '',
|
||||||
open: '',
|
open: '',
|
||||||
},
|
},
|
||||||
|
markPriceConfiguration: {
|
||||||
|
decayWeight: '',
|
||||||
|
decayPower: 0,
|
||||||
|
cashAmount: '',
|
||||||
|
SourceStalenessTolerance: [],
|
||||||
|
CompositePriceType:
|
||||||
|
Schema.CompositePriceType.COMPOSITE_PRICE_TYPE_LAST_TRADE,
|
||||||
|
},
|
||||||
tradableInstrument: {
|
tradableInstrument: {
|
||||||
__typename: 'TradableInstrument',
|
__typename: 'TradableInstrument',
|
||||||
instrument: {
|
instrument: {
|
||||||
|
@ -51,6 +51,14 @@ export const generateFill = (override?: PartialDeep<Trade>) => {
|
|||||||
positionDecimalPlaces: 0,
|
positionDecimalPlaces: 0,
|
||||||
decimalPlaces: 5,
|
decimalPlaces: 5,
|
||||||
tickSize: '1',
|
tickSize: '1',
|
||||||
|
markPriceConfiguration: {
|
||||||
|
decayWeight: '',
|
||||||
|
decayPower: 0,
|
||||||
|
cashAmount: '',
|
||||||
|
SourceStalenessTolerance: [],
|
||||||
|
CompositePriceType:
|
||||||
|
Schema.CompositePriceType.COMPOSITE_PRICE_TYPE_LAST_TRADE,
|
||||||
|
},
|
||||||
fees: {
|
fees: {
|
||||||
__typename: 'Fees',
|
__typename: 'Fees',
|
||||||
factors: {
|
factors: {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import merge from 'lodash/merge';
|
import merge from 'lodash/merge';
|
||||||
import type { PartialDeep } from 'type-fest';
|
import type { PartialDeep } from 'type-fest';
|
||||||
import type { FundingPayment } from './funding-payments-data-provider';
|
import type { FundingPayment } from './funding-payments-data-provider';
|
||||||
|
import { CompositePriceType } from '@vegaprotocol/types';
|
||||||
|
|
||||||
export const generateFundingPayment = (
|
export const generateFundingPayment = (
|
||||||
override?: PartialDeep<FundingPayment>
|
override?: PartialDeep<FundingPayment>
|
||||||
@ -27,6 +28,13 @@ export const generateFundingPayment = (
|
|||||||
makerFee: '0.1',
|
makerFee: '0.1',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
markPriceConfiguration: {
|
||||||
|
decayWeight: '',
|
||||||
|
decayPower: 0,
|
||||||
|
cashAmount: '',
|
||||||
|
SourceStalenessTolerance: [],
|
||||||
|
CompositePriceType: CompositePriceType.COMPOSITE_PRICE_TYPE_LAST_TRADE,
|
||||||
|
},
|
||||||
marketTimestamps: {
|
marketTimestamps: {
|
||||||
__typename: 'MarketTimestamps',
|
__typename: 'MarketTimestamps',
|
||||||
proposed: '2005-03-31T19:37:00.000Z',
|
proposed: '2005-03-31T19:37:00.000Z',
|
||||||
|
File diff suppressed because one or more lines are too long
12
libs/markets/src/lib/__generated__/markets.ts
generated
12
libs/markets/src/lib/__generated__/markets.ts
generated
File diff suppressed because one or more lines are too long
@ -63,6 +63,9 @@ fragment MarketFields on Market {
|
|||||||
tickSize
|
tickSize
|
||||||
parentMarketID
|
parentMarketID
|
||||||
successorMarketID
|
successorMarketID
|
||||||
|
markPriceConfiguration {
|
||||||
|
...PriceConfiguration
|
||||||
|
}
|
||||||
fees {
|
fees {
|
||||||
factors {
|
factors {
|
||||||
makerFee
|
makerFee
|
||||||
|
@ -159,6 +159,14 @@ export const createMarketFragment = (
|
|||||||
__typename: 'TradableInstrument',
|
__typename: 'TradableInstrument',
|
||||||
},
|
},
|
||||||
__typename: 'Market',
|
__typename: 'Market',
|
||||||
|
markPriceConfiguration: {
|
||||||
|
decayWeight: '',
|
||||||
|
decayPower: 0,
|
||||||
|
cashAmount: '',
|
||||||
|
SourceStalenessTolerance: [],
|
||||||
|
CompositePriceType:
|
||||||
|
Schema.CompositePriceType.COMPOSITE_PRICE_TYPE_LAST_TRADE,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
return merge(cloneDeep(defaultFragment), override);
|
return merge(cloneDeep(defaultFragment), override);
|
||||||
|
@ -21,6 +21,14 @@ export const generateOrder = (partialOrder?: PartialDeep<Order>) => {
|
|||||||
makerFee: '0.1',
|
makerFee: '0.1',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
markPriceConfiguration: {
|
||||||
|
decayWeight: '',
|
||||||
|
decayPower: 0,
|
||||||
|
cashAmount: '',
|
||||||
|
SourceStalenessTolerance: [],
|
||||||
|
CompositePriceType:
|
||||||
|
Schema.CompositePriceType.COMPOSITE_PRICE_TYPE_LAST_TRADE,
|
||||||
|
},
|
||||||
marketTimestamps: {
|
marketTimestamps: {
|
||||||
__typename: 'MarketTimestamps',
|
__typename: 'MarketTimestamps',
|
||||||
proposed: '2022-08-23T11:36:32.252490405Z',
|
proposed: '2022-08-23T11:36:32.252490405Z',
|
||||||
|
@ -31,6 +31,14 @@ export const generateStopOrder = (
|
|||||||
makerFee: '0.1',
|
makerFee: '0.1',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
markPriceConfiguration: {
|
||||||
|
decayWeight: '',
|
||||||
|
decayPower: 0,
|
||||||
|
cashAmount: '',
|
||||||
|
SourceStalenessTolerance: [],
|
||||||
|
CompositePriceType:
|
||||||
|
Schema.CompositePriceType.COMPOSITE_PRICE_TYPE_LAST_TRADE,
|
||||||
|
},
|
||||||
marketTimestamps: {
|
marketTimestamps: {
|
||||||
__typename: 'MarketTimestamps',
|
__typename: 'MarketTimestamps',
|
||||||
proposed: '2005-04-02T19:37:00.000Z',
|
proposed: '2005-04-02T19:37:00.000Z',
|
||||||
|
@ -132,7 +132,8 @@ export const update = <T extends Omit<OrderFieldsFragment, 'market'> & Cursor>(
|
|||||||
): T[] => {
|
): T[] => {
|
||||||
const updatedData = data ? [...data] : ([] as T[]);
|
const updatedData = data ? [...data] : ([] as T[]);
|
||||||
delta.forEach((orderUpdate) => {
|
delta.forEach((orderUpdate) => {
|
||||||
const index = data?.findIndex((order) => order.id === orderUpdate.id) ?? -1;
|
const index =
|
||||||
|
data?.findIndex((order) => order?.id === orderUpdate.id) ?? -1;
|
||||||
const newer = !data?.length || orderUpdate.createdAt >= data[0].createdAt;
|
const newer = !data?.length || orderUpdate.createdAt >= data[0].createdAt;
|
||||||
const doesFilterPass =
|
const doesFilterPass =
|
||||||
!variables || orderMatchFilters(orderUpdate, variables);
|
!variables || orderMatchFilters(orderUpdate, variables);
|
||||||
@ -204,7 +205,7 @@ export const activeOrdersProvider = makeDerivedDataProvider<
|
|||||||
}
|
}
|
||||||
const orders = partsData[0] as ReturnType<typeof getData>;
|
const orders = partsData[0] as ReturnType<typeof getData>;
|
||||||
return variables.marketId
|
return variables.marketId
|
||||||
? orders.filter((order) => variables.marketId === order.market.id)
|
? orders.filter((order) => variables.marketId === order?.market.id)
|
||||||
: orders;
|
: orders;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -3,6 +3,7 @@ import { OrderViewDialog } from './order-view-dialog';
|
|||||||
import type { Order } from '../order-data-provider';
|
import type { Order } from '../order-data-provider';
|
||||||
import { BrowserRouter } from 'react-router-dom';
|
import { BrowserRouter } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
|
CompositePriceType,
|
||||||
OrderStatus,
|
OrderStatus,
|
||||||
OrderTimeInForce,
|
OrderTimeInForce,
|
||||||
OrderType,
|
OrderType,
|
||||||
@ -18,6 +19,14 @@ describe('OrderViewDialog', () => {
|
|||||||
id: 'b66cd4be223dfd900a4750bb5175e17d8f678996877d262be4c749a99e22a970',
|
id: 'b66cd4be223dfd900a4750bb5175e17d8f678996877d262be4c749a99e22a970',
|
||||||
decimalPlaces: 5,
|
decimalPlaces: 5,
|
||||||
positionDecimalPlaces: 3,
|
positionDecimalPlaces: 3,
|
||||||
|
markPriceConfiguration: {
|
||||||
|
decayWeight: '',
|
||||||
|
decayPower: 0,
|
||||||
|
cashAmount: '',
|
||||||
|
SourceStalenessTolerance: [],
|
||||||
|
CompositePriceType:
|
||||||
|
CompositePriceType.COMPOSITE_PRICE_TYPE_LAST_TRADE,
|
||||||
|
},
|
||||||
tickSize: '1',
|
tickSize: '1',
|
||||||
fees: {
|
fees: {
|
||||||
__typename: 'Fees',
|
__typename: 'Fees',
|
||||||
|
@ -148,6 +148,14 @@ describe('WithdrawFormContainer', () => {
|
|||||||
liquidityFee: '0.001',
|
liquidityFee: '0.001',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
markPriceConfiguration: {
|
||||||
|
decayWeight: '',
|
||||||
|
decayPower: 0,
|
||||||
|
cashAmount: '',
|
||||||
|
SourceStalenessTolerance: [],
|
||||||
|
CompositePriceType:
|
||||||
|
Types.CompositePriceType.COMPOSITE_PRICE_TYPE_LAST_TRADE,
|
||||||
|
},
|
||||||
tradableInstrument: {
|
tradableInstrument: {
|
||||||
__typename: 'TradableInstrument',
|
__typename: 'TradableInstrument',
|
||||||
instrument: {
|
instrument: {
|
||||||
|
Loading…
Reference in New Issue
Block a user