-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: [sc-2168] LBPFactoryNoAccessControl #116
base: development
Are you sure you want to change the base?
Changes from all commits
a331e24
b24e75f
dca0857
1e7eafc
51229ca
87e37b0
1c476a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -16,13 +16,14 @@ pragma solidity 0.8.17; | |||||
|
||||||
import "../utils/CloneFactory.sol"; | ||||||
import "@openzeppelin/contracts/access/Ownable.sol"; | ||||||
import "./LBPManager.sol"; | ||||||
import "./LBPManagerV1.sol"; | ||||||
|
||||||
/** | ||||||
* @title LBPManager Factory | ||||||
* @dev Governance to create new LBPManager contracts. | ||||||
*/ | ||||||
contract LBPManagerFactory is CloneFactory, Ownable { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
bytes6 public version = "2.1.0"; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I expected to see "1.0.0" here, since LBP is still v1? I also expect LBP and Seed versioning to be independent. |
||||||
address public masterCopy; | ||||||
address public lbpFactory; | ||||||
|
||||||
|
@@ -134,7 +135,7 @@ contract LBPManagerFactory is CloneFactory, Ownable { | |||||
|
||||||
address lbpManager = createClone(masterCopy); | ||||||
|
||||||
LBPManager(lbpManager).initializeLBPManager( | ||||||
LBPManagerV1(lbpManager).initializeLBPManager( | ||||||
lbpFactory, | ||||||
_beneficiary, | ||||||
_name, | ||||||
|
@@ -148,7 +149,7 @@ contract LBPManagerFactory is CloneFactory, Ownable { | |||||
_metadata | ||||||
); | ||||||
|
||||||
LBPManager(lbpManager).transferAdminRights(_admin); | ||||||
LBPManagerV1(lbpManager).transferAdminRights(_admin); | ||||||
|
||||||
emit LBPManagerDeployed(lbpManager, _admin, _metadata); | ||||||
} | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
/* | ||
██████╗░██████╗░██╗███╗░░░███╗███████╗██████╗░░█████╗░░█████╗░ | ||
██╔══██╗██╔══██╗██║████╗░████║██╔════╝██╔══██╗██╔══██╗██╔══██╗ | ||
██████╔╝██████╔╝██║██╔████╔██║█████╗░░██║░░██║███████║██║░░██║ | ||
██╔═══╝░██╔══██╗██║██║╚██╔╝██║██╔══╝░░██║░░██║██╔══██║██║░░██║ | ||
██║░░░░░██║░░██║██║██║░╚═╝░██║███████╗██████╔╝██║░░██║╚█████╔╝ | ||
╚═╝░░░░░╚═╝░░╚═╝╚═╝╚═╝░░░░░╚═╝╚══════╝╚═════╝░╚═╝░░╚═╝░╚════╝░ | ||
*/ | ||
|
||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
// LBPManager Factory contract. Governance to create new LBPManager contracts. | ||
// Copyright (C) 2021 PrimeDao | ||
|
||
// solium-disable linebreak-style | ||
pragma solidity 0.8.17; | ||
|
||
import "../utils/CloneFactory.sol"; | ||
import "@openzeppelin/contracts/access/Ownable.sol"; | ||
import "./LBPManagerV1.sol"; | ||
|
||
/** | ||
* @title LBPManager Factory no access control version 1 | ||
* @dev Governance to create new LBPManager contract without the onlyOwner modifer for the | ||
* function deployLBPManager(). By removing the access control, everyone can deploy a | ||
* LBPManager from this contract. This is a temporarly solution in response to the | ||
* flaky Celo Safe. | ||
*/ | ||
contract LBPManagerFactoryV1NoAccessControl is CloneFactory, Ownable { | ||
bytes6 public version = "1.0.0"; | ||
address public masterCopy; | ||
address public lbpFactory; | ||
|
||
event LBPManagerDeployed( | ||
address indexed lbpManager, | ||
address indexed admin, | ||
bytes metadata | ||
); | ||
|
||
event LBPFactoryChanged( | ||
address indexed oldLBPFactory, | ||
address indexed newLBPFactory | ||
); | ||
|
||
event MastercopyChanged( | ||
address indexed oldMasterCopy, | ||
address indexed newMasterCopy | ||
); | ||
|
||
/** | ||
* @dev Constructor. | ||
* @param _lbpFactory The address of Balancers LBP factory. | ||
*/ | ||
constructor(address _lbpFactory) { | ||
require(_lbpFactory != address(0), "LBPMFactory: LBPFactory is zero"); | ||
lbpFactory = _lbpFactory; | ||
} | ||
|
||
modifier validAddress(address addressToCheck) { | ||
require(addressToCheck != address(0), "LBPMFactory: address is zero"); | ||
// solhint-disable-next-line reason-string | ||
require( | ||
addressToCheck != address(this), | ||
"LBPMFactory: address same as LBPManagerFactory" | ||
); | ||
_; | ||
} | ||
|
||
/** | ||
* @dev Set LBPManager contract which works as a base for clones. | ||
* @param _masterCopy The address of the new LBPManager basis. | ||
*/ | ||
function setMasterCopy(address _masterCopy) | ||
external | ||
onlyOwner | ||
validAddress(_masterCopy) | ||
{ | ||
emit MastercopyChanged(masterCopy, _masterCopy); | ||
masterCopy = _masterCopy; | ||
} | ||
|
||
/** | ||
* @dev Set Balancers LBP Factory contract as basis for deploying LBPs. | ||
* @param _lbpFactory The address of Balancers LBP factory. | ||
*/ | ||
function setLBPFactory(address _lbpFactory) | ||
external | ||
onlyOwner | ||
validAddress(_lbpFactory) | ||
{ | ||
emit LBPFactoryChanged(lbpFactory, _lbpFactory); | ||
lbpFactory = _lbpFactory; | ||
} | ||
|
||
/** | ||
* @dev Deploy and initialize LBPManager. | ||
* @param _admin The address of the admin of the LBPManager. | ||
* @param _beneficiary The address that receives the _fees. | ||
* @param _name Name of the LBP. | ||
* @param _symbol Symbol of the LBP. | ||
* @param _tokenList Numerically sorted array (ascending) containing two addresses: | ||
- The address of the project token being distributed. | ||
- The address of the funding token being exchanged for the project token. | ||
* @param _amounts Sorted array to match the _tokenList, containing two parameters: | ||
- The amounts of project token to be added as liquidity to the LBP. | ||
- The amounts of funding token to be added as liquidity to the LBP. | ||
* @param _startWeights Sorted array to match the _tokenList, containing two parametes: | ||
- The start weight for the project token in the LBP. | ||
- The start weight for the funding token in the LBP. | ||
* @param _startTimeEndtime Array containing two parameters: | ||
- Start time for the LBP. | ||
- End time for the LBP. | ||
* @param _endWeights Sorted array to match the _tokenList, containing two parametes: | ||
- The end weight for the project token in the LBP. | ||
- The end weight for the funding token in the LBP. | ||
* @param _fees Array containing two parameters: | ||
- Percentage of fee paid for every swap in the LBP. | ||
- Percentage of fee paid to the _beneficiary for providing the service of the LBP Manager. | ||
* @param _metadata IPFS Hash of the LBP creation wizard information. | ||
*/ | ||
function deployLBPManager( | ||
address _admin, | ||
address _beneficiary, | ||
string memory _name, | ||
string memory _symbol, | ||
IERC20[] memory _tokenList, | ||
uint256[] memory _amounts, | ||
uint256[] memory _startWeights, | ||
uint256[] memory _startTimeEndtime, | ||
uint256[] memory _endWeights, | ||
uint256[] memory _fees, | ||
bytes memory _metadata | ||
) external { | ||
// solhint-disable-next-line reason-string | ||
require( | ||
masterCopy != address(0), | ||
"LBPMFactory: LBPManager mastercopy not set" | ||
); | ||
|
||
address lbpManager = createClone(masterCopy); | ||
|
||
LBPManagerV1(lbpManager).initializeLBPManager( | ||
lbpFactory, | ||
_beneficiary, | ||
_name, | ||
_symbol, | ||
_tokenList, | ||
_amounts, | ||
_startWeights, | ||
_startTimeEndtime, | ||
_endWeights, | ||
_fees, | ||
_metadata | ||
); | ||
|
||
LBPManagerV1(lbpManager).transferAdminRights(_admin); | ||
|
||
emit LBPManagerDeployed(lbpManager, _admin, _metadata); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const { getBalancerContractAddress } = require("@balancer-labs/v2-deployments"); | ||
|
||
const deployFunction = async ({ | ||
getNamedAccounts, | ||
deployments, | ||
ethers, | ||
network, | ||
}) => { | ||
const { deploy } = deployments; | ||
const { root } = await getNamedAccounts(); | ||
|
||
const liquidityBootstrappingPoolFactoryTaskId = | ||
"20211202-no-protocol-fee-lbp"; | ||
const contractName = "LiquidityBootstrappingPoolFactory"; | ||
|
||
// Balancer contracts are not deployed on Celo and Alfajores, so we're using Symmetric/root instead | ||
const lbpFactoryAddress = | ||
network.name === "celo" | ||
? "0xdF87a2369FAa3140613c3C5D008A9F50B3303fD3" // can be found https://docs.symmetric.exchange/general-resources-and-tools/symmetric-contract-addresses#v2-contracts | ||
: network.name === "goerli" | ||
? "0xb48Cc42C45d262534e46d5965a9Ac496F1B7a830" // can be found https://dev.balancer.fi/references/contracts/deployment-addresses | ||
: // ToDo: Need to be updated to new package | ||
await getBalancerContractAddress( | ||
liquidityBootstrappingPoolFactoryTaskId, | ||
contractName, | ||
network.name | ||
); | ||
|
||
await deploy("LBPManagerFactoryV1NoAccessControl", { | ||
from: root, | ||
args: [lbpFactoryAddress], | ||
log: true, | ||
}); | ||
|
||
const { address: lbpManagerAddress } = await deploy("LBPManagerV1", { | ||
from: root, | ||
args: [], | ||
log: true, | ||
}); | ||
|
||
const lbpManagerFactoryInstance = await ethers.getContract( | ||
"LBPManagerFactoryV1NoAccessControl" | ||
); | ||
|
||
await lbpManagerFactoryInstance.setMasterCopy(lbpManagerAddress); | ||
}; | ||
|
||
module.exports = deployFunction; | ||
module.exports.tags = ["LBPNoAccessControl"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should rename this file too to include "V1"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BUT, I'm also fine with maybe not versioning LBP for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not add the version to the standard LBPManagerFactory because for now, we will only use the other one