diff --git a/apps/trading/client-pages/rewards/index.ts b/apps/trading/client-pages/rewards/index.ts new file mode 100644 index 000000000..b41d3a1d5 --- /dev/null +++ b/apps/trading/client-pages/rewards/index.ts @@ -0,0 +1 @@ +export { Rewards } from './rewards'; diff --git a/apps/trading/client-pages/rewards/rewards.tsx b/apps/trading/client-pages/rewards/rewards.tsx new file mode 100644 index 000000000..ffcc5ac00 --- /dev/null +++ b/apps/trading/client-pages/rewards/rewards.tsx @@ -0,0 +1,11 @@ +import { t } from '@vegaprotocol/i18n'; +import { RewardsContainer } from '../../components/rewards-container'; + +export const Rewards = () => { + return ( +
+

{t('Rewards')}

+ +
+ ); +}; diff --git a/apps/trading/components/card/card.tsx b/apps/trading/components/card/card.tsx new file mode 100644 index 000000000..ca508c0b3 --- /dev/null +++ b/apps/trading/components/card/card.tsx @@ -0,0 +1,102 @@ +import { Tooltip } from '@vegaprotocol/ui-toolkit'; +import classNames from 'classnames'; +import type { HTMLProps, ReactNode } from 'react'; + +export const Card = ({ + children, + title, + className, + loading = false, + highlight = false, +}: { + children: ReactNode; + title: string; + className?: string; + loading?: boolean; + highlight?: boolean; +}) => { + return ( +
+
+

{title}

+ {loading ? : children} +
+
+ ); +}; + +export const CardLoader = () => { + return ( +
+
+
+
+ ); +}; + +export const CardStat = ({ + value, + text, + highlight, + description, + testId, +}: { + value: ReactNode; + text?: string; + highlight?: boolean; + description?: ReactNode; + testId?: string; +}) => { + const val = ( + + {value} + + ); + + return ( +

+ {description ? {val} : val} + {text && ( + {text} + )} +

+ ); +}; + +export const CardTable = (props: HTMLProps) => { + return ( + + {props.children} +
+ ); +}; + +export const CardTableTH = (props: HTMLProps) => { + return ( + + ); +}; + +export const CardTableTD = (props: HTMLProps) => { + return ( + + ); +}; diff --git a/apps/trading/components/card/index.ts b/apps/trading/components/card/index.ts new file mode 100644 index 000000000..a4b7d3b15 --- /dev/null +++ b/apps/trading/components/card/index.ts @@ -0,0 +1 @@ +export { Card, CardStat, CardTable, CardTableTH, CardTableTD } from './card'; diff --git a/apps/trading/components/fees-container/fees-card.tsx b/apps/trading/components/fees-container/fees-card.tsx deleted file mode 100644 index 48d773956..000000000 --- a/apps/trading/components/fees-container/fees-card.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import classNames from 'classnames'; -import type { ReactNode } from 'react'; - -export const FeeCard = ({ - children, - title, - className, - loading = false, -}: { - children: ReactNode; - title: string; - className?: string; - loading?: boolean; -}) => { - return ( -
-

{title}

- {loading ? : children} -
- ); -}; - -export const FeeCardLoader = () => { - return ( -
-
-
-
- ); -}; diff --git a/apps/trading/components/fees-container/fees-container.tsx b/apps/trading/components/fees-container/fees-container.tsx index ea4c8a095..4c4d6b7d1 100644 --- a/apps/trading/components/fees-container/fees-container.tsx +++ b/apps/trading/components/fees-container/fees-container.tsx @@ -9,9 +9,8 @@ import { import { useMarketList } from '@vegaprotocol/markets'; import { formatNumber, formatNumberRounded } from '@vegaprotocol/utils'; import { useDiscountProgramsQuery, useFeesQuery } from './__generated__/Fees'; -import { FeeCard } from './fees-card'; +import { Card, CardStat, CardTable, CardTableTD, CardTableTH } from '../card'; import { MarketFees } from './market-fees'; -import { Stat } from './stat'; import { useVolumeStats } from './use-volume-stats'; import { useReferralStats } from './use-referral-stats'; import { formatPercentage, getAdjustedFee } from './utils'; @@ -87,7 +86,7 @@ export const FeesContainer = () => {
{isConnected && ( <> - { referralDiscount={referralDiscount} volumeDiscount={volumeDiscount} /> - - + { isReferralProgramRunning={isReferralProgramRunning} isVolumeDiscountProgramRunning={isVolumeDiscountProgramRunning} /> - - + { windowLength={volumeDiscountWindowLength} /> ) : ( -

+

{t('No volume discount program active')}

)} -
- + { epochs={referralDiscountWindowLength} /> ) : ( -

+

{t('No referral program active')}

)} -
+ )} - { lastEpochVolume={volumeInWindow} windowLength={volumeDiscountWindowLength} /> - - + { epochsInSet={epochsInSet} referralVolumeInWindow={referralVolumeInWindow} /> - - + { referralDiscount={referralDiscount} volumeDiscount={volumeDiscount} /> - +
); }; @@ -244,8 +243,8 @@ export const TradingFees = ({ } return ( -
-
+
+

{minAdjustedTotal !== undefined && maxAdjustedTotal !== undefined ? `${formatPercentage(minAdjustedTotal)}%-${formatPercentage( @@ -253,47 +252,43 @@ export const TradingFees = ({ )}%` : `${formatPercentage(adjustedTotal)}%`}

- - + + + {t('Total fee before discount')} + + {minTotal !== undefined && maxTotal !== undefined + ? `${formatPercentage(minTotal.toNumber())}%-${formatPercentage( + maxTotal.toNumber() + )}%` + : `${formatPercentage(total.toNumber())}%`} + + + + {t('Infrastructure')} + + {formatPercentage( + Number(params.market_fee_factors_infrastructureFee) + )} + % + + + + {t('Maker')} + + {formatPercentage(Number(params.market_fee_factors_makerFee))}% + + + {minLiq && maxLiq && ( - - + {t('Liquidity')} + + {formatPercentage(Number(minLiq.fees.factors.liquidityFee))}% + {'-'} + {formatPercentage(Number(maxLiq.fees.factors.liquidityFee))}% + - - - - - - - - - {minLiq && maxLiq && ( - - - - - )} - -
- {t('Total fee before discount')} - - {minTotal !== undefined && maxTotal !== undefined - ? `${formatPercentage( - minTotal.toNumber() - )}%-${formatPercentage(maxTotal.toNumber())}%` - : `${formatPercentage(total.toNumber())}%`} -
{t('Infrastructure')} - {formatPercentage( - Number(params.market_fee_factors_infrastructureFee) - )} - % -
{t('Maker')} - {formatPercentage(Number(params.market_fee_factors_makerFee))}% -
{t('Liquidity')} - {formatPercentage(Number(minLiq.fees.factors.liquidityFee))}% - {'-'} - {formatPercentage(Number(maxLiq.fees.factors.liquidityFee))}% -
+ )} +
); @@ -316,13 +311,13 @@ export const CurrentVolume = ({ : 0; return ( -
- + {requiredForNextTier > 0 && ( - @@ -341,8 +336,8 @@ const ReferralBenefits = ({ epochs: number; }) => { return ( -
- + - +
); }; @@ -377,8 +372,8 @@ const TotalDiscount = ({ ); return ( -
- + {totalDiscountDescription} @@ -388,38 +383,36 @@ const TotalDiscount = ({ value={formatPercentage(totalDiscount) + '%'} highlight={true} /> - - - - - - - - - - - -
{t('Volume discount')} - {formatPercentage(volumeDiscount)}% - {!isVolumeDiscountProgramRunning && ( - - - {' '} - - - - )} -
{t('Referral discount')} - {formatPercentage(referralDiscount)}% - {!isReferralProgramRunning && ( - - - {' '} - - - - )} -
+ + + {t('Volume discount')} + + {formatPercentage(volumeDiscount)}% + {!isVolumeDiscountProgramRunning && ( + + + {' '} + + + + )} + + + + {t('Referral discount')} + + {formatPercentage(referralDiscount)}% + {!isReferralProgramRunning && ( + + + {' '} + + + + )} + + +
); }; @@ -440,7 +433,7 @@ const VolumeTiers = ({ }) => { if (!tiers.length) { return ( -

+

{t('No volume discount program active')}

); @@ -501,7 +494,7 @@ const ReferralTiers = ({ }) => { if (!tiers.length) { return ( -

{t('No referral program active')}

+

{t('No referral program active')}

); } @@ -557,20 +550,20 @@ const ReferralTiers = ({ const YourTier = () => { return ( - + {t('Your tier')} ); }; const ReferrerInfo = ({ code }: { code?: string }) => ( -
+

{t('Connected key is owner of the referral set')} {code && ( <> {' '} - + {truncateMiddle(code)} @@ -581,7 +574,7 @@ const ReferrerInfo = ({ code }: { code?: string }) => (

{t('See')}{' '} {t('Referrals')} diff --git a/apps/trading/components/fees-container/stat.tsx b/apps/trading/components/fees-container/stat.tsx deleted file mode 100644 index 307b77ff0..000000000 --- a/apps/trading/components/fees-container/stat.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import { Tooltip } from '@vegaprotocol/ui-toolkit'; -import classNames from 'classnames'; -import type { ReactNode } from 'react'; - -export const Stat = ({ - value, - text, - highlight, - description, -}: { - value: string | number; - text?: string; - highlight?: boolean; - description?: ReactNode; -}) => { - const val = ( - - {value} - - ); - return ( -

- {description ? {val} : val} - {text && ( - {text} - )} -

- ); -}; diff --git a/apps/trading/components/navbar/navbar.spec.tsx b/apps/trading/components/navbar/navbar.spec.tsx index fce4e5035..3f043ce7b 100644 --- a/apps/trading/components/navbar/navbar.spec.tsx +++ b/apps/trading/components/navbar/navbar.spec.tsx @@ -68,6 +68,7 @@ describe('Navbar', () => { ['/portfolio', 'Portfolio'], ['/referrals', 'Referrals'], ['/fees', 'Fees'], + ['/rewards', 'Rewards'], [expect.stringContaining('governance'), 'Governance'], ]; @@ -102,6 +103,7 @@ describe('Navbar', () => { ['/portfolio', 'Portfolio'], ['/referrals', 'Referrals'], ['/fees', 'Fees'], + ['/rewards', 'Rewards'], [expect.stringContaining('governance'), 'Governance'], ]; const links = menu.getAllByRole('link'); diff --git a/apps/trading/components/navbar/navbar.tsx b/apps/trading/components/navbar/navbar.tsx index 72644837d..232254c44 100644 --- a/apps/trading/components/navbar/navbar.tsx +++ b/apps/trading/components/navbar/navbar.tsx @@ -73,7 +73,7 @@ export const Navbar = ({
{/* Right section */} -
+
{ @@ -107,18 +107,18 @@ export const Navbar = ({ onOpenChange={(open) => setMenu((x) => (open ? x : null))} > -
+
setMenu(null)}> {t('Close menu')} @@ -142,7 +142,7 @@ const NavbarMenu = ({ onClick }: { onClick: () => void }) => { const marketId = useGlobalStore((store) => store.marketId); return ( -
+
@@ -192,6 +192,11 @@ const NavbarMenu = ({ onClick }: { onClick: () => void }) => { {t('Fees')} + + + {t('Rewards')} + + {t('Governance')} @@ -241,8 +246,8 @@ const NavbarTrigger = ({ onPointerMove={preventHover} onPointerLeave={preventHover} className={classNames( - 'w-full lg:w-auto lg:h-full', - 'flex items-center justify-between lg:justify-center gap-2 px-6 py-2 lg:p-0', + 'w-full lg:h-full lg:w-auto', + 'flex items-center justify-between gap-2 px-6 py-2 lg:justify-center lg:p-0', 'text-lg lg:text-sm', 'hover:text-vega-clight-100 dark:hover:text-vega-cdark-100' )} @@ -273,8 +278,8 @@ const NavbarLink = ({ to={to} end={end} className={classNames( - 'block lg:flex lg:h-full flex-col justify-center', - 'px-6 py-2 lg:p-0 text-lg lg:text-sm', + 'block flex-col justify-center lg:flex lg:h-full', + 'px-6 py-2 text-lg lg:p-0 lg:text-sm', 'hover:text-vega-clight-100 dark:hover:text-vega-cdark-100' )} onClick={onClick} @@ -297,7 +302,7 @@ const NavbarLink = ({