Compare commits

...
Author SHA1 Message Date
Dariusz Majcherczyk f6ed5016d1 test: added wait for the markets as beforeEach 2023-02-21 17:27:44 +01:00
Dariusz Majcherczyk d4e151d4be test: remove wrong wait 2023-02-21 17:13:07 +01:00
Dariusz Majcherczyk efee4f9e1a test: changed wait 2023-02-21 16:54:10 +01:00
Dariusz Majcherczyk a3257b33b4 test: node version update for live workflow 2023-02-21 15:24:47 +01:00
mattrussell36 96007bd230 chore: update tranches
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-02-21 12:06:41 +00:00
mattrussell36 554d9ecb06 chore: update tranches
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-02-21 06:08:22 +00:00
Matthew Russell a12a5b3a15 chore(trading,governance): remove busEvent for proposals (#2946) 2023-02-20 16:57:25 -08:00
mattrussell36 a79e2f85bc chore: update tranches
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-02-21 00:12:00 +00:00
14 changed files with 249 additions and 216 deletions

No files matched your search

+4
View File
@@ -18,6 +18,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Run Cypress tests
uses: cypress-io/github-action@v4
with:
+32 -21
View File
@@ -2761,7 +2761,7 @@
"tranche_end": "2023-12-05T00:00:00.000Z",
"total_added": "86666.297",
"total_removed": "0",
"locked_amount": "68204.1112467141064238038",
"locked_amount": "68026.0050809900766642912",
"deposits": [
{
"amount": "86666.297",
@@ -2827,7 +2827,7 @@
"tranche_end": "2023-06-01T00:00:00.000Z",
"total_added": "2500",
"total_removed": "0",
"locked_amount": "1376.99811762311775",
"locked_amount": "1366.694488960114",
"deposits": [
{
"amount": "2500",
@@ -3215,7 +3215,7 @@
"tranche_end": "2023-08-01T00:00:00.000Z",
"total_added": "37500",
"total_removed": "3009.936598125",
"locked_amount": "33407.2091774094525",
"locked_amount": "33251.80085558624625",
"deposits": [
{
"amount": "7500",
@@ -3337,7 +3337,7 @@
"tranche_end": "2023-12-05T00:00:00.000Z",
"total_added": "129999.45",
"total_removed": "0",
"locked_amount": "68141.88357697181733279",
"locked_amount": "67963.9399107138444471",
"deposits": [
{
"amount": "129999.45",
@@ -3403,7 +3403,7 @@
"tranche_end": "2023-09-03T00:00:00.000Z",
"total_added": "62600",
"total_removed": "0",
"locked_amount": "33314.42734652460852",
"locked_amount": "33185.77934424150344",
"deposits": [
{
"amount": "10000",
@@ -3596,7 +3596,7 @@
"tranche_end": "2023-09-17T00:00:00.000Z",
"total_added": "5000",
"total_removed": "0",
"locked_amount": "2852.677574835109",
"locked_amount": "2842.40217529173",
"deposits": [
{
"amount": "5000",
@@ -3807,7 +3807,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "97499.58",
"total_removed": "0",
"locked_amount": "10063.041708339958997166",
"locked_amount": "9888.4955479431840552672",
"deposits": [
{
"amount": "97499.58",
@@ -3840,7 +3840,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "135173.4239508",
"total_removed": "98230.390980249184455396",
"locked_amount": "13754.440703626382165312324964",
"locked_amount": "13515.866236501447216654821204",
"deposits": [
{
"amount": "135173.4239508",
@@ -3886,7 +3886,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "32499.86",
"total_removed": "0",
"locked_amount": "4233.3478672634979601984",
"locked_amount": "4159.9193118355352539772",
"deposits": [
{
"amount": "32499.86",
@@ -3919,7 +3919,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "10833.29",
"total_removed": "0",
"locked_amount": "1377.9136513589326159943",
"locked_amount": "1354.013369100967212235",
"deposits": [
{
"amount": "10833.29",
@@ -3952,7 +3952,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "22749.93",
"total_removed": "4720.860935375",
"locked_amount": "5150.948980235602753755",
"locked_amount": "5061.6043871236901291745",
"deposits": [
{
"amount": "6500",
@@ -4104,7 +4104,7 @@
"tranche_end": "2023-05-01T00:00:00.000Z",
"total_added": "22500",
"total_removed": "4546.97235645",
"locked_amount": "8607.861418047881625",
"locked_amount": "8514.6164249539599",
"deposits": [
{
"amount": "7500",
@@ -4346,7 +4346,7 @@
"tranche_end": "2023-06-02T00:00:00.000Z",
"total_added": "1939928.38",
"total_removed": "928642.9598472029154",
"locked_amount": "538106.703967371859419281",
"locked_amount": "534119.9961293638279815094",
"deposits": [
{
"amount": "1852091.69",
@@ -36638,7 +36638,7 @@
"tranche_end": "2023-06-05T00:00:00.000Z",
"total_added": "3732368.4671",
"total_removed": "609657.626547646980493",
"locked_amount": "851383.979871343316981060205",
"locked_amount": "845257.797948570775371065827",
"deposits": [
{
"amount": "1998.95815",
@@ -37976,7 +37976,7 @@
"tranche_end": "2023-12-05T00:00:00.000Z",
"total_added": "15870102.715470999700000001",
"total_removed": "572826.70366554650274952",
"locked_amount": "8318640.5141883996928739572247338928521222",
"locked_amount": "8296917.466428724395809164572318349628278",
"deposits": [
{
"amount": "16249.93",
@@ -43629,8 +43629,8 @@
"tranche_start": "2021-11-05T00:00:00.000Z",
"tranche_end": "2023-05-05T00:00:00.000Z",
"total_added": "14597706.0446472999",
"total_removed": "3930266.448252707129704282",
"locked_amount": "1958270.581387242551207619820565376",
"total_removed": "4396450.802668984389787156",
"locked_amount": "1938216.002398478950673792862823089",
"deposits": [
{
"amount": "129284.449",
@@ -43884,6 +43884,11 @@
"user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b",
"tx": "0x5fcd1783bbd5f8b519d94782580777ff37d84df742f617baf632fc693615f39a"
},
{
"amount": "466184.354416277260082874",
"user": "0xfc3b2D0b548d3edBb512CeE0Bb79Fb7FaD50AaF3",
"tx": "0x43c34302d1895983b4f5b28ad186ea31662a045f3c7c63075a1c9db4b059e42d"
},
{
"amount": "1333.9237119810715295",
"user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b",
@@ -50127,6 +50132,12 @@
}
],
"withdrawals": [
{
"amount": "466184.354416277260082874",
"user": "0xfc3b2D0b548d3edBb512CeE0Bb79Fb7FaD50AaF3",
"tranche_id": 3,
"tx": "0x43c34302d1895983b4f5b28ad186ea31662a045f3c7c63075a1c9db4b059e42d"
},
{
"amount": "32828.670452546475795519",
"user": "0xfc3b2D0b548d3edBb512CeE0Bb79Fb7FaD50AaF3",
@@ -50135,8 +50146,8 @@
}
],
"total_tokens": "575536.79731735",
"withdrawn_tokens": "32828.670452546475795519",
"remaining_tokens": "542708.126864803524204481"
"withdrawn_tokens": "499013.024868823735878393",
"remaining_tokens": "76523.772448526264121607"
},
{
"address": "0xaAeD573103e3f981867C4cd31c6674DE1c8a13c3",
@@ -50587,7 +50598,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "5778205.3912159303",
"total_removed": "2749067.463242913023296295",
"locked_amount": "456821.14668779032274974044808737",
"locked_amount": "448897.461240245945578932424695999",
"deposits": [
{
"amount": "552496.6455",
@@ -52614,7 +52625,7 @@
"tranche_end": "2023-06-05T00:00:00.000Z",
"total_added": "472355.6199999996",
"total_removed": "34093.0379154332685",
"locked_amount": "134906.65832892426701505075291732",
"locked_amount": "133935.9297845122141846487163876",
"deposits": [
{
"amount": "3000",
@@ -1,4 +1,4 @@
import { act } from '@testing-library/react-hooks';
import { act } from '@testing-library/react';
import { usePendingBalancesStore } from './use-pending-balances-manager';
import type { Event } from 'ethers';
@@ -1,6 +1,6 @@
import { mockConnectWallet } from '@vegaprotocol/cypress';
before(() => {
beforeEach(() => {
cy.mockTradingPage();
cy.mockSubscription();
cy.visit('/');
@@ -19,11 +19,11 @@ describe('Desktop view', { tags: '@smoke' }, () => {
cy.getByTestId('navbar')
.find(`[data-testid="navbar-links"] a[data-testid=${link}]`)
.then((element) => {
cy.contains('Loading...').should('not.exist');
cy.wrap(element).click();
cy.wrap(element)
.get('span.absolute.md\\:h-1.w-full')
.should('exist');
cy.contains('No market').should('not.exist');
cy.location('hash').should('equal', hashes[index]);
});
});
@@ -69,7 +69,6 @@ describe('Mobile view', { tags: '@smoke' }, () => {
cy.getByTestId('button-menu-drawer').click();
cy.getByTestId('menu-drawer').within((el) => {
cy.wrap(el).getByTestId('Trading').click();
cy.contains('No market').should('not.exist');
cy.location('hash').should('equal', '#/markets/market-1');
});
});
@@ -27,12 +27,8 @@ fragment UpdateNetworkParameterProposal on Proposal {
}
subscription OnUpdateNetworkParameters {
busEvents(types: [Proposal], batchSize: 0) {
event {
... on Proposal {
...UpdateNetworkParameterProposal
}
}
proposals {
...UpdateNetworkParameterProposal
}
}
@@ -18,7 +18,7 @@ export type UpdateNetworkParameterProposalFragment = { __typename?: 'Proposal',
export type OnUpdateNetworkParametersSubscriptionVariables = Types.Exact<{ [key: string]: never; }>;
export type OnUpdateNetworkParametersSubscription = { __typename?: 'Subscription', busEvents?: Array<{ __typename?: 'BusEvent', event: { __typename?: 'AccountEvent' } | { __typename?: 'Asset' } | { __typename?: 'AuctionEvent' } | { __typename?: 'Deposit' } | { __typename?: 'LiquidityProvision' } | { __typename?: 'LossSocialization' } | { __typename?: 'MarginLevels' } | { __typename?: 'Market' } | { __typename?: 'MarketData' } | { __typename?: 'MarketEvent' } | { __typename?: 'MarketTick' } | { __typename?: 'NodeSignature' } | { __typename?: 'OracleSpec' } | { __typename?: 'Order' } | { __typename?: 'Party' } | { __typename?: 'PositionResolution' } | { __typename?: 'Proposal', id?: string | null, state: Types.ProposalState, datetime: any, terms: { __typename?: 'ProposalTerms', enactmentDatetime?: any | null, change: { __typename?: 'NewAsset' } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket' } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket' } | { __typename?: 'UpdateNetworkParameter', networkParameter: { __typename?: 'NetworkParameter', key: string, value: string } } } } | { __typename?: 'RiskFactor' } | { __typename?: 'SettleDistressed' } | { __typename?: 'SettlePosition' } | { __typename?: 'TimeUpdate' } | { __typename?: 'Trade' } | { __typename?: 'TransactionResult' } | { __typename?: 'TransferResponses' } | { __typename?: 'Vote' } | { __typename?: 'Withdrawal' } }> | null };
export type OnUpdateNetworkParametersSubscription = { __typename?: 'Subscription', proposals: { __typename?: 'Proposal', id?: string | null, state: Types.ProposalState, datetime: any, terms: { __typename?: 'ProposalTerms', enactmentDatetime?: any | null, change: { __typename?: 'NewAsset' } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket' } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket' } | { __typename?: 'UpdateNetworkParameter', networkParameter: { __typename?: 'NetworkParameter', key: string, value: string } } } } };
export type ProposalOfMarketQueryVariables = Types.Exact<{
marketId: Types.Scalars['ID'];
@@ -83,12 +83,8 @@ export type ProposalEventSubscriptionHookResult = ReturnType<typeof useProposalE
export type ProposalEventSubscriptionResult = Apollo.SubscriptionResult<ProposalEventSubscription>;
export const OnUpdateNetworkParametersDocument = gql`
subscription OnUpdateNetworkParameters {
busEvents(types: [Proposal], batchSize: 0) {
event {
... on Proposal {
...UpdateNetworkParameterProposal
}
}
proposals {
...UpdateNetworkParameterProposal
}
}
${UpdateNetworkParameterProposalFragmentDoc}`;
@@ -7,11 +7,16 @@ import type { Toast } from '@vegaprotocol/ui-toolkit';
import { ToastHeading } from '@vegaprotocol/ui-toolkit';
import { useToasts } from '@vegaprotocol/ui-toolkit';
import { ExternalLink, Intent } from '@vegaprotocol/ui-toolkit';
import compact from 'lodash/compact';
import { useCallback } from 'react';
import type { UpdateNetworkParameterProposalFragment } from './__generated__/Proposal';
import { useOnUpdateNetworkParametersSubscription } from './__generated__/Proposal';
export const PROPOSAL_STATES_TO_TOAST = [
ProposalState.STATE_DECLINED,
ProposalState.STATE_ENACTED,
ProposalState.STATE_OPEN,
ProposalState.STATE_PASSED,
];
const CLOSE_AFTER = 5000;
type Proposal = UpdateNetworkParameterProposalFragment;
@@ -75,26 +80,16 @@ export const useUpdateNetworkParametersToasts = () => {
[remove]
);
useOnUpdateNetworkParametersSubscription({
onData: (options) => {
const events = compact(options.data.data?.busEvents);
if (!events || events.length === 0) return;
const validProposals = events
.filter(
(ev) =>
ev.event.__typename === 'Proposal' &&
ev.event.terms.__typename === 'ProposalTerms' &&
ev.event.terms.change.__typename === 'UpdateNetworkParameter' &&
[
ProposalState.STATE_DECLINED,
ProposalState.STATE_ENACTED,
ProposalState.STATE_OPEN,
ProposalState.STATE_PASSED,
].includes(ev.event.state)
)
.map((ev) => ev.event as Proposal);
if (validProposals.length < 5) {
validProposals.forEach((p) => setToast(fromProposal(p)));
return useOnUpdateNetworkParametersSubscription({
onData: ({ data }) => {
// note proposals is poorly named, it is actually a single proposal
const proposal = data.data?.proposals;
if (!proposal) return;
if (proposal.terms.change.__typename !== 'UpdateNetworkParameter') return;
// if one of the following states show a toast
if (PROPOSAL_STATES_TO_TOAST.includes(proposal.state)) {
setToast(fromProposal(proposal));
}
},
});
@@ -1,16 +1,19 @@
import merge from 'lodash/merge';
import type { MockedResponse } from '@apollo/client/testing';
import { MockedProvider } from '@apollo/client/testing';
import { renderHook } from '@testing-library/react-hooks';
import { ProposalState } from '@vegaprotocol/types';
import type { ReactNode } from 'react';
import { useUpdateNetworkParametersToasts } from './use-update-network-paramaters-toasts';
import {
PROPOSAL_STATES_TO_TOAST,
useUpdateNetworkParametersToasts,
} from './use-update-network-paramaters-toasts';
import type {
UpdateNetworkParameterProposalFragment,
OnUpdateNetworkParametersSubscription,
} from './__generated__/Proposal';
import { OnUpdateNetworkParametersDocument } from './__generated__/Proposal';
import { useToasts } from '@vegaprotocol/ui-toolkit';
import { waitFor } from '@testing-library/react';
import { waitFor, renderHook } from '@testing-library/react';
const render = (mocks?: MockedResponse[]) => {
const wrapper = ({ children }: { children: ReactNode }) => (
@@ -42,56 +45,6 @@ const generateUpdateNetworkParametersProposal = (
},
});
const mockedWrongEvent: MockedResponse<OnUpdateNetworkParametersSubscription> =
{
request: {
query: OnUpdateNetworkParametersDocument,
},
result: {
data: {
__typename: 'Subscription',
busEvents: [
{
__typename: 'BusEvent',
event: {
__typename: 'Asset',
},
},
],
},
},
};
const mockedEmptyEvent: MockedResponse<OnUpdateNetworkParametersSubscription> =
{
request: {
query: OnUpdateNetworkParametersDocument,
},
result: {
data: {
__typename: 'Subscription',
busEvents: [],
},
},
};
const mockedEvent: MockedResponse<OnUpdateNetworkParametersSubscription> = {
request: {
query: OnUpdateNetworkParametersDocument,
},
result: {
data: {
__typename: 'Subscription',
busEvents: [
{
__typename: 'BusEvent',
event: generateUpdateNetworkParametersProposal('abc.def', '123.456'),
},
],
},
},
};
const INITIAL = useToasts.getState();
const clear = () => {
@@ -102,23 +55,113 @@ describe('useUpdateNetworkParametersToasts', () => {
beforeEach(clear);
afterAll(clear);
it('returns toast for update network parameters bus event', async () => {
render([mockedEvent]);
await waitFor(() => {
expect(useToasts.getState().count).toBe(1);
});
});
it.each(PROPOSAL_STATES_TO_TOAST)(
'toasts for %s network param proposals',
async (state) => {
const mockOpenProposal: MockedResponse<OnUpdateNetworkParametersSubscription> =
{
request: {
query: OnUpdateNetworkParametersDocument,
},
result: {
data: {
proposals: generateUpdateNetworkParametersProposal(
'abc.def',
'123.456',
state
),
},
},
};
const { result } = render([mockOpenProposal]);
expect(result.current.loading).toBe(true);
await waitFor(() => {
expect(result.current.loading).toBe(false);
expect(useToasts.getState().count).toBe(1);
});
}
);
it('does not return toast for empty event', async () => {
render([mockedEmptyEvent]);
const IGNORE_STATES = Object.keys(ProposalState).filter((state) => {
return !PROPOSAL_STATES_TO_TOAST.includes(state as ProposalState);
}) as ProposalState[];
it.each(IGNORE_STATES)('does not toast for %s proposals', async (state) => {
const mockFailedProposal: MockedResponse<OnUpdateNetworkParametersSubscription> =
{
request: {
query: OnUpdateNetworkParametersDocument,
},
result: {
data: {
proposals: generateUpdateNetworkParametersProposal(
'abc.def',
'123.456',
state
),
},
},
};
const { result } = render([mockFailedProposal]);
expect(result.current.loading).toBe(true);
await waitFor(() => {
expect(result.current.loading).toBe(false);
expect(useToasts.getState().count).toBe(0);
});
});
it('does not return toast for wrong event', async () => {
render([mockedWrongEvent]);
it('does not return toast for empty propsal', async () => {
const error = console.error;
console.error = () => {
/* no op */
};
const mockEmptyProposal: MockedResponse<OnUpdateNetworkParametersSubscription> =
{
request: {
query: OnUpdateNetworkParametersDocument,
},
result: {
data: {
proposals:
undefined as unknown as UpdateNetworkParameterProposalFragment,
},
},
};
const { result } = render([mockEmptyProposal]);
expect(result.current.loading).toBe(true);
await waitFor(() => {
expect(result.current.loading).toBe(false);
expect(useToasts.getState().count).toBe(0);
});
console.error = error;
});
it('does not return toast for wrong proposal type', async () => {
const wrongProposalType = merge(
generateUpdateNetworkParametersProposal('a', 'b'),
{
terms: {
change: {
__typename: 'NewMarket',
},
},
}
);
const mockWrongProposalType: MockedResponse<OnUpdateNetworkParametersSubscription> =
{
request: {
query: OnUpdateNetworkParametersDocument,
},
result: {
data: {
proposals: wrongProposalType,
},
},
};
const { result } = render([mockWrongProposalType]);
expect(result.current.loading).toBe(true);
await waitFor(() => {
expect(result.current.loading).toBe(false);
expect(useToasts.getState().count).toBe(0);
});
});
+67 -53
View File
@@ -344,58 +344,12 @@ export type BusEvent = {
/** Event types */
export enum BusEventType {
/** An account has been updated */
Account = 'Account',
/** An asset has been created or update */
Asset = 'Asset',
/** A market has either entered or exited auction */
Auction = 'Auction',
/** Collateral has deposited in to this Vega network via the bridge */
Deposit = 'Deposit',
/** A liquidity commitment change occurred */
LiquidityProvision = 'LiquidityProvision',
/** A position has been closed without sufficient insurance pool balance to cover it */
LossSocialization = 'LossSocialization',
/** Margin levels have changed for a position */
MarginLevels = 'MarginLevels',
/** Constant for market events - mainly used for logging */
Market = 'Market',
/** A new market has been created */
MarketCreated = 'MarketCreated',
/** Market data has been updated */
MarketData = 'MarketData',
/** A market has progressed by one tick */
MarketTick = 'MarketTick',
/** A market has been updated */
MarketUpdated = 'MarketUpdated',
/** Validator node signatures for an event */
NodeSignature = 'NodeSignature',
/** An oracle spec has been registered */
OracleSpec = 'OracleSpec',
/** An order has been created or updated */
Order = 'Order',
/** A party has been updated */
Party = 'Party',
/** A position resolution event has occurred */
PositionResolution = 'PositionResolution',
/** A governance proposal has been created or updated */
Proposal = 'Proposal',
/** A risk factor adjustment was made */
RiskFactor = 'RiskFactor',
/** A distressed position has been settled */
SettleDistressed = 'SettleDistressed',
/** A position has been settled */
SettlePosition = 'SettlePosition',
/** Vega Time has changed */
TimeUpdate = 'TimeUpdate',
/** A trade has been created */
Trade = 'Trade',
/** The results from processing at transaction */
TransactionResult = 'TransactionResult',
/** A balance has been transferred between accounts */
TransferResponses = 'TransferResponses',
/** A vote has been placed on a governance proposal */
Vote = 'Vote',
/** Collateral has been withdrawn from this Vega network via the bridge */
Withdrawal = 'Withdrawal'
}
@@ -1014,7 +968,7 @@ export type EthereumKeyRotationsConnection = {
};
/** Union type for wrapped events in stream PROPOSAL is mapped to governance data, something to keep in mind */
export type Event = AccountEvent | Asset | AuctionEvent | Deposit | LiquidityProvision | LossSocialization | MarginLevels | Market | MarketData | MarketEvent | MarketTick | NodeSignature | OracleSpec | Order | Party | PositionResolution | Proposal | RiskFactor | SettleDistressed | SettlePosition | TimeUpdate | Trade | TransactionResult | TransferResponses | Vote | Withdrawal;
export type Event = Deposit | TimeUpdate | TransactionResult | Withdrawal;
export type ExternalData = {
__typename?: 'ExternalData';
@@ -1100,8 +1054,6 @@ export type FutureProduct = {
/** A segment of data node history */
export type HistorySegment = {
__typename?: 'HistorySegment';
/** Chain ID of the history segment */
chainID: Scalars['String'];
/** From block height of the history segment */
fromHeight: Scalars['Int'];
/** ID of the history segment */
@@ -1225,6 +1177,8 @@ export type LedgerEntryFilter = {
/** Configuration of a market liquidity monitoring parameters */
export type LiquidityMonitoringParameters = {
__typename?: 'LiquidityMonitoringParameters';
/** Specifies by how many seconds an auction should be extended if leaving the auction were to trigger a liquidity auction */
auctionExtensionSecs: Scalars['Int'];
/** Specifies parameters related to target stake calculation */
targetStakeParameters: TargetStakeParameters;
/** Specifies the triggering ratio for entering liquidity auction */
@@ -1489,6 +1443,8 @@ export type Market = {
fees: Fees;
/** Market ID */
id: Scalars['ID'];
/** Linear slippage factor is used to cap the slippage component of maintainence margin - it is applied to the slippage volume */
linearSlippageFactor: Scalars['String'];
/** Liquidity monitoring parameters for the market */
liquidityMonitoringParameters: LiquidityMonitoringParameters;
/** The list of the liquidity provision commitments for this market */
@@ -1515,6 +1471,8 @@ export type Market = {
priceMonitoringSettings: PriceMonitoringSettings;
/** The proposal that initiated this market */
proposal?: Maybe<Proposal>;
/** Quadratic slippage factor is used to cap the slippage component of maintainence margin - it is applied to the square of the slippage volume */
quadraticSlippageFactor: Scalars['String'];
/** Risk factors for the market */
riskFactors?: Maybe<RiskFactor>;
/** Current state of the market */
@@ -1870,10 +1828,20 @@ export type NewMarket = {
decimalPlaces: Scalars['Int'];
/** New market instrument configuration */
instrument: InstrumentConfiguration;
/** Linear slippage factor is used to cap the slippage component of maintainence margin - it is applied to the slippage volume */
linearSlippageFactor: Scalars['String'];
/** Liquidity monitoring parameters */
liquidityMonitoringParameters: LiquidityMonitoringParameters;
/** Liquidity Provision order price range */
lpPriceRange: Scalars['String'];
/** Metadata for this instrument, tags */
metadata?: Maybe<Array<Scalars['String']>>;
/** 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 maintainence margin - it is applied to the square of the slippage volume */
quadraticSlippageFactor: Scalars['String'];
/** New market risk configuration */
riskParameters: RiskModel;
};
@@ -2519,7 +2487,10 @@ export type Party = {
marginsConnection?: Maybe<MarginConnection>;
/** Orders relating to a party */
ordersConnection?: Maybe<OrderConnection>;
/** Trading positions relating to a party */
/**
* Trading positions relating to a party
* @deprecated Use root positions query instead of sub-query
*/
positionsConnection?: Maybe<PositionConnection>;
/** All governance proposals in the Vega network */
proposalsConnection?: Maybe<ProposalsConnection>;
@@ -2610,7 +2581,9 @@ export type PartyrewardSummariesArgs = {
/** Represents a party on Vega, could be an ethereum wallet address in the future */
export type PartyrewardsConnectionArgs = {
assetId?: InputMaybe<Scalars['ID']>;
fromEpoch?: InputMaybe<Scalars['Int']>;
pagination?: InputMaybe<Pagination>;
toEpoch?: InputMaybe<Scalars['Int']>;
};
@@ -2707,6 +2680,8 @@ export type Position = {
__typename?: 'Position';
/** Average entry price for this position */
averageEntryPrice: Scalars['String'];
/** The total amount of profit and loss that was not transferred due to loss socialisation */
lossSocializationAmount: Scalars['String'];
/** Margins of the party for the given position */
marginsConnection?: Maybe<MarginConnection>;
/** Market relating to this position */
@@ -2715,6 +2690,8 @@ export type Position = {
openVolume: Scalars['String'];
/** The party holding this position */
party: Party;
/** Enum set if the position was closed out or orders were removed because party was distressed */
positionStatus: PositionStatus;
/** Realised Profit and Loss (int64) */
realisedPNL: Scalars['String'];
/** Unrealised Profit and Loss (int64) */
@@ -2764,6 +2741,16 @@ export type PositionResolution = {
marketId: Scalars['ID'];
};
/** Position status can change if a position is distressed */
export enum PositionStatus {
/** The position was distressed, and had to be closed out entirely - orders were removed from the book, and the open volume was closed out by the network */
POSITION_STATUS_CLOSED_OUT = 'POSITION_STATUS_CLOSED_OUT',
/** The position was distressed, but removing open orders from the book brought the margin level back to a point where the open position could be maintained */
POSITION_STATUS_ORDERS_CLOSED = 'POSITION_STATUS_ORDERS_CLOSED',
/** The position is either healthy, or if closed out, was closed out normally */
POSITION_STATUS_UNSPECIFIED = 'POSITION_STATUS_UNSPECIFIED'
}
/**
* An individual party at any point in time is considered net long or net short. This refers to their Open Volume,
* calculated using FIFO. This volume is signed as either negative for LONG positions and positive for SHORT positions. A
@@ -2788,6 +2775,12 @@ export type PositionUpdate = {
updatedAt?: Maybe<Scalars['Timestamp']>;
};
/** Filter to apply to the positions connection query */
export type PositionsFilter = {
marketIds?: InputMaybe<Array<Scalars['ID']>>;
partyIds?: InputMaybe<Array<Scalars['ID']>>;
};
/** Represents a price on either the buy or sell side and all the orders at that price */
export type PriceLevel = {
__typename?: 'PriceLevel';
@@ -2826,7 +2819,7 @@ export type PriceMonitoringSettings = {
parameters?: Maybe<PriceMonitoringParameters>;
};
/** PriceMonitoringParameters holds together price projection horizon τ, probability level p, and auction extension duration */
/** PriceMonitoringTrigger holds together price projection horizon τ, probability level p, and auction extension duration */
export type PriceMonitoringTrigger = {
__typename?: 'PriceMonitoringTrigger';
/**
@@ -3281,6 +3274,8 @@ export type Query = {
partiesConnection?: Maybe<PartyConnection>;
/** An entity that is trading on the Vega network */
party?: Maybe<Party>;
/** Fetch all positions */
positions?: Maybe<PositionConnection>;
/** A governance proposal located by either its ID or reference. If both are set, ID is used. */
proposal?: Maybe<Proposal>;
/** All governance proposals in the Vega network */
@@ -3348,9 +3343,8 @@ export type QueryepochArgs = {
/** Queries allow a caller to read data and filter data via GraphQL. */
export type QueryepochRewardSummariesArgs = {
fromEpoch?: InputMaybe<Scalars['Int']>;
filter?: InputMaybe<RewardSummaryFilter>;
pagination?: InputMaybe<Pagination>;
toEpoch?: InputMaybe<Scalars['Int']>;
};
@@ -3453,6 +3447,7 @@ export type QuerymarketArgs = {
/** Queries allow a caller to read data and filter data via GraphQL. */
export type QuerymarketsConnectionArgs = {
id?: InputMaybe<Scalars['ID']>;
includeSettled?: InputMaybe<Scalars['Boolean']>;
pagination?: InputMaybe<Pagination>;
};
@@ -3546,6 +3541,13 @@ export type QuerypartyArgs = {
};
/** Queries allow a caller to read data and filter data via GraphQL. */
export type QuerypositionsArgs = {
filter?: InputMaybe<PositionsFilter>;
pagination?: InputMaybe<Pagination>;
};
/** Queries allow a caller to read data and filter data via GraphQL. */
export type QueryproposalArgs = {
id?: InputMaybe<Scalars['ID']>;
@@ -3698,6 +3700,14 @@ export type RewardSummaryEdge = {
node: RewardSummary;
};
/** Filter for historical reward summary queries */
export type RewardSummaryFilter = {
assetIds?: InputMaybe<Array<Scalars['ID']>>;
fromEpoch?: InputMaybe<Scalars['Int']>;
marketIds?: InputMaybe<Array<Scalars['ID']>>;
toEpoch?: InputMaybe<Scalars['Int']>;
};
/** Connection type for retrieving cursor-based paginated rewards information */
export type RewardsConnection = {
__typename?: 'RewardsConnection';
@@ -3894,6 +3904,10 @@ export type Statistics = {
chainVersion: Scalars['String'];
/** RFC3339Nano current time (real) */
currentTime: Scalars['Timestamp'];
/** Total number of events on the last block */
eventCount: Scalars['String'];
/** The number of events per second on the last block */
eventsPerSecond: Scalars['String'];
/** RFC3339Nano genesis time of the chain */
genesisTime: Scalars['Timestamp'];
/** Number of orders per seconds */
@@ -1,9 +1,8 @@
import { renderHook, act } from '@testing-library/react-hooks';
import { renderHook, waitFor } from '@testing-library/react';
import type { MockedResponse } from '@apollo/client/testing';
import { MockedProvider } from '@apollo/client/testing';
import type { ReactNode } from 'react';
import { useVegaTransactionUpdater } from './use-vega-transaction-updater';
import waitForNextTick from 'flush-promises';
import {
OrderTxUpdateDocument,
TransactionEventDocument,
@@ -112,14 +111,13 @@ const mockedTransactionResultBusEvent: MockedResponse<TransactionEventSubscripti
data: {
busEvents: [
{
type: BusEventType.Order,
type: BusEventType.TransactionResult,
event: transactionResultBusEvent,
},
],
},
},
};
const withdrawalBusEvent: WithdrawalBusEventFieldsFragment = {
id: '2fca514cebf9f465ae31ecb4c5721e3a6f5f260425ded887ca50ba15b81a5d50',
status: WithdrawalStatus.STATUS_OPEN,
@@ -167,20 +165,16 @@ const mockedWithdrawalBusEvent: MockedResponse<WithdrawalBusEventSubscription> =
describe('useVegaTransactionManager', () => {
it('updates order on OrderTxUpdate', async () => {
mockTransactionStoreState.mockReturnValue(defaultState);
const { waitForNextUpdate } = render([mockedOrderUpdate]);
await act(async () => {
waitForNextUpdate();
await waitForNextTick();
render([mockedOrderUpdate]);
await waitFor(() => {
expect(updateOrder).toHaveBeenCalledWith(orderUpdate);
});
});
it('updates transaction on TransactionResultBusEvents', async () => {
mockTransactionStoreState.mockReturnValue(defaultState);
const { waitForNextUpdate } = render([mockedTransactionResultBusEvent]);
await act(async () => {
waitForNextUpdate();
await waitForNextTick();
render([mockedTransactionResultBusEvent]);
await waitFor(() => {
expect(updateTransactionResult).toHaveBeenCalledWith(
transactionResultBusEvent
);
@@ -193,10 +187,8 @@ describe('useVegaTransactionManager', () => {
mockWaitForWithdrawalApproval.mockResolvedValueOnce(
erc20WithdrawalApproval
);
const { waitForNextUpdate } = render([mockedWithdrawalBusEvent]);
await act(async () => {
waitForNextUpdate();
await waitForNextTick();
render([mockedWithdrawalBusEvent]);
await waitFor(() => {
expect(updateWithdrawal).toHaveBeenCalledWith(
withdrawalBusEvent,
erc20WithdrawalApproval
@@ -38,9 +38,9 @@ export const useVegaTransactionUpdater = () => {
result.data?.busEvents?.forEach((event) => {
if (event.event.__typename === 'Withdrawal') {
const withdrawal = event.event;
waitForWithdrawalApproval(withdrawal.id, client).then((approval) =>
updateWithdrawal(withdrawal, approval)
);
waitForWithdrawalApproval(withdrawal.id, client).then((approval) => {
updateWithdrawal(withdrawal, approval);
});
}
}),
});
@@ -1,9 +1,8 @@
import { renderHook } from '@testing-library/react-hooks';
import { renderHook, waitFor } from '@testing-library/react';
import type { MockedResponse } from '@apollo/client/testing';
import { MockedProvider } from '@apollo/client/testing';
import type { ReactNode } from 'react';
import { useEthTransactionUpdater } from './use-ethereum-transaction-updater';
import waitForNextTick from 'flush-promises';
import {
DepositBusEventDocument,
VegaWalletContext,
@@ -77,9 +76,9 @@ const mockedDepositBusEvent: MockedResponse<DepositBusEventSubscription> = {
describe('useEthTransactionUpdater', () => {
it('updates deposit on DepositBusEvents', async () => {
mockTransactionStoreState.mockReturnValue(defaultState);
const { waitForNextUpdate } = render([mockedDepositBusEvent]);
waitForNextUpdate();
await waitForNextTick();
expect(updateDeposit).toHaveBeenCalledWith(depositBusEvent);
render([mockedDepositBusEvent]);
await waitFor(() => {
expect(updateDeposit).toHaveBeenCalledWith(depositBusEvent);
});
});
});
-1
View File
@@ -128,7 +128,6 @@
"@svgr/webpack": "^5.4.0",
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "13.3.0",
"@testing-library/react-hooks": "^8.0.1",
"@testing-library/user-event": "^14.4.1",
"@types/classnames": "^2.3.1",
"@types/faker": "^5.5.8",
-15
View File
@@ -6364,14 +6364,6 @@
lodash "^4.17.15"
redent "^3.0.0"
"@testing-library/react-hooks@^8.0.1":
version "8.0.1"
resolved "https://registry.yarnpkg.com/@testing-library/react-hooks/-/react-hooks-8.0.1.tgz#0924bbd5b55e0c0c0502d1754657ada66947ca12"
integrity sha512-Aqhl2IVmLt8IovEVarNDFuJDVWVvhnr9/GCU6UUnrYXwgDFF9h2L2o2P9KBni1AST5sT6riAyoukFLyjQUgD/g==
dependencies:
"@babel/runtime" "^7.12.5"
react-error-boundary "^3.1.0"
"@testing-library/react@13.3.0":
version "13.3.0"
resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-13.3.0.tgz#bf298bfbc5589326bbcc8052b211f3bb097a97c5"
@@ -19130,13 +19122,6 @@ react-element-to-jsx-string@^14.3.4:
is-plain-object "5.0.0"
react-is "17.0.2"
react-error-boundary@^3.1.0:
version "3.1.4"
resolved "https://registry.yarnpkg.com/react-error-boundary/-/react-error-boundary-3.1.4.tgz#255db92b23197108757a888b01e5b729919abde0"
integrity sha512-uM9uPzZJTF6wRQORmSrvOIgt4lJ9MC1sNgEOj2XGsDTRE4kmpWxg7ENK9EWNKJRMAOY9z0MuF4yIfl6gp4sotA==
dependencies:
"@babel/runtime" "^7.12.5"
react-hook-form@^7.27.0:
version "7.37.0"
resolved "https://registry.yarnpkg.com/react-hook-form/-/react-hook-form-7.37.0.tgz#4d1738f092d3d8a3ade34ee892d97350b1032b19"