diff --git a/apps/frontend/src/app/2_molecules/CollateralRatio/CollateralRatio.tsx b/apps/frontend/src/app/2_molecules/CollateralRatio/CollateralRatio.tsx deleted file mode 100644 index c083beaca..000000000 --- a/apps/frontend/src/app/2_molecules/CollateralRatio/CollateralRatio.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import React, { FC } from 'react'; - -import { t } from 'i18next'; - -import { Heading, HealthBar, HeadingType } from '@sovryn/ui'; -import { Decimal } from '@sovryn/utils'; - -import { translations } from '../../../locales/i18n'; - -export type CollateralRatioProps = { - value?: Decimal; -}; - -export const CollateralRatio: FC = ({ value }) => { - return ( -
-
- - {t(translations.collateralRatio.title)} - - - {value !== undefined ? `${value}%` : 'N/A'} - -
- -
- ); -}; diff --git a/apps/frontend/src/app/2_molecules/ConnectWalletButton/ConnectWalletButton.tsx b/apps/frontend/src/app/2_molecules/ConnectWalletButton/ConnectWalletButton.tsx index ab21a7670..ef2e75665 100644 --- a/apps/frontend/src/app/2_molecules/ConnectWalletButton/ConnectWalletButton.tsx +++ b/apps/frontend/src/app/2_molecules/ConnectWalletButton/ConnectWalletButton.tsx @@ -16,7 +16,7 @@ import { useNotificationContext } from '../../../contexts/NotificationContext'; import { translations } from '../../../locales/i18n'; import { sharedState } from '../../../store/rxjs/shared-state'; -export type ConnectWalletButtonProps = { +type ConnectWalletButtonProps = { onConnect: () => void; onDisconnect: () => void; address: string | undefined; diff --git a/apps/frontend/src/app/2_molecules/LanguageSelector/LanguageSelector.module.css b/apps/frontend/src/app/2_molecules/LanguageSelector/LanguageSelector.module.css deleted file mode 100644 index 351a152a4..000000000 --- a/apps/frontend/src/app/2_molecules/LanguageSelector/LanguageSelector.module.css +++ /dev/null @@ -1,3 +0,0 @@ -.menu { - @apply font-medium; -} diff --git a/apps/frontend/src/app/2_molecules/LanguageSelector/LanguageSelector.tsx b/apps/frontend/src/app/2_molecules/LanguageSelector/LanguageSelector.tsx deleted file mode 100644 index 39c481eff..000000000 --- a/apps/frontend/src/app/2_molecules/LanguageSelector/LanguageSelector.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import React, { FC, useCallback, useState } from 'react'; - -import i18next from 'i18next'; -import { reactLocalStorage } from 'reactjs-localstorage'; - -import { Menu, MenuItem, Dropdown, DropdownSize } from '@sovryn/ui'; - -import { languages, languageLocalStorageKey } from '../../../locales/i18n'; -import styles from './LanguageSelector.module.css'; - -type LanguageSelectorProps = { - className?: string; - dataAttribute?: string; -}; - -export const LanguageSelector: FC = ({ - className, - dataAttribute, -}) => { - const [currentLang, setCurrentLang] = useState( - i18next.language || reactLocalStorage.get('i18nextLng'), - ); - - const changeLanguage = useCallback( - (language: string) => () => { - i18next.changeLanguage(language); - reactLocalStorage.set(languageLocalStorageKey, language); - setCurrentLang(language); - }, - [], - ); - - return ( - - - {languages.map(language => ( - - ))} - - - ); -}; diff --git a/apps/frontend/src/app/2_molecules/SocialLinks/SocialLinks.tsx b/apps/frontend/src/app/2_molecules/SocialLinks/SocialLinks.tsx index 2bf9c1c18..7d43d4d74 100644 --- a/apps/frontend/src/app/2_molecules/SocialLinks/SocialLinks.tsx +++ b/apps/frontend/src/app/2_molecules/SocialLinks/SocialLinks.tsx @@ -9,7 +9,7 @@ import { GITHUB_LINKS, SOCIAL_LINKS } from '../../../constants/links'; import { translations } from '../../../locales/i18n'; import styles from './SocialLinks.module.css'; -export type SocialLinksProps = { +type SocialLinksProps = { className?: string; innerClassName?: string; dataAttribute?: string; diff --git a/apps/frontend/src/app/2_molecules/WalletBalance/WalletBalance.module.css b/apps/frontend/src/app/2_molecules/WalletBalance/WalletBalance.module.css deleted file mode 100644 index 784fafbd1..000000000 --- a/apps/frontend/src/app/2_molecules/WalletBalance/WalletBalance.module.css +++ /dev/null @@ -1,11 +0,0 @@ -.walletBalance { - @apply mb-3; -} - -.row { - @apply uppercase; - - & > span { - @apply text-gray-10; - } -} diff --git a/apps/frontend/src/app/2_molecules/WalletBalance/WalletBalance.tsx b/apps/frontend/src/app/2_molecules/WalletBalance/WalletBalance.tsx deleted file mode 100644 index cd8e09080..000000000 --- a/apps/frontend/src/app/2_molecules/WalletBalance/WalletBalance.tsx +++ /dev/null @@ -1,103 +0,0 @@ -import React, { FC, useEffect, useMemo, useState } from 'react'; - -import { constants, Contract } from 'ethers'; -import { commify } from 'ethers/lib/utils'; - -import { getTokenDetails, SupportedTokens } from '@sovryn/contracts'; -import { ChainId, getProvider } from '@sovryn/ethers-provider'; -import { SimpleTable, SimpleTableRow } from '@sovryn/ui'; - -import { useWalletConnect } from '../../../hooks'; -import { useIsMounted } from '../../../hooks/useIsMounted'; -import { asyncCall, idHash } from '../../../store/rxjs/provider-cache'; -import { getRskChainId } from '../../../utils/chain'; -import { fromWeiFixed } from '../../../utils/math'; -import styles from './WalletBalance.module.css'; - -const tokensToDisplay = [ - SupportedTokens.rbtc, - SupportedTokens.zusd, - SupportedTokens.xusd, - SupportedTokens.dllr, -]; - -const getBalances = async (account: string, chainId: ChainId) => { - return await Promise.all( - tokensToDisplay.map(token => getBalance(account, token, chainId)), - ); -}; - -const getBalance = async ( - account: string, - asset: SupportedTokens, - chainId: ChainId, -) => { - try { - const tokenDetails = await getTokenDetails(asset, chainId); - const hashedArgs = idHash([ - tokenDetails.address, - tokenDetails.address === constants.AddressZero - ? 'nativeBalance' - : 'balanceOf', - account, - ]); - - const callback = - tokenDetails.address === constants.AddressZero - ? () => - getProvider(chainId) - .getBalance(account) - .then(result => result.toString()) - : () => - new Contract( - tokenDetails.address, - tokenDetails.abi, - getProvider(chainId), - ) - .balanceOf(account) - .then(result => result.toString()); - - return await asyncCall(hashedArgs, callback, { - ttl: 1000 * 30, - fallbackToPreviousResult: true, - }); - } catch (e) { - return '0'; - } -}; - -export const WalletBalance: FC = () => { - const isMounted = useIsMounted(); - const { account } = useWalletConnect(); - - const [balances, setBalances] = useState([]); - - useEffect(() => { - if (!isMounted() && account) { - return; - } - - getBalances(account, getRskChainId()) - .then(setBalances) - .catch(() => setBalances([])); - }, [account, isMounted]); - - const tokenOptions = useMemo( - () => - tokensToDisplay.map(token => ( - - )), - [balances], - ); - - return ( - - ); -}; diff --git a/apps/frontend/src/app/2_molecules/index.tsx b/apps/frontend/src/app/2_molecules/index.tsx index 5cb60a8a1..5437ee9ef 100644 --- a/apps/frontend/src/app/2_molecules/index.tsx +++ b/apps/frontend/src/app/2_molecules/index.tsx @@ -1,5 +1,3 @@ export * from './ConnectWalletButton/ConnectWalletButton'; -export * from './LanguageSelector/LanguageSelector'; export * from './SocialLinks/SocialLinks'; export * from './SovrynLogo/SovrynLogo'; -export * from './WalletBalance/WalletBalance'; diff --git a/apps/frontend/src/app/3_organisms/FundingHistoryFrame/index.ts b/apps/frontend/src/app/3_organisms/FundingHistoryFrame/index.ts deleted file mode 100644 index beae6b978..000000000 --- a/apps/frontend/src/app/3_organisms/FundingHistoryFrame/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './FundingHistoryFrame'; diff --git a/apps/frontend/src/app/3_organisms/LOCChart/hooks/useGetRBTCPrice.ts b/apps/frontend/src/app/3_organisms/LOCChart/hooks/useGetRBTCPrice.ts deleted file mode 100644 index 19824ceb7..000000000 --- a/apps/frontend/src/app/3_organisms/LOCChart/hooks/useGetRBTCPrice.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { useEffect, useState } from 'react'; - -import { EthersLiquity, ReadableEthersLiquity } from '@sovryn-zero/lib-ethers'; -import { getProvider } from '@sovryn/ethers-provider'; - -import { getRskChainId } from '../../../../utils/chain'; - -export const useGetRBTCPrice = () => { - const [price, setPrice] = useState('0'); - - useEffect(() => { - const getPrice = async () => { - const provider = await ReadableEthersLiquity.connect( - getProvider(getRskChainId()), - { useStore: 'blockPolled' }, - ); - const liquity = new EthersLiquity(provider); - const price = await liquity.getPrice(); - return price.toString(); - }; - getPrice().then(setPrice); - }, [price]); - - return { price }; -}; diff --git a/apps/frontend/src/app/3_organisms/LOCChart/types.ts b/apps/frontend/src/app/3_organisms/LOCChart/types.ts index 235c05509..6cfd6394a 100644 --- a/apps/frontend/src/app/3_organisms/LOCChart/types.ts +++ b/apps/frontend/src/app/3_organisms/LOCChart/types.ts @@ -12,8 +12,3 @@ export enum ChartSortingType { id = 'id', collateralRatio = 'collateralRatio', } - -export enum TrovesFilterType { - above = 'above', - below = 'below', -} diff --git a/apps/frontend/src/app/3_organisms/LOCChart/utils.ts b/apps/frontend/src/app/3_organisms/LOCChart/utils.ts index cbaa4eb46..7a462bc6d 100644 --- a/apps/frontend/src/app/3_organisms/LOCChart/utils.ts +++ b/apps/frontend/src/app/3_organisms/LOCChart/utils.ts @@ -1,6 +1,3 @@ -import { decimalic } from '../../../utils/math'; -import { TroveData } from './types'; - export const chartConfig = { defaultFont: 'Roboto', fontColor: '#F5F5F5', @@ -23,11 +20,6 @@ export const chartConfig = { maxValue: 21, }; -export const sortData = (data: TroveData[]) => - data.sort((a, b) => - decimalic(a.collateralRatio).sub(b.collateralRatio).toNumber(), - ); - export const calculateRedemptionBuffer = ( debt: number, collateral: number, diff --git a/apps/frontend/src/app/3_organisms/RedemptionsHistoryFrame/RedemptionsHistoryFrame.tsx b/apps/frontend/src/app/3_organisms/RedemptionsHistoryFrame/RedemptionsHistoryFrame.tsx deleted file mode 100644 index 022f96398..000000000 --- a/apps/frontend/src/app/3_organisms/RedemptionsHistoryFrame/RedemptionsHistoryFrame.tsx +++ /dev/null @@ -1,273 +0,0 @@ -import React, { FC, useCallback, useEffect, useMemo, useState } from 'react'; - -import { t } from 'i18next'; -import { nanoid } from 'nanoid'; - -import { SupportedTokens } from '@sovryn/contracts'; -import { - ErrorBadge, - ErrorLevel, - NotificationType, - OrderDirection, - OrderOptions, - Pagination, - Paragraph, - ParagraphSize, - Table, -} from '@sovryn/ui'; - -import { chains, defaultChainId } from '../../../config/chains'; - -import { AmountRenderer } from '../../2_molecules/AmountRenderer/AmountRenderer'; -import { ExportCSV } from '../../2_molecules/ExportCSV/ExportCSV'; -import { TxIdWithNotification } from '../../2_molecules/TxIdWithNotification/TransactionIdWithNotification'; -import { - BITCOIN, - BTC_RENDER_PRECISION, - TOKEN_RENDER_PRECISION, -} from '../../../constants/currencies'; -import { - DEFAULT_HISTORY_FRAME_PAGE_SIZE, - EXPORT_RECORD_LIMIT, -} from '../../../constants/general'; -import { useNotificationContext } from '../../../contexts/NotificationContext'; -import { useAccount } from '../../../hooks/useAccount'; -import { useBlockNumber } from '../../../hooks/useBlockNumber'; -import { useMaintenance } from '../../../hooks/useMaintenance'; -import { translations } from '../../../locales/i18n'; -import { - Redemption, - Redemption_Filter, - useGetRedemptionsLazyQuery, -} from '../../../utils/graphql/zero/generated'; -import { dateFormat } from '../../../utils/helpers'; -import { useGetRedemptionsHistory } from './hooks/useGetRedemptionsHistory'; - -const pageSize = DEFAULT_HISTORY_FRAME_PAGE_SIZE; - -export const RedemptionsHistoryFrame: FC = () => { - const { account } = useAccount(); - const { addNotification } = useNotificationContext(); - const { value: block } = useBlockNumber(); - - const [page, setPage] = useState(0); - const chain = chains.find(chain => chain.id === defaultChainId); - - const [orderOptions, setOrderOptions] = useState({ - orderBy: 'sequenceNumber', - orderDirection: OrderDirection.Desc, - }); - - const { data, loading, refetch } = useGetRedemptionsHistory( - account, - pageSize, - page, - orderOptions, - ); - - useEffect(() => { - refetch(); - }, [refetch, block]); - - const [getRedemptions] = useGetRedemptionsLazyQuery(); - - const redemptions = useMemo(() => { - return (data?.redemptions as Redemption[]) || []; - }, [data]); - - const generateRowTitle = useCallback( - (redemption: Redemption) => ( - - {dateFormat(redemption.transaction.timestamp)} - - ), - [], - ); - - const renderZUSDRedeemed = useCallback( - (redemption: Redemption) => ( - <> - {redemption.tokensActuallyRedeemed.length ? ( - - ) : ( - '-' - )} - - ), - [], - ); - - const renderRBTCReceived = useCallback( - (redemption: Redemption) => ( - <> - {redemption.collateralRedeemed.length ? ( - - ) : ( - '-' - )} - - ), - [], - ); - - const renderRedemptionFee = useCallback( - (redemption: Redemption) => ( - <> - {redemption.fee.length ? ( - - ) : ( - '-' - )} - - ), - [], - ); - - const columns = useMemo( - () => [ - { - id: 'sequenceNumber', - title: t(translations.common.tables.columnTitles.timestamp), - cellRenderer: (item: Redemption) => - dateFormat(item.transaction.timestamp), - sortable: true, - }, - { - id: 'zusdRedeemed', - title: t(translations.redemptionsHistory.table.zusdRedeemed), - cellRenderer: renderZUSDRedeemed, - }, - { - id: 'rbtcReceived', - title: t(translations.redemptionsHistory.table.rbtcReceived), - cellRenderer: renderRBTCReceived, - }, - { - id: 'redemptionFee', - title: t(translations.redemptionsHistory.table.redemptionFee), - cellRenderer: renderRedemptionFee, - }, - { - id: 'transactionID', - title: t(translations.common.tables.columnTitles.transactionID), - cellRenderer: (item: Redemption) => ( - - ), - }, - ], - [chain, renderZUSDRedeemed, renderRBTCReceived, renderRedemptionFee], - ); - - const onPageChange = useCallback( - (value: number) => { - if (redemptions.length < pageSize && value > page) { - return; - } - setPage(value); - }, - [page, redemptions.length], - ); - - const isNextButtonDisabled = useMemo( - () => !loading && redemptions?.length < pageSize, - [loading, redemptions], - ); - - const exportData = useCallback(async () => { - const { data } = await getRedemptions({ - variables: { - skip: 0, - filters: { - redeemer: account || '', - } as Redemption_Filter, - pageSize: EXPORT_RECORD_LIMIT, - }, - }); - - let redemptions = data?.redemptions || []; - - if (!redemptions || !redemptions.length) { - addNotification({ - type: NotificationType.warning, - title: t(translations.common.tables.actions.noDataToExport), - content: '', - dismissible: true, - id: nanoid(), - }); - } - - return redemptions.map(tx => ({ - timestamp: dateFormat(tx.transaction.timestamp), - zusdRedeemed: tx.tokensActuallyRedeemed, - rbtcReceived: tx.collateralRedeemed, - redemptionFee: tx.fee, - transactionID: tx.transaction.id, - })); - }, [account, addNotification, getRedemptions]); - - useEffect(() => { - setPage(0); - }, [orderOptions]); - - const { checkMaintenance, States } = useMaintenance(); - const exportLocked = checkMaintenance(States.ZERO_EXPORT_CSV); - - return ( - <> -
- - {exportLocked && ( - - )} -
-
- - - - - ); -}; diff --git a/apps/frontend/src/app/3_organisms/RedemptionsHistoryFrame/hooks/useGetRedemptionsHistory.ts b/apps/frontend/src/app/3_organisms/RedemptionsHistoryFrame/hooks/useGetRedemptionsHistory.ts deleted file mode 100644 index f6ce3ed09..000000000 --- a/apps/frontend/src/app/3_organisms/RedemptionsHistoryFrame/hooks/useGetRedemptionsHistory.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { useMemo } from 'react'; - -import { OrderOptions } from '@sovryn/ui'; - -import { zeroClient } from '../../../../utils/clients'; -import { - Redemption_OrderBy, - useGetRedemptionsQuery, -} from '../../../../utils/graphql/zero/generated'; -import { Redemption_Filter } from './../../../../utils/graphql/zero/generated'; - -export const useGetRedemptionsHistory = ( - account: string, - pageSize: number, - page: number, - orderOptions: OrderOptions, -) => { - const redemptionConfig = useMemo( - () => ({ - skip: page * pageSize, - pageSize, - orderBy: (orderOptions.orderBy as Redemption_OrderBy) || undefined, - orderDirection: orderOptions.orderDirection || undefined, - filters: { - redeemer: account?.toLowerCase(), - } as Redemption_Filter, - }), - [page, orderOptions, pageSize, account], - ); - - return useGetRedemptionsQuery({ - variables: redemptionConfig, - client: zeroClient, - }); -}; diff --git a/apps/frontend/src/app/3_organisms/RedemptionsHistoryFrame/index.ts b/apps/frontend/src/app/3_organisms/RedemptionsHistoryFrame/index.ts deleted file mode 100644 index bd6334c52..000000000 --- a/apps/frontend/src/app/3_organisms/RedemptionsHistoryFrame/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './RedemptionsHistoryFrame'; diff --git a/apps/frontend/src/app/3_organisms/RewardHistory/components/StabilityPoolRewards/utils.ts b/apps/frontend/src/app/3_organisms/RewardHistory/components/StabilityPoolRewards/utils.ts index 4de22031c..d635ec290 100644 --- a/apps/frontend/src/app/3_organisms/RewardHistory/components/StabilityPoolRewards/utils.ts +++ b/apps/frontend/src/app/3_organisms/RewardHistory/components/StabilityPoolRewards/utils.ts @@ -1,12 +1,7 @@ import { t } from 'i18next'; -import { SupportedTokens } from '@sovryn/contracts'; - -import { BTC_RENDER_PRECISION } from '../../../../../constants/currencies'; -import { getTokenDisplayName } from '../../../../../constants/tokens'; import { translations } from '../../../../../locales/i18n'; import { StabilityDepositOperation } from '../../../../../utils/graphql/zero/generated'; -import { formatValue } from '../../../../../utils/math'; export const getTransactionType = (operation: StabilityDepositOperation) => { switch (operation) { @@ -23,11 +18,3 @@ export const getTransactionType = (operation: StabilityDepositOperation) => { return operation; } }; - -export const renderCollateralChange = ( - collateralGain: string, - isCsvExport?: boolean, -) => - `${formatValue(Math.abs(Number(collateralGain)), BTC_RENDER_PRECISION)} ${ - isCsvExport ? '' : getTokenDisplayName(SupportedTokens.rbtc) - }`; diff --git a/apps/frontend/src/app/3_organisms/ZeroLocForm/constants.ts b/apps/frontend/src/app/3_organisms/ZeroLocForm/constants.ts index 14a0b14d1..6ed9b476c 100644 --- a/apps/frontend/src/app/3_organisms/ZeroLocForm/constants.ts +++ b/apps/frontend/src/app/3_organisms/ZeroLocForm/constants.ts @@ -9,4 +9,3 @@ export const MIN_DEBT_SIZE = decimalic(200); // 200 ZUSD export const SMALL_AMOUNT = decimalic(0.001); export const DEBT_TOKEN = SupportedTokens.zusd; -export const COLLATERAL_TOKEN = SupportedTokens.rbtc; diff --git a/apps/frontend/src/app/3_organisms/ZeroLocForm/types.ts b/apps/frontend/src/app/3_organisms/ZeroLocForm/types.ts index a9d14352c..4d9414508 100644 --- a/apps/frontend/src/app/3_organisms/ZeroLocForm/types.ts +++ b/apps/frontend/src/app/3_organisms/ZeroLocForm/types.ts @@ -5,11 +5,6 @@ export enum AmountType { Remove = 'Remove', } -export enum CreditLineType { - Open, - Adjust, -} - export type CreditLineSubmitValue = { token: SupportedTokens; borrow: string; @@ -18,13 +13,3 @@ export type CreditLineSubmitValue = { withdrawCollateral: string; maxOriginationFeeRate: string; }; - -export enum TroveErrorLevel { - Warning = 'Warning', - Critical = 'Critical', -} - -export type TroveError = { - level: TroveErrorLevel; - message: string; -}; diff --git a/apps/frontend/src/app/3_organisms/index.tsx b/apps/frontend/src/app/3_organisms/index.tsx index d463657b8..f8b1386b0 100644 --- a/apps/frontend/src/app/3_organisms/index.tsx +++ b/apps/frontend/src/app/3_organisms/index.tsx @@ -1,5 +1,4 @@ export * from './Header/Header'; export * from './TransactionStepDialog'; export * from './BorrowHistory/BorrowHistory'; -export * from './RedemptionsHistoryFrame'; export * from './Footer/Footer'; diff --git a/apps/frontend/src/app/5_pages/BitocracyPage/BitocracyPage.utils.tsx b/apps/frontend/src/app/5_pages/BitocracyPage/BitocracyPage.utils.tsx index 283077c49..5f9bc5919 100644 --- a/apps/frontend/src/app/5_pages/BitocracyPage/BitocracyPage.utils.tsx +++ b/apps/frontend/src/app/5_pages/BitocracyPage/BitocracyPage.utils.tsx @@ -25,11 +25,6 @@ export const generateRowTitle = (item: Proposal) => ( ); -export const prettifyId = (item: string) => { - const id = item.split('-'); - return id[1]; -}; - export const shouldProposalBeDefeated = (proposal: Proposal) => { const totalVotes = Decimal.fromBigNumberString(proposal.votesFor).add( Decimal.fromBigNumberString(proposal.votesAgainst), diff --git a/apps/frontend/src/app/5_pages/BorrowPage/BorrowPage.utils.tsx b/apps/frontend/src/app/5_pages/BorrowPage/BorrowPage.utils.tsx index 47e9f5205..0d496d8dd 100644 --- a/apps/frontend/src/app/5_pages/BorrowPage/BorrowPage.utils.tsx +++ b/apps/frontend/src/app/5_pages/BorrowPage/BorrowPage.utils.tsx @@ -22,19 +22,6 @@ import { translations } from '../../../locales/i18n'; import { isBitpro, isBtcBasedAsset } from '../../../utils/helpers'; import { decimalic } from '../../../utils/math'; -export const getCollateralAssetPrice = ( - collateralToken: SupportedTokens, - debtToken: SupportedTokens, - rbtcPrice: string, - collateralPriceUsd: string, - borrowPriceUsd: string, -) => - decimalic( - collateralToken === SupportedTokens.rbtc ? rbtcPrice : collateralPriceUsd, - ) - .div(debtToken === SupportedTokens.rbtc ? rbtcPrice : borrowPriceUsd) - .toString(); - export const renderValue = ( value: string, token: SupportedTokens | string, diff --git a/apps/frontend/src/app/5_pages/BorrowPage/components/AdjustLoanForm/AdjustLoanForm.tsx b/apps/frontend/src/app/5_pages/BorrowPage/components/AdjustLoanForm/AdjustLoanForm.tsx index f0e72482e..6f6acce0a 100644 --- a/apps/frontend/src/app/5_pages/BorrowPage/components/AdjustLoanForm/AdjustLoanForm.tsx +++ b/apps/frontend/src/app/5_pages/BorrowPage/components/AdjustLoanForm/AdjustLoanForm.tsx @@ -674,18 +674,6 @@ export const AdjustLoanForm: FC = ({ loan }) => { [isValidDebtAmount], ); - // const maxDrawdown = calculateMaxDrawdown( - // decimalic(loan.collateral.toString()), - // decimalic(loan.debt.toString()).add(debtSize), - // loan.startMargin, - // decimalic(1).div(collateralToLoanRate), - // ); - - // const drawdownInLoan = maxDrawdown - // .mul(collateralToLoanRate) - // .mul(100) - // .div(loan.startMargin.add(100)); - return ( <> = ({ - asset, - pools, -}) => { - const rskExplorerUrl = getRskExplorerUrl(); - const [tooltipContent, setTooltipContent] = useState(null); - - useEffect(() => { - const fetchTokenDetails = async () => { - if (!asset && !pools) { - setTooltipContent(null); - return; - } - - const tokens: SupportedTokens[] = []; - if (asset) { - tokens.push(asset); - } - if (pools) { - tokens.push(...pools); - } - - try { - const links = await Promise.all( - tokens.map(async token => { - const { address } = await getTokenDetailsData( - token, - defaultChainId, - ); - return ( -
- -
- – {collateralRatio}%{' '} - {t(translations.fixedInterestPage.collateralRatio)} -
-
- ); - }), - ); - - setTooltipContent(links); - } catch (error) { - console.error('Error fetching token details:', error); - setTooltipContent(null); - } - }; - - fetchTokenDetails(); - }, [asset, pools, rskExplorerUrl]); - - return <>{tooltipContent}; -}; diff --git a/apps/frontend/src/app/5_pages/BorrowPage/components/NewLoanForm/NewLoanForm.utils.tsx b/apps/frontend/src/app/5_pages/BorrowPage/components/NewLoanForm/NewLoanForm.utils.tsx deleted file mode 100644 index d20c19977..000000000 --- a/apps/frontend/src/app/5_pages/BorrowPage/components/NewLoanForm/NewLoanForm.utils.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { Decimal } from '@sovryn/utils'; - -export const calculateMargin = ( - collateral: Decimal, - debt: Decimal, - collateralToLoanRate: Decimal, -) => { - if (debt.isZero()) { - return Decimal.ZERO; - } - - return collateral.mul(collateralToLoanRate).sub(debt).div(debt).mul(100); -}; - -export const calculateMaxDrawdown = ( - collateral: Decimal, - debt: Decimal, - margin: Decimal, - loanToCollateralRate: Decimal, - precision: Decimal = Decimal.from(1), -) => { - const loanToCollateralAmount = debt.mul(loanToCollateralRate).div(precision); - const combined = loanToCollateralAmount.add( - loanToCollateralAmount.mul(margin).div(100), - ); - - return collateral.gt(combined) ? collateral.sub(combined) : Decimal.ZERO; -}; diff --git a/apps/frontend/src/app/5_pages/BorrowPage/components/OpenLoansTable/OpenLoansTable.types.ts b/apps/frontend/src/app/5_pages/BorrowPage/components/OpenLoansTable/OpenLoansTable.types.ts index 83b352eb8..e1e0b76d6 100644 --- a/apps/frontend/src/app/5_pages/BorrowPage/components/OpenLoansTable/OpenLoansTable.types.ts +++ b/apps/frontend/src/app/5_pages/BorrowPage/components/OpenLoansTable/OpenLoansTable.types.ts @@ -14,11 +14,3 @@ export type LoanItem = { interestOwedPerDay: number; startMargin: Decimal; }; - -export type LoanItemSmartContract = { - id: string; - debt: Decimal; - collateral: Decimal; - interestOwedPerDay: Decimal; - endTimestamp: Decimal; -}; diff --git a/apps/frontend/src/app/5_pages/ConvertPage/hooks/useGetDefaultSourceToken.ts b/apps/frontend/src/app/5_pages/ConvertPage/hooks/useGetDefaultSourceToken.ts deleted file mode 100644 index 8388222d2..000000000 --- a/apps/frontend/src/app/5_pages/ConvertPage/hooks/useGetDefaultSourceToken.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { useMemo } from 'react'; - -import { SupportedTokens } from '@sovryn/contracts'; - -import { useAssetBalance } from '../../../../hooks/useAssetBalance'; - -export const useGetDefaultSourceToken = () => { - const dllrBalance = useAssetBalance(SupportedTokens.dllr).weiBalance; - const zusdBalance = useAssetBalance(SupportedTokens.zusd).weiBalance; - const docBalance = useAssetBalance(SupportedTokens.doc).weiBalance; - - const hasDllr = useMemo(() => dllrBalance !== '0', [dllrBalance]); - const hasZusd = useMemo(() => zusdBalance !== '0', [zusdBalance]); - const hasDoc = useMemo(() => docBalance !== '0', [docBalance]); - - if (hasDllr || (!hasDllr && !hasZusd && !hasDoc)) { - return SupportedTokens.dllr; - } - - if (!hasDllr && hasZusd) { - return SupportedTokens.zusd; - } - - return SupportedTokens.doc; -}; diff --git a/apps/frontend/src/app/5_pages/LendPage/components/LendFrame/components/LendFrameChart/LendFrameChart.types.ts b/apps/frontend/src/app/5_pages/LendPage/components/LendFrame/components/LendFrameChart/LendFrameChart.types.ts index 5e8173a44..a7fadaa62 100644 --- a/apps/frontend/src/app/5_pages/LendPage/components/LendFrame/components/LendFrameChart/LendFrameChart.types.ts +++ b/apps/frontend/src/app/5_pages/LendPage/components/LendFrame/components/LendFrameChart/LendFrameChart.types.ts @@ -1,14 +1,3 @@ -export type ChartData = { - date: Date; - lendApr: number; - availableLiquidity: number; - borrowedLiquidity: number; -}; - -export type ChartProps = { - data: ChartData[]; -}; - export type PoolHistoryData = { supply: string; supply_apr: string; diff --git a/apps/frontend/src/app/5_pages/LendPage/components/LendFrame/components/LendFrameChart/hooks/useGetLendFrameChartOptions.ts b/apps/frontend/src/app/5_pages/LendPage/components/LendFrame/components/LendFrameChart/hooks/useGetLendFrameChartOptions.ts deleted file mode 100644 index aeaaf94f7..000000000 --- a/apps/frontend/src/app/5_pages/LendPage/components/LendFrame/components/LendFrameChart/hooks/useGetLendFrameChartOptions.ts +++ /dev/null @@ -1,112 +0,0 @@ -import { t } from 'i18next'; - -import { translations } from '../../../../../../../../locales/i18n'; -import { LendingPool } from '../../../../../../../../utils/LendingPool'; -import { MockData } from '../LendFrameChart.types'; - -export const useGetLendFrameChartOptions = ( - lendAprTickStep: number, - mockData: MockData, - pool: LendingPool, -) => { - return { - responsive: true, - maintainAspectRatio: false, - pointStyle: false, - radius: 0, - plugins: { - customCanvasBackgroundColor: { - color: '#2C303B', - }, - legend: { - labels: { - color: '#f5f5f5', - boxWidth: 12, - boxHeight: 12, - padding: 20, - }, - }, - tooltip: { - enabled: false, - }, - }, - scales: { - y1: { - border: { - color: '#484D59', - }, - position: 'left' as const, - display: true, - title: { - display: true, - text: t(translations.lending.apr), - color: '#B6BAC2', - }, - ticks: { - callback: value => Number(value).toFixed(0) + '%', - stepSize: lendAprTickStep, - min: Math.min(...mockData.lendApr) - 3 * lendAprTickStep, - max: Math.max(...mockData.lendApr) + 3 * lendAprTickStep, - color: '#B6BAC2', - font: { - family: 'Roboto', - fontSize: 12, - fontWeight: 500, - }, - padding: 5, - }, - grid: { - drawOnChartArea: true, - drawTicks: true, - gridDashType: 'dash', - tickColor: '#484D59', - }, - }, - y: { - border: { - color: '#484D59', - }, - display: true, - position: 'right' as const, - title: { - display: true, - text: `Borrowed/Available ${pool.getAsset().toUpperCase()}`, - color: '#B6BAC2', - }, - grid: { - drawTicks: true, - tickColor: '#484D59', - }, - ticks: { - color: '#B6BAC2', - font: { - family: 'Roboto', - fontSize: 12, - fontWeight: 500, - }, - padding: 5, - }, - }, - x: { - border: { - color: '#484D59', - }, - grid: { - drawTicks: true, - tickColor: '#484D59', - }, - display: true, - ticks: { - color: '#B6BAC2', - font: { - family: 'Roboto', - fontSize: 12, - fontWeight: 500, - }, - padding: 15, - }, - }, - }, - stacked: false, - }; -}; diff --git a/apps/frontend/src/app/5_pages/LendPage/hooks/useHandleLending.ts b/apps/frontend/src/app/5_pages/LendPage/hooks/useHandleLending.ts index 2670f07fa..c0051e2cc 100644 --- a/apps/frontend/src/app/5_pages/LendPage/hooks/useHandleLending.ts +++ b/apps/frontend/src/app/5_pages/LendPage/hooks/useHandleLending.ts @@ -20,12 +20,6 @@ import { LendingPoolDictionary } from '../../../../utils/LendingPoolDictionary'; import { prepareApproveTransaction } from '../../../../utils/transactions'; import { lendingBalanceOf } from '../utils/contract-calls'; -export type Args = Partial<{ - tokenDetails: TokenDetailsData; - tokenContract: Contract; - poolTokenContract: Contract; -}>; - export const useHandleLending = ( onBegin: () => void, onComplete: () => void, diff --git a/apps/frontend/src/app/5_pages/ProposalPage/ProposalPage.utils.ts b/apps/frontend/src/app/5_pages/ProposalPage/ProposalPage.utils.ts index a0da9e182..3fe1c482e 100644 --- a/apps/frontend/src/app/5_pages/ProposalPage/ProposalPage.utils.ts +++ b/apps/frontend/src/app/5_pages/ProposalPage/ProposalPage.utils.ts @@ -1,14 +1,6 @@ import sanitizeHtml from 'sanitize-html'; import { Proposal } from '../../../utils/graphql/rsk/generated'; -import { BLOCK_TIME_IN_SECONDS } from '../BitocracyPage/BitocracyPage.constants'; - -export function getSecondsBetweenBlocks( - startBlock: number, - endBlock: number, -): number { - return (Number(endBlock) - Number(startBlock)) * BLOCK_TIME_IN_SECONDS; -} export function parseProposalInfo(proposal: Proposal | undefined) { if (proposal?.description.includes('\n---\n')) { diff --git a/apps/frontend/src/app/5_pages/RewardsPage/components/Staking/Staking.utils.ts b/apps/frontend/src/app/5_pages/RewardsPage/components/Staking/Staking.utils.ts deleted file mode 100644 index c3fa972d3..000000000 --- a/apps/frontend/src/app/5_pages/RewardsPage/components/Staking/Staking.utils.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { t } from 'i18next'; - -import { SupportedTokens } from '@sovryn/contracts'; - -import { translations } from '../../../../../locales/i18n'; - -export const getStakingRevenueType = (token: SupportedTokens) => - [SupportedTokens.mynt].includes(token) - ? t(translations.rewardPage.staking.stakingRevenueLegacy) - : t(translations.rewardPage.staking.stakingRevenue); diff --git a/apps/frontend/src/app/5_pages/RewardsPage/components/Staking/components/WithdrawFee/WithdrawFee.tsx b/apps/frontend/src/app/5_pages/RewardsPage/components/Staking/components/WithdrawFee/WithdrawFee.tsx deleted file mode 100644 index 1362c4475..000000000 --- a/apps/frontend/src/app/5_pages/RewardsPage/components/Staking/components/WithdrawFee/WithdrawFee.tsx +++ /dev/null @@ -1,167 +0,0 @@ -import React, { FC, useCallback, useMemo } from 'react'; - -import { t } from 'i18next'; - -import { SupportedTokens } from '@sovryn/contracts'; -import { Button, ButtonType, ButtonStyle } from '@sovryn/ui'; - -import { - Transaction, - TransactionType, -} from '../../../../../../3_organisms/TransactionStepDialog/TransactionStepDialog.types'; -import { useTransactionContext } from '../../../../../../../contexts/TransactionContext'; -import { useAccount } from '../../../../../../../hooks/useAccount'; -import { useGetProtocolContract } from '../../../../../../../hooks/useGetContract'; -import { useMaintenance } from '../../../../../../../hooks/useMaintenance'; -import { translations } from '../../../../../../../locales/i18n'; -import { getMaxProcessableCheckpoints } from '../../../../../../../utils/helpers'; -import { decimalic } from '../../../../../../../utils/math'; -import { EarnedFee } from '../../../../RewardsPage.types'; -import { useGetNextPositiveCheckpoint } from '../../../../hooks/useGetNextPositiveCheckpoint'; -import { useGetTotalTokenCheckpoints } from '../../../../hooks/useGetTotalTokenCheckpoints'; - -type WithdrawFeeProps = EarnedFee & { - refetch: () => void; -}; - -/** @deprecated */ -export const WithdrawFee: FC = ({ - token, - value, - contractAddress, - refetch, -}) => { - const { account } = useAccount(); - const { setTransactions, setIsOpen, setTitle } = useTransactionContext(); - - const { checkMaintenance, States } = useMaintenance(); - const claimFeesEarnedLocked = checkMaintenance(States.CLAIM_FEES_EARNED); - const rewardsLocked = checkMaintenance(States.REWARDS_FULL); - - const isRBTC = useMemo(() => token === SupportedTokens.rbtc, [token]); - - const feeSharing = useGetProtocolContract('feeSharing'); - - const { maxCheckpoints } = useGetTotalTokenCheckpoints(contractAddress); - const { userCheckpoint, updateNextPositiveCheckpoint } = - useGetNextPositiveCheckpoint(contractAddress, Number(maxCheckpoints)); - - const isClaimDisabled = useMemo( - () => - !userCheckpoint?.hasFees || - claimFeesEarnedLocked || - rewardsLocked || - decimalic(value).lte(0), - [userCheckpoint?.hasFees, claimFeesEarnedLocked, rewardsLocked, value], - ); - - const maxWithdrawCheckpoint = useMemo( - () => - Number(maxCheckpoints) > getMaxProcessableCheckpoints(token) - ? String(getMaxProcessableCheckpoints(token)) - : maxCheckpoints, - [maxCheckpoints, token], - ); - - const onComplete = useCallback(() => { - updateNextPositiveCheckpoint(); - refetch(); - }, [refetch, updateNextPositiveCheckpoint]); - - const onSubmit = useCallback(() => { - if (!feeSharing) { - return; - } - - const transactions: Transaction[] = []; - const title = t(translations.rewardPage.stabilityPool.tx.withdrawGains); - const txTitle = t(translations.rewardPage.stabilityPool.tx.withdraw); - - if (userCheckpoint?.hasSkippedCheckpoints) { - if (isRBTC) { - transactions.push({ - title, - request: { - type: TransactionType.signTransaction, - contract: feeSharing, - fnName: 'withdrawRBTCStartingFromCheckpoint', - args: [ - userCheckpoint?.checkpointNum, - maxWithdrawCheckpoint, - account, - ], - }, - onComplete, - }); - } else { - transactions.push({ - title, - request: { - type: TransactionType.signTransaction, - contract: feeSharing, - fnName: 'withdrawStartingFromCheckpoint', - args: [ - contractAddress, - userCheckpoint?.checkpointNum, - maxWithdrawCheckpoint, - account, - ], - }, - onComplete, - }); - } - } else { - if (isRBTC) { - transactions.push({ - title, - request: { - type: TransactionType.signTransaction, - contract: feeSharing, - fnName: 'withdrawRBTC', - args: [maxWithdrawCheckpoint, account], - }, - onComplete, - }); - } else { - transactions.push({ - title, - request: { - type: TransactionType.signTransaction, - contract: feeSharing, - fnName: 'withdraw', - args: [contractAddress, maxWithdrawCheckpoint, account], - }, - onComplete, - }); - } - } - - setTransactions(transactions); - setTitle(txTitle); - setIsOpen(true); - }, [ - account, - contractAddress, - feeSharing, - isRBTC, - maxWithdrawCheckpoint, - onComplete, - setIsOpen, - setTitle, - setTransactions, - userCheckpoint?.checkpointNum, - userCheckpoint?.hasSkippedCheckpoints, - ]); - - return ( -