- | undefined;
+
+ let parentSuccessorConfig: SuccessorConfiguration | undefined = undefined;
+
+ if (parentSuccessorProposalDetails?.proposal?.__typename === 'Proposal') {
+ const parentProposal = parentSuccessorProposalDetails?.proposal;
+ parentSuccessorConfig =
+ parentProposal.terms.change.__typename === 'NewMarket'
+ ? parentProposal.terms.change.successorConfiguration || undefined
+ : undefined;
+ } else if (
+ parentSuccessorProposalDetails?.proposal?.__typename === 'BatchProposal'
+ ) {
+ const subTerms =
+ parentSuccessorProposalDetails.proposal.batchTerms?.changes.find(
+ (c) => c?.change.__typename === 'NewMarket'
+ );
+ parentSuccessorConfig =
+ subTerms?.change.__typename === 'NewMarket'
+ ? subTerms.change.successorConfiguration || undefined
+ : undefined;
+ }
const assetDecimals = getAsset(market).decimals;
@@ -339,10 +367,7 @@ export const KeyDetailsInfoPanel = ({
parentMarket && {
name: parentMarket?.tradableInstrument?.instrument?.name,
parentMarketID: grandparentMarketIdData?.market?.parentMarketID,
- insurancePoolFraction:
- parentProposal?.terms.change.__typename === 'NewMarket' &&
- parentProposal?.terms.change.successorConfiguration
- ?.insurancePoolFraction,
+ insurancePoolFraction: parentSuccessorConfig?.insurancePoolFraction,
status:
parentMarket?.state && MarketStateMapping[parentMarket.state],
tradingMode:
@@ -872,8 +897,15 @@ export const EthOraclePanel = ({ sourceType }: { sourceType: EthCallSpec }) => {
-
- {t('View on Etherscan')}
+
+ {t('View on {{chainLabel}}', {
+ chainLabel: getExternalChainLabel(
+ sourceType.sourceChainId.toString()
+ ),
+ })}
>
diff --git a/libs/markets/src/lib/components/market-info/market-info.mock.ts b/libs/markets/src/lib/components/market-info/market-info.mock.ts
index 6afaae03f..906d3da4d 100644
--- a/libs/markets/src/lib/components/market-info/market-info.mock.ts
+++ b/libs/markets/src/lib/components/market-info/market-info.mock.ts
@@ -27,6 +27,8 @@ export const marketInfoQuery = (
linearSlippageFactor: '0.01',
marketTimestamps: {
__typename: 'MarketTimestamps',
+ proposed: '2022-11-13T02:15:24.543614154Z',
+ pending: '2022-11-14T02:15:24.543614154Z',
open: '2022-11-15T02:15:24.543614154Z',
close: null,
},
diff --git a/libs/markets/src/lib/market-utils.spec.tsx b/libs/markets/src/lib/market-utils.spec.tsx
index 88d2d6fba..d12b6af7d 100644
--- a/libs/markets/src/lib/market-utils.spec.tsx
+++ b/libs/markets/src/lib/market-utils.spec.tsx
@@ -13,6 +13,8 @@ const MARKET_A: Partial = {
id: '1',
marketTimestamps: {
__typename: 'MarketTimestamps',
+ proposed: '2022-05-11T13:08:27.693537312Z',
+ pending: '2022-05-12T13:08:27.693537312Z',
open: '2022-05-18T13:08:27.693537312Z',
close: null,
},
@@ -24,6 +26,8 @@ const MARKET_B: Partial = {
id: '2',
marketTimestamps: {
__typename: 'MarketTimestamps',
+ proposed: '2022-05-11T13:08:27.693537312Z',
+ pending: '2022-05-12T13:08:27.693537312Z',
open: '2022-05-18T13:00:39.328347732Z',
close: null,
},
@@ -35,6 +39,8 @@ const MARKET_C: Partial = {
id: '3',
marketTimestamps: {
__typename: 'MarketTimestamps',
+ proposed: '2022-05-11T13:08:27.693537312Z',
+ pending: '2022-05-12T13:08:27.693537312Z',
open: '2022-05-17T13:00:39.328347732Z',
close: null,
},
@@ -46,6 +52,8 @@ const MARKET_D: Partial = {
id: '4',
marketTimestamps: {
__typename: 'MarketTimestamps',
+ proposed: '2022-05-11T13:08:27.693537312Z',
+ pending: '2022-05-12T13:08:27.693537312Z',
open: '2022-05-16T13:00:39.328347732Z',
close: null,
},
diff --git a/libs/markets/src/lib/market-utils.ts b/libs/markets/src/lib/market-utils.ts
index 36f5f4d2b..4f425f315 100644
--- a/libs/markets/src/lib/market-utils.ts
+++ b/libs/markets/src/lib/market-utils.ts
@@ -123,6 +123,16 @@ export const filterAndSortClosedMarkets = (markets: MarketMaybeWithData[]) => {
});
};
+export const filterAndSortProposedMarkets = (
+ markets: MarketMaybeWithData[]
+) => {
+ return markets.filter((m) => {
+ return [MarketState.STATE_PROPOSED].includes(
+ m.data?.marketState || m.state
+ );
+ });
+};
+
export const calcCandleLow = (candles: Candle[]): string | undefined => {
return candles
?.reduce((acc: BigNumber, c) => {
diff --git a/libs/markets/src/lib/markets-provider.ts b/libs/markets/src/lib/markets-provider.ts
index 433a1f1bd..2bf2924a3 100644
--- a/libs/markets/src/lib/markets-provider.ts
+++ b/libs/markets/src/lib/markets-provider.ts
@@ -27,6 +27,7 @@ import * as Schema from '@vegaprotocol/types';
import {
filterAndSortClosedMarkets,
filterAndSortMarkets,
+ filterAndSortProposedMarkets,
} from './market-utils';
import type { Candle } from './market-candles-provider';
@@ -114,6 +115,11 @@ export const closedMarketsProvider = makeDerivedDataProvider(
([markets]) => filterAndSortClosedMarkets(markets)
);
+export const proposedMarketsProvider = makeDerivedDataProvider(
+ [marketsProvider],
+ ([markets]) => filterAndSortProposedMarkets(markets)
+);
+
export type MarketMaybeWithCandles = Market & { candles?: Candle[] };
const addCandles = (
@@ -241,3 +247,10 @@ export const useMarketList = () => {
reload,
};
};
+
+export const useProposedMarketsList = () => {
+ return useDataProvider({
+ dataProvider: proposedMarketsProvider,
+ variables: undefined,
+ });
+};
diff --git a/libs/markets/src/lib/markets.graphql b/libs/markets/src/lib/markets.graphql
index f517df987..79aba6760 100644
--- a/libs/markets/src/lib/markets.graphql
+++ b/libs/markets/src/lib/markets.graphql
@@ -37,9 +37,19 @@ fragment MarketFields on Market {
}
}
marketTimestamps {
+ proposed
+ pending
open
close
}
+ marketProposal {
+ ... on Proposal {
+ id
+ }
+ ... on BatchProposal {
+ id
+ }
+ }
}
query Markets {
diff --git a/libs/markets/src/lib/markets.mock.ts b/libs/markets/src/lib/markets.mock.ts
index e1086ce40..431661d62 100644
--- a/libs/markets/src/lib/markets.mock.ts
+++ b/libs/markets/src/lib/markets.mock.ts
@@ -40,8 +40,10 @@ export const createMarketFragment = (
tickSize: '1',
marketTimestamps: {
__typename: 'MarketTimestamps',
- close: null,
+ proposed: '2022-08-23T11:36:32.252490405Z',
+ pending: '2022-08-24T11:36:32.252490405Z',
open: null,
+ close: null,
},
successorMarketID: null,
parentMarketID: null,
@@ -190,6 +192,9 @@ const marketFieldsFragments: MarketFieldsFragment[] = [
tradingMode: Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION,
state: Schema.MarketState.STATE_SUSPENDED,
marketTimestamps: {
+ proposed: '2022-08-23T11:36:32.252490405Z',
+ pending: '2022-08-24T11:36:32.252490405Z',
+ open: '2022-08-25T11:36:32.252490405Z',
close: '2022-08-26T11:36:32.252490405Z',
},
fees: {
@@ -220,6 +225,9 @@ const marketFieldsFragments: MarketFieldsFragment[] = [
createMarketFragment({
id: 'market-3',
marketTimestamps: {
+ proposed: '2022-08-23T11:36:32.252490405Z',
+ pending: '2022-08-24T11:36:32.252490405Z',
+ open: '2022-08-25T11:36:32.252490405Z',
close: '2022-08-26T11:36:32.252490405Z',
},
fees: {
diff --git a/libs/orders/src/lib/components/mocks/generate-orders.ts b/libs/orders/src/lib/components/mocks/generate-orders.ts
index eacc46881..2b43999f5 100644
--- a/libs/orders/src/lib/components/mocks/generate-orders.ts
+++ b/libs/orders/src/lib/components/mocks/generate-orders.ts
@@ -23,8 +23,10 @@ export const generateOrder = (partialOrder?: PartialDeep) => {
},
marketTimestamps: {
__typename: 'MarketTimestamps',
- close: '',
- open: '',
+ proposed: '2022-08-23T11:36:32.252490405Z',
+ pending: '2022-08-24T11:36:32.252490405Z',
+ open: null,
+ close: null,
},
positionDecimalPlaces: 2,
state: Schema.MarketState.STATE_ACTIVE,
diff --git a/libs/orders/src/lib/components/mocks/generate-stop-orders.ts b/libs/orders/src/lib/components/mocks/generate-stop-orders.ts
index 397aec887..d0cdde878 100644
--- a/libs/orders/src/lib/components/mocks/generate-stop-orders.ts
+++ b/libs/orders/src/lib/components/mocks/generate-stop-orders.ts
@@ -33,6 +33,8 @@ export const generateStopOrder = (
},
marketTimestamps: {
__typename: 'MarketTimestamps',
+ proposed: '2005-04-02T19:37:00.000Z',
+ pending: '2005-04-03T19:37:00.000Z',
close: '',
open: '',
},
diff --git a/libs/orders/src/lib/components/order-list/order-view-dialog.spec.tsx b/libs/orders/src/lib/components/order-list/order-view-dialog.spec.tsx
index 4c6651cae..f364a8cea 100644
--- a/libs/orders/src/lib/components/order-list/order-view-dialog.spec.tsx
+++ b/libs/orders/src/lib/components/order-list/order-view-dialog.spec.tsx
@@ -117,6 +117,8 @@ describe('OrderViewDialog', () => {
},
marketTimestamps: {
__typename: 'MarketTimestamps',
+ proposed: '2023-07-17T12:05:25.822854221Z',
+ pending: '2023-07-18T12:05:25.822854221Z',
open: '2023-07-19T12:05:25.822854221Z',
close: null,
},
diff --git a/libs/proposals/src/components/index.ts b/libs/proposals/src/components/index.ts
index fcd956727..87fae9505 100644
--- a/libs/proposals/src/components/index.ts
+++ b/libs/proposals/src/components/index.ts
@@ -1,6 +1,5 @@
export * from './asset-proposal-notification';
export * from './market-proposal-notification';
-export * from './proposals-list';
export * from './protocol-upgrade-countdown';
export * from './protocol-upgrade-in-progress-notification';
export * from './protocol-upgrade-proposal-notification';
diff --git a/libs/proposals/src/components/proposals-list/index.ts b/libs/proposals/src/components/proposals-list/index.ts
deleted file mode 100644
index 8b5156f64..000000000
--- a/libs/proposals/src/components/proposals-list/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './proposals-list';
diff --git a/libs/proposals/src/components/proposals-list/proposals-list.tsx b/libs/proposals/src/components/proposals-list/proposals-list.tsx
deleted file mode 100644
index 92aef168f..000000000
--- a/libs/proposals/src/components/proposals-list/proposals-list.tsx
+++ /dev/null
@@ -1,56 +0,0 @@
-import type { FC } from 'react';
-import { AgGrid } from '@vegaprotocol/datagrid';
-import * as Types from '@vegaprotocol/types';
-import { removePaginationWrapper } from '@vegaprotocol/utils';
-import type { ProposalListFieldsFragment } from '../../lib/proposals-data-provider/__generated__/Proposals';
-import { useProposalsListQuery } from '../../lib/proposals-data-provider/__generated__/Proposals';
-import { useColumnDefs } from './use-column-defs';
-import { useT } from '../../use-t';
-
-export const getNewMarketProposals = (data: ProposalListFieldsFragment[]) =>
- data.filter((proposal) =>
- [
- Types.ProposalState.STATE_OPEN,
- Types.ProposalState.STATE_PASSED,
- Types.ProposalState.STATE_WAITING_FOR_NODE_VOTE,
- ].includes(proposal.state)
- );
-
-const defaultColDef = {
- sortable: true,
- filter: true,
- resizable: true,
- filterParams: { buttons: ['reset'] },
-};
-
-interface ProposalListProps {
- cellRenderers: {
- [name: string]: FC<{ value: string; data: ProposalListFieldsFragment }>;
- };
-}
-
-export const ProposalsList = ({ cellRenderers }: ProposalListProps) => {
- const t = useT();
- const { data } = useProposalsListQuery({
- variables: {
- proposalType: Types.ProposalType.TYPE_NEW_MARKET,
- },
- errorPolicy: 'all', // currently there are some proposals failing due to proposals existing without settlement asset ids
- });
- const filteredData = getNewMarketProposals(
- removePaginationWrapper(data?.proposalsConnection?.edges)
- );
- const columnDefs = useColumnDefs();
-
- return (
- data.id}
- overlayNoRowsTemplate={t('No proposed markets')}
- components={cellRenderers}
- rowHeight={45}
- />
- );
-};
diff --git a/libs/proposals/src/lib/proposals-data-provider/index.ts b/libs/proposals/src/lib/proposals-data-provider/index.ts
index 0c6a2a3b8..35d7f5e63 100644
--- a/libs/proposals/src/lib/proposals-data-provider/index.ts
+++ b/libs/proposals/src/lib/proposals-data-provider/index.ts
@@ -1,2 +1,3 @@
export * from './proposals-data-provider';
export * from './__generated__/Proposals';
+export * from './proposals.mock';
diff --git a/libs/proposals/src/lib/proposals-hooks/Proposal.graphql b/libs/proposals/src/lib/proposals-hooks/Proposal.graphql
index e9165a980..f7d5f2b26 100644
--- a/libs/proposals/src/lib/proposals-hooks/Proposal.graphql
+++ b/libs/proposals/src/lib/proposals-hooks/Proposal.graphql
@@ -47,14 +47,10 @@ query ProposalOfMarket($marketId: ID!) {
}
... on BatchProposal {
id
- batchTerms {
- changes {
+ subProposals {
+ id
+ terms {
enactmentDatetime
- change {
- ... on NewMarket {
- __typename
- }
- }
}
}
}
@@ -76,6 +72,22 @@ query SuccessorMarketProposalDetails($proposalId: ID!) {
}
}
}
+ ... on BatchProposal {
+ id
+ batchTerms {
+ changes {
+ change {
+ ... on NewMarket {
+ __typename
+ successorConfiguration {
+ parentMarketId
+ insurancePoolFraction
+ }
+ }
+ }
+ }
+ }
+ }
}
}
diff --git a/libs/proposals/src/lib/proposals-hooks/__generated__/Proposal.ts b/libs/proposals/src/lib/proposals-hooks/__generated__/Proposal.ts
index 83a090536..fffa469b6 100644
--- a/libs/proposals/src/lib/proposals-hooks/__generated__/Proposal.ts
+++ b/libs/proposals/src/lib/proposals-hooks/__generated__/Proposal.ts
@@ -25,14 +25,14 @@ export type ProposalOfMarketQueryVariables = Types.Exact<{
}>;
-export type ProposalOfMarketQuery = { __typename?: 'Query', proposal?: { __typename?: 'BatchProposal', id?: string | null, batchTerms?: { __typename?: 'BatchProposalTerms', changes: Array<{ __typename?: 'BatchProposalTermsChange', enactmentDatetime?: any | null, change: { __typename?: 'CancelTransfer' } | { __typename?: 'NewAsset' } | { __typename?: 'NewFreeform' } | { __typename: 'NewMarket' } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket' } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter' } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } } | null> } | null } | { __typename?: 'Proposal', id?: string | null, terms: { __typename?: 'ProposalTerms', enactmentDatetime?: any | null } } | null };
+export type ProposalOfMarketQuery = { __typename?: 'Query', proposal?: { __typename?: 'BatchProposal', id?: string | null, subProposals?: Array<{ __typename?: 'ProposalDetail', id?: string | null, terms?: { __typename?: 'ProposalTerms', enactmentDatetime?: any | null } | null } | null> | null } | { __typename?: 'Proposal', id?: string | null, terms: { __typename?: 'ProposalTerms', enactmentDatetime?: any | null } } | null };
export type SuccessorMarketProposalDetailsQueryVariables = Types.Exact<{
proposalId: Types.Scalars['ID'];
}>;
-export type SuccessorMarketProposalDetailsQuery = { __typename?: 'Query', proposal?: { __typename?: 'BatchProposal' } | { __typename?: 'Proposal', id?: string | null, terms: { __typename?: 'ProposalTerms', change: { __typename?: 'CancelTransfer' } | { __typename?: 'NewAsset' } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', successorConfiguration?: { __typename?: 'SuccessorConfiguration', parentMarketId: string, insurancePoolFraction: string } | null } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket' } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter' } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } } } | null };
+export type SuccessorMarketProposalDetailsQuery = { __typename?: 'Query', proposal?: { __typename?: 'BatchProposal', id?: string | null, batchTerms?: { __typename?: 'BatchProposalTerms', changes: Array<{ __typename?: 'BatchProposalTermsChange', change: { __typename?: 'CancelTransfer' } | { __typename?: 'NewAsset' } | { __typename?: 'NewFreeform' } | { __typename: 'NewMarket', successorConfiguration?: { __typename?: 'SuccessorConfiguration', parentMarketId: string, insurancePoolFraction: string } | null } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket' } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter' } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } } | null> } | null } | { __typename?: 'Proposal', id?: string | null, terms: { __typename?: 'ProposalTerms', change: { __typename?: 'CancelTransfer' } | { __typename?: 'NewAsset' } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', successorConfiguration?: { __typename?: 'SuccessorConfiguration', parentMarketId: string, insurancePoolFraction: string } | null } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket' } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter' } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } } } | null };
export type InstrumentDetailsQueryVariables = Types.Exact<{
marketId: Types.Scalars['ID'];
@@ -154,14 +154,10 @@ export const ProposalOfMarketDocument = gql`
}
... on BatchProposal {
id
- batchTerms {
- changes {
+ subProposals {
+ id
+ terms {
enactmentDatetime
- change {
- ... on NewMarket {
- __typename
- }
- }
}
}
}
@@ -212,6 +208,22 @@ export const SuccessorMarketProposalDetailsDocument = gql`
}
}
}
+ ... on BatchProposal {
+ id
+ batchTerms {
+ changes {
+ change {
+ ... on NewMarket {
+ __typename
+ successorConfiguration {
+ parentMarketId
+ insurancePoolFraction
+ }
+ }
+ }
+ }
+ }
+ }
}
}
`;
diff --git a/libs/ui-toolkit/src/components/sparkline/sparkline.tsx b/libs/ui-toolkit/src/components/sparkline/sparkline.tsx
index 7839bce68..4208ff68c 100644
--- a/libs/ui-toolkit/src/components/sparkline/sparkline.tsx
+++ b/libs/ui-toolkit/src/components/sparkline/sparkline.tsx
@@ -31,12 +31,26 @@ export interface SparklineProps {
}
export const SparklineView = ({
- data,
+ data: rawData,
width = 60,
height = 15,
points = 24,
className,
}: SparklineProps) => {
+ // Value can come in as 0, due to candle.close being empty string ''
+ // Instead of skewing the sparkline with 0 values, we map over and set any
+ // 0 values to the last non 0 value resulting in a better sparkline
+ let lastClose = 0;
+ const data = rawData.map((val) => {
+ if (val === 0) {
+ return lastClose;
+ } else {
+ lastClose = val;
+ }
+
+ return val;
+ });
+
// Get the extent for our y value
const [min, max] = extent(data, (d) => d);
diff --git a/libs/utils/src/lib/price-change.ts b/libs/utils/src/lib/price-change.ts
index 82dbfc551..d26122e28 100644
--- a/libs/utils/src/lib/price-change.ts
+++ b/libs/utils/src/lib/price-change.ts
@@ -1,18 +1,16 @@
import BigNumber from 'bignumber.js';
export const priceChangePercentage = (candles: string[]) => {
- const change = priceChange(candles);
- if (change && candles && candles.length > 0) {
- const yesterdayLastPrice = candles[0] && BigInt(candles[0]);
- if (yesterdayLastPrice) {
- return new BigNumber(change.toString())
- .dividedBy(new BigNumber(yesterdayLastPrice.toString()))
- .multipliedBy(100)
- .toNumber();
- }
+ if (!candles.length) {
return 0;
}
- return 0;
+
+ const change = priceChange(candles);
+
+ return new BigNumber(change.toString())
+ .dividedBy(new BigNumber(candles[0]))
+ .multipliedBy(100)
+ .toNumber();
};
export const priceChange = (candles: string[]) => {
diff --git a/libs/withdraws/src/lib/withdraw-form-container.spec.tsx b/libs/withdraws/src/lib/withdraw-form-container.spec.tsx
index 7887655f0..1293ffa81 100644
--- a/libs/withdraws/src/lib/withdraw-form-container.spec.tsx
+++ b/libs/withdraws/src/lib/withdraw-form-container.spec.tsx
@@ -217,6 +217,8 @@ describe('WithdrawFormContainer', () => {
},
marketTimestamps: {
__typename: 'MarketTimestamps',
+ proposed: '2022-10-23T18:17:59.149283671Z',
+ pending: '2022-10-24T18:17:59.149283671Z',
open: '2022-10-25T18:17:59.149283671Z',
close: null,
},