From 6aea10c27b1dda99450a6da7cb527b44b8cb7283 Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Wed, 24 Jan 2024 17:34:11 -0500 Subject: [PATCH] chore(trading, governance, explorer): 0.74.0 type regen (#5619) --- .../links/proposal-link/Proposal.graphql | 10 +- .../proposal-link/__generated__/Proposal.ts | 12 +- .../proposal-link/proposal-link.spec.tsx | 31 +- .../links/proposal-link/proposal-link.tsx | 13 +- .../txs/details/proposal/Proposal.graphql | 8 +- .../proposal/__generated__/Proposal.ts | 10 +- .../txs/details/proposal/proposal-date.tsx | 18 +- .../details/proposal/proposal-status-icon.tsx | 40 +- apps/governance/src/routes/home/index.tsx | 4 +- .../current-proposal-state.tsx | 13 +- .../current-proposal-status.spec.tsx | 272 -------- .../current-proposal-status.tsx | 143 ---- .../current-proposal-status/index.tsx | 1 - .../proposal-change-table.tsx | 5 +- .../proposal-header.spec.tsx | 20 +- .../proposal-header.tsx | 10 +- .../proposal-referral-program-details.tsx | 4 +- .../proposal-cancel-transfer-details.tsx | 5 +- .../proposal-transfer-details.tsx | 5 +- .../proposal-update-benefit-tiers-details.tsx | 4 +- .../proposal-update-market-state.tsx | 4 +- ...oposal-volume-discount-program-details.tsx | 4 +- .../components/proposal/proposal.spec.tsx | 8 +- .../components/proposal/proposal.tsx | 10 +- .../proposals-list-item-details.spec.tsx | 6 +- .../proposals-list-item-details.tsx | 7 +- .../proposals-list-item.tsx | 4 +- .../proposals-list/proposals-list.spec.tsx | 6 +- .../proposals-list/proposals-list.tsx | 26 +- .../rejected-proposals-list.spec.tsx | 4 +- .../rejected-proposals-list.tsx | 6 +- .../vote-breakdown/vote-breakdown.spec.tsx | 8 +- .../vote-breakdown/vote-breakdown.tsx | 7 +- .../components/vote-details/user-vote.tsx | 11 +- .../hooks/use-proposal-network-params.ts | 5 +- .../proposals/hooks/use-vote-information.ts | 9 +- .../proposals/proposal/Proposal.graphql | 528 +++++++-------- .../proposal/__generated__/Proposal.ts | 450 ++++++------- .../proposals/proposal/proposal-container.tsx | 34 +- .../test-helpers/generate-proposals.ts | 22 +- apps/governance/src/routes/proposals/types.ts | 11 + .../chart-container/chart-container.tsx | 17 +- .../components/chart-container/chart-menu.tsx | 14 +- .../components/chart-container/constants.ts | 12 + .../candles-chart/src/lib/data-source.spec.ts | 201 +++--- .../components/deal-ticket/deal-ticket.tsx | 7 +- .../trading-mode-tooltip.tsx | 15 +- .../src/hooks/use-position-estimate.spec.ts | 33 - .../src/hooks/use-position-estimate.ts | 14 +- .../market-info/market-info-panels.tsx | 33 +- libs/positions/src/lib/Positions.graphql | 14 +- .../src/lib/__generated__/Positions.ts | 23 +- .../src/lib/liquidation-price.spec.tsx | 15 +- libs/positions/src/lib/liquidation-price.tsx | 23 +- .../src/lib/positions-data-providers.ts | 2 + libs/positions/src/lib/positions-table.tsx | 7 +- libs/positions/src/lib/positions.mock.ts | 1 + libs/proposals/src/index.ts | 1 + .../src/lib/proposals-hooks/Proposal.graphql | 48 +- .../proposals-hooks/__generated__/Proposal.ts | 56 +- .../use-cancel-transfer-proposal-details.ts | 16 +- .../use-new-transfer-proposal-details.ts | 16 +- .../use-successor-market-proposal-details.ts | 14 +- libs/proposals/src/types.ts | 6 + libs/types/src/__generated__/types.ts | 625 +++++++++++++++++- libs/types/src/global-types-mappings.ts | 7 +- 66 files changed, 1669 insertions(+), 1349 deletions(-) delete mode 100644 apps/governance/src/routes/proposals/components/current-proposal-status/current-proposal-status.spec.tsx delete mode 100644 apps/governance/src/routes/proposals/components/current-proposal-status/current-proposal-status.tsx delete mode 100644 apps/governance/src/routes/proposals/components/current-proposal-status/index.tsx create mode 100644 apps/governance/src/routes/proposals/types.ts create mode 100644 apps/trading/components/chart-container/constants.ts delete mode 100644 libs/deal-ticket/src/hooks/use-position-estimate.spec.ts create mode 100644 libs/proposals/src/types.ts diff --git a/apps/explorer/src/app/components/links/proposal-link/Proposal.graphql b/apps/explorer/src/app/components/links/proposal-link/Proposal.graphql index 85d2c3518..77694a2bb 100644 --- a/apps/explorer/src/app/components/links/proposal-link/Proposal.graphql +++ b/apps/explorer/src/app/components/links/proposal-link/Proposal.graphql @@ -1,9 +1,11 @@ query ExplorerProposal($id: ID!) { proposal(id: $id) { - id - rationale { - title - description + ... on Proposal { + id + rationale { + title + description + } } } } diff --git a/apps/explorer/src/app/components/links/proposal-link/__generated__/Proposal.ts b/apps/explorer/src/app/components/links/proposal-link/__generated__/Proposal.ts index 00a3cf101..60bb107bd 100644 --- a/apps/explorer/src/app/components/links/proposal-link/__generated__/Proposal.ts +++ b/apps/explorer/src/app/components/links/proposal-link/__generated__/Proposal.ts @@ -8,16 +8,18 @@ export type ExplorerProposalQueryVariables = Types.Exact<{ }>; -export type ExplorerProposalQuery = { __typename?: 'Query', proposal?: { __typename?: 'Proposal', id?: string | null, rationale: { __typename?: 'ProposalRationale', title: string, description: string } } | null }; +export type ExplorerProposalQuery = { __typename?: 'Query', proposal?: { __typename?: 'BatchProposal' } | { __typename?: 'Proposal', id?: string | null, rationale: { __typename?: 'ProposalRationale', title: string, description: string } } | null }; export const ExplorerProposalDocument = gql` query ExplorerProposal($id: ID!) { proposal(id: $id) { - id - rationale { - title - description + ... on Proposal { + id + rationale { + title + description + } } } } diff --git a/apps/explorer/src/app/components/links/proposal-link/proposal-link.spec.tsx b/apps/explorer/src/app/components/links/proposal-link/proposal-link.spec.tsx index 81fdcaf8c..340e98197 100644 --- a/apps/explorer/src/app/components/links/proposal-link/proposal-link.spec.tsx +++ b/apps/explorer/src/app/components/links/proposal-link/proposal-link.spec.tsx @@ -3,7 +3,11 @@ import { MockedProvider } from '@apollo/client/testing'; import type { MockedResponse } from '@apollo/client/testing'; import { render } from '@testing-library/react'; import ProposalLink from './proposal-link'; -import { ExplorerProposalDocument } from './__generated__/Proposal'; +import { + ExplorerProposalDocument, + type ExplorerProposalQuery, + type ExplorerProposalQueryVariables, +} from './__generated__/Proposal'; import { GraphQLError } from 'graphql'; function renderComponent(id: string, mocks: MockedResponse[]) { @@ -23,7 +27,10 @@ describe('Proposal link component', () => { }); it('Renders the ID on error', async () => { - const mock = { + const mock: MockedResponse< + ExplorerProposalQuery, + ExplorerProposalQueryVariables + > = { request: { query: ExplorerProposalDocument, variables: { @@ -40,17 +47,22 @@ describe('Proposal link component', () => { }); it('Renders the proposal title when the query returns a result', async () => { - const mock = { + const proposalId = '123'; + const mock: MockedResponse< + ExplorerProposalQuery, + ExplorerProposalQueryVariables + > = { request: { query: ExplorerProposalDocument, variables: { - id: '123', + id: proposalId, }, }, result: { data: { proposal: { - id: '123', + __typename: 'Proposal', + id: proposalId, rationale: { title: 'test-title', description: 'test description', @@ -60,13 +72,16 @@ describe('Proposal link component', () => { }, }; - const res = render(renderComponent('123', [mock])); - expect(res.getByText('123')).toBeInTheDocument(); + const res = render(renderComponent(proposalId, [mock])); + expect(res.getByText(proposalId)).toBeInTheDocument(); expect(await res.findByText('test-title')).toBeInTheDocument(); }); it('Leaves the proposal id when the market is not found', async () => { - const mock = { + const mock: MockedResponse< + ExplorerProposalQuery, + ExplorerProposalQueryVariables + > = { request: { query: ExplorerProposalDocument, variables: { diff --git a/apps/explorer/src/app/components/links/proposal-link/proposal-link.tsx b/apps/explorer/src/app/components/links/proposal-link/proposal-link.tsx index c9ae74675..c7bd14820 100644 --- a/apps/explorer/src/app/components/links/proposal-link/proposal-link.tsx +++ b/apps/explorer/src/app/components/links/proposal-link/proposal-link.tsx @@ -1,7 +1,11 @@ -import { useExplorerProposalQuery } from './__generated__/Proposal'; +import { + useExplorerProposalQuery, + type ExplorerProposalQuery, +} from './__generated__/Proposal'; import { ExternalLink } from '@vegaprotocol/ui-toolkit'; import { ENV } from '../../../config/env'; import Hash from '../hash'; + export type ProposalLinkProps = { id: string; text?: string; @@ -16,8 +20,13 @@ const ProposalLink = ({ id, text }: ProposalLinkProps) => { variables: { id }, }); + const proposal = data?.proposal as Extract< + ExplorerProposalQuery['proposal'], + { __typename?: 'Proposal' } + >; + const base = ENV.dataSources.governanceUrl; - const label = data?.proposal?.rationale.title || id; + const label = proposal?.rationale.title || id; return ( diff --git a/apps/explorer/src/app/components/txs/details/proposal/Proposal.graphql b/apps/explorer/src/app/components/txs/details/proposal/Proposal.graphql index aa67158dd..db4b2ea66 100644 --- a/apps/explorer/src/app/components/txs/details/proposal/Proposal.graphql +++ b/apps/explorer/src/app/components/txs/details/proposal/Proposal.graphql @@ -1,7 +1,9 @@ query ExplorerProposalStatus($id: ID!) { proposal(id: $id) { - id - state - rejectionReason + ... on Proposal { + id + state + rejectionReason + } } } diff --git a/apps/explorer/src/app/components/txs/details/proposal/__generated__/Proposal.ts b/apps/explorer/src/app/components/txs/details/proposal/__generated__/Proposal.ts index 8a1e9222a..0034cd2e2 100644 --- a/apps/explorer/src/app/components/txs/details/proposal/__generated__/Proposal.ts +++ b/apps/explorer/src/app/components/txs/details/proposal/__generated__/Proposal.ts @@ -8,15 +8,17 @@ export type ExplorerProposalStatusQueryVariables = Types.Exact<{ }>; -export type ExplorerProposalStatusQuery = { __typename?: 'Query', proposal?: { __typename?: 'Proposal', id?: string | null, state: Types.ProposalState, rejectionReason?: Types.ProposalRejectionReason | null } | null }; +export type ExplorerProposalStatusQuery = { __typename?: 'Query', proposal?: { __typename?: 'BatchProposal' } | { __typename?: 'Proposal', id?: string | null, state: Types.ProposalState, rejectionReason?: Types.ProposalRejectionReason | null } | null }; export const ExplorerProposalStatusDocument = gql` query ExplorerProposalStatus($id: ID!) { proposal(id: $id) { - id - state - rejectionReason + ... on Proposal { + id + state + rejectionReason + } } } `; diff --git a/apps/explorer/src/app/components/txs/details/proposal/proposal-date.tsx b/apps/explorer/src/app/components/txs/details/proposal/proposal-date.tsx index a94aa7b49..1b93926d3 100644 --- a/apps/explorer/src/app/components/txs/details/proposal/proposal-date.tsx +++ b/apps/explorer/src/app/components/txs/details/proposal/proposal-date.tsx @@ -14,16 +14,18 @@ export function format(date: string | undefined, def: string) { return new Date().toLocaleDateString() || def; } -export function getDate( - data: ExplorerProposalStatusQuery | undefined, - terms: Terms -): string { +type Proposal = Extract< + ExplorerProposalStatusQuery['proposal'], + { __typename?: 'Proposal' } +>; + +export function getDate(proposal: Proposal | undefined, terms: Terms): string { const DEFAULT = t('Unknown'); - if (!data?.proposal?.state) { + if (!proposal?.state) { return DEFAULT; } - switch (data.proposal.state) { + switch (proposal.state) { case 'STATE_DECLINED': return `${t('Rejected on')}: ${format(terms.closingTimestamp, DEFAULT)}`; case 'STATE_ENACTED': @@ -62,9 +64,11 @@ export const ProposalDate = ({ terms, id }: ProposalDateProps) => { }, }); + const proposal = data?.proposal as Proposal; + return ( - {getDate(data, terms)} + {getDate(proposal, terms)} ); }; diff --git a/apps/explorer/src/app/components/txs/details/proposal/proposal-status-icon.tsx b/apps/explorer/src/app/components/txs/details/proposal/proposal-status-icon.tsx index 41ff4db87..61d617373 100644 --- a/apps/explorer/src/app/components/txs/details/proposal/proposal-status-icon.tsx +++ b/apps/explorer/src/app/components/txs/details/proposal/proposal-status-icon.tsx @@ -2,17 +2,8 @@ import { Icon, Tooltip } from '@vegaprotocol/ui-toolkit'; import type { IconProps } from '@vegaprotocol/ui-toolkit'; import { useExplorerProposalStatusQuery } from './__generated__/Proposal'; import type { ExplorerProposalStatusQuery } from './__generated__/Proposal'; -import type * as Apollo from '@apollo/client'; -import type * as Types from '@vegaprotocol/types'; import { t } from '@vegaprotocol/i18n'; -type ProposalQueryResult = Apollo.QueryResult< - ExplorerProposalStatusQuery, - Types.Exact<{ - id: string; - }> ->; - interface ProposalStatusIconProps { id: string; } @@ -29,29 +20,38 @@ type IconAndLabel = { * @param data a data result from useExplorerProposalStatusQuery * @returns Icon name */ -export function getIconAndLabelForStatus( - res: ProposalQueryResult -): IconAndLabel { +export function useIconAndLabelForStatus(id: string): IconAndLabel { + const { data, loading, error } = useExplorerProposalStatusQuery({ + variables: { + id, + }, + }); + + const proposal = data?.proposal as Extract< + ExplorerProposalStatusQuery['proposal'], + { __typename?: 'Proposal' } + >; + const DEFAULT: IconAndLabel = { icon: 'error', label: t('Proposal state unknown'), }; - if (res.loading) { + if (loading) { return { icon: 'more', label: t('Loading data'), }; } - if (!res?.data?.proposal || res.error) { + if (!data?.proposal || error) { return { icon: 'error', - label: res.error?.message || DEFAULT.label, + label: error?.message || DEFAULT.label, }; } - switch (res.data.proposal.state) { + switch (proposal.state) { case 'STATE_DECLINED': return { icon: 'stop', @@ -99,13 +99,7 @@ export function getIconAndLabelForStatus( /** */ export const ProposalStatusIcon = ({ id }: ProposalStatusIconProps) => { - const { icon, label } = getIconAndLabelForStatus( - useExplorerProposalStatusQuery({ - variables: { - id, - }, - }) - ); + const { icon, label } = useIconAndLabelForStatus(id); return (
diff --git a/apps/governance/src/routes/home/index.tsx b/apps/governance/src/routes/home/index.tsx index ad39cba62..9e9c3e2cb 100644 --- a/apps/governance/src/routes/home/index.tsx +++ b/apps/governance/src/routes/home/index.tsx @@ -31,7 +31,7 @@ import { orderByUpgradeBlockHeight, } from '../proposals/components/proposals-list/proposals-list'; import { BigNumber } from '../../lib/bignumber'; -import type { ProposalQuery } from '../proposals/proposal/__generated__/Proposal'; +import { type Proposal } from '../proposals/types'; const nodesToShow = 6; @@ -39,7 +39,7 @@ const HomeProposals = ({ proposals, protocolUpgradeProposals, }: { - proposals: ProposalQuery['proposal'][]; + proposals: Proposal[]; protocolUpgradeProposals: ProtocolUpgradeProposalFieldsFragment[]; }) => { const { t } = useTranslation(); diff --git a/apps/governance/src/routes/proposals/components/current-proposal-state/current-proposal-state.tsx b/apps/governance/src/routes/proposals/components/current-proposal-state/current-proposal-state.tsx index 8e2587076..76674a7e9 100644 --- a/apps/governance/src/routes/proposals/components/current-proposal-state/current-proposal-state.tsx +++ b/apps/governance/src/routes/proposals/components/current-proposal-state/current-proposal-state.tsx @@ -1,16 +1,11 @@ import { useTranslation } from 'react-i18next'; -import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals'; -import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; import { ProposalState } from '@vegaprotocol/types'; import { ProposalInfoLabel } from '../proposal-info-label'; -import type { ReactNode } from 'react'; -import type { ProposalInfoLabelVariant } from '../proposal-info-label'; +import { type ReactNode } from 'react'; +import { type ProposalInfoLabelVariant } from '../proposal-info-label'; +import { type Proposal } from '../../types'; -export const CurrentProposalState = ({ - proposal, -}: { - proposal: ProposalFieldsFragment | ProposalQuery['proposal']; -}) => { +export const CurrentProposalState = ({ proposal }: { proposal: Proposal }) => { const { t } = useTranslation(); let proposalStatus: ReactNode; let variant = 'tertiary' as ProposalInfoLabelVariant; diff --git a/apps/governance/src/routes/proposals/components/current-proposal-status/current-proposal-status.spec.tsx b/apps/governance/src/routes/proposals/components/current-proposal-status/current-proposal-status.spec.tsx deleted file mode 100644 index 719b910ca..000000000 --- a/apps/governance/src/routes/proposals/components/current-proposal-status/current-proposal-status.spec.tsx +++ /dev/null @@ -1,272 +0,0 @@ -import type { MockedResponse } from '@apollo/client/testing'; -import { MockedProvider } from '@apollo/client/testing'; -import { render, screen } from '@testing-library/react'; -import { ProposalRejectionReason, ProposalState } from '@vegaprotocol/types'; -import type { NetworkParamsQuery } from '@vegaprotocol/network-parameters'; -import { NetworkParamsDocument } from '@vegaprotocol/network-parameters'; -import { AppStateProvider } from '../../../../contexts/app-state/app-state-provider'; -import { generateProposal } from '../../test-helpers/generate-proposals'; -import { CurrentProposalStatus } from './current-proposal-status'; -import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; - -const networkParamsQueryMock: MockedResponse = { - request: { - query: NetworkParamsDocument, - }, - result: { - data: { - networkParametersConnection: { - edges: [ - { - node: { - __typename: 'NetworkParameter', - key: 'governance.proposal.updateNetParam.requiredMajority', - value: '0.00000001', - }, - }, - { - node: { - __typename: 'NetworkParameter', - key: 'governance.proposal.updateNetParam.requiredParticipation', - value: '0.000000001', - }, - }, - ], - }, - }, - }, -}; - -const renderComponent = ({ - proposal, -}: { - proposal: ProposalQuery['proposal']; -}) => { - render( - - - - - - ); -}; - -beforeEach(() => { - jest.useFakeTimers(); - jest.setSystemTime(60 * 60 * 1000); -}); - -afterEach(() => { - jest.useRealTimers(); -}); - -it('Proposal open - renders will fail state if the proposal will fail', async () => { - const failedProposal = generateProposal({ - votes: { - __typename: 'ProposalVotes', - yes: { - __typename: 'ProposalVoteSide', - totalNumber: '0', - totalTokens: '0', - totalEquityLikeShareWeight: '0', - }, - no: { - __typename: 'ProposalVoteSide', - totalNumber: '0', - totalTokens: '0', - totalEquityLikeShareWeight: '0', - }, - }, - }); - renderComponent({ proposal: failedProposal }); - expect(await screen.findByText('Currently expected to')).toBeInTheDocument(); - expect(await screen.findByText('fail.')).toBeInTheDocument(); -}); - -it('Proposal open - renders will pass state if the proposal will pass', async () => { - const proposal = generateProposal(); - - renderComponent({ proposal }); - expect(await screen.findByText('Currently expected to')).toBeInTheDocument(); - expect(await screen.findByText('pass.')).toBeInTheDocument(); -}); - -it('Proposal enacted - renders vote passed and time since enactment', async () => { - const proposal = generateProposal({ - state: ProposalState.STATE_ENACTED, - terms: { - enactmentDatetime: new Date(0).toISOString(), - }, - }); - - renderComponent({ proposal }); - expect(await screen.findByText('Vote passed.')).toBeInTheDocument(); - expect(await screen.findByText('about 1 hour ago')).toBeInTheDocument(); -}); - -it('Proposal passed - renders vote passed and time since vote closed', async () => { - const proposal = generateProposal({ - state: ProposalState.STATE_PASSED, - terms: { - closingDatetime: new Date(0).toISOString(), - }, - }); - - renderComponent({ proposal }); - expect(await screen.findByText('Vote passed.')).toBeInTheDocument(); - expect(await screen.findByText('about 1 hour ago')).toBeInTheDocument(); -}); - -it('Proposal waiting for node vote - will pass - renders if the vote will pass and status', async () => { - const failedProposal = generateProposal({ - state: ProposalState.STATE_WAITING_FOR_NODE_VOTE, - votes: { - __typename: 'ProposalVotes', - yes: { - __typename: 'ProposalVoteSide', - totalNumber: '0', - totalTokens: '0', - totalEquityLikeShareWeight: '0', - }, - no: { - __typename: 'ProposalVoteSide', - totalNumber: '0', - totalTokens: '0', - totalEquityLikeShareWeight: '0', - }, - }, - }); - renderComponent({ proposal: failedProposal }); - expect( - await screen.findByText('Waiting for nodes to validate asset.') - ).toBeInTheDocument(); - expect(await screen.findByText('Currently expected to')).toBeInTheDocument(); - expect(await screen.findByText('fail.')).toBeInTheDocument(); -}); - -it('Proposal waiting for node vote - will fail - renders if the vote will pass and status', async () => { - const proposal = generateProposal({ - state: ProposalState.STATE_WAITING_FOR_NODE_VOTE, - }); - - renderComponent({ proposal }); - expect( - await screen.findByText('Waiting for nodes to validate asset.') - ).toBeInTheDocument(); - expect(await screen.findByText('Currently expected to')).toBeInTheDocument(); - expect(await screen.findByText('pass.')).toBeInTheDocument(); -}); - -it('Proposal failed - renders vote failed reason and vote closed ago', async () => { - const proposal = generateProposal({ - state: ProposalState.STATE_FAILED, - errorDetails: 'foo', - terms: { - closingDatetime: new Date(0).toISOString(), - }, - }); - - renderComponent({ proposal }); - expect( - await screen.findByText('Vote closed. Failed due to:') - ).toBeInTheDocument(); - expect(await screen.findByText('foo')).toBeInTheDocument(); - expect(await screen.findByText('about 1 hour ago')).toBeInTheDocument(); -}); - -it('Proposal failed - renders rejection reason there are no error details', async () => { - const proposal = generateProposal({ - state: ProposalState.STATE_FAILED, - rejectionReason: ProposalRejectionReason.PROPOSAL_ERROR_CLOSE_TIME_TOO_LATE, - terms: { - closingDatetime: new Date(0).toISOString(), - }, - }); - - renderComponent({ proposal }); - expect( - await screen.findByText('Vote closed. Failed due to:') - ).toBeInTheDocument(); - expect( - await screen.findByText('PROPOSAL_ERROR_CLOSE_TIME_TOO_LATE') - ).toBeInTheDocument(); - expect(await screen.findByText('about 1 hour ago')).toBeInTheDocument(); -}); - -it('Proposal failed - renders unknown reason if there are no error details or rejection reason', async () => { - const proposal = generateProposal({ - state: ProposalState.STATE_FAILED, - terms: { - closingDatetime: new Date(0).toISOString(), - }, - }); - - renderComponent({ proposal }); - expect( - await screen.findByText('Vote closed. Failed due to:') - ).toBeInTheDocument(); - expect(await screen.findByText('unknown reason')).toBeInTheDocument(); - expect(await screen.findByText('about 1 hour ago')).toBeInTheDocument(); -}); - -it('Proposal failed - renders participation not met if participation is not met', async () => { - const proposal = generateProposal({ - state: ProposalState.STATE_FAILED, - terms: { - closingDatetime: new Date(0).toISOString(), - }, - votes: { - __typename: 'ProposalVotes', - yes: { - __typename: 'ProposalVoteSide', - totalNumber: '0', - totalTokens: '0', - totalEquityLikeShareWeight: '0', - }, - no: { - __typename: 'ProposalVoteSide', - totalNumber: '0', - totalTokens: '0', - totalEquityLikeShareWeight: '0', - }, - }, - }); - - renderComponent({ proposal }); - expect( - await screen.findByText('Vote closed. Failed due to:') - ).toBeInTheDocument(); - expect(await screen.findByText('Participation not met')).toBeInTheDocument(); - expect(await screen.findByText('about 1 hour ago')).toBeInTheDocument(); -}); - -it('Proposal failed - renders majority not met if majority is not met', async () => { - const proposal = generateProposal({ - state: ProposalState.STATE_FAILED, - terms: { - closingDatetime: new Date(0).toISOString(), - }, - votes: { - __typename: 'ProposalVotes', - yes: { - __typename: 'ProposalVoteSide', - totalNumber: '0', - totalTokens: '0', - totalEquityLikeShareWeight: '0', - }, - no: { - __typename: 'ProposalVoteSide', - totalNumber: '1', - totalTokens: '25242474195500835440000', - totalEquityLikeShareWeight: '0', - }, - }, - }); - - renderComponent({ proposal }); - expect( - await screen.findByText('Vote closed. Failed due to:') - ).toBeInTheDocument(); - expect(await screen.findByText('Majority not met')).toBeInTheDocument(); - expect(await screen.findByText('about 1 hour ago')).toBeInTheDocument(); -}); diff --git a/apps/governance/src/routes/proposals/components/current-proposal-status/current-proposal-status.tsx b/apps/governance/src/routes/proposals/components/current-proposal-status/current-proposal-status.tsx deleted file mode 100644 index c4943d2df..000000000 --- a/apps/governance/src/routes/proposals/components/current-proposal-status/current-proposal-status.tsx +++ /dev/null @@ -1,143 +0,0 @@ -import type { ReactNode } from 'react'; -import { formatDistanceToNow } from 'date-fns'; -import { useTranslation } from 'react-i18next'; - -import { ProposalState } from '@vegaprotocol/types'; -import { useVoteInformation } from '../../hooks'; -import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals'; -import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; - -export const StatusPass = ({ children }: { children: ReactNode }) => ( - {children} -); - -export const StatusFail = ({ children }: { children: ReactNode }) => ( - {children} -); - -const WillPass = ({ - willPass, - children, -}: { - willPass: boolean; - children?: ReactNode; -}) => { - const { t } = useTranslation(); - if (willPass) { - return ( - <> - {children} - {t('pass')}. - {t('finalOutcomeMayDiffer')} - - ); - } else { - return ( - <> - {children} - {t('fail')}. - {t('finalOutcomeMayDiffer')} - - ); - } -}; - -export const CurrentProposalStatus = ({ - proposal, -}: { - proposal: ProposalFieldsFragment | ProposalQuery['proposal']; -}) => { - const { willPassByTokenVote, majorityMet, participationMet } = - useVoteInformation({ - proposal, - }); - const { t } = useTranslation(); - - const daysClosedAgo = formatDistanceToNow( - new Date(proposal?.terms.closingDatetime), - { addSuffix: true } - ); - - const daysEnactedAgo = - proposal?.terms.enactmentDatetime && - formatDistanceToNow(new Date(proposal.terms.enactmentDatetime), { - addSuffix: true, - }); - - if (proposal?.state === ProposalState.STATE_OPEN) { - return ( - {t('currentlySetTo')} - ); - } - - if ( - proposal?.state === ProposalState.STATE_FAILED || - proposal?.state === ProposalState.STATE_DECLINED || - proposal?.state === ProposalState.STATE_REJECTED - ) { - if (!participationMet) { - return ( - <> - {t('voteFailedReason')} - {t('participationNotMet')} -  {daysClosedAgo} - - ); - } - - if (!majorityMet) { - return ( - <> - {t('voteFailedReason')} - {t('majorityNotMet')} -  {daysClosedAgo} - - ); - } - - return ( - <> - {t('voteFailedReason')} - - {proposal?.errorDetails || - proposal?.rejectionReason || - t('unknownReason')} - -  {daysClosedAgo} - - ); - } - if ( - proposal?.state === ProposalState.STATE_ENACTED || - proposal?.state === ProposalState.STATE_PASSED - ) { - return ( - <> - {t('votePassed')} - -   - {proposal?.state === ProposalState.STATE_ENACTED - ? t('Enacted') - : t('Passed')} - - -   - {proposal?.state === ProposalState.STATE_ENACTED - ? daysEnactedAgo - : daysClosedAgo} - - - ); - } - - if (proposal?.state === ProposalState.STATE_WAITING_FOR_NODE_VOTE) { - return ( - - {t('WaitingForNodeVote')}{' '} - {t('currentlySetTo')} - - ); - } - - return null; -}; diff --git a/apps/governance/src/routes/proposals/components/current-proposal-status/index.tsx b/apps/governance/src/routes/proposals/components/current-proposal-status/index.tsx deleted file mode 100644 index a269b2cdd..000000000 --- a/apps/governance/src/routes/proposals/components/current-proposal-status/index.tsx +++ /dev/null @@ -1 +0,0 @@ -export { CurrentProposalStatus } from './current-proposal-status'; diff --git a/apps/governance/src/routes/proposals/components/proposal-change-table/proposal-change-table.tsx b/apps/governance/src/routes/proposals/components/proposal-change-table/proposal-change-table.tsx index 45457a689..2e83f6e67 100644 --- a/apps/governance/src/routes/proposals/components/proposal-change-table/proposal-change-table.tsx +++ b/apps/governance/src/routes/proposals/components/proposal-change-table/proposal-change-table.tsx @@ -6,11 +6,10 @@ import { KeyValueTableRow, RoundedWrapper, } from '@vegaprotocol/ui-toolkit'; -import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals'; -import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; +import { type Proposal } from '../../types'; interface ProposalChangeTableProps { - proposal: ProposalFieldsFragment | ProposalQuery['proposal']; + proposal: Proposal; } export const ProposalChangeTable = ({ proposal }: ProposalChangeTableProps) => { diff --git a/apps/governance/src/routes/proposals/components/proposal-detail-header/proposal-header.spec.tsx b/apps/governance/src/routes/proposals/components/proposal-detail-header/proposal-header.spec.tsx index 1f1f25788..e2991886b 100644 --- a/apps/governance/src/routes/proposals/components/proposal-detail-header/proposal-header.spec.tsx +++ b/apps/governance/src/routes/proposals/components/proposal-detail-header/proposal-header.spec.tsx @@ -23,8 +23,8 @@ import { useFeatureFlags } from '@vegaprotocol/environment'; import { BrowserRouter } from 'react-router-dom'; import { VoteState } from '../vote-details/use-user-vote'; import { useNewTransferProposalDetails } from '@vegaprotocol/proposals'; -import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; -import type { MockedResponse } from '@apollo/client/testing'; +import { type MockedResponse } from '@apollo/client/testing'; +import { type Proposal } from '../../types'; jest.mock('@vegaprotocol/proposals', () => ({ ...jest.requireActual('@vegaprotocol/proposals'), @@ -36,7 +36,7 @@ jest.mock('@vegaprotocol/proposals', () => ({ })); const renderComponent = ( - proposal: ProposalQuery['proposal'], + proposal: Proposal, isListItem = true, mocks: MockedResponse[] = [], voteState?: VoteState @@ -64,6 +64,7 @@ describe('Proposal header', () => { it('Renders New market proposal', () => { useFeatureFlags.setState({ flags: { SUCCESSOR_MARKETS: true } }); renderComponent( + // @ts-ignore we aren't using batch yet generateProposal({ rationale: { title: 'New some market', @@ -102,6 +103,7 @@ describe('Proposal header', () => { it('Renders Update market proposal', () => { renderComponent( + // @ts-ignore we aren't using batch yet generateProposal({ rationale: { title: 'New market id', @@ -130,6 +132,7 @@ describe('Proposal header', () => { it('Renders New asset proposal - ERC20', () => { renderComponent( + // @ts-ignore we aren't using batch yet generateProposal({ rationale: { title: 'New asset: Fake currency', @@ -159,6 +162,7 @@ describe('Proposal header', () => { it('Renders New asset proposal - BuiltInAsset', () => { renderComponent( + // @ts-ignore we aren't using batch yet generateProposal({ terms: { change: { @@ -184,6 +188,7 @@ describe('Proposal header', () => { it('Renders Update network', () => { renderComponent( + // @ts-ignore we aren't using batch yet generateProposal({ rationale: { title: 'Network parameter', @@ -213,6 +218,7 @@ describe('Proposal header', () => { it('Renders Freeform proposal - short rationale', () => { renderComponent( + // @ts-ignore we aren't using batch yet generateProposal({ id: 'short', rationale: { @@ -234,6 +240,7 @@ describe('Proposal header', () => { it('Renders Freeform proposal - long rationale (105 chars) - listing', () => { renderComponent( + // @ts-ignore we aren't using batch yet generateProposal({ id: 'long', rationale: { @@ -259,6 +266,7 @@ describe('Proposal header', () => { // Remove once proposals have rationale and re-enable above tests it('Renders Freeform proposal - id for title', () => { renderComponent( + // @ts-ignore we aren't using batch yet generateProposal({ id: 'freeform id', rationale: { @@ -280,6 +288,7 @@ describe('Proposal header', () => { it('Renders asset change proposal header', () => { renderComponent( + // @ts-ignore we aren't using batch yet generateProposal({ terms: { change: { @@ -297,6 +306,7 @@ describe('Proposal header', () => { it("Renders unknown proposal if it's a different proposal type", () => { renderComponent( + // @ts-ignore we aren't using batch yet generateProposal({ terms: { change: { @@ -313,6 +323,7 @@ describe('Proposal header', () => { it('Renders proposal state: Enacted', () => { renderComponent( + // @ts-ignore we aren't using batch yet generateProposal({ state: ProposalState.STATE_ENACTED, terms: { @@ -325,6 +336,7 @@ describe('Proposal header', () => { it('Renders proposal state: Passed', () => { renderComponent( + // @ts-ignore we aren't using batch yet generateProposal({ state: ProposalState.STATE_PASSED, terms: { @@ -338,6 +350,7 @@ describe('Proposal header', () => { it('Renders proposal state: Waiting for node vote', () => { renderComponent( + // @ts-ignore we aren't using batch yet generateProposal({ state: ProposalState.STATE_WAITING_FOR_NODE_VOTE, terms: { @@ -352,6 +365,7 @@ describe('Proposal header', () => { it('Renders proposal state: Open', () => { renderComponent( + // @ts-ignore we aren't using batch yet generateProposal({ state: ProposalState.STATE_OPEN, votes: { diff --git a/apps/governance/src/routes/proposals/components/proposal-detail-header/proposal-header.tsx b/apps/governance/src/routes/proposals/components/proposal-detail-header/proposal-header.tsx index 243a3f5f6..004b11bb3 100644 --- a/apps/governance/src/routes/proposals/components/proposal-detail-header/proposal-header.tsx +++ b/apps/governance/src/routes/proposals/components/proposal-detail-header/proposal-header.tsx @@ -8,8 +8,7 @@ import { } from '@vegaprotocol/ui-toolkit'; import { shorten } from '@vegaprotocol/utils'; import { Heading, SubHeading } from '../../../../components/heading'; -import type { ReactNode } from 'react'; -import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; +import { type ReactNode } from 'react'; import { truncateMiddle } from '../../../../lib/truncate-middle'; import { CurrentProposalState } from '../current-proposal-state'; import { ProposalInfoLabel } from '../proposal-info-label'; @@ -26,16 +25,17 @@ import { } from '@vegaprotocol/environment'; import Routes from '../../../routes'; import { Link } from 'react-router-dom'; -import type { VoteState } from '../vote-details/use-user-vote'; +import { type VoteState } from '../vote-details/use-user-vote'; import { VoteBreakdown } from '../vote-breakdown'; import { GovernanceTransferKindMapping } from '@vegaprotocol/types'; +import { type Proposal } from '../../types'; export const ProposalHeader = ({ proposal, isListItem = true, voteState, }: { - proposal: ProposalQuery['proposal']; + proposal: Proposal; isListItem?: boolean; voteState?: VoteState | null; }) => { @@ -53,7 +53,7 @@ export const ProposalHeader = ({ const titleContent = shorten(title ?? '', 100); - const getAsset = (proposal: ProposalQuery['proposal']) => { + const getAsset = (proposal: Proposal) => { const terms = proposal?.terms; if ( terms?.change.__typename === 'NewMarket' && diff --git a/apps/governance/src/routes/proposals/components/proposal-referral-program-details/proposal-referral-program-details.tsx b/apps/governance/src/routes/proposals/components/proposal-referral-program-details/proposal-referral-program-details.tsx index 20797e16a..c6f99d2f7 100644 --- a/apps/governance/src/routes/proposals/components/proposal-referral-program-details/proposal-referral-program-details.tsx +++ b/apps/governance/src/routes/proposals/components/proposal-referral-program-details/proposal-referral-program-details.tsx @@ -1,5 +1,4 @@ import { useTranslation } from 'react-i18next'; -import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; import { KeyValueTable, KeyValueTableRow, @@ -14,9 +13,10 @@ import { } from '@vegaprotocol/utils'; import BigNumber from 'bignumber.js'; import { useAppState } from '../../../../contexts/app-state/app-state-context'; +import { type Proposal } from '../../types'; interface ProposalReferralProgramDetailsProps { - proposal: ProposalQuery['proposal']; + proposal: Proposal | null; } export const formatEndOfProgramTimestamp = (value: string) => { diff --git a/apps/governance/src/routes/proposals/components/proposal-transfer/proposal-cancel-transfer-details.tsx b/apps/governance/src/routes/proposals/components/proposal-transfer/proposal-cancel-transfer-details.tsx index 6f51bd39b..aca9e3c9b 100644 --- a/apps/governance/src/routes/proposals/components/proposal-transfer/proposal-cancel-transfer-details.tsx +++ b/apps/governance/src/routes/proposals/components/proposal-transfer/proposal-cancel-transfer-details.tsx @@ -1,6 +1,4 @@ import { useTranslation } from 'react-i18next'; -import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; -import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals'; import { useCancelTransferProposalDetails } from '@vegaprotocol/proposals'; import { KeyValueTable, @@ -8,11 +6,12 @@ import { RoundedWrapper, } from '@vegaprotocol/ui-toolkit'; import { SubHeading } from '../../../../components/heading'; +import { type Proposal } from '../../types'; export const ProposalCancelTransferDetails = ({ proposal, }: { - proposal: ProposalFieldsFragment | ProposalQuery['proposal']; + proposal: Proposal; }) => { const { t } = useTranslation(); const details = useCancelTransferProposalDetails(proposal?.id); diff --git a/apps/governance/src/routes/proposals/components/proposal-transfer/proposal-transfer-details.tsx b/apps/governance/src/routes/proposals/components/proposal-transfer/proposal-transfer-details.tsx index 59d8c5314..c5530b19c 100644 --- a/apps/governance/src/routes/proposals/components/proposal-transfer/proposal-transfer-details.tsx +++ b/apps/governance/src/routes/proposals/components/proposal-transfer/proposal-transfer-details.tsx @@ -1,6 +1,4 @@ import { useState } from 'react'; -import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals'; -import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; import { CollapsibleToggle } from '../../../../components/collapsible-toggle'; import { SubHeading } from '../../../../components/heading'; import { useTranslation } from 'react-i18next'; @@ -21,11 +19,12 @@ import { addDecimalsFormatNumberQuantum, formatDateWithLocalTimezone, } from '@vegaprotocol/utils'; +import { type Proposal } from '../../types'; export const ProposalTransferDetails = ({ proposal, }: { - proposal: ProposalFieldsFragment | ProposalQuery['proposal']; + proposal: Proposal; }) => { const { t } = useTranslation(); const [show, setShow] = useState(false); diff --git a/apps/governance/src/routes/proposals/components/proposal-update-benefit-tiers/proposal-update-benefit-tiers-details.tsx b/apps/governance/src/routes/proposals/components/proposal-update-benefit-tiers/proposal-update-benefit-tiers-details.tsx index 29f4fc773..81c9a95b9 100644 --- a/apps/governance/src/routes/proposals/components/proposal-update-benefit-tiers/proposal-update-benefit-tiers-details.tsx +++ b/apps/governance/src/routes/proposals/components/proposal-update-benefit-tiers/proposal-update-benefit-tiers-details.tsx @@ -1,5 +1,4 @@ import { useTranslation } from 'react-i18next'; -import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; import { KeyValueTable, KeyValueTableRow, @@ -12,6 +11,7 @@ import { } from '../proposal-referral-program-details'; import { formatNumberPercentage } from '@vegaprotocol/utils'; import BigNumber from 'bignumber.js'; +import { type Proposal } from '../../types'; // These types are not generated as it's not known how dynamic these are type VestingBenefitTier = { @@ -43,7 +43,7 @@ export const formatVolumeDiscountFactor = (value: string) => { }; interface ProposalReferralProgramDetailsProps { - proposal: ProposalQuery['proposal']; + proposal: Proposal | null; } /** diff --git a/apps/governance/src/routes/proposals/components/proposal-update-market-state/proposal-update-market-state.tsx b/apps/governance/src/routes/proposals/components/proposal-update-market-state/proposal-update-market-state.tsx index 4c27ce3ae..b9bcc997d 100644 --- a/apps/governance/src/routes/proposals/components/proposal-update-market-state/proposal-update-market-state.tsx +++ b/apps/governance/src/routes/proposals/components/proposal-update-market-state/proposal-update-market-state.tsx @@ -5,13 +5,13 @@ import { RoundedWrapper, } from '@vegaprotocol/ui-toolkit'; import { Row } from '@vegaprotocol/markets'; -import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; import { useState } from 'react'; import { CollapsibleToggle } from '../../../../components/collapsible-toggle'; import { SubHeading } from '../../../../components/heading'; +import { type Proposal } from '../../types'; interface ProposalUpdateMarketStateProps { - proposal: ProposalQuery['proposal']; + proposal: Proposal | null; } export const ProposalUpdateMarketState = ({ diff --git a/apps/governance/src/routes/proposals/components/proposal-volume-discount-program-details/proposal-volume-discount-program-details.tsx b/apps/governance/src/routes/proposals/components/proposal-volume-discount-program-details/proposal-volume-discount-program-details.tsx index 486310f42..cb2454097 100644 --- a/apps/governance/src/routes/proposals/components/proposal-volume-discount-program-details/proposal-volume-discount-program-details.tsx +++ b/apps/governance/src/routes/proposals/components/proposal-volume-discount-program-details/proposal-volume-discount-program-details.tsx @@ -1,5 +1,4 @@ import { useTranslation } from 'react-i18next'; -import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; import { KeyValueTable, KeyValueTableRow, @@ -12,9 +11,10 @@ import { } from '../proposal-referral-program-details'; import { formatNumberPercentage } from '@vegaprotocol/utils'; import BigNumber from 'bignumber.js'; +import { type Proposal } from '../../types'; interface ProposalReferralProgramDetailsProps { - proposal: ProposalQuery['proposal']; + proposal: Proposal | null; } export const formatVolumeDiscountFactor = (value: string) => { diff --git a/apps/governance/src/routes/proposals/components/proposal/proposal.spec.tsx b/apps/governance/src/routes/proposals/components/proposal/proposal.spec.tsx index 806ac3af9..c0793d1ee 100644 --- a/apps/governance/src/routes/proposals/components/proposal/proposal.spec.tsx +++ b/apps/governance/src/routes/proposals/components/proposal/proposal.spec.tsx @@ -1,13 +1,13 @@ import { MemoryRouter } from 'react-router-dom'; import { MockedProvider } from '@apollo/client/testing'; import { VegaWalletProvider } from '@vegaprotocol/wallet'; -import type { VegaWalletConfig } from '@vegaprotocol/wallet'; +import { type VegaWalletConfig } from '@vegaprotocol/wallet'; import { render, screen } from '@testing-library/react'; import { generateProposal } from '../../test-helpers/generate-proposals'; import { Proposal } from './proposal'; -import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; import { ProposalState } from '@vegaprotocol/types'; import { mockNetworkParams } from '../../test-helpers/mocks'; +import { type Proposal as IProposal } from '../../types'; jest.mock('@vegaprotocol/network-parameters', () => ({ ...jest.requireActual('@vegaprotocol/network-parameters'), @@ -51,14 +51,14 @@ const vegaWalletConfig: VegaWalletConfig = { chainId: 'VEGA_CHAIN_ID', }; -const renderComponent = (proposal: ProposalQuery['proposal']) => { +const renderComponent = (proposal: IProposal) => { render( diff --git a/apps/governance/src/routes/proposals/components/proposal/proposal.tsx b/apps/governance/src/routes/proposals/components/proposal/proposal.tsx index 1fd25c5de..b971b709d 100644 --- a/apps/governance/src/routes/proposals/components/proposal/proposal.tsx +++ b/apps/governance/src/routes/proposals/components/proposal/proposal.tsx @@ -12,14 +12,13 @@ import { UserVote } from '../vote-details'; import { ListAsset } from '../list-asset'; import Routes from '../../../routes'; import { ProposalMarketData } from '../proposal-market-data'; -import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; -import type { MarketInfo } from '@vegaprotocol/markets'; -import type { AssetQuery } from '@vegaprotocol/assets'; +import { type MarketInfo } from '@vegaprotocol/markets'; +import { type AssetQuery } from '@vegaprotocol/assets'; import { removePaginationWrapper } from '@vegaprotocol/utils'; import { ProposalState } from '@vegaprotocol/types'; import { ProposalMarketChanges } from '../proposal-market-changes'; import { ProposalUpdateMarketState } from '../proposal-update-market-state'; -import type { NetworkParamsResult } from '@vegaprotocol/network-parameters'; +import { type NetworkParamsResult } from '@vegaprotocol/network-parameters'; import { useVoteSubmit } from '@vegaprotocol/proposals'; import { useUserVote } from '../vote-details/use-user-vote'; import { @@ -28,9 +27,10 @@ import { } from '../proposal-transfer'; import { useFeatureFlags } from '@vegaprotocol/environment'; import { ProposalUpdateBenefitTiers } from '../proposal-update-benefit-tiers'; +import { type Proposal as IProposal } from '../../types'; export interface ProposalProps { - proposal: ProposalQuery['proposal']; + proposal: IProposal; networkParams: Partial; marketData?: MarketInfo | null; parentMarketData?: MarketInfo | null; diff --git a/apps/governance/src/routes/proposals/components/proposals-list-item/proposals-list-item-details.spec.tsx b/apps/governance/src/routes/proposals/components/proposals-list-item/proposals-list-item-details.spec.tsx index bbc0edb46..2b2697c15 100644 --- a/apps/governance/src/routes/proposals/components/proposals-list-item/proposals-list-item-details.spec.tsx +++ b/apps/governance/src/routes/proposals/components/proposals-list-item/proposals-list-item-details.spec.tsx @@ -1,7 +1,7 @@ import { BrowserRouter as Router } from 'react-router-dom'; import { AppStateProvider } from '../../../../contexts/app-state/app-state-provider'; import { VegaWalletContext } from '@vegaprotocol/wallet'; -import type { MockedResponse } from '@apollo/client/testing'; +import { type MockedResponse } from '@apollo/client/testing'; import { MockedProvider } from '@apollo/client/testing'; import { render, screen } from '@testing-library/react'; import { format } from 'date-fns'; @@ -18,10 +18,10 @@ import { lastWeek, nextWeek, } from '../../test-helpers/mocks'; -import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; +import { type Proposal } from '../../types'; const renderComponent = ( - proposal: ProposalQuery['proposal'], + proposal: Proposal, // eslint-disable-next-line @typescript-eslint/no-explicit-any mocks: MockedResponse[] = [networkParamsQueryMock] ) => diff --git a/apps/governance/src/routes/proposals/components/proposals-list-item/proposals-list-item-details.tsx b/apps/governance/src/routes/proposals/components/proposals-list-item/proposals-list-item-details.tsx index 4cb854c62..dbef6f77c 100644 --- a/apps/governance/src/routes/proposals/components/proposals-list-item/proposals-list-item-details.tsx +++ b/apps/governance/src/routes/proposals/components/proposals-list-item/proposals-list-item-details.tsx @@ -1,21 +1,20 @@ +import { type ReactNode } from 'react'; import { Link } from 'react-router-dom'; import { Button } from '@vegaprotocol/ui-toolkit'; import { differenceInHours, format, formatDistanceToNowStrict } from 'date-fns'; import { useTranslation } from 'react-i18next'; import { DATE_FORMAT_DETAILED } from '../../../../lib/date-formats'; -import type { ReactNode } from 'react'; import { ProposalRejectionReasonMapping, ProposalState, } from '@vegaprotocol/types'; import Routes from '../../../routes'; -import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals'; -import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; +import { type Proposal } from '../../types'; export const ProposalsListItemDetails = ({ proposal, }: { - proposal: ProposalFieldsFragment | ProposalQuery['proposal']; + proposal: Proposal; }) => { const { t } = useTranslation(); const state = proposal?.state; diff --git a/apps/governance/src/routes/proposals/components/proposals-list-item/proposals-list-item.tsx b/apps/governance/src/routes/proposals/components/proposals-list-item/proposals-list-item.tsx index 09747d2b6..7c795d937 100644 --- a/apps/governance/src/routes/proposals/components/proposals-list-item/proposals-list-item.tsx +++ b/apps/governance/src/routes/proposals/components/proposals-list-item/proposals-list-item.tsx @@ -2,10 +2,10 @@ import { RoundedWrapper } from '@vegaprotocol/ui-toolkit'; import { ProposalHeader } from '../proposal-detail-header/proposal-header'; import { ProposalsListItemDetails } from './proposals-list-item-details'; import { useUserVote } from '../vote-details/use-user-vote'; -import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; +import { type Proposal } from '../../types'; interface ProposalsListItemProps { - proposal?: ProposalQuery['proposal'] | null; + proposal?: Proposal | null; } export const ProposalsListItem = ({ proposal }: ProposalsListItemProps) => { diff --git a/apps/governance/src/routes/proposals/components/proposals-list/proposals-list.spec.tsx b/apps/governance/src/routes/proposals/components/proposals-list/proposals-list.spec.tsx index bb8c93f70..d90c0bb5a 100644 --- a/apps/governance/src/routes/proposals/components/proposals-list/proposals-list.spec.tsx +++ b/apps/governance/src/routes/proposals/components/proposals-list/proposals-list.spec.tsx @@ -17,8 +17,8 @@ import { lastMonth, nextMonth, } from '../../test-helpers/mocks'; -import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; -import type { ProtocolUpgradeProposalFieldsFragment } from '@vegaprotocol/proposals'; +import { type ProtocolUpgradeProposalFieldsFragment } from '@vegaprotocol/proposals'; +import { type Proposal } from '../../types'; const openProposalClosesNextMonth = generateProposal({ id: 'proposal1', @@ -63,7 +63,7 @@ const closedProtocolUpgradeProposal = generateProtocolUpgradeProposal({ }); const renderComponent = ( - proposals: ProposalQuery['proposal'][], + proposals: Proposal[], protocolUpgradeProposals?: ProtocolUpgradeProposalFieldsFragment[] ) => ( diff --git a/apps/governance/src/routes/proposals/components/proposals-list/proposals-list.tsx b/apps/governance/src/routes/proposals/components/proposals-list/proposals-list.tsx index b6d651856..faf0d0ff1 100644 --- a/apps/governance/src/routes/proposals/components/proposals-list/proposals-list.tsx +++ b/apps/governance/src/routes/proposals/components/proposals-list/proposals-list.tsx @@ -10,20 +10,20 @@ import Routes from '../../../routes'; import { Button, Toggle } from '@vegaprotocol/ui-toolkit'; import { Link } from 'react-router-dom'; import { ExternalLink } from '@vegaprotocol/ui-toolkit'; -import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; -import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals'; -import type { ProtocolUpgradeProposalFieldsFragment } from '@vegaprotocol/proposals'; import { ExternalLinks } from '@vegaprotocol/environment'; +import { type ProposalFieldsFragment } from '../../proposals/__generated__/Proposals'; +import { type ProtocolUpgradeProposalFieldsFragment } from '@vegaprotocol/proposals'; +import { type Proposal } from '../../types'; interface ProposalsListProps { - proposals: Array; + proposals: Proposal[]; protocolUpgradeProposals: ProtocolUpgradeProposalFieldsFragment[]; lastBlockHeight?: string; } interface SortedProposalsProps { - open: ProposalQuery['proposal'][]; - closed: ProposalQuery['proposal'][]; + open: Proposal[]; + closed: Proposal[]; } interface SortedProtocolUpgradeProposalsProps { @@ -31,7 +31,7 @@ interface SortedProtocolUpgradeProposalsProps { closed: ProtocolUpgradeProposalFieldsFragment[]; } -export const orderByDate = (arr: ProposalQuery['proposal'][]) => +export const orderByDate = (arr: Proposal[]) => orderBy( arr, [ @@ -91,14 +91,10 @@ export const ProposalsList = ({ ); return { open: - initialSorting.open.length > 0 - ? orderByDate(initialSorting.open as ProposalQuery['proposal'][]) - : [], + initialSorting.open.length > 0 ? orderByDate(initialSorting.open) : [], closed: initialSorting.closed.length > 0 - ? orderByDate( - initialSorting.closed as ProposalQuery['proposal'][] - ).reverse() + ? orderByDate(initialSorting.closed).reverse() : [], }; }, [proposals]); @@ -125,9 +121,7 @@ export const ProposalsList = ({ }; }, [protocolUpgradeProposals, lastBlockHeight]); - const filterPredicate = ( - p: ProposalFieldsFragment | ProposalQuery['proposal'] - ) => + const filterPredicate = (p: ProposalFieldsFragment | Proposal) => p?.id?.includes(filterString) || p?.party?.id?.toString().includes(filterString); diff --git a/apps/governance/src/routes/proposals/components/proposals-list/rejected-proposals-list.spec.tsx b/apps/governance/src/routes/proposals/components/proposals-list/rejected-proposals-list.spec.tsx index ad288470b..e9cdc7f4d 100644 --- a/apps/governance/src/routes/proposals/components/proposals-list/rejected-proposals-list.spec.tsx +++ b/apps/governance/src/routes/proposals/components/proposals-list/rejected-proposals-list.spec.tsx @@ -12,7 +12,7 @@ import { nextWeek, lastMonth, } from '../../test-helpers/mocks'; -import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; +import { type Proposal } from '../../types'; const rejectedProposalClosesNextWeek = generateProposal({ id: 'rejected1', @@ -35,7 +35,7 @@ const rejectedProposalClosedLastMonth = generateProposal({ }, }); -const renderComponent = (proposals: ProposalQuery['proposal'][]) => ( +const renderComponent = (proposals: Proposal[]) => ( diff --git a/apps/governance/src/routes/proposals/components/proposals-list/rejected-proposals-list.tsx b/apps/governance/src/routes/proposals/components/proposals-list/rejected-proposals-list.tsx index 64a90752a..687149374 100644 --- a/apps/governance/src/routes/proposals/components/proposals-list/rejected-proposals-list.tsx +++ b/apps/governance/src/routes/proposals/components/proposals-list/rejected-proposals-list.tsx @@ -3,17 +3,17 @@ import { useTranslation } from 'react-i18next'; import { Heading } from '../../../../components/heading'; import { ProposalsListItem } from '../proposals-list-item'; import { ProposalsListFilter } from '../proposals-list-filter'; -import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; +import { type Proposal } from '../../types'; interface ProposalsListProps { - proposals: ProposalQuery['proposal'][]; + proposals: Proposal[]; } export const RejectedProposalsList = ({ proposals }: ProposalsListProps) => { const { t } = useTranslation(); const [filterString, setFilterString] = useState(''); - const filterPredicate = (p: ProposalQuery['proposal']) => + const filterPredicate = (p: Proposal) => p?.id?.includes(filterString) || p?.party?.id?.toString().includes(filterString); diff --git a/apps/governance/src/routes/proposals/components/vote-breakdown/vote-breakdown.spec.tsx b/apps/governance/src/routes/proposals/components/vote-breakdown/vote-breakdown.spec.tsx index f3a286c33..d9739e0d6 100644 --- a/apps/governance/src/routes/proposals/components/vote-breakdown/vote-breakdown.spec.tsx +++ b/apps/governance/src/routes/proposals/components/vote-breakdown/vote-breakdown.spec.tsx @@ -9,8 +9,7 @@ import { nextWeek, } from '../../test-helpers/mocks'; import { CompactVotes, VoteBreakdown } from './vote-breakdown'; -import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; -import type { MockedResponse } from '@apollo/client/testing'; +import { type MockedResponse } from '@apollo/client/testing'; import { generateNoVotes, generateProposal, @@ -18,7 +17,8 @@ import { } from '../../test-helpers/generate-proposals'; import { ProposalState } from '@vegaprotocol/types'; import { BigNumber } from '../../../../lib/bignumber'; -import type { AppState } from '../../../../contexts/app-state/app-state-context'; +import { type AppState } from '../../../../contexts/app-state/app-state-context'; +import { type Proposal } from '../../types'; const mockTotalSupply = new BigNumber(100); // Note - giving a fixedTokenValue of 1 means a ratio of 1:1 votes to tokens, making sums easier :) @@ -41,7 +41,7 @@ jest.mock('../../../../contexts/app-state/app-state-context', () => ({ })); const renderComponent = ( - proposal: ProposalQuery['proposal'], + proposal: Proposal, // eslint-disable-next-line @typescript-eslint/no-explicit-any mocks: MockedResponse[] = [networkParamsQueryMock] ) => diff --git a/apps/governance/src/routes/proposals/components/vote-breakdown/vote-breakdown.tsx b/apps/governance/src/routes/proposals/components/vote-breakdown/vote-breakdown.tsx index df82865c9..0c03fca66 100644 --- a/apps/governance/src/routes/proposals/components/vote-breakdown/vote-breakdown.tsx +++ b/apps/governance/src/routes/proposals/components/vote-breakdown/vote-breakdown.tsx @@ -1,3 +1,4 @@ +import { type ReactNode } from 'react'; import classNames from 'classnames'; import BigNumber from 'bignumber.js'; import { useTranslation } from 'react-i18next'; @@ -5,10 +6,8 @@ import { useVoteInformation } from '../../hooks'; import { Icon, Tooltip } from '@vegaprotocol/ui-toolkit'; import { formatNumber } from '@vegaprotocol/utils'; import { ProposalState } from '@vegaprotocol/types'; -import type { ReactNode } from 'react'; -import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals'; -import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; import { CompactNumber } from '@vegaprotocol/react-helpers'; +import { type Proposal } from '../../types'; export const CompactVotes = ({ number }: { number: BigNumber }) => ( ( ); interface VoteBreakdownProps { - proposal: ProposalFieldsFragment | ProposalQuery['proposal']; + proposal: Proposal; } interface VoteProgressProps { diff --git a/apps/governance/src/routes/proposals/components/vote-details/user-vote.tsx b/apps/governance/src/routes/proposals/components/vote-details/user-vote.tsx index 67624194e..ad4eb9386 100644 --- a/apps/governance/src/routes/proposals/components/vote-details/user-vote.tsx +++ b/apps/governance/src/routes/proposals/components/vote-details/user-vote.tsx @@ -5,14 +5,13 @@ import { ProposalState } from '@vegaprotocol/types'; import { ConnectToVega } from '../../../../components/connect-to-vega'; import { VoteButtonsContainer } from './vote-buttons'; import { SubHeading } from '../../../../components/heading'; -import type { VoteValue } from '@vegaprotocol/types'; -import type { DialogProps, VegaTxState } from '@vegaprotocol/proposals'; -import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals'; -import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; -import type { VoteState } from './use-user-vote'; +import { type VoteValue } from '@vegaprotocol/types'; +import { type DialogProps, type VegaTxState } from '@vegaprotocol/proposals'; +import { type VoteState } from './use-user-vote'; +import { type Proposal } from '../../types'; interface UserVoteProps { - proposal: ProposalFieldsFragment | ProposalQuery['proposal']; + proposal: Proposal; minVoterBalance: string | null | undefined; spamProtectionMinTokens: string | null | undefined; transaction: VegaTxState | null; diff --git a/apps/governance/src/routes/proposals/hooks/use-proposal-network-params.ts b/apps/governance/src/routes/proposals/hooks/use-proposal-network-params.ts index 424f3a96a..665a43ef6 100644 --- a/apps/governance/src/routes/proposals/hooks/use-proposal-network-params.ts +++ b/apps/governance/src/routes/proposals/hooks/use-proposal-network-params.ts @@ -3,13 +3,12 @@ import { useNetworkParams, } from '@vegaprotocol/network-parameters'; import { BigNumber } from '../../../lib/bignumber'; -import type { ProposalFieldsFragment } from '../proposals/__generated__/Proposals'; -import type { ProposalQuery } from '../proposal/__generated__/Proposal'; +import { type Proposal } from '../types'; export const useProposalNetworkParams = ({ proposal, }: { - proposal: ProposalFieldsFragment | ProposalQuery['proposal']; + proposal: Proposal; }) => { const { params } = useNetworkParams([ NetworkParams.governance_proposal_updateMarket_requiredMajority, diff --git a/apps/governance/src/routes/proposals/hooks/use-vote-information.ts b/apps/governance/src/routes/proposals/hooks/use-vote-information.ts index e66823b83..2c6add8fb 100644 --- a/apps/governance/src/routes/proposals/hooks/use-vote-information.ts +++ b/apps/governance/src/routes/proposals/hooks/use-vote-information.ts @@ -2,15 +2,10 @@ import { useMemo } from 'react'; import { useAppState } from '../../../contexts/app-state/app-state-context'; import { BigNumber } from '../../../lib/bignumber'; import { useProposalNetworkParams } from './use-proposal-network-params'; -import type { ProposalFieldsFragment } from '../proposals/__generated__/Proposals'; -import type { ProposalQuery } from '../proposal/__generated__/Proposal'; import { addDecimal } from '@vegaprotocol/utils'; +import { type Proposal } from '../types'; -export const useVoteInformation = ({ - proposal, -}: { - proposal: ProposalFieldsFragment | ProposalQuery['proposal']; -}) => { +export const useVoteInformation = ({ proposal }: { proposal: Proposal }) => { const { appState: { totalSupply, decimals }, } = useAppState(); diff --git a/apps/governance/src/routes/proposals/proposal/Proposal.graphql b/apps/governance/src/routes/proposals/proposal/Proposal.graphql index e7f0be3d3..21aa371cb 100644 --- a/apps/governance/src/routes/proposals/proposal/Proposal.graphql +++ b/apps/governance/src/routes/proposals/proposal/Proposal.graphql @@ -86,228 +86,65 @@ query Proposal( $includeUpdateReferralProgram: Boolean! ) { proposal(id: $proposalId) { - id - rationale { - title - description - } - reference - state - datetime - rejectionReason - party { + ... on Proposal { id - } - errorDetails - ...NewMarketProductField @include(if: $includeNewMarketProductField) - ...UpdateMarketState @include(if: $includeUpdateMarketState) - ...UpdateReferralProgram @include(if: $includeUpdateReferralProgram) - ...UpdateVolumeDiscountProgram - terms { - closingDatetime - enactmentDatetime - change { - ... on NewMarket { - decimalPlaces - metadata - riskParameters { - ... on LogNormalRiskModel { - riskAversionParameter - tau - params { - mu - r - sigma - } - } - ... on SimpleRiskModel { - params { - factorLong - factorShort - } - } - } - instrument { - name - code - product { - ... on FutureProduct { - settlementAsset { - id - name - symbol - decimals - quantum - } - quoteName - dataSourceSpecBinding { - settlementDataProperty - tradingTerminationProperty - } - dataSourceSpecForSettlementData { - sourceType { - ... on DataSourceDefinitionInternal { - sourceType { - ... on DataSourceSpecConfigurationTime { - conditions { - operator - value - } - } - } - } - ... on DataSourceDefinitionExternal { - sourceType { - ... on DataSourceSpecConfiguration { - signers { - signer { - ... on PubKey { - key - } - ... on ETHAddress { - address - } - } - } - filters { - key { - name - type - } - conditions { - operator - value - } - } - } - } - } - } + rationale { + title + description + } + reference + state + datetime + rejectionReason + party { + id + } + errorDetails + ...NewMarketProductField @include(if: $includeNewMarketProductField) + ...UpdateMarketState @include(if: $includeUpdateMarketState) + ...UpdateReferralProgram @include(if: $includeUpdateReferralProgram) + ...UpdateVolumeDiscountProgram + terms { + closingDatetime + enactmentDatetime + change { + ... on NewMarket { + decimalPlaces + metadata + riskParameters { + ... on LogNormalRiskModel { + riskAversionParameter + tau + params { + mu + r + sigma } } - ... on PerpetualProduct { - settlementAsset { - id - name - symbol - decimals - quantum + ... on SimpleRiskModel { + params { + factorLong + factorShort } - quoteName } } - } - priceMonitoringParameters { - triggers { - horizonSecs - probability - auctionExtensionSecs - } - } - liquidityMonitoringParameters { - targetStakeParameters { - timeWindow - scalingFactor - } - } - positionDecimalPlaces - linearSlippageFactor - } - ... on UpdateMarket { - marketId - updateMarketConfiguration { instrument { + name code product { - ... on UpdateFutureProduct { - quoteName - dataSourceSpecForSettlementData { - sourceType { - ... on DataSourceDefinitionInternal { - sourceType { - ... on DataSourceSpecConfigurationTime { - conditions { - operator - value - } - } - } - } - ... on DataSourceDefinitionExternal { - sourceType { - ... on DataSourceSpecConfiguration { - signers { - signer { - ... on PubKey { - key - } - ... on ETHAddress { - address - } - } - } - filters { - key { - name - type - } - conditions { - operator - value - } - } - } - } - } - } + ... on FutureProduct { + settlementAsset { + id + name + symbol + decimals + quantum } - # dataSourceSpecForTradingTermination { - # sourceType { - # ... on DataSourceDefinitionInternal { - # sourceType { - # ... on DataSourceSpecConfigurationTime { - # conditions { - # operator - # value - # } - # } - # } - # } - # ... on DataSourceDefinitionExternal { - # sourceType { - # ... on DataSourceSpecConfiguration { - # signers { - # signer { - # ... on PubKey { - # key - # } - # ... on ETHAddress { - # address - # } - # } - # } - # filters { - # key { - # name - # type - # } - # conditions { - # operator - # value - # } - # } - # } - # } - # } - # } - # } + quoteName dataSourceSpecBinding { settlementDataProperty tradingTerminationProperty } - } - ... on UpdatePerpetualProduct { - quoteName dataSourceSpecForSettlementData { sourceType { ... on DataSourceDefinitionInternal { @@ -348,14 +185,19 @@ query Proposal( } } } - dataSourceSpecBinding { - settlementDataProperty - settlementScheduleProperty + } + ... on PerpetualProduct { + settlementAsset { + id + name + symbol + decimals + quantum } + quoteName } } } - metadata priceMonitoringParameters { triggers { horizonSecs @@ -369,71 +211,231 @@ query Proposal( scalingFactor } } - riskParameters { - ... on UpdateMarketSimpleRiskModel { - simple { - factorLong - factorShort + positionDecimalPlaces + linearSlippageFactor + } + ... on UpdateMarket { + marketId + updateMarketConfiguration { + instrument { + code + product { + ... on UpdateFutureProduct { + quoteName + dataSourceSpecForSettlementData { + sourceType { + ... on DataSourceDefinitionInternal { + sourceType { + ... on DataSourceSpecConfigurationTime { + conditions { + operator + value + } + } + } + } + ... on DataSourceDefinitionExternal { + sourceType { + ... on DataSourceSpecConfiguration { + signers { + signer { + ... on PubKey { + key + } + ... on ETHAddress { + address + } + } + } + filters { + key { + name + type + } + conditions { + operator + value + } + } + } + } + } + } + } + # dataSourceSpecForTradingTermination { + # sourceType { + # ... on DataSourceDefinitionInternal { + # sourceType { + # ... on DataSourceSpecConfigurationTime { + # conditions { + # operator + # value + # } + # } + # } + # } + # ... on DataSourceDefinitionExternal { + # sourceType { + # ... on DataSourceSpecConfiguration { + # signers { + # signer { + # ... on PubKey { + # key + # } + # ... on ETHAddress { + # address + # } + # } + # } + # filters { + # key { + # name + # type + # } + # conditions { + # operator + # value + # } + # } + # } + # } + # } + # } + # } + dataSourceSpecBinding { + settlementDataProperty + tradingTerminationProperty + } + } + ... on UpdatePerpetualProduct { + quoteName + dataSourceSpecForSettlementData { + sourceType { + ... on DataSourceDefinitionInternal { + sourceType { + ... on DataSourceSpecConfigurationTime { + conditions { + operator + value + } + } + } + } + ... on DataSourceDefinitionExternal { + sourceType { + ... on DataSourceSpecConfiguration { + signers { + signer { + ... on PubKey { + key + } + ... on ETHAddress { + address + } + } + } + filters { + key { + name + type + } + conditions { + operator + value + } + } + } + } + } + } + } + dataSourceSpecBinding { + settlementDataProperty + settlementScheduleProperty + } + } } } - ... on UpdateMarketLogNormalRiskModel { - logNormal { - riskAversionParameter - tau - params { - r - sigma - mu + metadata + priceMonitoringParameters { + triggers { + horizonSecs + probability + auctionExtensionSecs + } + } + liquidityMonitoringParameters { + targetStakeParameters { + timeWindow + scalingFactor + } + } + riskParameters { + ... on UpdateMarketSimpleRiskModel { + simple { + factorLong + factorShort + } + } + ... on UpdateMarketLogNormalRiskModel { + logNormal { + riskAversionParameter + tau + params { + r + sigma + mu + } } } } } } - } - ... on NewAsset { - name - symbol - decimals - quantum - source { - ... on BuiltinAsset { - maxFaucetAmountMint - } - ... on ERC20 { - contractAddress - lifetimeLimit - withdrawThreshold + ... on NewAsset { + name + symbol + decimals + quantum + source { + ... on BuiltinAsset { + maxFaucetAmountMint + } + ... on ERC20 { + contractAddress + lifetimeLimit + withdrawThreshold + } } } - } - ... on UpdateNetworkParameter { - networkParameter { - key - value + ... on UpdateNetworkParameter { + networkParameter { + key + value + } } - } - ... on UpdateAsset { - quantum - assetId - source { - ... on UpdateERC20 { - lifetimeLimit - withdrawThreshold + ... on UpdateAsset { + quantum + assetId + source { + ... on UpdateERC20 { + lifetimeLimit + withdrawThreshold + } } } } } - } - votes { - yes { - totalTokens - totalNumber - totalEquityLikeShareWeight - } - no { - totalTokens - totalNumber - totalEquityLikeShareWeight + votes { + yes { + totalTokens + totalNumber + totalEquityLikeShareWeight + } + no { + totalTokens + totalNumber + totalEquityLikeShareWeight + } } } } diff --git a/apps/governance/src/routes/proposals/proposal/__generated__/Proposal.ts b/apps/governance/src/routes/proposals/proposal/__generated__/Proposal.ts index 9b4c5f93c..1baf8d3a2 100644 --- a/apps/governance/src/routes/proposals/proposal/__generated__/Proposal.ts +++ b/apps/governance/src/routes/proposals/proposal/__generated__/Proposal.ts @@ -19,7 +19,7 @@ export type ProposalQueryVariables = Types.Exact<{ }>; -export type ProposalQuery = { __typename?: 'Query', proposal?: { __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, datetime: any, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null, rationale: { __typename?: 'ProposalRationale', title: string, description: string }, party: { __typename?: 'Party', id: string }, terms: { __typename?: 'ProposalTerms', closingDatetime: any, enactmentDatetime?: any | null, change: { __typename?: 'CancelTransfer' } | { __typename?: 'NewAsset', name: string, symbol: string, decimals: number, quantum: string, source: { __typename?: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename?: 'ERC20', contractAddress: string, lifetimeLimit: string, withdrawThreshold: string } } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', decimalPlaces: number, metadata?: Array | null, positionDecimalPlaces: number, linearSlippageFactor: string, riskParameters: { __typename?: 'LogNormalRiskModel', riskAversionParameter: number, tau: number, params: { __typename?: 'LogNormalModelParams', mu: number, r: number, sigma: number } } | { __typename?: 'SimpleRiskModel', params: { __typename?: 'SimpleRiskModelParams', factorLong: number, factorShort: number } }, instrument: { __typename?: 'InstrumentConfiguration', name: string, code: string, product?: { __typename: 'FutureProduct', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, quantum: string }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecToFutureBinding', settlementDataProperty: string, tradingTerminationProperty: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType }, conditions?: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null }> | null }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger' } } } } | { __typename: 'PerpetualProduct', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, quantum: string } } | { __typename: 'SpotProduct' } | null }, priceMonitoringParameters: { __typename?: 'PriceMonitoringParameters', triggers?: Array<{ __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number }> | null }, liquidityMonitoringParameters: { __typename?: 'LiquidityMonitoringParameters', targetStakeParameters: { __typename?: 'TargetStakeParameters', timeWindow: number, scalingFactor: number } } } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset', quantum: string, assetId: string, source: { __typename?: 'UpdateERC20', lifetimeLimit: string, withdrawThreshold: string } } | { __typename?: 'UpdateMarket', marketId: string, updateMarketConfiguration: { __typename?: 'UpdateMarketConfiguration', metadata?: Array | null, instrument: { __typename?: 'UpdateInstrumentConfiguration', code: string, product: { __typename?: 'UpdateFutureProduct', quoteName: string, dataSourceSpecForSettlementData: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType }, conditions?: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null }> | null }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger' } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecToFutureBinding', settlementDataProperty: string, tradingTerminationProperty: string } } | { __typename?: 'UpdatePerpetualProduct', quoteName: string, dataSourceSpecForSettlementData: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType }, conditions?: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null }> | null }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger' } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecPerpetualBinding', settlementDataProperty: string, settlementScheduleProperty: string } } }, priceMonitoringParameters: { __typename?: 'PriceMonitoringParameters', triggers?: Array<{ __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number }> | null }, liquidityMonitoringParameters: { __typename?: 'LiquidityMonitoringParameters', targetStakeParameters: { __typename?: 'TargetStakeParameters', timeWindow: number, scalingFactor: number } }, riskParameters: { __typename?: 'UpdateMarketLogNormalRiskModel', logNormal?: { __typename?: 'LogNormalRiskModel', riskAversionParameter: number, tau: number, params: { __typename?: 'LogNormalModelParams', r: number, sigma: number, mu: number } } | null } | { __typename?: 'UpdateMarketSimpleRiskModel', simple?: { __typename?: 'SimpleRiskModelParams', factorLong: number, factorShort: number } | null } } } | { __typename?: 'UpdateMarketState', updateType: Types.MarketUpdateType, price?: string | null, market: { __typename?: 'Market', decimalPlaces: number, id: string, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string, code: string, product: { __typename: 'Future', quoteName: string } | { __typename: 'Perpetual', quoteName: string } | { __typename: 'Spot' } } } } } | { __typename?: 'UpdateNetworkParameter', networkParameter: { __typename?: 'NetworkParameter', key: string, value: string } } | { __typename?: 'UpdateReferralProgram', windowLength: number, endOfProgram: any, benefitTiers: Array<{ __typename?: 'BenefitTier', minimumEpochs: number, minimumRunningNotionalTakerVolume: string, referralDiscountFactor: string, referralRewardFactor: string }>, stakingTiers: Array<{ __typename?: 'StakingTier', minimumStakedTokens: string, referralRewardMultiplier: string }> } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram', endOfProgramTimestamp: any, windowLength: number, benefitTiers: Array<{ __typename?: 'VolumeBenefitTier', minimumRunningNotionalTakerVolume: string, volumeDiscountFactor: string }> } }, votes: { __typename?: 'ProposalVotes', yes: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string }, no: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string } } } | null }; +export type ProposalQuery = { __typename?: 'Query', proposal?: { __typename?: 'BatchProposal' } | { __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, datetime: any, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null, rationale: { __typename?: 'ProposalRationale', title: string, description: string }, party: { __typename?: 'Party', id: string }, terms: { __typename?: 'ProposalTerms', closingDatetime: any, enactmentDatetime?: any | null, change: { __typename?: 'CancelTransfer' } | { __typename?: 'NewAsset', name: string, symbol: string, decimals: number, quantum: string, source: { __typename?: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename?: 'ERC20', contractAddress: string, lifetimeLimit: string, withdrawThreshold: string } } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', decimalPlaces: number, metadata?: Array | null, positionDecimalPlaces: number, linearSlippageFactor: string, riskParameters: { __typename?: 'LogNormalRiskModel', riskAversionParameter: number, tau: number, params: { __typename?: 'LogNormalModelParams', mu: number, r: number, sigma: number } } | { __typename?: 'SimpleRiskModel', params: { __typename?: 'SimpleRiskModelParams', factorLong: number, factorShort: number } }, instrument: { __typename?: 'InstrumentConfiguration', name: string, code: string, product?: { __typename: 'FutureProduct', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, quantum: string }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecToFutureBinding', settlementDataProperty: string, tradingTerminationProperty: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType }, conditions?: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null }> | null }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger' } } } } | { __typename: 'PerpetualProduct', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, quantum: string } } | { __typename: 'SpotProduct' } | null }, priceMonitoringParameters: { __typename?: 'PriceMonitoringParameters', triggers?: Array<{ __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number }> | null }, liquidityMonitoringParameters: { __typename?: 'LiquidityMonitoringParameters', targetStakeParameters: { __typename?: 'TargetStakeParameters', timeWindow: number, scalingFactor: number } } } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer' } | { __typename?: 'UpdateAsset', quantum: string, assetId: string, source: { __typename?: 'UpdateERC20', lifetimeLimit: string, withdrawThreshold: string } } | { __typename?: 'UpdateMarket', marketId: string, updateMarketConfiguration: { __typename?: 'UpdateMarketConfiguration', metadata?: Array | null, instrument: { __typename?: 'UpdateInstrumentConfiguration', code: string, product: { __typename?: 'UpdateFutureProduct', quoteName: string, dataSourceSpecForSettlementData: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType }, conditions?: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null }> | null }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger' } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecToFutureBinding', settlementDataProperty: string, tradingTerminationProperty: string } } | { __typename?: 'UpdatePerpetualProduct', quoteName: string, dataSourceSpecForSettlementData: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType }, conditions?: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null }> | null }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger' } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecPerpetualBinding', settlementDataProperty: string, settlementScheduleProperty: string } } }, priceMonitoringParameters: { __typename?: 'PriceMonitoringParameters', triggers?: Array<{ __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number }> | null }, liquidityMonitoringParameters: { __typename?: 'LiquidityMonitoringParameters', targetStakeParameters: { __typename?: 'TargetStakeParameters', timeWindow: number, scalingFactor: number } }, riskParameters: { __typename?: 'UpdateMarketLogNormalRiskModel', logNormal?: { __typename?: 'LogNormalRiskModel', riskAversionParameter: number, tau: number, params: { __typename?: 'LogNormalModelParams', r: number, sigma: number, mu: number } } | null } | { __typename?: 'UpdateMarketSimpleRiskModel', simple?: { __typename?: 'SimpleRiskModelParams', factorLong: number, factorShort: number } | null } } } | { __typename?: 'UpdateMarketState', updateType: Types.MarketUpdateType, price?: string | null, market: { __typename?: 'Market', decimalPlaces: number, id: string, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string, code: string, product: { __typename: 'Future', quoteName: string } | { __typename: 'Perpetual', quoteName: string } | { __typename: 'Spot' } } } } } | { __typename?: 'UpdateNetworkParameter', networkParameter: { __typename?: 'NetworkParameter', key: string, value: string } } | { __typename?: 'UpdateReferralProgram', windowLength: number, endOfProgram: any, benefitTiers: Array<{ __typename?: 'BenefitTier', minimumEpochs: number, minimumRunningNotionalTakerVolume: string, referralDiscountFactor: string, referralRewardFactor: string }>, stakingTiers: Array<{ __typename?: 'StakingTier', minimumStakedTokens: string, referralRewardMultiplier: string }> } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram', endOfProgramTimestamp: any, windowLength: number, benefitTiers: Array<{ __typename?: 'VolumeBenefitTier', minimumRunningNotionalTakerVolume: string, volumeDiscountFactor: string }> } }, votes: { __typename?: 'ProposalVotes', yes: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string }, no: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, totalEquityLikeShareWeight: string } } } | null }; export const NewMarketProductFieldFragmentDoc = gql` fragment NewMarketProductField on Proposal { @@ -109,188 +109,65 @@ export const UpdateVolumeDiscountProgramFragmentDoc = gql` export const ProposalDocument = gql` query Proposal($proposalId: ID!, $includeNewMarketProductField: Boolean!, $includeUpdateMarketState: Boolean!, $includeUpdateReferralProgram: Boolean!) { proposal(id: $proposalId) { - id - rationale { - title - description - } - reference - state - datetime - rejectionReason - party { + ... on Proposal { id - } - errorDetails - ...NewMarketProductField @include(if: $includeNewMarketProductField) - ...UpdateMarketState @include(if: $includeUpdateMarketState) - ...UpdateReferralProgram @include(if: $includeUpdateReferralProgram) - ...UpdateVolumeDiscountProgram - terms { - closingDatetime - enactmentDatetime - change { - ... on NewMarket { - decimalPlaces - metadata - riskParameters { - ... on LogNormalRiskModel { - riskAversionParameter - tau - params { - mu - r - sigma - } - } - ... on SimpleRiskModel { - params { - factorLong - factorShort - } - } - } - instrument { - name - code - product { - ... on FutureProduct { - settlementAsset { - id - name - symbol - decimals - quantum - } - quoteName - dataSourceSpecBinding { - settlementDataProperty - tradingTerminationProperty - } - dataSourceSpecForSettlementData { - sourceType { - ... on DataSourceDefinitionInternal { - sourceType { - ... on DataSourceSpecConfigurationTime { - conditions { - operator - value - } - } - } - } - ... on DataSourceDefinitionExternal { - sourceType { - ... on DataSourceSpecConfiguration { - signers { - signer { - ... on PubKey { - key - } - ... on ETHAddress { - address - } - } - } - filters { - key { - name - type - } - conditions { - operator - value - } - } - } - } - } - } + rationale { + title + description + } + reference + state + datetime + rejectionReason + party { + id + } + errorDetails + ...NewMarketProductField @include(if: $includeNewMarketProductField) + ...UpdateMarketState @include(if: $includeUpdateMarketState) + ...UpdateReferralProgram @include(if: $includeUpdateReferralProgram) + ...UpdateVolumeDiscountProgram + terms { + closingDatetime + enactmentDatetime + change { + ... on NewMarket { + decimalPlaces + metadata + riskParameters { + ... on LogNormalRiskModel { + riskAversionParameter + tau + params { + mu + r + sigma } } - ... on PerpetualProduct { - settlementAsset { - id - name - symbol - decimals - quantum + ... on SimpleRiskModel { + params { + factorLong + factorShort } - quoteName } } - } - priceMonitoringParameters { - triggers { - horizonSecs - probability - auctionExtensionSecs - } - } - liquidityMonitoringParameters { - targetStakeParameters { - timeWindow - scalingFactor - } - } - positionDecimalPlaces - linearSlippageFactor - } - ... on UpdateMarket { - marketId - updateMarketConfiguration { instrument { + name code product { - ... on UpdateFutureProduct { - quoteName - dataSourceSpecForSettlementData { - sourceType { - ... on DataSourceDefinitionInternal { - sourceType { - ... on DataSourceSpecConfigurationTime { - conditions { - operator - value - } - } - } - } - ... on DataSourceDefinitionExternal { - sourceType { - ... on DataSourceSpecConfiguration { - signers { - signer { - ... on PubKey { - key - } - ... on ETHAddress { - address - } - } - } - filters { - key { - name - type - } - conditions { - operator - value - } - } - } - } - } - } + ... on FutureProduct { + settlementAsset { + id + name + symbol + decimals + quantum } + quoteName dataSourceSpecBinding { settlementDataProperty tradingTerminationProperty } - } - ... on UpdatePerpetualProduct { - quoteName dataSourceSpecForSettlementData { sourceType { ... on DataSourceDefinitionInternal { @@ -331,14 +208,19 @@ export const ProposalDocument = gql` } } } - dataSourceSpecBinding { - settlementDataProperty - settlementScheduleProperty + } + ... on PerpetualProduct { + settlementAsset { + id + name + symbol + decimals + quantum } + quoteName } } } - metadata priceMonitoringParameters { triggers { horizonSecs @@ -352,71 +234,191 @@ export const ProposalDocument = gql` scalingFactor } } - riskParameters { - ... on UpdateMarketSimpleRiskModel { - simple { - factorLong - factorShort + positionDecimalPlaces + linearSlippageFactor + } + ... on UpdateMarket { + marketId + updateMarketConfiguration { + instrument { + code + product { + ... on UpdateFutureProduct { + quoteName + dataSourceSpecForSettlementData { + sourceType { + ... on DataSourceDefinitionInternal { + sourceType { + ... on DataSourceSpecConfigurationTime { + conditions { + operator + value + } + } + } + } + ... on DataSourceDefinitionExternal { + sourceType { + ... on DataSourceSpecConfiguration { + signers { + signer { + ... on PubKey { + key + } + ... on ETHAddress { + address + } + } + } + filters { + key { + name + type + } + conditions { + operator + value + } + } + } + } + } + } + } + dataSourceSpecBinding { + settlementDataProperty + tradingTerminationProperty + } + } + ... on UpdatePerpetualProduct { + quoteName + dataSourceSpecForSettlementData { + sourceType { + ... on DataSourceDefinitionInternal { + sourceType { + ... on DataSourceSpecConfigurationTime { + conditions { + operator + value + } + } + } + } + ... on DataSourceDefinitionExternal { + sourceType { + ... on DataSourceSpecConfiguration { + signers { + signer { + ... on PubKey { + key + } + ... on ETHAddress { + address + } + } + } + filters { + key { + name + type + } + conditions { + operator + value + } + } + } + } + } + } + } + dataSourceSpecBinding { + settlementDataProperty + settlementScheduleProperty + } + } } } - ... on UpdateMarketLogNormalRiskModel { - logNormal { - riskAversionParameter - tau - params { - r - sigma - mu + metadata + priceMonitoringParameters { + triggers { + horizonSecs + probability + auctionExtensionSecs + } + } + liquidityMonitoringParameters { + targetStakeParameters { + timeWindow + scalingFactor + } + } + riskParameters { + ... on UpdateMarketSimpleRiskModel { + simple { + factorLong + factorShort + } + } + ... on UpdateMarketLogNormalRiskModel { + logNormal { + riskAversionParameter + tau + params { + r + sigma + mu + } } } } } } - } - ... on NewAsset { - name - symbol - decimals - quantum - source { - ... on BuiltinAsset { - maxFaucetAmountMint - } - ... on ERC20 { - contractAddress - lifetimeLimit - withdrawThreshold + ... on NewAsset { + name + symbol + decimals + quantum + source { + ... on BuiltinAsset { + maxFaucetAmountMint + } + ... on ERC20 { + contractAddress + lifetimeLimit + withdrawThreshold + } } } - } - ... on UpdateNetworkParameter { - networkParameter { - key - value + ... on UpdateNetworkParameter { + networkParameter { + key + value + } } - } - ... on UpdateAsset { - quantum - assetId - source { - ... on UpdateERC20 { - lifetimeLimit - withdrawThreshold + ... on UpdateAsset { + quantum + assetId + source { + ... on UpdateERC20 { + lifetimeLimit + withdrawThreshold + } } } } } - } - votes { - yes { - totalTokens - totalNumber - totalEquityLikeShareWeight - } - no { - totalTokens - totalNumber - totalEquityLikeShareWeight + votes { + yes { + totalTokens + totalNumber + totalEquityLikeShareWeight + } + no { + totalTokens + totalNumber + totalEquityLikeShareWeight + } } } } diff --git a/apps/governance/src/routes/proposals/proposal/proposal-container.tsx b/apps/governance/src/routes/proposals/proposal/proposal-container.tsx index 2bf866624..57693bcd2 100644 --- a/apps/governance/src/routes/proposals/proposal/proposal-container.tsx +++ b/apps/governance/src/routes/proposals/proposal/proposal-container.tsx @@ -17,6 +17,7 @@ import { import { useParentMarketIdQuery } from '@vegaprotocol/markets'; import { useFeatureFlags } from '@vegaprotocol/environment'; import { useSuccessorMarketProposalDetails } from '@vegaprotocol/proposals'; +import { type Proposal as IProposal } from '../types'; export const ProposalContainer = () => { const featureFlags = useFeatureFlags((state) => state.flags); @@ -67,6 +68,8 @@ export const ProposalContainer = () => { skip: !params.proposalId, }); + const proposal = data?.proposal as IProposal; + const successor = useSuccessorMarketProposalDetails(params.proposalId); const isSuccessor = !!successor?.parentMarketId || !!successor.code; @@ -79,12 +82,12 @@ export const ProposalContainer = () => { }, } = useFetch( `${ENV.rest}governance?proposalId=${ - data?.proposal?.terms.change.__typename === 'UpdateMarket' && - data?.proposal.terms.change.marketId + proposal?.terms.change.__typename === 'UpdateMarket' && + proposal.terms.change.marketId }`, undefined, true, - data?.proposal?.terms.change.__typename !== 'UpdateMarket' + proposal?.terms.change.__typename !== 'UpdateMarket' ); const { @@ -97,7 +100,7 @@ export const ProposalContainer = () => { `${ENV.rest}governances?proposalState=STATE_ENACTED&proposalType=TYPE_UPDATE_MARKET`, undefined, true, - data?.proposal?.terms.change.__typename !== 'UpdateMarket' + proposal?.terms.change.__typename !== 'UpdateMarket' ); const { @@ -108,8 +111,8 @@ export const ProposalContainer = () => { dataProvider: marketInfoProvider, skipUpdates: true, variables: { - marketId: data?.proposal?.id || '', - skip: !data?.proposal?.id, + marketId: proposal?.id || '', + skip: !proposal?.id, }, }); @@ -148,23 +151,22 @@ export const ProposalContainer = () => { fetchPolicy: 'network-only', variables: { assetId: - (data?.proposal?.terms.change.__typename === 'NewAsset' && - data?.proposal?.id) || - (data?.proposal?.terms.change.__typename === 'UpdateAsset' && - data.proposal.terms.change.assetId) || + (proposal?.terms.change.__typename === 'NewAsset' && proposal?.id) || + (proposal?.terms.change.__typename === 'UpdateAsset' && + proposal.terms.change.assetId) || '', }, skip: !['NewAsset', 'UpdateAsset'].includes( - data?.proposal?.terms?.change?.__typename || '' + proposal?.terms?.change?.__typename || '' ), }); useEffect(() => { if ( previouslyEnactedMarketProposalsRestData && - data?.proposal?.terms.change.__typename === 'UpdateMarket' + proposal?.terms.change.__typename === 'UpdateMarket' ) { - const change = data?.proposal?.terms?.change as { marketId: string }; + const change = proposal?.terms?.change as { marketId: string }; const filteredProposals = // @ts-ignore rest data is not typed @@ -188,8 +190,8 @@ export const ProposalContainer = () => { }, [ previouslyEnactedMarketProposalsRestData, params.proposalId, - data?.proposal?.terms.change.__typename, - data?.proposal?.terms.change, + proposal?.terms.change.__typename, + proposal?.terms.change, ]); useEffect(() => { @@ -242,7 +244,7 @@ export const ProposalContainer = () => { > {data?.proposal ? ( = {} @@ -43,8 +44,8 @@ export function generateProtocolUpgradeProposal( } export function generateProposal( - override: PartialDeep = {} -): ProposalQuery['proposal'] { + override: PartialDeep = {} +): Proposal { const defaultProposal: ProposalQuery['proposal'] = { __typename: 'Proposal', id: faker.datatype.uuid(), @@ -92,15 +93,16 @@ export function generateProposal( }, }; - return mergeWith< - ProposalQuery['proposal'], - PartialDeep - >(defaultProposal, override, (objValue, srcValue) => { - if (!isArray(objValue)) { - return; + return mergeWith>( + defaultProposal, + override, + (objValue, srcValue) => { + if (!isArray(objValue)) { + return; + } + return srcValue; } - return srcValue; - }); + ); } type Vote = Pick; diff --git a/apps/governance/src/routes/proposals/types.ts b/apps/governance/src/routes/proposals/types.ts new file mode 100644 index 000000000..ad21280dd --- /dev/null +++ b/apps/governance/src/routes/proposals/types.ts @@ -0,0 +1,11 @@ +import type { ProposalQuery } from './proposal/__generated__/Proposal'; + +/** + * The default Proposal type needs extracting from the ProposalNode union type + * as lots of fields on the original type don't exist on BatchProposal. Eventually + * we will support BatchProposal but for now we don't + */ +export type Proposal = Extract< + ProposalQuery['proposal'], + { __typename?: 'Proposal' } +>; diff --git a/apps/trading/components/chart-container/chart-container.tsx b/apps/trading/components/chart-container/chart-container.tsx index 3f91b9589..ed3ddec00 100644 --- a/apps/trading/components/chart-container/chart-container.tsx +++ b/apps/trading/components/chart-container/chart-container.tsx @@ -11,6 +11,7 @@ import { } from '@vegaprotocol/candles-chart'; import { useEnvironment } from '@vegaprotocol/environment'; import { useChartSettings, STUDY_SIZE } from './use-chart-settings'; +import { SUPPORTED_INTERVALS, type SupportedInterval } from './constants'; /** * Renders either the pennant chart or the tradingview chart @@ -36,7 +37,7 @@ export const ChartContainer = ({ marketId }: { marketId: string }) => { const pennantChart = ( { libraryPath={CHARTING_LIBRARY_PATH} libraryHash={CHARTING_LIBRARY_HASH} marketId={marketId} - interval={toTradingViewResolution(interval)} + interval={toTradingViewResolution(interval as SupportedInterval)} onIntervalChange={(newInterval) => { setInterval(fromTradingViewResolution(newInterval)); }} @@ -83,7 +84,11 @@ export const ChartContainer = ({ marketId }: { marketId: string }) => { } }; -const toTradingViewResolution = (interval: Interval) => { +const toTradingViewResolution = (interval: SupportedInterval) => { + if (!SUPPORTED_INTERVALS.includes(interval)) { + throw new Error(`interval ${interval} is not supported`); + } + const resolution = TRADINGVIEW_INTERVAL_MAP[interval]; if (!resolution) { @@ -107,7 +112,11 @@ const fromTradingViewResolution = (resolution: string) => { return interval as Interval; }; -const toPennantInterval = (interval: Interval) => { +const toPennantInterval = (interval: SupportedInterval) => { + if (!SUPPORTED_INTERVALS.includes(interval)) { + throw new Error(`interval ${interval} is not supported`); + } + const pennantInterval = PENNANT_INTERVAL_MAP[interval]; if (!pennantInterval) { diff --git a/apps/trading/components/chart-container/chart-menu.tsx b/apps/trading/components/chart-container/chart-menu.tsx index 15645ddba..cc7fa8b3a 100644 --- a/apps/trading/components/chart-container/chart-menu.tsx +++ b/apps/trading/components/chart-container/chart-menu.tsx @@ -18,21 +18,13 @@ import { TradingDropdownTrigger, Icon, } from '@vegaprotocol/ui-toolkit'; -import { Interval } from '@vegaprotocol/types'; +import { type Interval } from '@vegaprotocol/types'; import { useEnvironment } from '@vegaprotocol/environment'; import { ALLOWED_TRADINGVIEW_HOSTNAMES } from '@vegaprotocol/trading-view'; import { IconNames, type IconName } from '@blueprintjs/icons'; import { useChartSettings } from './use-chart-settings'; import { useT } from '../../lib/use-t'; - -const INTERVALS = [ - Interval.INTERVAL_I1M, - Interval.INTERVAL_I5M, - Interval.INTERVAL_I15M, - Interval.INTERVAL_I1H, - Interval.INTERVAL_I6H, - Interval.INTERVAL_I1D, -]; +import { SUPPORTED_INTERVALS } from './constants'; const chartTypeIcon = new Map([ [ChartType.AREA, IconNames.TIMELINE_AREA_CHART], @@ -94,7 +86,7 @@ export const ChartMenu = () => { setInterval(value as Interval); }} > - {INTERVALS.map((timeInterval) => ( + {SUPPORTED_INTERVALS.map((timeInterval) => ( { } as CandlesQuery; }; -const dataMocks: { [key in Schema.Interval]: Partial[] } = - { - [Schema.Interval.INTERVAL_I1M]: [ - { - __typename: 'Candle', - periodStart: '2023-05-10T12:00:00Z', - lastUpdateInPeriod: '', - close: '10', - volume: '1', - }, - { - __typename: 'Candle', - periodStart: '2023-05-10T12:05:00Z', - lastUpdateInPeriod: '', - close: '5', - volume: '2', - }, - ], - [Schema.Interval.INTERVAL_I5M]: [ - { - __typename: 'Candle', - periodStart: '2023-05-10T12:00:00Z', - lastUpdateInPeriod: '', - close: '10', - volume: '1', - }, - { - __typename: 'Candle', - periodStart: '2023-05-10T12:25:00Z', - lastUpdateInPeriod: '', - close: '5', - volume: '2', - }, - ], - [Schema.Interval.INTERVAL_I15M]: [ - { - __typename: 'Candle', - periodStart: '2023-05-10T12:00:00Z', - lastUpdateInPeriod: '', - close: '10', - volume: '1', - }, - { - __typename: 'Candle', - periodStart: '2023-05-10T13:15:00Z', - lastUpdateInPeriod: '', - close: '5', - volume: '2', - }, - ], - [Schema.Interval.INTERVAL_I1H]: [ - { - __typename: 'Candle', - periodStart: '2023-05-10T12:00:00Z', - lastUpdateInPeriod: '', - close: '10', - volume: '1', - }, - { - __typename: 'Candle', - periodStart: '2023-05-10T17:00:00Z', - lastUpdateInPeriod: '', - close: '5', - volume: '2', - }, - ], - [Schema.Interval.INTERVAL_I6H]: [ - { - __typename: 'Candle', - periodStart: '2023-05-10T12:00:00Z', - lastUpdateInPeriod: '', - close: '10', - volume: '1', - }, - { - __typename: 'Candle', - periodStart: '2023-05-11T18:00:00Z', - lastUpdateInPeriod: '', - close: '5', - volume: '2', - }, - ], - [Schema.Interval.INTERVAL_I1D]: [ - { - __typename: 'Candle', - periodStart: '2023-05-10T00:00:00Z', - lastUpdateInPeriod: '', - close: '10', - volume: '1', - }, - { - __typename: 'Candle', - periodStart: '2023-05-15T00:00:00Z', - lastUpdateInPeriod: '', - close: '5', - volume: '2', - }, - ], - [Schema.Interval.INTERVAL_BLOCK]: [], - }; +const dataMocks: { + [key in Schema.Interval]?: Partial[]; +} = { + [Schema.Interval.INTERVAL_I1M]: [ + { + __typename: 'Candle', + periodStart: '2023-05-10T12:00:00Z', + lastUpdateInPeriod: '', + close: '10', + volume: '1', + }, + { + __typename: 'Candle', + periodStart: '2023-05-10T12:05:00Z', + lastUpdateInPeriod: '', + close: '5', + volume: '2', + }, + ], + [Schema.Interval.INTERVAL_I5M]: [ + { + __typename: 'Candle', + periodStart: '2023-05-10T12:00:00Z', + lastUpdateInPeriod: '', + close: '10', + volume: '1', + }, + { + __typename: 'Candle', + periodStart: '2023-05-10T12:25:00Z', + lastUpdateInPeriod: '', + close: '5', + volume: '2', + }, + ], + [Schema.Interval.INTERVAL_I15M]: [ + { + __typename: 'Candle', + periodStart: '2023-05-10T12:00:00Z', + lastUpdateInPeriod: '', + close: '10', + volume: '1', + }, + { + __typename: 'Candle', + periodStart: '2023-05-10T13:15:00Z', + lastUpdateInPeriod: '', + close: '5', + volume: '2', + }, + ], + [Schema.Interval.INTERVAL_I1H]: [ + { + __typename: 'Candle', + periodStart: '2023-05-10T12:00:00Z', + lastUpdateInPeriod: '', + close: '10', + volume: '1', + }, + { + __typename: 'Candle', + periodStart: '2023-05-10T17:00:00Z', + lastUpdateInPeriod: '', + close: '5', + volume: '2', + }, + ], + [Schema.Interval.INTERVAL_I6H]: [ + { + __typename: 'Candle', + periodStart: '2023-05-10T12:00:00Z', + lastUpdateInPeriod: '', + close: '10', + volume: '1', + }, + { + __typename: 'Candle', + periodStart: '2023-05-11T18:00:00Z', + lastUpdateInPeriod: '', + close: '5', + volume: '2', + }, + ], + [Schema.Interval.INTERVAL_I1D]: [ + { + __typename: 'Candle', + periodStart: '2023-05-10T00:00:00Z', + lastUpdateInPeriod: '', + close: '10', + volume: '1', + }, + { + __typename: 'Candle', + periodStart: '2023-05-15T00:00:00Z', + lastUpdateInPeriod: '', + close: '5', + volume: '2', + }, + ], + [Schema.Interval.INTERVAL_BLOCK]: [], +}; describe('VegaDataSource', () => { const marketId = 'marketId'; diff --git a/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx b/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx index 0f3b6d6db..ee3e9abcf 100644 --- a/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx +++ b/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx @@ -263,8 +263,11 @@ export const DealTicket = ({ marketId: market.id, openVolume, orders, - collateralAvailable: - marginAccountBalance || generalAccountBalance ? balance : undefined, + marginAccountBalance: marginAccountBalance, + generalAccountBalance: generalAccountBalance, + orderMarginAccountBalance: '0', // TODO: Get real balance + marginMode: Schema.MarginMode.MARGIN_MODE_CROSS_MARGIN, // TODO: unhardcode this and get users margin mode for the market + averageEntryPrice: marketPrice || '0', // TODO: This assumes the order will be entirely filled at the current market price skip: !normalizedOrder || (normalizedOrder.type !== Schema.OrderType.TYPE_MARKET && diff --git a/libs/deal-ticket/src/components/trading-mode-tooltip/trading-mode-tooltip.tsx b/libs/deal-ticket/src/components/trading-mode-tooltip/trading-mode-tooltip.tsx index 44988900d..56b6421bb 100644 --- a/libs/deal-ticket/src/components/trading-mode-tooltip/trading-mode-tooltip.tsx +++ b/libs/deal-ticket/src/components/trading-mode-tooltip/trading-mode-tooltip.tsx @@ -1,7 +1,11 @@ import { useMemo } from 'react'; import { parseISO, isValid, isAfter } from 'date-fns'; import classNames from 'classnames'; -import { useProposalOfMarketQuery } from '@vegaprotocol/proposals'; +import { + useProposalOfMarketQuery, + type ProposalOfMarketQuery, + type SingleProposal, +} from '@vegaprotocol/proposals'; import { DocsLinks } from '@vegaprotocol/environment'; import { getDateTimeFormat } from '@vegaprotocol/utils'; import * as Schema from '@vegaprotocol/types'; @@ -36,12 +40,15 @@ export const TradingModeTooltip = ({ marketTradingMode, }); + // We only fetch Proposals (and not BatchProposals) + const proposal = proposalData?.proposal as SingleProposal< + ProposalOfMarketQuery['proposal'] + >; + if (!market || !marketData) { return null; } - const enactmentDate = parseISO( - proposalData?.proposal?.terms.enactmentDatetime - ); + const enactmentDate = parseISO(proposal?.terms.enactmentDatetime); const compiledGrid = !skipGrid && compileGridData(t, market, marketData, onSelect); diff --git a/libs/deal-ticket/src/hooks/use-position-estimate.spec.ts b/libs/deal-ticket/src/hooks/use-position-estimate.spec.ts deleted file mode 100644 index 422dbccc4..000000000 --- a/libs/deal-ticket/src/hooks/use-position-estimate.spec.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { renderHook } from '@testing-library/react'; -import { usePositionEstimate } from './use-position-estimate'; -import * as positionsModule from '@vegaprotocol/positions'; -import type { - EstimatePositionQuery, - EstimatePositionQueryVariables, -} from '@vegaprotocol/positions'; -import type { QueryResult } from '@apollo/client'; - -let mockData: object | undefined = {}; - -describe('usePositionEstimate', () => { - const args = { - marketId: 'marketId', - openVolume: '10', - orders: [], - collateralAvailable: '200', - skip: false, - }; - it('should return proper data', () => { - jest - .spyOn(positionsModule, 'useEstimatePositionQuery') - .mockReturnValue({ data: mockData } as unknown as QueryResult< - EstimatePositionQuery, - EstimatePositionQueryVariables - >); - const { result, rerender } = renderHook(() => usePositionEstimate(args)); - expect(result.current).toEqual(mockData); - mockData = undefined; - rerender(true); - expect(result.current).toEqual({}); - }); -}); diff --git a/libs/deal-ticket/src/hooks/use-position-estimate.ts b/libs/deal-ticket/src/hooks/use-position-estimate.ts index c91947681..98ed0a619 100644 --- a/libs/deal-ticket/src/hooks/use-position-estimate.ts +++ b/libs/deal-ticket/src/hooks/use-position-estimate.ts @@ -13,7 +13,12 @@ export const usePositionEstimate = ({ marketId, openVolume, orders, - collateralAvailable, + generalAccountBalance, + marginAccountBalance, + orderMarginAccountBalance, + averageEntryPrice, + marginMode, + marginFactor, skip, }: PositionEstimateProps) => { const [estimates, setEstimates] = useState( @@ -24,7 +29,12 @@ export const usePositionEstimate = ({ marketId, openVolume, orders, - collateralAvailable, + generalAccountBalance, + marginAccountBalance, + orderMarginAccountBalance, + averageEntryPrice, + marginMode, + marginFactor, }, skip, fetchPolicy: 'no-cache', 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 8d661a7cd..ba5837a3f 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 @@ -65,7 +65,11 @@ import { useSuccessorMarketIdsQuery, useSuccessorMarketQuery, } from '../../__generated__'; -import { useSuccessorMarketProposalDetailsQuery } from '@vegaprotocol/proposals'; +import { + useSuccessorMarketProposalDetailsQuery, + type SuccessorMarketProposalDetailsQuery, + type SingleProposal, +} from '@vegaprotocol/proposals'; import { getQuoteName, getAsset } from '../../market-utils'; import classNames from 'classnames'; import compact from 'lodash/compact'; @@ -206,6 +210,11 @@ export const KeyDetailsInfoPanel = ({ skip: !featureFlags.SUCCESSOR_MARKETS || !market.proposal?.id, }); + const successorProposal = + successorProposalDetails?.proposal as SingleProposal< + SuccessorMarketProposalDetailsQuery['proposal'] + >; + // The following queries are needed as the parent market could also have been a successor market. // Note: the parent market is only passed to this component if the successor markets flag is enabled, // so that check is not needed in the skip. @@ -223,6 +232,10 @@ export const KeyDetailsInfoPanel = ({ }, skip: !parentMarket?.proposal?.id, }); + const parentProposal = + parentSuccessorProposalDetails?.proposal as SingleProposal< + SuccessorMarketProposalDetailsQuery['proposal'] + >; const assetDecimals = getAsset(market).decimals; @@ -252,10 +265,9 @@ export const KeyDetailsInfoPanel = ({ parentMarketID: parentMarketIdData?.market?.parentMarketID || '-', insurancePoolFraction: - (successorProposalDetails?.proposal?.terms.change - .__typename === 'NewMarket' && - successorProposalDetails.proposal.terms.change - .successorConfiguration?.insurancePoolFraction) || + (successorProposal.terms.change.__typename === 'NewMarket' && + successorProposal.terms.change.successorConfiguration + ?.insurancePoolFraction) || '-', status: market.state && MarketStateMapping[market.state], tradingMode: @@ -281,10 +293,9 @@ export const KeyDetailsInfoPanel = ({ name: parentMarket?.tradableInstrument?.instrument?.name, parentMarketID: grandparentMarketIdData?.market?.parentMarketID, insurancePoolFraction: - parentSuccessorProposalDetails?.proposal?.terms.change - .__typename === 'NewMarket' && - parentSuccessorProposalDetails.proposal.terms.change - .successorConfiguration?.insurancePoolFraction, + parentProposal?.terms.change.__typename === 'NewMarket' && + parentProposal?.terms.change.successorConfiguration + ?.insurancePoolFraction, status: parentMarket?.state && MarketStateMapping[parentMarket.state], tradingMode: @@ -796,7 +807,6 @@ export const EthOraclePanel = ({ sourceType }: { sourceType: EthCallSpec }) => {
)} - { -

{t('Normalisers')}

{sourceType.normalisers?.map((normaliser, i) => ( @@ -844,7 +853,7 @@ export const EthOraclePanel = ({ sourceType }: { sourceType: EthCallSpec }) => { <>

{t('Conditions')}

- {filter.conditions?.map((condition, i) => ( + {filter.conditions?.map((condition) => ( {ConditionOperatorMapping[condition.operator]} {condition.value} diff --git a/libs/positions/src/lib/Positions.graphql b/libs/positions/src/lib/Positions.graphql index 22cf50a68..9d360b894 100644 --- a/libs/positions/src/lib/Positions.graphql +++ b/libs/positions/src/lib/Positions.graphql @@ -42,13 +42,23 @@ query EstimatePosition( $marketId: ID! $openVolume: String! $orders: [OrderInfo!] - $collateralAvailable: String + $averageEntryPrice: String! + $marginAccountBalance: String! + $generalAccountBalance: String! + $orderMarginAccountBalance: String! + $marginMode: MarginMode! + $marginFactor: String ) { estimatePosition( marketId: $marketId openVolume: $openVolume orders: $orders - collateralAvailable: $collateralAvailable + averageEntryPrice: $averageEntryPrice + marginAccountBalance: $marginAccountBalance + generalAccountBalance: $generalAccountBalance + orderMarginAccountBalance: $orderMarginAccountBalance + marginMode: $marginMode + marginFactor: $marginFactor # Everywhere in the codebase we expect price values of the underlying to have the right # number of digits for formatting with market.decimalPlaces. By default the estimatePosition # query will return a full value requiring formatting using asset.decimals. For consistency diff --git a/libs/positions/src/lib/__generated__/Positions.ts b/libs/positions/src/lib/__generated__/Positions.ts index e43a9d2e1..cf59d76d6 100644 --- a/libs/positions/src/lib/__generated__/Positions.ts +++ b/libs/positions/src/lib/__generated__/Positions.ts @@ -23,7 +23,12 @@ export type EstimatePositionQueryVariables = Types.Exact<{ marketId: Types.Scalars['ID']; openVolume: Types.Scalars['String']; orders?: Types.InputMaybe | Types.OrderInfo>; - collateralAvailable?: Types.InputMaybe; + averageEntryPrice: Types.Scalars['String']; + marginAccountBalance: Types.Scalars['String']; + generalAccountBalance: Types.Scalars['String']; + orderMarginAccountBalance: Types.Scalars['String']; + marginMode: Types.MarginMode; + marginFactor?: Types.InputMaybe; }>; @@ -124,12 +129,17 @@ export function usePositionsSubscriptionSubscription(baseOptions: Apollo.Subscri export type PositionsSubscriptionSubscriptionHookResult = ReturnType; export type PositionsSubscriptionSubscriptionResult = Apollo.SubscriptionResult; export const EstimatePositionDocument = gql` - query EstimatePosition($marketId: ID!, $openVolume: String!, $orders: [OrderInfo!], $collateralAvailable: String) { + query EstimatePosition($marketId: ID!, $openVolume: String!, $orders: [OrderInfo!], $averageEntryPrice: String!, $marginAccountBalance: String!, $generalAccountBalance: String!, $orderMarginAccountBalance: String!, $marginMode: MarginMode!, $marginFactor: String) { estimatePosition( marketId: $marketId openVolume: $openVolume orders: $orders - collateralAvailable: $collateralAvailable + averageEntryPrice: $averageEntryPrice + marginAccountBalance: $marginAccountBalance + generalAccountBalance: $generalAccountBalance + orderMarginAccountBalance: $orderMarginAccountBalance + marginMode: $marginMode + marginFactor: $marginFactor scaleLiquidationPriceToMarketDecimals: true ) { margin { @@ -177,7 +187,12 @@ export const EstimatePositionDocument = gql` * marketId: // value for 'marketId' * openVolume: // value for 'openVolume' * orders: // value for 'orders' - * collateralAvailable: // value for 'collateralAvailable' + * averageEntryPrice: // value for 'averageEntryPrice' + * marginAccountBalance: // value for 'marginAccountBalance' + * generalAccountBalance: // value for 'generalAccountBalance' + * orderMarginAccountBalance: // value for 'orderMarginAccountBalance' + * marginMode: // value for 'marginMode' + * marginFactor: // value for 'marginFactor' * }, * }); */ diff --git a/libs/positions/src/lib/liquidation-price.spec.tsx b/libs/positions/src/lib/liquidation-price.spec.tsx index 906d23d53..f438e09c7 100644 --- a/libs/positions/src/lib/liquidation-price.spec.tsx +++ b/libs/positions/src/lib/liquidation-price.spec.tsx @@ -6,13 +6,19 @@ import { EstimatePositionDocument } from './__generated__/Positions'; import type { EstimatePositionQuery } from './__generated__/Positions'; import { LiquidationPrice } from './liquidation-price'; import { addDecimalsFormatNumber } from '@vegaprotocol/utils'; +import { MarginMode } from '@vegaprotocol/types'; describe('LiquidationPrice', () => { const props = { marketId: 'market-id', openVolume: '100', - collateralAvailable: '1000', decimalPlaces: 2, + averageEntryPrice: '100', + generalAccountBalance: '100', + marginAccountBalance: '100', + orderMarginAccountBalance: '100', + marginMode: MarginMode.MARGIN_MODE_CROSS_MARGIN, + marginFactor: '1', }; const worstCaseOpenVolume = '200'; const bestCaseOpenVolume = '100'; @@ -22,7 +28,12 @@ describe('LiquidationPrice', () => { variables: { marketId: props.marketId, openVolume: props.openVolume, - collateralAvailable: props.collateralAvailable, + averageEntryPrice: props.averageEntryPrice, + generalAccountBalance: props.generalAccountBalance, + marginAccountBalance: props.marginAccountBalance, + orderMarginAccountBalance: props.orderMarginAccountBalance, + marginMode: props.marginMode, + marginFactor: props.marginFactor, }, }, result: { diff --git a/libs/positions/src/lib/liquidation-price.tsx b/libs/positions/src/lib/liquidation-price.tsx index 30b4bc4c7..472768258 100644 --- a/libs/positions/src/lib/liquidation-price.tsx +++ b/libs/positions/src/lib/liquidation-price.tsx @@ -2,26 +2,43 @@ import { Tooltip } from '@vegaprotocol/ui-toolkit'; import { useEstimatePositionQuery } from './__generated__/Positions'; import { addDecimalsFormatNumber } from '@vegaprotocol/utils'; import { useT } from '../use-t'; +import { MarginMode } from '@vegaprotocol/types'; export const LiquidationPrice = ({ marketId, openVolume, - collateralAvailable, + averageEntryPrice, + generalAccountBalance, + marginAccountBalance, + orderMarginAccountBalance, + marginMode = MarginMode.MARGIN_MODE_CROSS_MARGIN, + marginFactor, decimalPlaces, className, }: { marketId: string; openVolume: string; - collateralAvailable: string; + averageEntryPrice: string; + generalAccountBalance: string; + marginAccountBalance: string; + orderMarginAccountBalance: string; + marginMode: MarginMode; + marginFactor: string; decimalPlaces: number; className?: string; }) => { const t = useT(); + const { data: currentData, previousData } = useEstimatePositionQuery({ variables: { marketId, openVolume, - collateralAvailable, + averageEntryPrice, + generalAccountBalance, + marginAccountBalance, + orderMarginAccountBalance, + marginMode, + marginFactor, }, fetchPolicy: 'no-cache', skip: !openVolume || openVolume === '0', diff --git a/libs/positions/src/lib/positions-data-providers.ts b/libs/positions/src/lib/positions-data-providers.ts index ff602a562..9ffacc70d 100644 --- a/libs/positions/src/lib/positions-data-providers.ts +++ b/libs/positions/src/lib/positions-data-providers.ts @@ -42,6 +42,7 @@ import { export interface Position { marginMode: MarginFieldsFragment['marginMode']; + marginFactor: MarginFieldsFragment['marginFactor']; maintenanceLevel: MarginFieldsFragment['maintenanceLevel'] | undefined; assetId: string; assetSymbol: string; @@ -152,6 +153,7 @@ export const getMetrics = ( : undefined; metrics.push({ marginMode, + marginFactor: marginFactor || '0', maintenanceLevel: margin?.maintenanceLevel, assetId: asset.id, assetSymbol: asset.symbol, diff --git a/libs/positions/src/lib/positions-table.tsx b/libs/positions/src/lib/positions-table.tsx index 14e2f0516..7388cfb8e 100644 --- a/libs/positions/src/lib/positions-table.tsx +++ b/libs/positions/src/lib/positions-table.tsx @@ -410,7 +410,12 @@ export const PositionsTable = ({ className="block text-right grow" marketId={data.marketId} openVolume={data.openVolume} - collateralAvailable={data.totalBalance} + generalAccountBalance={data.generalAccountBalance} + marginAccountBalance={data.marginAccountBalance} + orderMarginAccountBalance={data.orderAccountBalance} + averageEntryPrice={data.averageEntryPrice} + marginFactor={data.marginFactor} + marginMode={data.marginMode} decimalPlaces={data.marketDecimalPlaces} /> diff --git a/libs/positions/src/lib/positions.mock.ts b/libs/positions/src/lib/positions.mock.ts index 3eb30a86e..971a258a6 100644 --- a/libs/positions/src/lib/positions.mock.ts +++ b/libs/positions/src/lib/positions.mock.ts @@ -184,6 +184,7 @@ export const singleRow: Position = { generalAccountBalance: '12345600', maintenanceLevel: '12300000', marginMode: Schema.MarginMode.MARGIN_MODE_CROSS_MARGIN, + marginFactor: '1', orderAccountBalance: '0', partyId: 'partyId', assetId: 'asset-id', diff --git a/libs/proposals/src/index.ts b/libs/proposals/src/index.ts index 9c6f479d4..d202a8d7d 100644 --- a/libs/proposals/src/index.ts +++ b/libs/proposals/src/index.ts @@ -1,3 +1,4 @@ export * from './lib'; export * from './utils'; export * from './components'; +export * from './types'; diff --git a/libs/proposals/src/lib/proposals-hooks/Proposal.graphql b/libs/proposals/src/lib/proposals-hooks/Proposal.graphql index 54441be42..009fa78dd 100644 --- a/libs/proposals/src/lib/proposals-hooks/Proposal.graphql +++ b/libs/proposals/src/lib/proposals-hooks/Proposal.graphql @@ -39,22 +39,26 @@ subscription OnProposal { query ProposalOfMarket($marketId: ID!) { proposal(id: $marketId) { - id - terms { - enactmentDatetime + ... on Proposal { + id + terms { + enactmentDatetime + } } } } query SuccessorMarketProposalDetails($proposalId: ID!) { proposal(id: $proposalId) { - id - terms { - change { - ... on NewMarket { - successorConfiguration { - parentMarketId - insurancePoolFraction + ... on Proposal { + id + terms { + change { + ... on NewMarket { + successorConfiguration { + parentMarketId + insurancePoolFraction + } } } } @@ -75,11 +79,13 @@ query InstrumentDetails($marketId: ID!) { query NewTransferDetails($proposalId: ID!) { proposal(id: $proposalId) { - id - terms { - change { - ... on NewTransfer { - ...NewTransferFields + ... on Proposal { + id + terms { + change { + ... on NewTransfer { + ...NewTransferFields + } } } } @@ -88,11 +94,13 @@ query NewTransferDetails($proposalId: ID!) { query CancelTransferDetails($proposalId: ID!) { proposal(id: $proposalId) { - id - terms { - change { - ... on CancelTransfer { - ...CancelTransferFields + ... on Proposal { + id + terms { + change { + ... on CancelTransfer { + ...CancelTransferFields + } } } } diff --git a/libs/proposals/src/lib/proposals-hooks/__generated__/Proposal.ts b/libs/proposals/src/lib/proposals-hooks/__generated__/Proposal.ts index 38a12574b..d4e1a5cd4 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?: 'Proposal', id?: string | null, terms: { __typename?: 'ProposalTerms', enactmentDatetime?: any | null } } | null }; +export type ProposalOfMarketQuery = { __typename?: 'Query', proposal?: { __typename?: 'BatchProposal' } | { __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?: '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' } | { __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']; @@ -46,14 +46,14 @@ export type NewTransferDetailsQueryVariables = Types.Exact<{ }>; -export type NewTransferDetailsQuery = { __typename?: 'Query', proposal?: { __typename?: 'Proposal', id?: string | null, terms: { __typename?: 'ProposalTerms', change: { __typename?: 'CancelTransfer' } | { __typename?: 'NewAsset' } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket' } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer', source: string, sourceType: Types.AccountType, destination: string, destinationType: Types.AccountType, fraction_of_balance: string, amount: string, transferType: Types.GovernanceTransferType, asset: { __typename?: 'Asset', id: string, symbol: string, decimals: number, quantum: string }, kind: { __typename: 'OneOffGovernanceTransfer', deliverOn?: any | null } | { __typename: 'RecurringGovernanceTransfer', startEpoch: number, endEpoch?: number | null } } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket' } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter' } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } } } | null }; +export type NewTransferDetailsQuery = { __typename?: 'Query', proposal?: { __typename?: 'BatchProposal' } | { __typename?: 'Proposal', id?: string | null, terms: { __typename?: 'ProposalTerms', change: { __typename?: 'CancelTransfer' } | { __typename?: 'NewAsset' } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket' } | { __typename?: 'NewSpotMarket' } | { __typename?: 'NewTransfer', source: string, sourceType: Types.AccountType, destination: string, destinationType: Types.AccountType, fraction_of_balance: string, amount: string, transferType: Types.GovernanceTransferType, asset: { __typename?: 'Asset', id: string, symbol: string, decimals: number, quantum: string }, kind: { __typename: 'OneOffGovernanceTransfer', deliverOn?: any | null } | { __typename: 'RecurringGovernanceTransfer', startEpoch: number, endEpoch?: number | null } } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket' } | { __typename?: 'UpdateMarketState' } | { __typename?: 'UpdateNetworkParameter' } | { __typename?: 'UpdateReferralProgram' } | { __typename?: 'UpdateSpotMarket' } | { __typename?: 'UpdateVolumeDiscountProgram' } } } | null }; export type CancelTransferDetailsQueryVariables = Types.Exact<{ proposalId: Types.Scalars['ID']; }>; -export type CancelTransferDetailsQuery = { __typename?: 'Query', proposal?: { __typename?: 'Proposal', id?: string | null, terms: { __typename?: 'ProposalTerms', change: { __typename?: 'CancelTransfer', transferId: string } | { __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 }; +export type CancelTransferDetailsQuery = { __typename?: 'Query', proposal?: { __typename?: 'BatchProposal' } | { __typename?: 'Proposal', id?: string | null, terms: { __typename?: 'ProposalTerms', change: { __typename?: 'CancelTransfer', transferId: string } | { __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 }; export const ProposalEventFieldsFragmentDoc = gql` fragment ProposalEventFields on Proposal { @@ -146,9 +146,11 @@ export type OnProposalSubscriptionResult = Apollo.SubscriptionResult; + + if (proposal?.terms.change.__typename === 'CancelTransfer') { + return proposal?.terms.change as CancelTransferFieldsFragment; } return undefined; diff --git a/libs/proposals/src/lib/proposals-hooks/use-new-transfer-proposal-details.ts b/libs/proposals/src/lib/proposals-hooks/use-new-transfer-proposal-details.ts index 70f1204bb..1c877dbbd 100644 --- a/libs/proposals/src/lib/proposals-hooks/use-new-transfer-proposal-details.ts +++ b/libs/proposals/src/lib/proposals-hooks/use-new-transfer-proposal-details.ts @@ -1,5 +1,9 @@ -import type { NewTransferFieldsFragment } from '../proposals-data-provider'; -import { useNewTransferDetailsQuery } from './__generated__/Proposal'; +import { type SingleProposal } from '../../types'; +import { type NewTransferFieldsFragment } from '../proposals-data-provider'; +import { + useNewTransferDetailsQuery, + type NewTransferDetailsQuery, +} from './__generated__/Proposal'; export const useNewTransferProposalDetails = (proposalId?: string | null) => { const { data } = useNewTransferDetailsQuery({ @@ -9,8 +13,12 @@ export const useNewTransferProposalDetails = (proposalId?: string | null) => { skip: !proposalId || proposalId.length === 0, }); - if (data?.proposal?.terms.change.__typename === 'NewTransfer') { - return data?.proposal?.terms.change as NewTransferFieldsFragment; + const proposal = data?.proposal as SingleProposal< + NewTransferDetailsQuery['proposal'] + >; + + if (proposal?.terms.change.__typename === 'NewTransfer') { + return proposal?.terms.change as NewTransferFieldsFragment; } return undefined; diff --git a/libs/proposals/src/lib/proposals-hooks/use-successor-market-proposal-details.ts b/libs/proposals/src/lib/proposals-hooks/use-successor-market-proposal-details.ts index cea43aaf0..2a0464168 100644 --- a/libs/proposals/src/lib/proposals-hooks/use-successor-market-proposal-details.ts +++ b/libs/proposals/src/lib/proposals-hooks/use-successor-market-proposal-details.ts @@ -2,22 +2,28 @@ import omit from 'lodash/omit'; import { useInstrumentDetailsQuery, useSuccessorMarketProposalDetailsQuery, + type SuccessorMarketProposalDetailsQuery, } from './__generated__/Proposal'; +import { type SingleProposal } from '../../types'; export const useSuccessorMarketProposalDetails = ( proposalId?: string | null ) => { - const { data: proposal } = useSuccessorMarketProposalDetailsQuery({ + const { data } = useSuccessorMarketProposalDetailsQuery({ variables: { proposalId: proposalId || '', }, skip: !proposalId || proposalId.length === 0, }); + const proposal = data?.proposal as SingleProposal< + SuccessorMarketProposalDetailsQuery['proposal'] + >; + const successorDetails = - (proposal?.proposal && - proposal.proposal?.terms.change.__typename === 'NewMarket' && - proposal.proposal.terms.change.successorConfiguration) || + (proposal && + proposal?.terms.change.__typename === 'NewMarket' && + proposal.terms.change.successorConfiguration) || undefined; const { data: market } = useInstrumentDetailsQuery({ diff --git a/libs/proposals/src/types.ts b/libs/proposals/src/types.ts new file mode 100644 index 000000000..1572c1a6c --- /dev/null +++ b/libs/proposals/src/types.ts @@ -0,0 +1,6 @@ +type Batch = { __typename?: 'BatchProposal' | undefined } | null | undefined; +type Single = { __typename?: 'Proposal' | undefined } | null | undefined; +export type SingleProposal = Extract< + T, + { __typename?: 'Proposal' } +>; diff --git a/libs/types/src/__generated__/types.ts b/libs/types/src/__generated__/types.ts index 5dc4ca91f..af219c512 100644 --- a/libs/types/src/__generated__/types.ts +++ b/libs/types/src/__generated__/types.ts @@ -357,6 +357,62 @@ export enum AuctionTrigger { AUCTION_TRIGGER_UNSPECIFIED = 'AUCTION_TRIGGER_UNSPECIFIED' } +export type BatchProposal = { + __typename?: 'BatchProposal'; + /** RFC3339Nano time and date when the proposal reached the network */ + datetime: Scalars['Timestamp']; + /** Details of the rejection reason */ + errorDetails?: Maybe; + /** Proposal ID that is provided by Vega once proposal reaches the network */ + id?: Maybe; + /** Party that prepared the proposal */ + party: Party; + /** Rationale behind the proposal */ + rationale: ProposalRationale; + /** A UUID reference to aid tracking proposals on Vega */ + reference: Scalars['String']; + /** Reason the proposal was rejected */ + rejectionReason?: Maybe; + /** Equity-like share required for a market amendment proposal to be enacted, represented as a fraction that can be converted to a percentage. If not met, the proposal will not be enacted */ + requiredLpMajority?: Maybe; + /** The market share of LPs' equity-like share that must take part in a market amendment vote for the proposal to pass. This means the votes of LPs that have submitted more liquidity to that market, or have been LPs from the start carry more weight. If it requires 50% of a market's equity-like share for a majority, and the full batch of proposals receives all YES votes but only LPs with 49% of the equity-like share voted, the proposal will not pass */ + requiredLpParticipation?: Maybe; + /** Required majority for this proposal to succeed */ + requiredMajority: Scalars['String']; + /** Required participation for this proposal to succeed */ + requiredParticipation: Scalars['String']; + /** State of the proposal */ + state: ProposalState; + /** Proposals that are part of the batch */ + subProposals?: Maybe>>; + /** Votes cast for this proposal */ + votes: ProposalVotes; +}; + +/** The rationale for the proposal */ +export type BatchProposalTerms = { + __typename?: 'BatchProposalTerms'; + /** Actual changes being introduced by the proposal - actions the proposal triggers if passed and enacted. */ + changes: Array>; + /** + * RFC3339Nano time and date when voting closes for this proposal. + * Constrained by "minClose" and "maxClose" network parameters. + */ + closingDatetime: Scalars['Timestamp']; +}; + +/** Terms for a batch governance proposal */ +export type BatchProposalTermsChange = { + __typename?: 'BatchProposalTermsChange'; + /** Actual change being introduced by the proposal - action the proposal triggers if passed and enacted. */ + change: ProposalChange; + /** + * RFC3339Nano time and date when this proposal will be executed, if it passes. + * Constrained by "minEnactInSeconds" and "maxEnactInSeconds" network parameters. + */ + enactmentDatetime?: Maybe; +}; + export type BenefitTier = { __typename?: 'BenefitTier'; /** The minimum number of epochs the party needs to be in the referral set to be eligible for the benefit */ @@ -446,6 +502,44 @@ export type CandleEdge = { node: Candle; }; +/** Collateral increase estimate for the additional funds needed to support the specified position */ +export type CollateralIncreaseEstimate = { + __typename?: 'CollateralIncreaseEstimate'; + /** Estimate assuming no slippage */ + bestCase: Scalars['String']; + /** Estimate assuming slippage cap is applied */ + worstCase: Scalars['String']; +}; + +export type CompositePriceConfiguration = { + __typename?: 'CompositePriceConfiguration'; + /** Composite price calculation methodology */ + CompositePriceType: CompositePriceType; + /** Staleness tolerance duration for each given price sources in the order mentioned above */ + SourceStalenessTolerance: Array; + /** Weights for each given price source, first entry is price from trade, then price from book, then first oracle, next oracle, etc. And last entry is for median price */ + SourceWeights?: Maybe>; + /** Cash amount used in calculating mark price from the order book */ + cashAmount: Scalars['String']; + /** Oracle configuration for external composite price sources */ + dataSourcesSpec?: Maybe>>; + /** Spec bindings for external composite price sources */ + dataSourcesSpecBinding?: Maybe>>; + /** Decay power used in calculating time weight for a given trade */ + decayPower: Scalars['Int']; + /** Decay weight used in calculating time weight for a given trade */ + decayWeight: Scalars['String']; +}; + +export enum CompositePriceType { + /** Composite price is set to the last trade (legacy) */ + COMPOSITE_PRICE_TYPE_LAST_TRADE = 'COMPOSITE_PRICE_TYPE_LAST_TRADE', + /** Composite price is calculated as a median of the underlying price sources */ + COMPOSITE_PRICE_TYPE_MEDIAN = 'COMPOSITE_PRICE_TYPE_MEDIAN', + /** Composite price is calculated as a weighted average of the underlying price sources */ + COMPOSITE_PRICE_TYPE_WEIGHTED = 'COMPOSITE_PRICE_TYPE_WEIGHTED' +} + /** Condition describes the condition that must be validated by the data source engine */ export type Condition = { __typename?: 'Condition'; @@ -1137,6 +1231,15 @@ export type Erc20WithdrawalDetails = { receiverAddress: Scalars['String']; }; +/** EstimatedTransferFee Results of estimation of transfer fee and the fee discount */ +export type EstimatedTransferFee = { + __typename?: 'EstimatedTransferFee'; + /** Discount applied to the fee. */ + discount: Scalars['String']; + /** Estimated fee for the transfer. */ + fee: Scalars['String']; +}; + /** * Specifies a data source that derives its content from calling a read method * on an Ethereum contract. @@ -1164,6 +1267,8 @@ export type EthCallSpec = { normalisers?: Maybe>; /** Number of confirmations required before the query is considered verified. */ requiredConfirmations: Scalars['Int']; + /** The ID of the EVM based chain which is to be used to source the oracle data. */ + sourceChainId: Scalars['Int']; /** Conditions for determining when to call the contract method. */ trigger: EthCallTrigger; }; @@ -1276,6 +1381,8 @@ export type Fees = { __typename?: 'Fees'; /** The factors used to calculate the different fees */ factors: FeeFactors; + /** Liquidity fee settings for the market describing how the fee was calculated */ + liquidityFeeSettings?: Maybe; }; /** Fees that have been applied on a specific market/asset up to the given epoch. */ @@ -1478,6 +1585,39 @@ export type FutureProduct = { settlementAsset: Asset; }; +/** Game metrics for a given epoch */ +export type Game = { + __typename?: 'Game'; + /** Entities that were rewarded during the epoch. */ + entities: Array; + /** Epoch during which the metrics were calculated. */ + epoch: Scalars['Int']; + /** ID of the game. */ + id: Scalars['ID']; + /** Number of participants that took part in the game during the epoch. */ + numberOfParticipants: Scalars['Int']; +}; + +/** Edge type containing the game metrics and cursor information returned by a GameConnection */ +export type GameEdge = { + __typename?: 'GameEdge'; + /** Cursor identifying the game */ + cursor: Scalars['String']; + /** Game information and metrics. */ + node: Game; +}; + +export type GameEntity = IndividualGameEntity | TeamGameEntity; + +/** Connection type for retrieving cursor-based paginated game information */ +export type GamesConnection = { + __typename?: 'GamesConnection'; + /** Page of game edges for the connection */ + edges?: Maybe>>; + /** Current page information */ + pageInfo?: Maybe; +}; + export type GovernanceTransferKind = OneOffGovernanceTransfer | RecurringGovernanceTransfer; export enum GovernanceTransferType { @@ -1511,6 +1651,23 @@ export type IcebergOrder = { reservedRemaining: Scalars['String']; }; +/** Individual party participating in a game and their metrics */ +export type IndividualGameEntity = { + __typename?: 'IndividualGameEntity'; + /** Party ID of the participant */ + individual: Scalars['ID']; + /** The rank of the individual within the game. If the individual is in a team, then the rank of the individual in the team */ + rank: Scalars['Int']; + /** The rewards earned by the individual during the epoch */ + rewardEarned: Scalars['String']; + /** The reward metric applied to the game */ + rewardMetric: DispatchMetric; + /** Total rewards earned by the individual during the game */ + totalRewardsEarned: Scalars['String']; + /** The volume traded by the individual */ + volume: Scalars['String']; +}; + export enum IndividualScope { /** All parties on the network are within the scope of this reward */ INDIVIDUAL_SCOPE_ALL = 'INDIVIDUAL_SCOPE_ALL', @@ -1578,12 +1735,22 @@ export enum Interval { INTERVAL_I1H = 'INTERVAL_I1H', /** 1 minute interval */ INTERVAL_I1M = 'INTERVAL_I1M', + /** 4 hour interval */ + INTERVAL_I4H = 'INTERVAL_I4H', /** 5 minute interval */ INTERVAL_I5M = 'INTERVAL_I5M', /** 6 hour interval */ INTERVAL_I6H = 'INTERVAL_I6H', + /** 7 day interval */ + INTERVAL_I7D = 'INTERVAL_I7D', + /** 8 hour interval */ + INTERVAL_I8H = 'INTERVAL_I8H', + /** 12 hour interval */ + INTERVAL_I12H = 'INTERVAL_I12H', /** 15 minute interval (default) */ - INTERVAL_I15M = 'INTERVAL_I15M' + INTERVAL_I15M = 'INTERVAL_I15M', + /** 30 minute interval */ + INTERVAL_I30M = 'INTERVAL_I30M' } /** A node's key rotation event */ @@ -1652,6 +1819,8 @@ export type LedgerEntryFilter = { FromAccountFilter?: InputMaybe; /** Used to set values for filtering receiver accounts. Party must be provided in this filter or from_account_filter, or both. */ ToAccountFilter?: InputMaybe; + /** Optional transfer ID to filter by. If provided, all other filters are ignored. */ + TransferId?: InputMaybe; /** List of transfer types that is used for filtering sender and receiver accounts. */ TransferTypes?: InputMaybe>>; }; @@ -1676,6 +1845,37 @@ export type LiquidationPrice = { open_volume_only: Scalars['String']; }; +export type LiquidationStrategy = { + __typename?: 'LiquidationStrategy'; + /** Specifies the fraction of its position the network will try to reduce its position by in a single disposal attempt. */ + disposalFraction: Scalars['String']; + /** Specifies the interval, in seconds, at which point the network will try to unload its position. */ + disposalTimeStep: Scalars['Int']; + /** Specifies the size of the position held by the network that it will try to dispose of in one attempt. */ + fullDisposalSize: Scalars['Int']; + /** Specifies the maximum size by which the network can reduce its position as a fraction of the volume on the book. */ + maxFractionConsumed: Scalars['String']; +}; + +export enum LiquidityFeeMethod { + /** Fee is set by the market to a constant value irrespective of any liquidity provider's nominated fee */ + METHOD_CONSTANT = 'METHOD_CONSTANT', + /** Fee is smallest value of all bids, such that liquidity providers with nominated fees less than or equal to this value still have sufficient commitment to fulfil the market's target stake. */ + METHOD_MARGINAL_COST = 'METHOD_MARGINAL_COST', + METHOD_UNSPECIFIED = 'METHOD_UNSPECIFIED', + /** Fee is the weighted average of all liquidity providers' nominated fees, weighted by their commitment */ + METHOD_WEIGHTED_AVERAGE = 'METHOD_WEIGHTED_AVERAGE' +} + +/** Market settings that describe how the liquidity fee is calculated */ +export type LiquidityFeeSettings = { + __typename?: 'LiquidityFeeSettings'; + /** Constant liquidity fee used when using the constant fee method */ + feeConstant?: Maybe; + /** Method used to calculate the market's liquidity fee */ + method: LiquidityFeeMethod; +}; + /** Configuration of a market liquidity monitoring parameters */ export type LiquidityMonitoringParameters = { __typename?: 'LiquidityMonitoringParameters'; @@ -2038,7 +2238,9 @@ export enum MarginMode { /** Party is in cross margin mode */ MARGIN_MODE_CROSS_MARGIN = 'MARGIN_MODE_CROSS_MARGIN', /** Party is in isolated margin mode */ - MARGIN_MODE_ISOLATED_MARGIN = 'MARGIN_MODE_ISOLATED_MARGIN' + MARGIN_MODE_ISOLATED_MARGIN = 'MARGIN_MODE_ISOLATED_MARGIN', + /** Margin mode is not specified. */ + MARGIN_MODE_UNSPECIFIED = 'MARGIN_MODE_UNSPECIFIED' } /** Represents a product & associated parameters that can be traded on Vega, has an associated OrderBook and Trade history */ @@ -2077,6 +2279,8 @@ export type Market = { insurancePoolFraction?: Maybe; /** Linear slippage factor is used to cap the slippage component of maintainence margin - it is applied to the slippage volume */ linearSlippageFactor: Scalars['String']; + /** Optional: Liquidation strategy for the market */ + liquidationStrategy?: Maybe; /** Liquidity monitoring parameters for the market */ liquidityMonitoringParameters: LiquidityMonitoringParameters; /** The list of the liquidity provision commitments for this market */ @@ -2088,6 +2292,10 @@ export type Market = { liquidityProvisionsConnection?: Maybe; /** Optional: Liquidity SLA parameters for the market */ liquiditySLAParameters?: Maybe; + /** Configuration driving the mark price for the market */ + markPriceConfiguration: CompositePriceConfiguration; + /** The proposal that initiated this market */ + marketProposal?: Maybe; /** Timestamps for state changes in the market */ marketTimestamps: MarketTimestamps; /** @@ -2111,9 +2319,15 @@ export type Market = { positionDecimalPlaces: Scalars['Int']; /** Price monitoring settings for the market */ priceMonitoringSettings: PriceMonitoringSettings; - /** The proposal that initiated this market */ + /** + * The proposal that initiated this market + * @deprecated Use marketProposal + */ proposal?: Maybe; - /** Quadratic slippage factor is used to cap the slippage component of maintainence margin - it is applied to the square of the slippage volume */ + /** + * Quadratic slippage factor is used to cap the slippage component of maintainence margin - it is applied to the square of the slippage volume + * @deprecated This field will be removed in a future release + */ quadraticSlippageFactor: Scalars['String']; /** Risk factors for the market */ riskFactors?: Maybe; @@ -2229,6 +2443,8 @@ export type MarketData = { liquidityProviderSla?: Maybe>; /** The mark price (an unsigned integer) */ markPrice: Scalars['String']; + /** The methodology used for the calculation of the mark price */ + markPriceType: CompositePriceType; /** Market of the associated mark price */ market: Market; /** The market growth factor for the last market time window */ @@ -2243,6 +2459,8 @@ export type MarketData = { midPrice: Scalars['String']; /** RFC3339Nano time indicating the next time positions will be marked to market */ nextMarkToMarket: Scalars['String']; + /** RFC3339Nano time indicating the next time the network will attempt to close part of its position */ + nextNetworkCloseout: Scalars['String']; /** The sum of the size of all positions greater than 0. */ openInterest: Scalars['String']; /** A list of valid price ranges per associated trigger */ @@ -2427,6 +2645,15 @@ export enum MarketUpdateType { MARKET_STATE_UPDATE_TYPE_UNSPECIFIED = 'MARKET_STATE_UPDATE_TYPE_UNSPECIFIED' } +/** Generic structure holding a key/value pair. */ +export type Metadata = { + __typename?: 'Metadata'; + /** Key of the metadata. */ + key: Scalars['String']; + /** Value of the metadata. */ + value: Scalars['String']; +}; + /** Information about whether proposals are enabled, if the markets are still bootstrapping, etc.. */ export type NetworkLimits = { __typename?: 'NetworkLimits'; @@ -2506,17 +2733,26 @@ export type NewMarket = { instrument: InstrumentConfiguration; /** Linear slippage factor is used to cap the slippage component of maintenance margin - it is applied to the slippage volume */ linearSlippageFactor: Scalars['String']; + /** Liquidation strategy for the market */ + liquidationStrategy?: Maybe; + /** Specifies how the liquidity fee for the market will be calculated */ + liquidityFeeSettings?: Maybe; /** Liquidity monitoring parameters */ liquidityMonitoringParameters: LiquidityMonitoringParameters; /** Liquidity SLA Parameters */ liquiditySLAParameters?: Maybe; + /** Configuration for mark price calculation for the market */ + markPriceConfiguration: CompositePriceConfiguration; /** Metadata for this instrument, tags */ metadata?: Maybe>; /** Decimal places for order sizes, sets what size the smallest order / position on the market can be */ positionDecimalPlaces: Scalars['Int']; /** Price monitoring parameters */ priceMonitoringParameters: PriceMonitoringParameters; - /** Quadratic slippage factor is used to cap the slippage component of maintenance margin - it is applied to the square of the slippage volume */ + /** + * Quadratic slippage factor is used to cap the slippage component of maintenance margin - it is applied to the square of the slippage volume + * @deprecated This field will be removed in a future release + */ quadraticSlippageFactor: Scalars['String']; /** New market risk configuration */ riskParameters: RiskModel; @@ -2531,6 +2767,8 @@ export type NewSpotMarket = { decimal_places: Scalars['Int']; /** New spot market instrument configuration */ instrument: InstrumentConfiguration; + /** Specifies how the liquidity fee for the market will be calculated */ + liquidityFeeSettings?: Maybe; /** Specifies the liquidity provision SLA parameters */ liquiditySLAParams: LiquiditySLAParameters; /** Optional spot market metadata tags */ @@ -2819,6 +3057,8 @@ export type ObservableMarketData = { liquidityProviderSla?: Maybe>; /** The mark price (an unsigned integer) */ markPrice: Scalars['String']; + /** The methodology used to calculated mark price */ + markPriceType: CompositePriceType; /** The market growth factor for the last market time window */ marketGrowth: Scalars['String']; /** Market ID of the associated mark price */ @@ -3370,6 +3610,15 @@ export type PaidLiquidityFeesEdge = { node: PaidLiquidityFees; }; +/** Connection type for retrieving cursor-based paginated profile information for multiple parties */ +export type PartiesProfilesConnection = { + __typename?: 'PartiesProfilesConnection'; + /** The profiles in this connection */ + edges: Array; + /** The pagination information */ + pageInfo: PageInfo; +}; + /** Represents a party on Vega, could be an ethereum wallet address in the future */ export type Party = { __typename?: 'Party'; @@ -3507,7 +3756,9 @@ export type PartyrewardSummariesArgs = { export type PartyrewardsConnectionArgs = { assetId?: InputMaybe; fromEpoch?: InputMaybe; + gameId?: InputMaybe; pagination?: InputMaybe; + teamId?: InputMaybe; toEpoch?: InputMaybe; }; @@ -3529,8 +3780,12 @@ export type PartytradesConnectionArgs = { /** Represents a party on Vega, could be an ethereum wallet address in the future */ export type PartytransfersConnectionArgs = { direction?: InputMaybe; + fromEpoch?: InputMaybe; isReward?: InputMaybe; pagination?: InputMaybe; + scope?: InputMaybe; + status?: InputMaybe; + toEpoch?: InputMaybe; }; @@ -3616,16 +3871,16 @@ export type PartyMarginMode = { __typename?: 'PartyMarginMode'; /** Epoch at which the update happened. */ atEpoch: Scalars['Int']; + /** Margin factor for the market. Isolated mode only. */ + marginFactor?: Maybe; /** Selected margin mode. */ marginMode: MarginMode; - /** Margin factor for the market. Isolated mode only. */ - margin_factor?: Maybe; /** Unique ID of the market. */ marketId: Scalars['ID']; /** Maximum theoretical leverage for the market. Isolated mode only. */ - max_theoretical_leverage?: Maybe; + maxTheoreticalLeverage?: Maybe; /** Minimum theoretical margin factor for the market. Isolated mode only. */ - min_theoretical_margin_factor?: Maybe; + minTheoreticalMarginFactor?: Maybe; /** Unique ID of the party. */ partyId: Scalars['ID']; }; @@ -3646,6 +3901,25 @@ export type PartyMarginModesConnection = { pageInfo?: Maybe; }; +/** Holds metadata associated to a party. */ +export type PartyProfile = { + __typename?: 'PartyProfile'; + /** Alias given to the party. */ + alias: Scalars['String']; + /** Metadata to associate to a party, in a key/value format where the key describes the type of metadata in the value field. */ + metadata: Array; + partyId: Scalars['ID']; +}; + +/** Edge type containing the party and cursor information returned by a PartiesProfilesConnection */ +export type PartyProfileEdge = { + __typename?: 'PartyProfileEdge'; + /** The cursor for this party's profile */ + cursor: Scalars['String']; + /** The party's profile */ + node: PartyProfile; +}; + /** * All staking information related to a Party. * Contains the current recognised balance by the network and @@ -3722,6 +3996,14 @@ export type Perpetual = { dataSourceSpecForSettlementData: DataSourceSpec; /** Data source specification describing the data source for settlement schedule */ dataSourceSpecForSettlementSchedule: DataSourceSpec; + /** Lower bound for the funding-rate such that the funding-rate will never be lower than this value */ + fundingRateLowerBound: Scalars['String']; + /** Factor applied to funding-rates. This scales the impact that spot price deviations have on funding payments */ + fundingRateScalingFactor: Scalars['String']; + /** Upper bound for the funding-rate such that the funding-rate will never be higher than this value */ + fundingRateUpperBound: Scalars['String']; + /** Optional configuration driving the index price calculation for perpetual product */ + indexPriceConfig?: Maybe; /** Continuously compounded interest rate used in funding rate calculation, in the range [-1, 1] */ interestRate: Scalars['String']; /** Controls how much the upcoming funding payment liability contributes to party's margin, in the range [0, 1] */ @@ -3741,8 +4023,18 @@ export type PerpetualData = { fundingPayment?: Maybe; /** Percentage difference between the time-weighted average price of the external and internal data point. */ fundingRate?: Maybe; + /** The index price used for external VWAP calculation */ + indexPrice: Scalars['String']; + /** The methodology used to calculated index price for perps */ + indexPriceType: CompositePriceType; /** Time-weighted average price calculated from data points for this period from the internal data source. */ internalTwap?: Maybe; + /** RFC3339Nano time indicating the next time index price will be calculated for perps where applicable */ + nextIndexPriceCalc: Scalars['String']; + /** Funding period sequence number */ + seqNum: Scalars['Int']; + /** Time at which the funding period started */ + startTime: Scalars['Timestamp']; }; export type PerpetualProduct = { @@ -3757,6 +4049,12 @@ export type PerpetualProduct = { dataSourceSpecForSettlementData: DataSourceDefinition; /** Data source specification describing the data source for settlement schedule */ dataSourceSpecForSettlementSchedule: DataSourceDefinition; + /** Lower bound for the funding-rate such that the funding-rate will never be lower than this value */ + fundingRateLowerBound: Scalars['String']; + /** Factor applied to funding-rates. This scales the impact that spot price deviations have on funding payments. */ + fundingRateScalingFactor: Scalars['String']; + /** Upper bound for the funding-rate such that the funding-rate will never be higher than this value */ + fundingRateUpperBound: Scalars['String']; /** Continuously compounded interest rate used in funding rate calculation, in the range [-1, 1] */ interestRate: Scalars['String']; /** Controls how much the upcoming funding payment liability contributes to party's margin, in the range [0, 1] */ @@ -3829,6 +4127,8 @@ export type PositionEdge = { /** Response for the estimate of the margin level and, if available, collateral was provided in the request, liquidation price for the specified position */ export type PositionEstimate = { __typename?: 'PositionEstimate'; + /** Estimated margin account balance increase */ + collateralIncreaseEstimate: CollateralIncreaseEstimate; /** Liquidation price range estimate for the specified position. Only populated if available collateral was specified in the request */ liquidation?: Maybe; /** Margin level range estimate for the specified position */ @@ -4030,6 +4330,10 @@ export type ProposalChange = CancelTransfer | NewAsset | NewFreeform | NewMarket export type ProposalDetail = { __typename?: 'ProposalDetail'; + /** Batch proposal ID that is provided by Vega once proposal reaches the network */ + batchId?: Maybe; + /** Terms of the proposal for a batch proposal */ + batchTerms?: Maybe; /** RFC3339Nano time and date when the proposal reached the Vega network */ datetime: Scalars['Timestamp']; /** Error details of the rejectionReason */ @@ -4054,8 +4358,8 @@ export type ProposalDetail = { requiredParticipation: Scalars['String']; /** State of the proposal */ state: ProposalState; - /** Terms of the proposal */ - terms: ProposalTerms; + /** Terms of the proposal for proposal */ + terms?: Maybe; }; /** Edge type containing the proposals and cursor information returned by a ProposalsConnection */ @@ -4063,10 +4367,17 @@ export type ProposalEdge = { __typename?: 'ProposalEdge'; /** Cursor identifying the proposal */ cursor: Scalars['String']; - /** The proposal data */ + /** + * The proposal data + * @deprecated Use proposalNode + */ node: Proposal; + /** The data of either single or batch proposal */ + proposalNode?: Maybe; }; +export type ProposalNode = BatchProposal | Proposal; + export type ProposalRationale = { __typename?: 'ProposalRationale'; /** @@ -4370,6 +4681,14 @@ export type PubKey = { key?: Maybe; }; +export type QuantumRewardsPerEpoch = { + __typename?: 'QuantumRewardsPerEpoch'; + /** Epoch for which this information is valid. */ + epoch: Scalars['Int']; + /** Total of rewards accumulated over the epoch period expressed in quantum value. */ + total_quantum_rewards: Scalars['String']; +}; + /** Queries allow a caller to read data and filter data via GraphQL. */ export type Query = { __typename?: 'Query'; @@ -4414,6 +4733,8 @@ export type Query = { estimateOrder: OrderEstimate; /** Return a margin range for the specified position and liquidation price range if available collateral is supplied */ estimatePosition?: Maybe; + /** Estimate transfer fee */ + estimateTransferFee?: Maybe; /** Query for historic ethereum key rotations */ ethereumKeyRotations: EthereumKeyRotationsConnection; /** Get fees statistics */ @@ -4429,6 +4750,8 @@ export type Query = { fundingPeriodDataPoints: FundingPeriodDataPointConnection; /** Funding periods for perpetual markets */ fundingPeriods: FundingPeriodConnection; + /** Get a list of games and their metrics. */ + games: GamesConnection; /** Get market data history for a specific market. If no dates are given, the latest snapshot will be returned. If only the start date is provided all history from the given date will be provided, and if only the end date is provided, all history from the start up to and including the end date will be provided. */ getMarketDataHistoryConnectionByID?: Maybe; /** Query for historic key rotations */ @@ -4444,10 +4767,10 @@ export type Query = { * At least one party ID must be specified in the from or to account filter. * * Entries can be filtered by: - * - the sending account (market ID, asset ID, account type) - * - receiving account (market ID, asset ID, account type) - * - sending AND receiving account - * - transfer type either in addition to the above filters or as a standalone option + * - the sending account (market ID, asset ID, account type) + * - receiving account (market ID, asset ID, account type) + * - sending AND receiving account + * - transfer type either in addition to the above filters or as a standalone option * * Note: The date range is restricted to any 5 days. * If no start or end date is provided, only ledger entries from the last 5 days will be returned. @@ -4492,10 +4815,12 @@ export type Query = { orderByReference: Order; /** Order versions (created via amendments if any) found by orderID */ orderVersionsConnection?: Maybe; - /** List paid liquidity fees statistics */ + /** List statistics about paid liquidity fees */ paidLiquidityFees?: Maybe; /** One or more entities that are trading on the Vega network */ partiesConnection?: Maybe; + /** List parties' profiles by their IDs. If no ID is set, all profiles are returned. */ + partiesProfilesConnection?: Maybe; /** An entity that is trading on the Vega network */ party?: Maybe; /** @@ -4507,7 +4832,7 @@ export type Query = { /** Fetch all positions */ positions?: Maybe; /** A governance proposal located by either its ID or reference. If both are set, ID is used. */ - proposal?: Maybe; + proposal?: Maybe; /** All governance proposals in the Vega network */ proposalsConnection?: Maybe; /** List protocol upgrade proposals, optionally filtering on status or approver */ @@ -4527,6 +4852,12 @@ export type Query = { stopOrders?: Maybe; /** List markets in a succession line */ successorMarkets?: Maybe; + /** + * List team members' statistics for a given team + * Get the statistics of all team members for a given team ID, or for a specific member by using party ID, over a number of epochs. + * If a team does not have at least the number of epochs worth of data, it is ignored. + */ + teamMembersStatistics?: Maybe; /** List a referee's team history */ teamRefereeHistory?: Maybe; /** List all referees for a team */ @@ -4539,10 +4870,18 @@ export type Query = { * If both team ID and party ID is provided, only the team ID will be used. */ teams?: Maybe; + /** + * List teams statistics + * Get the statistics of all teams, or for a specific team by using team ID, over a number of epochs. + * If a team does not have at least the number of epochs worth of data, it is ignored. + */ + teamsStatistics?: Maybe; + /** Get total transfer fee discount available */ + totalTransferFeeDiscount?: Maybe; /** Get a list of all trades and apply any given filters to the results */ trades?: Maybe; /** Find a transfer using its ID */ - transfer?: Maybe; + transfer?: Maybe; /** Get a list of all transfers for a public key */ transfersConnection?: Maybe; /** Get volume discount statistics */ @@ -4678,14 +5017,30 @@ export type QueryestimateOrderArgs = { /** Queries allow a caller to read data and filter data via GraphQL. */ export type QueryestimatePositionArgs = { - collateralAvailable?: InputMaybe; + averageEntryPrice: Scalars['String']; + generalAccountBalance: Scalars['String']; + includeCollateralIncreaseInAvailableCollateral?: InputMaybe; + marginAccountBalance: Scalars['String']; + marginFactor?: InputMaybe; + marginMode: MarginMode; marketId: Scalars['ID']; openVolume: Scalars['String']; + orderMarginAccountBalance: Scalars['String']; orders?: InputMaybe>; scaleLiquidationPriceToMarketDecimals?: InputMaybe; }; +/** Queries allow a caller to read data and filter data via GraphQL. */ +export type QueryestimateTransferFeeArgs = { + amount: Scalars['String']; + assetId: Scalars['String']; + fromAccount: Scalars['ID']; + fromAccountType: AccountType; + toAccount: Scalars['ID']; +}; + + /** Queries allow a caller to read data and filter data via GraphQL. */ export type QueryethereumKeyRotationsArgs = { nodeId?: InputMaybe; @@ -4735,6 +5090,16 @@ export type QueryfundingPeriodsArgs = { }; +/** Queries allow a caller to read data and filter data via GraphQL. */ +export type QuerygamesArgs = { + entityScope?: InputMaybe; + epochFrom?: InputMaybe; + epochTo?: InputMaybe; + gameId?: InputMaybe; + pagination?: InputMaybe; +}; + + /** Queries allow a caller to read data and filter data via GraphQL. */ export type QuerygetMarketDataHistoryConnectionByIDArgs = { end?: InputMaybe; @@ -4873,12 +5238,27 @@ export type QuerypartiesConnectionArgs = { }; +/** Queries allow a caller to read data and filter data via GraphQL. */ +export type QuerypartiesProfilesConnectionArgs = { + ids?: InputMaybe>; + pagination?: InputMaybe; +}; + + /** Queries allow a caller to read data and filter data via GraphQL. */ export type QuerypartyArgs = { id: Scalars['ID']; }; +/** Queries allow a caller to read data and filter data via GraphQL. */ +export type QuerypartyMarginModesArgs = { + marketId?: InputMaybe; + pagination?: InputMaybe; + partyId?: InputMaybe; +}; + + /** Queries allow a caller to read data and filter data via GraphQL. */ export type QuerypositionsArgs = { filter?: InputMaybe; @@ -4958,6 +5338,15 @@ export type QuerysuccessorMarketsArgs = { }; +/** Queries allow a caller to read data and filter data via GraphQL. */ +export type QueryteamMembersStatisticsArgs = { + aggregationEpochs?: InputMaybe; + pagination?: InputMaybe; + partyId?: InputMaybe; + teamId: Scalars['ID']; +}; + + /** Queries allow a caller to read data and filter data via GraphQL. */ export type QueryteamRefereeHistoryArgs = { pagination?: InputMaybe; @@ -4980,6 +5369,21 @@ export type QueryteamsArgs = { }; +/** Queries allow a caller to read data and filter data via GraphQL. */ +export type QueryteamsStatisticsArgs = { + aggregationEpochs?: InputMaybe; + pagination?: InputMaybe; + teamId?: InputMaybe; +}; + + +/** Queries allow a caller to read data and filter data via GraphQL. */ +export type QuerytotalTransferFeeDiscountArgs = { + assetId: Scalars['String']; + partyId: Scalars['String']; +}; + + /** Queries allow a caller to read data and filter data via GraphQL. */ export type QuerytradesArgs = { dateRange?: InputMaybe; @@ -4997,9 +5401,13 @@ export type QuerytransferArgs = { /** Queries allow a caller to read data and filter data via GraphQL. */ export type QuerytransfersConnectionArgs = { direction?: InputMaybe; + fromEpoch?: InputMaybe; isReward?: InputMaybe; pagination?: InputMaybe; partyId?: InputMaybe; + scope?: InputMaybe; + status?: InputMaybe; + toEpoch?: InputMaybe; }; @@ -5216,18 +5624,27 @@ export type Reward = { asset: Asset; /** Epoch for which this reward was distributed */ epoch: Epoch; + /** Optional game ID for rewards that are paid for participation in a game */ + gameId?: Maybe; /** The epoch when the reward is released */ lockedUntilEpoch: Epoch; - /** The market ID for which this reward is paid if any */ + /** + * The market ID for which this reward is paid if any + * @deprecated Use gameId + */ marketId: Scalars['ID']; /** Party receiving the reward */ party: Party; /** Percentage out of the total distributed reward */ percentageOfTotal: Scalars['String']; + /** Amount paid as a reward, expressed in asset's quantum unit */ + quantumAmount: Scalars['String']; /** RFC3339Nano time when the rewards were received */ receivedAt: Scalars['Timestamp']; /** The type of reward */ rewardType: AccountType; + /** Optional team ID for rewards that are paid if the party is a member of a team, and for participation in a game. */ + teamId?: Maybe; }; /** Edge type containing the reward and cursor information returned by a RewardsConnection */ @@ -5387,6 +5804,15 @@ export type SimpleRiskModelParams = { factorShort: Scalars['Float']; }; +/** + * Describes which property of the data source data should be + * used as composite price source. + */ +export type SpecBindingForCompositePrice = { + __typename?: 'SpecBindingForCompositePrice'; + priceSourceProperty: Scalars['String']; +}; + /** Spot FX product */ export type Spot = { __typename?: 'Spot'; @@ -5581,6 +6007,10 @@ export type StopOrder = { partyId: Scalars['ID']; /** Optional rejection reason for an order */ rejectionReason?: Maybe; + /** Size override setting */ + sizeOverrideSetting: StopOrderSizeOverrideSetting; + /** Size override value */ + sizeOverrideValue?: Maybe; /** Status of the stop order */ status: StopOrderStatus; /** Order to submit when the stop order is triggered. */ @@ -5651,6 +6081,8 @@ export enum StopOrderRejectionReason { REJECTION_REASON_MAX_STOP_ORDERS_PER_PARTY_REACHED = 'REJECTION_REASON_MAX_STOP_ORDERS_PER_PARTY_REACHED', /** Stop orders submission must be reduce only */ REJECTION_REASON_MUST_BE_REDUCE_ONLY = 'REJECTION_REASON_MUST_BE_REDUCE_ONLY', + /** Stop order cannot have matching OCO expiry times */ + REJECTION_REASON_STOP_ORDER_CANNOT_MATCH_OCO_EXPIRY_TIMES = 'REJECTION_REASON_STOP_ORDER_CANNOT_MATCH_OCO_EXPIRY_TIMES', /** Stop orders are not allowed during the opening auction */ REJECTION_REASON_STOP_ORDER_NOT_ALLOWED_DURING_OPENING_AUCTION = 'REJECTION_REASON_STOP_ORDER_NOT_ALLOWED_DURING_OPENING_AUCTION', /** Stop orders are not allowed without a position */ @@ -5661,6 +6093,16 @@ export enum StopOrderRejectionReason { REJECTION_REASON_TRADING_NOT_ALLOWED = 'REJECTION_REASON_TRADING_NOT_ALLOWED' } +/** Stop order size override settings */ +export enum StopOrderSizeOverrideSetting { + /** No size override, the size within the contained normal order submission will be used */ + SIZE_OVERRIDE_SETTING_NONE = 'SIZE_OVERRIDE_SETTING_NONE', + /** Use the total position of the trader */ + SIZE_OVERRIDE_SETTING_POSITION = 'SIZE_OVERRIDE_SETTING_POSITION', + /** The size override has not been specified, this should never happen! */ + SIZE_OVERRIDE_SETTING_UNSPECIFIED = 'SIZE_OVERRIDE_SETTING_UNSPECIFIED' +} + /** Valid stop order statuses, these determine several states for a stop order that cannot be expressed with other fields in StopOrder. */ export enum StopOrderStatus { /** Stop order has been cancelled. This could be by the trader or by the network. */ @@ -5873,9 +6315,11 @@ export type TargetStakeParameters = { /** Team record containing the team information. */ export type Team = { __typename?: 'Team'; + /** List of public keys that are allowed to join the team. Only applicable to closed teams. */ + allowList: Array; /** Link to an image of the team's avatar. */ - avatarURL: Scalars['String']; - /** Tells if a party can join the team or not. */ + avatarUrl: Scalars['String']; + /** Whether or not the team is closed to new party members. When closed, only parties specified in the allow list can join the team. */ closed: Scalars['Boolean']; /** Time in RFC3339Nano format when the team was created. */ createdAt: Scalars['Timestamp']; @@ -5888,7 +6332,7 @@ export type Team = { /** Unique ID of the team. */ teamId: Scalars['ID']; /** Link to the team's homepage. */ - teamURL: Scalars['String']; + teamUrl: Scalars['String']; }; /** Connection type for retrieving cursor-based paginated team data */ @@ -5909,6 +6353,67 @@ export type TeamEdge = { node: Team; }; +/** Team participating in a game and their metrics. */ +export type TeamGameEntity = { + __typename?: 'TeamGameEntity'; + /** Rank of the team within the game. */ + rank: Scalars['Int']; + /** Total rewards earned by the team during the epoch */ + rewardEarned: Scalars['String']; + /** Reward metric applied to the game. */ + rewardMetric: DispatchMetric; + /** Breakdown of the team members and their contributions to the total team metrics. */ + team: TeamParticipation; + /** Total rewards earned by the team for the game */ + totalRewardsEarned: Scalars['String']; + /** Total volume traded by the team */ + volume: Scalars['String']; +}; + +/** Team member's statistics record containing the member's information. */ +export type TeamMemberStatistics = { + __typename?: 'TeamMemberStatistics'; + /** List of games played over the requested epoch period. */ + gamesPlayed: Array; + /** Party ID the statistics are related to. */ + partyId: Scalars['String']; + /** List of rewards over the requested epoch period, expressed in quantum value for each epoch */ + quantumRewards: Array; + /** Total number of games played. */ + totalGamesPlayed: Scalars['Int']; + /** Total of rewards accumulated over the requested epoch period, expressed in quantum value. */ + totalQuantumRewards: Scalars['String']; + /** Total of volume accumulated over the requested epoch period, expressed in quantum value. */ + totalQuantumVolume: Scalars['String']; +}; + +/** Edge type containing a team member statistics cursor and its associated statistics data */ +export type TeamMemberStatisticsEdge = { + __typename?: 'TeamMemberStatisticsEdge'; + /** Cursor identifying the team data */ + cursor: Scalars['String']; + /** Team member's statistics data */ + node: TeamMemberStatistics; +}; + +/** Connection type for retrieving cursor-based paginated team member statistics data */ +export type TeamMembersStatisticsConnection = { + __typename?: 'TeamMembersStatisticsConnection'; + /** Team members' statistics in this connection */ + edges: Array; + /** Pagination information */ + pageInfo: PageInfo; +}; + +/** Team participation information, i.e. the team ID and the metrics for each participating team member. */ +export type TeamParticipation = { + __typename?: 'TeamParticipation'; + /** List of participating team members and their metrics. */ + membersParticipating: Array; + /** Team ID */ + teamId: Scalars['ID']; +}; + /** A team's referee info */ export type TeamReferee = { __typename?: 'TeamReferee'; @@ -5969,12 +6474,54 @@ export type TeamRefereeHistoryEdge = { node: TeamRefereeHistory; }; +/** Team's statistics record containing the team information. */ +export type TeamStatistics = { + __typename?: 'TeamStatistics'; + /** List of games played over the requested epoch period. */ + gamesPlayed: Array; + /** List of rewards over the requested epoch period, expressed in quantum value for each epoch */ + quantumRewards: Array; + /** Team ID the statistics are related to. */ + teamId: Scalars['String']; + /** Total of games played. */ + totalGamesPlayed: Scalars['Int']; + /** Total of rewards accumulated over the requested epoch period, expressed in quantum value. */ + totalQuantumRewards: Scalars['String']; + /** Total of volume accumulated over the requested epoch period, expressed in quantum value. */ + totalQuantumVolume: Scalars['String']; +}; + +/** Edge type containing a team statistics cursor and its associated team's statistics data */ +export type TeamStatisticsEdge = { + __typename?: 'TeamStatisticsEdge'; + /** Cursor identifying the team data */ + cursor: Scalars['String']; + /** Team's statistics data */ + node: TeamStatistics; +}; + +/** Connection type for retrieving cursor-based paginated team statistics data */ +export type TeamsStatisticsConnection = { + __typename?: 'TeamsStatisticsConnection'; + /** Teams' statistics in this connection */ + edges: Array; + /** Pagination information */ + pageInfo: PageInfo; +}; + export type TimeUpdate = { __typename?: 'TimeUpdate'; /** RFC3339Nano time of new block time */ timestamp: Scalars['Timestamp']; }; +/** Returns total transfer fee discount available */ +export type TotalTransferFeeDiscount = { + __typename?: 'TotalTransferFeeDiscount'; + /** Total per party per asset discount available. */ + totalDiscount: Scalars['String']; +}; + /** A tradable instrument is a combination of an instrument and a risk model */ export type TradableInstrument = { __typename?: 'TradableInstrument'; @@ -6157,6 +6704,8 @@ export type Transfer = { from: Scalars['String']; /** The account type from which funds have been sent */ fromAccountType: AccountType; + /** An optional game ID to filter for transfers that are made for rewarding participation in games */ + gameId?: Maybe; /** ID of this transfer */ id: Scalars['ID']; /** The type of transfer being made, i.e. a one-off or recurring transfer */ @@ -6240,6 +6789,14 @@ export type TransferResponses = { responses?: Maybe>; }; +/** Defines the types of a dispatch strategy's scope the API can filter on. */ +export enum TransferScope { + /** Matches transfers that have dispatch strategy scope of individual set. */ + SCOPE_INDIVIDUAL = 'SCOPE_INDIVIDUAL', + /** Matches transfers that have dispatch strategy scope of team set. */ + SCOPE_TEAM = 'SCOPE_TEAM' +} + /** All the states a transfer can transition between */ export enum TransferStatus { /** Indication of a transfer cancelled by the user */ @@ -6384,6 +6941,7 @@ export type UpdateFutureProduct = { export type UpdateInstrumentConfiguration = { __typename?: 'UpdateInstrumentConfiguration'; code: Scalars['String']; + name: Scalars['String']; product: UpdateProductConfiguration; }; @@ -6403,15 +6961,24 @@ export type UpdateMarketConfiguration = { instrument: UpdateInstrumentConfiguration; /** Linear slippage factor is used to cap the slippage component of maintenance margin - it is applied to the slippage volume. */ linearSlippageFactor: Scalars['String']; + /** Liquidation strategy for the market */ + liquidationStrategy?: Maybe; + /** Specifies how the liquidity fee for the market will be calculated */ + liquidityFeeSettings?: Maybe; /** Liquidity monitoring parameters. */ liquidityMonitoringParameters: LiquidityMonitoringParameters; /** Liquidity SLA Parameters. */ liquiditySLAParameters?: Maybe; + /** Configuration for mark price calculation for the market */ + markPriceConfiguration?: Maybe; /** Optional futures market metadata, tags. */ metadata?: Maybe>>; /** Price monitoring parameters. */ priceMonitoringParameters: PriceMonitoringParameters; - /** Quadratic slippage factor is used to cap the slippage component of maintenance margin - it is applied to the square of the slippage volume. */ + /** + * Quadratic slippage factor is used to cap the slippage component of maintenance margin - it is applied to the square of the slippage volume. + * @deprecated This field will be removed in a future release + */ quadraticSlippageFactor: Scalars['String']; /** Updated futures market risk model parameters. */ riskParameters: UpdateMarketRiskParameters; @@ -6457,6 +7024,12 @@ export type UpdatePerpetualProduct = { dataSourceSpecForSettlementData: DataSourceDefinition; /** Data source specification describing the data source for settlement schedule */ dataSourceSpecForSettlementSchedule: DataSourceDefinition; + /** Lower bound for the funding-rate such that the funding-rate will never be lower than this value */ + fundingRateLowerBound: Scalars['String']; + /** Factor applied to funding-rates. This scales the impact that spot price deviations have on funding payments. */ + fundingRateScalingFactor: Scalars['String']; + /** Upper bound for the funding-rate such that the funding-rate will never be higher than this value */ + fundingRateUpperBound: Scalars['String']; /** Continuously compounded interest rate used in funding rate calculation, in the range [-1, 1] */ interestRate: Scalars['String']; /** Controls how much the upcoming funding payment liability contributes to party's margin, in the range [0, 1] */ @@ -6494,6 +7067,8 @@ export type UpdateSpotMarket = { export type UpdateSpotMarketConfiguration = { __typename?: 'UpdateSpotMarketConfiguration'; + /** Specifies how the liquidity fee for the market will be calculated */ + liquidityFeeSettings?: Maybe; /** Specifies the liquidity provision SLA parameters */ liquiditySLAParams: LiquiditySLAParameters; /** Optional spot market metadata tags */ diff --git a/libs/types/src/global-types-mappings.ts b/libs/types/src/global-types-mappings.ts index 7ce958f93..7c2eb5cd2 100644 --- a/libs/types/src/global-types-mappings.ts +++ b/libs/types/src/global-types-mappings.ts @@ -38,7 +38,6 @@ import type { ProductType, ProposalProductType } from './product'; export const AccountTypeMapping: { [T in AccountType]: string; } = { - ACCOUNT_TYPE_ORDER_MARGIN: 'Per asset market account', ACCOUNT_TYPE_BOND: 'Bond account', ACCOUNT_TYPE_EXTERNAL: 'External account', ACCOUNT_TYPE_FEES_INFRASTRUCTURE: 'Infrastructure fees account', @@ -49,6 +48,7 @@ export const AccountTypeMapping: { ACCOUNT_TYPE_GLOBAL_REWARD: 'Global reward account', ACCOUNT_TYPE_INSURANCE: 'Insurance account', ACCOUNT_TYPE_MARGIN: 'Margin account', + ACCOUNT_TYPE_ORDER_MARGIN: 'Per asset market account', ACCOUNT_TYPE_PENDING_TRANSFERS: 'Pending transfers account', ACCOUNT_TYPE_PENDING_FEE_REFERRAL_REWARD: 'Pending fee referral reward account', @@ -116,9 +116,14 @@ export const IntervalMapping: { INTERVAL_BLOCK: '1 block', INTERVAL_I15M: 'I15M', INTERVAL_I1D: 'I1D', + INTERVAL_I7D: 'I7D', INTERVAL_I1H: 'I1H', + INTERVAL_I4H: 'I4H', + INTERVAL_I8H: 'I8H', + INTERVAL_I12H: 'I12H', INTERVAL_I1M: 'I1M', INTERVAL_I5M: 'I5M', + INTERVAL_I30M: 'I30M', INTERVAL_I6H: 'I6H', };