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

Fee controller migration contracts #1299

Open
wants to merge 50 commits into
base: protocol-fee-controller-v3
Choose a base branch
from

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! We might not have thought this all the way through during the original design.

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 too.

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.

One thing that needs to be cleaned up before merging is the current constructor / fee controller setter mechanism, which is only there because the fee controller is not yet deployed, so we have to deploy it in the fork test. After the v3 protocol fee controller is deployed, it will be accessible through the normal READ_ONLY task, and able to be passed in at deployment time.

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

@jubeira jubeira requested review from joaobrunoah and jubeira and removed request for joaobrunoah February 18, 2025 18:45
@EndymionJkb EndymionJkb changed the base branch from main to protocol-fee-controller-v2 February 19, 2025 02:10
# Conflicts:
#	pkg/interfaces/contracts/vault/IProtocolFeeController.sol
#	pkg/vault/contracts/ProtocolFeeController.sol
# Conflicts:
#	pkg/pool-stable/test/foundry/E2eBatchSwap.t.sol
#	pkg/pool-stable/test/foundry/E2eErc4626Swaps.t.sol
#	pkg/pool-stable/test/foundry/E2eSwapRateProvider.t.sol
#	pkg/pool-weighted/test/foundry/E2ESwapRateProvider.t.sol
# Conflicts:
#	pkg/pool-weighted/test/foundry/E2eSwap.t.sol
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
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.

2 participants