From cf18116ee9cadf07f324214e4ce48f4f47806a77 Mon Sep 17 00:00:00 2001 From: Madalina Raicu Date: Mon, 4 Mar 2024 17:10:56 +0000 Subject: [PATCH] feat(trading): update inputs --- apps/trading/.env | 14 +-- ...-tp-sl.tsx => deal-ticket-price-tp-sl.tsx} | 110 +++++++++++------- .../components/deal-ticket/deal-ticket.tsx | 5 +- .../utils/map-form-values-to-submission.ts | 4 +- 4 files changed, 81 insertions(+), 52 deletions(-) rename libs/deal-ticket/src/components/deal-ticket/{deal-ticket-size-tp-sl.tsx => deal-ticket-price-tp-sl.tsx} (50%) diff --git a/apps/trading/.env b/apps/trading/.env index 2c6c06afa..39e3202db 100644 --- a/apps/trading/.env +++ b/apps/trading/.env @@ -3,16 +3,17 @@ NX_ETHERSCAN_URL=https://sepolia.etherscan.io NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions NX_HOSTED_WALLET_URL=https://wallet.testnet.vega.xyz NX_SENTRY_DSN=https://2ffce43721964aafa78277c50654ece4@o286262.ingest.sentry.io/6300613 -NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks-internal/main/stagnet1/vegawallet-stagnet1.toml -NX_VEGA_ENV=STAGNET1 -NX_VEGA_EXPLORER_URL=https://explorer.stagnet1.vega.rocks +NX_VEGA_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/networks-internal/main/fairground/vegawallet-fairground.toml +NX_VEGA_ENV=TESTNET +NX_VEGA_EXPLORER_URL=https://explorer.fairground.wtf NX_VEGA_NETWORKS={\"MAINNET\":\"https://console.vega.xyz\",\"TESTNET\":\"https://console.fairground.wtf\",\"STAGNET1\":\"https://trading.stagnet1.vega.rocks\"} -NX_VEGA_TOKEN_URL=https://governance.stagnet1.vega.rocks +NX_VEGA_TOKEN_URL=https://governance.fairground.wtf NX_VEGA_WALLET_URL=http://localhost:1789 NX_VEGA_DOCS_URL=https://docs.vega.xyz/testnet NX_VEGA_REPO_URL=https://github.com/vegaprotocol/vega/releases NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json NX_VEGA_INCIDENT_URL=https://blog.vega.xyz/tagged/vega-incident-reports +NX_VEGA_CONSOLE_URL=https://console.fairground.wtf NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/en-GB/firefox/addon/vega-wallet-beta/ NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json @@ -25,11 +26,10 @@ NX_ISOLATED_MARGIN=true NX_ICEBERG_ORDERS=true NX_METAMASK_SNAPS=true NX_REFERRALS=true -# NX_DISABLE_CLOSE_POSITION=false NX_TEAM_COMPETITION=true -NX_TENDERMINT_URL=https://be.vega.community -NX_TENDERMINT_WEBSOCKET_URL=wss://be.vega.community/websocket +NX_TENDERMINT_URL=https://tm.be.testnet.vega.xyz +NX_TENDERMINT_WEBSOCKET_URL=wss://be.testnet.vega.xyz/websocket NX_CHARTING_LIBRARY_PATH=https://assets.vega.community/trading-view-bundle/v0.0.1/ NX_CHARTING_LIBRARY_HASH=PDjWaqPFndDp+LCvqbKvntWriaqNzNpZ5i9R/BULzCg= diff --git a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-size-tp-sl.tsx b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-price-tp-sl.tsx similarity index 50% rename from libs/deal-ticket/src/components/deal-ticket/deal-ticket-size-tp-sl.tsx rename to libs/deal-ticket/src/components/deal-ticket/deal-ticket-price-tp-sl.tsx index cd961d6b8..8a8d307e8 100644 --- a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-size-tp-sl.tsx +++ b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-price-tp-sl.tsx @@ -4,14 +4,17 @@ import type { OrderFormValues } from '../../hooks/use-form-values'; import { toDecimal, useValidateAmount } from '@vegaprotocol/utils'; import { TradingFormGroup, - TradingInput, TradingInputError, Tooltip, + FormGroup, + Input, + InputError, + Pill, } from '@vegaprotocol/ui-toolkit'; import { useT } from '../../use-t'; import { type Side } from '@vegaprotocol/types'; -export interface DealTicketSizeTakeProfitStopLossProps { +export interface DealTicketPriceTakeProfitStopLossProps { control: Control; market: Market; takeProfitError?: string; @@ -20,18 +23,20 @@ export interface DealTicketSizeTakeProfitStopLossProps { takeProfit?: string; stopLoss?: string; side?: Side; + quoteName?: string; } -export const DealTicketSizeTakeProfitStopLoss = ({ +export const DealTicketPriceTakeProfitStopLoss = ({ control, market, takeProfitError, stopLossError, + quoteName, setPrice, takeProfit, stopLoss, side, -}: DealTicketSizeTakeProfitStopLossProps) => { +}: DealTicketPriceTakeProfitStopLossProps) => { const t = useT(); const validateAmount = useValidateAmount(); const priceStep = toDecimal(market?.decimalPlaces); @@ -62,14 +67,12 @@ export const DealTicketSizeTakeProfitStopLoss = ({ return (
-
+
{t('The price at which you can take profit.')}
- } + description={
{t('The price for take profit.')}
} > {t('Take profit')} @@ -81,34 +84,46 @@ export const DealTicketSizeTakeProfitStopLoss = ({ name="takeProfit" control={control} rules={{ - required: t('You need to provide a take profit value'), + required: t('You need provide a take profit price'), min: { value: priceStep, - message: t('Take profit cannot be lower than {{value}}', { - value: priceStep, - }), + message: t( + 'Take profit price cannot be lower than {{priceStep}}', + { + priceStep, + } + ), }, validate: validateAmount(priceStep, 'takeProfit'), }} - render={({ field }) => ( - e.currentTarget.blur()} - {...field} - /> + render={({ field, fieldState }) => ( +
+ + {quoteName}} + className="w-full" + type="number" + step={priceStep} + data-testid="order-price-take-profit" + onWheel={(e) => e.currentTarget.blur()} + {...field} + /> + + {fieldState.error && ( + + {fieldState.error.message} + + )} +
)} />
-
-
-
-
( - e.currentTarget.blur()} - {...field} - /> + render={({ field, fieldState }) => ( +
+ + {quoteName}} + className="w-full" + type="number" + step={priceStep} + data-testid="order-price-stop-loss" + onWheel={(e) => e.currentTarget.blur()} + {...field} + /> + + {fieldState.error && ( + + {fieldState.error.message} + + )} +
)} />
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 281a9b5ae..32d021e56 100644 --- a/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx +++ b/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx @@ -80,7 +80,7 @@ import { isNonPersistentOrder } from '../../utils/time-in-force-persistence'; import { KeyValue } from './key-value'; import { DocsLinks } from '@vegaprotocol/environment'; import { useT } from '../../use-t'; -import { DealTicketSizeTakeProfitStopLoss } from './deal-ticket-size-tp-sl'; +import { DealTicketPriceTakeProfitStopLoss } from './deal-ticket-price-tp-sl'; export const REDUCE_ONLY_TOOLTIP = '"Reduce only" will ensure that this order will not increase the size of an open position. When the order is matched, it will only trade enough volume to bring your open volume towards 0 but never change the direction of your position. If applied to a limit order that is not instantly filled, the order will be stopped.'; @@ -756,7 +756,7 @@ export const DealTicket = ({ /> )} {tpSl && ( - )} diff --git a/libs/deal-ticket/src/utils/map-form-values-to-submission.ts b/libs/deal-ticket/src/utils/map-form-values-to-submission.ts index b3e59918c..0d37aeae2 100644 --- a/libs/deal-ticket/src/utils/map-form-values-to-submission.ts +++ b/libs/deal-ticket/src/utils/map-form-values-to-submission.ts @@ -181,7 +181,7 @@ export const mapFormValuesToTakeProfitAndStopLoss = ( mapFormValuesToStopOrdersSubmission( { ...formValues, - price: formValues.takeProfit, + ocoPrice: formValues.takeProfit, triggerDirection: formValues.side === Schema.Side.SIDE_SELL ? Schema.StopOrderTriggerDirection.TRIGGER_DIRECTION_FALLS_BELOW @@ -203,7 +203,7 @@ export const mapFormValuesToTakeProfitAndStopLoss = ( mapFormValuesToStopOrdersSubmission( { ...formValues, - price: formValues.stopLoss, + ocoPrice: formValues.stopLoss, triggerDirection: formValues.side === Schema.Side.SIDE_BUY ? Schema.StopOrderTriggerDirection.TRIGGER_DIRECTION_FALLS_BELOW