def harvest_all(badger: BadgerSystem, skip): for key, vault in badger.sett_system.vaults.items(): if key in skip: continue console.print("\n[bold yellow]===== Harvest: " + str(key) + " =====[/bold yellow]\n") print("Harvest: " + key) snap = SnapshotManager(badger, key) strategy = badger.getStrategy(key) keeper = accounts.at(badger.keeper) before = snap.snap() if strategy.keeper() == badger.badgerRewardsManager: snap.settHarvestViaManager( strategy, { "from": keeper, "gas_limit": 2000000, "allow_revert": True }, confirm=False, ) else: snap.settHarvest( { "from": keeper, "gas_limit": 2000000, "allow_revert": True }, confirm=False, ) tx_wait() if rpc.is_active(): chain.mine() after = snap.snap() snap.printCompare(before, after)
def harvest_all(badger: BadgerSystem, skip, min_profit=0): """ Runs harvest function for strategies if they are expected to be profitable. If a profit estimate fails for any reason the default behavior is to treat it as having a profit of zero. :param badger: badger system :param skip: strategies to skip checking :param min_profit: minimum estimated profit (in ETH or BNB) required for harvest to be executed on chain """ for key, vault in badger.sett_system.vaults.items(): if key in skip: continue console.print("\n[bold yellow]===== Harvest: " + str(key) + " =====[/bold yellow]\n") print("Harvest: " + key) snap = SnapshotManager(badger, key) strategy = badger.getStrategy(key) before = snap.snap() if strategy.keeper() == badger.badgerRewardsManager: keeper = accounts.at(strategy.keeper()) estimated_profit = snap.estimateProfitHarvestViaManager( key, strategy, { "from": keeper, "gas_limit": 2000000, "allow_revert": True }, min_profit, ) if estimated_profit >= min_profit: snap.settHarvestViaManager( strategy, { "from": keeper, "gas_limit": 2000000, "allow_revert": True }, confirm=False, ) else: estimated_profit = snap.estimateProfitHarvest( key, { "from": keeper, "gas_limit": 2000000, "allow_revert": True }, min_profit, ) if estimated_profit >= min_profit: snap.settHarvest( { "from": keeper, "gas_limit": 2000000, "allow_revert": True }, confirm=False, ) tx_wait() if rpc.is_active(): chain.mine() after = snap.snap() snap.printCompare(before, after)