diff --git a/apps/governance/src/routes/proposals/components/proposal-market-data/proposal-market-data.tsx b/apps/governance/src/routes/proposals/components/proposal-market-data/proposal-market-data.tsx index 63ed16cdb..5f49d20b5 100644 --- a/apps/governance/src/routes/proposals/components/proposal-market-data/proposal-market-data.tsx +++ b/apps/governance/src/routes/proposals/components/proposal-market-data/proposal-market-data.tsx @@ -14,8 +14,6 @@ import { SettlementAssetInfoPanel, } from '@vegaprotocol/markets'; import { - Accordion, - AccordionItem, Button, CopyWithTooltip, Dialog, @@ -42,6 +40,9 @@ export const useMarketDataDialogStore = create( }) ); +const marketDataHeaderStyles = + 'font-alpha calt text-base border-b border-vega-dark-200 mt-2 py-2'; + export const ProposalMarketData = ({ marketData, parentMarketData, @@ -64,12 +65,6 @@ export const ProposalMarketData = ({ .dataSourceSpecForSettlementData.data as DataSourceDefinition) : undefined; - const settlementScheduleData = - marketData.tradableInstrument.instrument.product.__typename === 'Perpetual' - ? (marketData.tradableInstrument.instrument.product - .dataSourceSpecForSettlementSchedule.data as DataSourceDefinition) - : undefined; - const parentSettlementData = parentMarketData?.tradableInstrument.instrument.product.__typename === 'Future' || @@ -79,6 +74,12 @@ export const ProposalMarketData = ({ ?.dataSourceSpecForSettlementData?.data : undefined; + const settlementScheduleData = + marketData.tradableInstrument.instrument.product.__typename === 'Perpetual' + ? (marketData.tradableInstrument.instrument.product + .dataSourceSpecForSettlementSchedule.data as DataSourceDefinition) + : undefined; + const parentSettlementScheduleData = parentMarketData?.tradableInstrument.instrument.product.__typename === 'Perpetual' @@ -87,16 +88,17 @@ export const ProposalMarketData = ({ : undefined; const terminationData = - 'dataSourceSpecForTradingTermination' in - marketData.tradableInstrument.instrument.product && - (marketData.tradableInstrument.instrument.product - .dataSourceSpecForTradingTermination.data as DataSourceDefinition); + marketData.tradableInstrument.instrument.product.__typename === 'Future' + ? (marketData.tradableInstrument.instrument.product + .dataSourceSpecForTradingTermination.data as DataSourceDefinition) + : undefined; + const parentTerminationData = - parentMarketData && - 'dataSourceSpecForTradingTermination' in - parentMarketData.tradableInstrument.instrument.product && - parentMarketData?.tradableInstrument.instrument?.product - ?.dataSourceSpecForTradingTermination?.data; + parentMarketData?.tradableInstrument.instrument.product.__typename === + 'Future' + ? parentMarketData?.tradableInstrument.instrument?.product + ?.dataSourceSpecForTradingTermination?.data + : undefined; // TODO add settlementScheduleData for Perp Proposal @@ -112,6 +114,14 @@ export const ProposalMarketData = ({ parentTerminationData !== undefined && isEqual(terminationData, parentTerminationData); + const showParentPriceMonitoringBounds = + parentMarketData?.priceMonitoringSettings?.parameters?.triggers !== + undefined && + !isEqual( + marketData.priceMonitoringSettings?.parameters?.triggers, + parentMarketData?.priceMonitoringSettings?.parameters?.triggers + ); + const getSigners = (data: DataSourceDefinition) => { if (data.sourceType.__typename === 'DataSourceDefinitionExternal') { const signers = @@ -147,172 +157,160 @@ export const ProposalMarketData = ({
- - - } - /> - - } - /> - {settlementData && - terminationData && - isEqual( - getSigners(settlementData), - getSigners(terminationData) - ) ? ( - {t('Key details')} + + +

{t('Instrument')}

+ + + {settlementData && + terminationData && + isEqual(getSigners(settlementData), getSigners(terminationData)) ? ( + <> +

{t('Oracle')}

+ + + + ) : ( + <> +

+ {t('Settlement oracle')} +

+ + + {marketData.tradableInstrument.instrument.product.__typename === + 'Future' && ( +
+

+ {t('Termination oracle')} +

- } - /> - ) : ( - <> - - } - /> +
+ )} - - } - /> - - - } - /> - - )} - {/*Note: successor markets will not differ in their settlement*/} - {/*assets, so no need to pass in parent market data for comparison.*/} - } - /> - - } - /> - - } - /> - - } - /> - - } - /> - {( - marketData.priceMonitoringSettings?.parameters?.triggers || [] - ).map((_, triggerIndex) => ( - +

+ {t('Settlement schedule oracle')} +

+ +
+ )} + + )} + + {/*Note: successor markets will not differ in their settlement*/} + {/*assets, so no need to pass in parent market data for comparison.*/} + +

{t('Settlement assets')}

+ + +

{t('Metadata')}

+ + +

{t('Risk model')}

+ + +

{t('Risk parameters')}

+ + +

{t('Risk factors')}

+ + + {showParentPriceMonitoringBounds && + ( + parentMarketData?.priceMonitoringSettings?.parameters + ?.triggers || [] + ).map((_, triggerIndex) => ( + <> +

+ {t(`Parent price monitoring bounds ${triggerIndex + 1}`)} +

+ +
+ - } - /> +
+ ))} - - } - /> - + + {( + marketData.priceMonitoringSettings?.parameters?.triggers || [] + ).map((_, triggerIndex) => ( + <> +

+ {t(`Price monitoring bounds ${triggerIndex + 1}`)} +

+ + + + ))} + +

+ {t('Liquidity monitoring parameters')} +

+ )} diff --git a/libs/markets/src/lib/components/market-info/info-key-value-table.tsx b/libs/markets/src/lib/components/market-info/info-key-value-table.tsx index e717453bb..483b0aaa9 100644 --- a/libs/markets/src/lib/components/market-info/info-key-value-table.tsx +++ b/libs/markets/src/lib/components/market-info/info-key-value-table.tsx @@ -98,7 +98,7 @@ export const Row = ({
{valueDiffersFromParentMarket ? (
- + {getFormattedValue(parentValue)} {formattedValue} diff --git a/libs/markets/src/lib/components/market-info/market-info-panels.tsx b/libs/markets/src/lib/components/market-info/market-info-panels.tsx index 315c9fc85..7b50b9a26 100644 --- a/libs/markets/src/lib/components/market-info/market-info-panels.tsx +++ b/libs/markets/src/lib/components/market-info/market-info-panels.tsx @@ -1,13 +1,14 @@ import isEqual from 'lodash/isEqual'; import type { ReactNode } from 'react'; -import { Fragment, useState } from 'react'; -import { useMemo } from 'react'; +import { Fragment, useMemo, useState } from 'react'; import { AssetDetailsTable, useAssetDataProvider } from '@vegaprotocol/assets'; import { t } from '@vegaprotocol/i18n'; import { marketDataProvider } from '../../market-data-provider'; import { totalFeesPercentage } from '../../market-utils'; import { ExternalLink, + Intent, + Lozenge, Splash, Tooltip, VegaIcon, @@ -26,9 +27,15 @@ import type { } from './market-info-data-provider'; import { Last24hVolume } from '../last-24h-volume'; import BigNumber from 'bignumber.js'; -import type { DataSourceDefinition, SignerKind } from '@vegaprotocol/types'; -import { ConditionOperatorMapping } from '@vegaprotocol/types'; -import { MarketTradingModeMapping } from '@vegaprotocol/types'; +import type { + DataSourceDefinition, + MarketTradingMode, + SignerKind, +} from '@vegaprotocol/types'; +import { + ConditionOperatorMapping, + MarketTradingModeMapping, +} from '@vegaprotocol/types'; import { DApp, FLAGS, @@ -47,9 +54,7 @@ import { useSuccessorMarketQuery, } from '../../__generated__'; import { useSuccessorMarketProposalDetailsQuery } from '@vegaprotocol/proposals'; -import type { MarketTradingMode } from '@vegaprotocol/types'; import { getQuoteName, getAsset } from '../../market-utils'; -import type { Signer } from '@vegaprotocol/types'; import classNames from 'classnames'; import compact from 'lodash/compact'; @@ -564,7 +569,6 @@ export const RiskFactorsInfoPanel = ({ export const PriceMonitoringBoundsInfoPanel = ({ market, triggerIndex, - parentMarket, }: MarketInfoProps & { triggerIndex: number; }) => { @@ -573,31 +577,12 @@ export const PriceMonitoringBoundsInfoPanel = ({ variables: { marketId: market.id }, }); - const { data: parentData } = useDataProvider({ - dataProvider: marketDataProvider, - variables: { marketId: parentMarket?.id || '' }, - skip: - !parentMarket || - !parentMarket?.priceMonitoringSettings?.parameters?.triggers?.[ - triggerIndex - ], - }); - const quoteUnit = getQuoteName(market); - const parentQuoteUnit = parentMarket && getQuoteName(parentMarket); - const isParentQuoteUnitEqual = quoteUnit === parentQuoteUnit; const trigger = market.priceMonitoringSettings?.parameters?.triggers?.[triggerIndex]; - const parentTrigger = - parentMarket?.priceMonitoringSettings?.parameters?.triggers?.[triggerIndex]; - const isParentTriggerEqual = isEqual(trigger, parentTrigger); const bounds = data?.priceMonitoringBounds?.[triggerIndex]; - const parentBounds = parentData?.priceMonitoringBounds?.[triggerIndex]; - - const shouldShowParentData = - isParentQuoteUnitEqual && isParentTriggerEqual && !!parentBounds; if (!trigger) { console.error( @@ -625,14 +610,6 @@ export const PriceMonitoringBoundsInfoPanel = ({ highestPrice: bounds.maxValidPrice, lowestPrice: bounds.minValidPrice, }} - parentData={ - shouldShowParentData - ? { - highestPrice: parentBounds.maxValidPrice, - lowestPrice: parentBounds.minValidPrice, - } - : undefined - } decimalPlaces={market.decimalPlaces} assetSymbol={quoteUnit} /> @@ -719,43 +696,78 @@ export const OracleInfoPanel = ({ parentDataSourceSpec = parentDataSourceSpec.dataSourceSpec; } - // We'll only provide successor parent data (if it differs) to the - // DataSourceProof component. Having an old external link struck through - // is unlikely to be useful. + const shouldShowParentData = + parentMarket !== undefined && + parentDataSourceSpecId !== undefined && + !isEqual(dataSourceSpec, parentDataSourceSpec); + + const wrapperClasses = classNames('mb-4', { + 'flex items-center gap-6': shouldShowParentData, + }); + return ( -
- {dataSourceSpec && dataSourceSpecId && ( - + <> + {shouldShowParentData && ( + + {t('Updated')} + )} - {dataSourceSpecId && ( - - {type === 'settlementData' - ? t('View settlement data specification') - : type === 'settlementSchedule' - ? t('View settlement schedule specification') - : t('View termination specification')} - - )} -
+ +
+ {shouldShowParentData && + parentDataSourceSpec && + parentDataSourceSpecId && + parentProduct && ( +
+ + + {dataSourceSpecId && ( + + {type === 'settlementData' + ? t('View settlement data specification') + : type === 'settlementSchedule' + ? t('View settlement schedule specification') + : t('View termination specification')} + + )} +
+ )} + +
+ {dataSourceSpecId && dataSourceSpec && ( + + )} + + {dataSourceSpecId && ( + + {type === 'settlementData' + ? t('View settlement data specification') + : type === 'settlementSchedule' + ? t('View settlement schedule specification') + : t('View termination specification')} + + )} +
+
+ ); }; @@ -764,34 +776,17 @@ export const DataSourceProof = ({ providers, type, dataSourceSpecId, - parentData, - parentDataSourceSpecId, }: { data: DataSourceDefinition; providers: Provider[] | undefined; type: 'settlementData' | 'termination' | 'settlementSchedule'; dataSourceSpecId: string; - parentData?: DataSourceDefinition; - parentDataSourceSpecId?: string; }) => { - // If this is a successor market, we'll only pass parent data to child - // components for comparison if the data differs from the parent market. if (data.sourceType.__typename === 'DataSourceDefinitionExternal') { const signers = ('signers' in data.sourceType.sourceType && data.sourceType.sourceType.signers) || []; - let parentSigners: Signer[]; - - if ( - parentData && - parentData.sourceType.__typename === 'DataSourceDefinitionExternal' - ) { - parentSigners = - ('signers' in parentData.sourceType.sourceType && - parentData.sourceType.sourceType?.signers) || - []; - } if (!providers?.length) { return ; @@ -799,34 +794,15 @@ export const DataSourceProof = ({ return (
- {signers.map(({ signer }, i) => { - const parentSigner = parentSigners?.find( - ({ signer: ParentSigner }) => - ParentSigner.__typename === signer.__typename - )?.signer; - - const isParentSignerEqual = isEqual(signer, parentSigner); - - return isParentSignerEqual ? ( - - ) : ( - - ); - })} + {signers.map(({ signer }, i) => ( + + ))}
); } @@ -939,22 +915,13 @@ const OracleLink = ({ signer, type, dataSourceSpecId, - parentSigner, - parentDataSourceSpecId, }: { providers: Provider[]; signer: SignerKind; type: 'settlementData' | 'termination' | 'settlementSchedule'; dataSourceSpecId: string; - parentSigner?: SignerKind; - parentDataSourceSpecId?: string; }) => { - // If this is a successor market, the parent market data will only have been passed - // in if it differs from the current data. const signerProviders = getSignerProviders(signer, providers); - const parentSignerProviders = parentSigner - ? getSignerProviders(parentSigner, providers) - : []; if (!signerProviders.length) { return ; @@ -962,34 +929,13 @@ const OracleLink = ({ return (
- {signerProviders.map((provider) => { - // Making the assumption here that if the provider name is the same, - // that it is the same provider that the parent market used. - const parentProvider = parentSignerProviders.find( - (p) => p.name === provider.name - ); - - const isParentProviderEqual = - parentProvider && isEqual(provider, parentProvider); - - // We only want to pass the parent data to the child component if the - // data differs from the parent market. - return isParentProviderEqual ? ( - - ) : ( - - ); - })} + {signerProviders.map((provider) => ( + + ))}
); }; @@ -1012,18 +958,13 @@ const NoOracleProof = ({ const OracleProfile = (props: { provider: Provider; dataSourceSpecId: string; - parentProvider?: Provider; - parentDataSourceSpecId?: string; }) => { - // If this is a successor market, the parent market data will only have been passed - // in if it differs from the current data. const [open, onChange] = useState(false); return (
onChange(!open)} - parentProvider={props.parentProvider} />
diff --git a/libs/markets/src/lib/components/oracle-basic-profile/oracle-basic-profile.tsx b/libs/markets/src/lib/components/oracle-basic-profile/oracle-basic-profile.tsx index b9243ffc7..a8afd2966 100644 --- a/libs/markets/src/lib/components/oracle-basic-profile/oracle-basic-profile.tsx +++ b/libs/markets/src/lib/components/oracle-basic-profile/oracle-basic-profile.tsx @@ -5,7 +5,6 @@ import { ExternalLink, Icon, Intent, - Lozenge, VegaIcon, VegaIconNames, } from '@vegaprotocol/ui-toolkit'; @@ -60,12 +59,10 @@ export const OracleBasicProfile = ({ provider, onClick, markets: oracleMarkets, - parentProvider, }: { provider: Provider; markets?: OracleMarketSpecFieldsFragment[] | undefined; onClick?: (value?: boolean) => void; - parentProvider?: Provider; }) => { const { icon, message, intent } = getVerifiedStatusIcon(provider); @@ -81,14 +78,8 @@ export const OracleBasicProfile = ({ icon: getLinkIcon(proof.type), })); - // If this is a successor market and there's a different parent provider, - // we'll just show that there's been a change, rather than add old data - // in alongside the new provider. return ( <> - {parentProvider && ( - {t('Updated')} - )} {provider.url && (