Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 2.0.4 #15

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 133 additions & 0 deletions .openzeppelin/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -1777,6 +1777,139 @@
}
}
}
},
"f1b96b0b9753393d8af640a936efa684a1660ed32aae6c968b1a1bf6f908e3b8": {
"address": "0x7A2bbAe82bd08196d64Ff01c53788d942CF5F7b2",
"txHash": "0x8fc693195467e6a5d9b38856ee0b935ce7e508c5efe5719f7193b3e1d3743baf",
"layout": {
"storage": [
{
"contract": "Initializable",
"label": "initialized",
"type": "t_bool",
"src": "..\\@openzeppelin\\upgrades\\contracts\\Initializable.sol:21"
},
{
"contract": "Initializable",
"label": "initializing",
"type": "t_bool",
"src": "..\\@openzeppelin\\upgrades\\contracts\\Initializable.sol:26"
},
{
"contract": "Initializable",
"label": "______gap",
"type": "t_array(t_uint256)50_storage",
"src": "..\\@openzeppelin\\upgrades\\contracts\\Initializable.sol:61"
},
{
"contract": "Ownable",
"label": "_owner",
"type": "t_address",
"src": "..\\@openzeppelin\\contracts-ethereum-package\\contracts\\ownership\\Ownable.sol:17"
},
{
"contract": "Ownable",
"label": "______gap",
"type": "t_array(t_uint256)50_storage",
"src": "..\\@openzeppelin\\contracts-ethereum-package\\contracts\\ownership\\Ownable.sol:80"
},
{
"contract": "RariGovernanceTokenUniswapDistributor",
"label": "disabled",
"type": "t_bool",
"src": "..\\project:\\contracts\\RariGovernanceTokenUniswapDistributor.sol:41"
},
{
"contract": "RariGovernanceTokenUniswapDistributor",
"label": "rariGovernanceToken",
"type": "t_contract(RariGovernanceToken)2685",
"src": "..\\project:\\contracts\\RariGovernanceTokenUniswapDistributor.sol:73"
},
{
"contract": "RariGovernanceTokenUniswapDistributor",
"label": "distributionStartBlock",
"type": "t_uint256",
"src": "..\\project:\\contracts\\RariGovernanceTokenUniswapDistributor.sol:88"
},
{
"contract": "RariGovernanceTokenUniswapDistributor",
"label": "distributionEndBlock",
"type": "t_uint256",
"src": "..\\project:\\contracts\\RariGovernanceTokenUniswapDistributor.sol:93"
},
{
"contract": "RariGovernanceTokenUniswapDistributor",
"label": "totalStaked",
"type": "t_uint256",
"src": "..\\project:\\contracts\\RariGovernanceTokenUniswapDistributor.sol:119"
},
{
"contract": "RariGovernanceTokenUniswapDistributor",
"label": "stakingBalances",
"type": "t_mapping(t_address,t_uint256)",
"src": "..\\project:\\contracts\\RariGovernanceTokenUniswapDistributor.sol:124"
},
{
"contract": "RariGovernanceTokenUniswapDistributor",
"label": "_rgtPerLpTokenAtLastSpeedUpdate",
"type": "t_uint256",
"src": "..\\project:\\contracts\\RariGovernanceTokenUniswapDistributor.sol:167"
},
{
"contract": "RariGovernanceTokenUniswapDistributor",
"label": "_rgtDistributedAtLastSpeedUpdate",
"type": "t_uint256",
"src": "..\\project:\\contracts\\RariGovernanceTokenUniswapDistributor.sol:172"
},
{
"contract": "RariGovernanceTokenUniswapDistributor",
"label": "_rgtPerLpTokenAtLastDistribution",
"type": "t_mapping(t_address,t_uint256)",
"src": "..\\project:\\contracts\\RariGovernanceTokenUniswapDistributor.sol:177"
},
{
"contract": "RariGovernanceTokenUniswapDistributor",
"label": "_rgtDistributedByHolder",
"type": "t_mapping(t_address,t_uint256)",
"src": "..\\project:\\contracts\\RariGovernanceTokenUniswapDistributor.sol:220"
},
{
"contract": "RariGovernanceTokenUniswapDistributor",
"label": "_rgtClaimedByHolder",
"type": "t_mapping(t_address,t_uint256)",
"src": "..\\project:\\contracts\\RariGovernanceTokenUniswapDistributor.sol:225"
},
{
"contract": "RariGovernanceTokenUniswapDistributor",
"label": "rgtEthUniswapV2Pair",
"type": "t_contract(IERC20)1407",
"src": "..\\project:\\contracts\\RariGovernanceTokenUniswapDistributor.sol:331"
}
],
"types": {
"t_bool": {
"label": "bool"
},
"t_contract(RariGovernanceToken)2685": {
"label": "contract RariGovernanceToken"
},
"t_uint256": {
"label": "uint256"
},
"t_mapping(t_address,t_uint256)": {
"label": "mapping(address => uint256)"
},
"t_address": {
"label": "address"
},
"t_contract(IERC20)1407": {
"label": "contract IERC20"
},
"t_array(t_uint256)50_storage": {
"label": "uint256[50]"
}
}
}
}
}
}
18 changes: 13 additions & 5 deletions contracts/RariGovernanceTokenUniswapDistributor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ contract RariGovernanceTokenUniswapDistributor is Initializable, Ownable {
rgtEthUniswapV2Pair = _rgtEthUniswapV2Pair;
}

/**
* @dev Sets the distribution end block since its modification in April 2022.
*/
function setDistributionEndBlock() external {
distributionEndBlock = distributionStartBlock + DISTRIBUTION_PERIOD;
}

/**
* @notice Boolean indicating if this contract is disabled.
*/
Expand Down Expand Up @@ -88,12 +95,12 @@ contract RariGovernanceTokenUniswapDistributor is Initializable, Ownable {
/**
* @notice Length in blocks of the distribution period.
*/
uint256 public constant DISTRIBUTION_PERIOD = 6500 * 365 * 3;
uint256 public constant DISTRIBUTION_PERIOD = 6500 * (365 + 60);

/**
* @notice Total and final quantity of all RGT to be distributed by the end of the period.
*/
uint256 public constant FINAL_RGT_DISTRIBUTION = uint256(568717819057309757517546) * 80 / 100;
uint256 public constant FINAL_RGT_DISTRIBUTION = uint256(568717819057309757517546) * 80 / 100 * (365 + 60) / (365 * 3);

/**
* @notice Returns the amount of RGT earned via liquidity mining at the given `blockNumber`.
Expand Down Expand Up @@ -309,12 +316,13 @@ contract RariGovernanceTokenUniswapDistributor is Initializable, Ownable {
}

/**
* @dev Forwards all RGT to a new RariGovernanceTokenUniswapDistributor contract.
* @dev Forwards RGT to a new RariGovernanceTokenUniswapDistributor contract.
* @param newContract The new RariGovernanceTokenUniswapDistributor contract.
* @param amount Amount of RGT to forward to the new contract.
*/
function upgrade(address newContract) external onlyOwner {
function upgrade(address newContract, uint256 amount) external onlyOwner {
require(disabled, "This governance token distributor contract must be disabled before it can be upgraded.");
rariGovernanceToken.transfer(newContract, rariGovernanceToken.balanceOf(address(this)));
rariGovernanceToken.transfer(newContract, amount);
}

/**
Expand Down
15 changes: 7 additions & 8 deletions migrations/2_deploy_contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ module.exports = async function(deployer, network, accounts) {
}

if (parseInt(process.env.UPGRADE_FROM_LAST_VERSION) > 0) {
// Deploy RariGovernanceTokenVestingV3
var rariGovernanceTokenVestingV3 = await deployProxy(RariGovernanceTokenVestingV3, [1635724800, web3.utils.toBN(100000).mul(web3.utils.toBN(1e18)).toString()], { deployer });

// Connect RariGovernanceToken to distributors and vesting contracts
await rariGovernanceTokenVestingV3.setGovernanceToken(RariGovernanceToken.address);

// Live network: transfer ownership of deployed contracts from the deployer to the owner
if (["live", "live-fork"].indexOf(network) >= 0) await rariGovernanceTokenVestingV3.transferOwnership(process.env.LIVE_GOVERNANCE_OWNER);
// Upgrade RariGovernanceTokenUniswapDistributor
await prepareUpgrade(process.env.UPGRADE_GOVERNANCE_TOKEN_SUSHISWAP_DISTRIBUTOR_ADDRESS, RariGovernanceTokenUniswapDistributor, { deployer });
// Need on-chain gov to call:
// ProxyAdmin.upgrade(RariGovernanceTokenUniswapDistributor, implementation)
// RariGovernanceTokenUniswapDistributor.setDisabled(true)
// RariGovernanceTokenUniswapDistributor.upgrade(Timelock, 568717819057309757517546 - (568717819057309757517546 * 80 / 100 / 3))
// RariGovernanceTokenUniswapDistributor.setDisabled(false)
} else {
if (!process.env.POOL_OWNER) return console.error("POOL_OWNER is missing for deployment");
if (!process.env.POOL_STABLE_MANAGER_ADDRESS || process.env.POOL_STABLE_MANAGER_ADDRESS == "0x0000000000000000000000000000000000000000") return console.error("POOL_STABLE_MANAGER_ADDRESS missing for deployment");
Expand Down