diff --git a/src/components/ClassicElasticTab.tsx b/src/components/ClassicElasticTab.tsx index dde42e3db3..bf2fec8021 100644 --- a/src/components/ClassicElasticTab.tsx +++ b/src/components/ClassicElasticTab.tsx @@ -46,10 +46,11 @@ function ClassicElasticTab() { const isFarmPage = location.pathname.startsWith(APP_PATHS.FARMS) const isMyPoolPage = location.pathname.startsWith(APP_PATHS.MY_POOLS) const [isOpenElasticHacked, setOpenElasticHacked] = useState( - tab === VERSION.ELASTIC && !notSupportedElasticMsg && !skipAlert, + isMyPoolPage ? false : tab === VERSION.ELASTIC && !notSupportedElasticMsg && !skipAlert, ) useEffect(() => { + if (isMyPoolPage) return if (notSupportedClassicMsg) { setOpenElasticHacked(!skipAlert) } @@ -57,7 +58,7 @@ function ClassicElasticTab() { setOpenElasticHacked(!skipAlert) } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [chainId]) + }, [chainId, isMyPoolPage]) const upToMedium = useMedia(`(max-width: ${MEDIA_WIDTHS.upToMedium}px)`) @@ -282,15 +283,11 @@ function ClassicElasticTab() { isOpen={isOpenElasticHacked} onClose={() => { setOpenElasticHacked(false) - if (!isMyPoolPage) { - handleSwitchTab(VERSION.CLASSIC) - } + handleSwitchTab(VERSION.CLASSIC) }} onConfirm={() => { setOpenElasticHacked(false) - if (!isMyPoolPage) { - navigate({ pathname: APP_PATHS.MY_POOLS, search: 'skipAlert=1' }) - } + navigate({ pathname: APP_PATHS.MY_POOLS, search: 'skipAlert=1' }) }} /> diff --git a/src/components/ProAmm/ProAmmFee.tsx b/src/components/ProAmm/ProAmmFee.tsx index eb778f9023..6334ae6fb2 100644 --- a/src/components/ProAmm/ProAmmFee.tsx +++ b/src/components/ProAmm/ProAmmFee.tsx @@ -142,8 +142,8 @@ export default function ProAmmFee({ amount1Min.quotient.toString(), deadline?.toString(), buildFlagsForFarmV21({ - isClaimFee: !!feeValue0?.greaterThan('0') && !!feeValue1?.greaterThan('0'), - isSyncFee: !!feeValue0?.greaterThan('0') && !!feeValue1?.greaterThan('0'), + isClaimFee: false, // !!feeValue0?.greaterThan('0') && !!feeValue1?.greaterThan('0'), + isSyncFee: false, // !!feeValue0?.greaterThan('0') && !!feeValue1?.greaterThan('0'), isClaimReward: false, isReceiveNative: true, }), diff --git a/src/pages/ProAmmPool/PositionGrid.tsx b/src/pages/ProAmmPool/PositionGrid.tsx index bb9991defb..c4f79486e0 100644 --- a/src/pages/ProAmmPool/PositionGrid.tsx +++ b/src/pages/ProAmmPool/PositionGrid.tsx @@ -7,9 +7,7 @@ import { FixedSizeGrid as FixedSizeGridRW, GridChildComponentProps, areEqual } f import styled from 'styled-components' import { useActiveWeb3React } from 'hooks' -import { useProAmmTickReader } from 'hooks/useContract' import { useKyberSwapConfig } from 'state/application/hooks' -import { useSingleContractMultipleData } from 'state/multicall/hooks' import { MEDIA_WIDTHS } from 'theme' import { PositionDetails } from 'types/position' @@ -65,7 +63,7 @@ const queryPositionLastCollectedTimes = gql` ` function PositionGrid({ positions, refe }: { positions: PositionDetails[]; refe?: React.MutableRefObject }) { - const { networkInfo, chainId } = useActiveWeb3React() + const { chainId } = useActiveWeb3React() const { elasticClient } = useKyberSwapConfig(chainId) const upToSmall = useMedia(`(max-width: ${MEDIA_WIDTHS.upToSmall}px)`) @@ -117,26 +115,27 @@ function PositionGrid({ positions, refe }: { positions: PositionDetails[]; refe? [data], ) - const tickReaderContract = useProAmmTickReader() - const rewardRes = useSingleContractMultipleData( - tickReaderContract, - 'getTotalFeesOwedToPosition', - positions.map(item => [networkInfo.elastic.nonfungiblePositionManager, item.poolId, item.tokenId]), - ) + // TODO: Temporary hardcoded fee to 0 + // const rewardRes = useSingleContractMultipleData( + // tickReaderContract, + // 'getTotalFeesOwedToPosition', + // positions.map(item => [networkInfo.elastic.nonfungiblePositionManager, item.poolId, item.tokenId]), + // ) const feeRewards = useMemo(() => { - return positions.reduce<{ [tokenId: string]: [string, string] }>((acc, item, index) => { + return positions.reduce<{ [tokenId: string]: [string, string] }>((acc, item, _index) => { return { ...acc, - [item.tokenId.toString()]: rewardRes[index].result - ? [ - rewardRes[index].result?.token0Owed?.toString() || '0', - rewardRes[index].result?.token1Owed.toString() || '0', - ] - : ['0', '0'], + [item.tokenId.toString()]: ['0', '0'], + // rewardRes[index].result + // ? [ + // rewardRes[index].result?.token0Owed?.toString() || '0', + // rewardRes[index].result?.token1Owed.toString() || '0', + // ] + // : ['0', '0'] , } }, {}) - }, [positions, rewardRes]) + }, [positions]) const itemData = createItemData(positions, liquidityTimes, farmingTimes, feeRewards, createdAts, refe) diff --git a/src/pages/ProAmmPool/PositionListItem.tsx b/src/pages/ProAmmPool/PositionListItem.tsx index f6fcdbd202..2590edd498 100644 --- a/src/pages/ProAmmPool/PositionListItem.tsx +++ b/src/pages/ProAmmPool/PositionListItem.tsx @@ -4,7 +4,7 @@ import { Trans, t } from '@lingui/macro' import { BigNumber } from 'ethers' import mixpanel from 'mixpanel-browser' import { stringify } from 'querystring' -import React, { useEffect, useMemo, useState } from 'react' +import React, { useMemo, useState } from 'react' import { Link } from 'react-router-dom' import { Flex, Text } from 'rebass' import styled from 'styled-components' @@ -22,7 +22,6 @@ import { MouseoverTooltip } from 'components/Tooltip' import { APP_PATHS, PROMM_ANALYTICS_URL } from 'constants/index' import { useActiveWeb3React } from 'hooks' import { useToken } from 'hooks/Tokens' -import { useProMMFarmReadingContract } from 'hooks/useContract' import useIsTickAtLimit from 'hooks/useIsTickAtLimit' import useMixpanel, { MIXPANEL_TYPE } from 'hooks/useMixpanel' import { usePool } from 'hooks/usePools' @@ -30,7 +29,6 @@ import useTheme from 'hooks/useTheme' import { useElasticFarms } from 'state/farms/elastic/hooks' import { UserPositionFarm } from 'state/farms/elastic/types' import { useElasticFarmsV2 } from 'state/farms/elasticv2/hooks' -import { NEVER_RELOAD, useSingleCallResult } from 'state/multicall/hooks' import { useTokenPrices } from 'state/tokenPrices/hooks' import { ExternalLink, StyledInternalLink } from 'theme' import { PositionDetails } from 'types/position' @@ -165,7 +163,7 @@ function PositionListItem({ const { farms: farmV2s, userInfo } = useElasticFarmsV2() let farmAddress = '' - let pid = '' + // let pid = '' let rewardTokens: Currency[] = [] let hasActiveFarm = false @@ -175,7 +173,7 @@ function PositionListItem({ farmAddress = farm.id rewardTokens = pool.rewardTokens if (pool.endTime > Date.now() / 1000) { - pid = pool.pid + // pid = pool.pid hasActiveFarm = true } } @@ -189,25 +187,25 @@ function PositionListItem({ f.ranges.some(r => positionDetails.tickLower <= r.tickLower && positionDetails.tickUpper >= r.tickUpper), ).length - const farmContract = useProMMFarmReadingContract(farmAddress) + // const farmContract = useProMMFarmReadingContract(farmAddress) const tokenId = positionDetails.tokenId.toString() - const [farmReward, setFarmReward] = useState(null) - - const res = useSingleCallResult( - pid !== '' ? farmContract : undefined, - 'getUserInfo', - pid !== '' ? [tokenId, pid] : undefined, - NEVER_RELOAD, - ) - useEffect(() => { - if (res?.result?.rewardPending) { - setFarmReward(res.result.rewardPending) - } else { - setFarmReward(null) - } - }, [res]) + const [farmReward, _setFarmReward] = useState(null) + + // const res = useSingleCallResult( + // pid !== '' ? farmContract : undefined, + // 'getUserInfo', + // pid !== '' ? [tokenId, pid] : undefined, + // NEVER_RELOAD, + // ) + // useEffect(() => { + // if (res?.result?.rewardPending) { + // setFarmReward(res.result.rewardPending) + // } else { + // setFarmReward(null) + // } + // }, [res]) const token0 = useToken(token0Address) const token1 = useToken(token1Address) diff --git a/src/pages/RemoveLiquidityProAmm/index.tsx b/src/pages/RemoveLiquidityProAmm/index.tsx index 4f63bc27c7..d0523fe4da 100644 --- a/src/pages/RemoveLiquidityProAmm/index.tsx +++ b/src/pages/RemoveLiquidityProAmm/index.tsx @@ -1,7 +1,7 @@ import { BigNumber } from '@ethersproject/bignumber' import { TransactionResponse } from '@ethersproject/providers' import { ZERO } from '@kyberswap/ks-sdk-classic' -import { ChainId, Currency, CurrencyAmount, Percent, WETH } from '@kyberswap/ks-sdk-core' +import { Currency, CurrencyAmount, Percent, WETH } from '@kyberswap/ks-sdk-core' import { FeeAmount, NonfungiblePositionManager } from '@kyberswap/ks-sdk-elastic' import { Trans, t } from '@lingui/macro' import { captureException } from '@sentry/react' @@ -29,7 +29,6 @@ import ProAmmPooledTokens from 'components/ProAmm/ProAmmPooledTokens' import { RowBetween } from 'components/Row' import Slider from 'components/Slider' import { SLIPPAGE_EXPLANATION_URL } from 'components/SlippageWarningNote' -import Toggle from 'components/Toggle' import { MouseoverTooltip, TextDashed } from 'components/Tooltip' import TransactionConfirmationModal, { ConfirmationModalContent, @@ -154,14 +153,9 @@ function Remove({ tokenId }: { tokenId: BigNumber }) { const { position } = useProAmmPositionsFromTokenId(tokenId) const positionManager = useProAmmNFTPositionManagerReadingContract() const theme = useTheme() - const [claimFee, setIsClaimFee] = useState(false) + const [claimFee, _setIsClaimFee] = useState(false) const { networkInfo, account, chainId } = useActiveWeb3React() - useEffect(() => { - if (chainId === ChainId.LINEA || chainId === ChainId.SCROLL) { - setIsClaimFee(true) - } - }, [chainId]) const { library } = useWeb3React() const toggleWalletModal = useWalletModalToggle() @@ -317,9 +311,9 @@ function Remove({ tokenId }: { tokenId: BigNumber }) { amount1Min.quotient.toString(), deadline.toString(), buildFlagsForFarmV21({ - isClaimFee: claimFee && !!feeValue0?.greaterThan('0') && !!feeValue1?.greaterThan('0'), - isSyncFee: !!feeValue0?.greaterThan('0') && !!feeValue1?.greaterThan('0'), - isClaimReward: claimFee, + isClaimFee: false, + isSyncFee: false, + isClaimReward: false, isReceiveNative: !receiveWETH, }), ] @@ -330,7 +324,7 @@ function Remove({ tokenId }: { tokenId: BigNumber }) { amount0Min.quotient.toString(), amount1Min.quotient.toString(), deadline.toString(), - claimFee ? feeValue0?.greaterThan('0') : 0, + false, // isClaimFee !receiveWETH, ] : [ @@ -340,7 +334,7 @@ function Remove({ tokenId }: { tokenId: BigNumber }) { amount1Min.quotient.toString(), deadline.toString(), !receiveWETH, - [claimFee && feeValue0?.greaterThan('0'), claimFee], + [false, false], ] const gasEstimation = await contract.estimateGas.removeLiquidity(...params) @@ -781,18 +775,6 @@ function Remove({ tokenId }: { tokenId: BigNumber }) { /> - - - - Claim Your Fees Earned - - { - setIsClaimFee(prev => !prev) - }} - /> - {slippageStatus === SLIPPAGE_STATUS.HIGH && ( diff --git a/src/state/burn/proamm/hooks.tsx b/src/state/burn/proamm/hooks.tsx index a35f4914cc..4820a46297 100644 --- a/src/state/burn/proamm/hooks.tsx +++ b/src/state/burn/proamm/hooks.tsx @@ -6,7 +6,6 @@ import { ReactNode, useCallback, useMemo } from 'react' import { useActiveWeb3React } from 'hooks' import { useToken } from 'hooks/Tokens' import { usePool } from 'hooks/usePools' -import { useTotalFeeOwedByElasticPosition } from 'hooks/useProAmmPreviousTicks' import { AppState } from 'state' import { useAppDispatch, useAppSelector } from 'state/hooks' import { tryParseAmount } from 'state/swap/hooks' @@ -128,9 +127,9 @@ export function useDerivedProAmmBurnInfo( // error = error ?? Enter a percent // } - const { feeOwed, loading: loadingFee } = useTotalFeeOwedByElasticPosition(pool, position?.tokenId.toString(), asWETH) + // const { feeOwed, loading: loadingFee } = useTotalFeeOwedByElasticPosition(pool, position?.tokenId.toString(), asWETH) - const [feeValue0, feeValue1] = feeOwed + // const [feeValue0, feeValue1] = feeOwed const parsedAmounts: { [Field.LIQUIDITY_PERCENT]: Percent @@ -155,9 +154,9 @@ export function useDerivedProAmmBurnInfo( liquidityPercentage, liquidityValue0, liquidityValue1, - feeValue0, - feeValue1, - loadingFee, + feeValue0: liquidityValue0?.currency ? CurrencyAmount.fromRawAmount(liquidityValue0?.currency, 0) : undefined, + feeValue1: liquidityValue1?.currency ? CurrencyAmount.fromRawAmount(liquidityValue1?.currency, 0) : undefined, + loadingFee: false, outOfRange, error, parsedAmounts, diff --git a/src/state/farms/elastic/hooks.ts b/src/state/farms/elastic/hooks.ts index a1cae68449..f02bc649ba 100644 --- a/src/state/farms/elastic/hooks.ts +++ b/src/state/farms/elastic/hooks.ts @@ -1,5 +1,5 @@ import { defaultAbiCoder } from '@ethersproject/abi' -import { ChainId, Currency, CurrencyAmount, Token } from '@kyberswap/ks-sdk-core' +import { Currency, CurrencyAmount, Token } from '@kyberswap/ks-sdk-core' import { FeeAmount, Position, computePoolAddress } from '@kyberswap/ks-sdk-elastic' import { t } from '@lingui/macro' import { BigNumber } from 'ethers' @@ -672,7 +672,6 @@ const getUserInfoFragment = farmInterface.getFunction('getUserInfo') export function useJoinedPositions() { const positions = useDepositedNfts() const { farms } = useElasticFarms() - const { chainId } = useActiveWeb3React() const params = useMemo(() => { return (farms || []).map(farm => { @@ -759,9 +758,9 @@ export function useJoinedPositions() { rewardPendings[pid][i] = rewardPendings[pid][i].add(amount) } - // TODO: - if (chainId !== ChainId.LINEA && chainId !== ChainId.SCROLL) - rewardPendings[pid][i] = CurrencyAmount.fromRawAmount(currency, 0) + // TODO: hardcode for now. maybe all farm code will be delete in the future :/ + rewardPendings[pid][i] = CurrencyAmount.fromRawAmount(currency, 0) + rewardByNft[id][i] = CurrencyAmount.fromRawAmount(currency, 0) }) } } @@ -774,7 +773,7 @@ export function useJoinedPositions() { } }) return userInfo - }, [result, params, chainId, farms, positions]) + }, [result, params, farms, positions]) } export function useUserInfoByFarm(farmAddress: string): UserInfo { diff --git a/src/state/farms/elasticv2/updater.tsx b/src/state/farms/elasticv2/updater.tsx index ad4c11782c..6fe94021a3 100644 --- a/src/state/farms/elasticv2/updater.tsx +++ b/src/state/farms/elasticv2/updater.tsx @@ -2,7 +2,7 @@ import { gql, useLazyQuery } from '@apollo/client' import { defaultAbiCoder } from '@ethersproject/abi' import { getCreate2Address } from '@ethersproject/address' import { keccak256 } from '@ethersproject/solidity' -import { ChainId, CurrencyAmount, Token, WETH } from '@kyberswap/ks-sdk-core' +import { CurrencyAmount, Token, WETH } from '@kyberswap/ks-sdk-core' import { FeeAmount, Pool, Position } from '@kyberswap/ks-sdk-elastic' import { BigNumber } from 'ethers' import { Interface } from 'ethers/lib/utils' @@ -416,12 +416,10 @@ export default function ElasticFarmV2Updater({ interval = true }: { interval?: b +stakedPos.amount1.toExact() * (prices[stakedPos.amount1.currency.wrapped.address] || 0) // TODO: temporary set 0: item.currentUnclaimedRewards[i].toString() - const unclaimedRewards = - chainId === ChainId.LINEA || chainId === ChainId.SCROLL - ? farm.totalRewards.map((rw, i) => - CurrencyAmount.fromRawAmount(rw.currency, item.currentUnclaimedRewards[i].toString()), - ) - : farm.totalRewards.map((rw, _i) => CurrencyAmount.fromRawAmount(rw.currency, 0)) + const unclaimedRewards = farm.totalRewards.map((rw, i) => + CurrencyAmount.fromRawAmount(rw.currency, item.currentUnclaimedRewards[i].toString()), + ) + // : farm.totalRewards.map((rw, _i) => CurrencyAmount.fromRawAmount(rw.currency, 0)) const unclaimedRewardsUsd = unclaimedRewards.reduce( (total, item) => total + +item.toExact() * (prices[item.currency.wrapped.address] || 0),