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 quoteUnit = getQuoteName(market);
|
||||
|
||||
const dataSourceSpec = market.markPriceConfiguration.dataSourcesSpec?.[1];
|
||||
const sourceType =
|
||||
dataSourceSpec?.sourceType.__typename === 'DataSourceDefinitionExternal' &&
|
||||
dataSourceSpec?.sourceType.sourceType.__typename === 'EthCallSpec' &&
|
||||
dataSourceSpec?.sourceType.sourceType;
|
||||
|
||||
return (
|
||||
<>
|
||||
<HeaderStat heading={t('Mark Price')} testId="market-price">
|
||||
@ -125,14 +131,25 @@ export const MarketHeaderStats = ({ market }: MarketHeaderStatsProps) => {
|
||||
{t(
|
||||
'The external time weighted average price (TWAP) received from the data source defined in the data sourcing specification.'
|
||||
)}
|
||||
{DocsLinks && (
|
||||
<ExternalLink
|
||||
href={DocsLinks.ETH_DATA_SOURCES}
|
||||
className="mt-2"
|
||||
>
|
||||
{t('Find out more')}
|
||||
</ExternalLink>
|
||||
)}
|
||||
<div className="flex flex-col gap-1">
|
||||
{DocsLinks && (
|
||||
<ExternalLink
|
||||
href={DocsLinks.ETH_DATA_SOURCES}
|
||||
className="mt-2"
|
||||
>
|
||||
{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>
|
||||
}
|
||||
testId="index-price"
|
||||
|
@ -17,6 +17,14 @@ export function generateMarket(override?: PartialDeep<Market>): Market {
|
||||
close: '',
|
||||
open: '',
|
||||
},
|
||||
markPriceConfiguration: {
|
||||
decayWeight: '',
|
||||
decayPower: 0,
|
||||
cashAmount: '',
|
||||
SourceStalenessTolerance: [],
|
||||
CompositePriceType:
|
||||
Schema.CompositePriceType.COMPOSITE_PRICE_TYPE_LAST_TRADE,
|
||||
},
|
||||
tradableInstrument: {
|
||||
__typename: 'TradableInstrument',
|
||||
instrument: {
|
||||
|
@ -51,6 +51,14 @@ export const generateFill = (override?: PartialDeep<Trade>) => {
|
||||
positionDecimalPlaces: 0,
|
||||
decimalPlaces: 5,
|
||||
tickSize: '1',
|
||||
markPriceConfiguration: {
|
||||
decayWeight: '',
|
||||
decayPower: 0,
|
||||
cashAmount: '',
|
||||
SourceStalenessTolerance: [],
|
||||
CompositePriceType:
|
||||
Schema.CompositePriceType.COMPOSITE_PRICE_TYPE_LAST_TRADE,
|
||||
},
|
||||
fees: {
|
||||
__typename: 'Fees',
|
||||
factors: {
|
||||
|
@ -1,6 +1,7 @@
|
||||
import merge from 'lodash/merge';
|
||||
import type { PartialDeep } from 'type-fest';
|
||||
import type { FundingPayment } from './funding-payments-data-provider';
|
||||
import { CompositePriceType } from '@vegaprotocol/types';
|
||||
|
||||
export const generateFundingPayment = (
|
||||
override?: PartialDeep<FundingPayment>
|
||||
@ -27,6 +28,13 @@ export const generateFundingPayment = (
|
||||
makerFee: '0.1',
|
||||
},
|
||||
},
|
||||
markPriceConfiguration: {
|
||||
decayWeight: '',
|
||||
decayPower: 0,
|
||||
cashAmount: '',
|
||||
SourceStalenessTolerance: [],
|
||||
CompositePriceType: CompositePriceType.COMPOSITE_PRICE_TYPE_LAST_TRADE,
|
||||
},
|
||||
marketTimestamps: {
|
||||
__typename: 'MarketTimestamps',
|
||||
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
|
||||
parentMarketID
|
||||
successorMarketID
|
||||
markPriceConfiguration {
|
||||
...PriceConfiguration
|
||||
}
|
||||
fees {
|
||||
factors {
|
||||
makerFee
|
||||
|
@ -159,6 +159,14 @@ export const createMarketFragment = (
|
||||
__typename: 'TradableInstrument',
|
||||
},
|
||||
__typename: 'Market',
|
||||
markPriceConfiguration: {
|
||||
decayWeight: '',
|
||||
decayPower: 0,
|
||||
cashAmount: '',
|
||||
SourceStalenessTolerance: [],
|
||||
CompositePriceType:
|
||||
Schema.CompositePriceType.COMPOSITE_PRICE_TYPE_LAST_TRADE,
|
||||
},
|
||||
};
|
||||
|
||||
return merge(cloneDeep(defaultFragment), override);
|
||||
|
@ -21,6 +21,14 @@ export const generateOrder = (partialOrder?: PartialDeep<Order>) => {
|
||||
makerFee: '0.1',
|
||||
},
|
||||
},
|
||||
markPriceConfiguration: {
|
||||
decayWeight: '',
|
||||
decayPower: 0,
|
||||
cashAmount: '',
|
||||
SourceStalenessTolerance: [],
|
||||
CompositePriceType:
|
||||
Schema.CompositePriceType.COMPOSITE_PRICE_TYPE_LAST_TRADE,
|
||||
},
|
||||
marketTimestamps: {
|
||||
__typename: 'MarketTimestamps',
|
||||
proposed: '2022-08-23T11:36:32.252490405Z',
|
||||
|
@ -31,6 +31,14 @@ export const generateStopOrder = (
|
||||
makerFee: '0.1',
|
||||
},
|
||||
},
|
||||
markPriceConfiguration: {
|
||||
decayWeight: '',
|
||||
decayPower: 0,
|
||||
cashAmount: '',
|
||||
SourceStalenessTolerance: [],
|
||||
CompositePriceType:
|
||||
Schema.CompositePriceType.COMPOSITE_PRICE_TYPE_LAST_TRADE,
|
||||
},
|
||||
marketTimestamps: {
|
||||
__typename: 'MarketTimestamps',
|
||||
proposed: '2005-04-02T19:37:00.000Z',
|
||||
|
@ -132,7 +132,8 @@ export const update = <T extends Omit<OrderFieldsFragment, 'market'> & Cursor>(
|
||||
): T[] => {
|
||||
const updatedData = data ? [...data] : ([] as T[]);
|
||||
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 doesFilterPass =
|
||||
!variables || orderMatchFilters(orderUpdate, variables);
|
||||
@ -204,7 +205,7 @@ export const activeOrdersProvider = makeDerivedDataProvider<
|
||||
}
|
||||
const orders = partsData[0] as ReturnType<typeof getData>;
|
||||
return variables.marketId
|
||||
? orders.filter((order) => variables.marketId === order.market.id)
|
||||
? orders.filter((order) => variables.marketId === order?.market.id)
|
||||
: orders;
|
||||
}
|
||||
);
|
||||
|
@ -3,6 +3,7 @@ import { OrderViewDialog } from './order-view-dialog';
|
||||
import type { Order } from '../order-data-provider';
|
||||
import { BrowserRouter } from 'react-router-dom';
|
||||
import {
|
||||
CompositePriceType,
|
||||
OrderStatus,
|
||||
OrderTimeInForce,
|
||||
OrderType,
|
||||
@ -18,6 +19,14 @@ describe('OrderViewDialog', () => {
|
||||
id: 'b66cd4be223dfd900a4750bb5175e17d8f678996877d262be4c749a99e22a970',
|
||||
decimalPlaces: 5,
|
||||
positionDecimalPlaces: 3,
|
||||
markPriceConfiguration: {
|
||||
decayWeight: '',
|
||||
decayPower: 0,
|
||||
cashAmount: '',
|
||||
SourceStalenessTolerance: [],
|
||||
CompositePriceType:
|
||||
CompositePriceType.COMPOSITE_PRICE_TYPE_LAST_TRADE,
|
||||
},
|
||||
tickSize: '1',
|
||||
fees: {
|
||||
__typename: 'Fees',
|
||||
|
@ -148,6 +148,14 @@ describe('WithdrawFormContainer', () => {
|
||||
liquidityFee: '0.001',
|
||||
},
|
||||
},
|
||||
markPriceConfiguration: {
|
||||
decayWeight: '',
|
||||
decayPower: 0,
|
||||
cashAmount: '',
|
||||
SourceStalenessTolerance: [],
|
||||
CompositePriceType:
|
||||
Types.CompositePriceType.COMPOSITE_PRICE_TYPE_LAST_TRADE,
|
||||
},
|
||||
tradableInstrument: {
|
||||
__typename: 'TradableInstrument',
|
||||
instrument: {
|
||||
|
Loading…
Reference in New Issue
Block a user