From b7aad5868b28db085d9d61c184658c2b3610fd30 Mon Sep 17 00:00:00 2001 From: Daniel Schiavini Date: Fri, 28 Feb 2025 13:23:10 +0100 Subject: [PATCH 1/8] chore: remove unused and useless code --- .../GaugeVotingBarChartCustomTooltip.tsx | 7 -- .../components/Charts/LineChartComponent.tsx | 2 +- .../Charts/LineChartCustomTooltip.tsx | 6 -- .../ComboBoxSelectGauge/ComboBoxListItem.tsx | 5 -- apps/main/src/dao/components/MetricsComp.tsx | 6 -- .../PositiveAndNegativeBarChartTooltip.tsx | 6 -- .../src/dao/components/PageAnalytics/Page.tsx | 2 +- .../VeCrvFeesChart/FeesBarChartTooltip.tsx | 6 -- .../PageGauges/GaugeListItem/GaugeDetails.tsx | 2 +- .../GaugeListItem/GaugeDetailsSm.tsx | 2 +- .../GaugeListItem/SmallScreenCard.tsx | 5 -- .../PageUser/UserLocksTable/index.tsx | 3 +- .../src/dao/components/PageUser/index.tsx | 2 +- .../components/PaginatedTable/TableRow.tsx | 3 +- .../ProposalVoteStatusBox/index.tsx | 3 +- .../src/dao/components/UserBox/VoteDialog.tsx | 3 +- .../main/src/dao/components/UserBox/index.tsx | 3 +- .../src/dao/store/createProposalsSlice.ts | 6 +- apps/main/src/dao/store/createUserSlice.ts | 11 +-- apps/main/src/dao/utils/index.ts | 5 +- apps/main/src/dao/utils/utilsDates.ts | 10 +-- .../PageCreatePool/ConfirmModal/index.tsx | 28 ------- .../Parameters/SelectPreset.tsx | 6 -- .../PageCreatePool/TokensInPool/index.tsx | 14 ++-- .../components/SwitchTokensButton.tsx | 3 +- .../components/PageCreatePool/constants.ts | 5 -- .../dex/components/PageCreatePool/types.ts | 16 ---- .../dex/components/PageDeployGauge/index.tsx | 2 +- .../ChartOhlcWrapper/PoolActivity.tsx | 2 - .../PoolDetails/ChartOhlcWrapper/index.tsx | 2 - .../PoolDetails/ChartOhlcWrapper/types.ts | 2 - .../PagePoolList/components/PoolRow.tsx | 2 +- .../PagePoolList/components/TableRow.tsx | 2 +- .../components/TableRowMobile.tsx | 2 +- .../src/dex/components/PagePoolList/index.tsx | 8 -- .../src/dex/components/PagePoolList/types.ts | 2 - apps/main/src/dex/components/PoolLabel.tsx | 2 +- apps/main/src/dex/entities/appstats-tvl.ts | 2 +- .../src/dex/entities/gauge/api/gauge-query.ts | 12 --- .../src/dex/entities/gauge/lib/gauge-info.ts | 9 --- .../dex/entities/gauge/model/query-options.ts | 29 +------ apps/main/src/dex/entities/gauge/types.ts | 12 --- .../model/default-values.ts | 2 +- .../ui/ActionsStepper.tsx | 2 +- .../ui/AmountTokenInput.tsx | 2 +- .../deposit-gauge-reward/ui/DepositReward.tsx | 2 +- .../deposit-gauge-reward/ui/HelperFields.tsx | 3 +- apps/main/src/dex/lib/utils.ts | 2 +- .../src/dex/store/createDeployGaugeSlice.ts | 30 ++++---- apps/main/src/dex/store/types.ts | 7 -- apps/main/src/dex/utils/utilsStyles.ts | 19 ----- .../widgets/manage-gauge/ui/ManageGauge.tsx | 7 +- .../ChartOhlcWrapper/LiquidityData.tsx | 5 -- .../components/ChartOhlcWrapper/index.tsx | 28 +++---- .../src/lend/components/DetailsUser/styles.ts | 18 ----- .../TableRowViewContentTable/TableRow.tsx | 2 +- .../TableRowMobileContent.tsx | 2 +- .../SharedCellData/CellHealthStatus.tsx | 7 +- .../SharedCellData/CellLoanUserState.tsx | 2 +- .../lend/hooks/useCampaignRewardsMapper.tsx | 3 +- apps/main/src/lend/utils/helpers.ts | 5 +- apps/main/src/lend/utils/utilsGasPrices.ts | 48 ------------ .../components/ChartOhlcWrapper/index.tsx | 27 +++---- .../loan/components/LoanInfoUser/index.tsx | 4 +- .../DepositWithdraw/DepositModule.tsx | 2 - .../DepositWithdraw/WithdrawModule.tsx | 2 - .../TransactionDetails/index.tsx | 16 ---- .../UserInformation/index.tsx | 2 +- .../components/InputComp/NumberField.tsx | 2 +- .../components/InputComp/index.tsx | 8 -- .../components/PageCrvUsdStaking/index.tsx | 4 +- .../components/PageCrvUsdStaking/utils.ts | 2 - apps/main/src/loan/entities/scrvusdRevenue.ts | 4 +- .../src/loan/entities/scrvusdUserStats.ts | 6 +- .../main/src/loan/store/createScrvUsdSlice.ts | 3 +- apps/main/src/loan/utils/helpers.ts | 6 +- apps/main/src/loan/utils/utilsGasPrices.ts | 48 ------------ apps/main/src/loan/utils/utilsStyles.ts | 10 --- .../lib/model/query/chain-name-validation.ts | 3 - .../src/lib/model/query/chain-validation.ts | 3 - .../curve-ui-kit/src/lib/queries/combine.ts | 11 --- .../curve-ui-kit/src/lib/queries/factory.ts | 5 -- packages/curve-ui-kit/src/utils/BigDecimal.ts | 14 ++-- .../curve-ui-kit/src/widgets/Header/types.ts | 2 - packages/prices-api/src/crvusd/models.ts | 10 --- packages/prices-api/src/index.ts | 4 +- packages/prices-api/src/llamalend/models.ts | 2 - packages/prices-api/src/proposal/index.ts | 1 - packages/prices-api/src/proposal/util.ts | 30 -------- packages/prices-api/src/revenue/api.ts | 4 +- packages/ui/src/AppPage/styles.ts | 8 -- packages/ui/src/Chart/CandleChart.tsx | 22 +++--- packages/ui/src/Chart/ChartWrapper.tsx | 5 -- packages/ui/src/Chart/types.ts | 51 ------------ packages/ui/src/Chart/utils.ts | 77 +------------------ packages/ui/src/Radio/Radio.tsx | 2 +- .../ui/src/Select/SelectSortingMethod.tsx | 4 - packages/ui/src/Tooltip/Tooltip.tsx | 2 +- packages/ui/src/utils/helpers.ts | 4 +- tests/cypress/support/helpers/metamask.ts | 3 +- tests/runHardhatNodes.js | 12 +-- 101 files changed, 125 insertions(+), 756 deletions(-) delete mode 100644 apps/main/src/dex/components/PagePool/PoolDetails/ChartOhlcWrapper/types.ts delete mode 100644 apps/main/src/dex/utils/utilsStyles.ts delete mode 100644 apps/main/src/lend/components/DetailsUser/styles.ts delete mode 100644 apps/main/src/lend/utils/utilsGasPrices.ts delete mode 100644 apps/main/src/loan/utils/utilsGasPrices.ts delete mode 100644 apps/main/src/loan/utils/utilsStyles.ts delete mode 100644 packages/prices-api/src/proposal/util.ts diff --git a/apps/main/src/dao/components/Charts/GaugeVotingBarChartCustomTooltip.tsx b/apps/main/src/dao/components/Charts/GaugeVotingBarChartCustomTooltip.tsx index 079262995..be8d7b7d4 100644 --- a/apps/main/src/dao/components/Charts/GaugeVotingBarChartCustomTooltip.tsx +++ b/apps/main/src/dao/components/Charts/GaugeVotingBarChartCustomTooltip.tsx @@ -68,11 +68,4 @@ const TooltipData = styled.p` color: var(--chart-red); } ` -const TooltipDataNotAvailable = styled.p` - font-size: var(--font-size-1); - font-weight: var(--semi-bold); - color: var(--page--text-color); - font-style: italic; -` - export default BarChartCustomTooltip diff --git a/apps/main/src/dao/components/Charts/LineChartComponent.tsx b/apps/main/src/dao/components/Charts/LineChartComponent.tsx index e77e75115..f60896d75 100644 --- a/apps/main/src/dao/components/Charts/LineChartComponent.tsx +++ b/apps/main/src/dao/components/Charts/LineChartComponent.tsx @@ -52,7 +52,7 @@ const LineChartComponent = ({ data, height = 400 }: Props) => { verticalAlign="top" iconSize={0} height={32} - formatter={(value) => 'Relative Gauge Weight'} + formatter={() => 'Relative Gauge Weight'} wrapperStyle={{ fontWeight: 'bold', fontSize: 'var(--font-size-1)', diff --git a/apps/main/src/dao/components/Charts/LineChartCustomTooltip.tsx b/apps/main/src/dao/components/Charts/LineChartCustomTooltip.tsx index 3cd3677c1..a5cd6a489 100644 --- a/apps/main/src/dao/components/Charts/LineChartCustomTooltip.tsx +++ b/apps/main/src/dao/components/Charts/LineChartCustomTooltip.tsx @@ -76,12 +76,6 @@ const TooltipWrapper = styled.div` gap: var(--spacing-2); ` -const TooltipTitle = styled.p` - font-size: var(--font-size-3); - color: var(--page--text-color); - font-weight: var(--bold); -` - const TooltipColumn = styled.div` display: flex; flex-direction: column; diff --git a/apps/main/src/dao/components/ComboBoxSelectGauge/ComboBoxListItem.tsx b/apps/main/src/dao/components/ComboBoxSelectGauge/ComboBoxListItem.tsx index 6fe882f4d..eaa5fbc56 100644 --- a/apps/main/src/dao/components/ComboBoxSelectGauge/ComboBoxListItem.tsx +++ b/apps/main/src/dao/components/ComboBoxSelectGauge/ComboBoxListItem.tsx @@ -56,11 +56,6 @@ const ItemButton = styled(Button)` width: 100%; ` -const IconWrapper = styled.div` - min-width: 1.875rem; // 30px; - text-align: left; -` - const LabelText = styled.div` overflow: hidden; diff --git a/apps/main/src/dao/components/MetricsComp.tsx b/apps/main/src/dao/components/MetricsComp.tsx index accab16c4..79949ee08 100644 --- a/apps/main/src/dao/components/MetricsComp.tsx +++ b/apps/main/src/dao/components/MetricsComp.tsx @@ -47,10 +47,4 @@ export const MetricsColumnData = styled.h3<{ noMargin?: boolean }>` margin-top: ${({ noMargin }) => (noMargin ? '0' : 'var(--spacing-1)')}; font-size: var(--font-size-2); ` - -export const MetricsRowData = styled.h3` - font-size: var(--font-size-2); - margin-left: var(--spacing-1); -` - export default MetricsComp diff --git a/apps/main/src/dao/components/PageAnalytics/DailyLocksChart/PositiveAndNegativeBarChartTooltip.tsx b/apps/main/src/dao/components/PageAnalytics/DailyLocksChart/PositiveAndNegativeBarChartTooltip.tsx index c67634f22..5253c0b2d 100644 --- a/apps/main/src/dao/components/PageAnalytics/DailyLocksChart/PositiveAndNegativeBarChartTooltip.tsx +++ b/apps/main/src/dao/components/PageAnalytics/DailyLocksChart/PositiveAndNegativeBarChartTooltip.tsx @@ -64,11 +64,5 @@ const TooltipData = styled.p` color: var(--chart-red); } ` -const TooltipDataNotAvailable = styled.p` - font-size: var(--font-size-1); - font-weight: var(--semi-bold); - color: var(--page--text-color); - font-style: italic; -` export default PositiveAndNegativeBarChartTooltip diff --git a/apps/main/src/dao/components/PageAnalytics/Page.tsx b/apps/main/src/dao/components/PageAnalytics/Page.tsx index dde70a80a..391eb34f2 100644 --- a/apps/main/src/dao/components/PageAnalytics/Page.tsx +++ b/apps/main/src/dao/components/PageAnalytics/Page.tsx @@ -15,7 +15,7 @@ const Page: NextPage = () => { const params = useParams() const location = useLocation() const navigate = useNavigate() - const { routerParams } = usePageOnMount(params, location, navigate) + usePageOnMount(params, location, navigate) useEffect(() => { scrollToTop() diff --git a/apps/main/src/dao/components/PageAnalytics/VeCrvFeesChart/FeesBarChartTooltip.tsx b/apps/main/src/dao/components/PageAnalytics/VeCrvFeesChart/FeesBarChartTooltip.tsx index d7cd45a20..e3f434802 100644 --- a/apps/main/src/dao/components/PageAnalytics/VeCrvFeesChart/FeesBarChartTooltip.tsx +++ b/apps/main/src/dao/components/PageAnalytics/VeCrvFeesChart/FeesBarChartTooltip.tsx @@ -70,11 +70,5 @@ const TooltipData = styled.p` color: var(--chart-red); } ` -const TooltipDataNotAvailable = styled.p` - font-size: var(--font-size-1); - font-weight: var(--semi-bold); - color: var(--page--text-color); - font-style: italic; -` export default FeesBarChartTooltip diff --git a/apps/main/src/dao/components/PageGauges/GaugeListItem/GaugeDetails.tsx b/apps/main/src/dao/components/PageGauges/GaugeListItem/GaugeDetails.tsx index 63c2ec98b..6fbb85ee3 100644 --- a/apps/main/src/dao/components/PageGauges/GaugeListItem/GaugeDetails.tsx +++ b/apps/main/src/dao/components/PageGauges/GaugeListItem/GaugeDetails.tsx @@ -47,7 +47,7 @@ const GaugeDetails = ({ gaugeData, className }: { gaugeData: GaugeFormattedData; : 'N/A'}
- {gaugeData.pool?.tvl_usd && gaugeData.pool.tvl_usd !== undefined + {gaugeData.pool?.tvl_usd ? formatNumber(gaugeData.pool.tvl_usd, { showDecimalIfSmallNumberOnly: true, currency: 'USD', diff --git a/apps/main/src/dao/components/PageGauges/GaugeListItem/GaugeDetailsSm.tsx b/apps/main/src/dao/components/PageGauges/GaugeListItem/GaugeDetailsSm.tsx index 27bb554b2..afc5aa083 100644 --- a/apps/main/src/dao/components/PageGauges/GaugeListItem/GaugeDetailsSm.tsx +++ b/apps/main/src/dao/components/PageGauges/GaugeListItem/GaugeDetailsSm.tsx @@ -112,7 +112,7 @@ const GaugeDetailsSm = ({ gaugeData, userGaugeWeightVoteData, className }: Gauge {t`TVL`} - {gaugeData.pool?.tvl_usd && gaugeData.pool.tvl_usd !== undefined + {gaugeData.pool?.tvl_usd ? formatNumber(gaugeData.pool.tvl_usd, { showDecimalIfSmallNumberOnly: true, currency: 'USD', diff --git a/apps/main/src/dao/components/PageGauges/GaugeListItem/SmallScreenCard.tsx b/apps/main/src/dao/components/PageGauges/GaugeListItem/SmallScreenCard.tsx index 53898475e..f62e4abbf 100644 --- a/apps/main/src/dao/components/PageGauges/GaugeListItem/SmallScreenCard.tsx +++ b/apps/main/src/dao/components/PageGauges/GaugeListItem/SmallScreenCard.tsx @@ -147,11 +147,6 @@ const StyledTitleComp = styled(TitleComp)` margin-right: auto; ` -const DataComp = styled.div` - display: grid; - grid-template-columns: 1fr 1fr; -` - const GaugeDataTitle = styled.p` font-size: var(--font-size-1); text-align: right; diff --git a/apps/main/src/dao/components/PageUser/UserLocksTable/index.tsx b/apps/main/src/dao/components/PageUser/UserLocksTable/index.tsx index b1662f478..c9f9d2d42 100644 --- a/apps/main/src/dao/components/PageUser/UserLocksTable/index.tsx +++ b/apps/main/src/dao/components/PageUser/UserLocksTable/index.tsx @@ -13,10 +13,9 @@ import { UserLock, UserLocksSortBy, veCrvLockType } from '@/dao/types/dao.types' interface UserLocksTableProps { userAddress: string - tableMinWidth: number } -const UserLocksTable = ({ userAddress, tableMinWidth }: UserLocksTableProps) => { +const UserLocksTable = ({ userAddress }: UserLocksTableProps) => { const { getUserLocks, userLocksMapper, userLocksSortBy, setUserLocksSortBy } = useStore((state) => state.user) const gridTemplateColumns = '5.375rem 1fr 10rem 8rem' diff --git a/apps/main/src/dao/components/PageUser/index.tsx b/apps/main/src/dao/components/PageUser/index.tsx index cd6dcdc68..f44f66c91 100644 --- a/apps/main/src/dao/components/PageUser/index.tsx +++ b/apps/main/src/dao/components/PageUser/index.tsx @@ -78,7 +78,7 @@ const UserPage = ({ routerParams: { rUserAddress } }: UserPageProps) => { {activeNavKey === 'gauge_votes' && ( )} - {activeNavKey === 'locks' && } + {activeNavKey === 'locks' && } diff --git a/apps/main/src/dao/components/PaginatedTable/TableRow.tsx b/apps/main/src/dao/components/PaginatedTable/TableRow.tsx index e737b19ee..e8a3c6c35 100644 --- a/apps/main/src/dao/components/PaginatedTable/TableRow.tsx +++ b/apps/main/src/dao/components/PaginatedTable/TableRow.tsx @@ -10,11 +10,10 @@ interface TableRowProps { holder: any sortBy: { key: string; label: string; order: 'asc' | 'desc' } labels: { key: string; label: string }[] - rank: number gridTemplateColumns?: string } -const TableRow = ({ holder, sortBy, labels, rank, gridTemplateColumns }: TableRowProps) => ( +const TableRow = ({ holder, sortBy, labels, gridTemplateColumns }: TableRowProps) => ( {labels.map((label, index) => ( diff --git a/apps/main/src/dao/components/ProposalVoteStatusBox/index.tsx b/apps/main/src/dao/components/ProposalVoteStatusBox/index.tsx index 025035489..adc3a81b9 100644 --- a/apps/main/src/dao/components/ProposalVoteStatusBox/index.tsx +++ b/apps/main/src/dao/components/ProposalVoteStatusBox/index.tsx @@ -14,8 +14,7 @@ type ProposalVoteStatusBoxProps = { } const ProposalVoteStatusBox = ({ proposalData, className }: ProposalVoteStatusBoxProps) => { - const { votesFor, votesAgainst, quorumVeCrv, minAcceptQuorumPercent, minSupport, currentQuorumPercentage } = - proposalData + const { votesFor, votesAgainst, minAcceptQuorumPercent, minSupport, currentQuorumPercentage } = proposalData const totalVotes = votesFor + votesAgainst const support = totalVotes > 0 ? (votesFor / totalVotes) * 100 : 0 diff --git a/apps/main/src/dao/components/UserBox/VoteDialog.tsx b/apps/main/src/dao/components/UserBox/VoteDialog.tsx index 6b9efd2df..58fb360cd 100644 --- a/apps/main/src/dao/components/UserBox/VoteDialog.tsx +++ b/apps/main/src/dao/components/UserBox/VoteDialog.tsx @@ -14,14 +14,13 @@ import { ProposalType, SnapshotVotingPower, ActiveProposal } from '@/dao/types/d type Props = { userAddress: string activeProposal?: ActiveProposal - testId?: string proposalId?: string votingPower: SnapshotVotingPower snapshotVotingPower: boolean className?: string } -const VoteDialog = ({ userAddress, activeProposal, testId, className, votingPower, proposalId }: Props) => { +const VoteDialog = ({ userAddress, activeProposal, className, votingPower, proposalId }: Props) => { const { castVote, voteTxMapper, executeProposal, executeTxMapper } = useStore((state) => state.proposals) const userProposalVote = useStore((state) => state.proposals.userProposalVoteMapper[proposalId ?? '']) ?? null const pricesProposal = useStore((state) => state.proposals.proposalMapper[proposalId ?? '']) diff --git a/apps/main/src/dao/components/UserBox/index.tsx b/apps/main/src/dao/components/UserBox/index.tsx index f5f43296a..982f43474 100644 --- a/apps/main/src/dao/components/UserBox/index.tsx +++ b/apps/main/src/dao/components/UserBox/index.tsx @@ -13,10 +13,9 @@ type Props = { votingPower?: SnapshotVotingPower activeProposal?: ActiveProposal snapshotVotingPower: boolean - row?: boolean } -const UserBox = ({ className, children, votingPower, snapshotVotingPower, activeProposal, row }: Props) => { +const UserBox = ({ className, children, votingPower, snapshotVotingPower, activeProposal }: Props) => { const { wallet, connect } = useWallet() return ( diff --git a/apps/main/src/dao/store/createProposalsSlice.ts b/apps/main/src/dao/store/createProposalsSlice.ts index 628c0c6be..790f6330e 100644 --- a/apps/main/src/dao/store/createProposalsSlice.ts +++ b/apps/main/src/dao/store/createProposalsSlice.ts @@ -23,7 +23,7 @@ import { TransactionState, UserProposalVoteResData, } from '@/dao/types/dao.types' -import { useWallet, notify } from '@ui-kit/features/connect-wallet' +import { notify, useWallet } from '@ui-kit/features/connect-wallet' type StateKey = keyof typeof DEFAULT_STATE @@ -297,9 +297,7 @@ const createProposalsSlice = (set: SetState, get: GetState): Propo const proposals = Object.values(proposalsData) const filteredProposals = filterProposals(proposals, activeFilter) - const sortedProposals = sortProposals(filteredProposals, activeSortBy, activeSortDirection) - - return sortedProposals + return sortProposals(filteredProposals, activeSortBy, activeSortDirection) }, setProposals: (searchValue: string) => { const { selectFilteredSortedProposals, activeSortBy, activeSortDirection } = get()[sliceKey] diff --git a/apps/main/src/dao/store/createUserSlice.ts b/apps/main/src/dao/store/createUserSlice.ts index ae6694e61..2f856a125 100644 --- a/apps/main/src/dao/store/createUserSlice.ts +++ b/apps/main/src/dao/store/createUserSlice.ts @@ -512,8 +512,7 @@ const createUserSlice = (set: SetState, get: GetState): UserSlice set( produce((state) => { - const reversedEntries = [...locks].reverse() - state[sliceKey].userLocksMapper[address].locks = reversedEntries + state[sliceKey].userLocksMapper[address].locks = [...locks].reverse() state[sliceKey].userLocksSortBy.order = order }), ) @@ -590,8 +589,7 @@ const createUserSlice = (set: SetState, get: GetState): UserSlice set( produce((state) => { - const reversedEntries = [...votes].reverse() - state[sliceKey].userGaugeVotesMapper[address].votes = reversedEntries + state[sliceKey].userGaugeVotesMapper[address].votes = [...votes].reverse() state[sliceKey].userGaugeVotesSortBy.order = order }), ) @@ -623,8 +621,7 @@ const createUserSlice = (set: SetState, get: GetState): UserSlice set( produce((state) => { - const reversedEntries = [...data.gauges].reverse() - state[sliceKey].userGaugeVoteWeightsMapper[address].data.gauges = reversedEntries + state[sliceKey].userGaugeVoteWeightsMapper[address].data.gauges = [...data.gauges].reverse() state[sliceKey].userGaugeVoteWeightsSortBy.order = order }), ) @@ -680,6 +677,4 @@ const createUserSlice = (set: SetState, get: GetState): UserSlice }, }) -const calculateGaugeVoteStale = (usedVeCrv: number, futureVeCrv: number) => usedVeCrv < futureVeCrv - export default createUserSlice diff --git a/apps/main/src/dao/utils/index.ts b/apps/main/src/dao/utils/index.ts index 23b208a20..024e80dae 100644 --- a/apps/main/src/dao/utils/index.ts +++ b/apps/main/src/dao/utils/index.ts @@ -10,7 +10,7 @@ export function copyToClipboard(text: string) { // IE specific code path to prevent textarea being shown while dialog is visible. return window.clipboardData.setData('Text', text) } else if (document.queryCommandSupported && document.queryCommandSupported('copy')) { - var textarea = document.createElement('textarea') + const textarea = document.createElement('textarea') textarea.textContent = text textarea.style.position = 'fixed' // Prevent scrolling to bottom of page in MS Edge. document.body.appendChild(textarea) @@ -65,6 +65,5 @@ export const httpFetcher = (uri: string) => fetch(uri).then((res) => res.json()) export function getChainIdFromGaugeData(gaugeData: GaugeFormattedData | undefined) { if (!gaugeData) return 1 const gaugeNetwork = gaugeData?.pool?.chain ?? gaugeData?.market?.chain ?? 'ethereum' - const chainId = Chain[upperFirst(gaugeNetwork) as keyof typeof Chain] ?? 1 - return chainId + return Chain[upperFirst(gaugeNetwork) as keyof typeof Chain] ?? 1 } diff --git a/apps/main/src/dao/utils/utilsDates.ts b/apps/main/src/dao/utils/utilsDates.ts index 32a6dfd12..1881565db 100644 --- a/apps/main/src/dao/utils/utilsDates.ts +++ b/apps/main/src/dao/utils/utilsDates.ts @@ -1,16 +1,8 @@ import type { Dayjs } from 'dayjs' - import { parseDate } from '@internationalized/date' import dayjs from '@ui-kit/lib/dayjs' -export function todayInMilliseconds() { - const parsedToday = dayjs().format('YYYY-MM-DD') - return dayjs(parsedToday).valueOf() -} - -export function toCalendarDate(date: Dayjs) { - return parseDate(date.format('YYYY-MM-DD')) -} +export const toCalendarDate = (date: Dayjs) => parseDate(date.format('YYYY-MM-DD')) export function formatDisplayDate(date: Dayjs | string) { const parsedDate = typeof date === 'string' ? dayjs(date) : date diff --git a/apps/main/src/dex/components/PageCreatePool/ConfirmModal/index.tsx b/apps/main/src/dex/components/PageCreatePool/ConfirmModal/index.tsx index be2123038..4d7ae1ad2 100644 --- a/apps/main/src/dex/components/PageCreatePool/ConfirmModal/index.tsx +++ b/apps/main/src/dex/components/PageCreatePool/ConfirmModal/index.tsx @@ -377,34 +377,6 @@ const StyledButtonSpinner = styled(Spinner)` } ` -const StyledPendingSpinner = styled(Spinner)` - margin: var(--spacing-4) auto; - > div { - border-color: var(--page--text-color) transparent transparent transparent; - } -` - -const Transaction = styled(ExternalLink)` - display: flex; - align-items: center; - font-size: var(--font-size-2); - font-weight: var(--semi-bold); - color: var(--page--text-color); - text-transform: none; - text-decoration: none; - background-color: var(--page--background-color); - padding: var(--spacing-2); - p { - font-weight: var(--bold); - margin-right: var(--spacing-1); - } -` - -const StyledIcon = styled(Icon)` - margin: auto 0 auto var(--spacing-1); - color: var(--page--text-color); -` - const ButtonWrapper = styled.div` margin: 0 var(--spacing-normal); ` diff --git a/apps/main/src/dex/components/PageCreatePool/Parameters/SelectPreset.tsx b/apps/main/src/dex/components/PageCreatePool/Parameters/SelectPreset.tsx index eeb3be4b1..69ffb6494 100644 --- a/apps/main/src/dex/components/PageCreatePool/Parameters/SelectPreset.tsx +++ b/apps/main/src/dex/components/PageCreatePool/Parameters/SelectPreset.tsx @@ -341,10 +341,4 @@ const StyledExternalLink = styled(ExternalLink)` } ` -const InternalLink = styled.a` - color: var(--page--text-color); - font-weight: var(--bold); - text-decoration: underline; -` - export default SelectPreset diff --git a/apps/main/src/dex/components/PageCreatePool/TokensInPool/index.tsx b/apps/main/src/dex/components/PageCreatePool/TokensInPool/index.tsx index 44efad82a..56c34baae 100644 --- a/apps/main/src/dex/components/PageCreatePool/TokensInPool/index.tsx +++ b/apps/main/src/dex/components/PageCreatePool/TokensInPool/index.tsx @@ -608,7 +608,7 @@ const TokensInPool = ({ curve, chainId, haveSigner }: Props) => { flexJustifyContent="center" className={`${swapType === CRYPTOSWAP ? 'extra-margin-top' : ''}`} > - + {/* Token B */} { flexJustifyContent="center" className={`${swapType === CRYPTOSWAP ? 'extra-margin-top' : ''}`} > - + {/* Token C */} { {tokensInPool.tokenAmount > 3 && ( <> - + {/* Token D */} { {tokensInPool.tokenAmount > 4 && ( <> - + {/* Token D */} { {tokensInPool.tokenAmount > 5 && ( <> - + {/* Token D */} { {tokensInPool.tokenAmount > 6 && ( <> - + {/* Token D */} { {tokensInPool.tokenAmount > 7 && ( <> - + {/* Token D */} { +const SwitchTokensButton = ({ curve, from, to, disabled, className }: Props) => { const { tokenA, tokenB, tokenC, tokenD, tokenE, tokenF, tokenG, tokenH } = useStore( (state) => state.createPool.tokensInPool, ) diff --git a/apps/main/src/dex/components/PageCreatePool/constants.ts b/apps/main/src/dex/components/PageCreatePool/constants.ts index 7049a1afc..2009244f3 100644 --- a/apps/main/src/dex/components/PageCreatePool/constants.ts +++ b/apps/main/src/dex/components/PageCreatePool/constants.ts @@ -230,11 +230,6 @@ export const IMPLEMENTATION_IDS = ( } } -export const DEFAULT_INITIAL_PRICE = { - min: 0.000000000001, - max: 1000000000000, -} - // MIN-MAX PARAMS export const STABLESWAP_MIN_MAX_PARAMETERS = (swapFee: number) => ({ diff --git a/apps/main/src/dex/components/PageCreatePool/types.ts b/apps/main/src/dex/components/PageCreatePool/types.ts index f14f02f3f..6392edc44 100644 --- a/apps/main/src/dex/components/PageCreatePool/types.ts +++ b/apps/main/src/dex/components/PageCreatePool/types.ts @@ -24,28 +24,12 @@ export type CreateToken = { basePool?: boolean } -export type CreateTokensMapper = { - [address: string]: CreateToken -} - export type CreateQuickListToken = { address: string haveSameTokenName?: boolean symbol: string } -export type BasePoolToken = { - namne: string - token: string - pool: string -} - -export type PoolPreset = { - name: string - descriptionName: string - description: string -} - export type TokenState = { address: string symbol: string diff --git a/apps/main/src/dex/components/PageDeployGauge/index.tsx b/apps/main/src/dex/components/PageDeployGauge/index.tsx index aef610c48..ec47317b0 100644 --- a/apps/main/src/dex/components/PageDeployGauge/index.tsx +++ b/apps/main/src/dex/components/PageDeployGauge/index.tsx @@ -46,7 +46,7 @@ const DeployGauge = ({ curve }: Props) => { const overlayTriggerState = useOverlayTriggerState({}) const openButtonRef = useRef(null) - const { buttonProps: openButtonProps } = useButton({ onPressEnd: () => overlayTriggerState.open() }, openButtonRef) + useButton({ onPressEnd: () => overlayTriggerState.open() }, openButtonRef) const validateDeployButton = useMemo(() => { // validate sidechain gauge deployment diff --git a/apps/main/src/dex/components/PagePool/PoolDetails/ChartOhlcWrapper/PoolActivity.tsx b/apps/main/src/dex/components/PagePool/PoolDetails/ChartOhlcWrapper/PoolActivity.tsx index aaef3c4b8..fb66d7efa 100644 --- a/apps/main/src/dex/components/PagePool/PoolDetails/ChartOhlcWrapper/PoolActivity.tsx +++ b/apps/main/src/dex/components/PagePool/PoolDetails/ChartOhlcWrapper/PoolActivity.tsx @@ -20,7 +20,6 @@ const PoolActivity = ({ coins, tradesTokens, chartCombinations, - refetchPricesData, }: { poolAddress: string chainId: ChainId @@ -28,7 +27,6 @@ const PoolActivity = ({ coins: PricesApiCoin[] tradesTokens: LpTradeToken[] chartCombinations: PricesApiCoin[][] - refetchPricesData: () => void }) => { const activityHidden = useStore((state) => state.pools.pricesApiState.activityHidden) const { diff --git a/apps/main/src/dex/components/PagePool/PoolDetails/ChartOhlcWrapper/index.tsx b/apps/main/src/dex/components/PagePool/PoolDetails/ChartOhlcWrapper/index.tsx index 479ae2481..8eeb78171 100644 --- a/apps/main/src/dex/components/PagePool/PoolDetails/ChartOhlcWrapper/index.tsx +++ b/apps/main/src/dex/components/PagePool/PoolDetails/ChartOhlcWrapper/index.tsx @@ -232,7 +232,6 @@ const PoolInfoData = ({ rChainId, pricesApiPoolData }: { rChainId: ChainId; pric poolAddress={pricesApiPoolData.address} chainId={rChainId} chartCombinations={chartCombinations} - refetchPricesData={refetchPricesData} /> @@ -268,7 +267,6 @@ const PoolInfoData = ({ rChainId, pricesApiPoolData }: { rChainId: ChainId; pric poolAddress={pricesApiPoolData.address} chainId={rChainId} chartCombinations={chartCombinations} - refetchPricesData={refetchPricesData} /> )} {poolInfo === 'chart' && ( diff --git a/apps/main/src/dex/components/PagePool/PoolDetails/ChartOhlcWrapper/types.ts b/apps/main/src/dex/components/PagePool/PoolDetails/ChartOhlcWrapper/types.ts deleted file mode 100644 index c1fa889ad..000000000 --- a/apps/main/src/dex/components/PagePool/PoolDetails/ChartOhlcWrapper/types.ts +++ /dev/null @@ -1,2 +0,0 @@ -export type TimeOptions = '15m' | '30m' | '1h' | '4h' | '6h' | '12h' | '1d' | '7d' | '14d' -export type OhlcIntervals = 900 | 3600 | 14400 | 86400 diff --git a/apps/main/src/dex/components/PagePoolList/components/PoolRow.tsx b/apps/main/src/dex/components/PagePoolList/components/PoolRow.tsx index fc513496e..d9e0484e1 100644 --- a/apps/main/src/dex/components/PagePoolList/components/PoolRow.tsx +++ b/apps/main/src/dex/components/PagePoolList/components/PoolRow.tsx @@ -7,7 +7,7 @@ import type { import { ROUTE } from '@/dex/constants' import TableRowMobile from '@/dex/components/PagePoolList/components/TableRowMobile' import TableRow, { TableRowProps } from '@/dex/components/PagePoolList/components/TableRow' -import React, { FunctionComponent, useCallback, useMemo } from 'react' +import React, { useCallback, useMemo } from 'react' import useStore from '@/dex/store/useStore' import { getUserActiveKey } from '@/dex/store/createUserSlice' import { useNavigate } from 'react-router-dom' diff --git a/apps/main/src/dex/components/PagePoolList/components/TableRow.tsx b/apps/main/src/dex/components/PagePoolList/components/TableRow.tsx index 15788b3c1..5deff72de 100644 --- a/apps/main/src/dex/components/PagePoolList/components/TableRow.tsx +++ b/apps/main/src/dex/components/PagePoolList/components/TableRow.tsx @@ -3,7 +3,7 @@ import type { CampaignRewardsMapper } from 'ui/src/CampaignRewards/types' import React from 'react' import { t } from '@ui-kit/lib/i18n' -import { FunctionComponent, HTMLAttributes, useEffect, useRef, useState } from 'react' +import { HTMLAttributes, useEffect, useRef, useState } from 'react' import { COLUMN_KEYS } from '@/dex/components/PagePoolList/utils' import useIntersectionObserver from '@ui/hooks/useIntersectionObserver' diff --git a/apps/main/src/dex/components/PagePoolList/components/TableRowMobile.tsx b/apps/main/src/dex/components/PagePoolList/components/TableRowMobile.tsx index d4239d4f0..77d39a090 100644 --- a/apps/main/src/dex/components/PagePoolList/components/TableRowMobile.tsx +++ b/apps/main/src/dex/components/PagePoolList/components/TableRowMobile.tsx @@ -2,7 +2,7 @@ import type { PoolListTableLabel } from '@/dex/components/PagePoolList/types' import type { CampaignRewardsMapper } from '@ui/CampaignRewards/types' import { t } from '@ui-kit/lib/i18n' -import React, { FunctionComponent, useMemo } from 'react' +import React, { useMemo } from 'react' import styled from 'styled-components' import { COLUMN_KEYS } from '@/dex/components/PagePoolList/utils' diff --git a/apps/main/src/dex/components/PagePoolList/index.tsx b/apps/main/src/dex/components/PagePoolList/index.tsx index 67618ece7..84545d678 100644 --- a/apps/main/src/dex/components/PagePoolList/index.tsx +++ b/apps/main/src/dex/components/PagePoolList/index.tsx @@ -234,12 +234,4 @@ const PoolList = ({ ) } -const ConnectWalletWrapper = styled.div` - display: flex; - justify-content: center; - align-items: center; - height: 100%; - width: 100%; -` - export default PoolList diff --git a/apps/main/src/dex/components/PagePoolList/types.ts b/apps/main/src/dex/components/PagePoolList/types.ts index 76286f161..62b9590f5 100644 --- a/apps/main/src/dex/components/PagePoolList/types.ts +++ b/apps/main/src/dex/components/PagePoolList/types.ts @@ -79,5 +79,3 @@ export type PoolListFilter = { } export type ColumnKeys = keyof typeof COLUMN_KEYS - -export type ShowDetailsMapper = { [poolId: string]: boolean } diff --git a/apps/main/src/dex/components/PoolLabel.tsx b/apps/main/src/dex/components/PoolLabel.tsx index b76e28951..683d35282 100644 --- a/apps/main/src/dex/components/PoolLabel.tsx +++ b/apps/main/src/dex/components/PoolLabel.tsx @@ -64,7 +64,7 @@ const PoolLabel = ({ className = '', blockchainId, isVisible = true, poolData, p let foundSearchedToken = false - const highlightedTokens = tokens.map(({ symbol, address }, idx) => { + const highlightedTokens = tokens.map(({ symbol, address }) => { const isHighLight = searchedTerms.findIndex((searched) => { const parsedToken = symbol.toLowerCase() diff --git a/apps/main/src/dex/entities/appstats-tvl.ts b/apps/main/src/dex/entities/appstats-tvl.ts index ab3d0bd6c..fa908977b 100644 --- a/apps/main/src/dex/entities/appstats-tvl.ts +++ b/apps/main/src/dex/entities/appstats-tvl.ts @@ -5,7 +5,7 @@ import curvejsApi from '@/dex/lib/curvejs' import useStore from '@/dex/store/useStore' import { curvejsValidationSuite } from './validation/curvejs-validation' -async function _fetchAppStatsTvl({ chainId }: ChainParams) { +async function _fetchAppStatsTvl(_: ChainParams) { const curve = useStore.getState().curve const { getTVL } = curvejsApi.network diff --git a/apps/main/src/dex/entities/gauge/api/gauge-query.ts b/apps/main/src/dex/entities/gauge/api/gauge-query.ts index 93d4e51b7..c91d3f19d 100644 --- a/apps/main/src/dex/entities/gauge/api/gauge-query.ts +++ b/apps/main/src/dex/entities/gauge/api/gauge-query.ts @@ -15,12 +15,6 @@ import { BD } from '@ui-kit/utils' import { GaugeQuery } from '@ui-kit/lib/model/query' import useStore from '@/dex/store/useStore' -export const queryGaugeStatus = async ({ poolId }: GaugeQuery) => { - const curve = useStore.getState().curve - const pool = curve.getPool(poolId) - return pool.gaugeStatus() -} - export const queryGaugeManager = async ({ poolId }: GaugeQuery): Promise
=> { const curve = useStore.getState().curve const pool = curve.getPool(poolId) @@ -37,12 +31,6 @@ export const queryGaugeDistributors = async ({ poolId }: GaugeQuery) => { return pool.gauge.gaugeDistributors() } -export const queryGaugeVersion = async ({ poolId }: GaugeQuery) => { - const curve = useStore.getState().curve - const pool = curve.getPool(poolId) - return (await pool.gauge.gaugeVersion()) ?? null -} - export const queryIsDepositRewardAvailable = async ({ poolId }: GaugeQuery) => { const { curve } = useStore.getState() const pool = curve.getPool(poolId) diff --git a/apps/main/src/dex/entities/gauge/lib/gauge-info.ts b/apps/main/src/dex/entities/gauge/lib/gauge-info.ts index f98235112..c317c4f87 100644 --- a/apps/main/src/dex/entities/gauge/lib/gauge-info.ts +++ b/apps/main/src/dex/entities/gauge/lib/gauge-info.ts @@ -11,16 +11,7 @@ */ import * as models from '@/dex/entities/gauge/model' -import { useCombinedQueries } from '@ui-kit/lib/queries' -import { GaugeParams } from '@ui-kit/lib/model/query' -export const useGauge = ({ chainId, poolId }: GaugeParams) => - useCombinedQueries([ - models.gaugeStatus.getQueryOptions({ chainId, poolId }), - models.depositRewardAvailable.getQueryOptions({ chainId, poolId }), - ]) - -export const { useQuery: useGaugeVersion } = models.gaugeVersion export const { useQuery: useIsDepositRewardAvailable } = models.depositRewardAvailable export const { useQuery: useGaugeManager } = models.gaugeManager export const { useQuery: useGaugeRewardsDistributors } = models.gaugeDistributors diff --git a/apps/main/src/dex/entities/gauge/model/query-options.ts b/apps/main/src/dex/entities/gauge/model/query-options.ts index 229a457e7..3da66d7bf 100644 --- a/apps/main/src/dex/entities/gauge/model/query-options.ts +++ b/apps/main/src/dex/entities/gauge/model/query-options.ts @@ -1,35 +1,15 @@ -/** - * @description This file defines the data fetching and mutation logic for gauge-related operations in the Curve.fi DApp. - * It's a core part of the 'gauge' entity in the FSD architecture. - * - * This module exports functions that create React Query options for various gauge operations - * - * These functions utilize the API methods from './api' and query keys from './query-keys', - * providing a clean interface for components to interact with gauge data. - * They encapsulate the data fetching logic, making it easier to manage and reuse across the application. - */ - import { poolValidationSuite } from '@ui-kit/lib/model/query/pool-validation' import { GaugeParams, rootKeys } from '@ui-kit/lib/model/query' import { queryFactory } from '@ui-kit/lib/model/query/factory' import { - queryGaugeStatus, - queryGaugeVersion, queryDepositRewardIsApproved, - queryGaugeManager, queryGaugeDistributors, + queryGaugeManager, queryIsDepositRewardAvailable, } from '../api' import type { DepositRewardApproveParams } from '../types' import { gaugeDepositRewardApproveValidationSuite } from './gauge-validation' -export const gaugeStatus = queryFactory({ - queryKey: (params: GaugeParams) => [...rootKeys.gauge(params), 'gauge', 'status'] as const, - queryFn: queryGaugeStatus, - staleTime: '5m', - validationSuite: poolValidationSuite, -}) - export const depositRewardAvailable = queryFactory({ queryKey: (params: GaugeParams) => [...rootKeys.gauge(params), 'isDepositRewardAvailable'] as const, queryFn: queryIsDepositRewardAvailable, @@ -51,13 +31,6 @@ export const gaugeDistributors = queryFactory({ validationSuite: poolValidationSuite, }) -export const gaugeVersion = queryFactory({ - queryKey: (params: GaugeParams) => [...rootKeys.gauge(params), 'version'] as const, - queryFn: queryGaugeVersion, - staleTime: 'Inf', - validationSuite: poolValidationSuite, -}) - export const depositRewardIsApproved = queryFactory({ queryKey: ({ rewardTokenId, amount, ...gaugeParams }: DepositRewardApproveParams) => [...rootKeys.gauge(gaugeParams), 'depositRewardIsApproved', { rewardTokenId }, { amount }] as const, diff --git a/apps/main/src/dex/entities/gauge/types.ts b/apps/main/src/dex/entities/gauge/types.ts index dbdd1e6f5..05c89c8fb 100644 --- a/apps/main/src/dex/entities/gauge/types.ts +++ b/apps/main/src/dex/entities/gauge/types.ts @@ -1,15 +1,3 @@ -/** - * @file entities/gauge/types.ts - * @description This file defines TypeScript types and interfaces related to gauges in the Curve.fi DApp. - * It's part of the 'gauge' entity in the FSD architecture. - * - * The types defined here are used throughout the gauge-related components and functions, - * ensuring type safety and consistency in gauge operations. - * - * These types are essential for maintaining a well-typed codebase and improving - * developer experience when working with gauge-related functionality. - */ - import type { Address } from 'viem' import { FieldsOf } from '@ui-kit/lib/validation' import { GaugeQuery } from '@ui-kit/lib/model/query' diff --git a/apps/main/src/dex/features/deposit-gauge-reward/model/default-values.ts b/apps/main/src/dex/features/deposit-gauge-reward/model/default-values.ts index f4fc65994..131c500d6 100644 --- a/apps/main/src/dex/features/deposit-gauge-reward/model/default-values.ts +++ b/apps/main/src/dex/features/deposit-gauge-reward/model/default-values.ts @@ -5,6 +5,6 @@ import { DepositRewardStep, type DepositRewardFormValues } from '@/dex/features/ export const DepositRewardDefaultValues: DepositRewardFormValues = { rewardTokenId: zeroAddress, amount: '', - epoch: 1 * TIME_FRAMES.WEEK, + epoch: TIME_FRAMES.WEEK, step: DepositRewardStep.APPROVAL, } as const diff --git a/apps/main/src/dex/features/deposit-gauge-reward/ui/ActionsStepper.tsx b/apps/main/src/dex/features/deposit-gauge-reward/ui/ActionsStepper.tsx index c61505ace..a3a46864d 100644 --- a/apps/main/src/dex/features/deposit-gauge-reward/ui/ActionsStepper.tsx +++ b/apps/main/src/dex/features/deposit-gauge-reward/ui/ActionsStepper.tsx @@ -1,5 +1,5 @@ import { t } from '@ui-kit/lib/i18n' -import { FunctionComponent, useCallback, useLayoutEffect, useMemo, useState } from 'react' +import { useCallback, useLayoutEffect, useMemo, useState } from 'react' import { useFormContext } from 'react-hook-form' import { DepositRewardFormValues, DepositRewardStep } from '@/dex/features/deposit-gauge-reward/types' import { StepperContainer } from '@/dex/features/deposit-gauge-reward/ui' diff --git a/apps/main/src/dex/features/deposit-gauge-reward/ui/AmountTokenInput.tsx b/apps/main/src/dex/features/deposit-gauge-reward/ui/AmountTokenInput.tsx index 8bd64f9b6..8b1feb41c 100644 --- a/apps/main/src/dex/features/deposit-gauge-reward/ui/AmountTokenInput.tsx +++ b/apps/main/src/dex/features/deposit-gauge-reward/ui/AmountTokenInput.tsx @@ -26,7 +26,7 @@ import { ChainId, Token } from '@/dex/types/main.types' import { formatNumber } from '@ui/utils' export const AmountTokenInput = ({ chainId, poolId }: { chainId: ChainId; poolId: string }) => { - const { setValue, getValues, formState, watch, setError, clearErrors } = useFormContext() + const { setValue, getValues, formState, watch } = useFormContext() const rewardTokenId = watch('rewardTokenId') const amount = watch('amount') const epoch = watch('epoch') diff --git a/apps/main/src/dex/features/deposit-gauge-reward/ui/DepositReward.tsx b/apps/main/src/dex/features/deposit-gauge-reward/ui/DepositReward.tsx index 968651e64..1ec66db51 100644 --- a/apps/main/src/dex/features/deposit-gauge-reward/ui/DepositReward.tsx +++ b/apps/main/src/dex/features/deposit-gauge-reward/ui/DepositReward.tsx @@ -43,7 +43,7 @@ export const DepositReward = ({ chainId, poolId }: { chainId: ChainId; poolId: s - + diff --git a/apps/main/src/dex/features/deposit-gauge-reward/ui/HelperFields.tsx b/apps/main/src/dex/features/deposit-gauge-reward/ui/HelperFields.tsx index 4950af45b..be3cca1ff 100644 --- a/apps/main/src/dex/features/deposit-gauge-reward/ui/HelperFields.tsx +++ b/apps/main/src/dex/features/deposit-gauge-reward/ui/HelperFields.tsx @@ -3,9 +3,8 @@ import FieldHelperUsdRate from '@/dex/components/FieldHelperUsdRate' import { type DepositRewardFormValues } from '@/dex/features/deposit-gauge-reward/types' import { useTokensUSDRates } from '@/dex/entities/token' import { FlexContainer } from '@ui/styled-containers' -import { ChainId } from '@/dex/types/main.types' -export const HelperFields = ({ chainId, poolId }: { chainId: ChainId; poolId: string }) => { +export const HelperFields = () => { const { watch } = useFormContext() const rewardTokenId = watch('rewardTokenId') const amount = watch('amount') diff --git a/apps/main/src/dex/lib/utils.ts b/apps/main/src/dex/lib/utils.ts index c8c74ed21..984940917 100644 --- a/apps/main/src/dex/lib/utils.ts +++ b/apps/main/src/dex/lib/utils.ts @@ -8,7 +8,7 @@ export function copyToClipboard(text: string) { // IE specific code path to prevent textarea being shown while dialog is visible. return window.clipboardData.setData('Text', text) } else if (document.queryCommandSupported && document.queryCommandSupported('copy')) { - var textarea = document.createElement('textarea') + const textarea = document.createElement('textarea') textarea.textContent = text textarea.style.position = 'fixed' // Prevent scrolling to bottom of page in MS Edge. document.body.appendChild(textarea) diff --git a/apps/main/src/dex/store/createDeployGaugeSlice.ts b/apps/main/src/dex/store/createDeployGaugeSlice.ts index 3f98ad845..81c0b0491 100644 --- a/apps/main/src/dex/store/createDeployGaugeSlice.ts +++ b/apps/main/src/dex/store/createDeployGaugeSlice.ts @@ -217,7 +217,7 @@ const createDeployGaugeSlice = (set: SetState, get: GetState) => ( dismissNotificationHandler = dismissDeploying - const gaugeAddress = await curve.stableNgFactory.getDeployedGaugeAddress(deployGaugeTx) + await curve.stableNgFactory.getDeployedGaugeAddress(deployGaugeTx) set( produce((state) => { state.deployGauge.deploymentStatus.mainnet.status = 'SUCCESS' @@ -254,7 +254,7 @@ const createDeployGaugeSlice = (set: SetState, get: GetState) => ( dismissNotificationHandler = dismissDeploying - const gaugeAddress = await curve.cryptoFactory.getDeployedGaugeAddress(deployGaugeTx) + await curve.cryptoFactory.getDeployedGaugeAddress(deployGaugeTx) set( produce((state) => { state.deployGauge.deploymentStatus.mainnet.status = 'SUCCESS' @@ -291,7 +291,7 @@ const createDeployGaugeSlice = (set: SetState, get: GetState) => ( dismissNotificationHandler = dismissDeploying - const gaugeAddress = await curve.twocryptoFactory.getDeployedGaugeAddress(deployGaugeTx) + await curve.twocryptoFactory.getDeployedGaugeAddress(deployGaugeTx) set( produce((state) => { state.deployGauge.deploymentStatus.mainnet.status = 'SUCCESS' @@ -328,7 +328,7 @@ const createDeployGaugeSlice = (set: SetState, get: GetState) => ( dismissNotificationHandler = dismissDeploying - const gaugeAddress = await curve.tricryptoFactory.getDeployedGaugeAddress(deployGaugeTx) + await curve.tricryptoFactory.getDeployedGaugeAddress(deployGaugeTx) set( produce((state) => { state.deployGauge.deploymentStatus.mainnet.status = 'SUCCESS' @@ -364,7 +364,7 @@ const createDeployGaugeSlice = (set: SetState, get: GetState) => ( dismissNotificationHandler = dismissDeploying - const gaugeAddress = await curve.factory.getDeployedGaugeAddress(deployGaugeTx) + await curve.factory.getDeployedGaugeAddress(deployGaugeTx) set( produce((state) => { state.deployGauge.deploymentStatus.mainnet.status = 'SUCCESS' @@ -410,7 +410,7 @@ const createDeployGaugeSlice = (set: SetState, get: GetState) => ( dismissNotificationHandler = dismissDeploying - const gaugeAddress = await curve.stableNgFactory.getDeployedGaugeAddress(deployGaugeTx) + await curve.stableNgFactory.getDeployedGaugeAddress(deployGaugeTx) set( produce((state) => { state.deployGauge.deploymentStatus.sidechain.status = 'SUCCESS' @@ -448,7 +448,7 @@ const createDeployGaugeSlice = (set: SetState, get: GetState) => ( dismissNotificationHandler = dismissDeploying - const gaugeAddress = await curve.cryptoFactory.getDeployedGaugeAddress(deployGaugeTx) + await curve.cryptoFactory.getDeployedGaugeAddress(deployGaugeTx) set( produce((state) => { state.deployGauge.deploymentStatus.sidechain.status = 'SUCCESS' @@ -486,7 +486,7 @@ const createDeployGaugeSlice = (set: SetState, get: GetState) => ( dismissNotificationHandler = dismissDeploying - const gaugeAddress = await curve.twocryptoFactory.getDeployedGaugeAddress(deployGaugeTx) + await curve.twocryptoFactory.getDeployedGaugeAddress(deployGaugeTx) set( produce((state) => { state.deployGauge.deploymentStatus.sidechain.status = 'SUCCESS' @@ -524,7 +524,7 @@ const createDeployGaugeSlice = (set: SetState, get: GetState) => ( dismissNotificationHandler = dismissDeploying - const gaugeAddress = await curve.tricryptoFactory.getDeployedGaugeAddress(deployGaugeTx) + await curve.tricryptoFactory.getDeployedGaugeAddress(deployGaugeTx) set( produce((state) => { state.deployGauge.deploymentStatus.sidechain.status = 'SUCCESS' @@ -562,7 +562,7 @@ const createDeployGaugeSlice = (set: SetState, get: GetState) => ( dismissNotificationHandler = dismissDeploying - const gaugeAddress = await curve.factory.getDeployedGaugeAddress(deployGaugeTx) + await curve.factory.getDeployedGaugeAddress(deployGaugeTx) set( produce((state) => { state.deployGauge.deploymentStatus.sidechain.status = 'SUCCESS' @@ -613,7 +613,7 @@ const createDeployGaugeSlice = (set: SetState, get: GetState) => ( dismissNotificationHandler = dismissDeploying - const gaugeAddress = await curve.stableNgFactory.getDeployedGaugeMirrorAddressByTx(deployGaugeTx) + await curve.stableNgFactory.getDeployedGaugeMirrorAddressByTx(deployGaugeTx) set( produce((state) => { state.deployGauge.deploymentStatus.mirror.status = 'SUCCESS' @@ -652,7 +652,7 @@ const createDeployGaugeSlice = (set: SetState, get: GetState) => ( dismissNotificationHandler = dismissDeploying - const gaugeAddress = await curve.cryptoFactory.getDeployedGaugeMirrorAddressByTx(deployGaugeTx) + await curve.cryptoFactory.getDeployedGaugeMirrorAddressByTx(deployGaugeTx) set( produce((state) => { state.deployGauge.deploymentStatus.mirror.status = 'SUCCESS' @@ -691,7 +691,7 @@ const createDeployGaugeSlice = (set: SetState, get: GetState) => ( dismissNotificationHandler = dismissDeploying - const gaugeAddress = await curve.twocryptoFactory.getDeployedGaugeMirrorAddressByTx(deployGaugeTx) + await curve.twocryptoFactory.getDeployedGaugeMirrorAddressByTx(deployGaugeTx) set( produce((state) => { state.deployGauge.deploymentStatus.mirror.status = 'SUCCESS' @@ -730,7 +730,7 @@ const createDeployGaugeSlice = (set: SetState, get: GetState) => ( dismissNotificationHandler = dismissDeploying - const gaugeAddress = await curve.tricryptoFactory.getDeployedGaugeMirrorAddressByTx(deployGaugeTx) + await curve.tricryptoFactory.getDeployedGaugeMirrorAddressByTx(deployGaugeTx) set( produce((state) => { state.deployGauge.deploymentStatus.mirror.status = 'SUCCESS' @@ -766,7 +766,7 @@ const createDeployGaugeSlice = (set: SetState, get: GetState) => ( dismissNotificationHandler = dismissDeploying - const gaugeAddress = await curve.factory.getDeployedGaugeMirrorAddressByTx(deployGaugeTx) + await curve.factory.getDeployedGaugeMirrorAddressByTx(deployGaugeTx) set( produce((state) => { state.deployGauge.deploymentStatus.mirror.status = 'SUCCESS' diff --git a/apps/main/src/dex/store/types.ts b/apps/main/src/dex/store/types.ts index a000ed6f9..cafe01de3 100644 --- a/apps/main/src/dex/store/types.ts +++ b/apps/main/src/dex/store/types.ts @@ -14,10 +14,3 @@ export interface PricesApiPool { liquidity_fee_24h: number coins: PricesApiCoin[] } - -export interface PricesApiPoolResponse { - chain: string - page: number - per_page: number - data: PricesApiPool[] -} diff --git a/apps/main/src/dex/utils/utilsStyles.ts b/apps/main/src/dex/utils/utilsStyles.ts deleted file mode 100644 index e3cb4e95a..000000000 --- a/apps/main/src/dex/utils/utilsStyles.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { keyframes } from 'styled-components' - -export const positiveFadeIn = keyframes` - from { - color: green; - } - to { - color: inherit; - } -` - -export const negativeFadeIn = keyframes` - from { - color: red; - } - to { - color: inherit; - } -` diff --git a/apps/main/src/dex/widgets/manage-gauge/ui/ManageGauge.tsx b/apps/main/src/dex/widgets/manage-gauge/ui/ManageGauge.tsx index 1ba8d6d10..53c0068c5 100644 --- a/apps/main/src/dex/widgets/manage-gauge/ui/ManageGauge.tsx +++ b/apps/main/src/dex/widgets/manage-gauge/ui/ManageGauge.tsx @@ -24,11 +24,8 @@ const ManageGauge = ({ poolId, chainId }: { poolId: string; chainId: ChainId }) const [activeTab, setActiveTab] = useState('add_reward') const { data: signerAddress } = useSignerAddress() - const { data: gaugeManager, isPending: isPendingGaugeManager } = useGaugeManager({ chainId, poolId }) - const { data: rewardDistributors, isPending: isPendingRewardDistributors } = useGaugeRewardsDistributors({ - chainId, - poolId, - }) + const { data: gaugeManager } = useGaugeManager({ chainId, poolId }) + const { data: rewardDistributors } = useGaugeRewardsDistributors({ chainId, poolId }) const isGaugeManager = useMemo( () => !!gaugeManager && !!signerAddress && isAddressEqual(gaugeManager, signerAddress), diff --git a/apps/main/src/lend/components/ChartOhlcWrapper/LiquidityData.tsx b/apps/main/src/lend/components/ChartOhlcWrapper/LiquidityData.tsx index 1121e8a72..0da934ae7 100644 --- a/apps/main/src/lend/components/ChartOhlcWrapper/LiquidityData.tsx +++ b/apps/main/src/lend/components/ChartOhlcWrapper/LiquidityData.tsx @@ -135,11 +135,6 @@ const LiquidityEventTitle = styled.span` } ` -const LpTokensContainer = styled.div` - display: flex; - flex-direction: column; -` - const Nrange = styled.p` font-size: var(--font-size-1); font-weight: var(--bold); diff --git a/apps/main/src/lend/components/ChartOhlcWrapper/index.tsx b/apps/main/src/lend/components/ChartOhlcWrapper/index.tsx index f4b981d92..d9124a9c7 100644 --- a/apps/main/src/lend/components/ChartOhlcWrapper/index.tsx +++ b/apps/main/src/lend/components/ChartOhlcWrapper/index.tsx @@ -1,7 +1,7 @@ -import type { LlammaLiquididationRange, LiquidationRanges } from '@ui/Chart/types' +import type { LiquidationRanges, LlammaLiquididationRange } from '@ui/Chart/types' import { ChartOhlcWrapperProps, LendingMarketTokens } from './types' -import { useEffect, useState, useMemo, useCallback } from 'react' +import { useCallback, useEffect, useMemo, useState } from 'react' import styled from 'styled-components' import { t } from '@ui-kit/lib/i18n' @@ -120,47 +120,39 @@ const ChartOhlcWrapper = ({ rChainId, userActiveKey, rOwmId }: ChartOhlcWrapperP if (liqRangesMapper[formValues.n].prices.length !== 0) { const currentPrices = liqRangesMapper[formValues.n].prices // flip order to match other data - const range = formatRange([currentPrices[1], currentPrices[0]]) - liqRanges.new = range + liqRanges.new = formatRange([currentPrices[1], currentPrices[0]]) } else { const currentPrices = loanCreateDetailInfo?.prices if (currentPrices) { - const range = formatRange([currentPrices[0], currentPrices[1]]) - liqRanges.new = range + liqRanges.new = formatRange([currentPrices[0], currentPrices[1]]) } } } // current loan prices if (userPrices && currentChart.data) { - const range = formatRange(userPrices) - liqRanges.current = range + liqRanges.current = formatRange(userPrices) } // increase loan prices if (borrowMorePrices && borrowMorePrices.length !== 0 && currentChart.data) { - const range = formatRange(borrowMorePrices) - liqRanges.new = range + liqRanges.new = formatRange(borrowMorePrices) } // decrease loan prices if (repayLoanPrices && repayLoanPrices.length !== 0 && currentChart.data) { - const range = formatRange(repayLoanPrices) - liqRanges.new = range + liqRanges.new = formatRange(repayLoanPrices) } // increase collateral prices if (addCollateralPrices && addCollateralPrices.length !== 0 && currentChart.data) { - const range = formatRange(addCollateralPrices) - liqRanges.new = range + liqRanges.new = formatRange(addCollateralPrices) } // decrease collateral prices if (removeCollateralPrices && removeCollateralPrices.length !== 0 && currentChart.data) { - const range = formatRange(removeCollateralPrices) - liqRanges.new = range + liqRanges.new = formatRange(removeCollateralPrices) } // // deleverage prices if (repayLeveragePrices && currentChart.data) { - const range = formatRange(repayLeveragePrices) - liqRanges.new = range + liqRanges.new = formatRange(repayLeveragePrices) } return liqRanges diff --git a/apps/main/src/lend/components/DetailsUser/styles.ts b/apps/main/src/lend/components/DetailsUser/styles.ts deleted file mode 100644 index 4a3ad4f3f..000000000 --- a/apps/main/src/lend/components/DetailsUser/styles.ts +++ /dev/null @@ -1,18 +0,0 @@ -import styled from 'styled-components' -import UserInfoStats from '@/lend/components/DetailsUser/components/UserInfoStats' -import { HeathColorKey } from '@/lend/types/lend.types' - -export const MainUserInfoStats = styled(UserInfoStats)` - border: 1px solid var(--nav_button--border-color); - display: inline-block; - padding: var(--spacing-narrow); -` - -export const MainUserInfoStatsContent = styled.span` - font-size: var(--font-size-6); - font-weight: bold; -` - -export const HealthColorText = styled.span<{ colorKey?: HeathColorKey }>` - color: ${({ colorKey }) => `var(--health_mode_${colorKey}--color)`}; -` diff --git a/apps/main/src/lend/components/PageMarketList/components/TableRowViewContentTable/TableRow.tsx b/apps/main/src/lend/components/PageMarketList/components/TableRowViewContentTable/TableRow.tsx index 290a79d3d..168e99418 100644 --- a/apps/main/src/lend/components/PageMarketList/components/TableRowViewContentTable/TableRow.tsx +++ b/apps/main/src/lend/components/PageMarketList/components/TableRowViewContentTable/TableRow.tsx @@ -71,7 +71,7 @@ const TableRowContent = ({ { className: 'left', content: }, { className: 'left', content: }, { className: 'center border-left', content: , show: showBorrowSignerCell }, - { className: 'center border-right', content: , show: showBorrowSignerCell }, + { className: 'center border-right', content: , show: showBorrowSignerCell }, { className: 'right', content: }, { className: 'right', content: }, { className: 'right', content: }, diff --git a/apps/main/src/lend/components/PageMarketList/components/TableRowViewContentTable/TableRowMobileContent.tsx b/apps/main/src/lend/components/PageMarketList/components/TableRowViewContentTable/TableRowMobileContent.tsx index 4c1d3b986..c49b6899a 100644 --- a/apps/main/src/lend/components/PageMarketList/components/TableRowViewContentTable/TableRowMobileContent.tsx +++ b/apps/main/src/lend/components/PageMarketList/components/TableRowViewContentTable/TableRowMobileContent.tsx @@ -48,7 +48,7 @@ const TableRowMobileContent = ({ const content: { borrow: Content[][], supply: Content[][] } = { [FilterType.borrow]: [ [ - { tableKey: TITLE.myDebt, content: , show: loanExists, showLine: true }, + { tableKey: TITLE.myDebt, content: , show: loanExists, showLine: true }, { tableKey: TITLE.myHealth, content: , show: loanExists, showLine: true }, ], [ diff --git a/apps/main/src/lend/components/SharedCellData/CellHealthStatus.tsx b/apps/main/src/lend/components/SharedCellData/CellHealthStatus.tsx index 4e192fb79..e1f9d2498 100644 --- a/apps/main/src/lend/components/SharedCellData/CellHealthStatus.tsx +++ b/apps/main/src/lend/components/SharedCellData/CellHealthStatus.tsx @@ -1,9 +1,12 @@ import React from 'react' - import { FORMAT_OPTIONS, formatNumber } from '@ui/utils' import useStore from '@/lend/store/useStore' +import styled from 'styled-components' +import { HeathColorKey } from '@/lend/types/lend.types' -import { HealthColorText } from '@/lend/components/DetailsUser/styles' +const HealthColorText = styled.span<{ colorKey?: HeathColorKey }>` + color: ${({ colorKey }) => `var(--health_mode_${colorKey}--color)`}; +` const CellHealthStatus = ({ userActiveKey, type }: { userActiveKey: string; type: 'status' | 'percent' }) => { const resp = useStore((state) => state.user.loansDetailsMapper[userActiveKey]) diff --git a/apps/main/src/lend/components/SharedCellData/CellLoanUserState.tsx b/apps/main/src/lend/components/SharedCellData/CellLoanUserState.tsx index c871dc077..0532cd084 100644 --- a/apps/main/src/lend/components/SharedCellData/CellLoanUserState.tsx +++ b/apps/main/src/lend/components/SharedCellData/CellLoanUserState.tsx @@ -1,7 +1,7 @@ import { formatNumber } from '@ui/utils' import useStore from '@/lend/store/useStore' -const CellLoanUserState = ({ userActiveKey, type }: { userActiveKey: string; type: 'debt' }) => { +const CellLoanUserState = ({ userActiveKey }: { userActiveKey: string }) => { const loanExistsResp = useStore((state) => state.user.loansExistsMapper[userActiveKey]) const stateResp = useStore((state) => state.user.loansStatesMapper[userActiveKey]) diff --git a/apps/main/src/lend/hooks/useCampaignRewardsMapper.tsx b/apps/main/src/lend/hooks/useCampaignRewardsMapper.tsx index 5763b733f..cdef41055 100644 --- a/apps/main/src/lend/hooks/useCampaignRewardsMapper.tsx +++ b/apps/main/src/lend/hooks/useCampaignRewardsMapper.tsx @@ -5,8 +5,7 @@ import useStore from '@/lend/store/useStore' const useCampaignRewardsMapper = () => { const cached = useStore((state) => state.storeCache.campaignRewardsMapper) const api = useStore((state) => state.campaigns.campaignRewardsMapper) - const campaignRewardsMapper = useMemo(() => api ?? cached ?? {}, [api, cached]) - return campaignRewardsMapper + return useMemo(() => api ?? cached ?? {}, [api, cached]) } export default useCampaignRewardsMapper diff --git a/apps/main/src/lend/utils/helpers.ts b/apps/main/src/lend/utils/helpers.ts index b560046a1..21875573d 100644 --- a/apps/main/src/lend/utils/helpers.ts +++ b/apps/main/src/lend/utils/helpers.ts @@ -2,7 +2,6 @@ import { t } from '@ui-kit/lib/i18n' import { OneWayMarketTemplate } from '@curvefi/lending-api/lib/markets' import { Api } from '@/lend/types/lend.types' -export * from './utilsGasPrices' export * from './utilsRouter' interface CustomError extends Error { @@ -68,7 +67,7 @@ export function getErrorMessage(error: CustomError, defaultErrorMessage: string) errorMessage = t`User rejected transaction` } else if ('data' in error && typeof error.data?.message === 'string') { errorMessage = error.data.message - } else if (typeof error.message === 'string') { + } else { errorMessage = error.message } } @@ -99,7 +98,7 @@ export function copyToClipboard(text: string) { // IE specific code path to prevent textarea being shown while dialog is visible. return window.clipboardData.setData('Text', text) } else if (document.queryCommandSupported && document.queryCommandSupported('copy')) { - var textarea = document.createElement('textarea') + const textarea = document.createElement('textarea') textarea.textContent = text textarea.style.position = 'fixed' // Prevent scrolling to bottom of page in MS Edge. document.body.appendChild(textarea) diff --git a/apps/main/src/lend/utils/utilsGasPrices.ts b/apps/main/src/lend/utils/utilsGasPrices.ts deleted file mode 100644 index f8ea06f33..000000000 --- a/apps/main/src/lend/utils/utilsGasPrices.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { httpFetcher } from '@/lend/utils/helpers' -import networks from '@/lend/networks' -import { ChainId } from '@/lend/types/lend.types' - -export type GasPrices = { - eip1559Gas: { - base: number - priority: number[] - max: number[] - basePlusPriority: number[] - } - label: string[] -} - -export async function fetchGasPrices(chainId: ChainId) { - try { - if (chainId === 1) { - const url = networks[1].gasPricesUrl - const gas = await httpFetcher(url) - - if (gas) { - const { eip1559Gas } = gas.data - const base = Math.trunc(eip1559Gas.base) - const priority = eip1559Gas.prio.map(Math.trunc) - - return { - eip1559Gas: { - base, - priority, - max: Math.trunc(eip1559Gas.max), - basePlusPriority: priority.map((p: number) => { - const basePlusPriority = base + p - if (chainId === 1) { - return basePlusPriority - } - - // temp hack to get reduced est gas cost for layer 2 - return basePlusPriority * 0.1 - }), - }, - label: ['fastest', 'fast', 'medium', 'slow'], - } - } - } - } catch (error) { - console.error(error) - } -} diff --git a/apps/main/src/loan/components/ChartOhlcWrapper/index.tsx b/apps/main/src/loan/components/ChartOhlcWrapper/index.tsx index dcb48314b..78f9ea202 100644 --- a/apps/main/src/loan/components/ChartOhlcWrapper/index.tsx +++ b/apps/main/src/loan/components/ChartOhlcWrapper/index.tsx @@ -1,7 +1,7 @@ -import type { LlammaLiquididationRange, LiquidationRanges } from '@ui/Chart/types' -import { LlammaLiquidityCoins, ChartOhlcWrapperProps } from './types' +import type { LiquidationRanges, LlammaLiquididationRange } from '@ui/Chart/types' +import { ChartOhlcWrapperProps, LlammaLiquidityCoins } from './types' -import { useEffect, useState, useMemo, useCallback } from 'react' +import { useCallback, useEffect, useMemo, useState } from 'react' import styled from 'styled-components' import { t } from '@ui-kit/lib/i18n' @@ -99,40 +99,33 @@ const ChartOhlcWrapper = ({ rChainId, llamma, llammaId }: ChartOhlcWrapperProps) if (formValues.n && liqRangesMapper && chartOhlcData) { const currentPrices = liqRangesMapper[formValues.n].prices // flip order to match other data - const range = formatRange([currentPrices[1], currentPrices[0]]) - liqRanges.new = range + liqRanges.new = formatRange([currentPrices[1], currentPrices[0]]) } // current loan prices if (userPrices && chartOhlcData) { - const range = formatRange(userPrices) - liqRanges.current = range + liqRanges.current = formatRange(userPrices) } // increase loan prices if (increaseLoanPrices && increaseLoanPrices.length !== 0 && chartOhlcData) { - const range = formatRange(increaseLoanPrices) - liqRanges.new = range + liqRanges.new = formatRange(increaseLoanPrices) } // decrease loan prices if (decreaseLoanPrices && decreaseLoanPrices.length !== 0 && chartOhlcData) { - const range = formatRange(decreaseLoanPrices) - liqRanges.new = range + liqRanges.new = formatRange(decreaseLoanPrices) } // increase collateral prices if (increaseCollateralPrices && increaseCollateralPrices.length !== 0 && chartOhlcData) { - const range = formatRange(increaseCollateralPrices) - liqRanges.new = range + liqRanges.new = formatRange(increaseCollateralPrices) } // decrease collateral prices if (decreaseCollateralPrices && decreaseCollateralPrices.length !== 0 && chartOhlcData) { - const range = formatRange(decreaseCollateralPrices) - liqRanges.new = range + liqRanges.new = formatRange(decreaseCollateralPrices) } // deleverage prices if (deleveragePrices && chartOhlcData) { - const range = formatRange(deleveragePrices) - liqRanges.new = range + liqRanges.new = formatRange(deleveragePrices) } return liqRanges diff --git a/apps/main/src/loan/components/LoanInfoUser/index.tsx b/apps/main/src/loan/components/LoanInfoUser/index.tsx index 649ea465f..49e5fe4e2 100644 --- a/apps/main/src/loan/components/LoanInfoUser/index.tsx +++ b/apps/main/src/loan/components/LoanInfoUser/index.tsx @@ -19,11 +19,11 @@ import UserInfos from '@/loan/components/LoanInfoUser/components/UserInfos' import { useUserProfileStore } from '@ui-kit/features/user-profile' import { ChainId } from '@/loan/types/loan.types' -interface Props extends Pick { +interface Props extends Pick { rChainId: ChainId } -const LoanInfoUser = ({ isReady, llamma, llammaId, rChainId, titleMapper }: Props) => { +const LoanInfoUser = ({ llamma, llammaId, rChainId, titleMapper }: Props) => { const loanDetails = useStore((state) => state.loans.detailsMapper[llammaId]) const userLoanDetails = useStore((state) => state.loans.userDetailsMapper[llammaId]) const { chartExpanded } = useStore((state) => state.ohlcCharts) diff --git a/apps/main/src/loan/components/PageCrvUsdStaking/DepositWithdraw/DepositModule.tsx b/apps/main/src/loan/components/PageCrvUsdStaking/DepositWithdraw/DepositModule.tsx index 56365b438..e67c2e54c 100644 --- a/apps/main/src/loan/components/PageCrvUsdStaking/DepositWithdraw/DepositModule.tsx +++ b/apps/main/src/loan/components/PageCrvUsdStaking/DepositWithdraw/DepositModule.tsx @@ -49,7 +49,6 @@ const DepositModule = () => { { { { ` cursor: pointer; ${({ isOpen }) => isOpen && 'border-bottom: 1px solid var(--gray-500a25)'}; @@ -111,17 +104,8 @@ const ToggleTitle = styled.div` font-weight: var(--bold); ` -const ToggleValue = styled.div` - font-size: var(--font-size-2); - display: flex; - flex-direction: row; - align-items: center; -` - const StyledIcon = styled(Icon)` margin-left: var(--spacing-1); ` -const StyledDetailInfoSlippageTolerance = styled(DetailInfoSlippageTolerance)`` - export default TransactionDetails diff --git a/apps/main/src/loan/components/PageCrvUsdStaking/UserInformation/index.tsx b/apps/main/src/loan/components/PageCrvUsdStaking/UserInformation/index.tsx index 763f3cfe3..4d9af456c 100644 --- a/apps/main/src/loan/components/PageCrvUsdStaking/UserInformation/index.tsx +++ b/apps/main/src/loan/components/PageCrvUsdStaking/UserInformation/index.tsx @@ -14,7 +14,7 @@ const { Spacing } = SizesAndSpaces const UserInformation = () => { const { - design: { Layer, Text }, + design: { Layer }, } = useTheme() return ( diff --git a/apps/main/src/loan/components/PageCrvUsdStaking/components/InputComp/NumberField.tsx b/apps/main/src/loan/components/PageCrvUsdStaking/components/InputComp/NumberField.tsx index 33efc4fe6..2e431cc87 100644 --- a/apps/main/src/loan/components/PageCrvUsdStaking/components/InputComp/NumberField.tsx +++ b/apps/main/src/loan/components/PageCrvUsdStaking/components/InputComp/NumberField.tsx @@ -21,7 +21,7 @@ const NumberField = ({ value, isDisabled = false, onChange, maxDecimals = 18, on // Remove leading zeros const cleanValue = normalizedValue.replace(/^0+(\d)/, '$1') // Prevent more than maxDecimals decimal places - const [whole, decimal] = cleanValue.split('.') + const [, decimal] = cleanValue.split('.') if (decimal && decimal.length > maxDecimals) return onChange?.(cleanValue === '' ? '0' : cleanValue) diff --git a/apps/main/src/loan/components/PageCrvUsdStaking/components/InputComp/index.tsx b/apps/main/src/loan/components/PageCrvUsdStaking/components/InputComp/index.tsx index 1841655d3..98d1d6e32 100644 --- a/apps/main/src/loan/components/PageCrvUsdStaking/components/InputComp/index.tsx +++ b/apps/main/src/loan/components/PageCrvUsdStaking/components/InputComp/index.tsx @@ -13,7 +13,6 @@ import NumberField from '@/loan/components/PageCrvUsdStaking/components/InputCom type InputCompProps = { walletBalance: string - walletBalanceUSD: string walletBalanceSymbol: string value: string isLoadingInput: boolean @@ -28,7 +27,6 @@ const InputComp = ({ className, readOnly = false, walletBalance, - walletBalanceUSD, walletBalanceSymbol, isLoadingInput, isLoadingBalances, @@ -117,12 +115,6 @@ const WalletBalance = styled.p` white-space: nowrap; ` -const WalletBalanceUSD = styled.p` - font-size: var(--font-size-1); - opacity: 0.5; - white-space: nowrap; -` - const StyledButton = styled(Button)` margin: auto var(--spacing-1) auto 0; text-transform: uppercase; diff --git a/apps/main/src/loan/components/PageCrvUsdStaking/index.tsx b/apps/main/src/loan/components/PageCrvUsdStaking/index.tsx index 23b12921f..fa7807aaf 100644 --- a/apps/main/src/loan/components/PageCrvUsdStaking/index.tsx +++ b/apps/main/src/loan/components/PageCrvUsdStaking/index.tsx @@ -37,10 +37,10 @@ const CrvUsdStaking = () => { } = useScrvUsdUserBalances({ userAddress: signerAddress ?? '' }) const isUserScrvUsdBalanceZero = - signerAddress && userScrvUsdBalance ? BigNumber(userScrvUsdBalance.scrvUSD).isZero() : true + !signerAddress || !userScrvUsdBalance || BigNumber(userScrvUsdBalance.scrvUSD).isZero() const connectedUserNoScrvUsdBalance = - !!signerAddress && !!walletName && !!isUserScrvUsdBalanceFetched && !!isUserScrvUsdBalanceZero + !!signerAddress && !!walletName && isUserScrvUsdBalanceFetched && isUserScrvUsdBalanceZero // walletName indicates the wallet is cached and will begin connecting const showStatsBanner = diff --git a/apps/main/src/loan/components/PageCrvUsdStaking/utils.ts b/apps/main/src/loan/components/PageCrvUsdStaking/utils.ts index 187c38958..00998fd46 100644 --- a/apps/main/src/loan/components/PageCrvUsdStaking/utils.ts +++ b/apps/main/src/loan/components/PageCrvUsdStaking/utils.ts @@ -6,9 +6,7 @@ export const isIdle = (status: FetchStatus) => status === '' export const txIsConfirming = (status: TransactionStatus) => status === 'confirming' export const txIsSuccess = (status: TransactionStatus) => status === 'success' -export const txIsError = (status: TransactionStatus) => status === 'error' export const txIsLoading = (status: TransactionStatus) => status === 'loading' -export const txIsIdle = (status: TransactionStatus) => status === '' export const oneMonthProjectionYield = (apy: number, balance: number) => (apy / 100 / 12) * balance export const oneYearProjectionYield = (apy: number, balance: number) => (apy / 100) * balance diff --git a/apps/main/src/loan/entities/scrvusdRevenue.ts b/apps/main/src/loan/entities/scrvusdRevenue.ts index 78424de54..7fe4096b9 100644 --- a/apps/main/src/loan/entities/scrvusdRevenue.ts +++ b/apps/main/src/loan/entities/scrvusdRevenue.ts @@ -50,9 +50,7 @@ export const _getScrvUsdRevenue = async (): Promise => { const data = await getRevenue(pages, dataPerPage) - const formattedData = { ...data, epochs: organizeDataIntoEpochs(data.history) } - - return formattedData + return { ...data, epochs: organizeDataIntoEpochs(data.history) } } export const { useQuery: useScrvUsdRevenue } = queryFactory({ diff --git a/apps/main/src/loan/entities/scrvusdUserStats.ts b/apps/main/src/loan/entities/scrvusdUserStats.ts index 25578138e..29ba77f69 100644 --- a/apps/main/src/loan/entities/scrvusdUserStats.ts +++ b/apps/main/src/loan/entities/scrvusdUserStats.ts @@ -3,11 +3,7 @@ import { queryFactory } from '@ui-kit/lib/model/query' import { getUserStats } from '@curvefi/prices-api/savings' import { userAddressValidationSuite } from '@ui-kit/lib/model/query/user-address-validation' -async function _fetchScrvUsdUserStats({ userAddress }: { userAddress: string }): Promise { - const data = await getUserStats(userAddress) - - return data -} +const _fetchScrvUsdUserStats = async ({ userAddress }: { userAddress: string }): Promise => await getUserStats(userAddress) export const { useQuery: useScrvUsdUserStats } = queryFactory({ queryKey: (params: { userAddress: string }) => ['scrvUsdUserStats', { userAddress: params.userAddress }] as const, diff --git a/apps/main/src/loan/store/createScrvUsdSlice.ts b/apps/main/src/loan/store/createScrvUsdSlice.ts index 4b62fb274..04341a9ca 100644 --- a/apps/main/src/loan/store/createScrvUsdSlice.ts +++ b/apps/main/src/loan/store/createScrvUsdSlice.ts @@ -490,8 +490,7 @@ const createScrvUsdSlice = (set: SetState, get: GetState) => ({ ]) ?? { crvUSD: '0', scrvUSD: '0' } try { - let response = '' - + let response if (flag === 'deposit') { response = await lendApi.st_crvUSD.previewDeposit(amount) } else if (amount === userBalance.scrvUSD) { diff --git a/apps/main/src/loan/utils/helpers.ts b/apps/main/src/loan/utils/helpers.ts index 41fb2f212..4a996cb61 100644 --- a/apps/main/src/loan/utils/helpers.ts +++ b/apps/main/src/loan/utils/helpers.ts @@ -20,7 +20,7 @@ export function isMobile() { const mQ = matchMedia?.('(pointer:coarse)') if (mQ?.media === '(pointer:coarse)') { // @ts-ignore - hasTouchScreen = !!mQ.matches + hasTouchScreen = mQ.matches } else if ('orientation' in window) { hasTouchScreen = true // deprecated, but good fallback } else { @@ -70,7 +70,7 @@ export function getErrorMessage(error: CustomError, defaultErrorMessage: string) errorMessage = t`User rejected transaction` } else if ('data' in error && typeof error.data?.message === 'string') { errorMessage = error.data.message - } else if (typeof error.message === 'string') { + } else { errorMessage = error.message } } @@ -106,7 +106,7 @@ export function copyToClipboard(text: string) { // IE specific code path to prevent textarea being shown while dialog is visible. return window.clipboardData.setData('Text', text) } else if (document.queryCommandSupported && document.queryCommandSupported('copy')) { - var textarea = document.createElement('textarea') + const textarea = document.createElement('textarea') textarea.textContent = text textarea.style.position = 'fixed' // Prevent scrolling to bottom of page in MS Edge. document.body.appendChild(textarea) diff --git a/apps/main/src/loan/utils/utilsGasPrices.ts b/apps/main/src/loan/utils/utilsGasPrices.ts deleted file mode 100644 index b25272867..000000000 --- a/apps/main/src/loan/utils/utilsGasPrices.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { httpFetcher } from '@/loan/utils/helpers' -import networks from '@/loan/networks' -import { ChainId } from '@/loan/types/loan.types' - -export type GasPrices = { - eip1559Gas: { - base: number - priority: number[] - max: number[] - basePlusPriority: number[] - } - label: string[] -} - -export async function fetchGasPrices(chainId: ChainId) { - try { - if (chainId === 1) { - const url = networks[1].gasPricesUrl - const gas = await httpFetcher(url) - - if (gas) { - const { eip1559Gas } = gas.data - const base = Math.trunc(eip1559Gas.base) - const priority = eip1559Gas.prio.map(Math.trunc) - - return { - eip1559Gas: { - base, - priority, - max: Math.trunc(eip1559Gas.max), - basePlusPriority: priority.map((p: number) => { - const basePlusPriority = base + p - if (chainId === 1) { - return basePlusPriority - } - - // temp hack to get reduced est gas cost for layer 2 - return basePlusPriority * 0.1 - }), - }, - label: ['fastest', 'fast', 'medium', 'slow'], - } - } - } - } catch (error) { - console.error(error) - } -} diff --git a/apps/main/src/loan/utils/utilsStyles.ts b/apps/main/src/loan/utils/utilsStyles.ts deleted file mode 100644 index 3af929d25..000000000 --- a/apps/main/src/loan/utils/utilsStyles.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { keyframes } from 'styled-components' - -export const fadeIn = keyframes` - from { - opacity: 0; - } - to { - opacity: 1; - } -` diff --git a/packages/curve-ui-kit/src/lib/model/query/chain-name-validation.ts b/packages/curve-ui-kit/src/lib/model/query/chain-name-validation.ts index 210479aee..9976f94a4 100644 --- a/packages/curve-ui-kit/src/lib/model/query/chain-name-validation.ts +++ b/packages/curve-ui-kit/src/lib/model/query/chain-name-validation.ts @@ -1,5 +1,4 @@ import { enforce, group, test } from 'vest' -import { createValidationSuite } from '@ui-kit/lib/validation' import { ChainNameParams } from './root-keys' export const chainNameValidationGroup = ({ blockchainId }: ChainNameParams) => @@ -12,5 +11,3 @@ export const chainNameValidationGroup = ({ blockchainId }: ChainNameParams) => .isValidChainName() }) }) - -export const chainNameValidationSuite = createValidationSuite(chainNameValidationGroup) diff --git a/packages/curve-ui-kit/src/lib/model/query/chain-validation.ts b/packages/curve-ui-kit/src/lib/model/query/chain-validation.ts index 32e9cf818..308eafb0d 100644 --- a/packages/curve-ui-kit/src/lib/model/query/chain-validation.ts +++ b/packages/curve-ui-kit/src/lib/model/query/chain-validation.ts @@ -1,5 +1,4 @@ import { enforce, group, test } from 'vest' -import { createValidationSuite } from '@ui-kit/lib/validation' import { ChainParams } from './root-keys' export const chainValidationGroup = ({ chainId }: ChainParams) => @@ -8,5 +7,3 @@ export const chainValidationGroup = ({ chainId }: ChainParams) => enforce(chainId).message('Chain ID is required').isNotEmpty().message('Invalid chain ID').isValidChainId() }) }) - -export const chainValidationSuite = createValidationSuite(chainValidationGroup) diff --git a/packages/curve-ui-kit/src/lib/queries/combine.ts b/packages/curve-ui-kit/src/lib/queries/combine.ts index f24fe33a5..74dc54289 100644 --- a/packages/curve-ui-kit/src/lib/queries/combine.ts +++ b/packages/curve-ui-kit/src/lib/queries/combine.ts @@ -38,17 +38,6 @@ const combineQueriesToObject = ...combineQueriesMeta(results), }) -/** - * Combines multiple queries into a single list. - * @param queryOptions The query options to combine - * @returns The combined queries in a list - */ -export const useCombinedQueries = (queryOptions: [...T]): CombinedQueriesResult => - useQueries({ - queries: queryOptions, - combine: combineQueriesToList, - }) - /** * Combines multiple queries into a single object with keys for each query * @param queryOptions The query options to combine diff --git a/packages/curve-ui-kit/src/lib/queries/factory.ts b/packages/curve-ui-kit/src/lib/queries/factory.ts index 0d36c67c3..e106bfce8 100644 --- a/packages/curve-ui-kit/src/lib/queries/factory.ts +++ b/packages/curve-ui-kit/src/lib/queries/factory.ts @@ -10,8 +10,3 @@ export const createQueryHook = const options = getQueryOptions(params, condition) return useQuery(options) } - -export const createGetQueryData = - readonly any[]>>(keys: KeysObject) => - (key: Key, keyData: Parameters[0]) => - queryClient.getQueryData(keys[key](keyData)) diff --git a/packages/curve-ui-kit/src/utils/BigDecimal.ts b/packages/curve-ui-kit/src/utils/BigDecimal.ts index e3c099b19..59df44f96 100644 --- a/packages/curve-ui-kit/src/utils/BigDecimal.ts +++ b/packages/curve-ui-kit/src/utils/BigDecimal.ts @@ -3,10 +3,10 @@ import { BigDecimalTypes } from './BigDecimal.d' class BigDecimal { private static readonly STRING_REGEX = /^(-?)(\d*)(?:\.(\d+))?$/ - private _integerPart: bigint - private _fractionalPart: bigint - private _scale: number - private _isNegative: boolean + private readonly _integerPart: bigint + private readonly _fractionalPart: bigint + private readonly _scale: number + private readonly _isNegative: boolean /** * Creates a new BigDecimal instance. @@ -85,11 +85,7 @@ class BigDecimal { return !isNaN(value) && isFinite(value) } - if (typeof value === 'bigint') { - return true - } - - return false + return typeof value === 'bigint'; } /** diff --git a/packages/curve-ui-kit/src/widgets/Header/types.ts b/packages/curve-ui-kit/src/widgets/Header/types.ts index fabbd83ad..9c88130be 100644 --- a/packages/curve-ui-kit/src/widgets/Header/types.ts +++ b/packages/curve-ui-kit/src/widgets/Header/types.ts @@ -4,8 +4,6 @@ import { RefObject } from 'react' import { AppName } from '@ui-kit/shared/routes' import { GlobalBannerProps } from '@ui/Banner/GlobalBanner' -export type Locale = 'en' | 'zh-Hans' | 'zh-Hant' | 'pseudo' - export type AppPage = { route: string label: string diff --git a/packages/prices-api/src/crvusd/models.ts b/packages/prices-api/src/crvusd/models.ts index 8fe89c439..a99409b1f 100644 --- a/packages/prices-api/src/crvusd/models.ts +++ b/packages/prices-api/src/crvusd/models.ts @@ -43,16 +43,6 @@ export type Snapshot = { discountLoan: number } -export type PoolPrice = { - timestamp: number - [token: string]: number -} - -export type PriceHistogram = { - x: number[] - y: number[] -} - export type CrvUsdSupply = { timestamp: Date market: string diff --git a/packages/prices-api/src/index.ts b/packages/prices-api/src/index.ts index 1074b810b..8ffed524d 100644 --- a/packages/prices-api/src/index.ts +++ b/packages/prices-api/src/index.ts @@ -42,9 +42,7 @@ export const chains = [ export type Chain = (typeof chains)[number] -export function isChain(chain: string): chain is Chain { - return chains.includes(chain as Chain) -} +export const isChain = (chain: string): chain is Chain => chains.includes(chain as Chain) // Copied from Viem such that you don't actually need a Viem dependency but may also use Ethers. export type Address = `0x${string}` diff --git a/packages/prices-api/src/llamalend/models.ts b/packages/prices-api/src/llamalend/models.ts index 9f06ad3de..b40b848c8 100644 --- a/packages/prices-api/src/llamalend/models.ts +++ b/packages/prices-api/src/llamalend/models.ts @@ -46,8 +46,6 @@ export type Market = { leverage: number } -export type MarketPair = { long?: Market; short?: Market } - export type Snapshot = { rate: number borrowApy: number diff --git a/packages/prices-api/src/proposal/index.ts b/packages/prices-api/src/proposal/index.ts index fed1247de..a5927c33c 100644 --- a/packages/prices-api/src/proposal/index.ts +++ b/packages/prices-api/src/proposal/index.ts @@ -1,4 +1,3 @@ export * from './models' export * from './responses' -export * from './util' export * from './api' diff --git a/packages/prices-api/src/proposal/util.ts b/packages/prices-api/src/proposal/util.ts deleted file mode 100644 index 95f14a6bb..000000000 --- a/packages/prices-api/src/proposal/util.ts +++ /dev/null @@ -1,30 +0,0 @@ -import type { Proposal, ProposalStatus } from './models' - -export function getStatus(proposal: Proposal): ProposalStatus { - if (proposal.executed) { - return 'executed' - } - - if (proposal.end > Date.now() / 1000) { - return 'active' - } - - if (hasWon(proposal) && hasReachedQuorum(proposal) && hasReachedSupport(proposal)) { - return 'passed' - } - - return 'denied' -} - -export function hasReachedSupport(proposal: Proposal): boolean { - return proposal.votesFor > proposal.support * proposal.quorum * proposal.totalSupply -} - -export function hasReachedQuorum(proposal: Proposal): boolean { - return proposal.votesFor > proposal.quorum * proposal.totalSupply -} - -export function hasWon(proposal: Proposal): boolean { - const totalVotes = proposal.votesFor + proposal.votesAgainst - return proposal.votesFor > totalVotes * 0.51 -} diff --git a/packages/prices-api/src/revenue/api.ts b/packages/prices-api/src/revenue/api.ts index d31c83958..2dc6a081d 100644 --- a/packages/prices-api/src/revenue/api.ts +++ b/packages/prices-api/src/revenue/api.ts @@ -50,9 +50,7 @@ export async function getDistributions(options?: Options) { (resp) => resp.distributions.map(Parsers.parseDistribution), ) - const distributions = await paginate(fs, 1, 100) - - return distributions + return await paginate(fs, 1, 100) } export async function getCowSwapSettlements(timestamp?: number, options?: Options) { diff --git a/packages/ui/src/AppPage/styles.ts b/packages/ui/src/AppPage/styles.ts index 6e6847c82..9c2852e97 100644 --- a/packages/ui/src/AppPage/styles.ts +++ b/packages/ui/src/AppPage/styles.ts @@ -69,14 +69,6 @@ export const AppPageFormTitleWrapper = styled.header` } ` -export const AppPageFormTitleContent = styled(TextEllipsis)` - color: var(--page--text-color); - font-size: var(--font-size-5); - font-weight: bold; - line-height: 1; - padding: 0 2px; -` - export const AppPageFormTitleLinks = styled.div` color: var(--page--text-color); font-size: var(--font-size-2); diff --git a/packages/ui/src/Chart/CandleChart.tsx b/packages/ui/src/Chart/CandleChart.tsx index cd61c695c..3db48a635 100644 --- a/packages/ui/src/Chart/CandleChart.tsx +++ b/packages/ui/src/Chart/CandleChart.tsx @@ -119,7 +119,7 @@ const CandleChart = ({ width: wrapperRef.current.clientWidth, height: chartExpanded ? chartHeight.expanded : chartHeight.standard, timeScale: { - timeVisible: timeOption === 'day' ? false : true, + timeVisible: timeOption !== 'day', }, rightPriceScale: { autoScale: true, @@ -172,13 +172,13 @@ const CandleChart = ({ priceFormat: { type: 'custom', formatter: (price: any) => { - let [whole, fraction] = price.toString().split('.') + const [, fraction] = price.toString().split('.') if (!fraction) { return price.toFixed(4) } - let nonZeroIndex = fraction.split('').findIndex((char: any) => char !== '0') + const nonZeroIndex = fraction.split('').findIndex((char: any) => char !== '0') // If the price is less than 1, then there will be 4 decimal places after the first non-zero digit. // If the price is greater than or equal to 1, there will be 4 decimal places after the decimal point. @@ -203,13 +203,13 @@ const CandleChart = ({ priceFormat: { type: 'custom', formatter: (price: any) => { - let [whole, fraction] = price.toString().split('.') + const [, fraction] = price.toString().split('.') if (!fraction) { return price.toFixed(4) } - let nonZeroIndex = fraction.split('').findIndex((char: any) => char !== '0') + const nonZeroIndex = fraction.split('').findIndex((char: any) => char !== '0') // If the price is less than 1, then there will be 4 decimal places after the first non-zero digit. // If the price is greater than or equal to 1, there will be 4 decimal places after the decimal point. @@ -238,13 +238,13 @@ const CandleChart = ({ priceFormat: { type: 'custom', formatter: (price: any) => { - let [whole, fraction] = price.toString().split('.') + const [, fraction] = price.toString().split('.') if (!fraction) { return price.toFixed(4) } - let nonZeroIndex = fraction.split('').findIndex((char: any) => char !== '0') + const nonZeroIndex = fraction.split('').findIndex((char: any) => char !== '0') // If the price is less than 1, then there will be 4 decimal places after the first non-zero digit. // If the price is greater than or equal to 1, there will be 4 decimal places after the decimal point. @@ -269,13 +269,13 @@ const CandleChart = ({ priceFormat: { type: 'custom', formatter: (price: any) => { - let [whole, fraction] = price.toString().split('.') + const [, fraction] = price.toString().split('.') if (!fraction) { return price.toFixed(4) } - let nonZeroIndex = fraction.split('').findIndex((char: any) => char !== '0') + const nonZeroIndex = fraction.split('').findIndex((char: any) => char !== '0') // If the price is less than 1, then there will be 4 decimal places after the first non-zero digit. // If the price is greater than or equal to 1, there will be 4 decimal places after the decimal point. @@ -321,13 +321,13 @@ const CandleChart = ({ priceFormat: { type: 'custom', formatter: (price: any) => { - let [whole, fraction] = price.toString().split('.') + const [, fraction] = price.toString().split('.') if (!fraction) { return price.toFixed(4) } - let nonZeroIndex = fraction.split('').findIndex((char: any) => char !== '0') + const nonZeroIndex = fraction.split('').findIndex((char: any) => char !== '0') // If the price is less than 1, then there will be 4 decimal places after the first non-zero digit. // If the price is greater than or equal to 1, there will be 4 decimal places after the decimal point. diff --git a/packages/ui/src/Chart/ChartWrapper.tsx b/packages/ui/src/Chart/ChartWrapper.tsx index a0b99e962..8e34b5cfa 100644 --- a/packages/ui/src/Chart/ChartWrapper.tsx +++ b/packages/ui/src/Chart/ChartWrapper.tsx @@ -384,11 +384,6 @@ const StyledCheckbox = styled(Checkbox)` } ` -const TipIcon = styled(Icon)` - position: relative; - left: -2px; -` - const TipText = styled.p` font-size: var(--font-size-1); font-weight: none; diff --git a/packages/ui/src/Chart/types.ts b/packages/ui/src/Chart/types.ts index 2316845a2..4449f2b1c 100644 --- a/packages/ui/src/Chart/types.ts +++ b/packages/ui/src/Chart/types.ts @@ -4,24 +4,6 @@ export type ChartType = 'swap' | 'crvusd' | 'poolPage' export type TimeOptions = '15m' | '30m' | '1h' | '4h' | '6h' | '12h' | '1d' | '7d' | '14d' export type FetchingStatus = 'LOADING' | 'ERROR' | 'READY' -export const DEFAULT_CHART_COLORS: ChartColors = { - backgroundColor: '#fafafa', - lineColor: '#2962FF', - textColor: 'black', - areaTopColor: '#2962FF', - areaBottomColor: 'rgba(41, 98, 255, 0.28)', - chartGreenColor: '#2962FF', - chartRedColor: '#ef5350', - chartLabelColor: '#9B7DFF', - chartVolumeRed: '#ef53507e', - chartVolumeGreen: '#26a6997e', - chartOraclePrice: '#3360c9c0', - rangeColor: '#dfb316', - rangeColorA25: '#dfb4167f', - rangeColorOld: '#ab792f', - rangeColorA25Old: '#ab792f25', -} - export type ChartColors = { backgroundColor: string lineColor: string @@ -111,23 +93,6 @@ export interface LpPriceApiResponse { data: LpPriceOhlcData[] } -export interface LpExchangeRateObject { - main_token: string - reference_token: string - chain: string - address: string - data: LpPriceOhlcData[] -} - -export interface ChartDataObject { - main_token?: string - reference_token?: string - chain: string - address: string - label?: string - data: LpPriceOhlcData[] -} - export interface LpTradeToken { symbol: string address: string @@ -165,22 +130,6 @@ export interface LpTradesData { usd_fee: number } -export interface PricesTradesData { - sold_id: number - bought_id: number - tokens_sold: number - tokens_sold_usd: number - tokens_bought: number - tokens_bought_usd: number - price: number - block_number: number - time: string - transaction_hash: string - buyer: string - fee: number - usd_fee: number -} - export interface LpTradesApiResponse { chain: string address: string diff --git a/packages/ui/src/Chart/utils.ts b/packages/ui/src/Chart/utils.ts index a96c90c61..50c99bde0 100644 --- a/packages/ui/src/Chart/utils.ts +++ b/packages/ui/src/Chart/utils.ts @@ -1,21 +1,5 @@ import type { TimeOptions } from './types' -export const combinations = (inputArray: T[], size: number): T[][] => { - const combinationHelper = (start: number, chosen: T[]): T[][] => { - if (chosen.length === size) { - return [chosen] - } - let result: T[][] = [] - for (let i = start; i < inputArray.length; i++) { - const newChosen = [...chosen, inputArray[i]] - result = [...result, ...combinationHelper(i + 1, newChosen)] - } - return result - } - - return combinationHelper(0, []) -} - const seconds = { '5m': 5 * 60, '15m': 15 * 60, @@ -27,71 +11,14 @@ const seconds = { '1d': 24 * 60 * 60, '7d': 7 * 24 * 60 * 60, '14d': 14 * 24 * 60 * 60, -} +} as const export const subtractTimeUnit = (timeOption: TimeOptions, timestamp: number) => timestamp - seconds[timeOption] export const getThreeHundredResultsAgo = (timeOption: TimeOptions, timestamp: number) => Math.floor(timestamp - 299 * seconds[timeOption]) -export const getAggNumber = (timeOption: TimeOptions) => { - if (timeOption === '15m') return 15 // interval 900 - if (timeOption === '30m') return 30 - if (timeOption === '1h') return 1 // interval 3600 - if (timeOption === '4h') return 4 // interval 14400 - if (timeOption === '6h') return 6 - if (timeOption === '12h') return 12 - if (timeOption === '1d') return 1 // interval 86400 - if (timeOption === '7d') return 7 - if (timeOption === '14d') return 14 -} - -export const getTimeUnit = (timeOption: TimeOptions) => { - if (timeOption === '15m') return 'minute' - if (timeOption === '30m') return 'minute' - if (timeOption === '1h') return 'hour' - if (timeOption === '4h') return 'hour' - if (timeOption === '6h') return 'hour' - if (timeOption === '12h') return 'hour' - if (timeOption === '1d') return 'day' - if (timeOption === '7d') return 'day' - if (timeOption === '14d') return 'day' -} - -export const getMilliseconds = (timeOption: TimeOptions) => seconds[timeOption] * 1000 - -export const getLiquidationRange = ( - price1: string, - price2: string, - priceDataLength: number, - timeOption: TimeOptions, -) => { - const endDate = new Date() - const interval = getMilliseconds(timeOption) - const startDate = new Date(endDate.getTime() - priceDataLength * interval) - - const dataSeries1 = [] - const dataSeries2 = [] - - for (let i = 0; i < priceDataLength; i++) { - const date = new Date(startDate.getTime() + i * interval) - const timeStamp = Math.floor(date.getTime() / 1000) - - const value1 = price1 ? +price1.replace(/,/g, '') : 0 - const value2 = price2 ? +price2.replace(/,/g, '') : 0 - - dataSeries1.push({ time: timeStamp, value: value1 }) - dataSeries2.push({ time: timeStamp, value: value2 }) - } - - return { - upperRange: dataSeries1, - lowerRange: dataSeries2, - } -} - export const convertToLocaleTimestamp = (unixTimestamp: number) => { const offsetInSeconds = new Date().getTimezoneOffset() * 60 - const localTimestamp = unixTimestamp - offsetInSeconds - return localTimestamp + return unixTimestamp - offsetInSeconds } diff --git a/packages/ui/src/Radio/Radio.tsx b/packages/ui/src/Radio/Radio.tsx index 1b41e4979..be98e58fb 100644 --- a/packages/ui/src/Radio/Radio.tsx +++ b/packages/ui/src/Radio/Radio.tsx @@ -24,7 +24,7 @@ const Radio = ({ >) => { const inputRef = React.useRef(null) const state = React.useContext(RadioContext) - const { inputProps = {}, isSelected, isDisabled } = useRadio(props, state, inputRef) + const { inputProps = {}, isSelected } = useRadio(props, state, inputRef) const { isFocusVisible, focusProps } = useFocusRing() const labelClassName = `${className} ${state.isDisabled ? 'disabled' : ''}` diff --git a/packages/ui/src/Select/SelectSortingMethod.tsx b/packages/ui/src/Select/SelectSortingMethod.tsx index 857d0ad1a..8cfde2521 100644 --- a/packages/ui/src/Select/SelectSortingMethod.tsx +++ b/packages/ui/src/Select/SelectSortingMethod.tsx @@ -31,8 +31,4 @@ const StyledItem = styled(Item)` flex-wrap: no-wrap; ` -const Description = styled.p` - font-size: var(--font-size-2); -` - export default SelectSortingMethod diff --git a/packages/ui/src/Tooltip/Tooltip.tsx b/packages/ui/src/Tooltip/Tooltip.tsx index 6e17da7a9..444cfc8ca 100644 --- a/packages/ui/src/Tooltip/Tooltip.tsx +++ b/packages/ui/src/Tooltip/Tooltip.tsx @@ -19,7 +19,7 @@ const Tooltip = ({ increaseZIndex?: boolean } >) => { - const { tooltipProps, ...rest } = useTooltip(props, state) + const { tooltipProps } = useTooltip(props, state) const charCount = typeof props.children === 'string' ? props.children.length : null const getClosePlacement = useCallback((buttonNode: HTMLButtonElement | null) => { diff --git a/packages/ui/src/utils/helpers.ts b/packages/ui/src/utils/helpers.ts index 0d8e4e09b..e115e5df3 100644 --- a/packages/ui/src/utils/helpers.ts +++ b/packages/ui/src/utils/helpers.ts @@ -11,7 +11,7 @@ export function getIsMobile() { const mQ = matchMedia?.('(pointer:coarse)') if (mQ?.media === '(pointer:coarse)') { // @ts-ignore - hasTouchScreen = !!mQ.matches + hasTouchScreen = mQ.matches } else if ('orientation' in window) { hasTouchScreen = true // deprecated, but good fallback } else { @@ -65,7 +65,7 @@ export function shortenTokenAddress(tokenAddress: string, startOnly?: boolean) { export function copyToClipboard(text: string) { if (document.queryCommandSupported && document.queryCommandSupported('copy')) { - var textarea = document.createElement('textarea') + const textarea = document.createElement('textarea') textarea.textContent = text textarea.style.position = 'fixed' // Prevent scrolling to bottom of page in MS Edge. document.body.appendChild(textarea) diff --git a/tests/cypress/support/helpers/metamask.ts b/tests/cypress/support/helpers/metamask.ts index a05bbdd0c..aa7c8f92a 100644 --- a/tests/cypress/support/helpers/metamask.ts +++ b/tests/cypress/support/helpers/metamask.ts @@ -2,8 +2,7 @@ import { Eip1193BridgeV6 } from '@/tools/Eip1193BridgeV6' import { ethers } from 'ethers' export function injectMetamaskProvider(win: Cypress.AUTWindow, wallet: ethers.HDNodeWallet) { - const eip1193BridgeProvider = new Eip1193BridgeV6(wallet) - win.ethereum = eip1193BridgeProvider + win.ethereum = new Eip1193BridgeV6(wallet) win.ethereum.isMetaMask = true } diff --git a/tests/runHardhatNodes.js b/tests/runHardhatNodes.js index fdcde4a59..87f322cd5 100644 --- a/tests/runHardhatNodes.js +++ b/tests/runHardhatNodes.js @@ -10,17 +10,7 @@ const networks = require('./cypress/fixtures/networks.json') const BASIC_PORT = 8545 const HOST_NAME = '127.0.0.1' -const checkPort = (port) => { - return new Promise((resolve, reject) => { - exec(`lsof -i tcp:${port}`, (error, stdout, stderr) => { - if (error) { - resolve(false) // Port is not in use - } else { - resolve(true) // Port is in use - } - }) - }) -} +const checkPort = (port) => new Promise((resolve) => exec(`lsof -i tcp:${port}`, (error) => resolve(!error))) const startNode = (network) => { return new Promise(async (resolve, reject) => { From a7ce59fd869272552123a1c3263d928f1fb468d1 Mon Sep 17 00:00:00 2001 From: Daniel Schiavini Date: Fri, 28 Feb 2025 13:42:17 +0100 Subject: [PATCH 2/8] chore: delete unused code --- apps/main/src/dao/store/createLayoutSlice.ts | 17 --------- .../src/dao/store/createProposalsSlice.ts | 2 +- .../PageCreatePool/ConfirmModal/index.tsx | 12 ++----- .../Parameters/InitialPrice.tsx | 4 +-- .../components/SwitchTokensButton.tsx | 4 +-- .../src/dex/components/PagePoolList/index.tsx | 1 - apps/main/src/dex/components/PoolLabel.tsx | 2 +- .../src/dex/entities/gauge/api/gauge-query.ts | 11 ------ .../dex/entities/gauge/api/rewards-mutate.ts | 11 ------ apps/main/src/dex/entities/gauge/index.ts | 12 ------- .../src/dex/entities/gauge/lib/gauge-info.ts | 12 ------- .../gauge/model/estimate-gas-options.ts | 11 ------ .../dex/entities/gauge/model/query-keys.ts | 12 ------- .../add-gauge-reward-token/types/index.ts | 7 +--- apps/main/src/dex/hooks/usePageOnMount.ts | 5 +-- apps/main/src/dex/store/types.ts | 16 --------- .../loan/components/LoanInfoUser/index.tsx | 2 +- .../TransactionDetails/index.tsx | 1 - .../PageLoanManage/LoanLiquidate/index.tsx | 2 +- .../loan/components/PageMarketList/types.ts | 6 ---- apps/main/src/loan/components/TokenLabel.tsx | 2 +- .../src/loan/entities/scrvusdUserStats.ts | 3 +- packages/curve-ui-kit/src/lib/logging.ts | 1 - .../curve-ui-kit/src/lib/queries/combine.ts | 8 ----- packages/curve-ui-kit/src/utils/BigDecimal.ts | 18 +++------- packages/ui/src/AppForm/styles.ts | 2 +- packages/ui/src/AppPage/styles.ts | 3 +- packages/ui/src/Box/InfoBox.tsx | 35 ------------------- packages/ui/src/Box/index.ts | 1 - packages/ui/src/InputComp/InputDebounced.tsx | 6 ++-- packages/ui/src/InputComp/InputField.tsx | 5 +-- packages/ui/src/Overlay/OverlayContainer.tsx | 24 ------------- packages/ui/src/Overlay/index.ts | 1 - packages/ui/src/Popover2/Popover2Trigger.tsx | 4 +-- packages/ui/src/Stepper/StepAction.tsx | 2 +- packages/ui/src/Table/TheadSortButton.tsx | 2 +- packages/ui/src/utils/helpers.ts | 7 ---- 37 files changed, 32 insertions(+), 242 deletions(-) delete mode 100644 apps/main/src/dex/store/types.ts delete mode 100644 packages/ui/src/Box/InfoBox.tsx delete mode 100644 packages/ui/src/Overlay/OverlayContainer.tsx diff --git a/apps/main/src/dao/store/createLayoutSlice.ts b/apps/main/src/dao/store/createLayoutSlice.ts index 9cb085c2a..5763659ce 100644 --- a/apps/main/src/dao/store/createLayoutSlice.ts +++ b/apps/main/src/dao/store/createLayoutSlice.ts @@ -42,7 +42,6 @@ const DEFAULT_LAYOUT_HEIGHT: LayoutHeight = { secondaryNav: 0, footer: 0, } -export const layoutHeightKeys = ['globalAlert', 'mainNav', 'secondaryNav', 'footer'] as const const DEFAULT_STATE: SliceState = { height: DEFAULT_LAYOUT_HEIGHT, @@ -112,19 +111,3 @@ const createLayoutSlice = (set: SetState, get: GetState) => ({ }) export default createLayoutSlice - -export function getPageWidthClassName(pageWidth: number) { - if (pageWidth > 1920) { - return 'page-wide' - } else if (pageWidth > 1280 && pageWidth <= 1920) { - return 'page-large' - } else if (pageWidth > 960 && pageWidth <= 1280) { - return 'page-medium' - } else if (pageWidth > 450 && pageWidth <= 960) { - return 'page-small' - } else if (pageWidth > 321 && pageWidth <= 450) { - return 'page-small-x' - } else { - return 'page-small-xx' - } -} diff --git a/apps/main/src/dao/store/createProposalsSlice.ts b/apps/main/src/dao/store/createProposalsSlice.ts index 790f6330e..ea859ed14 100644 --- a/apps/main/src/dao/store/createProposalsSlice.ts +++ b/apps/main/src/dao/store/createProposalsSlice.ts @@ -297,7 +297,7 @@ const createProposalsSlice = (set: SetState, get: GetState): Propo const proposals = Object.values(proposalsData) const filteredProposals = filterProposals(proposals, activeFilter) - return sortProposals(filteredProposals, activeSortBy, activeSortDirection) + return sortProposals(filteredProposals, activeSortBy, activeSortDirection) }, setProposals: (searchValue: string) => { const { selectFilteredSortedProposals, activeSortBy, activeSortDirection } = get()[sliceKey] diff --git a/apps/main/src/dex/components/PageCreatePool/ConfirmModal/index.tsx b/apps/main/src/dex/components/PageCreatePool/ConfirmModal/index.tsx index 4d7ae1ad2..282849511 100644 --- a/apps/main/src/dex/components/PageCreatePool/ConfirmModal/index.tsx +++ b/apps/main/src/dex/components/PageCreatePool/ConfirmModal/index.tsx @@ -1,26 +1,20 @@ -import { useRef, useMemo, useCallback } from 'react' +import { useCallback, useMemo, useRef } from 'react' import { useOverlayTriggerState } from '@react-stately/overlays' import { useButton } from '@react-aria/button' import styled from 'styled-components' import { t } from '@ui-kit/lib/i18n' -import { useNavigate } from 'react-router-dom' -import { useParams } from 'react-router-dom' +import { useNavigate, useParams } from 'react-router-dom' import { getPath } from '@/dex/utils/utilsRouter' - import useStore from '@/dex/store/useStore' - import { breakpoints } from '@ui/utils/responsive' import { checkFormReady } from '@/dex/components/PageCreatePool/utils' - import Icon from '@ui/Icon' import Box from '@ui/Box' import Button from '@ui/Button' import InternalLinkButton from '@ui/InternalLinkButton' -import ExternalLink from '@ui/Link/ExternalLink' import { ROUTE } from '@/dex/constants' import Spinner from 'ui/src/Spinner/Spinner' import ModalPendingTx from 'ui/src/ModalPendingTx' - import ModalDialog from '@/dex/components/PageCreatePool/ConfirmModal/ModalDialog' import CreatePoolButton from '@/dex/components/PageCreatePool/ConfirmModal/CreatePoolButton' import InfoLinkBar from '@/dex/components/PageCreatePool/ConfirmModal/CreateInfoLinkBar' @@ -28,7 +22,7 @@ import PoolTypeSummary from '@/dex/components/PageCreatePool/Summary/PoolTypeSum import TokensInPoolSummary from '@/dex/components/PageCreatePool/Summary/TokensInPoolSummary' import ParametersSummary from '@/dex/components/PageCreatePool/Summary/ParametersSummary' import PoolInfoSummary from '@/dex/components/PageCreatePool/Summary/PoolInfoSummary' -import { CurveApi, ChainId } from '@/dex/types/main.types' +import { ChainId, CurveApi } from '@/dex/types/main.types' type Props = { disabled?: boolean diff --git a/apps/main/src/dex/components/PageCreatePool/Parameters/InitialPrice.tsx b/apps/main/src/dex/components/PageCreatePool/Parameters/InitialPrice.tsx index 280d5180a..04839709f 100644 --- a/apps/main/src/dex/components/PageCreatePool/Parameters/InitialPrice.tsx +++ b/apps/main/src/dex/components/PageCreatePool/Parameters/InitialPrice.tsx @@ -68,9 +68,9 @@ const InitialPrice = ({ curve, chainId }: Props) => { )} - + {tokenAmount === 3 && ( - + )} diff --git a/apps/main/src/dex/components/PageCreatePool/components/SwitchTokensButton.tsx b/apps/main/src/dex/components/PageCreatePool/components/SwitchTokensButton.tsx index 3955e4afc..52be965fc 100644 --- a/apps/main/src/dex/components/PageCreatePool/components/SwitchTokensButton.tsx +++ b/apps/main/src/dex/components/PageCreatePool/components/SwitchTokensButton.tsx @@ -1,6 +1,5 @@ import styled from 'styled-components' import { t } from '@ui-kit/lib/i18n' - import useStore from '@/dex/store/useStore' import { TOKEN_A, @@ -12,10 +11,9 @@ import { TOKEN_G, TOKEN_H, } from '@/dex/components/PageCreatePool/constants' - import Icon from '@ui/Icon' import IconButton from '@ui/IconButton' -import { CurveApi, ChainId } from '@/dex/types/main.types' +import { CurveApi } from '@/dex/types/main.types' type Props = { curve: CurveApi diff --git a/apps/main/src/dex/components/PagePoolList/index.tsx b/apps/main/src/dex/components/PagePoolList/index.tsx index 84545d678..700faa372 100644 --- a/apps/main/src/dex/components/PagePoolList/index.tsx +++ b/apps/main/src/dex/components/PagePoolList/index.tsx @@ -1,6 +1,5 @@ import type { ColumnKeys, PagePoolList, SearchParams } from '@/dex/components/PagePoolList/types' import React, { useCallback, useEffect, useMemo, useState } from 'react' -import styled from 'styled-components' import { COLUMN_KEYS } from '@/dex/components/PagePoolList/utils' import { DEFAULT_FORM_STATUS, getPoolListActiveKey } from '@/dex/store/createPoolListSlice' import { REFRESH_INTERVAL } from '@/dex/constants' diff --git a/apps/main/src/dex/components/PoolLabel.tsx b/apps/main/src/dex/components/PoolLabel.tsx index 683d35282..9565d5c46 100644 --- a/apps/main/src/dex/components/PoolLabel.tsx +++ b/apps/main/src/dex/components/PoolLabel.tsx @@ -8,7 +8,7 @@ import useTokenAlert from '@/dex/hooks/useTokenAlert' import { Chip } from '@ui/Typography' import AlertBox from '@ui/AlertBox' -import AlertTooltipIcon from '@ui/Tooltip/TooltipAlert' +import { TooltipAlert as AlertTooltipIcon } from '@ui/Tooltip' import Box from '@ui/Box' import ChipPool from '@/dex/components/ChipPool' import ChipToken from '@/dex/components/ChipToken' diff --git a/apps/main/src/dex/entities/gauge/api/gauge-query.ts b/apps/main/src/dex/entities/gauge/api/gauge-query.ts index c91d3f19d..05d429f0d 100644 --- a/apps/main/src/dex/entities/gauge/api/gauge-query.ts +++ b/apps/main/src/dex/entities/gauge/api/gauge-query.ts @@ -1,14 +1,3 @@ -/** - * @file entities/gauge/api.ts - * @description This file contains API functions for fetching and manipulating gauge-related data. - * It serves as part of the 'gauge' entity in the FSD architecture. - * - * The functions in this file interact with the Curve.fi protocol and are typically used - * in conjunction with React Query for state management in the application. - * Other files in the 'gauge' entity may use these functions to handle gauge-specific - * business logic and data fetching. - */ - import { type Address, zeroAddress } from 'viem' import { DepositRewardApproveQuery } from '@/dex/entities/gauge/types' import { BD } from '@ui-kit/utils' diff --git a/apps/main/src/dex/entities/gauge/api/rewards-mutate.ts b/apps/main/src/dex/entities/gauge/api/rewards-mutate.ts index 3556e63ee..6738ca960 100644 --- a/apps/main/src/dex/entities/gauge/api/rewards-mutate.ts +++ b/apps/main/src/dex/entities/gauge/api/rewards-mutate.ts @@ -1,14 +1,3 @@ -/** - * @file entities/gauge/api.ts - * @description This file contains API functions for fetching and manipulating gauge-related data. - * It serves as part of the 'gauge' entity in the FSD architecture. - * - * The functions in this file interact with the Curve.fi protocol and are typically used - * in conjunction with React Query for state management in the application. - * Other files in the 'gauge' entity may use these functions to handle gauge-specific - * business logic and data fetching. - */ - import { AddRewardQuery, DepositRewardApproveQuery, DepositRewardQuery } from '@/dex/entities/gauge/types' import useStore from '@/dex/store/useStore' diff --git a/apps/main/src/dex/entities/gauge/index.ts b/apps/main/src/dex/entities/gauge/index.ts index f99c4bd09..3d607ecaa 100644 --- a/apps/main/src/dex/entities/gauge/index.ts +++ b/apps/main/src/dex/entities/gauge/index.ts @@ -1,15 +1,3 @@ -/** - * @file entities/gauge/index.ts - * @description This is the main entry point for the 'gauge' entity in the FSD architecture. - * It exports all the necessary components, functions, and types related to gauges in the Curve.fi DApp. - * - * This file serves as a centralized export point, making it easier for other parts of the application - * to import gauge-related functionality without having to know the exact file structure. - * - * By using this index file, we maintain a clean and organized structure for the gauge entity, - * following the principles of FSD. - */ - export * from './lib' export * from './types' export * from './model' diff --git a/apps/main/src/dex/entities/gauge/lib/gauge-info.ts b/apps/main/src/dex/entities/gauge/lib/gauge-info.ts index c317c4f87..a7e4eaec4 100644 --- a/apps/main/src/dex/entities/gauge/lib/gauge-info.ts +++ b/apps/main/src/dex/entities/gauge/lib/gauge-info.ts @@ -1,15 +1,3 @@ -/** - * @file entities/gauge/lib.ts - * @description This file contains custom hooks and utility functions for gauge-related operations in the Curve.fi DApp. - * It's a crucial part of the 'gauge' entity in the FSD architecture. - * - * The hooks in this file provide an easy-to-use interface for components to interact with gauge data and operations. - * They encapsulate the usage of React Query and the application's global state, offering a clean API - * - * These hooks abstract away the complexity of data fetching and state management, - * allowing components to easily access and manipulate gauge-related data. - */ - import * as models from '@/dex/entities/gauge/model' export const { useQuery: useIsDepositRewardAvailable } = models.depositRewardAvailable diff --git a/apps/main/src/dex/entities/gauge/model/estimate-gas-options.ts b/apps/main/src/dex/entities/gauge/model/estimate-gas-options.ts index 6704061c5..c4a72a057 100644 --- a/apps/main/src/dex/entities/gauge/model/estimate-gas-options.ts +++ b/apps/main/src/dex/entities/gauge/model/estimate-gas-options.ts @@ -1,14 +1,3 @@ -/** - * @description This file defines the data fetching and mutation logic for gauge-related operations in the Curve.fi DApp. - * It's a core part of the 'gauge' entity in the FSD architecture. - * - * This module exports functions that create React Query options for various gauge operations - * - * These functions utilize the API methods from './api' and query keys from './query-keys', - * providing a clean interface for components to interact with gauge data. - * They encapsulate the data fetching logic, making it easier to manage and reuse across the application. - */ - import * as api from '@/dex/entities/gauge/api' import type { AddRewardParams, DepositRewardApproveParams, DepositRewardParams } from '@/dex/entities/gauge/types' import { queryFactory, rootKeys } from '@ui-kit/lib/model/query' diff --git a/apps/main/src/dex/entities/gauge/model/query-keys.ts b/apps/main/src/dex/entities/gauge/model/query-keys.ts index 75bc382a7..7808fb560 100644 --- a/apps/main/src/dex/entities/gauge/model/query-keys.ts +++ b/apps/main/src/dex/entities/gauge/model/query-keys.ts @@ -1,15 +1,3 @@ -/** - * @description This file defines the query keys used for React Query operations related to gauges in the Curve.fi DApp. - * It's an integral part of the 'gauge' entity in the FSD architecture. - * - * The `gaugeKeys` object contains functions that generate consistent and type-safe query keys - * for various gauge-related operations. - * - * These query keys are used throughout the application to ensure consistent caching, - * refetching, and invalidation of gauge-related data in React Query. - * They play a crucial role in maintaining a predictable and efficient data fetching strategy. - */ - import type { AddRewardParams, DepositRewardApproveParams, DepositRewardParams } from '@/dex/entities/gauge/types' import { GaugeParams, rootKeys } from '@ui-kit/lib/model/query' diff --git a/apps/main/src/dex/features/add-gauge-reward-token/types/index.ts b/apps/main/src/dex/features/add-gauge-reward-token/types/index.ts index 46d67efab..4bf72860a 100644 --- a/apps/main/src/dex/features/add-gauge-reward-token/types/index.ts +++ b/apps/main/src/dex/features/add-gauge-reward-token/types/index.ts @@ -1,10 +1,5 @@ import type { Address } from 'viem' -import { ChainId, PoolData } from '@/dex/types/main.types' - -export interface ManageGaugeProps { - pool: PoolData - chainId: ChainId -} +import { ChainId } from '@/dex/types/main.types' export type AddRewardTokenProps = { chainId: ChainId diff --git a/apps/main/src/dex/hooks/usePageOnMount.ts b/apps/main/src/dex/hooks/usePageOnMount.ts index 2e7ec25cb..c01c1677d 100644 --- a/apps/main/src/dex/hooks/usePageOnMount.ts +++ b/apps/main/src/dex/hooks/usePageOnMount.ts @@ -104,7 +104,7 @@ function usePageOnMount(params: Params, location: Location, navigate: NavigateFu } else { const foundNetwork = networks[walletChainId as ChainId]?.id if (foundNetwork) { - console.warn(`Network is switched to ${walletChainId}, redirecting...`, parsedParams) + console.warn(`Network is switched to ${walletChainId}, redirecting...`, parsedParams.rChainId, parsedParams.restFullPathname) navigate(`/${foundNetwork}/${parsedParams.restFullPathname}`) updateConnectState('loading', CONNECT_STAGE.CONNECT_API, [walletChainId, true]) } else { @@ -161,7 +161,8 @@ function usePageOnMount(params: Params, location: Location, navigate: NavigateFu if (foundNetwork) { console.warn( `Could not switch network to ${newChainId}, redirecting to ${foundNetwork}`, - parsedParams, + currChainId, + parsedParams.restFullPathname, error, ) navigate(`/${foundNetwork}/${parsedParams.restFullPathname}`) diff --git a/apps/main/src/dex/store/types.ts b/apps/main/src/dex/store/types.ts deleted file mode 100644 index cafe01de3..000000000 --- a/apps/main/src/dex/store/types.ts +++ /dev/null @@ -1,16 +0,0 @@ -export interface PricesApiCoin { - pool_index: number - symbol: string - address: string -} - -export interface PricesApiPool { - name: string - address: string - n_coins: number - tvl_usd: number - trading_fee_24h: number - liquidity_volume_24h: number - liquidity_fee_24h: number - coins: PricesApiCoin[] -} diff --git a/apps/main/src/loan/components/LoanInfoUser/index.tsx b/apps/main/src/loan/components/LoanInfoUser/index.tsx index 49e5fe4e2..a15a4a703 100644 --- a/apps/main/src/loan/components/LoanInfoUser/index.tsx +++ b/apps/main/src/loan/components/LoanInfoUser/index.tsx @@ -19,7 +19,7 @@ import UserInfos from '@/loan/components/LoanInfoUser/components/UserInfos' import { useUserProfileStore } from '@ui-kit/features/user-profile' import { ChainId } from '@/loan/types/loan.types' -interface Props extends Pick { +interface Props extends Pick { rChainId: ChainId } diff --git a/apps/main/src/loan/components/PageCrvUsdStaking/TransactionDetails/index.tsx b/apps/main/src/loan/components/PageCrvUsdStaking/TransactionDetails/index.tsx index 97ebfbdfe..a5429aa9f 100644 --- a/apps/main/src/loan/components/PageCrvUsdStaking/TransactionDetails/index.tsx +++ b/apps/main/src/loan/components/PageCrvUsdStaking/TransactionDetails/index.tsx @@ -12,7 +12,6 @@ import Box from '@ui/Box' import Loader from '@ui/Loader' import Switch from '@/loan/components/PageCrvUsdStaking/components/Switch' -import DetailInfoSlippageTolerance from '@/loan/components/DetailInfoSlippageTolerance' import FieldValue from '@/loan/components/PageCrvUsdStaking/TransactionDetails/FieldValue' import { useWallet } from '@ui-kit/features/connect-wallet' import Collapse from '@mui/material/Collapse' diff --git a/apps/main/src/loan/components/PageLoanManage/LoanLiquidate/index.tsx b/apps/main/src/loan/components/PageLoanManage/LoanLiquidate/index.tsx index 2aca9accd..f318c68b6 100644 --- a/apps/main/src/loan/components/PageLoanManage/LoanLiquidate/index.tsx +++ b/apps/main/src/loan/components/PageLoanManage/LoanLiquidate/index.tsx @@ -15,7 +15,7 @@ import useStore from '@/loan/store/useStore' import networks from '@/loan/networks' import AlertFormWarning from '@/loan/components/AlertFormWarning' import AlertFormError from '@/loan/components/AlertFormError' -import AlertInfoSelfLiquidation from '@ui/AlertBox/AlertInfoSelfLiquidation' +import { AlertInfoSelfLiquidation } from '@ui/AlertBox' import DetailInfoEstimateGas from '@/loan/components/DetailInfoEstimateGas' import DetailInfoSlippageTolerance from '@/loan/components/DetailInfoSlippageTolerance' import InputReadOnly from '@ui/InputReadOnly' diff --git a/apps/main/src/loan/components/PageMarketList/types.ts b/apps/main/src/loan/components/PageMarketList/types.ts index 130df672a..b8837604a 100644 --- a/apps/main/src/loan/components/PageMarketList/types.ts +++ b/apps/main/src/loan/components/PageMarketList/types.ts @@ -51,9 +51,3 @@ export type TableLabel = { width?: string indicatorPlacement?: TheadSortButtonProps['indicatorPlacement'] } - -export type TableSettings = { - isNotSortable?: boolean - sortBy?: TitleKey | '' - sortByOrder?: Order -} diff --git a/apps/main/src/loan/components/TokenLabel.tsx b/apps/main/src/loan/components/TokenLabel.tsx index 58661c0c9..5cc3ba3da 100644 --- a/apps/main/src/loan/components/TokenLabel.tsx +++ b/apps/main/src/loan/components/TokenLabel.tsx @@ -3,7 +3,7 @@ import styled from 'styled-components' import useCollateralAlert from '@/loan/hooks/useCollateralAlert' -import AlertTooltipIcon from '@ui/Tooltip/TooltipAlert' +import { TooltipAlert as AlertTooltipIcon } from '@ui/Tooltip' import Box from '@ui/Box' import { TokenIcon } from '@ui-kit/shared/ui/TokenIcon' import { CollateralData, CollateralDataCache } from '@/loan/types/loan.types' diff --git a/apps/main/src/loan/entities/scrvusdUserStats.ts b/apps/main/src/loan/entities/scrvusdUserStats.ts index 29ba77f69..daaebc2b7 100644 --- a/apps/main/src/loan/entities/scrvusdUserStats.ts +++ b/apps/main/src/loan/entities/scrvusdUserStats.ts @@ -3,7 +3,8 @@ import { queryFactory } from '@ui-kit/lib/model/query' import { getUserStats } from '@curvefi/prices-api/savings' import { userAddressValidationSuite } from '@ui-kit/lib/model/query/user-address-validation' -const _fetchScrvUsdUserStats = async ({ userAddress }: { userAddress: string }): Promise => await getUserStats(userAddress) +const _fetchScrvUsdUserStats = async ({ userAddress }: { userAddress: string }): Promise => + await getUserStats(userAddress) export const { useQuery: useScrvUsdUserStats } = queryFactory({ queryKey: (params: { userAddress: string }) => ['scrvUsdUserStats', { userAddress: params.userAddress }] as const, diff --git a/packages/curve-ui-kit/src/lib/logging.ts b/packages/curve-ui-kit/src/lib/logging.ts index f0bb21c2d..05307bcbe 100644 --- a/packages/curve-ui-kit/src/lib/logging.ts +++ b/packages/curve-ui-kit/src/lib/logging.ts @@ -115,4 +115,3 @@ export const logQuery = (key: LogKey, ...args: unknown[]) => log(key, LogStatus. export const logMutation = (key: LogKey, ...args: unknown[]) => log(key, LogStatus.MUTATION, ...args) export const logError = (key: LogKey, ...args: unknown[]) => log(key, LogStatus.ERROR, ...args) export const logSuccess = (key: LogKey, ...args: unknown[]) => log(key, LogStatus.SUCCESS, ...args) -export const logInfo = (key: LogKey, ...args: unknown[]) => log(key, LogStatus.INFO, ...args) diff --git a/packages/curve-ui-kit/src/lib/queries/combine.ts b/packages/curve-ui-kit/src/lib/queries/combine.ts index 74dc54289..cfd6b309c 100644 --- a/packages/curve-ui-kit/src/lib/queries/combine.ts +++ b/packages/curve-ui-kit/src/lib/queries/combine.ts @@ -18,14 +18,6 @@ export const combineQueriesMeta = ( isFetching: results.some((result) => result.isFetching), }) -/** Combines the data and metadata of multiple queries into a single object. */ -const combineQueriesToList = ( - results: QueryResultsArray, -): CombinedQueriesResult => ({ - data: results.map((result) => result.data), - ...combineQueriesMeta(results), -}) - /** Combines the data and metadata of multiple queries into a single object. */ const combineQueriesToObject = ( results: QueryResultsArray, diff --git a/packages/curve-ui-kit/src/utils/BigDecimal.ts b/packages/curve-ui-kit/src/utils/BigDecimal.ts index 59df44f96..5e6773e64 100644 --- a/packages/curve-ui-kit/src/utils/BigDecimal.ts +++ b/packages/curve-ui-kit/src/utils/BigDecimal.ts @@ -3,10 +3,10 @@ import { BigDecimalTypes } from './BigDecimal.d' class BigDecimal { private static readonly STRING_REGEX = /^(-?)(\d*)(?:\.(\d+))?$/ - private readonly _integerPart: bigint - private readonly _fractionalPart: bigint - private readonly _scale: number - private readonly _isNegative: boolean + private _integerPart: bigint + private _fractionalPart: bigint + private _scale: number + private _isNegative: boolean /** * Creates a new BigDecimal instance. @@ -85,7 +85,7 @@ class BigDecimal { return !isNaN(value) && isFinite(value) } - return typeof value === 'bigint'; + return typeof value === 'bigint' } /** @@ -217,14 +217,6 @@ class BigDecimal { return new BigDecimal(this._integerPart * this.scaleFactor(newScale) + newFractionalPart, newScale) } - private scaleDown(newScale: number): BigDecimal { - if (newScale >= this._scale) return this - const scaleDiff = this._scale - newScale - const divisor = this.scaleFactor(scaleDiff) - const newFractionalPart = this._fractionalPart / divisor - return new BigDecimal(this._integerPart * this.scaleFactor(newScale) + newFractionalPart, newScale) - } - /** * Implements the toPrimitive symbol to allow BigDecimal to be used in comparisons. */ diff --git a/packages/ui/src/AppForm/styles.ts b/packages/ui/src/AppForm/styles.ts index 223c794b4..ebf87df2e 100644 --- a/packages/ui/src/AppForm/styles.ts +++ b/packages/ui/src/AppForm/styles.ts @@ -2,7 +2,7 @@ import styled from 'styled-components' import Box from 'ui/src/Box' import SlideTab from 'ui/src/TabSlide/SlideTab' -import TabContentWrapper from 'ui/src/Tab/TabContentWrapper' +import { TabContentWrapper } from 'ui/src/Tab' export const AppFormContentWrapper = styled(TabContentWrapper)` align-items: flex-start; diff --git a/packages/ui/src/AppPage/styles.ts b/packages/ui/src/AppPage/styles.ts index 9c2852e97..2f23f9ff4 100644 --- a/packages/ui/src/AppPage/styles.ts +++ b/packages/ui/src/AppPage/styles.ts @@ -4,8 +4,7 @@ import { breakpoints } from 'ui/src/utils' import Box from 'ui/src/Box' import BoxHeader from 'ui/src/Box/BoxHeader' -import TabContentWrapper from 'ui/src/Tab/TabContentWrapper' -import TextEllipsis from 'ui/src/TextEllipsis' +import { TabContentWrapper } from 'ui/src/Tab' // PAGE STYLES export const AppPageContainer = styled.div` diff --git a/packages/ui/src/Box/InfoBox.tsx b/packages/ui/src/Box/InfoBox.tsx deleted file mode 100644 index 3aefb4950..000000000 --- a/packages/ui/src/Box/InfoBox.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import * as React from 'react' -import styled from 'styled-components' - -type Props = {} - -const InfoBox = ({ children, ...rest }: React.PropsWithChildren) => ( - - {children} - -) - -export const Wrapper = styled.div` - padding: var(--spacing-2); - background-color: var(--info-400); -` - -const Message = styled.span` - width: 100%; - font-size: var(--font-size-4); - font-weight: var(--font-weight--semi-bold); - color: var(--white); - - &::before { - content: '!'; - padding: 0 var(--spacing-2); - margin-right: var(--spacing-2); - color: var(--info-400); - background-color: var(--white); - border-radius: 2px; - } -` - -InfoBox.displayName = 'InfoBox' - -export default InfoBox diff --git a/packages/ui/src/Box/index.ts b/packages/ui/src/Box/index.ts index fa8a32131..6d840c962 100644 --- a/packages/ui/src/Box/index.ts +++ b/packages/ui/src/Box/index.ts @@ -1,3 +1,2 @@ -export { default as InfoBox } from './InfoBox' export { default as BoxHeader } from './BoxHeader' export { default } from './Box' diff --git a/packages/ui/src/InputComp/InputDebounced.tsx b/packages/ui/src/InputComp/InputDebounced.tsx index c28858cee..2142c0acd 100644 --- a/packages/ui/src/InputComp/InputDebounced.tsx +++ b/packages/ui/src/InputComp/InputDebounced.tsx @@ -3,11 +3,11 @@ import type { InputLabelProps, InputProps } from './types' import React from 'react' import { useInputContext } from 'ui/src/InputComp/InputProvider' -import useDebounceValue from 'ui/src/hooks/useDebouncedValue' +import { useDebouncedValue } from 'ui/src/hooks' import Box from 'ui/src/Box/Box' import Input from 'ui/src/InputComp/Input' -import InputLabel from 'ui/src/InputComp/InputLabel' +import { InputLabel } from 'ui/src/InputComp' const InputDebounced = ({ className, @@ -27,7 +27,7 @@ const InputDebounced = ({ onChange: (value: string) => void }) => { const { disabled: contextDisabled } = useInputContext() - const [debouncedValue, handleInputChange] = useDebounceValue(value, delay, onChange) + const [debouncedValue, handleInputChange] = useDebouncedValue(value, delay, onChange) return ( diff --git a/packages/ui/src/InputComp/InputField.tsx b/packages/ui/src/InputComp/InputField.tsx index da2f1126d..ae9041480 100644 --- a/packages/ui/src/InputComp/InputField.tsx +++ b/packages/ui/src/InputComp/InputField.tsx @@ -1,12 +1,9 @@ import type { InputLabelProps, InputProps } from 'ui/src/InputComp/types' - import * as React from 'react' import styled from 'styled-components' - import Box from 'ui/src/Box/Box' import Input from 'ui/src/InputComp/Input' -import InputLabel from 'ui/src/InputComp/InputLabel' -import InputMessage from 'ui/src/InputComp/InputMessage' +import { InputLabel, InputMessage } from 'ui/src/InputComp' const InputField = ({ className, diff --git a/packages/ui/src/Overlay/OverlayContainer.tsx b/packages/ui/src/Overlay/OverlayContainer.tsx deleted file mode 100644 index 5872830be..000000000 --- a/packages/ui/src/Overlay/OverlayContainer.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import styled from 'styled-components' -import { OverlayContainer as Container } from 'react-aria' - -import { breakpoints } from 'ui/src/utils/responsive' - -const OverlayContainer = styled(Container)` - position: absolute; - top: 0; - left: 0; - bottom: 0; - right: 0; - background: var(--dialog--background-color); - - width: 100%; - height: 100%; - z-index: var(--z-index-overlay); - - @media (min-width: ${breakpoints.sm}rem) { - background: rgba(0, 0, 0, 0.5); - backdrop-filter: blur(3px); - } -` - -export default OverlayContainer diff --git a/packages/ui/src/Overlay/index.ts b/packages/ui/src/Overlay/index.ts index 02e187e42..3638ac763 100644 --- a/packages/ui/src/Overlay/index.ts +++ b/packages/ui/src/Overlay/index.ts @@ -1,2 +1 @@ -export { default as OverlayContainer } from './OverlayContainer' export { default } from './Overlay' diff --git a/packages/ui/src/Popover2/Popover2Trigger.tsx b/packages/ui/src/Popover2/Popover2Trigger.tsx index 46e919b8f..617182507 100644 --- a/packages/ui/src/Popover2/Popover2Trigger.tsx +++ b/packages/ui/src/Popover2/Popover2Trigger.tsx @@ -5,8 +5,8 @@ import * as React from 'react' import styled from 'styled-components' import Icon from 'ui/src/Icon/Icon' -import Popover2 from 'ui/src/Popover2/Popover2' -import Popover2Button from 'ui/src/Popover2/Popover2Button' +import { Popover2 } from 'ui/src/Popover2' +import { Popover2Button } from 'ui/src/Popover2' function Popover2Trigger({ label, children, showExpandIcon = false, ...props }) { let ref = React.useRef(null) diff --git a/packages/ui/src/Stepper/StepAction.tsx b/packages/ui/src/Stepper/StepAction.tsx index 408a66330..992405926 100644 --- a/packages/ui/src/Stepper/StepAction.tsx +++ b/packages/ui/src/Stepper/StepAction.tsx @@ -10,7 +10,7 @@ import styled, { css } from 'styled-components' import { isInProgress, taskStepStatusStyles } from './helpers' import Button from 'ui/src/Button' import Spinner from 'ui/src/Spinner/Spinner' -import StepModal from 'ui/src/Stepper/StepModal' +import { StepModal } from 'ui/src/Stepper' const StepAction = ({ className, step }: { className?: string; step: Step }) => { const overlayTriggerState = useOverlayTriggerState({}) diff --git a/packages/ui/src/Table/TheadSortButton.tsx b/packages/ui/src/Table/TheadSortButton.tsx index 1d54aca1a..52006264d 100644 --- a/packages/ui/src/Table/TheadSortButton.tsx +++ b/packages/ui/src/Table/TheadSortButton.tsx @@ -6,7 +6,7 @@ import styled from 'styled-components' import Spinner from 'ui/src/Spinner/Spinner' import SortIcon from 'ui/src/SortIcon/SortIcon' -import TheadButton from 'ui/src/Table/TheadButton' +import { TheadButton } from 'ui/src/Table' export type Order = 'desc' | 'asc' diff --git a/packages/ui/src/utils/helpers.ts b/packages/ui/src/utils/helpers.ts index e115e5df3..121b4abe0 100644 --- a/packages/ui/src/utils/helpers.ts +++ b/packages/ui/src/utils/helpers.ts @@ -49,13 +49,6 @@ export function shortenAccount(account: string, visibleLength = 4) { } } -export const sizes = { - sm: '0.875rem', //14px - md: '1.125rem', // 18px - lg: '1.5rem', // 24px - xl: '1.75rem', // 28px -} - export function shortenTokenAddress(tokenAddress: string, startOnly?: boolean) { if (!tokenAddress) return const start = tokenAddress.slice(0, 4) From 19702f0a24fa96d4342d0368208c13043e523195 Mon Sep 17 00:00:00 2001 From: Daniel Schiavini Date: Fri, 28 Feb 2025 13:49:55 +0100 Subject: [PATCH 3/8] chore: delete unused code --- .../ComboBoxSelectGauge/ComboBoxListItem.tsx | 2 +- .../PageCreatePool/Parameters/InitialPrice.tsx | 10 +++------- .../dex/components/PageCreatePool/Parameters/index.tsx | 2 +- apps/main/src/dex/hooks/usePageOnMount.ts | 6 +++++- packages/curve-ui-kit/src/lib/queries/factory.ts | 1 - packages/ui/src/AppPage/styles.ts | 2 -- packages/ui/src/Chart/ChartWrapper.tsx | 2 -- 7 files changed, 10 insertions(+), 15 deletions(-) diff --git a/apps/main/src/dao/components/ComboBoxSelectGauge/ComboBoxListItem.tsx b/apps/main/src/dao/components/ComboBoxSelectGauge/ComboBoxListItem.tsx index eaa5fbc56..0dfdb4c06 100644 --- a/apps/main/src/dao/components/ComboBoxSelectGauge/ComboBoxListItem.tsx +++ b/apps/main/src/dao/components/ComboBoxSelectGauge/ComboBoxListItem.tsx @@ -40,7 +40,7 @@ const ComboBoxListItem = ({ const ItemButton = styled(Button)` ${focusVisible}; - &.focus-visible, + &:focus-visible, &.active { color: var(--box--primary--color); background-color: var(--table_detail_row--active--background-color); diff --git a/apps/main/src/dex/components/PageCreatePool/Parameters/InitialPrice.tsx b/apps/main/src/dex/components/PageCreatePool/Parameters/InitialPrice.tsx index 04839709f..e51251e0b 100644 --- a/apps/main/src/dex/components/PageCreatePool/Parameters/InitialPrice.tsx +++ b/apps/main/src/dex/components/PageCreatePool/Parameters/InitialPrice.tsx @@ -8,15 +8,14 @@ import useStore from '@/dex/store/useStore' import Box from '@ui/Box' import NumberField from '@/dex/components/PageCreatePool/components/NumberField' import SwitchTokensButton from '@/dex/components/PageCreatePool/components/SwitchTokensButton' -import { CurveApi, ChainId } from '@/dex/types/main.types' +import { CurveApi } from '@/dex/types/main.types' type Props = { curve: CurveApi - chainId: ChainId haveSigner: boolean } -const InitialPrice = ({ curve, chainId }: Props) => { +const InitialPrice = ({ curve }: Props) => { const { tokensInPool: { tokenA, tokenB, tokenC, tokenAmount }, initialPrice, @@ -69,9 +68,7 @@ const InitialPrice = ({ curve, chainId }: Props) => { - {tokenAmount === 3 && ( - - )} + {tokenAmount === 3 && } @@ -183,7 +180,6 @@ const SumWrapper = styled.div` const InitialPriceSumData = styled.div` padding: var(--spacing-2) var(--spacing-3); - color: var(--box--primary--color); background-color: var(--layout--home--background-color); border: 1px solid var(--border-600); color: var(--page--text-color); diff --git a/apps/main/src/dex/components/PageCreatePool/Parameters/index.tsx b/apps/main/src/dex/components/PageCreatePool/Parameters/index.tsx index 81068047f..e3fb59769 100644 --- a/apps/main/src/dex/components/PageCreatePool/Parameters/index.tsx +++ b/apps/main/src/dex/components/PageCreatePool/Parameters/index.tsx @@ -268,7 +268,7 @@ const Parameters = ({ curve, chainId, haveSigner }: Props) => { {(tokensInPool.tokenA.address && tokensInPool.tokenB.address) !== '' && ( {t`Dollar prices are fetched from coingecko.`} )} - + {checkInitialPrice && ( ( diff --git a/packages/ui/src/AppPage/styles.ts b/packages/ui/src/AppPage/styles.ts index 2f23f9ff4..c106a4211 100644 --- a/packages/ui/src/AppPage/styles.ts +++ b/packages/ui/src/AppPage/styles.ts @@ -1,7 +1,5 @@ import styled from 'styled-components' - import { breakpoints } from 'ui/src/utils' - import Box from 'ui/src/Box' import BoxHeader from 'ui/src/Box/BoxHeader' import { TabContentWrapper } from 'ui/src/Tab' diff --git a/packages/ui/src/Chart/ChartWrapper.tsx b/packages/ui/src/Chart/ChartWrapper.tsx index 8e34b5cfa..d74c0c3cf 100644 --- a/packages/ui/src/Chart/ChartWrapper.tsx +++ b/packages/ui/src/Chart/ChartWrapper.tsx @@ -315,7 +315,6 @@ const MagnetButton = styled(Button)` margin-left: var(--spacing-2); margin-right: var(--spacing-2); box-shadow: none; - display: flex; display: none; align-items: center; &.active:not(:disabled) { @@ -329,7 +328,6 @@ const MagnetButton = styled(Button)` const RefreshButton = styled(Button)` margin-left: var(--spacing-2); box-shadow: none; - display: flex; display: none; align-items: center; &.active:not(:disabled) { From 91eccb419a8830bfa062d4c358aa0fd8e2b5bf31 Mon Sep 17 00:00:00 2001 From: Daniel Schiavini Date: Mon, 3 Mar 2025 09:54:58 +0100 Subject: [PATCH 4/8] fix: revert changes prices-api --- packages/prices-api/src/crvusd/models.ts | 10 +++++++ packages/prices-api/src/llamalend/models.ts | 2 ++ packages/prices-api/src/proposal/index.ts | 1 + packages/prices-api/src/proposal/util.ts | 30 +++++++++++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 packages/prices-api/src/proposal/util.ts diff --git a/packages/prices-api/src/crvusd/models.ts b/packages/prices-api/src/crvusd/models.ts index a99409b1f..8fe89c439 100644 --- a/packages/prices-api/src/crvusd/models.ts +++ b/packages/prices-api/src/crvusd/models.ts @@ -43,6 +43,16 @@ export type Snapshot = { discountLoan: number } +export type PoolPrice = { + timestamp: number + [token: string]: number +} + +export type PriceHistogram = { + x: number[] + y: number[] +} + export type CrvUsdSupply = { timestamp: Date market: string diff --git a/packages/prices-api/src/llamalend/models.ts b/packages/prices-api/src/llamalend/models.ts index b40b848c8..9f06ad3de 100644 --- a/packages/prices-api/src/llamalend/models.ts +++ b/packages/prices-api/src/llamalend/models.ts @@ -46,6 +46,8 @@ export type Market = { leverage: number } +export type MarketPair = { long?: Market; short?: Market } + export type Snapshot = { rate: number borrowApy: number diff --git a/packages/prices-api/src/proposal/index.ts b/packages/prices-api/src/proposal/index.ts index a5927c33c..fed1247de 100644 --- a/packages/prices-api/src/proposal/index.ts +++ b/packages/prices-api/src/proposal/index.ts @@ -1,3 +1,4 @@ export * from './models' export * from './responses' +export * from './util' export * from './api' diff --git a/packages/prices-api/src/proposal/util.ts b/packages/prices-api/src/proposal/util.ts new file mode 100644 index 000000000..95f14a6bb --- /dev/null +++ b/packages/prices-api/src/proposal/util.ts @@ -0,0 +1,30 @@ +import type { Proposal, ProposalStatus } from './models' + +export function getStatus(proposal: Proposal): ProposalStatus { + if (proposal.executed) { + return 'executed' + } + + if (proposal.end > Date.now() / 1000) { + return 'active' + } + + if (hasWon(proposal) && hasReachedQuorum(proposal) && hasReachedSupport(proposal)) { + return 'passed' + } + + return 'denied' +} + +export function hasReachedSupport(proposal: Proposal): boolean { + return proposal.votesFor > proposal.support * proposal.quorum * proposal.totalSupply +} + +export function hasReachedQuorum(proposal: Proposal): boolean { + return proposal.votesFor > proposal.quorum * proposal.totalSupply +} + +export function hasWon(proposal: Proposal): boolean { + const totalVotes = proposal.votesFor + proposal.votesAgainst + return proposal.votesFor > totalVotes * 0.51 +} From 0838f44ece65453ece554f72c32bd525cfcce4df Mon Sep 17 00:00:00 2001 From: Daniel Schiavini Date: Mon, 3 Mar 2025 10:07:05 +0100 Subject: [PATCH 5/8] chore: get rid of global react imports --- .../components/SelectedLpTokenExpected.tsx | 1 - .../components/SelectedOneCoinExpected.tsx | 1 - .../src/widgets/Header/HeaderLogo.tsx | 1 - packages/ui/src/Accordion/Accordion.tsx | 16 +++++++------- packages/ui/src/AlertBox/AlertBox.tsx | 1 - packages/ui/src/Button/Button.tsx | 10 ++++----- packages/ui/src/Button/ConnectWallet.tsx | 1 - packages/ui/src/DetailInfo/DetailInfo.tsx | 1 - packages/ui/src/Dialog/ModalDialog.tsx | 1 - packages/ui/src/IconButton/IconButton.tsx | 1 - packages/ui/src/IconButton/types.ts | 1 - packages/ui/src/InputComp/Input.tsx | 1 - packages/ui/src/InputComp/InputField.tsx | 1 - packages/ui/src/InputComp/InputLabel.tsx | 11 ++++------ packages/ui/src/InputComp/types.ts | 1 - packages/ui/src/LinkButton/LinkButton.tsx | 1 - packages/ui/src/Loader/Loader.tsx | 1 - packages/ui/src/Popover/Popover.tsx | 15 +++++++------ packages/ui/src/Popover2/Popover2.tsx | 9 ++++---- packages/ui/src/Popover2/Popover2Button.tsx | 1 - packages/ui/src/Popover2/Popover2Dialog.tsx | 10 ++++----- packages/ui/src/Popover2/Popover2Trigger.tsx | 1 - packages/ui/src/Radio/Radio.tsx | 21 +++++++------------ packages/ui/src/Radio/RadioGroup.tsx | 1 - packages/ui/src/SearchInput/SearchInput.tsx | 1 - packages/ui/src/Select/Select.tsx | 8 +++---- packages/ui/src/Select/SelectBtn.tsx | 1 - .../ui/src/Select/SelectIconBtnDelete.tsx | 1 - packages/ui/src/Select/SelectModal.tsx | 12 +++++------ packages/ui/src/Select/SelectModalFull.tsx | 1 - packages/ui/src/Select/SelectModalListBox.tsx | 8 +++---- .../ui/src/Select/SelectModalListBoxItem.tsx | 5 ++--- .../ui/src/SelectNetwork/SelectNetwork.tsx | 1 - .../src/SelectNetwork/SelectNetworkItem.tsx | 7 +++---- .../src/SliderMultiThumb/SliderMultiThumb.tsx | 12 +++++------ .../SliderSingleThumb/SliderSingleThumb.tsx | 8 +++---- packages/ui/src/Spinner/Spinner.tsx | 1 - packages/ui/src/Stats/Stats.tsx | 1 - packages/ui/src/Stepper/StepAction.tsx | 1 - packages/ui/src/Stepper/StepModal.tsx | 12 +++++------ packages/ui/src/Stepper/Stepper.tsx | 1 - packages/ui/src/Stepper/types.ts | 1 - packages/ui/src/TabSlide/SlideTabs.tsx | 6 ++---- packages/ui/src/TabSlide/SlideTabsWrapper.tsx | 1 - packages/ui/src/Table/TheadSortButton.tsx | 1 - packages/ui/src/Tooltip/TooltipAlert.tsx | 1 - packages/ui/src/TxInfoBar/TxInfoBar.tsx | 1 - packages/ui/src/Typography/Chip.tsx | 7 +++---- .../ui/src/hooks/useHeightResizeObserver.ts | 8 +++---- .../ui/src/hooks/usePageVisibleInterval.ts | 12 +++++------ 50 files changed, 87 insertions(+), 141 deletions(-) diff --git a/apps/main/src/dex/components/PagePool/components/SelectedLpTokenExpected.tsx b/apps/main/src/dex/components/PagePool/components/SelectedLpTokenExpected.tsx index 7d7400e32..2b7d73cf1 100644 --- a/apps/main/src/dex/components/PagePool/components/SelectedLpTokenExpected.tsx +++ b/apps/main/src/dex/components/PagePool/components/SelectedLpTokenExpected.tsx @@ -1,6 +1,5 @@ import type { Amount } from '@/dex/components/PagePool/utils' -import * as React from 'react' import styled from 'styled-components' import { shortenTokenAddress } from '@/dex/utils' diff --git a/apps/main/src/dex/components/PagePool/components/SelectedOneCoinExpected.tsx b/apps/main/src/dex/components/PagePool/components/SelectedOneCoinExpected.tsx index bc974d115..327c6f448 100644 --- a/apps/main/src/dex/components/PagePool/components/SelectedOneCoinExpected.tsx +++ b/apps/main/src/dex/components/PagePool/components/SelectedOneCoinExpected.tsx @@ -1,6 +1,5 @@ import type { Amount } from '@/dex/components/PagePool/utils' -import * as React from 'react' import styled from 'styled-components' import { shortenTokenAddress } from '@/dex/utils' diff --git a/packages/curve-ui-kit/src/widgets/Header/HeaderLogo.tsx b/packages/curve-ui-kit/src/widgets/Header/HeaderLogo.tsx index 6dc7279a4..51555ad1d 100644 --- a/packages/curve-ui-kit/src/widgets/Header/HeaderLogo.tsx +++ b/packages/curve-ui-kit/src/widgets/Header/HeaderLogo.tsx @@ -1,4 +1,3 @@ -import * as React from 'react' import Box from '@mui/material/Box' import { LogoImg, RCLogoText } from '@ui/images' import { styled } from '@mui/material/styles' diff --git a/packages/ui/src/Accordion/Accordion.tsx b/packages/ui/src/Accordion/Accordion.tsx index 06f94ae53..773000605 100644 --- a/packages/ui/src/Accordion/Accordion.tsx +++ b/packages/ui/src/Accordion/Accordion.tsx @@ -1,8 +1,8 @@ import type { AriaButtonProps } from 'react-aria' -import * as React from 'react' import { useButton } from 'react-aria' import styled from 'styled-components' import Icon from 'ui/src/Icon/Icon' +import { ReactNode, useLayoutEffect, useRef, useState } from 'react' function Button( props: AriaButtonProps & { @@ -10,7 +10,7 @@ function Button( isHideTopBorder?: boolean }, ) { - let ref = React.useRef(null) + let ref = useRef(null) let { buttonProps } = useButton(props, ref) let { className = '', children, isHideTopBorder } = props @@ -28,17 +28,17 @@ const Accordion = ({ defaultOpen, isHideTopBorder, ...props -}: React.PropsWithChildren< +}: AriaButtonProps & { className?: string - btnLabel: string | React.ReactNode + btnLabel: ReactNode defaultOpen?: boolean isHideTopBorder?: boolean } ->) => { - const contentRef = React.useRef(null) +) => { + const contentRef = useRef(null) - const [show, setShow] = React.useState(defaultOpen ?? false) + const [show, setShow] = useState(defaultOpen ?? false) const { scrollHeight } = contentRef.current ?? {} @@ -51,7 +51,7 @@ const Accordion = ({ } } - React.useLayoutEffect(() => { + useLayoutEffect(() => { if (defaultOpen && contentRef.current) { contentRef.current.style.maxHeight = MAX_HEIGHT } diff --git a/packages/ui/src/AlertBox/AlertBox.tsx b/packages/ui/src/AlertBox/AlertBox.tsx index 9b00e31a7..48707c8a9 100644 --- a/packages/ui/src/AlertBox/AlertBox.tsx +++ b/packages/ui/src/AlertBox/AlertBox.tsx @@ -1,6 +1,5 @@ import type { AlertBoxProps } from 'ui/src/AlertBox/types' -import * as React from 'react' import { useState, useRef, useEffect, useMemo } from 'react' import styled from 'styled-components' diff --git a/packages/ui/src/Button/Button.tsx b/packages/ui/src/Button/Button.tsx index 62184d88d..b5e64c58d 100644 --- a/packages/ui/src/Button/Button.tsx +++ b/packages/ui/src/Button/Button.tsx @@ -1,22 +1,20 @@ import type { ButtonProps } from 'ui/src/Button/types' - -import * as React from 'react' +import { forwardRef, ButtonHTMLAttributes, useRef } from 'react' import styled from 'styled-components' import { useFocusRing } from '@react-aria/focus' - import { buttonBaseStyles } from './styles' import Box from 'ui/src/Box/Box' import Spinner from 'ui/src/Spinner/Spinner' -const Button = React.forwardRef< +const Button = forwardRef< HTMLButtonElement, ButtonProps & - React.ButtonHTMLAttributes & { + ButtonHTMLAttributes & { className?: string testId?: string } >(({ className, children, loading, testId, ...props }, ref) => { - const buttonRef = React.useRef(null) + const buttonRef = useRef(null) const { isFocusVisible, focusProps } = useFocusRing() return ( diff --git a/packages/ui/src/Button/ConnectWallet.tsx b/packages/ui/src/Button/ConnectWallet.tsx index c7d4bf194..3dad86219 100644 --- a/packages/ui/src/Button/ConnectWallet.tsx +++ b/packages/ui/src/Button/ConnectWallet.tsx @@ -2,7 +2,6 @@ import type { ButtonProps } from 'ui/src/Button/types' import type { ConnectState } from 'ui/src/utils' import styled from 'styled-components' -import * as React from 'react' import { isLoading, isSuccess, shortenAccount } from 'ui/src/utils' diff --git a/packages/ui/src/DetailInfo/DetailInfo.tsx b/packages/ui/src/DetailInfo/DetailInfo.tsx index d3781738f..488fdd3ad 100644 --- a/packages/ui/src/DetailInfo/DetailInfo.tsx +++ b/packages/ui/src/DetailInfo/DetailInfo.tsx @@ -1,4 +1,3 @@ -import * as React from 'react' import styled from 'styled-components' import Box from 'ui/src/Box/Box' diff --git a/packages/ui/src/Dialog/ModalDialog.tsx b/packages/ui/src/Dialog/ModalDialog.tsx index 524e496d0..d20548bc3 100644 --- a/packages/ui/src/Dialog/ModalDialog.tsx +++ b/packages/ui/src/Dialog/ModalDialog.tsx @@ -1,4 +1,3 @@ -import * as React from 'react' import type { AriaDialogProps } from '@react-types/dialog' import type { AriaOverlayProps } from 'react-aria' import type { OverlayTriggerState } from 'react-stately' diff --git a/packages/ui/src/IconButton/IconButton.tsx b/packages/ui/src/IconButton/IconButton.tsx index c0b9ad0a8..5c9cba3ce 100644 --- a/packages/ui/src/IconButton/IconButton.tsx +++ b/packages/ui/src/IconButton/IconButton.tsx @@ -1,6 +1,5 @@ import type { IconButtonProps } from './types' -import * as React from 'react' import { forwardRef, useRef } from 'react' import { useFocusRing } from '@react-aria/focus' diff --git a/packages/ui/src/IconButton/types.ts b/packages/ui/src/IconButton/types.ts index e7eb4ffb9..46fb100fe 100644 --- a/packages/ui/src/IconButton/types.ts +++ b/packages/ui/src/IconButton/types.ts @@ -1,4 +1,3 @@ -import * as React from 'react' export type Size = 'x-small' | 'small' | 'medium' | 'large' | 'x-large' diff --git a/packages/ui/src/InputComp/Input.tsx b/packages/ui/src/InputComp/Input.tsx index d0a2aca69..5146ca21d 100644 --- a/packages/ui/src/InputComp/Input.tsx +++ b/packages/ui/src/InputComp/Input.tsx @@ -1,6 +1,5 @@ import type { InputProps } from './types' -import * as React from 'react' import { forwardRef, useRef } from 'react' import { StyledInput } from './styles' diff --git a/packages/ui/src/InputComp/InputField.tsx b/packages/ui/src/InputComp/InputField.tsx index ae9041480..c0d882a0c 100644 --- a/packages/ui/src/InputComp/InputField.tsx +++ b/packages/ui/src/InputComp/InputField.tsx @@ -1,5 +1,4 @@ import type { InputLabelProps, InputProps } from 'ui/src/InputComp/types' -import * as React from 'react' import styled from 'styled-components' import Box from 'ui/src/Box/Box' import Input from 'ui/src/InputComp/Input' diff --git a/packages/ui/src/InputComp/InputLabel.tsx b/packages/ui/src/InputComp/InputLabel.tsx index ea6546a7a..b0dec03ac 100644 --- a/packages/ui/src/InputComp/InputLabel.tsx +++ b/packages/ui/src/InputComp/InputLabel.tsx @@ -1,11 +1,8 @@ import type { InputLabelProps } from './types' - -import * as React from 'react' import styled from 'styled-components' - import { useInputContext } from 'ui/src/InputComp/InputProvider' - import Loader from 'ui/src/Loader' +import { useEffect, useRef, useState } from 'react' const InputLabel = ({ className, @@ -15,13 +12,13 @@ const InputLabel = ({ testId, ...props }: InputLabelProps & { testId?: string }) => { - const descriptionRef = React.useRef(null) + const descriptionRef = useRef(null) const { id } = useInputContext() - const [skeleton, setSkeleton] = React.useState<[number, number] | null>(null) + const [skeleton, setSkeleton] = useState<[number, number] | null>(null) const descriptionEl = descriptionRef.current - React.useEffect(() => { + useEffect(() => { const { offsetWidth, offsetHeight } = descriptionEl ?? {} if (offsetWidth && offsetHeight && description !== '-') { setSkeleton([offsetWidth > 10 ? offsetWidth : 20, offsetHeight - 4] as [number, number]) diff --git a/packages/ui/src/InputComp/types.ts b/packages/ui/src/InputComp/types.ts index 1f7a0a77f..354f4debf 100644 --- a/packages/ui/src/InputComp/types.ts +++ b/packages/ui/src/InputComp/types.ts @@ -1,4 +1,3 @@ -import * as React from 'react' export type InputMinHeight = 'small' | 'medium' | 'large' | 'x-large' export type InputVariant = 'error' | 'warning' | 'small' diff --git a/packages/ui/src/LinkButton/LinkButton.tsx b/packages/ui/src/LinkButton/LinkButton.tsx index 239a8fc70..f6b60e10e 100644 --- a/packages/ui/src/LinkButton/LinkButton.tsx +++ b/packages/ui/src/LinkButton/LinkButton.tsx @@ -1,7 +1,6 @@ import type { ButtonProps } from 'ui/src/Button/types' import type { LinkProps } from 'react-router-dom' -import * as React from 'react' import { Link } from 'react-router-dom' import styled from 'styled-components' diff --git a/packages/ui/src/Loader/Loader.tsx b/packages/ui/src/Loader/Loader.tsx index 412535dac..c20bdd791 100644 --- a/packages/ui/src/Loader/Loader.tsx +++ b/packages/ui/src/Loader/Loader.tsx @@ -1,4 +1,3 @@ -import * as React from 'react' import styled, { keyframes } from 'styled-components' type Props = { diff --git a/packages/ui/src/Popover/Popover.tsx b/packages/ui/src/Popover/Popover.tsx index b49304342..249623c8a 100644 --- a/packages/ui/src/Popover/Popover.tsx +++ b/packages/ui/src/Popover/Popover.tsx @@ -1,22 +1,21 @@ import type { AriaOverlayProps } from 'react-aria' - -import * as React from 'react' import styled from 'styled-components' - import { useOverlay, DismissButton } from '@react-aria/overlays' import { FocusScope } from '@react-aria/focus' +import { ReactNode, RefObject, useRef } from 'react' interface Props extends AriaOverlayProps { - popoverRef: React.RefObject + popoverRef: RefObject + children: ReactNode } -const Popover = (props: React.PropsWithChildren) => { - let ref = React.useRef(null) - let { popoverRef = ref, isOpen, onClose, children } = props +const Popover = (props: Props) => { + const ref = useRef(null) + const { popoverRef = ref, isOpen, onClose, children } = props // Handle events that should cause the popup to close, // e.g. blur, clicking outside, or pressing the escape key. - let { overlayProps } = useOverlay( + const { overlayProps } = useOverlay( { isOpen, onClose, diff --git a/packages/ui/src/Popover2/Popover2.tsx b/packages/ui/src/Popover2/Popover2.tsx index e785b8b27..ddaa451cb 100644 --- a/packages/ui/src/Popover2/Popover2.tsx +++ b/packages/ui/src/Popover2/Popover2.tsx @@ -1,18 +1,17 @@ import { DismissButton, Overlay, usePopover } from 'react-aria' import type { AriaPopoverProps } from 'react-aria' import type { OverlayTriggerState } from 'react-stately' - -import * as React from 'react' import styled from 'styled-components' +import { ReactNode, useRef } from 'react' interface PopoverProps extends Omit { - children: React.ReactNode + children: ReactNode portalContainer: Element state: OverlayTriggerState } function Popover2({ children, state, offset = 8, portalContainer, ...props }: PopoverProps) { - let popoverRef = React.useRef(null) + let popoverRef = useRef(null) let { popoverProps, underlayProps } = usePopover( { ...props, @@ -37,7 +36,7 @@ function Popover2({ children, state, offset = 8, portalContainer, ...props }: Po > {/* @ts-ignore */} - {React.cloneElement(children, state)} + {cloneElement(children, state)} diff --git a/packages/ui/src/Popover2/Popover2Button.tsx b/packages/ui/src/Popover2/Popover2Button.tsx index a6940d8e3..86919daca 100644 --- a/packages/ui/src/Popover2/Popover2Button.tsx +++ b/packages/ui/src/Popover2/Popover2Button.tsx @@ -1,6 +1,5 @@ // @ts-nocheck import { useButton } from 'react-aria' -import * as React from 'react' import styled from 'styled-components' import { buttonOutlinedStyles } from 'ui/src/Button/styles' diff --git a/packages/ui/src/Popover2/Popover2Dialog.tsx b/packages/ui/src/Popover2/Popover2Dialog.tsx index 57df13823..1baefeb2e 100644 --- a/packages/ui/src/Popover2/Popover2Dialog.tsx +++ b/packages/ui/src/Popover2/Popover2Dialog.tsx @@ -1,17 +1,17 @@ import type { AriaDialogProps } from 'react-aria' import { useDialog } from 'react-aria' -import * as React from 'react' import { focusVisible } from 'ui/src/utils/sharedStyles' import styled from 'styled-components' +import { ReactNode, useRef } from 'react' interface DialogProps extends AriaDialogProps { className?: string - title?: React.ReactNode - children: React.ReactNode + title?: ReactNode + children: ReactNode } function Popover2Dialog({ title, children, ...props }: DialogProps) { - let ref = React.useRef(null) + let ref = useRef(null) let { dialogProps, titleProps } = useDialog(props, ref) return ( @@ -22,7 +22,7 @@ function Popover2Dialog({ title, children, ...props }: DialogProps) {
)} {/* @ts-ignore */} - {React.cloneElement(children, props)} + {cloneElement(children, props)} ) } diff --git a/packages/ui/src/Popover2/Popover2Trigger.tsx b/packages/ui/src/Popover2/Popover2Trigger.tsx index 617182507..6493d7ed1 100644 --- a/packages/ui/src/Popover2/Popover2Trigger.tsx +++ b/packages/ui/src/Popover2/Popover2Trigger.tsx @@ -1,7 +1,6 @@ // @ts-nocheck import { useOverlayTrigger } from 'react-aria' import { useOverlayTriggerState } from 'react-stately' -import * as React from 'react' import styled from 'styled-components' import Icon from 'ui/src/Icon/Icon' diff --git a/packages/ui/src/Radio/Radio.tsx b/packages/ui/src/Radio/Radio.tsx index be98e58fb..f3845e15e 100644 --- a/packages/ui/src/Radio/Radio.tsx +++ b/packages/ui/src/Radio/Radio.tsx @@ -1,13 +1,11 @@ import type { AriaRadioProps } from '@react-types/radio' - -import * as React from 'react' import styled from 'styled-components' import { useRadio } from '@react-aria/radio' import { VisuallyHidden } from '@react-aria/visually-hidden' import { useFocusRing } from '@react-aria/focus' - import { RadioContext } from 'ui/src/Radio' import Box from 'ui/src/Box' +import { useContext, useRef } from 'react' const Radio = ({ children, @@ -15,18 +13,15 @@ const Radio = ({ isCustom, testId, ...props -}: React.PropsWithChildren< - AriaRadioProps & { - className?: string - isCustom?: boolean // don't show radio icon if it is custom - testId?: string - } ->) => { - const inputRef = React.useRef(null) - const state = React.useContext(RadioContext) +}: AriaRadioProps & { + className?: string + isCustom?: boolean // don't show radio icon if it is custom + testId?: string +}) => { + const inputRef = useRef(null) + const state = useContext(RadioContext) const { inputProps = {}, isSelected } = useRadio(props, state, inputRef) const { isFocusVisible, focusProps } = useFocusRing() - const labelClassName = `${className} ${state.isDisabled ? 'disabled' : ''}` return ( diff --git a/packages/ui/src/Radio/RadioGroup.tsx b/packages/ui/src/Radio/RadioGroup.tsx index 9fb35848a..03ed83fcd 100644 --- a/packages/ui/src/Radio/RadioGroup.tsx +++ b/packages/ui/src/Radio/RadioGroup.tsx @@ -1,6 +1,5 @@ import type { AriaRadioGroupProps, RadioGroupProps } from '@react-types/radio' -import * as React from 'react' import styled, { css } from 'styled-components' import { useRadioGroup } from '@react-aria/radio' import { useRadioGroupState } from '@react-stately/radio' diff --git a/packages/ui/src/SearchInput/SearchInput.tsx b/packages/ui/src/SearchInput/SearchInput.tsx index d47e0f0c4..dbae24c95 100644 --- a/packages/ui/src/SearchInput/SearchInput.tsx +++ b/packages/ui/src/SearchInput/SearchInput.tsx @@ -1,4 +1,3 @@ -import * as React from 'react' import styled from 'styled-components' import { RCEditClear } from 'ui/src/images' diff --git a/packages/ui/src/Select/Select.tsx b/packages/ui/src/Select/Select.tsx index 550cf0b94..df5759057 100644 --- a/packages/ui/src/Select/Select.tsx +++ b/packages/ui/src/Select/Select.tsx @@ -1,24 +1,24 @@ import { AriaSelectOptions, HiddenSelect, useSelect } from 'react-aria' import type { SelectProps as ReactStatelySelectProps } from 'react-stately' import { useSelectState } from 'react-stately' -import * as React from 'react' import styled from 'styled-components' import { getIsFullScreen } from 'ui/src/utils' import Icon from 'ui/src/Icon/Icon' import SelectBtn from 'ui/src/Select/SelectBtn' import SelectModal from 'ui/src/Select/SelectModal' import SelectModalFull from 'ui/src/Select/SelectModalFull' +import { CSSProperties, ReactNode, useRef } from 'react' export interface SelectProps extends Omit, 'children'>, AriaSelectOptions { - buttonStyles?: React.CSSProperties + buttonStyles?: CSSProperties className?: string loading?: boolean minWidth?: string noLabelChange?: boolean // do not update label to select key mobileRightAlign?: boolean // right align dropdown list on small width - selectedItemLabel?: string | React.ReactNode // selected button label that is different from list + selectedItemLabel?: ReactNode // selected button label that is different from list onSelectionDelete?: () => void selectSearchOptions?: { searchFilterKeys: string[] @@ -33,7 +33,7 @@ function Select({ ...props }: SelectProps) { const state = useSelectState(props) - const buttonRef = React.useRef(null) + const buttonRef = useRef(null) const { labelProps, triggerProps, menuProps } = useSelect(props, state, buttonRef) const title = props['aria-label'] || 'Select' diff --git a/packages/ui/src/Select/SelectBtn.tsx b/packages/ui/src/Select/SelectBtn.tsx index 7dca0daa3..fa00cfa27 100644 --- a/packages/ui/src/Select/SelectBtn.tsx +++ b/packages/ui/src/Select/SelectBtn.tsx @@ -2,7 +2,6 @@ import type { ButtonProps } from 'ui/src/Button/types' import type { AriaButtonProps } from 'react-aria' import { useButton } from 'react-aria' -import * as React from 'react' import styled from 'styled-components' import { StyledBtn } from 'ui/src/Select/styles' diff --git a/packages/ui/src/Select/SelectIconBtnDelete.tsx b/packages/ui/src/Select/SelectIconBtnDelete.tsx index fd29b8352..390106283 100644 --- a/packages/ui/src/Select/SelectIconBtnDelete.tsx +++ b/packages/ui/src/Select/SelectIconBtnDelete.tsx @@ -1,4 +1,3 @@ -import * as React from 'react' import { StyledBtn } from 'ui/src/Select/styles' import Icon from 'ui/src/Icon' diff --git a/packages/ui/src/Select/SelectModal.tsx b/packages/ui/src/Select/SelectModal.tsx index 4ca3ae8fc..d1f6963bd 100644 --- a/packages/ui/src/Select/SelectModal.tsx +++ b/packages/ui/src/Select/SelectModal.tsx @@ -1,33 +1,33 @@ import type { AriaListBoxOptions, AriaOverlayProps } from 'react-aria' import type { SelectState } from 'react-stately' -import * as React from 'react' import { useOverlay, DismissButton, FocusScope, usePreventScroll } from 'react-aria' import styled from 'styled-components' import { breakpoints } from 'ui/src/utils' import SelectModalListBox from 'ui/src/Select/SelectModalListBox' +import { Key, RefObject, useRef } from 'react' function SelectModal({ menuProps, state, selectSearchOptions, ...props -}: React.PropsWithChildren< +}: AriaOverlayProps & { menuProps: AriaListBoxOptions minWidth?: string mobileRightAlign?: boolean - popoverRef?: React.RefObject + popoverRef?: RefObject selectSearchOptions?: { - onSelectionChange: (key: React.Key) => void + onSelectionChange: (key: Key) => void searchFilterKeys: string[] } state: SelectState } ->) { - const ref = React.useRef(null) +) { + const ref = useRef(null) const { mobileRightAlign, popoverRef = ref, minWidth } = props usePreventScroll() diff --git a/packages/ui/src/Select/SelectModalFull.tsx b/packages/ui/src/Select/SelectModalFull.tsx index ea429a259..8c4d364a3 100644 --- a/packages/ui/src/Select/SelectModalFull.tsx +++ b/packages/ui/src/Select/SelectModalFull.tsx @@ -1,6 +1,5 @@ import type { SelectProps as ReactStatelySelectProps, SelectState } from 'react-stately' -import * as React from 'react' import styled from 'styled-components' import { delayAction } from 'ui/src/utils' diff --git a/packages/ui/src/Select/SelectModalListBox.tsx b/packages/ui/src/Select/SelectModalListBox.tsx index 0f78a5172..7fe1454e1 100644 --- a/packages/ui/src/Select/SelectModalListBox.tsx +++ b/packages/ui/src/Select/SelectModalListBox.tsx @@ -1,19 +1,17 @@ import type { AriaListBoxOptions } from 'react-aria' import type { SelectState } from 'react-stately' - -import * as React from 'react' import { useListBox } from 'react-aria' import styled from 'styled-components' - import SelectModalListBoxItem from 'ui/src/Select/SelectModalListBoxItem' +import { RefObject, useRef } from 'react' function SelectModalListBox( props: AriaListBoxOptions & { state: SelectState - listBoxRef?: React.RefObject + listBoxRef?: RefObject }, ) { - const ref = React.useRef(null) + const ref = useRef(null) const { listBoxRef = ref, state } = props const { listBoxProps } = useListBox(props, state, listBoxRef) diff --git a/packages/ui/src/Select/SelectModalListBoxItem.tsx b/packages/ui/src/Select/SelectModalListBoxItem.tsx index cec7697ee..2bc7207e0 100644 --- a/packages/ui/src/Select/SelectModalListBoxItem.tsx +++ b/packages/ui/src/Select/SelectModalListBoxItem.tsx @@ -1,14 +1,13 @@ import type { Node } from '@react-types/shared' import type { ListState } from 'react-stately' -import * as React from 'react' import { useOption } from 'react-aria' import styled from 'styled-components' +import { useRef } from 'react' function SelectModalListBoxItem({ item, state }: { item: Node; state: ListState }) { - const ref = React.useRef(null) + const ref = useRef(null) const { optionProps } = useOption(item, state, ref) - return ( {item.rendered} diff --git a/packages/ui/src/SelectNetwork/SelectNetwork.tsx b/packages/ui/src/SelectNetwork/SelectNetwork.tsx index 501beeed0..cf588c771 100644 --- a/packages/ui/src/SelectNetwork/SelectNetwork.tsx +++ b/packages/ui/src/SelectNetwork/SelectNetwork.tsx @@ -1,7 +1,6 @@ import type { ConnectState } from 'ui/src/utils' import type { SelectProps } from 'ui/src/Select/Select' -import * as React from 'react' import { Item } from 'react-stately' import Select from 'ui/src/Select' diff --git a/packages/ui/src/SelectNetwork/SelectNetworkItem.tsx b/packages/ui/src/SelectNetwork/SelectNetworkItem.tsx index a67b06fab..2d26b9935 100644 --- a/packages/ui/src/SelectNetwork/SelectNetworkItem.tsx +++ b/packages/ui/src/SelectNetwork/SelectNetworkItem.tsx @@ -1,7 +1,6 @@ -import * as React from 'react' - import Image from 'next/image' import styled from 'styled-components' +import { SyntheticEvent, useState } from 'react' export type Props = { label: string @@ -10,9 +9,9 @@ export type Props = { } const SelectNetworkItem = ({ label, src, fallbackSrc }: Props) => { - const [errorOccurred, setErrorOccurred] = React.useState(false) + const [errorOccurred, setErrorOccurred] = useState(false) - const handleOnError = (evt: React.SyntheticEvent, fallbackSrc: string) => { + const handleOnError = (evt: SyntheticEvent, fallbackSrc: string) => { if (errorOccurred) return setErrorOccurred(true) diff --git a/packages/ui/src/SliderMultiThumb/SliderMultiThumb.tsx b/packages/ui/src/SliderMultiThumb/SliderMultiThumb.tsx index 8bd75ceab..ed4e3e961 100644 --- a/packages/ui/src/SliderMultiThumb/SliderMultiThumb.tsx +++ b/packages/ui/src/SliderMultiThumb/SliderMultiThumb.tsx @@ -1,7 +1,6 @@ import type { NumberFormatOptions } from '@internationalized/number' import type { SliderState } from 'react-stately' - -import * as React from 'react' +import { useSliderState } from 'react-stately' import { AriaSliderProps, mergeProps, @@ -11,12 +10,11 @@ import { useSliderThumb, VisuallyHidden, } from 'react-aria' -import { useSliderState } from 'react-stately' import styled, { css } from 'styled-components' - import Chip from 'ui/src/Typography/Chip' import Spinner from 'ui/src/Spinner/Spinner' import SpinnerWrapper from 'ui/src/Spinner/SpinnerWrapper' +import { RefObject, useRef } from 'react' interface Props extends AriaSliderProps { formatOptions: NumberFormatOptions @@ -26,7 +24,7 @@ interface Props extends AriaSliderProps { } const SliderMultiThumb = ({ loading, hideValue, hideLabel, ...props }: Props) => { - const trackRef = React.useRef(null) + const trackRef = useRef(null) const numberFormatter = useNumberFormatter(props.formatOptions) const state = useSliderState({ ...props, numberFormatter }) const { groupProps, trackProps, labelProps, outputProps } = useSlider(props, state, trackRef) @@ -74,10 +72,10 @@ function Thumb(props: { index: number isDisplayOnly: boolean state: SliderState - trackRef: React.RefObject + trackRef: RefObject }) { const { state, trackRef, index, isDisplayOnly } = props - const inputRef = React.useRef(null) + const inputRef = useRef(null) const { thumbProps, inputProps, isDragging } = useSliderThumb( { index, diff --git a/packages/ui/src/SliderSingleThumb/SliderSingleThumb.tsx b/packages/ui/src/SliderSingleThumb/SliderSingleThumb.tsx index 42fcde325..f559ca166 100644 --- a/packages/ui/src/SliderSingleThumb/SliderSingleThumb.tsx +++ b/packages/ui/src/SliderSingleThumb/SliderSingleThumb.tsx @@ -2,13 +2,13 @@ import type { NumberFormatOptions } from '@internationalized/number' import type { AriaSliderProps } from 'react-aria' import type { SliderState } from 'react-stately' -import * as React from 'react' import { mergeProps, useFocusRing, useNumberFormatter, useSlider, useSliderThumb, VisuallyHidden } from 'react-aria' import { useSliderState } from 'react-stately' import styled from 'styled-components' import Spinner from 'ui/src/Spinner/Spinner' import SpinnerWrapper from 'ui/src/Spinner/SpinnerWrapper' +import { RefObject, useRef } from 'react' interface Props extends AriaSliderProps { formatOptions: NumberFormatOptions @@ -18,7 +18,7 @@ interface Props extends AriaSliderProps { } function SliderSingleThumb({ loading, hideValue, hideLabel, ...props }: Props) { - const trackRef = React.useRef(null) + const trackRef = useRef(null) const numberFormatter = useNumberFormatter(props.formatOptions) const state = useSliderState({ ...props, numberFormatter }) const { groupProps, trackProps, labelProps, outputProps } = useSlider(props, state, trackRef) @@ -60,9 +60,9 @@ function SliderSingleThumb({ loading, hideValue, hideLabel, ...props }: Props) { ) } -function Thumb(props: { index: number; state: SliderState; trackRef: React.RefObject }) { +function Thumb(props: { index: number; state: SliderState; trackRef: RefObject }) { const { state, trackRef, index } = props - const inputRef = React.useRef(null) + const inputRef = useRef(null) const { thumbProps, inputProps, isDragging } = useSliderThumb( { index, diff --git a/packages/ui/src/Spinner/Spinner.tsx b/packages/ui/src/Spinner/Spinner.tsx index 013bac820..dd9e2b2bc 100644 --- a/packages/ui/src/Spinner/Spinner.tsx +++ b/packages/ui/src/Spinner/Spinner.tsx @@ -1,4 +1,3 @@ -import * as React from 'react' import styled, { keyframes } from 'styled-components' type SpinnerProps = { diff --git a/packages/ui/src/Stats/Stats.tsx b/packages/ui/src/Stats/Stats.tsx index 57c18a77e..06ed30d33 100644 --- a/packages/ui/src/Stats/Stats.tsx +++ b/packages/ui/src/Stats/Stats.tsx @@ -1,4 +1,3 @@ -import * as React from 'react' import styled from 'styled-components' type Props = { diff --git a/packages/ui/src/Stepper/StepAction.tsx b/packages/ui/src/Stepper/StepAction.tsx index 992405926..e1e9947fb 100644 --- a/packages/ui/src/Stepper/StepAction.tsx +++ b/packages/ui/src/Stepper/StepAction.tsx @@ -1,7 +1,6 @@ import type { ButtonProps } from 'ui/src/Button/types' import type { Step, StepStatus } from 'ui/src/Stepper/types' -import * as React from 'react' import { useOverlayTriggerState } from 'react-stately' import { useRef } from 'react' import { useButton } from 'react-aria' diff --git a/packages/ui/src/Stepper/StepModal.tsx b/packages/ui/src/Stepper/StepModal.tsx index ddb8242f9..17c56809d 100644 --- a/packages/ui/src/Stepper/StepModal.tsx +++ b/packages/ui/src/Stepper/StepModal.tsx @@ -1,19 +1,17 @@ import type { StepActionModal } from 'ui/src/Stepper/types' import type { OverlayTriggerState } from '@react-stately/overlays' - -import * as React from 'react' import { useButton } from 'react-aria' - import Box from 'ui/src/Box' import Button from 'ui/src/Button' import ModalDialog from 'ui/src/Dialog/ModalDialog' +import { type MouseEvent, useEffect, useRef } from 'react' interface StepModalProps extends Pick { overlayTriggerState: OverlayTriggerState } -const StepModal = ({ modal, overlayTriggerState }: React.PropsWithChildren) => { - const closeButtonRef = React.useRef(null) +const StepModal = ({ modal, overlayTriggerState }: StepModalProps) => { + const closeButtonRef = useRef(null) const { buttonProps: closeButtonProps } = useButton({}, closeButtonRef) const { title, testId, content, cancelBtnProps, primaryBtnProps, primaryBtnLabel } = modal @@ -25,12 +23,12 @@ const StepModal = ({ modal, overlayTriggerState }: React.PropsWithChildren) => { + const handlePrimaryBtnClick = (evt: MouseEvent) => { if (typeof onClick === 'function') onClick(evt) overlayTriggerState.close() } - React.useEffect(() => { + useEffect(() => { if (typeof modal.initFn === 'function') modal.initFn() // eslint-disable-next-line react-hooks/exhaustive-deps }, []) diff --git a/packages/ui/src/Stepper/Stepper.tsx b/packages/ui/src/Stepper/Stepper.tsx index b74ca0b69..8641ce9a4 100644 --- a/packages/ui/src/Stepper/Stepper.tsx +++ b/packages/ui/src/Stepper/Stepper.tsx @@ -1,6 +1,5 @@ import type { Step, StepStatus } from 'ui/src/Stepper/types' -import * as React from 'react' import styled from 'styled-components' import { statusColorMap } from 'ui/src/Stepper/helpers' diff --git a/packages/ui/src/Stepper/types.ts b/packages/ui/src/Stepper/types.ts index b4964b222..b5d2f28dc 100644 --- a/packages/ui/src/Stepper/types.ts +++ b/packages/ui/src/Stepper/types.ts @@ -1,4 +1,3 @@ -import * as React from 'react' export type StepStatus = 'current' | 'pending' | 'in-progress' | 'succeeded' | 'failed' diff --git a/packages/ui/src/TabSlide/SlideTabs.tsx b/packages/ui/src/TabSlide/SlideTabs.tsx index a49f42bbb..153cf4fea 100644 --- a/packages/ui/src/TabSlide/SlideTabs.tsx +++ b/packages/ui/src/TabSlide/SlideTabs.tsx @@ -1,10 +1,8 @@ -import * as React from 'react' -import { useContext } from 'react' +import { forwardRef, ReactNode, useContext } from 'react' import styled from 'styled-components' - import { Context, Slider } from './SlideTabsWrapper' -const SlideTabs = React.forwardRef>(({ children }, ref) => { +const SlideTabs = forwardRef(({ children }, ref) => { const { className = '', sliderPosition } = useContext(Context) return ( diff --git a/packages/ui/src/TabSlide/SlideTabsWrapper.tsx b/packages/ui/src/TabSlide/SlideTabsWrapper.tsx index 25c4c4b1a..c473aa324 100644 --- a/packages/ui/src/TabSlide/SlideTabsWrapper.tsx +++ b/packages/ui/src/TabSlide/SlideTabsWrapper.tsx @@ -1,4 +1,3 @@ -import * as React from 'react' import { createContext, useState } from 'react' import styled from 'styled-components' diff --git a/packages/ui/src/Table/TheadSortButton.tsx b/packages/ui/src/Table/TheadSortButton.tsx index 52006264d..0319185bf 100644 --- a/packages/ui/src/Table/TheadSortButton.tsx +++ b/packages/ui/src/Table/TheadSortButton.tsx @@ -1,7 +1,6 @@ import type { IndicatorPlacement } from './types' import type { ButtonProps } from 'ui/src/Button/types' -import * as React from 'react' import styled from 'styled-components' import Spinner from 'ui/src/Spinner/Spinner' diff --git a/packages/ui/src/Tooltip/TooltipAlert.tsx b/packages/ui/src/Tooltip/TooltipAlert.tsx index b0b4ceb77..860fbb89e 100644 --- a/packages/ui/src/Tooltip/TooltipAlert.tsx +++ b/packages/ui/src/Tooltip/TooltipAlert.tsx @@ -3,7 +3,6 @@ import WarningOutlinedIcon from '@mui/icons-material/WarningOutlined' import type { AlertType } from 'ui/src/AlertBox/types' import type { TooltipProps } from 'ui/src/Tooltip/types' -import * as React from 'react' import IconTooltip from 'ui/src/Tooltip/TooltipIcon' const TooltipAlert = ({ diff --git a/packages/ui/src/TxInfoBar/TxInfoBar.tsx b/packages/ui/src/TxInfoBar/TxInfoBar.tsx index 007f95bd2..c38f7fd30 100644 --- a/packages/ui/src/TxInfoBar/TxInfoBar.tsx +++ b/packages/ui/src/TxInfoBar/TxInfoBar.tsx @@ -1,4 +1,3 @@ -import * as React from 'react' import styled from 'styled-components' import { RCExternal } from 'ui/src/images' diff --git a/packages/ui/src/Typography/Chip.tsx b/packages/ui/src/Typography/Chip.tsx index f6e06737f..7fe2780df 100644 --- a/packages/ui/src/Typography/Chip.tsx +++ b/packages/ui/src/Typography/Chip.tsx @@ -1,12 +1,11 @@ import type { ChipProps } from 'ui/src/Typography/types' - -import * as React from 'react' import styled from 'styled-components' import Tooltip from 'ui/src/Tooltip/TooltipButton' +import { PropsWithChildren, useRef } from 'react' -const Chip = ({ as, ...props }: React.PropsWithChildren) => { +const Chip = ({ as, ...props }: PropsWithChildren) => { const { children, className, tooltip, tooltipProps, ...rest } = props - const ref = React.useRef(null) + const ref = useRef(null) const LabelComp = () => (