Skip to content

Commit

Permalink
fix some decimal handling and incorrect USDC.e symbol on drop down menu
Browse files Browse the repository at this point in the history
  • Loading branch information
divine-comedian committed Dec 2, 2024
1 parent 83737bf commit 7eafe7a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
17 changes: 10 additions & 7 deletions src/components/views/donate/Recurring/RecurringDonationCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import { showToastError, truncateToDecimalPlaces } from '@/lib/helpers';
import config from '@/configuration';
import { WrongNetworkLayer } from '../WrongNetworkLayer';
import { ModifySuperTokenModal } from './ModifySuperToken/ModifySuperTokenModal';
import { limitFraction } from '@/helpers/number';
import { limitFraction, formatDonation } from '@/helpers/number';
import AlloProtocolFirstDonationModal from './AlloProtocolFirstDonationModal';
import links from '@/lib/constants/links';
import Routes from '@/lib/constants/Routes';
Expand Down Expand Up @@ -570,12 +570,15 @@ export const RecurringDonationCard = () => {
id: 'label.you_will_donate_total',
})}{' '}
<TotalMonthlyStream>
{limitFraction(
formatUnits(
totalStreamPerSec *
ONE_MONTH_SECONDS,
selectedRecurringToken
?.token.decimals || 18,
{formatDonation(
limitFraction(
formatUnits(
totalStreamPerSec *
ONE_MONTH_SECONDS,
selectedRecurringToken
?.token.decimals ||
18,
),
),
)}{' '}
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ const SelectTokenInnerModal: FC<ISelectTokenModalProps> = ({
return balances[symbol] !== undefined && balances[symbol] > 0n;
},
);

return (
<>
<Wrapper>
Expand All @@ -137,6 +136,7 @@ const SelectTokenInnerModal: FC<ISelectTokenModalProps> = ({
<StreamInfo
key={tokenId}
stream={tokenStreams[tokenId.toLowerCase()]}
superToken={token}
balance={balances[token.symbol]}
disable={
!balances[token.symbol] ||
Expand Down Expand Up @@ -176,7 +176,6 @@ const SelectTokenInnerModal: FC<ISelectTokenModalProps> = ({
)}
</>
)}

{!isUserHasBalanceForAllSuperTokens && (
<>
<Title $medium>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import styled from 'styled-components';
import { type FC } from 'react';
import { formatUnits } from 'viem';
import { useIntl } from 'react-intl';
import { ISuperfluidStream } from '@/types/superFluid';
import { ISuperfluidStream, IToken } from '@/types/superFluid';
import { limitFraction } from '@/helpers/number';
import { countActiveStreams } from '@/helpers/donate';
import { findTokenByAddress } from '@/helpers/superfluid';
import { TokenIconWithGIVBack } from '../../TokenIcon/TokenIconWithGIVBack';

interface IStreamInfoProps {
stream: ISuperfluidStream[];
superToken: IToken;
balance: bigint;
disable: boolean;
onClick: () => void;
Expand All @@ -20,12 +21,12 @@ interface IStreamInfoProps {
export const StreamInfo: FC<IStreamInfoProps> = ({
stream,
balance,
superToken,
disable,
onClick,
isSuperToken,
}) => {
const { formatMessage } = useIntl();

const totalFlowRate = stream.reduce(
(acc, curr) => acc + BigInt(curr.currentFlowRate),
0n,
Expand All @@ -38,7 +39,6 @@ export const StreamInfo: FC<IStreamInfoProps> = ({
const token = findTokenByAddress(stream[0].token.id);
const underlyingToken = token?.underlyingToken;
const activeStreamCount = countActiveStreams(stream);

return (
<Wrapper
gap='16px'
Expand All @@ -62,8 +62,8 @@ export const StreamInfo: FC<IStreamInfoProps> = ({
>
<Row $justifyContent='space-between'>
<Symbol>
<Caption $medium>{stream[0].token.symbol}</Caption>
<GrayCaption>{stream[0].token.name}</GrayCaption>
<Caption $medium>{superToken.symbol}</Caption>
<GrayCaption>{superToken.name}</GrayCaption>
</Symbol>
<Balance gap='4px'>
<GrayCaption>Stream Balance</GrayCaption>
Expand All @@ -78,7 +78,7 @@ export const StreamInfo: FC<IStreamInfoProps> = ({
)
: '--'}
</Caption>
<Caption $medium>{stream[0].token.symbol}</Caption>
<Caption $medium>{superToken.symbol}</Caption>
</Balance>
</Row>
{totalFlowRate !== undefined && (
Expand Down

0 comments on commit 7eafe7a

Please sign in to comment.