-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Arnaud DN
committed
Oct 24, 2022
1 parent
4dc0784
commit bc0b4c0
Showing
46 changed files
with
2,050 additions
and
469 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.4; | ||
|
||
import "@openzeppelin/contracts/access/Ownable.sol"; | ||
import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol"; | ||
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; | ||
import {FairnessDAOFairERC721Vesting} from "./FairnessDAOFairERC721Vesting.sol"; | ||
import {FairnessDAOProposalRegistry} from "./FairnessDAOProposalRegistry.sol"; | ||
import {Counters} from "@openzeppelin/contracts/utils/Counters.sol"; | ||
|
||
/// @title FairnessDAOFactory | ||
/// @dev First draft of FairnessDAO protocol. | ||
/// @author Smart-Chain Team | ||
|
||
contract FairnessDAOFactoryERC721 is Ownable { | ||
using Counters for Counters.Counter; | ||
|
||
mapping(address => address) public | ||
fairnessDAOProposalRegistryAddressToOwnerAddress; | ||
mapping(uint256 => address) public indexToFairnessDAOProposalRegistryAddress; | ||
mapping(uint256 => address) public indexToFairnessDAOVestingAddress; | ||
|
||
Counters.Counter public fairnessDAOVestingERC721Id; | ||
Counters.Counter public fairnessDAOProposalRegistryId; | ||
|
||
address vestingLibraryAddress; | ||
address proposalLibraryAddress; | ||
|
||
event NewFairVesting( | ||
address indexed instance, uint256 indexed fairnessDAOVestingERC721Id | ||
); | ||
event NewFairGovernance( | ||
address indexed owner, | ||
address indexed instance, | ||
uint256 indexed fairnessDAOProposalRegistryId | ||
); | ||
|
||
/// @dev Update the base contract to clone | ||
/// @param _vestingLibraryAddress - new vesting base contract address | ||
/// @param _proposalLibraryAddress - new proposal registry base contract address | ||
function setLibraryAddress( | ||
address _vestingLibraryAddress, | ||
address _proposalLibraryAddress | ||
) external onlyOwner { | ||
vestingLibraryAddress = _vestingLibraryAddress; | ||
proposalLibraryAddress = _proposalLibraryAddress; | ||
} | ||
|
||
function deployFairVestingForERC20TokenClone( | ||
string memory tokenName, | ||
string memory tokenSymbol, | ||
address initFairTokenTarget, | ||
uint256 initZInflationDelta, | ||
uint256 fairnessDAOFairProposalRegistryIndex | ||
) external returns (address, address) { | ||
FairnessDAOFairERC721Vesting fairnessDAOFairERC721Vesting = | ||
FairnessDAOFairERC721Vesting(Clones.clone(vestingLibraryAddress)); | ||
|
||
fairnessDAOFairERC721Vesting.initialize( | ||
tokenName, | ||
tokenSymbol, | ||
initFairTokenTarget, | ||
initZInflationDelta, | ||
indexToFairnessDAOProposalRegistryAddress[fairnessDAOFairProposalRegistryIndex] | ||
); | ||
|
||
fairnessDAOVestingERC721Id.increment(); | ||
uint256 _fairnessDAOVestingERC721Id = | ||
fairnessDAOVestingERC721Id.current(); | ||
|
||
indexToFairnessDAOVestingAddress[_fairnessDAOVestingERC721Id] = | ||
address(fairnessDAOFairERC721Vesting); | ||
|
||
emit NewFairVesting( | ||
address(fairnessDAOFairERC721Vesting), _fairnessDAOVestingERC721Id | ||
); | ||
} | ||
|
||
function deployFairGovernanceForERC721TokenClone( | ||
uint256 fairnessDAOFairERC721VestingIndex, | ||
uint256 initMinimumSupplyShareRequiredForSubmittingProposals, | ||
uint256 initialVoteTimeLengthSoftProposal, | ||
uint256 initialVoteTimeLengthHardProposal, | ||
uint256 initialMinimumTotalSupplyShareRequiredForSoftProposal, | ||
uint256 initialMinimumTotalSupplyShareRequiredForHardProposal, | ||
uint256 initialMinimumVoterShareRequiredForSoftProposal, | ||
uint256 initialMinimumVoterShareRequiredForHardProposal, | ||
uint256 initalBoostedRewardBonusValue | ||
) external returns (address, address) { | ||
FairnessDAOProposalRegistry fairnessDAOProposalRegistry = | ||
FairnessDAOProposalRegistry(Clones.clone(proposalLibraryAddress)); | ||
|
||
fairnessDAOProposalRegistry.initialize( | ||
indexToFairnessDAOVestingAddress[fairnessDAOFairERC721VestingIndex], | ||
initMinimumSupplyShareRequiredForSubmittingProposals, | ||
initialVoteTimeLengthSoftProposal, | ||
initialVoteTimeLengthHardProposal, | ||
initialMinimumTotalSupplyShareRequiredForSoftProposal, | ||
initialMinimumTotalSupplyShareRequiredForHardProposal, | ||
initialMinimumVoterShareRequiredForSoftProposal, | ||
initialMinimumVoterShareRequiredForHardProposal, | ||
initalBoostedRewardBonusValue | ||
); | ||
|
||
fairnessDAOProposalRegistryId.increment(); | ||
uint256 _fairnessDAOProposalRegistryId = | ||
fairnessDAOProposalRegistryId.current(); | ||
|
||
indexToFairnessDAOProposalRegistryAddress[_fairnessDAOProposalRegistryId] | ||
= address(fairnessDAOProposalRegistry); | ||
|
||
fairnessDAOProposalRegistryAddressToOwnerAddress[address( | ||
fairnessDAOProposalRegistry | ||
)] = msg.sender; | ||
|
||
emit NewFairGovernance( | ||
msg.sender, | ||
address(fairnessDAOProposalRegistry), | ||
_fairnessDAOProposalRegistryId | ||
); | ||
} | ||
} |
Oops, something went wrong.