dao-contracts icon indicating copy to clipboard operation
dao-contracts copied to clipboard

Add cw20-vest and compatibility updates to cw20-staked-balance-voting

Open teddyknox opened this issue 1 year ago • 2 comments

Hi all, this is my first foray into contributing to dao-dao, thanks in advance for considering.

This is a generic vesting contract for locking up DAO tokens and releasing them to vestees over time according to per-vestee schedules. The vesting contract stakes tokens internally to accumulate funding rewards accrued before vested tokens are claimed. This contract integrates modularly with cw20-base and cw20-stake; there is no overlap in functionality with either. cwd-voting-cw20-staked required some changes in order to grant vestees full control over the voting power of their unvested shares.

In a vacuum, usage of this contract goes like this:

  1. The contract is instantiated with a token contract, a staking contract, and a list of (address, vesting_schedule).
  2. The contract is now in an unfunded state. Once the contract is funded with the full amount to be vested over the lifetime of all vesting schedules, the contract "activates".
  3. Once the contract is activated, users can call "vest" on the contract begin the unstaking process for their vested shares. The unstaking_duration still applies here, but with some changes to cw20_stake that could be avoided.
  4. Finally, once a user's tokens in c20-vest are unstaked, they can be claimed with a call to "claim".
  5. From here the user will likely opt to restake the tokens or sell them.

I also made changes to cwd-voting-cw20-staked to support instantiating/configuring cw20-vest at deploy time.

A vesting schedule is a list of monotonically increasing points (timestamp, amount) which may be piecewise linearly interpolated to describe the total amount vested at any given time. Vesting cliffs can be implemented by making the first point's amount greater than 0 and in the future.

Testing

  • cw20_stake has decent test coverage right now but I will be adding much more.
  • cwd-voting-cw20-staked has no tests of this functionality yet (hence the draft status)
  • existing tests are passing :)

Open Questions

  • cw20-vest currently assumes usage with a cw20-stake contract. Is this a good assumption or should staking be optional?
  • I'm curious whether my query API design passes snuff with respect to conventions.

teddyknox avatar Oct 14 '22 20:10 teddyknox

Bump. What I will do is write tests and then do a production instantiation to demo this software.

teddyknox avatar Oct 17 '22 14:10 teddyknox

Thanks so much for your review. I've been swamped but should get another draft out this week.

teddyknox avatar Oct 25 '22 00:10 teddyknox

@teddyknox how hard do you think it would be to make this such that you could upgrade an existing cw20 to this contract? that would be a really killer feature because existing DAOs with illiquid tokens could upgrade to this configuration.

0xekez avatar Nov 01 '22 23:11 0xekez

@0xekez it should be possible in the current design. All you need to do is deploy cw20-vest and upgrade the voting power contract. Am I understanding you correctly?

teddyknox avatar Nov 01 '22 23:11 teddyknox

@teddyknox i'm wondering more if we could make this so that a DAO with an existing cw20 token and staking contract could upgrade to this and in doing so vest all outstanding tokens? if this is really hard, ignore me. :)

0xekez avatar Nov 02 '22 00:11 0xekez

and in doing so vest all outstanding tokens?

What is our definition of outstanding tokens in this case?

@0xekez

teddyknox avatar Nov 02 '22 00:11 teddyknox