How do I autocompound my donuts

Basically the thought process behind my idea is as follows:

  1. Withdraw donuts from DonutDashboard once it reaches a certain amount
  2. Sell 51% of donuts that was withdrawn from the dashboard so that there is always an excess amount of Xdai building up.
  3. “Select All” donuts that are currently in the wallet and add it to a pool along with the corresponding Xdai amount. Seeing as we sold 51% of donuts it means there will be an extra 1% worth of Xdai left after each compound allowing you to always have enough for fees.
  4. Add the LP token that was created in the previous step to the dashboard and repeat everytime the balance reaches a certain amount.

Now the question remains how would i go about automating these steps using a smart contract if it is even possible in the first place?

submitted by /u/Zues6921