From 21dc0f223b35cfbe9d65f2a1d639321295149561 Mon Sep 17 00:00:00 2001 From: EndymionJkb Date: Thu, 27 Oct 2022 11:19:26 -0400 Subject: [PATCH] Great Pool Migration (prep) (#1954) * refactor: rename BasePool to LegacyBasePool * refactor: move new BasePool out of managed pool * refactor: rename again to reduce diff --- pkg/pool-linear/contracts/LinearPool.sol | 8 ++++---- pkg/pool-utils/contracts/BaseGeneralPool.sol | 6 +++--- pkg/pool-utils/contracts/BaseMinimalSwapInfoPool.sol | 6 +++--- .../contracts/NewBasePool.sol} | 8 ++++---- pkg/pool-utils/contracts/lib/ComposablePoolLib.sol | 2 ++ .../contracts/test/MockNewBasePool.sol} | 9 ++++----- .../test/NewBasePool.test.ts} | 4 ++-- pkg/pool-weighted/contracts/managed/ManagedPool.sol | 2 +- .../contracts/managed/ManagedPoolSettings.sol | 5 ++--- .../contracts/test/MockManagedPoolSettings.sol | 2 +- 10 files changed, 26 insertions(+), 26 deletions(-) rename pkg/{pool-weighted/contracts/managed/vendor/BasePool.sol => pool-utils/contracts/NewBasePool.sol} (98%) rename pkg/{pool-weighted/contracts/test/MockBasePool.sol => pool-utils/contracts/test/MockNewBasePool.sol} (96%) rename pkg/{pool-weighted/test/managed/BasePool.test.ts => pool-utils/test/NewBasePool.test.ts} (99%) diff --git a/pkg/pool-linear/contracts/LinearPool.sol b/pkg/pool-linear/contracts/LinearPool.sol index 4c796012c4..b6a05ca669 100644 --- a/pkg/pool-linear/contracts/LinearPool.sol +++ b/pkg/pool-linear/contracts/LinearPool.sol @@ -38,8 +38,8 @@ import "./LinearMath.sol"; * The Pool will register three tokens in the Vault however: the two assets and the BPT itself, * so that BPT can be exchanged (effectively joining and exiting) via swaps. * - * Despite inheriting from BasePool, much of the basic behavior changes. This Pool does not support regular joins and - * exits, as the initial BPT supply is 'preminted' during initialization. No further BPT can be minted, and BPT can + * Despite inheriting from BasePool, much of the basic behavior changes. This Pool does not support regular joins + * and exits, as the initial BPT supply is 'preminted' during initialization. No further BPT can be minted, and BPT can * only be burned if governance enables Recovery Mode and LPs use it to exit proportionally. * * Unlike most other Pools, this one does not attempt to create revenue by charging fees: value is derived by holding @@ -86,8 +86,8 @@ abstract contract LinearPool is ILinearPool, IGeneralPool, IRateProvider, BasePo uint256 private immutable _scalingFactorMainToken; uint256 private immutable _scalingFactorWrappedToken; - // The lower and upper targets are in BasePool's misc data field, which has 192 bits available (as it shares the - // same storage slot as the swap fee percentage and recovery mode flag, which together take up 64 bits). + // The lower and upper targets are in BasePool's misc data field, which has 192 bits available (as it shares + // the same storage slot as the swap fee percentage and recovery mode flag, which together take up 64 bits). // We use 64 of these 192 for the targets (32 for each). // // The targets are already scaled by the main token's scaling factor (which makes the token behave as if it had 18 diff --git a/pkg/pool-utils/contracts/BaseGeneralPool.sol b/pkg/pool-utils/contracts/BaseGeneralPool.sol index 4f6f25789f..bfbd43a3c1 100644 --- a/pkg/pool-utils/contracts/BaseGeneralPool.sol +++ b/pkg/pool-utils/contracts/BaseGeneralPool.sol @@ -22,9 +22,9 @@ import "./BasePool.sol"; /** * @dev Extension of `BasePool`, adding a handler for `IGeneralPool.onSwap`. * - * Derived contracts must call `BasePool`'s constructor, and implement `_onSwapGivenIn` and `_onSwapGivenOut` along with - * `BasePool`'s virtual functions. Inheriting from this contract lets derived contracts choose the General - * specialization setting. + * Derived contracts must call `BasePool`'s constructor, and implement `_onSwapGivenIn` and `_onSwapGivenOut` + * along with `BasePool`'s virtual functions. Inheriting from this contract lets derived contracts choose the + * General specialization setting. */ abstract contract BaseGeneralPool is IGeneralPool, BasePool { // Swap Hooks diff --git a/pkg/pool-utils/contracts/BaseMinimalSwapInfoPool.sol b/pkg/pool-utils/contracts/BaseMinimalSwapInfoPool.sol index 702b14a151..7828e5eae0 100644 --- a/pkg/pool-utils/contracts/BaseMinimalSwapInfoPool.sol +++ b/pkg/pool-utils/contracts/BaseMinimalSwapInfoPool.sol @@ -22,9 +22,9 @@ import "./BasePool.sol"; /** * @dev Extension of `BasePool`, adding a handler for `IMinimalSwapInfoPool.onSwap`. * - * Derived contracts must call `BasePool`'s constructor, and implement `_onSwapGivenIn` and `_onSwapGivenOut` along with - * `BasePool`'s virtual functions. Inheriting from this contract lets derived contracts choose the Two Token or Minimal - * Swap Info specialization settings. + * Derived contracts must call `BasePool`'s constructor, and implement `_onSwapGivenIn` and `_onSwapGivenOut` + * along with `BasePool`'s virtual functions. Inheriting from this contract lets derived contracts choose the + * Two Token or Minimal Swap Info specialization settings. */ abstract contract BaseMinimalSwapInfoPool is IMinimalSwapInfoPool, BasePool { // Swap Hooks diff --git a/pkg/pool-weighted/contracts/managed/vendor/BasePool.sol b/pkg/pool-utils/contracts/NewBasePool.sol similarity index 98% rename from pkg/pool-weighted/contracts/managed/vendor/BasePool.sol rename to pkg/pool-utils/contracts/NewBasePool.sol index ee9c0d71ec..b4bb2eade5 100644 --- a/pkg/pool-weighted/contracts/managed/vendor/BasePool.sol +++ b/pkg/pool-utils/contracts/NewBasePool.sol @@ -22,9 +22,9 @@ import "@balancer-labs/v2-interfaces/contracts/vault/IMinimalSwapInfoPool.sol"; import "@balancer-labs/v2-solidity-utils/contracts/helpers/TemporarilyPausable.sol"; -import "@balancer-labs/v2-pool-utils/contracts/BalancerPoolToken.sol"; -import "@balancer-labs/v2-pool-utils/contracts/BasePoolAuthorization.sol"; -import "@balancer-labs/v2-pool-utils/contracts/RecoveryMode.sol"; +import "./BalancerPoolToken.sol"; +import "./BasePoolAuthorization.sol"; +import "./RecoveryMode.sol"; // solhint-disable max-states-count @@ -47,7 +47,7 @@ import "@balancer-labs/v2-pool-utils/contracts/RecoveryMode.sol"; * BaseGeneralPool or BaseMinimalSwapInfoPool. Otherwise, subclasses must inherit from the corresponding interfaces * and implement the swap callbacks themselves. */ -abstract contract BasePool is +abstract contract NewBasePool is IBasePool, IGeneralPool, IMinimalSwapInfoPool, diff --git a/pkg/pool-utils/contracts/lib/ComposablePoolLib.sol b/pkg/pool-utils/contracts/lib/ComposablePoolLib.sol index 9e4ead9467..caea0fa294 100644 --- a/pkg/pool-utils/contracts/lib/ComposablePoolLib.sol +++ b/pkg/pool-utils/contracts/lib/ComposablePoolLib.sol @@ -18,6 +18,8 @@ import "@balancer-labs/v2-interfaces/contracts/solidity-utils/openzeppelin/IERC2 import "@balancer-labs/v2-solidity-utils/contracts/math/FixedPoint.sol"; +// solhint-disable no-inline-assembly + library ComposablePoolLib { using FixedPoint for uint256; diff --git a/pkg/pool-weighted/contracts/test/MockBasePool.sol b/pkg/pool-utils/contracts/test/MockNewBasePool.sol similarity index 96% rename from pkg/pool-weighted/contracts/test/MockBasePool.sol rename to pkg/pool-utils/contracts/test/MockNewBasePool.sol index 4326cf403c..165aacba3c 100644 --- a/pkg/pool-weighted/contracts/test/MockBasePool.sol +++ b/pkg/pool-utils/contracts/test/MockNewBasePool.sol @@ -17,11 +17,10 @@ pragma experimental ABIEncoderV2; import "@balancer-labs/v2-interfaces/contracts/pool-weighted/WeightedPoolUserData.sol"; -import "@balancer-labs/v2-pool-utils/contracts/lib/PoolRegistrationLib.sol"; +import "../lib/PoolRegistrationLib.sol"; +import "../NewBasePool.sol"; -import "../managed/vendor/BasePool.sol"; - -contract MockBasePool is BasePool { +contract MockNewBasePool is NewBasePool { uint256 public constant ON_SWAP_MINIMAL_RETURN = 0xa987654321; uint256 public constant ON_SWAP_GENERAL_RETURN = 0x123456789a; uint256 public constant ON_JOIN_RETURN = 0xbbaa11; @@ -50,7 +49,7 @@ contract MockBasePool is BasePool { uint256 bufferPeriodDuration, address owner ) - BasePool( + NewBasePool( vault, PoolRegistrationLib.registerPoolWithAssetManagers(vault, specialization, tokens, assetManagers), name, diff --git a/pkg/pool-weighted/test/managed/BasePool.test.ts b/pkg/pool-utils/test/NewBasePool.test.ts similarity index 99% rename from pkg/pool-weighted/test/managed/BasePool.test.ts rename to pkg/pool-utils/test/NewBasePool.test.ts index e94546ba95..3cf217ebbd 100644 --- a/pkg/pool-weighted/test/managed/BasePool.test.ts +++ b/pkg/pool-utils/test/NewBasePool.test.ts @@ -28,7 +28,7 @@ import { random } from 'lodash'; import { defaultAbiCoder } from 'ethers/lib/utils'; import { sharedBeforeEach } from '@balancer-labs/v2-common/sharedBeforeEach'; -describe('BasePool', function () { +describe('NewBasePool', function () { let admin: SignerWithAddress, poolOwner: SignerWithAddress, deployer: SignerWithAddress, @@ -85,7 +85,7 @@ describe('BasePool', function () { if (!owner) owner = ZERO_ADDRESS; if (!from) from = deployer; - return deploy('v2-pool-weighted/MockBasePool', { + return deploy('MockNewBasePool', { from, args: [ vault.address, diff --git a/pkg/pool-weighted/contracts/managed/ManagedPool.sol b/pkg/pool-weighted/contracts/managed/ManagedPool.sol index 14c6f2033f..60c44f3168 100644 --- a/pkg/pool-weighted/contracts/managed/ManagedPool.sol +++ b/pkg/pool-weighted/contracts/managed/ManagedPool.sol @@ -67,7 +67,7 @@ contract ManagedPool is ManagedPoolSettings { uint256 pauseWindowDuration, uint256 bufferPeriodDuration ) - BasePool( + NewBasePool( vault, PoolRegistrationLib.registerComposablePool( vault, diff --git a/pkg/pool-weighted/contracts/managed/ManagedPoolSettings.sol b/pkg/pool-weighted/contracts/managed/ManagedPoolSettings.sol index 44086ec5b4..2dd6184b47 100644 --- a/pkg/pool-weighted/contracts/managed/ManagedPoolSettings.sol +++ b/pkg/pool-weighted/contracts/managed/ManagedPoolSettings.sol @@ -27,13 +27,12 @@ import "@balancer-labs/v2-pool-utils/contracts/lib/PoolRegistrationLib.sol"; import "@balancer-labs/v2-pool-utils/contracts/external-fees/InvariantGrowthProtocolSwapFees.sol"; import "@balancer-labs/v2-pool-utils/contracts/external-fees/ProtocolFeeCache.sol"; import "@balancer-labs/v2-pool-utils/contracts/external-fees/ExternalAUMFees.sol"; +import "@balancer-labs/v2-pool-utils/contracts/NewBasePool.sol"; import "../lib/GradualValueChange.sol"; import "../managed/CircuitBreakerStorageLib.sol"; import "../WeightedMath.sol"; -import "./vendor/BasePool.sol"; - import "./ManagedPoolStorageLib.sol"; import "./ManagedPoolAumStorageLib.sol"; import "./ManagedPoolTokenStorageLib.sol"; @@ -42,7 +41,7 @@ import "./ManagedPoolAddRemoveTokenLib.sol"; /** * @title Managed Pool Settings */ -abstract contract ManagedPoolSettings is BasePool, ProtocolFeeCache, IManagedPool { +abstract contract ManagedPoolSettings is NewBasePool, ProtocolFeeCache, IManagedPool { // ManagedPool weights and swap fees can change over time: these periods are expected to be long enough (e.g. days) // that any timestamp manipulation would achieve very little. // solhint-disable not-rely-on-time diff --git a/pkg/pool-weighted/contracts/test/MockManagedPoolSettings.sol b/pkg/pool-weighted/contracts/test/MockManagedPoolSettings.sol index 4d83b0a364..cc5fb0f75f 100644 --- a/pkg/pool-weighted/contracts/test/MockManagedPoolSettings.sol +++ b/pkg/pool-weighted/contracts/test/MockManagedPoolSettings.sol @@ -32,7 +32,7 @@ contract MockManagedPoolSettings is ManagedPoolSettings { uint256 pauseWindowDuration, uint256 bufferPeriodDuration ) - BasePool( + NewBasePool( vault, PoolRegistrationLib.registerPoolWithAssetManagers( vault,