Skip to content

Commit

Permalink
fix: can not claim reward
Browse files Browse the repository at this point in the history
  • Loading branch information
viet-nv committed Sep 11, 2023
1 parent 2d1b019 commit 3bcd517
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ const CollectFeesPanel: React.FC<Props> = ({
}

const collectFeeFromFarmContract = async () => {
console.log(farmAddress, feeValue0, feeValue1)
if (!farmAddress || !feeValue0 || !feeValue1) {
dispatch(setAttemptingTxn(false))
dispatch(setTxError('Something went wrong!'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ const PositionView: React.FC<CommonProps> = 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)
Expand All @@ -135,16 +135,17 @@ const PositionView: React.FC<CommonProps> = 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

Expand Down Expand Up @@ -278,14 +279,14 @@ const PositionView: React.FC<CommonProps> = props => {

<CollectFeesPanel
nftId={positionEarning.id}
fId={positionEarning?.farmV2DepositedPosition?.farmV2.id.split('_')[1]}
fId={positionEarning?.farmV2DepositedPositions?.[0].farmV2.id.split('_')[1]}
chainId={chainId}
feeUsd={feeUsd}
feeValue0={feeReward0}
feeValue1={feeReward1}
hasUserDepositedInFarm={positionEarning.owner !== positionEarning.ownerOriginal}
farmAddress={
positionEarning?.farmV2DepositedPosition?.farmV2.id.split('_')[0] ||
positionEarning?.farmV2DepositedPositions?.[0].farmV2.id.split('_')[0] ||
positionEarning.depositedPosition?.farm ||
positionEarning.joinedPositions?.[0]?.farmId
}
Expand Down
6 changes: 3 additions & 3 deletions src/services/earning/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ export type ElasticPositionEarningWithDetails = {
liquidity: string
}[]

farmV2DepositedPosition: {
farmV2DepositedPositions: {
farmV2: {
id: string
rewards: Array<{ amount: string; index: number; token: string }>
rewards: Array<{ amount: string; index: number; tokenID: string }>
}
pendingRewards: Array<string>
}
}[]
} & HistoricalEarning

export type ClassicPositionEarningWithDetails = {
Expand Down

0 comments on commit 3bcd517

Please sign in to comment.