Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bot Improvements #88

Open
dapp-whisperer opened this issue Apr 26, 2021 · 0 comments
Open

Bot Improvements #88

dapp-whisperer opened this issue Apr 26, 2021 · 0 comments
Assignees

Comments

@dapp-whisperer
Copy link
Contributor

The Sett system requires a series of bots to perform key actions.

Earn

earn() is called on the Sett and brings deposits into the strategy position. By batching the deposits, we save gas costs for the users and ourselves.

This should be called whenever sufficient deposits have accumulated in the Sett, as defined on a per-sett basis.

Earn script

Harvest

When strategies are harvested, it realizes the profit from the strategy position activities. The most common way is claiming & selling rewards tokens.

The harvest bot needs to be more intelligent about gas usage. By doing a read call (staticcall) of the harvest function on chain, it can view what the expected profit of the harvest would be. This should exceed the expected gas price by a certain extent in order to harvest. The harvesters current harvest on a pre-defined interval, which ranges from 24 hours on Ethereum to 30 minutes for certain BSC Setts.

Harvest script

Tend

The tend() bot runs maintenance on strategy positions between harvests. It's designed to include functionality that increases the yield on harvest. (For example, rewards tokens might be staked between harvests, with any gains re-injected into the staking position)

This bot needs to have the same gas analysis as harvest(). The amount tended should justify the gas cost. It currently runs on a 12-hour schedule on ethereum.

Tend script

External Harvester

Many strategies are incentivized by Badger and/or Digg rewards. These rewards are handled by the External Harvester. This system:

  • Converts badger and digg into the underlying vault tokens.
  • Deposits the gains into the appropriate strategy.
  • This increases the value of each shares just like gains from the strategy activities.

This should be run once a day, and be 100% reliable in doing so. If needed, we can have the contract emit more data around when the latest external harvest was for a strategy.

External harvester

Rebase

The rebase() function needs to be called within a certain window every day in order to trigger that days' DIGG rebase. The rebase reads the most recent valid reports from oracle data and enacts a supply change based on that. It is a permissionless function with no parameters, and just needs to be called as soon after the rebase window opens at 3pm EST as possible.

Rebase script

Bot Automation

The current bots run on a simple loop, in the scripts/keeper/auto folder there are variants of each bot logic that are run on a pre-defined interval. If an iteration fails, the script catches the error and tries again after the interval has passed.

You can see the keeper config for all intervals.

A note on ETH Transactions

To avoid transactions getting stuck, we use the ExponentialScalingStrategy created by brownie. This re-sends a transaction with a higher gas price if the previous one is not confirmed within a configurable amount of time. The gas price scales at a gentle exponential slope. This could use some thought as to the specific parameters to use.

Desired Improvements

Crash Handling

When a bot crashes, it does not restart automatically. The machine running the bot should restart it.

Hanging Node Connection Handling

The bot may lose connection to the node at some point. It should have a timeout, backup node, and report if it cannot reach either.

Transaction Never Posts Handling

If a transaction get stuck for too long, even with the exponential scaling strategy, it should report.

Smarter Gas Estimation

As mentioned in the tend() and harvest() sections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants