diff --git a/contracts/factories/PrivateOfferFactory.sol b/contracts/factories/PrivateOfferFactory.sol index 8c2767f2..94b34b1f 100644 --- a/contracts/factories/PrivateOfferFactory.sol +++ b/contracts/factories/PrivateOfferFactory.sol @@ -64,34 +64,24 @@ contract PrivateOfferFactory { // deploy the vesting contract Vesting vesting = Vesting( - vestingCloneFactory.createVestingClone(salt, trustedForwarder, address(this), address(_arguments.token)) + vestingCloneFactory.createVestingCloneWithLockupPlan( + salt, + trustedForwarder, + _vestingContractOwner, + address(_arguments.token), + _arguments.tokenAmount, + _arguments.tokenReceiver, + _vestingStart, + _vestingCliff, + _vestingDuration + ) ); - // create the vesting plan - vesting.createVesting( - _arguments.tokenAmount, - _arguments.tokenReceiver, - _vestingStart, - _vestingCliff, - _vestingDuration, - false - ); // this plan is not mintable - - vesting.removeManager(address(this)); - - // transfer ownership of the vesting contract - if (_vestingContractOwner == address(0)) { - // if the owner is 0, the vesting contract will not have an owner. So no one can interfere with the vesting. - vesting.renounceOwnership(); - } else { - vesting.transferOwnership(_vestingContractOwner); - } - - // deploy the private offer + // update currency receiver to be the vesting contract PrivateOfferArguments memory calldataArguments = _arguments; calldataArguments.tokenReceiver = address(vesting); - // update currency receiver to be the vesting contract + // deploy the private offer address privateOffer = _deployPrivateOffer(_rawSalt, calldataArguments); require(_arguments.token.balanceOf(address(vesting)) == _arguments.tokenAmount, "Execution failed"); @@ -131,7 +121,7 @@ contract PrivateOfferFactory { address vestingAddress = vestingCloneFactory.predictCloneAddress( salt, trustedForwarder, - address(this), + address(vestingCloneFactory), address(_arguments.token) ); diff --git a/contracts/factories/VestingCloneFactory.sol b/contracts/factories/VestingCloneFactory.sol index 65df7bde..bef4c394 100644 --- a/contracts/factories/VestingCloneFactory.sol +++ b/contracts/factories/VestingCloneFactory.sol @@ -26,7 +26,7 @@ contract VestingCloneFactory is CloneFactory { address _trustedForwarder, address _owner, address _token - ) external returns (address) { + ) public returns (address) { bytes32 salt = keccak256(abi.encode(_rawSalt, _trustedForwarder, _owner, _token)); address clone = Clones.cloneDeterministic(implementation, salt); Vesting vesting = Vesting(clone); @@ -36,6 +36,37 @@ contract VestingCloneFactory is CloneFactory { return clone; } + function createVestingCloneWithLockupPlan( + bytes32 _rawSalt, + address _trustedForwarder, + address _owner, + address _token, + uint256 _allocation, + address _beneficiary, + uint64 _start, + uint64 _cliff, + uint64 _duration + ) external returns (address) { + // deploy the vesting contract + Vesting vesting = Vesting(createVestingClone(_rawSalt, _trustedForwarder, address(this), _token)); + + // create the vesting plan + vesting.createVesting(_allocation, _beneficiary, _start, _cliff, _duration, false); // this plan is not mintable + + // remove the manager role from the vesting contract + vesting.removeManager(address(this)); + + // transfer ownership of the vesting contract + if (_owner == address(0)) { + // if the owner is 0, the vesting contract will not have an owner. So no one can interfere with the vesting. + vesting.renounceOwnership(); + } else { + vesting.transferOwnership(_owner); + } + + return address(vesting); + } + /** * Calculate the address a clone will have using the given parameters * @param _rawSalt value that influences the address of the clone, but not the initialization