Skip to content

Latest commit

 

History

History
691 lines (570 loc) · 19.9 KB

VestingRegistry3.md

File metadata and controls

691 lines (570 loc) · 19.9 KB

VestingRegistry3.sol

View Source: contracts/governance/Vesting/VestingRegistry3.sol

↗ Extends: Ownable

VestingRegistry3 contract

Enums

VestingType

enum VestingType {
 TeamVesting,
 Vesting
}

Contract Members

Constants & Variables

contract IVestingFactory public vestingFactory;
address public SOV;
address public staking;
address public feeSharingCollector;
address public vestingOwner;
mapping(address => mapping(uint256 => address)) public vestingContracts;
mapping(address => bool) public admins;

Events

event SOVTransferred(address indexed receiver, uint256  amount);
event VestingCreated(address indexed tokenOwner, address  vesting, uint256  cliff, uint256  duration, uint256  amount);
event TeamVestingCreated(address indexed tokenOwner, address  vesting, uint256  cliff, uint256  duration, uint256  amount);
event TokensStaked(address indexed vesting, uint256  amount);
event AdminAdded(address  admin);
event AdminRemoved(address  admin);

Modifiers

onlyAuthorized

Throws if called by any account other than the owner or admin.

modifier onlyAuthorized() internal

Functions


constructor

function (address _vestingFactory, address _SOV, address _staking, address _feeSharingCollector, address _vestingOwner) public nonpayable

Arguments

Name Type Description
_vestingFactory address
_SOV address
_staking address
_feeSharingCollector address
_vestingOwner address
Source Code
constructor(
        address _vestingFactory,
        address _SOV,
        address _staking,
        address _feeSharingCollector,
        address _vestingOwner
    ) public {
        require(_SOV != address(0), "SOV address invalid");
        require(_staking != address(0), "staking address invalid");
        require(_feeSharingCollector != address(0), "feeSharingCollector address invalid");
        require(_vestingOwner != address(0), "vestingOwner address invalid");

        _setVestingFactory(_vestingFactory);

        SOV = _SOV;
        staking = _staking;
        feeSharingCollector = _feeSharingCollector;
        vestingOwner = _vestingOwner;
    }

addAdmin

function addAdmin(address _admin) public nonpayable onlyOwner 

Arguments

Name Type Description
_admin address
Source Code
function addAdmin(address _admin) public onlyOwner {
        admins[_admin] = true;
        emit AdminAdded(_admin);
    }

removeAdmin

function removeAdmin(address _admin) public nonpayable onlyOwner 

Arguments

Name Type Description
_admin address
Source Code
function removeAdmin(address _admin) public onlyOwner {
        admins[_admin] = false;
        emit AdminRemoved(_admin);
    }

setVestingFactory

sets vesting factory address

function setVestingFactory(address _vestingFactory) public nonpayable onlyOwner 

Arguments

Name Type Description
_vestingFactory address the address of vesting factory contract
Source Code
function setVestingFactory(address _vestingFactory) public onlyOwner {
        _setVestingFactory(_vestingFactory);
    }

_setVestingFactory

function _setVestingFactory(address _vestingFactory) internal nonpayable

Arguments

Name Type Description
_vestingFactory address
Source Code
function _setVestingFactory(address _vestingFactory) internal {
        require(_vestingFactory != address(0), "vestingFactory address invalid");
        vestingFactory = IVestingFactory(_vestingFactory);
    }

transferSOV

transfers SOV tokens to given address

function transferSOV(address _receiver, uint256 _amount) public nonpayable onlyOwner 

Arguments

Name Type Description
_receiver address the address of the SOV receiver
_amount uint256 the amount to be transferred
Source Code
function transferSOV(address _receiver, uint256 _amount) public onlyOwner {
        require(_receiver != address(0), "receiver address invalid");
        require(_amount != 0, "amount invalid");

        IERC20(SOV).transfer(_receiver, _amount);
        emit SOVTransferred(_receiver, _amount);
    }

createVesting

creates Vesting contract

function createVesting(address _tokenOwner, uint256 _amount, uint256 _cliff, uint256 _duration) public nonpayable onlyAuthorized 

Arguments

Name Type Description
_tokenOwner address the owner of the tokens
_amount uint256 the amount to be staked
_cliff uint256 the cliff in seconds
_duration uint256 the total duration in seconds
Source Code
function createVesting(
        address _tokenOwner,
        uint256 _amount,
        uint256 _cliff,
        uint256 _duration
    ) public onlyAuthorized {
        address vesting = _getOrCreateVesting(_tokenOwner, _cliff, _duration);
        emit VestingCreated(_tokenOwner, vesting, _cliff, _duration, _amount);
    }

createTeamVesting

creates Team Vesting contract

function createTeamVesting(address _tokenOwner, uint256 _amount, uint256 _cliff, uint256 _duration) public nonpayable onlyAuthorized 

Arguments

Name Type Description
_tokenOwner address the owner of the tokens
_amount uint256 the amount to be staked
_cliff uint256 the cliff in seconds
_duration uint256 the total duration in seconds
Source Code
function createTeamVesting(
        address _tokenOwner,
        uint256 _amount,
        uint256 _cliff,
        uint256 _duration
    ) public onlyAuthorized {
        address vesting = _getOrCreateTeamVesting(_tokenOwner, _cliff, _duration);
        emit TeamVestingCreated(_tokenOwner, vesting, _cliff, _duration, _amount);
    }

stakeTokens

stakes tokens according to the vesting schedule

function stakeTokens(address _vesting, uint256 _amount) public nonpayable onlyAuthorized 

Arguments

Name Type Description
_vesting address the address of Vesting contract
_amount uint256 the amount of tokens to stake
Source Code
function stakeTokens(address _vesting, uint256 _amount) public onlyAuthorized {
        require(_vesting != address(0), "vesting address invalid");
        require(_amount > 0, "amount invalid");

        IERC20(SOV).approve(_vesting, _amount);
        IVesting(_vesting).stakeTokens(_amount);
        emit TokensStaked(_vesting, _amount);
    }

getVesting

returns vesting contract address for the given token owner

function getVesting(address _tokenOwner) public view
returns(address)

Arguments

Name Type Description
_tokenOwner address the owner of the tokens
Source Code
function getVesting(address _tokenOwner) public view returns (address) {
        return vestingContracts[_tokenOwner][uint256(VestingType.Vesting)];
    }

getTeamVesting

returns team vesting contract address for the given token owner

function getTeamVesting(address _tokenOwner) public view
returns(address)

Arguments

Name Type Description
_tokenOwner address the owner of the tokens
Source Code
function getTeamVesting(address _tokenOwner) public view returns (address) {
        return vestingContracts[_tokenOwner][uint256(VestingType.TeamVesting)];
    }

_getOrCreateVesting

function _getOrCreateVesting(address _tokenOwner, uint256 _cliff, uint256 _duration) internal nonpayable
returns(address)

Arguments

Name Type Description
_tokenOwner address
_cliff uint256
_duration uint256
Source Code
function _getOrCreateVesting(
        address _tokenOwner,
        uint256 _cliff,
        uint256 _duration
    ) internal returns (address) {
        uint256 type_ = uint256(VestingType.Vesting);
        if (vestingContracts[_tokenOwner][type_] == address(0)) {
            //TODO Owner of OwnerVesting contracts - the same address as tokenOwner
            address vesting =
                vestingFactory.deployVesting(
                    SOV,
                    staking,
                    _tokenOwner,
                    _cliff,
                    _duration,
                    feeSharingCollector,
                    _tokenOwner
                );
            vestingContracts[_tokenOwner][type_] = vesting;
        }
        return vestingContracts[_tokenOwner][type_];
    }

_getOrCreateTeamVesting

function _getOrCreateTeamVesting(address _tokenOwner, uint256 _cliff, uint256 _duration) internal nonpayable
returns(address)

Arguments

Name Type Description
_tokenOwner address
_cliff uint256
_duration uint256
Source Code
function _getOrCreateTeamVesting(
        address _tokenOwner,
        uint256 _cliff,
        uint256 _duration
    ) internal returns (address) {
        uint256 type_ = uint256(VestingType.TeamVesting);
        if (vestingContracts[_tokenOwner][type_] == address(0)) {
            address vesting =
                vestingFactory.deployTeamVesting(
                    SOV,
                    staking,
                    _tokenOwner,
                    _cliff,
                    _duration,
                    feeSharingCollector,
                    vestingOwner
                );
            vestingContracts[_tokenOwner][type_] = vesting;
        }
        return vestingContracts[_tokenOwner][type_];
    }

Contracts