-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge to master branch 4 year vestings & Fix tiny position when closing
Merge 4 year vesting contracts and fix tiny positions when closing to master branch
- Loading branch information
Showing
38 changed files
with
2,812 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Extend Staking | ||
|
||
on: | ||
schedule: | ||
# The cron job should run every four weeks from the creation of four year vesting contract | ||
# and only for 52 weeks | ||
- cron: "30 10 * * FRI" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Setup node.js | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: "14.x" | ||
- name: Cache node modules | ||
uses: actions/cache@v2 | ||
env: | ||
cache-name: cache-node-modules | ||
with: | ||
# npm cache files are stored in `~/.npm` on Linux/macOS | ||
path: ~/.npm | ||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-build-${{ env.cache-name }}- | ||
${{ runner.os }}-build- | ||
${{ runner.os }}- | ||
- name: Cache compiler installations | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.solcx | ||
~/.vvm | ||
key: ${{ runner.os }}-compiler-cache | ||
|
||
- name: Install python dependencies | ||
run: pip install -r requirements.txt | ||
|
||
- name: Extend Staking | ||
run: echo $REWARDS_CRON && brownie networks import network-config.yaml true && brownie run scripts/fouryearvesting/extendStakingCron.py --network=rsk-mainnet | ||
env: | ||
REWARDS_CRON: 1 | ||
FEE_CLAIMER: ${{secrets.FEE_CLAIMER}} |
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,72 @@ | ||
pragma solidity ^0.5.17; | ||
pragma experimental ABIEncoderV2; | ||
|
||
import "../../../openzeppelin/Ownable.sol"; | ||
import "../../../interfaces/IERC20.sol"; | ||
import "../../Staking/Staking.sol"; | ||
import "../../IFeeSharingProxy.sol"; | ||
import "../../ApprovalReceiver.sol"; | ||
import "./FourYearVestingStorage.sol"; | ||
import "../../../proxy/UpgradableProxy.sol"; | ||
import "../../../openzeppelin/Address.sol"; | ||
|
||
/** | ||
* @title Four Year Vesting Contract. | ||
* | ||
* @notice A four year vesting contract. | ||
* | ||
* @dev Vesting contract is upgradable, | ||
* Make sure the vesting owner is multisig otherwise it will be | ||
* catastrophic. | ||
* */ | ||
contract FourYearVesting is FourYearVestingStorage, UpgradableProxy { | ||
/** | ||
* @notice Setup the vesting schedule. | ||
* @param _logic The address of logic contract. | ||
* @param _SOV The SOV token address. | ||
* @param _tokenOwner The owner of the tokens. | ||
* @param _feeSharingProxy Fee sharing proxy address. | ||
* @param _extendDurationFor Duration till the unlocked tokens are extended. | ||
* */ | ||
constructor( | ||
address _logic, | ||
address _SOV, | ||
address _stakingAddress, | ||
address _tokenOwner, | ||
address _feeSharingProxy, | ||
uint256 _extendDurationFor | ||
) public { | ||
require(Address.isContract(_logic), "_logic not a contract"); | ||
require(_SOV != address(0), "SOV address invalid"); | ||
require(Address.isContract(_SOV), "_SOV not a contract"); | ||
require(_stakingAddress != address(0), "staking address invalid"); | ||
require(Address.isContract(_stakingAddress), "_stakingAddress not a contract"); | ||
require(_tokenOwner != address(0), "token owner address invalid"); | ||
require(_feeSharingProxy != address(0), "feeSharingProxy address invalid"); | ||
require(Address.isContract(_feeSharingProxy), "_feeSharingProxy not a contract"); | ||
require((_extendDurationFor % FOUR_WEEKS) == 0, "invalid duration"); | ||
|
||
_setImplementation(_logic); | ||
SOV = IERC20(_SOV); | ||
staking = Staking(_stakingAddress); | ||
tokenOwner = _tokenOwner; | ||
feeSharingProxy = IFeeSharingProxy(_feeSharingProxy); | ||
maxInterval = 18 * FOUR_WEEKS; | ||
extendDurationFor = _extendDurationFor; | ||
} | ||
|
||
/** | ||
* @notice Set address of the implementation - vesting owner. | ||
* @dev Overriding setImplementation function of UpgradableProxy. The logic can only be | ||
* modified when both token owner and veting owner approve. Since | ||
* setImplementation can only be called by vesting owner, we also need to check | ||
* if the new logic is already approved by the token owner. | ||
* @param _implementation Address of the implementation. Must match with what is set by token owner. | ||
* */ | ||
function setImplementation(address _implementation) public onlyProxyOwner { | ||
require(Address.isContract(_implementation), "_implementation not a contract"); | ||
require(newImplementation == _implementation, "address mismatch"); | ||
_setImplementation(_implementation); | ||
newImplementation = address(0); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
contracts/governance/Vesting/fouryear/FourYearVestingFactory.sol
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,52 @@ | ||
pragma solidity ^0.5.17; | ||
|
||
import "../../../openzeppelin/Ownable.sol"; | ||
import "./FourYearVesting.sol"; | ||
import "./IFourYearVestingFactory.sol"; | ||
|
||
/** | ||
* @title Four Year Vesting Factory: Contract to deploy four year vesting contracts. | ||
* @notice Factory pattern allows to create multiple instances | ||
* of the same contract and keep track of them easier. | ||
* */ | ||
contract FourYearVestingFactory is IFourYearVestingFactory, Ownable { | ||
/// @dev Added an event to keep track of the vesting contract created for a token owner | ||
event FourYearVestingCreated(address indexed tokenOwner, address indexed vestingAddress); | ||
|
||
/** | ||
* @notice Deploys four year vesting contract. | ||
* @param _SOV the address of SOV token. | ||
* @param _staking The address of staking contract. | ||
* @param _tokenOwner The owner of the tokens. | ||
* @param _feeSharing The address of fee sharing contract. | ||
* @param _vestingOwnerMultisig The address of an owner of vesting contract. | ||
* @dev _vestingOwnerMultisig should ALWAYS be multisig. | ||
* @param _fourYearVestingLogic The implementation contract. | ||
* @param _extendDurationFor Duration till the unlocked tokens are extended. | ||
* @return The four year vesting contract address. | ||
* */ | ||
function deployFourYearVesting( | ||
address _SOV, | ||
address _staking, | ||
address _tokenOwner, | ||
address _feeSharing, | ||
address _vestingOwnerMultisig, | ||
address _fourYearVestingLogic, | ||
uint256 _extendDurationFor | ||
) external onlyOwner returns (address) { | ||
address fourYearVesting = | ||
address( | ||
new FourYearVesting( | ||
_fourYearVestingLogic, | ||
_SOV, | ||
_staking, | ||
_tokenOwner, | ||
_feeSharing, | ||
_extendDurationFor | ||
) | ||
); | ||
Ownable(fourYearVesting).transferOwnership(_vestingOwnerMultisig); | ||
emit FourYearVestingCreated(_tokenOwner, fourYearVesting); | ||
return fourYearVesting; | ||
} | ||
} |
Oops, something went wrong.