Skip to content

Commit

Permalink
hotfix: crash farm due to token not found
Browse files Browse the repository at this point in the history
  • Loading branch information
viet-nv committed Nov 8, 2023
1 parent 4cddec4 commit f842f98
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/components/YieldPools/ElasticFarmGroup/FarmCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ const FarmCard = ({
const token0Symbol = getTokenSymbolWithHardcode(
chainId,
pool?.token0?.wrapped?.address,
pool.token0.isNative ? pool.token0.symbol : allTokens[pool.token0.wrapped.address].symbol,
pool.token0.isNative ? pool.token0.symbol : allTokens[pool.token0.wrapped.address]?.symbol || pool.token0.symbol,
)
const token1Symbol = getTokenSymbolWithHardcode(
chainId,
pool?.token1?.wrapped?.address,
pool.token1.isNative ? pool.token1.symbol : allTokens[pool.token1.wrapped.address].symbol,
pool.token1.isNative ? pool.token1.symbol : allTokens[pool.token1.wrapped.address]?.symbol || pool.token1.symbol,
)

return (
Expand Down
8 changes: 6 additions & 2 deletions src/components/YieldPools/ElasticFarmGroup/Row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,16 @@ const Row = ({
const symbol0 = getTokenSymbolWithHardcode(
chainId,
farmingPool.token0.wrapped.address,
farmingPool.token0.isNative ? farmingPool.token0.symbol : allTokens[farmingPool.token0.wrapped.address].symbol,
farmingPool.token0.isNative
? farmingPool.token0.symbol
: allTokens[farmingPool.token0.wrapped.address]?.symbol || farmingPool.token0.symbol,
)
const symbol1 = getTokenSymbolWithHardcode(
chainId,
farmingPool.token1.wrapped.address,
farmingPool.token1.isNative ? farmingPool.token1.symbol : allTokens[farmingPool.token1.wrapped.address].symbol,
farmingPool.token1.isNative
? farmingPool.token1.symbol
: allTokens[farmingPool.token1.wrapped.address]?.symbol || farmingPool.token1.symbol,
)

return (
Expand Down
20 changes: 18 additions & 2 deletions src/pages/Farm/ElasticFarmv2/components/FarmCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { APRTooltipContent } from 'components/YieldPools/FarmingPoolAPRCell'
import { PartnerFarmTag } from 'components/YieldPools/PartnerFarmTag'
import { APP_PATHS, ELASTIC_BASE_FEE_UNIT } from 'constants/index'
import { useActiveWeb3React } from 'hooks'
import { useAllTokens } from 'hooks/Tokens'
import useTheme from 'hooks/useTheme'
import { useShareFarmAddress } from 'state/farms/classic/hooks'
import { useFarmV2Action, useUserFarmV2Info } from 'state/farms/elasticv2/hooks'
Expand Down Expand Up @@ -208,6 +209,8 @@ function FarmCard({

const range = farm.ranges.find(range => range.index === activeRangeIndex)

const allTokens = useAllTokens()

return (
<>
<Wrapper hasRewards={canUnstake}>
Expand All @@ -221,8 +224,21 @@ function FarmCard({
}}
>
<Text fontSize="16px" lineHeight="20px" color={theme.primary}>
{getTokenSymbolWithHardcode(chainId, farm.token0.wrapped.address, farm.token0.symbol)} -{' '}
{getTokenSymbolWithHardcode(chainId, farm.token1.wrapped.address, farm.token1.symbol)}
{getTokenSymbolWithHardcode(
chainId,
farm.token0.wrapped.address,
farm.token0.isNative
? farm.token0.symbol
: allTokens[farm.token0.address]?.symbol || farm.token0.symbol,
)}{' '}
-{' '}
{getTokenSymbolWithHardcode(
chainId,
farm.token1.wrapped.address,
farm.token1.isNative
? farm.token1.symbol
: allTokens[farm.token1.address]?.symbol || farm.token1.symbol,
)}
</Text>
</Link>
<IconButton>
Expand Down
20 changes: 18 additions & 2 deletions src/pages/Farm/ElasticFarmv2/components/ListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { PartnerFarmTag } from 'components/YieldPools/PartnerFarmTag'
import { ElasticFarmV2TableRow } from 'components/YieldPools/styleds'
import { APP_PATHS, ELASTIC_BASE_FEE_UNIT } from 'constants/index'
import { useActiveWeb3React } from 'hooks'
import { useAllTokens } from 'hooks/Tokens'
import useTheme from 'hooks/useTheme'
import { useShareFarmAddress } from 'state/farms/classic/hooks'
import { useFarmV2Action, useUserFarmV2Info } from 'state/farms/elasticv2/hooks'
Expand Down Expand Up @@ -114,6 +115,8 @@ export const ListView = ({
const [errorMessage, setErrorMessage] = useState('')
const [attemptingTxn, setAttemptingTxn] = useState(false)

const allTokens = useAllTokens()

const handleDismiss = () => {
setTxHash('')
setShowConfirmModal(false)
Expand Down Expand Up @@ -173,8 +176,21 @@ export const ListView = ({
}}
>
<Text fontSize={14} fontWeight={500}>
{getTokenSymbolWithHardcode(chainId, farm.token0.wrapped.address, farm.token0.symbol)} -{' '}
{getTokenSymbolWithHardcode(chainId, farm.token1.wrapped.address, farm.token1.symbol)}
{getTokenSymbolWithHardcode(
chainId,
farm.token0.wrapped.address,
farm.token0.isNative
? farm.token0.symbol
: allTokens[farm.token0.address]?.symbol || farm.token0.symbol,
)}{' '}
-{' '}
{getTokenSymbolWithHardcode(
chainId,
farm.token1.wrapped.address,
farm.token1.isNative
? farm.token1.symbol
: allTokens[farm.token1.address]?.symbol || farm.token1.symbol,
)}
</Text>
</Link>

Expand Down

0 comments on commit f842f98

Please sign in to comment.