From 3bcd517207bc0cd23609d62c7fe0ad4bf95a5798 Mon Sep 17 00:00:00 2001 From: viet-nv Date: Mon, 11 Sep 2023 16:38:42 +0700 Subject: [PATCH] fix: can not claim reward --- .../SinglePosition/CollectFeesPanel.tsx | 1 + .../SinglePosition/PositionView.tsx | 17 +++++++++-------- src/services/earning/types.ts | 6 +++--- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/pages/MyEarnings/ElasticPools/SinglePosition/CollectFeesPanel.tsx b/src/pages/MyEarnings/ElasticPools/SinglePosition/CollectFeesPanel.tsx index 417ba4dc86..bca7b879e4 100644 --- a/src/pages/MyEarnings/ElasticPools/SinglePosition/CollectFeesPanel.tsx +++ b/src/pages/MyEarnings/ElasticPools/SinglePosition/CollectFeesPanel.tsx @@ -135,6 +135,7 @@ const CollectFeesPanel: React.FC = ({ } const collectFeeFromFarmContract = async () => { + console.log(farmAddress, feeValue0, feeValue1) if (!farmAddress || !feeValue0 || !feeValue1) { dispatch(setAttemptingTxn(false)) dispatch(setTxError('Something went wrong!')) diff --git a/src/pages/MyEarnings/ElasticPools/SinglePosition/PositionView.tsx b/src/pages/MyEarnings/ElasticPools/SinglePosition/PositionView.tsx index 7ed985fbe5..c948ed4855 100644 --- a/src/pages/MyEarnings/ElasticPools/SinglePosition/PositionView.tsx +++ b/src/pages/MyEarnings/ElasticPools/SinglePosition/PositionView.tsx @@ -124,8 +124,8 @@ const PositionView: React.FC = props => { }) || [] const farmV2Rewards = - positionEarning.farmV2DepositedPosition?.pendingRewards.map((amount, index) => { - const tokenId = positionEarning.farmV2DepositedPosition?.farmV2.rewards[index].token || '' + positionEarning.farmV2DepositedPositions?.[0].pendingRewards.map((amount, index) => { + const tokenId = positionEarning.farmV2DepositedPositions?.[0].farmV2.rewards[index].tokenID || '' const token = tokens[tokenId] || new Token(chainId, tokenId, 18, '', '') return CurrencyAmount.fromRawAmount(token, amount) @@ -135,16 +135,17 @@ const PositionView: React.FC = props => { const disabledHarvest = !positionEarning.joinedPositions?.[0]?.pendingRewards?.some(item => item !== '0') && - !positionEarning.farmV2DepositedPosition?.pendingRewards?.some(item => item !== '0') + !positionEarning.farmV2DepositedPositions?.[0].pendingRewards?.some(item => item !== '0') const addTransactionWithType = useTransactionAdder() const handleHarvest = () => { const farmContract = - positionEarning.joinedPositions?.[0]?.farmId || positionEarning.farmV2DepositedPosition?.farmV2.id.split('_')[0] - const isInFarmV2 = !!positionEarning.farmV2DepositedPosition + positionEarning.joinedPositions?.[0]?.farmId || + positionEarning.farmV2DepositedPositions?.[0].farmV2.id.split('_')[0] + const isInFarmV2 = !!positionEarning.farmV2DepositedPositions?.[0] const pId = positionEarning.joinedPositions?.[0]?.pid - const fId = positionEarning?.farmV2DepositedPosition?.farmV2.id.split('_')[1] + const fId = positionEarning?.farmV2DepositedPositions?.[0].farmV2.id.split('_')[1] const library = libraryRef.current @@ -278,14 +279,14 @@ const PositionView: React.FC = props => { + rewards: Array<{ amount: string; index: number; tokenID: string }> } pendingRewards: Array - } + }[] } & HistoricalEarning export type ClassicPositionEarningWithDetails = {