Skip to content

Commit

Permalink
Merge branch 'master' into forge-std-v1
Browse files Browse the repository at this point in the history
* master:
  test: always use abi encoder v2 in fuzz tests (#2121)
  Configurable pause window Preparation (#2118)
  Do deployment (#2117)
  Add missing managed factory ids (#2120)
  • Loading branch information
TomAFrench committed Dec 7, 2022
2 parents 4ce589f + 2e209fd commit 3a5d5d0
Show file tree
Hide file tree
Showing 19 changed files with 95 additions and 24 deletions.
9 changes: 9 additions & 0 deletions pkg/deployments/action-ids/arbitrum/action-ids.json
Original file line number Diff line number Diff line change
Expand Up @@ -492,5 +492,14 @@
"updateTokenRateCache(address)": "0x43e924739082162d0dfbe4b85270de4e7fe29526d812caeaa4797cf243c0bdfa"
}
}
},
"20221021-managed-pool": {
"ManagedPoolFactory": {
"useAdaptor": false,
"actionIds": {
"create((string,string,address[],uint256[],address[],uint256,bool,bool,uint256,uint256),address)": "0x0becf11063e0bab3ba20ce688e996dc9656adfe73f7a3b0baa3e2c7ede18e682",
"disable()": "0x0ebf042d38f8e1bb630c3010c686232d7334f90360a82eb23623fd01fbe8e656"
}
}
}
}
9 changes: 9 additions & 0 deletions pkg/deployments/action-ids/goerli/action-ids.json
Original file line number Diff line number Diff line change
Expand Up @@ -756,5 +756,14 @@
"updateTokenRateCache(address)": "0x43e924739082162d0dfbe4b85270de4e7fe29526d812caeaa4797cf243c0bdfa"
}
}
},
"20221021-managed-pool": {
"ManagedPoolFactory": {
"useAdaptor": false,
"actionIds": {
"create((string,string,address[],uint256[],address[],uint256,bool,bool,uint256,uint256),address)": "0x36109068009b7f32260b11e16b4afd875bba8106abcebb01b586994398dcc8c2",
"disable()": "0xec29307f87abfc2b5468e96f3e9ecae58a8b7eaeac6c2438d75b5b4c102cc918"
}
}
}
}
9 changes: 9 additions & 0 deletions pkg/deployments/action-ids/optimism/action-ids.json
Original file line number Diff line number Diff line change
Expand Up @@ -382,5 +382,14 @@
"updateTokenRateCache(address)": "0x43e924739082162d0dfbe4b85270de4e7fe29526d812caeaa4797cf243c0bdfa"
}
}
},
"20221021-managed-pool": {
"ManagedPoolFactory": {
"useAdaptor": false,
"actionIds": {
"create((string,string,address[],uint256[],address[],uint256,bool,bool,uint256,uint256),address)": "0x0becf11063e0bab3ba20ce688e996dc9656adfe73f7a3b0baa3e2c7ede18e682",
"disable()": "0x0ebf042d38f8e1bb630c3010c686232d7334f90360a82eb23623fd01fbe8e656"
}
}
}
}
9 changes: 9 additions & 0 deletions pkg/deployments/action-ids/polygon/action-ids.json
Original file line number Diff line number Diff line change
Expand Up @@ -577,5 +577,14 @@
"updateTokenRateCache(address)": "0x43e924739082162d0dfbe4b85270de4e7fe29526d812caeaa4797cf243c0bdfa"
}
}
},
"20221021-managed-pool": {
"ManagedPoolFactory": {
"useAdaptor": false,
"actionIds": {
"create((string,string,address[],uint256[],address[],uint256,bool,bool,uint256,uint256),address)": "0x01ed6b1d1a76460295cf1325534f6c4bd3fc1f8717cd0cf9733f493a0821da71",
"disable()": "0xa010f28803768154a04542ff29718c73ff40e307b10e5f39fbdff6c90db7b4ec"
}
}
}
}
3 changes: 2 additions & 1 deletion pkg/deployments/deployment-txs/goerli.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,6 @@
"0xee47ef369CDa5a65639D7794b70a4d247826DdF3": "0x2e73806eba95a16ee3009eb8da077d1faa39db65ad2b6b63a114b1c10dba4352",
"0x85a80afee867aDf27B50BdB7b76DA70f1E853062": "0x652709f2f555d1d38febfd567abf9b4bd0fcccda6ad0eb0341c540730bc6f740",
"0x373b347bc87998b151A5E9B6bB6ca692b766648a": "0xb0f85bd0cb95451e8dc26d4956699a16cd7ad47d3c0f1a952de77e937af17a8c",
"0xf23b4DB826DbA14c0e857029dfF076b1c0264843": "0xd97f6363f6067ff3dc12a8748d2c8307256d07532428e549db5e2c5b1e5a9788"
"0xf23b4DB826DbA14c0e857029dfF076b1c0264843": "0xd97f6363f6067ff3dc12a8748d2c8307256d07532428e549db5e2c5b1e5a9788",
"0xd13AFc362F619b840C8f4AaC1D957cE219eF37Ca": "0xeb4e8cf2670cbbc96d137146fbc05435e88b7d7126f472dc099549f01297feb2"
}
3 changes: 2 additions & 1 deletion pkg/deployments/deployment-txs/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,6 @@
"0xf8ee6f1F9B54F9b2C192D703ea2d22112cBC062b": "0x20eb23f4393fd592240ec788f44fb9658cc6ef487b88398e9b76c910294c4eae",
"0x85a80afee867aDf27B50BdB7b76DA70f1E853062": "0x0042954a30f282acd402606c83163c95fc6e0484a56b87dee0d9685cd0de1662",
"0x373b347bc87998b151A5E9B6bB6ca692b766648a": "0x8a92b6e8db14842aaf6a3c4de54627887798189a306243f6cb1387724fde96f7",
"0xf23b4DB826DbA14c0e857029dfF076b1c0264843": "0x6381ca48c4967cca2373acbbd4f4e6c6f22d0f73d6fae93528ad14834d10c99a"
"0xf23b4DB826DbA14c0e857029dfF076b1c0264843": "0x6381ca48c4967cca2373acbbd4f4e6c6f22d0f73d6fae93528ad14834d10c99a",
"0x67F8DF125B796B05895a6dc8Ecf944b9556ecb0B": "0xa4c9c16a06c031280b888274d73278fc2df88febebbede26fab617623b512873"
}
3 changes: 3 additions & 0 deletions pkg/deployments/tasks/20221205-veboost-v2/output/goerli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"VeBoostV2": "0xd13AFc362F619b840C8f4AaC1D957cE219eF37Ca"
}
3 changes: 3 additions & 0 deletions pkg/deployments/tasks/20221205-veboost-v2/output/mainnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"VeBoostV2": "0x67F8DF125B796B05895a6dc8Ecf944b9556ecb0B"
}
4 changes: 1 addition & 3 deletions pkg/pool-linear/contracts/aave/AaveLinearPoolFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import "@balancer-labs/v2-interfaces/contracts/pool-utils/IFactoryCreatedPoolVer

import "@balancer-labs/v2-pool-utils/contracts/Version.sol";
import "@balancer-labs/v2-pool-utils/contracts/factories/BasePoolFactory.sol";
import "@balancer-labs/v2-pool-utils/contracts/factories/FactoryWidePauseWindow.sol";

import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/Create2.sol";
import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/ReentrancyGuard.sol";
Expand All @@ -35,8 +34,7 @@ contract AaveLinearPoolFactory is
IFactoryCreatedPoolVersion,
Version,
BasePoolFactory,
ReentrancyGuard,
FactoryWidePauseWindow
ReentrancyGuard
{
// Associate a name with each registered protocol that uses this factory.
struct ProtocolIdData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ pragma experimental ABIEncoderV2;
import "@balancer-labs/v2-interfaces/contracts/vault/IVault.sol";

import "@balancer-labs/v2-pool-utils/contracts/factories/BasePoolFactory.sol";
import "@balancer-labs/v2-pool-utils/contracts/factories/FactoryWidePauseWindow.sol";

import "./UnbuttonAaveLinearPool.sol";

contract UnbuttonAaveLinearPoolFactory is BasePoolFactory, FactoryWidePauseWindow {
contract UnbuttonAaveLinearPoolFactory is BasePoolFactory {
constructor(IVault vault, IProtocolFeePercentagesProvider protocolFeeProvider)
BasePoolFactory(vault, protocolFeeProvider, type(UnbuttonAaveLinearPool).creationCode)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ pragma experimental ABIEncoderV2;
import "@balancer-labs/v2-interfaces/contracts/vault/IVault.sol";

import "@balancer-labs/v2-pool-utils/contracts/factories/BasePoolFactory.sol";
import "@balancer-labs/v2-pool-utils/contracts/factories/FactoryWidePauseWindow.sol";

import "./ERC4626LinearPool.sol";

contract ERC4626LinearPoolFactory is BasePoolFactory, FactoryWidePauseWindow {
contract ERC4626LinearPoolFactory is BasePoolFactory {
constructor(IVault vault, IProtocolFeePercentagesProvider protocolFeeProvider)
BasePoolFactory(vault, protocolFeeProvider, type(ERC4626LinearPool).creationCode)
{
Expand Down
3 changes: 1 addition & 2 deletions pkg/pool-linear/contracts/reaper/ReaperLinearPoolFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ import "@balancer-labs/v2-interfaces/contracts/standalone-utils/IBalancerQueries
import "@balancer-labs/v2-interfaces/contracts/pool-utils/ILastCreatedPoolFactory.sol";

import "@balancer-labs/v2-pool-utils/contracts/factories/BasePoolFactory.sol";
import "@balancer-labs/v2-pool-utils/contracts/factories/FactoryWidePauseWindow.sol";

import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/Create2.sol";
import "@balancer-labs/v2-solidity-utils/contracts/openzeppelin/ReentrancyGuard.sol";

import "./ReaperLinearPool.sol";
import "./ReaperLinearPoolRebalancer.sol";

contract ReaperLinearPoolFactory is ILastCreatedPoolFactory, BasePoolFactory, ReentrancyGuard, FactoryWidePauseWindow {
contract ReaperLinearPoolFactory is ILastCreatedPoolFactory, BasePoolFactory, ReentrancyGuard {
// Used for create2 deployments
uint256 private _nextRebalancerSalt;

Expand Down
3 changes: 1 addition & 2 deletions pkg/pool-stable/contracts/ComposableStablePoolFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ import "@balancer-labs/v2-interfaces/contracts/pool-utils/IVersion.sol";
import "@balancer-labs/v2-interfaces/contracts/vault/IVault.sol";

import "@balancer-labs/v2-pool-utils/contracts/factories/BasePoolFactory.sol";
import "@balancer-labs/v2-pool-utils/contracts/factories/FactoryWidePauseWindow.sol";

import "./ComposableStablePool.sol";

contract ComposableStablePoolFactory is IVersion, IPoolVersion, BasePoolFactory, FactoryWidePauseWindow {
contract ComposableStablePoolFactory is IVersion, IPoolVersion, BasePoolFactory {
string private _version;
string private _poolVersion;

Expand Down
11 changes: 9 additions & 2 deletions pkg/pool-utils/contracts/factories/BasePoolFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import "@balancer-labs/v2-interfaces/contracts/pool-utils/IBasePoolFactory.sol";
import "@balancer-labs/v2-solidity-utils/contracts/helpers/BaseSplitCodeFactory.sol";
import "@balancer-labs/v2-solidity-utils/contracts/helpers/SingletonAuthentication.sol";

import "./FactoryWidePauseWindow.sol";

/**
* @notice Base contract for Pool factories.
*
Expand All @@ -35,7 +37,12 @@ import "@balancer-labs/v2-solidity-utils/contracts/helpers/SingletonAuthenticati
* become increasingly important. Governance can deprecate a factory by calling `disable`, which will permanently
* prevent the creation of any future pools from the factory.
*/
abstract contract BasePoolFactory is IBasePoolFactory, BaseSplitCodeFactory, SingletonAuthentication {
abstract contract BasePoolFactory is
IBasePoolFactory,
BaseSplitCodeFactory,
SingletonAuthentication,
FactoryWidePauseWindow
{
IProtocolFeePercentagesProvider private immutable _protocolFeeProvider;

mapping(address => bool) private _isPoolFromFactory;
Expand All @@ -48,7 +55,7 @@ abstract contract BasePoolFactory is IBasePoolFactory, BaseSplitCodeFactory, Sin
IVault vault,
IProtocolFeePercentagesProvider protocolFeeProvider,
bytes memory creationCode
) BaseSplitCodeFactory(creationCode) SingletonAuthentication(vault) {
) BaseSplitCodeFactory(creationCode) SingletonAuthentication(vault) FactoryWidePauseWindow() {
_protocolFeeProvider = protocolFeeProvider;
}

Expand Down
33 changes: 31 additions & 2 deletions pkg/pool-utils/test/factories/BasePoolFactory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { actionId } from '@balancer-labs/v2-helpers/src/models/misc/actions';
import { deploy } from '@balancer-labs/v2-helpers/src/contract';
import { ANY_ADDRESS } from '@balancer-labs/v2-helpers/src/constants';
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers';
import { MONTH } from '@balancer-labs/v2-helpers/src/time';
import { MONTH, currentTimestamp } from '@balancer-labs/v2-helpers/src/time';
import { expect } from 'chai';
import { fp } from '@balancer-labs/v2-helpers/src/numbers';
import { fp, bn } from '@balancer-labs/v2-helpers/src/numbers';
import Vault from '@balancer-labs/v2-helpers/src/models/vault/Vault';

describe('BasePoolFactory', function () {
Expand Down Expand Up @@ -108,4 +108,33 @@ describe('BasePoolFactory', function () {
});
});
});

describe('pause durations', () => {
const PAUSE_WINDOW_DURATION = MONTH * 3;
const BUFFER_PERIOD_DURATION = MONTH;

let factoryDeployTime: BigNumber;

sharedBeforeEach(async () => {
factory = await deploy('MockPoolFactory', {
args: [vault.address, protocolFeesProvider.address],
});
factoryDeployTime = await currentTimestamp();
});

context('with valid durations', () => {
it('returns the current pause window duration', async () => {
const now = await currentTimestamp();
const expectedDuration = bn(PAUSE_WINDOW_DURATION).sub(now.sub(factoryDeployTime));

const { pauseWindowDuration } = await factory.getPauseConfiguration();
expect(pauseWindowDuration).to.equal(expectedDuration);
});

it('returns the buffer period duration', async () => {
const { bufferPeriodDuration } = await factory.getPauseConfiguration();
expect(bufferPeriodDuration).to.equal(BUFFER_PERIOD_DURATION);
});
});
});
});
2 changes: 1 addition & 1 deletion pkg/pool-utils/test/foundry/BasePoolMath.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import { Test } from "forge-std/Test.sol";
import "@balancer-labs/v2-solidity-utils/contracts/math/FixedPoint.sol";
Expand Down Expand Up @@ -66,7 +67,6 @@ contract BasePoolMathJoinExitRoundingTest is Test {
bptAmount
);


// And check that we didn't get any free tokens
for (uint256 i = 0; i < arrayLength; ++i) {
assertLe(amountsOut[i], amountsIn[i]);
Expand Down
3 changes: 1 addition & 2 deletions pkg/pool-weighted/contracts/WeightedPoolFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ pragma experimental ABIEncoderV2;
import "@balancer-labs/v2-interfaces/contracts/vault/IVault.sol";

import "@balancer-labs/v2-pool-utils/contracts/factories/BasePoolFactory.sol";
import "@balancer-labs/v2-pool-utils/contracts/factories/FactoryWidePauseWindow.sol";

import "./WeightedPool.sol";

contract WeightedPoolFactory is BasePoolFactory, FactoryWidePauseWindow {
contract WeightedPoolFactory is BasePoolFactory {
constructor(IVault vault, IProtocolFeePercentagesProvider protocolFeeProvider)
BasePoolFactory(vault, protocolFeeProvider, type(WeightedPool).creationCode)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ pragma experimental ABIEncoderV2;
import "@balancer-labs/v2-interfaces/contracts/vault/IVault.sol";

import "@balancer-labs/v2-pool-utils/contracts/factories/BasePoolFactory.sol";
import "@balancer-labs/v2-pool-utils/contracts/factories/FactoryWidePauseWindow.sol";

import "./LiquidityBootstrappingPool.sol";

contract LiquidityBootstrappingPoolFactory is BasePoolFactory, FactoryWidePauseWindow {
contract LiquidityBootstrappingPoolFactory is BasePoolFactory {
constructor(IVault vault, IProtocolFeePercentagesProvider protocolFeeProvider)
BasePoolFactory(vault, protocolFeeProvider, type(LiquidityBootstrappingPool).creationCode)
{
Expand Down
3 changes: 1 addition & 2 deletions pkg/pool-weighted/contracts/managed/ManagedPoolFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import "@balancer-labs/v2-interfaces/contracts/pool-utils/IFactoryCreatedPoolVer
import "@balancer-labs/v2-interfaces/contracts/standalone-utils/IProtocolFeePercentagesProvider.sol";

import "@balancer-labs/v2-pool-utils/contracts/factories/BasePoolFactory.sol";
import "@balancer-labs/v2-pool-utils/contracts/factories/FactoryWidePauseWindow.sol";
import "@balancer-labs/v2-pool-utils/contracts/Version.sol";

import "./ManagedPool.sol";
Expand All @@ -37,7 +36,7 @@ import "../ExternalWeightedMath.sol";
* In this design, other client-specific factories will deploy a contract, then call this factory
* to deploy the pool, passing in that contract address as the owner.
*/
contract ManagedPoolFactory is IFactoryCreatedPoolVersion, Version, BasePoolFactory, FactoryWidePauseWindow {
contract ManagedPoolFactory is IFactoryCreatedPoolVersion, Version, BasePoolFactory {
IExternalWeightedMath private immutable _weightedMath;
string private _poolVersion;

Expand Down

0 comments on commit 3a5d5d0

Please sign in to comment.