Popcorn-Limited / contracts

The Unlicense
28 stars 15 forks source link

V2 Vault Infra Contracts Redesign #122

Open mayorcoded opened 1 year ago

mayorcoded commented 1 year ago

Having redesigned our strategies and vaults, we are opening this issue to explore the possibilities of resigning the infrastructure contracts that deploy our vaults. These are the contracts that are currently being considered for a redesign:

AdminProxy.sol FeeRecipientProxy.sol CloneRegistry.sol TemplateRegistry.sol PermissionRegistry.sol CloneFactory.sol DeploymentController.sol VaultRegistry.sol VaultController.sol

The design considerations we are considering for these contracts are highlight below:

  1. Deploying v2 vaults and strategies with the current infrastructure contracts
  2. Calling management functions in v2 vaults and strategies with the current infrastructure contracts

To track the conversations around this issue, recommendations will be added as comments.

mayorcoded commented 1 year ago

Here are some of the design changes that we might consider making:

VaultController:

Questions

RedVeil commented 1 year ago

Thanks for the overview. Makes sense that we need to adjust the deploy logic.

In regards to your question. These staking contracts were originally build to allow for claiming rewards of the underlying adapter while simultaneously allowing anyone to incenitivise vaults. So they would always be deployed with each Vault. Didn't turn out like that in the end.

Btw. Can we call setRewardToken and similar admin functions on the strategies? Since all contracts are owned by the adminProxy I think we would need to add this to the controller.

mayorcoded commented 1 year ago

@RedVeil does that mean the staking logic would be removed since it didn't end up being used as imagined? We should be able to call admin functions on strategies.

0xruhum commented 1 year ago

Staking stuff should be removed. It clashes with the vePOP stuff.

RedVeil commented 1 year ago

yup what @0xruhum said

mayorcoded commented 1 year ago

@0xruhum can you provide some more clarification on how the vePOP integrates with our v2 vaults now? My reason for asking is that there is a VaultRouter.sol in v1 that practically takes some underlying asset and deposits it into a a vault and then stakes the shares received from the deposit. Will this logic (VaultRouter) persist for the v2 vaults or are we removing it altogether?

0xruhum commented 1 year ago

In the vePOP system, each vault has a gauge. You deposit your vault shares into that gauge to earn oPOP rewards. So the VaultRouter will do the same thing as before but instead of staking into the staking contract it'll deposit the vault shares into the gauge.

mayorcoded commented 1 year ago

Alright, that clears it up for me, thanks!

0xruhum commented 1 year ago

VaultController

VaultRegistry

CloneRegistry

CloneFactory

PermissionRegistry

TemplateRegistry

Redesign

Contracts:

0xruhum commented 1 year ago

How do we handle new versions?

For each major version there's a separate namespace in the template registry contract, e.g. v1, v2, v3, etc.

Any vault registered for major version X is compatible with any strategy registered for the same version. Meaning, a v2 Vault can only use v2 strategies. In case a new major version is released, each strategy has to be evaluated on whether it's still compatible. If that's the case, it's added to the registry again for the new version.

For any minor or patch versions, we assume that they introduce non-breaking changes and thus are still compatible with any other strategy or vault in their respective major version. Thus, a vault with version v2.1 is compatible with a strategy with version v2.0.

This way we have a clear separation of which vault can interact with which strategy without mixing up different versions. Even if a v3 vault is compatible with a v2 strategy the factory shouldn't allow them to be deployed unless the same strategy is registered in the v3 namespace.


Given that requirement we have two options:

  1. we have a single infra stack that handles deployments for each major version
  2. each new version gets its own infra stack (registry & factory). Balancer does this for example. Each new major version has its own pool factory contract.
mayorcoded commented 1 year ago

vault infra

@0xruhum @RedVeil please let me know if this diagram represents what we expect from the redesign

0xruhum commented 12 months ago

Sorry, forgot to reply here.

0xruhum commented 12 months ago

TODOs for Vault Controller: