From 39e1435b951e9c7a97422672d2699d03c198b0e2 Mon Sep 17 00:00:00 2001 From: Yunip Shrestha Date: Mon, 15 Apr 2024 11:00:40 +0545 Subject: [PATCH 1/6] add ValueWithPrice component to ActionAccordion --- src/assets/scss/components/_modal.scss | 13 ++++++- src/components/Actions/Borrow.component.tsx | 2 +- src/components/Actions/Repay.component.tsx | 2 +- src/components/Actions/Supply.component.tsx | 3 +- src/components/Actions/Withdraw.component.tsx | 2 +- src/components/Price/Price.component.tsx | 5 ++- .../actions/ActionAccordion.component.tsx | 38 ++++++++++++++++--- 7 files changed, 50 insertions(+), 15 deletions(-) diff --git a/src/assets/scss/components/_modal.scss b/src/assets/scss/components/_modal.scss index 671ff88..7cb27a6 100644 --- a/src/assets/scss/components/_modal.scss +++ b/src/assets/scss/components/_modal.scss @@ -377,6 +377,15 @@ .value { font-weight: 600; } + + .price.secondary { + .price-label span { + font-size: 14px; + } + .price-value { + font-size: 12px; + } + } } } .old-value { @@ -401,13 +410,13 @@ padding: 6px 10px; .field-left { - font-size: 15px; + font-size: 16px; font-weight: 600; color: $text-color-primary; } .field-right { - font-size: 15px; + font-size: 16px; .value { font-weight: 700; } diff --git a/src/components/Actions/Borrow.component.tsx b/src/components/Actions/Borrow.component.tsx index 083ba39..21a41bf 100644 --- a/src/components/Actions/Borrow.component.tsx +++ b/src/components/Actions/Borrow.component.tsx @@ -252,7 +252,7 @@ export const BorrowModal: FC = ({ = ({ = ({ = ({ = ({ pool, value, displayUnit = false, unit, variant = 'primary' }) => { +export const ValueWithPrice: FC = ({ pool, value, displayUnit = false, unit, variant = 'primary', prefix = '' }) => { const { oraclePrices } = useAppSelector(state => state.pool) const poolPrice = useMemo(() => { @@ -58,7 +59,7 @@ export const ValueWithPrice: FC = ({ pool, value, displayU
{/* TODO should the precision be 4 for tokens? */}
- {toFixedNumber(value, 4, true)}{' '} + {prefix} {toFixedNumber(value, 4, true)} {displayUnit ? unit ?? getTokenSymbol(pool) : ''}
${toFixedCutZero(dollarEquivalent, 2, true)}
diff --git a/src/components/shared/actions/ActionAccordion.component.tsx b/src/components/shared/actions/ActionAccordion.component.tsx index 24577aa..972caf1 100644 --- a/src/components/shared/actions/ActionAccordion.component.tsx +++ b/src/components/shared/actions/ActionAccordion.component.tsx @@ -1,9 +1,11 @@ import React, { type FC } from 'react' import { Accordion } from './Accordion.component' +import { ValueWithPrice } from '@/components/Price' +import { type tPoolIds } from '@cedro-finance/sdk' interface ActionAccordionProps { fieldName: string - token: string + pool: tPoolIds values: { gasOnDestination: string fee: string @@ -13,7 +15,7 @@ interface ActionAccordionProps { } children: React.ReactNode } -export const ActionAccordion: FC = ({ fieldName, token, children, values }) => { +export const ActionAccordion: FC = ({ fieldName, pool, children, values }) => { // const [airdropAmount, setAirdropAmount] = useState() // const handleAirdropAmountChange = (e: ChangeEvent): void => { // setAirdropAmount(Number(e.target.value)) @@ -32,7 +34,13 @@ export const ActionAccordion: FC = ({ fieldName, token, ch
Rebalancing Reward
- + {values.reward} {token} +
{/*
@@ -55,7 +63,13 @@ export const ActionAccordion: FC = ({ fieldName, token, ch
Rebalancing Fee
- - {values.fee} {token} +
@@ -63,7 +77,13 @@ export const ActionAccordion: FC = ({ fieldName, token, ch
Transaction Fee
- - {values.gasFee} {token} +
)} @@ -71,7 +91,13 @@ export const ActionAccordion: FC = ({ fieldName, token, ch
LayerZero Fee
- - {values.layerzero} {token} +
)} From adb44a7a833273c509f90903c1265a2ab1024c17 Mon Sep 17 00:00:00 2001 From: Yunip Shrestha Date: Mon, 15 Apr 2024 11:22:29 +0545 Subject: [PATCH 2/6] add tooltip to action accordion --- .../actions/ActionAccordion.component.tsx | 23 +++++++++++++++---- src/constants/tooltip.ts | 6 ++++- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/components/shared/actions/ActionAccordion.component.tsx b/src/components/shared/actions/ActionAccordion.component.tsx index 972caf1..faf2749 100644 --- a/src/components/shared/actions/ActionAccordion.component.tsx +++ b/src/components/shared/actions/ActionAccordion.component.tsx @@ -2,6 +2,8 @@ import React, { type FC } from 'react' import { Accordion } from './Accordion.component' import { ValueWithPrice } from '@/components/Price' import { type tPoolIds } from '@cedro-finance/sdk' +import { AboutTooltip } from '@/components/AboutTooltip' +import { TooltipText } from '@/constants' interface ActionAccordionProps { fieldName: string @@ -32,8 +34,12 @@ export const ActionAccordion: FC = ({ fieldName, pool, chi const accordionContent = ( <>
-
Rebalancing Reward
+
+ Rebalancing Reward + +
+ {/* TODO add loading to value with price */} = ({ fieldName, pool, chi
*/}
-
Rebalancing Fee
+
+ Rebalancing Fee + +
= ({ fieldName, pool, chi {values.gasFee && (
-
Transaction Fee
+
+ Gas Fee + +
= ({ fieldName, pool, chi {values.layerzero && (
-
LayerZero Fee
+
+ LayerZero Fee + +
Date: Mon, 15 Apr 2024 11:57:55 +0545 Subject: [PATCH 3/6] change address truncate type --- src/components/Navbar/AvailableTokens.component.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Navbar/AvailableTokens.component.tsx b/src/components/Navbar/AvailableTokens.component.tsx index e70e558..da6441a 100644 --- a/src/components/Navbar/AvailableTokens.component.tsx +++ b/src/components/Navbar/AvailableTokens.component.tsx @@ -22,7 +22,7 @@ export const AvailableTokens: FC = () => { From 450e756a063e9c7ee5c4305b43dba1cd159603fc Mon Sep 17 00:00:00 2001 From: Yunip Shrestha Date: Mon, 15 Apr 2024 13:23:13 +0545 Subject: [PATCH 4/6] use getter for network and chain icon mappings --- .../LiquidityTooltip.component.tsx | 4 ++-- .../Navbar/NavbarSharedCompoent.tsx | 8 +++---- .../modal/SwitchNetwork.component.tsx | 6 ++--- .../ChainlistCheckbox.component.tsx | 4 ++-- .../actions/DestinationChain.component.tsx | 8 +++---- .../shared/actions/RewardInfo.component.tsx | 4 ++-- src/constants/icons.ts | 24 ++++++++++++------- 7 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/components/LiquidityTooltip/LiquidityTooltip.component.tsx b/src/components/LiquidityTooltip/LiquidityTooltip.component.tsx index c560d86..b8c18d0 100644 --- a/src/components/LiquidityTooltip/LiquidityTooltip.component.tsx +++ b/src/components/LiquidityTooltip/LiquidityTooltip.component.tsx @@ -2,7 +2,7 @@ import type { tSupportedChains } from '@cedro-finance/sdk' import { type FC } from 'react' import { Tooltip } from 'react-tooltip' import { Icon } from '../icon' -import { ChainIconMapping, getChainConfig } from '@/constants' +import { getChainConfig, getChainIcon } from '@/constants' import { NETWORK_TYPE } from '@/configs/env' interface ILiquidityTooltipProps { @@ -35,7 +35,7 @@ export const LiquidityTooltip: FC = ({ id }) => {
diff --git a/src/components/Navbar/NavbarSharedCompoent.tsx b/src/components/Navbar/NavbarSharedCompoent.tsx index 2d4a0d2..067c984 100644 --- a/src/components/Navbar/NavbarSharedCompoent.tsx +++ b/src/components/Navbar/NavbarSharedCompoent.tsx @@ -4,7 +4,7 @@ import { toFixedCutZero } from '@/utils' import { useAvailableBalance } from '@/hooks/useAvailableBalance' import { Dropdown } from '@/components/Dropdown' import { Icon, type TIcons } from '@/components/icon' -import { ChainIconMapping, TokenIconMapping } from '@/constants' +import { getChainIcon } from '@/constants' import { WalletConnect } from '@/components/wallet' import { Button } from '../Button' import { useChainContext } from '@/context/chain.context' @@ -31,9 +31,7 @@ export const SwitchNetworkDropdown: FC = () => { const iconName = useMemo(() => { return ( - ChainIconMapping[(connectedChain as ConnectedChain)?.chain ?? 'eth'] || - TokenIconMapping.unknown - ) + getChainIcon((connectedChain as ConnectedChain)?.chain ?? 'eth')) }, [connectedChain?.id]) return ( @@ -59,7 +57,7 @@ export const SwitchNetworkDropdown: FC = () => { }} > diff --git a/src/components/modal/SwitchNetwork.component.tsx b/src/components/modal/SwitchNetwork.component.tsx index 8fd4f7d..0a4105c 100644 --- a/src/components/modal/SwitchNetwork.component.tsx +++ b/src/components/modal/SwitchNetwork.component.tsx @@ -3,7 +3,7 @@ import { type FC } from 'react' import { Button, Modal, Icon } from '@/components' import { type IChainConfig } from '@/@types' import { useNetwork } from 'wagmi' -import { NETWORK_SWITCH_TYPE, NetworkIconMapping } from '@/constants' +import { getNetworkIcon, NETWORK_SWITCH_TYPE } from '@/constants' interface SwitchNetworkProps { isVisible: boolean @@ -70,7 +70,7 @@ export const SwitchNetwork: FC = ({ switchType, isVisible, t
{switchType !== NETWORK_SWITCH_TYPE.UNSUPPORTED ? <>
- +
{currentNetwork?.name}
@@ -82,7 +82,7 @@ export const SwitchNetwork: FC = ({ switchType, isVisible, t : null}
- +
{switchToNetwork?.name}
diff --git a/src/components/shared/ChainlistCheckbox/ChainlistCheckbox.component.tsx b/src/components/shared/ChainlistCheckbox/ChainlistCheckbox.component.tsx index b3c7b9d..32c4076 100644 --- a/src/components/shared/ChainlistCheckbox/ChainlistCheckbox.component.tsx +++ b/src/components/shared/ChainlistCheckbox/ChainlistCheckbox.component.tsx @@ -3,7 +3,7 @@ import { Dropdown } from '@/components/Dropdown' import { Icon } from '@/components/icon' import { Button } from '@/components/Button' import { type tSupportedChains } from '@cedro-finance/sdk' -import { ChainIconMapping } from '@/constants' +import { getChainIcon } from '@/constants' import { cedroClient } from '@/configs/chainConfig' interface IChainlistCheckboxProps { @@ -85,7 +85,7 @@ export const ChainListCheckbox: FC = ({ checkedChainLis readOnly id={chainInfo.symbol} /> - + {chainInfo.name} diff --git a/src/components/shared/actions/DestinationChain.component.tsx b/src/components/shared/actions/DestinationChain.component.tsx index d4454e4..e8c47eb 100644 --- a/src/components/shared/actions/DestinationChain.component.tsx +++ b/src/components/shared/actions/DestinationChain.component.tsx @@ -6,7 +6,7 @@ import { type tPoolIds, type tSupportedChains } from '@cedro-finance/sdk' -import { ChainIconMapping, DEFAULT_WEI_DECIMAL } from '@/constants' +import { DEFAULT_WEI_DECIMAL, getChainIcon } from '@/constants' import { usePoolDetails } from '@/hooks/usePoolDetails' import { convertBigIntValueToNormal, weiMultiply } from '@/utils' import { cedroClient } from '@/configs/chainConfig' @@ -49,7 +49,7 @@ export const DestinationChain: FC = ({