diff --git a/src/pages/Farm/ElasticFarmv2/components/FarmCard.tsx b/src/pages/Farm/ElasticFarmv2/components/FarmCard.tsx index 760f00cc17..3de0fdcf6c 100644 --- a/src/pages/Farm/ElasticFarmv2/components/FarmCard.tsx +++ b/src/pages/Farm/ElasticFarmv2/components/FarmCard.tsx @@ -116,12 +116,15 @@ function FarmCard({ const currentTimestamp = Math.floor(Date.now() / 1000) const stakedPos = useUserFarmV2Info(farm.farmAddress, farm.fId) + let amountToken0 = CurrencyAmount.fromRawAmount(farm.token0.wrapped, 0) let amountToken1 = CurrencyAmount.fromRawAmount(farm.token1.wrapped, 0) stakedPos.forEach(item => { - amountToken0 = amountToken0.add(item.position.amount0) - amountToken1 = amountToken1.add(item.position.amount1) + if (item.position.amount0?.currency.equals(amountToken0.currency)) + amountToken0 = amountToken0.add(item.position.amount0) + if (item.position.amount1?.currency.equals(amountToken1.currency)) + amountToken1 = amountToken1.add(item.position.amount1) }) const canUnstake = stakedPos.length > 0 @@ -131,7 +134,10 @@ function FarmCard({ const userTotalRewards = farm.totalRewards.map((item, index) => { return stakedPos .map(item => item.unclaimedRewards[index]) - .reduce((total, cur) => total.add(cur), CurrencyAmount.fromRawAmount(item.currency, 0)) + .reduce( + (total, cur) => (cur?.currency?.equals(total.currency) ? total.add(cur) : total), + CurrencyAmount.fromRawAmount(item.currency, 0), + ) }) const myDepositUSD = stakedPos.reduce((total, item) => item.stakedUsdValue + total, 0) diff --git a/src/pages/Farm/ElasticFarmv2/components/ListView.tsx b/src/pages/Farm/ElasticFarmv2/components/ListView.tsx index 6901f83183..a4058de4cc 100644 --- a/src/pages/Farm/ElasticFarmv2/components/ListView.tsx +++ b/src/pages/Farm/ElasticFarmv2/components/ListView.tsx @@ -73,8 +73,10 @@ export const ListView = ({ let amountToken1 = CurrencyAmount.fromRawAmount(farm.token1.wrapped, 0) stakedPos.forEach(item => { - amountToken0 = amountToken0.add(item.position.amount0) - amountToken1 = amountToken1.add(item.position.amount1) + if (item.position.amount0?.currency.equals(amountToken0.currency)) + amountToken0 = amountToken0.add(item.position.amount0) + if (item.position.amount1?.currency.equals(amountToken1.currency)) + amountToken1 = amountToken1.add(item.position.amount1) }) const canUnstake = stakedPos.length > 0 @@ -84,7 +86,10 @@ export const ListView = ({ const userTotalRewards = farm.totalRewards.map((item, index) => { return stakedPos .map(item => item.unclaimedRewards[index]) - .reduce((total, cur) => total.add(cur), CurrencyAmount.fromRawAmount(item.currency, 0)) + .reduce( + (total, cur) => (cur?.currency?.equals(total.currency) ? total.add(cur) : total), + CurrencyAmount.fromRawAmount(item.currency, 0), + ) }) const myDepositUSD = stakedPos.reduce((total, item) => item.stakedUsdValue + total, 0)