diff --git a/package.json b/package.json index 0b4bc6725f..0af0c9d564 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "givethdapp", - "version": "2.25.0", + "version": "2.25.1", "private": true, "scripts": { "build": "next build", diff --git a/src/components/AmountInput/AmountInput.tsx b/src/components/AmountInput/AmountInput.tsx index 5baad4ca10..4289f312eb 100644 --- a/src/components/AmountInput/AmountInput.tsx +++ b/src/components/AmountInput/AmountInput.tsx @@ -4,15 +4,24 @@ import { brandColors, Flex, } from '@giveth/ui-design-system'; -import { FC, useState, useCallback, Dispatch, SetStateAction } from 'react'; +import { + FC, + useState, + useCallback, + Dispatch, + SetStateAction, + useEffect, +} from 'react'; import styled from 'styled-components'; import { useIntl } from 'react-intl'; import { captureException } from '@sentry/nextjs'; -import BigNumber from 'bignumber.js'; +import { formatUnits, parseUnits } from 'viem'; import { formatWeiHelper } from '@/helpers/number'; import { BaseInput } from '../input/BaseInput'; +import { truncateToDecimalPlaces } from '@/lib/helpers'; export interface IAmountInput { + amount: bigint; setAmount: Dispatch>; decimals?: number; className?: string; @@ -21,11 +30,10 @@ export interface IAmountInput { showMax?: boolean; balanceUnit?: string; showPercentage?: boolean; - displayAmount?: string; - setDisplayAmount?: Dispatch>; } export const AmountInput: FC = ({ + amount, maxAmount, setAmount, className, @@ -33,59 +41,43 @@ export const AmountInput: FC = ({ disabled = false, showMax = false, showPercentage = false, - displayAmount: externalDisplayAmount = undefined, - setDisplayAmount: externalSetDisplayAmount = undefined, }) => { const { formatMessage } = useIntl(); - const [internalDisplayAmount, internalSetDisplayAmount] = useState(''); const [activeStep, setActiveStep] = useState(0); + const [displayAmount, setDisplayAmount] = useState(''); - // Determine which displayAmount and setDisplayAmount to use - const displayAmount = - externalDisplayAmount !== undefined - ? externalDisplayAmount - : internalDisplayAmount; - - const setDisplayAmount = - externalSetDisplayAmount !== undefined - ? externalSetDisplayAmount - : internalSetDisplayAmount; + useEffect(() => { + if (!amount) return; + const _displayAmount = truncateToDecimalPlaces( + formatUnits(amount, decimals), + decimals / 3, + ).toString(); + setDisplayAmount(_displayAmount); + }, [amount, decimals]); const setAmountPercentage = useCallback( (percentage: number): void => { if (!maxAmount) return; - const newAmount = new BigNumber(maxAmount.toString()) - .multipliedBy(percentage) - .div(100) - .toFixed(0); - const _displayAmount = formatWeiHelper(newAmount, 6, false); - setDisplayAmount(_displayAmount); - setAmount( + const newAmount = percentage === 100 ? maxAmount - : BigInt( - new BigNumber(_displayAmount) - .multipliedBy(10 ** decimals) - .toFixed(0), - ), - ); + : (maxAmount * BigInt(percentage)) / 100n; + + setAmount(newAmount); }, - [decimals, maxAmount, setAmount], + [maxAmount, setAmount], ); const onUserInput = useCallback( (value: string) => { const [, _decimals] = value.split('.'); - if (_decimals?.length > 6) { - return; - } + if (_decimals?.length > 6) return; setDisplayAmount(value); setActiveStep(0); - let valueBn = new BigNumber(0); try { - valueBn = new BigNumber(value).multipliedBy(10 ** decimals); - setAmount(BigInt(valueBn.toFixed(0))); + let valueBn = parseUnits(value, decimals); + setAmount(valueBn); } catch (error) { setAmount(0n); console.debug( diff --git a/src/components/modals/StakeLock/Lock.tsx b/src/components/modals/StakeLock/Lock.tsx index fcba36aeb4..a8a36efa4d 100644 --- a/src/components/modals/StakeLock/Lock.tsx +++ b/src/components/modals/StakeLock/Lock.tsx @@ -135,6 +135,7 @@ const LockModal: FC = ({ })} = ({ = ({ })} = ({ { + return ( + + Managing your recurring donations +
+

+ You can modify or delete your recurring donation as well as + top-up funds to your stream balance from the  + + Recurring Donations page + + . +

+

+ To learn more about how recurring donations work, visit our{' '} + + documentation article + +  . +

+
+ ); +}; + +const Title = styled(H5)` + color: ${brandColors.deep[800]}; +`; + +const Box = styled.div` + padding: 16px; + border-radius: 12px; + border: 1px solid ${brandColors.giv[200]}; + a { + color: ${brandColors.pinky[500]}; + &:hover { + color: ${brandColors.pinky[600]}; + } + } +`; diff --git a/src/components/views/donate/ModifySuperToken/DepositSuperToken.tsx b/src/components/views/donate/ModifySuperToken/DepositSuperToken.tsx index 5875d1b99b..bdb8f8abb3 100644 --- a/src/components/views/donate/ModifySuperToken/DepositSuperToken.tsx +++ b/src/components/views/donate/ModifySuperToken/DepositSuperToken.tsx @@ -22,6 +22,7 @@ import { EModifySuperTokenSteps, actionButtonLabel } from './common'; import { wagmiConfig } from '@/wagmiConfigs'; import { getEthersProvider, getEthersSigner } from '@/helpers/ethers'; import { EToastType } from '@/components/toasts/InlineToast'; +import { ensureCorrectNetwork } from '@/helpers/network'; interface IDepositSuperTokenProps extends IModifySuperTokenInnerModalProps { token?: IToken; @@ -73,8 +74,9 @@ export const DepositSuperToken: FC = ({ const onApprove = async () => { console.log('Approve', amount, address, superToken, token); if (!address || !superToken || !token) return; - setStep(EModifySuperTokenSteps.APPROVING); try { + setStep(EModifySuperTokenSteps.APPROVING); + await ensureCorrectNetwork(config.OPTIMISM_NETWORK_NUMBER); const approve = await approveERC20tokenTransfer( amount, address, @@ -95,8 +97,9 @@ export const DepositSuperToken: FC = ({ }; const onDeposit = async () => { - setStep(EModifySuperTokenSteps.DEPOSITING); try { + setStep(EModifySuperTokenSteps.DEPOSITING); + await ensureCorrectNetwork(config.OPTIMISM_NETWORK_NUMBER); if (!address) { throw new Error('address not found1'); } @@ -170,6 +173,7 @@ export const DepositSuperToken: FC = ({ >; balance?: GetBalanceReturnType; refetch: any; @@ -44,6 +45,7 @@ interface IModifySectionProps { export const ModifySection: FC = ({ titleLabel, token, + amount, setAmount, balance, refetch, @@ -54,15 +56,9 @@ export const ModifySection: FC = ({ modifySectionPlace, }) => { const { formatMessage } = useIntl(); - const [displayAmount, setDisplayAmount] = useState(''); const handleSetMaxAmount = () => { if (!balance || !balance.value) return; // If balance is not available, return - const maxAmountDisplay = truncateToDecimalPlaces( - formatUnits(maxAmount, balance.decimals), - 6, - ).toString(); // Convert your balance value to string properly - setDisplayAmount(maxAmountDisplay); // Update the display amount setAmount(balance.value); // Set the amount to the balance value }; @@ -104,19 +100,10 @@ export const ModifySection: FC = ({ @@ -132,7 +119,7 @@ export const ModifySection: FC = ({ {balance ? truncateToDecimalPlaces( formatUnits(maxAmount, balance.decimals), - 6, + balance.decimals / 3, ) : '--'} diff --git a/src/components/views/donate/ModifySuperToken/StreamInfo.tsx b/src/components/views/donate/ModifySuperToken/StreamInfo.tsx index b836744697..7049b3ed64 100644 --- a/src/components/views/donate/ModifySuperToken/StreamInfo.tsx +++ b/src/components/views/donate/ModifySuperToken/StreamInfo.tsx @@ -72,16 +72,20 @@ export const StreamInfo: FC = ({ })}{' '} {totalStreamPerSec > 0 ? ( - {streamRunOutInMonth < 0n - ? '0' - : streamRunOutInMonth.toString()}{' '} - {formatMessage( - { - id: 'label.months', - }, - { - count: streamRunOutInMonth.toString(), - }, + {streamRunOutInMonth < 1n ? ( + ' < 1 Month ' + ) : ( + <> + {streamRunOutInMonth.toString()}{' '} + {formatMessage( + { + id: 'label.months', + }, + { + count: streamRunOutInMonth.toString(), + }, + )} + )} ) : ( diff --git a/src/components/views/donate/ModifySuperToken/WithDrawSuperToken.tsx b/src/components/views/donate/ModifySuperToken/WithDrawSuperToken.tsx index 23050f0f40..cab0a5266a 100644 --- a/src/components/views/donate/ModifySuperToken/WithDrawSuperToken.tsx +++ b/src/components/views/donate/ModifySuperToken/WithDrawSuperToken.tsx @@ -20,6 +20,7 @@ import { ONE_MONTH_SECONDS } from '@/lib/constants/constants'; import { wagmiConfig } from '@/wagmiConfigs'; import { getEthersProvider, getEthersSigner } from '@/helpers/ethers'; import { EToastType } from '@/components/toasts/InlineToast'; +import { ensureCorrectNetwork } from '@/helpers/network'; interface IWithDrawSuperTokenProps extends IModifySuperTokenInnerModalProps { token?: IToken; @@ -59,6 +60,7 @@ export const WithDrawSuperToken: FC = ({ const onWithdraw = async () => { setStep(EModifySuperTokenSteps.WITHDRAWING); try { + await ensureCorrectNetwork(config.OPTIMISM_NETWORK_NUMBER); if (!address) { throw new Error('address not found1'); } @@ -148,6 +150,7 @@ export const WithDrawSuperToken: FC = ({ {

) : ( { selectedToken !== undefined && balance !== undefined && ( - + setAmount(balance.value)} + > {formatMessage({ id: 'label.available', })} :{' '} - {limitFraction( + {truncateToDecimalPlaces( formatUnits( balance.value, balance.decimals, ), + balance.decimals / 3, )} - + !isRefetching && refetch()} > @@ -812,6 +817,13 @@ export const IconWrapper = styled.div` color: ${brandColors.giv[500]}; `; +const GLinkStyled = styled(GLink)` + &&:hover { + cursor: pointer; + text-decoration: underline; + } +`; + const SliderWrapper = styled.div` width: 100%; position: relative; diff --git a/src/components/views/donate/RecurringDonationModal/RecurringDonationModal.tsx b/src/components/views/donate/RecurringDonationModal/RecurringDonationModal.tsx index 35913dacd2..1066432775 100644 --- a/src/components/views/donate/RecurringDonationModal/RecurringDonationModal.tsx +++ b/src/components/views/donate/RecurringDonationModal/RecurringDonationModal.tsx @@ -40,6 +40,7 @@ import { import { getEthersProvider, getEthersSigner } from '@/helpers/ethers'; import { ERecurringDonationStatus } from '@/apollo/types/types'; import { findAnchorContractAddress } from '@/helpers/superfluid'; +import { ensureCorrectNetwork } from '@/helpers/network'; interface IRecurringDonationModalProps extends IModal { donationToGiveth: number; amount: bigint; @@ -143,15 +144,18 @@ const RecurringDonationInnerModal: FC = ({ }, [selectedToken, setStep]); const onApprove = async () => { - console.log( - 'amount', - formatUnits(amount, selectedToken?.token.decimals || 18), - ); - setStep(EDonationSteps.APPROVING); - if (!address || !selectedToken) return; - const superToken = findSuperTokenByTokenAddress(selectedToken.token.id); - if (!superToken) return; try { + await ensureCorrectNetwork(config.OPTIMISM_NETWORK_NUMBER); + console.log( + 'amount', + formatUnits(amount, selectedToken?.token.decimals || 18), + ); + setStep(EDonationSteps.APPROVING); + if (!address || !selectedToken) return; + const superToken = findSuperTokenByTokenAddress( + selectedToken.token.id, + ); + if (!superToken) throw new Error('SuperToken not found'); const approve = await approveERC20tokenTransfer( amount, address, @@ -171,8 +175,9 @@ const RecurringDonationInnerModal: FC = ({ }; const onDonate = async () => { - setStep(EDonationSteps.DONATING); try { + await ensureCorrectNetwork(config.OPTIMISM_NETWORK_NUMBER); + setStep(EDonationSteps.DONATING); const projectAnchorContract = findAnchorContractAddress( project?.anchorContracts, ); @@ -334,6 +339,8 @@ const RecurringDonationInnerModal: FC = ({ ); } + await ensureCorrectNetwork(config.OPTIMISM_NETWORK_NUMBER); + if (isBatch) { const batchOp = sf.batchCall(operations); tx = await batchOp.exec(signer); @@ -447,11 +454,13 @@ const RecurringDonationInnerModal: FC = ({ { txHash: tx.hash, chainType: ChainType.EVM }, ], excludeFromQF: true, + isRecurring: true, }); } else { setSuccessDonation({ txHash: [{ txHash: tx.hash, chainType: ChainType.EVM }], excludeFromQF: true, + isRecurring: true, }); } } diff --git a/src/components/views/donate/SuccessView.tsx b/src/components/views/donate/SuccessView.tsx index e85002e544..4625b85660 100644 --- a/src/components/views/donate/SuccessView.tsx +++ b/src/components/views/donate/SuccessView.tsx @@ -30,6 +30,7 @@ import links from '@/lib/constants/links'; import { EContentType } from '@/lib/constants/shareContent'; import QFToast from './QFToast'; import { DonationInfo } from './DonationInfo'; +import { ManageRecurringDonation } from './ManageRecurringDonation'; export const SuccessView: FC = () => { const { formatMessage } = useIntl(); @@ -38,6 +39,7 @@ export const SuccessView: FC = () => { givBackEligible, txHash = [], excludeFromQF, + isRecurring, } = successDonation || {}; const hasMultipleTxs = txHash.length > 1; const isSafeEnv = useIsSafeEnvironment(); @@ -98,11 +100,13 @@ export const SuccessView: FC = () => { - - {formatMessage({ id: 'label.youre_giver_now' })} - -
- {message} +
+ + {formatMessage({ id: 'label.youre_giver_now' })} + +
+ {message} +

{givBackEligible && ( <> @@ -132,6 +136,7 @@ export const SuccessView: FC = () => { hasActiveQFRound && passportState !== EPassportState.LOADING && isOnEligibleNetworks && } + {isRecurring && } { {formatMessage({ id: 'label.matching_pool' })} - {data?.qfRoundStats?.matchingPool || '--'} $ + ${data?.qfRoundStats?.matchingPool || ' --'} @@ -40,8 +40,7 @@ export const ActiveQFRoundStats = () => { {formatMessage({ id: 'label.donations' })} - $  - {data?.qfRoundStats?.allDonationsUsdValue || '--'} + ${data?.qfRoundStats?.allDonationsUsdValue || ' --'} @@ -54,14 +53,14 @@ export const ActiveQFRoundStats = () => { - Round started + Round start {activeRound?.endDate ? formatDate(new Date(activeRound.beginDate)) : '--'} - Ends on + Round end {activeRound?.endDate ? formatDate(new Date(activeRound.endDate)) diff --git a/src/components/views/projects/ArchivedQFRoundStats.tsx b/src/components/views/projects/ArchivedQFRoundStats.tsx index f8977432c2..253bdc40d9 100644 --- a/src/components/views/projects/ArchivedQFRoundStats.tsx +++ b/src/components/views/projects/ArchivedQFRoundStats.tsx @@ -34,7 +34,7 @@ export const ArchivedQFRoundStats = () => { {formatMessage({ id: 'label.matching_pool' })} - {data?.qfRoundStats?.matchingPool || '--'} $ + ${data?.qfRoundStats?.matchingPool || ' --'} @@ -42,8 +42,7 @@ export const ArchivedQFRoundStats = () => { {formatMessage({ id: 'label.donations' })} - $  - {data?.qfRoundStats?.allDonationsUsdValue || '--'} + ${data?.qfRoundStats?.allDonationsUsdValue || ' --'} diff --git a/src/components/views/userProfile/donationsTab/recurringTab/ModifyStreamModal/UpdateStreamInnerModal.tsx b/src/components/views/userProfile/donationsTab/recurringTab/ModifyStreamModal/UpdateStreamInnerModal.tsx index 6237c28719..30bce4219e 100644 --- a/src/components/views/userProfile/donationsTab/recurringTab/ModifyStreamModal/UpdateStreamInnerModal.tsx +++ b/src/components/views/userProfile/donationsTab/recurringTab/ModifyStreamModal/UpdateStreamInnerModal.tsx @@ -26,6 +26,7 @@ import { TXLink } from './TXLink'; import { useProfileDonateTabData } from '../ProfileDonateTab.context'; import { ERecurringDonationStatus } from '@/apollo/types/types'; import { findAnchorContractAddress } from '@/helpers/superfluid'; +import { ensureCorrectNetwork } from '@/helpers/network'; interface IModifyStreamInnerModalProps extends IModifyStreamModalProps { step: EDonationSteps; @@ -56,6 +57,7 @@ export const UpdateStreamInnerModal: FC = ({ const onDonate = async () => { setStep(EDonationSteps.DONATING); try { + await ensureCorrectNetwork(config.OPTIMISM_NETWORK_NUMBER); const projectAnchorContract = findAnchorContractAddress( donation.project.anchorContracts, ); diff --git a/src/components/views/userProfile/projectsTab/ClaimWithdrawalModal.tsx b/src/components/views/userProfile/projectsTab/ClaimWithdrawalModal.tsx index 7298e734fe..a28cd8695d 100644 --- a/src/components/views/userProfile/projectsTab/ClaimWithdrawalModal.tsx +++ b/src/components/views/userProfile/projectsTab/ClaimWithdrawalModal.tsx @@ -25,6 +25,7 @@ import { formatTxLink } from '@/lib/helpers'; import { ChainType } from '@/types/config'; import { ClaimTransactionState } from './type'; import { wagmiConfig } from '@/wagmiConfigs'; +import { ensureCorrectNetwork } from '@/helpers/network'; interface IClaimWithdrawalModal extends IModal { selectedStream: ITokenWithBalance; project: IProject; @@ -85,6 +86,7 @@ const ClaimWithdrawalModal = ({ console.log('anchorContractAddress', anchorContractAddress); try { console.log('isETHx', isETHx); + await ensureCorrectNetwork(config.OPTIMISM_NETWORK_NUMBER); const encodedDowngradeTo = isETHx ? encodeFunctionData({ abi: ISETH.abi, diff --git a/src/components/views/verification/projectContact/ProjectContactIndex.tsx b/src/components/views/verification/projectContact/ProjectContactIndex.tsx index 72fc783f08..8fa932ad2e 100644 --- a/src/components/views/verification/projectContact/ProjectContactIndex.tsx +++ b/src/components/views/verification/projectContact/ProjectContactIndex.tsx @@ -7,13 +7,14 @@ import { neutralColors, IconTelegram, IconWhatsApp, + IconLink, P, IconInfoFilled, IconXSocial, } from '@giveth/ui-design-system'; import styled from 'styled-components'; import { useForm } from 'react-hook-form'; -import { validators } from '@/lib/constants/regex'; +import { requiredOptions, validators } from '@/lib/constants/regex'; import Input from '@/components/Input'; import { BtnContainer, ContentSeparator, OutlineStyled } from '../Common.sc'; @@ -167,6 +168,24 @@ export default function ProjectContactIndex() { buttonType='primary' /> )} + + {formatMessage({ + id: 'label.in_order_to_ensure_that_you_are_a_representative', + })} + +
+ } + error={errors['SocialLink']} + register={register} + registerName='SocialLink' + registerOptions={isDraft ? requiredOptions.website : {}} + disabled={!isDraft} + />
@@ -243,3 +262,7 @@ const FormContainer = styled.form` max-width: 100%; } `; + +const SocialLinkInfo = styled(P)` + max-width: fit-content; +`; diff --git a/src/components/views/verification/projectContact/common.types.ts b/src/components/views/verification/projectContact/common.types.ts index 546b80cdb8..7ed564fc06 100644 --- a/src/components/views/verification/projectContact/common.types.ts +++ b/src/components/views/verification/projectContact/common.types.ts @@ -3,6 +3,7 @@ export enum EMainSocials { Discord = 'Discord', Telegram = 'Telegram', WhatsApp = 'WhatsApp', + SocialLink = 'SocialLink', } export interface IMainSocials { @@ -10,4 +11,5 @@ export interface IMainSocials { [EMainSocials.Discord]: string; [EMainSocials.Telegram]: string; [EMainSocials.WhatsApp]: string; + [EMainSocials.SocialLink]: string; } diff --git a/src/config/development.tsx b/src/config/development.tsx index 2e85d3e7f4..84935b6b1c 100644 --- a/src/config/development.tsx +++ b/src/config/development.tsx @@ -387,6 +387,7 @@ const config: EnvConfig = { id: OPTIMISM_GIV_TOKEN_ADDRESS, name: 'Giveth', symbol: 'GIV', + coingeckoId: 'giveth', }, decimals: 18, id: '0xdfd824f6928b9776c031f7ead948090e2824ce8b', @@ -401,6 +402,7 @@ const config: EnvConfig = { symbol: 'ETH', decimals: 18, id: '0x0000000000000000000000000000000000000000', + coingeckoId: 'ethereum', }, decimals: 18, id: '0x0043d7c85c8b96a49a72a92c0b48cdc4720437d7', diff --git a/src/config/production.tsx b/src/config/production.tsx index f99e91739c..e29e7559e3 100644 --- a/src/config/production.tsx +++ b/src/config/production.tsx @@ -459,6 +459,7 @@ const config: EnvConfig = { id: '0x4200000000000000000000000000000000000042', name: 'Optimism', symbol: 'OP', + coingeckoId: 'optimism', }, decimals: 18, id: '0x1828bff08bd244f7990eddcd9b19cc654b33cdb4', @@ -473,6 +474,7 @@ const config: EnvConfig = { symbol: 'ETH', decimals: 18, id: '0x0000000000000000000000000000000000000000', + coingeckoId: 'ethereum', }, decimals: 18, id: '0x4ac8bd1bdae47beef2d1c6aa62229509b962aa0d', @@ -487,6 +489,7 @@ const config: EnvConfig = { id: '0x528cdc92eab044e1e39fe43b9514bfdab4412b98', name: 'Giveth Token', symbol: 'GIV', + coingeckoId: 'giveth', }, decimals: 18, id: '0x4cab5b9930210e2edc6a905b9c75d615872a1a7e', @@ -501,6 +504,7 @@ const config: EnvConfig = { id: '0xda10009cbd5d07dd0cecc66161fc93d7c9000da1', name: 'Dai Stablecoin', symbol: 'DAI', + coingeckoId: 'dai', }, decimals: 18, id: '0x7d342726b69c28d942ad8bfe6ac81b972349d524', @@ -515,6 +519,7 @@ const config: EnvConfig = { id: '0x7f5c764cbc14f9669b88837ca1490cca17c31607', name: 'USD Coin', symbol: 'USDC', + coingeckoId: 'usd-coin', }, decimals: 18, id: '0x8430f084b939208e2eded1584889c9a66b90562f', diff --git a/src/context/donate.context.tsx b/src/context/donate.context.tsx index 3c1b7a2ad0..f0922734c1 100644 --- a/src/context/donate.context.tsx +++ b/src/context/donate.context.tsx @@ -24,6 +24,7 @@ interface ISuccessDonation { txHash: TxHashWithChainType[]; givBackEligible?: boolean; excludeFromQF?: boolean; + isRecurring?: boolean; } interface IDonateContext { diff --git a/src/helpers/network.ts b/src/helpers/network.ts new file mode 100644 index 0000000000..f0242bee2e --- /dev/null +++ b/src/helpers/network.ts @@ -0,0 +1,16 @@ +import { getChainId, switchChain } from '@wagmi/core'; +import { wagmiConfig } from '@/wagmiConfigs'; + +export const ensureCorrectNetwork = async (targetChainId: number) => { + try { + const chainId = getChainId(wagmiConfig); + if (targetChainId === chainId) return true; + const chain = await switchChain(wagmiConfig, { + chainId: targetChainId, + }); + return chain.id === targetChainId; + } catch (error) { + console.log('error', error); + return false; + } +}; diff --git a/src/helpers/number.ts b/src/helpers/number.ts index 5437b2d096..0a988e6acf 100644 --- a/src/helpers/number.ts +++ b/src/helpers/number.ts @@ -1,6 +1,7 @@ import BigNumber from 'bignumber.js'; import { formatEther } from 'viem'; import config from '@/configuration'; +import { truncateToDecimalPlaces } from '@/lib/helpers'; export const Zero = new BigNumber(0); @@ -79,7 +80,10 @@ export function limitFraction( return `<${smallestRepresentable.toFixed(maxDecimals)}`; } - let formattedNumber = number.toFixed(maxDecimals); + let formattedNumber = truncateToDecimalPlaces( + numberStr.toString(), + maxDecimals, + ).toString(); // If trim is true, remove trailing zeros after the decimal point, and also the decimal point if it becomes unnecessary. if (trim) { diff --git a/src/types/superFluid.ts b/src/types/superFluid.ts index d5c6b5a623..a45afd248a 100644 --- a/src/types/superFluid.ts +++ b/src/types/superFluid.ts @@ -7,12 +7,12 @@ export type IToken = { decimals: number; isSuperToken?: boolean; underlyingToken?: IToken; + coingeckoId: string; }; export interface ISuperToken extends IToken { underlyingToken: IToken; isSuperToken: boolean; - coingeckoId: string; } export interface ISuperfluidStream {