diff --git a/apps/explorer/src/app/components/markets/market-details.tsx b/apps/explorer/src/app/components/markets/market-details.tsx index 5cd4f3e34..34de36f0d 100644 --- a/apps/explorer/src/app/components/markets/market-details.tsx +++ b/apps/explorer/src/app/components/markets/market-details.tsx @@ -19,16 +19,16 @@ import { SettlementAssetInfoPanel, } from '@vegaprotocol/markets'; import { MarketInfoTable } from '@vegaprotocol/markets'; -import type { DataSourceDefinition } from '@vegaprotocol/types'; +import type { DataSourceFragment } from '@vegaprotocol/markets'; import isEqual from 'lodash/isEqual'; export const MarketDetails = ({ market }: { market: MarketInfoWithData }) => { if (!market) return null; const { product } = market.tradableInstrument.instrument; - const settlementData = getDataSourceSpecForSettlementData(product)?.data; - const terminationData = getDataSourceSpecForTradingTermination(product)?.data; + const settlementDataSource = getDataSourceSpecForSettlementData(product); + const terminationDataSource = getDataSourceSpecForTradingTermination(product); - const getSigners = (data: DataSourceDefinition) => { + const getSigners = ({ data }: DataSourceFragment) => { if (data.sourceType.__typename === 'DataSourceDefinitionExternal') { const signers = ('signers' in data.sourceType.sourceType && @@ -46,9 +46,12 @@ export const MarketDetails = ({ market }: { market: MarketInfoWithData }) => { }; const showTwoOracles = - settlementData && - terminationData && - isEqual(getSigners(settlementData), getSigners(terminationData)); + settlementDataSource && + terminationDataSource && + isEqual( + getSigners(settlementDataSource), + getSigners(terminationDataSource) + ); const headerClassName = 'font-alpha calt text-xl mt-4 border-b-2 pb-2'; 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 3aa853e0e..e9420b1a1 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 @@ -15,6 +15,7 @@ import { getDataSourceSpecForSettlementSchedule, getDataSourceSpecForSettlementData, getDataSourceSpecForTradingTermination, + getSigners, } from '@vegaprotocol/markets'; import { Button, @@ -26,7 +27,6 @@ import { import { SubHeading } from '../../../../components/heading'; import { CollapsibleToggle } from '../../../../components/collapsible-toggle'; import type { MarketInfo } from '@vegaprotocol/markets'; -import type { DataSourceDefinition } from '@vegaprotocol/types'; import { create } from 'zustand'; type MarketDataDialogState = { @@ -98,23 +98,6 @@ export const ProposalMarketData = ({ parentMarketData?.priceMonitoringSettings?.parameters?.triggers ); - const getSigners = (data: DataSourceDefinition) => { - if (data.sourceType.__typename === 'DataSourceDefinitionExternal') { - const signers = - ('signers' in data.sourceType.sourceType && - data.sourceType.sourceType.signers) || - []; - - return signers.map(({ signer }) => { - return ( - (signer.__typename === 'ETHAddress' && signer.address) || - (signer.__typename === 'PubKey' && signer.key) - ); - }); - } - return []; - }; - return (
{ - if (data.sourceType.__typename === 'DataSourceDefinitionExternal') { - const signers = - ('signers' in data.sourceType.sourceType && - data.sourceType.sourceType.signers) || - []; - - return signers.map(({ signer }, i) => { - return ( - (signer.__typename === 'ETHAddress' && signer.address) || - (signer.__typename === 'PubKey' && signer.key) - ); - }); - } - return []; - }; + const settlementDataSource = getDataSourceSpecForSettlementData(product); + const terminationDataSource = getDataSourceSpecForTradingTermination(product); + const settlementScheduleDataSource = + getDataSourceSpecForSettlementSchedule(product); const showOneOracleSection = (isFuture(product) && - settlementData && - terminationData && - isEqual(getSigners(settlementData), getSigners(terminationData))) || + settlementDataSource && + terminationDataSource && + isEqual( + getSigners(settlementDataSource), + getSigners(terminationDataSource) + )) || (isPerpetual(product) && - settlementData && - settlementScheduleData && - isEqual(getSigners(settlementData), getSigners(settlementScheduleData))); + settlementDataSource && + settlementScheduleDataSource && + isEqual( + getSigners(settlementDataSource), + getSigners(settlementScheduleDataSource) + )); return (
@@ -178,6 +168,15 @@ export const MarketInfoAccordion = ({ title={t('Instrument')} content={} /> + {settlementScheduleDataSource && ( + + } + /> + )} {showOneOracleSection ? ( } /> - {market.tradableInstrument.instrument.product.__typename === - 'Perpetual' && ( + {isPerpetual(product) && ( )} - {market.tradableInstrument.instrument.product.__typename === - 'Future' && ( + {isFuture(product) && ( { ); }; +export const FundingInfoPanel = ({ + dataSource, +}: { + dataSource: DataSourceFragment; +}) => { + const sourceType = dataSource.data.sourceType.sourceType; + if ( + sourceType.__typename !== 'DataSourceSpecConfigurationTimeTrigger' || + !sourceType.triggers?.[0]?.every + ) { + return null; + } + const { every, initial } = sourceType.triggers[0]; + const hours = Math.floor(every / (60 * 60)); + const minutes = Math.floor(every / 60) % 60; + const initialLabel = initial + ? ` ${t('from')} ${getDateTimeFormat().format(new Date(initial * 1000))}` + : ''; + return `${t('every')} ${formatDuration({ + hours, + minutes, + })} ${initialLabel}`; +}; + export const OracleInfoPanel = ({ market, type, diff --git a/libs/markets/src/lib/product.ts b/libs/markets/src/lib/product.ts index 0270dd253..9cd83511b 100644 --- a/libs/markets/src/lib/product.ts +++ b/libs/markets/src/lib/product.ts @@ -1,4 +1,5 @@ import type { + DataSourceFragment, FutureFragment, MarketInfo, PerpetualFragment, @@ -29,3 +30,20 @@ export const getDataSourceSpecBinding = (product: Product) => isFuture(product) || isPerpetual(product) ? product.dataSourceSpecBinding : undefined; + +export const getSigners = ({ data }: DataSourceFragment) => { + if (data.sourceType.__typename === 'DataSourceDefinitionExternal') { + const signers = + ('signers' in data.sourceType.sourceType && + data.sourceType.sourceType.signers) || + []; + + return signers.map(({ signer }, i) => { + return ( + (signer.__typename === 'ETHAddress' && signer.address) || + (signer.__typename === 'PubKey' && signer.key) + ); + }); + } + return []; +}; diff --git a/libs/types/src/global-types-mappings.ts b/libs/types/src/global-types-mappings.ts index 7ffe5afa3..3b4360e51 100644 --- a/libs/types/src/global-types-mappings.ts +++ b/libs/types/src/global-types-mappings.ts @@ -41,6 +41,7 @@ export const AccountTypeMapping: { ACCOUNT_TYPE_INSURANCE: 'Insurance', ACCOUNT_TYPE_MARGIN: 'Margin', ACCOUNT_TYPE_PENDING_TRANSFERS: 'Pending transfers', + ACCOUNT_TYPE_PENDING_FEE_REFERRAL_REWARD: 'Pending fee referral reward', ACCOUNT_TYPE_REWARD_LP_RECEIVED_FEES: 'Reward LP received fees', ACCOUNT_TYPE_REWARD_MAKER_RECEIVED_FEES: 'Reward Maker received fees', ACCOUNT_TYPE_REWARD_MARKET_PROPOSERS: 'Reward Market Proposers',