Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge dev to master #947

Merged
merged 4 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/connectors/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ const allNonMetamaskFlags: NonMetaMaskFlag[] = [
'isTrust',
];
export const getIsMetaMaskWallet = () => {
const { ethereum } = window as any;
const { ethereum, web3 } = window as any;

return Boolean(
ethereum &&
ethereum.isMetaMask &&
ethereum._metamask &&
web3 &&
(ethereum.detected && ethereum.detected.length > 0
? ethereum.detected.find(
(provider: any) =>
Expand Down
1 change: 0 additions & 1 deletion src/hooks/useGasPrice.ts

This file was deleted.

11 changes: 0 additions & 11 deletions src/hooks/useStakerHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,17 @@ import {
} from '../state/transactions/hooks';
import { useActiveWeb3React } from 'hooks';
import JSBI from 'jsbi';
import { GAS_PRICE_MULTIPLIER } from './useGasPrice';
import { TransactionResponse } from '@ethersproject/providers';
import { FarmingType } from '../models/enums';
import { useTranslation } from 'react-i18next';
import { toHex } from 'lib/src/utils/calldata';
import { useAppSelector } from 'state';
import { useV3StakeData } from 'state/farms/hooks';
import { calculateGasMargin } from 'utils';

export function useFarmingHandlers() {
const { chainId, account, provider } = useActiveWeb3React();
const { t } = useTranslation();

const gasPrice = useAppSelector((state) => {
if (!state.application.gasPrice.fetched) return 36;
return state.application.gasPrice.override
? 36
: state.application.gasPrice.fetched;
});

const addTransaction = useTransactionAdder();
const finalizeTransaction = useTransactionFinalizer();

Expand Down Expand Up @@ -140,7 +131,6 @@ export function useFarmingHandlers() {
result = await farmingCenterContract.callStatic.multicall(
callDatas,
{
gasPrice: gasPrice * GAS_PRICE_MULTIPLIER,
gasLimit: 350000,
},
);
Expand Down Expand Up @@ -235,7 +225,6 @@ export function useFarmingHandlers() {
addTransaction,
chainId,
finalizeTransaction,
gasPrice,
provider,
updateV3Stake,
t,
Expand Down
8 changes: 0 additions & 8 deletions src/hooks/useV3ApproveCallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
import { useTokenContract } from './useContract';
import { useActiveWeb3React } from 'hooks';
import { useTokenAllowance } from './useTokenAllowance';
import { useAppSelector } from 'state';
import { calculateGasMargin } from 'utils';

export enum ApprovalState {
Expand All @@ -42,13 +41,6 @@ export function useApproveCallback(
);
const pendingApproval = useHasPendingApproval(token?.address, spender);

const gasPrice = useAppSelector((state) => {
if (!state.application.gasPrice.fetched) return 36;
return state.application.gasPrice.override
? 36
: state.application.gasPrice.fetched;
});

// check the current approval status
const approvalState: ApprovalState = useMemo(() => {
if (!amountToApprove || !spender) return ApprovalState.UNKNOWN;
Expand Down
28 changes: 4 additions & 24 deletions src/hooks/v3/useSwapCallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import { calculateGasMargin, isAddress, isZero, shortenAddress } from 'utils';
import useENS from 'hooks/useENS';
import { SWAP_ROUTER_ADDRESSES } from 'constants/v3/addresses';
import { useActiveWeb3React } from 'hooks';
import { useAppSelector } from 'state';
import { GAS_PRICE_MULTIPLIER } from 'hooks/useGasPrice';
import { SwapRouter } from 'lib/src/swapRouter';
import useTransactionDeadline from 'hooks/useTransactionDeadline';
import { getTradeVersion } from 'utils/v3/getTradeVersion';
Expand Down Expand Up @@ -222,13 +220,6 @@ export function useSwapCallback(

const addTransaction = useTransactionAdder();

const gasPrice = useAppSelector((state) => {
if (!state.application.gasPrice.fetched) return 36;
return state.application.gasPrice.override
? 36
: state.application.gasPrice.fetched;
});

const { address: recipientAddress } = useENS(recipientAddressOrName);
const recipient =
recipientAddressOrName === null ? account : recipientAddress;
Expand Down Expand Up @@ -318,10 +309,7 @@ export function useSwapCallback(
);

// a successful estimation is a bignumber gas estimate and the next call is also a bignumber gas estimate
let bestCallOption:
| SuccessfulCall
| SwapCallEstimate
| undefined = estimatedCalls.find(
const bestCallOption = estimatedCalls.find(
(el, ix, list): el is SuccessfulCall =>
'gasEstimate' in el &&
(ix === list.length - 1 || 'gasEstimate' in list[ix + 1]),
Expand All @@ -334,14 +322,9 @@ export function useSwapCallback(
);
if (errorCalls.length > 0)
throw errorCalls[errorCalls.length - 1].error;
const firstNoErrorCall = estimatedCalls.find<SwapCallEstimate>(
(call): call is SwapCallEstimate => !('error' in call),
throw new Error(
'Unexpected error. Could not estimate gas for the swap.',
);
if (!firstNoErrorCall)
throw new Error(
'Unexpected error. Could not estimate gas for the swap.',
);
bestCallOption = firstNoErrorCall;
}

const {
Expand All @@ -355,9 +338,7 @@ export function useSwapCallback(
to: address,
data: calldata,
// let the wallet try if we can't estimate the gas
...('gasEstimate' in bestCallOption
? { gasLimit: calculateGasMargin(bestCallOption.gasEstimate) }
: { gasPrice: gasPrice * GAS_PRICE_MULTIPLIER }),
gasLimit: calculateGasMargin(bestCallOption.gasEstimate),
...(value && !isZero(value) ? { value } : {}),
})
.then((response) => {
Expand Down Expand Up @@ -413,7 +394,6 @@ export function useSwapCallback(
recipient,
recipientAddressOrName,
swapCalls,
gasPrice,
addTransaction,
]);
}
4 changes: 2 additions & 2 deletions src/pages/LandingPage/LandingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,9 @@ const LandingPage: React.FC = () => {
<h3>{t('faqs')}</h3>
<Box className='featureDivider' />
</Box>
<Box className=''>
<Box>
{faqs.map((val, i) => (
<Accordion key={`accordation-{i}`}>
<Accordion key={`accordation-${i}`}>
<AccordionSummary
expandIcon={<ExpandMoreOutlined />}
aria-controls='panel1a-content'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import useIsTickAtLimit from 'hooks/v3/useIsTickAtLimit';
import { formatTickPrice } from 'utils/v3/formatTickPrice';
import usePrevious from 'hooks/usePrevious';
import ReactGA from 'react-ga';
import { useAppSelector } from 'state/hooks';
import {
FARMING_CENTER,
NONFUNGIBLE_POSITION_MANAGER_ADDRESSES,
Expand Down Expand Up @@ -66,13 +65,6 @@ export default function PositionListItemDetails({
false,
);

const gasPrice = useAppSelector((state) => {
if (!state.application.gasPrice.fetched) return 36;
return state.application.gasPrice.override
? 36
: state.application.gasPrice.fetched;
});

const { tokenId } = positionDetails || {};

const prevPositionDetails = usePrevious({ ...positionDetails });
Expand Down
5 changes: 0 additions & 5 deletions src/state/application/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ export const updateTokenDetails = createAction<TokenDetail>(
'application/updateTokenDetail',
);

export const updateGasPrice = createAction<{
fetched: number | null;
override: boolean;
}>('application/updateGasPrice');

export const updateIsV2 = createAction<boolean>('application/updateIsV2');

export const updateUDDomain = createAction<string | undefined>(
Expand Down
7 changes: 0 additions & 7 deletions src/state/application/reducer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createReducer, nanoid } from '@reduxjs/toolkit';
import { ChainId } from '@uniswap/sdk';
import {
addPopup,
PopupContent,
Expand All @@ -16,7 +15,6 @@ import {
updateBookmarkPairs,
updateTokenDetails,
updateMaticPrice,
updateGasPrice,
updateIsV2,
updateUDDomain,
} from './actions';
Expand Down Expand Up @@ -58,7 +56,6 @@ export interface ApplicationState {
readonly analyticToken: any;
readonly tokenChartData: any;
readonly tokenDetails: TokenDetail[];
readonly gasPrice: { fetched: number | null; override: boolean };
readonly isV2: boolean | undefined;
readonly udDomain: string | undefined;
}
Expand All @@ -75,7 +72,6 @@ const initialState: ApplicationState = {
analyticToken: null,
tokenChartData: null,
tokenDetails: [],
gasPrice: { fetched: 70, override: true },
isV2: undefined,
udDomain: undefined,
};
Expand All @@ -93,9 +89,6 @@ export default createReducer(initialState, (builder) =>
);
}
})
.addCase(updateGasPrice, (state, action) => {
state.gasPrice = action.payload;
})
.addCase(setOpenModal, (state, action) => {
state.openModal = action.payload;
})
Expand Down
Loading