In the direction of #813, this runs the basic Weighted Pool tests while fuzzing the weights between the minimum and maximum (also varying the swap fee for unbalanced adds).
It doesn't resolve #813, since that should really be another contract derived from LiquidityApproximationTest... but that test really deeply assumes equal weights/equal value, so it would be a fair bit of work to generalize it. The standard tests are much easier, and are a good first step. Perhaps the Mock introduced here can be reused there.
The fact that weights are immutable after deployment is really annoying for tests. To avoid deploying a new contract on every fuzz iteration, this PR introduces a WeightedPool mock that supports two tokens and has mutable weights. So you deploy it once at the beginning, and just set the weights on each iteration.
Since each test would change the state (balances, etc.), it uses snapshots to reset the state after each test runs. Both the weights and swap fee percentage are fuzzed; the swap fee percentage is only used in the last test.
Type of change
[ ] Bug fix
[ ] New feature
[ ] Breaking change
[ ] Dependency changes
[ ] Code refactor / cleanup
[ ] Optimization: [ ] gas / [ ] bytecode
[ ] Documentation or wording changes
[X] Other
Checklist:
[X] The diff is legible and has no extraneous changes
[X] Complex code has been commented, including external interfaces
[ ] Tests have 100% code coverage
[X] The base branch is either main, or there's a description of how to merge
Description
In the direction of #813, this runs the basic Weighted Pool tests while fuzzing the weights between the minimum and maximum (also varying the swap fee for unbalanced adds).
It doesn't resolve #813, since that should really be another contract derived from LiquidityApproximationTest... but that test really deeply assumes equal weights/equal value, so it would be a fair bit of work to generalize it. The standard tests are much easier, and are a good first step. Perhaps the Mock introduced here can be reused there.
The fact that weights are immutable after deployment is really annoying for tests. To avoid deploying a new contract on every fuzz iteration, this PR introduces a WeightedPool mock that supports two tokens and has mutable weights. So you deploy it once at the beginning, and just set the weights on each iteration.
Since each test would change the state (balances, etc.), it uses snapshots to reset the state after each test runs. Both the weights and swap fee percentage are fuzzed; the swap fee percentage is only used in the last test.
Type of change
Checklist:
main
, or there's a description of how to mergeIssue Resolution