Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- RewardTracker
- Optimization enabled
- true
- Compiler version
- v0.6.12+commit.27d51765
- Optimization runs
- 15
- Verified at
- 2023-07-05T00:33:15.345159Z
Constructor Arguments
0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000135374616b6564202b20426f6e7573204b494e4700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000673624b494e470000000000000000000000000000000000000000000000000000
Arg [0] (string) : Staked + Bonus KING
Arg [1] (string) : sbKING
contracts/staking/RewardTracker.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; import "../libraries/math/SafeMath.sol"; import "../libraries/token/IERC20.sol"; import "../libraries/token/SafeERC20.sol"; import "../libraries/utils/ReentrancyGuard.sol"; import "./interfaces/IRewardDistributor.sol"; import "./interfaces/IRewardTracker.sol"; import "../access/Governable.sol"; contract RewardTracker is IERC20, ReentrancyGuard, IRewardTracker, Governable { using SafeMath for uint256; using SafeERC20 for IERC20; uint256 public constant BASIS_POINTS_DIVISOR = 10000; uint256 public constant PRECISION = 1e30; uint8 public constant decimals = 18; bool public isInitialized; string public name; string public symbol; address public distributor; mapping (address => bool) public isDepositToken; mapping (address => mapping (address => uint256)) public override depositBalances; mapping (address => uint256) public totalDepositSupply; uint256 public override totalSupply; mapping (address => uint256) public balances; mapping (address => mapping (address => uint256)) public allowances; uint256 public cumulativeRewardPerToken; mapping (address => uint256) public override stakedAmounts; mapping (address => uint256) public claimableReward; mapping (address => uint256) public previousCumulatedRewardPerToken; mapping (address => uint256) public override cumulativeRewards; mapping (address => uint256) public override averageStakedAmounts; bool public inPrivateTransferMode; bool public inPrivateStakingMode; bool public inPrivateClaimingMode; mapping (address => bool) public isHandler; event Claim(address receiver, uint256 amount); constructor(string memory _name, string memory _symbol) public { name = _name; symbol = _symbol; } function initialize( address[] memory _depositTokens, address _distributor ) external onlyGov { require(!isInitialized, "RewardTracker: already initialized"); isInitialized = true; for (uint256 i = 0; i < _depositTokens.length; i++) { address depositToken = _depositTokens[i]; isDepositToken[depositToken] = true; } distributor = _distributor; } function setDepositToken(address _depositToken, bool _isDepositToken) external onlyGov { isDepositToken[_depositToken] = _isDepositToken; } function setInPrivateTransferMode(bool _inPrivateTransferMode) external onlyGov { inPrivateTransferMode = _inPrivateTransferMode; } function setInPrivateStakingMode(bool _inPrivateStakingMode) external onlyGov { inPrivateStakingMode = _inPrivateStakingMode; } function setInPrivateClaimingMode(bool _inPrivateClaimingMode) external onlyGov { inPrivateClaimingMode = _inPrivateClaimingMode; } function setHandler(address _handler, bool _isActive) external onlyGov { isHandler[_handler] = _isActive; } // to help users who accidentally send their tokens to this contract function withdrawToken(address _token, address _account, uint256 _amount) external onlyGov { IERC20(_token).safeTransfer(_account, _amount); } function balanceOf(address _account) external view override returns (uint256) { return balances[_account]; } function stake(address _depositToken, uint256 _amount) external override nonReentrant { if (inPrivateStakingMode) { revert("RewardTracker: action not enabled"); } _stake(msg.sender, msg.sender, _depositToken, _amount); } function stakeForAccount(address _fundingAccount, address _account, address _depositToken, uint256 _amount) external override nonReentrant { _validateHandler(); _stake(_fundingAccount, _account, _depositToken, _amount); } function unstake(address _depositToken, uint256 _amount) external override nonReentrant { if (inPrivateStakingMode) { revert("RewardTracker: action not enabled"); } _unstake(msg.sender, _depositToken, _amount, msg.sender); } function unstakeForAccount(address _account, address _depositToken, uint256 _amount, address _receiver) external override nonReentrant { _validateHandler(); _unstake(_account, _depositToken, _amount, _receiver); } function transfer(address _recipient, uint256 _amount) external override returns (bool) { _transfer(msg.sender, _recipient, _amount); return true; } function allowance(address _owner, address _spender) external view override returns (uint256) { return allowances[_owner][_spender]; } function approve(address _spender, uint256 _amount) external override returns (bool) { _approve(msg.sender, _spender, _amount); return true; } function transferFrom(address _sender, address _recipient, uint256 _amount) external override returns (bool) { if (isHandler[msg.sender]) { _transfer(_sender, _recipient, _amount); return true; } uint256 nextAllowance = allowances[_sender][msg.sender].sub(_amount, "RewardTracker: transfer amount exceeds allowance"); _approve(_sender, msg.sender, nextAllowance); _transfer(_sender, _recipient, _amount); return true; } function tokensPerInterval() external override view returns (uint256) { return IRewardDistributor(distributor).tokensPerInterval(); } function updateRewards() external override nonReentrant { _updateRewards(address(0)); } function claim(address _receiver) external override nonReentrant returns (uint256) { if (inPrivateClaimingMode) { revert("RewardTracker: action not enabled"); } return _claim(msg.sender, _receiver); } function claimForAccount(address _account, address _receiver) external override nonReentrant returns (uint256) { _validateHandler(); return _claim(_account, _receiver); } function claimable(address _account) public override view returns (uint256) { uint256 stakedAmount = stakedAmounts[_account]; if (stakedAmount == 0) { return claimableReward[_account]; } uint256 supply = totalSupply; uint256 pendingRewards = IRewardDistributor(distributor).pendingRewards().mul(PRECISION); uint256 nextCumulativeRewardPerToken = cumulativeRewardPerToken.add(pendingRewards.div(supply)); return claimableReward[_account].add( stakedAmount.mul(nextCumulativeRewardPerToken.sub(previousCumulatedRewardPerToken[_account])).div(PRECISION)); } function rewardToken() public view returns (address) { return IRewardDistributor(distributor).rewardToken(); } function _claim(address _account, address _receiver) private returns (uint256) { _updateRewards(_account); uint256 tokenAmount = claimableReward[_account]; claimableReward[_account] = 0; if (tokenAmount > 0) { IERC20(rewardToken()).safeTransfer(_receiver, tokenAmount); emit Claim(_account, tokenAmount); } return tokenAmount; } function _mint(address _account, uint256 _amount) internal { require(_account != address(0), "RewardTracker: mint to the zero address"); totalSupply = totalSupply.add(_amount); balances[_account] = balances[_account].add(_amount); emit Transfer(address(0), _account, _amount); } function _burn(address _account, uint256 _amount) internal { require(_account != address(0), "RewardTracker: burn from the zero address"); balances[_account] = balances[_account].sub(_amount, "RewardTracker: burn amount exceeds balance"); totalSupply = totalSupply.sub(_amount); emit Transfer(_account, address(0), _amount); } function _transfer(address _sender, address _recipient, uint256 _amount) private { require(_sender != address(0), "RewardTracker: transfer from the zero address"); require(_recipient != address(0), "RewardTracker: transfer to the zero address"); if (inPrivateTransferMode) { _validateHandler(); } balances[_sender] = balances[_sender].sub(_amount, "RewardTracker: transfer amount exceeds balance"); balances[_recipient] = balances[_recipient].add(_amount); emit Transfer(_sender, _recipient,_amount); } function _approve(address _owner, address _spender, uint256 _amount) private { require(_owner != address(0), "RewardTracker: approve from the zero address"); require(_spender != address(0), "RewardTracker: approve to the zero address"); allowances[_owner][_spender] = _amount; emit Approval(_owner, _spender, _amount); } function _validateHandler() private view { require(isHandler[msg.sender], "RewardTracker: forbidden"); } function _stake(address _fundingAccount, address _account, address _depositToken, uint256 _amount) private { require(_amount > 0, "RewardTracker: invalid _amount"); require(isDepositToken[_depositToken], "RewardTracker: invalid _depositToken"); IERC20(_depositToken).safeTransferFrom(_fundingAccount, address(this), _amount); _updateRewards(_account); stakedAmounts[_account] = stakedAmounts[_account].add(_amount); depositBalances[_account][_depositToken] = depositBalances[_account][_depositToken].add(_amount); totalDepositSupply[_depositToken] = totalDepositSupply[_depositToken].add(_amount); _mint(_account, _amount); } function _unstake(address _account, address _depositToken, uint256 _amount, address _receiver) private { require(_amount > 0, "RewardTracker: invalid _amount"); require(isDepositToken[_depositToken], "RewardTracker: invalid _depositToken"); _updateRewards(_account); uint256 stakedAmount = stakedAmounts[_account]; require(stakedAmounts[_account] >= _amount, "RewardTracker: _amount exceeds stakedAmount"); stakedAmounts[_account] = stakedAmount.sub(_amount); uint256 depositBalance = depositBalances[_account][_depositToken]; require(depositBalance >= _amount, "RewardTracker: _amount exceeds depositBalance"); depositBalances[_account][_depositToken] = depositBalance.sub(_amount); totalDepositSupply[_depositToken] = totalDepositSupply[_depositToken].sub(_amount); _burn(_account, _amount); IERC20(_depositToken).safeTransfer(_receiver, _amount); } function _updateRewards(address _account) private { uint256 blockReward = IRewardDistributor(distributor).distribute(); uint256 supply = totalSupply; uint256 _cumulativeRewardPerToken = cumulativeRewardPerToken; if (supply > 0 && blockReward > 0) { _cumulativeRewardPerToken = _cumulativeRewardPerToken.add(blockReward.mul(PRECISION).div(supply)); cumulativeRewardPerToken = _cumulativeRewardPerToken; } // cumulativeRewardPerToken can only increase // so if cumulativeRewardPerToken is zero, it means there are no rewards yet if (_cumulativeRewardPerToken == 0) { return; } if (_account != address(0)) { uint256 stakedAmount = stakedAmounts[_account]; uint256 accountReward = stakedAmount.mul(_cumulativeRewardPerToken.sub(previousCumulatedRewardPerToken[_account])).div(PRECISION); uint256 _claimableReward = claimableReward[_account].add(accountReward); claimableReward[_account] = _claimableReward; previousCumulatedRewardPerToken[_account] = _cumulativeRewardPerToken; if (_claimableReward > 0 && stakedAmounts[_account] > 0) { uint256 nextCumulativeReward = cumulativeRewards[_account].add(accountReward); averageStakedAmounts[_account] = averageStakedAmounts[_account].mul(cumulativeRewards[_account]).div(nextCumulativeReward) .add(stakedAmount.mul(accountReward).div(nextCumulativeReward)); cumulativeRewards[_account] = nextCumulativeReward; } } } }
contracts/access/Governable.sol
// SPDX-License-Identifier: MIT pragma solidity >=0.6.12; contract Governable { address public gov; constructor() public { gov = msg.sender; } modifier onlyGov() { require(msg.sender == gov, "Governable: forbidden"); _; } function setGov(address _gov) external onlyGov { gov = _gov; } }
contracts/staking/interfaces/IRewardTracker.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; interface IRewardTracker { function depositBalances(address _account, address _depositToken) external view returns (uint256); function stakedAmounts(address _account) external view returns (uint256); function updateRewards() external; function stake(address _depositToken, uint256 _amount) external; function stakeForAccount(address _fundingAccount, address _account, address _depositToken, uint256 _amount) external; function unstake(address _depositToken, uint256 _amount) external; function unstakeForAccount(address _account, address _depositToken, uint256 _amount, address _receiver) external; function tokensPerInterval() external view returns (uint256); function claim(address _receiver) external returns (uint256); function claimForAccount(address _account, address _receiver) external returns (uint256); function claimable(address _account) external view returns (uint256); function averageStakedAmounts(address _account) external view returns (uint256); function cumulativeRewards(address _account) external view returns (uint256); }
contracts/libraries/math/SafeMath.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @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, 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) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * 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); uint256 c = a - b; return c; } /** * @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) { // 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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
contracts/libraries/token/IERC20.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @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); }
contracts/libraries/token/SafeERC20.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; 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"); } } }
contracts/libraries/utils/Address.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.6.2; /** * @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.3._ */ 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.3._ */ 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); } } } }
contracts/libraries/utils/ReentrancyGuard.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @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]. */ 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; } }
contracts/staking/interfaces/IRewardDistributor.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; interface IRewardDistributor { function rewardToken() external view returns (address); function tokensPerInterval() external view returns (uint256); function pendingRewards() external view returns (uint256); function distribute() external returns (uint256); }
contracts/access/Governable.sol
// SPDX-License-Identifier: MIT pragma solidity >=0.6.12; contract Governable { address public gov; constructor() public { gov = msg.sender; } modifier onlyGov() { require(msg.sender == gov, "Governable: forbidden"); _; } function setGov(address _gov) external onlyGov { gov = _gov; } }
contracts/staking/interfaces/IRewardTracker.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; interface IRewardTracker { function depositBalances(address _account, address _depositToken) external view returns (uint256); function stakedAmounts(address _account) external view returns (uint256); function updateRewards() external; function stake(address _depositToken, uint256 _amount) external; function stakeForAccount(address _fundingAccount, address _account, address _depositToken, uint256 _amount) external; function unstake(address _depositToken, uint256 _amount) external; function unstakeForAccount(address _account, address _depositToken, uint256 _amount, address _receiver) external; function tokensPerInterval() external view returns (uint256); function claim(address _receiver) external returns (uint256); function claimForAccount(address _account, address _receiver) external returns (uint256); function claimable(address _account) external view returns (uint256); function averageStakedAmounts(address _account) external view returns (uint256); function cumulativeRewards(address _account) external view returns (uint256); }
contracts/libraries/math/SafeMath.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @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, 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) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * 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); uint256 c = a - b; return c; } /** * @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) { // 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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
contracts/libraries/token/IERC20.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @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); }
contracts/libraries/token/SafeERC20.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; 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"); } } }
contracts/libraries/utils/Address.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.6.2; /** * @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.3._ */ 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.3._ */ 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); } } } }
contracts/libraries/utils/ReentrancyGuard.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @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]. */ 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; } }
contracts/staking/interfaces/IRewardDistributor.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; interface IRewardDistributor { function rewardToken() external view returns (address); function tokensPerInterval() external view returns (uint256); function pendingRewards() external view returns (uint256); function distribute() external returns (uint256); }
contracts/access/Governable.sol
// SPDX-License-Identifier: MIT pragma solidity >=0.6.12; contract Governable { address public gov; constructor() public { gov = msg.sender; } modifier onlyGov() { require(msg.sender == gov, "Governable: forbidden"); _; } function setGov(address _gov) external onlyGov { gov = _gov; } }
contracts/staking/interfaces/IRewardTracker.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; interface IRewardTracker { function depositBalances(address _account, address _depositToken) external view returns (uint256); function stakedAmounts(address _account) external view returns (uint256); function updateRewards() external; function stake(address _depositToken, uint256 _amount) external; function stakeForAccount(address _fundingAccount, address _account, address _depositToken, uint256 _amount) external; function unstake(address _depositToken, uint256 _amount) external; function unstakeForAccount(address _account, address _depositToken, uint256 _amount, address _receiver) external; function tokensPerInterval() external view returns (uint256); function claim(address _receiver) external returns (uint256); function claimForAccount(address _account, address _receiver) external returns (uint256); function claimable(address _account) external view returns (uint256); function averageStakedAmounts(address _account) external view returns (uint256); function cumulativeRewards(address _account) external view returns (uint256); }
contracts/libraries/math/SafeMath.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @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, 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) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * 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); uint256 c = a - b; return c; } /** * @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) { // 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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
contracts/libraries/token/IERC20.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @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); }
contracts/libraries/token/SafeERC20.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; 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"); } } }
contracts/libraries/utils/Address.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.6.2; /** * @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.3._ */ 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.3._ */ 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); } } } }
contracts/libraries/utils/ReentrancyGuard.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @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]. */ 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; } }
contracts/staking/interfaces/IRewardDistributor.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; interface IRewardDistributor { function rewardToken() external view returns (address); function tokensPerInterval() external view returns (uint256); function pendingRewards() external view returns (uint256); function distribute() external returns (uint256); }
contracts/access/Governable.sol
// SPDX-License-Identifier: MIT pragma solidity >=0.6.12; contract Governable { address public gov; constructor() public { gov = msg.sender; } modifier onlyGov() { require(msg.sender == gov, "Governable: forbidden"); _; } function setGov(address _gov) external onlyGov { gov = _gov; } }
contracts/staking/interfaces/IRewardTracker.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; interface IRewardTracker { function depositBalances(address _account, address _depositToken) external view returns (uint256); function stakedAmounts(address _account) external view returns (uint256); function updateRewards() external; function stake(address _depositToken, uint256 _amount) external; function stakeForAccount(address _fundingAccount, address _account, address _depositToken, uint256 _amount) external; function unstake(address _depositToken, uint256 _amount) external; function unstakeForAccount(address _account, address _depositToken, uint256 _amount, address _receiver) external; function tokensPerInterval() external view returns (uint256); function claim(address _receiver) external returns (uint256); function claimForAccount(address _account, address _receiver) external returns (uint256); function claimable(address _account) external view returns (uint256); function averageStakedAmounts(address _account) external view returns (uint256); function cumulativeRewards(address _account) external view returns (uint256); }
contracts/libraries/math/SafeMath.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @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, 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) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * 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); uint256 c = a - b; return c; } /** * @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) { // 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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
contracts/libraries/token/IERC20.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @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); }
contracts/libraries/token/SafeERC20.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; 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"); } } }
contracts/libraries/utils/Address.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.6.2; /** * @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.3._ */ 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.3._ */ 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); } } } }
contracts/libraries/utils/ReentrancyGuard.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @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]. */ 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; } }
contracts/staking/interfaces/IRewardDistributor.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; interface IRewardDistributor { function rewardToken() external view returns (address); function tokensPerInterval() external view returns (uint256); function pendingRewards() external view returns (uint256); function distribute() external returns (uint256); }
contracts/access/Governable.sol
// SPDX-License-Identifier: MIT pragma solidity >=0.6.12; contract Governable { address public gov; constructor() public { gov = msg.sender; } modifier onlyGov() { require(msg.sender == gov, "Governable: forbidden"); _; } function setGov(address _gov) external onlyGov { gov = _gov; } }
contracts/staking/interfaces/IRewardTracker.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; interface IRewardTracker { function depositBalances(address _account, address _depositToken) external view returns (uint256); function stakedAmounts(address _account) external view returns (uint256); function updateRewards() external; function stake(address _depositToken, uint256 _amount) external; function stakeForAccount(address _fundingAccount, address _account, address _depositToken, uint256 _amount) external; function unstake(address _depositToken, uint256 _amount) external; function unstakeForAccount(address _account, address _depositToken, uint256 _amount, address _receiver) external; function tokensPerInterval() external view returns (uint256); function claim(address _receiver) external returns (uint256); function claimForAccount(address _account, address _receiver) external returns (uint256); function claimable(address _account) external view returns (uint256); function averageStakedAmounts(address _account) external view returns (uint256); function cumulativeRewards(address _account) external view returns (uint256); }
contracts/libraries/math/SafeMath.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @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, 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) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * 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); uint256 c = a - b; return c; } /** * @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) { // 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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
contracts/libraries/token/IERC20.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @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); }
contracts/libraries/token/SafeERC20.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; 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"); } } }
contracts/libraries/utils/Address.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.6.2; /** * @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.3._ */ 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.3._ */ 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); } } } }
contracts/libraries/utils/ReentrancyGuard.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @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]. */ 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; } }
contracts/staking/interfaces/IRewardDistributor.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; interface IRewardDistributor { function rewardToken() external view returns (address); function tokensPerInterval() external view returns (uint256); function pendingRewards() external view returns (uint256); function distribute() external returns (uint256); }
contracts/access/Governable.sol
// SPDX-License-Identifier: MIT pragma solidity >=0.6.12; contract Governable { address public gov; constructor() public { gov = msg.sender; } modifier onlyGov() { require(msg.sender == gov, "Governable: forbidden"); _; } function setGov(address _gov) external onlyGov { gov = _gov; } }
contracts/staking/interfaces/IRewardTracker.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; interface IRewardTracker { function depositBalances(address _account, address _depositToken) external view returns (uint256); function stakedAmounts(address _account) external view returns (uint256); function updateRewards() external; function stake(address _depositToken, uint256 _amount) external; function stakeForAccount(address _fundingAccount, address _account, address _depositToken, uint256 _amount) external; function unstake(address _depositToken, uint256 _amount) external; function unstakeForAccount(address _account, address _depositToken, uint256 _amount, address _receiver) external; function tokensPerInterval() external view returns (uint256); function claim(address _receiver) external returns (uint256); function claimForAccount(address _account, address _receiver) external returns (uint256); function claimable(address _account) external view returns (uint256); function averageStakedAmounts(address _account) external view returns (uint256); function cumulativeRewards(address _account) external view returns (uint256); }
contracts/libraries/math/SafeMath.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @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, 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) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * 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); uint256 c = a - b; return c; } /** * @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) { // 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 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts 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) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts 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) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
contracts/libraries/token/IERC20.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @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); }
contracts/libraries/token/SafeERC20.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; 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"); } } }
contracts/libraries/utils/Address.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.6.2; /** * @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.3._ */ 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.3._ */ 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); } } } }
contracts/libraries/utils/ReentrancyGuard.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; /** * @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]. */ 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; } }
contracts/staking/interfaces/IRewardDistributor.sol
// SPDX-License-Identifier: MIT pragma solidity 0.6.12; interface IRewardDistributor { function rewardToken() external view returns (address); function tokensPerInterval() external view returns (uint256); function pendingRewards() external view returns (uint256); function distribute() external returns (uint256); }
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"string","name":"_name","internalType":"string"},{"type":"string","name":"_symbol","internalType":"string"}]},{"type":"event","name":"Approval","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"address","name":"spender","internalType":"address","indexed":true},{"type":"uint256","name":"value","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Claim","inputs":[{"type":"address","name":"receiver","internalType":"address","indexed":false},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Transfer","inputs":[{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256","name":"value","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"BASIS_POINTS_DIVISOR","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"PRECISION","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"allowance","inputs":[{"type":"address","name":"_owner","internalType":"address"},{"type":"address","name":"_spender","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"allowances","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"approve","inputs":[{"type":"address","name":"_spender","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"averageStakedAmounts","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balanceOf","inputs":[{"type":"address","name":"_account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balances","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"claim","inputs":[{"type":"address","name":"_receiver","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"claimForAccount","inputs":[{"type":"address","name":"_account","internalType":"address"},{"type":"address","name":"_receiver","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"claimable","inputs":[{"type":"address","name":"_account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"claimableReward","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"cumulativeRewardPerToken","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"cumulativeRewards","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint8","name":"","internalType":"uint8"}],"name":"decimals","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"depositBalances","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"distributor","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"gov","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"inPrivateClaimingMode","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"inPrivateStakingMode","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"inPrivateTransferMode","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address[]","name":"_depositTokens","internalType":"address[]"},{"type":"address","name":"_distributor","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isDepositToken","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isHandler","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isInitialized","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"name","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"previousCumulatedRewardPerToken","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"rewardToken","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setDepositToken","inputs":[{"type":"address","name":"_depositToken","internalType":"address"},{"type":"bool","name":"_isDepositToken","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setGov","inputs":[{"type":"address","name":"_gov","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setHandler","inputs":[{"type":"address","name":"_handler","internalType":"address"},{"type":"bool","name":"_isActive","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setInPrivateClaimingMode","inputs":[{"type":"bool","name":"_inPrivateClaimingMode","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setInPrivateStakingMode","inputs":[{"type":"bool","name":"_inPrivateStakingMode","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setInPrivateTransferMode","inputs":[{"type":"bool","name":"_inPrivateTransferMode","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"stake","inputs":[{"type":"address","name":"_depositToken","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"stakeForAccount","inputs":[{"type":"address","name":"_fundingAccount","internalType":"address"},{"type":"address","name":"_account","internalType":"address"},{"type":"address","name":"_depositToken","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"stakedAmounts","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"symbol","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"tokensPerInterval","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalDepositSupply","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalSupply","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"transfer","inputs":[{"type":"address","name":"_recipient","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"transferFrom","inputs":[{"type":"address","name":"_sender","internalType":"address"},{"type":"address","name":"_recipient","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unstake","inputs":[{"type":"address","name":"_depositToken","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unstakeForAccount","inputs":[{"type":"address","name":"_account","internalType":"address"},{"type":"address","name":"_depositToken","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"},{"type":"address","name":"_receiver","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateRewards","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawToken","inputs":[{"type":"address","name":"_token","internalType":"address"},{"type":"address","name":"_account","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"}]}]
Contract Creation Code
0x60806040523480156200001157600080fd5b5060405162002c3b38038062002c3b833981810160405260408110156200003757600080fd5b81019080805160405193929190846401000000008211156200005857600080fd5b9083019060208201858111156200006e57600080fd5b82516401000000008111828201881017156200008957600080fd5b82525081516020918201929091019080838360005b83811015620000b85781810151838201526020016200009e565b50505050905090810190601f168015620000e65780820380516001836020036101000a031916815260200191505b50604052602001805160405193929190846401000000008211156200010a57600080fd5b9083019060208201858111156200012057600080fd5b82516401000000008111828201881017156200013b57600080fd5b82525081516020918201929091019080838360005b838110156200016a57818101518382015260200162000150565b50505050905090810190601f168015620001985780820380516001836020036101000a031916815260200191505b5060405250506001600081905580546001600160a01b03191633179055508151620001cb906002906020850190620001ea565b508051620001e1906003906020840190620001ea565b50505062000286565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106200022d57805160ff19168380011785556200025d565b828001600101855582156200025d579182015b828111156200025d57825182559160200191906001019062000240565b506200026b9291506200026f565b5090565b5b808211156200026b576000815560010162000270565b6129a580620002966000396000f3fe608060405234801561001057600080fd5b50600436106102355760003560e01c806355b6ed5c1161013757806355b6ed5c1461065d5780635a47a1a71461068b57806370a08231146106aa578063790b5a6c146106d057806395d89b411461070c5780639cb7de4b14610714578063a318021714610742578063a8d9362714610768578063a9059cbb14610770578063aaf5eb681461079c578063adc9772e146107a4578063b89e45b3146107d0578063bfe10928146107f6578063c2a672e0146107fe578063c5fa27301461082a578063cfad57a214610832578063dd62ed3e14610858578063dfbaefb114610886578063e44b75581461088e578063e9503425146108bc578063f5d9d63e146108e2578063f5fc507614610910578063f76033d314610918578063f7c618c11461092057610235565b806301e336671461023a57806306fdde0314610272578063095ea7b3146102ef578063098bf59d1461032f57806310c1c1031461036b578063126082cf146103a357806312d43a51146103ab57806313e82e7a146103cf57806318160ddd146103fd5780631d30d5bc146104055780631e83409a1461042457806323b872dd1461044a57806327e235e314610480578063313ce567146104a65780633792def3146104c4578063392e53cd146104ea5780633cd7f700146104f25780633e158b0c14610511578063402914f51461051957806344a084111461053f578063462d0b2e1461056557806346ea87af14610611578063552ce1dc14610637575b600080fd5b6102706004803603606081101561025057600080fd5b506001600160a01b03813581169160208101359091169060400135610928565b005b61027a61098e565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102b457818101518382015260200161029c565b50505050905090810190601f1680156102e15780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61031b6004803603604081101561030557600080fd5b506001600160a01b038135169060200135610a19565b604080519115158252519081900360200190f35b6102706004803603608081101561034557600080fd5b506001600160a01b03813581169160208101358216916040820135916060013516610a30565b6103916004803603602081101561038157600080fd5b50356001600160a01b0316610a9a565b60408051918252519081900360200190f35b610391610aac565b6103b3610ab2565b604080516001600160a01b039092168252519081900360200190f35b610391600480360360408110156103e557600080fd5b506001600160a01b0381358116916020013516610ac1565b610391610b2c565b6102706004803603602081101561041b57600080fd5b50351515610b32565b6103916004803603602081101561043a57600080fd5b50356001600160a01b0316610b99565b61031b6004803603606081101561046057600080fd5b506001600160a01b03813581169160208101359091169060400135610c43565b6103916004803603602081101561049657600080fd5b50356001600160a01b0316610cdd565b6104ae610cef565b6040805160ff9092168252519081900360200190f35b610391600480360360208110156104da57600080fd5b50356001600160a01b0316610cf4565b61031b610d06565b6102706004803603602081101561050857600080fd5b50351515610d16565b610270610d7f565b6103916004803603602081101561052f57600080fd5b50356001600160a01b0316610ddc565b6103916004803603602081101561055557600080fd5b50356001600160a01b0316610f3a565b6102706004803603604081101561057b57600080fd5b810190602081018135600160201b81111561059557600080fd5b8201836020820111156105a757600080fd5b803590602001918460208302840111600160201b831117156105c857600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550505090356001600160a01b03169150610f4c9050565b61031b6004803603602081101561062757600080fd5b50356001600160a01b031661106f565b6103916004803603602081101561064d57600080fd5b50356001600160a01b0316611084565b6103916004803603604081101561067357600080fd5b506001600160a01b0381358116916020013516611096565b610270600480360360208110156106a157600080fd5b503515156110b3565b610391600480360360208110156106c057600080fd5b50356001600160a01b0316611113565b610270600480360360808110156106e657600080fd5b506001600160a01b0381358116916020810135821691604082013516906060013561112e565b61027a61118d565b6102706004803603604081101561072a57600080fd5b506001600160a01b03813516906020013515156111e8565b6103916004803603602081101561075857600080fd5b50356001600160a01b0316611260565b610391611272565b61031b6004803603604081101561078657600080fd5b506001600160a01b0381351690602001356112f3565b610391611300565b610270600480360360408110156107ba57600080fd5b506001600160a01b038135169060200135611310565b61031b600480360360208110156107e657600080fd5b50356001600160a01b03166113b7565b6103b36113cc565b6102706004803603604081101561081457600080fd5b506001600160a01b0381351690602001356113db565b61031b611479565b6102706004803603602081101561084857600080fd5b50356001600160a01b0316611487565b6103916004803603604081101561086e57600080fd5b506001600160a01b03813581169160200135166114f6565b61031b611521565b610270600480360360408110156108a457600080fd5b506001600160a01b038135169060200135151561152a565b610391600480360360208110156108d257600080fd5b50356001600160a01b03166115a2565b610391600480360360408110156108f857600080fd5b506001600160a01b03813581169160200135166115b4565b6103916115d1565b61031b6115d7565b6103b36115e6565b6001546001600160a01b03163314610975576040805162461bcd60e51b81526020600482015260156024820152600080516020612724833981519152604482015290519081900360640190fd5b6109896001600160a01b0384168383611636565b505050565b6002805460408051602060018416156101000260001901909316849004601f81018490048402820184019092528181529291830182828015610a115780601f106109e657610100808354040283529160200191610a11565b820191906000526020600020905b8154815290600101906020018083116109f457829003601f168201915b505050505081565b6000610a26338484611688565b5060015b92915050565b60026000541415610a76576040805162461bcd60e51b815260206004820152601f6024820152600080516020612684833981519152604482015290519081900360640190fd5b6002600055610a83611774565b610a8f848484846117d5565b505060016000555050565b600c6020526000908152604090205481565b61271081565b6001546001600160a01b031681565b600060026000541415610b09576040805162461bcd60e51b815260206004820152601f6024820152600080516020612684833981519152604482015290519081900360640190fd5b6002600055610b16611774565b610b2083836119e3565b60016000559392505050565b60085481565b6001546001600160a01b03163314610b7f576040805162461bcd60e51b81526020600482015260156024820152600080516020612724833981519152604482015290519081900360640190fd5b601180549115156101000261ff0019909216919091179055565b600060026000541415610be1576040805162461bcd60e51b815260206004820152601f6024820152600080516020612684833981519152604482015290519081900360640190fd5b600260005560115462010000900460ff1615610c2e5760405162461bcd60e51b81526004018080602001828103825260218152602001806128f46021913960400191505060405180910390fd5b610c3833836119e3565b600160005592915050565b3360009081526012602052604081205460ff1615610c6e57610c66848484611a79565b506001610cd6565b6000610cb88360405180606001604052806030815260200161289a603091396001600160a01b0388166000908152600a602090815260408083203384529091529020549190611bcc565b9050610cc5853383611688565b610cd0858585611a79565b60019150505b9392505050565b60096020526000908152604090205481565b601281565b600f6020526000908152604090205481565b600154600160a01b900460ff1681565b6001546001600160a01b03163314610d63576040805162461bcd60e51b81526020600482015260156024820152600080516020612724833981519152604482015290519081900360640190fd5b60118054911515620100000262ff000019909216919091179055565b60026000541415610dc5576040805162461bcd60e51b815260206004820152601f6024820152600080516020612684833981519152604482015290519081900360640190fd5b60026000908155610dd590611c63565b6001600055565b6001600160a01b0381166000908152600c602052604081205480610e1a5750506001600160a01b0381166000908152600d6020526040902054610f35565b60085460048054604080516376f69fed60e11b81529051600093610ea79368327cb2734119d3b7a9601e1b936001600160a01b039091169263eded3fda92828101926020929190829003018186803b158015610e7557600080fd5b505afa158015610e89573d6000803e3d6000fd5b505050506040513d6020811015610e9f57600080fd5b505190611eb3565b90506000610ec1610eb88385611f0c565b600b5490611f4b565b6001600160a01b0387166000908152600e6020526040902054909150610f2e90610f0f9068327cb2734119d3b7a9601e1b90610f0990610f02908690611fa3565b8890611eb3565b90611f0c565b6001600160a01b0388166000908152600d602052604090205490611f4b565b9450505050505b919050565b600e6020526000908152604090205481565b6001546001600160a01b03163314610f99576040805162461bcd60e51b81526020600482015260156024820152600080516020612724833981519152604482015290519081900360640190fd5b600154600160a01b900460ff1615610fe25760405162461bcd60e51b81526004018080602001828103825260228152602001806128046022913960400191505060405180910390fd5b6001805460ff60a01b1916600160a01b17905560005b825181101561104b57600083828151811061100f57fe5b6020908102919091018101516001600160a01b03166000908152600590915260409020805460ff19166001908117909155919091019050610ff8565b50600480546001600160a01b0319166001600160a01b039290921691909117905550565b60126020526000908152604090205460ff1681565b60076020526000908152604090205481565b600a60209081526000928352604080842090915290825290205481565b6001546001600160a01b03163314611100576040805162461bcd60e51b81526020600482015260156024820152600080516020612724833981519152604482015290519081900360640190fd5b6011805460ff1916911515919091179055565b6001600160a01b031660009081526009602052604090205490565b60026000541415611174576040805162461bcd60e51b815260206004820152601f6024820152600080516020612684833981519152604482015290519081900360640190fd5b6002600055611181611774565b610a8f84848484611fe5565b6003805460408051602060026001851615610100026000190190941693909304601f81018490048402820184019092528181529291830182828015610a115780601f106109e657610100808354040283529160200191610a11565b6001546001600160a01b03163314611235576040805162461bcd60e51b81526020600482015260156024820152600080516020612724833981519152604482015290519081900360640190fd5b6001600160a01b03919091166000908152601260205260409020805460ff1916911515919091179055565b60106020526000908152604090205481565b6000600460009054906101000a90046001600160a01b03166001600160a01b031663a8d936276040518163ffffffff1660e01b815260040160206040518083038186803b1580156112c257600080fd5b505afa1580156112d6573d6000803e3d6000fd5b505050506040513d60208110156112ec57600080fd5b5051905090565b6000610a26338484611a79565b68327cb2734119d3b7a9601e1b81565b60026000541415611356576040805162461bcd60e51b815260206004820152601f6024820152600080516020612684833981519152604482015290519081900360640190fd5b6002600055601154610100900460ff16156113a25760405162461bcd60e51b81526004018080602001828103825260218152602001806128f46021913960400191505060405180910390fd5b6113ae33338484611fe5565b50506001600055565b60056020526000908152604090205460ff1681565b6004546001600160a01b031681565b60026000541415611421576040805162461bcd60e51b815260206004820152601f6024820152600080516020612684833981519152604482015290519081900360640190fd5b6002600055601154610100900460ff161561146d5760405162461bcd60e51b81526004018080602001828103825260218152602001806128f46021913960400191505060405180910390fd5b6113ae338383336117d5565b601154610100900460ff1681565b6001546001600160a01b031633146114d4576040805162461bcd60e51b81526020600482015260156024820152600080516020612724833981519152604482015290519081900360640190fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b039182166000908152600a6020908152604080832093909416825291909152205490565b60115460ff1681565b6001546001600160a01b03163314611577576040805162461bcd60e51b81526020600482015260156024820152600080516020612724833981519152604482015290519081900360640190fd5b6001600160a01b03919091166000908152600560205260409020805460ff1916911515919091179055565b600d6020526000908152604090205481565b600660209081526000928352604080842090915290825290205481565b600b5481565b60115462010000900460ff1681565b6000600460009054906101000a90046001600160a01b03166001600160a01b031663f7c618c16040518163ffffffff1660e01b815260040160206040518083038186803b1580156112c257600080fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261098990849061216e565b6001600160a01b0383166116cd5760405162461bcd60e51b815260040180806020018281038252602c8152602001806126cf602c913960400191505060405180910390fd5b6001600160a01b0382166117125760405162461bcd60e51b815260040180806020018281038252602a8152602001806127b9602a913960400191505060405180910390fd5b6001600160a01b038084166000818152600a6020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b3360009081526012602052604090205460ff166117d3576040805162461bcd60e51b81526020600482015260186024820152772932bbb0b9322a3930b1b5b2b91d103337b93134b23232b760411b604482015290519081900360640190fd5b565b6000821161182a576040805162461bcd60e51b815260206004820152601e60248201527f526577617264547261636b65723a20696e76616c6964205f616d6f756e740000604482015290519081900360640190fd5b6001600160a01b03831660009081526005602052604090205460ff166118815760405162461bcd60e51b81526004018080602001828103825260248152602001806127956024913960400191505060405180910390fd5b61188a84611c63565b6001600160a01b0384166000908152600c6020526040902054828110156118e25760405162461bcd60e51b815260040180806020018281038252602b8152602001806126a4602b913960400191505060405180910390fd5b6118ec8184611fa3565b6001600160a01b038087166000908152600c60209081526040808320949094556006815283822092881682529190915220548381101561195d5760405162461bcd60e51b815260040180806020018281038252602d815260200180612915602d913960400191505060405180910390fd5b6119678185611fa3565b6001600160a01b038088166000908152600660209081526040808320938a1683529281528282209390935560079092529020546119a49085611fa3565b6001600160a01b0386166000908152600760205260409020556119c7868561221f565b6119db6001600160a01b0386168486611636565b505050505050565b60006119ee83611c63565b6001600160a01b0383166000908152600d6020526040812080549190558015610cd657611a2e8382611a1e6115e6565b6001600160a01b03169190611636565b604080516001600160a01b03861681526020810183905281517f47cee97cb7acd717b3c0aa1435d004cd5b3c8c57d70dbceb4e4458bbd60e39d4929181900390910190a19392505050565b6001600160a01b038316611abe5760405162461bcd60e51b815260040180806020018281038252602d815260200180612826602d913960400191505060405180910390fd5b6001600160a01b038216611b035760405162461bcd60e51b815260040180806020018281038252602b815260200180612744602b913960400191505060405180910390fd5b60115460ff1615611b1657611b16611774565b611b53816040518060600160405280602e8152602001612942602e91396001600160a01b0386166000908152600960205260409020549190611bcc565b6001600160a01b038085166000908152600960205260408082209390935590841681522054611b829082611f4b565b6001600160a01b03808416600081815260096020908152604091829020949094558051858152905191939287169260008051602061287a83398151915292918290030190a3505050565b60008184841115611c5b5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611c20578181015183820152602001611c08565b50505050905090810190601f168015611c4d5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000600460009054906101000a90046001600160a01b03166001600160a01b031663e4fc6b6d6040518163ffffffff1660e01b8152600401602060405180830381600087803b158015611cb557600080fd5b505af1158015611cc9573d6000803e3d6000fd5b505050506040513d6020811015611cdf57600080fd5b5051600854600b54919250908115801590611cfa5750600083115b15611d2b57611d23611d1c83610f098668327cb2734119d3b7a9601e1b611eb3565b8290611f4b565b600b81905590505b80611d3857505050611eb0565b6001600160a01b03841615611eac576001600160a01b0384166000908152600c6020908152604080832054600e909252822054909190611d969068327cb2734119d3b7a9601e1b90610f0990611d8f908790611fa3565b8590611eb3565b6001600160a01b0387166000908152600d602052604081205491925090611dbd9083611f4b565b6001600160a01b0388166000908152600d60209081526040808320849055600e909152902085905590508015801590611e0d57506001600160a01b0387166000908152600c602052604090205415155b15611ea8576001600160a01b0387166000908152600f6020526040812054611e359084611f4b565b9050611e82611e4882610f098787611eb3565b6001600160a01b038a166000908152600f6020908152604080832054601090925290912054611e7c918591610f0991611eb3565b90611f4b565b6001600160a01b038916600090815260106020908152604080832093909355600f905220555b5050505b5050505b50565b600082611ec257506000610a2a565b82820282848281611ecf57fe5b0414610cd65760405162461bcd60e51b81526004018080602001828103825260218152602001806127e36021913960400191505060405180910390fd5b6000610cd683836040518060400160405280601a815260200179536166654d6174683a206469766973696f6e206279207a65726f60301b8152506122fd565b600082820183811015610cd6576040805162461bcd60e51b815260206004820152601b60248201527a536166654d6174683a206164646974696f6e206f766572666c6f7760281b604482015290519081900360640190fd5b6000610cd683836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611bcc565b6000811161203a576040805162461bcd60e51b815260206004820152601e60248201527f526577617264547261636b65723a20696e76616c6964205f616d6f756e740000604482015290519081900360640190fd5b6001600160a01b03821660009081526005602052604090205460ff166120915760405162461bcd60e51b81526004018080602001828103825260248152602001806127956024913960400191505060405180910390fd5b6120a66001600160a01b038316853084612362565b6120af83611c63565b6001600160a01b0383166000908152600c60205260409020546120d29082611f4b565b6001600160a01b038085166000908152600c602090815260408083209490945560068152838220928616825291909152205461210e9082611f4b565b6001600160a01b038085166000908152600660209081526040808320938716835292815282822093909355600790925290205461214b9082611f4b565b6001600160a01b038316600090815260076020526040902055611eac83826123bc565b60606121c3826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661247a9092919063ffffffff16565b805190915015610989578080602001905160208110156121e257600080fd5b50516109895760405162461bcd60e51b815260040180806020018281038252602a8152602001806128ca602a913960400191505060405180910390fd5b6001600160a01b0382166122645760405162461bcd60e51b81526004018080602001828103825260298152602001806126fb6029913960400191505060405180910390fd5b6122a1816040518060600160405280602a815260200161265a602a91396001600160a01b0385166000908152600960205260409020549190611bcc565b6001600160a01b0383166000908152600960205260409020556008546122c79082611fa3565b6008556040805182815290516000916001600160a01b0385169160008051602061287a8339815191529181900360200190a35050565b6000818361234c5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315611c20578181015183820152602001611c08565b50600083858161235857fe5b0495945050505050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052611eac90859061216e565b6001600160a01b0382166124015760405162461bcd60e51b81526004018080602001828103825260278152602001806128536027913960400191505060405180910390fd5b60085461240e9082611f4b565b6008556001600160a01b0382166000908152600960205260409020546124349082611f4b565b6001600160a01b038316600081815260096020908152604080832094909455835185815293519293919260008051602061287a8339815191529281900390910190a35050565b60606124898484600085612491565b949350505050565b6060824710156124d25760405162461bcd60e51b815260040180806020018281038252602681526020018061276f6026913960400191505060405180910390fd5b6124db856125ed565b61252c576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b6020831061256b5780518252601f19909201916020918201910161254c565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146125cd576040519150601f19603f3d011682016040523d82523d6000602084013e6125d2565b606091505b50915091506125e28282866125f3565b979650505050505050565b3b151590565b60608315612602575081610cd6565b8251156126125782518084602001fd5b60405162461bcd60e51b8152602060048201818152845160248401528451859391928392604401919085019080838360008315611c20578181015183820152602001611c0856fe526577617264547261636b65723a206275726e20616d6f756e7420657863656564732062616c616e63655265656e7472616e637947756172643a207265656e7472616e742063616c6c00526577617264547261636b65723a205f616d6f756e742065786365656473207374616b6564416d6f756e74526577617264547261636b65723a20617070726f76652066726f6d20746865207a65726f2061646472657373526577617264547261636b65723a206275726e2066726f6d20746865207a65726f2061646472657373476f7665726e61626c653a20666f7262696464656e0000000000000000000000526577617264547261636b65723a207472616e7366657220746f20746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c526577617264547261636b65723a20696e76616c6964205f6465706f736974546f6b656e526577617264547261636b65723a20617070726f766520746f20746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77526577617264547261636b65723a20616c726561647920696e697469616c697a6564526577617264547261636b65723a207472616e736665722066726f6d20746865207a65726f2061646472657373526577617264547261636b65723a206d696e7420746f20746865207a65726f2061646472657373ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef526577617264547261636b65723a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63655361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564526577617264547261636b65723a20616374696f6e206e6f7420656e61626c6564526577617264547261636b65723a205f616d6f756e742065786365656473206465706f73697442616c616e6365526577617264547261636b65723a207472616e7366657220616d6f756e7420657863656564732062616c616e6365a2646970667358221220ee857f8a48efe3e29b76b476a3d71a137e6ab5703cd4c2b95871dd4b5ad0b31b64736f6c634300060c00330000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000135374616b6564202b20426f6e7573204b494e4700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000673624b494e470000000000000000000000000000000000000000000000000000
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106102355760003560e01c806355b6ed5c1161013757806355b6ed5c1461065d5780635a47a1a71461068b57806370a08231146106aa578063790b5a6c146106d057806395d89b411461070c5780639cb7de4b14610714578063a318021714610742578063a8d9362714610768578063a9059cbb14610770578063aaf5eb681461079c578063adc9772e146107a4578063b89e45b3146107d0578063bfe10928146107f6578063c2a672e0146107fe578063c5fa27301461082a578063cfad57a214610832578063dd62ed3e14610858578063dfbaefb114610886578063e44b75581461088e578063e9503425146108bc578063f5d9d63e146108e2578063f5fc507614610910578063f76033d314610918578063f7c618c11461092057610235565b806301e336671461023a57806306fdde0314610272578063095ea7b3146102ef578063098bf59d1461032f57806310c1c1031461036b578063126082cf146103a357806312d43a51146103ab57806313e82e7a146103cf57806318160ddd146103fd5780631d30d5bc146104055780631e83409a1461042457806323b872dd1461044a57806327e235e314610480578063313ce567146104a65780633792def3146104c4578063392e53cd146104ea5780633cd7f700146104f25780633e158b0c14610511578063402914f51461051957806344a084111461053f578063462d0b2e1461056557806346ea87af14610611578063552ce1dc14610637575b600080fd5b6102706004803603606081101561025057600080fd5b506001600160a01b03813581169160208101359091169060400135610928565b005b61027a61098e565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102b457818101518382015260200161029c565b50505050905090810190601f1680156102e15780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61031b6004803603604081101561030557600080fd5b506001600160a01b038135169060200135610a19565b604080519115158252519081900360200190f35b6102706004803603608081101561034557600080fd5b506001600160a01b03813581169160208101358216916040820135916060013516610a30565b6103916004803603602081101561038157600080fd5b50356001600160a01b0316610a9a565b60408051918252519081900360200190f35b610391610aac565b6103b3610ab2565b604080516001600160a01b039092168252519081900360200190f35b610391600480360360408110156103e557600080fd5b506001600160a01b0381358116916020013516610ac1565b610391610b2c565b6102706004803603602081101561041b57600080fd5b50351515610b32565b6103916004803603602081101561043a57600080fd5b50356001600160a01b0316610b99565b61031b6004803603606081101561046057600080fd5b506001600160a01b03813581169160208101359091169060400135610c43565b6103916004803603602081101561049657600080fd5b50356001600160a01b0316610cdd565b6104ae610cef565b6040805160ff9092168252519081900360200190f35b610391600480360360208110156104da57600080fd5b50356001600160a01b0316610cf4565b61031b610d06565b6102706004803603602081101561050857600080fd5b50351515610d16565b610270610d7f565b6103916004803603602081101561052f57600080fd5b50356001600160a01b0316610ddc565b6103916004803603602081101561055557600080fd5b50356001600160a01b0316610f3a565b6102706004803603604081101561057b57600080fd5b810190602081018135600160201b81111561059557600080fd5b8201836020820111156105a757600080fd5b803590602001918460208302840111600160201b831117156105c857600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550505090356001600160a01b03169150610f4c9050565b61031b6004803603602081101561062757600080fd5b50356001600160a01b031661106f565b6103916004803603602081101561064d57600080fd5b50356001600160a01b0316611084565b6103916004803603604081101561067357600080fd5b506001600160a01b0381358116916020013516611096565b610270600480360360208110156106a157600080fd5b503515156110b3565b610391600480360360208110156106c057600080fd5b50356001600160a01b0316611113565b610270600480360360808110156106e657600080fd5b506001600160a01b0381358116916020810135821691604082013516906060013561112e565b61027a61118d565b6102706004803603604081101561072a57600080fd5b506001600160a01b03813516906020013515156111e8565b6103916004803603602081101561075857600080fd5b50356001600160a01b0316611260565b610391611272565b61031b6004803603604081101561078657600080fd5b506001600160a01b0381351690602001356112f3565b610391611300565b610270600480360360408110156107ba57600080fd5b506001600160a01b038135169060200135611310565b61031b600480360360208110156107e657600080fd5b50356001600160a01b03166113b7565b6103b36113cc565b6102706004803603604081101561081457600080fd5b506001600160a01b0381351690602001356113db565b61031b611479565b6102706004803603602081101561084857600080fd5b50356001600160a01b0316611487565b6103916004803603604081101561086e57600080fd5b506001600160a01b03813581169160200135166114f6565b61031b611521565b610270600480360360408110156108a457600080fd5b506001600160a01b038135169060200135151561152a565b610391600480360360208110156108d257600080fd5b50356001600160a01b03166115a2565b610391600480360360408110156108f857600080fd5b506001600160a01b03813581169160200135166115b4565b6103916115d1565b61031b6115d7565b6103b36115e6565b6001546001600160a01b03163314610975576040805162461bcd60e51b81526020600482015260156024820152600080516020612724833981519152604482015290519081900360640190fd5b6109896001600160a01b0384168383611636565b505050565b6002805460408051602060018416156101000260001901909316849004601f81018490048402820184019092528181529291830182828015610a115780601f106109e657610100808354040283529160200191610a11565b820191906000526020600020905b8154815290600101906020018083116109f457829003601f168201915b505050505081565b6000610a26338484611688565b5060015b92915050565b60026000541415610a76576040805162461bcd60e51b815260206004820152601f6024820152600080516020612684833981519152604482015290519081900360640190fd5b6002600055610a83611774565b610a8f848484846117d5565b505060016000555050565b600c6020526000908152604090205481565b61271081565b6001546001600160a01b031681565b600060026000541415610b09576040805162461bcd60e51b815260206004820152601f6024820152600080516020612684833981519152604482015290519081900360640190fd5b6002600055610b16611774565b610b2083836119e3565b60016000559392505050565b60085481565b6001546001600160a01b03163314610b7f576040805162461bcd60e51b81526020600482015260156024820152600080516020612724833981519152604482015290519081900360640190fd5b601180549115156101000261ff0019909216919091179055565b600060026000541415610be1576040805162461bcd60e51b815260206004820152601f6024820152600080516020612684833981519152604482015290519081900360640190fd5b600260005560115462010000900460ff1615610c2e5760405162461bcd60e51b81526004018080602001828103825260218152602001806128f46021913960400191505060405180910390fd5b610c3833836119e3565b600160005592915050565b3360009081526012602052604081205460ff1615610c6e57610c66848484611a79565b506001610cd6565b6000610cb88360405180606001604052806030815260200161289a603091396001600160a01b0388166000908152600a602090815260408083203384529091529020549190611bcc565b9050610cc5853383611688565b610cd0858585611a79565b60019150505b9392505050565b60096020526000908152604090205481565b601281565b600f6020526000908152604090205481565b600154600160a01b900460ff1681565b6001546001600160a01b03163314610d63576040805162461bcd60e51b81526020600482015260156024820152600080516020612724833981519152604482015290519081900360640190fd5b60118054911515620100000262ff000019909216919091179055565b60026000541415610dc5576040805162461bcd60e51b815260206004820152601f6024820152600080516020612684833981519152604482015290519081900360640190fd5b60026000908155610dd590611c63565b6001600055565b6001600160a01b0381166000908152600c602052604081205480610e1a5750506001600160a01b0381166000908152600d6020526040902054610f35565b60085460048054604080516376f69fed60e11b81529051600093610ea79368327cb2734119d3b7a9601e1b936001600160a01b039091169263eded3fda92828101926020929190829003018186803b158015610e7557600080fd5b505afa158015610e89573d6000803e3d6000fd5b505050506040513d6020811015610e9f57600080fd5b505190611eb3565b90506000610ec1610eb88385611f0c565b600b5490611f4b565b6001600160a01b0387166000908152600e6020526040902054909150610f2e90610f0f9068327cb2734119d3b7a9601e1b90610f0990610f02908690611fa3565b8890611eb3565b90611f0c565b6001600160a01b0388166000908152600d602052604090205490611f4b565b9450505050505b919050565b600e6020526000908152604090205481565b6001546001600160a01b03163314610f99576040805162461bcd60e51b81526020600482015260156024820152600080516020612724833981519152604482015290519081900360640190fd5b600154600160a01b900460ff1615610fe25760405162461bcd60e51b81526004018080602001828103825260228152602001806128046022913960400191505060405180910390fd5b6001805460ff60a01b1916600160a01b17905560005b825181101561104b57600083828151811061100f57fe5b6020908102919091018101516001600160a01b03166000908152600590915260409020805460ff19166001908117909155919091019050610ff8565b50600480546001600160a01b0319166001600160a01b039290921691909117905550565b60126020526000908152604090205460ff1681565b60076020526000908152604090205481565b600a60209081526000928352604080842090915290825290205481565b6001546001600160a01b03163314611100576040805162461bcd60e51b81526020600482015260156024820152600080516020612724833981519152604482015290519081900360640190fd5b6011805460ff1916911515919091179055565b6001600160a01b031660009081526009602052604090205490565b60026000541415611174576040805162461bcd60e51b815260206004820152601f6024820152600080516020612684833981519152604482015290519081900360640190fd5b6002600055611181611774565b610a8f84848484611fe5565b6003805460408051602060026001851615610100026000190190941693909304601f81018490048402820184019092528181529291830182828015610a115780601f106109e657610100808354040283529160200191610a11565b6001546001600160a01b03163314611235576040805162461bcd60e51b81526020600482015260156024820152600080516020612724833981519152604482015290519081900360640190fd5b6001600160a01b03919091166000908152601260205260409020805460ff1916911515919091179055565b60106020526000908152604090205481565b6000600460009054906101000a90046001600160a01b03166001600160a01b031663a8d936276040518163ffffffff1660e01b815260040160206040518083038186803b1580156112c257600080fd5b505afa1580156112d6573d6000803e3d6000fd5b505050506040513d60208110156112ec57600080fd5b5051905090565b6000610a26338484611a79565b68327cb2734119d3b7a9601e1b81565b60026000541415611356576040805162461bcd60e51b815260206004820152601f6024820152600080516020612684833981519152604482015290519081900360640190fd5b6002600055601154610100900460ff16156113a25760405162461bcd60e51b81526004018080602001828103825260218152602001806128f46021913960400191505060405180910390fd5b6113ae33338484611fe5565b50506001600055565b60056020526000908152604090205460ff1681565b6004546001600160a01b031681565b60026000541415611421576040805162461bcd60e51b815260206004820152601f6024820152600080516020612684833981519152604482015290519081900360640190fd5b6002600055601154610100900460ff161561146d5760405162461bcd60e51b81526004018080602001828103825260218152602001806128f46021913960400191505060405180910390fd5b6113ae338383336117d5565b601154610100900460ff1681565b6001546001600160a01b031633146114d4576040805162461bcd60e51b81526020600482015260156024820152600080516020612724833981519152604482015290519081900360640190fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b039182166000908152600a6020908152604080832093909416825291909152205490565b60115460ff1681565b6001546001600160a01b03163314611577576040805162461bcd60e51b81526020600482015260156024820152600080516020612724833981519152604482015290519081900360640190fd5b6001600160a01b03919091166000908152600560205260409020805460ff1916911515919091179055565b600d6020526000908152604090205481565b600660209081526000928352604080842090915290825290205481565b600b5481565b60115462010000900460ff1681565b6000600460009054906101000a90046001600160a01b03166001600160a01b031663f7c618c16040518163ffffffff1660e01b815260040160206040518083038186803b1580156112c257600080fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261098990849061216e565b6001600160a01b0383166116cd5760405162461bcd60e51b815260040180806020018281038252602c8152602001806126cf602c913960400191505060405180910390fd5b6001600160a01b0382166117125760405162461bcd60e51b815260040180806020018281038252602a8152602001806127b9602a913960400191505060405180910390fd5b6001600160a01b038084166000818152600a6020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b3360009081526012602052604090205460ff166117d3576040805162461bcd60e51b81526020600482015260186024820152772932bbb0b9322a3930b1b5b2b91d103337b93134b23232b760411b604482015290519081900360640190fd5b565b6000821161182a576040805162461bcd60e51b815260206004820152601e60248201527f526577617264547261636b65723a20696e76616c6964205f616d6f756e740000604482015290519081900360640190fd5b6001600160a01b03831660009081526005602052604090205460ff166118815760405162461bcd60e51b81526004018080602001828103825260248152602001806127956024913960400191505060405180910390fd5b61188a84611c63565b6001600160a01b0384166000908152600c6020526040902054828110156118e25760405162461bcd60e51b815260040180806020018281038252602b8152602001806126a4602b913960400191505060405180910390fd5b6118ec8184611fa3565b6001600160a01b038087166000908152600c60209081526040808320949094556006815283822092881682529190915220548381101561195d5760405162461bcd60e51b815260040180806020018281038252602d815260200180612915602d913960400191505060405180910390fd5b6119678185611fa3565b6001600160a01b038088166000908152600660209081526040808320938a1683529281528282209390935560079092529020546119a49085611fa3565b6001600160a01b0386166000908152600760205260409020556119c7868561221f565b6119db6001600160a01b0386168486611636565b505050505050565b60006119ee83611c63565b6001600160a01b0383166000908152600d6020526040812080549190558015610cd657611a2e8382611a1e6115e6565b6001600160a01b03169190611636565b604080516001600160a01b03861681526020810183905281517f47cee97cb7acd717b3c0aa1435d004cd5b3c8c57d70dbceb4e4458bbd60e39d4929181900390910190a19392505050565b6001600160a01b038316611abe5760405162461bcd60e51b815260040180806020018281038252602d815260200180612826602d913960400191505060405180910390fd5b6001600160a01b038216611b035760405162461bcd60e51b815260040180806020018281038252602b815260200180612744602b913960400191505060405180910390fd5b60115460ff1615611b1657611b16611774565b611b53816040518060600160405280602e8152602001612942602e91396001600160a01b0386166000908152600960205260409020549190611bcc565b6001600160a01b038085166000908152600960205260408082209390935590841681522054611b829082611f4b565b6001600160a01b03808416600081815260096020908152604091829020949094558051858152905191939287169260008051602061287a83398151915292918290030190a3505050565b60008184841115611c5b5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611c20578181015183820152602001611c08565b50505050905090810190601f168015611c4d5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6000600460009054906101000a90046001600160a01b03166001600160a01b031663e4fc6b6d6040518163ffffffff1660e01b8152600401602060405180830381600087803b158015611cb557600080fd5b505af1158015611cc9573d6000803e3d6000fd5b505050506040513d6020811015611cdf57600080fd5b5051600854600b54919250908115801590611cfa5750600083115b15611d2b57611d23611d1c83610f098668327cb2734119d3b7a9601e1b611eb3565b8290611f4b565b600b81905590505b80611d3857505050611eb0565b6001600160a01b03841615611eac576001600160a01b0384166000908152600c6020908152604080832054600e909252822054909190611d969068327cb2734119d3b7a9601e1b90610f0990611d8f908790611fa3565b8590611eb3565b6001600160a01b0387166000908152600d602052604081205491925090611dbd9083611f4b565b6001600160a01b0388166000908152600d60209081526040808320849055600e909152902085905590508015801590611e0d57506001600160a01b0387166000908152600c602052604090205415155b15611ea8576001600160a01b0387166000908152600f6020526040812054611e359084611f4b565b9050611e82611e4882610f098787611eb3565b6001600160a01b038a166000908152600f6020908152604080832054601090925290912054611e7c918591610f0991611eb3565b90611f4b565b6001600160a01b038916600090815260106020908152604080832093909355600f905220555b5050505b5050505b50565b600082611ec257506000610a2a565b82820282848281611ecf57fe5b0414610cd65760405162461bcd60e51b81526004018080602001828103825260218152602001806127e36021913960400191505060405180910390fd5b6000610cd683836040518060400160405280601a815260200179536166654d6174683a206469766973696f6e206279207a65726f60301b8152506122fd565b600082820183811015610cd6576040805162461bcd60e51b815260206004820152601b60248201527a536166654d6174683a206164646974696f6e206f766572666c6f7760281b604482015290519081900360640190fd5b6000610cd683836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611bcc565b6000811161203a576040805162461bcd60e51b815260206004820152601e60248201527f526577617264547261636b65723a20696e76616c6964205f616d6f756e740000604482015290519081900360640190fd5b6001600160a01b03821660009081526005602052604090205460ff166120915760405162461bcd60e51b81526004018080602001828103825260248152602001806127956024913960400191505060405180910390fd5b6120a66001600160a01b038316853084612362565b6120af83611c63565b6001600160a01b0383166000908152600c60205260409020546120d29082611f4b565b6001600160a01b038085166000908152600c602090815260408083209490945560068152838220928616825291909152205461210e9082611f4b565b6001600160a01b038085166000908152600660209081526040808320938716835292815282822093909355600790925290205461214b9082611f4b565b6001600160a01b038316600090815260076020526040902055611eac83826123bc565b60606121c3826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661247a9092919063ffffffff16565b805190915015610989578080602001905160208110156121e257600080fd5b50516109895760405162461bcd60e51b815260040180806020018281038252602a8152602001806128ca602a913960400191505060405180910390fd5b6001600160a01b0382166122645760405162461bcd60e51b81526004018080602001828103825260298152602001806126fb6029913960400191505060405180910390fd5b6122a1816040518060600160405280602a815260200161265a602a91396001600160a01b0385166000908152600960205260409020549190611bcc565b6001600160a01b0383166000908152600960205260409020556008546122c79082611fa3565b6008556040805182815290516000916001600160a01b0385169160008051602061287a8339815191529181900360200190a35050565b6000818361234c5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315611c20578181015183820152602001611c08565b50600083858161235857fe5b0495945050505050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052611eac90859061216e565b6001600160a01b0382166124015760405162461bcd60e51b81526004018080602001828103825260278152602001806128536027913960400191505060405180910390fd5b60085461240e9082611f4b565b6008556001600160a01b0382166000908152600960205260409020546124349082611f4b565b6001600160a01b038316600081815260096020908152604080832094909455835185815293519293919260008051602061287a8339815191529281900390910190a35050565b60606124898484600085612491565b949350505050565b6060824710156124d25760405162461bcd60e51b815260040180806020018281038252602681526020018061276f6026913960400191505060405180910390fd5b6124db856125ed565b61252c576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b6020831061256b5780518252601f19909201916020918201910161254c565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146125cd576040519150601f19603f3d011682016040523d82523d6000602084013e6125d2565b606091505b50915091506125e28282866125f3565b979650505050505050565b3b151590565b60608315612602575081610cd6565b8251156126125782518084602001fd5b60405162461bcd60e51b8152602060048201818152845160248401528451859391928392604401919085019080838360008315611c20578181015183820152602001611c0856fe526577617264547261636b65723a206275726e20616d6f756e7420657863656564732062616c616e63655265656e7472616e637947756172643a207265656e7472616e742063616c6c00526577617264547261636b65723a205f616d6f756e742065786365656473207374616b6564416d6f756e74526577617264547261636b65723a20617070726f76652066726f6d20746865207a65726f2061646472657373526577617264547261636b65723a206275726e2066726f6d20746865207a65726f2061646472657373476f7665726e61626c653a20666f7262696464656e0000000000000000000000526577617264547261636b65723a207472616e7366657220746f20746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c526577617264547261636b65723a20696e76616c6964205f6465706f736974546f6b656e526577617264547261636b65723a20617070726f766520746f20746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77526577617264547261636b65723a20616c726561647920696e697469616c697a6564526577617264547261636b65723a207472616e736665722066726f6d20746865207a65726f2061646472657373526577617264547261636b65723a206d696e7420746f20746865207a65726f2061646472657373ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef526577617264547261636b65723a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e63655361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564526577617264547261636b65723a20616374696f6e206e6f7420656e61626c6564526577617264547261636b65723a205f616d6f756e742065786365656473206465706f73697442616c616e6365526577617264547261636b65723a207472616e7366657220616d6f756e7420657863656564732062616c616e6365a2646970667358221220ee857f8a48efe3e29b76b476a3d71a137e6ab5703cd4c2b95871dd4b5ad0b31b64736f6c634300060c0033