diff --git a/contracts/L1/Distribution.sol b/contracts/L1/Distribution.sol index 9c13c97..72296d0 100644 --- a/contracts/L1/Distribution.sol +++ b/contracts/L1/Distribution.sol @@ -68,7 +68,7 @@ contract Distribution is IDistribution, OwnableUpgradeable { } /**********************************************************************************************/ - /*** Pool managment and data retrieval ***/ + /*** Pool management and data retrieval ***/ /**********************************************************************************************/ function createPool(Pool calldata pool_) public onlyOwner { require(pool_.payoutStart > block.timestamp, "DS: invalid payout start value"); diff --git a/contracts/Factory.sol b/contracts/factories/Factory.sol similarity index 97% rename from contracts/Factory.sol rename to contracts/factories/Factory.sol index af3287d..bcaa539 100644 --- a/contracts/Factory.sol +++ b/contracts/factories/Factory.sol @@ -2,13 +2,13 @@ pragma solidity ^0.8.20; import {Create2} from "@openzeppelin/contracts/utils/Create2.sol"; -import {IFreezableBeaconProxy, FreezableBeaconProxy} from "./proxy/FreezableBeaconProxy.sol"; import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import {PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import {UpgradeableBeacon} from "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; -import {IFactory} from "./interfaces/IFactory.sol"; +import {IFactory} from "../interfaces/IFactory.sol"; +import {IFreezableBeaconProxy, FreezableBeaconProxy} from "../proxy/FreezableBeaconProxy.sol"; abstract contract Factory is IFactory, OwnableUpgradeable, PausableUpgradeable, UUPSUpgradeable { mapping(uint8 poolType => UpgradeableBeacon) internal _beacons; diff --git a/contracts/L1/L1Factory.sol b/contracts/factories/L1Factory.sol similarity index 96% rename from contracts/L1/L1Factory.sol rename to contracts/factories/L1Factory.sol index 2806205..c455127 100644 --- a/contracts/L1/L1Factory.sol +++ b/contracts/factories/L1Factory.sol @@ -7,7 +7,7 @@ import {IL1Sender} from "../interfaces/L1/IL1Sender.sol"; import {IOwnable} from "../interfaces/IOwnable.sol"; import {IFreezableBeaconProxy} from "../interfaces/proxy/IFreezableBeaconProxy.sol"; -import {Factory} from "../Factory.sol"; +import {Factory} from "./Factory.sol"; contract L1Factory is IL1Factory, Factory { address public feeConfig; @@ -82,8 +82,9 @@ contract L1Factory is IL1Factory, Factory { IL1Sender(l1SenderProxy_).L1Sender__init(distributionProxy_, lzConfig_, arbConfig_); - if (l1Params_.isNotUpgradeable) { + if (!l1Params_.isUpgradeable) { IFreezableBeaconProxy(distributionProxy_).freeze(); + IFreezableBeaconProxy(l1SenderProxy_).freeze(); } IOwnable(distributionProxy_).transferOwnership(_msgSender()); diff --git a/contracts/L2/L2Factory.sol b/contracts/factories/L2Factory.sol similarity index 91% rename from contracts/L2/L2Factory.sol rename to contracts/factories/L2Factory.sol index d46e048..459d890 100644 --- a/contracts/L2/L2Factory.sol +++ b/contracts/factories/L2Factory.sol @@ -6,8 +6,9 @@ import {IL2TokenReceiver} from "../interfaces/L2/IL2TokenReceiver.sol"; import {IL2Factory} from "../interfaces/L2/IL2Factory.sol"; import {IOwnable} from "../interfaces/IOwnable.sol"; import {IMOR20} from "../interfaces/L2/IMOR20.sol"; +import {IFreezableBeaconProxy} from "../interfaces/proxy/IFreezableBeaconProxy.sol"; -import {Factory} from "../Factory.sol"; +import {Factory} from "./Factory.sol"; import {MOR20Deployer} from "../libs/MOR20Deployer.sol"; contract L2Factory is IL2Factory, Factory { @@ -67,6 +68,11 @@ contract L2Factory is IL2Factory, Factory { IL2TokenReceiver.SwapParams(l2Params_.firstSwapParams_.tokenOut, mor20_, l2Params_.secondSwapFee) ); + if (!l2Params_.isUpgradeable) { + IFreezableBeaconProxy(l2MessageReceiver_).freeze(); + IFreezableBeaconProxy(l2TokenReceiver_).freeze(); + } + IOwnable(l2MessageReceiver_).transferOwnership(_msgSender()); IOwnable(l2TokenReceiver_).transferOwnership(_msgSender()); } diff --git a/contracts/interfaces/L1/IL1Factory.sol b/contracts/interfaces/L1/IL1Factory.sol index cd868b3..d5f31de 100644 --- a/contracts/interfaces/L1/IL1Factory.sol +++ b/contracts/interfaces/L1/IL1Factory.sol @@ -18,15 +18,15 @@ interface IL1Factory { /** * The struct that represents the parameters for * deploying specific L1 contracts. + * @param isUpgradeable The flag indicating whether the deployed pools are upgradeable. * @param protocolName The protocol name. - * @param isNotUpgradeable The flag that indicates if the contract is not upgradeable. * @param poolsInfo The pools information. * @param l2TokenReceiver The L2 token receiver address. * @param l2MessageReceiver The L2 message receiver address. */ struct L1Params { + bool isUpgradeable; string protocolName; - bool isNotUpgradeable; IDistribution.Pool[] poolsInfo; address l2TokenReceiver; address l2MessageReceiver; diff --git a/contracts/interfaces/L2/IL2Factory.sol b/contracts/interfaces/L2/IL2Factory.sol index 774747d..bf86d9a 100644 --- a/contracts/interfaces/L2/IL2Factory.sol +++ b/contracts/interfaces/L2/IL2Factory.sol @@ -15,6 +15,7 @@ interface IL2Factory { /** * The struct that represents the parameters for * deploying specific L2 contracts. + * @param isUpgradeable The flag indicating whether the deployed pools are upgradeable. * @param protocolName The protocol name. * @param mor20Name The MOR20 name. * @param mor20Symbol The MOR20 symbol. @@ -23,6 +24,7 @@ interface IL2Factory { * @param secondSwapFee The second swap fee. */ struct L2Params { + bool isUpgradeable; string protocolName; string mor20Name; string mor20Symbol; diff --git a/contracts/mock/FactoryMock.sol b/contracts/mock/FactoryMock.sol index 3754a8f..e2bb449 100644 --- a/contracts/mock/FactoryMock.sol +++ b/contracts/mock/FactoryMock.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.20; -import {Factory} from "../Factory.sol"; +import {Factory} from "../factories/Factory.sol"; contract FactoryMock is Factory { function Factory_init() external initializer { diff --git a/test/Integration.test.ts b/test/Integration.test.ts index 1b7d5df..9510118 100644 --- a/test/Integration.test.ts +++ b/test/Integration.test.ts @@ -218,13 +218,14 @@ describe('Integration', () => { await l1LzEndpoint.setDestLzEndpoint(l2MessageReceiverPredicted, l2LzEndpoint); const l1Params: IL1Factory.L1ParamsStruct = { + isUpgradeable: false, protocolName: protocolName, - isNotUpgradeable: true, poolsInfo: [], l2TokenReceiver: l2TokenReceiverPredicted, l2MessageReceiver: l2MessageReceiverPredicted, }; const l2Params: IL2Factory.L2ParamsStruct = { + isUpgradeable: false, protocolName: protocolName, mor20Name: 'MOR20', mor20Symbol: 'M20', diff --git a/test/L1/L1Factory.test.ts b/test/L1/L1Factory.test.ts index 21a5d1d..f768413 100644 --- a/test/L1/L1Factory.test.ts +++ b/test/L1/L1Factory.test.ts @@ -133,8 +133,8 @@ describe('L1Factory', () => { function getL1DefaultParams() { const l1Params: IL1Factory.L1ParamsStruct = { + isUpgradeable: true, protocolName: 'Mor20', - isNotUpgradeable: false, poolsInfo: [], l2TokenReceiver: SECOND, l2MessageReceiver: SECOND, diff --git a/test/L2/L2Factory.test.ts b/test/L2/L2Factory.test.ts index b9cd6ed..31f960e 100644 --- a/test/L2/L2Factory.test.ts +++ b/test/L2/L2Factory.test.ts @@ -127,6 +127,7 @@ describe('L2Factory', () => { function getL2DefaultParams() { const l2Params: IL2Factory.L2ParamsStruct = { + isUpgradeable: true, protocolName: 'Mor20', mor20Name: 'MOR20', mor20Symbol: 'M20',