diff --git a/apps/liquidity-provision-dashboard/src/app/components/dashboard/market-list/market-list.tsx b/apps/liquidity-provision-dashboard/src/app/components/dashboard/market-list/market-list.tsx
index 356d42cbf..80c31ac8a 100644
--- a/apps/liquidity-provision-dashboard/src/app/components/dashboard/market-list/market-list.tsx
+++ b/apps/liquidity-provision-dashboard/src/app/components/dashboard/market-list/market-list.tsx
@@ -35,7 +35,6 @@ import { HealthDialog } from '../../health-dialog';
import { Status } from '../../status';
import { intentForStatus } from '../../../lib/utils';
import { formatDistanceToNow } from 'date-fns';
-import get from 'lodash/get';
import { getAsset } from '@vegaprotocol/markets';
export const MarketList = () => {
@@ -53,7 +52,7 @@ export const MarketList = () => {
return (
<>
{value}
- {get(getAsset(data), 'symbol')}
+ {getAsset(data).symbol}
>
);
},
diff --git a/apps/trading/client-pages/market/market-header-stats.tsx b/apps/trading/client-pages/market/market-header-stats.tsx
index 62d4cca53..8e177d8f1 100644
--- a/apps/trading/client-pages/market/market-header-stats.tsx
+++ b/apps/trading/client-pages/market/market-header-stats.tsx
@@ -118,8 +118,7 @@ const ExpiryTooltipContent = ({
}: ExpiryTooltipContentProps) => {
if (market?.marketTimestamps.close === null) {
const oracleId =
- 'dataSourceSpecForTradingTermination' in
- market.tradableInstrument.instrument.product
+ market.tradableInstrument.instrument.product.__typename === 'Future'
? market.tradableInstrument.instrument.product
.dataSourceSpecForTradingTermination?.id
: undefined;
diff --git a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-stop-order.tsx b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-stop-order.tsx
index 753fb87f6..3841b71d1 100644
--- a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-stop-order.tsx
+++ b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-stop-order.tsx
@@ -170,7 +170,7 @@ export const StopOrder = ({ market, marketPrice, submit }: StopOrderProps) => {
}
if (market.tradableInstrument.instrument.product.__typename === 'Spot') {
- // TODO add baseAsset and quoteAsset for Spots
+ // TODO to handle baseAsset and quoteAsset for Spots
// quoteName = market.tradableInstrument.instrument.product.quoteAsset;
// asset = market.tradableInstrument.instrument.product.baseAsset;
}
diff --git a/libs/markets/src/lib/components/market-info/market-info-accordion.tsx b/libs/markets/src/lib/components/market-info/market-info-accordion.tsx
index 9f793a6a7..6eff0b951 100644
--- a/libs/markets/src/lib/components/market-info/market-info-accordion.tsx
+++ b/libs/markets/src/lib/components/market-info/market-info-accordion.tsx
@@ -88,20 +88,18 @@ export const MarketInfoAccordion = ({
);
const settlementData =
- 'dataSourceSpecForSettlementData' in
- market.tradableInstrument.instrument.product
+ market.tradableInstrument.instrument.product.__typename === 'Future' ||
+ market.tradableInstrument.instrument.product.__typename === 'Perpetual'
? (market.tradableInstrument.instrument.product
.dataSourceSpecForSettlementData.data as DataSourceDefinition)
: undefined;
const terminationData =
- 'dataSourceSpecForTradingTermination' in
- market.tradableInstrument.instrument.product
+ market.tradableInstrument.instrument.product.__typename === 'Future'
? (market.tradableInstrument.instrument.product
.dataSourceSpecForTradingTermination.data as DataSourceDefinition)
: undefined;
const settlementScheduleData =
- 'dataSourceSpecForSettlementSchedule' in
- market.tradableInstrument.instrument.product
+ market.tradableInstrument.instrument.product.__typename === 'Perpetual'
? (market.tradableInstrument.instrument.product
.dataSourceSpecForSettlementSchedule.data as DataSourceDefinition)
: undefined;
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 32cb60f61..315c9fc85 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
@@ -858,7 +858,7 @@ export const DataSourceProof = ({
return
{t('Invalid data source')}
;
};
-const getDataSourceSpec = (
+export const getDataSourceSpec = (
product: MarketInfo['tradableInstrument']['instrument']['product'],
type: 'settlementData' | 'termination' | 'settlementSchedule'
): {
diff --git a/libs/markets/src/lib/components/markets-container/use-column-defs.tsx b/libs/markets/src/lib/components/markets-container/use-column-defs.tsx
index 76bad3f5a..7a6e8a70e 100644
--- a/libs/markets/src/lib/components/markets-container/use-column-defs.tsx
+++ b/libs/markets/src/lib/components/markets-container/use-column-defs.tsx
@@ -15,6 +15,7 @@ import { useAssetDetailsDialogStore } from '@vegaprotocol/assets';
import { FLAGS } from '@vegaprotocol/environment';
import type { MarketMaybeWithData } from '../../markets-provider';
import { MarketActionsDropdown } from './market-table-actions';
+import { getAsset } from '../../market-utils';
interface Props {
onMarketClick: (marketId: string, metaKey?: boolean) => void;
@@ -166,11 +167,7 @@ export const useColumnDefs = ({ onMarketClick }: Props) => {
MarketMaybeWithData,
'tradableInstrument.instrument.product.settlementAsset.symbol'
>) => {
- const value =
- data &&
- 'settlementAsset' in data.tradableInstrument.instrument.product
- ? data?.tradableInstrument.instrument.product.settlementAsset
- : undefined;
+ const value = data && getAsset(data);
return value ? (
{
return (
);
},
diff --git a/libs/markets/src/lib/hooks/use-oracle-markets.ts b/libs/markets/src/lib/hooks/use-oracle-markets.ts
index 471cbb9be..445439a0f 100644
--- a/libs/markets/src/lib/hooks/use-oracle-markets.ts
+++ b/libs/markets/src/lib/hooks/use-oracle-markets.ts
@@ -30,7 +30,7 @@ export const useOracleMarkets = (
const signers =
'signers' in sourceType.sourceType
? sourceType?.sourceType.signers
- : null;
+ : undefined;
const signerKeys = signers?.filter(Boolean).map((signer) => {
if (signer.signer.__typename === 'ETHAddress') {
return signer.signer.address;
diff --git a/libs/markets/src/lib/market-utils.ts b/libs/markets/src/lib/market-utils.ts
index 2aa83cb78..71e0dfd3f 100644
--- a/libs/markets/src/lib/market-utils.ts
+++ b/libs/markets/src/lib/market-utils.ts
@@ -10,6 +10,48 @@ import type {
} from '../';
const { MarketState, MarketTradingMode } = Schema;
+export const getAsset = (market: Partial) => {
+ if (!market.tradableInstrument?.instrument.product) {
+ throw new Error(
+ 'Failed to retrieve settlementAsset. Invalid tradable instrument'
+ );
+ }
+
+ const product = market.tradableInstrument.instrument.product;
+
+ if (product.__typename === 'Perpetual' || product.__typename === 'Future') {
+ return product.settlementAsset;
+ }
+
+ if (product.__typename === 'Spot') {
+ // TODO to handle baseAsset for Spots
+ throw new Error('Failed to retrieve asset. Spots not yet implemented');
+ }
+
+ throw new Error('Failed to retrieve asset. Invalid product type');
+};
+
+export const getQuoteName = (market: Partial) => {
+ if (!market.tradableInstrument?.instrument.product) {
+ throw new Error(
+ 'Failed to retrieve quoteName. Invalid tradable instrument'
+ );
+ }
+
+ const product = market.tradableInstrument.instrument.product;
+
+ if (product.__typename === 'Perpetual' || product.__typename === 'Future') {
+ return product.quoteName;
+ }
+
+ if (product.__typename === 'Spot') {
+ // TODO to handle baseAsset for Spots
+ throw new Error('Failed to retrieve quoteName. Spots not yet implemented');
+ }
+
+ throw new Error('Failed to retrieve quoteName. Invalid product type');
+};
+
export const totalFees = (fees: Market['fees']['factors']) => {
return fees
? new BigNumber(fees.makerFee)
@@ -103,47 +145,3 @@ export const calcTradedFactor = (m: MarketMaybeWithDataAndCandles) => {
const factor = fq.multipliedBy(fp).multipliedBy(volume);
return factor.toNumber();
};
-
-export const getAsset = (market: Partial) => {
- if (!market.tradableInstrument?.instrument.product) {
- throw new Error(
- 'Failed to retrieve settlementAsset. Invalid tradable instrument'
- );
- }
-
- const product = market.tradableInstrument.instrument.product;
-
- if (product.__typename === 'Perpetual' || product.__typename === 'Future') {
- return product.settlementAsset;
- }
-
- if (product.__typename === 'Spot') {
- // TODO to handle baseAsset for Spots
- throw new Error(
- 'Failed to retrieve settlementAsset. Spots not yet implemented'
- );
- }
-
- throw new Error('Failed to retrieve settlementAsset. Invalid product type');
-};
-
-export const getQuoteName = (market: Partial) => {
- if (!market.tradableInstrument?.instrument.product) {
- throw new Error(
- 'Failed to retrieve quoteName. Invalid tradable instrument'
- );
- }
-
- const product = market.tradableInstrument.instrument.product;
-
- if (product.__typename === 'Perpetual' || product.__typename === 'Future') {
- return product.quoteName;
- }
-
- if (product.__typename === 'Spot') {
- // TODO to handle baseAsset for Spots
- throw new Error('Failed to retrieve quoteName. Spots not yet implemented');
- }
-
- throw new Error('Failed to retrieve quoteName. Invalid product type');
-};
diff --git a/libs/positions/src/lib/positions-data-providers.ts b/libs/positions/src/lib/positions-data-providers.ts
index a7dd8d311..8d080468b 100644
--- a/libs/positions/src/lib/positions-data-providers.ts
+++ b/libs/positions/src/lib/positions-data-providers.ts
@@ -68,7 +68,10 @@ export const getMetrics = (
const market = position.market;
if (
!market ||
- !('settlementAsset' in market.tradableInstrument.instrument.product)
+ !(
+ market.tradableInstrument.instrument.product.__typename === 'Future' ||
+ market.tradableInstrument.instrument.product.__typename === 'Perpetual'
+ )
) {
return;
}