View Source: contracts/governance/Vesting/VestingRegistryLogic.sol
↗ Extends: VestingRegistryStorage
Events
event SOVTransferred(address indexed receiver, uint256 amount);
event VestingCreated(address indexed tokenOwner, address vesting, uint256 cliff, uint256 duration, uint256 amount, uint256 vestingCreationType);
event TeamVestingCreated(address indexed tokenOwner, address vesting, uint256 cliff, uint256 duration, uint256 amount, uint256 vestingCreationType);
event TokensStaked(address indexed vesting, uint256 amount);
event VestingCreationAndTypesSet(address indexed vesting, struct VestingRegistryStorage.VestingCreationAndTypeDetails vestingCreationAndType);
- initialize(address _vestingFactory, address _SOV, address _staking, address _feeSharingCollector, address _vestingOwner, address _lockedSOV, address[] _vestingRegistries)
- setVestingFactory(address _vestingFactory)
- _setVestingFactory(address _vestingFactory)
- transferSOV(address _receiver, uint256 _amount)
- addDeployedVestings(address[] _tokenOwners, uint256[] _vestingCreationTypes)
- addFourYearVestings(address[] _tokenOwners, address[] _vestingAddresses)
- createVesting(address _tokenOwner, uint256 _amount, uint256 _cliff, uint256 _duration)
- createVestingAddr(address _tokenOwner, uint256 _amount, uint256 _cliff, uint256 _duration, uint256 _vestingCreationType)
- createTeamVesting(address _tokenOwner, uint256 _amount, uint256 _cliff, uint256 _duration, uint256 _vestingCreationType)
- stakeTokens(address _vesting, uint256 _amount)
- getVesting(address _tokenOwner)
- getVestingAddr(address _tokenOwner, uint256 _cliff, uint256 _duration, uint256 _vestingCreationType)
- getTeamVesting(address _tokenOwner, uint256 _cliff, uint256 _duration, uint256 _vestingCreationType)
- isTeamVesting(address _vestingAddress)
- registerVestingToVestingCreationAndTypes(address[] _vestingAddresses, struct VestingRegistryStorage.VestingCreationAndTypeDetails[] _vestingCreationAndTypes)
- _getOrCreateVesting(address _tokenOwner, uint256 _cliff, uint256 _duration, uint256 _type, uint256 _vestingCreationType)
- _addDeployedVestings(address _tokenOwner, uint256 _vestingCreationType)
- getVestingsOf(address _tokenOwner)
- getVestingDetails(address _vestingAddress)
- isVestingAddress(address _vestingAddress)
Replace constructor with initialize function for Upgradable Contracts This function will be called only once by the owner
function initialize(address _vestingFactory, address _SOV, address _staking, address _feeSharingCollector, address _vestingOwner, address _lockedSOV, address[] _vestingRegistries) external nonpayable onlyOwner initializer
Arguments
Name | Type | Description |
---|---|---|
_vestingFactory | address | |
_SOV | address | |
_staking | address | |
_feeSharingCollector | address | |
_vestingOwner | address | |
_lockedSOV | address | |
_vestingRegistries | address[] |
Source Code
function initialize(
address _vestingFactory,
address _SOV,
address _staking,
address _feeSharingCollector,
address _vestingOwner,
address _lockedSOV,
address[] calldata _vestingRegistries
) external onlyOwner initializer {
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");
require(_lockedSOV != address(0), "LockedSOV address invalid");
_setVestingFactory(_vestingFactory);
SOV = _SOV;
staking = _staking;
feeSharingCollector = _feeSharingCollector;
vestingOwner = _vestingOwner;
lockedSOV = LockedSOV(_lockedSOV);
for (uint256 i = 0; i < _vestingRegistries.length; i++) {
require(_vestingRegistries[i] != address(0), "Vesting registry address invalid");
vestingRegistries.push(IVestingRegistry(_vestingRegistries[i]));
}
}
sets vesting factory address
function setVestingFactory(address _vestingFactory) external nonpayable onlyOwner
Arguments
Name | Type | Description |
---|---|---|
_vestingFactory | address | the address of vesting factory contract |
Source Code
function setVestingFactory(address _vestingFactory) external onlyOwner {
_setVestingFactory(_vestingFactory);
}
Internal function that sets vesting factory address
function _setVestingFactory(address _vestingFactory) internal nonpayable
Arguments
Name | Type | Description |
---|---|---|
_vestingFactory | address | the address of vesting factory contract |
Source Code
function _setVestingFactory(address _vestingFactory) internal {
require(_vestingFactory != address(0), "vestingFactory address invalid");
vestingFactory = IVestingFactory(_vestingFactory);
}
transfers SOV tokens to given address
function transferSOV(address _receiver, uint256 _amount) external 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) external onlyOwner {
require(_receiver != address(0), "receiver address invalid");
require(_amount != 0, "amount invalid");
require(IERC20(SOV).transfer(_receiver, _amount), "transfer failed");
emit SOVTransferred(_receiver, _amount);
}
adds vestings that were deployed in previous vesting registries
function addDeployedVestings(address[] _tokenOwners, uint256[] _vestingCreationTypes) external nonpayable onlyAuthorized
Arguments
Name | Type | Description |
---|---|---|
_tokenOwners | address[] | |
_vestingCreationTypes | uint256[] |
Source Code
function addDeployedVestings(
address[] calldata _tokenOwners,
uint256[] calldata _vestingCreationTypes
) external onlyAuthorized {
for (uint256 i = 0; i < _tokenOwners.length; i++) {
require(_tokenOwners[i] != address(0), "token owner cannot be 0 address");
require(_vestingCreationTypes[i] > 0, "vesting creation type must be greater than 0");
_addDeployedVestings(_tokenOwners[i], _vestingCreationTypes[i]);
}
}
adds four year vestings to vesting registry logic
function addFourYearVestings(address[] _tokenOwners, address[] _vestingAddresses) external nonpayable onlyAuthorized
Arguments
Name | Type | Description |
---|---|---|
_tokenOwners | address[] | array of token owners |
_vestingAddresses | address[] | array of vesting addresses |
Source Code
function addFourYearVestings(
address[] calldata _tokenOwners,
address[] calldata _vestingAddresses
) external onlyAuthorized {
require(_tokenOwners.length == _vestingAddresses.length, "arrays mismatch");
uint256 vestingCreationType = 4;
uint256 cliff = 4 weeks;
uint256 duration = 156 weeks;
for (uint256 i = 0; i < _tokenOwners.length; i++) {
require(!isVesting[_vestingAddresses[i]], "vesting exists");
require(_tokenOwners[i] != address(0), "token owner cannot be 0 address");
require(_vestingAddresses[i] != address(0), "vesting cannot be 0 address");
uint256 uid =
uint256(
keccak256(
abi.encodePacked(
_tokenOwners[i],
uint256(VestingType.Vesting),
cliff,
duration,
vestingCreationType
)
)
);
vestings[uid] = Vesting(
uint256(VestingType.Vesting),
vestingCreationType,
_vestingAddresses[i]
);
vestingsOf[_tokenOwners[i]].push(uid);
isVesting[_vestingAddresses[i]] = true;
}
}
creates Vesting contract
function createVesting(address _tokenOwner, uint256 _amount, uint256 _cliff, uint256 _duration) external 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
) external onlyAuthorized {
createVestingAddr(_tokenOwner, _amount, _cliff, _duration, 3);
}
creates Vesting contract
function createVestingAddr(address _tokenOwner, uint256 _amount, uint256 _cliff, uint256 _duration, uint256 _vestingCreationType) 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 |
_vestingCreationType | uint256 | the type of vesting created(e.g. Origin, Bug Bounty etc.) |
Source Code
function createVestingAddr(
address _tokenOwner,
uint256 _amount,
uint256 _cliff,
uint256 _duration,
uint256 _vestingCreationType
) public onlyAuthorized {
address vesting =
_getOrCreateVesting(
_tokenOwner,
_cliff,
_duration,
uint256(VestingType.Vesting),
_vestingCreationType
);
emit VestingCreated(
_tokenOwner,
vesting,
_cliff,
_duration,
_amount,
_vestingCreationType
);
}
creates Team Vesting contract
function createTeamVesting(address _tokenOwner, uint256 _amount, uint256 _cliff, uint256 _duration, uint256 _vestingCreationType) external 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 |
_vestingCreationType | uint256 | the type of vesting created(e.g. Origin, Bug Bounty etc.) |
Source Code
function createTeamVesting(
address _tokenOwner,
uint256 _amount,
uint256 _cliff,
uint256 _duration,
uint256 _vestingCreationType
) external onlyAuthorized {
address vesting =
_getOrCreateVesting(
_tokenOwner,
_cliff,
_duration,
uint256(VestingType.TeamVesting),
_vestingCreationType
);
emit TeamVestingCreated(
_tokenOwner,
vesting,
_cliff,
_duration,
_amount,
_vestingCreationType
);
}
stakes tokens according to the vesting schedule
function stakeTokens(address _vesting, uint256 _amount) external 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) external 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);
}
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 getVestingAddr(_tokenOwner, lockedSOV.cliff(), lockedSOV.duration(), 3);
}
public function that returns vesting contract address for the given token owner, cliff, duration
function getVestingAddr(address _tokenOwner, uint256 _cliff, uint256 _duration, uint256 _vestingCreationType) public view
returns(address)
Arguments
Name | Type | Description |
---|---|---|
_tokenOwner | address | |
_cliff | uint256 | |
_duration | uint256 | |
_vestingCreationType | uint256 |
Source Code
function getVestingAddr(
address _tokenOwner,
uint256 _cliff,
uint256 _duration,
uint256 _vestingCreationType
) public view returns (address) {
uint256 type_ = uint256(VestingType.Vesting);
uint256 uid =
uint256(
keccak256(
abi.encodePacked(_tokenOwner, type_, _cliff, _duration, _vestingCreationType)
)
);
return vestings[uid].vestingAddress;
}
returns team vesting contract address for the given token owner, cliff, duration
function getTeamVesting(address _tokenOwner, uint256 _cliff, uint256 _duration, uint256 _vestingCreationType) public view
returns(address)
Arguments
Name | Type | Description |
---|---|---|
_tokenOwner | address | |
_cliff | uint256 | |
_duration | uint256 | |
_vestingCreationType | uint256 |
Source Code
function getTeamVesting(
address _tokenOwner,
uint256 _cliff,
uint256 _duration,
uint256 _vestingCreationType
) public view returns (address) {
uint256 type_ = uint256(VestingType.TeamVesting);
uint256 uid =
uint256(
keccak256(
abi.encodePacked(_tokenOwner, type_, _cliff, _duration, _vestingCreationType)
)
);
return vestings[uid].vestingAddress;
}
check if the specific vesting address is team vesting or not
function isTeamVesting(address _vestingAddress) external view
returns(bool)
Arguments
Name | Type | Description |
---|---|---|
_vestingAddress | address | address of vesting contract * |
Returns
true for teamVesting, false for normal vesting
Source Code
function isTeamVesting(address _vestingAddress) external view returns (bool) {
return (vestingCreationAndTypes[_vestingAddress].isSet &&
vestingCreationAndTypes[_vestingAddress].vestingType ==
uint32(VestingType.TeamVesting));
}
setter function to register existing vesting contract to vestingCreationAndTypes storage
function registerVestingToVestingCreationAndTypes(address[] _vestingAddresses, struct VestingRegistryStorage.VestingCreationAndTypeDetails[] _vestingCreationAndTypes) public nonpayable onlyAuthorized
Arguments
Name | Type | Description |
---|---|---|
_vestingAddresses | address[] | array of vesting address |
_vestingCreationAndTypes | struct VestingRegistryStorage.VestingCreationAndTypeDetails[] | array for VestingCreationAndTypeDetails struct |
Source Code
function registerVestingToVestingCreationAndTypes(
address[] memory _vestingAddresses,
VestingCreationAndTypeDetails[] memory _vestingCreationAndTypes
) public onlyAuthorized {
require(_vestingAddresses.length == _vestingCreationAndTypes.length, "Unmatched length");
for (uint256 i = 0; i < _vestingCreationAndTypes.length; i++) {
VestingCreationAndTypeDetails memory _vestingCreationAndType =
_vestingCreationAndTypes[i];
address _vestingAddress = _vestingAddresses[i];
vestingCreationAndTypes[_vestingAddress] = _vestingCreationAndType;
emit VestingCreationAndTypesSet(
_vestingAddress,
vestingCreationAndTypes[_vestingAddress]
);
}
}
Internal function to deploy Vesting/Team Vesting contract
function _getOrCreateVesting(address _tokenOwner, uint256 _cliff, uint256 _duration, uint256 _type, uint256 _vestingCreationType) internal nonpayable
returns(address)
Arguments
Name | Type | Description |
---|---|---|
_tokenOwner | address | the owner of the tokens |
_cliff | uint256 | the cliff in seconds |
_duration | uint256 | the total duration in seconds |
_type | uint256 | the type of vesting |
_vestingCreationType | uint256 | the type of vesting created(e.g. Origin, Bug Bounty etc.) |
Source Code
function _getOrCreateVesting(
address _tokenOwner,
uint256 _cliff,
uint256 _duration,
uint256 _type,
uint256 _vestingCreationType
) internal returns (address) {
address vesting;
uint256 uid =
uint256(
keccak256(
abi.encodePacked(_tokenOwner, _type, _cliff, _duration, _vestingCreationType)
)
);
if (vestings[uid].vestingAddress == address(0)) {
if (_type == 1) {
vesting = vestingFactory.deployVesting(
SOV,
staking,
_tokenOwner,
_cliff,
_duration,
feeSharingCollector,
_tokenOwner
);
} else {
vesting = vestingFactory.deployTeamVesting(
SOV,
staking,
_tokenOwner,
_cliff,
_duration,
feeSharingCollector,
vestingOwner
);
}
vestings[uid] = Vesting(_type, _vestingCreationType, vesting);
vestingsOf[_tokenOwner].push(uid);
isVesting[vesting] = true;
vestingCreationAndTypes[vesting] = VestingCreationAndTypeDetails({
isSet: true,
vestingType: uint32(_type),
vestingCreationType: uint128(_vestingCreationType)
});
emit VestingCreationAndTypesSet(vesting, vestingCreationAndTypes[vesting]);
}
return vestings[uid].vestingAddress;
}
stores the addresses of Vesting contracts from all three previous versions of Vesting Registry
function _addDeployedVestings(address _tokenOwner, uint256 _vestingCreationType) internal nonpayable
Arguments
Name | Type | Description |
---|---|---|
_tokenOwner | address | |
_vestingCreationType | uint256 |
Source Code
function _addDeployedVestings(address _tokenOwner, uint256 _vestingCreationType) internal {
uint256 uid;
uint256 i = _vestingCreationType - 1;
address vestingAddress = vestingRegistries[i].getVesting(_tokenOwner);
if (vestingAddress != address(0)) {
VestingLogic vesting = VestingLogic(vestingAddress);
uid = uint256(
keccak256(
abi.encodePacked(
_tokenOwner,
uint256(VestingType.Vesting),
vesting.cliff(),
vesting.duration(),
_vestingCreationType
)
)
);
vestings[uid] = Vesting(
uint256(VestingType.Vesting),
_vestingCreationType,
vestingAddress
);
vestingsOf[_tokenOwner].push(uid);
isVesting[vestingAddress] = true;
}
address teamVestingAddress = vestingRegistries[i].getTeamVesting(_tokenOwner);
if (teamVestingAddress != address(0)) {
VestingLogic vesting = VestingLogic(teamVestingAddress);
uid = uint256(
keccak256(
abi.encodePacked(
_tokenOwner,
uint256(VestingType.TeamVesting),
vesting.cliff(),
vesting.duration(),
_vestingCreationType
)
)
);
vestings[uid] = Vesting(
uint256(VestingType.TeamVesting),
_vestingCreationType,
teamVestingAddress
);
vestingsOf[_tokenOwner].push(uid);
isVesting[teamVestingAddress] = true;
}
}
returns all vesting details for the given token owner
function getVestingsOf(address _tokenOwner) external view
returns(struct VestingRegistryStorage.Vesting[])
Arguments
Name | Type | Description |
---|---|---|
_tokenOwner | address |
Source Code
function getVestingsOf(address _tokenOwner) external view returns (Vesting[] memory) {
uint256[] memory vestingIds = vestingsOf[_tokenOwner];
uint256 length = vestingIds.length;
Vesting[] memory _vestings = new Vesting[](vestingIds.length);
for (uint256 i = 0; i < length; i++) {
_vestings[i] = vestings[vestingIds[i]];
}
return _vestings;
}
returns cliff and duration for Vesting & TeamVesting contracts
function getVestingDetails(address _vestingAddress) external view
returns(cliff uint256, duration uint256)
Arguments
Name | Type | Description |
---|---|---|
_vestingAddress | address |
Source Code
function getVestingDetails(address _vestingAddress)
external
view
returns (uint256 cliff, uint256 duration)
{
VestingLogic vesting = VestingLogic(_vestingAddress);
return (vesting.cliff(), vesting.duration());
}
returns if the address is a vesting address
function isVestingAddress(address _vestingAddress) external view
returns(isVestingAddr bool)
Arguments
Name | Type | Description |
---|---|---|
_vestingAddress | address |
Source Code
function isVestingAddress(address _vestingAddress) external view returns (bool isVestingAddr) {
return isVesting[_vestingAddress];
}
- Address
- Administered
- AdminRole
- AdvancedToken
- AdvancedTokenStorage
- Affiliates
- AffiliatesEvents
- ApprovalReceiver
- BProPriceFeed
- CheckpointsShared
- Constants
- Context
- DevelopmentFund
- DummyContract
- EnumerableAddressSet
- EnumerableBytes32Set
- EnumerableBytes4Set
- ERC20
- ERC20Detailed
- ErrorDecoder
- Escrow
- EscrowReward
- FeedsLike
- FeesEvents
- FeeSharingCollector
- FeeSharingCollectorProxy
- FeeSharingCollectorStorage
- FeesHelper
- FourYearVesting
- FourYearVestingFactory
- FourYearVestingLogic
- FourYearVestingStorage
- GenericTokenSender
- GovernorAlpha
- GovernorVault
- IApproveAndCall
- IChai
- IContractRegistry
- IConverterAMM
- IERC1820Registry
- IERC20_
- IERC20
- IERC777
- IERC777Recipient
- IERC777Sender
- IFeeSharingCollector
- IFourYearVesting
- IFourYearVestingFactory
- IFunctionsList
- ILiquidityMining
- ILiquidityPoolV1Converter
- ILoanPool
- ILoanToken
- ILoanTokenLogicBeacon
- ILoanTokenLogicModules
- ILoanTokenLogicProxy
- ILoanTokenModules
- ILoanTokenWRBTC
- ILockedSOV
- IMoCState
- IModulesProxyRegistry
- Initializable
- InterestUser
- IPot
- IPriceFeeds
- IPriceFeedsExt
- IProtocol
- IRSKOracle
- ISovryn
- ISovrynSwapNetwork
- IStaking
- ISwapsImpl
- ITeamVesting
- ITimelock
- IV1PoolOracle
- IVesting
- IVestingFactory
- IVestingRegistry
- IWrbtc
- IWrbtcERC20
- LenderInterestStruct
- LiquidationHelper
- LiquidityMining
- LiquidityMiningConfigToken
- LiquidityMiningProxy
- LiquidityMiningStorage
- LoanClosingsEvents
- LoanClosingsLiquidation
- LoanClosingsRollover
- LoanClosingsShared
- LoanClosingsWith
- LoanClosingsWithoutInvariantCheck
- LoanInterestStruct
- LoanMaintenance
- LoanMaintenanceEvents
- LoanOpenings
- LoanOpeningsEvents
- LoanParamsStruct
- LoanSettings
- LoanSettingsEvents
- LoanStruct
- LoanToken
- LoanTokenBase
- LoanTokenLogicBeacon
- LoanTokenLogicLM
- LoanTokenLogicProxy
- LoanTokenLogicStandard
- LoanTokenLogicStorage
- LoanTokenLogicWrbtc
- LoanTokenSettingsLowerAdmin
- LockedSOV
- MarginTradeStructHelpers
- Medianizer
- ModuleCommonFunctionalities
- ModulesCommonEvents
- ModulesProxy
- ModulesProxyRegistry
- MultiSigKeyHolders
- MultiSigWallet
- Mutex
- Objects
- OrderStruct
- OrigingVestingCreator
- OriginInvestorsClaim
- Ownable
- Pausable
- PausableOz
- PreviousLoanToken
- PreviousLoanTokenSettingsLowerAdmin
- PriceFeedRSKOracle
- PriceFeeds
- PriceFeedsLocal
- PriceFeedsMoC
- PriceFeedV1PoolOracle
- ProtocolAffiliatesInterface
- ProtocolLike
- ProtocolSettings
- ProtocolSettingsEvents
- ProtocolSettingsLike
- ProtocolSwapExternalInterface
- ProtocolTokenUser
- Proxy
- ProxyOwnable
- ReentrancyGuard
- RewardHelper
- RSKAddrValidator
- SafeERC20
- SafeMath
- SafeMath96
- setGet
- SharedReentrancyGuard
- SignedSafeMath
- SOV
- sovrynProtocol
- StakingAdminModule
- StakingGovernanceModule
- StakingInterface
- StakingProxy
- StakingRewards
- StakingRewardsProxy
- StakingRewardsStorage
- StakingShared
- StakingStakeModule
- StakingStorageModule
- StakingStorageShared
- StakingVestingModule
- StakingWithdrawModule
- State
- SwapsEvents
- SwapsExternal
- SwapsImplLocal
- SwapsImplSovrynSwap
- SwapsUser
- TeamVesting
- Timelock
- TimelockHarness
- TimelockInterface
- TokenSender
- UpgradableProxy
- USDTPriceFeed
- Utils
- VaultController
- Vesting
- VestingCreator
- VestingFactory
- VestingLogic
- VestingRegistry
- VestingRegistry2
- VestingRegistry3
- VestingRegistryLogic
- VestingRegistryProxy
- VestingRegistryStorage
- VestingStorage
- WeightedStakingModule
- WRBTC