Skip to content

Commit b32ed79

Browse files
committed
show small balances button
1 parent 2b37f59 commit b32ed79

File tree

10 files changed

+89
-41
lines changed

10 files changed

+89
-41
lines changed

src/components/lists/ListWrapper.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ interface ListWrapperProps {
1818
wrapperSx?: BoxProps['sx'];
1919
tooltipOpen?: boolean;
2020
paperSx?: PaperProps['sx'];
21+
topInfoSx?: BoxProps['sx'];
2122
}
2223

2324
export const ListWrapper = ({
@@ -32,6 +33,7 @@ export const ListWrapper = ({
3233
wrapperSx,
3334
tooltipOpen,
3435
paperSx,
36+
topInfoSx,
3537
}: ListWrapperProps) => {
3638
const [isCollapse, setIsCollapse] = useState(
3739
localStorageName ? localStorage.getItem(localStorageName) === 'true' : false
@@ -170,6 +172,7 @@ export const ListWrapper = ({
170172
px: { xs: 4, xsm: 6 },
171173
pb: { xs: collapsed && !noData ? 6 : 2, xsm: collapsed && !noData ? 6 : 0 },
172174
overflowX: tooltipOpen ? 'hidden' : 'auto',
175+
...topInfoSx,
173176
}}
174177
>
175178
{topInfo}

src/locales/el/messages.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/locales/en/messages.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/locales/en/messages.po

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1835,6 +1835,10 @@ msgstr "Bridge history"
18351835
msgid "Borrow balance after switch"
18361836
msgstr "Borrow balance after switch"
18371837

1838+
#: src/modules/dashboard/lists/SuppliedPositionsList/SuppliedPositionsList.tsx
1839+
msgid "Show assets with small balance"
1840+
msgstr "Show assets with small balance"
1841+
18381842
#: src/components/transactions/Bridge/BridgeModalContent.tsx
18391843
msgid "Asset has been successfully sent to CCIP contract. You can check the status of the transactions below"
18401844
msgstr "Asset has been successfully sent to CCIP contract. You can check the status of the transactions below"
@@ -3269,7 +3273,7 @@ msgstr "APY"
32693273
msgid "Asset cannot be migrated because you have isolated collateral in {marketName} v3 Market which limits borrowable assets. You can manage your collateral in <0>{marketName} V3 Dashboard</0>"
32703274
msgstr "Asset cannot be migrated because you have isolated collateral in {marketName} v3 Market which limits borrowable assets. You can manage your collateral in <0>{marketName} V3 Dashboard</0>"
32713275

3272-
#: src/modules/dashboard/DashboardListTopPanel.tsx
3276+
#: src/modules/dashboard/lists/SupplyAssetsList/SupplyAssetsList.tsx
32733277
msgid "Show assets with 0 balance"
32743278
msgstr "Show assets with 0 balance"
32753279

src/locales/es/messages.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/locales/fr/messages.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
import { Trans } from '@lingui/macro';
2-
import { Box, Checkbox, FormControlLabel } from '@mui/material';
1+
import { Box, Checkbox, FormControlLabel, SxProps } from '@mui/material';
32
import { FaucetButton } from 'src/components/FaucetButton';
43
import { useRootStore } from 'src/store/root';
5-
import { DASHBOARD } from 'src/utils/events';
6-
import { ENABLE_TESTNET, STAGING_ENV } from 'src/utils/marketsAndNetworksConfig';
74

85
import { BridgeButton } from '../../components/BridgeButton';
96
import { toggleLocalStorageClick } from '../../helpers/toggle-local-storage-click';
@@ -13,13 +10,23 @@ interface DashboardListTopPanelProps extends Pick<NetworkConfig, 'bridge'> {
1310
value: boolean;
1411
onClick: (value: boolean) => void;
1512
localStorageName: string;
13+
eventName: string;
14+
label: React.ReactNode;
15+
showFaucet: boolean;
16+
showBridge: boolean;
17+
sx?: SxProps;
1618
}
1719

1820
export const DashboardListTopPanel = ({
1921
value,
2022
onClick,
2123
localStorageName,
2224
bridge,
25+
eventName,
26+
label,
27+
showFaucet,
28+
showBridge,
29+
sx,
2330
}: DashboardListTopPanelProps) => {
2431
const trackEvent = useRootStore((store) => store.trackEvent);
2532

@@ -33,22 +40,23 @@ export const DashboardListTopPanel = ({
3340
px: { xs: 4, xsm: 6 },
3441
py: 2,
3542
pl: { xs: '18px', xsm: '27px' },
43+
...sx,
3644
}}
3745
>
3846
<FormControlLabel
3947
sx={{ mt: { xs: bridge ? 2 : 0, xsm: 0 } }}
4048
control={<Checkbox sx={{ p: '6px' }} />}
4149
checked={value}
4250
onChange={() => {
43-
trackEvent(DASHBOARD.SHOW_ASSETS_0_BALANCE, {});
51+
trackEvent(eventName, {});
4452

4553
toggleLocalStorageClick(value, onClick, localStorageName);
4654
}}
47-
label={<Trans>Show assets with 0 balance</Trans>}
55+
label={label}
4856
/>
4957

50-
{(STAGING_ENV || ENABLE_TESTNET) && <FaucetButton />}
51-
{!ENABLE_TESTNET && <BridgeButton bridge={bridge} />}
58+
{showFaucet && <FaucetButton />}
59+
{showBridge && <BridgeButton bridge={bridge} />}
5260
</Box>
5361
);
5462
};

src/modules/dashboard/lists/SuppliedPositionsList/SuppliedPositionsList.tsx

Lines changed: 54 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { API_ETH_MOCK_ADDRESS } from '@aave/contract-helpers';
22
import { Trans } from '@lingui/macro';
3-
import { Typography, useMediaQuery, useTheme } from '@mui/material';
4-
import { Fragment, useState } from 'react';
3+
import { Box, Typography, useMediaQuery, useTheme } from '@mui/material';
4+
import { Fragment, useMemo, useState } from 'react';
55
import { ListColumn } from 'src/components/lists/ListColumn';
66
import { ListHeaderTitle } from 'src/components/lists/ListHeaderTitle';
77
import { ListHeaderWrapper } from 'src/components/lists/ListHeaderWrapper';
88
import { AssetCapsProvider } from 'src/hooks/useAssetCaps';
99
import { useRootStore } from 'src/store/root';
1010
import { fetchIconSymbolAndName } from 'src/ui-config/reservePatches';
11-
import { GENERAL } from 'src/utils/events';
11+
import { DASHBOARD, GENERAL } from 'src/utils/events';
1212

1313
import { CollateralSwitchTooltip } from '../../../../components/infoTooltips/CollateralSwitchTooltip';
1414
import { CollateralTooltip } from '../../../../components/infoTooltips/CollateralTooltip';
@@ -23,6 +23,7 @@ import {
2323
import { amountToUsd } from '../../../../utils/utils';
2424
import { ListTopInfoItem } from '../../../dashboard/lists/ListTopInfoItem';
2525
import { DashboardContentNoData } from '../../DashboardContentNoData';
26+
import { DashboardListTopPanel } from '../../DashboardListTopPanel';
2627
import { ListButtonsColumn } from '../ListButtonsColumn';
2728
import { ListLoader } from '../ListLoader';
2829
import { SuppliedPositionsListItem } from './SuppliedPositionsListItem';
@@ -58,6 +59,8 @@ const head = [
5859
},
5960
];
6061

62+
export const SMALL_BALANCE_THRESHOLD = 0.001;
63+
6164
export const SuppliedPositionsList = () => {
6265
const { user, loading, marketReferencePriceInUsd } = useAppDataContext();
6366
const currentNetworkConfig = useRootStore((store) => store.currentNetworkConfig);
@@ -67,33 +70,42 @@ export const SuppliedPositionsList = () => {
6770
const [sortDesc, setSortDesc] = useState(false);
6871
const [tooltipOpen, setTooltipOpen] = useState<boolean>(false);
6972

70-
const suppliedPositions =
71-
user?.userReservesData
72-
.filter((userReserve) => {
73-
if (userReserve.underlyingBalance === '0') return false;
73+
const localStorageName = 'showSuppliedSmallBalanceAssets';
74+
const [isShowSmallBalanceAssets, setIsShowSmallBalanceAssets] = useState(
75+
localStorage.getItem(localStorageName) === 'true'
76+
);
77+
78+
const suppliedPositions = useMemo(() => {
79+
return (
80+
user?.userReservesData
81+
.filter((userReserve) => {
82+
if (userReserve.underlyingBalance === '0') return false;
7483

75-
// Filter out dust amounts < $0.01 USD
76-
const balanceUSD = amountToUsd(
77-
userReserve.underlyingBalance,
78-
userReserve.reserve.formattedPriceInMarketReferenceCurrency,
79-
marketReferencePriceInUsd
80-
);
84+
if (isShowSmallBalanceAssets) return true;
8185

82-
return Number(balanceUSD) >= 0.01;
83-
})
84-
.map((userReserve) => ({
85-
...userReserve,
86-
supplyAPY: userReserve.reserve.supplyAPY, // Note: added only for table sort
87-
reserve: {
88-
...userReserve.reserve,
89-
...(userReserve.reserve.isWrappedBaseAsset
90-
? fetchIconSymbolAndName({
91-
symbol: currentNetworkConfig.baseAssetSymbol,
92-
underlyingAsset: API_ETH_MOCK_ADDRESS.toLowerCase(),
93-
})
94-
: {}),
95-
},
96-
})) || [];
86+
// Filter out dust amounts < $0.01 USD
87+
const balanceUSD = amountToUsd(
88+
userReserve.underlyingBalance,
89+
userReserve.reserve.formattedPriceInMarketReferenceCurrency,
90+
marketReferencePriceInUsd
91+
);
92+
return Number(balanceUSD) >= SMALL_BALANCE_THRESHOLD;
93+
})
94+
.map((userReserve) => ({
95+
...userReserve,
96+
supplyAPY: userReserve.reserve.supplyAPY, // Note: added only for table sort
97+
reserve: {
98+
...userReserve.reserve,
99+
...(userReserve.reserve.isWrappedBaseAsset
100+
? fetchIconSymbolAndName({
101+
symbol: currentNetworkConfig.baseAssetSymbol,
102+
underlyingAsset: API_ETH_MOCK_ADDRESS.toLowerCase(),
103+
})
104+
: {}),
105+
},
106+
})) || []
107+
);
108+
}, [isShowSmallBalanceAssets]);
97109

98110
// Transform to the DashboardReserve schema so the sort utils can work with it
99111
const preSortedReserves = suppliedPositions as DashboardReserve[];
@@ -143,6 +155,20 @@ export const SuppliedPositionsList = () => {
143155
}
144156
localStorageName="suppliedAssetsDashboardTableCollapse"
145157
noData={!sortedReserves.length}
158+
subChildrenComponent={
159+
<Box>
160+
<DashboardListTopPanel
161+
value={isShowSmallBalanceAssets}
162+
onClick={setIsShowSmallBalanceAssets}
163+
localStorageName={localStorageName}
164+
bridge={currentNetworkConfig.bridge}
165+
eventName={DASHBOARD.SHOW_ASSETS_SMALL_BALANCE}
166+
label={<Trans>Show assets with small balance</Trans>}
167+
showFaucet={false}
168+
showBridge={false}
169+
/>
170+
</Box>
171+
}
146172
topInfo={
147173
<>
148174
{!!sortedReserves.length && (

src/modules/dashboard/lists/SupplyAssetsList/SupplyAssetsList.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ import { AssetCapsProvider } from 'src/hooks/useAssetCaps';
1212
import { useWrappedTokens } from 'src/hooks/useWrappedTokens';
1313
import { useRootStore } from 'src/store/root';
1414
import { fetchIconSymbolAndName } from 'src/ui-config/reservePatches';
15+
import { DASHBOARD } from 'src/utils/events';
1516
import { displayGhoForMintableMarket } from 'src/utils/ghoUtilities';
17+
import { ENABLE_TESTNET, STAGING_ENV } from 'src/utils/marketsAndNetworksConfig';
1618

1719
import { ListWrapper } from '../../../../components/lists/ListWrapper';
1820
import { Link, ROUTES } from '../../../../components/primitives/Link';
@@ -286,6 +288,10 @@ export const SupplyAssetsList = () => {
286288
onClick={setIsShowZeroAssets}
287289
localStorageName={localStorageName}
288290
bridge={bridge}
291+
eventName={DASHBOARD.SHOW_ASSETS_0_BALANCE}
292+
label={<Trans>Show assets with 0 balance</Trans>}
293+
showFaucet={STAGING_ENV || ENABLE_TESTNET}
294+
showBridge={!ENABLE_TESTNET}
289295
/>
290296
)}
291297
</>

src/utils/events.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const DASHBOARD = {
4141
NOTIFY_DASHBOARD: 'Notify dashboard', // done
4242
TILE_VISBILITY: 'Tile visibility',
4343
SHOW_ASSETS_0_BALANCE: 'Show assets with zero balance dashboard', // done
44+
SHOW_ASSETS_SMALL_BALANCE: 'Show assets with small balance dashboard',
4445
SELECT_V3_ETH_MARKET: 'Clicks a V3 ETH market from dashboard', // done
4546
};
4647

0 commit comments

Comments
 (0)