Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protocol Fee Controller migration contract #1299

Merged
merged 57 commits into from
Mar 8, 2025
Merged

Conversation

EndymionJkb
Copy link
Collaborator

@EndymionJkb EndymionJkb commented Feb 18, 2025

Description

Based on #1307, this is the monorepo part of the ProtocolFeeController migration. It introduces a /governance-scripts package, and adds contracts used for the migration.

Turns out this is actually quite tricky! Essentially, there is no way to copy the "hidden" state that is set only on registration through the Vault or by pool creators. See #1307 for the ProtocolFeeController changes necessary to accomplish this (i.e., a migratePool function).

We'd thought the problem was only pool creators, but it's actually worse. We cannot call the updateProtocolSwap/YieldFeePercentage functions to "copy" pool state, because those call into the Vault to update the aggregate percentage - and this function can only be called by the current fee controller: not one we're migrating to.

So the final solution is to migrate to a new Protocol Fee Controller that has the ability to copy hidden state, with one twist. We needed to add new getters in order to copy the pool creator percentages, so these do not exist in the current (original) ProtocolFeeController. The first migration (very soon) has no pools with pool creators, so it's fine, but we need to tolerate failure so that the first migration works. (If any pool creators are missed, the pool creators can simply set the percentages again in the new fee controller, so it's not catastrophic. The fact that there is a pool creator cannot be lost, as that's stored in the Vault.)

So in the first migration, all the pool creator getter calls will fail (try... catch, so it doesn't revert), which is fine because they're all zero anyway. However, in future migrations they will work and correctly copy the pool creator fees.

This adds a new package, so if you see "hardhat not found" or something like that, run "yarn" at the top level to update the dependencies.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Dependency changes
  • Code refactor / cleanup
  • Optimization: [ ] gas / [ ] bytecode
  • Documentation or wording changes
  • Other

Checklist:

  • The diff is legible and has no extraneous changes
  • Complex code has been commented, including external interfaces
  • Tests have 100% code coverage
  • The base branch is either main, or there's a description of how to merge

Issue Resolution

Resolves #1290

@jubeira jubeira requested review from joaobrunoah and jubeira and removed request for joaobrunoah February 18, 2025 18:45
Base automatically changed from protocol-fee-controller-v2 to main February 20, 2025 22:46
# Conflicts:
#	pkg/interfaces/contracts/vault/IProtocolFeeController.sol
#	pkg/vault/contracts/ProtocolFeeController.sol
#	pkg/vault/test/foundry/ProtocolFeeController.t.sol
@EndymionJkb EndymionJkb requested a review from jubeira February 20, 2025 23:49
@EndymionJkb EndymionJkb marked this pull request as draft February 21, 2025 22:38
@EndymionJkb EndymionJkb changed the base branch from main to protocol-fee-controller-v3 February 22, 2025 01:40
@EndymionJkb EndymionJkb marked this pull request as ready for review February 22, 2025 02:33
Base automatically changed from protocol-fee-controller-v3 to main February 28, 2025 19:02
@EndymionJkb EndymionJkb changed the title Fee controller migration contracts Fee controller migration contract Feb 28, 2025
@EndymionJkb EndymionJkb changed the title Fee controller migration contract Protocol Fee Controller migration contract Mar 4, 2025
Copy link
Contributor

@jubeira jubeira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable. I don't really have any comments; looking good!

I was thinking that if there are fees collected but not withdrawn in the old controller, probably the best way to get them is to just grant the permission to a multisig to pull them out. WDYT? We should probably include that detail in the notion docs as part of the 'user manual' for this migration.

@EndymionJkb
Copy link
Collaborator Author

I was thinking that if there are fees collected but not withdrawn in the old controller, probably the best way to get them is to just grant the permission to a multisig to pull them out. WDYT? We should probably include that detail in the notion docs as part of the 'user manual' for this migration.

I added a section on for post-migration considerations. The account that withdraws would already have permission on the old controller; could just leave it alone. The account could withdraw from both controllers if necessary. Nothing more can be collected post-migration, so the old controller would just be inert (to governance) after that. Pool creators could still withdraw forever, as they don't need permission.

Copy link
Contributor

@joaobrunoah joaobrunoah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@EndymionJkb EndymionJkb merged commit 40b4cd3 into main Mar 8, 2025
16 checks passed
@EndymionJkb EndymionJkb deleted the fee-controller-script branch March 8, 2025 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Governance script for Protocol Fee Controller V2
3 participants