Skip to content

Commit

Permalink
chores: replace maxUint256
Browse files Browse the repository at this point in the history
  • Loading branch information
Majorfi committed Oct 28, 2024
1 parent 44cae89 commit e290375
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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';

Expand Down Expand Up @@ -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<void> => {
await triggerRetrieveAllowance();
Expand Down
4 changes: 2 additions & 2 deletions apps/vaults/hooks/solvers/useSolverChainCoin.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
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';
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';

Expand Down Expand Up @@ -97,7 +97,7 @@ export function useSolverChainCoin(): TSolverContext {
*********************************************************************************************/
const onApprove = useCallback(
async (
amount = MAX_UINT_256,
amount = maxUint256,
txStatusSetter: React.Dispatch<React.SetStateAction<TTxStatus>>,
onSuccess: () => Promise<void>
): Promise<void> => {
Expand Down
6 changes: 3 additions & 3 deletions apps/vaults/hooks/solvers/useSolverCowswap.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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';

Expand Down Expand Up @@ -362,7 +362,7 @@ export function useSolverCowswap(): TSolverContext {
**************************************************************************/
const onApprove = useCallback(
async (
amount = MAX_UINT_256,
amount = maxUint256,
txStatusSetter: React.Dispatch<React.SetStateAction<TTxStatus>>,
onSuccess: () => Promise<void>
): Promise<void> => {
Expand Down
4 changes: 2 additions & 2 deletions apps/vaults/hooks/solvers/useSolverGaugeStakingBooster.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
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 {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';

Expand Down Expand Up @@ -84,7 +84,7 @@ export function useSolverGaugeStakingBooster(): TSolverContext {
*********************************************************************************************/
const onApprove = useCallback(
async (
amount = MAX_UINT_256,
amount = maxUint256,
txStatusSetter: React.Dispatch<React.SetStateAction<TTxStatus>>,
onSuccess: () => Promise<void>
): Promise<void> => {
Expand Down
5 changes: 3 additions & 2 deletions apps/vaults/hooks/solvers/useSolverInternalMigration.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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';

Expand Down Expand Up @@ -103,7 +104,7 @@ export function useSolverInternalMigration(): TSolverContext {
**************************************************************************/
const onApprove = useCallback(
async (
amount = MAX_UINT_256,
amount = maxUint256,
txStatusSetter: React.Dispatch<React.SetStateAction<TTxStatus>>,
onSuccess: () => Promise<void>
): Promise<void> => {
Expand Down
4 changes: 2 additions & 2 deletions apps/vaults/hooks/solvers/useSolverJuicedStakingBooster.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
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 {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';

Expand Down Expand Up @@ -84,7 +84,7 @@ export function useSolverJuicedStakingBooster(): TSolverContext {
*********************************************************************************************/
const onApprove = useCallback(
async (
amount = MAX_UINT_256,
amount = maxUint256,
txStatusSetter: React.Dispatch<React.SetStateAction<TTxStatus>>,
onSuccess: () => Promise<void>
): Promise<void> => {
Expand Down
5 changes: 3 additions & 2 deletions apps/vaults/hooks/solvers/useSolverOptimismBooster.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
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 {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';
Expand Down Expand Up @@ -83,7 +84,7 @@ export function useSolverOptimismBooster(): TSolverContext {
*********************************************************************************************/
const onApprove = useCallback(
async (
amount = MAX_UINT_256,
amount = maxUint256,
txStatusSetter: React.Dispatch<React.SetStateAction<TTxStatus>>,
onSuccess: () => Promise<void>
): Promise<void> => {
Expand Down
4 changes: 2 additions & 2 deletions apps/vaults/hooks/solvers/useSolverPartnerContract.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -87,7 +87,7 @@ export function useSolverPartnerContract(): TSolverContext {
**************************************************************************/
const onApprove = useCallback(
async (
amount = MAX_UINT_256,
amount = maxUint256,
txStatusSetter: React.Dispatch<React.SetStateAction<TTxStatus>>,
onSuccess: () => Promise<void>
): Promise<void> => {
Expand Down
7 changes: 3 additions & 4 deletions apps/vaults/hooks/solvers/useSolverPortals.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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';

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -316,7 +315,7 @@ export function useSolverPortals(): TSolverContext {
**************************************************************************/
const onApprove = useCallback(
async (
amount = MAX_UINT_256,
amount = maxUint256,
txStatusSetter: React.Dispatch<React.SetStateAction<TTxStatus>>,
onSuccess: () => Promise<void>
): Promise<void> => {
Expand Down
4 changes: 2 additions & 2 deletions apps/vaults/hooks/solvers/useSolverV3StakingBooster.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
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';
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';

Expand Down Expand Up @@ -84,7 +84,7 @@ export function useSolverV3StakingBooster(): TSolverContext {
*********************************************************************************************/
const onApprove = useCallback(
async (
amount = MAX_UINT_256,
amount = maxUint256,
txStatusSetter: React.Dispatch<React.SetStateAction<TTxStatus>>,
onSuccess: () => Promise<void>
): Promise<void> => {
Expand Down
4 changes: 2 additions & 2 deletions apps/vaults/hooks/solvers/useSolverVanilla.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -90,7 +90,7 @@ export function useSolverVanilla(): TSolverContext {
**************************************************************************/
const onApprove = useCallback(
async (
amount = MAX_UINT_256,
amount = maxUint256,
txStatusSetter: React.Dispatch<React.SetStateAction<TTxStatus>>,
onSuccess: () => Promise<void>
): Promise<void> => {
Expand Down

0 comments on commit e290375

Please sign in to comment.