* chore: remove stagnet2, add stagnet3 * fix: types for transaction order submission (#932) * test: add night runs again (#917) Co-authored-by: Rado <rado@vegaprotocol.io> * chore: update tranches Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Feat/893 anchor per network param (#907) * feat: highlight network param targeted by anchor * Feat/893: Highlighted key-value row colours * Feat/893: Removed unneeded important bangs Co-authored-by: sam-keen <samuel.kleinmann@gmail.com> * Fix/687: Jump to block input should not allow negative block numbers or 0 (#918) * Fix/687: Jump to block input should not allow negative block numbers * Fix/687: Jump to block input should have a minimum of 1 * fix: text and theme icon colors (#920) * Fix/eager connection (#923) * fix: eager connect * chore: add comment for eslint disable * chore: update tranches Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: update tranches Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: update tranches Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: update tranches Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: update tranches Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: update tranches Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: update tranches Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: update tranches Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: update tranches Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: update tranches Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: update tranches Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Task/Remove vegawallet service api client (#916) * chore: remove generated vegawallet client code and implement in rest connector * feat: add zod validation * feat: handle specific auth/token delete case * feat: make withdraw dialog match vega tx dialog * fix: response stub to be right shape, add content type to requests * chore: revert unrelated classname change * feat: [console-lite] - fixes in order margin calcs (#891) * feat: [console-lite] - fixes in order margin calcs * feat: [console-lite] - fixes in order margin calcs - fix decimals * feat: [console-lite] - fixes in order margin calcs - add unit tests * feat: [console-lite] - fixes in order margin calcs - improve cals * feat: [console-lite] - fixes in order margin calcs - improve cals * feat: [console-lite] - fixes in order margin calcs - more improvements Co-authored-by: maciek <maciek@vegaprotocol.io> * fix: make check link unclickable while loading (#928) * fix: make check link unclickable while loading * fix: format * chore: update tranches Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * fix/904: Validators sorting (#913) * fix(790): gap between orderbook headers and tabs (#929) * feat: show correct reward type (#930) * chore: update tranches Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: update tranches Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: update tranches Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Task/remove vegawallet service (#926) * feat: improve error handling * chore: lint * fix: cypress test incorrect assertion * chore: update tranches Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: update tranches Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: update tranches Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * chore: update tranches Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * fix: order transaction types Co-authored-by: Radosław Szpiech <szpiechrados@gmail.com> Co-authored-by: Rado <rado@vegaprotocol.io> Co-authored-by: mattrussell36 <mattrussell36@users.noreply.github.com> Co-authored-by: Edd <edd@vega.xyz> Co-authored-by: sam-keen <samuel.kleinmann@gmail.com> Co-authored-by: Sam Keen <samuel@vegaprotocol.io> Co-authored-by: Matthew Russell <mattrussell36@gmail.com> Co-authored-by: macqbat <kubat.maciek@gmail.com> Co-authored-by: maciek <maciek@vegaprotocol.io> Co-authored-by: asiaznik <artur.siaznik@gmail.com> Co-authored-by: Dexter Edwards <dexter.edwards93@gmail.com> * test: fix test import * chore: resolve bad merge files * chore: begin enum changes * test: fix the majority of the tests * test: fix tests * style: lint * fix: update enums * fix: adjusted tests to updated enums * ci: bump capsule * fix: temporarily skip failing staking tests * ci: revert capsule changes * test: fix tests for stats * chore: merge few changes and api updates to stagnet3 updates branch (#1100) * chore: merge few changes and api updates to stagnet3 updates branch * chore: [console-lite] - fast fix in unit test Co-authored-by: maciek <maciek@vegaprotocol.io> * test: fix broken test * chore: change to use the new nodes rather than load balancer * style: formatting * style: formatting * chore: fix env file * fix: don't assume GQL URL path * fix: skip positions query if there is no part * fix: simple trading app test Co-authored-by: botond <105208209+notbot00@users.noreply.github.com> Co-authored-by: Radosław Szpiech <szpiechrados@gmail.com> Co-authored-by: Rado <rado@vegaprotocol.io> Co-authored-by: mattrussell36 <mattrussell36@users.noreply.github.com> Co-authored-by: Edd <edd@vega.xyz> Co-authored-by: sam-keen <samuel.kleinmann@gmail.com> Co-authored-by: Sam Keen <samuel@vegaprotocol.io> Co-authored-by: Matthew Russell <mattrussell36@gmail.com> Co-authored-by: macqbat <kubat.maciek@gmail.com> Co-authored-by: maciek <maciek@vegaprotocol.io> Co-authored-by: asiaznik <artur.siaznik@gmail.com> Co-authored-by: Joe <joe@vega.xyz> Co-authored-by: m.ray <16125548+MadalinaRaicu@users.noreply.github.com>
202 lines
5.8 KiB
TypeScript
202 lines
5.8 KiB
TypeScript
import type { ReactNode } from 'react';
|
|
import {
|
|
t,
|
|
getDateTimeFormat,
|
|
addDecimalsFormatNumber,
|
|
} from '@vegaprotocol/react-helpers';
|
|
import { Link } from '@vegaprotocol/ui-toolkit';
|
|
import { MarketTradingMode, AuctionTrigger } from '@vegaprotocol/types';
|
|
import type { Market_market } from '../../pages/markets/__generated__/Market';
|
|
|
|
type MarketDataGridProps = {
|
|
grid: {
|
|
label: string;
|
|
value?: ReactNode;
|
|
isEstimate?: boolean;
|
|
}[];
|
|
};
|
|
|
|
const MarketDataGrid = ({ grid }: MarketDataGridProps) => {
|
|
return (
|
|
<>
|
|
{grid.map(
|
|
({ label, value, isEstimate }, index) =>
|
|
value && (
|
|
<div key={index} className="grid grid-cols-2">
|
|
<span data-testid="tooltip-label">{label}</span>
|
|
<span data-testid="tooltip-value">
|
|
{isEstimate && <span className="ml-[-0.625em]">{'~'}</span>}
|
|
{value}
|
|
</span>
|
|
</div>
|
|
)
|
|
)}
|
|
</>
|
|
);
|
|
};
|
|
|
|
const formatStake = (value: string, market: Market_market) => {
|
|
const formattedValue = addDecimalsFormatNumber(
|
|
value,
|
|
market.positionDecimalPlaces
|
|
);
|
|
const asset =
|
|
market.tradableInstrument.instrument.product.settlementAsset.symbol;
|
|
return `${formattedValue} ${asset}`;
|
|
};
|
|
|
|
const compileGridData = (market: Market_market) => {
|
|
const grid: MarketDataGridProps['grid'] = [];
|
|
const isLiquidityMonitoringAuction =
|
|
market.tradingMode === MarketTradingMode.TRADING_MODE_MONITORING_AUCTION &&
|
|
market.data?.trigger === AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY;
|
|
|
|
if (!market.data) return grid;
|
|
|
|
if (market.data?.auctionStart) {
|
|
grid.push({
|
|
label: t('Auction start'),
|
|
value: getDateTimeFormat().format(new Date(market.data.auctionStart)),
|
|
});
|
|
}
|
|
|
|
if (market.data?.auctionEnd) {
|
|
grid.push({
|
|
label: isLiquidityMonitoringAuction
|
|
? t('Est auction end')
|
|
: t('Auction end'),
|
|
value: getDateTimeFormat().format(new Date(market.data.auctionEnd)),
|
|
isEstimate: isLiquidityMonitoringAuction ? true : false,
|
|
});
|
|
}
|
|
|
|
if (isLiquidityMonitoringAuction && market.data?.targetStake) {
|
|
grid.push({
|
|
label: t('Target liquidity'),
|
|
value: formatStake(market.data.targetStake, market),
|
|
});
|
|
}
|
|
|
|
if (isLiquidityMonitoringAuction && market.data?.suppliedStake) {
|
|
grid.push({
|
|
label: t('Current liquidity'),
|
|
// @TODO: link this to liquidity view when https://github.com/vegaprotocol/frontend-monorepo/issues/491 is done
|
|
value: formatStake(market.data.suppliedStake, market),
|
|
});
|
|
}
|
|
|
|
if (market.data?.indicativePrice) {
|
|
grid.push({
|
|
label: t('Est uncrossing price'),
|
|
value: addDecimalsFormatNumber(
|
|
market.data.indicativePrice,
|
|
market.positionDecimalPlaces
|
|
),
|
|
isEstimate: true,
|
|
});
|
|
}
|
|
|
|
if (market.data?.indicativeVolume) {
|
|
grid.push({
|
|
label: t('Est uncrossing vol'),
|
|
value: addDecimalsFormatNumber(
|
|
market.data.indicativeVolume,
|
|
market.positionDecimalPlaces
|
|
),
|
|
isEstimate: true,
|
|
});
|
|
}
|
|
|
|
return grid;
|
|
};
|
|
|
|
type TradingModeTooltipProps = {
|
|
market: Market_market;
|
|
};
|
|
|
|
export const TradingModeTooltip = ({ market }: TradingModeTooltipProps) => {
|
|
switch (market.tradingMode) {
|
|
case MarketTradingMode.TRADING_MODE_CONTINUOUS: {
|
|
return (
|
|
<>
|
|
{t(
|
|
'This is the standard trading mode where trades are executed whenever orders are received.'
|
|
)}
|
|
</>
|
|
);
|
|
}
|
|
case MarketTradingMode.TRADING_MODE_OPENING_AUCTION: {
|
|
return (
|
|
<>
|
|
<p className="mb-16">
|
|
<span>
|
|
{t(
|
|
'This new market is in an opening auction to determine a fair mid-price before starting continuous trading.'
|
|
)}
|
|
</span>{' '}
|
|
<Link
|
|
href="https://docs.fairground.vega.xyz/docs/trading-questions/#auctions-what-happens-in-an-opening-auction"
|
|
target="_blank"
|
|
>
|
|
{t('Find out more')}
|
|
</Link>
|
|
</p>
|
|
<MarketDataGrid grid={compileGridData(market)} />
|
|
</>
|
|
);
|
|
}
|
|
case MarketTradingMode.TRADING_MODE_MONITORING_AUCTION: {
|
|
switch (market.data?.trigger) {
|
|
case AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY: {
|
|
return (
|
|
<>
|
|
<p data-testid="tooltip-market-info" className="mb-16">
|
|
<span>
|
|
{t(
|
|
'This market is in auction until it reaches sufficient liquidity.'
|
|
)}
|
|
</span>{' '}
|
|
<Link
|
|
href="https://docs.fairground.vega.xyz/docs/trading-questions/#auctions-what-is-a-liquidity-monitoring-auction"
|
|
target="_blank"
|
|
>
|
|
{t('Find out more')}
|
|
</Link>
|
|
</p>
|
|
<MarketDataGrid grid={compileGridData(market)} />
|
|
</>
|
|
);
|
|
}
|
|
case AuctionTrigger.AUCTION_TRIGGER_PRICE: {
|
|
return (
|
|
<>
|
|
<p className="mb-16">
|
|
<span>
|
|
{t('This market is in auction due to high price volatility.')}
|
|
</span>{' '}
|
|
<Link
|
|
href="https://docs.fairground.vega.xyz/docs/trading-questions/#auctions-what-is-a-price-monitoring-auction"
|
|
target="_blank"
|
|
>
|
|
{t('Find out more')}
|
|
</Link>
|
|
</p>
|
|
<MarketDataGrid grid={compileGridData(market)} />
|
|
</>
|
|
);
|
|
}
|
|
default: {
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
case MarketTradingMode.TRADING_MODE_NO_TRADING: {
|
|
return <>{t('No trading enabled for this market.')}</>;
|
|
}
|
|
case MarketTradingMode.TRADING_MODE_BATCH_AUCTION:
|
|
default: {
|
|
return null;
|
|
}
|
|
}
|
|
};
|