Skip to content

Commit

Permalink
factories dir & isUpgradeable for all pools
Browse files Browse the repository at this point in the history
  • Loading branch information
dovgopoly committed May 15, 2024
1 parent 1900eed commit 58baedd
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion contracts/L1/Distribution.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions contracts/Factory.sol → contracts/factories/Factory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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());
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/interfaces/L1/IL1Factory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions contracts/interfaces/L2/IL2Factory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -23,6 +24,7 @@ interface IL2Factory {
* @param secondSwapFee The second swap fee.
*/
struct L2Params {
bool isUpgradeable;
string protocolName;
string mor20Name;
string mor20Symbol;
Expand Down
2 changes: 1 addition & 1 deletion contracts/mock/FactoryMock.sol
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion test/Integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion test/L1/L1Factory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ describe('L1Factory', () => {

function getL1DefaultParams() {
const l1Params: IL1Factory.L1ParamsStruct = {
isUpgradeable: true,
protocolName: 'Mor20',
isNotUpgradeable: false,
poolsInfo: [],
l2TokenReceiver: SECOND,
l2MessageReceiver: SECOND,
Expand Down
1 change: 1 addition & 0 deletions test/L2/L2Factory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ describe('L2Factory', () => {

function getL2DefaultParams() {
const l2Params: IL2Factory.L2ParamsStruct = {
isUpgradeable: true,
protocolName: 'Mor20',
mor20Name: 'MOR20',
mor20Symbol: 'M20',
Expand Down

0 comments on commit 58baedd

Please sign in to comment.