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

refactor: simplify swap fee update workflow #15

Merged
merged 3 commits into from
Apr 12, 2024
Merged

Conversation

chefburger
Copy link
Collaborator

@chefburger chefburger commented Apr 9, 2024

Changes:

  1. rename src/libraries/FeeLibrary.sol to src/libraries/SwapFeeLibrary.sol so that it makes more sense and avoid mixup with protocolFee (Fee.sol)
  2. This PR switched up how we update swap fees from pulling to pushing, hence instead of
1. someone call `updateDynamicSwapFee()` on poolManager to trigger update
2. poolManager fetch the fee through `hook.getFee(msg.sender, key);`

we do

hook call `updateDynamicSwapFee(poolKey, newDynamicFee)` directly

Potential update for third party hooks:

For dynamic fee pool, the initial swap fee is 0 and must be set in afterInitialize hook if a nonzero value is expected

ChefSnoopy
ChefSnoopy previously approved these changes Apr 11, 2024
@@ -5,11 +5,13 @@ pragma solidity ^0.8.24;
/// @dev Library for parsing swap fee info from PoolKey.fee:
/// 24 bits (upper 4 bits are used to store flag, if swap fee is static, parse lower 20 bits to get swap fee)
/// 1. flag to indicate the activation of dynamic swap fee, otherwise static swap fee is used
/// - if dynamic swap fee is activated, then the swap fee is controlled by IDynamicFeeManager(hook).getFee()
/// - if dynamic swap fee is activated, then the swap fee is controlled by hook
Copy link
Collaborator

Choose a reason for hiding this comment

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

(optional) then the swap fee is controlled by hook -> then the swap fee can be updated by hook

ChefMist
ChefMist previously approved these changes Apr 11, 2024
Copy link
Collaborator

@ChefMist ChefMist left a comment

Choose a reason for hiding this comment

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

will keep a note to update developer docs and hooks-template probably to reflect new dynamic fee model (push)

@chefburger chefburger dismissed stale reviews from ChefMist and ChefSnoopy via d3d3a5e April 12, 2024 03:10
@chefburger chefburger merged commit b41cd40 into main Apr 12, 2024
2 checks passed
@chefburger chefburger deleted the refactor/swap-fee branch April 12, 2024 03:16
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.

3 participants