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

Adding new gauges #96

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"@chakra-ui/toast": "2.1.0",
"@clover-network/clover-connector": "^1.0.0",
"@datastructures-js/priority-queue": "6.1.1",
"@emotion/react": "^11",
"@emotion/styled": "^11",
"@emotion/react": "11.11.1",
"@emotion/styled": "11.11.0",
"@gelatonetwork/limit-orders-lib": "4.3.0-alpha.6",
"@jcoreio/async-throttle": "^1.4.3",
"@lifi/sdk": "1.1.3",
Expand Down
15 changes: 15 additions & 0 deletions src/app/assets/icons/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ import { ReactComponent as PeckShieldAudit } from 'app/assets/images/peckShieldA
import { ReactComponent as ParaSwap } from 'app/assets/images/paraSwap.svg';
import { ReactComponent as Algebra } from 'app/assets/images/algebra.svg';

import { ReactComponent as V3Icon } from 'app/assets/images/V3Icon.svg';
import { ReactComponent as V2Icon } from 'app/assets/images/V2Icon.svg';
import { ReactComponent as X2Icon } from 'app/assets/images/X2Icon.svg';

const { ci, grayDarker, danger, warning } = colors;
const iconSize = {
xs: '12px',
Expand All @@ -98,6 +102,17 @@ const iconSize = {

const { md } = iconSize;

export const V3IconBadge = ({ w = md, h = md, ...rest }) => {
return <Icon {...rest} as={V3Icon} w={w} h={h} />;
};
export const X2IconBadge = ({ w = md, h = md, ...rest }) => {
return <Icon {...rest} as={X2Icon} w={w} h={h} />;
};

export const V2IconBadge = ({ w = md, h = md, ...rest }) => {
return <Icon {...rest} as={V2Icon} w={w} h={h} />;
};

export const ZokyoAuditLogo = ({ w = md, h = md, color = ci, ...rest }) => {
return <Icon {...rest} as={zokyoAudit} color={color} w={w} h={h} />;
};
Expand Down
37 changes: 37 additions & 0 deletions src/app/assets/images/V2Icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions src/app/assets/images/V3Icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions src/app/assets/images/X2Icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 10 additions & 9 deletions src/app/components/NewTokenAmountPanel/NewTokenAmountPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,16 @@ const NewTokenAmountPanel = ({
token?.symbol !== 'FTM' ? [token?.address ?? ''] : [WFTM.address],
token?.chainId ?? 1,
);
tokensPrices.forEach(price => {
if (
price.address.toLowerCase() === token?.address.toLowerCase() ||
(token?.symbol === 'FTM' &&
price.address.toLowerCase() === WFTM.address.toLowerCase())
) {
setTokenPrice(price.rate);
}
});
tokensPrices &&
tokensPrices.forEach(price => {
if (
price.address.toLowerCase() === token?.address.toLowerCase() ||
(token?.symbol === 'FTM' &&
price.address.toLowerCase() === WFTM.address.toLowerCase())
) {
setTokenPrice(price.rate);
}
});
};

fetchTokenPrice();
Expand Down
5 changes: 0 additions & 5 deletions src/app/components/RangeSelector/RangeSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { Bound } from 'store/v3/mint/actions';

import { RangeSelectorPart } from '../RangeSelectorPart';

import type { Props } from './RangeSelector.d';
import { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { Grid, GridItem, Skeleton } from '@chakra-ui/react';
import { Heading } from '../Typography';
import { StyledCurrentPrice, StyledCurrentPriceWrapper } from './styled';
Expand All @@ -26,8 +23,6 @@ export default function RangeSelector({
isAfterPrice,
mintInfo,
}: Props) {
const { t } = useTranslation();

const tokenA = (currencyA ?? undefined)?.wrapped;
const tokenB = (currencyB ?? undefined)?.wrapped;

Expand Down
4 changes: 2 additions & 2 deletions src/app/components/Select/Select.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { FC, useCallback } from 'react';
import React, { useCallback } from 'react';
import { Props } from './Select.d';
import { StyledContainer, StyledHeading, StyledItem } from './styles';

const Select: FC<Props> = ({
const Select = ({
labels = [],
selected = 0,
disabled = false,
Expand Down
5 changes: 1 addition & 4 deletions src/app/components/TWAP/TWAPOrders.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Orders } from '@orbs-network/twap-ui-spiritswap';
import useWallets from 'app/hooks/useWallets';
import { useTokens } from 'app/hooks/useTokens';
import { getProvider } from 'app/connectors/EthersConnector/login';
import { LimitOrderContainer } from 'app/pages/Swap/components/LimitOrders/styles';
import { getTokenImageUrl } from '../ImageLogo';

Expand All @@ -14,9 +13,7 @@ function TWAPOrders({ showChart }: { showChart: boolean }) {
<Orders
dappTokens={tokens || []}
account={account}
getProvider={async () => {
return await getProvider();
}}
getProvider={() => window.ethereum}
getTokenImageUrl={getTokenImageUrl}
/>
</LimitOrderContainer>
Expand Down
3 changes: 1 addition & 2 deletions src/app/components/TWAP/TWAPPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ModalToken } from 'app/components/ModalToken';
import { getProvider } from 'app/connectors/EthersConnector/login';
import { useTokens } from 'app/hooks/useTokens';
import useWallets from 'app/hooks/useWallets';
import { TWAP } from '@orbs-network/twap-ui-spiritswap';
Expand Down Expand Up @@ -29,7 +28,7 @@ function TWAPPanel({ gasPrice, panelProps }: TWAPPanelProps) {
TokenSelectModal={ModalToken}
dappTokens={tokens}
account={account}
getProvider={getProvider}
getProvider={() => window.ethereum}
getTokenImageUrl={getTokenImageUrl}
onSrcTokenSelected={(token: Token) =>
handleChangeToken(token, () => {}, 0)
Expand Down
14 changes: 7 additions & 7 deletions src/app/components/TransactionFlow/utils/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const buildAddLiquidity = (
| AddLiquidityTradeV3
| null,
isV2?: boolean,
type?: number, // classic: 0, stable: 1, concentrated: 2, weighted: 3
type?: number, // varible: 0, stable: 1, concentrated: 2, weighted: 3
isStable?: boolean,
): StepProps | {} => {
let action: Function = addLiquidity;
Expand All @@ -91,12 +91,12 @@ export const buildAddLiquidity = (
}
}

if (type === 3) {
action = addWeightedLiquidity;
if (liquidityTrade) {
params = Object.values(liquidityTrade);
}
}
// if (type === 3) {
// action = addWeightedLiquidity;
// if (liquidityTrade) {
// params = Object.values(liquidityTrade);
// }
// }

return {
number,
Expand Down
7 changes: 6 additions & 1 deletion src/app/connectors/EthersConnector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { WorkerCall } from 'types';
import useWallets from 'app/hooks/useWallets';
import getNotificationIcon from '../getNotificationIcon';
import { selectAddress, selectPendingTransactions } from 'store/user/selectors';
import { ethers } from 'ethers';

const EthersConnector = ({ children }) => {
const toast = useToast();
Expand Down Expand Up @@ -245,7 +246,11 @@ const EthersConnector = ({ children }) => {
Object.keys(inQueue).forEach(hash => {
if (!hash) return;

const receiptPromise = provider!.getTransactionReceipt(hash);
const newProvider = provider
? new ethers.providers.Web3Provider(provider, 'any')
: undefined;

const receiptPromise = newProvider!.getTransactionReceipt(hash);

const match = pending.find(
transaction => `${transaction.hash}` === `${hash}`,
Expand Down
2 changes: 1 addition & 1 deletion src/app/connectors/EthersConnector/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const useLogin = () => {
dispatch(resetUserStatistics());
}
} catch (error) {
console.log(error);
console.error(error);
}
},
[dispatch, setLoggedIn],
Expand Down
1 change: 1 addition & 0 deletions src/app/hooks/useGetTokensPrices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const useGetTokensPrices = ({
try {
setLoadingPrices(true);
const data = await getTokensDetails(tokenAddresses, chainId);
if (!data) return setTokensPrices({});
let tokenObjectPrices = {};
data?.forEach(token => {
if (token.address === BASE_TOKEN_ADDRESS) {
Expand Down
1 change: 0 additions & 1 deletion src/app/hooks/usePieChartData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ const usePieChartData = ({ farmsList }: { farmsList: BoostedFarm[] }) => {
datasets: [
{
data,

borderColor: ['white'],
borderWidth: 1,
hoverBorderWidth: 2,
Expand Down
6 changes: 2 additions & 4 deletions src/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ export function App() {
<GlobalStyleProxy />

<Layout>
<>
<Layers />
<SiteRouting />
</>
<Layers />
<SiteRouting />
</Layout>
</RootPathContext.Provider>
);
Expand Down
3 changes: 1 addition & 2 deletions src/app/interfaces/Farm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,9 @@ export interface GaugeFarm {

export enum FarmType {
ALL,
CLASSIC,
VARIABLE,
STABLE,
CONCENTRATED,
ADMIN,
}

export enum EcosystemFarmType {
Expand Down
5 changes: 2 additions & 3 deletions src/app/pages/Farms/Farm/Farm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { YourApr } from '../components/YourApr';
import { IconButton } from 'app/components/IconButton';
import { StyledContainer } from './styles';
import { ReactComponent as SparklesIcon } from 'app/assets/images/sparkles.svg';
import { BoostFactor } from '../components/BoostFactor';
import Web3Monitoring from 'app/connectors/EthersConnector/transactions';
import { transactionResponse } from 'utils/web3/actions/utils';
import { checkAddress, formatNumber, getRoundedSFs } from 'app/utils';
Expand All @@ -22,7 +21,6 @@ import {
AccordionPanel,
Spinner,
Skeleton,
Flex,
} from '@chakra-ui/react';
import { RetrieveTokens } from '../components/RetrieveTokens/RetrieveTokens';
import {
Expand All @@ -41,7 +39,7 @@ import BigNumber from 'bignumber.js';
import { formatUnits } from 'ethers/lib/utils';
import { Props } from './Farm.d';
import useGetTokensPrices from 'app/hooks/useGetTokensPrices';
import { LIQUIDITY, resolveRoutePath } from 'app/router/routes';
import { LIQUIDITY } from 'app/router/routes';
import { RetrieveConcentratedPosition } from '../components/RetrieveConcentratedPosition/RetrieveConcentratedPosition';

export const Farm = ({
Expand Down Expand Up @@ -306,6 +304,7 @@ export const Farm = ({

return earnedRewards;
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [concentratedEarned, concentratedBonusEarned]);

const hasConcenctratedRewards = concentratedEarned || concentratedBonusEarned;
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/Farms/FarmController/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const MemorizeTokenList = memo(({ farm }: IFarm) => (
ecosystem={farm.ecosystem}
apr={farm.apr}
rewardToken={farm.rewardToken}
farmType={farm.type}
farmType={farm.label}
lpAddress={farm.lpAddress}
type={farm.type}
hideTypeIcons={Boolean(farm.concentrated)}
Expand Down
Loading