diff --git a/apps/vaults-v3/components/details/actions/QuickActionsButtons.tsx b/apps/vaults-v3/components/details/actions/QuickActionsButtons.tsx index 3825c3efe..861aff1a6 100644 --- a/apps/vaults-v3/components/details/actions/QuickActionsButtons.tsx +++ b/apps/vaults-v3/components/details/actions/QuickActionsButtons.tsx @@ -1,6 +1,7 @@ import {useCallback, useState} from 'react'; import {useRouter} from 'next/router'; import {usePlausible} from 'next-plausible'; +import {maxUint256} from 'viem'; import {useWeb3} from '@builtbymom/web3/contexts/useWeb3'; import {useAsyncTrigger} from '@builtbymom/web3/hooks/useAsyncTrigger'; import {isZero, toAddress, toBigInt, zeroNormalizedBN} from '@builtbymom/web3/utils'; @@ -9,7 +10,7 @@ import {useActionFlow} from '@vaults/contexts/useActionFlow'; import {useSolver} from '@vaults/contexts/useSolver'; import {Solver} from '@vaults/types/solvers'; import {Button} from '@yearn-finance/web-lib/components/Button'; -import {ETH_TOKEN_ADDRESS, MAX_UINT_256} from '@yearn-finance/web-lib/utils/constants'; +import {ETH_TOKEN_ADDRESS} from '@yearn-finance/web-lib/utils/constants'; import {useYearn} from '@common/contexts/useYearn'; import {PLAUSIBLE_EVENTS} from '@common/utils/plausible'; @@ -145,7 +146,7 @@ export function VaultDetailsQuickActionsButtons({currentVault}: {currentVault: T currentSolver === Solver.enum.Vanilla || currentSolver === Solver.enum.InternalMigration; onApprove( - shouldApproveInfinite ? MAX_UINT_256 : toBigInt(actionParams.amount?.raw), + shouldApproveInfinite ? maxUint256 : toBigInt(actionParams.amount?.raw), set_txStatusApprove, async (): Promise => { await triggerRetrieveAllowance(); diff --git a/apps/vaults/hooks/solvers/useSolverChainCoin.ts b/apps/vaults/hooks/solvers/useSolverChainCoin.ts index ac19d5fb0..fce6949f7 100644 --- a/apps/vaults/hooks/solvers/useSolverChainCoin.ts +++ b/apps/vaults/hooks/solvers/useSolverChainCoin.ts @@ -1,4 +1,5 @@ import {useCallback, useMemo, useRef} from 'react'; +import {maxUint256} from 'viem'; import {useWeb3} from '@builtbymom/web3/contexts/useWeb3'; import {assert, isEthAddress, toAddress, toNormalizedBN, zeroNormalizedBN} from '@builtbymom/web3/utils'; import {allowanceOf, approveERC20} from '@builtbymom/web3/utils/wagmi'; @@ -6,7 +7,6 @@ import {isSolverDisabled} from '@vaults/contexts/useSolver'; import {Solver} from '@vaults/types/solvers'; import {getEthZapperContract, getNativeTokenWrapperContract} from '@vaults/utils'; import {getVaultEstimateOut} from '@vaults/utils/getVaultEstimateOut'; -import {MAX_UINT_256} from '@yearn-finance/web-lib/utils/constants'; import {allowanceKey} from '@common/utils'; import {depositETH, withdrawETH} from '@common/utils/actions'; @@ -97,7 +97,7 @@ export function useSolverChainCoin(): TSolverContext { *********************************************************************************************/ const onApprove = useCallback( async ( - amount = MAX_UINT_256, + amount = maxUint256, txStatusSetter: React.Dispatch>, onSuccess: () => Promise ): Promise => { diff --git a/apps/vaults/hooks/solvers/useSolverCowswap.ts b/apps/vaults/hooks/solvers/useSolverCowswap.ts index 6daa41e04..e89d3bb6f 100644 --- a/apps/vaults/hooks/solvers/useSolverCowswap.ts +++ b/apps/vaults/hooks/solvers/useSolverCowswap.ts @@ -1,6 +1,6 @@ import {useCallback, useMemo, useRef} from 'react'; import {ethers} from 'ethers'; -import {BaseError} from 'viem'; +import {BaseError, maxUint256} from 'viem'; import axios from 'axios'; import {useWeb3} from '@builtbymom/web3/contexts/useWeb3'; import {assert, isEthAddress, isZeroAddress, toBigInt, toNormalizedBN, zeroNormalizedBN} from '@builtbymom/web3/utils'; @@ -16,7 +16,7 @@ import {OrderBookApi, OrderQuoteSide, OrderSigningUtils} from '@cowprotocol/cow- import {isSolverDisabled} from '@vaults/contexts/useSolver'; import {Solver} from '@vaults/types/solvers'; import {toast} from '@yearn-finance/web-lib/components/yToast'; -import {MAX_UINT_256, SOLVER_COW_VAULT_RELAYER_ADDRESS} from '@yearn-finance/web-lib/utils/constants'; +import {SOLVER_COW_VAULT_RELAYER_ADDRESS} from '@yearn-finance/web-lib/utils/constants'; import {allowanceKey} from '@yearn-finance/web-lib/utils/helpers'; import {useYearn} from '@common/contexts/useYearn'; @@ -362,7 +362,7 @@ export function useSolverCowswap(): TSolverContext { **************************************************************************/ const onApprove = useCallback( async ( - amount = MAX_UINT_256, + amount = maxUint256, txStatusSetter: React.Dispatch>, onSuccess: () => Promise ): Promise => { diff --git a/apps/vaults/hooks/solvers/useSolverGaugeStakingBooster.ts b/apps/vaults/hooks/solvers/useSolverGaugeStakingBooster.ts index ccbc1e35d..a35a6823b 100644 --- a/apps/vaults/hooks/solvers/useSolverGaugeStakingBooster.ts +++ b/apps/vaults/hooks/solvers/useSolverGaugeStakingBooster.ts @@ -1,4 +1,5 @@ import {useCallback, useMemo, useRef} from 'react'; +import {maxUint256} from 'viem'; import {useWeb3} from '@builtbymom/web3/contexts/useWeb3'; import {assert, toAddress, toNormalizedBN, zeroNormalizedBN} from '@builtbymom/web3/utils'; import {allowanceOf, approveERC20} from '@builtbymom/web3/utils/wagmi'; @@ -6,7 +7,6 @@ import {isSolverDisabled} from '@vaults/contexts/useSolver'; import {Solver} from '@vaults/types/solvers'; import {depositAndStake} from '@vaults/utils/actions'; import {getVaultEstimateOut} from '@vaults/utils/getVaultEstimateOut'; -import {MAX_UINT_256} from '@yearn-finance/web-lib/utils/constants'; import {allowanceKey} from '@common/utils'; import {YGAUGES_ZAP_ADDRESS} from '@common/utils/constants'; @@ -84,7 +84,7 @@ export function useSolverGaugeStakingBooster(): TSolverContext { *********************************************************************************************/ const onApprove = useCallback( async ( - amount = MAX_UINT_256, + amount = maxUint256, txStatusSetter: React.Dispatch>, onSuccess: () => Promise ): Promise => { diff --git a/apps/vaults/hooks/solvers/useSolverInternalMigration.ts b/apps/vaults/hooks/solvers/useSolverInternalMigration.ts index 795758549..d60d3757a 100644 --- a/apps/vaults/hooks/solvers/useSolverInternalMigration.ts +++ b/apps/vaults/hooks/solvers/useSolverInternalMigration.ts @@ -1,4 +1,5 @@ import {useCallback, useMemo, useRef} from 'react'; +import {maxUint256} from 'viem'; import {useWeb3} from '@builtbymom/web3/contexts/useWeb3'; import {assert, toAddress, toBigInt, toNormalizedBN, zeroNormalizedBN} from '@builtbymom/web3/utils'; import {allowanceOf, approveERC20, retrieveConfig} from '@builtbymom/web3/utils/wagmi'; @@ -8,7 +9,7 @@ import {ZAP_CRV_ABI} from '@vaults/utils/abi/zapCRV.abi'; import {zapCRV} from '@vaults/utils/actions'; import {getVaultEstimateOut} from '@vaults/utils/getVaultEstimateOut'; import {readContract} from '@wagmi/core'; -import {MAX_UINT_256, ZAP_YEARN_VE_CRV_ADDRESS} from '@yearn-finance/web-lib/utils/constants'; +import {ZAP_YEARN_VE_CRV_ADDRESS} from '@yearn-finance/web-lib/utils/constants'; import {allowanceKey} from '@common/utils'; import {migrateShares} from '@common/utils/actions'; @@ -103,7 +104,7 @@ export function useSolverInternalMigration(): TSolverContext { **************************************************************************/ const onApprove = useCallback( async ( - amount = MAX_UINT_256, + amount = maxUint256, txStatusSetter: React.Dispatch>, onSuccess: () => Promise ): Promise => { diff --git a/apps/vaults/hooks/solvers/useSolverJuicedStakingBooster.ts b/apps/vaults/hooks/solvers/useSolverJuicedStakingBooster.ts index d095defba..1f6a6cb79 100644 --- a/apps/vaults/hooks/solvers/useSolverJuicedStakingBooster.ts +++ b/apps/vaults/hooks/solvers/useSolverJuicedStakingBooster.ts @@ -1,4 +1,5 @@ import {useCallback, useMemo, useRef} from 'react'; +import {maxUint256} from 'viem'; import {useWeb3} from '@builtbymom/web3/contexts/useWeb3'; import {assert, toAddress, toNormalizedBN, zeroNormalizedBN} from '@builtbymom/web3/utils'; import {allowanceOf, approveERC20} from '@builtbymom/web3/utils/wagmi'; @@ -6,7 +7,6 @@ import {isSolverDisabled} from '@vaults/contexts/useSolver'; import {Solver} from '@vaults/types/solvers'; import {depositAndStake} from '@vaults/utils/actions'; import {getVaultEstimateOut} from '@vaults/utils/getVaultEstimateOut'; -import {MAX_UINT_256} from '@yearn-finance/web-lib/utils/constants'; import {allowanceKey} from '@common/utils'; import {YGAUGES_ZAP_ADDRESS} from '@common/utils/constants'; @@ -84,7 +84,7 @@ export function useSolverJuicedStakingBooster(): TSolverContext { *********************************************************************************************/ const onApprove = useCallback( async ( - amount = MAX_UINT_256, + amount = maxUint256, txStatusSetter: React.Dispatch>, onSuccess: () => Promise ): Promise => { diff --git a/apps/vaults/hooks/solvers/useSolverOptimismBooster.ts b/apps/vaults/hooks/solvers/useSolverOptimismBooster.ts index 084b234b7..52b2297ad 100644 --- a/apps/vaults/hooks/solvers/useSolverOptimismBooster.ts +++ b/apps/vaults/hooks/solvers/useSolverOptimismBooster.ts @@ -1,4 +1,5 @@ import {useCallback, useMemo, useRef} from 'react'; +import {maxUint256} from 'viem'; import {useWeb3} from '@builtbymom/web3/contexts/useWeb3'; import {assert, toAddress, toNormalizedBN, zeroNormalizedBN} from '@builtbymom/web3/utils'; import {allowanceOf, approveERC20} from '@builtbymom/web3/utils/wagmi'; @@ -6,7 +7,7 @@ import {isSolverDisabled} from '@vaults/contexts/useSolver'; import {Solver} from '@vaults/types/solvers'; import {depositAndStake} from '@vaults/utils/actions'; import {getVaultEstimateOut} from '@vaults/utils/getVaultEstimateOut'; -import {MAX_UINT_256, STAKING_REWARDS_ZAP_ADDRESS} from '@yearn-finance/web-lib/utils/constants'; +import {STAKING_REWARDS_ZAP_ADDRESS} from '@yearn-finance/web-lib/utils/constants'; import {allowanceKey} from '@common/utils'; import type {TDict, TNormalizedBN} from '@builtbymom/web3/types'; @@ -83,7 +84,7 @@ export function useSolverOptimismBooster(): TSolverContext { *********************************************************************************************/ const onApprove = useCallback( async ( - amount = MAX_UINT_256, + amount = maxUint256, txStatusSetter: React.Dispatch>, onSuccess: () => Promise ): Promise => { diff --git a/apps/vaults/hooks/solvers/useSolverPartnerContract.ts b/apps/vaults/hooks/solvers/useSolverPartnerContract.ts index aa06ad5b8..b963a98a2 100644 --- a/apps/vaults/hooks/solvers/useSolverPartnerContract.ts +++ b/apps/vaults/hooks/solvers/useSolverPartnerContract.ts @@ -1,11 +1,11 @@ import {useCallback, useMemo, useRef} from 'react'; +import {maxUint256} from 'viem'; import {useWeb3} from '@builtbymom/web3/contexts/useWeb3'; import {assert, assertAddress, toAddress, toNormalizedBN, zeroNormalizedBN} from '@builtbymom/web3/utils'; import {allowanceOf, approveERC20, getNetwork} from '@builtbymom/web3/utils/wagmi'; import {isSolverDisabled} from '@vaults/contexts/useSolver'; import {Solver} from '@vaults/types/solvers'; import {getVaultEstimateOut} from '@vaults/utils/getVaultEstimateOut'; -import {MAX_UINT_256} from '@yearn-finance/web-lib/utils/constants'; import {allowanceKey} from '@yearn-finance/web-lib/utils/helpers'; import {useYearn} from '@common/contexts/useYearn'; import {depositViaPartner, withdrawShares} from '@common/utils/actions'; @@ -87,7 +87,7 @@ export function useSolverPartnerContract(): TSolverContext { **************************************************************************/ const onApprove = useCallback( async ( - amount = MAX_UINT_256, + amount = maxUint256, txStatusSetter: React.Dispatch>, onSuccess: () => Promise ): Promise => { diff --git a/apps/vaults/hooks/solvers/useSolverPortals.ts b/apps/vaults/hooks/solvers/useSolverPortals.ts index c7359625c..0a978f306 100644 --- a/apps/vaults/hooks/solvers/useSolverPortals.ts +++ b/apps/vaults/hooks/solvers/useSolverPortals.ts @@ -1,5 +1,5 @@ import {useCallback, useMemo, useRef} from 'react'; -import {BaseError, isHex, zeroAddress} from 'viem'; +import {BaseError, isHex, maxUint256, zeroAddress} from 'viem'; import axios from 'axios'; import {useWeb3} from '@builtbymom/web3/contexts/useWeb3'; import { @@ -26,7 +26,6 @@ import {getPortalsApproval, getPortalsEstimate, getPortalsTx, PORTALS_NETWORK} f import {Solver} from '@vaults/types/solvers'; import {sendTransaction, switchChain, waitForTransactionReceipt} from '@wagmi/core'; import {toast} from '@yearn-finance/web-lib/components/yToast'; -import {MAX_UINT_256} from '@yearn-finance/web-lib/utils/constants'; import {allowanceKey} from '@yearn-finance/web-lib/utils/helpers'; import {useYearn} from '@common/contexts/useYearn'; @@ -272,7 +271,7 @@ export function useSolverPortals(): TSolverContext { } const inputToken = request.current.inputToken.value; if (isEthAddress(request.current.inputToken.value)) { - return toNormalizedBN(MAX_UINT_256, 18); + return toNormalizedBN(maxUint256, 18); } const key = allowanceKey( request.current.chainID, @@ -316,7 +315,7 @@ export function useSolverPortals(): TSolverContext { **************************************************************************/ const onApprove = useCallback( async ( - amount = MAX_UINT_256, + amount = maxUint256, txStatusSetter: React.Dispatch>, onSuccess: () => Promise ): Promise => { diff --git a/apps/vaults/hooks/solvers/useSolverV3StakingBooster.ts b/apps/vaults/hooks/solvers/useSolverV3StakingBooster.ts index 4d00228bd..2d1ab2ca1 100644 --- a/apps/vaults/hooks/solvers/useSolverV3StakingBooster.ts +++ b/apps/vaults/hooks/solvers/useSolverV3StakingBooster.ts @@ -1,4 +1,5 @@ import {useCallback, useMemo, useRef} from 'react'; +import {maxUint256} from 'viem'; import {useWeb3} from '@builtbymom/web3/contexts/useWeb3'; import {assert, isAddress, toAddress, toNormalizedBN, zeroNormalizedBN} from '@builtbymom/web3/utils'; import {allowanceOf, approveERC20} from '@builtbymom/web3/utils/wagmi'; @@ -6,7 +7,6 @@ import {isSolverDisabled} from '@vaults/contexts/useSolver'; import {Solver} from '@vaults/types/solvers'; import {depositAndStake} from '@vaults/utils/actions'; import {getVaultEstimateOut} from '@vaults/utils/getVaultEstimateOut'; -import {MAX_UINT_256} from '@yearn-finance/web-lib/utils/constants'; import {allowanceKey} from '@common/utils'; import {V3_STAKING_ZAP_ADDRESS} from '@common/utils/constants'; @@ -84,7 +84,7 @@ export function useSolverV3StakingBooster(): TSolverContext { *********************************************************************************************/ const onApprove = useCallback( async ( - amount = MAX_UINT_256, + amount = maxUint256, txStatusSetter: React.Dispatch>, onSuccess: () => Promise ): Promise => { diff --git a/apps/vaults/hooks/solvers/useSolverVanilla.ts b/apps/vaults/hooks/solvers/useSolverVanilla.ts index 2bb9fe3cd..a1cc1831e 100644 --- a/apps/vaults/hooks/solvers/useSolverVanilla.ts +++ b/apps/vaults/hooks/solvers/useSolverVanilla.ts @@ -1,11 +1,11 @@ import {useCallback, useMemo, useRef} from 'react'; +import {maxUint256} from 'viem'; import {useWeb3} from '@builtbymom/web3/contexts/useWeb3'; import {assert, toAddress, toNormalizedBN, zeroNormalizedBN} from '@builtbymom/web3/utils'; import {allowanceOf, approveERC20} from '@builtbymom/web3/utils/wagmi'; import {isSolverDisabled} from '@vaults/contexts/useSolver'; import {Solver} from '@vaults/types/solvers'; import {getVaultEstimateOut} from '@vaults/utils/getVaultEstimateOut'; -import {MAX_UINT_256} from '@yearn-finance/web-lib/utils/constants'; import {allowanceKey} from '@yearn-finance/web-lib/utils/helpers'; import {useYearn} from '@common/contexts/useYearn'; import {deposit, redeemV3Shares, withdrawShares} from '@common/utils/actions'; @@ -90,7 +90,7 @@ export function useSolverVanilla(): TSolverContext { **************************************************************************/ const onApprove = useCallback( async ( - amount = MAX_UINT_256, + amount = maxUint256, txStatusSetter: React.Dispatch>, onSuccess: () => Promise ): Promise => {