Skip to content

Commit

Permalink
Merge pull request #941 from QuickSwap/hotfix/enable-zkevm-besttrade
Browse files Browse the repository at this point in the history
Enable best trade in zkevm and fix some UI issues
  • Loading branch information
sameepsi authored Aug 1, 2023
2 parents 0d9e299 + e9bee07 commit 85867cb
Show file tree
Hide file tree
Showing 12 changed files with 101 additions and 24 deletions.
11 changes: 0 additions & 11 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,10 @@ IPFS_DEPLOY_PINATA__SECRET_API_KEY=d17f8f50c3e6a633b12843890a8fb537908f0632f642b
REACT_APP_PORTIS_ID="e086c1f2-2d26-4443-804f-3398bbab069e"
REACT_APP_FORTMATIC_KEY="pk_live_F937DF033A1666BF"

REACT_APP_GRAPH_V2_137_API_URL="https://api.thegraph.com/subgraphs/name/sameepsi/quickswap06"
REACT_APP_GRAPH_V2_2000_API_URL="https://graph-node.dogechain.dog/subgraphs/name/quickswap/v2"

REACT_APP_GRAPH_V3_137_API_URL="https://api.thegraph.com/subgraphs/name/sameepsi/quickswap-v3"
REACT_APP_GRAPH_V3_2000_API_URL="https://graph-node.dogechain.dog/subgraphs/name/quickswap/dogechain-info"
REACT_APP_GRAPH_V3_1101_API_URL="https://api.studio.thegraph.com/query/44554/quickswap-v3-02/0.0.7"

REACT_APP_V3_FARMING_API_137_URL="https://api.thegraph.com/subgraphs/name/sameepsi/quickswap-v3-farming"
REACT_APP_V3_FARMING_API_2000_URL="https://graph-node.dogechain.dog/subgraphs/name/quickswap/dogechain-farming"
REACT_APP_V3_FARMING_API_1101_URL="https://api.studio.thegraph.com/query/44554/quickswap-v3-farming/0.0.7"

REACT_APP_GRAPH_137_BLOCK_CLIENT_API_URL="https://api.thegraph.com/subgraphs/name/sameepsi/maticblocks"
REACT_APP_GRAPH_2000_BLOCK_CLIENT_API_URL="https://graph-node.dogechain.dog/subgraphs/name/quickswap/dogechain-blocklytics"
REACT_APP_GRAPH_1101_BLOCK_CLIENT_API_URL="https://api.studio.thegraph.com/query/44554/zkevm-blocks/0.0.2"

REACT_APP_PREDICTIONS_URL="https://quickswap.nexter.fi/"
REACT_APP_GAMEHUB_URL="https://versagames.io/quickswap-gaming-hub"
REACT_APP_TOKEN_LIST_DEFAULT_URL="https://unpkg.com/quickswap-default-token-list@latest/build/quickswap-default.tokenlist.json"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
11 changes: 8 additions & 3 deletions src/components/ConfirmSwapModal/SwapModalHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import { AlertTriangle } from 'react-feather';
import { Box, Button } from '@material-ui/core';
import { Field } from 'state/swap/actions';
import { DoubleCurrencyLogo } from 'components';
import useUSDCPrice from 'utils/useUSDCPrice';
import { useUSDCPriceFromAddress } from 'utils/useUSDCPrice';
import { computeSlippageAdjustedAmounts } from 'utils/prices';
import { ReactComponent as ArrowDownIcon } from 'assets/images/ArrowDownIcon.svg';
import { basisPointsToPercent, formatTokenAmount } from 'utils';
import { useTranslation } from 'react-i18next';
import { OptimalRate, SwapSide } from '@paraswap/sdk';
import { ONE } from 'v3lib/utils';
import { wrappedCurrency } from 'utils/wrappedCurrency';
import { useActiveWeb3React } from 'hooks';

interface SwapModalHeaderProps {
trade?: Trade;
Expand All @@ -34,13 +36,16 @@ const SwapModalHeader: React.FC<SwapModalHeaderProps> = ({
onConfirm,
}) => {
const { t } = useTranslation();
const { chainId } = useActiveWeb3React();
const slippageAdjustedAmounts = useMemo(
() => computeSlippageAdjustedAmounts(trade, allowedSlippage),
[trade, allowedSlippage],
);
const usdPrice = useUSDCPrice(
const wrappedToken = wrappedCurrency(
trade ? trade.inputAmount.currency : inputCurrency,
chainId,
);
const usdPrice = useUSDCPriceFromAddress(wrappedToken?.address ?? '');

const pct = basisPointsToPercent(allowedSlippage);

Expand Down Expand Up @@ -75,7 +80,7 @@ const SwapModalHeader: React.FC<SwapModalHeaderProps> = ({
: ''}{' '}
{trade ? trade.inputAmount.currency.symbol : inputCurrency?.symbol} ($
{(
Number(usdPrice?.toSignificant()) *
(usdPrice ?? 0) *
(optimalRate
? Number(optimalRate.srcAmount) / 10 ** optimalRate.srcDecimals
: trade
Expand Down
5 changes: 1 addition & 4 deletions src/components/v3/CurrencyInputPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,7 @@ export default function CurrencyInputPanel({
currency?.isNative ? nativeCurrency : currency ?? undefined,
);

const currentPrice = useUSDCPriceFromAddress(
currency?.wrapped.address ?? '',
true,
);
const currentPrice = useUSDCPriceFromAddress(currency?.wrapped.address ?? '');

const valueAsUsd = useMemo(() => {
if (!currentPrice || !value) {
Expand Down
2 changes: 1 addition & 1 deletion src/config/zkmainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"swap": {
"available": true,
"bestTrade": false,
"bestTrade": true,
"proMode": false,
"limitOrder": false,
"crossChain": false
Expand Down
49 changes: 49 additions & 0 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ import {
dDD,
frxETH,
PUSH,
LINK,
AAVE,
} from './v3/addresses';

export const AVERAGE_L1_BLOCK_TIME = 12000;
Expand Down Expand Up @@ -1132,6 +1134,17 @@ export const GammaPairs: {
pid: 84,
},
],
'0x7ceb23fd6bc0add59e62ac25578270cff1b9f619-0xd6df932a45c0f255f85145f286ea0b292b21c90b': [
{
type: Presets.GAMMA_WIDE,
title: 'Wide',
address: '0x5ba383530db75a22e028239dbc777c7ee8ce4752',
token0Address: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
token1Address: '0xd6df932a45c0f255f85145f286ea0b292b21c90b',
ableToFarm: true,
pid: 85,
},
],
},
[ChainId.MUMBAI]: {},
[ChainId.DOEGCHAIN_TESTNET]: {},
Expand Down Expand Up @@ -1377,6 +1390,39 @@ export const GammaPairs: {
pid: 22,
},
],
'0x4b16e4752711a7abec32799c976f3cefc0111f2b-0x4f9a0e7fd2bf6067db6994cf12e4495df938e6e9': [
{
type: Presets.GAMMA_WIDE,
title: 'Wide',
address: '0xECfA9CD134E77f573b079378940A4Be944993F17',
token0Address: '0x4b16e4752711a7abec32799c976f3cefc0111f2b',
token1Address: '0x4f9a0e7fd2bf6067db6994cf12e4495df938e6e9',
ableToFarm: true,
pid: 23,
},
],
'0x3d5320821bfca19fb0b5428f2c79d63bd5246f89-0x4f9a0e7fd2bf6067db6994cf12e4495df938e6e9': [
{
type: Presets.GAMMA_WIDE,
title: 'Wide',
address: '0xbAAA5a2D780C5914FB1BAD0Ea6Cbf7B99589d6FE',
token0Address: '0x3d5320821bfca19fb0b5428f2c79d63bd5246f89',
token1Address: '0x4f9a0e7fd2bf6067db6994cf12e4495df938e6e9',
ableToFarm: true,
pid: 24,
},
],
'0x4f9a0e7fd2bf6067db6994cf12e4495df938e6e9-0x68791cfe079814c46e0e25c19bcc5bfc71a744f7': [
{
type: Presets.GAMMA_WIDE,
title: 'Wide',
address: '0x06895D6f6680E5e8301604D5E0483A3655C547B8',
token0Address: '0x4f9a0e7fd2bf6067db6994cf12e4495df938e6e9',
token1Address: '0x68791cfe079814c46e0e25c19bcc5bfc71a744f7',
ableToFarm: true,
pid: 25,
},
],
},
};

Expand Down Expand Up @@ -1460,6 +1506,9 @@ export const GlobalValue = {
WBTC[ChainId.ZKEVM],
DAI[ChainId.ZKEVM],
MATIC[ChainId.ZKEVM],
CRV[ChainId.ZKEVM],
LINK[ChainId.ZKEVM],
AAVE[ChainId.ZKEVM],
],
[ChainId.MUMBAI]: [],
[ChainId.DOEGCHAIN_TESTNET]: [],
Expand Down
27 changes: 27 additions & 0 deletions src/constants/v3/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,13 @@ export const CRV: { [chainId: number]: Token } = {
'CRV',
'CRV (PoS)',
),
[ChainId.ZKEVM]: new Token(
ChainId.ZKEVM,
'0x3d5320821bfca19fb0b5428f2c79d63bd5246f89',
18,
'CRV',
'Curve DAO Token',
),
};

export const DAVOS: { [chainId: number]: Token } = {
Expand Down Expand Up @@ -755,6 +762,26 @@ export const PUSH: { [chainId: number]: Token } = {
),
};

export const LINK: { [chainId: number]: Token } = {
[ChainId.ZKEVM]: new Token(
ChainId.ZKEVM,
'0x4b16e4752711a7abec32799c976f3cefc0111f2b',
18,
'LINK',
'ChainLink Token',
),
};

export const AAVE: { [chainId: number]: Token } = {
[ChainId.ZKEVM]: new Token(
ChainId.ZKEVM,
'0x68791cfe079814c46e0e25c19bcc5bfc71a744f7',
18,
'AAVE',
'Aave Token',
),
};

export const EMPTY: { [chainId: number]: Token } = {
[ChainId.MATIC]: new Token(
ChainId.MATIC,
Expand Down
8 changes: 7 additions & 1 deletion src/pages/FarmPage/FarmPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const FarmPage: React.FC = () => {
const farmAvailable = config['farm']['available'];
const v3 = config['v3'];
const v2 = config['v2'];
const { isV2 } = useIsV2();
const { isV2, updateIsV2 } = useIsV2();

const lpFarms = useDefaultFarmList();
const cntFarms = useDefaultCNTFarmList(chainIdToUse);
Expand Down Expand Up @@ -65,6 +65,12 @@ const FarmPage: React.FC = () => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [farmAvailable]);

useEffect(() => {
if (!v2) {
updateIsV2(false);
}
}, [updateIsV2, v2]);

const pairListStr = pairLists.join('_');
useEffect(() => {
if (isV2) {
Expand Down
10 changes: 8 additions & 2 deletions src/pages/PoolsPage/PoolsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { lazy } from 'react';
import React, { lazy, useEffect } from 'react';
import { Box, Grid, useMediaQuery, useTheme } from '@material-ui/core';
import { ReactComponent as HelpIcon } from 'assets/images/HelpIcon1.svg';
import SupplyLiquidity from './SupplyLiquidity';
Expand All @@ -18,7 +18,7 @@ const MyGammaPoolsV3 = lazy(() => import('./v3/MyGammaPoolsV3'));

const PoolsPage: React.FC = () => {
const { t } = useTranslation();
const { isV2 } = useIsV2();
const { isV2, updateIsV2 } = useIsV2();
const { chainId } = useActiveWeb3React();
const chainIdToUse = chainId ?? ChainId.MATIC;
const config = getConfig(chainIdToUse);
Expand All @@ -32,6 +32,12 @@ const PoolsPage: React.FC = () => {
const helpURL = process.env.REACT_APP_HELP_URL;
const allGammaPairs = chainId ? GammaPairs[chainId] : {};

useEffect(() => {
if (!v2) {
updateIsV2(false);
}
}, [updateIsV2, v2]);

return (
<Box width='100%' mb={3}>
<Box className='pageHeading'>
Expand Down
2 changes: 0 additions & 2 deletions src/utils/useUSDCPrice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ import { PairState, usePairs, usePair } from 'data/Reserves';
import { useActiveWeb3React } from 'hooks';
import { unwrappedToken, wrappedCurrency } from './wrappedCurrency';
import { useDQUICKtoQUICK } from 'state/stake/hooks';
import { GlobalValue } from 'constants/index';
import { useAllCommonPairs } from 'hooks/Trades';
import { tryParseAmount } from 'state/swap/hooks';
import { useEthPrice, useMaticPrice } from 'state/application/hooks';
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import weekOfYear from 'dayjs/plugin/weekOfYear';
Expand Down

0 comments on commit 85867cb

Please sign in to comment.