OriginProtocol / origin-dollar

OUSD and OETH are stablecoins that passively accrue yield while you are holding it
https://originprotocol.com
MIT License
119 stars 80 forks source link

Automated buyback #1560

Open micahalcorn opened 1 year ago

micahalcorn commented 1 year ago

Half of OUSD's performance fee (10% of yield) is used to buy back OGV from the open market and distribute it to OGV stakers. In the future, it's likely that some or all of OETH's performance fee will be handled in a similar fashion. Currently, these buyback transactions are constructed, verified, and executed manually by the Strategists. The intention is to conduct a buyback approximately every two weeks, but this doesn't always happen due to scheduling conflicts or other competing priorities. The transactions are fairly straightforward and just need to mitigate the risk of sandwich attacks by setting appropriate slippage parameters.

For several months, we've discussed the possbility of automating these buybacks with a cron scheduler. I don't think there's any desire right now to decentralize this function and we may want to start by keeping the manual verification requirement rather than having fully automated execution (not sure).

The other consideration is that we don't want these purchases to occur at the exact same time/day every week so that they aren't frontrun. An approximate recurring schedule is good, but perfect predictability would be bad.

Let's reduce the amount of manual work involved and simplify the process for automatically buying back OGV.

micahalcorn commented 1 year ago

Here's a sample recent transaction: https://etherscan.io/tx/0x09a128b0442f2a6b46a5096f4a2c8b2ed7092c8f6bb9df3b00598bf8bd2bb4b7

sparrowDom commented 1 year ago

Agree with everything written, the happy path could behave like this:

Need to do some research, of how trustworthy the Relayer/Autotask module is. If it is enough, we don't even need the standalone slippage protection within the Buyback contract. @naddison36 you have some experience with those tools, curious what are your thoughts?

joshfraser commented 1 year ago

Why not make this function an incentivized call just like our harvester code?

naddison36 commented 1 year ago

This is a similar problem to the Harvester. We have a number of options including

  1. Atomically execute the buyback using a DEX like Uniswap or a DEX aggregator like 1Inch Pathfinder. We can incentivise this by giving a percentage to the caller. We can reuse what we have done for vault collateral swaps.
  2. Implement our own trustless swap protocol as proposed for the Harvester https://github.com/OriginProtocol/origin-dollar/issues/1523#issuecomment-1556047747
  3. Publish our swap (limit order) to an off-chain marketplace for competing arbitragers to execute at the best market price. The executers also pay for the gas. See my Harvester comments for more details https://github.com/OriginProtocol/origin-dollar/issues/1523#issuecomment-1569230976

As for automation, I like OZ's Defender Relay and Autotask products. It works well for use cases like automated buybacks where there is some trusted off-chain processing that interacts with an Ethereum chain.