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

Automatically renormalize on gradual weight changes #1768

Merged
merged 1 commit into from
Sep 15, 2022

Conversation

TomAFrench
Copy link
Contributor

This avoids the issue we identified a while back where a Pool owner can manipulate _denormWeightSum by manipulating the weights in combination with adding or removing tokens

@TomAFrench TomAFrench requested a review from nventuro September 14, 2022 16:41
@@ -1057,7 +1062,7 @@ contract ManagedPool is BaseWeightedPool, ProtocolFeeCache, ReentrancyGuard, ICo
_tokenState[token],
startWeights[i],
endWeight,
denormWeightSum
FixedPoint.ONE
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, interesting. This does seem correct. It'd be good to review the existing tests to get a sense of what the current coverage of all of this looks like.

@TomAFrench
Copy link
Contributor Author

One thing I like about this is that we don't need to pass in a denormWeightSum if we push this out to an abstract contract/library. We just need to make sure to add a _denormWeightSum = FixedPoint.ONE after calls to this function.

@TomAFrench TomAFrench force-pushed the renormalize-weights-on-weight-change branch from 105bfda to ccf99f7 Compare September 15, 2022 19:02
@TomAFrench TomAFrench force-pushed the renormalize-weights-on-weight-change branch from ccf99f7 to ccad8fe Compare September 15, 2022 19:03
@TomAFrench TomAFrench merged commit 611206b into master Sep 15, 2022
@TomAFrench TomAFrench deleted the renormalize-weights-on-weight-change branch September 15, 2022 19:04
TomAFrench added a commit that referenced this pull request Sep 15, 2022
* master:
  feat: automatically renormalize weight sum on gradual weight change (#1768)
  Inline `getSwapEnabled()` inside swap hooks (#1778)
TomAFrench added a commit that referenced this pull request Sep 16, 2022
* master:
  Add some random fuzz tests (#1782)
  docs: typos and readability (#1784)
  refactor: rename WeightCompression to ValueCompression (#1783)
  Update `_startGradualWeightChange` to return updated pool state (#1779)
  feat: automatically renormalize weight sum on gradual weight change (#1768)
  Inline `getSwapEnabled()` inside swap hooks (#1778)
  refactor: remove unused constants (#1781)
  style: rearrange functions (#1777)
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