Compare commits
4 Commits
chore/e2e-
...
develop
Author | SHA1 | Date | |
---|---|---|---|
88264d890d | |||
|
26b78f878b | ||
|
054c0377b4 | ||
|
29bcbd06fb |
@ -4,6 +4,5 @@ tmp/*
|
||||
.dockerignore
|
||||
dockerfiles
|
||||
node_modules
|
||||
.git
|
||||
.github
|
||||
.vscode
|
||||
|
@ -38,6 +38,7 @@ import { differenceInHours, format, formatDistanceToNowStrict } from 'date-fns';
|
||||
import { DATE_FORMAT_DETAILED } from '../../../../lib/date-formats';
|
||||
import { MarketName } from '../proposal/market-name';
|
||||
import { Indicator } from '../proposal/indicator';
|
||||
import { type ProposalNode } from '../proposal/proposal-utils';
|
||||
|
||||
const ProposalTypeTags = ({
|
||||
proposal,
|
||||
@ -540,10 +541,12 @@ const BatchProposalStateText = ({
|
||||
|
||||
export const ProposalHeader = ({
|
||||
proposal,
|
||||
restData,
|
||||
isListItem = true,
|
||||
voteState,
|
||||
}: {
|
||||
proposal: Proposal | BatchProposal;
|
||||
restData?: ProposalNode | null;
|
||||
isListItem?: boolean;
|
||||
voteState?: VoteState | null;
|
||||
}) => {
|
||||
@ -595,7 +598,7 @@ export const ProposalHeader = ({
|
||||
)}
|
||||
</div>
|
||||
<ProposalDetails proposal={proposal} />
|
||||
<VoteBreakdown proposal={proposal} />
|
||||
<VoteBreakdown proposal={proposal} restData={restData} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
@ -91,6 +91,28 @@ export type ProposalNode = {
|
||||
proposal: ProposalData;
|
||||
proposalType: ProposalNodeType;
|
||||
proposals: SubProposalData[];
|
||||
yes?: [
|
||||
{
|
||||
partyId: string;
|
||||
elsPerMarket?: [
|
||||
{
|
||||
marketId: string;
|
||||
els: string;
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
no?: [
|
||||
{
|
||||
partyId: string;
|
||||
elsPerMarket?: [
|
||||
{
|
||||
marketId: string;
|
||||
els: string;
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
type SingleProposalNode = ProposalNode & {
|
||||
|
@ -48,6 +48,7 @@ export const Proposal = ({ proposal, restData }: ProposalProps) => {
|
||||
|
||||
<ProposalHeader
|
||||
proposal={proposal}
|
||||
restData={restData}
|
||||
isListItem={false}
|
||||
voteState={voteState}
|
||||
/>
|
||||
|
@ -17,6 +17,7 @@ import {
|
||||
import { useBatchVoteInformation } from '../../hooks/use-vote-information';
|
||||
import { MarketName } from '../proposal/market-name';
|
||||
import { Indicator } from '../proposal/indicator';
|
||||
import { type ProposalNode } from '../proposal/proposal-utils';
|
||||
|
||||
export const CompactVotes = ({ number }: { number: BigNumber }) => (
|
||||
<CompactNumber
|
||||
@ -110,24 +111,64 @@ const Status = ({ reached, threshold, text, testId }: StatusProps) => {
|
||||
|
||||
export const VoteBreakdown = ({
|
||||
proposal,
|
||||
restData,
|
||||
}: {
|
||||
proposal: Proposal | BatchProposal;
|
||||
restData?: ProposalNode | null;
|
||||
}) => {
|
||||
if (proposal.__typename === 'Proposal') {
|
||||
return <VoteBreakdownNormal proposal={proposal} />;
|
||||
}
|
||||
|
||||
if (proposal.__typename === 'BatchProposal') {
|
||||
return <VoteBreakdownBatch proposal={proposal} />;
|
||||
return <VoteBreakdownBatch proposal={proposal} restData={restData} />;
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
const VoteBreakdownBatch = ({ proposal }: { proposal: BatchProposal }) => {
|
||||
const VoteBreakdownBatch = ({
|
||||
proposal,
|
||||
restData,
|
||||
}: {
|
||||
proposal: BatchProposal;
|
||||
restData?: ProposalNode | null;
|
||||
}) => {
|
||||
const [fullBreakdown, setFullBreakdown] = useState(false);
|
||||
const { t } = useTranslation();
|
||||
|
||||
const yesELS =
|
||||
restData?.yes?.reduce((all, y) => {
|
||||
if (y.elsPerMarket) {
|
||||
y.elsPerMarket.forEach((item) => {
|
||||
const share = Number(item.els);
|
||||
if (all[item.marketId]) {
|
||||
all[item.marketId].push(share);
|
||||
} else {
|
||||
all[item.marketId] = [share];
|
||||
}
|
||||
return all;
|
||||
});
|
||||
}
|
||||
return all;
|
||||
}, {} as Record<string, number[]>) || {};
|
||||
|
||||
const noELS =
|
||||
restData?.no?.reduce((all, y) => {
|
||||
if (y.elsPerMarket) {
|
||||
y.elsPerMarket.forEach((item) => {
|
||||
const share = Number(item.els);
|
||||
if (all[item.marketId]) {
|
||||
all[item.marketId].push(share);
|
||||
} else {
|
||||
all[item.marketId] = [share];
|
||||
}
|
||||
return all;
|
||||
});
|
||||
}
|
||||
return all;
|
||||
}, {} as Record<string, number[]>) || {};
|
||||
|
||||
const voteInfo = useBatchVoteInformation({
|
||||
terms: compact(
|
||||
proposal.subProposals ? proposal.subProposals.map((p) => p?.terms) : []
|
||||
@ -194,6 +235,8 @@ const VoteBreakdownBatch = ({ proposal }: { proposal: BatchProposal }) => {
|
||||
proposal={proposal}
|
||||
votes={proposal.votes}
|
||||
terms={p.terms}
|
||||
yesELS={yesELS}
|
||||
noELS={noELS}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
@ -254,6 +297,8 @@ const VoteBreakdownBatch = ({ proposal }: { proposal: BatchProposal }) => {
|
||||
proposal={proposal}
|
||||
votes={proposal.votes}
|
||||
terms={p.terms}
|
||||
yesELS={yesELS}
|
||||
noELS={noELS}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
@ -271,17 +316,17 @@ const VoteBreakdownBatchSubProposal = ({
|
||||
votes,
|
||||
terms,
|
||||
indicator,
|
||||
yesELS,
|
||||
noELS,
|
||||
}: {
|
||||
proposal: BatchProposal;
|
||||
votes: VoteFieldsFragment;
|
||||
terms: ProposalTermsFieldsFragment;
|
||||
indicator?: number;
|
||||
yesELS: Record<string, number[]>;
|
||||
noELS: Record<string, number[]>;
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const voteInfo = useVoteInformation({
|
||||
votes,
|
||||
terms,
|
||||
});
|
||||
|
||||
const isProposalOpen = proposal?.state === ProposalState.STATE_OPEN;
|
||||
const isUpdateMarket = terms?.change?.__typename === 'UpdateMarket';
|
||||
@ -294,6 +339,15 @@ const VoteBreakdownBatchSubProposal = ({
|
||||
marketId = terms.change.market.id;
|
||||
}
|
||||
|
||||
const voteInfo = useVoteInformation({
|
||||
votes,
|
||||
terms,
|
||||
// yes votes ELS for this specific proposal (market)
|
||||
yesELS: marketId ? yesELS[marketId] : undefined,
|
||||
// no votes ELS for this specific proposal (market)
|
||||
noELS: marketId ? noELS[marketId] : undefined,
|
||||
});
|
||||
|
||||
const marketName = marketId ? (
|
||||
<>
|
||||
: <MarketName marketId={marketId} />
|
||||
|
@ -8,13 +8,18 @@ import {
|
||||
type VoteFieldsFragment,
|
||||
} from '../__generated__/Proposals';
|
||||
import { type ProposalChangeType } from '../types';
|
||||
import sum from 'lodash/sum';
|
||||
|
||||
export const useVoteInformation = ({
|
||||
votes,
|
||||
terms,
|
||||
yesELS,
|
||||
noELS,
|
||||
}: {
|
||||
votes: VoteFieldsFragment;
|
||||
terms: ProposalTermsFieldsFragment;
|
||||
yesELS?: number[];
|
||||
noELS?: number[];
|
||||
}) => {
|
||||
const {
|
||||
appState: { totalSupply, decimals },
|
||||
@ -31,7 +36,9 @@ export const useVoteInformation = ({
|
||||
paramsForChange,
|
||||
votes,
|
||||
totalSupply,
|
||||
decimals
|
||||
decimals,
|
||||
yesELS,
|
||||
noELS
|
||||
);
|
||||
};
|
||||
|
||||
@ -72,7 +79,11 @@ const getVoteData = (
|
||||
},
|
||||
votes: ProposalFieldsFragment['votes'],
|
||||
totalSupply: BigNumber,
|
||||
decimals: number
|
||||
decimals: number,
|
||||
/** A list of ELS yes votes */
|
||||
yesELS?: number[],
|
||||
/** A list if ELS no votes */
|
||||
noELS?: number[]
|
||||
) => {
|
||||
const requiredMajorityPercentage = params.requiredMajority
|
||||
? new BigNumber(params.requiredMajority).times(100)
|
||||
@ -86,17 +97,31 @@ const getVoteData = (
|
||||
addDecimal(votes.no.totalTokens ?? 0, decimals)
|
||||
);
|
||||
|
||||
const noEquityLikeShareWeight = !votes.no.totalEquityLikeShareWeight
|
||||
let noEquityLikeShareWeight = !votes.no.totalEquityLikeShareWeight
|
||||
? new BigNumber(0)
|
||||
: new BigNumber(votes.no.totalEquityLikeShareWeight).times(100);
|
||||
// there's no meaningful `totalEquityLikeShareWeight` in batch proposals,
|
||||
// it has to be deduced from `elsPerMarket` of `no` votes of given proposal
|
||||
// data. (by REST DATA)
|
||||
if (noELS != null) {
|
||||
const noTotalELS = sum(noELS);
|
||||
noEquityLikeShareWeight = new BigNumber(noTotalELS).times(100);
|
||||
}
|
||||
|
||||
const yesTokens = new BigNumber(
|
||||
addDecimal(votes.yes.totalTokens ?? 0, decimals)
|
||||
);
|
||||
|
||||
const yesEquityLikeShareWeight = !votes.yes.totalEquityLikeShareWeight
|
||||
let yesEquityLikeShareWeight = !votes.yes.totalEquityLikeShareWeight
|
||||
? new BigNumber(0)
|
||||
: new BigNumber(votes.yes.totalEquityLikeShareWeight).times(100);
|
||||
// there's no meaningful `totalEquityLikeShareWeight` in batch proposals,
|
||||
// it has to be deduced from `elsPerMarket` of `yes` votes of given proposal
|
||||
// data. (by REST DATA)
|
||||
if (noELS != null) {
|
||||
const yesTotalELS = sum(yesELS);
|
||||
yesEquityLikeShareWeight = new BigNumber(yesTotalELS).times(100);
|
||||
}
|
||||
|
||||
const totalTokensVoted = yesTokens.plus(noTokens);
|
||||
|
||||
|
@ -1,66 +0,0 @@
|
||||
import pytest
|
||||
from playwright.sync_api import Page, expect
|
||||
from vega_sim.null_service import VegaServiceNull
|
||||
from actions.vega import submit_order
|
||||
from actions.utils import wait_for_toast_confirmation
|
||||
from wallet_config import MM_WALLET, MM_WALLET2, PARTY_A, PARTY_B
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("auth", "risk_accepted")
|
||||
def test_take_profit_stop_loss_deal_ticket(
|
||||
continuous_market, page: Page, vega: VegaServiceNull
|
||||
):
|
||||
# 7002-SORD-032
|
||||
page.goto(f"/#/markets/{continuous_market}")
|
||||
tdai_id = vega.find_asset_id(symbol="tDAI")
|
||||
vega.mint(
|
||||
PARTY_A.name,
|
||||
asset=tdai_id,
|
||||
amount=10e5,
|
||||
)
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
vega.mint(
|
||||
PARTY_B.name,
|
||||
asset=tdai_id,
|
||||
amount=10e5,
|
||||
)
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
page.get_by_test_id("tpSl").click()
|
||||
page.get_by_test_id("order-size").fill("1")
|
||||
page.get_by_test_id("order-price").fill("100")
|
||||
page.get_by_test_id("order-price-stop-loss").fill("95")
|
||||
page.get_by_test_id("order-price-take-profit").fill("200")
|
||||
page.get_by_test_id("place-order").click()
|
||||
wait_for_toast_confirmation(page)
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
page.get_by_test_id("All").click()
|
||||
expect(page.get_by_role("row").nth(5)).to_contain_text("0+1LimitActive100.00GTC")
|
||||
page.get_by_test_id("Stop orders").click()
|
||||
text_locator_mark_under_95_pending = "Mark < 95.00-1MarketPendingOCO-FOK"
|
||||
text_locator_mark_over_200_pending = "Mark > 200.00-1MarketPendingOCO-FOK"
|
||||
|
||||
expect(page.locator(f"text={text_locator_mark_under_95_pending}")).to_be_visible()
|
||||
expect(page.locator(f"text={text_locator_mark_over_200_pending}")).to_be_visible()
|
||||
|
||||
submit_order(vega, PARTY_A.name, continuous_market, "SIDE_SELL", 100, 90)
|
||||
submit_order(vega, PARTY_B.name, continuous_market, "SIDE_BUY", 100, 90)
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
|
||||
page.get_by_test_id("All").click()
|
||||
expect(page.get_by_role("row").nth(5)).to_contain_text("1+1LimitFilled100.00GTC")
|
||||
submit_order(vega, MM_WALLET.name, continuous_market, "SIDE_SELL", 100, 80)
|
||||
submit_order(vega, MM_WALLET2.name, continuous_market, "SIDE_BUY", 100, 90)
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
page.get_by_test_id("All").click()
|
||||
expect(page.get_by_role("row").nth(8)).to_contain_text("1-1MarketFilled-FOK")
|
||||
page.get_by_test_id("Stop orders").click()
|
||||
text_locator_mark_under_95_triggered = "Mark < 95.00-1MarketTriggeredOCO-FOK"
|
||||
text_locator_mark_over_200_stopped = "Mark > 200.00-1MarketStoppedOCO-FOK"
|
||||
|
||||
expect(page.locator(f"text={text_locator_mark_under_95_triggered}")).to_be_visible()
|
||||
expect(page.locator(f"text={text_locator_mark_over_200_stopped}")).to_be_visible()
|
@ -39,6 +39,8 @@ const nextConfig = {
|
||||
GIT_COMMIT: commitHash,
|
||||
GIT_TAG: tag,
|
||||
},
|
||||
basePath: '/apps/vegas', // Set the base path
|
||||
assetPrefix: '/apps/vegas', // Set the asset prefix
|
||||
};
|
||||
|
||||
module.exports = SENTRY_AUTH_TOKEN
|
||||
|
@ -34,6 +34,21 @@
|
||||
"options": {
|
||||
"jestConfig": "libs/types/jest.config.ts"
|
||||
}
|
||||
},
|
||||
"generate": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"commands": ["npx graphql-codegen --config=libs/types/codegen.yml"],
|
||||
"parallel": false
|
||||
}
|
||||
},
|
||||
"local-registry": {
|
||||
"executor": "@nx/js:verdaccio",
|
||||
"options": {
|
||||
"port": 4873,
|
||||
"config": ".verdaccio/config.yml",
|
||||
"storage": "tmp/local-registry/storage"
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags": []
|
||||
|
@ -35,6 +35,14 @@
|
||||
"options": {
|
||||
"jestConfig": "libs/utils/jest.config.ts"
|
||||
}
|
||||
},
|
||||
"local-registry": {
|
||||
"executor": "@nx/js:verdaccio",
|
||||
"options": {
|
||||
"port": 4873,
|
||||
"config": ".verdaccio/config.yml",
|
||||
"storage": "tmp/local-registry/storage"
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags": []
|
||||
|
@ -35,6 +35,14 @@
|
||||
"options": {
|
||||
"jestConfig": "libs/wallet/jest.config.ts"
|
||||
}
|
||||
},
|
||||
"local-registry": {
|
||||
"executor": "@nx/js:verdaccio",
|
||||
"options": {
|
||||
"port": 4873,
|
||||
"config": ".verdaccio/config.yml",
|
||||
"storage": "tmp/local-registry/storage"
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags": []
|
||||
|
@ -241,8 +241,5 @@
|
||||
"graphql": "15.8.0",
|
||||
"//": "workaround storybook issue: https://github.com/storybookjs/storybook/issues/21642",
|
||||
"@storybook/react-docgen-typescript-plugin": "1.0.6--canary.9.cd77847.0"
|
||||
},
|
||||
"nx": {
|
||||
"includedScripts": []
|
||||
}
|
||||
}
|
||||
|
14
project.json
14
project.json
@ -1,14 +0,0 @@
|
||||
{
|
||||
"name": "nx-monorepo",
|
||||
"$schema": "node_modules/nx/schemas/project-schema.json",
|
||||
"targets": {
|
||||
"local-registry": {
|
||||
"executor": "@nx/js:verdaccio",
|
||||
"options": {
|
||||
"port": 4873,
|
||||
"config": ".verdaccio/config.yml",
|
||||
"storage": "tmp/local-registry/storage"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user