From 531d50357cecd6fc0c131e87ce1f7468e81a500f Mon Sep 17 00:00:00 2001 From: William Poulin Date: Tue, 7 Nov 2023 16:11:31 -0500 Subject: [PATCH] fix(trader-joe): Fix reward balances (#3022) --- ...joe.chef-v2-farm.contract-position-fetcher.ts | 16 ++++++++++++++-- ...joe.chef-v3-farm.contract-position-fetcher.ts | 16 ++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/apps/trader-joe/avalanche/trader-joe.chef-v2-farm.contract-position-fetcher.ts b/src/apps/trader-joe/avalanche/trader-joe.chef-v2-farm.contract-position-fetcher.ts index 332f46180..3bdb3f8ae 100644 --- a/src/apps/trader-joe/avalanche/trader-joe.chef-v2-farm.contract-position-fetcher.ts +++ b/src/apps/trader-joe/avalanche/trader-joe.chef-v2-farm.contract-position-fetcher.ts @@ -94,7 +94,13 @@ export class AvalancheTraderJoeChefV2FarmContractPositionFetcher extends MasterC contract, contractPosition, }: GetMasterChefTokenBalancesParams) { - return contract.pendingTokens(contractPosition.dataProps.poolIndex, address).then(v => v.pendingJoe); + return contract + .pendingTokens(contractPosition.dataProps.poolIndex, address) + .then(v => v.pendingJoe) + .catch(e => { + if (isMulticallUnderlyingError(e)) return 0; + throw e; + }); } async getExtraRewardTokenBalances({ @@ -102,6 +108,12 @@ export class AvalancheTraderJoeChefV2FarmContractPositionFetcher extends MasterC contract, contractPosition, }: GetMasterChefV2ExtraRewardTokenBalancesParams) { - return contract.pendingTokens(contractPosition.dataProps.poolIndex, address).then(v => v.pendingBonusToken); + return contract + .pendingTokens(contractPosition.dataProps.poolIndex, address) + .then(v => v.pendingBonusToken) + .catch(e => { + if (isMulticallUnderlyingError(e)) return 0; + throw e; + }); } } diff --git a/src/apps/trader-joe/avalanche/trader-joe.chef-v3-farm.contract-position-fetcher.ts b/src/apps/trader-joe/avalanche/trader-joe.chef-v3-farm.contract-position-fetcher.ts index e6c8182c5..28e85736c 100644 --- a/src/apps/trader-joe/avalanche/trader-joe.chef-v3-farm.contract-position-fetcher.ts +++ b/src/apps/trader-joe/avalanche/trader-joe.chef-v3-farm.contract-position-fetcher.ts @@ -97,7 +97,13 @@ export class AvalancheTraderJoeChefV3FarmContractPositionFetcher extends MasterC contract, contractPosition, }: GetMasterChefTokenBalancesParams) { - return contract.pendingTokens(contractPosition.dataProps.poolIndex, address).then(v => v.pendingJoe); + return contract + .pendingTokens(contractPosition.dataProps.poolIndex, address) + .then(v => v.pendingJoe) + .catch(e => { + if (isMulticallUnderlyingError(e)) return 0; + throw e; + }); } async getExtraRewardTokenBalances({ @@ -105,6 +111,12 @@ export class AvalancheTraderJoeChefV3FarmContractPositionFetcher extends MasterC contract, contractPosition, }: GetMasterChefV2ExtraRewardTokenBalancesParams) { - return contract.pendingTokens(contractPosition.dataProps.poolIndex, address).then(v => v.pendingBonusToken); + return contract + .pendingTokens(contractPosition.dataProps.poolIndex, address) + .then(v => v.pendingBonusToken) + .catch(e => { + if (isMulticallUnderlyingError(e)) return 0; + throw e; + }); } }