Overview
ETH Balance
0.001831642992508001 ETH
ETH Value
$7.17 (@ $3,912.75/ETH)More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 25 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Earmark Rewards | 15916496 | 93 days ago | IN | 0 ETH | 0.00005068 | ||||
Earmark Rewards | 15785539 | 97 days ago | IN | 0 ETH | 0.00003921 | ||||
Earmark Rewards | 15329350 | 113 days ago | IN | 0 ETH | 0.00005938 | ||||
Deposit | 15061267 | 123 days ago | IN | 0 ETH | 0.00001857 | ||||
Deposit | 15054803 | 123 days ago | IN | 0 ETH | 0.00006437 | ||||
Deposit | 15024004 | 124 days ago | IN | 0 ETH | 0.00002321 | ||||
Deposit | 14990911 | 125 days ago | IN | 0 ETH | 0.00002011 | ||||
Earmark Rewards | 14984523 | 125 days ago | IN | 0 ETH | 0.00005462 | ||||
Deposit | 14965259 | 126 days ago | IN | 0 ETH | 0.00006964 | ||||
Deposit | 14931762 | 127 days ago | IN | 0 ETH | 0.00010058 | ||||
Deposit | 14912892 | 128 days ago | IN | 0 ETH | 0.00006035 | ||||
Deposit | 14888452 | 129 days ago | IN | 0 ETH | 0.00002011 | ||||
Deposit | 14879525 | 129 days ago | IN | 0 ETH | 0.00004178 | ||||
Deposit | 14773730 | 133 days ago | IN | 0 ETH | 0.00002011 | ||||
Deposit | 14770790 | 133 days ago | IN | 0 ETH | 0.00002353 | ||||
Deposit | 14765020 | 133 days ago | IN | 0 ETH | 0.00006259 | ||||
Deposit | 14765019 | 133 days ago | IN | 0 ETH | 0.00006259 | ||||
Deposit | 14765017 | 133 days ago | IN | 0 ETH | 0.00006057 | ||||
Deposit | 14765017 | 133 days ago | IN | 0 ETH | 0.00006259 | ||||
Deposit | 14764381 | 133 days ago | IN | 0 ETH | 0.00004178 | ||||
Earmark Rewards | 14764246 | 133 days ago | IN | 0.00273187 ETH | 0.00003829 | ||||
Deposit | 14723483 | 135 days ago | IN | 0 ETH | 0.00002403 | ||||
Deposit | 14719459 | 135 days ago | IN | 0 ETH | 0.00003289 | ||||
Deposit | 14719007 | 135 days ago | IN | 0 ETH | 0.00002308 | ||||
Deposit | 14709323 | 135 days ago | IN | 0 ETH | 0.00014278 |
Latest 7 internal transactions
Loading...
Loading
Contract Name:
BoosterLite
Compiler Version
v0.6.12+commit.27d51765
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./Interfaces.sol"; import "@openzeppelin/contracts-0.6/math/SafeMath.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts-0.6/utils/Address.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts-0.6/utils/ReentrancyGuard.sol"; interface ICoordinator { function queueNewRewards( address, uint256, uint256, address ) external payable; } /** * @title BoosterLite * @author ConvexFinance -> AuraFinance * @dev A lite version of the original Booster for use on sidechains */ contract BoosterLite is ReentrancyGuard { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; address public crv; uint256 public lockIncentive = 825; //incentive to crv stakers uint256 public stakerIncentive = 825; //incentive to native token stakers uint256 public earmarkIncentive = 50; //incentive to users who spend gas to make calls uint256 public platformFee = 0; //possible fee to build treasury uint256 public constant MaxFees = 4000; uint256 public constant FEE_DENOMINATOR = 10000; address public owner; address public feeManager; address public poolManager; address public immutable staker; address public minter; address public rewardFactory; address public stashFactory; address public tokenFactory; address public treasury; address public rewards; //cvxCrv rewards(crv) bool public isShutdown; struct PoolInfo { address lptoken; address token; address gauge; address crvRewards; address stash; bool shutdown; } //index(pid) -> pool PoolInfo[] public poolInfo; mapping(address => bool) public gaugeMap; event Deposited(address indexed user, uint256 indexed poolid, uint256 amount); event Withdrawn(address indexed user, uint256 indexed poolid, uint256 amount); event PoolAdded(address lpToken, address gauge, address token, address rewardPool, address stash, uint256 pid); event PoolShutdown(uint256 poolId); event OwnerUpdated(address newOwner); event FeeManagerUpdated(address newFeeManager); event PoolManagerUpdated(address newPoolManager); event FactoriesUpdated(address rewardFactory, address stashFactory, address tokenFactory); event RewardContractsUpdated(address rewards); event FeesUpdated(uint256 lockIncentive, uint256 stakerIncentive, uint256 earmarkIncentive, uint256 platformFee); event TreasuryUpdated(address newTreasury); /** * @dev Constructor doing what constructors do. It is noteworthy that * a lot of basic config is set to 0 - expecting subsequent calls setFeeManager etc. * @param _staker VoterProxyLite (locks the crv and adds to all gauges) */ constructor(address _staker) public { staker = _staker; isShutdown = false; owner = msg.sender; treasury = address(0); emit OwnerUpdated(msg.sender); } /** * @notice Initialize the contract. * @param _minter CVX token, or the thing that mints it * @param _crv CRV Token address * @param _owner Owner address */ function initialize( address _minter, address _crv, address _owner ) external { require(msg.sender == owner, "!auth"); require(crv == address(0), "Only once"); minter = _minter; crv = _crv; owner = _owner; feeManager = _owner; poolManager = _owner; emit OwnerUpdated(msg.sender); emit FeeManagerUpdated(msg.sender); emit PoolManagerUpdated(msg.sender); } /// SETTER SECTION /// /** * @notice Owner is responsible for setting initial config, updating vote delegate and shutting system */ function setOwner(address _owner) external { require(msg.sender == owner, "!auth"); owner = _owner; emit OwnerUpdated(_owner); } /** * @notice Fee Manager can update the fees (lockIncentive, stakeIncentive, earmarkIncentive, platformFee) */ function setFeeManager(address _feeM) external { require(msg.sender == owner, "!auth"); feeManager = _feeM; emit FeeManagerUpdated(_feeM); } /** * @notice Pool manager is responsible for adding new pools */ function setPoolManager(address _poolM) external { require(msg.sender == poolManager, "!auth"); poolManager = _poolM; emit PoolManagerUpdated(_poolM); } /** * @notice Factories are used when deploying new pools. Only the stash factory is mutable after init */ function setFactories( address _rfactory, address _sfactory, address _tfactory ) external { require(msg.sender == owner, "!auth"); //stash factory should be considered more safe to change //updating may be required to handle new types of gauges stashFactory = _sfactory; //reward factory only allow this to be called once even if owner //removes ability to inject malicious staking contracts //token factory can also be immutable if (rewardFactory == address(0)) { rewardFactory = _rfactory; tokenFactory = _tfactory; emit FactoriesUpdated(_rfactory, _sfactory, _tfactory); } else { emit FactoriesUpdated(address(0), _sfactory, address(0)); } } /** * @notice Only called once, to set the addresses of cvxCrv (rewards) */ function setRewardContracts(address _rewards) external { require(msg.sender == owner, "!auth"); //reward contracts are immutable or else the owner //has a means to redeploy and mint cvx via rewardClaimed() if (rewards == address(0)) { rewards = _rewards; emit RewardContractsUpdated(_rewards); } } /** * @notice Fee manager can set all the relevant fees * @param _lockFees % for cvxCrv stakers where 1% == 100 * @param _stakerFees % for CVX stakers where 1% == 100 * @param _callerFees % for whoever calls the claim where 1% == 100 * @param _platform % for "treasury" or vlCVX where 1% == 100 */ function setFees( uint256 _lockFees, uint256 _stakerFees, uint256 _callerFees, uint256 _platform ) external nonReentrant { require(msg.sender == feeManager, "!auth"); uint256 total = _lockFees.add(_stakerFees).add(_callerFees).add(_platform); require(total <= MaxFees, ">MaxFees"); require(_lockFees >= 300 && _lockFees <= 3500, "!lockFees"); require(_stakerFees >= 300 && _stakerFees <= 1500, "!stakerFees"); require(_callerFees >= 10 && _callerFees <= 100, "!callerFees"); require(_platform <= 200, "!platform"); lockIncentive = _lockFees; stakerIncentive = _stakerFees; earmarkIncentive = _callerFees; platformFee = _platform; emit FeesUpdated(_lockFees, _stakerFees, _callerFees, _platform); } /** * @notice Set the address of the treasury (i.e. vlCVX) */ function setTreasury(address _treasury) external { require(msg.sender == feeManager, "!auth"); treasury = _treasury; emit TreasuryUpdated(_treasury); } /// END SETTER SECTION /// function poolLength() external view returns (uint256) { return poolInfo.length; } /** * @notice Called by the PoolManager (i.e. PoolManagerProxy) to add a new pool - creates all the required * contracts (DepositToken, RewardPool, Stash) and then adds to the list! */ function addPool( address _lptoken, address _gauge, uint256 _stashVersion ) external returns (bool) { require(msg.sender == poolManager && !isShutdown, "!add"); require(_gauge != address(0) && _lptoken != address(0), "!param"); //the next pool's pid uint256 pid = poolInfo.length; //create a tokenized deposit address token = ITokenFactory(tokenFactory).CreateDepositToken(_lptoken); //create a reward contract for crv rewards address newRewardPool = IRewardFactory(rewardFactory).CreateCrvRewards(pid, token, _lptoken); //create a stash to handle extra incentives address stash = IStashFactory(stashFactory).CreateStash(pid, _gauge, staker, _stashVersion); //add the new pool poolInfo.push( PoolInfo({ lptoken: _lptoken, token: token, gauge: _gauge, crvRewards: newRewardPool, stash: stash, shutdown: false }) ); gaugeMap[_gauge] = true; //give stashes access to rewardfactory and voteproxy // voteproxy so it can grab the incentive tokens off the contract after claiming rewards // reward factory so that stashes can make new extra reward contracts if a new incentive is added to the gauge if (stash != address(0)) { poolInfo[pid].stash = stash; IStaker(staker).setStashAccess(stash, true); IRewardFactory(rewardFactory).setAccess(stash, true); } emit PoolAdded(_lptoken, _gauge, token, newRewardPool, stash, pid); return true; } /** * @notice Shuts down the pool by withdrawing everything from the gauge to here (can later be * claimed from depositors by using the withdraw fn) and marking it as shut down */ function shutdownPool(uint256 _pid) external nonReentrant returns (bool) { require(msg.sender == poolManager, "!auth"); PoolInfo storage pool = poolInfo[_pid]; //withdraw from gauge try IStaker(staker).withdrawAll(pool.lptoken, pool.gauge) {} catch {} pool.shutdown = true; gaugeMap[pool.gauge] = false; emit PoolShutdown(_pid); return true; } /** * @notice Shuts down the WHOLE SYSTEM by withdrawing all the LP tokens to here and then allowing * for subsequent withdrawal by any depositors. */ function shutdownSystem() external { require(msg.sender == owner, "!auth"); isShutdown = true; for (uint256 i = 0; i < poolInfo.length; i++) { PoolInfo storage pool = poolInfo[i]; if (pool.shutdown) continue; address token = pool.lptoken; address gauge = pool.gauge; //withdraw from gauge try IStaker(staker).withdrawAll(token, gauge) { pool.shutdown = true; } catch {} } } /** * @notice Deposits an "_amount" to a given gauge (specified by _pid), mints a `DepositToken` * and subsequently stakes that on Convex BaseRewardPool */ function deposit( uint256 _pid, uint256 _amount, bool _stake ) public nonReentrant returns (bool) { require(!isShutdown, "shutdown"); PoolInfo storage pool = poolInfo[_pid]; require(pool.shutdown == false, "pool is closed"); //send to proxy to stake address lptoken = pool.lptoken; IERC20(lptoken).safeTransferFrom(msg.sender, staker, _amount); //stake address gauge = pool.gauge; require(gauge != address(0), "!gauge setting"); IStaker(staker).deposit(lptoken, gauge); //some gauges claim rewards when depositing, stash them in a seperate contract until next claim address stash = pool.stash; if (stash != address(0)) { IStash(stash).stashRewards(); } address token = pool.token; if (_stake) { //mint here and send to rewards on user behalf ITokenMinter(token).mint(address(this), _amount); address rewardContract = pool.crvRewards; IERC20(token).safeApprove(rewardContract, 0); IERC20(token).safeApprove(rewardContract, _amount); IRewards(rewardContract).stakeFor(msg.sender, _amount); } else { //add user balance directly ITokenMinter(token).mint(msg.sender, _amount); } emit Deposited(msg.sender, _pid, _amount); return true; } /** * @notice Deposits all a senders balance to a given gauge (specified by _pid), mints a `DepositToken` * and subsequently stakes that on Convex BaseRewardPool */ function depositAll(uint256 _pid, bool _stake) external returns (bool) { address lptoken = poolInfo[_pid].lptoken; uint256 balance = IERC20(lptoken).balanceOf(msg.sender); deposit(_pid, balance, _stake); return true; } /** * @notice Withdraws LP tokens from a given PID (& user). * 1. Burn the cvxLP balance from "_from" (implicit balance check) * 2. If pool !shutdown.. withdraw from gauge * 3. If stash, stash rewards * 4. Transfer out the LP tokens */ function _withdraw( uint256 _pid, uint256 _amount, address _from, address _to ) internal nonReentrant { PoolInfo storage pool = poolInfo[_pid]; address lptoken = pool.lptoken; address gauge = pool.gauge; //remove lp balance address token = pool.token; ITokenMinter(token).burn(_from, _amount); //pull from gauge if not shutdown // if shutdown tokens will be in this contract if (!pool.shutdown) { IStaker(staker).withdraw(lptoken, gauge, _amount); } //some gauges claim rewards when withdrawing, stash them in a seperate contract until next claim //do not call if shutdown since stashes wont have access address stash = pool.stash; if (stash != address(0) && !isShutdown && !pool.shutdown) { IStash(stash).stashRewards(); } //return lp tokens IERC20(lptoken).safeTransfer(_to, _amount); emit Withdrawn(_to, _pid, _amount); } /** * @notice Withdraw a given amount from a pool (must already been unstaked from the Convex Reward Pool - * BaseRewardPool uses withdrawAndUnwrap to get around this) */ function withdraw(uint256 _pid, uint256 _amount) public returns (bool) { _withdraw(_pid, _amount, msg.sender, msg.sender); return true; } /** * @notice Withdraw all the senders LP tokens from a given gauge */ function withdrawAll(uint256 _pid) public returns (bool) { address token = poolInfo[_pid].token; uint256 userBal = IERC20(token).balanceOf(msg.sender); withdraw(_pid, userBal); return true; } /** * @notice Allows the actual BaseRewardPool to withdraw and send directly to the user */ function withdrawTo( uint256 _pid, uint256 _amount, address _to ) external returns (bool) { address rewardContract = poolInfo[_pid].crvRewards; require(msg.sender == rewardContract, "!auth"); _withdraw(_pid, _amount, msg.sender, _to); return true; } /** * @notice Allows a stash to claim secondary rewards from a gauge */ function claimRewards(uint256 _pid, address _gauge) external returns (bool) { address stash = poolInfo[_pid].stash; require(msg.sender == stash, "!auth"); IStaker(staker).claimRewards(_gauge); return true; } /** * @notice Tells the Curve gauge to redirect any accrued rewards to the given stash via the VoterProxy */ function setGaugeRedirect(uint256 _pid) external returns (bool) { address stash = poolInfo[_pid].stash; require(msg.sender == stash, "!auth"); address gauge = poolInfo[_pid].gauge; bytes memory data = abi.encodeWithSelector(bytes4(keccak256("set_rewards_receiver(address)")), stash); IStaker(staker).execute(gauge, uint256(0), data); return true; } /** * @notice Basically a hugely pivotal function. * Responsible for collecting the crv from gauge, and then redistributing to the correct place. * Pays the caller a fee to process this. */ function _earmarkRewards(uint256 _pid, address _zroPaymentAddress) internal { PoolInfo storage pool = poolInfo[_pid]; require(pool.shutdown == false, "pool is closed"); uint256 crvBal; { // If there is idle CRV in the Booster we need to transfer it out // in order that our accounting doesn't get scewed. uint256 crvBBalBefore = IERC20(crv).balanceOf(address(this)); uint256 crvVBalBefore = IERC20(crv).balanceOf(staker); uint256 crvBalBefore = crvBBalBefore.add(crvVBalBefore); //claim crv IStaker(staker).claimCrv(pool.gauge); //crv balance uint256 crvBalAfter = IERC20(crv).balanceOf(address(this)); crvBal = crvBalAfter.sub(crvBalBefore); if (crvBalBefore > 0 && treasury != address(0)) { IERC20(crv).safeTransfer(treasury, crvBalBefore); } } //check if there are extra rewards address stash = pool.stash; if (stash != address(0)) { //claim extra rewards IStash(stash).claimRewards(); //process extra rewards IStash(stash).processStash(); } if (crvBal > 0) { // LockIncentive = cvxCrv stakers uint256 _lockIncentive = crvBal.mul(lockIncentive).div(FEE_DENOMINATOR); // StakerIncentive = cvx stakers uint256 _stakerIncentive = crvBal.mul(stakerIncentive).div(FEE_DENOMINATOR); // CallIncentive = caller of this contract uint256 _callIncentive = crvBal.mul(earmarkIncentive).div(FEE_DENOMINATOR); // Platform incentives uint256 _platformIncentive = crvBal.mul(platformFee).div(FEE_DENOMINATOR); uint256 _totalIncentive = _lockIncentive.add(_stakerIncentive).add(_platformIncentive); //remove incentives from balance crvBal = crvBal.sub(_totalIncentive).sub(_callIncentive); //send incentives for calling IERC20(crv).safeTransfer(msg.sender, _callIncentive); //send crv to lp provider reward contract address rewardContract = pool.crvRewards; IERC20(crv).safeTransfer(rewardContract, crvBal); IRewards(rewardContract).queueNewRewards(crvBal); //send lockers' share of crv to reward contract IERC20(crv).safeTransfer(rewards, _totalIncentive); ICoordinator(rewards).queueNewRewards{ value: msg.value }( msg.sender, _totalIncentive, crvBal, _zroPaymentAddress ); } } /** * @notice Basically a hugely pivotal function. * Responsible for collecting the crv from gauge, and then redistributing to the correct place. * Pays the caller a fee to process this. */ function earmarkRewards(uint256 _pid, address _zroPaymentAddress) external payable nonReentrant returns (bool) { require(!isShutdown, "shutdown"); _earmarkRewards(_pid, _zroPaymentAddress); return true; } /** * @notice Callback from reward contract when crv is received. * @dev Goes off and mints a relative amount of `CVX` based on the distribution schedule. */ function rewardClaimed( uint256 _pid, address _address, uint256 _amount ) external returns (bool) { address rewardContract = poolInfo[_pid].crvRewards; require(msg.sender == rewardContract, "!auth"); if (_amount > 0) { //mint reward tokens ITokenMinter(minter).mint(_address, _amount); } return true; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev 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. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a / b); } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for * deploying minimal proxy contracts, also known as "clones". * * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies * > a minimal bytecode implementation that delegates all calls to a known, fixed address. * * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2` * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the * deterministic method. * * _Available since v3.4._ */ library Clones { /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `master`. * * This function uses the create opcode, which should never revert. */ function clone(address master) internal returns (address instance) { // solhint-disable-next-line no-inline-assembly assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, master)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) instance := create(0, ptr, 0x37) } require(instance != address(0), "ERC1167: create failed"); } /** * @dev Deploys and returns the address of a clone that mimics the behaviour of `master`. * * This function uses the create2 opcode and a `salt` to deterministically deploy * the clone. Using the same `master` and `salt` multiple time will revert, since * the clones cannot be deployed twice at the same address. */ function cloneDeterministic(address master, bytes32 salt) internal returns (address instance) { // solhint-disable-next-line no-inline-assembly assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, master)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000) instance := create2(0, ptr, 0x37, salt) } require(instance != address(0), "ERC1167: create2 failed"); } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress(address master, bytes32 salt, address deployer) internal pure returns (address predicted) { // solhint-disable-next-line no-inline-assembly assembly { let ptr := mload(0x40) mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000) mstore(add(ptr, 0x14), shl(0x60, master)) mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000) mstore(add(ptr, 0x38), shl(0x60, deployer)) mstore(add(ptr, 0x4c), salt) mstore(add(ptr, 0x6c), keccak256(ptr, 0x37)) predicted := keccak256(add(ptr, 0x37), 0x55) } } /** * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}. */ function predictDeterministicAddress(address master, bytes32 salt) internal view returns (address predicted) { return predictDeterministicAddress(master, salt, address(this)); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../../utils/Context.sol"; import "./IERC20.sol"; import "../../math/SafeMath.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) public { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal virtual { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./IERC20.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor () internal { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
// SPDX-License-Identifier: MIT // solhint-disable-next-line compiler-version pragma solidity >=0.4.24 <0.8.0; import "../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /// @dev Returns true if and only if the function is running in the constructor function _isConstructor() private view returns (bool) { return !AddressUpgradeable.isContract(address(this)); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../proxy/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; function __ReentrancyGuard_init() internal initializer { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal initializer { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } uint256[49] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./Interfaces.sol"; import "@openzeppelin/contracts-0.6/math/SafeMath.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts-0.6/utils/Address.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol"; /** * @title ArbitratorVault * @author ConvexFinance * @notice Hold extra reward tokens on behalf of pools that have the same token as a reward (e.g. stkAAVE fro multiple aave pools) * @dev Sits on top of the STASH to basically handle the re-distribution of rewards to multiple stashes. * Because anyone can call gauge.claim_rewards(address) for the convex staking contract, rewards * could be forced to the wrong pool. Hold tokens here and distribute fairly(or at least more fairly), * to both pools at a later timing. */ contract ArbitratorVault{ using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; address public operator; address public immutable depositor; /** * @param _depositor Booster address */ constructor(address _depositor)public { operator = msg.sender; depositor = _depositor; } function setOperator(address _op) external { require(msg.sender == operator, "!auth"); operator = _op; } /** * @notice Permissioned fn to distribute any accrued rewards to a relevant stash * @dev Only called by operator: ConvexMultisig */ function distribute(address _token, uint256[] calldata _toPids, uint256[] calldata _amounts) external { require(msg.sender == operator, "!auth"); for(uint256 i = 0; i < _toPids.length; i++){ //get stash from pid (,,,,address stashAddress,bool shutdown) = IDeposit(depositor).poolInfo(_toPids[i]); //if sent to a shutdown pool, could get trapped require(shutdown==false,"pool closed"); //transfer IERC20(_token).safeTransfer(stashAddress, _amounts[i]); } } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** *Submitted for verification at Etherscan.io on 2020-07-17 */ /* ____ __ __ __ _ / __/__ __ ___ / /_ / / ___ / /_ (_)__ __ _\ \ / // // _ \/ __// _ \/ -_)/ __// / \ \ / /___/ \_, //_//_/\__//_//_/\__/ \__//_/ /_\_\ /___/ * Synthetix: BaseRewardPool.sol * * Docs: https://docs.synthetix.io/ * * * MIT License * =========== * * Copyright (c) 2020 Synthetix * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */ import "./Interfaces.sol"; import "./interfaces/MathUtil.sol"; import "@openzeppelin/contracts-0.6/math/SafeMath.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts-0.6/utils/Address.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol"; /** * @title BaseRewardPool * @author Synthetix -> ConvexFinance * @notice Unipool rewards contract that is re-deployed from rFactory for each staking pool. * @dev Changes made here by ConvexFinance are to do with the delayed reward allocation. Curve is queued for * rewards and the distribution only begins once the new rewards are sufficiently large, or the epoch * has ended. Additionally, enables hooks for `extraRewards` that can be enabled at any point to * distribute a child reward token (i.e. a secondary one from Curve, or a seperate one). */ contract BaseRewardPool { using SafeMath for uint256; using SafeERC20 for IERC20; IERC20 public immutable rewardToken; IERC20 public immutable stakingToken; uint256 public constant duration = 7 days; address public immutable operator; address public immutable rewardManager; uint256 public immutable pid; uint256 public periodFinish = 0; uint256 public rewardRate = 0; uint256 public lastUpdateTime; uint256 public rewardPerTokenStored; uint256 public queuedRewards = 0; uint256 public currentRewards = 0; uint256 public historicalRewards = 0; uint256 public constant newRewardRatio = 830; uint256 private _totalSupply; mapping(address => uint256) public userRewardPerTokenPaid; mapping(address => uint256) public rewards; mapping(address => uint256) internal _balances; address[] public extraRewards; event RewardAdded(uint256 reward); event Staked(address indexed user, uint256 amount); event Withdrawn(address indexed user, uint256 amount); event RewardPaid(address indexed user, uint256 reward); event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev This is called directly from RewardFactory * @param pid_ Effectively the pool identifier - used in the Booster * @param stakingToken_ Pool LP token * @param rewardToken_ Crv * @param operator_ Booster * @param rewardManager_ RewardFactory */ constructor( uint256 pid_, address stakingToken_, address rewardToken_, address operator_, address rewardManager_ ) public { pid = pid_; stakingToken = IERC20(stakingToken_); rewardToken = IERC20(rewardToken_); operator = operator_; rewardManager = rewardManager_; } function totalSupply() public view virtual returns (uint256) { return _totalSupply; } function balanceOf(address account) public view virtual returns (uint256) { return _balances[account]; } function extraRewardsLength() external view returns (uint256) { return extraRewards.length; } function addExtraReward(address _reward) external returns(bool){ require(msg.sender == rewardManager, "!authorized"); require(_reward != address(0),"!reward setting"); if(extraRewards.length >= 12){ return false; } extraRewards.push(_reward); return true; } function clearExtraRewards() external{ require(msg.sender == rewardManager, "!authorized"); delete extraRewards; } modifier updateReward(address account) { rewardPerTokenStored = rewardPerToken(); lastUpdateTime = lastTimeRewardApplicable(); if (account != address(0)) { rewards[account] = earned(account); userRewardPerTokenPaid[account] = rewardPerTokenStored; } _; } function lastTimeRewardApplicable() public view returns (uint256) { return MathUtil.min(block.timestamp, periodFinish); } function rewardPerToken() public view returns (uint256) { if (totalSupply() == 0) { return rewardPerTokenStored; } return rewardPerTokenStored.add( lastTimeRewardApplicable() .sub(lastUpdateTime) .mul(rewardRate) .mul(1e18) .div(totalSupply()) ); } function earned(address account) public view returns (uint256) { return balanceOf(account) .mul(rewardPerToken().sub(userRewardPerTokenPaid[account])) .div(1e18) .add(rewards[account]); } function stake(uint256 _amount) public returns(bool) { _processStake(_amount, msg.sender); stakingToken.safeTransferFrom(msg.sender, address(this), _amount); emit Staked(msg.sender, _amount); return true; } function stakeAll() external returns(bool){ uint256 balance = stakingToken.balanceOf(msg.sender); stake(balance); return true; } function stakeFor(address _for, uint256 _amount) public returns(bool) { _processStake(_amount, _for); //take away from sender stakingToken.safeTransferFrom(msg.sender, address(this), _amount); emit Staked(_for, _amount); return true; } /** * @dev Generic internal staking function that basically does 3 things: update rewards based * on previous balance, trigger also on any child contracts, then update balances. * @param _amount Units to add to the users balance * @param _receiver Address of user who will receive the stake */ function _processStake(uint256 _amount, address _receiver) internal updateReward(_receiver) { require(_amount > 0, 'RewardPool : Cannot stake 0'); //also stake to linked rewards for(uint i=0; i < extraRewards.length; i++){ IRewards(extraRewards[i]).stake(_receiver, _amount); } _totalSupply = _totalSupply.add(_amount); _balances[_receiver] = _balances[_receiver].add(_amount); emit Transfer(address(0), _receiver, _amount); } function withdraw(uint256 amount, bool claim) public updateReward(msg.sender) returns(bool) { require(amount > 0, 'RewardPool : Cannot withdraw 0'); //also withdraw from linked rewards for(uint i=0; i < extraRewards.length; i++){ IRewards(extraRewards[i]).withdraw(msg.sender, amount); } _totalSupply = _totalSupply.sub(amount); _balances[msg.sender] = _balances[msg.sender].sub(amount); stakingToken.safeTransfer(msg.sender, amount); emit Withdrawn(msg.sender, amount); if(claim){ getReward(msg.sender,true); } emit Transfer(msg.sender, address(0), amount); return true; } function withdrawAll(bool claim) external{ withdraw(_balances[msg.sender],claim); } function withdrawAndUnwrap(uint256 amount, bool claim) public returns(bool){ _withdrawAndUnwrapTo(amount, msg.sender, msg.sender); //get rewards too if(claim){ getReward(msg.sender,true); } return true; } function _withdrawAndUnwrapTo(uint256 amount, address from, address receiver) internal updateReward(from) returns(bool){ //also withdraw from linked rewards for(uint i=0; i < extraRewards.length; i++){ IRewards(extraRewards[i]).withdraw(from, amount); } _totalSupply = _totalSupply.sub(amount); _balances[from] = _balances[from].sub(amount); //tell operator to withdraw from here directly to user IDeposit(operator).withdrawTo(pid,amount,receiver); emit Withdrawn(from, amount); emit Transfer(from, address(0), amount); return true; } function withdrawAllAndUnwrap(bool claim) external{ withdrawAndUnwrap(_balances[msg.sender],claim); } /** * @dev Gives a staker their rewards, with the option of claiming extra rewards * @param _account Account for which to claim * @param _claimExtras Get the child rewards too? */ function getReward(address _account, bool _claimExtras) public updateReward(_account) returns(bool){ uint256 reward = earned(_account); if (reward > 0) { rewards[_account] = 0; rewardToken.safeTransfer(_account, reward); IDeposit(operator).rewardClaimed(pid, _account, reward); emit RewardPaid(_account, reward); } //also get rewards from linked rewards if(_claimExtras){ for(uint i=0; i < extraRewards.length; i++){ IRewards(extraRewards[i]).getReward(_account); } } return true; } /** * @dev Called by a staker to get their allocated rewards */ function getReward() external returns(bool){ getReward(msg.sender,true); return true; } /** * @dev Processes queued rewards in isolation, providing the period has finished. * This allows a cheaper way to trigger rewards on low value pools. */ function processIdleRewards() external { if (block.timestamp >= periodFinish && queuedRewards > 0) { notifyRewardAmount(queuedRewards); queuedRewards = 0; } } /** * @dev Called by the booster to allocate new Crv rewards to this pool * Curve is queued for rewards and the distribution only begins once the new rewards are sufficiently * large, or the epoch has ended. */ function queueNewRewards(uint256 _rewards) external returns(bool){ require(msg.sender == operator, "!authorized"); _rewards = _rewards.add(queuedRewards); if (block.timestamp >= periodFinish) { notifyRewardAmount(_rewards); queuedRewards = 0; return true; } //et = now - (finish-duration) uint256 elapsedTime = block.timestamp.sub(periodFinish.sub(duration)); //current at now: rewardRate * elapsedTime uint256 currentAtNow = rewardRate * elapsedTime; uint256 queuedRatio = currentAtNow.mul(1000).div(_rewards); //uint256 queuedRatio = currentRewards.mul(1000).div(_rewards); if(queuedRatio < newRewardRatio){ notifyRewardAmount(_rewards); queuedRewards = 0; }else{ queuedRewards = _rewards; } return true; } function notifyRewardAmount(uint256 reward) internal updateReward(address(0)) { historicalRewards = historicalRewards.add(reward); if (block.timestamp >= periodFinish) { rewardRate = reward.div(duration); } else { uint256 remaining = periodFinish.sub(block.timestamp); uint256 leftover = remaining.mul(rewardRate); reward = reward.add(leftover); rewardRate = reward.div(duration); } currentRewards = reward; lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(duration); emit RewardAdded(reward); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import { IRewards } from "./Interfaces.sol"; import { BaseRewardPool, IDeposit } from "./BaseRewardPool.sol"; import { IERC4626, IERC20Metadata } from "./interfaces/IERC4626.sol"; import { IERC20 } from "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol"; import { ReentrancyGuard } from "@openzeppelin/contracts-0.6/utils/ReentrancyGuard.sol"; import { SafeERC20 } from "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol"; /** * @title BaseRewardPool4626 * @notice Simply wraps the BaseRewardPool with the new IERC4626 Vault standard functions. * @dev See https://github.com/fei-protocol/ERC4626/blob/main/src/interfaces/IERC4626.sol#L58 * This is not so much a vault as a Reward Pool, therefore asset:share ratio is always 1:1. * To create most utility for this RewardPool, the "asset" has been made to be the crvLP token, * as opposed to the cvxLP token. Therefore, users can easily deposit crvLP, and it will first * go to the Booster and mint the cvxLP before performing the normal staking function. */ contract BaseRewardPool4626 is BaseRewardPool, ReentrancyGuard, IERC4626 { using SafeERC20 for IERC20; /** * @notice The address of the underlying ERC20 token used for * the Vault for accounting, depositing, and withdrawing. */ address public override asset; mapping (address => mapping (address => uint256)) private _allowances; /** * @dev See BaseRewardPool.sol */ constructor( uint256 pid_, address stakingToken_, address rewardToken_, address operator_, address rewardManager_, address lptoken_ ) public BaseRewardPool(pid_, stakingToken_, rewardToken_, operator_, rewardManager_) { asset = lptoken_; IERC20(asset).safeApprove(operator_, type(uint256).max); } /** * @notice Total amount of the underlying asset that is "managed" by Vault. */ function totalAssets() external view virtual override returns(uint256){ return totalSupply(); } /** * @notice Mints `shares` Vault shares to `receiver`. * @dev Because `asset` is not actually what is collected here, first wrap to required token in the booster. */ function deposit(uint256 assets, address receiver) public virtual override nonReentrant returns (uint256) { // Transfer "asset" (crvLP) from sender IERC20(asset).safeTransferFrom(msg.sender, address(this), assets); // Convert crvLP to cvxLP through normal booster deposit process, but don't stake uint256 balBefore = stakingToken.balanceOf(address(this)); IDeposit(operator).deposit(pid, assets, false); uint256 balAfter = stakingToken.balanceOf(address(this)); require(balAfter.sub(balBefore) >= assets, "!deposit"); // Perform stake manually, now that the funds have been received _processStake(assets, receiver); emit Deposit(msg.sender, receiver, assets, assets); emit Staked(receiver, assets); return assets; } /** * @notice Mints exactly `shares` Vault shares to `receiver` * by depositing `assets` of underlying tokens. */ function mint(uint256 shares, address receiver) external virtual override returns (uint256) { return deposit(shares, receiver); } /** * @notice Redeems `shares` from `owner` and sends `assets` * of underlying tokens to `receiver`. */ function withdraw( uint256 assets, address receiver, address owner ) public virtual override nonReentrant returns (uint256) { if (msg.sender != owner) { _approve(owner, msg.sender, _allowances[owner][msg.sender].sub(assets, "ERC4626: withdrawal amount exceeds allowance")); } _withdrawAndUnwrapTo(assets, owner, receiver); emit Withdraw(msg.sender, receiver, owner, assets, assets); return assets; } /** * @notice Redeems `shares` from `owner` and sends `assets` * of underlying tokens to `receiver`. */ function redeem( uint256 shares, address receiver, address owner ) external virtual override returns (uint256) { return withdraw(shares, receiver, owner); } /** * @notice The amount of shares that the vault would * exchange for the amount of assets provided, in an * ideal scenario where all the conditions are met. */ function convertToShares(uint256 assets) public view virtual override returns (uint256) { return assets; } /** * @notice The amount of assets that the vault would * exchange for the amount of shares provided, in an * ideal scenario where all the conditions are met. */ function convertToAssets(uint256 shares) public view virtual override returns (uint256) { return shares; } /** * @notice Total number of underlying assets that can * be deposited by `owner` into the Vault, where `owner` * corresponds to the input parameter `receiver` of a * `deposit` call. */ function maxDeposit(address /* owner */) public view virtual override returns (uint256) { return type(uint256).max; } /** * @notice Allows an on-chain or off-chain user to simulate * the effects of their deposit at the current block, given * current on-chain conditions. */ function previewDeposit(uint256 assets) external view virtual override returns(uint256){ return convertToShares(assets); } /** * @notice Total number of underlying shares that can be minted * for `owner`, where `owner` corresponds to the input * parameter `receiver` of a `mint` call. */ function maxMint(address owner) external view virtual override returns (uint256) { return maxDeposit(owner); } /** * @notice Allows an on-chain or off-chain user to simulate * the effects of their mint at the current block, given * current on-chain conditions. */ function previewMint(uint256 shares) external view virtual override returns(uint256){ return convertToAssets(shares); } /** * @notice Total number of underlying assets that can be * withdrawn from the Vault by `owner`, where `owner` * corresponds to the input parameter of a `withdraw` call. */ function maxWithdraw(address owner) public view virtual override returns (uint256) { return balanceOf(owner); } /** * @notice Allows an on-chain or off-chain user to simulate * the effects of their withdrawal at the current block, * given current on-chain conditions. */ function previewWithdraw(uint256 assets) public view virtual override returns(uint256 shares){ return convertToShares(assets); } /** * @notice Total number of underlying shares that can be * redeemed from the Vault by `owner`, where `owner` corresponds * to the input parameter of a `redeem` call. */ function maxRedeem(address owner) external view virtual override returns (uint256) { return maxWithdraw(owner); } /** * @notice Allows an on-chain or off-chain user to simulate * the effects of their redeemption at the current block, * given current on-chain conditions. */ function previewRedeem(uint256 shares) external view virtual override returns(uint256){ return previewWithdraw(shares); } /* ========== IERC20 ========== */ /** * @dev Returns the name of the token. */ function name() external view override returns (string memory) { return string( abi.encodePacked(IERC20Metadata(address(stakingToken)).name(), " Vault") ); } /** * @dev Returns the symbol of the token. */ function symbol() external view override returns (string memory) { return string( abi.encodePacked(IERC20Metadata(address(stakingToken)).symbol(), "-vault") ); } /** * @dev Returns the decimals places of the token. */ function decimals() external view override returns (uint8) { return 18; } /** * @dev Returns the amount of tokens in existence. */ function totalSupply() public view override(BaseRewardPool, IERC20) returns (uint256) { return BaseRewardPool.totalSupply(); } /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) public view override(BaseRewardPool, IERC20) returns (uint256) { return BaseRewardPool.balanceOf(account); } /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external override returns (bool) { _transfer(msg.sender, recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(msg.sender, spender, amount); return true; } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC4626: approve from the zero address"); require(spender != address(0), "ERC4626: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. */ function transferFrom(address owner, address recipient, uint256 amount) external override returns (bool) { uint256 newAllowance = _allowances[owner][msg.sender].sub(amount, "ERC4626: withdrawal amount exceeds allowance"); _approve(owner, msg.sender, newAllowance); _transfer(owner, recipient, amount); return true; } function _transfer(address from, address to, uint256 amount) internal updateReward(from) updateReward(to) virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); for(uint i=0; i < extraRewards.length; i++){ IRewards(extraRewards[i]).withdraw(from , amount); IRewards(extraRewards[i]).stake(to, amount); } _balances[from] = fromBalance.sub(amount); _balances[to] = _balances[to].add(amount); emit Transfer(from, to, amount); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./Interfaces.sol"; import "@openzeppelin/contracts-0.6/math/SafeMath.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts-0.6/utils/Address.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts-0.6/utils/ReentrancyGuard.sol"; /** * @title Booster * @author ConvexFinance * @notice Main deposit contract; keeps track of pool info & user deposits; distributes rewards. * @dev They say all paths lead to Rome, and the cvxBooster is no different. This is where it all goes down. * It is responsible for tracking all the pools, it collects rewards from all pools and redirects it. */ contract Booster is ReentrancyGuard { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; address public immutable crv; address public immutable voteOwnership; address public immutable voteParameter; uint256 public lockIncentive = 825; //incentive to crv stakers uint256 public stakerIncentive = 825; //incentive to native token stakers uint256 public earmarkIncentive = 50; //incentive to users who spend gas to make calls uint256 public platformFee = 0; //possible fee to build treasury uint256 public constant MaxFees = 4000; uint256 public constant FEE_DENOMINATOR = 10000; address public owner; address public feeManager; address public poolManager; address public immutable staker; address public immutable minter; address public rewardFactory; address public stashFactory; address public tokenFactory; address public rewardArbitrator; address public voteDelegate; address public treasury; address public stakerRewards; //cvx rewards address public lockRewards; //cvxCrv rewards(crv) address public bridgeDelegate; mapping(uint256 => uint256) public l2FeesHistory; uint256 immutable epochLength = 1 weeks; mapping(address => FeeDistro) public feeTokens; struct FeeDistro { address distro; address rewards; bool active; } bool public isShutdown; struct PoolInfo { address lptoken; address token; address gauge; address crvRewards; address stash; bool shutdown; } //index(pid) -> pool PoolInfo[] public poolInfo; mapping(address => bool) public gaugeMap; // Reward multiplier for increasing or decreasing AURA rewards per PID uint256 public constant REWARD_MULTIPLIER_DENOMINATOR = 10000; // rewardContract => rewardMultiplier (10000 = 100%) mapping(address => uint256) public getRewardMultipliers; event Deposited(address indexed user, uint256 indexed poolid, uint256 amount); event Withdrawn(address indexed user, uint256 indexed poolid, uint256 amount); event PoolAdded(address lpToken, address gauge, address token, address rewardPool, address stash, uint256 pid); event PoolShutdown(uint256 poolId); event OwnerUpdated(address newOwner); event FeeManagerUpdated(address newFeeManager); event PoolManagerUpdated(address newPoolManager); event FactoriesUpdated(address rewardFactory, address stashFactory, address tokenFactory); event ArbitratorUpdated(address newArbitrator); event VoteDelegateUpdated(address newVoteDelegate); event RewardContractsUpdated(address lockRewards, address stakerRewards); event FeesUpdated(uint256 lockIncentive, uint256 stakerIncentive, uint256 earmarkIncentive, uint256 platformFee); event TreasuryUpdated(address newTreasury); event FeeInfoUpdated(address feeDistro, address lockFees, address feeToken); event FeeInfoChanged(address feeDistro, bool active); /** * @dev Constructor doing what constructors do. It is noteworthy that * a lot of basic config is set to 0 - expecting subsequent calls to setFeeInfo etc. * @param _staker VoterProxy (locks the crv and adds to all gauges) * @param _minter CVX token, or the thing that mints it * @param _crv CRV * @param _voteOwnership Address of the Curve DAO responsible for ownership stuff * @param _voteParameter Address of the Curve DAO responsible for param updates */ constructor( address _staker, address _minter, address _crv, address _voteOwnership, address _voteParameter ) public { staker = _staker; minter = _minter; crv = _crv; voteOwnership = _voteOwnership; voteParameter = _voteParameter; isShutdown = false; owner = msg.sender; voteDelegate = msg.sender; feeManager = msg.sender; poolManager = msg.sender; treasury = address(0); emit OwnerUpdated(msg.sender); emit VoteDelegateUpdated(msg.sender); emit FeeManagerUpdated(msg.sender); emit PoolManagerUpdated(msg.sender); } /// SETTER SECTION /// /** * @notice Owner is responsible for setting initial config, updating vote delegate and shutting system */ function setOwner(address _owner) external { require(msg.sender == owner, "!auth"); owner = _owner; emit OwnerUpdated(_owner); } /** * @notice Fee Manager can update the fees (lockIncentive, stakeIncentive, earmarkIncentive, platformFee) */ function setFeeManager(address _feeM) external { require(msg.sender == owner, "!auth"); feeManager = _feeM; emit FeeManagerUpdated(_feeM); } /** * @notice Pool manager is responsible for adding new pools */ function setPoolManager(address _poolM) external { require(msg.sender == poolManager, "!auth"); poolManager = _poolM; emit PoolManagerUpdated(_poolM); } /** * @notice Factories are used when deploying new pools. Only the stash factory is mutable after init */ function setFactories(address _rfactory, address _sfactory, address _tfactory) external { require(msg.sender == owner, "!auth"); //stash factory should be considered more safe to change //updating may be required to handle new types of gauges stashFactory = _sfactory; //reward factory only allow this to be called once even if owner //removes ability to inject malicious staking contracts //token factory can also be immutable if(rewardFactory == address(0)){ rewardFactory = _rfactory; tokenFactory = _tfactory; emit FactoriesUpdated(_rfactory, _sfactory, _tfactory); } else { emit FactoriesUpdated(address(0), _sfactory, address(0)); } } /** * @notice Arbitrator handles tokens that are used as secondary rewards across multiple pools */ function setArbitrator(address _arb) external { require(msg.sender==owner, "!auth"); rewardArbitrator = _arb; emit ArbitratorUpdated(_arb); } /** * @notice Vote Delegate has the rights to cast votes on the VoterProxy via the Booster */ function setVoteDelegate(address _voteDelegate) external { require(msg.sender==owner, "!auth"); voteDelegate = _voteDelegate; emit VoteDelegateUpdated(_voteDelegate); } /** * @notice Only called once, to set the addresses of cvxCrv (lockRewards) and cvx staking (stakerRewards) */ function setRewardContracts(address _rewards, address _stakerRewards) external { require(msg.sender == owner, "!auth"); //reward contracts are immutable or else the owner //has a means to redeploy and mint cvx via rewardClaimed() if(lockRewards == address(0)){ lockRewards = _rewards; stakerRewards = _stakerRewards; getRewardMultipliers[lockRewards] = REWARD_MULTIPLIER_DENOMINATOR; emit RewardContractsUpdated(_rewards, _stakerRewards); } } /** * @notice Set reward token and claim contract * @dev This creates a secondary (VirtualRewardsPool) rewards contract for the vcxCrv staking contract */ function setFeeInfo(address _feeToken, address _feeDistro) external nonReentrant { require(msg.sender == owner, "!auth"); require(!isShutdown, "shutdown"); require(lockRewards != address(0) && rewardFactory != address(0), "!initialised"); require(_feeToken != address(0) && _feeDistro != address(0), "!addresses"); require(IFeeDistributor(_feeDistro).getTokenTimeCursor(_feeToken) > 0, "!distro"); if(feeTokens[_feeToken].distro == address(0)){ require(!gaugeMap[_feeToken], "!token"); // Distributed directly if(_feeToken == crv){ feeTokens[crv] = FeeDistro({ distro: _feeDistro, rewards: lockRewards, active: true }); emit FeeInfoUpdated(_feeDistro, lockRewards, crv); } else { //create a new reward contract for the new token require(IRewards(lockRewards).extraRewardsLength() < 10, "too many rewards"); address rewards = IRewardFactory(rewardFactory).CreateTokenRewards(_feeToken, lockRewards, address(this)); feeTokens[_feeToken] = FeeDistro({ distro: _feeDistro, rewards: rewards, active: true }); emit FeeInfoUpdated(_feeDistro, rewards, _feeToken); } } else { feeTokens[_feeToken].distro = _feeDistro; emit FeeInfoUpdated(_feeDistro, address(0), _feeToken); } } /** * @notice Allows turning off or on for fee distro */ function updateFeeInfo(address _feeToken, bool _active) external { require(msg.sender==owner, "!auth"); require(feeTokens[_feeToken].distro != address(0), "Fee doesn't exist"); feeTokens[_feeToken].active = _active; emit FeeInfoChanged(_feeToken, _active); } /** * @notice Fee manager can set all the relevant fees * @param _lockFees % for cvxCrv stakers where 1% == 100 * @param _stakerFees % for CVX stakers where 1% == 100 * @param _callerFees % for whoever calls the claim where 1% == 100 * @param _platform % for "treasury" or vlCVX where 1% == 100 */ function setFees(uint256 _lockFees, uint256 _stakerFees, uint256 _callerFees, uint256 _platform) external nonReentrant{ require(msg.sender==feeManager, "!auth"); uint256 total = _lockFees.add(_stakerFees).add(_callerFees).add(_platform); require(total <= MaxFees, ">MaxFees"); require(_lockFees >= 300 && _lockFees <= 3500, "!lockFees"); require(_stakerFees >= 300 && _stakerFees <= 1500, "!stakerFees"); require(_callerFees >= 10 && _callerFees <= 100, "!callerFees"); require(_platform <= 200, "!platform"); lockIncentive = _lockFees; stakerIncentive = _stakerFees; earmarkIncentive = _callerFees; platformFee = _platform; emit FeesUpdated(_lockFees, _stakerFees, _callerFees, _platform); } /** * @notice Set the address of the treasury (i.e. vlCVX) */ function setTreasury(address _treasury) external { require(msg.sender==feeManager, "!auth"); treasury = _treasury; emit TreasuryUpdated(_treasury); } /** * @dev Set bridge delegate * @param _bridgeDelegate The bridge delegate address */ function setBridgeDelegate(address _bridgeDelegate) external { require(msg.sender == feeManager, "!auth"); bridgeDelegate = _bridgeDelegate; } function setRewardMultiplier(address rewardContract, uint256 multiplier) external { require(msg.sender == feeManager, "!auth"); require(multiplier <= REWARD_MULTIPLIER_DENOMINATOR * 2, "too high"); getRewardMultipliers[rewardContract] = multiplier; } /// END SETTER SECTION /// function poolLength() external view returns (uint256) { return poolInfo.length; } /** * @notice Called by the PoolManager (i.e. PoolManagerProxy) to add a new pool - creates all the required * contracts (DepositToken, RewardPool, Stash) and then adds to the list! */ function addPool(address _lptoken, address _gauge, uint256 _stashVersion) external returns(bool){ require(msg.sender==poolManager && !isShutdown, "!add"); require(_gauge != address(0) && _lptoken != address(0),"!param"); require(feeTokens[_gauge].distro == address(0), "!gauge"); //the next pool's pid uint256 pid = poolInfo.length; //create a tokenized deposit address token = ITokenFactory(tokenFactory).CreateDepositToken(_lptoken); //create a reward contract for crv rewards address newRewardPool = IRewardFactory(rewardFactory).CreateCrvRewards(pid,token,_lptoken); //create a stash to handle extra incentives address stash = IStashFactory(stashFactory).CreateStash(pid,_gauge,staker,_stashVersion); //add the new pool poolInfo.push( PoolInfo({ lptoken: _lptoken, token: token, gauge: _gauge, crvRewards: newRewardPool, stash: stash, shutdown: false }) ); gaugeMap[_gauge] = true; //give stashes access to rewardfactory and voteproxy // voteproxy so it can grab the incentive tokens off the contract after claiming rewards // reward factory so that stashes can make new extra reward contracts if a new incentive is added to the gauge if(stash != address(0)){ poolInfo[pid].stash = stash; IStaker(staker).setStashAccess(stash,true); IRewardFactory(rewardFactory).setAccess(stash,true); } // Init the pool with the default reward multiplier getRewardMultipliers[newRewardPool] = REWARD_MULTIPLIER_DENOMINATOR; emit PoolAdded(_lptoken, _gauge, token, newRewardPool, stash, pid); return true; } /** * @notice Shuts down the pool by withdrawing everything from the gauge to here (can later be * claimed from depositors by using the withdraw fn) and marking it as shut down */ function shutdownPool(uint256 _pid) external nonReentrant returns(bool){ require(msg.sender==poolManager, "!auth"); PoolInfo storage pool = poolInfo[_pid]; //withdraw from gauge try IStaker(staker).withdrawAll(pool.lptoken,pool.gauge){ }catch{} pool.shutdown = true; gaugeMap[pool.gauge] = false; emit PoolShutdown(_pid); return true; } /** * @notice Shuts down the WHOLE SYSTEM by withdrawing all the LP tokens to here and then allowing * for subsequent withdrawal by any depositors. */ function shutdownSystem() external{ require(msg.sender == owner, "!auth"); isShutdown = true; for(uint i=0; i < poolInfo.length; i++){ PoolInfo storage pool = poolInfo[i]; if (pool.shutdown) continue; address token = pool.lptoken; address gauge = pool.gauge; //withdraw from gauge try IStaker(staker).withdrawAll(token,gauge){ pool.shutdown = true; }catch{} } } /** * @notice Deposits an "_amount" to a given gauge (specified by _pid), mints a `DepositToken` * and subsequently stakes that on Convex BaseRewardPool */ function deposit(uint256 _pid, uint256 _amount, bool _stake) public nonReentrant returns(bool){ require(!isShutdown,"shutdown"); PoolInfo storage pool = poolInfo[_pid]; require(pool.shutdown == false, "pool is closed"); //send to proxy to stake address lptoken = pool.lptoken; IERC20(lptoken).safeTransferFrom(msg.sender, staker, _amount); //stake address gauge = pool.gauge; require(gauge != address(0),"!gauge setting"); IStaker(staker).deposit(lptoken,gauge); //some gauges claim rewards when depositing, stash them in a seperate contract until next claim address stash = pool.stash; if(stash != address(0)){ IStash(stash).stashRewards(); } address token = pool.token; if(_stake){ //mint here and send to rewards on user behalf ITokenMinter(token).mint(address(this),_amount); address rewardContract = pool.crvRewards; IERC20(token).safeApprove(rewardContract,0); IERC20(token).safeApprove(rewardContract,_amount); IRewards(rewardContract).stakeFor(msg.sender,_amount); }else{ //add user balance directly ITokenMinter(token).mint(msg.sender,_amount); } emit Deposited(msg.sender, _pid, _amount); return true; } /** * @notice Deposits all a senders balance to a given gauge (specified by _pid), mints a `DepositToken` * and subsequently stakes that on Convex BaseRewardPool */ function depositAll(uint256 _pid, bool _stake) external returns(bool){ address lptoken = poolInfo[_pid].lptoken; uint256 balance = IERC20(lptoken).balanceOf(msg.sender); deposit(_pid,balance,_stake); return true; } /** * @notice Withdraws LP tokens from a given PID (& user). * 1. Burn the cvxLP balance from "_from" (implicit balance check) * 2. If pool !shutdown.. withdraw from gauge * 3. If stash, stash rewards * 4. Transfer out the LP tokens */ function _withdraw(uint256 _pid, uint256 _amount, address _from, address _to) internal nonReentrant { PoolInfo storage pool = poolInfo[_pid]; address lptoken = pool.lptoken; address gauge = pool.gauge; //remove lp balance address token = pool.token; ITokenMinter(token).burn(_from,_amount); //pull from gauge if not shutdown // if shutdown tokens will be in this contract if (!pool.shutdown) { IStaker(staker).withdraw(lptoken,gauge, _amount); } //some gauges claim rewards when withdrawing, stash them in a seperate contract until next claim //do not call if shutdown since stashes wont have access address stash = pool.stash; if(stash != address(0) && !isShutdown && !pool.shutdown){ IStash(stash).stashRewards(); } //return lp tokens IERC20(lptoken).safeTransfer(_to, _amount); emit Withdrawn(_to, _pid, _amount); } /** * @notice Withdraw a given amount from a pool (must already been unstaked from the Convex Reward Pool - * BaseRewardPool uses withdrawAndUnwrap to get around this) */ function withdraw(uint256 _pid, uint256 _amount) public returns(bool){ _withdraw(_pid,_amount,msg.sender,msg.sender); return true; } /** * @notice Withdraw all the senders LP tokens from a given gauge */ function withdrawAll(uint256 _pid) public returns(bool){ address token = poolInfo[_pid].token; uint256 userBal = IERC20(token).balanceOf(msg.sender); withdraw(_pid, userBal); return true; } /** * @notice Allows the actual BaseRewardPool to withdraw and send directly to the user */ function withdrawTo(uint256 _pid, uint256 _amount, address _to) external returns(bool){ address rewardContract = poolInfo[_pid].crvRewards; require(msg.sender == rewardContract,"!auth"); _withdraw(_pid,_amount,msg.sender,_to); return true; } /** * @notice set valid vote hash on VoterProxy */ function setVote(bytes32 _hash) external returns(bool){ require(msg.sender == voteDelegate, "!auth"); IStaker(staker).setVote(_hash, false); return true; } /** * @notice Set delegate on snapshot */ function setDelegate(address _delegateContract, address _delegate, bytes32 _space) external{ require(msg.sender == voteDelegate, "!auth"); bytes memory data = abi.encodeWithSelector(bytes4(keccak256("setDelegate(bytes32,address)")), _space, _delegate); IStaker(staker).execute(_delegateContract,uint256(0),data); } /** * @notice Delegate address votes on dao via VoterProxy */ function vote(uint256 _voteId, address _votingAddress, bool _support) external returns(bool){ require(msg.sender == voteDelegate, "!auth"); require(_votingAddress == voteOwnership || _votingAddress == voteParameter, "!voteAddr"); IStaker(staker).vote(_voteId,_votingAddress,_support); return true; } /** * @notice Delegate address votes on gauge weight via VoterProxy */ function voteGaugeWeight(address[] calldata _gauge, uint256[] calldata _weight ) external returns(bool){ require(msg.sender == voteDelegate, "!auth"); for(uint256 i = 0; i < _gauge.length; i++){ IStaker(staker).voteGaugeWeight(_gauge[i],_weight[i]); } return true; } /** * @notice Allows a stash to claim secondary rewards from a gauge */ function claimRewards(uint256 _pid, address _gauge) external returns(bool){ address stash = poolInfo[_pid].stash; require(msg.sender == stash,"!auth"); IStaker(staker).claimRewards(_gauge); return true; } /** * @notice Tells the Curve gauge to redirect any accrued rewards to the given stash via the VoterProxy */ function setGaugeRedirect(uint256 _pid) external returns(bool){ address stash = poolInfo[_pid].stash; require(msg.sender == stash,"!auth"); address gauge = poolInfo[_pid].gauge; bytes memory data = abi.encodeWithSelector(bytes4(keccak256("set_rewards_receiver(address)")), stash); IStaker(staker).execute(gauge,uint256(0),data); return true; } /** * @notice Basically a hugely pivotal function. * Responsible for collecting the crv from gauge, and then redistributing to the correct place. * Pays the caller a fee to process this. */ function _earmarkRewards(uint256 _pid) internal { PoolInfo storage pool = poolInfo[_pid]; require(pool.shutdown == false, "pool is closed"); address gauge = pool.gauge; // If there is idle CRV in the Booster we need to transfer it out // in order that our accounting doesn't get scewed. uint256 crvBBalBefore = IERC20(crv).balanceOf(address(this)); uint256 crvVBalBefore = IERC20(crv).balanceOf(staker); uint256 crvBalBefore = crvBBalBefore.add(crvVBalBefore); //claim crv IStaker(staker).claimCrv(gauge); //crv balance uint256 crvBalAfter = IERC20(crv).balanceOf(address(this)); uint crvBal = crvBalAfter.sub(crvBalBefore); if(crvBalBefore > 0 && treasury != address(0)) { IERC20(crv).transfer(treasury, crvBalBefore); } //check if there are extra rewards address stash = pool.stash; if(stash != address(0)){ //claim extra rewards IStash(stash).claimRewards(); //process extra rewards IStash(stash).processStash(); } if (crvBal > 0) { // LockIncentive = cvxCrv stakers (currently 10%) uint256 _lockIncentive = crvBal.mul(lockIncentive).div(FEE_DENOMINATOR); // StakerIncentive = cvx stakers (currently 5%) uint256 _stakerIncentive = crvBal.mul(stakerIncentive).div(FEE_DENOMINATOR); // CallIncentive = caller of this contract (currently 1%) uint256 _callIncentive = crvBal.mul(earmarkIncentive).div(FEE_DENOMINATOR); // Treasury = vlCVX (currently 1%) if(treasury != address(0) && treasury != address(this) && platformFee > 0){ //only subtract after address condition check uint256 _platform = crvBal.mul(platformFee).div(FEE_DENOMINATOR); crvBal = crvBal.sub(_platform); IERC20(crv).safeTransfer(treasury, _platform); } //remove incentives from balance crvBal = crvBal.sub(_lockIncentive).sub(_callIncentive).sub(_stakerIncentive); //send incentives for calling IERC20(crv).safeTransfer(msg.sender, _callIncentive); //send crv to lp provider reward contract address rewardContract = pool.crvRewards; IERC20(crv).safeTransfer(rewardContract, crvBal); IRewards(rewardContract).queueNewRewards(crvBal); //send lockers' share of crv to reward contract IERC20(crv).safeTransfer(lockRewards, _lockIncentive); IRewards(lockRewards).queueNewRewards(_lockIncentive); //send stakers's share of crv to reward contract IERC20(crv).safeTransfer(stakerRewards, _stakerIncentive); } } /** * @notice Basically a hugely pivotal function. * Responsible for collecting the crv from gauge, and then redistributing to the correct place. * Pays the caller a fee to process this. */ function earmarkRewards(uint256 _pid) external nonReentrant returns(bool){ require(!isShutdown,"shutdown"); _earmarkRewards(_pid); return true; } /** * @notice Claim fees from curve distro contract, put in lockers' reward contract. * lockFees is the secondary reward contract that uses the virtual balances from cvxCrv */ function earmarkFees(address _feeToken) external nonReentrant returns(bool){ require(!isShutdown,"shutdown"); FeeDistro memory feeDistro = feeTokens[_feeToken]; require(feeDistro.active, "Inactive distro"); require(!gaugeMap[_feeToken], "Invalid token"); //claim fee rewards uint256 tokenBalanceVBefore = IERC20(_feeToken).balanceOf(staker); uint256 tokenBalanceBBefore = IERC20(_feeToken).balanceOf(address(this)); uint256 tokenBalanceBefore = tokenBalanceBBefore.add(tokenBalanceVBefore); IStaker(staker).claimFees(feeDistro.distro, _feeToken); uint256 tokenBalanceAfter = IERC20(_feeToken).balanceOf(address(this)); uint256 feesClaimed = tokenBalanceAfter.sub(tokenBalanceBefore); //send fee rewards to reward contract IERC20(_feeToken).safeTransfer(feeDistro.rewards, feesClaimed); IRewards(feeDistro.rewards).queueNewRewards(feesClaimed); return true; } /** * @notice Callback from reward contract when crv is received. * @dev Goes off and mints a relative amount of `CVX` based on the distribution schedule. */ function rewardClaimed(uint256 _pid, address _address, uint256 _amount) external returns(bool){ address rewardContract = poolInfo[_pid].crvRewards; require(msg.sender == rewardContract || msg.sender == lockRewards, "!auth"); uint256 mintAmount = _amount.mul(getRewardMultipliers[msg.sender]).div(REWARD_MULTIPLIER_DENOMINATOR); if(mintAmount > 0) { //mint reward tokens ITokenMinter(minter).mint(_address, mintAmount); } return true; } /** * @dev Distribute fees from L2 to L1 reward contracts * @param _amount Amount of fees to distribute */ function distributeL2Fees(uint256 _amount) external nonReentrant { require(msg.sender == bridgeDelegate, "!auth"); // calculate the rewards that were paid based on the incentives that // are being distributed uint256 totalIncentives = lockIncentive.add(stakerIncentive); uint256 totalFarmed = _amount.mul(FEE_DENOMINATOR).div(totalIncentives); uint256 eligibleForMint = totalFarmed.sub(_amount); // Ensure that the total amount of rewards claimed per epoch is less than 70k uint256 epoch = block.timestamp.div(epochLength); l2FeesHistory[epoch] = l2FeesHistory[epoch].add(totalFarmed); require(l2FeesHistory[epoch] <= 70000e18, "Too many L2 Fees"); // Calculate fees for individual reward contracts uint256 _lockIncentive = _amount.mul(lockIncentive).div(totalIncentives); uint256 _stakerIncentive = _amount.sub(_lockIncentive); //send lockers' share of crv to reward contract IERC20(crv).safeTransferFrom(bridgeDelegate, lockRewards, _lockIncentive); IRewards(lockRewards).queueNewRewards(_lockIncentive); //send stakers's share of crv to reward contract IERC20(crv).safeTransferFrom(bridgeDelegate, stakerRewards, _stakerIncentive); // Mint CVX to bridge delegate ITokenMinter(minter).mint(bridgeDelegate, eligibleForMint); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; interface IOwner { //booster function setFactories(address _rfactory, address _sfactory, address _tfactory) external; function setArbitrator(address _arb) external; function setFeeInfo(address _feeToken, address _feeDistro) external; function updateFeeInfo(address _feeToken, bool _active) external; function shutdownSystem() external; function isShutdown() external view returns(bool); function poolLength() external view returns(uint256); function poolInfo(uint256) external view returns(address,address,address,address,address,bool); function setVoteDelegate(address _voteDelegate) external; function setFeeManager(address _feeM) external; function setOwner(address _owner) external; //rescue function setDistribution(address _distributor, address _rewardDeposit, address _treasury) external; function setExtraReward(address _token, uint256 _option) external; //stash function setExtraReward(address _token) external; function setRewardHook(address _hook) external; //stash factory function setImplementation(address _v1, address _v2, address _v3) external; //vote extension function revertControl() external; } // prettier-ignore interface IBoosterOwner { function transferOwnership(address _owner) external; function acceptOwnership() external; function setFactories(address _rfactory, address _sfactory, address _tfactory) external; function setArbitrator(address _arb) external; function setFeeInfo(address _feeToken, address _feeDistro) external; function updateFeeInfo(address _feeToken, bool _active) external; function setFeeManager(address _feeM) external; function setVoteDelegate(address _voteDelegate) external; function shutdownSystem() external; function queueForceShutdown() external; function forceShutdownSystem() external; function execute( address _to, uint256 _value, bytes calldata _data) external returns (bool, bytes memory); function setRescueTokenDistribution(address _distributor, address _rewardDeposit, address _treasury) external; function setRescueTokenReward(address _token, uint256 _option) external; function setStashExtraReward(address _stash, address _token) external; function setStashRewardHook(address _stash, address _hook) external; function setStashFactoryImplementation(address _v1, address _v2, address _v3) external; } /** * @title Booster * @author ConvexFinance * @notice Immutable booster owner that requires all pools to be shutdown before shutting down the entire convex system * @dev A timelock is required if forcing a shutdown if there is a bugged pool that can not be withdrawn from. * Allow arbitrary calls to other contracts, but limit how calls are made to Booster. */ contract BoosterOwner is IBoosterOwner{ address public immutable poolManager; address public immutable booster; address public immutable stashFactory; address public immutable rescueStash; address public owner; address public pendingowner; bool public isSealed; uint256 public constant FORCE_DELAY = 30 days; bool public isForceTimerStarted; uint256 public forceTimestamp; event ShutdownStarted(uint256 executableTimestamp); event ShutdownExecuted(); event TransferOwnership(address pendingOwner); event AcceptedOwnership(address newOwner); event OwnershipSealed(); /** * @param _owner Owner (e.g. CVX multisig) * @param _poolManager PoolManager (e.g. PoolManagerSecondaryProxy or 0xD20904e5916113D11414F083229e9C8C6F91D1e1) * @param _booster The booster (e.g. 0xF403C135812408BFbE8713b5A23a04b3D48AAE31) * @param _stashFactory Creates stashes (e.g. 0x884da067B66677e72530df91eabb6e3CE69c2bE4) * @param _rescueStash Rescues tokens for subsequent vlCVX redistribution (e.g. 0x01140351069af98416cC08b16424b9E765436531) */ constructor( address _owner, address _poolManager, address _booster, address _stashFactory, address _rescueStash, bool _seal ) public { owner = _owner; poolManager = _poolManager; booster = _booster; stashFactory = _stashFactory; rescueStash = _rescueStash; isSealed = _seal; } modifier onlyOwner() { require(owner == msg.sender, "!owner"); _; } function transferOwnership(address _owner) external override onlyOwner{ pendingowner = _owner; emit TransferOwnership(_owner); } function acceptOwnership() external override { require(pendingowner == msg.sender, "!pendingowner"); owner = pendingowner; pendingowner = address(0); emit AcceptedOwnership(owner); } function sealOwnership() external onlyOwner{ isSealed = true; emit OwnershipSealed(); } function setBoosterOwner() external onlyOwner{ //allow reverting ownership until sealed require(!isSealed, "ownership sealed"); //transfer booster ownership to this owner IOwner(booster).setOwner(owner); } function setFactories(address _rfactory, address _sfactory, address _tfactory) external override onlyOwner{ IOwner(booster).setFactories(_rfactory, _sfactory, _tfactory); } function setArbitrator(address _arb) external override onlyOwner{ IOwner(booster).setArbitrator(_arb); } function setFeeInfo(address _feeToken, address _feeDistro) external override onlyOwner{ IOwner(booster).setFeeInfo(_feeToken, _feeDistro); } function updateFeeInfo(address _feeToken, bool _active) external override onlyOwner{ IOwner(booster).updateFeeInfo(_feeToken, _active); } function setFeeManager(address _feeM) external override onlyOwner{ IOwner(booster).setFeeManager(_feeM); } function setVoteDelegate(address _voteDelegate) external override onlyOwner{ IOwner(booster).setVoteDelegate(_voteDelegate); } function shutdownSystem() external override onlyOwner{ require(IOwner(poolManager).isShutdown(),"!poolMgrShutdown"); //check that all pools are already shutdown uint256 poolCount = IOwner(booster).poolLength(); for(uint256 i = 0; i < poolCount; i++){ (,,,,,bool isshutdown) = IOwner(booster).poolInfo(i); require(isshutdown, "!poolShutdown"); } //complete the shutdown process IOwner(booster).shutdownSystem(); emit ShutdownExecuted(); } //queue a forced shutdown that does not require pools to already be shutdown //this should only be needed if a pool is broken and withdrawAll() does not //correctly return enough lp tokens function queueForceShutdown() external override onlyOwner{ require(IOwner(poolManager).isShutdown(),"!poolMgrShutdown"); require(!isForceTimerStarted, "already started"); isForceTimerStarted = true; forceTimestamp = block.timestamp + FORCE_DELAY; emit ShutdownStarted(forceTimestamp); } //force shutdown the system after timer has expired function forceShutdownSystem() external override onlyOwner{ require(isForceTimerStarted, "!timer start"); require(block.timestamp > forceTimestamp, "!timer finish"); IOwner(booster).shutdownSystem(); emit ShutdownExecuted(); } //allow arbitrary calls to any contract other than the booster, as some contracts //may use ownership as booster.owner() instead of local variable function execute( address _to, uint256 _value, bytes calldata _data ) external override onlyOwner returns (bool, bytes memory) { require(_to != booster, "!invalid target"); (bool success, bytes memory result) = _to.call{value:_value}(_data); return (success, result); } // --- Helper functions for other systems, could also just use execute() --- //TokenRescue setDistribution function setRescueTokenDistribution(address _distributor, address _rewardDeposit, address _treasury) external override onlyOwner{ IOwner(rescueStash).setDistribution(_distributor, _rewardDeposit, _treasury); } //TokenRescue setExtraReward function setRescueTokenReward(address _token, uint256 _option) external override onlyOwner{ IOwner(rescueStash).setExtraReward(_token, _option); } //stash v3 - set extra reward function setStashExtraReward(address _stash, address _token) external override onlyOwner{ IOwner(_stash).setExtraReward(_token); } //stash v3 - set reward hook function setStashRewardHook(address _stash, address _hook) external override onlyOwner{ IOwner(_stash).setRewardHook(_hook); } //stash factory - set implementation function setStashFactoryImplementation(address _v1, address _v2, address _v3) external override onlyOwner{ IOwner(stashFactory).setImplementation(_v1, _v2, _v3); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import { IPools, IStash, IStashFactory } from "./Interfaces.sol"; import { IBoosterOwner } from "./BoosterOwner.sol"; interface IFeeTokenVerifier { function checkToken(address) external view returns (bool); } /** * @title BoosterOwnerSecondary * @author ConvexFinance -> AuraFinance * @notice Immutable booster owner that requires all pools to be shutdown before shutting down the entire convex system * @dev A timelock is required if forcing a shutdown if there is a bugged pool that can not be withdrawn from. * Allow arbitrary calls to other contracts, but limit how calls are made to Booster. */ contract BoosterOwnerSecondary { IPools public immutable booster; IBoosterOwner public immutable boosterOwner; uint256 public immutable oldPidCheckpoint; address public owner; address public manager; address public pendingowner; bool public sealStashImplementation; address public feeTokenVerifier; event TransferOwnership(address pendingOwner); event AcceptedOwnership(address newOwner); event SealStashImplementation(); event SetFeeTokenVerifier(address feeTokenVerifier); event SetManager(address manager); /** * @param _owner Owner (e.g. CVX multisig) * @param _boosterOwner BoosterOwner */ constructor( address _owner, address _boosterOwner, address _booster ) public { owner = _owner; manager = _owner; boosterOwner = IBoosterOwner(_boosterOwner); booster = IPools(_booster); oldPidCheckpoint = IPools(_booster).poolLength() - 1; } /* ---------------------------------------------------------------- * Modifiers * ------------------------------------------------------------- */ modifier onlyOwner() { require(owner == msg.sender, "!owner"); _; } modifier onlyManager() { require(manager == msg.sender, "!manager"); _; } /* ---------------------------------------------------------------- * Setters * ------------------------------------------------------------- */ function setSealStashImplementation() external onlyOwner { sealStashImplementation = true; emit SealStashImplementation(); } function setFeeTokenVerifier(address _feeTokenVerifier) external onlyManager { feeTokenVerifier = _feeTokenVerifier; emit SetFeeTokenVerifier(_feeTokenVerifier); } function setManager(address _manager) external onlyOwner { require(manager != address(0), "sealed"); manager = _manager; emit SetManager(_manager); } function transferOwnership(address _owner) external onlyOwner { pendingowner = _owner; emit TransferOwnership(_owner); } function acceptOwnership() external { require(pendingowner == msg.sender, "!pendingowner"); owner = pendingowner; pendingowner = address(0); emit AcceptedOwnership(owner); } /* ---------------------------------------------------------------- * Booster Functions * ------------------------------------------------------------- */ function acceptOwnershipBoosterOwner() external { boosterOwner.acceptOwnership(); } function setArbitrator(address _arb) external onlyOwner { boosterOwner.setArbitrator(_arb); } function setFeeInfo(address _feeToken, address _feeDistro) external onlyOwner { if (feeTokenVerifier != address(0)) { require(IFeeTokenVerifier(feeTokenVerifier).checkToken(_feeToken), "!verified"); } boosterOwner.setFeeInfo(_feeToken, _feeDistro); } function updateFeeInfo(address _feeToken, bool _active) external onlyOwner { boosterOwner.updateFeeInfo(_feeToken, _active); } function setFeeManager(address _feeM) external onlyOwner { boosterOwner.setFeeManager(_feeM); } function setVoteDelegate(address _voteDelegate) external onlyOwner { boosterOwner.setVoteDelegate(_voteDelegate); } function shutdownSystem() external onlyOwner { boosterOwner.shutdownSystem(); } function queueForceShutdown() external onlyOwner { boosterOwner.queueForceShutdown(); } function forceShutdownSystem() external onlyOwner { boosterOwner.forceShutdownSystem(); } function setStashFactoryImplementation( address _v1, address _v2, address _v3 ) external onlyOwner { require(!sealStashImplementation, "sealed"); boosterOwner.setStashFactoryImplementation(_v1, _v2, _v3); } function execute( address _to, uint256 _value, bytes memory _data ) external onlyOwner returns (bool, bytes memory) { bytes4 sig; assembly { sig := mload(add(_data, 32)) } require( sig != IBoosterOwner.setFactories.selector && sig != IStashFactory.setImplementation.selector && sig != IStash.setExtraReward.selector && sig != IBoosterOwner.setFeeInfo.selector, "!allowed" ); (bool success, bytes memory result) = boosterOwner.execute(_to, _value, _data); require(success, "!success"); return (success, result); } // --- Helper functions for other systems, could also just use execute() --- function setRescueTokenDistribution( address _distributor, address _rewardDeposit, address _treasury ) external onlyOwner { boosterOwner.setRescueTokenDistribution(_distributor, _rewardDeposit, _treasury); } function setRescueTokenReward(address _token, uint256 _option) external onlyOwner { boosterOwner.setRescueTokenReward(_token, _option); } function setStashExtraReward(uint256 _pid, address _token) external onlyOwner { require(_pid > oldPidCheckpoint, "!checkpoint"); (, , , , address stash, ) = booster.poolInfo(_pid); boosterOwner.setStashExtraReward(stash, _token); } function setStashRewardHook(address _stash, address _hook) external onlyOwner { boosterOwner.setStashRewardHook(_stash, _hook); } function setStashTokenIsValid(address stashToken, bool isValid) external onlyOwner { bytes memory data = abi.encodeWithSignature("setIsValid(bool)", isValid); (bool success, ) = boosterOwner.execute(stashToken, 0, data); require(success, "!success"); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./Interfaces.sol"; import "@openzeppelin/contracts-0.6/math/SafeMath.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts-0.6/utils/Address.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/ERC20.sol"; /** * @title cvxCrvToken * @author ConvexFinance * @notice Dumb ERC20 token that allows the operator (crvDepositor) to mint and burn tokens */ contract cvxCrvToken is ERC20 { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; address public operator; constructor(string memory _nameArg, string memory _symbolArg) public ERC20( _nameArg, _symbolArg ) { operator = msg.sender; } /** * @notice Allows the initial operator (deployer) to set the operator. * Note - crvDepositor has no way to change this back, so it's effectively immutable */ function setOperator(address _operator) external { require(msg.sender == operator, "!auth"); operator = _operator; } /** * @notice Allows the crvDepositor to mint */ function mint(address _to, uint256 _amount) external { require(msg.sender == operator, "!authorized"); _mint(_to, _amount); } /** * @notice Allows the crvDepositor to burn */ function burn(address _from, uint256 _amount) external { require(msg.sender == operator, "!authorized"); _burn(_from, _amount); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import { ReentrancyGuard } from "@openzeppelin/contracts-0.6/utils/ReentrancyGuard.sol"; import "@openzeppelin/contracts-0.6/math/SafeMath.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts-0.6/utils/Context.sol"; import "@openzeppelin/contracts-0.6/access/Ownable.sol"; import "./interfaces/IRewarder.sol"; /** * @title ConvexMasterChef * @author ConvexFinance * @notice Masterchef can distribute rewards to n pools over x time * @dev There are some caveats with this usage - once it's turned on it can't be turned off, * and thus it can over complicate the distribution of these rewards. * To kick things off, just transfer CVX here and add some pools - rewards will be distributed * pro-rata based on the allocation points in each pool vs the total alloc. */ contract ConvexMasterChef is Ownable, ReentrancyGuard { using SafeMath for uint256; using SafeERC20 for IERC20; // Info of each user. struct UserInfo { uint256 amount; // How many LP tokens the user has provided. uint256 rewardDebt; // Reward debt. See explanation below. // // We do some fancy math here. Basically, any point in time, the amount of CVXs // entitled to a user but is pending to be distributed is: // // pending reward = (user.amount * pool.accCvxPerShare) - user.rewardDebt // // Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens: // 1. The pool's `accCvxPerShare` (and `lastRewardBlock`) gets updated. // 2. User receives the pending reward sent to his/her address. // 3. User's `amount` gets updated. // 4. User's `rewardDebt` gets updated. } // Info of each pool. struct PoolInfo { IERC20 lpToken; // Address of LP token contract. uint256 allocPoint; // How many allocation points assigned to this pool. CVX to distribute per block. uint256 lastRewardBlock; // Last block number that CVXs distribution occurs. uint256 accCvxPerShare; // Accumulated CVXs per share, times 1e12. See below. IRewarder rewarder; } //cvx IERC20 public immutable cvx; // CVX tokens created per block. uint256 public immutable rewardPerBlock; // Bonus muliplier for early cvx makers. uint256 public constant BONUS_MULTIPLIER = 2; // Info of each pool. PoolInfo[] public poolInfo; mapping(address => bool) public isAddedPool; // Info of each user that stakes LP tokens. mapping(uint256 => mapping(address => UserInfo)) public userInfo; // Total allocation points. Must be the sum of all allocation points in all pools. uint256 public totalAllocPoint = 0; // The block number when CVX mining starts. uint256 public immutable startBlock; uint256 public immutable endBlock; // Events event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event RewardPaid(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw( address indexed user, uint256 indexed pid, uint256 amount ); constructor( IERC20 _cvx, uint256 _rewardPerBlock, uint256 _startBlock, uint256 _endBlock ) public { cvx = _cvx; isAddedPool[address(_cvx)] = true; rewardPerBlock = _rewardPerBlock; startBlock = _startBlock; endBlock = _endBlock; } function poolLength() external view returns (uint256) { return poolInfo.length; } // Add a new lp to the pool. Can only be called by the owner. // XXX DO NOT add the same LP token more than once. Rewards will be messed up if you do. function add( uint256 _allocPoint, IERC20 _lpToken, IRewarder _rewarder ) public onlyOwner nonReentrant { require(poolInfo.length < 32, "max pools"); require(!isAddedPool[address(_lpToken)], "add: Duplicated LP Token"); isAddedPool[address(_lpToken)] = true; massUpdatePools(); uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock; totalAllocPoint = totalAllocPoint.add(_allocPoint); poolInfo.push( PoolInfo({ lpToken: _lpToken, allocPoint: _allocPoint, lastRewardBlock: lastRewardBlock, accCvxPerShare: 0, rewarder: _rewarder }) ); } // Update the given pool's CVX allocation point. Can only be called by the owner. function set( uint256 _pid, uint256 _allocPoint, IRewarder _rewarder, bool _updateRewarder ) public onlyOwner nonReentrant { massUpdatePools(); totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add( _allocPoint ); require(totalAllocPoint > 0, "!alloc"); poolInfo[_pid].allocPoint = _allocPoint; if(_updateRewarder){ poolInfo[_pid].rewarder = _rewarder; } } // Return reward multiplier over the given _from to _to block. function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) { uint256 clampedTo = _to > endBlock ? endBlock : _to; uint256 clampedFrom = _from > endBlock ? endBlock : _from; return clampedTo.sub(clampedFrom); } // View function to see pending CVXs on frontend. function pendingCvx(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accCvxPerShare = pool.accCvxPerShare; uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (block.number > pool.lastRewardBlock && lpSupply != 0) { uint256 multiplier = getMultiplier( pool.lastRewardBlock, block.number ); uint256 cvxReward = multiplier .mul(rewardPerBlock) .mul(pool.allocPoint) .div(totalAllocPoint); accCvxPerShare = accCvxPerShare.add( cvxReward.mul(1e12).div(lpSupply) ); } return user.amount.mul(accCvxPerShare).div(1e12).sub(user.rewardDebt); } // Update reward vairables for all pools. Be careful of gas spending! function massUpdatePools() public { uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { updatePool(pid); } } // Update reward variables of the given pool to be up-to-date. function updatePool(uint256 _pid) public { PoolInfo storage pool = poolInfo[_pid]; if (block.number <= pool.lastRewardBlock) { return; } uint256 lpSupply = pool.lpToken.balanceOf(address(this)); if (lpSupply == 0) { pool.lastRewardBlock = block.number; return; } uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number); uint256 cvxReward = multiplier .mul(rewardPerBlock) .mul(pool.allocPoint) .div(totalAllocPoint); //cvx.mint(address(this), cvxReward); pool.accCvxPerShare = pool.accCvxPerShare.add( cvxReward.mul(1e12).div(lpSupply) ); pool.lastRewardBlock = block.number; } // Deposit LP tokens to MasterChef for CVX allocation. function deposit(uint256 _pid, uint256 _amount) public nonReentrant { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; updatePool(_pid); if (user.amount > 0) { uint256 pending = user .amount .mul(pool.accCvxPerShare) .div(1e12) .sub(user.rewardDebt); safeRewardTransfer(msg.sender, pending); } pool.lpToken.safeTransferFrom( address(msg.sender), address(this), _amount ); user.amount = user.amount.add(_amount); user.rewardDebt = user.amount.mul(pool.accCvxPerShare).div(1e12); //extra rewards IRewarder _rewarder = pool.rewarder; if (address(_rewarder) != address(0)) { _rewarder.onReward(_pid, msg.sender, msg.sender, 0, user.amount); } emit Deposit(msg.sender, _pid, _amount); } // Withdraw LP tokens from MasterChef. function withdraw(uint256 _pid, uint256 _amount) public nonReentrant { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; require(user.amount >= _amount, "withdraw: not good"); updatePool(_pid); uint256 pending = user.amount.mul(pool.accCvxPerShare).div(1e12).sub( user.rewardDebt ); safeRewardTransfer(msg.sender, pending); user.amount = user.amount.sub(_amount); user.rewardDebt = user.amount.mul(pool.accCvxPerShare).div(1e12); pool.lpToken.safeTransfer(address(msg.sender), _amount); //extra rewards IRewarder _rewarder = pool.rewarder; if (address(_rewarder) != address(0)) { _rewarder.onReward(_pid, msg.sender, msg.sender, pending, user.amount); } emit RewardPaid(msg.sender, _pid, pending); emit Withdraw(msg.sender, _pid, _amount); } function claim(uint256 _pid, address _account) external nonReentrant { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_account]; updatePool(_pid); uint256 pending = user.amount.mul(pool.accCvxPerShare).div(1e12).sub( user.rewardDebt ); safeRewardTransfer(_account, pending); user.rewardDebt = user.amount.mul(pool.accCvxPerShare).div(1e12); //extra rewards IRewarder _rewarder = pool.rewarder; if (address(_rewarder) != address(0)) { _rewarder.onReward(_pid, _account, _account, pending, user.amount); } emit RewardPaid(_account, _pid, pending); } // Withdraw without caring about rewards. EMERGENCY ONLY. function emergencyWithdraw(uint256 _pid) public nonReentrant { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][msg.sender]; pool.lpToken.safeTransfer(address(msg.sender), user.amount); emit EmergencyWithdraw(msg.sender, _pid, user.amount); user.amount = 0; user.rewardDebt = 0; //extra rewards IRewarder _rewarder = pool.rewarder; if (address(_rewarder) != address(0)) { _rewarder.onReward(_pid, msg.sender, msg.sender, 0, 0); } } // Safe cvx transfer function, just in case if rounding error causes pool to not have enough CVXs. function safeRewardTransfer(address _to, uint256 _amount) internal { uint256 cvxBal = cvx.balanceOf(address(this)); if (_amount > cvxBal) { cvx.safeTransfer(_to, cvxBal); } else { cvx.safeTransfer(_to, _amount); } } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./Interfaces.sol"; import "@openzeppelin/contracts-0.6/math/SafeMath.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts-0.6/utils/Address.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol"; /** * @title CrvDepositor * @author ConvexFinance * @notice This is the entry point for CRV > cvxCRV wrapping. It accepts CRV, sends to 'staker' * for depositing into Curves VotingEscrow, and then mints cvxCRV at 1:1 via the 'minter' (cCrv) minus * the lockIncentive (initially 1%) which is used to basically compensate users who call the `lock` function on Curves * system (larger depositors would likely want to lock). */ contract CrvDepositor{ using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; address public immutable crvBpt; address public immutable escrow; uint256 private constant MAXTIME = 1 * 364 * 86400; uint256 private constant WEEK = 7 * 86400; uint256 public lockIncentive = 10; //incentive to users who spend gas to lock crvBpt uint256 public constant FEE_DENOMINATOR = 10000; address public feeManager; address public daoOperator; address public immutable staker; address public immutable minter; uint256 public incentiveCrv = 0; uint256 public unlockTime; bool public cooldown; /** * @param _staker CVX VoterProxy (0x989AEb4d175e16225E39E87d0D97A3360524AD80) * @param _minter cvxCRV token (0x62B9c7356A2Dc64a1969e19C23e4f579F9810Aa7) * @param _crvBpt crvBPT for veCRV deposits * @param _escrow CRV VotingEscrow (0x5f3b5DfEb7B28CDbD7FAba78963EE202a494e2A2) */ constructor( address _staker, address _minter, address _crvBpt, address _escrow, address _daoOperator ) public { staker = _staker; minter = _minter; crvBpt = _crvBpt; escrow = _escrow; feeManager = msg.sender; daoOperator = _daoOperator; } function setFeeManager(address _feeManager) external { require(msg.sender == feeManager, "!auth"); feeManager = _feeManager; } function setDaoOperator(address _daoOperator) external { require(msg.sender == daoOperator, "!auth"); daoOperator = _daoOperator; } function setFees(uint256 _lockIncentive) external{ require(msg.sender==feeManager, "!auth"); if(_lockIncentive >= 0 && _lockIncentive <= 30){ lockIncentive = _lockIncentive; } } function setCooldown(bool _cooldown) external { require(msg.sender == daoOperator, "!auth"); cooldown = _cooldown; } /** * @notice Called once to deposit the balance of CRV in this contract to the VotingEscrow */ function initialLock() external{ require(!cooldown, "cooldown"); require(msg.sender==feeManager, "!auth"); uint256 vecrv = IERC20(escrow).balanceOf(staker); if(vecrv == 0){ uint256 unlockAt = block.timestamp + MAXTIME; uint256 unlockInWeeks = (unlockAt/WEEK)*WEEK; //release old lock if exists IStaker(staker).release(); //create new lock uint256 crvBalanceStaker = IERC20(crvBpt).balanceOf(staker); IStaker(staker).createLock(crvBalanceStaker, unlockAt); unlockTime = unlockInWeeks; } } //lock curve function _lockCurve() internal { if(cooldown) { return; } uint256 crvBalance = IERC20(crvBpt).balanceOf(address(this)); if(crvBalance > 0){ IERC20(crvBpt).safeTransfer(staker, crvBalance); } //increase ammount uint256 crvBalanceStaker = IERC20(crvBpt).balanceOf(staker); if(crvBalanceStaker == 0){ return; } //increase amount IStaker(staker).increaseAmount(crvBalanceStaker); uint256 unlockAt = block.timestamp + MAXTIME; uint256 unlockInWeeks = (unlockAt/WEEK)*WEEK; //increase time too if over 1 week buffer if(unlockInWeeks.sub(unlockTime) >= WEEK){ IStaker(staker).increaseTime(unlockAt); unlockTime = unlockInWeeks; } } /** * @notice Locks the balance of CRV, and gives out an incentive to the caller */ function lockCurve() external { require(!cooldown, "cooldown"); _lockCurve(); //mint incentives if(incentiveCrv > 0){ ITokenMinter(minter).mint(msg.sender,incentiveCrv); incentiveCrv = 0; } } /** * @notice Deposit crvBpt for cvxCrv on behalf of another user * @dev See depositFor(address, uint256, bool, address) */ function deposit(uint256 _amount, bool _lock, address _stakeAddress) public { depositFor(msg.sender, _amount, _lock, _stakeAddress); } /** * @notice Deposit crvBpt for cvxCrv * @dev Can lock immediately or defer locking to someone else by paying a fee. * while users can choose to lock or defer, this is mostly in place so that * the cvx reward contract isnt costly to claim rewards. * @param _amount Units of CRV to deposit * @param _lock Lock now? or pay ~1% to the locker * @param _stakeAddress Stake in cvxCrv staking? */ function depositFor(address to, uint256 _amount, bool _lock, address _stakeAddress) public { require(_amount > 0,"!>0"); require(!cooldown, "cooldown"); if(_lock){ //lock immediately, transfer directly to staker to skip an erc20 transfer IERC20(crvBpt).safeTransferFrom(msg.sender, staker, _amount); _lockCurve(); if(incentiveCrv > 0){ //add the incentive tokens here so they can be staked together _amount = _amount.add(incentiveCrv); incentiveCrv = 0; } }else{ //move tokens here IERC20(crvBpt).safeTransferFrom(msg.sender, address(this), _amount); //defer lock cost to another user uint256 callIncentive = _amount.mul(lockIncentive).div(FEE_DENOMINATOR); _amount = _amount.sub(callIncentive); //add to a pool for lock caller incentiveCrv = incentiveCrv.add(callIncentive); } bool depositOnly = _stakeAddress == address(0); if(depositOnly){ //mint for to ITokenMinter(minter).mint(to,_amount); }else{ //mint here ITokenMinter(minter).mint(address(this),_amount); //stake for to IERC20(minter).safeApprove(_stakeAddress,0); IERC20(minter).safeApprove(_stakeAddress,_amount); IRewards(_stakeAddress).stakeFor(to,_amount); } } function deposit(uint256 _amount, bool _lock) external { deposit(_amount,_lock,address(0)); } function depositAll(bool _lock, address _stakeAddress) external{ uint256 crvBal = IERC20(crvBpt).balanceOf(msg.sender); deposit(crvBal,_lock,_stakeAddress); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./Interfaces.sol"; import "@openzeppelin/contracts-0.6/math/SafeMath.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts-0.6/utils/Address.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/ERC20.sol"; /** * @title DepositToken * @author ConvexFinance * @notice Simply creates a token that can be minted and burned from the operator */ contract DepositToken is ERC20 { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; address public operator; /** * @param _operator Booster * @param _lptoken Underlying LP token for deposits * @param _namePostfix Postfixes lpToken name * @param _symbolPrefix Prefixed lpToken symbol */ constructor( address _operator, address _lptoken, string memory _namePostfix, string memory _symbolPrefix ) public ERC20( string( abi.encodePacked(ERC20(_lptoken).name(), _namePostfix) ), string(abi.encodePacked(_symbolPrefix, ERC20(_lptoken).symbol())) ) { operator = _operator; } function mint(address _to, uint256 _amount) external { require(msg.sender == operator, "!authorized"); _mint(_to, _amount); } function burn(address _from, uint256 _amount) external { require(msg.sender == operator, "!authorized"); _burn(_from, _amount); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./Interfaces.sol"; import "./interfaces/IRewardHook.sol"; import "./StashToken.sol"; import "@openzeppelin/contracts-0.6/math/SafeMath.sol"; import "@openzeppelin/contracts-0.6/proxy/Clones.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts-0.6/utils/Address.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol"; /** * @title ExtraRewardStashV3 * @author ConvexFinance -> AuraFinance * @notice ExtraRewardStash for pools added to the Booster to handle extra rewards * that aren't CRV that can be claimed from a gauge. * - v3.0: Support for curve gauge reward redirect * The Booster contract has a function called setGaugeRedirect. This function calls set_rewards_receiver * On the Curve Guage. This tells the Gauge where to send rewards. The Booster crafts the calldata for this * transaction and then calls execute on the VoterProxy which executes this transaction on the Curve Gauge * - v3.1: Support for arbitrary token rewards outside of gauge rewards add * reward hook to pull rewards during claims * - v3.2: Move constuctor to init function for proxy creation */ contract ExtraRewardStashV3 { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; address public immutable crv; uint256 private constant maxRewards = 8; uint256 public pid; address public operator; address public staker; address public gauge; address public rewardFactory; address public stashTokenImplementation; mapping(address => uint256) public historicalRewards; bool public hasRedirected; bool public hasCurveRewards; struct TokenInfo { address token; address rewardAddress; address stashToken; } //use mapping+array so that we dont have to loop check each time setToken is called mapping(address => TokenInfo) public tokenInfo; address[] public tokenList; //address to call for reward pulls address public rewardHook; /** * @param _crv CRV token address */ constructor(address _crv) public { crv = _crv; } /** * @param _pid Pool ID * @param _operator Operator (Booster) * @param _staker Staker (VoterProxy) * @param _gauge Gauge * @param _rFactory Reward factory */ function initialize(uint256 _pid, address _operator, address _staker, address _gauge, address _rFactory) external { require(gauge == address(0),"!init"); pid = _pid; operator = _operator; staker = _staker; gauge = _gauge; rewardFactory = _rFactory; stashTokenImplementation = address(new StashToken(address(this))); } function getName() external pure returns (string memory) { return "ExtraRewardStashV3.2"; } function tokenCount() external view returns (uint256){ return tokenList.length; } /** * @notice Claim rewards from the gauge * @dev The Stash's claimRewards function calls claimRewards on the Booster contract * which calls claimRewards on the VoterProxy which calls claim_rewards on the gauge * If a RewardHook is set onRewardClaim is also called on that * Called by Booster earmarkRewards * Guage rewards are sent directly to this stash even though the Curve method claim_rewards * is being called by the VoterProxy. This is because Curves guages have the ability to redirect * rewards to somewhere other than msg.sender. This is setup in Booster setGaugeRedirect */ function claimRewards() external returns (bool) { require(msg.sender == operator, "!operator"); //this is updateable from v2 gauges now so must check each time. checkForNewRewardTokens(); //make sure we're redirected if(!hasRedirected){ IDeposit(operator).setGaugeRedirect(pid); hasRedirected = true; } if(hasCurveRewards){ //claim rewards on gauge for staker //using reward_receiver so all rewards will be moved to this stash IDeposit(operator).claimRewards(pid,gauge); } //hook for reward pulls if(rewardHook != address(0)){ try IRewardHook(rewardHook).onRewardClaim(){ }catch{} } return true; } //check if gauge rewards have changed function checkForNewRewardTokens() internal { for(uint256 i = 0; i < maxRewards; i++){ address token = ICurveGauge(gauge).reward_tokens(i); if (token == address(0)) { break; } if(!hasCurveRewards){ hasCurveRewards = true; } setToken(token); } } //register an extra reward token to be handled // (any new incentive that is not directly on curve gauges) function setExtraReward(address _token) external{ //owner of booster can set extra rewards require(IDeposit(operator).owner() == msg.sender, "!owner"); require(tokenList.length < 4, "too many rewards"); setToken(_token); } function setRewardHook(address _hook) external{ //owner of booster can set reward hook require(IDeposit(operator).owner() == msg.sender, "!owner"); rewardHook = _hook; } /** * @notice Add a reward token to the token list so it can be claimed * @dev For each token that is added as a claimable reward a VirtualRewardsPool * is deployed to handle virtual distribution of tokens */ function setToken(address _token) internal { TokenInfo storage t = tokenInfo[_token]; if(t.token == address(0) && _token != crv){ //set token address t.token = _token; StashToken stashToken = StashToken(Clones.clone(stashTokenImplementation)); // we only want to add rewards that are not CRV //create new reward contract (for NON-crv tokens only) (,,,address mainRewardContract,,) = IDeposit(operator).poolInfo(pid); address rewardContract = IRewardFactory(rewardFactory).CreateTokenRewards( address(stashToken), mainRewardContract, address(this)); stashToken.init(operator, rewardContract, _token); t.rewardAddress = rewardContract; t.stashToken = address(stashToken); //add token to list of known rewards tokenList.push(_token); } } //pull assigned tokens from staker to stash function stashRewards() external pure returns(bool){ //after depositing/withdrawing, extra incentive tokens are claimed //but from v3 this is default to off, and this stash is the reward receiver too. return true; } /** * @notice Distribute rewards * @dev Send all extra token rewards to the rewardContract VirtualRewardsPool * Called by Booster earmarkRewards */ function processStash() external returns(bool){ require(msg.sender == operator, "!operator"); uint256 tCount = tokenList.length; for(uint i=0; i < tCount; i++){ TokenInfo storage t = tokenInfo[tokenList[i]]; address token = t.token; if(token == address(0)) continue; if(!StashToken(t.stashToken).isValid()) continue; uint256 amount = IERC20(token).balanceOf(address(this)); if (amount > 0) { historicalRewards[token] = historicalRewards[token].add(amount); //add to reward contract address rewards = t.rewardAddress; if(rewards == address(0)) continue; address stashToken = t.stashToken; IERC20(token).safeApprove(stashToken, 0); IERC20(token).safeApprove(stashToken, amount); StashToken(stashToken).mint(amount); IRewards(rewards).queueNewRewards(amount); } } return true; } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; interface ICurveGauge { function deposit(uint256) external; function balanceOf(address) external view returns (uint256); function withdraw(uint256) external; function claim_rewards() external; function reward_tokens(uint256) external view returns(address);//v2 function rewarded_token() external view returns(address);//v1 function lp_token() external view returns(address); } interface ICurveVoteEscrow { function create_lock(uint256, uint256) external; function increase_amount(uint256) external; function increase_unlock_time(uint256) external; function withdraw() external; function smart_wallet_checker() external view returns (address); function commit_smart_wallet_checker(address) external; function apply_smart_wallet_checker() external; } interface IWalletChecker { function check(address) external view returns (bool); function approveWallet(address) external; function dao() external view returns (address); } interface IVoting{ function vote(uint256, bool, bool) external; //voteId, support, executeIfDecided function getVote(uint256) external view returns(bool,bool,uint64,uint64,uint64,uint64,uint256,uint256,uint256,bytes memory); function vote_for_gauge_weights(address,uint256) external; } interface IMinter{ function mint(address) external; } interface IStaker{ function deposit(address, address) external returns (bool); function withdraw(address) external returns (uint256); function withdraw(address, address, uint256) external returns (bool); function withdrawAll(address, address) external returns (bool); function createLock(uint256, uint256) external returns(bool); function increaseAmount(uint256) external returns(bool); function increaseTime(uint256) external returns(bool); function release() external returns(bool); function claimCrv(address) external returns (uint256); function claimRewards(address) external returns(bool); function claimFees(address,address) external returns (uint256); function setStashAccess(address, bool) external returns (bool); function vote(uint256,address,bool) external returns(bool); function voteGaugeWeight(address,uint256) external returns(bool); function balanceOfPool(address) external view returns (uint256); function operator() external view returns (address); function execute(address _to, uint256 _value, bytes calldata _data) external returns (bool, bytes memory); function setVote(bytes32 hash, bool valid) external; function migrate(address to) external; } interface IRewards{ function stake(address, uint256) external; function stakeFor(address, uint256) external; function withdraw(address, uint256) external; function exit(address) external; function getReward(address) external; function queueNewRewards(uint256) external; function notifyRewardAmount(uint256) external; function addExtraReward(address) external; function extraRewardsLength() external view returns (uint256); function stakingToken() external view returns (address); function rewardToken() external view returns(address); function earned(address account) external view returns (uint256); } interface IStash{ function stashRewards() external returns (bool); function processStash() external returns (bool); function claimRewards() external returns (bool); function initialize(uint256 _pid, address _operator, address _staker, address _gauge, address _rewardFactory) external; function setExtraReward(address) external; } interface IFeeDistributor { function claimToken(address user, address token) external returns (uint256); function claimTokens(address user, address[] calldata tokens) external returns (uint256[] memory); function getTokenTimeCursor(address token) external view returns (uint256); } interface ITokenMinter{ function mint(address,uint256) external; function burn(address,uint256) external; } interface IDeposit{ function isShutdown() external view returns(bool); function balanceOf(address _account) external view returns(uint256); function totalSupply() external view returns(uint256); function poolInfo(uint256) external view returns(address,address,address,address,address, bool); function rewardClaimed(uint256,address,uint256) external; function withdrawTo(uint256,uint256,address) external; function claimRewards(uint256,address) external returns(bool); function rewardArbitrator() external returns(address); function setGaugeRedirect(uint256 _pid) external returns(bool); function owner() external returns(address); function deposit(uint256 _pid, uint256 _amount, bool _stake) external returns(bool); } interface ICrvDeposit{ function deposit(uint256, bool) external; function lockIncentive() external view returns(uint256); } interface IRewardFactory{ function setAccess(address,bool) external; function CreateCrvRewards(uint256,address,address) external returns(address); function CreateTokenRewards(address,address,address) external returns(address); function activeRewardCount(address) external view returns(uint256); function addActiveReward(address,uint256) external returns(bool); function removeActiveReward(address,uint256) external returns(bool); } interface IStashFactory{ function CreateStash(uint256,address,address,uint256) external returns(address); function setImplementation(address, address, address) external; } interface ITokenFactory{ function CreateDepositToken(address) external returns(address); } interface IPools{ function addPool(address _lptoken, address _gauge, uint256 _stashVersion) external returns(bool); function forceAddPool(address _lptoken, address _gauge, uint256 _stashVersion) external returns(bool); function shutdownPool(uint256 _pid) external returns(bool); function poolInfo(uint256) external view returns(address,address,address,address,address,bool); function poolLength() external view returns (uint256); function gaugeMap(address) external view returns(bool); function setPoolManager(address _poolM) external; function shutdownSystem() external; function setUsedAddress(address[] memory) external; } interface IVestedEscrow{ function fund(address[] calldata _recipient, uint256[] calldata _amount) external returns(bool); } interface IRewardDeposit { function addReward(address, uint256) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import { IERC20 } from "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import { IERC20Metadata } from "./IERC20Metadata.sol"; /// @title ERC4626 interface /// See: https://eips.ethereum.org/EIPS/eip-4626 abstract contract IERC4626 is IERC20Metadata { /*//////////////////////////////////////////////////////// Events ////////////////////////////////////////////////////////*/ /// @notice `caller` has exchanged `assets` for `shares`, and transferred those `shares` to `owner` event Deposit( address indexed caller, address indexed owner, uint256 assets, uint256 shares ); /// @notice `caller` has exchanged `shares`, owned by `owner`, for /// `assets`, and transferred those `assets` to `receiver`. event Withdraw( address indexed caller, address indexed receiver, address indexed owner, uint256 assets, uint256 shares ); /*//////////////////////////////////////////////////////// Vault properties ////////////////////////////////////////////////////////*/ /// @notice The address of the underlying ERC20 token used for /// the Vault for accounting, depositing, and withdrawing. function asset() external view virtual returns(address); /// @notice Total amount of the underlying asset that /// is "managed" by Vault. function totalAssets() external view virtual returns(uint256); /*//////////////////////////////////////////////////////// Deposit/Withdrawal Logic ////////////////////////////////////////////////////////*/ /// @notice Mints `shares` Vault shares to `receiver` by /// depositing exactly `assets` of underlying tokens. function deposit(uint256 assets, address receiver) external virtual returns(uint256 shares); /// @notice Mints exactly `shares` Vault shares to `receiver` /// by depositing `assets` of underlying tokens. function mint(uint256 shares, address receiver) external virtual returns(uint256 assets); /// @notice Redeems `shares` from `owner` and sends `assets` /// of underlying tokens to `receiver`. function withdraw(uint256 assets, address receiver, address owner) external virtual returns(uint256 shares); /// @notice Redeems `shares` from `owner` and sends `assets` /// of underlying tokens to `receiver`. function redeem(uint256 shares, address receiver, address owner) external virtual returns(uint256 assets); /*//////////////////////////////////////////////////////// Vault Accounting Logic ////////////////////////////////////////////////////////*/ /// @notice The amount of shares that the vault would /// exchange for the amount of assets provided, in an /// ideal scenario where all the conditions are met. function convertToShares(uint256 assets) external view virtual returns(uint256 shares); /// @notice The amount of assets that the vault would /// exchange for the amount of shares provided, in an /// ideal scenario where all the conditions are met. function convertToAssets(uint256 shares) external view virtual returns(uint256 assets); /// @notice Total number of underlying assets that can /// be deposited by `owner` into the Vault, where `owner` /// corresponds to the input parameter `receiver` of a /// `deposit` call. function maxDeposit(address owner) external view virtual returns(uint256 maxAssets); /// @notice Allows an on-chain or off-chain user to simulate /// the effects of their deposit at the current block, given /// current on-chain conditions. function previewDeposit(uint256 assets) external view virtual returns(uint256 shares); /// @notice Total number of underlying shares that can be minted /// for `owner`, where `owner` corresponds to the input /// parameter `receiver` of a `mint` call. function maxMint(address owner) external view virtual returns(uint256 maxShares); /// @notice Allows an on-chain or off-chain user to simulate /// the effects of their mint at the current block, given /// current on-chain conditions. function previewMint(uint256 shares) external view virtual returns(uint256 assets); /// @notice Total number of underlying assets that can be /// withdrawn from the Vault by `owner`, where `owner` /// corresponds to the input parameter of a `withdraw` call. function maxWithdraw(address owner) external view virtual returns(uint256 maxAssets); /// @notice Allows an on-chain or off-chain user to simulate /// the effects of their withdrawal at the current block, /// given current on-chain conditions. function previewWithdraw(uint256 assets) external view virtual returns(uint256 shares); /// @notice Total number of underlying shares that can be /// redeemed from the Vault by `owner`, where `owner` corresponds /// to the input parameter of a `redeem` call. function maxRedeem(address owner) external view virtual returns(uint256 maxShares); /// @notice Allows an on-chain or off-chain user to simulate /// the effects of their redeemption at the current block, /// given current on-chain conditions. function previewRedeem(uint256 shares) external view virtual returns(uint256 assets); }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; interface IGaugeController { function get_gauge_weight(address _gauge) external view returns(uint256); function vote_user_slopes(address,address) external view returns(uint256,uint256,uint256);//slope,power,end function vote_for_gauge_weights(address,uint256) external; function add_gauge(address,int128,uint256) external; function gauges(uint256) external view returns(address); function checkpoint_gauge(address) external; function n_gauges() external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; interface IProxyFactory { function clone(address _target) external returns(address); }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol"; interface IRewarder { using SafeERC20 for IERC20; function onReward(uint256 pid, address user, address recipient, uint256 sushiAmount, uint256 newLpAmount) external; function pendingTokens(uint256 pid, address user, uint256 sushiAmount) external view returns (IERC20[] memory, uint256[] memory); }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; interface IRewardHook { function onRewardClaim() external; }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @dev Standard math utilities missing in the Solidity language. */ library MathUtil { /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./Interfaces.sol"; import "@openzeppelin/contracts-0.6/math/SafeMath.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol"; /** * @title PoolManagerLite * @author ConvexFinance * @notice Pool Manager Lite * @dev Add pools to the Booster contract */ contract PoolManagerLite { using SafeMath for uint256; address public immutable booster; address public operator; bool public isShutdown; constructor(address _booster) public { booster = _booster; operator = msg.sender; } function setOperator(address _operator) external { require(msg.sender == operator, "!auth"); operator = _operator; } function addPool(address _gauge) external returns (bool) { return _addPool(_gauge, 3); } function addPool(address _gauge, uint256 _stashVersion) external returns (bool) { return _addPool(_gauge, _stashVersion); } function _addPool(address _gauge, uint256 _stashVersion) internal returns (bool) { require(msg.sender == operator, "!auth"); require(!IPools(booster).gaugeMap(_gauge), "already registered gauge"); require(!isShutdown, "shutdown"); address lptoken = ICurveGauge(_gauge).lp_token(); require(!IPools(booster).gaugeMap(lptoken), "already registered lptoken"); return IPools(booster).addPool(lptoken, _gauge, _stashVersion); } function shutdownPool(uint256 _pid) external returns (bool) { require(msg.sender == operator, "!auth"); // get pool info (address lptoken, address depositToken, , , , bool isshutdown) = IPools(booster).poolInfo(_pid); require(!isshutdown, "already shutdown"); // shutdown pool and get before and after amounts uint256 beforeBalance = IERC20(lptoken).balanceOf(booster); IPools(booster).shutdownPool(_pid); uint256 afterBalance = IERC20(lptoken).balanceOf(booster); // check that proper amount of tokens were withdrawn(will also fail if already shutdown) require(afterBalance.sub(beforeBalance) >= IERC20(depositToken).totalSupply(), "supply mismatch"); return true; } //shutdown pool management and disallow new pools. change is immutable function shutdownSystem() external { require(msg.sender == operator, "!auth"); isShutdown = true; } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./Interfaces.sol"; /** * @title PoolManagerProxy * @author ConvexFinance * @notice Immutable pool manager proxy to enforce that there are no multiple pools of the same gauge * as well as new lp tokens are not gauge tokens * @dev Called by PoolManagerShutdownProxy */ contract PoolManagerProxy{ address public immutable pools; address public owner; address public operator; /** * @param _pools Contract can call addPool currently Booster * @param _owner Contract owner currently multisig */ constructor( address _pools, address _owner ) public { pools = _pools; owner = _owner; operator = msg.sender; } modifier onlyOwner() { require(owner == msg.sender, "!owner"); _; } modifier onlyOperator() { require(operator == msg.sender, "!op"); _; } //set owner - only OWNER function setOwner(address _owner) external onlyOwner{ owner = _owner; } //set operator - only OWNER function setOperator(address _operator) external onlyOwner{ operator = _operator; } // sealed to be immutable // function revertControl() external{ // } //shutdown a pool - only OPERATOR function shutdownPool(uint256 _pid) external onlyOperator returns(bool){ return IPools(pools).shutdownPool(_pid); } /** * @notice Add pool to system * @dev Only callable by the operator looks up the gauge from the gaugeMap in Booster to ensure * it hasn't already been added */ function addPool(address _lptoken, address _gauge, uint256 _stashVersion) external onlyOperator returns(bool){ require(_gauge != address(0),"gauge is 0"); require(_lptoken != address(0),"lp token is 0"); //check if a pool with this gauge already exists bool gaugeExists = IPools(pools).gaugeMap(_gauge); require(!gaugeExists, "already registered gauge"); //must also check that the lp token is not a registered gauge //because curve gauges are tokenized gaugeExists = IPools(pools).gaugeMap(_lptoken); require(!gaugeExists, "already registered lptoken"); return IPools(pools).addPool(_lptoken,_gauge,_stashVersion); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./Interfaces.sol"; import "./interfaces/IGaugeController.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts-0.6/math/SafeMath.sol"; /** * @title PoolManagerSecondaryProxy * @author ConvexFinance * @notice Basically a PoolManager that has a better shutdown and calls addPool on PoolManagerProxy. * Immutable pool manager proxy to enforce that when a pool is shutdown, the proper number * of lp tokens are returned to the booster contract for withdrawal. */ contract PoolManagerSecondaryProxy{ using SafeMath for uint256; address public immutable gaugeController; address public immutable pools; address public immutable booster; address public owner; address public operator; bool public isShutdown; mapping(address => bool) public usedMap; /** * @param _gaugeController Curve Gauge controller (0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB) * @param _pools PoolManagerProxy (0x5F47010F230cE1568BeA53a06eBAF528D05c5c1B) * @param _booster Booster * @param _owner Executoor */ constructor( address _gaugeController, address _pools, address _booster, address _owner ) public { gaugeController = _gaugeController; pools = _pools; booster = _booster; owner = _owner; operator = msg.sender; } modifier onlyOwner() { require(owner == msg.sender, "!owner"); _; } modifier onlyOperator() { require(operator == msg.sender, "!op"); _; } //set owner - only OWNER function setOwner(address _owner) external onlyOwner{ owner = _owner; } //set operator - only OWNER function setOperator(address _operator) external onlyOwner{ operator = _operator; } //manual set an address to used state function setUsedAddress(address[] memory usedList) external onlyOwner{ for(uint i=0; i < usedList.length; i++){ usedMap[usedList[i]] = true; } } //shutdown pool management and disallow new pools. change is immutable function shutdownSystem() external onlyOwner{ isShutdown = true; } /** * @notice Shutdown a pool - only OPERATOR * @dev Shutdowns a pool and ensures all the LP tokens are properly * withdrawn to the Booster contract */ function shutdownPool(uint256 _pid) external onlyOperator returns(bool){ //get pool info (address lptoken, address depositToken,,,,bool isshutdown) = IPools(booster).poolInfo(_pid); require(!isshutdown, "already shutdown"); //shutdown pool and get before and after amounts uint256 beforeBalance = IERC20(lptoken).balanceOf(booster); IPools(pools).shutdownPool(_pid); uint256 afterBalance = IERC20(lptoken).balanceOf(booster); //check that proper amount of tokens were withdrawn(will also fail if already shutdown) require( afterBalance.sub(beforeBalance) >= IERC20(depositToken).totalSupply(), "supply mismatch"); return true; } //add a new pool if it has weight on the gauge controller - only OPERATOR function addPool(address _lptoken, address _gauge, uint256 _stashVersion) external onlyOperator returns(bool){ //check that the pool as weight uint256 weight = IGaugeController(gaugeController).get_gauge_weight(_gauge); require(weight > 0, "must have weight"); return _addPool(_lptoken, _gauge, _stashVersion); } //force add a new pool, but only for addresses that have never been used before - only OPERATOR function forceAddPool(address _lptoken, address _gauge, uint256 _stashVersion) external onlyOperator returns(bool){ require(!usedMap[_lptoken] && !usedMap[_gauge], "cant force used pool"); return _addPool(_lptoken, _gauge, _stashVersion); } //internal add pool and updated used list function _addPool(address _lptoken, address _gauge, uint256 _stashVersion) internal returns(bool){ require(!isShutdown, "shutdown"); usedMap[_lptoken] = true; usedMap[_gauge] = true; return IPools(pools).addPool(_lptoken,_gauge,_stashVersion); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./Interfaces.sol"; import "./interfaces/IGaugeController.sol"; /** * @title PoolManagerV3 * @author ConvexFinance * @notice Pool Manager v3 * PoolManagerV3 calls addPool on PoolManagerShutdownProxy which calls * addPool on PoolManagerProxy which calls addPool on Booster. * PoolManager-ception * @dev Add pools to the Booster contract */ contract PoolManagerV3{ address public immutable pools; address public immutable gaugeController; address public operator; bool public protectAddPool; /** * @param _pools Currently PoolManagerSecondaryProxy * @param _gaugeController Curve gauge controller e.g: (0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB) * @param _operator Convex multisig */ constructor( address _pools, address _gaugeController, address _operator ) public { pools = _pools; gaugeController = _gaugeController; operator = _operator; protectAddPool = true; } function setOperator(address _operator) external { require(msg.sender == operator, "!auth"); operator = _operator; } /** * @notice set if addPool is only callable by operator */ function setProtectPool(bool _protectAddPool) external { require(msg.sender == operator, "!auth"); protectAddPool = _protectAddPool; } /** * @notice Add a new curve pool to the system. (default stash to v3) */ function addPool(address _gauge) external returns(bool){ _addPool(_gauge,3); return true; } /** * @notice Add a new curve pool to the system */ function addPool(address _gauge, uint256 _stashVersion) external returns(bool){ _addPool(_gauge,_stashVersion); return true; } function _addPool(address _gauge, uint256 _stashVersion) internal{ if(protectAddPool) { require(msg.sender == operator, "!auth"); } //get lp token from gauge address lptoken = ICurveGauge(_gauge).lp_token(); //gauge/lptoken address checks will happen in the next call IPools(pools).addPool(lptoken,_gauge,_stashVersion); } function forceAddPool(address _lptoken, address _gauge, uint256 _stashVersion) external returns(bool){ require(msg.sender==operator, "!auth"); //force add pool without weight checks (can only be used on new token and gauge addresses) return IPools(pools).forceAddPool(_lptoken, _gauge, _stashVersion); } function shutdownPool(uint256 _pid) external returns(bool){ require(msg.sender==operator, "!auth"); IPools(pools).shutdownPool(_pid); return true; } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./Interfaces.sol"; /** * @title PoolManagerV4 * @author ConvexFinance -> AuraFinance * @notice Pool Manager v4 * - Changes: remove forceAddPool */ contract PoolManagerV4{ address public immutable pools; address public operator; bool public protectAddPool; /** * @param _pools Currently PoolManagerSecondaryProxy * @param _operator Convex multisig */ constructor( address _pools, address _operator ) public { pools = _pools; operator = _operator; protectAddPool = true; } function setOperator(address _operator) external { require(msg.sender == operator, "!auth"); operator = _operator; } /** * @notice set if addPool is only callable by operator */ function setProtectPool(bool _protectAddPool) external { require(msg.sender == operator, "!auth"); protectAddPool = _protectAddPool; } /** * @notice Add a new curve pool to the system. (default stash to v3) */ function addPool(address _gauge) external returns(bool){ _addPool(_gauge,3); return true; } function _addPool(address _gauge, uint256 _stashVersion) internal{ if(protectAddPool) { require(msg.sender == operator, "!auth"); } //get lp token from gauge address lptoken = ICurveGauge(_gauge).lp_token(); //gauge/lptoken address checks will happen in the next call IPools(pools).addPool(lptoken,_gauge,_stashVersion); } function shutdownPool(uint256 _pid) external returns(bool){ require(msg.sender==operator, "!auth"); IPools(pools).shutdownPool(_pid); return true; } //shutdown pool management and disallow new pools. change is immutable function shutdownSystem() external { require(msg.sender == operator, "!auth"); IPools(pools).shutdownSystem(); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./Interfaces.sol"; import "./BaseRewardPool4626.sol"; import "./VirtualBalanceRewardPool.sol"; import "@openzeppelin/contracts-0.6/math/SafeMath.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts-0.6/utils/Address.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol"; /** * @title RewardFactory * @author ConvexFinance * @notice Used to deploy reward pools when a new pool is added to the Booster * contract. This contract deploys two types of reward pools: * - BaseRewardPool handles CRV rewards for guages * - VirtualBalanceRewardPool for extra rewards */ contract RewardFactory { using Address for address; address public immutable operator; address public immutable crv; mapping (address => bool) private rewardAccess; mapping(address => uint256[]) public rewardActiveList; event RewardPoolCreated(address rewardPool, uint256 _pid, address depositToken); event TokenRewardPoolCreated(address rewardPool, address token, address mainRewards, address operator); event AccessChanged(address stash, bool hasAccess); /** * @param _operator Contract operator is Booster * @param _crv CRV token address */ constructor(address _operator, address _crv) public { operator = _operator; crv = _crv; } //stash contracts need access to create new Virtual balance pools for extra gauge incentives(ex. snx) function setAccess(address _stash, bool _status) external{ require(msg.sender == operator, "!auth"); rewardAccess[_stash] = _status; emit AccessChanged(_stash, _status); } /** * @notice Create a Managed Reward Pool to handle distribution of all crv mined in a pool */ function CreateCrvRewards(uint256 _pid, address _depositToken, address _lptoken) external returns (address) { require(msg.sender == operator, "!auth"); //operator = booster(deposit) contract so that new crv can be added and distributed //reward manager = this factory so that extra incentive tokens(ex. snx) can be linked to the main managed reward pool BaseRewardPool4626 rewardPool = new BaseRewardPool4626(_pid,_depositToken,crv,operator, address(this), _lptoken); emit RewardPoolCreated(address(rewardPool), _pid, _depositToken); return address(rewardPool); } /** * @notice Create a virtual balance reward pool that mimics the balance of a pool's main reward contract * used for extra incentive tokens(ex. snx) as well as vecrv fees */ function CreateTokenRewards(address _token, address _mainRewards, address _operator) external returns (address) { require(msg.sender == operator || rewardAccess[msg.sender] == true, "!auth"); //create new pool, use main pool for balance lookup VirtualBalanceRewardPool rewardPool = new VirtualBalanceRewardPool(_mainRewards,_token,_operator); address rAddress = address(rewardPool); //add the new pool to main pool's list of extra rewards, assuming this factory has "reward manager" role IRewards(_mainRewards).addExtraReward(rAddress); emit TokenRewardPoolCreated(rAddress, _token, _mainRewards, _operator); //return new pool's address return rAddress; } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "@openzeppelin/contracts-0.6/utils/Address.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts-0.6/math/SafeMath.sol"; /** * @title RewardHook * @author ConvexFinance * @notice Example Reward hook for stash * @dev ExtraRewardStash contracts call this hook if it is set. This hook * can be used to pull rewards during a claim. For example pulling * rewards from master chef. */ contract RewardHook{ using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; address public immutable stash; address public immutable rewardToken; /** * @param _stash Address of the reward stash * @param _reward Reward token */ constructor(address _stash, address _reward) public { stash = _stash; rewardToken = _reward; } /** * @dev Called when claimRewards is called in ExtraRewardStash can implement * logic to pull rewards i.e from a master chef contract. This is just an example * and assumes rewards are just sent directly to this hook contract */ function onRewardClaim() external{ //get balance uint256 bal = IERC20(rewardToken).balanceOf(address(this)); //send IERC20(rewardToken).safeTransfer(stash,bal); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./Interfaces.sol"; import "./interfaces/IProxyFactory.sol"; import "@openzeppelin/contracts-0.6/math/SafeMath.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts-0.6/utils/Address.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol"; /** * @title StashFactoryV2 * @author ConvexFinance * @notice Factory to deploy reward stash contracts that handle extra rewards */ contract StashFactoryV2 { using Address for address; bytes4 private constant rewarded_token = 0x16fa50b1; //rewarded_token() bytes4 private constant reward_tokens = 0x54c49fe9; //reward_tokens(uint256) bytes4 private constant rewards_receiver = 0x01ddabf1; //rewards_receiver(address) address public immutable operator; address public immutable rewardFactory; address public immutable proxyFactory; address public v1Implementation; address public v2Implementation; address public v3Implementation; event StashCreated(address stash, uint256 stashVersion); /** * @param _operator Operator is Booster * @param _rewardFactory Factory that creates reward contract that are * VirtualBalanceRewardPool's used for extra pool rewards * @param _proxyFactory Deploy proxies with stash implementation */ constructor(address _operator, address _rewardFactory, address _proxyFactory) public { operator = _operator; rewardFactory = _rewardFactory; proxyFactory = _proxyFactory; } function setImplementation(address _v1, address _v2, address _v3) external{ require(msg.sender == IDeposit(operator).owner(),"!auth"); v1Implementation = _v1; v2Implementation = _v2; v3Implementation = _v3; } //Create a stash contract for the given gauge. //function calls are different depending on the version of curve gauges so determine which stash type is needed function CreateStash(uint256 _pid, address _gauge, address _staker, uint256 _stashVersion) external returns(address){ require(msg.sender == operator, "!authorized"); require(_gauge != address(0), "!gauge"); if(_stashVersion == uint256(3) && IsV3(_gauge)){ //v3 require(v3Implementation!=address(0),"0 impl"); address stash = IProxyFactory(proxyFactory).clone(v3Implementation); IStash(stash).initialize(_pid,operator,_staker,_gauge,rewardFactory); emit StashCreated(stash, _stashVersion); return stash; }else if(_stashVersion == uint256(1) && IsV1(_gauge)){ //v1 require(v1Implementation!=address(0),"0 impl"); address stash = IProxyFactory(proxyFactory).clone(v1Implementation); IStash(stash).initialize(_pid,operator,_staker,_gauge,rewardFactory); emit StashCreated(stash, _stashVersion); return stash; }else if(_stashVersion == uint256(2) && !IsV3(_gauge) && IsV2(_gauge)){ //v2 require(v2Implementation!=address(0),"0 impl"); address stash = IProxyFactory(proxyFactory).clone(v2Implementation); IStash(stash).initialize(_pid,operator,_staker,_gauge,rewardFactory); emit StashCreated(stash, _stashVersion); return stash; } bool isV1 = IsV1(_gauge); bool isV2 = IsV2(_gauge); bool isV3 = IsV3(_gauge); require(!isV1 && !isV2 && !isV3,"stash version mismatch"); return address(0); } function IsV1(address _gauge) private returns(bool){ bytes memory data = abi.encode(rewarded_token); (bool success,) = _gauge.call(data); return success; } function IsV2(address _gauge) private returns(bool){ bytes memory data = abi.encodeWithSelector(reward_tokens,uint256(0)); (bool success,) = _gauge.call(data); return success; } function IsV3(address _gauge) private returns(bool){ bytes memory data = abi.encodeWithSelector(rewards_receiver,address(0)); (bool success,) = _gauge.call(data); return success; } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./Interfaces.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol"; import "@openzeppelin/contracts-0.6/math/SafeMath.sol"; import "@openzeppelin/contracts-upgradeable-0.6/utils/ReentrancyGuardUpgradeable.sol"; interface IERC20Metadata { function name() external view returns (string memory); function symbol() external view returns (string memory); } contract StashToken is ReentrancyGuardUpgradeable { using SafeERC20 for IERC20; using SafeMath for uint256; uint256 public constant MAX_TOTAL_SUPPLY = 1e38; address public immutable stash; address public operator; address public rewardPool; address public baseToken; bool public isValid; bool public isImplementation; uint256 internal _totalSupply; constructor(address _stash) public { stash = _stash; isImplementation = true; } function init( address _operator, address _rewardPool, address _baseToken ) external initializer { require(!isImplementation, "isImplementation"); __ReentrancyGuard_init(); operator = _operator; rewardPool = _rewardPool; baseToken = _baseToken; isValid = true; } function name() external view returns (string memory) { return string(abi.encodePacked("Stash Token ", IERC20Metadata(baseToken).name())); } function symbol() external view returns (string memory) { return string(abi.encodePacked("STASH-", IERC20Metadata(baseToken).symbol())); } function setIsValid(bool _isValid) external { require(msg.sender == IDeposit(operator).owner(), "!owner"); isValid = _isValid; } function totalSupply() public view returns (uint256) { return _totalSupply; } function mint(uint256 _amount) external nonReentrant { require(msg.sender == stash, "!stash"); require(_totalSupply.add(_amount) < MAX_TOTAL_SUPPLY, "totalSupply exceeded"); _totalSupply = _totalSupply.add(_amount); IERC20(baseToken).safeTransferFrom(msg.sender, address(this), _amount); } function transfer(address _to, uint256 _amount) public nonReentrant returns (bool) { require(msg.sender == rewardPool, "!rewardPool"); require(_totalSupply >= _amount, "amount>totalSupply"); _totalSupply = _totalSupply.sub(_amount); IERC20(baseToken).safeTransfer(_to, _amount); return true; } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./Interfaces.sol"; import "./DepositToken.sol"; import "@openzeppelin/contracts-0.6/math/SafeMath.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts-0.6/utils/Address.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol"; /** * @title TokenFactory * @author ConvexFinance * @notice Token factory used to create Deposit Tokens. These are the tokenized * pool deposit tokens e.g cvx3crv */ contract TokenFactory { using Address for address; address public immutable operator; string public namePostfix; string public symbolPrefix; event DepositTokenCreated(address token, address lpToken); /** * @param _operator Operator is Booster * @param _namePostfix Postfixes lpToken name * @param _symbolPrefix Prefixed lpToken symbol */ constructor( address _operator, string memory _namePostfix, string memory _symbolPrefix ) public { operator = _operator; namePostfix = _namePostfix; symbolPrefix = _symbolPrefix; } function CreateDepositToken(address _lptoken) external returns(address){ require(msg.sender == operator, "!authorized"); DepositToken dtoken = new DepositToken(operator,_lptoken,namePostfix,symbolPrefix); emit DepositTokenCreated(address(dtoken), _lptoken); return address(dtoken); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** *Submitted for verification at Etherscan.io on 2020-07-17 */ /* ____ __ __ __ _ / __/__ __ ___ / /_ / / ___ / /_ (_)__ __ _\ \ / // // _ \/ __// _ \/ -_)/ __// / \ \ / /___/ \_, //_//_/\__//_//_/\__/ \__//_/ /_\_\ /___/ * Synthetix: VirtualBalanceRewardPool.sol * * Docs: https://docs.synthetix.io/ * * * MIT License * =========== * * Copyright (c) 2020 Synthetix * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */ import "./Interfaces.sol"; import "./interfaces/MathUtil.sol"; import "@openzeppelin/contracts-0.6/math/SafeMath.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts-0.6/utils/Address.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol"; abstract contract VirtualBalanceWrapper { using SafeMath for uint256; using SafeERC20 for IERC20; IDeposit public immutable deposits; constructor(address deposit_) internal { deposits = IDeposit(deposit_); } function totalSupply() public view returns (uint256) { return deposits.totalSupply(); } function balanceOf(address account) public view returns (uint256) { return deposits.balanceOf(account); } } /** * @title VirtualBalanceRewardPool * @author ConvexFinance * @notice Reward pool used for ExtraRewards in Booster lockFees (3crv) and * Extra reward stashes * @dev The rewards are sent to this contract for distribution to stakers. This * contract does not hold any of the staking tokens it just maintains a virtual * balance of what a user has staked in the staking pool (BaseRewardPool). * For example the Booster sends veCRV fees (3Crv) to a VirtualBalanceRewardPool * which tracks the virtual balance of cxvCRV stakers and distributes their share * of 3Crv rewards */ contract VirtualBalanceRewardPool is VirtualBalanceWrapper { using SafeERC20 for IERC20; IERC20 public immutable rewardToken; uint256 public constant duration = 7 days; address public immutable operator; uint256 public periodFinish = 0; uint256 public rewardRate = 0; uint256 public lastUpdateTime; uint256 public rewardPerTokenStored; uint256 public queuedRewards = 0; uint256 public currentRewards = 0; uint256 public historicalRewards = 0; uint256 public constant newRewardRatio = 830; mapping(address => uint256) public userRewardPerTokenPaid; mapping(address => uint256) public rewards; mapping(uint256 => uint256) public epochRewards; event RewardAdded(uint256 reward); event Staked(address indexed user, uint256 amount); event Withdrawn(address indexed user, uint256 amount); event RewardPaid(address indexed user, uint256 reward); /** * @param deposit_ Parent deposit pool e.g cvxCRV staking in BaseRewardPool * @param reward_ The rewards token e.g 3Crv * @param op_ Operator contract (Booster) */ constructor( address deposit_, address reward_, address op_ ) public VirtualBalanceWrapper(deposit_) { rewardToken = IERC20(reward_); operator = op_; } /** * @notice Update rewards earned by this account */ modifier updateReward(address account) { rewardPerTokenStored = rewardPerToken(); lastUpdateTime = lastTimeRewardApplicable(); if (account != address(0)) { rewards[account] = earned(account); userRewardPerTokenPaid[account] = rewardPerTokenStored; } _; } function lastTimeRewardApplicable() public view returns (uint256) { return MathUtil.min(block.timestamp, periodFinish); } function rewardPerToken() public view returns (uint256) { if (totalSupply() == 0) { return rewardPerTokenStored; } return rewardPerTokenStored.add( lastTimeRewardApplicable() .sub(lastUpdateTime) .mul(rewardRate) .mul(1e18) .div(totalSupply()) ); } function earned(address account) public view returns (uint256) { return balanceOf(account) .mul(rewardPerToken().sub(userRewardPerTokenPaid[account])) .div(1e18) .add(rewards[account]); } /** * @notice Update reward, emit, call linked reward's stake * @dev Callable by the deposits address which is the BaseRewardPool * this updates the virtual balance of this user as this contract doesn't * actually hold any staked tokens it just diributes reward tokens */ function stake(address _account, uint256 amount) external updateReward(_account) { require(msg.sender == address(deposits), "!authorized"); // require(amount > 0, 'VirtualDepositRewardPool: Cannot stake 0'); emit Staked(_account, amount); } /** * @notice Withdraw stake and update reward, emit, call linked reward's stake * @dev See stake */ function withdraw(address _account, uint256 amount) public updateReward(_account) { require(msg.sender == address(deposits), "!authorized"); //require(amount > 0, 'VirtualDepositRewardPool : Cannot withdraw 0'); emit Withdrawn(_account, amount); } /** * @notice Get rewards for this account * @dev This can be called directly but it is usually called by the * BaseRewardPool getReward when the BaseRewardPool loops through * it's extraRewards array calling getReward on all of them */ function getReward(address _account) public updateReward(_account){ uint256 reward = earned(_account); if (reward > 0) { rewards[_account] = 0; rewardToken.safeTransfer(_account, reward); emit RewardPaid(_account, reward); } } function getReward() external{ getReward(msg.sender); } /** * @dev Processes queued rewards in isolation, providing the period has finished. * This allows a cheaper way to trigger rewards on low value pools. */ function processIdleRewards() external { if (block.timestamp >= periodFinish && queuedRewards > 0) { notifyRewardAmount(queuedRewards); queuedRewards = 0; } } function queueNewRewards(uint256 _rewards) external{ require(msg.sender == operator, "!authorized"); uint256 epoch = block.timestamp.div(duration); epochRewards[epoch] = epochRewards[epoch].add(_rewards); if(epochRewards[epoch] > 1e31) { return; } _rewards = _rewards.add(queuedRewards); if (block.timestamp >= periodFinish) { notifyRewardAmount(_rewards); queuedRewards = 0; return; } //et = now - (finish-duration) uint256 elapsedTime = block.timestamp.sub(periodFinish.sub(duration)); //current at now: rewardRate * elapsedTime uint256 currentAtNow = rewardRate * elapsedTime; uint256 queuedRatio = currentAtNow.mul(1000).div(_rewards); if(queuedRatio < newRewardRatio){ notifyRewardAmount(_rewards); queuedRewards = 0; }else{ queuedRewards = _rewards; } } function notifyRewardAmount(uint256 reward) internal updateReward(address(0)) { historicalRewards = historicalRewards.add(reward); if (block.timestamp >= periodFinish) { rewardRate = reward.div(duration); } else { uint256 remaining = periodFinish.sub(block.timestamp); uint256 leftover = remaining.mul(rewardRate); reward = reward.add(leftover); rewardRate = reward.div(duration); } currentRewards = reward; lastUpdateTime = block.timestamp; periodFinish = block.timestamp.add(duration); emit RewardAdded(reward); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./VirtualBalanceRewardPool.sol"; /** * @title VirtualRewardFacotry * @author Aura Finance */ contract VirtualRewardFactory { function createVirtualReward(address _deposits, address _reward, address _operator) external returns(address) { return address(new VirtualBalanceRewardPool(_deposits, _reward, _operator)); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./Interfaces.sol"; import "@openzeppelin/contracts-0.6/math/SafeMath.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts-0.6/utils/Address.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol"; /** * @title VoterProxy * @author ConvexFinance * @notice VoterProxy whitelisted in the curve SmartWalletWhitelist that * participates in Curve governance. Also handles all deposits since this is * the address that has the voting power. */ contract VoterProxy { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; address public mintr; address public immutable crv; address public immutable crvBpt; address public immutable escrow; address public gaugeController; address public rewardDeposit; address public withdrawer; address public owner; address public operator; address public depositor; mapping (address => bool) private stashPool; mapping (address => bool) private protectedTokens; mapping (bytes32 => bool) private votes; bytes4 constant internal EIP1271_MAGIC_VALUE = 0x1626ba7e; event VoteSet(bytes32 hash, bool valid); /** * @param _mintr CRV minter * @param _crv CRV Token address * @param _crvBpt CRV:ETH 80-20 BPT Token address * @param _escrow Curve Voting escrow contract * @param _gaugeController Curve Gauge Controller * Controls liquidity gauges and the issuance of coins through the gauges */ constructor( address _mintr, address _crv, address _crvBpt, address _escrow, address _gaugeController ) public { mintr = _mintr; crv = _crv; crvBpt = _crvBpt; escrow = _escrow; gaugeController = _gaugeController; owner = msg.sender; protectedTokens[_crv] = true; protectedTokens[_crvBpt] = true; } function getName() external pure returns (string memory) { return "BalancerVoterProxy"; } function setOwner(address _owner) external { require(msg.sender == owner, "!auth"); owner = _owner; } /** * @notice Allows dao to set the reward withdrawal address * @param _withdrawer Whitelisted withdrawer * @param _rewardDeposit Distributor address */ function setRewardDeposit(address _withdrawer, address _rewardDeposit) external { require(msg.sender == owner, "!auth"); withdrawer = _withdrawer; rewardDeposit = _rewardDeposit; } /** * @notice Allows dao to set the external system config, should it change in the future * @param _gaugeController External gauge controller address * @param _mintr Token minter address for claiming rewards */ function setSystemConfig(address _gaugeController, address _mintr) external returns (bool) { require(msg.sender == owner, "!auth"); gaugeController = _gaugeController; mintr = _mintr; return true; } /** * @notice Set the operator of the VoterProxy * @param _operator Address of the operator (Booster) */ function setOperator(address _operator) external { require(msg.sender == owner, "!auth"); require(operator == address(0) || IDeposit(operator).isShutdown() == true, "needs shutdown"); operator = _operator; } /** * @notice Set the depositor of the VoterProxy * @param _depositor Address of the depositor (CrvDepositor) */ function setDepositor(address _depositor) external { require(msg.sender == owner, "!auth"); depositor = _depositor; } function setStashAccess(address _stash, bool _status) external returns(bool){ require(msg.sender == operator, "!auth"); if(_stash != address(0)){ stashPool[_stash] = _status; } return true; } /** * @notice Save a vote hash so when snapshot.org asks this contract if * a vote signature is valid we are able to check for a valid hash * and return the appropriate response inline with EIP 1721 * @param _hash Hash of vote signature that was sent to snapshot.org * @param _valid Is the hash valid */ function setVote(bytes32 _hash, bool _valid) external { require(msg.sender == operator, "!auth"); votes[_hash] = _valid; emit VoteSet(_hash, _valid); } /** * @notice Verifies that the hash is valid * @dev Snapshot Hub will call this function when a vote is submitted using * snapshot.js on behalf of this contract. Snapshot Hub will call this * function with the hash and the signature of the vote that was cast. * @param _hash Hash of the message that was sent to Snapshot Hub to cast a vote * @return EIP1271 magic value if the signature is value */ function isValidSignature(bytes32 _hash, bytes memory) public view returns (bytes4) { if(votes[_hash]) { return EIP1271_MAGIC_VALUE; } else { return 0xffffffff; } } /** * @notice Deposit tokens into the Curve Gauge * @dev Only can be called by the operator (Booster) once this contract has been * whitelisted by the Curve DAO * @param _token Deposit LP token address * @param _gauge Gauge contract to deposit to */ function deposit(address _token, address _gauge) external returns(bool){ require(msg.sender == operator, "!auth"); if(protectedTokens[_token] == false){ protectedTokens[_token] = true; } if(protectedTokens[_gauge] == false){ protectedTokens[_gauge] = true; } uint256 balance = IERC20(_token).balanceOf(address(this)); if (balance > 0) { IERC20(_token).safeApprove(_gauge, 0); IERC20(_token).safeApprove(_gauge, balance); ICurveGauge(_gauge).deposit(balance); } return true; } /** * @notice Withdraw ERC20 tokens that have been distributed as extra rewards * @dev Tokens shouldn't end up here if they can help it. However, dao can * set a withdrawer that can process these to some ExtraRewardDistribution. */ function withdraw(IERC20 _asset) external returns (uint256 balance) { require(msg.sender == withdrawer, "!auth"); require(protectedTokens[address(_asset)] == false, "protected"); balance = _asset.balanceOf(address(this)); _asset.safeApprove(rewardDeposit, 0); _asset.safeApprove(rewardDeposit, balance); IRewardDeposit(rewardDeposit).addReward(address(_asset), balance); return balance; } /** * @notice Withdraw LP tokens from a gauge * @dev Only callable by the operator * @param _token LP token address * @param _gauge Gauge for this LP token * @param _amount Amount of LP token to withdraw */ function withdraw(address _token, address _gauge, uint256 _amount) public returns(bool){ require(msg.sender == operator, "!auth"); uint256 _balance = IERC20(_token).balanceOf(address(this)); if (_balance < _amount) { _amount = _withdrawSome(_gauge, _amount.sub(_balance)); _amount = _amount.add(_balance); } IERC20(_token).safeTransfer(msg.sender, _amount); return true; } /** * @notice Withdraw all LP tokens from a gauge * @dev Only callable by the operator * @param _token LP token address * @param _gauge Gauge for this LP token */ function withdrawAll(address _token, address _gauge) external returns(bool){ require(msg.sender == operator, "!auth"); uint256 amount = balanceOfPool(_gauge).add(IERC20(_token).balanceOf(address(this))); withdraw(_token, _gauge, amount); return true; } function _withdrawSome(address _gauge, uint256 _amount) internal returns (uint256) { ICurveGauge(_gauge).withdraw(_amount); return _amount; } /** * @notice Lock CRV in Curve's voting escrow contract * @dev Called by the CrvDepositor contract * @param _value Amount of crv to lock * @param _unlockTime Timestamp to unlock (max is 4 years) */ function createLock(uint256 _value, uint256 _unlockTime) external returns(bool){ require(msg.sender == depositor, "!auth"); IERC20(crvBpt).safeApprove(escrow, 0); IERC20(crvBpt).safeApprove(escrow, _value); ICurveVoteEscrow(escrow).create_lock(_value, _unlockTime); return true; } /** * @notice Called by the CrvDepositor to increase amount of locked curve */ function increaseAmount(uint256 _value) external returns(bool){ require(msg.sender == depositor, "!auth"); IERC20(crvBpt).safeApprove(escrow, 0); IERC20(crvBpt).safeApprove(escrow, _value); ICurveVoteEscrow(escrow).increase_amount(_value); return true; } /** * @notice Called by the CrvDepositor to increase unlocked time of curve * @param _value Timestamp to increase locking to */ function increaseTime(uint256 _value) external returns(bool){ require(msg.sender == depositor, "!auth"); ICurveVoteEscrow(escrow).increase_unlock_time(_value); return true; } /** * @notice Withdraw all CRV from Curve's voting escrow contract * @dev Only callable by CrvDepositor and can only withdraw if lock has expired */ function release() external returns(bool){ require(msg.sender == depositor, "!auth"); ICurveVoteEscrow(escrow).withdraw(); return true; } /** * @notice Vote on CRV DAO for proposal */ function vote(uint256 _voteId, address _votingAddress, bool _support) external returns(bool){ require(msg.sender == operator, "!auth"); IVoting(_votingAddress).vote(_voteId,_support,false); return true; } /** * @notice Vote for a single gauge weight via the controller */ function voteGaugeWeight(address _gauge, uint256 _weight) external returns(bool){ require(msg.sender == operator, "!auth"); //vote IVoting(gaugeController).vote_for_gauge_weights(_gauge, _weight); return true; } /** * @notice Claim CRV from Curve * @dev Claim CRV for LP token staking from the CRV minter contract */ function claimCrv(address _gauge) external returns (uint256){ require(msg.sender == operator, "!auth"); uint256 _balance = 0; try IMinter(mintr).mint(_gauge){ _balance = IERC20(crv).balanceOf(address(this)); IERC20(crv).safeTransfer(operator, _balance); }catch{} return _balance; } /** * @notice Claim extra rewards from gauge * @dev Called by operator (Booster) to claim extra rewards */ function claimRewards(address _gauge) external returns(bool){ require(msg.sender == operator, "!auth"); ICurveGauge(_gauge).claim_rewards(); return true; } /** * @notice Claim fees (3crv) from staking lp tokens * @dev Only callable by the operator Booster * @param _distroContract Fee distribution contract * @param _token LP token to claim fees for */ function claimFees(address _distroContract, address _token) external returns (uint256){ require(msg.sender == operator, "!auth"); IFeeDistributor(_distroContract).claimToken(address(this), _token); uint256 _balance = IERC20(_token).balanceOf(address(this)); IERC20(_token).safeTransfer(operator, _balance); return _balance; } function balanceOfPool(address _gauge) public view returns (uint256) { return ICurveGauge(_gauge).balanceOf(address(this)); } function execute( address _to, uint256 _value, bytes calldata _data ) external returns (bool, bytes memory) { require(msg.sender == operator,"!auth"); (bool success, bytes memory result) = _to.call{value:_value}(_data); require(success, "!success"); return (success, result); } }
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "./Interfaces.sol"; import "@openzeppelin/contracts-0.6/math/SafeMath.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts-0.6/token/ERC20/SafeERC20.sol"; /** * @title VoterProxyLite * @author ConvexFinance -> AuraFinance * @dev A lite version of the original VoterProxy for use on sidechains */ contract VoterProxyLite { using SafeERC20 for IERC20; using SafeMath for uint256; address public mintr; address public crv; address public rewardDeposit; address public withdrawer; address public owner; address public operator; mapping(address => bool) private stashPool; mapping(address => bool) private protectedTokens; constructor() public { owner = msg.sender; } /** * @notice Initialize the contract. * @param _mintr CRV minter * @param _crv CRV Token address * @param _owner The owner */ function initialize(address _mintr, address _crv, address _owner) external { require(msg.sender == owner, "!auth"); require(crv == address(0), "Only once"); mintr = _mintr; crv = _crv; owner = _owner; protectedTokens[_crv] = true; } function getName() external pure returns (string memory) { return "BalancerVoterProxy"; } function setOwner(address _owner) external { require(msg.sender == owner, "!auth"); owner = _owner; } /** * @notice Allows dao to set the reward withdrawal address * @param _withdrawer Whitelisted withdrawer * @param _rewardDeposit Distributor address */ function setRewardDeposit(address _withdrawer, address _rewardDeposit) external { require(msg.sender == owner, "!auth"); withdrawer = _withdrawer; rewardDeposit = _rewardDeposit; } /** * @notice Allows dao to set the external system config, should it change in the future * @param _mintr Token minter address for claiming rewards */ function setSystemConfig(address _mintr) external returns (bool) { require(msg.sender == owner, "!auth"); mintr = _mintr; return true; } /** * @notice Set the operator of the VoterProxy * @param _operator Address of the operator (Booster) */ function setOperator(address _operator) external { require(msg.sender == owner, "!auth"); require(operator == address(0) || IDeposit(operator).isShutdown() == true, "needs shutdown"); operator = _operator; } function setStashAccess(address _stash, bool _status) external returns (bool) { require(msg.sender == operator, "!auth"); if (_stash != address(0)) { stashPool[_stash] = _status; } return true; } /** * @notice Deposit tokens into the Curve Gauge * @dev Only can be called by the operator (Booster) once this contract has been * whitelisted by the Curve DAO * @param _token Deposit LP token address * @param _gauge Gauge contract to deposit to */ function deposit(address _token, address _gauge) external returns (bool) { require(msg.sender == operator, "!auth"); if (protectedTokens[_token] == false) { protectedTokens[_token] = true; } if (protectedTokens[_gauge] == false) { protectedTokens[_gauge] = true; } uint256 balance = IERC20(_token).balanceOf(address(this)); if (balance > 0) { IERC20(_token).safeApprove(_gauge, 0); IERC20(_token).safeApprove(_gauge, balance); ICurveGauge(_gauge).deposit(balance); } return true; } /** * @notice Withdraw ERC20 tokens that have been distributed as extra rewards * @dev Tokens shouldn't end up here if they can help it. However, dao can * set a withdrawer that can process these to some ExtraRewardDistribution. */ function withdraw(IERC20 _asset) external returns (uint256 balance) { require(msg.sender == withdrawer, "!auth"); require(protectedTokens[address(_asset)] == false, "protected"); balance = _asset.balanceOf(address(this)); _asset.safeApprove(rewardDeposit, 0); _asset.safeApprove(rewardDeposit, balance); IRewardDeposit(rewardDeposit).addReward(address(_asset), balance); return balance; } /** * @notice Withdraw LP tokens from a gauge * @dev Only callable by the operator * @param _token LP token address * @param _gauge Gauge for this LP token * @param _amount Amount of LP token to withdraw */ function withdraw( address _token, address _gauge, uint256 _amount ) public returns (bool) { require(msg.sender == operator, "!auth"); uint256 _balance = IERC20(_token).balanceOf(address(this)); if (_balance < _amount) { _amount = _withdrawSome(_gauge, _amount.sub(_balance)); _amount = _amount.add(_balance); } IERC20(_token).safeTransfer(msg.sender, _amount); return true; } /** * @notice Withdraw all LP tokens from a gauge * @dev Only callable by the operator * @param _token LP token address * @param _gauge Gauge for this LP token */ function withdrawAll(address _token, address _gauge) external returns (bool) { require(msg.sender == operator, "!auth"); uint256 amount = balanceOfPool(_gauge).add(IERC20(_token).balanceOf(address(this))); withdraw(_token, _gauge, amount); return true; } function _withdrawSome(address _gauge, uint256 _amount) internal returns (uint256) { ICurveGauge(_gauge).withdraw(_amount); return _amount; } /** * @notice Claim CRV from Curve * @dev Claim CRV for LP token staking from the CRV minter contract */ function claimCrv(address _gauge) external returns (uint256) { require(msg.sender == operator, "!auth"); uint256 _balance = 0; try IMinter(mintr).mint(_gauge) { _balance = IERC20(crv).balanceOf(address(this)); IERC20(crv).safeTransfer(operator, _balance); } catch {} return _balance; } /** * @notice Claim extra rewards from gauge * @dev Called by operator (Booster) to claim extra rewards */ function claimRewards(address _gauge) external returns (bool) { require(msg.sender == operator, "!auth"); ICurveGauge(_gauge).claim_rewards(); return true; } function balanceOfPool(address _gauge) public view returns (uint256) { return ICurveGauge(_gauge).balanceOf(address(this)); } function execute( address _to, uint256 _value, bytes calldata _data ) external returns (bool, bytes memory) { require(msg.sender == operator, "!auth"); (bool success, bytes memory result) = _to.call{ value: _value }(_data); require(success, "!success"); return (success, result); } }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_staker","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"poolid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"rewardFactory","type":"address"},{"indexed":false,"internalType":"address","name":"stashFactory","type":"address"},{"indexed":false,"internalType":"address","name":"tokenFactory","type":"address"}],"name":"FactoriesUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newFeeManager","type":"address"}],"name":"FeeManagerUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"lockIncentive","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"stakerIncentive","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"earmarkIncentive","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"platformFee","type":"uint256"}],"name":"FeesUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"lpToken","type":"address"},{"indexed":false,"internalType":"address","name":"gauge","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"rewardPool","type":"address"},{"indexed":false,"internalType":"address","name":"stash","type":"address"},{"indexed":false,"internalType":"uint256","name":"pid","type":"uint256"}],"name":"PoolAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newPoolManager","type":"address"}],"name":"PoolManagerUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"poolId","type":"uint256"}],"name":"PoolShutdown","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"rewards","type":"address"}],"name":"RewardContractsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newTreasury","type":"address"}],"name":"TreasuryUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"poolid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"FEE_DENOMINATOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MaxFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_lptoken","type":"address"},{"internalType":"address","name":"_gauge","type":"address"},{"internalType":"uint256","name":"_stashVersion","type":"uint256"}],"name":"addPool","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"address","name":"_gauge","type":"address"}],"name":"claimRewards","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"crv","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bool","name":"_stake","type":"bool"}],"name":"deposit","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"bool","name":"_stake","type":"bool"}],"name":"depositAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"earmarkIncentive","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"address","name":"_zroPaymentAddress","type":"address"}],"name":"earmarkRewards","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"feeManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"gaugeMap","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_minter","type":"address"},{"internalType":"address","name":"_crv","type":"address"},{"internalType":"address","name":"_owner","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isShutdown","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lockIncentive","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minter","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":"platformFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"poolInfo","outputs":[{"internalType":"address","name":"lptoken","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"gauge","type":"address"},{"internalType":"address","name":"crvRewards","type":"address"},{"internalType":"address","name":"stash","type":"address"},{"internalType":"bool","name":"shutdown","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"address","name":"_address","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"rewardClaimed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardFactory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewards","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_rfactory","type":"address"},{"internalType":"address","name":"_sfactory","type":"address"},{"internalType":"address","name":"_tfactory","type":"address"}],"name":"setFactories","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feeM","type":"address"}],"name":"setFeeManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lockFees","type":"uint256"},{"internalType":"uint256","name":"_stakerFees","type":"uint256"},{"internalType":"uint256","name":"_callerFees","type":"uint256"},{"internalType":"uint256","name":"_platform","type":"uint256"}],"name":"setFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"}],"name":"setGaugeRedirect","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"setOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_poolM","type":"address"}],"name":"setPoolManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_rewards","type":"address"}],"name":"setRewardContracts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_treasury","type":"address"}],"name":"setTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"}],"name":"shutdownPool","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"shutdownSystem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"staker","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stakerIncentive","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stashFactory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenFactory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"}],"name":"withdrawAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"withdrawTo","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60a06040526103396002556103396003556032600455600060055534801561002657600080fd5b506040516138273803806138278339818101604052602081101561004957600080fd5b505160016000556001600160601b0319606082901b16608052600e805460ff60a01b19169055600680546001600160a01b031990811633908117909255600d8054909116905560408051918252517f4ffd725fc4a22075e9ec71c59edf9c38cdeb588a91b24fc5b61388c5be41282b9181900360200190a15060805160601c61371161011660003980610c155280610dd45280610e4c52806111f952806113b052806115395280611db9528061203d52806122a1528061286f5280612d0a5280612dc652506137116000f3fe6080604052600436106102465760003560e01c80636a4874a1116101395780639123d404116100b6578063cb0d5b521161007a578063cb0d5b521461081d578063d0fb020314610850578063d73792a914610865578063dc4c90d31461087a578063e77772fe1461088f578063f0f44260146108a457610246565b80639123d4041461075a578063958e2d31146107845780639ec5a894146107ae578063bf86d690146107c3578063c0c53b8b146107d857610246565b80637979426b116100fd5780637979426b1461065e5780637aef67151461068a5780637bd3b995146106bd5780637e29d6c2146107025780638da5cb5b1461074557610246565b80636a4874a1146105805780636c7b69cb146105955780636fcba377146105ce57806371192b171461060a5780637303df9a1461064957610246565b80633a088cd2116101c75780635ebaf1db1161018b5780635ebaf1db146104e557806360759fce146104fa57806360cafe841461052c57806361d027b31461055657806362d28ac71461056b57610246565b80633a088cd21461042057806343a0d06614610435578063441a3e701461046d578063472d35b91461049d57806350940618146104d057610246565b80631526fe271161020e5780631526fe27146103405780631cc51d40146103ae578063245e4bf0146103e157806326232a2e146103f6578063354af9191461040b57610246565b8063068eb19e1461024b578063075461721461027c578063081e3eda1461029157806313af4035146102b857806314cd70e4146102ed575b600080fd5b34801561025757600080fd5b506102606108d7565b604080516001600160a01b039092168252519081900360200190f35b34801561028857600080fd5b506102606108e6565b34801561029d57600080fd5b506102a66108f5565b60408051918252519081900360200190f35b3480156102c457600080fd5b506102eb600480360360208110156102db57600080fd5b50356001600160a01b03166108fb565b005b3480156102f957600080fd5b5061032c6004803603606081101561031057600080fd5b50803590602081013590604001356001600160a01b0316610996565b604080519115158252519081900360200190f35b34801561034c57600080fd5b5061036a6004803603602081101561036357600080fd5b5035610a1a565b604080516001600160a01b0397881681529587166020870152938616858501529185166060850152909316608083015291151560a082015290519081900360c00190f35b3480156103ba57600080fd5b506102eb600480360360208110156103d157600080fd5b50356001600160a01b0316610a78565b3480156103ed57600080fd5b50610260610b24565b34801561040257600080fd5b506102a6610b33565b34801561041757600080fd5b506102eb610b39565b34801561042c57600080fd5b506102a6610cb1565b34801561044157600080fd5b5061032c6004803603606081101561045857600080fd5b50803590602081013590604001351515610cb7565b34801561047957600080fd5b5061032c6004803603604081101561049057600080fd5b508035906020013561113e565b3480156104a957600080fd5b506102eb600480360360208110156104c057600080fd5b50356001600160a01b0316611156565b3480156104dc57600080fd5b506102a66111f1565b3480156104f157600080fd5b506102606111f7565b34801561050657600080fd5b5061032c6004803603604081101561051d57600080fd5b5080359060200135151561121b565b34801561053857600080fd5b5061032c6004803603602081101561054f57600080fd5b50356112c8565b34801561056257600080fd5b506102606114a8565b34801561057757600080fd5b506102a66114b7565b34801561058c57600080fd5b506102606114bd565b3480156105a157600080fd5b5061032c600480360360408110156105b857600080fd5b50803590602001356001600160a01b03166114cc565b3480156105da57600080fd5b506102eb600480360360808110156105f157600080fd5b50803590602081013590604081013590606001356115d0565b34801561061657600080fd5b5061032c6004803603606081101561062d57600080fd5b508035906001600160a01b03602082013516906040013561185c565b34801561065557600080fd5b506102a6611945565b61032c6004803603604081101561067457600080fd5b50803590602001356001600160a01b031661194b565b34801561069657600080fd5b506102eb600480360360208110156106ad57600080fd5b50356001600160a01b03166119f9565b3480156106c957600080fd5b506102eb600480360360608110156106e057600080fd5b506001600160a01b038135811691602081013582169160409091013516611a94565b34801561070e57600080fd5b5061032c6004803603606081101561072557600080fd5b506001600160a01b03813581169160208101359091169060400135611bc4565b34801561075157600080fd5b5061026061218c565b34801561076657600080fd5b5061032c6004803603602081101561077d57600080fd5b503561219b565b34801561079057600080fd5b5061032c600480360360208110156107a757600080fd5b5035612444565b3480156107ba57600080fd5b506102606124f3565b3480156107cf57600080fd5b5061032c612502565b3480156107e457600080fd5b506102eb600480360360608110156107fb57600080fd5b506001600160a01b038135811691602081013582169160409091013516612512565b34801561082957600080fd5b5061032c6004803603602081101561084057600080fd5b50356001600160a01b0316612691565b34801561085c57600080fd5b506102606126a6565b34801561087157600080fd5b506102a66126b5565b34801561088657600080fd5b506102606126bb565b34801561089b57600080fd5b506102606126ca565b3480156108b057600080fd5b506102eb600480360360208110156108c757600080fd5b50356001600160a01b03166126d9565b600b546001600160a01b031681565b6009546001600160a01b031681565b600f5490565b6006546001600160a01b03163314610942576040805162461bcd60e51b8152602060048201526005602482015264042c2eae8d60db1b604482015290519081900360640190fd5b600680546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f4ffd725fc4a22075e9ec71c59edf9c38cdeb588a91b24fc5b61388c5be41282b9181900360200190a150565b600080600f85815481106109a657fe5b60009182526020909120600360059092020101546001600160a01b03169050338114610a01576040805162461bcd60e51b8152602060048201526005602482015264042c2eae8d60db1b604482015290519081900360640190fd5b610a0d85853386612774565b60019150505b9392505050565b600f8181548110610a2757fe5b6000918252602090912060059091020180546001820154600283015460038401546004909401546001600160a01b03938416955091831693908316929081169190811690600160a01b900460ff1686565b6006546001600160a01b03163314610abf576040805162461bcd60e51b8152602060048201526005602482015264042c2eae8d60db1b604482015290519081900360640190fd5b600e546001600160a01b0316610b2157600e80546001600160a01b0383166001600160a01b0319909116811790915560408051918252517fdcf314452b77e67d7e1752b1e7b47ce7819785996d300352a78b81d1a7df53c39181900360200190a15b50565b600a546001600160a01b031681565b60055481565b6006546001600160a01b03163314610b80576040805162461bcd60e51b8152602060048201526005602482015264042c2eae8d60db1b604482015290519081900360640190fd5b600e805460ff60a01b1916600160a01b17905560005b600f54811015610b21576000600f8281548110610baf57fe5b906000526020600020906005020190508060040160149054906101000a900460ff1615610bdc5750610ca9565b80546002820154604080516301395c5960e31b81526001600160a01b0393841660048201819052928416602482018190529151929391927f0000000000000000000000000000000000000000000000000000000000000000909216916309cae2c8916044808201926020929091908290030181600087803b158015610c6057600080fd5b505af1925050508015610c8557506040513d6020811015610c8057600080fd5b505160015b610c8e57610ca5565b5060048301805460ff60a01b1916600160a01b1790555b5050505b600101610b96565b60045481565b600060026000541415610cff576040805162461bcd60e51b815260206004820152601f6024820152600080516020613615833981519152604482015290519081900360640190fd5b6002600055600e54600160a01b900460ff1615610d4e576040805162461bcd60e51b815260206004820152600860248201526739b43aba3237bbb760c11b604482015290519081900360640190fd5b6000600f8581548110610d5d57fe5b600091825260209091206005909102016004810154909150600160a01b900460ff1615610dc2576040805162461bcd60e51b815260206004820152600e60248201526d1c1bdbdb081a5cc818db1bdcd95960921b604482015290519081900360640190fd5b80546001600160a01b0316610df981337f000000000000000000000000000000000000000000000000000000000000000088612a32565b60028201546001600160a01b031680610e4a576040805162461bcd60e51b815260206004820152600e60248201526d2167617567652073657474696e6760901b604482015290519081900360640190fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663f9609f0883836040518363ffffffff1660e01b815260040180836001600160a01b03168152602001826001600160a01b0316815260200192505050602060405180830381600087803b158015610eca57600080fd5b505af1158015610ede573d6000803e3d6000fd5b505050506040513d6020811015610ef457600080fd5b505060048301546001600160a01b03168015610f7257806001600160a01b031663b87bd4816040518163ffffffff1660e01b8152600401602060405180830381600087803b158015610f4557600080fd5b505af1158015610f59573d6000803e3d6000fd5b505050506040513d6020811015610f6f57600080fd5b50505b60018401546001600160a01b0316861561108b57604080516340c10f1960e01b8152306004820152602481018a905290516001600160a01b038316916340c10f1991604480830192600092919082900301818387803b158015610fd457600080fd5b505af1158015610fe8573d6000803e3d6000fd5b50505060038601546001600160a01b03908116915061100b908316826000612a92565b61101f6001600160a01b038316828b612a92565b604080516305dc812160e31b8152336004820152602481018b905290516001600160a01b03831691632ee4090891604480830192600092919082900301818387803b15801561106d57600080fd5b505af1158015611081573d6000803e3d6000fd5b50505050506110f2565b604080516340c10f1960e01b8152336004820152602481018a905290516001600160a01b038316916340c10f1991604480830192600092919082900301818387803b1580156110d957600080fd5b505af11580156110ed573d6000803e3d6000fd5b505050505b6040805189815290518a9133917f73a19dd210f1a7f902193214c0ee91dd35ee5b4d920cba8d519eca65a7b488ca9181900360200190a360019550505050505060016000559392505050565b600061114c83833333612774565b5060015b92915050565b6006546001600160a01b0316331461119d576040805162461bcd60e51b8152602060048201526005602482015264042c2eae8d60db1b604482015290519081900360640190fd5b600780546001600160a01b0383166001600160a01b0319909116811790915560408051918252517fe45f5e140399b0a7e12971ab020724b828fbed8ac408c420884dc7d1bbe506b49181900360200190a150565b60025481565b7f000000000000000000000000000000000000000000000000000000000000000081565b600080600f848154811061122b57fe5b60009182526020808320600590920290910154604080516370a0823160e01b815233600482015290516001600160a01b03909216945084926370a0823192602480840193829003018186803b15801561128357600080fd5b505afa158015611297573d6000803e3d6000fd5b505050506040513d60208110156112ad57600080fd5b505190506112bc858286610cb7565b50600195945050505050565b600060026000541415611310576040805162461bcd60e51b815260206004820152601f6024820152600080516020613615833981519152604482015290519081900360640190fd5b60026000556008546001600160a01b0316331461135c576040805162461bcd60e51b8152602060048201526005602482015264042c2eae8d60db1b604482015290519081900360640190fd5b6000600f838154811061136b57fe5b60009182526020808320600590920290910180546002820154604080516301395c5960e31b81526001600160a01b0393841660048201529183166024830152519295507f000000000000000000000000000000000000000000000000000000000000000091909116936309cae2c89360448084019491939192918390030190829087803b1580156113fb57600080fd5b505af192505050801561142057506040513d602081101561141b57600080fd5b505160015b6114295761142b565b505b60048101805460ff60a01b1916600160a01b17905560028101546001600160a01b0316600090815260106020908152604091829020805460ff19169055815185815291517f2ccd633716c6ce12394d1c984ad04b6173d18aedc4f505d1537a94a98a07b6e79281900390910190a160019150506001600055919050565b600d546001600160a01b031681565b60035481565b6001546001600160a01b031681565b600080600f84815481106114dc57fe5b60009182526020909120600460059092020101546001600160a01b03169050338114611537576040805162461bcd60e51b8152602060048201526005602482015264042c2eae8d60db1b604482015290519081900360640190fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663ef5cfb8c846040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050602060405180830381600087803b1580156115a657600080fd5b505af11580156115ba573d6000803e3d6000fd5b505050506040513d60208110156112bc57600080fd5b60026000541415611616576040805162461bcd60e51b815260206004820152601f6024820152600080516020613615833981519152604482015290519081900360640190fd5b60026000556007546001600160a01b03163314611662576040805162461bcd60e51b8152602060048201526005602482015264042c2eae8d60db1b604482015290519081900360640190fd5b600061167a8261167485818989612ba5565b90612ba5565b9050610fa08111156116be576040805162461bcd60e51b81526020600482015260086024820152673e4d61784665657360c01b604482015290519081900360640190fd5b61012c85101580156116d25750610dac8511155b61170f576040805162461bcd60e51b8152602060048201526009602482015268216c6f636b4665657360b81b604482015290519081900360640190fd5b61012c841015801561172357506105dc8411155b611762576040805162461bcd60e51b815260206004820152600b60248201526a217374616b65724665657360a81b604482015290519081900360640190fd5b600a8310158015611774575060648311155b6117b3576040805162461bcd60e51b815260206004820152600b60248201526a2163616c6c65724665657360a81b604482015290519081900360640190fd5b60c88211156117f5576040805162461bcd60e51b815260206004820152600960248201526821706c6174666f726d60b81b604482015290519081900360640190fd5b600285905560038490556004839055600582905560408051868152602081018690528082018590526060810184905290517f16e6f67290546b8dd0e587f4b7f67d4f61932ae17ffd8c60d3509dbc05c175fe9181900360800190a150506001600055505050565b600080600f858154811061186c57fe5b60009182526020909120600360059092020101546001600160a01b031690503381146118c7576040805162461bcd60e51b8152602060048201526005602482015264042c2eae8d60db1b604482015290519081900360640190fd5b8215610a0d57600954604080516340c10f1960e01b81526001600160a01b03878116600483015260248201879052915191909216916340c10f1991604480830192600092919082900301818387803b15801561192257600080fd5b505af1158015611936573d6000803e3d6000fd5b50600198975050505050505050565b610fa081565b600060026000541415611993576040805162461bcd60e51b815260206004820152601f6024820152600080516020613615833981519152604482015290519081900360640190fd5b6002600055600e54600160a01b900460ff16156119e2576040805162461bcd60e51b815260206004820152600860248201526739b43aba3237bbb760c11b604482015290519081900360640190fd5b6119ec8383612bff565b5060018060005592915050565b6008546001600160a01b03163314611a40576040805162461bcd60e51b8152602060048201526005602482015264042c2eae8d60db1b604482015290519081900360640190fd5b600880546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f70a64736553c84939f57deec269299882abbbee8dc4f316eccbc6fce57e4d3cf9181900360200190a150565b6006546001600160a01b03163314611adb576040805162461bcd60e51b8152602060048201526005602482015264042c2eae8d60db1b604482015290519081900360640190fd5b600b80546001600160a01b0319166001600160a01b0384811691909117909155600a5416611b7657600a80546001600160a01b038086166001600160a01b03199283168117909355600c805485831693168317905560408051938452908516602084015282810191909152517f013ea07699fbd5315b997a706906fb94a81c616771f1052b406707d7bfc6aa279181900360600190a1611bbf565b6040805160008082526001600160a01b03851660208301528183015290517f013ea07699fbd5315b997a706906fb94a81c616771f1052b406707d7bfc6aa279181900360600190a15b505050565b6008546000906001600160a01b031633148015611beb5750600e54600160a01b900460ff16155b611c25576040805162461bcd60e51b815260206004808301919091526024820152630858591960e21b604482015290519081900360640190fd5b6001600160a01b03831615801590611c4557506001600160a01b03841615155b611c7f576040805162461bcd60e51b815260206004820152600660248201526521706172616d60d01b604482015290519081900360640190fd5b600f54600c5460408051630452a26760e21b81526001600160a01b0388811660048301529151600093929092169163114a899c9160248082019260209290919082900301818787803b158015611cd457600080fd5b505af1158015611ce8573d6000803e3d6000fd5b505050506040513d6020811015611cfe57600080fd5b5051600a5460408051632f7260f160e01b8152600481018690526001600160a01b0380851660248301528a8116604483015291519394506000939190921691632f7260f191606480830192602092919082900301818787803b158015611d6357600080fd5b505af1158015611d77573d6000803e3d6000fd5b505050506040513d6020811015611d8d57600080fd5b5051600b5460408051634ce5896f60e11b8152600481018790526001600160a01b038a811660248301527f000000000000000000000000000000000000000000000000000000000000000081166044830152606482018a9052915193945060009391909216916399cb12de91608480830192602092919082900301818787803b158015611e1957600080fd5b505af1158015611e2d573d6000803e3d6000fd5b505050506040513d6020811015611e4357600080fd5b50516040805160c0810182526001600160a01b03808c16825286811660208381019182528c83168486018181528985166060870190815285891660808801818152600060a08a01818152600f8054600181810183559184529b516005909c027f8d1108e10bcb7c27dddfc02ed9d693a074039d026cf4ea4240b40f7d581ac802810180549d8d166001600160a01b03199e8f1617905599517f8d1108e10bcb7c27dddfc02ed9d693a074039d026cf4ea4240b40f7d581ac8038b018054918d16918e1691909117905595517f8d1108e10bcb7c27dddfc02ed9d693a074039d026cf4ea4240b40f7d581ac8048a018054918c16918d1691909117905593517f8d1108e10bcb7c27dddfc02ed9d693a074039d026cf4ea4240b40f7d581ac80589018054918b16918c1691909117905590517f8d1108e10bcb7c27dddfc02ed9d693a074039d026cf4ea4240b40f7d581ac806909701805493511515600160a01b0260ff60a01b199890991693909916929092179590951695909517909555835260109052929020805460ff191690911790559091501561211c5780600f8581548110611feb57fe5b600091825260208083206004600590930201820180546001600160a01b039586166001600160a01b031990911617905560408051637d1cb25960e11b81528686169381019390935260016024840152517f00000000000000000000000000000000000000000000000000000000000000009094169363fa3964b2936044808501948390030190829087803b15801561208257600080fd5b505af1158015612096573d6000803e3d6000fd5b505050506040513d60208110156120ac57600080fd5b5050600a546040805163b84614a560e01b81526001600160a01b038481166004830152600160248301529151919092169163b84614a591604480830192600092919082900301818387803b15801561210357600080fd5b505af1158015612117573d6000803e3d6000fd5b505050505b604080516001600160a01b03808b168252808a1660208301528086168284015280851660608301528316608082015260a0810186905290517fca1a6de26e4422518df9ab614eefa07fac43e4f4c7d704dbf82e903e582659ca9181900360c00190a1506001979650505050505050565b6006546001600160a01b031681565b600080600f83815481106121ab57fe5b60009182526020909120600460059092020101546001600160a01b03169050338114612206576040805162461bcd60e51b8152602060048201526005602482015264042c2eae8d60db1b604482015290519081900360640190fd5b6000600f848154811061221557fe5b6000918252602080832060026005909302019190910154604080516001600160a01b038781166024808401919091528351808403820181526044938401855295860180516001600160e01b0316635efcc08b60e11b1781529351635b0e93fb60e11b815294821660048601818152918601889052606093860193845286516064870152865190985095967f00000000000000000000000000000000000000000000000000000000000000009092169563b61d27f6958995939489949092608490920191808383895b838110156122f55781810151838201526020016122dd565b50505050905090810190601f1680156123225780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b15801561234357600080fd5b505af1158015612357573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604090815281101561238057600080fd5b8151602083018051604051929492938301929190846401000000008211156123a757600080fd5b9083019060208201858111156123bc57600080fd5b82516401000000008111828201881017156123d657600080fd5b82525081516020918201929091019080838360005b838110156124035781810151838201526020016123eb565b50505050905090810190601f1680156124305780820380516001836020036101000a031916815260200191505b506040525060019998505050505050505050565b600080600f838154811061245457fe5b6000918252602080832060016005909302019190910154604080516370a0823160e01b815233600482015290516001600160a01b03909216945084926370a0823192602480840193829003018186803b1580156124b057600080fd5b505afa1580156124c4573d6000803e3d6000fd5b505050506040513d60208110156124da57600080fd5b505190506124e8848261113e565b506001949350505050565b600e546001600160a01b031681565b600e54600160a01b900460ff1681565b6006546001600160a01b03163314612559576040805162461bcd60e51b8152602060048201526005602482015264042c2eae8d60db1b604482015290519081900360640190fd5b6001546001600160a01b0316156125a3576040805162461bcd60e51b81526020600482015260096024820152684f6e6c79206f6e636560b81b604482015290519081900360640190fd5b600980546001600160a01b038086166001600160a01b031992831617909255600180548584169083161790556006805492841692821683179055600780548216831790556008805490911690911790556040805133815290517f4ffd725fc4a22075e9ec71c59edf9c38cdeb588a91b24fc5b61388c5be41282b9181900360200190a16040805133815290517fe45f5e140399b0a7e12971ab020724b828fbed8ac408c420884dc7d1bbe506b49181900360200190a16040805133815290517f70a64736553c84939f57deec269299882abbbee8dc4f316eccbc6fce57e4d3cf9181900360200190a1505050565b60106020526000908152604090205460ff1681565b6007546001600160a01b031681565b61271081565b6008546001600160a01b031681565b600c546001600160a01b031681565b6007546001600160a01b03163314612720576040805162461bcd60e51b8152602060048201526005602482015264042c2eae8d60db1b604482015290519081900360640190fd5b600d80546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f7dae230f18360d76a040c81f050aa14eb9d6dc7901b20fc5d855e2a20fe814d19181900360200190a150565b600260005414156127ba576040805162461bcd60e51b815260206004820152601f6024820152600080516020613615833981519152604482015290519081900360640190fd5b60026000908155600f8054869081106127cf57fe5b60009182526020822060059091020180546002820154600183015460408051632770a7eb60e21b81526001600160a01b038a81166004830152602482018c9052915195975093811695928116949116928392639dc29fac9260448084019382900301818387803b15801561284257600080fd5b505af1158015612856573d6000803e3d6000fd5b505050506004840154600160a01b900460ff16612922577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d9caed1284848a6040518463ffffffff1660e01b815260040180846001600160a01b03168152602001836001600160a01b031681526020018281526020019350505050602060405180830381600087803b1580156128f557600080fd5b505af1158015612909573d6000803e3d6000fd5b505050506040513d602081101561291f57600080fd5b50505b60048401546001600160a01b031680158015906129495750600e54600160a01b900460ff16155b801561296157506004850154600160a01b900460ff16155b156129ce57806001600160a01b031663b87bd4816040518163ffffffff1660e01b8152600401602060405180830381600087803b1580156129a157600080fd5b505af11580156129b5573d6000803e3d6000fd5b505050506040513d60208110156129cb57600080fd5b50505b6129e26001600160a01b038516878a6131db565b6040805189815290518a916001600160a01b038916917f92ccf450a286a957af52509bc1c9939d1a6a481783e142e41e2499f0bb66ebc69181900360200190a35050600160005550505050505050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052612a8c908590613229565b50505050565b801580612b18575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b158015612aea57600080fd5b505afa158015612afe573d6000803e3d6000fd5b505050506040513d6020811015612b1457600080fd5b5051155b612b535760405162461bcd60e51b81526004018080602001828103825260368152602001806136a66036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b179052611bbf908490613229565b600082820183811015610a13576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000600f8381548110612c0e57fe5b600091825260209091206005909102016004810154909150600160a01b900460ff1615612c73576040805162461bcd60e51b815260206004820152600e60248201526d1c1bdbdb081a5cc818db1bdcd95960921b604482015290519081900360640190fd5b600154604080516370a0823160e01b8152306004820152905160009283926001600160a01b03909116916370a0823191602480820192602092909190829003018186803b158015612cc357600080fd5b505afa158015612cd7573d6000803e3d6000fd5b505050506040513d6020811015612ced57600080fd5b5051600154604080516370a0823160e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166004830152915193945060009391909216916370a08231916024808301926020929190829003018186803b158015612d6257600080fd5b505afa158015612d76573d6000803e3d6000fd5b505050506040513d6020811015612d8c57600080fd5b505190506000612d9c8383612ba5565b600286015460408051631ff4de0360e11b81526001600160a01b03928316600482015290519293507f000000000000000000000000000000000000000000000000000000000000000090911691633fe9bc06916024808201926020929091908290030181600087803b158015612e1157600080fd5b505af1158015612e25573d6000803e3d6000fd5b505050506040513d6020811015612e3b57600080fd5b5050600154604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b158015612e8857600080fd5b505afa158015612e9c573d6000803e3d6000fd5b505050506040513d6020811015612eb257600080fd5b50519050612ec081836132da565b9450600082118015612edc5750600d546001600160a01b031615155b15612efe57600d54600154612efe916001600160a01b039182169116846131db565b5050505060048201546001600160a01b03168015612fec57806001600160a01b031663372500ab6040518163ffffffff1660e01b8152600401602060405180830381600087803b158015612f5157600080fd5b505af1158015612f65573d6000803e3d6000fd5b505050506040513d6020811015612f7b57600080fd5b50506040805163654580bb60e11b815290516001600160a01b0383169163ca8b01769160048083019260209291908290030181600087803b158015612fbf57600080fd5b505af1158015612fd3573d6000803e3d6000fd5b505050506040513d6020811015612fe957600080fd5b50505b81156131d457600061301561271061300f6002548661333790919063ffffffff16565b90613390565b9050600061303461271061300f6003548761333790919063ffffffff16565b9050600061305361271061300f6004548861333790919063ffffffff16565b9050600061307261271061300f6005548961333790919063ffffffff16565b90506000613084826116748787612ba5565b905061309a8361309489846132da565b906132da565b6001549097506130b4906001600160a01b031633856131db565b60038801546001546001600160a01b03918216916130d49116828a6131db565b806001600160a01b031663590a41f5896040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561311a57600080fd5b505af115801561312e573d6000803e3d6000fd5b5050600e5460015461314f93506001600160a01b03908116925016846131db565b600e546040805163d288227360e01b815233600482015260248101859052604481018b90526001600160a01b038d811660648301529151919092169163d288227391349160848082019260009290919082900301818588803b1580156131b457600080fd5b505af11580156131c8573d6000803e3d6000fd5b50505050505050505050505b5050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052611bbf9084905b606061327e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166133f79092919063ffffffff16565b805190915015611bbf5780806020019051602081101561329d57600080fd5b5051611bbf5760405162461bcd60e51b815260040180806020018281038252602a81526020018061367c602a913960400191505060405180910390fd5b600082821115613331576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b60008261334657506000611150565b8282028284828161335357fe5b0414610a135760405162461bcd60e51b815260040180806020018281038252602181526020018061365b6021913960400191505060405180910390fd5b60008082116133e6576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b8183816133ef57fe5b049392505050565b6060613406848460008561340e565b949350505050565b60608247101561344f5760405162461bcd60e51b81526004018080602001828103825260268152602001806136356026913960400191505060405180910390fd5b6134588561356a565b6134a9576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106134e85780518252601f1990920191602091820191016134c9565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811461354a576040519150601f19603f3d011682016040523d82523d6000602084013e61354f565b606091505b509150915061355f828286613570565b979650505050505050565b3b151590565b6060831561357f575081610a13565b82511561358f5782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156135d95781810151838201526020016135c1565b50505050905090810190601f1680156136065780820380516001836020036101000a031916815260200191505b509250505060405180910390fdfe5265656e7472616e637947756172643a207265656e7472616e742063616c6c00416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a264697066735822122073195a7ec07ff9bb53a3f7360471631febb71777b1e718191199665b1b72081e64736f6c634300060c0033000000000000000000000000c181edc719480bd089b94647c2dc504e2700a2b0
Deployed Bytecode
0x6080604052600436106102465760003560e01c80636a4874a1116101395780639123d404116100b6578063cb0d5b521161007a578063cb0d5b521461081d578063d0fb020314610850578063d73792a914610865578063dc4c90d31461087a578063e77772fe1461088f578063f0f44260146108a457610246565b80639123d4041461075a578063958e2d31146107845780639ec5a894146107ae578063bf86d690146107c3578063c0c53b8b146107d857610246565b80637979426b116100fd5780637979426b1461065e5780637aef67151461068a5780637bd3b995146106bd5780637e29d6c2146107025780638da5cb5b1461074557610246565b80636a4874a1146105805780636c7b69cb146105955780636fcba377146105ce57806371192b171461060a5780637303df9a1461064957610246565b80633a088cd2116101c75780635ebaf1db1161018b5780635ebaf1db146104e557806360759fce146104fa57806360cafe841461052c57806361d027b31461055657806362d28ac71461056b57610246565b80633a088cd21461042057806343a0d06614610435578063441a3e701461046d578063472d35b91461049d57806350940618146104d057610246565b80631526fe271161020e5780631526fe27146103405780631cc51d40146103ae578063245e4bf0146103e157806326232a2e146103f6578063354af9191461040b57610246565b8063068eb19e1461024b578063075461721461027c578063081e3eda1461029157806313af4035146102b857806314cd70e4146102ed575b600080fd5b34801561025757600080fd5b506102606108d7565b604080516001600160a01b039092168252519081900360200190f35b34801561028857600080fd5b506102606108e6565b34801561029d57600080fd5b506102a66108f5565b60408051918252519081900360200190f35b3480156102c457600080fd5b506102eb600480360360208110156102db57600080fd5b50356001600160a01b03166108fb565b005b3480156102f957600080fd5b5061032c6004803603606081101561031057600080fd5b50803590602081013590604001356001600160a01b0316610996565b604080519115158252519081900360200190f35b34801561034c57600080fd5b5061036a6004803603602081101561036357600080fd5b5035610a1a565b604080516001600160a01b0397881681529587166020870152938616858501529185166060850152909316608083015291151560a082015290519081900360c00190f35b3480156103ba57600080fd5b506102eb600480360360208110156103d157600080fd5b50356001600160a01b0316610a78565b3480156103ed57600080fd5b50610260610b24565b34801561040257600080fd5b506102a6610b33565b34801561041757600080fd5b506102eb610b39565b34801561042c57600080fd5b506102a6610cb1565b34801561044157600080fd5b5061032c6004803603606081101561045857600080fd5b50803590602081013590604001351515610cb7565b34801561047957600080fd5b5061032c6004803603604081101561049057600080fd5b508035906020013561113e565b3480156104a957600080fd5b506102eb600480360360208110156104c057600080fd5b50356001600160a01b0316611156565b3480156104dc57600080fd5b506102a66111f1565b3480156104f157600080fd5b506102606111f7565b34801561050657600080fd5b5061032c6004803603604081101561051d57600080fd5b5080359060200135151561121b565b34801561053857600080fd5b5061032c6004803603602081101561054f57600080fd5b50356112c8565b34801561056257600080fd5b506102606114a8565b34801561057757600080fd5b506102a66114b7565b34801561058c57600080fd5b506102606114bd565b3480156105a157600080fd5b5061032c600480360360408110156105b857600080fd5b50803590602001356001600160a01b03166114cc565b3480156105da57600080fd5b506102eb600480360360808110156105f157600080fd5b50803590602081013590604081013590606001356115d0565b34801561061657600080fd5b5061032c6004803603606081101561062d57600080fd5b508035906001600160a01b03602082013516906040013561185c565b34801561065557600080fd5b506102a6611945565b61032c6004803603604081101561067457600080fd5b50803590602001356001600160a01b031661194b565b34801561069657600080fd5b506102eb600480360360208110156106ad57600080fd5b50356001600160a01b03166119f9565b3480156106c957600080fd5b506102eb600480360360608110156106e057600080fd5b506001600160a01b038135811691602081013582169160409091013516611a94565b34801561070e57600080fd5b5061032c6004803603606081101561072557600080fd5b506001600160a01b03813581169160208101359091169060400135611bc4565b34801561075157600080fd5b5061026061218c565b34801561076657600080fd5b5061032c6004803603602081101561077d57600080fd5b503561219b565b34801561079057600080fd5b5061032c600480360360208110156107a757600080fd5b5035612444565b3480156107ba57600080fd5b506102606124f3565b3480156107cf57600080fd5b5061032c612502565b3480156107e457600080fd5b506102eb600480360360608110156107fb57600080fd5b506001600160a01b038135811691602081013582169160409091013516612512565b34801561082957600080fd5b5061032c6004803603602081101561084057600080fd5b50356001600160a01b0316612691565b34801561085c57600080fd5b506102606126a6565b34801561087157600080fd5b506102a66126b5565b34801561088657600080fd5b506102606126bb565b34801561089b57600080fd5b506102606126ca565b3480156108b057600080fd5b506102eb600480360360208110156108c757600080fd5b50356001600160a01b03166126d9565b600b546001600160a01b031681565b6009546001600160a01b031681565b600f5490565b6006546001600160a01b03163314610942576040805162461bcd60e51b8152602060048201526005602482015264042c2eae8d60db1b604482015290519081900360640190fd5b600680546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f4ffd725fc4a22075e9ec71c59edf9c38cdeb588a91b24fc5b61388c5be41282b9181900360200190a150565b600080600f85815481106109a657fe5b60009182526020909120600360059092020101546001600160a01b03169050338114610a01576040805162461bcd60e51b8152602060048201526005602482015264042c2eae8d60db1b604482015290519081900360640190fd5b610a0d85853386612774565b60019150505b9392505050565b600f8181548110610a2757fe5b6000918252602090912060059091020180546001820154600283015460038401546004909401546001600160a01b03938416955091831693908316929081169190811690600160a01b900460ff1686565b6006546001600160a01b03163314610abf576040805162461bcd60e51b8152602060048201526005602482015264042c2eae8d60db1b604482015290519081900360640190fd5b600e546001600160a01b0316610b2157600e80546001600160a01b0383166001600160a01b0319909116811790915560408051918252517fdcf314452b77e67d7e1752b1e7b47ce7819785996d300352a78b81d1a7df53c39181900360200190a15b50565b600a546001600160a01b031681565b60055481565b6006546001600160a01b03163314610b80576040805162461bcd60e51b8152602060048201526005602482015264042c2eae8d60db1b604482015290519081900360640190fd5b600e805460ff60a01b1916600160a01b17905560005b600f54811015610b21576000600f8281548110610baf57fe5b906000526020600020906005020190508060040160149054906101000a900460ff1615610bdc5750610ca9565b80546002820154604080516301395c5960e31b81526001600160a01b0393841660048201819052928416602482018190529151929391927f000000000000000000000000c181edc719480bd089b94647c2dc504e2700a2b0909216916309cae2c8916044808201926020929091908290030181600087803b158015610c6057600080fd5b505af1925050508015610c8557506040513d6020811015610c8057600080fd5b505160015b610c8e57610ca5565b5060048301805460ff60a01b1916600160a01b1790555b5050505b600101610b96565b60045481565b600060026000541415610cff576040805162461bcd60e51b815260206004820152601f6024820152600080516020613615833981519152604482015290519081900360640190fd5b6002600055600e54600160a01b900460ff1615610d4e576040805162461bcd60e51b815260206004820152600860248201526739b43aba3237bbb760c11b604482015290519081900360640190fd5b6000600f8581548110610d5d57fe5b600091825260209091206005909102016004810154909150600160a01b900460ff1615610dc2576040805162461bcd60e51b815260206004820152600e60248201526d1c1bdbdb081a5cc818db1bdcd95960921b604482015290519081900360640190fd5b80546001600160a01b0316610df981337f000000000000000000000000c181edc719480bd089b94647c2dc504e2700a2b088612a32565b60028201546001600160a01b031680610e4a576040805162461bcd60e51b815260206004820152600e60248201526d2167617567652073657474696e6760901b604482015290519081900360640190fd5b7f000000000000000000000000c181edc719480bd089b94647c2dc504e2700a2b06001600160a01b031663f9609f0883836040518363ffffffff1660e01b815260040180836001600160a01b03168152602001826001600160a01b0316815260200192505050602060405180830381600087803b158015610eca57600080fd5b505af1158015610ede573d6000803e3d6000fd5b505050506040513d6020811015610ef457600080fd5b505060048301546001600160a01b03168015610f7257806001600160a01b031663b87bd4816040518163ffffffff1660e01b8152600401602060405180830381600087803b158015610f4557600080fd5b505af1158015610f59573d6000803e3d6000fd5b505050506040513d6020811015610f6f57600080fd5b50505b60018401546001600160a01b0316861561108b57604080516340c10f1960e01b8152306004820152602481018a905290516001600160a01b038316916340c10f1991604480830192600092919082900301818387803b158015610fd457600080fd5b505af1158015610fe8573d6000803e3d6000fd5b50505060038601546001600160a01b03908116915061100b908316826000612a92565b61101f6001600160a01b038316828b612a92565b604080516305dc812160e31b8152336004820152602481018b905290516001600160a01b03831691632ee4090891604480830192600092919082900301818387803b15801561106d57600080fd5b505af1158015611081573d6000803e3d6000fd5b50505050506110f2565b604080516340c10f1960e01b8152336004820152602481018a905290516001600160a01b038316916340c10f1991604480830192600092919082900301818387803b1580156110d957600080fd5b505af11580156110ed573d6000803e3d6000fd5b505050505b6040805189815290518a9133917f73a19dd210f1a7f902193214c0ee91dd35ee5b4d920cba8d519eca65a7b488ca9181900360200190a360019550505050505060016000559392505050565b600061114c83833333612774565b5060015b92915050565b6006546001600160a01b0316331461119d576040805162461bcd60e51b8152602060048201526005602482015264042c2eae8d60db1b604482015290519081900360640190fd5b600780546001600160a01b0383166001600160a01b0319909116811790915560408051918252517fe45f5e140399b0a7e12971ab020724b828fbed8ac408c420884dc7d1bbe506b49181900360200190a150565b60025481565b7f000000000000000000000000c181edc719480bd089b94647c2dc504e2700a2b081565b600080600f848154811061122b57fe5b60009182526020808320600590920290910154604080516370a0823160e01b815233600482015290516001600160a01b03909216945084926370a0823192602480840193829003018186803b15801561128357600080fd5b505afa158015611297573d6000803e3d6000fd5b505050506040513d60208110156112ad57600080fd5b505190506112bc858286610cb7565b50600195945050505050565b600060026000541415611310576040805162461bcd60e51b815260206004820152601f6024820152600080516020613615833981519152604482015290519081900360640190fd5b60026000556008546001600160a01b0316331461135c576040805162461bcd60e51b8152602060048201526005602482015264042c2eae8d60db1b604482015290519081900360640190fd5b6000600f838154811061136b57fe5b60009182526020808320600590920290910180546002820154604080516301395c5960e31b81526001600160a01b0393841660048201529183166024830152519295507f000000000000000000000000c181edc719480bd089b94647c2dc504e2700a2b091909116936309cae2c89360448084019491939192918390030190829087803b1580156113fb57600080fd5b505af192505050801561142057506040513d602081101561141b57600080fd5b505160015b6114295761142b565b505b60048101805460ff60a01b1916600160a01b17905560028101546001600160a01b0316600090815260106020908152604091829020805460ff19169055815185815291517f2ccd633716c6ce12394d1c984ad04b6173d18aedc4f505d1537a94a98a07b6e79281900390910190a160019150506001600055919050565b600d546001600160a01b031681565b60035481565b6001546001600160a01b031681565b600080600f84815481106114dc57fe5b60009182526020909120600460059092020101546001600160a01b03169050338114611537576040805162461bcd60e51b8152602060048201526005602482015264042c2eae8d60db1b604482015290519081900360640190fd5b7f000000000000000000000000c181edc719480bd089b94647c2dc504e2700a2b06001600160a01b031663ef5cfb8c846040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050602060405180830381600087803b1580156115a657600080fd5b505af11580156115ba573d6000803e3d6000fd5b505050506040513d60208110156112bc57600080fd5b60026000541415611616576040805162461bcd60e51b815260206004820152601f6024820152600080516020613615833981519152604482015290519081900360640190fd5b60026000556007546001600160a01b03163314611662576040805162461bcd60e51b8152602060048201526005602482015264042c2eae8d60db1b604482015290519081900360640190fd5b600061167a8261167485818989612ba5565b90612ba5565b9050610fa08111156116be576040805162461bcd60e51b81526020600482015260086024820152673e4d61784665657360c01b604482015290519081900360640190fd5b61012c85101580156116d25750610dac8511155b61170f576040805162461bcd60e51b8152602060048201526009602482015268216c6f636b4665657360b81b604482015290519081900360640190fd5b61012c841015801561172357506105dc8411155b611762576040805162461bcd60e51b815260206004820152600b60248201526a217374616b65724665657360a81b604482015290519081900360640190fd5b600a8310158015611774575060648311155b6117b3576040805162461bcd60e51b815260206004820152600b60248201526a2163616c6c65724665657360a81b604482015290519081900360640190fd5b60c88211156117f5576040805162461bcd60e51b815260206004820152600960248201526821706c6174666f726d60b81b604482015290519081900360640190fd5b600285905560038490556004839055600582905560408051868152602081018690528082018590526060810184905290517f16e6f67290546b8dd0e587f4b7f67d4f61932ae17ffd8c60d3509dbc05c175fe9181900360800190a150506001600055505050565b600080600f858154811061186c57fe5b60009182526020909120600360059092020101546001600160a01b031690503381146118c7576040805162461bcd60e51b8152602060048201526005602482015264042c2eae8d60db1b604482015290519081900360640190fd5b8215610a0d57600954604080516340c10f1960e01b81526001600160a01b03878116600483015260248201879052915191909216916340c10f1991604480830192600092919082900301818387803b15801561192257600080fd5b505af1158015611936573d6000803e3d6000fd5b50600198975050505050505050565b610fa081565b600060026000541415611993576040805162461bcd60e51b815260206004820152601f6024820152600080516020613615833981519152604482015290519081900360640190fd5b6002600055600e54600160a01b900460ff16156119e2576040805162461bcd60e51b815260206004820152600860248201526739b43aba3237bbb760c11b604482015290519081900360640190fd5b6119ec8383612bff565b5060018060005592915050565b6008546001600160a01b03163314611a40576040805162461bcd60e51b8152602060048201526005602482015264042c2eae8d60db1b604482015290519081900360640190fd5b600880546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f70a64736553c84939f57deec269299882abbbee8dc4f316eccbc6fce57e4d3cf9181900360200190a150565b6006546001600160a01b03163314611adb576040805162461bcd60e51b8152602060048201526005602482015264042c2eae8d60db1b604482015290519081900360640190fd5b600b80546001600160a01b0319166001600160a01b0384811691909117909155600a5416611b7657600a80546001600160a01b038086166001600160a01b03199283168117909355600c805485831693168317905560408051938452908516602084015282810191909152517f013ea07699fbd5315b997a706906fb94a81c616771f1052b406707d7bfc6aa279181900360600190a1611bbf565b6040805160008082526001600160a01b03851660208301528183015290517f013ea07699fbd5315b997a706906fb94a81c616771f1052b406707d7bfc6aa279181900360600190a15b505050565b6008546000906001600160a01b031633148015611beb5750600e54600160a01b900460ff16155b611c25576040805162461bcd60e51b815260206004808301919091526024820152630858591960e21b604482015290519081900360640190fd5b6001600160a01b03831615801590611c4557506001600160a01b03841615155b611c7f576040805162461bcd60e51b815260206004820152600660248201526521706172616d60d01b604482015290519081900360640190fd5b600f54600c5460408051630452a26760e21b81526001600160a01b0388811660048301529151600093929092169163114a899c9160248082019260209290919082900301818787803b158015611cd457600080fd5b505af1158015611ce8573d6000803e3d6000fd5b505050506040513d6020811015611cfe57600080fd5b5051600a5460408051632f7260f160e01b8152600481018690526001600160a01b0380851660248301528a8116604483015291519394506000939190921691632f7260f191606480830192602092919082900301818787803b158015611d6357600080fd5b505af1158015611d77573d6000803e3d6000fd5b505050506040513d6020811015611d8d57600080fd5b5051600b5460408051634ce5896f60e11b8152600481018790526001600160a01b038a811660248301527f000000000000000000000000c181edc719480bd089b94647c2dc504e2700a2b081166044830152606482018a9052915193945060009391909216916399cb12de91608480830192602092919082900301818787803b158015611e1957600080fd5b505af1158015611e2d573d6000803e3d6000fd5b505050506040513d6020811015611e4357600080fd5b50516040805160c0810182526001600160a01b03808c16825286811660208381019182528c83168486018181528985166060870190815285891660808801818152600060a08a01818152600f8054600181810183559184529b516005909c027f8d1108e10bcb7c27dddfc02ed9d693a074039d026cf4ea4240b40f7d581ac802810180549d8d166001600160a01b03199e8f1617905599517f8d1108e10bcb7c27dddfc02ed9d693a074039d026cf4ea4240b40f7d581ac8038b018054918d16918e1691909117905595517f8d1108e10bcb7c27dddfc02ed9d693a074039d026cf4ea4240b40f7d581ac8048a018054918c16918d1691909117905593517f8d1108e10bcb7c27dddfc02ed9d693a074039d026cf4ea4240b40f7d581ac80589018054918b16918c1691909117905590517f8d1108e10bcb7c27dddfc02ed9d693a074039d026cf4ea4240b40f7d581ac806909701805493511515600160a01b0260ff60a01b199890991693909916929092179590951695909517909555835260109052929020805460ff191690911790559091501561211c5780600f8581548110611feb57fe5b600091825260208083206004600590930201820180546001600160a01b039586166001600160a01b031990911617905560408051637d1cb25960e11b81528686169381019390935260016024840152517f000000000000000000000000c181edc719480bd089b94647c2dc504e2700a2b09094169363fa3964b2936044808501948390030190829087803b15801561208257600080fd5b505af1158015612096573d6000803e3d6000fd5b505050506040513d60208110156120ac57600080fd5b5050600a546040805163b84614a560e01b81526001600160a01b038481166004830152600160248301529151919092169163b84614a591604480830192600092919082900301818387803b15801561210357600080fd5b505af1158015612117573d6000803e3d6000fd5b505050505b604080516001600160a01b03808b168252808a1660208301528086168284015280851660608301528316608082015260a0810186905290517fca1a6de26e4422518df9ab614eefa07fac43e4f4c7d704dbf82e903e582659ca9181900360c00190a1506001979650505050505050565b6006546001600160a01b031681565b600080600f83815481106121ab57fe5b60009182526020909120600460059092020101546001600160a01b03169050338114612206576040805162461bcd60e51b8152602060048201526005602482015264042c2eae8d60db1b604482015290519081900360640190fd5b6000600f848154811061221557fe5b6000918252602080832060026005909302019190910154604080516001600160a01b038781166024808401919091528351808403820181526044938401855295860180516001600160e01b0316635efcc08b60e11b1781529351635b0e93fb60e11b815294821660048601818152918601889052606093860193845286516064870152865190985095967f000000000000000000000000c181edc719480bd089b94647c2dc504e2700a2b09092169563b61d27f6958995939489949092608490920191808383895b838110156122f55781810151838201526020016122dd565b50505050905090810190601f1680156123225780820380516001836020036101000a031916815260200191505b50945050505050600060405180830381600087803b15801561234357600080fd5b505af1158015612357573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604090815281101561238057600080fd5b8151602083018051604051929492938301929190846401000000008211156123a757600080fd5b9083019060208201858111156123bc57600080fd5b82516401000000008111828201881017156123d657600080fd5b82525081516020918201929091019080838360005b838110156124035781810151838201526020016123eb565b50505050905090810190601f1680156124305780820380516001836020036101000a031916815260200191505b506040525060019998505050505050505050565b600080600f838154811061245457fe5b6000918252602080832060016005909302019190910154604080516370a0823160e01b815233600482015290516001600160a01b03909216945084926370a0823192602480840193829003018186803b1580156124b057600080fd5b505afa1580156124c4573d6000803e3d6000fd5b505050506040513d60208110156124da57600080fd5b505190506124e8848261113e565b506001949350505050565b600e546001600160a01b031681565b600e54600160a01b900460ff1681565b6006546001600160a01b03163314612559576040805162461bcd60e51b8152602060048201526005602482015264042c2eae8d60db1b604482015290519081900360640190fd5b6001546001600160a01b0316156125a3576040805162461bcd60e51b81526020600482015260096024820152684f6e6c79206f6e636560b81b604482015290519081900360640190fd5b600980546001600160a01b038086166001600160a01b031992831617909255600180548584169083161790556006805492841692821683179055600780548216831790556008805490911690911790556040805133815290517f4ffd725fc4a22075e9ec71c59edf9c38cdeb588a91b24fc5b61388c5be41282b9181900360200190a16040805133815290517fe45f5e140399b0a7e12971ab020724b828fbed8ac408c420884dc7d1bbe506b49181900360200190a16040805133815290517f70a64736553c84939f57deec269299882abbbee8dc4f316eccbc6fce57e4d3cf9181900360200190a1505050565b60106020526000908152604090205460ff1681565b6007546001600160a01b031681565b61271081565b6008546001600160a01b031681565b600c546001600160a01b031681565b6007546001600160a01b03163314612720576040805162461bcd60e51b8152602060048201526005602482015264042c2eae8d60db1b604482015290519081900360640190fd5b600d80546001600160a01b0383166001600160a01b0319909116811790915560408051918252517f7dae230f18360d76a040c81f050aa14eb9d6dc7901b20fc5d855e2a20fe814d19181900360200190a150565b600260005414156127ba576040805162461bcd60e51b815260206004820152601f6024820152600080516020613615833981519152604482015290519081900360640190fd5b60026000908155600f8054869081106127cf57fe5b60009182526020822060059091020180546002820154600183015460408051632770a7eb60e21b81526001600160a01b038a81166004830152602482018c9052915195975093811695928116949116928392639dc29fac9260448084019382900301818387803b15801561284257600080fd5b505af1158015612856573d6000803e3d6000fd5b505050506004840154600160a01b900460ff16612922577f000000000000000000000000c181edc719480bd089b94647c2dc504e2700a2b06001600160a01b031663d9caed1284848a6040518463ffffffff1660e01b815260040180846001600160a01b03168152602001836001600160a01b031681526020018281526020019350505050602060405180830381600087803b1580156128f557600080fd5b505af1158015612909573d6000803e3d6000fd5b505050506040513d602081101561291f57600080fd5b50505b60048401546001600160a01b031680158015906129495750600e54600160a01b900460ff16155b801561296157506004850154600160a01b900460ff16155b156129ce57806001600160a01b031663b87bd4816040518163ffffffff1660e01b8152600401602060405180830381600087803b1580156129a157600080fd5b505af11580156129b5573d6000803e3d6000fd5b505050506040513d60208110156129cb57600080fd5b50505b6129e26001600160a01b038516878a6131db565b6040805189815290518a916001600160a01b038916917f92ccf450a286a957af52509bc1c9939d1a6a481783e142e41e2499f0bb66ebc69181900360200190a35050600160005550505050505050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052612a8c908590613229565b50505050565b801580612b18575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b158015612aea57600080fd5b505afa158015612afe573d6000803e3d6000fd5b505050506040513d6020811015612b1457600080fd5b5051155b612b535760405162461bcd60e51b81526004018080602001828103825260368152602001806136a66036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b179052611bbf908490613229565b600082820183811015610a13576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000600f8381548110612c0e57fe5b600091825260209091206005909102016004810154909150600160a01b900460ff1615612c73576040805162461bcd60e51b815260206004820152600e60248201526d1c1bdbdb081a5cc818db1bdcd95960921b604482015290519081900360640190fd5b600154604080516370a0823160e01b8152306004820152905160009283926001600160a01b03909116916370a0823191602480820192602092909190829003018186803b158015612cc357600080fd5b505afa158015612cd7573d6000803e3d6000fd5b505050506040513d6020811015612ced57600080fd5b5051600154604080516370a0823160e01b81526001600160a01b037f000000000000000000000000c181edc719480bd089b94647c2dc504e2700a2b081166004830152915193945060009391909216916370a08231916024808301926020929190829003018186803b158015612d6257600080fd5b505afa158015612d76573d6000803e3d6000fd5b505050506040513d6020811015612d8c57600080fd5b505190506000612d9c8383612ba5565b600286015460408051631ff4de0360e11b81526001600160a01b03928316600482015290519293507f000000000000000000000000c181edc719480bd089b94647c2dc504e2700a2b090911691633fe9bc06916024808201926020929091908290030181600087803b158015612e1157600080fd5b505af1158015612e25573d6000803e3d6000fd5b505050506040513d6020811015612e3b57600080fd5b5050600154604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b158015612e8857600080fd5b505afa158015612e9c573d6000803e3d6000fd5b505050506040513d6020811015612eb257600080fd5b50519050612ec081836132da565b9450600082118015612edc5750600d546001600160a01b031615155b15612efe57600d54600154612efe916001600160a01b039182169116846131db565b5050505060048201546001600160a01b03168015612fec57806001600160a01b031663372500ab6040518163ffffffff1660e01b8152600401602060405180830381600087803b158015612f5157600080fd5b505af1158015612f65573d6000803e3d6000fd5b505050506040513d6020811015612f7b57600080fd5b50506040805163654580bb60e11b815290516001600160a01b0383169163ca8b01769160048083019260209291908290030181600087803b158015612fbf57600080fd5b505af1158015612fd3573d6000803e3d6000fd5b505050506040513d6020811015612fe957600080fd5b50505b81156131d457600061301561271061300f6002548661333790919063ffffffff16565b90613390565b9050600061303461271061300f6003548761333790919063ffffffff16565b9050600061305361271061300f6004548861333790919063ffffffff16565b9050600061307261271061300f6005548961333790919063ffffffff16565b90506000613084826116748787612ba5565b905061309a8361309489846132da565b906132da565b6001549097506130b4906001600160a01b031633856131db565b60038801546001546001600160a01b03918216916130d49116828a6131db565b806001600160a01b031663590a41f5896040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561311a57600080fd5b505af115801561312e573d6000803e3d6000fd5b5050600e5460015461314f93506001600160a01b03908116925016846131db565b600e546040805163d288227360e01b815233600482015260248101859052604481018b90526001600160a01b038d811660648301529151919092169163d288227391349160848082019260009290919082900301818588803b1580156131b457600080fd5b505af11580156131c8573d6000803e3d6000fd5b50505050505050505050505b5050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052611bbf9084905b606061327e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166133f79092919063ffffffff16565b805190915015611bbf5780806020019051602081101561329d57600080fd5b5051611bbf5760405162461bcd60e51b815260040180806020018281038252602a81526020018061367c602a913960400191505060405180910390fd5b600082821115613331576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b60008261334657506000611150565b8282028284828161335357fe5b0414610a135760405162461bcd60e51b815260040180806020018281038252602181526020018061365b6021913960400191505060405180910390fd5b60008082116133e6576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b8183816133ef57fe5b049392505050565b6060613406848460008561340e565b949350505050565b60608247101561344f5760405162461bcd60e51b81526004018080602001828103825260268152602001806136356026913960400191505060405180910390fd5b6134588561356a565b6134a9576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106134e85780518252601f1990920191602091820191016134c9565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811461354a576040519150601f19603f3d011682016040523d82523d6000602084013e61354f565b606091505b509150915061355f828286613570565b979650505050505050565b3b151590565b6060831561357f575081610a13565b82511561358f5782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156135d95781810151838201526020016135c1565b50505050905090810190601f1680156136065780820380516001836020036101000a031916815260200191505b509250505060405180910390fdfe5265656e7472616e637947756172643a207265656e7472616e742063616c6c00416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a264697066735822122073195a7ec07ff9bb53a3f7360471631febb71777b1e718191199665b1b72081e64736f6c634300060c0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000c181edc719480bd089b94647c2dc504e2700a2b0
-----Decoded View---------------
Arg [0] : _staker (address): 0xC181Edc719480bd089b94647c2Dc504e2700a2B0
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000c181edc719480bd089b94647c2dc504e2700a2b0
Deployed Bytecode Sourcemap
681:19638:16:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1438:27;;;;;;;;;;;;;:::i;:::-;;;;-1:-1:-1;;;;;1438:27:16;;;;;;;;;;;;;;1377:21;;;;;;;;;;;;;:::i;7602:93::-;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;3994:157;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;3994:157:16;-1:-1:-1;;;;;3994:157:16;;:::i;:::-;;15156:314;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;15156:314:16;;;;;;;;;;;-1:-1:-1;;;;;15156:314:16;;:::i;:::-;;;;;;;;;;;;;;;;;;1811:26;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1811:26:16;;:::i;:::-;;;;-1:-1:-1;;;;;1811:26:16;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5749:366;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;5749:366:16;-1:-1:-1;;;;;5749:366:16;;:::i;1404:28::-;;;;;;;;;;;;;:::i;1084:30::-;;;;;;;;;;;;;:::i;10419:512::-;;;;;;;;;;;;;:::i;993:36::-;;;;;;;;;;;;;:::i;11122:1436::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;11122:1436:16;;;;;;;;;;;;;;:::i;14568:157::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;14568:157:16;;;;;;;:::i;4283:169::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;4283:169:16;-1:-1:-1;;;;;4283:169:16;;:::i;848:34::-;;;;;;;;;;;;;:::i;1340:31::-;;;;;;;;;;;;;:::i;12758:254::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;12758:254:16;;;;;;;;;:::i;9821:414::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;9821:414:16;;:::i;1504:23::-;;;;;;;;;;;;;:::i;915:36::-;;;;;;;;;;;;;:::i;823:18::-;;;;;;;;;;;;;:::i;15562:244::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;15562:244:16;;;;;;-1:-1:-1;;;;;15562:244:16;;:::i;6465:837::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;6465:837:16;;;;;;;;;;;;;;;;;:::i;19917:400::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;19917:400:16;;;-1:-1:-1;;;;;19917:400:16;;;;;;;;;;:::i;1153:38::-;;;;;;;;;;;;;:::i;19499:232::-;;;;;;;;;;;;;;;;-1:-1:-1;19499:232:16;;;;;;-1:-1:-1;;;;;19499:232:16;;:::i;4538:181::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;4538:181:16;-1:-1:-1;;;;;4538:181:16;;:::i;4846:807::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;4846:807:16;;;;;;;;;;;;;;;;;;;:::i;7913:1695::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;7913:1695:16;;;;;;;;;;;;;;;;;:::i;1251:20::-;;;;;;;;;;;;;:::i;15935:400::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;15935:400:16;;:::i;14817:227::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;14817:227:16;;:::i;1533:22::-;;;;;;;;;;;;;:::i;1583:::-;;;;;;;;;;;;;:::i;3370:467::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;3370:467:16;;;;;;;;;;;;;;;;;;;:::i;1843:40::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1843:40:16;-1:-1:-1;;;;;1843:40:16;;:::i;1277:25::-;;;;;;;;;;;;;:::i;1197:47::-;;;;;;;;;;;;;:::i;1308:26::-;;;;;;;;;;;;;:::i;1471:27::-;;;;;;;;;;;;;:::i;7384:180::-;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;7384:180:16;-1:-1:-1;;;;;7384:180:16;;:::i;1438:27::-;;;-1:-1:-1;;;;;1438:27:16;;:::o;1377:21::-;;;-1:-1:-1;;;;;1377:21:16;;:::o;7602:93::-;7673:8;:15;7602:93;:::o;3994:157::-;4069:5;;-1:-1:-1;;;;;4069:5:16;4055:10;:19;4047:37;;;;;-1:-1:-1;;;4047:37:16;;;;;;;;;;;;-1:-1:-1;;;4047:37:16;;;;;;;;;;;;;;;4094:5;:14;;-1:-1:-1;;;;;4094:14:16;;-1:-1:-1;;;;;;4094:14:16;;;;;;;;4124:20;;;;;;;;;;;;;;;;3994:157;:::o;15156:314::-;15268:4;15284:22;15309:8;15318:4;15309:14;;;;;;;;;;;;;;;;:25;:14;;;;;:25;;-1:-1:-1;;;;;15309:25:16;;-1:-1:-1;15352:10:16;:28;;15344:46;;;;;-1:-1:-1;;;15344:46:16;;;;;;;;;;;;-1:-1:-1;;;15344:46:16;;;;;;;;;;;;;;;15401:41;15411:4;15417:7;15426:10;15438:3;15401:9;:41::i;:::-;15459:4;15452:11;;;15156:314;;;;;;:::o;1811:26::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;1811:26:16;;;;-1:-1:-1;1811:26:16;;;;;;;;;;;;;;;;-1:-1:-1;;;1811:26:16;;;;;:::o;5749:366::-;5836:5;;-1:-1:-1;;;;;5836:5:16;5822:10;:19;5814:37;;;;;-1:-1:-1;;;5814:37:16;;;;;;;;;;;;-1:-1:-1;;;5814:37:16;;;;;;;;;;;;;;;5992:7;;-1:-1:-1;;;;;5992:7:16;5988:121;;6029:7;:18;;-1:-1:-1;;;;;6029:18:16;;-1:-1:-1;;;;;;6029:18:16;;;;;;;;6066:32;;;;;;;;;;;;;;;;5988:121;5749:366;:::o;1404:28::-;;;-1:-1:-1;;;;;1404:28:16;;:::o;1084:30::-;;;;:::o;10419:512::-;10486:5;;-1:-1:-1;;;;;10486:5:16;10472:10;:19;10464:37;;;;;-1:-1:-1;;;10464:37:16;;;;;;;;;;;;-1:-1:-1;;;10464:37:16;;;;;;;;;;;;;;;10511:10;:17;;-1:-1:-1;;;;10511:17:16;-1:-1:-1;;;10511:17:16;;;;10539:386;10563:8;:15;10559:19;;10539:386;;;10599:21;10623:8;10632:1;10623:11;;;;;;;;;;;;;;;;;;10599:35;;10652:4;:13;;;;;;;;;;;;10648:27;;;10667:8;;;10648:27;10706:12;;10748:10;;;;10811:41;;;-1:-1:-1;;;10811:41:16;;-1:-1:-1;;;;;10706:12:16;;;10811:41;;;;;;10748:10;;;10811:41;;;;;;;;10706:12;;10748:10;;10819:6;10811:27;;;;;;:41;;;;;;;;;;;;;;;10690:13;10811:27;:41;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;10811:41:16;;;10807:108;;;;;-1:-1:-1;10871:13:16;;;:20;;-1:-1:-1;;;;10871:20:16;-1:-1:-1;;;10871:20:16;;;10807:108;10539:386;;;;10580:3;;10539:386;;993:36;;;;:::o;11122:1436::-;11242:4;1688:1:8;2277:7;;:19;;2269:63;;;;;-1:-1:-1;;;2269:63:8;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;2269:63:8;;;;;;;;;;;;;;;1688:1;2407:7;:18;11267:10:16::1;::::0;-1:-1:-1;;;11267:10:16;::::1;;;11266:11;11258:32;;;::::0;;-1:-1:-1;;;11258:32:16;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;-1:-1:-1;;;11258:32:16;;;;;;;;;;;;;::::1;;11300:21;11324:8;11333:4;11324:14;;;;;;;;;::::0;;;::::1;::::0;;;::::1;::::0;;::::1;;11356:13;::::0;::::1;::::0;11324:14;;-1:-1:-1;;;;11356:13:16;::::1;;;:22;11348:49;;;::::0;;-1:-1:-1;;;11348:49:16;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;-1:-1:-1;;;11348:49:16;;;;;;;;;;;;;::::1;;11459:12:::0;;-1:-1:-1;;;;;11459:12:16::1;11481:61;11459:12:::0;11514:10:::1;11526:6;11534:7:::0;11481:32:::1;:61::i;:::-;11585:10;::::0;::::1;::::0;-1:-1:-1;;;;;11585:10:16::1;11613:19:::0;11605:46:::1;;;::::0;;-1:-1:-1;;;11605:46:16;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;-1:-1:-1;;;11605:46:16;;;;;;;;;;;;;::::1;;11669:6;-1:-1:-1::0;;;;;11661:23:16::1;;11685:7;11694:5;11661:39;;;;;;;;;;;;;-1:-1:-1::0;;;;;11661:39:16::1;;;;;;-1:-1:-1::0;;;;;11661:39:16::1;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;::::0;::::1;;-1:-1:-1::0;;11831:10:16::1;::::0;::::1;::::0;-1:-1:-1;;;;;11831:10:16::1;11855:19:::0;;11851:78:::1;;11897:5;-1:-1:-1::0;;;;;11890:26:16::1;;:28;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;::::0;::::1;;-1:-1:-1::0;;11851:78:16::1;11955:10;::::0;::::1;::::0;-1:-1:-1;;;;;11955:10:16::1;11975:504:::0;::::1;;;12060:48;::::0;;-1:-1:-1;;;12060:48:16;;12093:4:::1;12060:48;::::0;::::1;::::0;;;;;;;;;-1:-1:-1;;;;;12060:24:16;::::1;::::0;::::1;::::0;:48;;;;;-1:-1:-1;;12060:48:16;;;;;;;-1:-1:-1;12060:24:16;:48;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;-1:-1:-1::0;;;12147:15:16::1;::::0;::::1;::::0;-1:-1:-1;;;;;12147:15:16;;::::1;::::0;-1:-1:-1;12176:44:16::1;::::0;:25;::::1;12147:15:::0;12122:22:::1;12176:25;:44::i;:::-;12234:50;-1:-1:-1::0;;;;;12234:25:16;::::1;12260:14:::0;12276:7;12234:25:::1;:50::i;:::-;12298:54;::::0;;-1:-1:-1;;;12298:54:16;;12332:10:::1;12298:54;::::0;::::1;::::0;;;;;;;;;-1:-1:-1;;;;;12298:33:16;::::1;::::0;::::1;::::0;:54;;;;;-1:-1:-1;;12298:54:16;;;;;;;-1:-1:-1;12298:33:16;:54;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;11975:504;;;;12423:45;::::0;;-1:-1:-1;;;12423:45:16;;12448:10:::1;12423:45;::::0;::::1;::::0;;;;;;;;;-1:-1:-1;;;;;12423:24:16;::::1;::::0;::::1;::::0;:45;;;;;-1:-1:-1;;12423:45:16;;;;;;;-1:-1:-1;12423:24:16;:45;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;11975:504;12494:36;::::0;;;;;;;12516:4;;12504:10:::1;::::0;12494:36:::1;::::0;;;;::::1;::::0;;::::1;12547:4;12540:11;;;;;;;1645:1:8::0;2580:7;:22;11122:1436:16;;-1:-1:-1;;;11122:1436:16:o;14568:157::-;14633:4;14649:48;14659:4;14665:7;14674:10;14686;14649:9;:48::i;:::-;-1:-1:-1;14714:4:16;14568:157;;;;;:::o;4283:169::-;4362:5;;-1:-1:-1;;;;;4362:5:16;4348:10;:19;4340:37;;;;;-1:-1:-1;;;4340:37:16;;;;;;;;;;;;-1:-1:-1;;;4340:37:16;;;;;;;;;;;;;;;4387:10;:18;;-1:-1:-1;;;;;4387:18:16;;-1:-1:-1;;;;;;4387:18:16;;;;;;;;4421:24;;;;;;;;;;;;;;;;4283:169;:::o;848:34::-;;;;:::o;1340:31::-;;;:::o;12758:254::-;12823:4;12839:15;12857:8;12866:4;12857:14;;;;;;;;;;;;;;;;;;;;;;;:22;12907:37;;;-1:-1:-1;;;12907:37:16;;12933:10;12907:37;;;;;;-1:-1:-1;;;;;12857:22:16;;;;-1:-1:-1;12857:22:16;;12907:25;;:37;;;;;;;;;;12857:22;12907:37;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;12907:37:16;;-1:-1:-1;12954:30:16;12962:4;12907:37;12977:6;12954:7;:30::i;:::-;-1:-1:-1;13001:4:16;;12758:254;-1:-1:-1;;;;;12758:254:16:o;9821:414::-;9888:4;1688:1:8;2277:7;;:19;;2269:63;;;;;-1:-1:-1;;;2269:63:8;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;2269:63:8;;;;;;;;;;;;;;;1688:1;2407:7;:18;9926:11:16::1;::::0;-1:-1:-1;;;;;9926:11:16::1;9912:10;:25;9904:43;;;::::0;;-1:-1:-1;;;9904:43:16;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;-1:-1:-1;;;9904:43:16;;;;;;;;;;;;;::::1;;9957:21;9981:8;9990:4;9981:14;;;;;;;;;::::0;;;::::1;::::0;;;::::1;::::0;;::::1;::::0;;::::1;10068:12:::0;;10082:10:::1;::::0;::::1;::::0;10040:53:::1;::::0;;-1:-1:-1;;;10040:53:16;;-1:-1:-1;;;;;10068:12:16;;::::1;10040:53;::::0;::::1;::::0;10082:10;;::::1;10040:53:::0;;;;;9981:14;;-1:-1:-1;10048:6:16::1;10040:27:::0;;;::::1;::::0;::::1;::::0;:53;;;;;9981:14;;10040:53;;;;;;;;;;:27;:53;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::1;;-1:-1:-1::0;10040:53:16;::::1;;10036:69;;;;;;;10115:13;::::0;::::1;:20:::0;;-1:-1:-1;;;;10115:20:16::1;-1:-1:-1::0;;;10115:20:16::1;::::0;;10154:10:::1;::::0;::::1;::::0;-1:-1:-1;;;;;10154:10:16::1;10115:20:::0;10145;;;:8:::1;:20;::::0;;;;;;;;:28;;-1:-1:-1;;10145:28:16::1;::::0;;10189:18;;;;;;;::::1;::::0;;;;;;;;::::1;10224:4;10217:11;;;1645:1:8::0;2580:7;:22;9821:414:16;;-1:-1:-1;9821:414:16:o;1504:23::-;;;-1:-1:-1;;;;;1504:23:16;;:::o;915:36::-;;;;:::o;823:18::-;;;-1:-1:-1;;;;;823:18:16;;:::o;15562:244::-;15632:4;15648:13;15664:8;15673:4;15664:14;;;;;;;;;;;;;;;;:20;:14;;;;;:20;;-1:-1:-1;;;;;15664:20:16;;-1:-1:-1;15702:10:16;:19;;15694:37;;;;;-1:-1:-1;;;15694:37:16;;;;;;;;;;;;-1:-1:-1;;;15694:37:16;;;;;;;;;;;;;;;15750:6;-1:-1:-1;;;;;15742:28:16;;15771:6;15742:36;;;;;;;;;;;;;-1:-1:-1;;;;;15742:36:16;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6465:837;1688:1:8;2277:7;;:19;;2269:63;;;;;-1:-1:-1;;;2269:63:8;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;2269:63:8;;;;;;;;;;;;;;;1688:1;2407:7;:18;6654:10:16::1;::::0;-1:-1:-1;;;;;6654:10:16::1;6640;:24;6632:42;;;::::0;;-1:-1:-1;;;6632:42:16;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;-1:-1:-1;;;6632:42:16;;;;;;;;;;;;;::::1;;6685:13;6701:58;6749:9:::0;6701:43:::1;6732:11:::0;6701:43;:9;6715:11;6701:13:::1;:26::i;:::-;:30:::0;::::1;:43::i;:58::-;6685:74;;1187:4;6777:5;:16;;6769:37;;;::::0;;-1:-1:-1;;;6769:37:16;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;-1:-1:-1;;;6769:37:16;;;;;;;;;;;;;::::1;;6838:3;6825:9;:16;;:37;;;;;6858:4;6845:9;:17;;6825:37;6817:59;;;::::0;;-1:-1:-1;;;6817:59:16;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;-1:-1:-1;;;6817:59:16;;;;;;;;;;;;;::::1;;6909:3;6894:11;:18;;:41;;;;;6931:4;6916:11;:19;;6894:41;6886:65;;;::::0;;-1:-1:-1;;;6886:65:16;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;-1:-1:-1;;;6886:65:16;;;;;;;;;;;;;::::1;;6984:2;6969:11;:17;;:39;;;;;7005:3;6990:11;:18;;6969:39;6961:63;;;::::0;;-1:-1:-1;;;6961:63:16;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;-1:-1:-1;;;6961:63:16;;;;;;;;;;;;;::::1;;7055:3;7042:9;:16;;7034:38;;;::::0;;-1:-1:-1;;;7034:38:16;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;-1:-1:-1;;;7034:38:16;;;;;;;;;;;;;::::1;;7083:13;:25:::0;;;7118:15:::1;:29:::0;;;7157:16:::1;:30:::0;;;7197:11:::1;:23:::0;;;7236:59:::1;::::0;;;;;::::1;::::0;::::1;::::0;;;;;;;;;;;;;;;;;::::1;::::0;;;;;;;::::1;-1:-1:-1::0;;1645:1:8;2580:7;:22;-1:-1:-1;;;6465:837:16:o;19917:400::-;20037:4;20053:22;20078:8;20087:4;20078:14;;;;;;;;;;;;;;;;:25;:14;;;;;:25;;-1:-1:-1;;;;;20078:25:16;;-1:-1:-1;20121:10:16;:28;;20113:46;;;;;-1:-1:-1;;;20113:46:16;;;;;;;;;;;;-1:-1:-1;;;20113:46:16;;;;;;;;;;;;;;;20174:11;;20170:119;;20247:6;;20234:44;;;-1:-1:-1;;;20234:44:16;;-1:-1:-1;;;;;20234:44:16;;;;;;;;;;;;;;;20247:6;;;;;20234:25;;:44;;;;;20247:6;;20234:44;;;;;;;20247:6;;20234:44;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;20306:4:16;;19917:400;-1:-1:-1;;;;;;;;19917:400:16:o;1153:38::-;1187:4;1153:38;:::o;19499:232::-;19604:4;1688:1:8;2277:7;;:19;;2269:63;;;;;-1:-1:-1;;;2269:63:8;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;2269:63:8;;;;;;;;;;;;;;;1688:1;2407:7;:18;19629:10:16::1;::::0;-1:-1:-1;;;19629:10:16;::::1;;;19628:11;19620:32;;;::::0;;-1:-1:-1;;;19620:32:16;;::::1;;::::0;::::1;::::0;::::1;::::0;;;;-1:-1:-1;;;19620:32:16;;;;;;;;;;;;;::::1;;19662:41;19678:4;19684:18;19662:15;:41::i;:::-;-1:-1:-1::0;19720:4:16::1;1645:1:8::0;2580:7;:22;19499:232:16;;-1:-1:-1;;19499:232:16:o;4538:181::-;4619:11;;-1:-1:-1;;;;;4619:11:16;4605:10;:25;4597:43;;;;;-1:-1:-1;;;4597:43:16;;;;;;;;;;;;-1:-1:-1;;;4597:43:16;;;;;;;;;;;;;;;4650:11;:20;;-1:-1:-1;;;;;4650:20:16;;-1:-1:-1;;;;;;4650:20:16;;;;;;;;4686:26;;;;;;;;;;;;;;;;4538:181;:::o;4846:807::-;4996:5;;-1:-1:-1;;;;;4996:5:16;4982:10;:19;4974:37;;;;;-1:-1:-1;;;4974:37:16;;;;;;;;;;;;-1:-1:-1;;;4974:37:16;;;;;;;;;;;;;;;5152:12;:24;;-1:-1:-1;;;;;;5152:24:16;-1:-1:-1;;;;;5152:24:16;;;;;;;;;;5374:13;;;5370:277;;5417:13;:25;;-1:-1:-1;;;;;5417:25:16;;;-1:-1:-1;;;;;;5417:25:16;;;;;;;;5456:12;:24;;;;;;;;;;;5500:49;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5370:277;;;5585:51;;;5610:1;5585:51;;;-1:-1:-1;;;;;5585:51:16;;;;;;;;;;;;;;;;;;;;;5370:277;4846:807;;;:::o;7913:1695::-;8073:11;;8035:4;;-1:-1:-1;;;;;8073:11:16;8059:10;:25;:40;;;;-1:-1:-1;8089:10:16;;-1:-1:-1;;;8089:10:16;;;;8088:11;8059:40;8051:57;;;;;-1:-1:-1;;;8051:57:16;;;;;;;;;;;;;;;-1:-1:-1;;;8051:57:16;;;;;;;;;;;;;;;-1:-1:-1;;;;;8126:20:16;;;;;;:46;;-1:-1:-1;;;;;;8150:22:16;;;;8126:46;8118:65;;;;;-1:-1:-1;;;8118:65:16;;;;;;;;;;;;-1:-1:-1;;;8118:65:16;;;;;;;;;;;;;;;8238:8;:15;8331:12;;8317:56;;;-1:-1:-1;;;8317:56:16;;-1:-1:-1;;;;;8317:56:16;;;;;;;;;8224:11;;8331:12;;;;;8317:46;;:56;;;;;;;;;;;;;;;8224:11;8331:12;8317:56;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;8317:56:16;8473:13;;8458:68;;;-1:-1:-1;;;8458:68:16;;;;;;;;-1:-1:-1;;;;;8458:68:16;;;;;;;;;;;;;;;;8317:56;;-1:-1:-1;8434:21:16;;8473:13;;;;;8458:46;;:68;;;;;8317:56;;8458:68;;;;;;;8434:21;8473:13;8458:68;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;8458:68:16;8618:12;;8604:75;;;-1:-1:-1;;;8604:75:16;;;;;;;;-1:-1:-1;;;;;8604:75:16;;;;;;;8657:6;8604:75;;;;;;;;;;;;;;8458:68;;-1:-1:-1;8588:13:16;;8618:12;;;;;8604:39;;:75;;;;;8458:68;;8604:75;;;;;;;8588:13;8618:12;8604:75;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;8604:75:16;8744:226;;;;;;;;-1:-1:-1;;;;;8744:226:16;;;;;;;;8604:75;8744:226;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;8744:226:16;;;;;;8717:8;:263;;8744:226;8717:263;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;8717:263:16;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;8717:263:16;-1:-1:-1;;;;8717:263:16;;;;;;;;;;;;;;;;;;;;;;;8990:16;;:8;:16;;;;;:23;;-1:-1:-1;;8990:23:16;;;;;;8604:75;;-1:-1:-1;9308:19:16;9304:200;;9365:5;9343:8;9352:3;9343:13;;;;;;;;;;;;;;;;:19;:13;;;;;:19;;:27;;-1:-1:-1;;;;;9343:27:16;;;-1:-1:-1;;;;;;9343:27:16;;;;;;9384:43;;;-1:-1:-1;;;9384:43:16;;;;;;;;;;;;9343:27;9384:43;;;;;9392:6;9384:30;;;;;;:43;;;;;;;;;;;;:30;:43;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;9456:13:16;;9441:52;;;-1:-1:-1;;;9441:52:16;;-1:-1:-1;;;;;9441:52:16;;;;;;;9456:13;9441:52;;;;;;9456:13;;;;;9441:39;;:52;;;;;9456:13;;9441:52;;;;;;;9456:13;;9441:52;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;9304:200;9519:61;;;-1:-1:-1;;;;;9519:61:16;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;9597:4:16;;7913:1695;-1:-1:-1;;;;;;;7913:1695:16:o;1251:20::-;;;-1:-1:-1;;;;;1251:20:16;;:::o;15935:400::-;15993:4;16009:13;16025:8;16034:4;16025:14;;;;;;;;;;;;;;;;:20;:14;;;;;:20;;-1:-1:-1;;;;;16025:20:16;;-1:-1:-1;16063:10:16;:19;;16055:37;;;;;-1:-1:-1;;;16055:37:16;;;;;;;;;;;;-1:-1:-1;;;16055:37:16;;;;;;;;;;;;;;;16102:13;16118:8;16127:4;16118:14;;;;;;;;;;;;;;;;:20;:14;;;;;:20;;;;;16168:81;;;-1:-1:-1;;;;;16168:81:16;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;16168:81:16;-1:-1:-1;;;16168:81:16;;;16259:48;;-1:-1:-1;;;16259:48:16;;16118:20;;;16259:48;;;;;;;;;;;;16148:17;16259:48;;;;;;;;;;;;;;16118:20;;-1:-1:-1;16168:81:16;;16267:6;16259:23;;;;;;16118:20;;:14;;16168:81;;16259:48;;;;;;;;;16168:81;16118:14;16259:48;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;16259:48:16;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;16259:48:16;;;;;;;;;;-1:-1:-1;16259:48:16;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;16259:48:16;;-1:-1:-1;16324:4:16;;15935:400;-1:-1:-1;;;;;;;;;15935:400:16:o;14817:227::-;14868:4;14884:13;14900:8;14909:4;14900:14;;;;;;;;;;;;;;;;:20;:14;;;;;:20;;;;;14948:35;;;-1:-1:-1;;;14948:35:16;;14972:10;14948:35;;;;;;-1:-1:-1;;;;;14900:20:16;;;;-1:-1:-1;14900:20:16;;14948:23;;:35;;;;;;;;;;14900:20;14948:35;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;14948:35:16;;-1:-1:-1;14993:23:16;15002:4;14948:35;14993:8;:23::i;:::-;-1:-1:-1;15033:4:16;;14817:227;-1:-1:-1;;;;14817:227:16:o;1533:22::-;;;-1:-1:-1;;;;;1533:22:16;;:::o;1583:::-;;;-1:-1:-1;;;1583:22:16;;;;;:::o;3370:467::-;3508:5;;-1:-1:-1;;;;;3508:5:16;3494:10;:19;3486:37;;;;;-1:-1:-1;;;3486:37:16;;;;;;;;;;;;-1:-1:-1;;;3486:37:16;;;;;;;;;;;;;;;3541:3;;-1:-1:-1;;;;;3541:3:16;:17;3533:39;;;;;-1:-1:-1;;;3533:39:16;;;;;;;;;;;;-1:-1:-1;;;3533:39:16;;;;;;;;;;;;;;;3582:6;:16;;-1:-1:-1;;;;;3582:16:16;;;-1:-1:-1;;;;;;3582:16:16;;;;;;;;3608:10;;;;;;;;;;;3628:5;:14;;;;;;;;;;;;3652:10;:19;;;;;;;;-1:-1:-1;3681:20:16;;;;;;;;;;3717:24;;;3730:10;3717:24;;;;;;;;;;;;;3756:29;;;3774:10;3756:29;;;;;;;;;;;;;3800:30;;;3819:10;3800:30;;;;;;;;;;;;;3370:467;;;:::o;1843:40::-;;;;;;;;;;;;;;;:::o;1277:25::-;;;-1:-1:-1;;;;;1277:25:16;;:::o;1197:47::-;1239:5;1197:47;:::o;1308:26::-;;;-1:-1:-1;;;;;1308:26:16;;:::o;1471:27::-;;;-1:-1:-1;;;;;1471:27:16;;:::o;7384:180::-;7465:10;;-1:-1:-1;;;;;7465:10:16;7451;:24;7443:42;;;;;-1:-1:-1;;;7443:42:16;;;;;;;;;;;;-1:-1:-1;;;7443:42:16;;;;;;;;;;;;;;;7495:8;:20;;-1:-1:-1;;;;;7495:20:16;;-1:-1:-1;;;;;;7495:20:16;;;;;;;;7531:26;;;;;;;;;;;;;;;;7384:180;:::o;13325:1037::-;1688:1:8;2277:7;;:19;;2269:63;;;;;-1:-1:-1;;;2269:63:8;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;2269:63:8;;;;;;;;;;;;;;;1688:1;2407:7;:18;;;13497:8:16::1;:14:::0;;13506:4;;13497:14;::::1;;;;;;::::0;;;::::1;::::0;;::::1;::::0;;::::1;;13539:12:::0;;13577:10:::1;::::0;::::1;::::0;13539:12;13642:10;::::1;::::0;13662:40:::1;::::0;;-1:-1:-1;;;13662:40:16;;-1:-1:-1;;;;;13662:40:16;;::::1;;::::0;::::1;::::0;;;;;;;;;13497:14;;-1:-1:-1;13539:12:16;;::::1;::::0;13577:10;;::::1;::::0;13642;::::1;::::0;;;13662:24:::1;::::0;:40;;;;;;;;;;13497:14;13642:10;13662:40;::::1;;::::0;::::1;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;-1:-1:-1::0;;;;13815:13:16::1;::::0;::::1;::::0;-1:-1:-1;;;13815:13:16;::::1;;;13810:94;;13852:6;-1:-1:-1::0;;;;;13844:24:16::1;;13869:7;13878:5;13885:7;13844:49;;;;;;;;;;;;;-1:-1:-1::0;;;;;13844:49:16::1;;;;;;-1:-1:-1::0;;;;;13844:49:16::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;::::0;::::1;;-1:-1:-1::0;;13810:94:16::1;14100:10;::::0;::::1;::::0;-1:-1:-1;;;;;14100:10:16::1;14124:19:::0;;;::::1;::::0;:34:::1;;-1:-1:-1::0;14148:10:16::1;::::0;-1:-1:-1;;;14148:10:16;::::1;;;14147:11;14124:34;:52;;;;-1:-1:-1::0;14163:13:16::1;::::0;::::1;::::0;-1:-1:-1;;;14163:13:16;::::1;;;14162:14;14124:52;14120:111;;;14199:5;-1:-1:-1::0;;;;;14192:26:16::1;;:28;;;;;;;;;;;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;::::0;::::1;;-1:-1:-1::0;;14120:111:16::1;14268:42;-1:-1:-1::0;;;;;14268:28:16;::::1;14297:3:::0;14302:7;14268:28:::1;:42::i;:::-;14326:29;::::0;;;;;;;14341:4;;-1:-1:-1;;;;;14326:29:16;::::1;::::0;::::1;::::0;;;;::::1;::::0;;::::1;-1:-1:-1::0;;1645:1:8;2580:7;:22;-1:-1:-1;;;;;;;13325:1037:16:o;885:203:5:-;1012:68;;;-1:-1:-1;;;;;1012:68:5;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;1012:68:5;-1:-1:-1;;;1012:68:5;;;985:96;;1005:5;;985:19;:96::i;:::-;885:203;;;;:::o;1348:613::-;1713:10;;;1712:62;;-1:-1:-1;1729:39:5;;;-1:-1:-1;;;1729:39:5;;1753:4;1729:39;;;;-1:-1:-1;;;;;1729:39:5;;;;;;;;;:15;;;;;;:39;;;;;;;;;;;;;;;:15;:39;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1729:39:5;:44;1712:62;1704:150;;;;-1:-1:-1;;;1704:150:5;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1891:62;;;-1:-1:-1;;;;;1891:62:5;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;1891:62:5;-1:-1:-1;;;1891:62:5;;;1864:90;;1884:5;;1864:19;:90::i;2690:175:1:-;2748:7;2779:5;;;2802:6;;;;2794:46;;;;;-1:-1:-1;;;2794:46:1;;;;;;;;;;;;;;;;;;;;;;;;;;;16571:2692:16;16657:21;16681:8;16690:4;16681:14;;;;;;;;;;;;;;;;;;;;;16713:13;;;;16681:14;;-1:-1:-1;;;;16713:13:16;;;;:22;16705:49;;;;;-1:-1:-1;;;16705:49:16;;;;;;;;;;;;-1:-1:-1;;;16705:49:16;;;;;;;;;;;;;;;16976:3;;16969:36;;;-1:-1:-1;;;16969:36:16;;16999:4;16969:36;;;;;;16765:14;;;;-1:-1:-1;;;;;16976:3:16;;;;16969:21;;:36;;;;;;;;;;;;;;;16976:3;16969:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;16969:36:16;17050:3;;17043:29;;;-1:-1:-1;;;17043:29:16;;-1:-1:-1;;;;;17065:6:16;17043:29;;;;;;;;16969:36;;-1:-1:-1;;;17050:3:16;;;;;17043:21;;:29;;;;;16969:36;;17043:29;;;;;;;17050:3;17043:29;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;17043:29:16;;-1:-1:-1;17086:20:16;17109:32;:13;17043:29;17109:17;:32::i;:::-;17205:10;;;;17180:36;;;-1:-1:-1;;;17180:36:16;;-1:-1:-1;;;;;17205:10:16;;;17180:36;;;;;;17086:55;;-1:-1:-1;17188:6:16;17180:24;;;;;;:36;;;;;;;;;;;;;;;-1:-1:-1;17180:24:16;:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;17286:3:16;;17279:36;;;-1:-1:-1;;;17279:36:16;;17309:4;17279:36;;;;;;17257:19;;-1:-1:-1;;;;;17286:3:16;;17279:21;;:36;;;;;17180;;17279;;;;;;;17286:3;17279:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;17279:36:16;;-1:-1:-1;17338:29:16;17279:36;17354:12;17338:15;:29::i;:::-;17329:38;;17401:1;17386:12;:16;:42;;;;-1:-1:-1;17406:8:16;;-1:-1:-1;;;;;17406:8:16;:22;;17386:42;17382:129;;;17473:8;;;17455:3;17448:48;;-1:-1:-1;;;;;17455:3:16;;;;17473:8;17483:12;17448:24;:48::i;:::-;-1:-1:-1;;;;17590:10:16;;;;-1:-1:-1;;;;;17590:10:16;17614:19;;17610:190;;17690:5;-1:-1:-1;;;;;17683:26:16;;:28;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;17761:28:16;;;-1:-1:-1;;;17761:28:16;;;;-1:-1:-1;;;;;17761:26:16;;;;;:28;;;;;17683;;17761;;;;;;;;:26;:28;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;17610:190:16;17814:10;;17810:1447;;17886:22;17911:46;1239:5;17911:25;17922:13;;17911:6;:10;;:25;;;;:::i;:::-;:29;;:46::i;:::-;17886:71;;18016:24;18043:48;1239:5;18043:27;18054:15;;18043:6;:10;;:27;;;;:::i;:48::-;18016:75;;18160:22;18185:49;1239:5;18185:28;18196:16;;18185:6;:10;;:28;;;;:::i;:49::-;18160:74;;18283:26;18312:44;1239:5;18312:23;18323:11;;18312:6;:10;;:23;;;;:::i;:44::-;18283:73;-1:-1:-1;18371:23:16;18397:60;18283:73;18397:36;:14;18416:16;18397:18;:36::i;:60::-;18371:86;-1:-1:-1;18526:47:16;18558:14;18526:27;:6;18371:86;18526:10;:27::i;:::-;:31;;:47::i;:::-;18637:3;;18517:56;;-1:-1:-1;18630:52:16;;-1:-1:-1;;;;;18637:3:16;18655:10;18667:14;18630:24;:52::i;:::-;18776:15;;;;;18812:3;-1:-1:-1;;;;;18776:15:16;;;;18805:48;;18812:3;18776:15;18846:6;18805:24;:48::i;:::-;18876:14;-1:-1:-1;;;;;18867:40:16;;18908:6;18867:48;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;19015:7:16;;;18997:3;18990:50;;-1:-1:-1;;;;;;18997:3:16;;;;-1:-1:-1;19015:7:16;19024:15;18990:24;:50::i;:::-;19067:7;;19054:192;;;-1:-1:-1;;;19054:192:16;;19129:10;19054:192;;;;;;;;;;;;;;;;-1:-1:-1;;;;;19054:192:16;;;;;;;;;19067:7;;;;;19054:37;;19100:9;;19054:192;;;;;19067:7;;19054:192;;;;;;;;19100:9;19067:7;19054:192;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;17810:1447;;;;;;;16571:2692;;;;;:::o;704:175:5:-;813:58;;;-1:-1:-1;;;;;813:58:5;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;813:58:5;-1:-1:-1;;;813:58:5;;;786:86;;806:5;;2967:751;3386:23;3412:69;3440:4;3412:69;;;;;;;;;;;;;;;;;3420:5;-1:-1:-1;;;;;3412:27:5;;;:69;;;;;:::i;:::-;3495:17;;3386:95;;-1:-1:-1;3495:21:5;3491:221;;3635:10;3624:30;;;;;;;;;;;;;;;-1:-1:-1;3624:30:5;3616:85;;;;-1:-1:-1;;;3616:85:5;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3136:155:1;3194:7;3226:1;3221;:6;;3213:49;;;;;-1:-1:-1;;;3213:49:1;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;3279:5:1;;;3136:155::o;3538:215::-;3596:7;3619:6;3615:20;;-1:-1:-1;3634:1:1;3627:8;;3615:20;3657:5;;;3661:1;3657;:5;:1;3680:5;;;;;:10;3672:56;;;;-1:-1:-1;;;3672:56:1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4217:150;4275:7;4306:1;4302;:5;4294:44;;;;;-1:-1:-1;;;4294:44:1;;;;;;;;;;;;;;;;;;;;;;;;;;;;4359:1;4355;:5;;;;;;;4217:150;-1:-1:-1;;;4217:150:1:o;3581:193:6:-;3684:12;3715:52;3737:6;3745:4;3751:1;3754:12;3715:21;:52::i;:::-;3708:59;3581:193;-1:-1:-1;;;;3581:193:6:o;4608:523::-;4735:12;4792:5;4767:21;:30;;4759:81;;;;-1:-1:-1;;;4759:81:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4858:18;4869:6;4858:10;:18::i;:::-;4850:60;;;;;-1:-1:-1;;;4850:60:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;4981:12;4995:23;5022:6;-1:-1:-1;;;;;5022:11:6;5042:5;5050:4;5022:33;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;5022:33:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4980:75;;;;5072:52;5090:7;5099:10;5111:12;5072:17;:52::i;:::-;5065:59;4608:523;-1:-1:-1;;;;;;;4608:523:6:o;726:413::-;1086:20;1124:8;;;726:413::o;7091:725::-;7206:12;7234:7;7230:580;;;-1:-1:-1;7264:10:6;7257:17;;7230:580;7375:17;;:21;7371:429;;7633:10;7627:17;7693:15;7680:10;7676:2;7672:19;7665:44;7582:145;7772:12;7765:20;;-1:-1:-1;;;7765:20:6;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Swarm Source
ipfs://73195a7ec07ff9bb53a3f7360471631febb71777b1e718191199665b1b72081e
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.