Skip to content

Commit adbfdc2

Browse files
authored
Merge pull request #245 from QuickSwap/dev
Merge dev to master
2 parents 70f7c7e + 3d08bf8 commit adbfdc2

34 files changed

Lines changed: 549 additions & 463 deletions

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ REACT_APP_FORTMATIC_KEY="pk_live_F937DF033A1666BF"
88
REACT_APP_MOONPAY_KEY="pk_live_72EGoobLnlgc8WB7AaxyiWu2S43dj8eY"
99
REACT_APP_TRANSAK_KEY="258960cf-1e17-4419-bf7f-77443282f5da"
1010
REACT_APP_GRAPH_API_URL="https://api.fura.org/subgraphs/name/quickswap"
11+
REACT_APP_TX_GRAPH_API_URL="https://api.thegraph.com/subgraphs/name/sameepsi/quickswap03"
1112
REACT_APP_PRDT_URL="https://prdt-quickswap-main.pages.dev/"
1213
REACT_APP_SCAN_BASE_URL="https://polygonscan.com"
1314
REACT_APP_TOKEN_LIST_DEFAULT_URL="https://unpkg.com/quickswap-default-token-list@latest/build/quickswap-default.tokenlist.json"

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@
101101
"ejs": "^3.1.7",
102102
"cross-fetch": "^3.1.5",
103103
"eventsource": "^2.0.2",
104-
"protobufjs": "^6.11.3"
104+
"protobufjs": "^6.11.3",
105+
"shell-quote": "^1.7.3",
106+
"terser": "^4.8.1",
107+
"got": "^11.8.5",
108+
"jpeg-js": "^0.4.4"
105109
},
106110
"scripts": {
107111
"analyze": "source-map-explorer 'build/static/js/*.js'",

src/apollo/client.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,9 @@ export const client = new ApolloClient({
1010
shouldBatch: true,
1111
});
1212

13-
export const healthClient = new ApolloClient({
14-
link: new HttpLink({
15-
uri: process.env.REACT_APP_GRAPH_API_URL,
16-
}),
17-
cache: new InMemoryCache(),
18-
shouldBatch: true,
19-
});
20-
2113
export const txClient = new ApolloClient({
2214
link: new HttpLink({
23-
uri: process.env.REACT_APP_GRAPH_API_URL,
15+
uri: process.env.REACT_APP_TX_GRAPH_API_URL,
2416
}),
2517
cache: new InMemoryCache(),
2618
shouldBatch: true,

src/apollo/queries.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -682,13 +682,11 @@ export const FILTERED_TRANSACTIONS = gql`
682682
`;
683683

684684
export const SWAP_TRANSACTIONS = gql`
685-
query($allPairs: [Bytes]!, $skip: Int!, $lastTime: Int!) {
685+
query($allPairs: [Bytes]!, $lastTime: Int!) {
686686
swaps(
687687
first: 1000
688688
where: { pair_in: $allPairs, timestamp_gte: $lastTime }
689-
skip: $skip
690689
orderBy: timestamp
691-
orderDirection: desc
692690
) {
693691
transaction {
694692
id

src/components/AddLiquidity/AddLiquidity.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,9 @@ const AddLiquidity: React.FC<{
355355
</small>
356356
</Box>
357357
<Box className='swapButtonWrapper'>
358-
<Button onClick={onAddLiquidity}>{t('confirmSupply')}</Button>
358+
<Button fullWidth onClick={onAddLiquidity}>
359+
{t('confirmSupply')}
360+
</Button>
359361
</Box>
360362
</Box>
361363
);

src/components/CurrencyLogo/CurrencyLogo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const CurrencyLogo: React.FC<CurrencyLogoProps> = ({
2828

2929
if (currency instanceof Token) {
3030
if (currency instanceof WrappedTokenInfo) {
31-
return [...getTokenLogoURL(currency.address), ...uriLocations];
31+
return [...uriLocations, ...getTokenLogoURL(currency.address)];
3232
}
3333

3434
return getTokenLogoURL(currency.address);

src/components/RewardSlider/RewardSlider.tsx

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ import { useTheme } from '@material-ui/core/styles';
55
import ChevronRightIcon from '@material-ui/icons/ChevronRight';
66
import ChevronLeftIcon from '@material-ui/icons/ChevronLeft';
77
import { StakingInfo } from 'types';
8-
import { useStakingInfo, getBulkPairData } from 'state/stake/hooks';
8+
import {
9+
useStakingInfo,
10+
getBulkPairData,
11+
useDualStakingInfo,
12+
} from 'state/stake/hooks';
913
import RewardSliderItem from './RewardSliderItem';
1014
import { useActiveWeb3React } from 'hooks';
1115
import { getOneYearFee } from 'utils';
1216
import 'components/styles/RewardSlider.scss';
13-
import { useDefaultFarmList } from 'state/farms/hooks';
1417
import { ChainId } from '@uniswap/sdk';
1518

1619
const RewardSlider: React.FC = () => {
@@ -19,26 +22,25 @@ const RewardSlider: React.FC = () => {
1922
const tabletWindowSize = useMediaQuery(theme.breakpoints.down('md'));
2023
const mobileWindowSize = useMediaQuery(theme.breakpoints.down('sm'));
2124
const defaultChainId = chainId ?? ChainId.MATIC;
22-
const rewardItems = useStakingInfo(defaultChainId, null, 0, 5);
25+
const lprewardItems = useStakingInfo(defaultChainId, null, 0, 2);
26+
const dualrewardItems = useDualStakingInfo(defaultChainId, null, 0, 1);
2327
const [bulkPairs, setBulkPairs] = useState<any>(null);
24-
const farms = useDefaultFarmList()[defaultChainId];
2528

2629
const stakingPairLists = useMemo(() => {
27-
return Object.values(farms)
28-
.filter((item) => !item.ended)
29-
.slice(0, 5)
30-
.map((item) => item.pair);
31-
}, [farms]);
30+
return lprewardItems
31+
.map((item) => item.pair)
32+
.concat(dualrewardItems.map((item) => item.pair));
33+
}, [dualrewardItems, lprewardItems]);
3234

3335
useEffect(() => {
3436
getBulkPairData(stakingPairLists).then((data) => setBulkPairs(data));
3537
}, [stakingPairLists]);
3638

3739
const stakingAPYs = useMemo(() => {
38-
if (bulkPairs && rewardItems.length > 0) {
39-
return rewardItems.map((info: StakingInfo) => {
40-
const oneDayVolume = bulkPairs[info.pair]?.oneDayVolumeUSD;
41-
const reserveUSD = bulkPairs[info.pair]?.reserveUSD;
40+
if (bulkPairs && stakingPairLists.length > 0) {
41+
return stakingPairLists.map((pair) => {
42+
const oneDayVolume = bulkPairs[pair]?.oneDayVolumeUSD;
43+
const reserveUSD = bulkPairs[pair]?.reserveUSD;
4244
if (oneDayVolume && reserveUSD) {
4345
return getOneYearFee(oneDayVolume, reserveUSD);
4446
} else {
@@ -48,7 +50,7 @@ const RewardSlider: React.FC = () => {
4850
} else {
4951
return [];
5052
}
51-
}, [bulkPairs, rewardItems]);
53+
}, [bulkPairs, stakingPairLists]);
5254

5355
const rewardSliderSettings = {
5456
dots: false,
@@ -62,7 +64,14 @@ const RewardSlider: React.FC = () => {
6264

6365
return (
6466
<Slider {...rewardSliderSettings} className='rewardsSlider'>
65-
{rewardItems.map((item, index) => (
67+
{lprewardItems.map((item, index) => (
68+
<RewardSliderItem
69+
key={index}
70+
stakingAPY={stakingAPYs[index]}
71+
info={item}
72+
/>
73+
))}
74+
{dualrewardItems.map((item, index) => (
6675
<RewardSliderItem
6776
key={index}
6877
stakingAPY={stakingAPYs[index]}

src/components/RewardSlider/RewardSliderItem.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { Box, Button } from '@material-ui/core';
33
import { useHistory } from 'react-router-dom';
4-
import { StakingInfo } from 'types';
4+
import { DualStakingInfo, StakingInfo } from 'types';
55
import { DoubleCurrencyLogo } from 'components';
66
import { ReactComponent as HelpIcon } from 'assets/images/HelpIcon.svg';
77
import {
@@ -13,7 +13,7 @@ import {
1313
import { useTranslation } from 'react-i18next';
1414

1515
interface RewardSliderItemProps {
16-
info: StakingInfo;
16+
info: StakingInfo | DualStakingInfo;
1717
stakingAPY: number;
1818
}
1919

@@ -30,7 +30,12 @@ const RewardSliderItem: React.FC<RewardSliderItemProps> = ({
3030
stakedAmounts?.totalStakedBase,
3131
);
3232

33-
const rewards = info.rate * info.rewardTokenPrice;
33+
const lpInfo = info as StakingInfo;
34+
const dualInfo = info as DualStakingInfo;
35+
const lprewards = lpInfo.rate * lpInfo.rewardTokenPrice;
36+
const dualrewards =
37+
dualInfo.rateA * dualInfo.rewardTokenAPrice +
38+
dualInfo.rateB * dualInfo.rewardTokenBPrice;
3439

3540
let apyWithFee;
3641
if (stakingAPY && stakingAPY > 0) {
@@ -61,7 +66,7 @@ const RewardSliderItem: React.FC<RewardSliderItemProps> = ({
6166
<Box className='row'>
6267
<p className='text-gray22'>{t('rewards')}</p>
6368
<p>
64-
${rewards.toLocaleString()} / {t('day')}
69+
${(lprewards ? lprewards : dualrewards).toLocaleString()} / {t('day')}
6570
</p>
6671
</Box>
6772
<Box className='row'>

src/components/SwapTokenDetails/SwapTokenDetails.tsx

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ import Skeleton from '@material-ui/lab/Skeleton';
44
import { ArrowDropUp, ArrowDropDown } from '@material-ui/icons';
55
import { useTheme } from '@material-ui/core/styles';
66
import { CurrencyLogo } from 'components';
7-
import { useBlockNumber, useTokenDetails } from 'state/application/hooks';
7+
import {
8+
useBlockNumber,
9+
useEthPrice,
10+
useTokenDetails,
11+
} from 'state/application/hooks';
812
import useCopyClipboard from 'hooks/useCopyClipboard';
913
import { ReactComponent as CopyIcon } from 'assets/images/CopyIcon.svg';
1014
import {
1115
shortenAddress,
1216
formatCompact,
1317
getTokenInfo,
14-
getEthPrice,
1518
getIntervalTokenData,
1619
formatNumber,
1720
} from 'utils';
@@ -36,9 +39,10 @@ const SwapTokenDetails: React.FC<{
3639
const priceUpPercent = Number(tokenData?.priceChangeUSD).toFixed(2);
3740
const [isCopied, setCopied] = useCopyClipboard();
3841
const prices = priceData ? priceData.map((price: any) => price.close) : [];
42+
const { ethPrice } = useEthPrice();
3943

4044
useEffect(() => {
41-
async function fetchTokenData() {
45+
(async () => {
4246
const tokenDetail = tokenDetails.find(
4347
(item) => item.address === tokenAddress,
4448
);
@@ -57,22 +61,26 @@ const SwapTokenDetails: React.FC<{
5761
);
5862
setPriceData(tokenPriceData);
5963

60-
const [newPrice, oneDayPrice] = await getEthPrice();
61-
const tokenInfo = await getTokenInfo(newPrice, oneDayPrice, tokenAddress);
62-
if (tokenInfo) {
63-
const token0 = tokenInfo[0];
64-
setTokenData(token0);
65-
const tokenDetailToUpdate = {
66-
address: tokenAddress,
67-
tokenData: token0,
68-
priceData: tokenPriceData,
69-
};
70-
updateTokenDetails(tokenDetailToUpdate);
64+
if (ethPrice.price && ethPrice.oneDayPrice) {
65+
const tokenInfo = await getTokenInfo(
66+
ethPrice.price,
67+
ethPrice.oneDayPrice,
68+
tokenAddress,
69+
);
70+
if (tokenInfo) {
71+
const token0 = tokenInfo[0];
72+
setTokenData(token0);
73+
const tokenDetailToUpdate = {
74+
address: tokenAddress,
75+
tokenData: token0,
76+
priceData: tokenPriceData,
77+
};
78+
updateTokenDetails(tokenDetailToUpdate);
79+
}
7180
}
72-
}
73-
fetchTokenData();
81+
})();
7482
// eslint-disable-next-line react-hooks/exhaustive-deps
75-
}, [tokenAddress]);
83+
}, [tokenAddress, ethPrice.price, ethPrice.oneDayPrice]);
7684

7785
return (
7886
<Box>

src/components/TopMovers/TopMovers.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,38 @@ import Skeleton from '@material-ui/lab/Skeleton';
55
import { Token, ChainId } from '@uniswap/sdk';
66
import { getAddress } from '@ethersproject/address';
77
import { CurrencyLogo } from 'components';
8-
import { getEthPrice, getTopTokens, getPriceClass, formatNumber } from 'utils';
8+
import { getTopTokens, getPriceClass, formatNumber } from 'utils';
99
import 'components/styles/TopMovers.scss';
1010
import { useTranslation } from 'react-i18next';
11+
import { useEthPrice } from 'state/application/hooks';
1112

1213
interface TopMoversProps {
1314
hideArrow?: boolean;
1415
}
1516
const TopMovers: React.FC<TopMoversProps> = ({ hideArrow = false }) => {
1617
const { t } = useTranslation();
1718
const [topTokens, updateTopTokens] = useState<any[] | null>(null);
19+
const { ethPrice } = useEthPrice();
1820

1921
const topMoverTokens = useMemo(
2022
() => (topTokens && topTokens.length >= 5 ? topTokens.slice(0, 5) : null),
2123
[topTokens],
2224
);
2325

2426
useEffect(() => {
25-
async function fetchTopTokens() {
26-
const [newPrice, oneDayPrice] = await getEthPrice();
27-
const topTokensData = await getTopTokens(newPrice, oneDayPrice, 5);
28-
if (topTokensData) {
29-
updateTopTokens(topTokensData);
27+
(async () => {
28+
if (ethPrice.price && ethPrice.oneDayPrice) {
29+
const topTokensData = await getTopTokens(
30+
ethPrice.price,
31+
ethPrice.oneDayPrice,
32+
5,
33+
);
34+
if (topTokensData) {
35+
updateTopTokens(topTokensData);
36+
}
3037
}
31-
}
32-
fetchTopTokens();
33-
}, [updateTopTokens]);
38+
})();
39+
}, [updateTopTokens, ethPrice.price, ethPrice.oneDayPrice]);
3440

3541
return (
3642
<Box className='bg-palette topMoversWrapper'>

0 commit comments

Comments
 (0)