From 82df401611d4471d8a9871511224969ed2ad8b29 Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Fri, 1 Mar 2024 17:22:17 -0500 Subject: [PATCH 1/4] fix(governance): incorrect penalty information in validators table and page (#5896) --- .../consensus-validators-table.spec.tsx | 2 +- .../consensus-validators-table.tsx | 16 +++++++++--- .../staking/home/validator-tables/shared.tsx | 11 ++++---- .../routes/staking/node/validator-table.tsx | 26 +++++++------------ 4 files changed, 29 insertions(+), 26 deletions(-) diff --git a/apps/governance/src/routes/staking/home/validator-tables/consensus-validators-table.spec.tsx b/apps/governance/src/routes/staking/home/validator-tables/consensus-validators-table.spec.tsx index d11d729b7..bae509c58 100644 --- a/apps/governance/src/routes/staking/home/validator-tables/consensus-validators-table.spec.tsx +++ b/apps/governance/src/routes/staking/home/validator-tables/consensus-validators-table.spec.tsx @@ -288,7 +288,7 @@ describe('Consensus validators table', () => { expect( grid.querySelector('[role="gridcell"][col-id="totalPenalties"]') - ).toHaveTextContent('13.16%'); + ).toHaveTextContent('10.07%'); expect( grid.querySelector('[role="gridcell"][col-id="normalisedVotingPower"]') diff --git a/apps/governance/src/routes/staking/home/validator-tables/consensus-validators-table.tsx b/apps/governance/src/routes/staking/home/validator-tables/consensus-validators-table.tsx index 63272683f..915d7f394 100644 --- a/apps/governance/src/routes/staking/home/validator-tables/consensus-validators-table.tsx +++ b/apps/governance/src/routes/staking/home/validator-tables/consensus-validators-table.tsx @@ -185,15 +185,19 @@ export const ConsensusValidatorsTable = ({ const { rawValidatorScore: previousEpochValidatorScore } = getLastEpochScoreAndPerformance(previousEpochData, id); - const overstakingPenalty = calculateOverallPenalty( + const overstakingPenalty = calculateOverstakedPenalty( id, allNodesInPreviousEpoch ); - const totalPenalty = calculateOverstakedPenalty( + const totalPenalty = calculateOverallPenalty( id, allNodesInPreviousEpoch ); + const lastEpochDataForNode = allNodesInPreviousEpoch.find( + (node) => node.id === id + ); + return { id, [ValidatorFields.RANKING_INDEX]: stakedTotalRanking, @@ -239,6 +243,12 @@ export const ConsensusValidatorsTable = ({ : undefined, [ValidatorFields.MULTISIG_ERROR]: multisigStatus?.showMultisigStatusError, + [ValidatorFields.MULTISIG_PENALTY]: formatNumberPercentage( + new BigNumber(1) + .minus(lastEpochDataForNode?.rewardScore?.multisigScore ?? 1) + .times(100), + 2 + ), }; } ); @@ -378,7 +388,6 @@ export const ConsensusValidatorsTable = ({ headerTooltip: t('StakeDescription').toString(), cellRenderer: TotalStakeRenderer, width: 120, - sort: 'desc', }, { field: ValidatorFields.PENDING_STAKE, @@ -400,6 +409,7 @@ export const ConsensusValidatorsTable = ({ headerTooltip: t('NormalisedVotingPowerDescription').toString(), cellRenderer: VotingPowerRenderer, width: 120, + sort: 'desc', }, { field: ValidatorFields.TOTAL_PENALTIES, diff --git a/apps/governance/src/routes/staking/home/validator-tables/shared.tsx b/apps/governance/src/routes/staking/home/validator-tables/shared.tsx index 1abc3f8d3..fd804ce2e 100644 --- a/apps/governance/src/routes/staking/home/validator-tables/shared.tsx +++ b/apps/governance/src/routes/staking/home/validator-tables/shared.tsx @@ -40,6 +40,7 @@ export enum ValidatorFields { PENDING_USER_STAKE = 'pendingUserStake', USER_STAKE_SHARE = 'userStakeShare', MULTISIG_ERROR = 'multisigError', + MULTISIG_PENALTY = 'multisigPenalty', } export const addUserDataToValidator = ( @@ -327,7 +328,7 @@ interface TotalPenaltiesRendererProps { overstakedAmount: string; overstakingPenalty: string; totalPenalties: string; - multisigError?: boolean; + multisigPenalty: string; }; } @@ -346,11 +347,9 @@ export const TotalPenaltiesRenderer = ({
{t('overstakedPenalty')}: {data.overstakingPenalty}
- {data.multisigError && ( -
- {t('multisigPenalty')}: 100% -
- )} +
+ {t('multisigPenalty')}: {data.multisigPenalty} +
} > diff --git a/apps/governance/src/routes/staking/node/validator-table.tsx b/apps/governance/src/routes/staking/node/validator-table.tsx index 7c0c79a19..550052796 100644 --- a/apps/governance/src/routes/staking/node/validator-table.tsx +++ b/apps/governance/src/routes/staking/node/validator-table.tsx @@ -37,7 +37,6 @@ import { import type { ReactNode } from 'react'; import type { StakingNodeFieldsFragment } from '../__generated__/Staking'; import type { PreviousEpochQuery } from '../__generated__/PreviousEpoch'; -import { getMultisigStatusInfo } from '../../../lib/get-multisig-status-info'; const statuses = { [Schema.ValidatorStatus.VALIDATOR_NODE_STATUS_ERSATZ]: 'status-ersatz', @@ -105,9 +104,10 @@ export const ValidatorTable = ({ }; }, [node, previousEpochData?.epoch.validatorsConnection?.edges]); - const multisigStatus = previousEpochData - ? getMultisigStatusInfo(previousEpochData) - : undefined; + const previousNodeData = + previousEpochData?.epoch.validatorsConnection?.edges?.find( + (e) => e?.node.id === node.id + ); return ( <> @@ -293,21 +293,15 @@ export const ValidatorTable = ({ data-testid="multisig-penalty" className="flex gap-2 items-baseline" > - {multisigStatus?.zeroScoreNodes.find( - (n) => n.id === node.id - ) ? ( - - - - ) : null} {formatNumberPercentage( - BigNumber( - multisigStatus?.showMultisigStatusError ? 100 : 0 - ), + new BigNumber(1) + .minus( + previousNodeData?.node.rewardScore?.multisigScore ?? + 1 + ) + .times(100), 2 )} From b163af3e8ad0031318c8969350f317016ee1b142 Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Mon, 4 Mar 2024 13:00:54 -0500 Subject: [PATCH 2/4] fix(trading): 24hr price and volume in header (#5908) --- libs/i18n/src/locales/en/markets.json | 5 -- .../last-24h-price-change.tsx | 57 +------------- .../last-24h-volume/last-24h-volume.tsx | 78 ------------------- libs/markets/src/lib/hooks/use-candles.ts | 9 +-- 4 files changed, 3 insertions(+), 146 deletions(-) diff --git a/libs/i18n/src/locales/en/markets.json b/libs/i18n/src/locales/en/markets.json index d9c51d509..37658239e 100644 --- a/libs/i18n/src/locales/en/markets.json +++ b/libs/i18n/src/locales/en/markets.json @@ -1,8 +1,6 @@ { "{{liquidityPriceRange}} of mid price": "{{liquidityPriceRange}} of mid price", "{{probability}} probability price bounds": "{{probability}} probability price bounds", - "24 hour change is unavailable at this time. The price change in the last 120 hours is:": "24 hour change is unavailable at this time. The price change in the last 120 hours is:", - "24 hour change is unavailable at this time. The volume change in the last 120 hours is {{candleVolumeValue}} for a total of {{candleVolumePrice}} {{quoteUnit}}": "24 hour change is unavailable at this time. The volume change in the last 120 hours is {{candleVolumeValue}} for a total of {{candleVolumePrice}} {{quoteUnit}}", "A concept derived from traditional markets. It is a calculated value for the ‘current market price’ on a market.": "A concept derived from traditional markets. It is a calculated value for the ‘current market price’ on a market.", "A number that will be calculated by an appropriate stochastic risk model, dependent on the type of risk model used and its parameters.": "A number that will be calculated by an appropriate stochastic risk model, dependent on the type of risk model used and its parameters.", "A sliding penalty for how much an LP bond is slashed if an LP fails to reach the minimum SLA. This is a network parameter.": "A sliding penalty for how much an LP bond is slashed if an LP fails to reach the minimum SLA. This is a network parameter.", @@ -51,9 +49,6 @@ "Market": "Market", "Market data": "Market data", "Market governance": "Market governance", - "Market has not been active for 24 hours. The price change between {{start}} and {{end}} is:": "Market has not been active for 24 hours. The price change between {{start}} and {{end}} is:", - "Market has not been active for 24 hours. The volume traded between {{start}} and {{end}} is:": "Market has not been active for 24 hours. The volume traded between {{start}} and {{end}} is:", - "Market has not been active for 24 hours. The volume traded between {{start}} and {{end}} is {{candleVolumeValue}} for a total of {{candleVolumePrice}} {{quoteUnit}}": "Market has not been active for 24 hours. The volume traded between {{start}} and {{end}} is {{candleVolumeValue}} for a total of {{candleVolumePrice}} {{quoteUnit}}", "Market ID": "Market ID", "Market price": "Market price", "Market specification": "Market specification", diff --git a/libs/markets/src/lib/components/last-24h-price-change/last-24h-price-change.tsx b/libs/markets/src/lib/components/last-24h-price-change/last-24h-price-change.tsx index 4d1a9d4d7..0eb29029f 100644 --- a/libs/markets/src/lib/components/last-24h-price-change/last-24h-price-change.tsx +++ b/libs/markets/src/lib/components/last-24h-price-change/last-24h-price-change.tsx @@ -2,16 +2,14 @@ import { type ReactNode } from 'react'; import { addDecimalsFormatNumber, formatNumberPercentage, - getDateTimeFormat, priceChange, priceChangePercentage, } from '@vegaprotocol/utils'; -import { PriceChangeCell, signedNumberCssClass } from '@vegaprotocol/datagrid'; -import { Tooltip, VegaIcon, VegaIconNames } from '@vegaprotocol/ui-toolkit'; +import { signedNumberCssClass } from '@vegaprotocol/datagrid'; +import { VegaIcon, VegaIconNames } from '@vegaprotocol/ui-toolkit'; import { useCandles } from '../../hooks/use-candles'; import BigNumber from 'bignumber.js'; import classNames from 'classnames'; -import { useT } from '../../use-t'; interface Props { marketId?: string; @@ -24,7 +22,6 @@ export const Last24hPriceChange = ({ decimalPlaces, fallback, }: Props) => { - const t = useT(); const { oneDayCandles, fiveDaysCandles, error } = useCandles({ marketId, }); @@ -35,56 +32,6 @@ export const Last24hPriceChange = ({ return nonIdeal; } - if (fiveDaysCandles.length < 24) { - return ( - - {t( - 'Market has not been active for 24 hours. The price change between {{start}} and {{end}} is:', - { - start: getDateTimeFormat().format( - new Date(fiveDaysCandles[0].periodStart) - ), - end: getDateTimeFormat().format( - new Date( - fiveDaysCandles[fiveDaysCandles.length - 1].periodStart - ) - ), - } - )} - c.close) || []} - decimalPlaces={decimalPlaces} - /> - - } - > - {nonIdeal} - - ); - } - - if (oneDayCandles.length < 24) { - return ( - - {t( - '24 hour change is unavailable at this time. The price change in the last 120 hours is:' - )}{' '} - c.close) || []} - decimalPlaces={decimalPlaces} - /> - - } - > - {nonIdeal} - - ); - } - const candles = oneDayCandles?.map((c) => c.close) || []; const change = priceChange(candles); const changePercentage = priceChangePercentage(candles); diff --git a/libs/markets/src/lib/components/last-24h-volume/last-24h-volume.tsx b/libs/markets/src/lib/components/last-24h-volume/last-24h-volume.tsx index c8b1f24cd..354f427c9 100644 --- a/libs/markets/src/lib/components/last-24h-volume/last-24h-volume.tsx +++ b/libs/markets/src/lib/components/last-24h-volume/last-24h-volume.tsx @@ -2,7 +2,6 @@ import { calcCandleVolume, calcCandleVolumePrice } from '../../market-utils'; import { addDecimalsFormatNumber, formatNumber, - getDateTimeFormat, isNumeric, } from '@vegaprotocol/utils'; import { Tooltip } from '@vegaprotocol/ui-toolkit'; @@ -37,83 +36,6 @@ export const Last24hVolume = ({ return nonIdeal; } - if (fiveDaysCandles.length < 24) { - const candleVolume = calcCandleVolume(fiveDaysCandles); - const candleVolumePrice = calcCandleVolumePrice( - fiveDaysCandles, - marketDecimals, - positionDecimalPlaces - ); - const candleVolumeValue = - candleVolume && isNumeric(positionDecimalPlaces) - ? addDecimalsFormatNumber( - candleVolume, - positionDecimalPlaces, - formatDecimals - ) - : '-'; - return ( - - - {t( - 'Market has not been active for 24 hours. The volume traded between {{start}} and {{end}} is {{candleVolumeValue}} for a total of {{candleVolumePrice}} {{quoteUnit}}', - { - start: getDateTimeFormat().format( - new Date(fiveDaysCandles[0].periodStart) - ), - end: getDateTimeFormat().format( - new Date( - fiveDaysCandles[fiveDaysCandles.length - 1].periodStart - ) - ), - candleVolumeValue, - candleVolumePrice, - quoteUnit, - } - )} - - - } - > - {nonIdeal} - - ); - } - - if (oneDayCandles.length < 24) { - const candleVolume = calcCandleVolume(fiveDaysCandles); - const candleVolumePrice = calcCandleVolumePrice( - fiveDaysCandles, - marketDecimals, - positionDecimalPlaces - ); - const candleVolumeValue = - candleVolume && isNumeric(positionDecimalPlaces) - ? addDecimalsFormatNumber( - candleVolume, - positionDecimalPlaces, - formatDecimals - ) - : '-'; - return ( - - - {t( - '24 hour change is unavailable at this time. The volume change in the last 120 hours is {{candleVolumeValue}} for a total of ({{candleVolumePrice}} {{quoteUnit}})', - { candleVolumeValue, candleVolumePrice, quoteUnit } - )} - - - } - > - {nonIdeal} - - ); - } const candleVolume = oneDayCandles ? calcCandleVolume(oneDayCandles) : initialValue; diff --git a/libs/markets/src/lib/hooks/use-candles.ts b/libs/markets/src/lib/hooks/use-candles.ts index d22adc991..0916b7945 100644 --- a/libs/markets/src/lib/hooks/use-candles.ts +++ b/libs/markets/src/lib/hooks/use-candles.ts @@ -8,7 +8,7 @@ export const useCandles = ({ marketId }: { marketId?: string }) => { const fiveDaysAgo = useFiveDaysAgo(); const yesterday = useYesterday(); const since = new Date(fiveDaysAgo).toISOString(); - const { data, error } = useThrottledDataProvider({ + const { data: fiveDaysCandles, error } = useThrottledDataProvider({ dataProvider: marketCandlesProvider, variables: { marketId: marketId || '', @@ -18,13 +18,6 @@ export const useCandles = ({ marketId }: { marketId?: string }) => { skip: !marketId, }); - const fiveDaysCandles = data?.filter((c) => { - if (c.open === '' || c.close === '' || c.high === '' || c.close === '') { - return false; - } - return true; - }); - const oneDayCandles = fiveDaysCandles?.filter((candle) => isCandleLessThan24hOld(candle, yesterday) ); From bbfe42ddb14d94dd8bbfc0df24ee4d5dbfc93d25 Mon Sep 17 00:00:00 2001 From: Art Date: Mon, 4 Mar 2024 19:09:52 +0100 Subject: [PATCH 3/4] fix(governance): rewards moved to console notification (#5904) --- .../rewards-moved-notification.tsx | 44 +++++++++++++++++++ .../components/page-templates/app-layout.tsx | 3 ++ libs/environment/src/hooks/use-links.ts | 1 + libs/i18n/src/locales/en/governance.json | 3 +- 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 apps/governance/src/components/notifications/rewards-moved-notification.tsx diff --git a/apps/governance/src/components/notifications/rewards-moved-notification.tsx b/apps/governance/src/components/notifications/rewards-moved-notification.tsx new file mode 100644 index 000000000..7c669e6b5 --- /dev/null +++ b/apps/governance/src/components/notifications/rewards-moved-notification.tsx @@ -0,0 +1,44 @@ +import { + useLinks, + DApp, + CONSOLE_REWARDS_PAGE, +} from '@vegaprotocol/environment'; +import { + ExternalLink, + Intent, + NotificationBanner, + VegaIcon, + VegaIconNames, +} from '@vegaprotocol/ui-toolkit'; +import { Trans } from 'react-i18next'; +import { useMatch } from 'react-router-dom'; +import Routes from '../../routes/routes'; +import { type ReactNode } from 'react'; + +const ConsoleRewardsLink = ({ children }: { children: ReactNode }) => { + const consoleLink = useLinks(DApp.Console); + return ( + + {children} + + + ); +}; + +export const RewardsMovedNotification = () => { + const onRewardsPage = useMatch(Routes.REWARDS); + if (!onRewardsPage) return null; + + return ( + + Console]} + /> + + ); +}; diff --git a/apps/governance/src/components/page-templates/app-layout.tsx b/apps/governance/src/components/page-templates/app-layout.tsx index 66f9bf9f1..c1171532d 100644 --- a/apps/governance/src/components/page-templates/app-layout.tsx +++ b/apps/governance/src/components/page-templates/app-layout.tsx @@ -10,6 +10,7 @@ import { ProtocolUpgradeProposalNotification, } from '@vegaprotocol/proposals'; import { ViewingAsBanner } from '@vegaprotocol/ui-toolkit'; +import { RewardsMovedNotification } from '../notifications/rewards-moved-notification'; interface AppLayoutProps { children: ReactNode; @@ -45,8 +46,10 @@ export const AppLayout = ({ children }: AppLayoutProps) => { const NotificationsContainer = () => { const { isReadOnly, pubKey, disconnect } = useVegaWallet(); + return (
+ diff --git a/libs/environment/src/hooks/use-links.ts b/libs/environment/src/hooks/use-links.ts index ad860aba8..0a16bd5af 100644 --- a/libs/environment/src/hooks/use-links.ts +++ b/libs/environment/src/hooks/use-links.ts @@ -134,6 +134,7 @@ export const CONSOLE_TRANSFER = '#/portfolio/assets/transfer'; export const CONSOLE_TRANSFER_ASSET = '#/portfolio/assets/transfer?assetId=:assetId'; export const CONSOLE_MARKET_PAGE = '#/markets/:marketId'; +export const CONSOLE_REWARDS_PAGE = '#/rewards'; // Governance pages export const TOKEN_NEW_MARKET_PROPOSAL = '/proposals/propose/new-market'; diff --git a/libs/i18n/src/locales/en/governance.json b/libs/i18n/src/locales/en/governance.json index e540cefaf..60003b346 100644 --- a/libs/i18n/src/locales/en/governance.json +++ b/libs/i18n/src/locales/en/governance.json @@ -969,5 +969,6 @@ "YourIdentityAnonymous": "Your identity is always anonymous on Vega", "yourStake": "Your stake", "yourVote": "Your vote", - "youVoted": "You voted" + "youVoted": "You voted", + "rewardsMovedNotification": "Trading and liquidity rewards have moved. Visit <0>Console to view your rewards." } From 7ea7362a7d484d5fb19199f69709d98de7e33920 Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Mon, 4 Mar 2024 14:08:42 -0500 Subject: [PATCH 4/4] fix(trading): market into tab 24hr vol and price fix (#5910) Co-authored-by: bwallacee --- apps/trading/e2e/tests/market/test_market_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/trading/e2e/tests/market/test_market_info.py b/apps/trading/e2e/tests/market/test_market_info.py index 287f2ebe2..c5223a0ee 100644 --- a/apps/trading/e2e/tests/market/test_market_info.py +++ b/apps/trading/e2e/tests/market/test_market_info.py @@ -77,7 +77,7 @@ def test_market_info_market_volume(page: Page): page.get_by_test_id(market_title_test_id).get_by_text( "Market volume").click() fields = [ - ["24 Hour Volume", "-"], + ["24 Hour Volume", "0 (0 )"], ["Open Interest", "1"], ["Best Bid Volume", "99"], ["Best Offer Volume", "99"],