Merge branch 'feature/browse-perpetuals' of github.com:vegaprotocol/frontend-monorepo into feature/browse-perpetuals
This commit is contained in:
+1
-2
@@ -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 (
|
||||
<>
|
||||
<span className="leading-3">{value}</span>
|
||||
<span className="leading-3">{get(getAsset(data), 'symbol')}</span>
|
||||
<span className="leading-3">{getAsset(data).symbol}</span>
|
||||
</>
|
||||
);
|
||||
},
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -858,7 +858,7 @@ export const DataSourceProof = ({
|
||||
return <div>{t('Invalid data source')}</div>;
|
||||
};
|
||||
|
||||
const getDataSourceSpec = (
|
||||
export const getDataSourceSpec = (
|
||||
product: MarketInfo['tradableInstrument']['instrument']['product'],
|
||||
type: 'settlementData' | 'termination' | 'settlementSchedule'
|
||||
): {
|
||||
|
||||
@@ -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 ? (
|
||||
<ButtonLink
|
||||
@@ -196,13 +193,7 @@ export const useColumnDefs = ({ onMarketClick }: Props) => {
|
||||
return (
|
||||
<MarketActionsDropdown
|
||||
marketId={data.id}
|
||||
assetId={
|
||||
'settlementAsset' in
|
||||
data.tradableInstrument.instrument.product
|
||||
? data.tradableInstrument.instrument.product.settlementAsset
|
||||
.id
|
||||
: ''
|
||||
}
|
||||
assetId={getAsset(data)?.id}
|
||||
/>
|
||||
);
|
||||
},
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -10,6 +10,48 @@ import type {
|
||||
} from '../';
|
||||
const { MarketState, MarketTradingMode } = Schema;
|
||||
|
||||
export const getAsset = (market: Partial<Market>) => {
|
||||
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<Market>) => {
|
||||
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<Market>) => {
|
||||
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<Market>) => {
|
||||
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');
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user