diff --git a/apps/common/components/Dropdown.tsx b/apps/common/components/Dropdown.tsx index 87b40259c..3415d43af 100644 --- a/apps/common/components/Dropdown.tsx +++ b/apps/common/components/Dropdown.tsx @@ -44,7 +44,7 @@ const DropdownOption = (option: TDropdownOption): ReactElement => { }; const DropdownEmpty = ({isSearching}: {isSearching: boolean}): ReactElement => { - if(isSearching) { + if (!isSearching) { return (
@@ -170,10 +170,8 @@ export const Dropdown = ({selected, options, onChange, label, legend, isDisabled leaveFrom={'transform scale-100 opacity-100'} leaveTo={'transform scale-95 opacity-0'} afterLeave={(): void => { - performBatchedUpdates((): void => { - set_isOpen(false); - set_search(''); - }); + set_isOpen(false); + set_search(''); }}> {filteredOptions.length === 0 ? ( diff --git a/apps/common/contexts/useWallet.tsx b/apps/common/contexts/useWallet.tsx index b57649c00..35b3f1a11 100755 --- a/apps/common/contexts/useWallet.tsx +++ b/apps/common/contexts/useWallet.tsx @@ -105,20 +105,6 @@ export const WalletContextApp = memo(function WalletContextApp({children}: {chil extraTokens.push({token: OPT_YVWUSDRV2_USDC_STAKING_CONTRACT, symbol: 'yvVelo-wUSDRv2-USDC', decimals: 18}); extraTokens.push({token: OPT_YVSTERN_ERN_STAKING_CONTRACT, symbol: 'yvVelo-stERN-ERN', decimals: 18}); } - if (safeChainID === 250) { - extraTokens.push(...[ - {token: toAddress('0x28D374F0cdabb327A034BA41B9A2967E2959fb1F')}, //TODO: Remove it - veYFI test - {token: toAddress('0xb8E45b5C3E49A9a4C2A086deAF59f7De19c100cC')}, //TODO: Remove it - veYFI test - {token: toAddress('0x2Cc4b29771fcAA71313dC946a89eDd1AA68292E2')}, //TODO: Remove it - veYFI test - {token: toAddress('0x9Cb511D44930c0C3D3114FFAaBedC3e0876D791a')}, //TODO: Remove it - veYFI test - {token: toAddress('0xC85509a31F218e66A7151A48e218AD98469Cbf4A')}, //TODO: Remove it - veYFI test - {token: toAddress('0x52Ca0fC251e7a28cf8E67357BCD3d771B105eCa9')}, //TODO: Remove it - veYFI test - {token: toAddress('0xbADfbF563C6C85F76e086E7a1915A1A46d683810')}, //TODO: Remove it - veYFI test - {token: toAddress('0xd5947C01dBaEFeFF05186FE34A976b2E28d90542')}, //TODO: Remove it - veYFI test - {token: toAddress('0x2262ef7F5A0171D9dBC16963727249787575cE42')}, //TODO: Remove it - veYFI test - {token: toAddress('0x79a37e400bC591f1B38e4Fe020Ec1f985F670218')} //TODO: Remove it - veYFI test - ]); - } for (const token of extraTokens) { tokensExists[token.token] = true; tokens.push(token); diff --git a/apps/common/hooks/useTimer.ts b/apps/common/hooks/useTimer.ts index cc61f52dd..d42e61b12 100755 --- a/apps/common/hooks/useTimer.ts +++ b/apps/common/hooks/useTimer.ts @@ -10,7 +10,6 @@ type TProps = { endTime?: TSeconds; } -// TODO Check if we can use `getTimeUntil` from the web lib for this computation export function computeTimeLeft({endTime}: {endTime?: TSeconds}): number { if (!endTime) { return 0; diff --git a/apps/common/hooks/useTokenPrice.ts b/apps/common/hooks/useTokenPrice.ts index d6651b959..bc557a5d9 100644 --- a/apps/common/hooks/useTokenPrice.ts +++ b/apps/common/hooks/useTokenPrice.ts @@ -1,7 +1,5 @@ import {useMemo} from 'react'; -import {VEYFI_DYFI_ADDRESS} from '@veYFI/utils/constants'; -import {ETH_TOKEN_ADDRESS, YFI_ADDRESS} from '@yearn-finance/web-lib/utils/constants'; import {formatToNormalizedValue, toBigInt} from '@yearn-finance/web-lib/utils/format.bigNumber'; import {useYearn} from '@common/contexts/useYearn'; @@ -11,15 +9,6 @@ export function useTokenPrice(address: TAddress): number { const {prices} = useYearn(); const tokenPrice = useMemo((): number => { - if (address === YFI_ADDRESS) { - return 5150.96; //TODO: REMOVE - } - if (address === ETH_TOKEN_ADDRESS) { - return 1601.69; //TODO: REMOVE - } - if (address === VEYFI_DYFI_ADDRESS) { - return 4557.85; //TODO: REMOVe - } return formatToNormalizedValue(toBigInt(prices?.[address] || 0), 6); }, [address, prices]); diff --git a/apps/veyfi/components/GaugesTab.tsx b/apps/veyfi/components/GaugesTab.tsx index 021e046e8..b4f03cc64 100644 --- a/apps/veyfi/components/GaugesTab.tsx +++ b/apps/veyfi/components/GaugesTab.tsx @@ -143,7 +143,7 @@ export function GaugesTab(): ReactElement { vaultDeposited: balances[vaultAddress], gaugeApy: 0, // TODO: gauge apy calcs gaugeBoost: positionsMap[address]?.boost ?? 1, - gaugeStaked: positionsMap[address]?.deposit.balance ?? toNormalizedBN(0), + gaugeStaked: positionsMap[address]?.deposit ?? toNormalizedBN(0), allowance: allowancesMap[allowanceKey(VEYFI_CHAIN_ID, vaultAddress, address, userAddress)], isApproved: toBigInt(allowancesMap[allowanceKey(VEYFI_CHAIN_ID, vaultAddress, address, userAddress)]?.raw) >= toBigInt(balances[vaultAddress]?.raw), actions: undefined diff --git a/apps/veyfi/components/RewardsTab.tsx b/apps/veyfi/components/RewardsTab.tsx index 80be95609..447b12bb6 100644 --- a/apps/veyfi/components/RewardsTab.tsx +++ b/apps/veyfi/components/RewardsTab.tsx @@ -25,7 +25,7 @@ export function RewardsTab(): ReactElement { const refreshData = useCallback((): unknown => Promise.all([refreshGauges()]), [refreshGauges]); const [claimStatus, set_claimStatus] = useState(defaultTxStatus); const selectedGaugeAddress = toAddress(selectedGauge?.id); - const selectedGaugeRewards = toNormalizedBN(toBigInt(positionsMap[selectedGaugeAddress]?.reward?.balance?.raw)); + const selectedGaugeRewards = positionsMap[selectedGaugeAddress]?.reward ?? toNormalizedBN(0n); const onClaim = useCallback(async (): Promise => { const result = await GaugeActions.claimRewards({ @@ -39,7 +39,7 @@ export function RewardsTab(): ReactElement { } }, [provider, refreshData, selectedGaugeAddress]); - const gaugeOptions = gaugeAddresses.filter((address): boolean => toBigInt(positionsMap[address]?.reward?.balance?.raw) > 0n ?? false) + const gaugeOptions = gaugeAddresses.filter((address): boolean => toBigInt(positionsMap[address]?.reward?.raw) > 0n ?? false) .map((address): TDropdownOption => { const gauge = gaugesMap[address]; const vaultAddress = toAddress(gauge?.vaultAddress); diff --git a/apps/veyfi/contexts/useGauge.tsx b/apps/veyfi/contexts/useGauge.tsx index 7821d1966..a08926204 100644 --- a/apps/veyfi/contexts/useGauge.tsx +++ b/apps/veyfi/contexts/useGauge.tsx @@ -2,7 +2,7 @@ import React, {createContext, memo, useCallback, useContext, useState} from 'rea import {FixedNumber} from 'ethers'; import {useDeepCompareMemo} from '@react-hookz/web'; import {VEYFI_GAUGE_ABI} from '@veYFI/utils/abi/veYFIGauge.abi'; -import {VEYFI_CHAIN_ID} from '@veYFI/utils/constants'; +import {VE_YFI_GAUGES,VEYFI_CHAIN_ID} from '@veYFI/utils/constants'; import {erc20ABI, readContracts} from '@wagmi/core'; import {useWeb3} from '@yearn-finance/web-lib/contexts/useWeb3'; import {allowanceKey, toAddress} from '@yearn-finance/web-lib/utils/address'; @@ -25,15 +25,10 @@ export type TGauge = { // apy?: number; } -export type TPosition = { - balance: TNormalizedBN, - underlyingBalance: TNormalizedBN, -} - export type TGaugePosition = { address: TAddress, - deposit: TPosition, - reward: TPosition, + deposit: TNormalizedBN, + reward: TNormalizedBN, boost: number, } @@ -59,27 +54,8 @@ export const GaugeContextApp = memo(function GaugeContextApp({children}: {childr const [allowancesMap, set_allowancesMap] = useState>({}); const [positionsMap, set_positionsMap] = useState>({}); - // const {data: vaultAddresses} = useContractRead({ - // address: VEYFI_REGISTRY_ADDRESS, - // abi: VEYFI_REGISTRY_ABI, - // functionName: 'getVaults', - // chainId: VEYFI_CHAIN_ID - // }); - // const vaultAddresses = [ - // toAddress('0x28D374F0cdabb327A034BA41B9A2967E2959fb1F'), - // toAddress('0xb8E45b5C3E49A9a4C2A086deAF59f7De19c100cC'), - // toAddress('0x2Cc4b29771fcAA71313dC946a89eDd1AA68292E2'), - // toAddress('0x9Cb511D44930c0C3D3114FFAaBedC3e0876D791a') - // ]; - const refreshVotingEscrow = useAsyncTrigger(async (): Promise => { - const gaugeAddresses = [ - toAddress('0xbADfbF563C6C85F76e086E7a1915A1A46d683810'), - toAddress('0xd5947C01dBaEFeFF05186FE34A976b2E28d90542'), - toAddress('0x2262ef7F5A0171D9dBC16963727249787575cE42'), - toAddress('0x79a37e400bC591f1B38e4Fe020Ec1f985F670218') - ]; - const gaugePromises = gaugeAddresses.map(async (gaugeAddress): Promise => { + const gaugePromises = VE_YFI_GAUGES.map(async (gaugeAddress): Promise => { const results = await readContracts({ contracts: [ {address: gaugeAddress, abi: VEYFI_GAUGE_ABI, chainId: VEYFI_CHAIN_ID, functionName: 'asset'}, @@ -177,15 +153,8 @@ export const GaugeContextApp = memo(function GaugeContextApp({children}: {childr const earned = decodeAsBigInt(results[1]); const boostedBalance = decodeAsBigInt(results[2]); const decimals = Number(decodeAsBigInt(results[3])) || decodeAsNumber(results[3]); - const depositPosition: TPosition = { - balance: toNormalizedBN(balance, decimals), - underlyingBalance: toNormalizedBN(balance, decimals) // TODO: convert to underlying - }; - - const rewardPosition: TPosition = { - balance: toNormalizedBN(earned, decimals), - underlyingBalance: toNormalizedBN(earned, decimals) // TODO: convert to underlying - }; + const depositPosition: TNormalizedBN = toNormalizedBN(balance, decimals); + const rewardPosition: TNormalizedBN = toNormalizedBN(earned, decimals); const boostRatio = balance > 0n ? FixedNumber.from(boostedBalance).divUnsafe(FixedNumber.from(balance)).toUnsafeFloat() diff --git a/apps/veyfi/contexts/useVotingEscrow.tsx b/apps/veyfi/contexts/useVotingEscrow.tsx index 9315f861c..4b8030afb 100644 --- a/apps/veyfi/contexts/useVotingEscrow.tsx +++ b/apps/veyfi/contexts/useVotingEscrow.tsx @@ -2,10 +2,10 @@ import {createContext, memo, useCallback, useContext, useMemo} from 'react'; import {erc20ABI, useContractRead, useContractReads} from 'wagmi'; import {VEYFI_ABI} from '@veYFI/utils/abi/veYFI.abi'; import {VEYFI_POSITION_HELPER_ABI} from '@veYFI/utils/abi/veYFIPositionHelper.abi'; -import {VEYFI_CHAIN_ID, YFI_ADDRESS} from '@veYFI/utils/constants'; +import {VEYFI_CHAIN_ID} from '@veYFI/utils/constants'; import {useWeb3} from '@yearn-finance/web-lib/contexts/useWeb3'; import {allowanceKey, isZeroAddress, toAddress} from '@yearn-finance/web-lib/utils/address'; -import {VEYFI_ADDRESS, VEYFI_POSITION_HELPER_ADDRESS} from '@yearn-finance/web-lib/utils/constants'; +import {VEYFI_ADDRESS, VEYFI_POSITION_HELPER_ADDRESS,YFI_ADDRESS} from '@yearn-finance/web-lib/utils/constants'; import {decodeAsBigInt, decodeAsNumber, decodeAsString} from '@yearn-finance/web-lib/utils/decoder'; import {toMilliseconds} from '@yearn-finance/web-lib/utils/time'; diff --git a/apps/veyfi/utils/abi/veYFIClaimRewardsZap.abi.ts b/apps/veyfi/utils/abi/veYFIClaimRewardsZap.abi.ts index f0f823276..d3c5eb586 100644 --- a/apps/veyfi/utils/abi/veYFIClaimRewardsZap.abi.ts +++ b/apps/veyfi/utils/abi/veYFIClaimRewardsZap.abi.ts @@ -1,2 +1 @@ -// TODO: update once final version deployed export const VEYFI_CLAIM_REWARDS_ZAP_ABI = ['function claim(address[] calldata _gauges, bool _lock, bool _claimVeYfi) external']; diff --git a/apps/veyfi/utils/abi/veYFIRegistry.abi.ts b/apps/veyfi/utils/abi/veYFIRegistry.abi.ts index 42b9e70a6..028723c5a 100644 --- a/apps/veyfi/utils/abi/veYFIRegistry.abi.ts +++ b/apps/veyfi/utils/abi/veYFIRegistry.abi.ts @@ -1,4 +1,3 @@ -// TODO: update once final version deployed export const VEYFI_REGISTRY_ABI = [ { 'inputs': [ diff --git a/apps/veyfi/utils/constants.ts b/apps/veyfi/utils/constants.ts index 643f87d6c..a9b167591 100644 --- a/apps/veyfi/utils/constants.ts +++ b/apps/veyfi/utils/constants.ts @@ -1,16 +1,13 @@ import {toAddress} from '@yearn-finance/web-lib/utils/address'; -import {YFI_ADDRESS as MAINNET_YFI_ADDRESS} from '@yearn-finance/web-lib/utils/constants'; import type {TAddress} from '@yearn-finance/web-lib/types'; import type {TWeeks} from '@yearn-finance/web-lib/utils/time'; -export const VEYFI_CHAIN_ID = 250; //TODO: change it to 1 - veYFI test +export const VEYFI_CHAIN_ID = 1; -export const YFI_ADDRESS = toAddress('0x52Ca0fC251e7a28cf8E67357BCD3d771B105eCa9') || MAINNET_YFI_ADDRESS; // TODO: change to MAINNET_YFI_ADDRESS export const VEYFI_REGISTRY_ADDRESS: TAddress = toAddress(''); // TODO: update once deployed -export const VEYFI_CLAIM_REWARDS_ZAP_ADDRESS: TAddress = toAddress(''); // TODO: update once deployed -export const VEYFI_OPTIONS_ADDRESS = toAddress('0x16A0cE5957642aDa37F58d5115E38fF3B0C30dc6'); //TODO: change it - veYFI test -export const VEYFI_DYFI_ADDRESS = toAddress('0xC85509a31F218e66A7151A48e218AD98469Cbf4A'); //TODO: change it for prod: 0x41252E8691e964f7DE35156B68493bAb6797a275 +export const VEYFI_OPTIONS_ADDRESS = toAddress('0x2fBa208E1B2106d40DaA472Cb7AE0c6C7EFc0224'); +export const VEYFI_DYFI_ADDRESS = toAddress('0x41252E8691e964f7DE35156B68493bAb6797a275'); export const SNAPSHOT_DELEGATE_REGISTRY_ADDRESS = toAddress('0x469788fE6E9E9681C6ebF3bF78e7Fd26Fc015446'); export const YEARN_SNAPSHOT_SPACE = 'veyfi.eth'; @@ -19,3 +16,8 @@ export const MAX_LOCK_TIME: TWeeks = 208; export const MIN_LOCK_TIME: TWeeks = 1; export const MIN_LOCK_AMOUNT: TWeeks = 1; +export const VE_YFI_GAUGES = [ + toAddress('0x7Fd8Af959B54A677a1D8F92265Bd0714274C56a3'), // YFI/ETH yVault + toAddress('0x107717C98C8125A94D3d2Cc82b86a1b705f3A27C'), // yCRV/CRV yVault + toAddress('0x81d93531720d86f0491DeE7D03f30b3b5aC24e59') // yETH/ETH yVault +]; diff --git a/apps/veyfi/utils/validations.ts b/apps/veyfi/utils/validations.ts index 79dfda502..633699670 100644 --- a/apps/veyfi/utils/validations.ts +++ b/apps/veyfi/utils/validations.ts @@ -26,7 +26,6 @@ export function validateAllowance(props: TValidateAllowanceProps): TValidationRe } // TODO: return valid when is native token - const allowance = allowances[allowanceKey(chainID, tokenAddress, spenderAddress, ownerAddress)]; const isApproved = allowance >= amount;