diff --git a/src/lib/harvest-chain.ts b/src/lib/harvest-chain.ts index f29459e..25d4d33 100644 --- a/src/lib/harvest-chain.ts +++ b/src/lib/harvest-chain.ts @@ -27,7 +27,6 @@ import { reportOnMultipleHarvestAsyncCall, reportOnSingleHarvestAsyncCall, } from './harvest-report'; -import { type MerklTokenData, fetchMerklTokenData, hasPendingMerklRewards } from './merkl'; import type { BeefyVault } from './vault'; const logger = rootLogger.child({ module: 'harvest-chain' }); @@ -101,7 +100,6 @@ export async function harvestChain({ paused: false, blockNumber: 0n, harvestResultData: '0x', - merklTokenData: null, gas: createGasEstimationReport({ rawGasPrice, rawGasAmountEstimation: 0n, @@ -124,25 +122,6 @@ export async function harvestChain({ const timeSinceLastHarvestMs = now.getTime() - lastHarvestDate.getTime(); const isLastHarvestRecent = timeSinceLastHarvestMs < rpcConfig.harvest.targetTimeBetweenHarvestsMs; - // fetch merkl token data if there is no estimated rewards - // this is just for the case where it's a vault that only has merkl rewards - const merklTokenData: MerklTokenData | null = null; - - // TODO: re-enable this. - // this is supposed to be a fallback for when the lens returns 0 rewards - // but it's not working as expected and vaults get harvested every time the script runs - // instead of every 24 hours. - // if (callReward === 0n) { - // try { - // merklTokenData = await fetchMerklTokenData(item.vault); - // } catch (error) { - // logger.error({ - // msg: 'Error fetching merkl token data', - // data: { error, vault: item.vault }, - // }); - // } - // } - return { estimatedCallRewardsWei: callReward, harvestWillSucceed: success, @@ -152,7 +131,6 @@ export async function harvestChain({ paused, blockNumber, harvestResultData: harvestResult, - merklTokenData: merklTokenData, gas: createGasEstimationReport({ rawGasPrice, rawGasAmountEstimation: gasUsed, @@ -299,16 +277,6 @@ export async function harvestChain({ } if (item.simulation.estimatedCallRewardsWei === 0n) { - // sometimes the lens returns 0 rewards but there are still pending merkl rewards - if (item.simulation.merklTokenData && hasPendingMerklRewards(item.simulation.merklTokenData)) { - return { - shouldHarvest: true, - level: 'info', - merklTokenData: item.simulation.merklTokenData, - notHarvestingReason: 'estimated call rewards is 0, but there are pending merkl rewards', - }; - } - if (item.simulation.isLastHarvestRecent) { return { shouldHarvest: false, diff --git a/src/lib/harvest-report.ts b/src/lib/harvest-report.ts index be1c3e5..db900bf 100644 --- a/src/lib/harvest-report.ts +++ b/src/lib/harvest-report.ts @@ -3,7 +3,6 @@ import type { Async, TimingData } from '../util/async'; import type { Chain } from './chain'; import type { CollectorBalance } from './collector-balance'; import type { GasEstimationReport } from './gas'; -import type { MerklTokenData } from './merkl'; import type { ReportAsyncStatus } from './report-error-status'; import { type AItem, type AKey, type AVal, reportOnMultipleAsyncCall, reportOnSingleAsyncCall } from './reports'; import type { BeefyVault } from './vault'; @@ -38,7 +37,6 @@ type HarvestReportSimulation = Async<{ paused: boolean; blockNumber: bigint; harvestResultData: Hex; - merklTokenData: MerklTokenData | null; }>; export type HarvestReportDecision = Async< @@ -105,12 +103,6 @@ export type HarvestReportDecision = Async< level: 'info'; notHarvestingReason: 'strategy paused'; } - | { - shouldHarvest: true; - level: 'info'; - merklTokenData: MerklTokenData; - notHarvestingReason: 'estimated call rewards is 0, but there are pending merkl rewards'; - } | { shouldHarvest: false; level: 'info'; diff --git a/src/lib/merkl.ts b/src/lib/merkl.ts deleted file mode 100644 index 8b3ceeb..0000000 --- a/src/lib/merkl.ts +++ /dev/null @@ -1,69 +0,0 @@ -import type { BeefyVault } from './vault'; - -type RawMerklTokenData = { - [tokenAddress: string]: { - accumulated: string; - unclaimed: string; - pending: string; - decimals: number; - symbol: string; - proof: string[]; - }; -}; - -type RawMerklRewardsResponse = { - [chainId: string]: { - tokenData: RawMerklTokenData; - }; -}; - -export type MerklTokenData = { - [chainId: string]: { - [tokenAddress: string]: { - accumulated: bigint; - unclaimed: bigint; - pending: bigint; - decimals: number; - symbol: string; - }; - }; -}; - -export function hasPendingMerklRewards(merklTokenData: MerklTokenData): boolean { - for (const chainId of Object.keys(merklTokenData)) { - for (const tokenData of Object.values(merklTokenData[chainId])) { - if (tokenData.unclaimed > 0n) { - return true; - } - } - } - return false; -} - -export async function fetchMerklTokenData(vault: BeefyVault): Promise { - // only cowcentrated vaults have merkl - if (!vault.isClmVault) { - return null; - } - - const url = `https://api.merkl.xyz/v3/rewards?user=${vault.strategyAddress}`; - - const response = await fetch(url); - const data: RawMerklRewardsResponse = await response.json(); - - const merklTokenData: MerklTokenData = {}; - for (const [chainId, chainData] of Object.entries(data)) { - merklTokenData[chainId] = {}; - for (const [tokenAddress, tokenData] of Object.entries(chainData.tokenData)) { - merklTokenData[chainId][tokenAddress] = { - accumulated: BigInt(tokenData.accumulated), - unclaimed: BigInt(tokenData.unclaimed), - pending: BigInt(tokenData.pending), - decimals: tokenData.decimals, - symbol: tokenData.symbol, - }; - } - } - - return merklTokenData; -}