├── .env.example ├── .gitignore ├── .prettierrc ├── README.md ├── contracts ├── allocateStaking │ ├── CHNReward.sol │ └── CHNStaking.sol └── mocks │ ├── ERC20Mock.sol │ ├── ERC20Token.sol │ ├── FakeToken.sol │ ├── IErc20Token.sol │ └── SafeMath.sol ├── deploy └── 0001_deploy_verify.js ├── deployments └── rinkeby │ ├── .chainId │ ├── CHNReward.json │ ├── CHNStaking.json │ ├── CHNStaking_Implementation.json │ ├── CHNStaking_Proxy.json │ ├── DefaultProxyAdmin.json │ └── solcInputs │ ├── 1635d55d57a0a2552952c0d22586ed23.json │ └── f334450306d96ba77ba6ff912ec2b37b.json ├── hardhat.config.js ├── package.json ├── tasks ├── compileOne.js └── index.ts ├── test ├── Ethereum.js └── stakingAllocate.js └── yarn.lock /.env.example: -------------------------------------------------------------------------------- 1 | ETHERSCAN_API_KEY= 2 | RPC_URL= 3 | ACC_PRIVATE_KEY= 4 | CHN_ADDRESS= 5 | 6 | START_BLOCK= 7 | END_BONUS_BLOCK= 8 | REWARD_PER_BLOCK= 9 | MULTIPLIER= 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .vscode 3 | 4 | #Hardhat files 5 | cache 6 | artifacts 7 | .env 8 | yarn-error.log 9 | 10 | .idea/ -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 120 3 | } 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # staking - hardhat 2 | 3 | 1. Install package 4 | ``` 5 | yarn 6 | ``` 7 | 8 | 2. Create .env file from .env.example 9 | 3. Fill value in .env file: 10 | 1. `ACC_PRIVATE_KEY`: account deploy all contract and also set as a `admin` role. Need deposit ETH in it to deploy. 11 | 2. `CHN_ADDRESS`: address reward token, default is CHN address. 12 | 3. `REWARD_PER_BLOCK`: reward per block while staking contract running. It will be divided among users by weight. 13 | 4. `START_BLOCK`: Contract staking will start in this block 14 | 5. `MULTIPLIER`: In order to incentive user staking soon, staking contract will bonus reward from `START_BLOCK` to `END_BONUS_BLOCK`. 15 | 6. `END_BONUS_BLOCK`: Time bonus will end in this block. 16 | 4. Compile 17 | ``` 18 | yarn hardhat compile 19 | ``` 20 | 5. Deploy + verify: 21 | ``` 22 | yarn hardhat deploy --reset --tags deploy-verify --network rinkeby 23 | 24 | ``` 25 | 26 | 6. You need deposit reward into contract after deploy. -------------------------------------------------------------------------------- /contracts/allocateStaking/CHNReward.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.3; 4 | 5 | import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 6 | import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; 7 | import "@openzeppelin/contracts/access/Ownable.sol"; 8 | 9 | interface CHNStakingInterface { 10 | function claimRewardFromVault(address userAddress, uint256 pid) external returns (uint256); 11 | } 12 | 13 | contract CHNReward is Ownable { 14 | using SafeERC20 for IERC20; 15 | 16 | event Claim(address indexed user, uint256 indexed pid, uint256 reward); 17 | event GrantDAO(address indexed user, uint256 amount); 18 | event ChangeStaking(address indexed stake); 19 | 20 | IERC20 public rewardToken; 21 | CHNStakingInterface public staking; 22 | 23 | constructor(IERC20 _rewardToken) Ownable() { 24 | rewardToken = _rewardToken; 25 | } 26 | 27 | function changeStakingAdderss(address _staking) public onlyOwner { 28 | staking = CHNStakingInterface(_staking); 29 | emit ChangeStaking(_staking); 30 | } 31 | 32 | function claimReward(uint256 pid) public { 33 | uint256 rewardAmount = staking.claimRewardFromVault(msg.sender, pid); 34 | rewardToken.safeTransfer(address(msg.sender), rewardAmount); 35 | emit Claim(msg.sender, pid, rewardAmount); 36 | } 37 | 38 | function grantDAO(address user, uint256 amount) public onlyOwner { 39 | rewardToken.safeTransfer(user, amount); 40 | emit GrantDAO(user, amount); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /contracts/allocateStaking/CHNStaking.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.3; 4 | 5 | import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; 6 | import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; 7 | import "@openzeppelin/contracts/utils/math/SafeMath.sol"; 8 | import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; 9 | 10 | contract CHNStaking is OwnableUpgradeable { 11 | using SafeMath for uint256; 12 | using SafeERC20 for IERC20; 13 | // Info of each user. 14 | struct UserInfo { 15 | uint256 amount; 16 | uint256 rewardDebt; 17 | uint256 pendingTokenReward; 18 | } 19 | // Info of each pool. 20 | struct PoolInfo { 21 | IERC20 stakeToken; 22 | uint256 allocPoint; 23 | uint256 lastRewardBlock; 24 | uint256 accCHNPerShare; 25 | uint256 totalAmountStake; 26 | } 27 | 28 | event Add(address indexed stakToken, uint256 indexed allocPoint); 29 | event Set(uint256 indexed pid, uint256 indexed allocPoint); 30 | event Stake(address indexed user, uint256 indexed pid, uint256 amount); 31 | event Withdraw(address indexed user, uint256 indexed pid, uint256 amount, uint256 reward); 32 | event EmergencyWithdraw( 33 | address indexed user, 34 | uint256 indexed pid, 35 | uint256 amount 36 | ); 37 | event ClaimRewardFromVault(address indexed userAddress, uint256 indexed pid); 38 | 39 | /// @notice An event thats emitted when a delegate account's vote balance changes 40 | event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance); 41 | 42 | IERC20 public rewardToken; 43 | uint256 public rewardPerBlock; 44 | PoolInfo[] public poolInfo; 45 | mapping(uint256 => mapping(address => UserInfo)) public userInfo; 46 | mapping(address => bool) public poolTokens; 47 | uint256 public totalAllocPoint = 0; 48 | uint256 public startBlock; 49 | uint256 public bonusEndBlock; 50 | uint256 public BONUS_MULTIPLIER; 51 | address public rewardVault; 52 | 53 | /// @notice A checkpoint for marking number of votes from a given block 54 | struct Checkpoint { 55 | uint32 fromBlock; 56 | uint256 votes; 57 | } 58 | 59 | /// @notice A record of votes checkpoints for each account, by index 60 | mapping (uint256 => mapping (address => mapping (uint32 => Checkpoint))) public checkpoints; 61 | 62 | /// @notice The number of checkpoints for each account 63 | mapping (uint256 => mapping (address => uint32)) public numCheckpoints; 64 | 65 | modifier validatePoolByPid(uint256 _pid) { 66 | require(_pid < poolInfo.length, "Pool does not exist"); 67 | _; 68 | } 69 | 70 | function initialize( 71 | IERC20 _rewardToken, 72 | uint256 _rewardPerBlock, 73 | uint256 _startBlock, 74 | uint256 _bonusEndBlock, 75 | uint256 _multiplier, 76 | address _rewardVault 77 | ) public initializer { 78 | require(_rewardVault != address(0) && address(_rewardToken) != address(0), "Zero address validation"); 79 | require(_startBlock < _bonusEndBlock, "Start block lower than bonus end block"); 80 | require(_rewardPerBlock < _rewardToken.totalSupply(), "Reward per block bigger than reward token total supply"); 81 | require(BONUS_MULTIPLIER < 100, "Bonus multipler bigger than 100x reward bonus"); 82 | __Ownable_init(); 83 | rewardToken = _rewardToken; 84 | rewardPerBlock = _rewardPerBlock; 85 | startBlock = _startBlock; 86 | bonusEndBlock = _bonusEndBlock; 87 | BONUS_MULTIPLIER = _multiplier; 88 | rewardVault = _rewardVault; 89 | } 90 | 91 | function poolLength() external view returns (uint256) { 92 | return poolInfo.length; 93 | } 94 | 95 | function getStakingAmount(uint256 pid, address user) public view returns (uint256) { 96 | UserInfo memory info = userInfo[pid][user]; 97 | return info.amount; 98 | } 99 | 100 | // Add a new stake to the pool. Can only be called by the Timelock and DAO. 101 | // XXX DO NOT add the same stake token more than once. Rewards will be messed up if you do. 102 | // This function can be only called by Timelock and DAO with voting power 103 | function add( 104 | uint256 _allocPoint, 105 | IERC20 _stakeToken 106 | ) public onlyOwner { 107 | require(!poolTokens[address(_stakeToken)], "Stake token already exist"); 108 | massUpdatePools(); 109 | uint256 lastRewardBlock = 110 | block.number > startBlock ? block.number : startBlock; 111 | totalAllocPoint = totalAllocPoint.add(_allocPoint); 112 | poolTokens[address(_stakeToken)] = true; 113 | poolInfo.push( 114 | PoolInfo({ 115 | stakeToken: _stakeToken, 116 | allocPoint: _allocPoint, 117 | lastRewardBlock: lastRewardBlock, 118 | accCHNPerShare: 0, 119 | totalAmountStake: 0 120 | }) 121 | ); 122 | emit Add(address(_stakeToken), _allocPoint); 123 | } 124 | 125 | // Update the given pool's XCN allocation point. Can only be called by the Timelock and DAO. 126 | // This function can be only called by Timelock and DAO with voting power 127 | function set( 128 | uint256 _pid, 129 | uint256 _allocPoint 130 | ) public onlyOwner validatePoolByPid(_pid) { 131 | massUpdatePools(); 132 | totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add( 133 | _allocPoint 134 | ); 135 | poolInfo[_pid].allocPoint = _allocPoint; 136 | emit Set(_pid, _allocPoint); 137 | } 138 | 139 | // Update reward per block by the Timelock and DAO 140 | function setRewardPerblock(uint256 speed) 141 | public 142 | onlyOwner { 143 | rewardPerBlock = speed; 144 | } 145 | 146 | // Return reward multiplier over the given _from to _to block. 147 | function getMultiplier(uint256 _from, uint256 _to) 148 | public 149 | view 150 | returns (uint256) 151 | { 152 | require(_from >= startBlock, "from block number bigger than start block"); 153 | if (_to <= bonusEndBlock) { 154 | return _to.sub(_from).mul(BONUS_MULTIPLIER); 155 | } else if (_from >= bonusEndBlock) { 156 | return _to.sub(_from); 157 | } else { 158 | return 159 | bonusEndBlock.sub(_from).mul(BONUS_MULTIPLIER).add( 160 | _to.sub(bonusEndBlock) 161 | ); 162 | } 163 | } 164 | 165 | function pendingReward(uint256 _pid, address _user) 166 | external 167 | view 168 | validatePoolByPid(_pid) 169 | returns (uint256) 170 | { 171 | PoolInfo storage pool = poolInfo[_pid]; 172 | UserInfo storage user = userInfo[_pid][_user]; 173 | uint256 accCHNPerShare = pool.accCHNPerShare; 174 | uint256 supply = pool.totalAmountStake; 175 | if (block.number > pool.lastRewardBlock && supply != 0) { 176 | uint256 multiplier = 177 | getMultiplier(pool.lastRewardBlock, block.number); 178 | uint256 reward = 179 | multiplier.mul(rewardPerBlock).mul(pool.allocPoint).div( 180 | totalAllocPoint 181 | ); 182 | accCHNPerShare = accCHNPerShare.add( 183 | reward.mul(1e12).div(supply) 184 | ); 185 | } 186 | return user.amount.mul(accCHNPerShare).div(1e12).add(user.pendingTokenReward).sub(user.rewardDebt); 187 | } 188 | 189 | // Update reward vairables for all pools. Be careful of gas spending! 190 | function massUpdatePools() public { 191 | uint256 length = poolInfo.length; 192 | for (uint256 pid = 0; pid < length; ++pid) { 193 | updatePool(pid); 194 | } 195 | } 196 | 197 | // Update reward variables of the given pool to be up-to-date. 198 | function updatePool(uint256 _pid) public validatePoolByPid(_pid) { 199 | PoolInfo storage pool = poolInfo[_pid]; 200 | if (block.number <= pool.lastRewardBlock) { 201 | return; 202 | } 203 | uint256 supply = pool.totalAmountStake; 204 | if (supply == 0) { 205 | pool.lastRewardBlock = block.number; 206 | return; 207 | } 208 | uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); 209 | uint256 reward = 210 | multiplier.mul(rewardPerBlock).mul(pool.allocPoint).div( 211 | totalAllocPoint 212 | ); 213 | pool.accCHNPerShare = pool.accCHNPerShare.add( 214 | reward.mul(1e12).div(supply) 215 | ); 216 | pool.lastRewardBlock = block.number; 217 | } 218 | 219 | function _moveDelegates(uint256 _pid, address dstRep, uint256 amount, bool stake) internal { 220 | if (amount > 0) { 221 | if (dstRep != address(0)) { 222 | uint32 dstRepNum = numCheckpoints[_pid][dstRep]; 223 | uint256 dstRepOld = dstRepNum > 0 ? checkpoints[_pid][dstRep][dstRepNum - 1].votes : 0; 224 | if (stake) { 225 | uint256 dstRepNew = dstRepOld.add(amount); 226 | _writeCheckpoint(_pid, dstRep, dstRepNum, dstRepOld, dstRepNew); 227 | } else { 228 | uint256 dstRepNew = dstRepOld.sub(amount); 229 | _writeCheckpoint(_pid, dstRep, dstRepNum, dstRepOld, dstRepNew); 230 | } 231 | } 232 | } 233 | } 234 | 235 | // Only support non-deflationary tokens staking 236 | function stake(uint256 _pid, uint256 _amount) public validatePoolByPid(_pid) { 237 | PoolInfo storage pool = poolInfo[_pid]; 238 | UserInfo storage user = userInfo[_pid][msg.sender]; 239 | updatePool(_pid); 240 | if (user.amount > 0) { 241 | uint256 pending = 242 | user.amount.mul(pool.accCHNPerShare).div(1e12).sub( 243 | user.rewardDebt 244 | ); 245 | user.pendingTokenReward = user.pendingTokenReward.add(pending); 246 | } 247 | pool.totalAmountStake = pool.totalAmountStake.add(_amount); 248 | pool.stakeToken.safeTransferFrom( 249 | address(msg.sender), 250 | address(this), 251 | _amount 252 | ); 253 | user.amount = user.amount.add(_amount); 254 | user.rewardDebt = user.amount.mul(pool.accCHNPerShare).div(1e12); 255 | 256 | _moveDelegates(_pid, msg.sender, _amount, true); 257 | emit Stake(msg.sender, _pid, _amount); 258 | } 259 | 260 | function withdraw(uint256 _pid, uint256 _amount) public validatePoolByPid(_pid) { 261 | PoolInfo storage pool = poolInfo[_pid]; 262 | UserInfo storage user = userInfo[_pid][msg.sender]; 263 | require(user.amount >= _amount, "withdraw: not good"); 264 | updatePool(_pid); 265 | uint256 pending = 266 | user.amount.mul(pool.accCHNPerShare).div(1e12).sub( 267 | user.rewardDebt 268 | ); 269 | // pending = pending.add(user.pendingTokenReward); 270 | // pool.stakeToken.safeTransfer(address(msg.sender), pending); 271 | user.pendingTokenReward = user.pendingTokenReward + pending; 272 | user.amount = user.amount.sub(_amount); 273 | pool.totalAmountStake = pool.totalAmountStake.sub(_amount); 274 | user.rewardDebt = user.amount.mul(pool.accCHNPerShare).div(1e12); 275 | pool.stakeToken.safeTransfer(address(msg.sender), _amount); 276 | 277 | // Remove delegates from staking user 278 | _moveDelegates(_pid, msg.sender, _amount, false); 279 | emit Withdraw(msg.sender, _pid, _amount, 0); 280 | } 281 | 282 | // Withdraw without caring about rewards. EMERGENCY ONLY. 283 | function emergencyWithdraw(uint256 _pid) public validatePoolByPid(_pid) { 284 | PoolInfo storage pool = poolInfo[_pid]; 285 | UserInfo storage user = userInfo[_pid][msg.sender]; 286 | uint256 userAmount = user.amount; 287 | user.amount = 0; 288 | user.rewardDebt = 0; 289 | user.pendingTokenReward = 0; 290 | pool.totalAmountStake = pool.totalAmountStake.sub(userAmount); 291 | pool.stakeToken.safeTransfer(address(msg.sender), userAmount); 292 | // Remove delegates from staking user 293 | _moveDelegates(_pid, msg.sender, userAmount, false); 294 | emit EmergencyWithdraw(msg.sender, _pid, userAmount); 295 | } 296 | 297 | function claimRewardFromVault(address userAddress, uint256 pid) public validatePoolByPid(pid) returns (uint256) { 298 | require(msg.sender == rewardVault, "Ownable: only reward vault"); 299 | PoolInfo storage pool = poolInfo[pid]; 300 | UserInfo storage user = userInfo[pid][userAddress]; 301 | updatePool(pid); 302 | uint256 pending = 303 | user.amount.mul(pool.accCHNPerShare).div(1e12).sub( 304 | user.rewardDebt 305 | ); 306 | pending = pending + user.pendingTokenReward; 307 | user.pendingTokenReward = 0; 308 | user.rewardDebt = user.amount.mul(pool.accCHNPerShare).div(1e12); 309 | emit ClaimRewardFromVault(userAddress, pid); 310 | return pending; 311 | } 312 | 313 | /** 314 | * @notice Determine the prior number of votes for an account as of a block number 315 | * @dev Block number must be a finalized block or else this function will revert to prevent misinformation. 316 | * @param account The address of the account to check 317 | * @param blockNumber The block number to get the vote balance at 318 | * @return The number of votes the account had as of the given block 319 | */ 320 | function getPriorVotes(uint256 _pid, address account, uint blockNumber) public view returns (uint256) { 321 | require(blockNumber < block.number, "Comp::getPriorVotes: not yet determined"); 322 | 323 | uint32 nCheckpoints = numCheckpoints[_pid][account]; 324 | if (nCheckpoints == 0) { 325 | return 0; 326 | } 327 | 328 | // First check most recent balance 329 | if (checkpoints[_pid][account][nCheckpoints - 1].fromBlock <= blockNumber) { 330 | return checkpoints[_pid][account][nCheckpoints - 1].votes; 331 | } 332 | 333 | // Next check implicit zero balance 334 | if (checkpoints[_pid][account][0].fromBlock > blockNumber) { 335 | return 0; 336 | } 337 | 338 | uint32 lower = 0; 339 | uint32 upper = nCheckpoints - 1; 340 | while (upper > lower) { 341 | uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow 342 | Checkpoint memory cp = checkpoints[_pid][account][center]; 343 | if (cp.fromBlock == blockNumber) { 344 | return cp.votes; 345 | } else if (cp.fromBlock < blockNumber) { 346 | lower = center; 347 | } else { 348 | upper = center - 1; 349 | } 350 | } 351 | return checkpoints[_pid][account][lower].votes; 352 | } 353 | 354 | function _writeCheckpoint(uint256 _pid, address delegatee, uint32 nCheckpoints, uint256 oldVotes, uint256 newVotes) internal { 355 | uint32 blockNumber = safe32(block.number, "Comp::_writeCheckpoint: block number exceeds 32 bits"); 356 | 357 | if (nCheckpoints > 0 && checkpoints[_pid][delegatee][nCheckpoints - 1].fromBlock == blockNumber) { 358 | checkpoints[_pid][delegatee][nCheckpoints - 1].votes = newVotes; 359 | } else { 360 | checkpoints[_pid][delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes); 361 | numCheckpoints[_pid][delegatee] = nCheckpoints + 1; 362 | } 363 | 364 | emit DelegateVotesChanged(delegatee, oldVotes, newVotes); 365 | } 366 | 367 | function safe32(uint n, string memory errorMessage) internal pure returns (uint32) { 368 | require(n < 2**32, errorMessage); 369 | return uint32(n); 370 | } 371 | } 372 | -------------------------------------------------------------------------------- /contracts/mocks/ERC20Mock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.0; 3 | 4 | import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 5 | 6 | contract ERC20Mock is ERC20 { 7 | constructor( 8 | string memory name, 9 | string memory symbol, 10 | uint256 supply 11 | ) ERC20(name, symbol) { 12 | _mint(msg.sender, supply); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /contracts/mocks/ERC20Token.sol: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright 2019 ZeroEx Intl. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | 17 | */ 18 | 19 | pragma solidity ^0.8.0; 20 | 21 | interface IERC20Token { 22 | 23 | // solhint-disable no-simple-event-func-name 24 | event Transfer( 25 | address indexed _from, 26 | address indexed _to, 27 | uint256 _value 28 | ); 29 | 30 | event Approval( 31 | address indexed _owner, 32 | address indexed _spender, 33 | uint256 _value 34 | ); 35 | 36 | /// @dev send `value` token to `to` from `msg.sender` 37 | /// @param _to The address of the recipient 38 | /// @param _value The amount of token to be transferred 39 | /// @return True if transfer was successful 40 | function transfer(address _to, uint256 _value) 41 | external 42 | returns (bool); 43 | 44 | /// @dev send `value` token to `to` from `from` on the condition it is approved by `from` 45 | /// @param _from The address of the sender 46 | /// @param _to The address of the recipient 47 | /// @param _value The amount of token to be transferred 48 | /// @return True if transfer was successful 49 | function transferFrom( 50 | address _from, 51 | address _to, 52 | uint256 _value 53 | ) 54 | external 55 | returns (bool); 56 | 57 | /// @dev `msg.sender` approves `_spender` to spend `_value` tokens 58 | /// @param _spender The address of the account able to transfer the tokens 59 | /// @param _value The amount of wei to be approved for transfer 60 | /// @return Always true if the call has enough gas to complete execution 61 | function approve(address _spender, uint256 _value) 62 | external 63 | returns (bool); 64 | 65 | /// @dev Query total supply of token 66 | /// @return Total supply of token 67 | function totalSupply() 68 | external 69 | view 70 | returns (uint256); 71 | 72 | /// @param _owner The address from which the balance will be retrieved 73 | /// @return Balance of owner 74 | function balanceOf(address _owner) 75 | external 76 | view 77 | returns (uint256); 78 | 79 | /// @param _owner The address of the account owning tokens 80 | /// @param _spender The address of the account able to transfer the tokens 81 | /// @return Amount of remaining tokens allowed to spent 82 | function allowance(address _owner, address _spender) 83 | external 84 | view 85 | returns (uint256); 86 | } 87 | 88 | 89 | contract ERC20Token is 90 | IERC20Token 91 | { 92 | mapping (address => uint256) internal balances; 93 | mapping (address => mapping (address => uint256)) internal allowed; 94 | 95 | uint256 internal _totalSupply; 96 | string public name; 97 | string public symbol; 98 | uint256 public decimals; 99 | 100 | constructor ( 101 | string memory _name, 102 | string memory _symbol, 103 | uint256 _decimals, 104 | uint256 _totalSupply 105 | ) 106 | public 107 | { 108 | name = _name; 109 | symbol = _symbol; 110 | decimals = _decimals; 111 | _totalSupply = _totalSupply; 112 | balances[msg.sender] = _totalSupply; 113 | } 114 | 115 | /// @dev send `value` token to `to` from `msg.sender` 116 | /// @param _to The address of the recipient 117 | /// @param _value The amount of token to be transferred 118 | /// @return True if transfer was successful 119 | function transfer(address _to, uint256 _value) 120 | public 121 | override 122 | returns (bool) 123 | { 124 | require( 125 | balances[msg.sender] >= _value, 126 | "ERC20_INSUFFICIENT_BALANCE" 127 | ); 128 | require( 129 | balances[_to] + _value >= balances[_to], 130 | "UINT256_OVERFLOW" 131 | ); 132 | 133 | balances[msg.sender] -= _value; 134 | balances[_to] += _value; 135 | 136 | emit Transfer( 137 | msg.sender, 138 | _to, 139 | _value 140 | ); 141 | 142 | return true; 143 | } 144 | 145 | /// @dev send `value` token to `to` from `from` on the condition it is approved by `from` 146 | /// @param _from The address of the sender 147 | /// @param _to The address of the recipient 148 | /// @param _value The amount of token to be transferred 149 | /// @return True if transfer was successful 150 | function transferFrom( 151 | address _from, 152 | address _to, 153 | uint256 _value 154 | ) 155 | public 156 | override 157 | returns (bool) 158 | { 159 | require( 160 | balances[_from] >= _value, 161 | "ERC20_INSUFFICIENT_BALANCE" 162 | ); 163 | require( 164 | allowed[_from][msg.sender] >= _value, 165 | "ERC20_INSUFFICIENT_ALLOWANCE" 166 | ); 167 | require( 168 | balances[_to] + _value >= balances[_to], 169 | "UINT256_OVERFLOW" 170 | ); 171 | 172 | balances[_to] += _value; 173 | balances[_from] -= _value; 174 | allowed[_from][msg.sender] -= _value; 175 | 176 | emit Transfer( 177 | _from, 178 | _to, 179 | _value 180 | ); 181 | 182 | return true; 183 | } 184 | 185 | /// @dev `msg.sender` approves `_spender` to spend `_value` tokens 186 | /// @param _spender The address of the account able to transfer the tokens 187 | /// @param _value The amount of wei to be approved for transfer 188 | /// @return Always true if the call has enough gas to complete execution 189 | function approve(address _spender, uint256 _value) 190 | public 191 | override 192 | returns (bool) 193 | { 194 | allowed[msg.sender][_spender] = _value; 195 | emit Approval( 196 | msg.sender, 197 | _spender, 198 | _value 199 | ); 200 | return true; 201 | } 202 | 203 | /// @dev Query total supply of token 204 | /// @return Total supply of token 205 | function totalSupply() 206 | public 207 | override 208 | view 209 | returns (uint256) 210 | { 211 | return _totalSupply; 212 | } 213 | 214 | /// @dev Query the balance of owner 215 | /// @param _owner The address from which the balance will be retrieved 216 | /// @return Balance of owner 217 | function balanceOf(address _owner) 218 | public 219 | override 220 | view 221 | returns (uint256) 222 | { 223 | return balances[_owner]; 224 | } 225 | 226 | /// @param _owner The address of the account owning tokens 227 | /// @param _spender The address of the account able to transfer the tokens 228 | /// @return Amount of remaining tokens allowed to spent 229 | function allowance(address _owner, address _spender) 230 | public 231 | override 232 | view 233 | returns (uint256) 234 | { 235 | return allowed[_owner][_spender]; 236 | } 237 | } 238 | -------------------------------------------------------------------------------- /contracts/mocks/FakeToken.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.0; 2 | 3 | import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 4 | 5 | contract FakeToken is ERC20 { 6 | constructor(uint256 initialSupply) ERC20("Chain", "CHN") { 7 | // _mint(msg.sender, initialSupply); 8 | } 9 | 10 | function mintForUser(uint256 amount) public { 11 | _mint(msg.sender, amount); 12 | } 13 | } -------------------------------------------------------------------------------- /contracts/mocks/IErc20Token.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.0; 2 | 3 | interface IErc20Token { 4 | function transfer(address recipient, uint256 amount) external returns (bool); 5 | function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); 6 | } 7 | -------------------------------------------------------------------------------- /contracts/mocks/SafeMath.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.0; 2 | 3 | // From https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/math/Math.sol 4 | // Subject to the MIT license. 5 | 6 | /** 7 | * @dev Wrappers over Solidity's arithmetic operations with added overflow 8 | * checks. 9 | * 10 | * Arithmetic operations in Solidity wrap on overflow. This can easily result 11 | * in bugs, because programmers usually assume that an overflow raises an 12 | * error, which is the standard behavior in high level programming languages. 13 | * `SafeMath` restores this intuition by reverting the transaction when an 14 | * operation overflows. 15 | * 16 | * Using this library instead of the unchecked operations eliminates an entire 17 | * class of bugs, so it's recommended to use it always. 18 | */ 19 | library SafeMath { 20 | /** 21 | * @dev Returns the addition of two unsigned integers, reverting on overflow. 22 | * 23 | * Counterpart to Solidity's `+` operator. 24 | * 25 | * Requirements: 26 | * - Addition cannot overflow. 27 | */ 28 | function add(uint256 a, uint256 b) internal pure returns (uint256) { 29 | uint256 c = a + b; 30 | require(c >= a, "SafeMath: addition overflow"); 31 | 32 | return c; 33 | } 34 | 35 | /** 36 | * @dev Returns the addition of two unsigned integers, reverting with custom message on overflow. 37 | * 38 | * Counterpart to Solidity's `+` operator. 39 | * 40 | * Requirements: 41 | * - Addition cannot overflow. 42 | */ 43 | function add(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { 44 | uint256 c = a + b; 45 | require(c >= a, errorMessage); 46 | 47 | return c; 48 | } 49 | 50 | /** 51 | * @dev Returns the subtraction of two unsigned integers, reverting on underflow (when the result is negative). 52 | * 53 | * Counterpart to Solidity's `-` operator. 54 | * 55 | * Requirements: 56 | * - Subtraction cannot underflow. 57 | */ 58 | function sub(uint256 a, uint256 b) internal pure returns (uint256) { 59 | return sub(a, b, "SafeMath: subtraction underflow"); 60 | } 61 | 62 | /** 63 | * @dev Returns the subtraction of two unsigned integers, reverting with custom message on underflow (when the result is negative). 64 | * 65 | * Counterpart to Solidity's `-` operator. 66 | * 67 | * Requirements: 68 | * - Subtraction cannot underflow. 69 | */ 70 | function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { 71 | require(b <= a, errorMessage); 72 | uint256 c = a - b; 73 | 74 | return c; 75 | } 76 | 77 | /** 78 | * @dev Returns the multiplication of two unsigned integers, reverting on overflow. 79 | * 80 | * Counterpart to Solidity's `*` operator. 81 | * 82 | * Requirements: 83 | * - Multiplication cannot overflow. 84 | */ 85 | function mul(uint256 a, uint256 b) internal pure returns (uint256) { 86 | // Gas optimization: this is cheaper than requiring 'a' not being zero, but the 87 | // benefit is lost if 'b' is also tested. 88 | // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 89 | if (a == 0) { 90 | return 0; 91 | } 92 | 93 | uint256 c = a * b; 94 | require(c / a == b, "SafeMath: multiplication overflow"); 95 | 96 | return c; 97 | } 98 | 99 | /** 100 | * @dev Returns the multiplication of two unsigned integers, reverting on overflow. 101 | * 102 | * Counterpart to Solidity's `*` operator. 103 | * 104 | * Requirements: 105 | * - Multiplication cannot overflow. 106 | */ 107 | function mul(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { 108 | // Gas optimization: this is cheaper than requiring 'a' not being zero, but the 109 | // benefit is lost if 'b' is also tested. 110 | // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 111 | if (a == 0) { 112 | return 0; 113 | } 114 | 115 | uint256 c = a * b; 116 | require(c / a == b, errorMessage); 117 | 118 | return c; 119 | } 120 | 121 | /** 122 | * @dev Returns the integer division of two unsigned integers. 123 | * Reverts on division by zero. The result is rounded towards zero. 124 | * 125 | * Counterpart to Solidity's `/` operator. Note: this function uses a 126 | * `revert` opcode (which leaves remaining gas untouched) while Solidity 127 | * uses an invalid opcode to revert (consuming all remaining gas). 128 | * 129 | * Requirements: 130 | * - The divisor cannot be zero. 131 | */ 132 | function div(uint256 a, uint256 b) internal pure returns (uint256) { 133 | return div(a, b, "SafeMath: division by zero"); 134 | } 135 | 136 | /** 137 | * @dev Returns the integer division of two unsigned integers. 138 | * Reverts with custom message on division by zero. The result is rounded towards zero. 139 | * 140 | * Counterpart to Solidity's `/` operator. Note: this function uses a 141 | * `revert` opcode (which leaves remaining gas untouched) while Solidity 142 | * uses an invalid opcode to revert (consuming all remaining gas). 143 | * 144 | * Requirements: 145 | * - The divisor cannot be zero. 146 | */ 147 | function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { 148 | // Solidity only automatically asserts when dividing by 0 149 | require(b > 0, errorMessage); 150 | uint256 c = a / b; 151 | // assert(a == b * c + a % b); // There is no case in which this doesn't hold 152 | 153 | return c; 154 | } 155 | 156 | /** 157 | * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), 158 | * Reverts when dividing by zero. 159 | * 160 | * Counterpart to Solidity's `%` operator. This function uses a `revert` 161 | * opcode (which leaves remaining gas untouched) while Solidity uses an 162 | * invalid opcode to revert (consuming all remaining gas). 163 | * 164 | * Requirements: 165 | * - The divisor cannot be zero. 166 | */ 167 | function mod(uint256 a, uint256 b) internal pure returns (uint256) { 168 | return mod(a, b, "SafeMath: modulo by zero"); 169 | } 170 | 171 | /** 172 | * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), 173 | * Reverts with custom message when dividing by zero. 174 | * 175 | * Counterpart to Solidity's `%` operator. This function uses a `revert` 176 | * opcode (which leaves remaining gas untouched) while Solidity uses an 177 | * invalid opcode to revert (consuming all remaining gas). 178 | * 179 | * Requirements: 180 | * - The divisor cannot be zero. 181 | */ 182 | function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { 183 | require(b != 0, errorMessage); 184 | return a % b; 185 | } 186 | } 187 | -------------------------------------------------------------------------------- /deploy/0001_deploy_verify.js: -------------------------------------------------------------------------------- 1 | require("dotenv").config(); 2 | const { deployments, ethers, artifacts } = require("hardhat"); 3 | 4 | const func = async function ({ deployments, getNamedAccounts, getChainId }) { 5 | const { deploy, execute } = deployments; 6 | const { deployer } = await getNamedAccounts(); 7 | 8 | console.log( {deployer} ); 9 | 10 | const rewardVault = await deploy("CHNReward", { 11 | from: deployer, 12 | args: [process.env.CHN_ADDRESS], 13 | log: true, 14 | }); 15 | 16 | await deploy("CHNStaking", { 17 | from: deployer, 18 | log: true, 19 | proxy: { 20 | proxyContract: "OptimizedTransparentProxy", 21 | execute: { 22 | init: { 23 | methodName: "initialize", 24 | args: [ 25 | process.env.CHN_ADDRESS, 26 | process.env.REWARD_PER_BLOCK, 27 | process.env.START_BLOCK, 28 | process.env.END_BONUS_BLOCK, 29 | process.env.MULTIPLIER, 30 | rewardVault.address 31 | ], 32 | } 33 | }, 34 | }, 35 | }); 36 | 37 | }; 38 | 39 | module.exports = func; 40 | 41 | module.exports.tags = ['deploy-verify']; 42 | 43 | async function sleep(timeout) { 44 | return new Promise((resolve, reject) => { 45 | setTimeout(() => { 46 | resolve(); 47 | }, timeout); 48 | }); 49 | } -------------------------------------------------------------------------------- /deployments/rinkeby/.chainId: -------------------------------------------------------------------------------- 1 | 4 -------------------------------------------------------------------------------- /deployments/rinkeby/CHNReward.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x5756138F7eF649B3ECcbaaC64001740158F1E426", 3 | "abi": [ 4 | { 5 | "inputs": [ 6 | { 7 | "internalType": "contract IERC20", 8 | "name": "_rewardToken", 9 | "type": "address" 10 | } 11 | ], 12 | "stateMutability": "nonpayable", 13 | "type": "constructor" 14 | }, 15 | { 16 | "anonymous": false, 17 | "inputs": [ 18 | { 19 | "indexed": true, 20 | "internalType": "address", 21 | "name": "user", 22 | "type": "address" 23 | }, 24 | { 25 | "indexed": true, 26 | "internalType": "uint256", 27 | "name": "pid", 28 | "type": "uint256" 29 | }, 30 | { 31 | "indexed": false, 32 | "internalType": "uint256", 33 | "name": "reward", 34 | "type": "uint256" 35 | } 36 | ], 37 | "name": "Claim", 38 | "type": "event" 39 | }, 40 | { 41 | "anonymous": false, 42 | "inputs": [ 43 | { 44 | "indexed": true, 45 | "internalType": "address", 46 | "name": "user", 47 | "type": "address" 48 | }, 49 | { 50 | "indexed": false, 51 | "internalType": "uint256", 52 | "name": "amount", 53 | "type": "uint256" 54 | } 55 | ], 56 | "name": "GrantDAO", 57 | "type": "event" 58 | }, 59 | { 60 | "anonymous": false, 61 | "inputs": [ 62 | { 63 | "indexed": true, 64 | "internalType": "address", 65 | "name": "previousOwner", 66 | "type": "address" 67 | }, 68 | { 69 | "indexed": true, 70 | "internalType": "address", 71 | "name": "newOwner", 72 | "type": "address" 73 | } 74 | ], 75 | "name": "OwnershipTransferred", 76 | "type": "event" 77 | }, 78 | { 79 | "inputs": [ 80 | { 81 | "internalType": "address", 82 | "name": "_staking", 83 | "type": "address" 84 | } 85 | ], 86 | "name": "changeStakingAdderss", 87 | "outputs": [], 88 | "stateMutability": "nonpayable", 89 | "type": "function" 90 | }, 91 | { 92 | "inputs": [ 93 | { 94 | "internalType": "uint256", 95 | "name": "pid", 96 | "type": "uint256" 97 | } 98 | ], 99 | "name": "claimReward", 100 | "outputs": [], 101 | "stateMutability": "nonpayable", 102 | "type": "function" 103 | }, 104 | { 105 | "inputs": [ 106 | { 107 | "internalType": "address", 108 | "name": "user", 109 | "type": "address" 110 | }, 111 | { 112 | "internalType": "uint256", 113 | "name": "amount", 114 | "type": "uint256" 115 | } 116 | ], 117 | "name": "grantDAO", 118 | "outputs": [], 119 | "stateMutability": "nonpayable", 120 | "type": "function" 121 | }, 122 | { 123 | "inputs": [], 124 | "name": "owner", 125 | "outputs": [ 126 | { 127 | "internalType": "address", 128 | "name": "", 129 | "type": "address" 130 | } 131 | ], 132 | "stateMutability": "view", 133 | "type": "function" 134 | }, 135 | { 136 | "inputs": [], 137 | "name": "renounceOwnership", 138 | "outputs": [], 139 | "stateMutability": "nonpayable", 140 | "type": "function" 141 | }, 142 | { 143 | "inputs": [], 144 | "name": "rewardToken", 145 | "outputs": [ 146 | { 147 | "internalType": "contract IERC20", 148 | "name": "", 149 | "type": "address" 150 | } 151 | ], 152 | "stateMutability": "view", 153 | "type": "function" 154 | }, 155 | { 156 | "inputs": [], 157 | "name": "staking", 158 | "outputs": [ 159 | { 160 | "internalType": "contract CHNStakingInterface", 161 | "name": "", 162 | "type": "address" 163 | } 164 | ], 165 | "stateMutability": "view", 166 | "type": "function" 167 | }, 168 | { 169 | "inputs": [ 170 | { 171 | "internalType": "address", 172 | "name": "newOwner", 173 | "type": "address" 174 | } 175 | ], 176 | "name": "transferOwnership", 177 | "outputs": [], 178 | "stateMutability": "nonpayable", 179 | "type": "function" 180 | } 181 | ], 182 | "transactionHash": "0xf8b458b36f34c6bfc32f5ae51f0d9c24f7468b80a634120a72bfad92c2f32e14", 183 | "receipt": { 184 | "to": null, 185 | "from": "0xD51bD125DEEe0d3CB12cf333B8910Ead844b5615", 186 | "contractAddress": "0x5756138F7eF649B3ECcbaaC64001740158F1E426", 187 | "transactionIndex": 18, 188 | "gasUsed": "738147", 189 | "logsBloom": "0x10000000400000000000080000000000000000000000000000800000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000002000000000000000000000000000000000000000000000000000000", 190 | "blockHash": "0x9cc5fb8e793bc83c3232535a4fde83dd0b32a03488e2dfcafffc3d7d6013226e", 191 | "transactionHash": "0xf8b458b36f34c6bfc32f5ae51f0d9c24f7468b80a634120a72bfad92c2f32e14", 192 | "logs": [ 193 | { 194 | "transactionIndex": 18, 195 | "blockNumber": 10022069, 196 | "transactionHash": "0xf8b458b36f34c6bfc32f5ae51f0d9c24f7468b80a634120a72bfad92c2f32e14", 197 | "address": "0x5756138F7eF649B3ECcbaaC64001740158F1E426", 198 | "topics": [ 199 | "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", 200 | "0x0000000000000000000000000000000000000000000000000000000000000000", 201 | "0x000000000000000000000000d51bd125deee0d3cb12cf333b8910ead844b5615" 202 | ], 203 | "data": "0x", 204 | "logIndex": 10, 205 | "blockHash": "0x9cc5fb8e793bc83c3232535a4fde83dd0b32a03488e2dfcafffc3d7d6013226e" 206 | } 207 | ], 208 | "blockNumber": 10022069, 209 | "cumulativeGasUsed": "4707240", 210 | "status": 1, 211 | "byzantium": true 212 | }, 213 | "args": [ 214 | "0x47974400432ADbCCAC6BdedAE73DDAaaFA91A5ec" 215 | ], 216 | "solcInputHash": "f334450306d96ba77ba6ff912ec2b37b", 217 | "metadata": "{\"compiler\":{\"version\":\"0.8.3+commit.8d00100c\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"_rewardToken\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"pid\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"reward\",\"type\":\"uint256\"}],\"name\":\"Claim\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"GrantDAO\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_staking\",\"type\":\"address\"}],\"name\":\"changeStakingAdderss\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"pid\",\"type\":\"uint256\"}],\"name\":\"claimReward\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"grantDAO\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"rewardToken\",\"outputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"staking\",\"outputs\":[{\"internalType\":\"contract CHNStakingInterface\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/allocateStaking/CHNReward.sol\":\"CHNReward\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0x24e0364e503a9bbde94c715d26573a76f14cd2a202d45f96f52134ab806b67b9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address sender,\\n address recipient,\\n uint256 amount\\n ) external returns (bool);\\n\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n}\\n\",\"keccak256\":\"0x61437cb513a887a1bbad006e7b1c8b414478427d33de47c5600af3c748f108da\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20 {\\n using Address for address;\\n\\n function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc3d946432c0ddbb1f846a0d3985be71299df331b91d06732152117f62f0be2b5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize, which returns 0 for contracts in\\n // construction, since the code is only stored at the end of the\\n // constructor execution.\\n\\n uint256 size;\\n assembly {\\n size := extcodesize(account)\\n }\\n return size > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x51b758a8815ecc9596c66c37d56b1d33883a444631a3f916b9fe65cb863ef7c4\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"contracts/allocateStaking/CHNReward.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.3;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\ninterface CHNStakingInterface {\\n function claimRewardFromVault(address userAddress, uint256 pid) external returns (uint256);\\n}\\n\\ncontract CHNReward is Ownable {\\n using SafeERC20 for IERC20;\\n\\n event Claim(address indexed user, uint256 indexed pid, uint256 reward);\\n event GrantDAO(address indexed user, uint256 amount);\\n\\n IERC20 public rewardToken;\\n CHNStakingInterface public staking;\\n\\n constructor(IERC20 _rewardToken) Ownable() {\\n rewardToken = _rewardToken;\\n }\\n\\n function changeStakingAdderss(address _staking) public onlyOwner {\\n staking = CHNStakingInterface(_staking);\\n }\\n\\n function claimReward(uint256 pid) public {\\n uint256 rewardAmount = staking.claimRewardFromVault(msg.sender, pid);\\n rewardToken.safeTransfer(address(msg.sender), rewardAmount);\\n emit Claim(msg.sender, pid, rewardAmount);\\n }\\n\\n function grantDAO(address user, uint256 amount) public onlyOwner {\\n rewardToken.safeTransfer(user, amount);\\n emit GrantDAO(user, amount);\\n }\\n}\\n\",\"keccak256\":\"0x416bc6d4fa839419f0134ba8de1ac0d02bb51cbdc6ecdd018d8c6130f7c89e4e\",\"license\":\"MIT\"}},\"version\":1}", 218 | "bytecode": "0x608060405234801561001057600080fd5b50604051610c7e380380610c7e83398101604081905261002f916100ad565b6100383361005d565b600180546001600160a01b0319166001600160a01b03929092169190911790556100db565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000602082840312156100be578081fd5b81516001600160a01b03811681146100d4578182fd5b9392505050565b610b94806100ea6000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c8063ae169a501161005b578063ae169a5014610111578063c3a4e83a14610124578063f2fde38b14610137578063f7c618c11461014a57610088565b8063317d2f5e1461008d5780634cf088d9146100a2578063715018a6146100eb5780638da5cb5b146100f3575b600080fd5b6100a061009b366004610a2e565b61016a565b005b6002546100c29073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b6100a0610237565b60005473ffffffffffffffffffffffffffffffffffffffff166100c2565b6100a061011f366004610a91565b6102c4565b6100a0610132366004610a48565b6103d1565b6100a0610145366004610a2e565b6104ca565b6001546100c29073ffffffffffffffffffffffffffffffffffffffff1681565b60005473ffffffffffffffffffffffffffffffffffffffff1633146101f0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60005473ffffffffffffffffffffffffffffffffffffffff1633146102b8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016101e7565b6102c260006105fa565b565b6002546040517f4bea3f030000000000000000000000000000000000000000000000000000000081523360048201526024810183905260009173ffffffffffffffffffffffffffffffffffffffff1690634bea3f0390604401602060405180830381600087803b15801561033757600080fd5b505af115801561034b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061036f9190610aa9565b6001549091506103969073ffffffffffffffffffffffffffffffffffffffff16338361066f565b604051818152829033907f34fcbac0073d7c3d388e51312faf357774904998eeb8fca628b9e6f65ee1cbf79060200160405180910390a35050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610452576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016101e7565b6001546104769073ffffffffffffffffffffffffffffffffffffffff16838361066f565b8173ffffffffffffffffffffffffffffffffffffffff167f8742eaee05554e58c50683f78014b9856234f78c6e67b703cfcdef048f6503d3826040516104be91815260200190565b60405180910390a25050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461054b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016101e7565b73ffffffffffffffffffffffffffffffffffffffff81166105ee576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016101e7565b6105f7816105fa565b50565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040805173ffffffffffffffffffffffffffffffffffffffff8416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790526106fc908490610701565b505050565b6000610763826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661080d9092919063ffffffff16565b8051909150156106fc57808060200190518101906107819190610a71565b6106fc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016101e7565b606061081c8484600085610826565b90505b9392505050565b6060824710156108b8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016101e7565b6108c1856109ad565b610927576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016101e7565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516109509190610ac1565b60006040518083038185875af1925050503d806000811461098d576040519150601f19603f3d011682016040523d82523d6000602084013e610992565b606091505b50915091506109a28282866109b7565b979650505050505050565b803b15155b919050565b606083156109c657508161081f565b8251156109d65782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101e79190610add565b803573ffffffffffffffffffffffffffffffffffffffff811681146109b257600080fd5b600060208284031215610a3f578081fd5b61081f82610a0a565b60008060408385031215610a5a578081fd5b610a6383610a0a565b946020939093013593505050565b600060208284031215610a82578081fd5b8151801515811461081f578182fd5b600060208284031215610aa2578081fd5b5035919050565b600060208284031215610aba578081fd5b5051919050565b60008251610ad3818460208701610b2e565b9190910192915050565b6000602082528251806020840152610afc816040850160208701610b2e565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b60005b83811015610b49578181015183820152602001610b31565b83811115610b58576000848401525b5050505056fea26469706673582212203a4c6256da7f13a76ca52670d50ce1dfb2a9712dfe6c934d9dfef162e16a94e764736f6c63430008030033", 219 | "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100885760003560e01c8063ae169a501161005b578063ae169a5014610111578063c3a4e83a14610124578063f2fde38b14610137578063f7c618c11461014a57610088565b8063317d2f5e1461008d5780634cf088d9146100a2578063715018a6146100eb5780638da5cb5b146100f3575b600080fd5b6100a061009b366004610a2e565b61016a565b005b6002546100c29073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b6100a0610237565b60005473ffffffffffffffffffffffffffffffffffffffff166100c2565b6100a061011f366004610a91565b6102c4565b6100a0610132366004610a48565b6103d1565b6100a0610145366004610a2e565b6104ca565b6001546100c29073ffffffffffffffffffffffffffffffffffffffff1681565b60005473ffffffffffffffffffffffffffffffffffffffff1633146101f0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60005473ffffffffffffffffffffffffffffffffffffffff1633146102b8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016101e7565b6102c260006105fa565b565b6002546040517f4bea3f030000000000000000000000000000000000000000000000000000000081523360048201526024810183905260009173ffffffffffffffffffffffffffffffffffffffff1690634bea3f0390604401602060405180830381600087803b15801561033757600080fd5b505af115801561034b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061036f9190610aa9565b6001549091506103969073ffffffffffffffffffffffffffffffffffffffff16338361066f565b604051818152829033907f34fcbac0073d7c3d388e51312faf357774904998eeb8fca628b9e6f65ee1cbf79060200160405180910390a35050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610452576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016101e7565b6001546104769073ffffffffffffffffffffffffffffffffffffffff16838361066f565b8173ffffffffffffffffffffffffffffffffffffffff167f8742eaee05554e58c50683f78014b9856234f78c6e67b703cfcdef048f6503d3826040516104be91815260200190565b60405180910390a25050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461054b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016101e7565b73ffffffffffffffffffffffffffffffffffffffff81166105ee576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016101e7565b6105f7816105fa565b50565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040805173ffffffffffffffffffffffffffffffffffffffff8416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790526106fc908490610701565b505050565b6000610763826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661080d9092919063ffffffff16565b8051909150156106fc57808060200190518101906107819190610a71565b6106fc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016101e7565b606061081c8484600085610826565b90505b9392505050565b6060824710156108b8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016101e7565b6108c1856109ad565b610927576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016101e7565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516109509190610ac1565b60006040518083038185875af1925050503d806000811461098d576040519150601f19603f3d011682016040523d82523d6000602084013e610992565b606091505b50915091506109a28282866109b7565b979650505050505050565b803b15155b919050565b606083156109c657508161081f565b8251156109d65782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101e79190610add565b803573ffffffffffffffffffffffffffffffffffffffff811681146109b257600080fd5b600060208284031215610a3f578081fd5b61081f82610a0a565b60008060408385031215610a5a578081fd5b610a6383610a0a565b946020939093013593505050565b600060208284031215610a82578081fd5b8151801515811461081f578182fd5b600060208284031215610aa2578081fd5b5035919050565b600060208284031215610aba578081fd5b5051919050565b60008251610ad3818460208701610b2e565b9190910192915050565b6000602082528251806020840152610afc816040850160208701610b2e565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b60005b83811015610b49578181015183820152602001610b31565b83811115610b58576000848401525b5050505056fea26469706673582212203a4c6256da7f13a76ca52670d50ce1dfb2a9712dfe6c934d9dfef162e16a94e764736f6c63430008030033", 220 | "devdoc": { 221 | "kind": "dev", 222 | "methods": { 223 | "owner()": { 224 | "details": "Returns the address of the current owner." 225 | }, 226 | "renounceOwnership()": { 227 | "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." 228 | }, 229 | "transferOwnership(address)": { 230 | "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." 231 | } 232 | }, 233 | "version": 1 234 | }, 235 | "userdoc": { 236 | "kind": "user", 237 | "methods": {}, 238 | "version": 1 239 | }, 240 | "storageLayout": { 241 | "storage": [ 242 | { 243 | "astId": 496, 244 | "contract": "contracts/allocateStaking/CHNReward.sol:CHNReward", 245 | "label": "_owner", 246 | "offset": 0, 247 | "slot": "0", 248 | "type": "t_address" 249 | }, 250 | { 251 | "astId": 2135, 252 | "contract": "contracts/allocateStaking/CHNReward.sol:CHNReward", 253 | "label": "rewardToken", 254 | "offset": 0, 255 | "slot": "1", 256 | "type": "t_contract(IERC20)1217" 257 | }, 258 | { 259 | "astId": 2138, 260 | "contract": "contracts/allocateStaking/CHNReward.sol:CHNReward", 261 | "label": "staking", 262 | "offset": 0, 263 | "slot": "2", 264 | "type": "t_contract(CHNStakingInterface)2112" 265 | } 266 | ], 267 | "types": { 268 | "t_address": { 269 | "encoding": "inplace", 270 | "label": "address", 271 | "numberOfBytes": "20" 272 | }, 273 | "t_contract(CHNStakingInterface)2112": { 274 | "encoding": "inplace", 275 | "label": "contract CHNStakingInterface", 276 | "numberOfBytes": "20" 277 | }, 278 | "t_contract(IERC20)1217": { 279 | "encoding": "inplace", 280 | "label": "contract IERC20", 281 | "numberOfBytes": "20" 282 | } 283 | } 284 | } 285 | } -------------------------------------------------------------------------------- /deployments/rinkeby/CHNStaking_Proxy.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0x3645F49b851Efbf7d5591b6f37848CFb53cb1Ce1", 3 | "abi": [ 4 | { 5 | "inputs": [ 6 | { 7 | "internalType": "address", 8 | "name": "initialLogic", 9 | "type": "address" 10 | }, 11 | { 12 | "internalType": "address", 13 | "name": "initialAdmin", 14 | "type": "address" 15 | }, 16 | { 17 | "internalType": "bytes", 18 | "name": "_data", 19 | "type": "bytes" 20 | } 21 | ], 22 | "stateMutability": "payable", 23 | "type": "constructor" 24 | }, 25 | { 26 | "anonymous": false, 27 | "inputs": [ 28 | { 29 | "indexed": true, 30 | "internalType": "address", 31 | "name": "implementation", 32 | "type": "address" 33 | } 34 | ], 35 | "name": "Upgraded", 36 | "type": "event" 37 | }, 38 | { 39 | "stateMutability": "payable", 40 | "type": "fallback" 41 | }, 42 | { 43 | "inputs": [], 44 | "name": "admin", 45 | "outputs": [ 46 | { 47 | "internalType": "address", 48 | "name": "", 49 | "type": "address" 50 | } 51 | ], 52 | "stateMutability": "nonpayable", 53 | "type": "function" 54 | }, 55 | { 56 | "inputs": [], 57 | "name": "implementation", 58 | "outputs": [ 59 | { 60 | "internalType": "address", 61 | "name": "", 62 | "type": "address" 63 | } 64 | ], 65 | "stateMutability": "nonpayable", 66 | "type": "function" 67 | }, 68 | { 69 | "inputs": [ 70 | { 71 | "internalType": "address", 72 | "name": "newImplementation", 73 | "type": "address" 74 | } 75 | ], 76 | "name": "upgradeTo", 77 | "outputs": [], 78 | "stateMutability": "nonpayable", 79 | "type": "function" 80 | }, 81 | { 82 | "inputs": [ 83 | { 84 | "internalType": "address", 85 | "name": "newImplementation", 86 | "type": "address" 87 | }, 88 | { 89 | "internalType": "bytes", 90 | "name": "data", 91 | "type": "bytes" 92 | } 93 | ], 94 | "name": "upgradeToAndCall", 95 | "outputs": [], 96 | "stateMutability": "payable", 97 | "type": "function" 98 | }, 99 | { 100 | "stateMutability": "payable", 101 | "type": "receive" 102 | } 103 | ], 104 | "transactionHash": "0x2a6af8ecba715c966b16553afb725296cdaddb5947d20aa0757905f8f2180b4f", 105 | "receipt": { 106 | "to": null, 107 | "from": "0xD51bD125DEEe0d3CB12cf333B8910Ead844b5615", 108 | "contractAddress": "0x3645F49b851Efbf7d5591b6f37848CFb53cb1Ce1", 109 | "transactionIndex": 33, 110 | "gasUsed": "630727", 111 | "logsBloom": "0x00000000000000000000080000000000000000000000000000800000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000001000000000000100000000000000000000000020000000210000000000800000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", 112 | "blockHash": "0x771a7a8a3b7afcd27803ccf84123dc43c4361fc6d36c63d71d291b45026785b9", 113 | "transactionHash": "0x2a6af8ecba715c966b16553afb725296cdaddb5947d20aa0757905f8f2180b4f", 114 | "logs": [ 115 | { 116 | "transactionIndex": 33, 117 | "blockNumber": 10022073, 118 | "transactionHash": "0x2a6af8ecba715c966b16553afb725296cdaddb5947d20aa0757905f8f2180b4f", 119 | "address": "0x3645F49b851Efbf7d5591b6f37848CFb53cb1Ce1", 120 | "topics": [ 121 | "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", 122 | "0x0000000000000000000000000000000000000000000000000000000000000000", 123 | "0x000000000000000000000000d51bd125deee0d3cb12cf333b8910ead844b5615" 124 | ], 125 | "data": "0x", 126 | "logIndex": 29, 127 | "blockHash": "0x771a7a8a3b7afcd27803ccf84123dc43c4361fc6d36c63d71d291b45026785b9" 128 | } 129 | ], 130 | "blockNumber": 10022073, 131 | "cumulativeGasUsed": "4534515", 132 | "status": 1, 133 | "byzantium": true 134 | }, 135 | "args": [ 136 | "0xA8C2102941E540D44C612e8b63568C3ec0cD64b9", 137 | "0xB71A7f2f2121780795e3b0acE7849C284Af6De9d", 138 | "0x5df5f96f00000000000000000000000047974400432adbccac6bdedae73ddaaafa91a5ec000000000000000000000000000000000000000000000000002386f26fc10000000000000000000000000000000000000000000000000000000000000097c1920000000000000000000000000000000000000000000000000000000000985d96000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000005756138f7ef649b3eccbaac64001740158f1e426" 139 | ], 140 | "solcInputHash": "1635d55d57a0a2552952c0d22586ed23", 141 | "metadata": "{\"compiler\":{\"version\":\"0.7.6+commit.7338295f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"initialLogic\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"initialAdmin\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"Upgraded\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"admin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"implementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"}],\"name\":\"upgradeTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newImplementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeToAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}],\"devdoc\":{\"details\":\"This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \\\"admin cannot fallback to proxy target\\\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative inerface of your proxy.\",\"kind\":\"dev\",\"methods\":{\"admin()\":{\"details\":\"Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\"},\"constructor\":{\"details\":\"Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {UpgradeableProxy-constructor}.\"},\"implementation()\":{\"details\":\"Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\"},\"upgradeTo(address)\":{\"details\":\"Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\"},\"upgradeToAndCall(address,bytes)\":{\"details\":\"Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\"}},\"stateVariables\":{\"_ADMIN_SLOT\":{\"details\":\"Storage slot with the admin of the contract. This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is validated in the constructor.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.7/proxy/OptimizedTransparentUpgradeableProxy.sol\":\"OptimizedTransparentUpgradeableProxy\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.7/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n * \\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n * \\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n * \\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal {\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 { revert(0, returndatasize()) }\\n default { return(0, returndatasize()) }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal virtual view returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n * \\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback () payable external {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive () payable external {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n * \\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {\\n }\\n}\\n\",\"keccak256\":\"0xc33f9858a67e34c77831163d5611d21fc627dfd2c303806a98a6c9db5a01b034\",\"license\":\"MIT\"},\"solc_0.7/openzeppelin/proxy/UpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"./Proxy.sol\\\";\\nimport \\\"../utils/Address.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n * \\n * Upgradeability is only provided internally through {_upgradeTo}. For an externally upgradeable proxy see\\n * {TransparentUpgradeableProxy}.\\n */\\ncontract UpgradeableProxy is Proxy {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n * \\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _setImplementation(_logic);\\n if(_data.length > 0) {\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success,) = _logic.delegatecall(_data);\\n require(success);\\n }\\n }\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 private constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal override view returns (address impl) {\\n bytes32 slot = _IMPLEMENTATION_SLOT;\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n impl := sload(slot)\\n }\\n }\\n\\n /**\\n * @dev Upgrades the proxy to a new implementation.\\n * \\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"UpgradeableProxy: new implementation is not a contract\\\");\\n\\n bytes32 slot = _IMPLEMENTATION_SLOT;\\n\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n sstore(slot, newImplementation)\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd68f4c11941712db79a61b9dca81a5db663cfacec3d7bb19f8d2c23bb1ab8afe\",\"license\":\"MIT\"},\"solc_0.7/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // According to EIP-1052, 0x0 is the value returned for not-yet created accounts\\n // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned\\n // for accounts without code, i.e. `keccak256('')`\\n bytes32 codehash;\\n bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;\\n // solhint-disable-next-line no-inline-assembly\\n assembly { codehash := extcodehash(account) }\\n return (codehash != accountHash && codehash != 0x0);\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\\n (bool success, ) = recipient.call{ value: amount }(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain`call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n return _functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n return _functionCallWithValue(target, data, value, errorMessage);\\n }\\n\\n function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.call{ value: weiValue }(data);\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x698f929f1097637d051976b322a2d532c27df022b09010e8d091e2888a5ebdf8\",\"license\":\"MIT\"},\"solc_0.7/proxy/OptimizedTransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\npragma solidity ^0.7.0;\\n\\nimport \\\"../openzeppelin/proxy/UpgradeableProxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n *\\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n *\\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n *\\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n *\\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative inerface of your proxy.\\n */\\ncontract OptimizedTransparentUpgradeableProxy is UpgradeableProxy {\\n address internal immutable _ADMIN;\\n\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {UpgradeableProxy-constructor}.\\n */\\n constructor(\\n address initialLogic,\\n address initialAdmin,\\n bytes memory _data\\n ) payable UpgradeableProxy(initialLogic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n bytes32 slot = _ADMIN_SLOT;\\n\\n _ADMIN = initialAdmin;\\n\\n // still store it to work with EIP-1967\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n sstore(slot, initialAdmin)\\n }\\n }\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 private constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _admin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address) {\\n return _admin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n *\\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address) {\\n return _implementation();\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeTo(newImplementation);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n *\\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeTo(newImplementation);\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, ) = newImplementation.delegatecall(data);\\n require(success);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view returns (address adm) {\\n return _ADMIN;\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal virtual override {\\n require(msg.sender != _admin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0x076456d71495e22183c672db71d719bd2dc7cb3b35e5bba21ce37eea1ec30347\",\"license\":\"MIT\"}},\"version\":1}", 142 | "bytecode": "0x60a06040526040516108fc3803806108fc8339818101604052606081101561002657600080fd5b8151602083015160408085018051915193959294830192918464010000000082111561005157600080fd5b90830190602082018581111561006657600080fd5b825164010000000081118282018810171561008057600080fd5b82525081516020918201929091019080838360005b838110156100ad578181015183820152602001610095565b50505050905090810190601f1680156100da5780820380516001836020036101000a031916815260200191505b50604052508491508290506100ee826101e9565b8051156101a6576000826001600160a01b0316826040518082805190602001908083835b602083106101315780518252601f199092019160209182019101610112565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d8060008114610191576040519150601f19603f3d011682016040523d82523d6000602084013e610196565b606091505b50509050806101a457600080fd5b505b506101ae9050565b506001600160601b0319606082901b166080527fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035550610297565b6101fc8161025b60201b6103581760201c565b6102375760405162461bcd60e51b81526004018080602001828103825260368152602001806108c66036913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc55565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061028f57508115155b949350505050565b60805160601c6106126102b46000398061047352506106126000f3fe6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461009a5780635c60da1b14610127578063f851a4401461016557610052565b366100525761005061017a565b005b61005061017a565b34801561006657600080fd5b506100506004803603602081101561007d57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610194565b610050600480360360408110156100b057600080fd5b73ffffffffffffffffffffffffffffffffffffffff82351691908101906040810160208201356401000000008111156100e857600080fd5b8201836020820111156100fa57600080fd5b8035906020019184600183028401116401000000008311171561011c57600080fd5b5090925090506101e8565b34801561013357600080fd5b5061013c6102bc565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b34801561017157600080fd5b5061013c610313565b610182610394565b61019261018d610428565b61044d565b565b61019c610471565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156101dd576101d881610495565b6101e5565b6101e561017a565b50565b6101f0610471565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102af5761022c83610495565b60008373ffffffffffffffffffffffffffffffffffffffff1683836040518083838082843760405192019450600093509091505080830381855af49150503d8060008114610296576040519150601f19603f3d011682016040523d82523d6000602084013e61029b565b606091505b50509050806102a957600080fd5b506102b7565b6102b761017a565b505050565b60006102c6610471565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561030857610301610428565b9050610310565b61031061017a565b90565b600061031d610471565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561030857610301610471565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061038c57508115155b949350505050565b61039c610471565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610420576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252604281526020018061059b6042913960600191505060405180910390fd5b610192610192565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b3660008037600080366000845af43d6000803e80801561046c573d6000f35b3d6000fd5b7f000000000000000000000000000000000000000000000000000000000000000090565b61049e816104e2565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6104eb81610358565b610540576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260368152602001806105656036913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5556fe5570677261646561626c6550726f78793a206e657720696d706c656d656e746174696f6e206973206e6f74206120636f6e74726163745472616e73706172656e745570677261646561626c6550726f78793a2061646d696e2063616e6e6f742066616c6c6261636b20746f2070726f787920746172676574a26469706673582212200f42fc9d1f991236ae26e240c8505def958528031655d7dd335d3988cc0c88f564736f6c634300070600335570677261646561626c6550726f78793a206e657720696d706c656d656e746174696f6e206973206e6f74206120636f6e7472616374", 143 | "deployedBytecode": "0x6080604052600436106100435760003560e01c80633659cfe61461005a5780634f1ef2861461009a5780635c60da1b14610127578063f851a4401461016557610052565b366100525761005061017a565b005b61005061017a565b34801561006657600080fd5b506100506004803603602081101561007d57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610194565b610050600480360360408110156100b057600080fd5b73ffffffffffffffffffffffffffffffffffffffff82351691908101906040810160208201356401000000008111156100e857600080fd5b8201836020820111156100fa57600080fd5b8035906020019184600183028401116401000000008311171561011c57600080fd5b5090925090506101e8565b34801561013357600080fd5b5061013c6102bc565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b34801561017157600080fd5b5061013c610313565b610182610394565b61019261018d610428565b61044d565b565b61019c610471565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156101dd576101d881610495565b6101e5565b6101e561017a565b50565b6101f0610471565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102af5761022c83610495565b60008373ffffffffffffffffffffffffffffffffffffffff1683836040518083838082843760405192019450600093509091505080830381855af49150503d8060008114610296576040519150601f19603f3d011682016040523d82523d6000602084013e61029b565b606091505b50509050806102a957600080fd5b506102b7565b6102b761017a565b505050565b60006102c6610471565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561030857610301610428565b9050610310565b61031061017a565b90565b600061031d610471565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561030857610301610471565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061038c57508115155b949350505050565b61039c610471565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610420576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252604281526020018061059b6042913960600191505060405180910390fd5b610192610192565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5490565b3660008037600080366000845af43d6000803e80801561046c573d6000f35b3d6000fd5b7f000000000000000000000000000000000000000000000000000000000000000090565b61049e816104e2565b60405173ffffffffffffffffffffffffffffffffffffffff8216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6104eb81610358565b610540576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260368152602001806105656036913960400191505060405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5556fe5570677261646561626c6550726f78793a206e657720696d706c656d656e746174696f6e206973206e6f74206120636f6e74726163745472616e73706172656e745570677261646561626c6550726f78793a2061646d696e2063616e6e6f742066616c6c6261636b20746f2070726f787920746172676574a26469706673582212200f42fc9d1f991236ae26e240c8505def958528031655d7dd335d3988cc0c88f564736f6c63430007060033", 144 | "devdoc": { 145 | "details": "This contract implements a proxy that is upgradeable by an admin. To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector clashing], which can potentially be used in an attack, this contract uses the https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two things that go hand in hand: 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if that call matches one of the admin functions exposed by the proxy itself. 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the implementation. If the admin tries to call a function on the implementation it will fail with an error that says \"admin cannot fallback to proxy target\". These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to call a function from the proxy implementation. Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, you should think of the `ProxyAdmin` instance as the real administrative inerface of your proxy.", 146 | "kind": "dev", 147 | "methods": { 148 | "admin()": { 149 | "details": "Returns the current admin. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`" 150 | }, 151 | "constructor": { 152 | "details": "Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in {UpgradeableProxy-constructor}." 153 | }, 154 | "implementation()": { 155 | "details": "Returns the current implementation. NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`" 156 | }, 157 | "upgradeTo(address)": { 158 | "details": "Upgrade the implementation of the proxy. NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}." 159 | }, 160 | "upgradeToAndCall(address,bytes)": { 161 | "details": "Upgrade the implementation of the proxy, and then call a function from the new implementation as specified by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the proxied contract. NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}." 162 | } 163 | }, 164 | "stateVariables": { 165 | "_ADMIN_SLOT": { 166 | "details": "Storage slot with the admin of the contract. This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1, and is validated in the constructor." 167 | } 168 | }, 169 | "version": 1 170 | }, 171 | "userdoc": { 172 | "kind": "user", 173 | "methods": {}, 174 | "version": 1 175 | }, 176 | "storageLayout": { 177 | "storage": [], 178 | "types": null 179 | } 180 | } -------------------------------------------------------------------------------- /deployments/rinkeby/DefaultProxyAdmin.json: -------------------------------------------------------------------------------- 1 | { 2 | "address": "0xB71A7f2f2121780795e3b0acE7849C284Af6De9d", 3 | "abi": [ 4 | { 5 | "inputs": [ 6 | { 7 | "internalType": "address", 8 | "name": "owner", 9 | "type": "address" 10 | } 11 | ], 12 | "stateMutability": "nonpayable", 13 | "type": "constructor" 14 | }, 15 | { 16 | "anonymous": false, 17 | "inputs": [ 18 | { 19 | "indexed": true, 20 | "internalType": "address", 21 | "name": "previousOwner", 22 | "type": "address" 23 | }, 24 | { 25 | "indexed": true, 26 | "internalType": "address", 27 | "name": "newOwner", 28 | "type": "address" 29 | } 30 | ], 31 | "name": "OwnershipTransferred", 32 | "type": "event" 33 | }, 34 | { 35 | "inputs": [ 36 | { 37 | "internalType": "contract TransparentUpgradeableProxy", 38 | "name": "proxy", 39 | "type": "address" 40 | }, 41 | { 42 | "internalType": "address", 43 | "name": "newAdmin", 44 | "type": "address" 45 | } 46 | ], 47 | "name": "changeProxyAdmin", 48 | "outputs": [], 49 | "stateMutability": "nonpayable", 50 | "type": "function" 51 | }, 52 | { 53 | "inputs": [ 54 | { 55 | "internalType": "contract TransparentUpgradeableProxy", 56 | "name": "proxy", 57 | "type": "address" 58 | } 59 | ], 60 | "name": "getProxyAdmin", 61 | "outputs": [ 62 | { 63 | "internalType": "address", 64 | "name": "", 65 | "type": "address" 66 | } 67 | ], 68 | "stateMutability": "view", 69 | "type": "function" 70 | }, 71 | { 72 | "inputs": [ 73 | { 74 | "internalType": "contract TransparentUpgradeableProxy", 75 | "name": "proxy", 76 | "type": "address" 77 | } 78 | ], 79 | "name": "getProxyImplementation", 80 | "outputs": [ 81 | { 82 | "internalType": "address", 83 | "name": "", 84 | "type": "address" 85 | } 86 | ], 87 | "stateMutability": "view", 88 | "type": "function" 89 | }, 90 | { 91 | "inputs": [], 92 | "name": "owner", 93 | "outputs": [ 94 | { 95 | "internalType": "address", 96 | "name": "", 97 | "type": "address" 98 | } 99 | ], 100 | "stateMutability": "view", 101 | "type": "function" 102 | }, 103 | { 104 | "inputs": [], 105 | "name": "renounceOwnership", 106 | "outputs": [], 107 | "stateMutability": "nonpayable", 108 | "type": "function" 109 | }, 110 | { 111 | "inputs": [ 112 | { 113 | "internalType": "address", 114 | "name": "newOwner", 115 | "type": "address" 116 | } 117 | ], 118 | "name": "transferOwnership", 119 | "outputs": [], 120 | "stateMutability": "nonpayable", 121 | "type": "function" 122 | }, 123 | { 124 | "inputs": [ 125 | { 126 | "internalType": "contract TransparentUpgradeableProxy", 127 | "name": "proxy", 128 | "type": "address" 129 | }, 130 | { 131 | "internalType": "address", 132 | "name": "implementation", 133 | "type": "address" 134 | } 135 | ], 136 | "name": "upgrade", 137 | "outputs": [], 138 | "stateMutability": "nonpayable", 139 | "type": "function" 140 | }, 141 | { 142 | "inputs": [ 143 | { 144 | "internalType": "contract TransparentUpgradeableProxy", 145 | "name": "proxy", 146 | "type": "address" 147 | }, 148 | { 149 | "internalType": "address", 150 | "name": "implementation", 151 | "type": "address" 152 | }, 153 | { 154 | "internalType": "bytes", 155 | "name": "data", 156 | "type": "bytes" 157 | } 158 | ], 159 | "name": "upgradeAndCall", 160 | "outputs": [], 161 | "stateMutability": "payable", 162 | "type": "function" 163 | } 164 | ], 165 | "transactionHash": "0x1a00f204cb29ed58f098a3358491e15ec488b56afc3ea22fcd9c315fdf35d5d7", 166 | "receipt": { 167 | "to": null, 168 | "from": "0xD51bD125DEEe0d3CB12cf333B8910Ead844b5615", 169 | "contractAddress": "0xB71A7f2f2121780795e3b0acE7849C284Af6De9d", 170 | "transactionIndex": 28, 171 | "gasUsed": "671461", 172 | "logsBloom": "0x00000000000000000000080000000000000000000000000000800000000000000000000000000000000000000000000000000000000008000000000000000000000400000000000000000000000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000000200000000000000000000000000000000000000000000000000000000000001000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", 173 | "blockHash": "0x333f11e959d5a2c291567edef00c7dedae55a6047a76fe5ef93dd3b198b1624b", 174 | "transactionHash": "0x1a00f204cb29ed58f098a3358491e15ec488b56afc3ea22fcd9c315fdf35d5d7", 175 | "logs": [ 176 | { 177 | "transactionIndex": 28, 178 | "blockNumber": 10022070, 179 | "transactionHash": "0x1a00f204cb29ed58f098a3358491e15ec488b56afc3ea22fcd9c315fdf35d5d7", 180 | "address": "0xB71A7f2f2121780795e3b0acE7849C284Af6De9d", 181 | "topics": [ 182 | "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", 183 | "0x0000000000000000000000000000000000000000000000000000000000000000", 184 | "0x000000000000000000000000d51bd125deee0d3cb12cf333b8910ead844b5615" 185 | ], 186 | "data": "0x", 187 | "logIndex": 24, 188 | "blockHash": "0x333f11e959d5a2c291567edef00c7dedae55a6047a76fe5ef93dd3b198b1624b" 189 | } 190 | ], 191 | "blockNumber": 10022070, 192 | "cumulativeGasUsed": "4845421", 193 | "status": 1, 194 | "byzantium": true 195 | }, 196 | "args": [ 197 | "0xD51bD125DEEe0d3CB12cf333B8910Ead844b5615" 198 | ], 199 | "solcInputHash": "1635d55d57a0a2552952c0d22586ed23", 200 | "metadata": "{\"compiler\":{\"version\":\"0.7.6+commit.7338295f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"contract TransparentUpgradeableProxy\",\"name\":\"proxy\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"changeProxyAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract TransparentUpgradeableProxy\",\"name\":\"proxy\",\"type\":\"address\"}],\"name\":\"getProxyAdmin\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract TransparentUpgradeableProxy\",\"name\":\"proxy\",\"type\":\"address\"}],\"name\":\"getProxyImplementation\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract TransparentUpgradeableProxy\",\"name\":\"proxy\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"}],\"name\":\"upgrade\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract TransparentUpgradeableProxy\",\"name\":\"proxy\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"implementation\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"upgradeAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.\",\"kind\":\"dev\",\"methods\":{\"changeProxyAdmin(address,address)\":{\"details\":\"Changes the admin of `proxy` to `newAdmin`. Requirements: - This contract must be the current admin of `proxy`.\"},\"getProxyAdmin(address)\":{\"details\":\"Returns the current admin of `proxy`. Requirements: - This contract must be the admin of `proxy`.\"},\"getProxyImplementation(address)\":{\"details\":\"Returns the current implementation of `proxy`. Requirements: - This contract must be the admin of `proxy`.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"upgrade(address,address)\":{\"details\":\"Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}. Requirements: - This contract must be the admin of `proxy`.\"},\"upgradeAndCall(address,address,bytes)\":{\"details\":\"Upgrades `proxy` to `implementation` and calls a function on the new implementation. See {TransparentUpgradeableProxy-upgradeToAndCall}. Requirements: - This contract must be the admin of `proxy`.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solc_0.7/openzeppelin/proxy/ProxyAdmin.sol\":\"ProxyAdmin\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":999999},\"remappings\":[]},\"sources\":{\"solc_0.7/openzeppelin/GSN/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/*\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with GSN meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address payable) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes memory) {\\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0x910a2e625b71168563edf9eeef55a50d6d699acfe27ceba3921f291829a8f938\",\"license\":\"MIT\"},\"solc_0.7/openzeppelin/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"../GSN/Context.sol\\\";\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\ncontract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor (address initialOwner) {\\n _owner = initialOwner;\\n emit OwnershipTransferred(address(0), initialOwner);\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(_owner == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n emit OwnershipTransferred(_owner, address(0));\\n _owner = address(0);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n emit OwnershipTransferred(_owner, newOwner);\\n _owner = newOwner;\\n }\\n}\\n\",\"keccak256\":\"0x85eb3b8575f16937ed27e36fae8b617d9e3e7a7e49f04e10d52dad66d0fa9e75\",\"license\":\"MIT\"},\"solc_0.7/openzeppelin/proxy/Proxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\\n * be specified by overriding the virtual {_implementation} function.\\n * \\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\\n * different contract through the {_delegate} function.\\n * \\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\\n */\\nabstract contract Proxy {\\n /**\\n * @dev Delegates the current call to `implementation`.\\n * \\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _delegate(address implementation) internal {\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n // Copy msg.data. We take full control of memory in this inline assembly\\n // block because it will not return to Solidity code. We overwrite the\\n // Solidity scratch pad at memory position 0.\\n calldatacopy(0, 0, calldatasize())\\n\\n // Call the implementation.\\n // out and outsize are 0 because we don't know the size yet.\\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\\n\\n // Copy the returned data.\\n returndatacopy(0, 0, returndatasize())\\n\\n switch result\\n // delegatecall returns 0 on error.\\n case 0 { revert(0, returndatasize()) }\\n default { return(0, returndatasize()) }\\n }\\n }\\n\\n /**\\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\\n * and {_fallback} should delegate.\\n */\\n function _implementation() internal virtual view returns (address);\\n\\n /**\\n * @dev Delegates the current call to the address returned by `_implementation()`.\\n * \\n * This function does not return to its internall call site, it will return directly to the external caller.\\n */\\n function _fallback() internal {\\n _beforeFallback();\\n _delegate(_implementation());\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\\n * function in the contract matches the call data.\\n */\\n fallback () payable external {\\n _fallback();\\n }\\n\\n /**\\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\\n * is empty.\\n */\\n receive () payable external {\\n _fallback();\\n }\\n\\n /**\\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\\n * call, or as part of the Solidity `fallback` or `receive` functions.\\n * \\n * If overriden should call `super._beforeFallback()`.\\n */\\n function _beforeFallback() internal virtual {\\n }\\n}\\n\",\"keccak256\":\"0xc33f9858a67e34c77831163d5611d21fc627dfd2c303806a98a6c9db5a01b034\",\"license\":\"MIT\"},\"solc_0.7/openzeppelin/proxy/ProxyAdmin.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"../access/Ownable.sol\\\";\\nimport \\\"./TransparentUpgradeableProxy.sol\\\";\\n\\n/**\\n * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an\\n * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.\\n */\\ncontract ProxyAdmin is Ownable {\\n\\n constructor(address owner) Ownable(owner) {}\\n\\n /**\\n * @dev Returns the current implementation of `proxy`.\\n *\\n * Requirements:\\n *\\n * - This contract must be the admin of `proxy`.\\n */\\n function getProxyImplementation(TransparentUpgradeableProxy proxy) public view returns (address) {\\n // We need to manually run the static call since the getter cannot be flagged as view\\n // bytes4(keccak256(\\\"implementation()\\\")) == 0x5c60da1b\\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\\\"5c60da1b\\\");\\n require(success);\\n return abi.decode(returndata, (address));\\n }\\n\\n /**\\n * @dev Returns the current admin of `proxy`.\\n *\\n * Requirements:\\n *\\n * - This contract must be the admin of `proxy`.\\n */\\n function getProxyAdmin(TransparentUpgradeableProxy proxy) public view returns (address) {\\n // We need to manually run the static call since the getter cannot be flagged as view\\n // bytes4(keccak256(\\\"admin()\\\")) == 0xf851a440\\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\\\"f851a440\\\");\\n require(success);\\n return abi.decode(returndata, (address));\\n }\\n\\n /**\\n * @dev Changes the admin of `proxy` to `newAdmin`.\\n *\\n * Requirements:\\n *\\n * - This contract must be the current admin of `proxy`.\\n */\\n function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public onlyOwner {\\n proxy.changeAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.\\n *\\n * Requirements:\\n *\\n * - This contract must be the admin of `proxy`.\\n */\\n function upgrade(TransparentUpgradeableProxy proxy, address implementation) public onlyOwner {\\n proxy.upgradeTo(implementation);\\n }\\n\\n /**\\n * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See\\n * {TransparentUpgradeableProxy-upgradeToAndCall}.\\n *\\n * Requirements:\\n *\\n * - This contract must be the admin of `proxy`.\\n */\\n function upgradeAndCall(TransparentUpgradeableProxy proxy, address implementation, bytes memory data) public payable onlyOwner {\\n proxy.upgradeToAndCall{value: msg.value}(implementation, data);\\n }\\n}\\n\",\"keccak256\":\"0xae77885dd899a14e94f172e4e9ec7ef4b2ced0472904626c59b46150a26b5714\",\"license\":\"MIT\"},\"solc_0.7/openzeppelin/proxy/TransparentUpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"./UpgradeableProxy.sol\\\";\\n\\n/**\\n * @dev This contract implements a proxy that is upgradeable by an admin.\\n * \\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\\n * clashing], which can potentially be used in an attack, this contract uses the\\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\\n * things that go hand in hand:\\n * \\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\\n * that call matches one of the admin functions exposed by the proxy itself.\\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\\n * \\\"admin cannot fallback to proxy target\\\".\\n * \\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\\n * to sudden errors when trying to call a function from the proxy implementation.\\n * \\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\\n * you should think of the `ProxyAdmin` instance as the real administrative inerface of your proxy.\\n */\\ncontract TransparentUpgradeableProxy is UpgradeableProxy {\\n /**\\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\\n * optionally initialized with `_data` as explained in {UpgradeableProxy-constructor}.\\n */\\n constructor(address initialLogic, address initialAdmin, bytes memory _data) payable UpgradeableProxy(initialLogic, _data) {\\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.admin\\\")) - 1));\\n _setAdmin(initialAdmin);\\n }\\n\\n /**\\n * @dev Emitted when the admin account has changed.\\n */\\n event AdminChanged(address previousAdmin, address newAdmin);\\n\\n /**\\n * @dev Storage slot with the admin of the contract.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.admin\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 private constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\\n\\n /**\\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\\n */\\n modifier ifAdmin() {\\n if (msg.sender == _admin()) {\\n _;\\n } else {\\n _fallback();\\n }\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n * \\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\\n * \\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\\n */\\n function admin() external ifAdmin returns (address) {\\n return _admin();\\n }\\n\\n /**\\n * @dev Returns the current implementation.\\n * \\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\\n * \\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\\n */\\n function implementation() external ifAdmin returns (address) {\\n return _implementation();\\n }\\n\\n /**\\n * @dev Changes the admin of the proxy.\\n * \\n * Emits an {AdminChanged} event.\\n * \\n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\\n */\\n function changeAdmin(address newAdmin) external ifAdmin {\\n require(newAdmin != address(0), \\\"TransparentUpgradeableProxy: new admin is the zero address\\\");\\n emit AdminChanged(_admin(), newAdmin);\\n _setAdmin(newAdmin);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy.\\n * \\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\\n */\\n function upgradeTo(address newImplementation) external ifAdmin {\\n _upgradeTo(newImplementation);\\n }\\n\\n /**\\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\\n * proxied contract.\\n * \\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\\n */\\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\\n _upgradeTo(newImplementation);\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success,) = newImplementation.delegatecall(data);\\n require(success);\\n }\\n\\n /**\\n * @dev Returns the current admin.\\n */\\n function _admin() internal view returns (address adm) {\\n bytes32 slot = _ADMIN_SLOT;\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n adm := sload(slot)\\n }\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 admin slot.\\n */\\n function _setAdmin(address newAdmin) private {\\n bytes32 slot = _ADMIN_SLOT;\\n\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n sstore(slot, newAdmin)\\n }\\n }\\n\\n /**\\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\\n */\\n function _beforeFallback() internal override virtual {\\n require(msg.sender != _admin(), \\\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\\\");\\n super._beforeFallback();\\n }\\n}\\n\",\"keccak256\":\"0xd6cecbe00dc78355aff1a16d83487bb73c54701004d61a2e48cdb81e2bcacc26\",\"license\":\"MIT\"},\"solc_0.7/openzeppelin/proxy/UpgradeableProxy.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\nimport \\\"./Proxy.sol\\\";\\nimport \\\"../utils/Address.sol\\\";\\n\\n/**\\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\\n * implementation address that can be changed. This address is stored in storage in the location specified by\\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\\n * implementation behind the proxy.\\n * \\n * Upgradeability is only provided internally through {_upgradeTo}. For an externally upgradeable proxy see\\n * {TransparentUpgradeableProxy}.\\n */\\ncontract UpgradeableProxy is Proxy {\\n /**\\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\\n * \\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\\n */\\n constructor(address _logic, bytes memory _data) payable {\\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\\\"eip1967.proxy.implementation\\\")) - 1));\\n _setImplementation(_logic);\\n if(_data.length > 0) {\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success,) = _logic.delegatecall(_data);\\n require(success);\\n }\\n }\\n\\n /**\\n * @dev Emitted when the implementation is upgraded.\\n */\\n event Upgraded(address indexed implementation);\\n\\n /**\\n * @dev Storage slot with the address of the current implementation.\\n * This is the keccak-256 hash of \\\"eip1967.proxy.implementation\\\" subtracted by 1, and is\\n * validated in the constructor.\\n */\\n bytes32 private constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\\n\\n /**\\n * @dev Returns the current implementation address.\\n */\\n function _implementation() internal override view returns (address impl) {\\n bytes32 slot = _IMPLEMENTATION_SLOT;\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n impl := sload(slot)\\n }\\n }\\n\\n /**\\n * @dev Upgrades the proxy to a new implementation.\\n * \\n * Emits an {Upgraded} event.\\n */\\n function _upgradeTo(address newImplementation) internal {\\n _setImplementation(newImplementation);\\n emit Upgraded(newImplementation);\\n }\\n\\n /**\\n * @dev Stores a new address in the EIP1967 implementation slot.\\n */\\n function _setImplementation(address newImplementation) private {\\n require(Address.isContract(newImplementation), \\\"UpgradeableProxy: new implementation is not a contract\\\");\\n\\n bytes32 slot = _IMPLEMENTATION_SLOT;\\n\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n sstore(slot, newImplementation)\\n }\\n }\\n}\\n\",\"keccak256\":\"0xd68f4c11941712db79a61b9dca81a5db663cfacec3d7bb19f8d2c23bb1ab8afe\",\"license\":\"MIT\"},\"solc_0.7/openzeppelin/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.7.0;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // According to EIP-1052, 0x0 is the value returned for not-yet created accounts\\n // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned\\n // for accounts without code, i.e. `keccak256('')`\\n bytes32 codehash;\\n bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;\\n // solhint-disable-next-line no-inline-assembly\\n assembly { codehash := extcodehash(account) }\\n return (codehash != accountHash && codehash != 0x0);\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\\n (bool success, ) = recipient.call{ value: amount }(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain`call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\\n return _functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n return _functionCallWithValue(target, data, value, errorMessage);\\n }\\n\\n function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n // solhint-disable-next-line avoid-low-level-calls\\n (bool success, bytes memory returndata) = target.call{ value: weiValue }(data);\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n // solhint-disable-next-line no-inline-assembly\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x698f929f1097637d051976b322a2d532c27df022b09010e8d091e2888a5ebdf8\",\"license\":\"MIT\"}},\"version\":1}", 201 | "bytecode": "0x608060405234801561001057600080fd5b50604051610b54380380610b548339818101604052602081101561003357600080fd5b5051600080546001600160a01b0319166001600160a01b03831690811782556040518392907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a35050610ac68061008e6000396000f3fe60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461015d57806399a88ec414610229578063f2fde38b14610271578063f3b7dead146102b15761007b565b8063204e1c7a14610080578063715018a6146100e95780637eff275e146101005780638da5cb5b14610148575b600080fd5b34801561008c57600080fd5b506100c0600480360360208110156100a357600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166102f1565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b3480156100f557600080fd5b506100fe6103a9565b005b34801561010c57600080fd5b506100fe6004803603604081101561012357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160200135166104a9565b34801561015457600080fd5b506100c06105bf565b6100fe6004803603606081101561017357600080fd5b73ffffffffffffffffffffffffffffffffffffffff82358116926020810135909116918101906060810160408201356401000000008111156101b457600080fd5b8201836020820111156101c657600080fd5b803590602001918460018302840111640100000000831117156101e857600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506105db945050505050565b34801561023557600080fd5b506100fe6004803603604081101561024c57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135811691602001351661075d565b34801561027d57600080fd5b506100fe6004803603602081101561029457600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610857565b3480156102bd57600080fd5b506100c0600480360360208110156102d457600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166109e1565b60008060008373ffffffffffffffffffffffffffffffffffffffff1660405180807f5c60da1b000000000000000000000000000000000000000000000000000000008152506004019050600060405180830381855afa9150503d8060008114610376576040519150601f19603f3d011682016040523d82523d6000602084013e61037b565b606091505b50915091508161038a57600080fd5b80806020019051602081101561039f57600080fd5b5051949350505050565b6103b1610a66565b60005473ffffffffffffffffffffffffffffffffffffffff90811691161461043a57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6000805460405173ffffffffffffffffffffffffffffffffffffffff909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b6104b1610a66565b60005473ffffffffffffffffffffffffffffffffffffffff90811691161461053a57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b8173ffffffffffffffffffffffffffffffffffffffff16638f283970826040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff168152602001915050600060405180830381600087803b1580156105a357600080fd5b505af11580156105b7573d6000803e3d6000fd5b505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff1690565b6105e3610a66565b60005473ffffffffffffffffffffffffffffffffffffffff90811691161461066c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b8273ffffffffffffffffffffffffffffffffffffffff16634f1ef2863484846040518463ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b838110156106f35781810151838201526020016106db565b50505050905090810190601f1680156107205780820380516001836020036101000a031916815260200191505b5093505050506000604051808303818588803b15801561073f57600080fd5b505af1158015610753573d6000803e3d6000fd5b5050505050505050565b610765610a66565b60005473ffffffffffffffffffffffffffffffffffffffff9081169116146107ee57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b8173ffffffffffffffffffffffffffffffffffffffff16633659cfe6826040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff168152602001915050600060405180830381600087803b1580156105a357600080fd5b61085f610a66565b60005473ffffffffffffffffffffffffffffffffffffffff9081169116146108e857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116610954576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180610a6b6026913960400191505060405180910390fd5b6000805460405173ffffffffffffffffffffffffffffffffffffffff808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60008060008373ffffffffffffffffffffffffffffffffffffffff1660405180807ff851a440000000000000000000000000000000000000000000000000000000008152506004019050600060405180830381855afa9150503d8060008114610376576040519150601f19603f3d011682016040523d82523d6000602084013e61037b565b339056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373a264697066735822122033c7eab8e5a7904ed291c191ebc004b4929d46e0bcbd0fea73fa80b0475d931164736f6c63430007060033", 202 | "deployedBytecode": "0x60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461015d57806399a88ec414610229578063f2fde38b14610271578063f3b7dead146102b15761007b565b8063204e1c7a14610080578063715018a6146100e95780637eff275e146101005780638da5cb5b14610148575b600080fd5b34801561008c57600080fd5b506100c0600480360360208110156100a357600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166102f1565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b3480156100f557600080fd5b506100fe6103a9565b005b34801561010c57600080fd5b506100fe6004803603604081101561012357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160200135166104a9565b34801561015457600080fd5b506100c06105bf565b6100fe6004803603606081101561017357600080fd5b73ffffffffffffffffffffffffffffffffffffffff82358116926020810135909116918101906060810160408201356401000000008111156101b457600080fd5b8201836020820111156101c657600080fd5b803590602001918460018302840111640100000000831117156101e857600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506105db945050505050565b34801561023557600080fd5b506100fe6004803603604081101561024c57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135811691602001351661075d565b34801561027d57600080fd5b506100fe6004803603602081101561029457600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610857565b3480156102bd57600080fd5b506100c0600480360360208110156102d457600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166109e1565b60008060008373ffffffffffffffffffffffffffffffffffffffff1660405180807f5c60da1b000000000000000000000000000000000000000000000000000000008152506004019050600060405180830381855afa9150503d8060008114610376576040519150601f19603f3d011682016040523d82523d6000602084013e61037b565b606091505b50915091508161038a57600080fd5b80806020019051602081101561039f57600080fd5b5051949350505050565b6103b1610a66565b60005473ffffffffffffffffffffffffffffffffffffffff90811691161461043a57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6000805460405173ffffffffffffffffffffffffffffffffffffffff909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b6104b1610a66565b60005473ffffffffffffffffffffffffffffffffffffffff90811691161461053a57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b8173ffffffffffffffffffffffffffffffffffffffff16638f283970826040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff168152602001915050600060405180830381600087803b1580156105a357600080fd5b505af11580156105b7573d6000803e3d6000fd5b505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff1690565b6105e3610a66565b60005473ffffffffffffffffffffffffffffffffffffffff90811691161461066c57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b8273ffffffffffffffffffffffffffffffffffffffff16634f1ef2863484846040518463ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff16815260200180602001828103825283818151815260200191508051906020019080838360005b838110156106f35781810151838201526020016106db565b50505050905090810190601f1680156107205780820380516001836020036101000a031916815260200191505b5093505050506000604051808303818588803b15801561073f57600080fd5b505af1158015610753573d6000803e3d6000fd5b5050505050505050565b610765610a66565b60005473ffffffffffffffffffffffffffffffffffffffff9081169116146107ee57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b8173ffffffffffffffffffffffffffffffffffffffff16633659cfe6826040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff168152602001915050600060405180830381600087803b1580156105a357600080fd5b61085f610a66565b60005473ffffffffffffffffffffffffffffffffffffffff9081169116146108e857604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116610954576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526026815260200180610a6b6026913960400191505060405180910390fd5b6000805460405173ffffffffffffffffffffffffffffffffffffffff808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60008060008373ffffffffffffffffffffffffffffffffffffffff1660405180807ff851a440000000000000000000000000000000000000000000000000000000008152506004019050600060405180830381855afa9150503d8060008114610376576040519150601f19603f3d011682016040523d82523d6000602084013e61037b565b339056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373a264697066735822122033c7eab8e5a7904ed291c191ebc004b4929d46e0bcbd0fea73fa80b0475d931164736f6c63430007060033", 203 | "devdoc": { 204 | "details": "This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.", 205 | "kind": "dev", 206 | "methods": { 207 | "changeProxyAdmin(address,address)": { 208 | "details": "Changes the admin of `proxy` to `newAdmin`. Requirements: - This contract must be the current admin of `proxy`." 209 | }, 210 | "getProxyAdmin(address)": { 211 | "details": "Returns the current admin of `proxy`. Requirements: - This contract must be the admin of `proxy`." 212 | }, 213 | "getProxyImplementation(address)": { 214 | "details": "Returns the current implementation of `proxy`. Requirements: - This contract must be the admin of `proxy`." 215 | }, 216 | "owner()": { 217 | "details": "Returns the address of the current owner." 218 | }, 219 | "renounceOwnership()": { 220 | "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." 221 | }, 222 | "transferOwnership(address)": { 223 | "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." 224 | }, 225 | "upgrade(address,address)": { 226 | "details": "Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}. Requirements: - This contract must be the admin of `proxy`." 227 | }, 228 | "upgradeAndCall(address,address,bytes)": { 229 | "details": "Upgrades `proxy` to `implementation` and calls a function on the new implementation. See {TransparentUpgradeableProxy-upgradeToAndCall}. Requirements: - This contract must be the admin of `proxy`." 230 | } 231 | }, 232 | "version": 1 233 | }, 234 | "userdoc": { 235 | "kind": "user", 236 | "methods": {}, 237 | "version": 1 238 | }, 239 | "storageLayout": { 240 | "storage": [ 241 | { 242 | "astId": 30, 243 | "contract": "solc_0.7/openzeppelin/proxy/ProxyAdmin.sol:ProxyAdmin", 244 | "label": "_owner", 245 | "offset": 0, 246 | "slot": "0", 247 | "type": "t_address" 248 | } 249 | ], 250 | "types": { 251 | "t_address": { 252 | "encoding": "inplace", 253 | "label": "address", 254 | "numberOfBytes": "20" 255 | } 256 | } 257 | } 258 | } -------------------------------------------------------------------------------- /deployments/rinkeby/solcInputs/1635d55d57a0a2552952c0d22586ed23.json: -------------------------------------------------------------------------------- 1 | { 2 | "language": "Solidity", 3 | "sources": { 4 | "solc_0.7/openzeppelin/access/Ownable.sol": { 5 | "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0;\n\nimport \"../GSN/Context.sol\";\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\ncontract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor (address initialOwner) {\n _owner = initialOwner;\n emit OwnershipTransferred(address(0), initialOwner);\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\n _;\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n emit OwnershipTransferred(_owner, address(0));\n _owner = address(0);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n emit OwnershipTransferred(_owner, newOwner);\n _owner = newOwner;\n }\n}\n" 6 | }, 7 | "solc_0.7/openzeppelin/GSN/Context.sol": { 8 | "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0;\n\n/*\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with GSN meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address payable) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes memory) {\n this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n return msg.data;\n }\n}\n" 9 | }, 10 | "solc_0.7/openzeppelin/proxy/ProxyAdmin.sol": { 11 | "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0;\n\nimport \"../access/Ownable.sol\";\nimport \"./TransparentUpgradeableProxy.sol\";\n\n/**\n * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an\n * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.\n */\ncontract ProxyAdmin is Ownable {\n\n constructor(address owner) Ownable(owner) {}\n\n /**\n * @dev Returns the current implementation of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyImplementation(TransparentUpgradeableProxy proxy) public view returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"implementation()\")) == 0x5c60da1b\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"5c60da1b\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Returns the current admin of `proxy`.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function getProxyAdmin(TransparentUpgradeableProxy proxy) public view returns (address) {\n // We need to manually run the static call since the getter cannot be flagged as view\n // bytes4(keccak256(\"admin()\")) == 0xf851a440\n (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"f851a440\");\n require(success);\n return abi.decode(returndata, (address));\n }\n\n /**\n * @dev Changes the admin of `proxy` to `newAdmin`.\n *\n * Requirements:\n *\n * - This contract must be the current admin of `proxy`.\n */\n function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public onlyOwner {\n proxy.changeAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgrade(TransparentUpgradeableProxy proxy, address implementation) public onlyOwner {\n proxy.upgradeTo(implementation);\n }\n\n /**\n * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See\n * {TransparentUpgradeableProxy-upgradeToAndCall}.\n *\n * Requirements:\n *\n * - This contract must be the admin of `proxy`.\n */\n function upgradeAndCall(TransparentUpgradeableProxy proxy, address implementation, bytes memory data) public payable onlyOwner {\n proxy.upgradeToAndCall{value: msg.value}(implementation, data);\n }\n}\n" 12 | }, 13 | "solc_0.7/openzeppelin/proxy/TransparentUpgradeableProxy.sol": { 14 | "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0;\n\nimport \"./UpgradeableProxy.sol\";\n\n/**\n * @dev This contract implements a proxy that is upgradeable by an admin.\n * \n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\n * clashing], which can potentially be used in an attack, this contract uses the\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\n * things that go hand in hand:\n * \n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\n * that call matches one of the admin functions exposed by the proxy itself.\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\n * \"admin cannot fallback to proxy target\".\n * \n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\n * to sudden errors when trying to call a function from the proxy implementation.\n * \n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\n * you should think of the `ProxyAdmin` instance as the real administrative inerface of your proxy.\n */\ncontract TransparentUpgradeableProxy is UpgradeableProxy {\n /**\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\n * optionally initialized with `_data` as explained in {UpgradeableProxy-constructor}.\n */\n constructor(address initialLogic, address initialAdmin, bytes memory _data) payable UpgradeableProxy(initialLogic, _data) {\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.admin\")) - 1));\n _setAdmin(initialAdmin);\n }\n\n /**\n * @dev Emitted when the admin account has changed.\n */\n event AdminChanged(address previousAdmin, address newAdmin);\n\n /**\n * @dev Storage slot with the admin of the contract.\n * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 private constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n /**\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\n */\n modifier ifAdmin() {\n if (msg.sender == _admin()) {\n _;\n } else {\n _fallback();\n }\n }\n\n /**\n * @dev Returns the current admin.\n * \n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\n * \n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\n */\n function admin() external ifAdmin returns (address) {\n return _admin();\n }\n\n /**\n * @dev Returns the current implementation.\n * \n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\n * \n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\n */\n function implementation() external ifAdmin returns (address) {\n return _implementation();\n }\n\n /**\n * @dev Changes the admin of the proxy.\n * \n * Emits an {AdminChanged} event.\n * \n * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.\n */\n function changeAdmin(address newAdmin) external ifAdmin {\n require(newAdmin != address(0), \"TransparentUpgradeableProxy: new admin is the zero address\");\n emit AdminChanged(_admin(), newAdmin);\n _setAdmin(newAdmin);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy.\n * \n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\n */\n function upgradeTo(address newImplementation) external ifAdmin {\n _upgradeTo(newImplementation);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\n * proxied contract.\n * \n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\n */\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\n _upgradeTo(newImplementation);\n // solhint-disable-next-line avoid-low-level-calls\n (bool success,) = newImplementation.delegatecall(data);\n require(success);\n }\n\n /**\n * @dev Returns the current admin.\n */\n function _admin() internal view returns (address adm) {\n bytes32 slot = _ADMIN_SLOT;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n adm := sload(slot)\n }\n }\n\n /**\n * @dev Stores a new address in the EIP1967 admin slot.\n */\n function _setAdmin(address newAdmin) private {\n bytes32 slot = _ADMIN_SLOT;\n\n // solhint-disable-next-line no-inline-assembly\n assembly {\n sstore(slot, newAdmin)\n }\n }\n\n /**\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\n */\n function _beforeFallback() internal override virtual {\n require(msg.sender != _admin(), \"TransparentUpgradeableProxy: admin cannot fallback to proxy target\");\n super._beforeFallback();\n }\n}\n" 15 | }, 16 | "solc_0.7/openzeppelin/proxy/UpgradeableProxy.sol": { 17 | "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0;\n\nimport \"./Proxy.sol\";\nimport \"../utils/Address.sol\";\n\n/**\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\n * implementation address that can be changed. This address is stored in storage in the location specified by\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\n * implementation behind the proxy.\n * \n * Upgradeability is only provided internally through {_upgradeTo}. For an externally upgradeable proxy see\n * {TransparentUpgradeableProxy}.\n */\ncontract UpgradeableProxy is Proxy {\n /**\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\n * \n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\n * function call, and allows initializating the storage of the proxy like a Solidity constructor.\n */\n constructor(address _logic, bytes memory _data) payable {\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.implementation\")) - 1));\n _setImplementation(_logic);\n if(_data.length > 0) {\n // solhint-disable-next-line avoid-low-level-calls\n (bool success,) = _logic.delegatecall(_data);\n require(success);\n }\n }\n\n /**\n * @dev Emitted when the implementation is upgraded.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Storage slot with the address of the current implementation.\n * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 private constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /**\n * @dev Returns the current implementation address.\n */\n function _implementation() internal override view returns (address impl) {\n bytes32 slot = _IMPLEMENTATION_SLOT;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n impl := sload(slot)\n }\n }\n\n /**\n * @dev Upgrades the proxy to a new implementation.\n * \n * Emits an {Upgraded} event.\n */\n function _upgradeTo(address newImplementation) internal {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Stores a new address in the EIP1967 implementation slot.\n */\n function _setImplementation(address newImplementation) private {\n require(Address.isContract(newImplementation), \"UpgradeableProxy: new implementation is not a contract\");\n\n bytes32 slot = _IMPLEMENTATION_SLOT;\n\n // solhint-disable-next-line no-inline-assembly\n assembly {\n sstore(slot, newImplementation)\n }\n }\n}\n" 18 | }, 19 | "solc_0.7/openzeppelin/proxy/Proxy.sol": { 20 | "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n * \n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n * \n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n /**\n * @dev Delegates the current call to `implementation`.\n * \n * This function does not return to its internall call site, it will return directly to the external caller.\n */\n function _delegate(address implementation) internal {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n // Copy msg.data. We take full control of memory in this inline assembly\n // block because it will not return to Solidity code. We overwrite the\n // Solidity scratch pad at memory position 0.\n calldatacopy(0, 0, calldatasize())\n\n // Call the implementation.\n // out and outsize are 0 because we don't know the size yet.\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\n\n // Copy the returned data.\n returndatacopy(0, 0, returndatasize())\n\n switch result\n // delegatecall returns 0 on error.\n case 0 { revert(0, returndatasize()) }\n default { return(0, returndatasize()) }\n }\n }\n\n /**\n * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function\n * and {_fallback} should delegate.\n */\n function _implementation() internal virtual view returns (address);\n\n /**\n * @dev Delegates the current call to the address returned by `_implementation()`.\n * \n * This function does not return to its internall call site, it will return directly to the external caller.\n */\n function _fallback() internal {\n _beforeFallback();\n _delegate(_implementation());\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n * function in the contract matches the call data.\n */\n fallback () payable external {\n _fallback();\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\n * is empty.\n */\n receive () payable external {\n _fallback();\n }\n\n /**\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\n * call, or as part of the Solidity `fallback` or `receive` functions.\n * \n * If overriden should call `super._beforeFallback()`.\n */\n function _beforeFallback() internal virtual {\n }\n}\n" 21 | }, 22 | "solc_0.7/openzeppelin/utils/Address.sol": { 23 | "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // According to EIP-1052, 0x0 is the value returned for not-yet created accounts\n // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned\n // for accounts without code, i.e. `keccak256('')`\n bytes32 codehash;\n bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;\n // solhint-disable-next-line no-inline-assembly\n assembly { codehash := extcodehash(account) }\n return (codehash != accountHash && codehash != 0x0);\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\n (bool success, ) = recipient.call{ value: amount }(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain`call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {\n return _functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n return _functionCallWithValue(target, data, value, errorMessage);\n }\n\n function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {\n require(isContract(target), \"Address: call to non-contract\");\n\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returndata) = target.call{ value: weiValue }(data);\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n // solhint-disable-next-line no-inline-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n" 24 | }, 25 | "solc_0.7/proxy/OptimizedTransparentUpgradeableProxy.sol": { 26 | "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.7.0;\n\nimport \"../openzeppelin/proxy/UpgradeableProxy.sol\";\n\n/**\n * @dev This contract implements a proxy that is upgradeable by an admin.\n *\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\n * clashing], which can potentially be used in an attack, this contract uses the\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\n * things that go hand in hand:\n *\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\n * that call matches one of the admin functions exposed by the proxy itself.\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\n * \"admin cannot fallback to proxy target\".\n *\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\n * to sudden errors when trying to call a function from the proxy implementation.\n *\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\n * you should think of the `ProxyAdmin` instance as the real administrative inerface of your proxy.\n */\ncontract OptimizedTransparentUpgradeableProxy is UpgradeableProxy {\n address internal immutable _ADMIN;\n\n /**\n * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\n * optionally initialized with `_data` as explained in {UpgradeableProxy-constructor}.\n */\n constructor(\n address initialLogic,\n address initialAdmin,\n bytes memory _data\n ) payable UpgradeableProxy(initialLogic, _data) {\n assert(_ADMIN_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.admin\")) - 1));\n bytes32 slot = _ADMIN_SLOT;\n\n _ADMIN = initialAdmin;\n\n // still store it to work with EIP-1967\n // solhint-disable-next-line no-inline-assembly\n assembly {\n sstore(slot, initialAdmin)\n }\n }\n\n /**\n * @dev Storage slot with the admin of the contract.\n * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 private constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n /**\n * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\n */\n modifier ifAdmin() {\n if (msg.sender == _admin()) {\n _;\n } else {\n _fallback();\n }\n }\n\n /**\n * @dev Returns the current admin.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\n */\n function admin() external ifAdmin returns (address) {\n return _admin();\n }\n\n /**\n * @dev Returns the current implementation.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\n */\n function implementation() external ifAdmin returns (address) {\n return _implementation();\n }\n\n /**\n * @dev Upgrade the implementation of the proxy.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.\n */\n function upgradeTo(address newImplementation) external ifAdmin {\n _upgradeTo(newImplementation);\n }\n\n /**\n * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\n * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\n * proxied contract.\n *\n * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.\n */\n function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {\n _upgradeTo(newImplementation);\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, ) = newImplementation.delegatecall(data);\n require(success);\n }\n\n /**\n * @dev Returns the current admin.\n */\n function _admin() internal view returns (address adm) {\n return _ADMIN;\n }\n\n /**\n * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.\n */\n function _beforeFallback() internal virtual override {\n require(msg.sender != _admin(), \"TransparentUpgradeableProxy: admin cannot fallback to proxy target\");\n super._beforeFallback();\n }\n}\n" 27 | } 28 | }, 29 | "settings": { 30 | "optimizer": { 31 | "enabled": true, 32 | "runs": 999999 33 | }, 34 | "outputSelection": { 35 | "*": { 36 | "*": [ 37 | "abi", 38 | "evm.bytecode", 39 | "evm.deployedBytecode", 40 | "evm.methodIdentifiers", 41 | "metadata", 42 | "devdoc", 43 | "userdoc", 44 | "storageLayout", 45 | "evm.gasEstimates" 46 | ], 47 | "": [ 48 | "ast" 49 | ] 50 | } 51 | }, 52 | "metadata": { 53 | "useLiteralContent": true 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /hardhat.config.js: -------------------------------------------------------------------------------- 1 | require("dotenv").config(); 2 | 3 | require("hardhat-deploy"); 4 | require("@nomiclabs/hardhat-waffle"); 5 | require("@nomiclabs/hardhat-truffle5"); 6 | require("@nomiclabs/hardhat-etherscan"); 7 | require("@nomiclabs/hardhat-ethers"); 8 | // require("@typechain/hardhat"); 9 | require("./tasks/compileOne.js"); 10 | // require("@setprotocol/index-coop-contracts"); 11 | 12 | /** 13 | * @type import('hardhat/config').HardhatUserConfig 14 | */ 15 | module.exports = { 16 | namedAccounts: { 17 | deployer: 0, 18 | }, 19 | etherscan: { 20 | apiKey: process.env.ETHERSCAN_API_KEY, 21 | }, 22 | networks: { 23 | hardhat: { 24 | allowUnlimitedContractSize: true, 25 | }, 26 | rinkeby: { 27 | url: process.env.RPC_URL, 28 | accounts: [process.env.ACC_PRIVATE_KEY], 29 | }, 30 | bsclocal: { 31 | url: "http://127.0.0.1:8885", 32 | accounts: [process.env.ACC_PRIVATE_KEY], 33 | }, 34 | bsctestnet: { 35 | url: "https://data-seed-prebsc-2-s3.binance.org:8545/", 36 | accounts: [process.env.ACC_PRIVATE_KEY], 37 | }, 38 | bscmainnet: { 39 | url: process.env.RPC_URL, 40 | accounts: [process.env.ACC_PRIVATE_KEY], 41 | chainId: 56 42 | }, 43 | }, 44 | solidity: { 45 | compilers: [ 46 | { 47 | version: "0.6.12", 48 | settings: { 49 | evmVersion: "istanbul", 50 | optimizer: { 51 | enabled: true, 52 | runs: 1000000, 53 | details: { yul: true, deduplicate: true, cse: true, constantOptimizer: true }, 54 | }, 55 | }, 56 | }, 57 | { 58 | version: "0.8.3", 59 | settings: { 60 | evmVersion: "istanbul", 61 | optimizer: { 62 | enabled: true, 63 | runs: 1000000, 64 | details: { 65 | yul: true, 66 | deduplicate: true, 67 | cse: true, 68 | constantOptimizer: true, 69 | }, 70 | }, 71 | }, 72 | }, 73 | { 74 | version: "0.8.0", 75 | settings: { 76 | evmVersion: "istanbul", 77 | optimizer: { 78 | enabled: true, 79 | runs: 1000000, 80 | details: { 81 | yul: true, 82 | deduplicate: true, 83 | cse: true, 84 | constantOptimizer: true, 85 | }, 86 | }, 87 | }, 88 | }, 89 | ], 90 | }, 91 | }; 92 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "fintech", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "accounts": "hardhat accounts", 8 | "compile": "hardhat compile", 9 | "deploy:hardhat": "hardhat deploy --network hardhat", 10 | "deploy:rinkeby": "hardhat deploy --network rinkeby", 11 | "test": "hardhat test" 12 | }, 13 | "keywords": [], 14 | "author": "", 15 | "license": "ISC", 16 | "devDependencies": { 17 | "@nomiclabs/hardhat-ethers": "2.0.2", 18 | "@nomiclabs/hardhat-etherscan": "2.1.2", 19 | "@nomiclabs/hardhat-truffle5": "2.0.0", 20 | "@nomiclabs/hardhat-waffle": "2.0.1", 21 | "@nomiclabs/hardhat-web3": "2.0.0", 22 | "chai": "4.3.4", 23 | "dotenv": "10.0.0", 24 | "ethereum-waffle": "3.3.0", 25 | "ethers": "5.2.0", 26 | "hardhat": "2.7.0", 27 | "hardhat-deploy": "0.9.3" 28 | }, 29 | "dependencies": { 30 | "@openzeppelin/contracts": "^4.3.2", 31 | "@openzeppelin/contracts-upgradeable": "^4.4.2", 32 | "@setprotocol/index-coop-contracts": "^0.0.26", 33 | "@typechain/hardhat": "^2.3.0", 34 | "chai-as-promised": "^7.1.1", 35 | "chai-bn": "^0.3.0", 36 | "eth-saddle": "^0.1.25", 37 | "hardhat-typechain": "^0.3.5", 38 | "jest-diff": "^27.3.1", 39 | "jest-junit": "^13.0.0", 40 | "solidity-coverage": "^0.7.16", 41 | "typechain": "^5.1.2" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /tasks/compileOne.js: -------------------------------------------------------------------------------- 1 | const { 2 | TASK_COMPILE_SOLIDITY_GET_COMPILATION_JOB_FOR_FILE, 3 | TASK_COMPILE_SOLIDITY_GET_DEPENDENCY_GRAPH, 4 | TASK_COMPILE_SOLIDITY_COMPILE_JOB 5 | } = require("hardhat/builtin-tasks/task-names"); 6 | 7 | // import * as taskTypes from "hardhat/types/builtin-tasks"; 8 | // const { taskTypes } = require("hardhat/types/builtin-tasks"); 9 | require("hardhat/types/builtin-tasks"); 10 | 11 | task("set:compile:one", "Compiles a single contract in isolation") 12 | .addPositionalParam("contractName") 13 | .setAction(async function(args, env) { 14 | 15 | const sourceName = env.artifacts.readArtifactSync(args.contractName).sourceName; 16 | 17 | const dependencyGraph = await env.run( 18 | TASK_COMPILE_SOLIDITY_GET_DEPENDENCY_GRAPH, 19 | { sourceNames: [sourceName] } 20 | ); 21 | 22 | const resolvedFiles = dependencyGraph 23 | .getResolvedFiles() 24 | .filter(resolvedFile => { 25 | return resolvedFile.sourceName === sourceName; 26 | }); 27 | 28 | const compilationJob = await env.run( 29 | TASK_COMPILE_SOLIDITY_GET_COMPILATION_JOB_FOR_FILE, 30 | { 31 | dependencyGraph, 32 | file: resolvedFiles[0], 33 | } 34 | ); 35 | 36 | await env.run(TASK_COMPILE_SOLIDITY_COMPILE_JOB, { 37 | compilationJob, 38 | compilationJobs: [compilationJob], 39 | compilationJobIndex: 0, 40 | emitsArtifacts: true, 41 | quiet: true, 42 | }); 43 | 44 | // await env.run("typechain"); 45 | }); 46 | -------------------------------------------------------------------------------- /tasks/index.ts: -------------------------------------------------------------------------------- 1 | export * from './compileOne'; -------------------------------------------------------------------------------- /test/Ethereum.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const BigNum = require('bignumber.js'); 4 | const { ethers } = require('hardhat'); 5 | 6 | function etherUnsigned(num) { 7 | return new BigNum(num).toFixed(); 8 | } 9 | 10 | async function increaseTime(seconds) { 11 | await rpc({ method: 'evm_increaseTime', params: [seconds] }); 12 | return rpc({ method: 'evm_mine' }); 13 | } 14 | 15 | async function setTime(seconds) { 16 | await rpc({ method: 'evm_setTime', params: [new Date(seconds * 1000)] }); 17 | } 18 | 19 | async function freezeTime(seconds) { 20 | await rpc({ method: 'evm_freezeTime', params: [seconds] }); 21 | return rpc({ method: 'evm_mine' }); 22 | } 23 | 24 | async function mineBlockNumber(blockNumber) { 25 | // return rpc({method: 'evm_mineBlockNumber', params: [blockNumber]}); 26 | const current = await ethers.provider.getBlockNumber(); 27 | await ethers.provider.send('evm_mine', [blockNumber + current]); 28 | } 29 | 30 | async function advanceBlock() { 31 | return ethers.provider.send("evm_mine", []); 32 | } 33 | async function advanceBlockTo(blockNumber) { 34 | for (let i = await ethers.provider.getBlockNumber(); i < blockNumber; i++) { 35 | await advanceBlock(); 36 | } 37 | } 38 | 39 | async function advanceIncreaseBlock(blockNumber) { 40 | const current = await ethers.provider.getBlockNumber(); 41 | const to = blockNumber + current; 42 | for (let i = await ethers.provider.getBlockNumber(); i < to; i++) { 43 | await advanceBlock(); 44 | } 45 | } 46 | 47 | 48 | module.exports = { 49 | etherUnsigned, 50 | freezeTime, 51 | increaseTime, 52 | setTime, 53 | mineBlockNumber, 54 | advanceBlockTo, 55 | advanceBlock, 56 | advanceIncreaseBlock 57 | }; 58 | -------------------------------------------------------------------------------- /test/stakingAllocate.js: -------------------------------------------------------------------------------- 1 | const FakeToken = artifacts.require('FakeToken'); 2 | const Staking = artifacts.require('CHNStaking'); 3 | const { default: BigNumber } = require('bignumber.js'); 4 | const { assert } = require('chai'); 5 | const { ethers, waffle } = require('hardhat'); 6 | 7 | const BN = web3.utils.BN; 8 | const { 9 | etherUnsigned, 10 | mineBlockNumber, 11 | advanceBlockTo, 12 | advanceBlock, 13 | advanceIncreaseBlock 14 | } = require('./Ethereum'); 15 | 16 | require('chai') 17 | .use(require('chai-as-promised')) 18 | .use(require('chai-bn')(BN)) 19 | .should(); 20 | 21 | contract('Staking Contract', function (accounts) { 22 | let root = accounts[0]; 23 | let a1 = accounts[1]; 24 | let a2 = accounts[2]; 25 | let a3 = accounts[3]; 26 | let a4 = accounts[4]; 27 | let a5 = accounts[5]; 28 | let token; 29 | let staking; 30 | let initAmount = new BN("10000000000000000000000000"); 31 | let periodAmount = new BN("250000000000000000000000"); 32 | const REWARD_SCALE = 10 ** 18; 33 | let rewardPerBlock = new BigNumber('100000000000000000000'); 34 | const bonus = new BigNumber('10'); 35 | const timeBonus = new BigNumber('100'); 36 | 37 | beforeEach(async () => { 38 | token = await FakeToken.new("10000000000000000000000000"); 39 | const block = await ethers.provider.getBlock("latest"); 40 | staking = await Staking.new(token.address, rewardPerBlock.toString(), block.number, block.number + timeBonus.toNumber(), bonus.toString()); 41 | }); 42 | 43 | it('create pool', async() => { 44 | await expectThrow(staking.add(100, token.address, 1, {from: a1}), "Ownable: caller is not the owner"); 45 | await staking.add(100, token.address, 1, {from: root}); 46 | const pool = await staking.poolInfo(0); 47 | assert(pool.stakeToken == token.address); 48 | assert(pool.lastRewardBlock == 4); 49 | assert(pool.accCHNPerShare == 0); 50 | assert(pool.totalAmountStake == 0); 51 | }) 52 | 53 | it('staking', async() => { 54 | await staking.add(100, token.address, 1); 55 | const stakeAmount = "1000000000000000000"; 56 | await token.mintForUser(initAmount, {from: a1}); 57 | await token.approve(staking.address, initAmount, {from: a1}); 58 | await staking.stake(0, stakeAmount, {from: a1}); 59 | let totalReward = await staking.pendingReward(0, a1); 60 | assert(totalReward.toString() == '0'); 61 | await advanceIncreaseBlock(1); 62 | totalReward = await staking.pendingReward(0, a1); 63 | assert(totalReward.toString() == rewardPerBlock.times(bonus).toFixed().toString()); 64 | await advanceIncreaseBlock(10); 65 | totalReward = await staking.pendingReward(0, a1); 66 | assert(totalReward.toString() == rewardPerBlock.times(bonus).times(11).toFixed().toString()); 67 | 68 | await staking.stake(0, stakeAmount, {from: a1}); 69 | }) 70 | 71 | 72 | it('withdraw', async () => { 73 | await staking.add(100, token.address, 1); 74 | const stakeAmount = "1000000000000000000"; 75 | await token.mintForUser(initAmount, {from: root}); 76 | await token.mintForUser(initAmount, {from: a1}); 77 | await token.transfer(staking.address, initAmount, {from: root}); 78 | await token.approve(staking.address, initAmount, {from: a1}); 79 | await staking.stake(0, stakeAmount, {from: a1}); 80 | let totalReward = await staking.pendingReward(0, a1); 81 | assert(totalReward.toString() == '0'); 82 | await advanceIncreaseBlock(49); 83 | totalReward = await staking.pendingReward(0, a1); 84 | assert(totalReward.toString() == rewardPerBlock.times(bonus).times(49).toFixed().toString()); 85 | const oldAmount = await token.balanceOf(a1); 86 | await staking.withdraw(0, stakeAmount, {from: a1}); 87 | let pendingReward = rewardPerBlock.times(bonus).times(50); 88 | totalReward = await staking.pendingReward(0, a1); 89 | assert(totalReward.toString() == '0'); 90 | let currentAmount = await token.balanceOf(a1); 91 | assert(pendingReward.plus(stakeAmount).plus(oldAmount).toFixed().toString() == currentAmount.toString()); 92 | 93 | }); 94 | 95 | it('emergencyWithdraw', async () => { 96 | await staking.add(100, token.address, 1); 97 | const stakeAmount = "1000000000000000000"; 98 | await token.mintForUser(initAmount, {from: root}); 99 | await token.mintForUser(initAmount, {from: a1}); 100 | await token.transfer(staking.address, initAmount, {from: root}); 101 | await token.approve(staking.address, initAmount, {from: a1}); 102 | await staking.stake(0, stakeAmount, {from: a1}); 103 | let totalReward = await staking.pendingReward(0, a1); 104 | assert(totalReward.toString() == '0'); 105 | await advanceIncreaseBlock(49); 106 | totalReward = await staking.pendingReward(0, a1); 107 | assert(totalReward.toString() == rewardPerBlock.times(bonus).times(49).toFixed().toString()); 108 | const oldAmount = await token.balanceOf(a1); 109 | await staking.emergencyWithdraw(0, {from: a1}); 110 | let currentAmount = await token.balanceOf(a1); 111 | assert(new BigNumber(stakeAmount).plus(oldAmount).toFixed().toString() == currentAmount.toString()); 112 | 113 | }); 114 | }); 115 | 116 | 117 | 118 | function assertEqual (val1, val2, errorStr) { 119 | val2 = val2.toString(); 120 | val1 = val1.toString() 121 | assert(new BN(val1).should.be.a.bignumber.that.equals(new BN(val2)), errorStr); 122 | } 123 | 124 | function expectError(message, messageCompare) { 125 | messageCompare = "Error: VM Exception while processing transaction: reverted with reason string '" + messageCompare + "'"; 126 | assert(message == messageCompare, 'Not valid message'); 127 | } 128 | 129 | async function expectThrow(f1, messageCompare) { 130 | let check = false; 131 | try { 132 | await f1; 133 | } catch (e) { 134 | check = true; 135 | expectError(e.toString(), messageCompare) 136 | }; 137 | 138 | if (!check) { 139 | assert(1 == 0, 'Not throw message'); 140 | } 141 | } 142 | 143 | async function increaseTime(second) { 144 | await ethers.provider.send('evm_increaseTime', [second]); 145 | await ethers.provider.send('evm_mine'); 146 | } --------------------------------------------------------------------------------