stake icon indicating copy to clipboard operation
stake copied to clipboard

lockup, registry: Remove special cased locked balances

Open armaniferrante opened this issue 3 years ago • 0 comments

Registry:

Instead of having two versions of balances, locked and unlocked, for a given member account, one can consolidate these two with the following scheme:

When depositing into the stake program, the program can create a redeemable "deposit token" that represents a claim on the assets in the stake account (separate from the pool token, which is just used as an accounting measurement for rewards). For locked tokens, the locked token program would send funds to the stake program, and the stake program would mint these "deposit tokens" to the lockup program. To withdraw, one would provide these "deposit tokens" to the stake program, which would burn them and return the corresponding number of assets.

Lockup

Any app can then facilitate the use of locked tokens by implementing an additional deposit_locked method that takes in a Vesting account and mints these "deposit tokens" to an account with an owner being program derived address with the vesting account as one of the seeds. Withdrawals would not need to be special cased. Any transaction signed by an owner of a "deposit token" would be able to withdrawal.

Pros

  • Cuts the number of required accounts for a Member account in half
  • Easier to reason about the locked property being maintained. A program has to just prove two things: 1) all tokens coming into and out of the program are through the deposit_* and withdraw instructions and 2) deposit_locked only mints "deposit tokens" to token accounts owned by vesting accounts.

armaniferrante avatar Apr 01 '21 18:04 armaniferrante