diff --git a/apps/trading/client-pages/market/market-header-stats.tsx b/apps/trading/client-pages/market/market-header-stats.tsx index 2b6c05f24..d37ef09f0 100644 --- a/apps/trading/client-pages/market/market-header-stats.tsx +++ b/apps/trading/client-pages/market/market-header-stats.tsx @@ -1,7 +1,6 @@ import { useAssetDetailsDialogStore } from '@vegaprotocol/assets'; import { DocsLinks, useEnvironment } from '@vegaprotocol/environment'; import { ButtonLink, ExternalLink, Link } from '@vegaprotocol/ui-toolkit'; -import { MarketProposalNotification } from '@vegaprotocol/proposals'; import type { Market } from '@vegaprotocol/markets'; import { addDecimalsFormatNumber, @@ -145,7 +144,6 @@ export const MarketHeaderStats = ({ market }: MarketHeaderStatsProps) => { /> )} - ); }; diff --git a/apps/trading/client-pages/referrals/hooks/use-referral-program.ts b/apps/trading/client-pages/referrals/hooks/use-referral-program.ts index 7a1a6cc76..d501c0161 100644 --- a/apps/trading/client-pages/referrals/hooks/use-referral-program.ts +++ b/apps/trading/client-pages/referrals/hooks/use-referral-program.ts @@ -75,22 +75,20 @@ export const useReferralProgram = () => { const benefitTiers = sortBy(data.currentReferralProgram.benefitTiers, (t) => Number(t.referralRewardFactor) - ) - .reverse() - .map((t, i) => { - return { - tier: i + 1, - rewardFactor: Number(t.referralRewardFactor), - commission: Number(t.referralRewardFactor) * 100 + '%', - discountFactor: Number(t.referralDiscountFactor), - discount: Number(t.referralDiscountFactor) * 100 + '%', - minimumVolume: Number(t.minimumRunningNotionalTakerVolume), - volume: getNumberFormat(0).format( - Number(t.minimumRunningNotionalTakerVolume) - ), - epochs: Number(t.minimumEpochs), - }; - }); + ).map((t, i) => { + return { + tier: i + 1, // sorted in asc order, hence first is the lowest tier + rewardFactor: Number(t.referralRewardFactor), + commission: Number(t.referralRewardFactor) * 100 + '%', + discountFactor: Number(t.referralDiscountFactor), + discount: Number(t.referralDiscountFactor) * 100 + '%', + minimumVolume: Number(t.minimumRunningNotionalTakerVolume), + volume: getNumberFormat(0).format( + Number(t.minimumRunningNotionalTakerVolume) + ), + epochs: Number(t.minimumEpochs), + }; + }); const stakingTiers = sortBy( data.currentReferralProgram.stakingTiers, diff --git a/apps/trading/client-pages/referrals/referral-statistics.tsx b/apps/trading/client-pages/referrals/referral-statistics.tsx index 0638504c3..419a317c5 100644 --- a/apps/trading/client-pages/referrals/referral-statistics.tsx +++ b/apps/trading/client-pages/referrals/referral-statistics.tsx @@ -1,3 +1,4 @@ +import minBy from 'lodash/minBy'; import { CodeTile, StatTile } from './tile'; import { VegaIcon, @@ -28,7 +29,6 @@ import sortBy from 'lodash/sortBy'; import { useLayoutEffect, useMemo, useRef, useState } from 'react'; import { useCurrentEpochInfoQuery } from './hooks/__generated__/Epoch'; import BigNumber from 'bignumber.js'; -import maxBy from 'lodash/maxBy'; import { DocsLinks } from '@vegaprotocol/environment'; import { useT, ns } from '../../lib/use-t'; import { Trans } from 'react-i18next'; @@ -128,7 +128,7 @@ export const useStats = ({ ); const nextBenefitTierValue = currentBenefitTierValue ? benefitTiers.find((t) => t.tier === currentBenefitTierValue.tier - 1) - : maxBy(benefitTiers, (bt) => bt.tier); // max tier number is lowest tier + : minBy(benefitTiers, (bt) => bt.tier); // min tier number is lowest tier const epochsValue = !isNaN(currentEpoch) && refereeInfo?.atEpoch ? currentEpoch - refereeInfo?.atEpoch diff --git a/apps/trading/client-pages/referrals/tiers.tsx b/apps/trading/client-pages/referrals/tiers.tsx index 113137ccd..cea2f8a24 100644 --- a/apps/trading/client-pages/referrals/tiers.tsx +++ b/apps/trading/client-pages/referrals/tiers.tsx @@ -218,13 +218,13 @@ const TiersTable = ({ ...d, className: classNames({ 'from-vega-pink-400 dark:from-vega-pink-600 to-20% bg-highlight': - d.tier === 1, + d.tier >= 3, 'from-vega-purple-400 dark:from-vega-purple-600 to-20% bg-highlight': d.tier === 2, 'from-vega-blue-400 dark:from-vega-blue-600 to-20% bg-highlight': - d.tier === 3, + d.tier === 1, 'from-vega-orange-400 dark:from-vega-orange-600 to-20% bg-highlight': - d.tier > 3, + d.tier == 0, }), }))} /> diff --git a/apps/trading/components/fees-container/fees-container.tsx b/apps/trading/components/fees-container/fees-container.tsx index 0347afc21..dd0db6d06 100644 --- a/apps/trading/components/fees-container/fees-container.tsx +++ b/apps/trading/components/fees-container/fees-container.tsx @@ -36,7 +36,7 @@ export const FeesContainer = () => { const { data: markets, loading: marketsLoading } = useMarketList(); const { data: programData, loading: programLoading } = - useDiscountProgramsQuery(); + useDiscountProgramsQuery({ errorPolicy: 'ignore' }); const volumeDiscountWindowLength = programData?.currentVolumeDiscountProgram?.windowLength || 1; @@ -459,25 +459,19 @@ const VolumeTiers = ({ - {Array.from(tiers) - .reverse() - .map((tier, i) => { - const isUserTier = tiers.length - 1 - tierIndex === i; + {Array.from(tiers).map((tier, i) => { + const isUserTier = tiers.length - 1 - tierIndex === i; - return ( - - {i + 1} - - {formatPercentage(Number(tier.volumeDiscountFactor))}% - - - {formatNumber(tier.minimumRunningNotionalTakerVolume)} - - {isUserTier ? formatNumber(lastEpochVolume) : ''} - {isUserTier ? : null} - - ); - })} + return ( + + {i + 1} + {formatPercentage(Number(tier.volumeDiscountFactor))}% + {formatNumber(tier.minimumRunningNotionalTakerVolume)} + {isUserTier ? formatNumber(lastEpochVolume) : ''} + {isUserTier ? : null} + + ); + })} @@ -520,37 +514,33 @@ const ReferralTiers = ({ - {Array.from(tiers) - .reverse() - .map((t, i) => { - const isUserTier = tiers.length - 1 - tierIndex === i; + {Array.from(tiers).map((t, i) => { + const isUserTier = tiers.length - 1 - tierIndex === i; - const requiredVolume = Number( - t.minimumRunningNotionalTakerVolume + const requiredVolume = Number(t.minimumRunningNotionalTakerVolume); + let unlocksIn = null; + + if ( + referralVolumeInWindow >= requiredVolume && + epochsInSet < t.minimumEpochs + ) { + unlocksIn = ( + + Unlocks in {t.minimumEpochs - epochsInSet} epochs + ); - let unlocksIn = null; + } - if ( - referralVolumeInWindow >= requiredVolume && - epochsInSet < t.minimumEpochs - ) { - unlocksIn = ( - - Unlocks in {t.minimumEpochs - epochsInSet} epochs - - ); - } - - return ( - - {i + 1} - {formatPercentage(Number(t.referralDiscountFactor))}% - {formatNumber(t.minimumRunningNotionalTakerVolume)} - {t.minimumEpochs} - {isUserTier ? : unlocksIn} - - ); - })} + return ( + + {i + 1} + {formatPercentage(Number(t.referralDiscountFactor))}% + {formatNumber(t.minimumRunningNotionalTakerVolume)} + {t.minimumEpochs} + {isUserTier ? : unlocksIn} + + ); + })} diff --git a/libs/datagrid/src/lib/ag-grid/ag-grid-themed.tsx b/libs/datagrid/src/lib/ag-grid/ag-grid-themed.tsx index 7d6147f9d..a4288c1b7 100644 --- a/libs/datagrid/src/lib/ag-grid/ag-grid-themed.tsx +++ b/libs/datagrid/src/lib/ag-grid/ag-grid-themed.tsx @@ -36,6 +36,9 @@ export const AgGridThemed = ({
{ if (!value) return '-'; - const newValue = new BigNumber(value) - .times(Number(stakeToCcyVolume) || 1) - .toString(); let lessThanFull = false, lessThanMinimum = false; if (data.sla) { @@ -154,7 +151,7 @@ export const LiquidityTable = ({ } ); } - return addDecimalsFormatNumber(newValue, assetDecimalPlaces ?? 0); + return addDecimalsFormatNumber(value, assetDecimalPlaces ?? 0); }; const stakeToCcyVolumeQuantumFormatter = ({ diff --git a/libs/proposals/src/components/market-proposal-notification.tsx b/libs/proposals/src/components/market-proposal-notification.tsx index a09e7fede..a591ff92b 100644 --- a/libs/proposals/src/components/market-proposal-notification.tsx +++ b/libs/proposals/src/components/market-proposal-notification.tsx @@ -30,7 +30,7 @@ export const MarketProposalNotification = ({
); return ( -
+