From 5bdc5cf4b7fc5233f07061b9e364151860b739de Mon Sep 17 00:00:00 2001 From: Majorfi Date: Wed, 4 Oct 2023 14:28:15 +0200 Subject: [PATCH] fix: line length --- .editorconfig | 2 +- apps/common/components/AmountInput.tsx | 22 +-- apps/common/components/AppHeader.tsx | 18 +-- apps/common/components/Apps.tsx | 22 +-- .../components/BalanceReminderPopover.tsx | 89 ++++-------- apps/common/components/Dropdown.tsx | 57 ++------ apps/common/components/GaugeDropdown.tsx | 36 ++--- apps/common/components/HeroTimer.tsx | 5 +- apps/common/components/Input.tsx | 4 +- apps/common/components/ListHead.tsx | 28 +--- apps/common/components/ListHero.tsx | 24 +--- apps/common/components/Meta.tsx | 7 +- apps/common/components/MotionDiv.tsx | 7 +- .../common/components/MultiSelectDropdown.tsx | 37 ++--- apps/common/components/Pagination.tsx | 16 +-- apps/common/components/Popover.tsx | 39 ++--- apps/common/components/RenderAmount.tsx | 11 +- apps/common/components/SearchBar.tsx | 16 +-- apps/common/components/SettingsOverwrite.tsx | 15 +- apps/common/components/Switch.tsx | 6 +- apps/common/components/Table.tsx | 65 +++------ apps/common/components/Tabs.tsx | 34 +---- apps/common/components/TokenDropdown.tsx | 46 ++---- apps/common/components/TokenIcon.tsx | 10 +- apps/common/components/ValueAnimation.tsx | 8 +- apps/common/contexts/useMenu.tsx | 6 +- apps/common/contexts/useWallet.tsx | 4 +- apps/common/contexts/useYearn.tsx | 35 ++--- apps/common/hooks/useAllowances.tsx | 5 +- apps/common/hooks/useTokenPrice.ts | 5 +- apps/common/icons/ArrowDown.tsx | 9 +- apps/common/icons/IconArrow.tsx | 8 +- apps/common/icons/IconArrowRight.tsx | 8 +- apps/common/icons/IconChevron.tsx | 8 +- apps/common/icons/IconChevronPlain.tsx | 8 +- apps/common/icons/IconPaginationArrow.tsx | 8 +- apps/common/icons/IconSpinner.tsx | 19 +-- apps/common/icons/LogoYearn.tsx | 8 +- apps/common/icons/LogoYearnBlue.tsx | 8 +- apps/common/icons/MessageIcon.tsx | 9 +- .../schemas/yDaemonTokenListBalances.ts | 12 +- apps/common/utils/actions.ts | 7 +- apps/common/utils/index.tsx | 13 +- apps/common/utils/wagmiUtils.ts | 13 +- apps/vaults/Wrapper.tsx | 8 +- apps/vaults/components/ImageWithOverlay.tsx | 31 +--- apps/vaults/components/RewardsTab.tsx | 19 +-- apps/vaults/components/SettingsPopover.tsx | 61 ++------ .../details/VaultActionsTabsWrapper.tsx | 59 ++------ .../components/details/VaultDetailsHeader.tsx | 25 +--- .../details/actions/QuickActionsButtons.tsx | 75 ++-------- .../details/actions/QuickActionsFrom.tsx | 65 ++------- .../details/actions/QuickActionsTo.tsx | 60 ++------ .../details/tabs/VaultDetailsAbout.tsx | 74 ++-------- .../details/tabs/VaultDetailsHistorical.tsx | 8 +- .../details/tabs/VaultDetailsStrategies.tsx | 35 +---- .../details/tabs/VaultDetailsTabsWrapper.tsx | 54 ++----- .../graphs/GraphForStrategyReports.tsx | 20 +-- .../graphs/GraphForVaultEarnings.tsx | 15 +- .../graphs/GraphForVaultPPSGrowth.tsx | 4 +- .../components/graphs/GraphForVaultTVL.tsx | 4 +- .../components/list/VaultListFactory.tsx | 13 +- .../components/list/VaultListOptions.tsx | 20 +-- .../components/list/VaultsListEmpty.tsx | 10 +- .../list/VaultsListInternalMigrationRow.tsx | 22 +-- .../components/list/VaultsListRetired.tsx | 26 +--- apps/vaults/components/list/VaultsListRow.tsx | 84 +++-------- apps/vaults/contexts/useActionFlow.tsx | 89 +++--------- apps/vaults/contexts/useAppSettings.tsx | 17 +-- apps/vaults/contexts/useSolver.tsx | 32 +---- apps/vaults/contexts/useStakingRewards.tsx | 6 +- apps/vaults/hooks/useFilteredVaults.ts | 10 +- apps/vaults/hooks/useFindVault.ts | 5 +- apps/vaults/hooks/useSolverChainCoin.ts | 23 +-- apps/vaults/hooks/useSolverCowswap.ts | 61 ++------ .../hooks/useSolverInternalMigration.ts | 30 +--- apps/vaults/hooks/useSolverOptimismBooster.ts | 18 +-- apps/vaults/hooks/useSolverPartnerContract.ts | 23 +-- apps/vaults/hooks/useSolverPortals.ts | 29 +--- apps/vaults/hooks/useSolverVanilla.ts | 23 +-- apps/vaults/hooks/useSolverWido.ts | 18 +-- apps/vaults/hooks/useSortVaults.ts | 32 +---- apps/vaults/types/solvers.ts | 32 +---- apps/vaults/utils/zapOptions.tsx | 18 +-- apps/veyfi/Wrapper.tsx | 8 +- apps/veyfi/components/ClaimTab.tsx | 9 +- apps/veyfi/components/GaugesTab.tsx | 63 ++------ apps/veyfi/components/LockTab.tsx | 33 +---- apps/veyfi/components/ManageLockTab.tsx | 36 +---- apps/veyfi/components/RedeemTab.tsx | 42 +----- apps/veyfi/components/RewardsTab.tsx | 7 +- apps/veyfi/components/VoteTab.tsx | 18 +-- apps/veyfi/contexts/useGauge.tsx | 41 ++---- apps/veyfi/contexts/useOption.tsx | 46 ++---- apps/veyfi/contexts/useVotingEscrow.tsx | 9 +- .../utils/abi/veYFIClaimRewardsZap.abi.ts | 4 +- apps/veyfi/utils/index.ts | 4 +- apps/veyfi/utils/validations.ts | 4 +- apps/ybal/Wrapper.tsx | 8 +- .../ybal/components/CardTransactorWrapper.tsx | 35 +---- apps/ybal/components/CardZap.tsx | 57 ++------ apps/ybal/components/Harvests.tsx | 32 +---- apps/ybal/components/HarvestsListRow.tsx | 8 +- apps/ybal/constants/tokens.tsx | 56 +------- apps/ybal/contexts/useAllowanceHook.tsx | 30 +--- apps/ybal/utils/actions.test.ts | 32 +---- apps/ybal/utils/actions.ts | 4 +- apps/ybal/utils/zapOptions.tsx | 39 +---- apps/ybribe/Wrapper.tsx | 8 +- .../components/bribe/GaugeBribeModal.tsx | 52 ++----- apps/ybribe/components/bribe/GaugeListRow.tsx | 30 +--- apps/ybribe/components/claim/GaugeListRow.tsx | 136 ++++-------------- .../components/rewardFeed/RewardFeedTable.tsx | 26 +--- .../rewardFeed/RewardFeedTableRow.tsx | 40 ++---- apps/ybribe/contexts/useBribes.tsx | 60 ++++---- apps/ycrv/Wrapper.tsx | 8 +- .../ycrv/components/CardTransactorWrapper.tsx | 25 +--- apps/ycrv/components/CardZap.tsx | 65 ++------- apps/ycrv/components/Harvests.tsx | 39 +---- apps/ycrv/components/HarvestsListRow.tsx | 16 +-- apps/ycrv/components/QuickActions.tsx | 33 +---- .../components/illustrations/how-it-works.tsx | 8 +- apps/ycrv/constants/tokens.tsx | 89 ++---------- apps/ycrv/contexts/useAllowanceHook.tsx | 50 ++----- apps/ycrv/contexts/useYCRV.tsx | 6 +- pages/_app.tsx | 13 +- pages/index.tsx | 15 +- pages/vaults/[chainID]/[address].tsx | 8 +- pages/vaults/about.tsx | 16 +-- pages/vaults/factory.tsx | 110 +++++--------- pages/vaults/index.tsx | 74 ++-------- pages/ybal/about.tsx | 51 ++----- pages/ybal/index.tsx | 38 +---- pages/ybribe/about.tsx | 24 +--- pages/ybribe/index.tsx | 76 ++++------ pages/ybribe/offer-bribe.tsx | 52 +++---- pages/ycrv/about.tsx | 69 ++------- pages/ycrv/index.tsx | 107 +++----------- 138 files changed, 815 insertions(+), 3229 deletions(-) diff --git a/.editorconfig b/.editorconfig index 298fec822..8cefed389 100755 --- a/.editorconfig +++ b/.editorconfig @@ -7,4 +7,4 @@ trim_trailing_whitespace = true insert_final_newline = true indent_style = tab indent_size = 4 -max_line_length = 120 +max_line_length = 180 diff --git a/apps/common/components/AmountInput.tsx b/apps/common/components/AmountInput.tsx index 2ad60f2bb..9b28e6799 100644 --- a/apps/common/components/AmountInput.tsx +++ b/apps/common/components/AmountInput.tsx @@ -18,19 +18,7 @@ type TAmountInputProps = { onMaxClick?: () => void; }; -export function AmountInput({ - amount, - maxAmount, - label, - placeholder, - legend, - error, - disabled, - loading, - onAmountChange, - onLegendClick, - onMaxClick -}: TAmountInputProps): ReactElement { +export function AmountInput({amount, maxAmount, label, placeholder, legend, error, disabled, loading, onAmountChange, onLegendClick, onMaxClick}: TAmountInputProps): ReactElement { let displayedAmount = amount.toString(); if (isZero(displayedAmount) && !disabled) { displayedAmount = ''; @@ -43,9 +31,7 @@ export function AmountInput({ {label &&

{label}

}
diff --git a/apps/common/components/AppHeader.tsx b/apps/common/components/AppHeader.tsx index 6c702409f..5261ce4f1 100644 --- a/apps/common/components/AppHeader.tsx +++ b/apps/common/components/AppHeader.tsx @@ -61,10 +61,7 @@ function LogoPopover(): ReactElement { }; return ( - set_isShowing(true)} - onMouseLeave={(): void => set_isShowing(false)} - className={'relative'}> + set_isShowing(true)} onMouseLeave={(): void => set_isShowing(false)} className={'relative'}> {'Back to home'} @@ -80,24 +77,17 @@ function LogoPopover(): ReactElement { leave={'transition ease-in duration-150'} leaveFrom={'opacity-100 translate-y-0'} leaveTo={'opacity-0 translate-y-1'}> - +
{[...Object.values(APPS), YETH] .filter(({isDisabled}): boolean => !isDisabled) .map(({name, href, icon}): ReactElement => { return ( - set_isShowing(false)}> + set_isShowing(false)}>
set_isShowing(false)} - className={ - 'flex cursor-pointer flex-col items-center p-4 transition-colors hover:bg-neutral-200' - }> + className={'flex cursor-pointer flex-col items-center p-4 transition-colors hover:bg-neutral-200'}>
{cloneElement(icon)}
{name} diff --git a/apps/common/components/Apps.tsx b/apps/common/components/Apps.tsx index 7ca33a92e..955504fa4 100644 --- a/apps/common/components/Apps.tsx +++ b/apps/common/components/Apps.tsx @@ -46,16 +46,7 @@ export const APPS: {[key in AppName]: TApp} = { href: '/ycrv', menu: YCRV_MENU, manifest: ycrvManifest, - icon: ( - - ) + icon: }, yBal: { name: AppName.YBAL, @@ -63,16 +54,7 @@ export const APPS: {[key in AppName]: TApp} = { menu: YBAL_MENU, manifest: yBalManifest, isDisabled: true, - icon: ( - - ) + icon: }, veYFI: { name: AppName.VEYFI, diff --git a/apps/common/components/BalanceReminderPopover.tsx b/apps/common/components/BalanceReminderPopover.tsx index af16e6bf7..c328c691e 100755 --- a/apps/common/components/BalanceReminderPopover.tsx +++ b/apps/common/components/BalanceReminderPopover.tsx @@ -31,12 +31,7 @@ function TokenItem({element}: {element: TBalanceReminderElement}): ReactElement const {safeChainID} = useChainID(); const balance = useBalance(element.address); - async function addTokenToMetamask( - address: TAddress, - symbol: string, - decimals: number, - image: string - ): Promise { + async function addTokenToMetamask(address: TAddress, symbol: string, decimals: number, image: string): Promise { if (!provider) { return; } @@ -68,9 +63,7 @@ function TokenItem({element}: {element: TBalanceReminderElement}): ReactElement width={32} height={32} quality={90} - src={`${process.env.BASE_YEARN_ASSETS_URI}/${safeChainID}/${toAddress( - element.address - )}/logo-128.png`} + src={`${process.env.BASE_YEARN_ASSETS_URI}/${safeChainID}/${toAddress(element.address)}/logo-128.png`} />
{element.symbol} @@ -85,14 +78,10 @@ function TokenItem({element}: {element: TBalanceReminderElement}): ReactElement element.address, element.symbol, element.decimals, - `${process.env.BASE_YEARN_ASSETS_URI}/${safeChainID}/${toAddress( - element.address - )}/logo-128.png` + `${process.env.BASE_YEARN_ASSETS_URI}/${safeChainID}/${toAddress(element.address)}/logo-128.png` ); }} - className={ - 'ml-4 h-4 w-4 cursor-pointer text-neutral-400 transition-colors hover:text-neutral-900' - } + className={'ml-4 h-4 w-4 cursor-pointer text-neutral-400 transition-colors hover:text-neutral-900'} /> @@ -106,34 +95,28 @@ export function BalanceReminderPopover(): ReactElement { const {vaults} = useYearn(); const nonNullBalances = useMemo((): TDict => { - const nonNullBalances = Object.entries(balances).reduce( - (acc: TDict, [address, balance]): TDict => { - if (toBigInt(balance?.raw) > 0n) { - acc[toAddress(address)] = balance; - } - return acc; - }, - {} - ); + const nonNullBalances = Object.entries(balances).reduce((acc: TDict, [address, balance]): TDict => { + if (toBigInt(balance?.raw) > 0n) { + acc[toAddress(address)] = balance; + } + return acc; + }, {}); return nonNullBalances; }, [balances]); const nonNullBalancesForVault = useMemo((): TBalanceReminderElement[] => { - const nonNullBalancesForVault = Object.entries(nonNullBalances).reduce( - (acc: TBalanceReminderElement[], [address, balance]): TBalanceReminderElement[] => { - const currentVault = vaults?.[toAddress(address)]; - if (currentVault) { - acc.push({ - address: toAddress(address), - normalizedBalance: balance.normalized, - decimals: balance.decimals, - symbol: currentVault.symbol - }); - } - return acc; - }, - [] - ); + const nonNullBalancesForVault = Object.entries(nonNullBalances).reduce((acc: TBalanceReminderElement[], [address, balance]): TBalanceReminderElement[] => { + const currentVault = vaults?.[toAddress(address)]; + if (currentVault) { + acc.push({ + address: toAddress(address), + normalizedBalance: balance.normalized, + decimals: balance.decimals, + symbol: currentVault.symbol + }); + } + return acc; + }, []); return nonNullBalancesForVault; }, [nonNullBalances, vaults]); @@ -159,36 +142,18 @@ export function BalanceReminderPopover(): ReactElement { leave={'transition ease-in duration-150'} leaveFrom={'opacity-100 translate-y-0'} leaveTo={'opacity-0 translate-y-1'}> - +
-
- - {isActive && address && ens - ? ens - : isActive && address - ? truncateHex(address, 5) - : 'Connect wallet'} - +
+ {isActive && address && ens ? ens : isActive && address ? truncateHex(address, 5) : 'Connect wallet'}
-
- 0} - fallback={renderNoTokenFallback(isLoading)}> + 0} fallback={renderNoTokenFallback(isLoading)}> {nonNullBalancesForVault.map( (element): ReactElement => ( diff --git a/apps/common/components/Dropdown.tsx b/apps/common/components/Dropdown.tsx index 361ee5547..1d50385a9 100644 --- a/apps/common/components/Dropdown.tsx +++ b/apps/common/components/Dropdown.tsx @@ -17,23 +17,12 @@ const DropdownOption = (option: TDropdownOption): ReactElement => {
{icon && (
- +
)}

{label}

- {description && ( -

- {description} -

- )} + {description &&

{description}

}
)} @@ -78,22 +67,12 @@ export type TDropdownProps = { className?: string; }; -export const Dropdown = ({ - selected, - options, - onChange, - label, - legend, - isDisabled, - className -}: TDropdownProps): ReactElement => { +export const Dropdown = ({selected, options, onChange, label, legend, isDisabled, className}: TDropdownProps): ReactElement => { const [isOpen, set_isOpen] = useThrottledState(false, 400); const [search, set_search] = useState(''); const isSearching = search !== ''; - const filteredOptions = isSearching - ? options.filter(({label}): boolean => label.toLowerCase().includes(search.toLowerCase())) - : options; + const filteredOptions = isSearching ? options.filter(({label}): boolean => label.toLowerCase().includes(search.toLowerCase())) : options; return (
@@ -131,14 +110,7 @@ export const Dropdown = ({
{selected?.icon && (
- +
)}

option?.label ?? '-'} spellCheck={false} onChange={(event): void => { @@ -163,12 +133,7 @@ export const Dropdown = ({

- +
( - + ) ) )} diff --git a/apps/common/components/GaugeDropdown.tsx b/apps/common/components/GaugeDropdown.tsx index 923c827f3..f2d4e38d1 100755 --- a/apps/common/components/GaugeDropdown.tsx +++ b/apps/common/components/GaugeDropdown.tsx @@ -12,13 +12,9 @@ function DropdownItem({option}: TDropdownGaugeItemProps): ReactElement { {({active}): ReactElement => (
-
- {option?.icon ? cloneElement(option.icon) : null} -
+
{option?.icon ? cloneElement(option.icon) : null}
-

- {option.label} -

+

{option.label}

{`APY ${formatPercent((option?.value?.APY || 0) * 100, 2, 2, 500)}`}

@@ -90,25 +86,14 @@ export function Dropdown({options, selected, onSelect, placeholder = ''}: TDropd <> set_isOpen(!isOpen)} - className={ - 'flex h-10 w-full items-center justify-between bg-neutral-0 p-2 text-base text-neutral-900 md:px-3' - }> + className={'flex h-10 w-full items-center justify-between bg-neutral-0 p-2 text-base text-neutral-900 md:px-3'}>
- {selected?.icon ? ( - cloneElement(selected.icon) - ) : ( -
- )} + {selected?.icon ? cloneElement(selected.icon) :
}
-

+

option.label} placeholder={placeholder} spellCheck={false} @@ -117,10 +102,7 @@ export function Dropdown({options, selected, onSelect, placeholder = ''}: TDropd

- +
set_query('')}> - 0} - fallback={}> + 0} fallback={}> {filteredOptions.map( (option): ReactElement => ( diff --git a/apps/common/components/HeroTimer.tsx b/apps/common/components/HeroTimer.tsx index 7487e3e51..ebec8303a 100755 --- a/apps/common/components/HeroTimer.tsx +++ b/apps/common/components/HeroTimer.tsx @@ -18,10 +18,7 @@ export function HeroTimer({endTime}: TProps): ReactElement {
-
+
{time} diff --git a/apps/common/components/Input.tsx b/apps/common/components/Input.tsx index e1e919ad5..4003c5760 100644 --- a/apps/common/components/Input.tsx +++ b/apps/common/components/Input.tsx @@ -32,9 +32,7 @@ export function Input(props: TAmountInputProps): ReactElement { />
{(error ?? legend) && ( - + {error ?? legend} )} diff --git a/apps/common/components/ListHead.tsx b/apps/common/components/ListHead.tsx index 1ffff38bf..ad97d4c54 100644 --- a/apps/common/components/ListHead.tsx +++ b/apps/common/components/ListHead.tsx @@ -20,23 +20,9 @@ export type TListHead = { onSort: (sortBy: string, sortDirection: TSortDirection) => void; }; -export function ListHead({ - items, - dataClassName, - wrapperClassName, - tokenClassName, - sortBy, - sortDirection, - onSort -}: TListHead): ReactElement { +export function ListHead({items, dataClassName, wrapperClassName, tokenClassName, sortBy, sortDirection, onSort}: TListHead): ReactElement { const toggleSortDirection = (newSortBy: string): TSortDirection => { - return sortBy === newSortBy - ? sortDirection === '' - ? 'desc' - : sortDirection === 'desc' - ? 'asc' - : 'desc' - : 'desc'; + return sortBy === newSortBy ? (sortDirection === '' ? 'desc' : sortDirection === 'desc' ? 'asc' : 'desc') : 'desc'; }; const renderChevron = useCallback( @@ -47,11 +33,7 @@ export function ListHead({ if (shouldSortBy && sortDirection === 'asc') { return ; } - return ( - - ); + return ; }, [sortDirection] ); @@ -63,9 +45,7 @@ export function ListHead({

{chain.label}

- diff --git a/apps/common/components/ListHero.tsx b/apps/common/components/ListHero.tsx index 526a79cba..37b3f91cd 100644 --- a/apps/common/components/ListHero.tsx +++ b/apps/common/components/ListHero.tsx @@ -57,10 +57,7 @@ function DesktopCategories({categories, onSelect}: TListHeroDesktopCategories
{(categories || []).map( (currentCategory, index: number): ReactElement => ( -
+
{currentCategory.map( (item): ReactElement => ( ) )} @@ -141,35 +126,29 @@ export function Table({ onRowClick ? 'cursor-pointer' : 'cursor-auto' )} onClick={(): void => onRowClick?.(item)}> - {metadata.map( - ({key, label, className, fullWidth, columnSpan, format, transform}): ReactElement => { - const isNumber = !isNaN(item[key] as number); - - return ( + {metadata.map(({key, label, className, fullWidth, columnSpan, format, transform}): ReactElement => { + const isNumber = !isNaN(item[key] as number); + + return ( +
+ {!fullWidth && }
- {!fullWidth && ( - - )} -
- {transform?.(item) ?? format?.(item).toString() ?? String(item[key])} -
+ {transform?.(item) ?? format?.(item).toString() ?? String(item[key])}
- ); - } - )} +
+ ); + })}
) )} diff --git a/apps/common/components/Tabs.tsx b/apps/common/components/Tabs.tsx index 749ae0cdb..b08575d5c 100644 --- a/apps/common/components/Tabs.tsx +++ b/apps/common/components/Tabs.tsx @@ -57,23 +57,11 @@ export function Tabs({items, className}: TTabsProps): ReactElement { ); set_selectedTabId(id); }}> -

+

{label}

- {selectedTabId === id && ( - - )} - {selectedTabId !== id && ( - - )} + {selectedTabId === id && } + {selectedTabId !== id && }
) )} @@ -86,13 +74,9 @@ export function Tabs({items, className}: TTabsProps): ReactElement { className={ 'flex h-10 w-full flex-row items-center border-0 border-b-2 border-neutral-900 bg-neutral-100 p-0 font-bold focus:border-neutral-900 md:hidden' }> -
- {items.find(({id}): boolean => id === selectedTabId)?.label || 'Menu'} -
+
{items.find(({id}): boolean => id === selectedTabId)?.label || 'Menu'}
- +
- + {items.map( ({id, content}): ReactElement => (

{vaultName}

-

{`${formatAmount(balanceToMigrate.normalized)} ${ - currentVault.token.symbol - }`}

+

{`${formatAmount(balanceToMigrate.normalized)} ${currentVault.token.symbol}`}

-
- { - "Looks like you're holding tokens from a previous version of this vault. To keep earning yield on your assets, migrate to the current vault." - } +
+ {"Looks like you're holding tokens from a previous version of this vault. To keep earning yield on your assets, migrate to the current vault."}
-
-
diff --git a/apps/vaults/components/list/VaultsListRetired.tsx b/apps/vaults/components/list/VaultsListRetired.tsx index 62a8c4c54..9e5b1f23b 100755 --- a/apps/vaults/components/list/VaultsListRetired.tsx +++ b/apps/vaults/components/list/VaultsListRetired.tsx @@ -16,9 +16,7 @@ export function VaultsListRetired({currentVault}: {currentVault: TYDaemonVault}) const balanceToMigrate = useBalance(currentVault.address, balances); return ( - +
@@ -27,31 +25,19 @@ export function VaultsListRetired({currentVault}: {currentVault: TYDaemonVault})

{vaultName}

-

{`${formatAmount(balanceToMigrate.normalized)} ${ - currentVault.token.symbol - }`}

+

{`${formatAmount(balanceToMigrate.normalized)} ${currentVault.token.symbol}`}

-
+
{'This Vault is no longer supported. '} - { - 'Sadly this vault is deprecated and will no longer earn yield. Please withdraw your funds (many other Vaults await you anon).' - } + {'Sadly this vault is deprecated and will no longer earn yield. Please withdraw your funds (many other Vaults await you anon).'}
-
-
diff --git a/apps/vaults/components/list/VaultsListRow.tsx b/apps/vaults/components/list/VaultsListRow.tsx index 512505539..8333dd0e0 100755 --- a/apps/vaults/components/list/VaultsListRow.tsx +++ b/apps/vaults/components/list/VaultsListRow.tsx @@ -37,37 +37,22 @@ export function VaultAPR({currentVault}: {currentVault: TYDaemonVault}): ReactEl
- + {'⚡️ '} -
+
-
+

{'• Base APR '}

-
+

{'• Rewards APR '}

- +
@@ -83,40 +68,24 @@ export function VaultAPR({currentVault}: {currentVault: TYDaemonVault}): ReactEl
- + - 0 && - !currentVault.apy?.staking_rewards_apr - }> + 0 && !currentVault.apy?.staking_rewards_apr}> {`BOOST ${formatAmount(currentVault.apy?.composite?.boost, 2, 2)}x`} -
+
-
+

{'• Base APR '}

-
+

{'• Boost '}

{`${formatAmount(currentVault.apy?.composite?.boost, 2, 2)} x`}

@@ -131,9 +100,7 @@ export function VaultAPR({currentVault}: {currentVault: TYDaemonVault}): ReactEl return (
- + @@ -145,9 +112,7 @@ export function VaultsListRow({currentVault}: {currentVault: TYDaemonVault}): Re const balanceOfWant = useBalance(currentVault.token.address); const balanceOfCoin = useBalance(ETH_TOKEN_ADDRESS); //TODO: Create a wagmi Chain upgrade to add the chain wrapper token address - const balanceOfWrappedCoin = useBalance( - toAddress(currentVault.token.address) === WFTM_TOKEN_ADDRESS ? WFTM_TOKEN_ADDRESS : WETH_TOKEN_ADDRESS - ); + const balanceOfWrappedCoin = useBalance(toAddress(currentVault.token.address) === WFTM_TOKEN_ADDRESS ? WFTM_TOKEN_ADDRESS : WETH_TOKEN_ADDRESS); const vaultName = useMemo((): string => getVaultName(currentVault), [currentVault]); const deposited = useBalance(currentVault.address)?.raw; const {stakingRewardsByVault, positionsMap} = useStakingRewards(); @@ -171,13 +136,9 @@ export function VaultsListRow({currentVault}: {currentVault: TYDaemonVault}): Re }, [currentVault.address, deposited, positionsMap, stakingRewardsByVault]); return ( - +
-
- {ChainIconMap.get(currentVault.chainID) ?? } -
+
{ChainIconMap.get(currentVault.chainID) ?? }
@@ -200,10 +161,7 @@ export function VaultsListRow({currentVault}: {currentVault: TYDaemonVault}): Re
-

+

-

- +

+

diff --git a/apps/vaults/contexts/useActionFlow.tsx b/apps/vaults/contexts/useActionFlow.tsx index a8a6c0f07..f13c9d87f 100644 --- a/apps/vaults/contexts/useActionFlow.tsx +++ b/apps/vaults/contexts/useActionFlow.tsx @@ -96,22 +96,14 @@ function useContextualIs({selectedTo, currentVault}: TUseContextualIs): [boolean const router = useRouter(); const isDepositing = useMemo( - (): boolean => - (!router.query.action || router.query.action === 'deposit') && - (!selectedTo?.value || toAddress(selectedTo?.value) === toAddress(currentVault.address)), + (): boolean => (!router.query.action || router.query.action === 'deposit') && (!selectedTo?.value || toAddress(selectedTo?.value) === toAddress(currentVault.address)), [selectedTo?.value, currentVault.address, router.query.action] ); - const isPartnerAddressValid = useMemo( - (): boolean => !isZeroAddress(getNetwork(safeChainID)?.contracts?.partnerContract?.address), - [safeChainID] - ); + const isPartnerAddressValid = useMemo((): boolean => !isZeroAddress(getNetwork(safeChainID)?.contracts?.partnerContract?.address), [safeChainID]); const isUsingPartnerContract = useMemo( - (): boolean => - (process?.env?.SHOULD_USE_PARTNER_CONTRACT === undefined - ? true - : Boolean(process?.env?.SHOULD_USE_PARTNER_CONTRACT)) && isPartnerAddressValid, + (): boolean => (process?.env?.SHOULD_USE_PARTNER_CONTRACT === undefined ? true : Boolean(process?.env?.SHOULD_USE_PARTNER_CONTRACT)) && isPartnerAddressValid, [isPartnerAddressValid] ); @@ -141,13 +133,7 @@ function getMaxDepositPossible(props: TGetMaxDepositPossible): TNormalizedBN { } const ActionFlowContext = createContext(DefaultActionFlowContext); -export function ActionFlowContextApp({ - children, - currentVault -}: { - children: ReactNode; - currentVault: TYDaemonVault; -}): React.ReactElement { +export function ActionFlowContextApp({children, currentVault}: {children: ReactNode; currentVault: TYDaemonVault}): React.ReactElement { const {balances, balancesNonce} = useWallet(); const {chainID, safeChainID} = useChainID(); const {balances: zapBalances, tokensList} = useWalletForZap(); @@ -225,18 +211,10 @@ export function ActionFlowContextApp({ isDepositing, depositLimit: depositLimit || 0n }); - }, [ - actionParams?.selectedOptionFrom?.decimals, - actionParams?.selectedOptionFrom?.value, - balances, - currentVault, - depositLimit, - isDepositing - ]); + }, [actionParams?.selectedOptionFrom?.decimals, actionParams?.selectedOptionFrom?.value, balances, currentVault, depositLimit, isDepositing]); const currentSolver = useMemo((): TSolver => { - const isUnderlyingToken = - toAddress(actionParams?.selectedOptionFrom?.value) === toAddress(currentVault.token.address); + const isUnderlyingToken = toAddress(actionParams?.selectedOptionFrom?.value) === toAddress(currentVault.token.address); // Only use OptimismBooster if the user chose to stake automatically if (hasStakingRewards && isStakingOpBoostedVaults && isDepositing && isUnderlyingToken) { @@ -253,10 +231,7 @@ export function ActionFlowContextApp({ if (isVaultTokenWrappedCoin && (isInputTokenEth || isOutputTokenEth)) { return Solver.enum.ChainCoin; } - if ( - currentVault?.migration?.available && - toAddress(actionParams?.selectedOptionTo?.value) === toAddress(currentVault?.migration?.address) - ) { + if (currentVault?.migration?.available && toAddress(actionParams?.selectedOptionTo?.value) === toAddress(currentVault?.migration?.address)) { return Solver.enum.InternalMigration; } if (isDepositing && (actionParams?.selectedOptionFrom?.solveVia?.length || 0) > 0) { @@ -301,9 +276,7 @@ export function ActionFlowContextApp({ if (isDepositing && (actionParams?.selectedOptionFrom?.solveVia || []).length > 0) { // We don't want to be able to withdraw to exotic tokens. If the current from is one of them, take another one. _selectedOptionFrom = possibleOptionsFrom.find( - (option: TDropdownOption): boolean => - option.value !== actionParams?.selectedOptionFrom?.value && - isZero((option.solveVia || []).length) + (option: TDropdownOption): boolean => option.value !== actionParams?.selectedOptionFrom?.value && isZero((option.solveVia || []).length) ); } actionParamsDispatcher({ @@ -358,10 +331,7 @@ export function ActionFlowContextApp({ }); } else if (nextFlow === Flow.Migrate) { const userBalance = toBigInt(balances?.[toAddress(currentVault?.address)]?.raw); - const _amount = toNormalizedBN( - userBalance, - currentVault?.decimals || currentVault?.token?.decimals || 18 - ); + const _amount = toNormalizedBN(userBalance, currentVault?.decimals || currentVault?.token?.decimals || 18); const selectedOptionTo = { name: currentVault?.name, symbol: currentVault?.symbol, @@ -433,13 +403,7 @@ export function ActionFlowContextApp({ } }); }, - [ - balances, - currentVault.details.depositLimit, - currentVault.token?.address, - currentVault.token.decimals, - isDepositing - ] + [balances, currentVault.details.depositLimit, currentVault.token?.address, currentVault.token.decimals, isDepositing] ); /* 🔵 - Yearn Finance ************************************************************************** @@ -478,11 +442,7 @@ export function ActionFlowContextApp({ }) ] ); - } else if ( - safeChainID === 250 && - currentVault && - toAddress(currentVault.token.address) === WFTM_TOKEN_ADDRESS - ) { + } else if (safeChainID === 250 && currentVault && toAddress(currentVault.token.address) === WFTM_TOKEN_ADDRESS) { payloadFrom.push( ...[ setZapOption({ @@ -501,11 +461,7 @@ export function ActionFlowContextApp({ }) ] ); - } else if ( - safeChainID === 10 && - currentVault && - toAddress(currentVault.token.address) === OPT_WETH_TOKEN_ADDRESS - ) { + } else if (safeChainID === 10 && currentVault && toAddress(currentVault.token.address) === OPT_WETH_TOKEN_ADDRESS) { payloadFrom.push( ...[ setZapOption({ @@ -604,12 +560,9 @@ export function ActionFlowContextApp({ **********************************************************************************************/ useUpdateEffect((): void => { const _possibleZapOptionsFrom: TDropdownOption[] = []; - const isWithWETH = - safeChainID === 1 && currentVault && toAddress(currentVault.token.address) === WETH_TOKEN_ADDRESS; - const isWithWOPT = - safeChainID === 10 && currentVault && toAddress(currentVault.token.address) === OPT_WETH_TOKEN_ADDRESS; - const isWithWFTM = - safeChainID === 250 && currentVault && toAddress(currentVault.token.address) === WFTM_TOKEN_ADDRESS; + const isWithWETH = safeChainID === 1 && currentVault && toAddress(currentVault.token.address) === WETH_TOKEN_ADDRESS; + const isWithWOPT = safeChainID === 10 && currentVault && toAddress(currentVault.token.address) === OPT_WETH_TOKEN_ADDRESS; + const isWithWFTM = safeChainID === 250 && currentVault && toAddress(currentVault.token.address) === WFTM_TOKEN_ADDRESS; Object.entries(zapBalances || {}) .filter((): boolean => safeChainID === currentVault?.chainID) // Disable if we are on the wrong chain @@ -701,17 +654,7 @@ export function ActionFlowContextApp({ maxDepositPossible, currentSolver }), - [ - currentVault, - possibleZapOptionsFrom, - possibleZapOptionsTo, - actionParams, - onSwitchSelectedOptions, - isDepositing, - maxDepositPossible, - currentSolver, - updateParams - ] + [currentVault, possibleZapOptionsFrom, possibleZapOptionsTo, actionParams, onSwitchSelectedOptions, isDepositing, maxDepositPossible, currentSolver, updateParams] ); return {children}; diff --git a/apps/vaults/contexts/useAppSettings.tsx b/apps/vaults/contexts/useAppSettings.tsx index a2d48ed26..991f658ce 100755 --- a/apps/vaults/contexts/useAppSettings.tsx +++ b/apps/vaults/contexts/useAppSettings.tsx @@ -30,11 +30,7 @@ const defaultProps: TAppSettingsContext = { }; const AppSettingsContext = createContext(defaultProps); -export const AppSettingsContextApp = memo(function AppSettingsContextApp({ - children -}: { - children: ReactElement; -}): ReactElement { +export const AppSettingsContextApp = memo(function AppSettingsContextApp({children}: {children: ReactElement}): ReactElement { const [category, set_category] = useSessionStorage('yearn.fi/vaults-category', 'All Vaults'); const [searchValue, set_searchValue] = useSessionStorage('yearn.fi/vaults-search', ''); const [selectedChains, set_selectedChains] = useSessionStorage('yearn.fi/selected-chains', '[1]'); @@ -57,16 +53,7 @@ export const AppSettingsContextApp = memo(function AppSettingsContextApp({ set_searchValue, set_selectedChains }), - [ - shouldHideDust, - shouldHideLowTVLVaults, - category, - searchValue, - set_category, - set_searchValue, - set_shouldHideDust, - set_shouldHideLowTVLVaults - ] + [shouldHideDust, shouldHideLowTVLVaults, category, searchValue, set_category, set_searchValue, set_shouldHideDust, set_shouldHideLowTVLVaults] ); return {children}; diff --git a/apps/vaults/contexts/useSolver.tsx b/apps/vaults/contexts/useSolver.tsx index 0ac704734..76ea09291 100644 --- a/apps/vaults/contexts/useSolver.tsx +++ b/apps/vaults/contexts/useSolver.tsx @@ -97,11 +97,7 @@ export function WithSolverContextApp({children}: {children: React.ReactElement}) **********************************************************************************************/ const onUpdateSolver = useCallback( async (currentNonce: number): Promise => { - if ( - !actionParams?.selectedOptionFrom || - !actionParams?.selectedOptionTo || - actionParams?.amount.raw === undefined - ) { + if (!actionParams?.selectedOptionFrom || !actionParams?.selectedOptionTo || actionParams?.amount.raw === undefined) { return; } set_isLoading(true); @@ -114,18 +110,8 @@ export function WithSolverContextApp({children}: {children: React.ReactElement}) isDepositing: isDepositing }; - const isValidSolver = ({ - quote, - solver - }: { - quote: PromiseSettledResult; - solver: TSolver; - }): boolean => { - return ( - quote.status === 'fulfilled' && - quote?.value.raw > 0n && - !isSolverDisabled(currentVault.chainID)[solver] - ); + const isValidSolver = ({quote, solver}: {quote: PromiseSettledResult; solver: TSolver}): boolean => { + return quote.status === 'fulfilled' && quote?.value.raw > 0n && !isSolverDisabled(currentVault.chainID)[solver]; }; switch (currentSolver) { @@ -168,17 +154,9 @@ export function WithSolverContextApp({children}: {children: React.ReactElement}) ctx: vanilla }; - const solverPriority = [ - Solver.enum.Wido, - Solver.enum.Cowswap, - Solver.enum.Portals, - Solver.enum.None - ]; + const solverPriority = [Solver.enum.Wido, Solver.enum.Cowswap, Solver.enum.Portals, Solver.enum.None]; - const newSolverPriority = [ - currentSolver, - ...solverPriority.filter((solver): boolean => solver !== currentSolver) - ]; + const newSolverPriority = [currentSolver, ...solverPriority.filter((solver): boolean => solver !== currentSolver)]; for (const solver of newSolverPriority) { if (!solvers[solver]) { diff --git a/apps/vaults/contexts/useStakingRewards.tsx b/apps/vaults/contexts/useStakingRewards.tsx index eca5167d9..6d11a9888 100644 --- a/apps/vaults/contexts/useStakingRewards.tsx +++ b/apps/vaults/contexts/useStakingRewards.tsx @@ -42,11 +42,7 @@ const defaultProps: TStakingRewardsContext = { }; const StakingRewardsContext = createContext(defaultProps); -export const StakingRewardsContextApp = memo(function StakingRewardsContextApp({ - children -}: { - children: ReactElement; -}): ReactElement { +export const StakingRewardsContextApp = memo(function StakingRewardsContextApp({children}: {children: ReactElement}): ReactElement { const {provider, address: userAddress, isActive} = useWeb3(); const {chainID: appChainID} = useChainID(); const router = useRouter(); diff --git a/apps/vaults/hooks/useFilteredVaults.ts b/apps/vaults/hooks/useFilteredVaults.ts index d07feb6b2..214dbd423 100644 --- a/apps/vaults/hooks/useFilteredVaults.ts +++ b/apps/vaults/hooks/useFilteredVaults.ts @@ -3,12 +3,6 @@ import {useMemo} from 'react'; import type {TDict} from '@yearn-finance/web-lib/types'; import type {TYDaemonVault} from '@common/schemas/yDaemonVaultsSchemas'; -export function useFilteredVaults( - vaultMap: TDict, - condition: (v: TYDaemonVault) => boolean -): TYDaemonVault[] { - return useMemo( - (): TYDaemonVault[] => Object.values(vaultMap).filter((vault): boolean => condition(vault)), - [vaultMap, condition] - ); +export function useFilteredVaults(vaultMap: TDict, condition: (v: TYDaemonVault) => boolean): TYDaemonVault[] { + return useMemo((): TYDaemonVault[] => Object.values(vaultMap).filter((vault): boolean => condition(vault)), [vaultMap, condition]); } diff --git a/apps/vaults/hooks/useFindVault.ts b/apps/vaults/hooks/useFindVault.ts index c9d499703..030e76a1e 100644 --- a/apps/vaults/hooks/useFindVault.ts +++ b/apps/vaults/hooks/useFindVault.ts @@ -3,10 +3,7 @@ import {useMemo} from 'react'; import type {TDict} from '@yearn-finance/web-lib/types'; import type {TYDaemonVault} from '@common/schemas/yDaemonVaultsSchemas'; -export function useFindVault( - vaultMap: TDict, - condition: (v: TYDaemonVault) => boolean -): TYDaemonVault | null { +export function useFindVault(vaultMap: TDict, condition: (v: TYDaemonVault) => boolean): TYDaemonVault | null { const foundVault = useMemo((): TYDaemonVault | undefined => { return Object.values(vaultMap).find((vault): boolean => condition(vault)); }, [vaultMap, condition]); diff --git a/apps/vaults/hooks/useSolverChainCoin.ts b/apps/vaults/hooks/useSolverChainCoin.ts index ec90e7529..0c4318914 100644 --- a/apps/vaults/hooks/useSolverChainCoin.ts +++ b/apps/vaults/hooks/useSolverChainCoin.ts @@ -58,12 +58,7 @@ export function useSolverChainCoin(): TSolverContext { return toNormalizedBN(0); } - const key = allowanceKey( - safeChainID, - toAddress(request.current.inputToken.value), - toAddress(request.current.outputToken.value), - toAddress(request.current.from) - ); + const key = allowanceKey(safeChainID, toAddress(request.current.inputToken.value), toAddress(request.current.outputToken.value), toAddress(request.current.from)); if (existingAllowances.current[key] && !shouldForceRefetch) { return existingAllowances.current[key]; } @@ -85,11 +80,7 @@ export function useSolverChainCoin(): TSolverContext { ** need to approve the yvWrappedCoin to be used by the zap contract. **************************************************************************/ const onApprove = useCallback( - async ( - amount = MAX_UINT_256, - txStatusSetter: React.Dispatch>, - onSuccess: () => Promise - ): Promise => { + async (amount = MAX_UINT_256, txStatusSetter: React.Dispatch>, onSuccess: () => Promise): Promise => { assert(request?.current?.inputToken, 'Input token is not set'); const result = await approveERC20({ @@ -112,10 +103,7 @@ export function useSolverChainCoin(): TSolverContext { ** aka the vault underlying token, and then deposit it to the vault. **************************************************************************/ const onExecuteDeposit = useCallback( - async ( - txStatusSetter: React.Dispatch>, - onSuccess: () => Promise - ): Promise => { + async (txStatusSetter: React.Dispatch>, onSuccess: () => Promise): Promise => { assert(request.current, 'Request is not set'); assert(request.current.inputAmount, 'Input amount is not set'); @@ -138,10 +126,7 @@ export function useSolverChainCoin(): TSolverContext { ** yvETH to wETH, unwrap the wETH and send them to the user. **************************************************************************/ const onExecuteWithdraw = useCallback( - async ( - txStatusSetter: React.Dispatch>, - onSuccess: () => Promise - ): Promise => { + async (txStatusSetter: React.Dispatch>, onSuccess: () => Promise): Promise => { assert(request.current, 'Request is not set'); assert(request.current.inputAmount, 'Input amount is not set'); diff --git a/apps/vaults/hooks/useSolverCowswap.ts b/apps/vaults/hooks/useSolverCowswap.ts index ba223e86b..6e5973928 100644 --- a/apps/vaults/hooks/useSolverCowswap.ts +++ b/apps/vaults/hooks/useSolverCowswap.ts @@ -21,21 +21,12 @@ import {assert} from '@common/utils/assert'; import type {TDict} from '@yearn-finance/web-lib/types'; import type {TTxResponse, TTxStatus} from '@yearn-finance/web-lib/utils/web3/transaction'; import type {TNormalizedBN} from '@common/types/types'; -import type { - Order, - OrderCreation, - OrderQuoteResponse, - SigningResult, - SigningScheme, - UnsignedOrder -} from '@cowprotocol/cow-sdk'; +import type {Order, OrderCreation, OrderQuoteResponse, SigningResult, SigningScheme, UnsignedOrder} from '@cowprotocol/cow-sdk'; import type {TInitSolverArgs, TSolverContext} from '@vaults/types/solvers'; const orderBookApi = new OrderBookApi({chainId: 1}); -async function getQuote( - request: TInitSolverArgs -): Promise<{data: OrderQuoteResponse | undefined; error: Error | undefined}> { +async function getQuote(request: TInitSolverArgs): Promise<{data: OrderQuoteResponse | undefined; error: Error | undefined}> { const YEARN_APP_DATA = '0x5d22bf49b708de1d2d9547a6cca9faccbdc2b162012e8573811c07103b163d4b'; const quoteRequest = { from: request.from, // receiver @@ -94,10 +85,7 @@ export function useSolverCowswap(): TSolverContext { } const {quote} = currentQuote; const buyAmount = Number(ethers.utils.formatUnits(quote.buyAmount, decimals)); - const withSlippage = ethers.utils.parseUnits( - (buyAmount * (1 - Number(zapSlippage / 100))).toFixed(decimals), - decimals - ); + const withSlippage = ethers.utils.parseUnits((buyAmount * (1 - Number(zapSlippage / 100))).toFixed(decimals), decimals); return withSlippage.toString(); }, [zapSlippage] @@ -205,10 +193,7 @@ export function useSolverCowswap(): TSolverContext { ** boolean value indicating whether the order was successful or not. ** It will timeout once the order is no longer valid or after 50 minutes (max should be 30mn) **********************************************************************************************/ - async function checkOrderStatus( - orderUID: string, - validTo: number - ): Promise<{isSuccessful: boolean; error?: Error}> { + async function checkOrderStatus(orderUID: string, validTo: number): Promise<{isSuccessful: boolean; error?: Error}> { for (let i = 0; i < maxIterations; i++) { const {data: order} = await axios.get(`https://api.cow.fi/mainnet/api/v1/orders/${orderUID}`); if (order?.status === 'fulfilled') { @@ -249,10 +234,7 @@ export function useSolverCowswap(): TSolverContext { assert(request?.current, 'No request available'); const {quote, from, id} = latestQuote.current; - const buyAmountWithSlippage = getBuyAmountWithSlippage( - latestQuote.current, - request.current.outputToken.decimals - ); + const buyAmountWithSlippage = getBuyAmountWithSlippage(latestQuote.current, request.current.outputToken.decimals); quote.buyAmount = buyAmountWithSlippage; const {signature, signingScheme} = await signCowswapOrder(quote as Order); const orderCreation: OrderCreation = { @@ -288,10 +270,7 @@ export function useSolverCowswap(): TSolverContext { if (!latestQuote?.current?.quote?.buyAmount || isDisabled) { return toNormalizedBN(0); } - return toNormalizedBN( - toBigInt(latestQuote?.current?.quote?.buyAmount), - request?.current?.outputToken?.decimals || 18 - ); + return toNormalizedBN(toBigInt(latestQuote?.current?.quote?.buyAmount), request?.current?.outputToken?.decimals || 18); }, [latestQuote, isDisabled]); /* 🔵 - Yearn Finance ****************************************************** @@ -304,17 +283,9 @@ export function useSolverCowswap(): TSolverContext { return toNormalizedBN(0); } assert(request.current, 'Request is not defined'); - assert( - request?.current?.inputToken?.solveVia?.includes(Solver.enum.Cowswap), - 'Input token is not supported by Cowswap' - ); + assert(request?.current?.inputToken?.solveVia?.includes(Solver.enum.Cowswap), 'Input token is not supported by Cowswap'); - const key = allowanceKey( - safeChainID, - request.current.inputToken.value, - request.current.outputToken.value, - request.current.from - ); + const key = allowanceKey(safeChainID, request.current.inputToken.value, request.current.outputToken.value, request.current.from); if (existingAllowances.current[key] && !shouldForceRefetch) { return existingAllowances.current[key]; } @@ -335,19 +306,12 @@ export function useSolverCowswap(): TSolverContext { ** of the token by the Cowswap solver. **************************************************************************/ const onApprove = useCallback( - async ( - amount = MAX_UINT_256, - txStatusSetter: React.Dispatch>, - onSuccess: () => Promise - ): Promise => { + async (amount = MAX_UINT_256, txStatusSetter: React.Dispatch>, onSuccess: () => Promise): Promise => { if (isDisabled) { return; } assert(request.current, 'Request is not defined'); - assert( - request?.current?.inputToken?.solveVia?.includes(Solver.enum.Cowswap), - 'Input token is not supported by Cowswap' - ); + assert(request?.current?.inputToken?.solveVia?.includes(Solver.enum.Cowswap), 'Input token is not supported by Cowswap'); const isApproved = await isApprovedERC20( provider, @@ -378,10 +342,7 @@ export function useSolverCowswap(): TSolverContext { ** simply swapping the input token for the output token. **************************************************************************/ const onExecute = useCallback( - async ( - txStatusSetter: React.Dispatch>, - onSuccess: () => Promise - ): Promise => { + async (txStatusSetter: React.Dispatch>, onSuccess: () => Promise): Promise => { assert(provider, 'Provider is not defined'); txStatusSetter({...defaultTxStatus, pending: true}); diff --git a/apps/vaults/hooks/useSolverInternalMigration.ts b/apps/vaults/hooks/useSolverInternalMigration.ts index a2a82755b..7d98c9f31 100644 --- a/apps/vaults/hooks/useSolverInternalMigration.ts +++ b/apps/vaults/hooks/useSolverInternalMigration.ts @@ -37,11 +37,7 @@ export function useSolverInternalMigration(): TSolverContext { address: ZAP_YEARN_VE_CRV_ADDRESS, abi: ZAP_CRV_ABI, functionName: 'calc_expected_out', - args: [ - request.current.inputToken.value, - request.current.outputToken.value, - request.current.inputAmount - ] + args: [request.current.inputToken.value, request.current.outputToken.value, request.current.inputAmount] }); const minAmountWithSlippage = estimateOut - (estimateOut * 6n) / 10_000n; latestQuote.current = toNormalizedBN(minAmountWithSlippage); @@ -72,12 +68,7 @@ export function useSolverInternalMigration(): TSolverContext { return toNormalizedBN(0); } - const key = allowanceKey( - safeChainID, - toAddress(request.current.inputToken.value), - toAddress(request.current.outputToken.value), - toAddress(request.current.from) - ); + const key = allowanceKey(safeChainID, toAddress(request.current.inputToken.value), toAddress(request.current.outputToken.value), toAddress(request.current.from)); if (existingAllowances.current[key] && !shouldForceRefetch) { return existingAllowances.current[key]; } @@ -100,11 +91,7 @@ export function useSolverInternalMigration(): TSolverContext { ** (not connected) or if the tx is still pending. **************************************************************************/ const onApprove = useCallback( - async ( - amount = MAX_UINT_256, - txStatusSetter: React.Dispatch>, - onSuccess: () => Promise - ): Promise => { + async (amount = MAX_UINT_256, txStatusSetter: React.Dispatch>, onSuccess: () => Promise): Promise => { assert(request.current, 'Request is not set'); assert(request.current.inputToken, 'Input token is not defined'); assert(request.current.migrator, 'Input token is not defined'); @@ -128,10 +115,7 @@ export function useSolverInternalMigration(): TSolverContext { ** the selected vault. **************************************************************************/ const onExecuteMigration = useCallback( - async ( - txStatusSetter: React.Dispatch>, - onSuccess: () => Promise - ): Promise => { + async (txStatusSetter: React.Dispatch>, onSuccess: () => Promise): Promise => { assert(request.current, 'Request is not set'); if (request.current.migrator === ZAP_YEARN_VE_CRV_ADDRESS) { @@ -139,11 +123,7 @@ export function useSolverInternalMigration(): TSolverContext { address: ZAP_YEARN_VE_CRV_ADDRESS, abi: ZAP_CRV_ABI, functionName: 'calc_expected_out', - args: [ - request.current.inputToken.value, - request.current.outputToken.value, - request.current.inputAmount - ] + args: [request.current.inputToken.value, request.current.outputToken.value, request.current.inputAmount] }); const result = await zapCRV({ connector: provider, diff --git a/apps/vaults/hooks/useSolverOptimismBooster.ts b/apps/vaults/hooks/useSolverOptimismBooster.ts index 3b534f814..cb25cbb4d 100644 --- a/apps/vaults/hooks/useSolverOptimismBooster.ts +++ b/apps/vaults/hooks/useSolverOptimismBooster.ts @@ -55,12 +55,7 @@ export function useSolverOptimismBooster(): TSolverContext { return toNormalizedBN(0); } - const key = allowanceKey( - safeChainID, - toAddress(request.current.inputToken.value), - toAddress(request.current.outputToken.value), - toAddress(request.current.from) - ); + const key = allowanceKey(safeChainID, toAddress(request.current.inputToken.value), toAddress(request.current.outputToken.value), toAddress(request.current.from)); if (existingAllowances.current[key] && !shouldForceRefetch) { return existingAllowances.current[key]; } @@ -82,11 +77,7 @@ export function useSolverOptimismBooster(): TSolverContext { ** (not connected) or if the tx is still pending. **************************************************************************/ const onApprove = useCallback( - async ( - amount = MAX_UINT_256, - txStatusSetter: React.Dispatch>, - onSuccess: () => Promise - ): Promise => { + async (amount = MAX_UINT_256, txStatusSetter: React.Dispatch>, onSuccess: () => Promise): Promise => { assert(request.current, 'Request is not set'); assert(request.current.inputToken, 'Input token is not set'); @@ -109,10 +100,7 @@ export function useSolverOptimismBooster(): TSolverContext { ** tokens via the Staking Rewards Zap Contract, to the selected vault. **************************************************************************/ const onExecuteDeposit = useCallback( - async ( - txStatusSetter: React.Dispatch>, - onSuccess: () => Promise - ): Promise => { + async (txStatusSetter: React.Dispatch>, onSuccess: () => Promise): Promise => { assert(request.current, 'Request is not set'); assert(request.current.inputAmount, 'Input amount is not set'); diff --git a/apps/vaults/hooks/useSolverPartnerContract.ts b/apps/vaults/hooks/useSolverPartnerContract.ts index 2946f64a3..14856dc19 100644 --- a/apps/vaults/hooks/useSolverPartnerContract.ts +++ b/apps/vaults/hooks/useSolverPartnerContract.ts @@ -57,12 +57,7 @@ export function useSolverPartnerContract(): TSolverContext { return toNormalizedBN(0); } - const key = allowanceKey( - safeChainID, - toAddress(request.current.inputToken.value), - toAddress(request.current.outputToken.value), - toAddress(request.current.from) - ); + const key = allowanceKey(safeChainID, toAddress(request.current.inputToken.value), toAddress(request.current.outputToken.value), toAddress(request.current.from)); if (existingAllowances.current[key] && !shouldForceRefetch) { return existingAllowances.current[key]; } @@ -86,11 +81,7 @@ export function useSolverPartnerContract(): TSolverContext { ** (not connected) or if the tx is still pending. **************************************************************************/ const onApprove = useCallback( - async ( - amount = MAX_UINT_256, - txStatusSetter: React.Dispatch>, - onSuccess: () => Promise - ): Promise => { + async (amount = MAX_UINT_256, txStatusSetter: React.Dispatch>, onSuccess: () => Promise): Promise => { const partnerContract = getNetwork(safeChainID)?.contracts?.partnerContract?.address; assert(request.current, 'Request is not set'); @@ -116,10 +107,7 @@ export function useSolverPartnerContract(): TSolverContext { ** via the Partner Contract, to the selected vault. **************************************************************************/ const onExecuteDeposit = useCallback( - async ( - txStatusSetter: React.Dispatch>, - onSuccess: () => Promise - ): Promise => { + async (txStatusSetter: React.Dispatch>, onSuccess: () => Promise): Promise => { const partnerContract = getNetwork(safeChainID)?.contracts?.partnerContract?.address; assert(request.current, 'Request is not set'); @@ -145,10 +133,7 @@ export function useSolverPartnerContract(): TSolverContext { ** some underlying token from this specific vault. **************************************************************************/ const onExecuteWithdraw = useCallback( - async ( - txStatusSetter: React.Dispatch>, - onSuccess: () => Promise - ): Promise => { + async (txStatusSetter: React.Dispatch>, onSuccess: () => Promise): Promise => { assert(request.current, 'Request is not set'); assert(request.current.inputToken, 'Input token is not set'); assert(request.current.inputAmount, 'Input amount is not set'); diff --git a/apps/vaults/hooks/useSolverPortals.ts b/apps/vaults/hooks/useSolverPortals.ts index 8eee85b0e..0354c5479 100644 --- a/apps/vaults/hooks/useSolverPortals.ts +++ b/apps/vaults/hooks/useSolverPortals.ts @@ -34,11 +34,7 @@ export type TPortalsQuoteResult = { error?: Error; }; -async function getQuote( - request: TInitSolverArgs, - safeChainID: number, - zapSlippage: number -): Promise<{data: TPortalsEstimate | null; error?: Error}> { +async function getQuote(request: TInitSolverArgs, safeChainID: number, zapSlippage: number): Promise<{data: TPortalsEstimate | null; error?: Error}> { const params = { sellToken: toAddress(request.inputToken.value), sellAmount: toBigInt(request.inputAmount).toString(), @@ -249,12 +245,7 @@ export function useSolverPortals(): TSolverContext { return toNormalizedBN(0); } - const key = allowanceKey( - safeChainID, - toAddress(request.current.inputToken.value), - toAddress(request.current.outputToken.value), - toAddress(request.current.from) - ); + const key = allowanceKey(safeChainID, toAddress(request.current.inputToken.value), toAddress(request.current.outputToken.value), toAddress(request.current.from)); if (existingAllowances.current[key] && !shouldForceRefetch) { return existingAllowances.current[key]; } @@ -274,10 +265,7 @@ export function useSolverPortals(): TSolverContext { throw new Error('Portals approval not found'); } - existingAllowances.current[key] = toNormalizedBN( - approval.context.allowance, - request.current.inputToken.decimals - ); + existingAllowances.current[key] = toNormalizedBN(approval.context.allowance, request.current.inputToken.decimals); return existingAllowances.current[key]; } catch (error) { console.error(error); @@ -293,11 +281,7 @@ export function useSolverPortals(): TSolverContext { ** of the token by the Portals solver. **************************************************************************/ const onApprove = useCallback( - async ( - amount = MAX_UINT_256, - txStatusSetter: React.Dispatch>, - onSuccess: () => Promise - ): Promise => { + async (amount = MAX_UINT_256, txStatusSetter: React.Dispatch>, onSuccess: () => Promise): Promise => { if (isSolverDisabled(safeChainID)[Solver.enum.Portals]) { return; } @@ -355,10 +339,7 @@ export function useSolverPortals(): TSolverContext { ** simply swapping the input token for the output token. **************************************************************************/ const onExecute = useCallback( - async ( - txStatusSetter: React.Dispatch>, - onSuccess: () => Promise - ): Promise => { + async (txStatusSetter: React.Dispatch>, onSuccess: () => Promise): Promise => { assert(provider, 'Provider is not set'); txStatusSetter({...defaultTxStatus, pending: true}); diff --git a/apps/vaults/hooks/useSolverVanilla.ts b/apps/vaults/hooks/useSolverVanilla.ts index 553615bef..d9d13dedf 100644 --- a/apps/vaults/hooks/useSolverVanilla.ts +++ b/apps/vaults/hooks/useSolverVanilla.ts @@ -54,12 +54,7 @@ export function useSolverVanilla(): TSolverContext { return toNormalizedBN(0); } - const key = allowanceKey( - safeChainID, - toAddress(request.current.inputToken.value), - toAddress(request.current.outputToken.value), - toAddress(request.current.from) - ); + const key = allowanceKey(safeChainID, toAddress(request.current.inputToken.value), toAddress(request.current.outputToken.value), toAddress(request.current.from)); if (existingAllowances.current[key] && !shouldForceRefetch) { return existingAllowances.current[key]; } @@ -82,11 +77,7 @@ export function useSolverVanilla(): TSolverContext { ** (not connected) or if the tx is still pending. **************************************************************************/ const onApprove = useCallback( - async ( - amount = MAX_UINT_256, - txStatusSetter: React.Dispatch>, - onSuccess: () => Promise - ): Promise => { + async (amount = MAX_UINT_256, txStatusSetter: React.Dispatch>, onSuccess: () => Promise): Promise => { assert(request.current, 'Request is not set'); assert(request.current.inputToken, 'Input token is not set'); assert(request.current.outputToken, 'Output token is not set'); @@ -110,10 +101,7 @@ export function useSolverVanilla(): TSolverContext { ** the selected vault. **************************************************************************/ const onExecuteDeposit = useCallback( - async ( - txStatusSetter: React.Dispatch>, - onSuccess: () => Promise - ): Promise => { + async (txStatusSetter: React.Dispatch>, onSuccess: () => Promise): Promise => { assert(request.current, 'Request is not set'); assert(request.current.outputToken, 'Output token is not set'); assert(request.current.inputAmount, 'Input amount is not set'); @@ -136,10 +124,7 @@ export function useSolverVanilla(): TSolverContext { ** some underlying token from this specific vault. **************************************************************************/ const onExecuteWithdraw = useCallback( - async ( - txStatusSetter: React.Dispatch>, - onSuccess: () => Promise - ): Promise => { + async (txStatusSetter: React.Dispatch>, onSuccess: () => Promise): Promise => { assert(request.current, 'Request is not set'); assert(request.current.inputToken, 'Output token is not set'); assert(request.current.inputAmount, 'Input amount is not set'); diff --git a/apps/vaults/hooks/useSolverWido.ts b/apps/vaults/hooks/useSolverWido.ts index 596f5a489..b298fe5bf 100644 --- a/apps/vaults/hooks/useSolverWido.ts +++ b/apps/vaults/hooks/useSolverWido.ts @@ -197,12 +197,7 @@ export function useSolverWido(): TSolverContext { return toNormalizedBN(MAX_UINT_256); } - const key = allowanceKey( - safeChainID, - toAddress(request.current.inputToken.value), - toAddress(request.current.outputToken.value), - toAddress(request.current.from) - ); + const key = allowanceKey(safeChainID, toAddress(request.current.inputToken.value), toAddress(request.current.outputToken.value), toAddress(request.current.from)); if (existingAllowances.current[key] && !shouldForceRefetch) { return existingAllowances.current[key]; @@ -241,11 +236,7 @@ export function useSolverWido(): TSolverContext { ** of the token by the Wido solver. **************************************************************************/ const onApprove = useCallback( - async ( - amount = MAX_UINT_256, - txStatusSetter: React.Dispatch>, - onSuccess: () => Promise - ): Promise => { + async (amount = MAX_UINT_256, txStatusSetter: React.Dispatch>, onSuccess: () => Promise): Promise => { if (isSolverDisabled(safeChainID)[Solver.enum.Wido]) { return; } @@ -292,10 +283,7 @@ export function useSolverWido(): TSolverContext { ** simply swapping the input token for the output token. **************************************************************************/ const onExecute = useCallback( - async ( - txStatusSetter: React.Dispatch>, - onSuccess: () => Promise - ): Promise => { + async (txStatusSetter: React.Dispatch>, onSuccess: () => Promise): Promise => { assert(provider, 'Provider is not set'); txStatusSetter({...defaultTxStatus, pending: true}); diff --git a/apps/vaults/hooks/useSortVaults.ts b/apps/vaults/hooks/useSortVaults.ts index 9c3cdf75a..f6d4812b6 100644 --- a/apps/vaults/hooks/useSortVaults.ts +++ b/apps/vaults/hooks/useSortVaults.ts @@ -13,11 +13,7 @@ import type {TSortDirection} from '@common/types/types'; export type TPossibleSortBy = 'apy' | 'tvl' | 'name' | 'deposited' | 'available'; -export function useSortVaults( - vaultList: TYDaemonVaults, - sortBy: TPossibleSortBy, - sortDirection: TSortDirection -): TYDaemonVaults { +export function useSortVaults(vaultList: TYDaemonVaults, sortBy: TPossibleSortBy, sortDirection: TSortDirection): TYDaemonVaults { const {balances, balancesNonce} = useWallet(); const {stakingRewardsByVault, positionsMap} = useStakingRewards(); @@ -45,24 +41,15 @@ export function useSortVaults( [sortDirection, vaultList] ); - const sortedByTVL = useCallback( - (): TYDaemonVaults => vaultList.sort((a, b): number => numberSort({a: a.tvl.tvl, b: b.tvl.tvl, sortDirection})), - [sortDirection, vaultList] - ); + const sortedByTVL = useCallback((): TYDaemonVaults => vaultList.sort((a, b): number => numberSort({a: a.tvl.tvl, b: b.tvl.tvl, sortDirection})), [sortDirection, vaultList]); const sortedByDeposited = useCallback((): TYDaemonVaults => { balancesNonce; // remove warning, force deep refresh return vaultList.sort((a, b): number => { const aDepositedBalance = balances[toAddress(a.address)]?.normalized || 0; const bDepositedBalance = balances[toAddress(b.address)]?.normalized || 0; - const aStakedBalance = toNormalizedValue( - toBigInt(positionsMap[toAddress(stakingRewardsByVault[a.address])]?.stake), - a.decimals - ); - const bStakedBalance = toNormalizedValue( - toBigInt(positionsMap[toAddress(stakingRewardsByVault[b.address])]?.stake), - b.decimals - ); + const aStakedBalance = toNormalizedValue(toBigInt(positionsMap[toAddress(stakingRewardsByVault[a.address])]?.stake), a.decimals); + const bStakedBalance = toNormalizedValue(toBigInt(positionsMap[toAddress(stakingRewardsByVault[b.address])]?.stake), b.decimals); if (sortDirection === 'asc') { return aDepositedBalance + aStakedBalance - (bDepositedBalance + bStakedBalance); } @@ -112,16 +99,7 @@ export function useSortVaults( } return sortResult; - }, [ - sortBy, - sortDirection, - sortedByAPY, - sortedByAvailable, - sortedByDeposited, - sortedByName, - sortedByTVL, - stringifiedVaultList - ]); + }, [sortBy, sortDirection, sortedByAPY, sortedByAvailable, sortedByDeposited, sortedByName, sortedByTVL, stringifiedVaultList]); return sortedVaults; } diff --git a/apps/vaults/types/solvers.ts b/apps/vaults/types/solvers.ts index 2038b6469..cc76c052e 100644 --- a/apps/vaults/types/solvers.ts +++ b/apps/vaults/types/solvers.ts @@ -14,19 +14,9 @@ export type TWithSolver = { hash?: string; isLoadingExpectedOut: boolean; onRetrieveAllowance: (shouldForceRefetch?: boolean) => Promise; - onApprove: ( - amount: bigint, - txStatusSetter: React.Dispatch>, - onSuccess: () => Promise - ) => Promise; - onExecuteDeposit: ( - txStatusSetter: React.Dispatch>, - onSuccess: () => Promise - ) => Promise; - onExecuteWithdraw: ( - txStatusSetter: React.Dispatch>, - onSuccess: () => Promise - ) => Promise; + onApprove: (amount: bigint, txStatusSetter: React.Dispatch>, onSuccess: () => Promise) => Promise; + onExecuteDeposit: (txStatusSetter: React.Dispatch>, onSuccess: () => Promise) => Promise; + onExecuteWithdraw: (txStatusSetter: React.Dispatch>, onSuccess: () => Promise) => Promise; }; export type TInitSolverArgs = { @@ -43,19 +33,9 @@ export type TSolverContext = { quote: TNormalizedBN; init: (args: TInitSolverArgs, shouldLogError?: boolean) => Promise; onRetrieveAllowance: (shouldForceRefetch?: boolean) => Promise; - onApprove: ( - amount: bigint, - txStatusSetter: React.Dispatch>, - onSuccess: () => Promise - ) => Promise; - onExecuteDeposit: ( - txStatusSetter: React.Dispatch>, - onSuccess: () => Promise - ) => Promise; - onExecuteWithdraw: ( - txStatusSetter: React.Dispatch>, - onSuccess: () => Promise - ) => Promise; + onApprove: (amount: bigint, txStatusSetter: React.Dispatch>, onSuccess: () => Promise) => Promise; + onExecuteDeposit: (txStatusSetter: React.Dispatch>, onSuccess: () => Promise) => Promise; + onExecuteWithdraw: (txStatusSetter: React.Dispatch>, onSuccess: () => Promise) => Promise; }; /* 🔵 - Yearn Finance ****************************************************** diff --git a/apps/vaults/utils/zapOptions.tsx b/apps/vaults/utils/zapOptions.tsx index c5c3f87a0..dbb03ae8a 100644 --- a/apps/vaults/utils/zapOptions.tsx +++ b/apps/vaults/utils/zapOptions.tsx @@ -12,27 +12,13 @@ type TSetZapOptionProps = { decimals: number; solveVia?: TSolver[]; }; -export function setZapOption({ - name, - symbol, - address, - chainID, - decimals, - solveVia -}: TSetZapOptionProps): TDropdownOption { +export function setZapOption({name, symbol, address, chainID, decimals, solveVia}: TSetZapOptionProps): TDropdownOption { return { label: name, symbol, value: address, decimals, solveVia, - icon: ( - - ) + icon: }; } diff --git a/apps/veyfi/Wrapper.tsx b/apps/veyfi/Wrapper.tsx index fef2f6464..41224a63f 100644 --- a/apps/veyfi/Wrapper.tsx +++ b/apps/veyfi/Wrapper.tsx @@ -20,13 +20,7 @@ export function Wrapper({children, router}: {children: ReactElement; router: Nex - + {children} diff --git a/apps/veyfi/components/ClaimTab.tsx b/apps/veyfi/components/ClaimTab.tsx index d789b3bb8..89cd36eaf 100644 --- a/apps/veyfi/components/ClaimTab.tsx +++ b/apps/veyfi/components/ClaimTab.tsx @@ -62,14 +62,7 @@ export function ClaimTab(): ReactElement { className={'w-full md:mt-7'} onClick={onWithdrawUnlocked} isBusy={withdrawUnlockedStatus.pending} - isDisabled={ - !isActive || - !isValidNetwork || - !isClaimable || - withdrawUnlockedStatus.pending || - !votingEscrow || - !address - }> + isDisabled={!isActive || !isValidNetwork || !isClaimable || withdrawUnlockedStatus.pending || !votingEscrow || !address}> {'Claim'}
diff --git a/apps/veyfi/components/GaugesTab.tsx b/apps/veyfi/components/GaugesTab.tsx index 018518daa..5dba6c50d 100644 --- a/apps/veyfi/components/GaugesTab.tsx +++ b/apps/veyfi/components/GaugesTab.tsx @@ -37,14 +37,7 @@ export function GaugesTab(): ReactElement { const [selectedGauge, set_selectedGauge] = useState(''); const [selectedAction, set_selectedAction] = useState<'stake' | 'unstake' | undefined>(); const {provider, address, isActive, chainID} = useWeb3(); - const { - gaugeAddresses, - gaugesMap, - positionsMap, - allowancesMap, - refresh: refreshGauges, - isLoading: isLoadingGauges - } = useGauge(); + const {gaugeAddresses, gaugesMap, positionsMap, allowancesMap, refresh: refreshGauges, isLoading: isLoadingGauges} = useGauge(); const {vaults} = useYearn(); const {balances, refresh: refreshBalances} = useWallet(); const refreshData = (): unknown => Promise.all([refreshGauges(), refreshBalances()]); @@ -70,9 +63,7 @@ export function GaugesTab(): ReactElement { gaugeApy: 0, // TODO: gauge apy calcs gaugeBoost: positionsMap[address]?.boost ?? 1, gaugeStaked: toBigInt(formatBigNumberAsAmount(positionsMap[address]?.deposit.balance)), - allowance: toBigInt( - formatBigNumberAsAmount(allowancesMap[allowanceKey(1, vaultAddress, address, userAddress)]) - ), + allowance: toBigInt(formatBigNumberAsAmount(allowancesMap[allowanceKey(1, vaultAddress, address, userAddress)])), isApproved: toBigInt(formatBigNumberAsAmount(allowancesMap[allowanceKey(1, vaultAddress, address, userAddress)])) >= toBigInt(formatBigNumberAsAmount(balances[vaultAddress]?.raw)), @@ -156,18 +147,8 @@ export function GaugesTab(): ReactElement { className: 'my-4 md:my-0', transform: ({vaultIcon, vaultName}): ReactElement => (
-
- +
+

{vaultName}

@@ -183,8 +164,7 @@ export function GaugesTab(): ReactElement { key: 'vaultDeposited', label: 'Deposited in Vault', sortable: true, - format: ({vaultDeposited, decimals}): string => - formatAmount(toNormalizedValue(vaultDeposited, decimals)) + format: ({vaultDeposited, decimals}): string => formatAmount(toNormalizedValue(vaultDeposited, decimals)) }, { key: 'gaugeApy', @@ -201,8 +181,7 @@ export function GaugesTab(): ReactElement { key: 'gaugeStaked', label: 'Staked in Gauge', sortable: true, - format: ({gaugeStaked, decimals}): string => - formatAmount(toNormalizedValue(gaugeStaked, decimals)) + format: ({gaugeStaked, decimals}): string => formatAmount(toNormalizedValue(gaugeStaked, decimals)) }, { key: 'actions', @@ -210,37 +189,22 @@ export function GaugesTab(): ReactElement { columnSpan: 2, fullWidth: true, className: 'my-4 md:my-0', - transform: ({ - isApproved, - vaultAddress, - gaugeAddress, - vaultDeposited, - gaugeStaked - }): ReactElement => ( + transform: ({isApproved, vaultAddress, gaugeAddress, vaultDeposited, gaugeStaked}): ReactElement => (
{!isApproved && ( @@ -250,12 +214,7 @@ export function GaugesTab(): ReactElement { className={'w-full md:w-24'} onClick={async (): Promise => onStake(gaugeAddress, vaultDeposited)} isDisabled={!isActive || !isValidNetwork || isZero(vaultDeposited)} - isBusy={ - (isLoadingGauges && vaultDeposited > 0n) || - (gaugeAddress === selectedGauge && - selectedAction === 'stake' && - stakeStatus.none) - }> + isBusy={(isLoadingGauges && vaultDeposited > 0n) || (gaugeAddress === selectedGauge && selectedAction === 'stake' && stakeStatus.none)}> {'Stake'} )} diff --git a/apps/veyfi/components/LockTab.tsx b/apps/veyfi/components/LockTab.tsx index 540e1ff5d..0865e1476 100644 --- a/apps/veyfi/components/LockTab.tsx +++ b/apps/veyfi/components/LockTab.tsx @@ -29,13 +29,7 @@ export function LockTab(): ReactElement { const {provider, address, isActive} = useWeb3(); const {safeChainID} = useChainID(); const {refresh: refreshBalances} = useWallet(); - const { - votingEscrow, - positions, - allowances, - isLoading: isLoadingVotingEscrow, - refresh: refreshVotingEscrow - } = useVotingEscrow(); + const {votingEscrow, positions, allowances, isLoading: isLoadingVotingEscrow, refresh: refreshVotingEscrow} = useVotingEscrow(); const tokenBalance = useBalance(toAddress(votingEscrow?.token)); const hasLockedAmount = toBigInt(positions?.deposit?.underlyingBalance) > 0n; const [approveLockStatus, set_approveLockStatus] = useState(defaultTxStatus); @@ -129,17 +123,8 @@ export function LockTab(): ReactElement { walletNetwork: safeChainID }); - const isApproveDisabled = - !isActive || !isValidNetwork || isApproved || isLoadingVotingEscrow || !votingEscrow || !address; - const isLockDisabled = - !isActive || - !isValidNetwork || - !isApproved || - !isValidLockAmount || - !isValidLockTime || - isLoadingVotingEscrow || - !votingEscrow || - !address; + const isApproveDisabled = !isActive || !isValidNetwork || isApproved || isLoadingVotingEscrow || !votingEscrow || !address; + const isLockDisabled = !isActive || !isValidNetwork || !isApproved || !isValidLockAmount || !isValidLockTime || isLoadingVotingEscrow || !votingEscrow || !address; const txAction = !isApproved ? { label: 'Approve', @@ -168,11 +153,7 @@ export function LockTab(): ReactElement {

{'Lock your YFI for veYFI to take part in Yearn governance.'}


-

- { - 'Please note, governance is currently the only use for veYFI until the full platform launches ‘soon’. Stay tuned anon.' - } -

+

{'Please note, governance is currently the only use for veYFI until the full platform launches ‘soon’. Stay tuned anon.'}

@@ -201,11 +182,7 @@ export function LockTab(): ReactElement {
-
diff --git a/apps/veyfi/components/ManageLockTab.tsx b/apps/veyfi/components/ManageLockTab.tsx index 424329a52..f08a398a6 100644 --- a/apps/veyfi/components/ManageLockTab.tsx +++ b/apps/veyfi/components/ManageLockTab.tsx @@ -62,9 +62,7 @@ export function ManageLockTab(): ReactElement { if (!positions?.deposit || !newUnlockTime) { return 0n; } - return willExtendLock - ? getVotingPower(positions?.deposit?.underlyingBalance, newUnlockTime) - : toBigInt(positions?.deposit?.balance); + return willExtendLock ? getVotingPower(positions?.deposit?.underlyingBalance, newUnlockTime) : toBigInt(positions?.deposit?.balance); }, [positions?.deposit, newUnlockTime, willExtendLock]); const {isValid: isValidLockTime, error: lockTimeError} = validateAmount({ @@ -93,13 +91,7 @@ export function ManageLockTab(): ReactElement { amount={lockTime} onAmountChange={(amount): void => set_lockTime(Math.floor(toTime(amount)).toString())} maxAmount={MAX_LOCK_TIME - weeksToUnlock > 0 ? MAX_LOCK_TIME - weeksToUnlock : 0} - onMaxClick={(): void => - set_lockTime( - Math.floor( - toTime(MAX_LOCK_TIME - weeksToUnlock > 0 ? MAX_LOCK_TIME - weeksToUnlock : 0) - ).toString() - ) - } + onMaxClick={(): void => set_lockTime(Math.floor(toTime(MAX_LOCK_TIME - weeksToUnlock > 0 ? MAX_LOCK_TIME - weeksToUnlock : 0)).toString())} disabled={!hasLockedAmount} error={lockTimeError} legend={'Minimum: 1 week'} @@ -111,14 +103,7 @@ export function ManageLockTab(): ReactElement { className={'w-full md:mt-7'} onClick={onExtendLockTime} isBusy={extendLockTimeStatus.pending} - isDisabled={ - !isActive || - !isValidNetwork || - !isValidLockTime || - extendLockTimeStatus.pending || - !votingEscrow || - !address - }> + isDisabled={!isActive || !isValidNetwork || !isValidLockTime || extendLockTimeStatus.pending || !votingEscrow || !address}> {'Extend'}
@@ -132,11 +117,7 @@ export function ManageLockTab(): ReactElement {
- +
@@ -150,14 +131,7 @@ export function ManageLockTab(): ReactElement { className={'w-full md:mt-7'} onClick={onWithdrawLocked} isBusy={withdrawLockedStatus.pending} - isDisabled={ - !isActive || - !isValidNetwork || - !hasPenalty || - withdrawLockedStatus.pending || - !votingEscrow || - !address - }> + isDisabled={!isActive || !isValidNetwork || !hasPenalty || withdrawLockedStatus.pending || !votingEscrow || !address}> {'Exit'}
diff --git a/apps/veyfi/components/RedeemTab.tsx b/apps/veyfi/components/RedeemTab.tsx index b4c70d4df..8133b4c63 100644 --- a/apps/veyfi/components/RedeemTab.tsx +++ b/apps/veyfi/components/RedeemTab.tsx @@ -9,11 +9,7 @@ import {useWeb3} from '@yearn-finance/web-lib/contexts/useWeb3'; import {useChainID} from '@yearn-finance/web-lib/hooks/useChainID'; import {toAddress} from '@yearn-finance/web-lib/utils/address'; import {BIG_ZERO, ETH_TOKEN_ADDRESS, YFI_ADDRESS} from '@yearn-finance/web-lib/utils/constants'; -import { - formatBigNumberAsAmount, - toNormalizedBN, - toNormalizedValue -} from '@yearn-finance/web-lib/utils/format.bigNumber'; +import {formatBigNumberAsAmount, toNormalizedBN, toNormalizedValue} from '@yearn-finance/web-lib/utils/format.bigNumber'; import {formatCounterValue} from '@yearn-finance/web-lib/utils/format.value'; import {handleInputChangeEventValue} from '@yearn-finance/web-lib/utils/handlers/handleInputChangeEventValue'; import {defaultTxStatus} from '@yearn-finance/web-lib/utils/web3/transaction'; @@ -31,19 +27,9 @@ export function RedeemTab(): ReactElement { const {provider, address, isActive} = useWeb3(); const {safeChainID} = useChainID(); const {refresh: refreshBalances} = useWallet(); - const { - getRequiredEth, - price: optionPrice, - positions, - allowances, - isLoading: isLoadingOption, - refresh - } = useOption(); + const {getRequiredEth, price: optionPrice, positions, allowances, isLoading: isLoadingOption, refresh} = useOption(); const clearLockAmount = (): void => set_redeemAmount(toNormalizedBN(0)); - const refreshData = useCallback( - (): unknown => Promise.all([refresh(), refreshBalances()]), - [refresh, refreshBalances] - ); + const refreshData = useCallback((): unknown => Promise.all([refresh(), refreshBalances()]), [refresh, refreshBalances]); const onTxSuccess = useCallback((): unknown => Promise.all([refreshData(), clearLockAmount()]), [refreshData]); const [{status, result}, fetchRequiredEth] = useAsync(getRequiredEth, BIG_ZERO); const ethBalance = useBalance(ETH_TOKEN_ADDRESS); @@ -111,12 +97,7 @@ export function RedeemTab(): ReactElement {
- + => (isApproved ? handleRedeem() : handleApproveRedeem())} - isBusy={ - isLoadingOption || - approveRedeemStatus.pending || - redeemStatus.pending || - status === 'loading' - } + isBusy={isLoadingOption || approveRedeemStatus.pending || redeemStatus.pending || status === 'loading'} isDisabled={ - !isActive || - !isValidNetwork || - !isValidRedeemAmount || - status === 'loading' || - status === 'error' || - !redeemStatus.none || - !approveRedeemStatus.none + !isActive || !isValidNetwork || !isValidRedeemAmount || status === 'loading' || status === 'error' || !redeemStatus.none || !approveRedeemStatus.none }> {isApproved ? 'Redeem' : 'Approve'} diff --git a/apps/veyfi/components/RewardsTab.tsx b/apps/veyfi/components/RewardsTab.tsx index c33ad03b0..3f4dafe43 100644 --- a/apps/veyfi/components/RewardsTab.tsx +++ b/apps/veyfi/components/RewardsTab.tsx @@ -110,12 +110,7 @@ export function RewardsTab(): ReactElement {
- +

{'Vote to direct future YFI rewards to a particular gauge.'}


-

- { - 'If you prefer your democracy on the representative side, you can delegate your vote to another address.' - } -

+

{'If you prefer your democracy on the representative side, you can delegate your vote to another address.'}

@@ -62,20 +58,12 @@ export function VoteTab(): ReactElement {
- +
diff --git a/apps/veyfi/contexts/useGauge.tsx b/apps/veyfi/contexts/useGauge.tsx index 1f65f4bb2..6a67f4b52 100644 --- a/apps/veyfi/contexts/useGauge.tsx +++ b/apps/veyfi/contexts/useGauge.tsx @@ -107,13 +107,7 @@ export const GaugeContextApp = memo(function GaugeContextApp({children}: {childr chainId: 1 }); - const [asset, name, symbol, decimals, totalAssets] = results.map(({result}): unknown => result) as [ - TAddress, - string, - string, - number, - bigint - ]; + const [asset, name, symbol, decimals, totalAssets] = results.map(({result}): unknown => result) as [TAddress, string, string, number, bigint]; return { address, @@ -127,28 +121,21 @@ export const GaugeContextApp = memo(function GaugeContextApp({children}: {childr return Promise.all(gaugePromises); }, []); - const [{result: allowancesMap, status: fetchAllowancesMapStatus}, {execute: refreshAllowances}] = useAsync( - async (): Promise | undefined> => { - if (!gauges || !isActive) { - return; - } - return allowancesFetcher(); - }, - {} - ); + const [{result: allowancesMap, status: fetchAllowancesMapStatus}, {execute: refreshAllowances}] = useAsync(async (): Promise | undefined> => { + if (!gauges || !isActive) { + return; + } + return allowancesFetcher(); + }, {}); - const [{result: positions, status: fetchPositionsStatus}, {execute: refreshPositions}] = useAsync(async (): Promise< - TGaugePosition[] | undefined - > => { + const [{result: positions, status: fetchPositionsStatus}, {execute: refreshPositions}] = useAsync(async (): Promise => { if (!gauges || !isActive) { return; } return positionsFetcher(); }, []); - const [{result: gauges, status: fetchGaugesStatus}, {execute: refreshVotingEscrow}] = useAsync(async (): Promise< - TGauge[] | undefined - > => { + const [{result: gauges, status: fetchGaugesStatus}, {execute: refreshVotingEscrow}] = useAsync(async (): Promise => { if (!isActive) { return; } @@ -204,10 +191,7 @@ export const GaugeContextApp = memo(function GaugeContextApp({children}: {childr underlyingBalance: earned // TODO: convert to underlying }; - const boostRatio = - balance > 0n - ? FixedNumber.from(boostedBalance).divUnsafe(FixedNumber.from(balance)).toUnsafeFloat() - : 0.1; + const boostRatio = balance > 0n ? FixedNumber.from(boostedBalance).divUnsafe(FixedNumber.from(balance)).toUnsafeFloat() : 0.1; const boost = Math.min(1, boostRatio) * 10; return { @@ -259,10 +243,7 @@ export const GaugeContextApp = memo(function GaugeContextApp({children}: {childr gaugesMap: keyBy(gauges ?? [], 'address'), positionsMap: keyBy(positions ?? [], 'address'), allowancesMap: allowancesMap ?? {}, - isLoading: - fetchGaugesStatus === 'loading' || - fetchPositionsStatus === 'loading' || - fetchAllowancesMapStatus === 'loading', + isLoading: fetchGaugesStatus === 'loading' || fetchPositionsStatus === 'loading' || fetchAllowancesMapStatus === 'loading', refresh }), [allowancesMap, fetchAllowancesMapStatus, fetchGaugesStatus, fetchPositionsStatus, gauges, positions, refresh] diff --git a/apps/veyfi/contexts/useOption.tsx b/apps/veyfi/contexts/useOption.tsx index d8b3a10e9..6df11c805 100644 --- a/apps/veyfi/contexts/useOption.tsx +++ b/apps/veyfi/contexts/useOption.tsx @@ -42,15 +42,12 @@ export const OptionContextApp = memo(function OptionContextApp({children}: {chil const yfiPrice = useTokenPrice(YFI_ADDRESS); const ethPrice = useTokenPrice(ETH_TOKEN_ADDRESS); - const [{result: price, status: fetchPriceStatus}, {execute: refreshPrice}] = useAsync( - async (): Promise => { - if (!isActive || provider) { - return; - } - return priceFetcher(); - }, - 0 - ); + const [{result: price, status: fetchPriceStatus}, {execute: refreshPrice}] = useAsync(async (): Promise => { + if (!isActive || provider) { + return; + } + return priceFetcher(); + }, 0); const [{result: positions, status: fetchPositionsStatus}, {execute: refreshPositions}] = useAsync( async (): Promise => { @@ -62,15 +59,12 @@ export const OptionContextApp = memo(function OptionContextApp({children}: {chil {balance: 0n} ); - const [{result: allowances, status: fetchAllowancesStatus}, {execute: refreshAllowances}] = useAsync( - async (): Promise | undefined> => { - if (!isActive || provider) { - return; - } - return allowancesFetcher(); - }, - {} - ); + const [{result: allowances, status: fetchAllowancesStatus}, {execute: refreshAllowances}] = useAsync(async (): Promise | undefined> => { + if (!isActive || provider) { + return; + } + return allowancesFetcher(); + }, {}); const refresh = useCallback((): void => { refreshPrice(); @@ -145,22 +139,10 @@ export const OptionContextApp = memo(function OptionContextApp({children}: {chil price, positions, allowances: allowances ?? {}, - isLoading: - fetchPriceStatus === 'loading' || - fetchPositionsStatus === 'loading' || - fetchAllowancesStatus === 'loading', + isLoading: fetchPriceStatus === 'loading' || fetchPositionsStatus === 'loading' || fetchAllowancesStatus === 'loading', refresh }), - [ - allowances, - fetchAllowancesStatus, - fetchPositionsStatus, - fetchPriceStatus, - getRequiredEth, - positions, - price, - refresh - ] + [allowances, fetchAllowancesStatus, fetchPositionsStatus, fetchPriceStatus, getRequiredEth, positions, price, refresh] ); return {children}; diff --git a/apps/veyfi/contexts/useVotingEscrow.tsx b/apps/veyfi/contexts/useVotingEscrow.tsx index 00ff104d1..902a8bd8b 100644 --- a/apps/veyfi/contexts/useVotingEscrow.tsx +++ b/apps/veyfi/contexts/useVotingEscrow.tsx @@ -51,11 +51,7 @@ const defaultProps: TVotingEscrowContext = { }; const VotingEscrowContext = createContext(defaultProps); -export const VotingEscrowContextApp = memo(function VotingEscrowContextApp({ - children -}: { - children: ReactElement; -}): ReactElement { +export const VotingEscrowContextApp = memo(function VotingEscrowContextApp({children}: {children: ReactElement}): ReactElement { const {address, isActive} = useWeb3(); /* 🔵 - Yearn Finance ********************************************************** @@ -163,8 +159,7 @@ export const VotingEscrowContextApp = memo(function VotingEscrowContextApp({ votingEscrow, positions, allowances: allowances ?? {}, - isLoading: - votingEscrowStatus === 'loading' && positionStatus === 'loading' && allowanceStatus === 'loading', + isLoading: votingEscrowStatus === 'loading' && positionStatus === 'loading' && allowanceStatus === 'loading', refresh }), [votingEscrow, positions, allowances, votingEscrowStatus, positionStatus, allowanceStatus, refresh] diff --git a/apps/veyfi/utils/abi/veYFIClaimRewardsZap.abi.ts b/apps/veyfi/utils/abi/veYFIClaimRewardsZap.abi.ts index 5872c99d0..f0f823276 100644 --- a/apps/veyfi/utils/abi/veYFIClaimRewardsZap.abi.ts +++ b/apps/veyfi/utils/abi/veYFIClaimRewardsZap.abi.ts @@ -1,4 +1,2 @@ // TODO: update once final version deployed -export const VEYFI_CLAIM_REWARDS_ZAP_ABI = [ - 'function claim(address[] calldata _gauges, bool _lock, bool _claimVeYfi) external' -]; +export const VEYFI_CLAIM_REWARDS_ZAP_ABI = ['function claim(address[] calldata _gauges, bool _lock, bool _claimVeYfi) external']; diff --git a/apps/veyfi/utils/index.ts b/apps/veyfi/utils/index.ts index 68080c7e0..65e4d2c1f 100644 --- a/apps/veyfi/utils/index.ts +++ b/apps/veyfi/utils/index.ts @@ -32,9 +32,7 @@ export const sort = (data: T[], by: Extract, order?: 'asc' | return order === 'desc' ? Number(elementA) - Number(elementB) : Number(elementB) - Number(elementA); } if (isString(elementA) && isString(elementB)) { - return order === 'desc' - ? elementA.toLowerCase().localeCompare(elementB.toLowerCase()) - : elementB.toLowerCase().localeCompare(elementA.toLowerCase()); + return order === 'desc' ? elementA.toLowerCase().localeCompare(elementB.toLowerCase()) : elementB.toLowerCase().localeCompare(elementA.toLowerCase()); } return 0; }; diff --git a/apps/veyfi/utils/validations.ts b/apps/veyfi/utils/validations.ts index c553d0148..abc1ac444 100644 --- a/apps/veyfi/utils/validations.ts +++ b/apps/veyfi/utils/validations.ts @@ -60,9 +60,7 @@ export function validateAmount(props: TValidateAmountProps): TValidationResponse if (minAmountAllowed !== undefined && amountNumber < Number(minAmountAllowed)) { return { isValid: false, - error: `Amount under minimum allowed ${ - shouldDisplayMin && minAmountAllowed !== undefined ? `(min ${minAmountAllowed})` : '' - }` + error: `Amount under minimum allowed ${shouldDisplayMin && minAmountAllowed !== undefined ? `(min ${minAmountAllowed})` : ''}` }; } diff --git a/apps/ybal/Wrapper.tsx b/apps/ybal/Wrapper.tsx index ccc003121..cde212400 100755 --- a/apps/ybal/Wrapper.tsx +++ b/apps/ybal/Wrapper.tsx @@ -15,13 +15,7 @@ export function Wrapper({children, router}: {children: ReactElement; router: Nex - + {children} diff --git a/apps/ybal/components/CardTransactorWrapper.tsx b/apps/ybal/components/CardTransactorWrapper.tsx index 9c19e3ef0..8c3f5986c 100755 --- a/apps/ybal/components/CardTransactorWrapper.tsx +++ b/apps/ybal/components/CardTransactorWrapper.tsx @@ -5,12 +5,7 @@ import {useWeb3} from '@yearn-finance/web-lib/contexts/useWeb3'; import {useAddToken} from '@yearn-finance/web-lib/hooks/useAddToken'; import {useDismissToasts} from '@yearn-finance/web-lib/hooks/useDismissToasts'; import {allowanceKey, toAddress} from '@yearn-finance/web-lib/utils/address'; -import { - LPYBAL_TOKEN_ADDRESS, - MAX_UINT_256, - STYBAL_TOKEN_ADDRESS, - ZAP_YEARN_YBAL_ADDRESS -} from '@yearn-finance/web-lib/utils/constants'; +import {LPYBAL_TOKEN_ADDRESS, MAX_UINT_256, STYBAL_TOKEN_ADDRESS, ZAP_YEARN_YBAL_ADDRESS} from '@yearn-finance/web-lib/utils/constants'; import {formatToNormalizedValue, toBigInt, toNormalizedBN} from '@yearn-finance/web-lib/utils/format.bigNumber'; import {formatPercent} from '@yearn-finance/web-lib/utils/format.number'; import {isZero} from '@yearn-finance/web-lib/utils/isZero'; @@ -64,11 +59,7 @@ const CardTransactorContext = createContext({ onZap: async (): Promise => undefined }); -export function CardTransactorContextApp({ - defaultOptionFrom = ZAP_OPTIONS_FROM[0], - defaultOptionTo = ZAP_OPTIONS_TO[0], - children =
-}): ReactElement { +export function CardTransactorContextApp({defaultOptionFrom = ZAP_OPTIONS_FROM[0], defaultOptionTo = ZAP_OPTIONS_TO[0], children =
}): ReactElement { const {provider, isActive, address} = useWeb3(); const {styBalAPY, allowances, refetchAllowances, slippage} = useYBal(); const {balancesNonce, balances, refresh} = useWallet(); @@ -112,12 +103,7 @@ export function CardTransactorContextApp({ ** called every 10s or when amount/in or out changes. **************************************************************************/ const [{result: expectedOut}, actions] = useAsync( - async ( - _provider: Connector | undefined, - _inputToken: TAddress, - _outputToken: TAddress, - _amountIn: bigint - ): Promise<{shouldMint: boolean; minOut: bigint}> => { + async (_provider: Connector | undefined, _inputToken: TAddress, _outputToken: TAddress, _amountIn: bigint): Promise<{shouldMint: boolean; minOut: bigint}> => { return await simulateZapForMinOut({ connector: provider, contractAddress: ZAP_YEARN_YBAL_ADDRESS, @@ -241,16 +227,7 @@ export function CardTransactorContextApp({ const allowanceFrom = useMemo((): bigint => { balancesNonce; // remove warning, force deep refresh - return toBigInt( - allowances?.[ - allowanceKey( - 1, - toAddress(selectedOptionFrom.value), - toAddress(selectedOptionFrom.zapVia), - toAddress(address) - ) - ] - ); + return toBigInt(allowances?.[allowanceKey(1, toAddress(selectedOptionFrom.value), toAddress(selectedOptionFrom.zapVia), toAddress(address))]); }, [balancesNonce, allowances, selectedOptionFrom.value, selectedOptionFrom.zapVia, address]); return ( @@ -264,9 +241,7 @@ export function CardTransactorContextApp({ allowanceFrom, fromVaultAPY, toVaultAPY, - expectedOutWithSlippage: formatToNormalizedValue( - expectedOut.minOut * (1n - toBigInt(slippage * 100) / 10000n) - ), + expectedOutWithSlippage: formatToNormalizedValue(expectedOut.minOut * (1n - toBigInt(slippage * 100) / 10000n)), set_selectedOptionFrom, set_selectedOptionTo, set_amount, diff --git a/apps/ybal/components/CardZap.tsx b/apps/ybal/components/CardZap.tsx index 628fa8a70..03e783675 100755 --- a/apps/ybal/components/CardZap.tsx +++ b/apps/ybal/components/CardZap.tsx @@ -3,11 +3,7 @@ import {Button} from '@yearn-finance/web-lib/components/Button'; import {useWeb3} from '@yearn-finance/web-lib/contexts/useWeb3'; import {toAddress} from '@yearn-finance/web-lib/utils/address'; import {cl} from '@yearn-finance/web-lib/utils/cl'; -import { - LPYBAL_TOKEN_ADDRESS, - YBAL_BALANCER_POOL_ADDRESS, - YBAL_TOKEN_ADDRESS -} from '@yearn-finance/web-lib/utils/constants'; +import {LPYBAL_TOKEN_ADDRESS, YBAL_BALANCER_POOL_ADDRESS, YBAL_TOKEN_ADDRESS} from '@yearn-finance/web-lib/utils/constants'; import {formatToNormalizedValue, toBigInt, toNormalizedBN} from '@yearn-finance/web-lib/utils/format.bigNumber'; import {formatCounterValue} from '@yearn-finance/web-lib/utils/format.value'; import {handleInputChangeEventValue} from '@yearn-finance/web-lib/utils/handlers/handleInputChangeEventValue'; @@ -45,15 +41,9 @@ function CardZap(): ReactElement { onZap } = useCardTransactor(); - const yBalPrice = useMemo( - (): number => formatToNormalizedValue(toBigInt(prices?.[YBAL_TOKEN_ADDRESS] || 0), 6), - [prices] - ); + const yBalPrice = useMemo((): number => formatToNormalizedValue(toBigInt(prices?.[YBAL_TOKEN_ADDRESS] || 0), 6), [prices]); - const yBalCurvePoolPrice = useMemo( - (): number => formatToNormalizedValue(toBigInt(prices?.[YBAL_BALANCER_POOL_ADDRESS] || 0), 6), - [prices] - ); + const yBalCurvePoolPrice = useMemo((): number => formatToNormalizedValue(toBigInt(prices?.[YBAL_BALANCER_POOL_ADDRESS] || 0), 6), [prices]); /* 🔵 - Yearn Finance ****************************************************** ** useMemo to get the current possible TO vaults path for the current FROM @@ -76,22 +66,14 @@ function CardZap(): ReactElement { if (txStatusApprove.pending || isAboveAllowance) { return ( - ); } return ( - ); @@ -109,11 +91,7 @@ function CardZap(): ReactElement { onSelect={(option: TDropdownOption): void => { performBatchedUpdates((): void => { if (option.value === selectedOptionTo.value) { - set_selectedOptionTo( - ZAP_OPTIONS_TO.find( - (o: TDropdownOption): boolean => o.value !== option.value - ) as TDropdownOption - ); + set_selectedOptionTo(ZAP_OPTIONS_TO.find((o: TDropdownOption): boolean => o.value !== option.value) as TDropdownOption); } set_selectedOptionFrom(option); set_amount(toNormalizedBN(balances[toAddress(option.value)]?.raw)); @@ -138,23 +116,14 @@ function CardZap(): ReactElement { value={amount.normalized} onChange={(e: ChangeEvent): void => { performBatchedUpdates((): void => { - set_amount( - handleInputChangeEventValue( - e.target.value, - balances[toAddress(selectedOptionFrom.value)]?.decimals || 18 - ) - ); + set_amount(handleInputChangeEventValue(e.target.value, balances[toAddress(selectedOptionFrom.value)]?.decimals || 18)); set_hasTypedSomething(true); }); }} />
@@ -166,9 +135,7 @@ function CardZap(): ReactElement { ? yBalPrice || 0 : toAddress(selectedOptionFrom.value) === YBAL_BALANCER_POOL_ADDRESS ? yBalCurvePoolPrice || 0 - : balances?.[toAddress(selectedOptionFrom.value)]?.normalizedPrice || - vaults?.[toAddress(selectedOptionFrom.value)]?.tvl?.price || - 0 + : balances?.[toAddress(selectedOptionFrom.value)]?.normalizedPrice || vaults?.[toAddress(selectedOptionFrom.value)]?.tvl?.price || 0 )}

@@ -209,9 +176,7 @@ function CardZap(): ReactElement { ? yBalPrice || 0 : toAddress(selectedOptionFrom.value) === YBAL_BALANCER_POOL_ADDRESS ? yBalCurvePoolPrice || 0 - : balances?.[toAddress(selectedOptionTo.value)]?.normalizedPrice || - vaults?.[toAddress(selectedOptionTo.value)]?.tvl?.price || - 0 + : balances?.[toAddress(selectedOptionTo.value)]?.normalizedPrice || vaults?.[toAddress(selectedOptionTo.value)]?.tvl?.price || 0 )}

diff --git a/apps/ybal/components/Harvests.tsx b/apps/ybal/components/Harvests.tsx index c57bd0fe9..a50feb93f 100644 --- a/apps/ybal/components/Harvests.tsx +++ b/apps/ybal/components/Harvests.tsx @@ -26,30 +26,18 @@ export function Harvests(): ReactElement { return (
-
+

{'Harvests'}

- - -
@@ -58,18 +46,10 @@ export function Harvests(): ReactElement { {(filteredHarvests || []) .filter((harvest: TYDaemonVaultHarvest): boolean => { - return ( - !isZeroAddress(toAddress(harvest.vaultAddress)) && - [STYBAL_TOKEN_ADDRESS, LPYBAL_TOKEN_ADDRESS].includes(toAddress(harvest.vaultAddress)) - ); + return !isZeroAddress(toAddress(harvest.vaultAddress)) && [STYBAL_TOKEN_ADDRESS, LPYBAL_TOKEN_ADDRESS].includes(toAddress(harvest.vaultAddress)); }) .map((harvest: TYDaemonVaultHarvest, index: number): ReactElement => { - return ( - - ); + return ; })}
diff --git a/apps/ybal/components/HarvestsListRow.tsx b/apps/ybal/components/HarvestsListRow.tsx index de23dd136..b92eb3e05 100755 --- a/apps/ybal/components/HarvestsListRow.tsx +++ b/apps/ybal/components/HarvestsListRow.tsx @@ -41,9 +41,7 @@ export function HarvestListRow({harvest}: {harvest: TYDaemonVaultHarvest}): Reac width={40} height={40} quality={90} - src={`${process.env.BASE_YEARN_ASSETS_URI}/1/${toAddress( - harvest.vaultAddress - )}/logo-128.png`} + src={`${process.env.BASE_YEARN_ASSETS_URI}/1/${toAddress(harvest.vaultAddress)}/logo-128.png`} loading={'eager'} />
@@ -58,9 +56,7 @@ export function HarvestListRow({harvest}: {harvest: TYDaemonVaultHarvest}): Reac

{'Hash'}

-
+
{truncateHex(harvest.txHash, 6)}
diff --git a/apps/ybal/constants/tokens.tsx b/apps/ybal/constants/tokens.tsx index ce72bb5d9..60b5fc50e 100755 --- a/apps/ybal/constants/tokens.tsx +++ b/apps/ybal/constants/tokens.tsx @@ -1,12 +1,5 @@ import {toAddress} from '@yearn-finance/web-lib/utils/address'; -import { - BAL_TOKEN_ADDRESS, - BALWETH_TOKEN_ADDRESS, - LPYBAL_TOKEN_ADDRESS, - STYBAL_TOKEN_ADDRESS, - WETH_TOKEN_ADDRESS, - YBAL_TOKEN_ADDRESS -} from '@yearn-finance/web-lib/utils/constants'; +import {BAL_TOKEN_ADDRESS, BALWETH_TOKEN_ADDRESS, LPYBAL_TOKEN_ADDRESS, STYBAL_TOKEN_ADDRESS, WETH_TOKEN_ADDRESS, YBAL_TOKEN_ADDRESS} from '@yearn-finance/web-lib/utils/constants'; import {ImageWithFallback} from '@common/components/ImageWithFallback'; import type {TDropdownOption} from '@common/types/types'; @@ -18,14 +11,7 @@ export const BAL = { decimals: 18, value: BAL_TOKEN_ADDRESS, zapVia: LOCAL_ZAP_YEARN_YBAL_ADDRESS, - icon: ( - - ) + icon: }; export const YBAL = { label: 'yBal', @@ -33,16 +19,7 @@ export const YBAL = { decimals: 18, value: YBAL_TOKEN_ADDRESS, zapVia: LOCAL_ZAP_YEARN_YBAL_ADDRESS, - icon: ( - - ) + icon: }; export const BALWETH = { label: 'BAL/wETH', @@ -68,14 +45,7 @@ export const STYBAL = { value: STYBAL_TOKEN_ADDRESS, zapVia: LOCAL_ZAP_YEARN_YBAL_ADDRESS, icon: ( - + ) }; export const LPYBAL = { @@ -85,14 +55,7 @@ export const LPYBAL = { value: LPYBAL_TOKEN_ADDRESS, zapVia: LOCAL_ZAP_YEARN_YBAL_ADDRESS, icon: ( - + ) }; export const WETH = { @@ -101,14 +64,7 @@ export const WETH = { decimals: 18, value: WETH_TOKEN_ADDRESS, zapVia: LOCAL_ZAP_YEARN_YBAL_ADDRESS, - icon: ( - - ) + icon: }; export const ZAP_OPTIONS_FROM: TDropdownOption[] = [BAL, WETH, BALWETH, YBAL, STYBAL, LPYBAL]; diff --git a/apps/ybal/contexts/useAllowanceHook.tsx b/apps/ybal/contexts/useAllowanceHook.tsx index d9859e776..9bac0dbcb 100644 --- a/apps/ybal/contexts/useAllowanceHook.tsx +++ b/apps/ybal/contexts/useAllowanceHook.tsx @@ -6,14 +6,7 @@ import {useMemo} from 'react'; import {erc20ABI, useContractReads} from 'wagmi'; import {useWeb3} from '@yearn-finance/web-lib/contexts/useWeb3'; import {allowanceKey, toAddress} from '@yearn-finance/web-lib/utils/address'; -import { - BAL_TOKEN_ADDRESS, - BALWETH_TOKEN_ADDRESS, - LPYBAL_TOKEN_ADDRESS, - STYBAL_TOKEN_ADDRESS, - WETH_TOKEN_ADDRESS, - YBAL_TOKEN_ADDRESS -} from '@yearn-finance/web-lib/utils/constants'; +import {BAL_TOKEN_ADDRESS, BALWETH_TOKEN_ADDRESS, LPYBAL_TOKEN_ADDRESS, STYBAL_TOKEN_ADDRESS, WETH_TOKEN_ADDRESS, YBAL_TOKEN_ADDRESS} from '@yearn-finance/web-lib/utils/constants'; import {decodeAsBigInt} from '@yearn-finance/web-lib/utils/decoder'; import type {TAddress, TDict} from '@yearn-finance/web-lib/types'; @@ -74,21 +67,12 @@ export function useAllowances(): [TDict, () => void] { } return [ { - [allowanceKey(1, BAL_TOKEN_ADDRESS, LOCAL_ZAP_YEARN_YBAL_ADDRESS, toAddress(address))]: decodeAsBigInt( - data[0] - ), - [allowanceKey(1, WETH_TOKEN_ADDRESS, LOCAL_ZAP_YEARN_YBAL_ADDRESS, toAddress(address))]: decodeAsBigInt( - data[1] - ), - [allowanceKey(1, BALWETH_TOKEN_ADDRESS, LOCAL_ZAP_YEARN_YBAL_ADDRESS, toAddress(address))]: - decodeAsBigInt(data[2]), - [allowanceKey(1, YBAL_TOKEN_ADDRESS, LOCAL_ZAP_YEARN_YBAL_ADDRESS, toAddress(address))]: decodeAsBigInt( - data[3] - ), - [allowanceKey(1, STYBAL_TOKEN_ADDRESS, LOCAL_ZAP_YEARN_YBAL_ADDRESS, toAddress(address))]: - decodeAsBigInt(data[4]), - [allowanceKey(1, LPYBAL_TOKEN_ADDRESS, LOCAL_ZAP_YEARN_YBAL_ADDRESS, toAddress(address))]: - decodeAsBigInt(data[5]) + [allowanceKey(1, BAL_TOKEN_ADDRESS, LOCAL_ZAP_YEARN_YBAL_ADDRESS, toAddress(address))]: decodeAsBigInt(data[0]), + [allowanceKey(1, WETH_TOKEN_ADDRESS, LOCAL_ZAP_YEARN_YBAL_ADDRESS, toAddress(address))]: decodeAsBigInt(data[1]), + [allowanceKey(1, BALWETH_TOKEN_ADDRESS, LOCAL_ZAP_YEARN_YBAL_ADDRESS, toAddress(address))]: decodeAsBigInt(data[2]), + [allowanceKey(1, YBAL_TOKEN_ADDRESS, LOCAL_ZAP_YEARN_YBAL_ADDRESS, toAddress(address))]: decodeAsBigInt(data[3]), + [allowanceKey(1, STYBAL_TOKEN_ADDRESS, LOCAL_ZAP_YEARN_YBAL_ADDRESS, toAddress(address))]: decodeAsBigInt(data[4]), + [allowanceKey(1, LPYBAL_TOKEN_ADDRESS, LOCAL_ZAP_YEARN_YBAL_ADDRESS, toAddress(address))]: decodeAsBigInt(data[5]) }, refetch ]; diff --git a/apps/ybal/utils/actions.test.ts b/apps/ybal/utils/actions.test.ts index 75711f9f5..285f8c87e 100644 --- a/apps/ybal/utils/actions.test.ts +++ b/apps/ybal/utils/actions.test.ts @@ -77,20 +77,8 @@ describe('actions', () => { amountIn: amountIn }); - expect(mockCallStaticZap).toHaveBeenNthCalledWith( - 1, - BAL_TOKEN_ADDRESS, - YBAL_TOKEN_ADDRESS, - amountIn, - true - ); - expect(mockCallStaticZap).toHaveBeenNthCalledWith( - 2, - BAL_TOKEN_ADDRESS, - YBAL_TOKEN_ADDRESS, - amountIn, - false - ); + expect(mockCallStaticZap).toHaveBeenNthCalledWith(1, BAL_TOKEN_ADDRESS, YBAL_TOKEN_ADDRESS, amountIn, true); + expect(mockCallStaticZap).toHaveBeenNthCalledWith(2, BAL_TOKEN_ADDRESS, YBAL_TOKEN_ADDRESS, amountIn, false); expect(shouldMint).toBe(false); expect(minOut).toEqual(toBigInt('197752499999999997726')); }); @@ -122,20 +110,8 @@ describe('actions', () => { amountIn: amountIn }); - expect(mockCallStaticZap).toHaveBeenNthCalledWith( - 1, - BAL_TOKEN_ADDRESS, - YBAL_TOKEN_ADDRESS, - expectedIn, - true - ); - expect(mockCallStaticZap).toHaveBeenNthCalledWith( - 2, - BAL_TOKEN_ADDRESS, - YBAL_TOKEN_ADDRESS, - expectedIn, - false - ); + expect(mockCallStaticZap).toHaveBeenNthCalledWith(1, BAL_TOKEN_ADDRESS, YBAL_TOKEN_ADDRESS, expectedIn, true); + expect(mockCallStaticZap).toHaveBeenNthCalledWith(2, BAL_TOKEN_ADDRESS, YBAL_TOKEN_ADDRESS, expectedIn, false); expect(shouldMint).toBe(true); expect(minOut).toEqual(toBigInt('41579999999999998295')); }); diff --git a/apps/ybal/utils/actions.ts b/apps/ybal/utils/actions.ts index 2c4b4534b..0f98607e7 100644 --- a/apps/ybal/utils/actions.ts +++ b/apps/ybal/utils/actions.ts @@ -55,9 +55,7 @@ type TSimulateZapForMinOut = TWriteTransaction & { outputToken: TAddress; amountIn: bigint; }; -export async function simulateZapForMinOut( - props: TSimulateZapForMinOut -): Promise<{shouldMint: boolean; minOut: bigint}> { +export async function simulateZapForMinOut(props: TSimulateZapForMinOut): Promise<{shouldMint: boolean; minOut: bigint}> { if (isZero(props.amountIn)) { return {shouldMint: false, minOut: 0n}; } diff --git a/apps/ybal/utils/zapOptions.tsx b/apps/ybal/utils/zapOptions.tsx index 22a1b1931..6e3902f54 100755 --- a/apps/ybal/utils/zapOptions.tsx +++ b/apps/ybal/utils/zapOptions.tsx @@ -1,10 +1,4 @@ -import { - BAL_TOKEN_ADDRESS, - LPYBAL_TOKEN_ADDRESS, - STYBAL_TOKEN_ADDRESS, - YBAL_TOKEN_ADDRESS, - ZAP_YEARN_YBAL_ADDRESS -} from '@yearn-finance/web-lib/utils/constants'; +import {BAL_TOKEN_ADDRESS, LPYBAL_TOKEN_ADDRESS, STYBAL_TOKEN_ADDRESS, YBAL_TOKEN_ADDRESS, ZAP_YEARN_YBAL_ADDRESS} from '@yearn-finance/web-lib/utils/constants'; import {ImageWithFallback} from '@common/components/ImageWithFallback'; import type {TDropdownOption} from '@common/types/types'; @@ -16,14 +10,7 @@ export const ZAP_OPTIONS_FROM: TDropdownOption[] = [ decimals: 18, value: BAL_TOKEN_ADDRESS, zapVia: ZAP_YEARN_YBAL_ADDRESS, - icon: ( - - ) + icon: }, { label: 'st-yBal', @@ -48,16 +35,7 @@ export const ZAP_OPTIONS_FROM: TDropdownOption[] = [ decimals: 18, value: YBAL_TOKEN_ADDRESS, zapVia: ZAP_YEARN_YBAL_ADDRESS, - icon: ( - - ) + icon: }, { label: 'lp-yBal', @@ -102,16 +80,7 @@ export const ZAP_OPTIONS_TO: TDropdownOption[] = [ decimals: 18, value: YBAL_TOKEN_ADDRESS, zapVia: ZAP_YEARN_YBAL_ADDRESS, - icon: ( - - ) + icon: }, { label: 'lp-yBal', diff --git a/apps/ybribe/Wrapper.tsx b/apps/ybribe/Wrapper.tsx index 05a9ee891..8e718f4b6 100755 --- a/apps/ybribe/Wrapper.tsx +++ b/apps/ybribe/Wrapper.tsx @@ -19,13 +19,7 @@ export function Wrapper({children, router}: {children: ReactElement; router: Nex - + {children} diff --git a/apps/ybribe/components/bribe/GaugeBribeModal.tsx b/apps/ybribe/components/bribe/GaugeBribeModal.tsx index 66dd2b15e..e269626be 100755 --- a/apps/ybribe/components/bribe/GaugeBribeModal.tsx +++ b/apps/ybribe/components/bribe/GaugeBribeModal.tsx @@ -38,13 +38,7 @@ const defaultExpectedOutFetcher: TExpectedOutFetcher = { allowance: toBigInt(0) }; -export function GaugeBribeModal({ - currentGauge, - onClose -}: { - currentGauge: TCurveGauge; - onClose: VoidFunction; -}): ReactElement { +export function GaugeBribeModal({currentGauge, onClose}: {currentGauge: TCurveGauge; onClose: VoidFunction}): ReactElement { const {chainID} = useChainID(); const {address, provider, isActive, openLoginModal, onSwitchChain} = useWeb3(); const {refresh} = useBribes(); @@ -137,9 +131,7 @@ export function GaugeBribeModal({ onClick={onApprove} className={'w-full'} isBusy={txStatusApprove.pending} - isDisabled={ - !isActive || isZeroAddress(tokenAddress) || isZero(amount.raw) || ![1, 1337].includes(chainID) - }> + isDisabled={!isActive || isZeroAddress(tokenAddress) || isZero(amount.raw) || ![1, 1337].includes(chainID)}> {`Approve ${selectedToken?.symbol || 'token'}`} ); @@ -150,13 +142,7 @@ export function GaugeBribeModal({ onClick={onAddReward} className={'w-full'} isBusy={txStatusAddReward.pending} - isDisabled={ - !isActive || - isZeroAddress(tokenAddress) || - isZero(amount.raw) || - toBigInt(amount?.raw) > toBigInt(selectedToken?.raw) || - ![1, 1337].includes(chainID) - }> + isDisabled={!isActive || isZeroAddress(tokenAddress) || isZero(amount.raw) || toBigInt(amount?.raw) > toBigInt(selectedToken?.raw) || ![1, 1337].includes(chainID)}> {'Deposit'} ); @@ -167,9 +153,7 @@ export function GaugeBribeModal({
{`Offer bribe to ${currentGauge.name}`} -

- {'Choose your reward token contract and reward amount to offer a bribe on your chosen gauge.'} -

+

{'Choose your reward token contract and reward amount to offer a bribe on your chosen gauge.'}

@@ -187,10 +171,7 @@ export function GaugeBribeModal({ value={tokenAddress} onChange={(e: ChangeEvent): void => { const {value} = e.target; - if ( - value === '' || - value.match(/^(0[x]{0,1})[a-fA-F0-9]{0,40}/gm)?.includes(value) - ) { + if (value === '' || value.match(/^(0[x]{0,1})[a-fA-F0-9]{0,40}/gm)?.includes(value)) { if (isZeroAddress(value)) { set_tokenAddress(ZERO_ADDRESS); } else { @@ -215,9 +196,7 @@ export function GaugeBribeModal({ disabled={!isActive} value={amount.normalized} onChange={(e: ChangeEvent): void => { - set_amount( - handleInputChangeEventValue(e.target.value, selectedToken?.decimals || 18) - ); + set_amount(handleInputChangeEventValue(e.target.value, selectedToken?.decimals || 18)); }} />
@@ -239,26 +216,17 @@ export function GaugeBribeModal({

{'Token'}

-

- {selectedToken ? `${selectedToken?.name} (${selectedToken?.symbol})` : '-'} -

+

{selectedToken ? `${selectedToken?.name} (${selectedToken?.symbol})` : '-'}

{'Value'}

- {selectedToken - ? formatCounterValue( - amount?.normalized || 0, - Number(prices?.[toAddress(tokenAddress)] || 0) / 1000000 - ) - : '-'} + {selectedToken ? formatCounterValue(amount?.normalized || 0, Number(prices?.[toAddress(tokenAddress)] || 0) / 1000000) : '-'}

{'Amount'}

-

- {selectedToken ? `${amount.raw.toString()}` : '-'} -

+

{selectedToken ? `${amount.raw.toString()}` : '-'}

{'Gauge'}

diff --git a/apps/ybribe/components/bribe/GaugeListRow.tsx b/apps/ybribe/components/bribe/GaugeListRow.tsx index c7150ea90..a2122ef04 100755 --- a/apps/ybribe/components/bribe/GaugeListRow.tsx +++ b/apps/ybribe/components/bribe/GaugeListRow.tsx @@ -84,10 +84,7 @@ export function GaugeListRow({currentGauge}: {currentGauge: TCurveGauge}): React
-
@@ -102,16 +99,10 @@ export function GaugeListRow({currentGauge}: {currentGauge: TCurveGauge}): React
- 0} - fallback={renderDefaultValueUSDFallback()}> + 0} fallback={renderDefaultValueUSDFallback()}> {currentRewardsForCurrentGaugeMap.map( ([key, value]: [string, bigint]): ReactElement => ( - + ) )} @@ -119,16 +110,10 @@ export function GaugeListRow({currentGauge}: {currentGauge: TCurveGauge}): React
- 0} - fallback={renderDefaultValueUSDFallback()}> + 0} fallback={renderDefaultValueUSDFallback()}> {nextRewardsForCurrentGaugeMap.map( ([key, value]: [string, bigint]): ReactElement => ( - + ) )} @@ -136,10 +121,7 @@ export function GaugeListRow({currentGauge}: {currentGauge: TCurveGauge}): React
-
diff --git a/apps/ybribe/components/claim/GaugeListRow.tsx b/apps/ybribe/components/claim/GaugeListRow.tsx index a956e1b93..7c55b0084 100755 --- a/apps/ybribe/components/claim/GaugeListRow.tsx +++ b/apps/ybribe/components/claim/GaugeListRow.tsx @@ -17,15 +17,7 @@ import type {ReactElement} from 'react'; import type {TAddress, TDict} from '@yearn-finance/web-lib/types'; import type {TCurveGauge} from '@common/schemas/curveSchemas'; -function GaugeRowItemWithExtraData({ - address, - value, - minDecimals = 5 -}: { - address: TAddress; - value: bigint; - minDecimals?: number; -}): ReactElement { +function GaugeRowItemWithExtraData({address, value, minDecimals = 5}: {address: TAddress; value: bigint; minDecimals?: number}): ReactElement { const {tokens, prices} = useYearn(); const tokenInfo = tokens?.[address]; @@ -37,9 +29,7 @@ function GaugeRowItemWithExtraData({ return (
-
- {formatUSD(bribeValue, minDecimals, minDecimals)} -
+
{formatUSD(bribeValue, minDecimals, minDecimals)}

{formatAmount(bribeAmount, minDecimals, minDecimals)}   @@ -127,9 +117,7 @@ export function GaugeListRow({currentGauge, category}: {currentGauge: TCurveGaug function renderDefaultValuesUSDFallback(): ReactElement { return (

-

- {formatUSD(0, 5, 5)} -

+

{formatUSD(0, 5, 5)}

{'-'}

); @@ -179,64 +167,34 @@ export function GaugeListRow({currentGauge, category}: {currentGauge: TCurveGaug
-
+
0 - } + shouldRender={!!currentRewardsForCurrentGaugeMap && currentRewardsForCurrentGaugeMap.length > 0} fallback={renderDefaultValuePercentFallback()}> {currentRewardsForCurrentGaugeMap.map( ([key, value]: [string, bigint]): ReactElement => ( - + ) )}
-
+
- 0 - } - fallback={renderDefaultValuePercentFallback()}> + 0} fallback={renderDefaultValuePercentFallback()}> {nextRewardsForCurrentGaugeMap.map( ([key, value]: [string, bigint]): ReactElement => ( - + ) )} @@ -246,44 +204,22 @@ export function GaugeListRow({currentGauge, category}: {currentGauge: TCurveGaug
-
+
- 0 - } - fallback={renderDefaultValueUSDFallback()}> + 0} fallback={renderDefaultValueUSDFallback()}> {currentRewardsForCurrentGaugeMap.map( ([key, value]: [string, bigint]): ReactElement => ( - + ) )}
-
+
- 0 - } - fallback={renderDefaultValueUSDFallback()}> + 0} fallback={renderDefaultValueUSDFallback()}> {nextRewardsForCurrentGaugeMap.map( ([key, value]: [string, bigint]): ReactElement => ( - + ) )} @@ -293,44 +229,27 @@ export function GaugeListRow({currentGauge, category}: {currentGauge: TCurveGaug
-
+
- 0 - } - fallback={renderDefaultValuesUSDFallback()}> + 0} fallback={renderDefaultValuesUSDFallback()}> {claimableForCurrentGaugeMap.map( ([key, value]: [string, bigint]): ReactElement => ( -
+
) )} - 0 - } - fallback={renderDefaultValuesUSDFallback()}> + 0} fallback={renderDefaultValuesUSDFallback()}> {claimableForCurrentGaugeMap.map( ([key, value]: [string, bigint]): ReactElement => ( -
+
diff --git a/apps/ybribe/components/rewardFeed/RewardFeedTable.tsx b/apps/ybribe/components/rewardFeed/RewardFeedTable.tsx index 2900624c2..5412c7a64 100644 --- a/apps/ybribe/components/rewardFeed/RewardFeedTable.tsx +++ b/apps/ybribe/components/rewardFeed/RewardFeedTable.tsx @@ -36,30 +36,20 @@ export function RewardFeedTable(): ReactElement | null { <> {currentItems.filter(Boolean).map( (item, index): ReactNode => ( - + ) )}
-
+
@@ -81,12 +71,8 @@ export function RewardFeedTable(): ReactElement | null { previousLinkClassName={ 'text-gray-500 hover:bg-neutral-300 relative inline-flex items-center p-2 text-sm font-medium focus:z-20 border border-neutral-400' } - nextLinkClassName={ - 'text-gray-500 hover:bg-neutral-300 relative inline-flex items-center p-2 text-sm font-medium focus:z-20 border border-neutral-400' - } - breakLinkClassName={ - 'text-gray-700 relative inline-flex items-center px-4 py-2 text-sm font-medium hover:bg-neutral-300 border border-neutral-400' - } + nextLinkClassName={'text-gray-500 hover:bg-neutral-300 relative inline-flex items-center p-2 text-sm font-medium focus:z-20 border border-neutral-400'} + breakLinkClassName={'text-gray-700 relative inline-flex items-center px-4 py-2 text-sm font-medium hover:bg-neutral-300 border border-neutral-400'} activeLinkClassName={ 'text-gray-500 hover:bg-neutral-300 relative hidden items-center px-4 py-2 text-sm font-medium focus:z-20 md:inline-flex bg-neutral-300' } diff --git a/apps/ybribe/components/rewardFeed/RewardFeedTableRow.tsx b/apps/ybribe/components/rewardFeed/RewardFeedTableRow.tsx index 15ad6a132..79b3df913 100755 --- a/apps/ybribe/components/rewardFeed/RewardFeedTableRow.tsx +++ b/apps/ybribe/components/rewardFeed/RewardFeedTableRow.tsx @@ -12,14 +12,7 @@ import type {TAddress} from '@yearn-finance/web-lib/types'; import type {TCurveGauge} from '@common/schemas/curveSchemas'; import type {TYDaemonGaugeRewardsFeed} from '@common/schemas/yDaemonGaugeRewardsFeedSchema'; -function RewardFeedRowItemWithExtraData({ - address, - value -}: { - address: TAddress; - value: bigint; - minDecimals?: number; -}): ReactElement { +function RewardFeedRowItemWithExtraData({address, value}: {address: TAddress; value: bigint; minDecimals?: number}): ReactElement { const {tokens, prices} = useYearn(); const tokenInfo = tokens?.[address]; @@ -31,9 +24,7 @@ function RewardFeedRowItemWithExtraData({ return (
-
- {formatUSD(bribeValue)} -
+
{formatUSD(bribeValue)}

{formatAmount(bribeAmount)}   @@ -43,11 +34,7 @@ function RewardFeedRowItemWithExtraData({ ); } -export function RewardFeedTableRow({ - currentRewardAdded -}: { - currentRewardAdded: TYDaemonGaugeRewardsFeed[0]; -}): ReactElement | null { +export function RewardFeedTableRow({currentRewardAdded}: {currentRewardAdded: TYDaemonGaugeRewardsFeed[0]}): ReactElement | null { const {gauges} = useCurve(); const gaugesObject = useMemo((): {[key: string]: TCurveGauge} => { @@ -80,16 +67,12 @@ export function RewardFeedTableRow({

@@ -97,21 +80,14 @@ export function RewardFeedTableRow({
-

- {formatDate(Number(currentRewardAdded.timestamp) * 1000)} -

+

{formatDate(Number(currentRewardAdded.timestamp) * 1000)}

- - + +
diff --git a/apps/ybribe/contexts/useBribes.tsx b/apps/ybribe/contexts/useBribes.tsx index b2ec12928..a8a4897a4 100755 --- a/apps/ybribe/contexts/useBribes.tsx +++ b/apps/ybribe/contexts/useBribes.tsx @@ -190,40 +190,37 @@ export const BribesContextApp = ({children}: {children: React.ReactElement}): Re tokenAddress: TAddress; nextRewards: bigint; }; - const getNextPeriodRewards = useCallback( - async (rewardsPerGauges: TDict): Promise> => { - const rewardsPerTokensPerGaugesCalls: Promise[] = []; + const getNextPeriodRewards = useCallback(async (rewardsPerGauges: TDict): Promise> => { + const rewardsPerTokensPerGaugesCalls: Promise[] = []; - for (const [gaugeAddress, rewardsTokens] of Object.entries(rewardsPerGauges)) { - for (const tokenAsReward of rewardsTokens) { - rewardsPerTokensPerGaugesCalls.push( - prepareWriteContract({ - address: CURVE_BRIBE_V3_HELPER_ADDRESS, - abi: CURVE_BRIBE_V3_HELPER_ABI, - functionName: 'getNewRewardPerToken', - args: [toAddress(gaugeAddress), tokenAsReward] - }) - ); - } + for (const [gaugeAddress, rewardsTokens] of Object.entries(rewardsPerGauges)) { + for (const tokenAsReward of rewardsTokens) { + rewardsPerTokensPerGaugesCalls.push( + prepareWriteContract({ + address: CURVE_BRIBE_V3_HELPER_ADDRESS, + abi: CURVE_BRIBE_V3_HELPER_ABI, + functionName: 'getNewRewardPerToken', + args: [toAddress(gaugeAddress), tokenAsReward] + }) + ); } + } - const result = await Promise.all(rewardsPerTokensPerGaugesCalls); - const multicallResult: TDict = {}; - let resultIndex = 0; - for (const [gaugeAddress, rewardsTokens] of Object.entries(rewardsPerGauges)) { - for (const tokenAsReward of rewardsTokens) { - multicallResult[gaugeAddress] = { - gaugeAddress: toAddress(gaugeAddress), - tokenAddress: toAddress(tokenAsReward), - nextRewards: toBigInt(result[resultIndex++].result as bigint) - }; - } + const result = await Promise.all(rewardsPerTokensPerGaugesCalls); + const multicallResult: TDict = {}; + let resultIndex = 0; + for (const [gaugeAddress, rewardsTokens] of Object.entries(rewardsPerGauges)) { + for (const tokenAsReward of rewardsTokens) { + multicallResult[gaugeAddress] = { + gaugeAddress: toAddress(gaugeAddress), + tokenAddress: toAddress(tokenAsReward), + nextRewards: toBigInt(result[resultIndex++].result as bigint) + }; } + } - return multicallResult; - }, - [] - ); + return multicallResult; + }, []); /* 🔵 - Yearn Finance ****************************************************** ** assignBribes will save the currentRewards, periods and clamable values @@ -271,10 +268,7 @@ export const BribesContextApp = ({children}: {children: React.ReactElement}): Re ***************************************************************************/ const getBribes = useCallback(async (): Promise => { const rewardsPerGauges = await getRewardsPerGauges(); - const [rewardsPerUser, nextPeriodRewards] = await Promise.all([ - getRewardsPerUser(rewardsPerGauges), - getNextPeriodRewards(rewardsPerGauges) - ]); + const [rewardsPerUser, nextPeriodRewards] = await Promise.all([getRewardsPerUser(rewardsPerGauges), getNextPeriodRewards(rewardsPerGauges)]); performBatchedUpdates((): void => { assignBribes(rewardsPerUser); diff --git a/apps/ycrv/Wrapper.tsx b/apps/ycrv/Wrapper.tsx index 4c039e0a4..cd64f1482 100755 --- a/apps/ycrv/Wrapper.tsx +++ b/apps/ycrv/Wrapper.tsx @@ -17,13 +17,7 @@ export function Wrapper({children, router}: {children: ReactElement; router: Nex - + {children} diff --git a/apps/ycrv/components/CardTransactorWrapper.tsx b/apps/ycrv/components/CardTransactorWrapper.tsx index 80d61ec39..6293b61f3 100755 --- a/apps/ycrv/components/CardTransactorWrapper.tsx +++ b/apps/ycrv/components/CardTransactorWrapper.tsx @@ -73,11 +73,7 @@ const CardTransactorContext = createContext({ onIncreaseCRVAllowance: async (): Promise => undefined }); -export function CardTransactorContextApp({ - defaultOptionFrom = ZAP_OPTIONS_FROM[0], - defaultOptionTo = ZAP_OPTIONS_TO[0], - children =
-}): ReactElement { +export function CardTransactorContextApp({defaultOptionFrom = ZAP_OPTIONS_FROM[0], defaultOptionTo = ZAP_OPTIONS_TO[0], children =
}): ReactElement { const {provider, isActive, address} = useWeb3(); const {styCRVAPY, allowances, refetchAllowances, slippage} = useYCRV(); const {balancesNonce, balances, refresh} = useWallet(); @@ -232,10 +228,7 @@ export function CardTransactorContextApp({ } }; - if ( - selectedOptionFrom.zapVia === LPYCRV_TOKEN_ADDRESS || - selectedOptionFrom.zapVia === LPYCRV_V2_TOKEN_ADDRESS - ) { + if (selectedOptionFrom.zapVia === LPYCRV_TOKEN_ADDRESS || selectedOptionFrom.zapVia === LPYCRV_V2_TOKEN_ADDRESS) { // Direct deposit to vault from crv/yCRV Curve LP Token to lp-yCRV Vault // This is valid for v1 and v2 const result = await deposit({ @@ -303,22 +296,12 @@ export function CardTransactorContextApp({ }, [vaults, selectedOptionTo, styCRVAPY]); const expectedOutWithSlippage = useMemo( - (): number => - getAmountWithSlippage(selectedOptionFrom.value, selectedOptionTo.value, toBigInt(expectedOut), slippage), + (): number => getAmountWithSlippage(selectedOptionFrom.value, selectedOptionTo.value, toBigInt(expectedOut), slippage), [expectedOut, selectedOptionFrom.value, selectedOptionTo.value, slippage] ); const allowanceFrom = useMemo((): bigint => { - return toBigInt( - allowances?.[ - allowanceKey( - 1, - toAddress(selectedOptionFrom.value), - toAddress(selectedOptionFrom.zapVia), - toAddress(address) - ) - ] - ); + return toBigInt(allowances?.[allowanceKey(1, toAddress(selectedOptionFrom.value), toAddress(selectedOptionFrom.zapVia), toAddress(address))]); }, [allowances, selectedOptionFrom.value, selectedOptionFrom.zapVia, address]); return ( diff --git a/apps/ycrv/components/CardZap.tsx b/apps/ycrv/components/CardZap.tsx index abbd33ab0..a9f1c3f53 100755 --- a/apps/ycrv/components/CardZap.tsx +++ b/apps/ycrv/components/CardZap.tsx @@ -49,24 +49,16 @@ function CardZap(): ReactElement { onIncreaseCRVAllowance } = useCardTransactor(); - const ycrvPrice = useMemo( - (): number => formatToNormalizedValue(toBigInt(prices?.[YCRV_TOKEN_ADDRESS] || 0), 6), - [prices] - ); + const ycrvPrice = useMemo((): number => formatToNormalizedValue(toBigInt(prices?.[YCRV_TOKEN_ADDRESS] || 0), 6), [prices]); - const ycrvCurvePoolPrice = useMemo( - (): number => formatToNormalizedValue(toBigInt(prices?.[YCRV_CURVE_POOL_ADDRESS] || 0), 6), - [prices] - ); + const ycrvCurvePoolPrice = useMemo((): number => formatToNormalizedValue(toBigInt(prices?.[YCRV_CURVE_POOL_ADDRESS] || 0), 6), [prices]); /* 🔵 - Yearn Finance ****************************************************** ** useMemo to get the current possible TO vaults path for the current FROM **************************************************************************/ const possibleTo = useMemo((): TDropdownOption[] => { if (selectedOptionFrom.value === LPYCRV_TOKEN_ADDRESS) { - const possibleOptions = ZAP_OPTIONS_TO.filter( - (option): boolean => option.value === LPYCRV_V2_TOKEN_ADDRESS - ); + const possibleOptions = ZAP_OPTIONS_TO.filter((option): boolean => option.value === LPYCRV_V2_TOKEN_ADDRESS); if (selectedOptionTo.value !== LPYCRV_V2_TOKEN_ADDRESS) { set_selectedOptionTo(possibleOptions[0]); } @@ -80,9 +72,7 @@ function CardZap(): ReactElement { return possibleOptions; } if (selectedOptionFrom.value === YCRV_CURVE_POOL_V2_ADDRESS) { - const possibleOptions = ZAP_OPTIONS_TO.filter( - (option): boolean => option.value === LPYCRV_V2_TOKEN_ADDRESS - ); + const possibleOptions = ZAP_OPTIONS_TO.filter((option): boolean => option.value === LPYCRV_V2_TOKEN_ADDRESS); if (selectedOptionTo.value !== LPYCRV_V2_TOKEN_ADDRESS) { set_selectedOptionTo(possibleOptions[0]); } @@ -99,32 +89,20 @@ function CardZap(): ReactElement { if (txStatusApprove.pending || isAboveAllowance) { if (allowanceFrom > 0n && toAddress(selectedOptionFrom.value) === CRV_TOKEN_ADDRESS) { return ( - ); } return ( - ); } return ( - ); @@ -142,11 +120,7 @@ function CardZap(): ReactElement { onSelect={(option: TDropdownOption): void => { performBatchedUpdates((): void => { if (option.value === selectedOptionTo.value) { - set_selectedOptionTo( - ZAP_OPTIONS_TO.find( - (o: TDropdownOption): boolean => o.value !== option.value - ) as TDropdownOption - ); + set_selectedOptionTo(ZAP_OPTIONS_TO.find((o: TDropdownOption): boolean => o.value !== option.value) as TDropdownOption); } set_selectedOptionFrom(option); set_amount(toNormalizedBN(balances[toAddress(option.value)]?.raw)); @@ -174,23 +148,14 @@ function CardZap(): ReactElement { value={amount.normalized} onChange={(e: ChangeEvent): void => { performBatchedUpdates((): void => { - set_amount( - handleInputChangeEventValue( - e.target.value, - balances[toAddress(selectedOptionFrom.value)]?.decimals || 18 - ) - ); + set_amount(handleInputChangeEventValue(e.target.value, balances[toAddress(selectedOptionFrom.value)]?.decimals || 18)); set_hasTypedSomething(true); }); }} />
@@ -202,9 +167,7 @@ function CardZap(): ReactElement { ? ycrvPrice || 0 : toAddress(selectedOptionFrom.value) === YCRV_CURVE_POOL_ADDRESS ? ycrvCurvePoolPrice || 0 - : balances?.[toAddress(selectedOptionFrom.value)]?.normalizedPrice || - vaults?.[toAddress(selectedOptionFrom.value)]?.tvl?.price || - 0 + : balances?.[toAddress(selectedOptionFrom.value)]?.normalizedPrice || vaults?.[toAddress(selectedOptionFrom.value)]?.tvl?.price || 0 )}

@@ -247,9 +210,7 @@ function CardZap(): ReactElement { ? ycrvPrice || 0 : toAddress(selectedOptionFrom.value) === YCRV_CURVE_POOL_ADDRESS ? ycrvCurvePoolPrice || 0 - : balances?.[toAddress(selectedOptionTo.value)]?.normalizedPrice || - vaults?.[toAddress(selectedOptionTo.value)]?.tvl?.price || - 0 + : balances?.[toAddress(selectedOptionTo.value)]?.normalizedPrice || vaults?.[toAddress(selectedOptionTo.value)]?.tvl?.price || 0 )}

diff --git a/apps/ycrv/components/Harvests.tsx b/apps/ycrv/components/Harvests.tsx index 65a96d411..8bc606225 100644 --- a/apps/ycrv/components/Harvests.tsx +++ b/apps/ycrv/components/Harvests.tsx @@ -1,11 +1,7 @@ import {useMemo, useState} from 'react'; import {Button} from '@yearn-finance/web-lib/components/Button'; import {toAddress} from '@yearn-finance/web-lib/utils/address'; -import { - LPYCRV_TOKEN_ADDRESS, - LPYCRV_V2_TOKEN_ADDRESS, - STYCRV_TOKEN_ADDRESS -} from '@yearn-finance/web-lib/utils/constants'; +import {LPYCRV_TOKEN_ADDRESS, LPYCRV_V2_TOKEN_ADDRESS, STYCRV_TOKEN_ADDRESS} from '@yearn-finance/web-lib/utils/constants'; import {HarvestListHead} from '@yCRV/components/HarvestsListHead'; import {HarvestListRow} from '@yCRV/components/HarvestsListRow'; import {useYCRV} from '@yCRV/contexts/useYCRV'; @@ -23,41 +19,25 @@ export function Harvests(): ReactElement { return _harvests.filter((harvest): boolean => toAddress(harvest.vaultAddress) === STYCRV_TOKEN_ADDRESS); } if (category === 'lp-yCRV') { - return _harvests.filter( - (harvest): boolean => - toAddress(harvest.vaultAddress) === LPYCRV_TOKEN_ADDRESS || - toAddress(harvest.vaultAddress) === LPYCRV_V2_TOKEN_ADDRESS - ); + return _harvests.filter((harvest): boolean => toAddress(harvest.vaultAddress) === LPYCRV_TOKEN_ADDRESS || toAddress(harvest.vaultAddress) === LPYCRV_V2_TOKEN_ADDRESS); } return _harvests; }, [category, harvests]); return (
-
+

{'Harvests'}

- - -
@@ -65,12 +45,7 @@ export function Harvests(): ReactElement {
{(filteredHarvests || [])?.map((harvest: TYDaemonVaultHarvest, index: number): ReactElement => { - return ( - - ); + return ; })}
diff --git a/apps/ycrv/components/HarvestsListRow.tsx b/apps/ycrv/components/HarvestsListRow.tsx index d51d4c360..c4722f64f 100755 --- a/apps/ycrv/components/HarvestsListRow.tsx +++ b/apps/ycrv/components/HarvestsListRow.tsx @@ -20,9 +20,7 @@ export function HarvestListRow({harvest}: {harvest: TYDaemonVaultHarvest}): Reac width={40} height={40} quality={90} - src={`${process.env.BASE_YEARN_ASSETS_URI}/1/${toAddress( - harvest.vaultAddress - )}/logo-128.png`} + src={`${process.env.BASE_YEARN_ASSETS_URI}/1/${toAddress(harvest.vaultAddress)}/logo-128.png`} loading={'eager'} />
@@ -33,16 +31,12 @@ export function HarvestListRow({harvest}: {harvest: TYDaemonVaultHarvest}): Reac

{'Gain'}

- - {formatAmount(formatToNormalizedValue(toBigInt(harvest.profit) - toBigInt(harvest.loss), 18))} - + {formatAmount(formatToNormalizedValue(toBigInt(harvest.profit) - toBigInt(harvest.loss), 18))}

{'Value'}

-

- {formatUSD(Number(harvest.profitValue) - Number(harvest.lossValue))} -

+

{formatUSD(Number(harvest.profitValue) - Number(harvest.lossValue))}

@@ -55,9 +49,7 @@ export function HarvestListRow({harvest}: {harvest: TYDaemonVaultHarvest}): Reac

{'Hash'}

-
+
{truncateHex(harvest.txHash, 6)}
diff --git a/apps/ycrv/components/QuickActions.tsx b/apps/ycrv/components/QuickActions.tsx index d2187802d..927095375 100644 --- a/apps/ycrv/components/QuickActions.tsx +++ b/apps/ycrv/components/QuickActions.tsx @@ -41,15 +41,7 @@ function QASelect(props: TQASelect): ReactElement { const {label, legend, options, selected, balanceSource, onSelect} = props; function renderMultipleOptionsFallback(): ReactElement { - return ( - undefined} - /> - ); + return undefined} />; } return ( @@ -62,20 +54,12 @@ function QASelect(props: TQASelect): ReactElement {
-
+
{selected?.icon}
-

- {selected?.symbol} -

+

{selected?.symbol}

@@ -100,8 +84,7 @@ function QASwitch(): ReactElement { } function QAInput(props: TQAInput): ReactElement { - const {className, label, legend, value, isDisabled, isMaxDisabled, onChange, onSetMaxAmount, type, ...inputProps} = - props; + const {className, label, legend, value, isDisabled, isMaxDisabled, onChange, onSetMaxAmount, type, ...inputProps} = props; return (
@@ -127,9 +110,7 @@ function QAInput(props: TQAInput): ReactElement {
- - {legend} - + {legend}
); } diff --git a/apps/ycrv/components/illustrations/how-it-works.tsx b/apps/ycrv/components/illustrations/how-it-works.tsx index 83243e1cd..4b71c508f 100644 --- a/apps/ycrv/components/illustrations/how-it-works.tsx +++ b/apps/ycrv/components/illustrations/how-it-works.tsx @@ -2,13 +2,7 @@ import type {ReactElement} from 'react'; export function HowItWorksDiagram(props: React.SVGProps): ReactElement { return ( - + diff --git a/apps/ycrv/constants/tokens.tsx b/apps/ycrv/constants/tokens.tsx index 160745a95..ee497c6f3 100644 --- a/apps/ycrv/constants/tokens.tsx +++ b/apps/ycrv/constants/tokens.tsx @@ -21,14 +21,7 @@ export const YVBOOST = { decimals: 18, value: YVBOOST_TOKEN_ADDRESS, zapVia: ZAP_YEARN_VE_CRV_ADDRESS, - icon: ( - - ) + icon: }; export const YVECRV = { @@ -37,16 +30,7 @@ export const YVECRV = { decimals: 18, value: YVECRV_TOKEN_ADDRESS, zapVia: ZAP_YEARN_VE_CRV_ADDRESS, - icon: ( - - ) + icon: }; export const STYCRV = { @@ -56,14 +40,7 @@ export const STYCRV = { value: STYCRV_TOKEN_ADDRESS, zapVia: ZAP_YEARN_VE_CRV_ADDRESS, icon: ( - + ) }; @@ -73,16 +50,7 @@ export const YCRV = { decimals: 18, value: YCRV_TOKEN_ADDRESS, zapVia: ZAP_YEARN_VE_CRV_ADDRESS, - icon: ( - - ) + icon: }; export const LPYCRV = { @@ -127,14 +95,7 @@ export const CRV = { decimals: 18, value: CRV_TOKEN_ADDRESS, zapVia: ZAP_YEARN_VE_CRV_ADDRESS, - icon: ( - - ) + icon: }; export const CVXCRV = { @@ -143,14 +104,7 @@ export const CVXCRV = { decimals: 18, value: CVXCRV_TOKEN_ADDRESS, zapVia: ZAP_YEARN_VE_CRV_ADDRESS, - icon: ( - - ) + icon: }; export const CRVYCRV = { @@ -159,14 +113,7 @@ export const CRVYCRV = { decimals: 18, value: YCRV_CURVE_POOL_ADDRESS, zapVia: LPYCRV_TOKEN_ADDRESS, - icon: ( - - ) + icon: }; export const CRVYCRV2 = { @@ -175,26 +122,8 @@ export const CRVYCRV2 = { decimals: 18, value: YCRV_CURVE_POOL_V2_ADDRESS, zapVia: LPYCRV_V2_TOKEN_ADDRESS, - icon: ( - - ) + icon: }; -export const ZAP_OPTIONS_FROM: TDropdownOption[] = [ - CRV, - STYCRV, - YCRV, - LPYCRV, - LPYCRV2, - CVXCRV, - CRVYCRV, - CRVYCRV2, - YVBOOST, - YVECRV -]; +export const ZAP_OPTIONS_FROM: TDropdownOption[] = [CRV, STYCRV, YCRV, LPYCRV, LPYCRV2, CVXCRV, CRVYCRV, CRVYCRV2, YVBOOST, YVECRV]; export const ZAP_OPTIONS_TO: TDropdownOption[] = [STYCRV, YCRV, LPYCRV2]; diff --git a/apps/ycrv/contexts/useAllowanceHook.tsx b/apps/ycrv/contexts/useAllowanceHook.tsx index f771e3a2e..18013eeb0 100644 --- a/apps/ycrv/contexts/useAllowanceHook.tsx +++ b/apps/ycrv/contexts/useAllowanceHook.tsx @@ -119,43 +119,19 @@ export function useAllowances(): [TDict, () => void] { } return [ { - [allowanceKey(1, YCRV_TOKEN_ADDRESS, ZAP_YEARN_VE_CRV_ADDRESS, toAddress(address))]: decodeAsBigInt( - data[0] - ), - [allowanceKey(1, STYCRV_TOKEN_ADDRESS, ZAP_YEARN_VE_CRV_ADDRESS, toAddress(address))]: decodeAsBigInt( - data[1] - ), - [allowanceKey(1, LPYCRV_TOKEN_ADDRESS, ZAP_YEARN_VE_CRV_ADDRESS, toAddress(address))]: decodeAsBigInt( - data[2] - ), - [allowanceKey(1, YVECRV_TOKEN_ADDRESS, ZAP_YEARN_VE_CRV_ADDRESS, toAddress(address))]: decodeAsBigInt( - data[3] - ), - [allowanceKey(1, CRV_TOKEN_ADDRESS, ZAP_YEARN_VE_CRV_ADDRESS, toAddress(address))]: decodeAsBigInt( - data[4] - ), - [allowanceKey(1, YVBOOST_TOKEN_ADDRESS, ZAP_YEARN_VE_CRV_ADDRESS, toAddress(address))]: decodeAsBigInt( - data[5] - ), - [allowanceKey(1, YCRV_CURVE_POOL_ADDRESS, LPYCRV_TOKEN_ADDRESS, toAddress(address))]: decodeAsBigInt( - data[6] - ), - [allowanceKey(1, CVXCRV_TOKEN_ADDRESS, ZAP_YEARN_VE_CRV_ADDRESS, toAddress(address))]: decodeAsBigInt( - data[7] - ), - [allowanceKey(1, YCRV_CURVE_POOL_V2_ADDRESS, ZAP_YEARN_VE_CRV_ADDRESS, toAddress(address))]: - decodeAsBigInt(data[8]), - [allowanceKey(1, YVECRV_TOKEN_ADDRESS, YVECRV_POOL_LP_ADDRESS, toAddress(address))]: decodeAsBigInt( - data[9] - ), - [allowanceKey(1, CRV_TOKEN_ADDRESS, YVECRV_POOL_LP_ADDRESS, toAddress(address))]: decodeAsBigInt( - data[10] - ), - [allowanceKey(1, YCRV_CURVE_POOL_ADDRESS, LPYCRV_TOKEN_ADDRESS, toAddress(address))]: decodeAsBigInt( - data[11] - ), - [allowanceKey(1, YCRV_CURVE_POOL_V2_ADDRESS, LPYCRV_V2_TOKEN_ADDRESS, toAddress(address))]: - decodeAsBigInt(data[12]) + [allowanceKey(1, YCRV_TOKEN_ADDRESS, ZAP_YEARN_VE_CRV_ADDRESS, toAddress(address))]: decodeAsBigInt(data[0]), + [allowanceKey(1, STYCRV_TOKEN_ADDRESS, ZAP_YEARN_VE_CRV_ADDRESS, toAddress(address))]: decodeAsBigInt(data[1]), + [allowanceKey(1, LPYCRV_TOKEN_ADDRESS, ZAP_YEARN_VE_CRV_ADDRESS, toAddress(address))]: decodeAsBigInt(data[2]), + [allowanceKey(1, YVECRV_TOKEN_ADDRESS, ZAP_YEARN_VE_CRV_ADDRESS, toAddress(address))]: decodeAsBigInt(data[3]), + [allowanceKey(1, CRV_TOKEN_ADDRESS, ZAP_YEARN_VE_CRV_ADDRESS, toAddress(address))]: decodeAsBigInt(data[4]), + [allowanceKey(1, YVBOOST_TOKEN_ADDRESS, ZAP_YEARN_VE_CRV_ADDRESS, toAddress(address))]: decodeAsBigInt(data[5]), + [allowanceKey(1, YCRV_CURVE_POOL_ADDRESS, LPYCRV_TOKEN_ADDRESS, toAddress(address))]: decodeAsBigInt(data[6]), + [allowanceKey(1, CVXCRV_TOKEN_ADDRESS, ZAP_YEARN_VE_CRV_ADDRESS, toAddress(address))]: decodeAsBigInt(data[7]), + [allowanceKey(1, YCRV_CURVE_POOL_V2_ADDRESS, ZAP_YEARN_VE_CRV_ADDRESS, toAddress(address))]: decodeAsBigInt(data[8]), + [allowanceKey(1, YVECRV_TOKEN_ADDRESS, YVECRV_POOL_LP_ADDRESS, toAddress(address))]: decodeAsBigInt(data[9]), + [allowanceKey(1, CRV_TOKEN_ADDRESS, YVECRV_POOL_LP_ADDRESS, toAddress(address))]: decodeAsBigInt(data[10]), + [allowanceKey(1, YCRV_CURVE_POOL_ADDRESS, LPYCRV_TOKEN_ADDRESS, toAddress(address))]: decodeAsBigInt(data[11]), + [allowanceKey(1, YCRV_CURVE_POOL_V2_ADDRESS, LPYCRV_V2_TOKEN_ADDRESS, toAddress(address))]: decodeAsBigInt(data[12]) }, refetch ]; diff --git a/apps/ycrv/contexts/useYCRV.tsx b/apps/ycrv/contexts/useYCRV.tsx index 65c42f47e..a60ce5565 100755 --- a/apps/ycrv/contexts/useYCRV.tsx +++ b/apps/ycrv/contexts/useYCRV.tsx @@ -1,9 +1,5 @@ import {createContext, useContext, useMemo, useState} from 'react'; -import { - LPYCRV_TOKEN_ADDRESS, - LPYCRV_V2_TOKEN_ADDRESS, - STYCRV_TOKEN_ADDRESS -} from '@yearn-finance/web-lib/utils/constants'; +import {LPYCRV_TOKEN_ADDRESS, LPYCRV_V2_TOKEN_ADDRESS, STYCRV_TOKEN_ADDRESS} from '@yearn-finance/web-lib/utils/constants'; import {useFetch} from '@common/hooks/useFetch'; import {yDaemonVaultHarvestsSchema, yDaemonVaultSchema} from '@common/schemas/yDaemonVaultsSchemas'; import {useYDaemonBaseURI} from '@common/utils/getYDaemonBaseURI'; diff --git a/pages/_app.tsx b/pages/_app.tsx index c7e5cfb8b..0cd76223c 100755 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -72,13 +72,7 @@ const WithLayout = memo(function WithLayout(props: AppProps): ReactElement { - + {getLayout(, router)} {!shouldHidePopover && } @@ -140,10 +134,7 @@ function NetworkStatusIndicator(): ReactElement { } return ( -
+
{"Updating data points, data may be inaccurate for a few minutes. Don't panic. DON'T PANIC!!!"}
diff --git a/pages/index.tsx b/pages/index.tsx index c722ce33a..4bfaaf1ac 100755 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -19,14 +19,7 @@ const apps = [ title: 'yCRV', description: 'get the best CRV yields in DeFi.', icon: ( - + ) }, // { @@ -225,11 +218,7 @@ function Index(): ReactElement {

- - { - 'Yearn is a decentralized suite of products helping individuals, DAOs, and other protocols\nearn yield on their digital assets.' - } - + {'Yearn is a decentralized suite of products helping individuals, DAOs, and other protocols\nearn yield on their digital assets.'}

diff --git a/pages/vaults/[chainID]/[address].tsx b/pages/vaults/[chainID]/[address].tsx index a01b22f8b..da7c1323c 100755 --- a/pages/vaults/[chainID]/[address].tsx +++ b/pages/vaults/[chainID]/[address].tsx @@ -29,9 +29,7 @@ function Index(): ReactElement | null { const {yDaemonBaseUri} = useYDaemonBaseURI({ chainID: Number(router.query.chainID) }); - const [currentVault, set_currentVault] = useState( - vaults[toAddress(router.query.address as string)] - ); + const [currentVault, set_currentVault] = useState(vaults[toAddress(router.query.address as string)]); const {data: vault, isLoading: isLoadingVault} = useFetch({ endpoint: `${yDaemonBaseUri}/vaults/${toAddress(router.query.address as string)}?${new URLSearchParams({ strategiesDetails: 'withDetails', @@ -76,9 +74,7 @@ function Index(): ReactElement | null { return (
-

- {"We couln't find this vault on the connected network."} -

+

{"We couln't find this vault on the connected network."}

); diff --git a/pages/vaults/about.tsx b/pages/vaults/about.tsx index 7c8aea3b3..5d25011b7 100755 --- a/pages/vaults/about.tsx +++ b/pages/vaults/about.tsx @@ -51,11 +51,7 @@ function About(): ReactElement {

{'For a full breakdown read more about our '} - + {'Risk Scores'} {'.'} @@ -111,14 +107,8 @@ function About(): ReactElement { }

- { - 'We can’t offer you a phone number with ambient jazz hold music to listen to - but please feel free to hop into our ' - } - + {'We can’t offer you a phone number with ambient jazz hold music to listen to - but please feel free to hop into our '} + {'discord'} {' if you have any questions, we’d love to chat.'} diff --git a/pages/vaults/factory.tsx b/pages/vaults/factory.tsx index 05313c4fb..5bcf89994 100644 --- a/pages/vaults/factory.tsx +++ b/pages/vaults/factory.tsx @@ -87,9 +87,7 @@ function Factory(): ReactElement { contracts: calls, chainId: _safeChainID }); - return _gaugesFromYearn.filter((_gauge: TCurveGaugeFromYearn, index: number): boolean => - decodeAsBoolean(canCreateVaults[index]) - ); + return _gaugesFromYearn.filter((_gauge: TCurveGaugeFromYearn, index: number): boolean => decodeAsBoolean(canCreateVaults[index])); }, []); useEffect((): void => { @@ -108,12 +106,7 @@ function Factory(): ReactElement { (gauge: TCurveGaugeFromYearn): TDropdownGaugeOption => ({ label: gauge.gauge_name, icon: ( - + ), value: { name: gauge.gauge_name, @@ -130,34 +123,31 @@ function Factory(): ReactElement { ** Name and symbol from the Curve API are not the one we want to display. ** We need to fetch the name and symbol from the gauge contract. **************************************************************************/ - const [{result: gaugeDisplayData, status}, fetchGaugeDisplayDataAction] = useAsync( - async function fetchGaugeDisplayData( - _safeChainID: number, - _selectedOption: TDropdownGaugeOption - ): Promise { - const baseContract = { - address: _selectedOption.value.gaugeAddress, - abi: erc20ABI - }; - const results = await multicall({ - contracts: [ - {...baseContract, functionName: 'name'}, - {...baseContract, functionName: 'symbol'} - ], - chainId: _safeChainID - }); + const [{result: gaugeDisplayData, status}, fetchGaugeDisplayDataAction] = useAsync(async function fetchGaugeDisplayData( + _safeChainID: number, + _selectedOption: TDropdownGaugeOption + ): Promise { + const baseContract = { + address: _selectedOption.value.gaugeAddress, + abi: erc20ABI + }; + const results = await multicall({ + contracts: [ + {...baseContract, functionName: 'name'}, + {...baseContract, functionName: 'symbol'} + ], + chainId: _safeChainID + }); - const name = decodeAsString(results[0]); - const symbol = decodeAsString(results[1]); - return { - name: name.replace('Curve.fi', '').replace('Gauge Deposit', '') || _selectedOption.value.name, - symbol: symbol.replace('-gauge', '').replace('-f', '') || _selectedOption.value.name, - poolAddress: _selectedOption.value.poolAddress, - gaugeAddress: _selectedOption.value.gaugeAddress - }; - }, - undefined - ); + const name = decodeAsString(results[0]); + const symbol = decodeAsString(results[1]); + return { + name: name.replace('Curve.fi', '').replace('Gauge Deposit', '') || _selectedOption.value.name, + symbol: symbol.replace('-gauge', '').replace('-f', '') || _selectedOption.value.name, + poolAddress: _selectedOption.value.poolAddress, + gaugeAddress: _selectedOption.value.gaugeAddress + }; + }, undefined); useEffect((): void => { fetchGaugeDisplayDataAction.execute(safeChainID, selectedOption); @@ -249,47 +239,31 @@ function Factory(): ReactElement {

{'Vault name'}

-
- {!gaugeDisplayData ? '' : `Curve ${gaugeDisplayData.name} Factory`} -
+
{!gaugeDisplayData ? '' : `Curve ${gaugeDisplayData.name} Factory`}

{'Symbol'}

-
- {!gaugeDisplayData ? '' : `yvCurve-${gaugeDisplayData.symbol}-f`} -
+
{!gaugeDisplayData ? '' : `yvCurve-${gaugeDisplayData.symbol}-f`}

{'Pool address'}

-
+
-

- {toAddress(gaugeDisplayData?.poolAddress)} -

+

{toAddress(gaugeDisplayData?.poolAddress)}

@@ -302,18 +276,11 @@ function Factory(): ReactElement {

{'Gauge address'}

-
+
-

- {toAddress(gaugeDisplayData?.gaugeAddress)} -

+

{toAddress(gaugeDisplayData?.gaugeAddress)}

@@ -331,12 +298,7 @@ function Factory(): ReactElement { diff --git a/pages/vaults/index.tsx b/pages/vaults/index.tsx index 10018b311..8cdf2404f 100644 --- a/pages/vaults/index.tsx +++ b/pages/vaults/index.tsx @@ -77,12 +77,7 @@ function HeaderUserPosition(): ReactElement {

{'Earnings'}

- +
@@ -97,16 +92,7 @@ function Index(): ReactElement { sortBy: TPossibleSortBy; sortDirection: TSortDirection; }>('yVaultsSorting', {sortBy: 'apy', sortDirection: 'desc'}); - const { - shouldHideDust, - shouldHideLowTVLVaults, - category, - searchValue, - selectedChains, - set_category, - set_searchValue, - set_selectedChains - } = useAppSettings(); + const {shouldHideDust, shouldHideLowTVLVaults, category, searchValue, selectedChains, set_category, set_searchValue, set_selectedChains} = useAppSettings(); const chains = JSON.parse(selectedChains) as number[]; @@ -171,9 +157,7 @@ function Index(): ReactElement { const balancerVaults = useFilteredVaults(vaults, ({category}): boolean => category === 'Balancer'); const cryptoVaults = useFilteredVaults(vaults, ({category}): boolean => category === 'Volatile'); const holdingsVaults = useFilteredVaults(vaults, ({address}): boolean => filterHoldingsCallback(address)); - const migratableVaults = useFilteredVaults(vaultsMigrations, ({address}): boolean => - filterMigrationCallback(address) - ); + const migratableVaults = useFilteredVaults(vaultsMigrations, ({address}): boolean => filterMigrationCallback(address)); const retiredVaults = useFilteredVaults(vaultsRetired, ({address}): boolean => filterMigrationCallback(address)); const categoriesToDisplay = useMemo((): TListHeroCategory[] => { @@ -240,9 +224,7 @@ function Index(): ReactElement { ** The possible lists are memoized to avoid unnecessary re-renders. **********************************************************************************************/ const vaultsToDisplay = useMemo((): TYDaemonVault[] => { - let _vaultList: TYDaemonVault[] = [...Object.values(vaults || {})].filter((v): boolean => - chains.includes(v.chainID) - ) as TYDaemonVault[]; + let _vaultList: TYDaemonVault[] = [...Object.values(vaults || {})].filter((v): boolean => chains.includes(v.chainID)) as TYDaemonVault[]; if (category === 'Curve Vaults') { _vaultList = curveVaults; @@ -259,9 +241,7 @@ function Index(): ReactElement { } else if (category === 'Holdings') { _vaultList = holdingsVaults; } else if (category === 'Featured Vaults') { - _vaultList.sort( - (a, b): number => (b.tvl.tvl || 0) * (b?.apy?.net_apy || 0) - (a.tvl.tvl || 0) * (a?.apy?.net_apy || 0) - ); + _vaultList.sort((a, b): number => (b.tvl.tvl || 0) * (b?.apy?.net_apy || 0) - (a.tvl.tvl || 0) * (a?.apy?.net_apy || 0)); _vaultList = _vaultList.slice(0, 10); } @@ -270,18 +250,7 @@ function Index(): ReactElement { } return _vaultList; - }, [ - vaults, - category, - shouldHideLowTVLVaults, - curveVaults, - balancerVaults, - velodromeVaults, - boostedVaults, - stablesVaults, - cryptoVaults, - holdingsVaults - ]); + }, [vaults, category, shouldHideLowTVLVaults, curveVaults, balancerVaults, velodromeVaults, boostedVaults, stablesVaults, cryptoVaults, holdingsVaults]); /* 🔵 - Yearn Finance ************************************************************************** ** Then, on the vaultsToDisplay list, we apply the search filter. The search filter is @@ -325,22 +294,10 @@ function Index(): ReactElement { **********************************************************************************************/ const VaultList = useMemo((): ReactNode => { if (isLoadingVaultList && category === 'Holdings') { - return ( - - ); + return ; } if (isLoadingVaultList || isZero(sortedVaultsToDisplay.length)) { - return ( - - ); + return ; } return sortedVaultsToDisplay.map((vault): ReactNode => { if (!vault) { @@ -373,19 +330,10 @@ function Index(): ReactElement { {'Holdings'} - - + + ) diff --git a/pages/ybal/about.tsx b/pages/ybal/about.tsx index 1e4cb4ae8..d51cede66 100755 --- a/pages/ybal/about.tsx +++ b/pages/ybal/about.tsx @@ -1,12 +1,7 @@ import {useState} from 'react'; import {Balancer} from 'react-wrap-balancer'; import {Button} from '@yearn-finance/web-lib/components/Button'; -import { - LPYBAL_TOKEN_ADDRESS, - STYBAL_TOKEN_ADDRESS, - YBAL_TOKEN_ADDRESS, - ZAP_YEARN_VE_CRV_ADDRESS -} from '@yearn-finance/web-lib/utils/constants'; +import {LPYBAL_TOKEN_ADDRESS, STYBAL_TOKEN_ADDRESS, YBAL_TOKEN_ADDRESS, ZAP_YEARN_VE_CRV_ADDRESS} from '@yearn-finance/web-lib/utils/constants'; import SettingsOverwrite from '@common/components/SettingsOverwrite'; import {useYBal} from '@yBal/contexts/useYBal'; import {Wrapper} from '@yBal/Wrapper'; @@ -24,11 +19,7 @@ function ContractListRow({label, address}: TContractListRowProps): ReactElement

{label} {': '} - + {address}

@@ -136,26 +127,16 @@ export function AboutContent(): ReactElement {
-

- { - 'Slippage is set to 1% and hidden by default to streamline the experience for the average user.' - } -

+

{'Slippage is set to 1% and hidden by default to streamline the experience for the average user.'}

{'For advanced apes users worried about MEV we advise using '} - + {'SecureRpc'} {'.'}

- { - 'If the above sentence causes your brain to wrinkle and eyes to glaze over, then you do not need to worry about this step. ' - } + {'If the above sentence causes your brain to wrinkle and eyes to glaze over, then you do not need to worry about this step. '}

@@ -164,19 +145,14 @@ export function AboutContent(): ReactElement { {'Slippage tolerance'}
-
+
{ set_localSlippage(parseFloat(e.target.value) || 0); @@ -184,20 +160,13 @@ export function AboutContent(): ReactElement { />

{'%'}

- - -
diff --git a/pages/ybal/index.tsx b/pages/ybal/index.tsx index c5cc009ad..6213d0b21 100755 --- a/pages/ybal/index.tsx +++ b/pages/ybal/index.tsx @@ -25,17 +25,12 @@ function HeaderPosition(): ReactElement { const lpyBalPrice = useTokenPrice(LPYBAL_TOKEN_ADDRESS); const formatedYearnHas = useMemo( - (): string => - holdings?.veBalBalance ? formatAmount(formatToNormalizedValue(holdings.veBalBalance, 18), 0, 0) : '', + (): string => (holdings?.veBalBalance ? formatAmount(formatToNormalizedValue(holdings.veBalBalance, 18), 0, 0) : ''), [holdings?.veBalBalance] ); const formatedYouHave = useMemo( - (): string => - formatCounterValueRaw( - balanceOfStyBal.normalized * styBalPrice + balanceOfLpyBal.normalized * lpyBalPrice, - 1 - ), + (): string => formatCounterValueRaw(balanceOfStyBal.normalized * styBalPrice + balanceOfLpyBal.normalized * lpyBalPrice, 1), [balanceOfStyBal.normalized, styBalPrice, balanceOfLpyBal.normalized, lpyBalPrice] ); @@ -44,23 +39,13 @@ function HeaderPosition(): ReactElement {

{'Yearn has'}

- +

{'You have'}

- +
@@ -90,9 +75,7 @@ function Holdings(): ReactElement {
{'PEG: '}

- {holdings?.balYBalPeg - ? formatPercent((formatToNormalizedValue(holdings?.balYBalPeg, 18) + 0.0015) * 100) - : formatPercent(0)} + {holdings?.balYBalPeg ? formatPercent((formatToNormalizedValue(holdings?.balYBalPeg, 18) + 0.0015) * 100) : formatPercent(0)}

@@ -126,9 +109,7 @@ function Holdings(): ReactElement {
{'Total Assets: '}

- {holdings?.styBalSupply - ? formatCounterValue(formatToNormalizedValue(holdings.styBalSupply, 18), yBalPrice) - : formatAmount(0)} + {holdings?.styBalSupply ? formatCounterValue(formatToNormalizedValue(holdings.styBalSupply, 18), yBalPrice) : formatAmount(0)}

@@ -168,12 +149,7 @@ function Holdings(): ReactElement {
{'Total Assets: '}

- {holdings?.lpyBalSupply - ? formatCounterValue( - formatToNormalizedValue(holdings.lpyBalSupply, 18), - lpyBalPrice - ) - : formatAmount(0)} + {holdings?.lpyBalSupply ? formatCounterValue(formatToNormalizedValue(holdings.lpyBalSupply, 18), lpyBalPrice) : formatAmount(0)}

diff --git a/pages/ybribe/about.tsx b/pages/ybribe/about.tsx index d25a7a79c..29f5e62ff 100755 --- a/pages/ybribe/about.tsx +++ b/pages/ybribe/about.tsx @@ -17,13 +17,9 @@ function About(): ReactElement {
+

{'yBribes pairs users looking to buy votes, with those looking to sell them. '}

- {'yBribes pairs users looking to buy votes, with those looking to sell them. '} -

-

- { - "You can sell your vote to the highest bidder by voting on briber's gauge and claiming rewards in exchange for your voting power." - } + {"You can sell your vote to the highest bidder by voting on briber's gauge and claiming rewards in exchange for your voting power."}

{ @@ -41,19 +37,13 @@ function About(): ReactElement {

- { - 'Claim periods run from thursday to thursday, and the scrolling clock on the main page displays the time remaining in the current period.' - } + {'Claim periods run from thursday to thursday, and the scrolling clock on the main page displays the time remaining in the current period.'}

- { - 'Make sure you claim any claimable rewards before the current period ends, and/ or submit your votes for the next period. ' - } + {'Make sure you claim any claimable rewards before the current period ends, and/ or submit your votes for the next period. '}

- { - "Be sure to claim any rewards before voting again on the same gauge or you'll be locked out of rewards until the following week." - } + {"Be sure to claim any rewards before voting again on the same gauge or you'll be locked out of rewards until the following week."}

@@ -71,9 +61,7 @@ function About(): ReactElement { }

- { - 'Holders who are not interested in directing rewards can instead sell their voting power to users who do. Win win.' - } + {'Holders who are not interested in directing rewards can instead sell their voting power to users who do. Win win.'}

diff --git a/pages/ybribe/index.tsx b/pages/ybribe/index.tsx index 4223fb25f..b957facd3 100755 --- a/pages/ybribe/index.tsx +++ b/pages/ybribe/index.tsx @@ -84,27 +84,21 @@ function GaugeList(): ReactElement { } if (sort.sortBy === 'rewards') { return searchedGauges.sort((a, b): number => { - const allARewards = Object.entries(currentRewards?.[toAddress(a.gauge)] || {}).reduce( - (acc, [address, value]): number => { - if (!isTAddress(address)) { - return 0; - } - const aBribeValue = getRewardValue(address, value || 0n); - return acc + aBribeValue; - }, - 0 - ); - - const allBRewards = Object.entries(currentRewards?.[toAddress(b.gauge)] || {}).reduce( - (acc, [address, value]): number => { - if (!isTAddress(address)) { - return 0; - } - const aBribeValue = getRewardValue(address, value || 0n); - return acc + aBribeValue; - }, - 0 - ); + const allARewards = Object.entries(currentRewards?.[toAddress(a.gauge)] || {}).reduce((acc, [address, value]): number => { + if (!isTAddress(address)) { + return 0; + } + const aBribeValue = getRewardValue(address, value || 0n); + return acc + aBribeValue; + }, 0); + + const allBRewards = Object.entries(currentRewards?.[toAddress(b.gauge)] || {}).reduce((acc, [address, value]): number => { + if (!isTAddress(address)) { + return 0; + } + const aBribeValue = getRewardValue(address, value || 0n); + return acc + aBribeValue; + }, 0); if (sort.sortDirection === 'desc') { return allBRewards - allARewards; @@ -114,27 +108,21 @@ function GaugeList(): ReactElement { } if (sort.sortBy === 'pendingRewards') { return searchedGauges.sort((a, b): number => { - const allARewards = Object.entries(nextRewards?.[toAddress(a.gauge)] || {}).reduce( - (acc, [address, value]): number => { - if (!isTAddress(address)) { - return 0; - } - const aBribeValue = getRewardValue(address, value || 0n); - return acc + aBribeValue; - }, - 0 - ); - - const allBRewards = Object.entries(nextRewards?.[toAddress(b.gauge)] || {}).reduce( - (acc, [address, value]): number => { - if (!isTAddress(address)) { - return 0; - } - const aBribeValue = getRewardValue(address, value || 0n); - return acc + aBribeValue; - }, - 0 - ); + const allARewards = Object.entries(nextRewards?.[toAddress(a.gauge)] || {}).reduce((acc, [address, value]): number => { + if (!isTAddress(address)) { + return 0; + } + const aBribeValue = getRewardValue(address, value || 0n); + return acc + aBribeValue; + }, 0); + + const allBRewards = Object.entries(nextRewards?.[toAddress(b.gauge)] || {}).reduce((acc, [address, value]): number => { + if (!isTAddress(address)) { + return 0; + } + const aBribeValue = getRewardValue(address, value || 0n); + return acc + aBribeValue; + }, 0); if (sort.sortDirection === 'desc') { return allBRewards - allARewards; @@ -243,9 +231,7 @@ function Index(): ReactElement { {'Get more for your votes.'}

- { - "Sell your vote to the highest bidder by voting on the briber's gauge and claiming a reward.\nIt's like DC lobbying, but without the long lunches." - } + {"Sell your vote to the highest bidder by voting on the briber's gauge and claiming a reward.\nIt's like DC lobbying, but without the long lunches."}

diff --git a/pages/ybribe/offer-bribe.tsx b/pages/ybribe/offer-bribe.tsx index de966c48f..bdaa0f609 100755 --- a/pages/ybribe/offer-bribe.tsx +++ b/pages/ybribe/offer-bribe.tsx @@ -84,21 +84,15 @@ function GaugeList(): ReactElement { } if (sort.sortBy === 'rewards') { return searchedGauges.sort((a, b): number => { - const allARewards = Object.entries(currentRewards?.[toAddress(a.gauge)] || {}).reduce( - (acc, [address, value]): number => { - const aBribeValue = getRewardValue(address, value || 0n); - return acc + aBribeValue; - }, - 0 - ); - - const allBRewards = Object.entries(currentRewards?.[toAddress(b.gauge)] || {}).reduce( - (acc, [address, value]): number => { - const aBribeValue = getRewardValue(address, value || 0n); - return acc + aBribeValue; - }, - 0 - ); + const allARewards = Object.entries(currentRewards?.[toAddress(a.gauge)] || {}).reduce((acc, [address, value]): number => { + const aBribeValue = getRewardValue(address, value || 0n); + return acc + aBribeValue; + }, 0); + + const allBRewards = Object.entries(currentRewards?.[toAddress(b.gauge)] || {}).reduce((acc, [address, value]): number => { + const aBribeValue = getRewardValue(address, value || 0n); + return acc + aBribeValue; + }, 0); if (sort.sortDirection === 'desc') { return allBRewards - allARewards; @@ -108,21 +102,15 @@ function GaugeList(): ReactElement { } if (sort.sortBy === 'pendingRewards') { return searchedGauges.sort((a, b): number => { - const allARewards = Object.entries(nextRewards?.[toAddress(a.gauge)] || {}).reduce( - (acc, [address, value]): number => { - const aBribeValue = getRewardValue(address, value || 0n); - return acc + aBribeValue; - }, - 0 - ); - - const allBRewards = Object.entries(nextRewards?.[toAddress(b.gauge)] || {}).reduce( - (acc, [address, value]): number => { - const aBribeValue = getRewardValue(address, value || 0n); - return acc + aBribeValue; - }, - 0 - ); + const allARewards = Object.entries(nextRewards?.[toAddress(a.gauge)] || {}).reduce((acc, [address, value]): number => { + const aBribeValue = getRewardValue(address, value || 0n); + return acc + aBribeValue; + }, 0); + + const allBRewards = Object.entries(nextRewards?.[toAddress(b.gauge)] || {}).reduce((acc, [address, value]): number => { + const aBribeValue = getRewardValue(address, value || 0n); + return acc + aBribeValue; + }, 0); if (sort.sortDirection === 'desc') { return allBRewards - allARewards; @@ -227,9 +215,7 @@ function OfferBribe(): ReactElement { {'Buy votes to boost emissions.'}

- { - 'Offer a bribe to increase CRV emissions to your favorite Curve pool.\nJust like democracy, minus the suit and expense account.' - } + {'Offer a bribe to increase CRV emissions to your favorite Curve pool.\nJust like democracy, minus the suit and expense account.'}

diff --git a/pages/ycrv/about.tsx b/pages/ycrv/about.tsx index 48dff2915..193c0c6af 100755 --- a/pages/ycrv/about.tsx +++ b/pages/ycrv/about.tsx @@ -1,12 +1,7 @@ import {useState} from 'react'; import {Balancer} from 'react-wrap-balancer'; import {Button} from '@yearn-finance/web-lib/components/Button'; -import { - LPYCRV_V2_TOKEN_ADDRESS, - STYCRV_TOKEN_ADDRESS, - YCRV_TOKEN_ADDRESS, - ZAP_YEARN_VE_CRV_ADDRESS -} from '@yearn-finance/web-lib/utils/constants'; +import {LPYCRV_V2_TOKEN_ADDRESS, STYCRV_TOKEN_ADDRESS, YCRV_TOKEN_ADDRESS, ZAP_YEARN_VE_CRV_ADDRESS} from '@yearn-finance/web-lib/utils/constants'; import SettingsOverwrite from '@common/components/SettingsOverwrite'; import {useYCRV} from '@yCRV/contexts/useYCRV'; import {Wrapper} from '@yCRV/Wrapper'; @@ -24,11 +19,7 @@ function ContractListRow({label, address}: TContractListRowProps): ReactElement

{label} {': '} - + {address}

@@ -55,11 +46,7 @@ function About(): ReactElement {

{'For more info on each token, and how to use the UI read our '} - + {'docs'} {'.'} @@ -82,9 +69,7 @@ function About(): ReactElement { {'lp-yCRV'} {' is generating better yield, you can swap anytime on the main page. Or vice versa.'}

-

- {'You get more yield, and a fun swap experience. Win win.'} -

+

{'You get more yield, and a fun swap experience. Win win.'}

@@ -97,9 +82,7 @@ function About(): ReactElement {

- { - 'By simplifying our product (and naming conventions) we can focus on getting users the best ‘hands off’ yield around.' - } + {'By simplifying our product (and naming conventions) we can focus on getting users the best ‘hands off’ yield around.'}

{'yCRV'} @@ -152,26 +135,16 @@ function About(): ReactElement {

-

- { - 'Slippage is set to 1% and hidden by default to streamline the experience for the average user.' - } -

+

{'Slippage is set to 1% and hidden by default to streamline the experience for the average user.'}

{'For advanced apes users worried about MEV we advise using '} - + {'SecureRpc'} {'.'}

- { - 'If the above sentence causes your brain to wrinkle and eyes to glaze over, then you do not need to worry about this step. ' - } + {'If the above sentence causes your brain to wrinkle and eyes to glaze over, then you do not need to worry about this step. '}

@@ -180,19 +153,14 @@ function About(): ReactElement { {'Slippage tolerance'}
-
+
{ set_localSlippage(parseFloat(e.target.value) || 0); @@ -200,20 +168,13 @@ function About(): ReactElement { />

{'%'}

- - -
@@ -227,9 +188,7 @@ function About(): ReactElement {
-

- {'Well anon, when a gauge and a pool love each other very much...'} -

+

{'Well anon, when a gauge and a pool love each other very much...'}

{'st-yCRV'}

{ diff --git a/pages/ycrv/index.tsx b/pages/ycrv/index.tsx index 6e42abed3..5b7c22503 100755 --- a/pages/ycrv/index.tsx +++ b/pages/ycrv/index.tsx @@ -1,12 +1,7 @@ import {Fragment, useMemo} from 'react'; import {VaultsListInternalMigrationRow} from '@vaults/components/list/VaultsListInternalMigrationRow'; import {cl} from '@yearn-finance/web-lib/utils/cl'; -import { - LPYCRV_TOKEN_ADDRESS, - LPYCRV_V2_TOKEN_ADDRESS, - STYCRV_TOKEN_ADDRESS, - YCRV_TOKEN_ADDRESS -} from '@yearn-finance/web-lib/utils/constants'; +import {LPYCRV_TOKEN_ADDRESS, LPYCRV_V2_TOKEN_ADDRESS, STYCRV_TOKEN_ADDRESS, YCRV_TOKEN_ADDRESS} from '@yearn-finance/web-lib/utils/constants'; import {formatBigNumberOver10K, formatToNormalizedValue, toBigInt} from '@yearn-finance/web-lib/utils/format.bigNumber'; import {formatAmount, formatNumberOver10K, formatPercent} from '@yearn-finance/web-lib/utils/format.number'; import {formatCounterValue, formatCounterValueRaw} from '@yearn-finance/web-lib/utils/format.value'; @@ -35,27 +30,13 @@ function HeaderPosition(): ReactElement { const lpycrvV2Price = useTokenPrice(LPYCRV_V2_TOKEN_ADDRESS); const formatedYearnHas = useMemo( - (): string => - holdings?.veCRVBalance ? formatAmount(formatToNormalizedValue(holdings.veCRVBalance, 18), 0, 0) : '', + (): string => (holdings?.veCRVBalance ? formatAmount(formatToNormalizedValue(holdings.veCRVBalance, 18), 0, 0) : ''), [holdings?.veCRVBalance] ); const formatedYouHave = useMemo( - (): string => - formatCounterValueRaw( - balanceOfStyCRV.normalized * stycrvPrice + - balanceOfLpyCRV.normalized * lpycrvPrice + - balanceOfLpyCRVV2.normalized * lpycrvV2Price, - 1 - ), - [ - balanceOfStyCRV.normalized, - stycrvPrice, - balanceOfLpyCRV.normalized, - lpycrvPrice, - balanceOfLpyCRVV2.normalized, - lpycrvV2Price - ] + (): string => formatCounterValueRaw(balanceOfStyCRV.normalized * stycrvPrice + balanceOfLpyCRV.normalized * lpycrvPrice + balanceOfLpyCRVV2.normalized * lpycrvV2Price, 1), + [balanceOfStyCRV.normalized, stycrvPrice, balanceOfLpyCRV.normalized, lpycrvPrice, balanceOfLpyCRVV2.normalized, lpycrvV2Price] ); return ( @@ -63,12 +44,7 @@ function HeaderPosition(): ReactElement {

{'Yearn has'}

- +
@@ -112,13 +88,7 @@ function ZapAndStats(): ReactElement { }, [curveWeeklyFees]); const currentVeCRVAPY = useMemo((): number => { - return ( - (latestCurveFeesValue / - (formatToNormalizedValue(toBigInt(holdings?.veCRVTotalSupply), 18) * - cgPrices?.['curve-dao-token']?.usd)) * - 52 * - 100 - ); + return (latestCurveFeesValue / (formatToNormalizedValue(toBigInt(holdings?.veCRVTotalSupply), 18) * cgPrices?.['curve-dao-token']?.usd)) * 52 * 100; }, [holdings, latestCurveFeesValue, cgPrices]); const curveAdminFeePercent = useMemo((): number => { @@ -139,9 +109,7 @@ function ZapAndStats(): ReactElement {
{'Price/PEG: '}

- {`Price = $${formatAmount(ycrvPrice || 0)} | Peg = ${ - holdings?.crvYCRVPeg ? formatPercent(crvYCRVPeg * 100) : formatPercent(0) - }`} + {`Price = $${formatAmount(ycrvPrice || 0)} | Peg = ${holdings?.crvYCRVPeg ? formatPercent(crvYCRVPeg * 100) : formatPercent(0)}`}

@@ -188,40 +156,19 @@ function ZapAndStats(): ReactElement { {`${formatPercent(styCRVAPY ?? 0)}*`} - -
+ +
-

- {styCRVAPY - ? `*${formatPercent(styCRVAPY)} APY: ` - : `*${formatPercent(0)} APY: `} +

+ {styCRVAPY ? `*${formatPercent(styCRVAPY)} APY: ` : `*${formatPercent(0)} APY: `}

-

- {`∙ ${ - curveAdminFeePercent - ? formatPercent(curveAdminFeePercent) - : formatPercent(0) - } Curve Admin Fees (${formatAmount( +

+ {`∙ ${curveAdminFeePercent ? formatPercent(curveAdminFeePercent) : formatPercent(0)} Curve Admin Fees (${formatAmount( Number(holdings?.boostMultiplier) / 10000 )}x boost)`}

-

- {`∙ ${ - styCRVAPY && curveAdminFeePercent - ? formatAmount(styCRVAPY - curveAdminFeePercent, 2, 2) - : '0.00' - }% Gauge Voting Bribes`} +

+ {`∙ ${styCRVAPY && curveAdminFeePercent ? formatAmount(styCRVAPY - curveAdminFeePercent, 2, 2) : '0.00'}% Gauge Voting Bribes`}

@@ -231,9 +178,7 @@ function ZapAndStats(): ReactElement {
{'Total Assets: '}

- {holdings?.styCRVSupply - ? formatCounterValue(formatToNormalizedValue(holdings.styCRVSupply, 18), ycrvPrice) - : formatAmount(0)} + {holdings?.styCRVSupply ? formatCounterValue(formatToNormalizedValue(holdings.styCRVSupply, 18), ycrvPrice) : formatAmount(0)}

@@ -273,12 +218,7 @@ function ZapAndStats(): ReactElement {
{'Total Assets: '}

- {holdings?.lpyCRVV2Supply - ? formatCounterValue( - formatToNormalizedValue(holdings.lpyCRVV2Supply, 18), - lpycrvV2Price - ) - : formatAmount(0)} + {holdings?.lpyCRVV2Supply ? formatCounterValue(formatToNormalizedValue(holdings.lpyCRVV2Supply, 18), lpycrvV2Price) : formatAmount(0)}

@@ -319,12 +259,7 @@ function ZapAndStats(): ReactElement {
{'Total Assets: '}

- {holdings?.lpyCRVSupply - ? formatCounterValue( - formatToNormalizedValue(holdings.lpyCRVSupply, 18), - lpycrvPrice - ) - : formatAmount(0)} + {holdings?.lpyCRVSupply ? formatCounterValue(formatToNormalizedValue(holdings.lpyCRVSupply, 18), lpycrvPrice) : formatAmount(0)}

@@ -348,11 +283,7 @@ function Holdings(): ReactElement { const hasLegacyLpyCRV = !!vaultsMigrations[LPYCRV_TOKEN_ADDRESS] && balance.raw > 0n; return ( -
+
{hasLegacyLpyCRV && (