Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- StakingRewards
- Optimization enabled
- true
- Compiler version
- v0.8.12+commit.f00d7308
- Optimization runs
- 10
- EVM Version
- london
- Verified at
- 2024-06-07T13:15:58.642036Z
contracts/Staking/StakingRewards.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.12;
// Inheritance
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import { IERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import { SafeERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import { IERC20Metadata } from "@openzeppelin/contracts/interfaces/IERC20Metadata.sol";
import "../interfaces/IStakingRewards.sol";
/// @title Staking reward contract
/// @author Steer Protocol
/// @dev This contract is used to reward stakers for their staking time.
contract StakingRewards is
IStakingRewards,
Initializable,
OwnableUpgradeable,
UUPSUpgradeable
{
using SafeERC20Upgradeable for IERC20Upgradeable;
// Storage
// Constants
uint256 public constant PRECISION = 1e18;
uint256 public constant SECONDS_IN_YEAR = 31_536_000;
uint256 public constant RATE_PRECISION = 100_00; //Precision for reward calculaion
// Mapping of Pool details to pool id
mapping(uint256 => Pool) public pools;
// Total no. of pools created
uint256 public totalPools;
//Mapping of user details per pool
mapping(uint256 => mapping(address => UserInfo)) public userInfoPerPool;
// Mapping of total rewards allocated currently for a pool
mapping(uint256 => uint256) public totalRewardsPerPool;
// Mapping that returns the state of pool by passing pool id, true means staking is paused and false means staking is allowed
mapping(uint256 => bool) public isPaused;
// Mapping that returns pending rewards for a particular user for a particular pool
mapping(address => mapping(uint256 => uint256)) public pendingRewards;
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() initializer() {}
// External Functions
/// @dev To stake tokens
/// @param amount The number of tokens to be staked.
/// @param poolId The id of the pool in which tokens should be staked.
function stake(uint256 amount, uint256 poolId) external {
_stake(msg.sender, amount, poolId);
}
/// @dev To stake tokens
/// @param user The address that stake tokens for.
/// @param amount The number of tokens to be staked.
/// @param poolId The id of the pool in which tokens should be staked.
function stakeFor(address user, uint256 amount, uint256 poolId) external {
_stake(user, amount, poolId);
}
/// @dev To unstake staked tokens.
/// @param poolId The id of pool from which the tokens whould be unstaked.
function unstake(uint256 poolId) external {
Pool memory pool = pools[poolId];
UserInfo storage userInfo = userInfoPerPool[poolId][msg.sender];
uint256 amount = userInfo.balance;
require(amount != 0, "0 Stake");
pools[poolId].totalAmount -= amount;
if (block.timestamp > pool.end) {
claimReward(poolId, pool, userInfo);
} else {
userInfo.lastRewarded = 0;
userInfo.rewards = 0;
userInfo.balance = 0;
}
IERC20Upgradeable(pool.stakingToken).safeTransfer(msg.sender, amount);
emit Withdrawn(msg.sender, amount, poolId);
}
/// @dev To claim the pending rewards
/// @param poolId The id of the pool from which the pending rewards should be claimed
function claimPendingRewards(uint256 poolId) external {
uint256 pending = pendingRewards[msg.sender][poolId];
pendingRewards[msg.sender][poolId] = 0;
totalRewardsPerPool[poolId] -= pending;
IERC20Upgradeable(pools[poolId].rewardToken).safeTransfer(
msg.sender,
pending
);
}
// Internal Functions
function claimReward(
uint256 poolId,
Pool memory pool,
UserInfo storage userInfo
) internal {
updateReward(pool, userInfo);
uint256 reward = userInfo.rewards;
userInfo.rewards = 0;
userInfo.balance = 0;
userInfo.lastRewarded = 0;
uint256 totalRewards = totalRewardsPerPool[poolId];
if (totalRewards >= reward) {
totalRewardsPerPool[poolId] = totalRewards - reward;
emit RewardPaid(msg.sender, poolId, reward);
IERC20Upgradeable(pool.rewardToken).safeTransfer(
msg.sender,
reward
);
} else {
pendingRewards[msg.sender][poolId] = reward - totalRewards;
totalRewardsPerPool[poolId] = 0;
emit RewardPaid(msg.sender, poolId, totalRewards);
IERC20Upgradeable(pool.rewardToken).safeTransfer(
msg.sender,
totalRewards
);
}
}
function updateReward(
Pool memory pool,
UserInfo storage userInfo
) internal {
uint256 stakeTime;
if (block.timestamp > pool.end) stakeTime = pool.end;
else stakeTime = block.timestamp;
uint256 balance = userInfo.balance;
uint256 lastReward;
if (balance != 0) {
lastReward =
(balance *
(((stakeTime - userInfo.lastRewarded) *
(pool.rewardRate * PRECISION)) /
(RATE_PRECISION * SECONDS_IN_YEAR))) /
PRECISION;
userInfo.rewards += lastReward;
}
userInfo.lastRewarded = stakeTime;
}
/// @dev To stake tokens
/// @param user The address that stake tokens for.
/// @param amount The number of tokens to be staked.
/// @param poolId The id of the pool in which tokens should be staked.
function _stake(address user, uint256 amount, uint256 poolId) internal {
// Validate
require(amount > 0, "Cannot stake 0");
Pool memory pool = pools[poolId];
UserInfo storage userInfo = userInfoPerPool[poolId][user];
require(pool.start <= block.timestamp, "Staking not started");
require(!isPaused[poolId], "Staking Paused");
require(block.timestamp < pool.end, "Staking Period is over");
// Update values before staking
updateReward(pool, userInfo);
// Stake
userInfo.balance += amount;
pools[poolId].totalAmount += amount;
IERC20Upgradeable(pool.stakingToken).safeTransferFrom(
msg.sender,
address(this),
amount
);
emit Staked(user, amount, poolId);
}
//Public functions
function initialize() public initializer {
__UUPSUpgradeable_init();
__Ownable_init();
}
// View Functions
/// @dev To get rewards for a particular address for a particular pool
/// @param account The address of the account whose reward is to be fetched
/// @param poolId The id of the pool from which rewards for the account needs to be fetched
function getRewardsForAPool(
address account,
uint256 poolId
) external view returns (uint256) {
Pool memory pool = pools[poolId];
UserInfo memory userInfo = userInfoPerPool[poolId][account];
uint256 stakeTime;
if (block.timestamp > pool.end) stakeTime = pool.end;
else stakeTime = block.timestamp;
uint256 currentReward = (userInfo.balance *
(((stakeTime - userInfo.lastRewarded) *
(pool.rewardRate * PRECISION)) /
(RATE_PRECISION * SECONDS_IN_YEAR))) / PRECISION;
currentReward += userInfo.rewards;
return currentReward;
}
/// @dev To get the pool for given id
/// @return Pool which has the details for every pool
function getPool(uint256 poolId) public view returns (Pool memory) {
return pools[poolId];
}
/// @dev To get the details for all pools
/// @return pools which has the details for every pool
function getPools() public view returns (Pool[] memory, string[] memory) {
uint256 _totalPools = totalPools;
Pool[] memory _pools = new Pool[](_totalPools);
string[] memory symbols = new string[](_totalPools);
for (uint256 i; i != _totalPools; ++i) {
_pools[i] = pools[i];
string memory stakingTokenSymbol = IERC20Metadata(
_pools[i].stakingToken
).symbol();
string memory rewardTokenSymbol = IERC20Metadata(
_pools[i].rewardToken
).symbol();
symbols[i] = string(
abi.encodePacked(stakingTokenSymbol, "/", rewardTokenSymbol)
);
}
return (_pools, symbols);
}
function getBalances(
address user
) external view returns (uint256[] memory) {
uint256 _totalPools = totalPools;
uint256[] memory _balances = new uint256[](_totalPools);
for (uint256 i; i != _totalPools; ++i)
_balances[i] = userInfoPerPool[i][user].balance;
return _balances;
}
//Only Owner functions
function _authorizeUpgrade(
address newImplementation
) internal override onlyOwner {}
/// @dev To create a staking pool
/// @param stakingToken Address of the token that will be staked
/// @param rewardToken Address of the token that will be given as reward
/// @param rewardRate Rate at which the rewards will be calculated yearly and then multiplied by 100
/// @param start Start time of the staking pool
/// @param end Ending time for the staking pool
function createPool(
address stakingToken,
address rewardToken,
uint256 rewardRate,
uint256 start,
uint256 end
) external onlyOwner {
uint256 _totalPools = totalPools;
require(start < end, "TIME");
require(stakingToken != rewardToken, "SAME");
pools[_totalPools] = Pool({
stakingToken: stakingToken,
rewardToken: rewardToken,
rewardRate: rewardRate * 100,
totalAmount: 0,
start: start,
end: end
});
totalPools = _totalPools + 1;
}
/// @dev To pause or resume a particular staking pool
/// @param poolId The id of the staking pool that should be paused or resumed
/// @param pause The boolean where passing true means pause the pool
/// and passing false means resume the pool
function setJobState(uint256 poolId, bool pause) external onlyOwner {
isPaused[poolId] = pause;
}
/// @dev To deposit reward tokens that will be given to the stakers.
/// @param poolId The id of the pool in which rewards should be allocated
/// @param amount The value of tokens that should be added to give out as rewards.
function depositRewards(uint256 poolId, uint256 amount) external {
totalRewardsPerPool[poolId] += amount;
emit RewardsDeposited(msg.sender, poolId, amount);
IERC20Upgradeable(pools[poolId].rewardToken).safeTransferFrom(
msg.sender,
address(this),
amount
);
}
/// @dev To withdraw the extra rewards that remains on the contract
/// and can only be called by owner of this contract.
/// @param poolId The id of the pool in which rewards should be withdrawn
/// @param amount The value of tokens that should be removed from the contract.
/// @param receiver The address where the withdrawn tokens should be sent
function withdrawRewards(
uint256 poolId,
uint256 amount,
address receiver
) external onlyOwner {
// Reduce totalRewards by amount.
// Owner cannot withdraw more rewards than they have deposited.
totalRewardsPerPool[poolId] -= amount;
emit RewardsWithdrawn(amount, poolId);
IERC20Upgradeable(pools[poolId].rewardToken).safeTransfer(
receiver,
amount
);
}
}
@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
function __Ownable_init() internal onlyInitializing {
__Context_init_unchained();
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal onlyInitializing {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
uint256[49] private __gap;
}
@openzeppelin/contracts-upgradeable/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Upgrade.sol)
pragma solidity ^0.8.2;
import "../beacon/IBeaconUpgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import "../utils/Initializable.sol";
/**
* @dev This abstract contract provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
*
* _Available since v4.1._
*
* @custom:oz-upgrades-unsafe-allow delegatecall
*/
abstract contract ERC1967UpgradeUpgradeable is Initializable {
function __ERC1967Upgrade_init() internal onlyInitializing {
__ERC1967Upgrade_init_unchained();
}
function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
}
// This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Returns the current implementation address.
*/
function _getImplementation() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Perform implementation upgrade
*
* Emits an {Upgraded} event.
*/
function _upgradeTo(address newImplementation) internal {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
}
/**
* @dev Perform implementation upgrade with additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCall(
address newImplementation,
bytes memory data,
bool forceCall
) internal {
_upgradeTo(newImplementation);
if (data.length > 0 || forceCall) {
_functionDelegateCall(newImplementation, data);
}
}
/**
* @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCallSecure(
address newImplementation,
bytes memory data,
bool forceCall
) internal {
address oldImplementation = _getImplementation();
// Initial upgrade and setup call
_setImplementation(newImplementation);
if (data.length > 0 || forceCall) {
_functionDelegateCall(newImplementation, data);
}
// Perform rollback test if not already in progress
StorageSlotUpgradeable.BooleanSlot storage rollbackTesting = StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT);
if (!rollbackTesting.value) {
// Trigger rollback using upgradeTo from the new implementation
rollbackTesting.value = true;
_functionDelegateCall(
newImplementation,
abi.encodeWithSignature("upgradeTo(address)", oldImplementation)
);
rollbackTesting.value = false;
// Check rollback was effective
require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades");
// Finally reset to the new implementation and log the upgrade
_upgradeTo(newImplementation);
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Returns the current admin.
*/
function _getAdmin() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
require(newAdmin != address(0), "ERC1967: new admin is the zero address");
StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {AdminChanged} event.
*/
function _changeAdmin(address newAdmin) internal {
emit AdminChanged(_getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
*/
bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Emitted when the beacon is upgraded.
*/
event BeaconUpgraded(address indexed beacon);
/**
* @dev Returns the current beacon.
*/
function _getBeacon() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the EIP1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
require(
AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
"ERC1967: beacon implementation is not a contract"
);
StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
}
/**
* @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
* not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
*
* Emits a {BeaconUpgraded} event.
*/
function _upgradeBeaconToAndCall(
address newBeacon,
bytes memory data,
bool forceCall
) internal {
_setBeacon(newBeacon);
emit BeaconUpgraded(newBeacon);
if (data.length > 0 || forceCall) {
_functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
}
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {
require(AddressUpgradeable.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 AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed");
}
uint256[50] private __gap;
}
@openzeppelin/contracts-upgradeable/proxy/beacon/IBeaconUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.0;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeaconUpgradeable {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {BeaconProxy} will check that this address is a contract.
*/
function implementation() external view returns (address);
}
@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/utils/Initializable.sol)
pragma solidity ^0.8.0;
import "../../utils/AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the
* initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() initializer {}
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
*/
bool private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Modifier to protect an initializer function from being invoked twice.
*/
modifier initializer() {
// If the contract is initializing we ignore whether _initialized is set in order to support multiple
// inheritance patterns, but we only do this in the context of a constructor, because in other contexts the
// contract may have been reentered.
require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized");
bool isTopLevelCall = !_initializing;
if (isTopLevelCall) {
_initializing = true;
_initialized = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
}
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} modifier, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
function _isConstructor() private view returns (bool) {
return !AddressUpgradeable.isContract(address(this));
}
}
@openzeppelin/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @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);
/**
* @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 `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, 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 `from` to `to` 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 from, address to, uint256 amount) external returns (bool);
}
@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.0;
import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import "./Initializable.sol";
/**
* @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
* {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
*
* A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
* reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
* `UUPSUpgradeable` with a custom implementation of upgrades.
*
* The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
*
* _Available since v4.1._
*/
abstract contract UUPSUpgradeable is Initializable, ERC1967UpgradeUpgradeable {
function __UUPSUpgradeable_init() internal onlyInitializing {
__ERC1967Upgrade_init_unchained();
__UUPSUpgradeable_init_unchained();
}
function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
}
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
address private immutable __self = address(this);
/**
* @dev Check that the execution is being performed through a delegatecall call and that the execution context is
* a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
* for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
* function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
* fail.
*/
modifier onlyProxy() {
require(address(this) != __self, "Function must be called through delegatecall");
require(_getImplementation() == __self, "Function must be called through active proxy");
_;
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*/
function upgradeTo(address newImplementation) external virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallSecure(newImplementation, new bytes(0), false);
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*/
function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallSecure(newImplementation, data, true);
}
/**
* @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeTo} and {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal override onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
uint256[50] private __gap;
}
@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20Upgradeable {
/**
* @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);
}
@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20Upgradeable.sol";
import "../../../utils/AddressUpgradeable.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 SafeERC20Upgradeable {
using AddressUpgradeable for address;
function safeTransfer(
IERC20Upgradeable token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20Upgradeable 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(
IERC20Upgradeable 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'
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(
IERC20Upgradeable token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20Upgradeable token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_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(IERC20Upgradeable 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
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
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");
(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");
(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");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal 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
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
__Context_init_unchained();
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
uint256[50] private __gap;
}
@openzeppelin/contracts-upgradeable/utils/StorageSlotUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol)
pragma solidity ^0.8.0;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC1967 implementation slot:
* ```
* contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
*/
library StorageSlotUpgradeable {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
assembly {
r.slot := slot
}
}
}
@openzeppelin/contracts/interfaces/IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../token/ERC20/extensions/IERC20Metadata.sol";
contracts/interfaces/IStakingRewards.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.12;
interface IStakingRewards {
// Structs
/// stakingToken : Address of the token that will be staked
/// rewardToken : Address of the token that will be given as reward
/// rewardRate : Rate at which the rewards will be calculated,
/// reward rate will be multiplied by 100 for decimal precision,
/// for e.g. 6000 means 60%/year, 1000 means 10%/year
/// start : Start time of the staking pool
/// end : Ending time for the staking pool
struct Pool {
address stakingToken;
address rewardToken;
uint256 rewardRate;
uint256 totalAmount;
uint256 start;
uint256 end;
}
///balance : Staked balance of a user
///lastRewarded : The time at which a user was last rewarded
///rewards : Amount of rewards accrued by a user(Note - This is not a track of
/// real time rewards,this is a track of rewards till the last time user interacted with
/// the last rewarded variable)
struct UserInfo {
uint256 balance;
uint256 lastRewarded;
uint256 rewards;
}
// Events
event Staked(address indexed user, uint256 amount, uint256 poolId);
event Withdrawn(address indexed user, uint256 amount, uint256 poolId);
event RewardPaid(address indexed user, uint256 poolId, uint256 reward);
event RewardsDeposited(address depositor, uint256 poolId, uint256 amount);
event RewardsWithdrawn(uint256 amount, uint256 poolId);
// Functions
function createPool(
address stakingToken,
address rewardToken,
uint256 rewardRate,
uint256 start,
uint256 end
) external;
function stake(uint256 amount, uint256 poolId) external;
function stakeFor(address user, uint256 amount, uint256 poolId) external;
function unstake(uint256 poolId) external;
function depositRewards(uint256 poolId, uint256 amount) external;
function withdrawRewards(
uint256 poolId,
uint256 amount,
address receiver
) external;
function setJobState(uint256 poolId, bool pause) external;
function claimPendingRewards(uint256 poolId) external;
function getRewardsForAPool(
address account,
uint256 poolId
) external view returns (uint256);
function getPools()
external
view
returns (Pool[] memory pools, string[] memory symbols);
function getPool(uint256 poolId) external view returns (Pool memory pool);
}
Compiler Settings
{"outputSelection":{"*":{"*":["*"],"":["*"]}},"optimizer":{"runs":10,"enabled":true},"metadata":{"useLiteralContent":true,"bytecodeHash":"ipfs"},"libraries":{},"evmVersion":"london"}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[]},{"type":"event","name":"AdminChanged","inputs":[{"type":"address","name":"previousAdmin","internalType":"address","indexed":false},{"type":"address","name":"newAdmin","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"BeaconUpgraded","inputs":[{"type":"address","name":"beacon","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RewardPaid","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"uint256","name":"poolId","internalType":"uint256","indexed":false},{"type":"uint256","name":"reward","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RewardsDeposited","inputs":[{"type":"address","name":"depositor","internalType":"address","indexed":false},{"type":"uint256","name":"poolId","internalType":"uint256","indexed":false},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"RewardsWithdrawn","inputs":[{"type":"uint256","name":"amount","internalType":"uint256","indexed":false},{"type":"uint256","name":"poolId","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Staked","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false},{"type":"uint256","name":"poolId","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Upgraded","inputs":[{"type":"address","name":"implementation","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Withdrawn","inputs":[{"type":"address","name":"user","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false},{"type":"uint256","name":"poolId","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"PRECISION","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"RATE_PRECISION","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"SECONDS_IN_YEAR","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"claimPendingRewards","inputs":[{"type":"uint256","name":"poolId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"createPool","inputs":[{"type":"address","name":"stakingToken","internalType":"address"},{"type":"address","name":"rewardToken","internalType":"address"},{"type":"uint256","name":"rewardRate","internalType":"uint256"},{"type":"uint256","name":"start","internalType":"uint256"},{"type":"uint256","name":"end","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"depositRewards","inputs":[{"type":"uint256","name":"poolId","internalType":"uint256"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256[]","name":"","internalType":"uint256[]"}],"name":"getBalances","inputs":[{"type":"address","name":"user","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"","internalType":"struct IStakingRewards.Pool","components":[{"type":"address","name":"stakingToken","internalType":"address"},{"type":"address","name":"rewardToken","internalType":"address"},{"type":"uint256","name":"rewardRate","internalType":"uint256"},{"type":"uint256","name":"totalAmount","internalType":"uint256"},{"type":"uint256","name":"start","internalType":"uint256"},{"type":"uint256","name":"end","internalType":"uint256"}]}],"name":"getPool","inputs":[{"type":"uint256","name":"poolId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple[]","name":"","internalType":"struct IStakingRewards.Pool[]","components":[{"type":"address","name":"stakingToken","internalType":"address"},{"type":"address","name":"rewardToken","internalType":"address"},{"type":"uint256","name":"rewardRate","internalType":"uint256"},{"type":"uint256","name":"totalAmount","internalType":"uint256"},{"type":"uint256","name":"start","internalType":"uint256"},{"type":"uint256","name":"end","internalType":"uint256"}]},{"type":"string[]","name":"","internalType":"string[]"}],"name":"getPools","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getRewardsForAPool","inputs":[{"type":"address","name":"account","internalType":"address"},{"type":"uint256","name":"poolId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isPaused","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"pendingRewards","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"stakingToken","internalType":"address"},{"type":"address","name":"rewardToken","internalType":"address"},{"type":"uint256","name":"rewardRate","internalType":"uint256"},{"type":"uint256","name":"totalAmount","internalType":"uint256"},{"type":"uint256","name":"start","internalType":"uint256"},{"type":"uint256","name":"end","internalType":"uint256"}],"name":"pools","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setJobState","inputs":[{"type":"uint256","name":"poolId","internalType":"uint256"},{"type":"bool","name":"pause","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"stake","inputs":[{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"poolId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"stakeFor","inputs":[{"type":"address","name":"user","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"poolId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalPools","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalRewardsPerPool","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unstake","inputs":[{"type":"uint256","name":"poolId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"upgradeTo","inputs":[{"type":"address","name":"newImplementation","internalType":"address"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"upgradeToAndCall","inputs":[{"type":"address","name":"newImplementation","internalType":"address"},{"type":"bytes","name":"data","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"balance","internalType":"uint256"},{"type":"uint256","name":"lastRewarded","internalType":"uint256"},{"type":"uint256","name":"rewards","internalType":"uint256"}],"name":"userInfoPerPool","inputs":[{"type":"uint256","name":"","internalType":"uint256"},{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawRewards","inputs":[{"type":"uint256","name":"poolId","internalType":"uint256"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"address","name":"receiver","internalType":"address"}]}]
Contract Creation Code
0x60a0604052306080523480156200001557600080fd5b50600054610100900460ff16620000335760005460ff16156200003d565b6200003d620000e2565b620000a55760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840160405180910390fd5b600054610100900460ff16158015620000c8576000805461ffff19166101011790555b8015620000db576000805461ff00191690555b5062000106565b6000620000fa306200010060201b620012aa1760201c565b15905090565b3b151590565b60805161261462000137600039600081816108a9015281816108e90152818161097201526109b201526126146000f3fe60806040526004361061013c5760003560e01c8063068bcd8d1461014157806308b1e6b9146101775780632b3ba681146101a55780632e17de78146101bb5780633659cfe6146101dd5780634f1ef286146101fd57806358e9a815146102105780635dcc939114610230578063602ae8a8146102485780636099ecb21461027557806366783250146102ad578063673a2a1f1461030f57806367c041e314610332578063715018a614610352578063716f02c0146103675780637b0472f0146103875780638129fc1c146103a757806385ac165a146103bc5780638da5cb5b146103dc578063aaf5eb68146103fe578063ab3c7e521461041a578063ac4afa3814610430578063bdd071fb146104c5578063bdf2a43c146104e5578063c84aae1714610525578063d68f265f14610552578063f2fde38b14610572575b600080fd5b34801561014d57600080fd5b5061016161015c366004611e4c565b610592565b60405161016e9190611eaa565b60405180910390f35b34801561018357600080fd5b50610197610192366004611ed4565b6105ff565b60405190815260200161016e565b3480156101b157600080fd5b5061019761271081565b3480156101c757600080fd5b506101db6101d6366004611e4c565b61073f565b005b3480156101e957600080fd5b506101db6101f8366004611efe565b61089e565b6101db61020b366004611f86565b610967565b34801561021c57600080fd5b506101db61022b366004612016565b610a21565b34801561023c57600080fd5b506101976301e1338081565b34801561025457600080fd5b50610197610263366004611e4c565b60cc6020526000908152604090205481565b34801561028157600080fd5b50610197610290366004611ed4565b60ce60209081526000928352604080842090915290825290205481565b3480156102b957600080fd5b506102f46102c8366004612049565b60cb60209081526000928352604080842090915290825290208054600182015460029092015490919083565b6040805193845260208401929092529082015260600161016e565b34801561031b57600080fd5b50610324610a31565b60405161016e9291906120cd565b34801561033e57600080fd5b506101db61034d36600461217d565b610cd4565b34801561035e57600080fd5b506101db610d23565b34801561037357600080fd5b506101db610382366004611e4c565b610d5e565b34801561039357600080fd5b506101db6103a23660046121ad565b610dc1565b3480156103b357600080fd5b506101db610dcc565b3480156103c857600080fd5b506101db6103d73660046121cf565b610e94565b3480156103e857600080fd5b506103f1611011565b60405161016e919061221c565b34801561040a57600080fd5b50610197670de0b6b3a764000081565b34801561042657600080fd5b5061019760ca5481565b34801561043c57600080fd5b5061048d61044b366004611e4c565b60c9602052600090815260409020805460018201546002830154600384015460048501546005909501546001600160a01b039485169593909416939192909186565b604080516001600160a01b039788168152969095166020870152938501929092526060840152608083015260a082015260c00161016e565b3480156104d157600080fd5b506101db6104e03660046121ad565b611020565b3480156104f157600080fd5b50610515610500366004611e4c565b60cd6020526000908152604090205460ff1681565b604051901515815260200161016e565b34801561053157600080fd5b50610545610540366004611efe565b6110ab565b60405161016e9190612230565b34801561055e57600080fd5b506101db61056d366004612274565b61115b565b34801561057e57600080fd5b506101db61058d366004611efe565b61120d565b61059a611e04565b50600090815260c96020908152604091829020825160c08101845281546001600160a01b03908116825260018301541692810192909252600281015492820192909252600382015460608201526004820154608082015260059091015460a082015290565b600081815260c960209081526040808320815160c08101835281546001600160a01b0390811682526001808401548216838701526002808501548487015260038501546060808601919091526004860154608086015260059095015460a0850190815289895260cb8852868920938b168952928752858820865195860187528054865291820154968501969096529094015492820192909252915190919083904211156106b1575060a08201516106b4565b50425b6000670de0b6b3a76400006106cf6301e133806127106122bf565b670de0b6b3a764000086604001516106e791906122bf565b60208601516106f690866122de565b61070091906122bf565b61070a91906122f5565b845161071691906122bf565b61072091906122f5565b90508260400151816107329190612317565b9450505050505b92915050565b600081815260c960209081526040808320815160c08101835281546001600160a01b03908116825260018301541681850152600282015481840152600382015460608201526004820154608082015260059091015460a082015284845260cb83528184203385529092529091208054806107ea5760405162461bcd60e51b815260206004820152600760248201526630205374616b6560c81b60448201526064015b60405180910390fd5b600084815260c960205260408120600301805483929061080b9084906122de565b909155505060a083015142111561082c576108278484846112b0565b61083f565b6000600183018190556002830181905582555b8251610855906001600160a01b031633836113c0565b336001600160a01b03167f92ccf450a286a957af52509bc1c9939d1a6a481783e142e41e2499f0bb66ebc6828660405161089092919061232f565b60405180910390a250505050565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614156108e75760405162461bcd60e51b81526004016107e19061233d565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610919611423565b6001600160a01b03161461093f5760405162461bcd60e51b81526004016107e190612377565b6109488161143f565b604080516000808252602082019092526109649183919061146e565b50565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614156109b05760405162461bcd60e51b81526004016107e19061233d565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166109e2611423565b6001600160a01b031614610a085760405162461bcd60e51b81526004016107e190612377565b610a118261143f565b610a1d8282600161146e565b5050565b610a2c8383836115ae565b505050565b60ca5460609081906000816001600160401b03811115610a5357610a53611f19565b604051908082528060200260200182016040528015610a8c57816020015b610a79611e04565b815260200190600190039081610a715790505b5090506000826001600160401b03811115610aa957610aa9611f19565b604051908082528060200260200182016040528015610adc57816020015b6060815260200190600190039081610ac75790505b50905060005b838114610cc957600081815260c96020908152604091829020825160c08101845281546001600160a01b03908116825260018301541692810192909252600281015492820192909252600382015460608201526004820154608082015260059091015460a08201528351849083908110610b5e57610b5e6123b1565b60200260200101819052506000838281518110610b7d57610b7d6123b1565b6020026020010151600001516001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015610bc6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610bee91908101906123c7565b90506000848381518110610c0457610c046123b1565b6020026020010151602001516001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015610c4d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610c7591908101906123c7565b90508181604051602001610c8a929190612434565b604051602081830303815290604052848481518110610cab57610cab6123b1565b6020026020010181905250505080610cc290612470565b9050610ae2565b509094909350915050565b33610cdd611011565b6001600160a01b031614610d035760405162461bcd60e51b81526004016107e19061248b565b600091825260cd6020526040909120805460ff1916911515919091179055565b33610d2c611011565b6001600160a01b031614610d525760405162461bcd60e51b81526004016107e19061248b565b610d5c60006117f0565b565b33600090815260ce60209081526040808320848452825280832080549084905560cc9092528220805491928392610d969084906122de565b9091555050600082815260c96020526040902060010154610a1d906001600160a01b031633836113c0565b610a1d3383836115ae565b600054610100900460ff16610de75760005460ff1615610deb565b303b155b610e4e5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016107e1565b600054610100900460ff16158015610e70576000805461ffff19166101011790555b610e78611842565b610e80611879565b8015610964576000805461ff001916905550565b33610e9d611011565b6001600160a01b031614610ec35760405162461bcd60e51b81526004016107e19061248b565b60ca54818310610efe5760405162461bcd60e51b81526004016107e19060208082526004908201526354494d4560e01b604082015260600190565b846001600160a01b0316866001600160a01b03161415610f495760405162461bcd60e51b81526004016107e19060208082526004908201526353414d4560e01b604082015260600190565b6040805160c0810182526001600160a01b03808916825287166020820152908101610f758660646122bf565b8152600060208083018290526040808401889052606093840187905285835260c9825291829020845181546001600160a01b039182166001600160a01b0319918216178355928601516001808401805492909316919094161790559184015160028301559183015160038201556080830151600482015560a090920151600590920191909155611006908290612317565b60ca55505050505050565b6033546001600160a01b031690565b600082815260cc60205260408120805483929061103e908490612317565b909155505060408051338152602081018490529081018290527f6e8a19c7bcac2f8ca75d80a333a2cfffd851001c55ba805c58cc66c70d92bd749060600160405180910390a1600082815260c96020526040902060010154610a1d906001600160a01b03163330846118b0565b60ca546060906000816001600160401b038111156110cb576110cb611f19565b6040519080825280602002602001820160405280156110f4578160200160208202803683370190505b50905060005b82811461115357600081815260cb602090815260408083206001600160a01b03891684529091529020548251839083908110611138576111386123b1565b602090810291909101015261114c81612470565b90506110fa565b509392505050565b33611164611011565b6001600160a01b03161461118a5760405162461bcd60e51b81526004016107e19061248b565b600083815260cc6020526040812080548492906111a89084906122de565b90915550506040517f630af8b49bb398089a74eacdb08106c528436090bdb35d7302152dc5117df9bd906111df908490869061232f565b60405180910390a1600083815260c96020526040902060010154610a2c906001600160a01b031682846113c0565b33611216611011565b6001600160a01b03161461123c5760405162461bcd60e51b81526004016107e19061248b565b6001600160a01b0381166112a15760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016107e1565b610964816117f0565b3b151590565b6112ba82826118ee565b6002810180546000918290558183556001830182905584825260cc602052604090912054818110611349576112ef82826122de565b600086815260cc6020526040908190209190915551339060008051602061257883398151915290611323908890869061232f565b60405180910390a26020840151611344906001600160a01b031633846113c0565b6113b9565b61135381836122de565b33600081815260ce602090815260408083208a845282528083209490945560cc905282812055905160008051602061257883398151915290611398908890859061232f565b60405180910390a260208401516113b9906001600160a01b031633836113c0565b5050505050565b6040516001600160a01b038316602482015260448101829052610a2c90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526119a3565b600080516020612598833981519152546001600160a01b031690565b33611448611011565b6001600160a01b0316146109645760405162461bcd60e51b81526004016107e19061248b565b6000611478611423565b905061148384611a75565b6000835111806114905750815b156114a15761149f8484611b08565b505b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143805460ff166113b957805460ff1916600117815560405161151c9086906114ed90859060240161221c565b60408051601f198184030181529190526020810180516001600160e01b0316631b2ce7f360e11b179052611b08565b50805460ff1916815561152d611423565b6001600160a01b0316826001600160a01b0316146115a55760405162461bcd60e51b815260206004820152602f60248201527f45524331393637557067726164653a207570677261646520627265616b73206660448201526e75727468657220757067726164657360881b60648201526084016107e1565b6113b985611bf3565b600082116115ef5760405162461bcd60e51b815260206004820152600e60248201526d043616e6e6f74207374616b6520360941b60448201526064016107e1565b600081815260c960209081526040808320815160c08101835281546001600160a01b03908116825260018301548116828601526002830154828501526003830154606083015260048301546080830190815260059093015460a083015286865260cb85528386209089168652909352922091519091904210156116aa5760405162461bcd60e51b815260206004820152601360248201527214dd185ada5b99c81b9bdd081cdd185c9d1959606a1b60448201526064016107e1565b600083815260cd602052604090205460ff16156116fa5760405162461bcd60e51b815260206004820152600e60248201526d14dd185ada5b99c814185d5cd95960921b60448201526064016107e1565b8160a0015142106117465760405162461bcd60e51b815260206004820152601660248201527529ba30b5b4b733902832b934b7b21034b99037bb32b960511b60448201526064016107e1565b61175082826118ee565b838160000160008282546117649190612317565b9091555050600083815260c960205260408120600301805486929061178a908490612317565b909155505081516117a6906001600160a01b03163330876118b0565b846001600160a01b03167f1449c6dd7851abc30abf37f57715f492010519147cc2652fbc38202c18a6ee9085856040516117e192919061232f565b60405180910390a25050505050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff166118695760405162461bcd60e51b81526004016107e1906124c0565b611871611c33565b610d5c611c33565b600054610100900460ff166118a05760405162461bcd60e51b81526004016107e1906124c0565b6118a8611c33565b610d5c611c5a565b6040516001600160a01b03808516602483015283166044820152606481018290526118e89085906323b872dd60e01b906084016113ec565b50505050565b60008260a00151421115611907575060a082015161190a565b50425b81546000811561199857670de0b6b3a764000061192d6301e133806127106122bf565b670de0b6b3a7640000876040015161194591906122bf565b600187015461195490876122de565b61195e91906122bf565b61196891906122f5565b61197290846122bf565b61197c91906122f5565b9050808460020160008282546119929190612317565b90915550505b505060019091015550565b60006119f8826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611c8a9092919063ffffffff16565b805190915015610a2c5780806020019051810190611a16919061250b565b610a2c5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016107e1565b803b611ad95760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016107e1565b60008051602061259883398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6060823b611b675760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016107e1565b600080846001600160a01b031684604051611b829190612528565b600060405180830381855af49150503d8060008114611bbd576040519150601f19603f3d011682016040523d82523d6000602084013e611bc2565b606091505b5091509150611bea82826040518060600160405280602781526020016125b860279139611ca3565b95945050505050565b611bfc81611a75565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b600054610100900460ff16610d5c5760405162461bcd60e51b81526004016107e1906124c0565b600054610100900460ff16611c815760405162461bcd60e51b81526004016107e1906124c0565b610d5c336117f0565b6060611c998484600085611cdc565b90505b9392505050565b60608315611cb2575081611c9c565b825115611cc25782518084602001fd5b8160405162461bcd60e51b81526004016107e19190612544565b606082471015611d3d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016107e1565b843b611d8b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016107e1565b600080866001600160a01b03168587604051611da79190612528565b60006040518083038185875af1925050503d8060008114611de4576040519150601f19603f3d011682016040523d82523d6000602084013e611de9565b606091505b5091509150611df9828286611ca3565b979650505050505050565b6040518060c0016040528060006001600160a01b0316815260200160006001600160a01b03168152602001600081526020016000815260200160008152602001600081525090565b600060208284031215611e5e57600080fd5b5035919050565b80516001600160a01b0390811683526020808301519091169083015260408082015190830152606080820151908301526080808201519083015260a090810151910152565b60c081016107398284611e65565b80356001600160a01b0381168114611ecf57600080fd5b919050565b60008060408385031215611ee757600080fd5b611ef083611eb8565b946020939093013593505050565b600060208284031215611f1057600080fd5b611c9c82611eb8565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715611f5757611f57611f19565b604052919050565b60006001600160401b03821115611f7857611f78611f19565b50601f01601f191660200190565b60008060408385031215611f9957600080fd5b611fa283611eb8565b915060208301356001600160401b03811115611fbd57600080fd5b8301601f81018513611fce57600080fd5b8035611fe1611fdc82611f5f565b611f2f565b818152866020838501011115611ff657600080fd5b816020840160208301376000602083830101528093505050509250929050565b60008060006060848603121561202b57600080fd5b61203484611eb8565b95602085013595506040909401359392505050565b6000806040838503121561205c57600080fd5b8235915061206c60208401611eb8565b90509250929050565b60005b83811015612090578181015183820152602001612078565b838111156118e85750506000910152565b600081518084526120b9816020860160208601612075565b601f01601f19169290920160200192915050565b604080825283519082018190526000906020906060840190828701845b82811015612110576120fd848351611e65565b60c09390930192908401906001016120ea565b50505083810382850152845180825282820190600581901b8301840187850160005b8381101561216057601f1986840301855261214e8383516120a1565b94870194925090860190600101612132565b50909998505050505050505050565b801515811461096457600080fd5b6000806040838503121561219057600080fd5b8235915060208301356121a28161216f565b809150509250929050565b600080604083850312156121c057600080fd5b50508035926020909101359150565b600080600080600060a086880312156121e757600080fd5b6121f086611eb8565b94506121fe60208701611eb8565b94979496505050506040830135926060810135926080909101359150565b6001600160a01b0391909116815260200190565b6020808252825182820181905260009190848201906040850190845b818110156122685783518352928401929184019160010161224c565b50909695505050505050565b60008060006060848603121561228957600080fd5b83359250602084013591506122a060408501611eb8565b90509250925092565b634e487b7160e01b600052601160045260246000fd5b60008160001904831182151516156122d9576122d96122a9565b500290565b6000828210156122f0576122f06122a9565b500390565b60008261231257634e487b7160e01b600052601260045260246000fd5b500490565b6000821982111561232a5761232a6122a9565b500190565b918252602082015260400190565b6020808252602c9082015260008051602061255883398151915260408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c9082015260008051602061255883398151915260408201526b6163746976652070726f787960a01b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b6000602082840312156123d957600080fd5b81516001600160401b038111156123ef57600080fd5b8201601f8101841361240057600080fd5b805161240e611fdc82611f5f565b81815285602083850101111561242357600080fd5b611bea826020830160208601612075565b60008351612446818460208801612075565b602f60f81b9083019081528351612464816001840160208801612075565b01600101949350505050565b6000600019821415612484576124846122a9565b5060010190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60006020828403121561251d57600080fd5b8151611c9c8161216f565b6000825161253a818460208701612075565b9190910192915050565b602081526000611c9c60208301846120a156fe46756e6374696f6e206d7573742062652063616c6c6564207468726f75676820d6f2c8500df5b44f11e9e48b91ff9f1b9d81bc496d55570c2b1b75bf65243f51360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220dc0d171e3d1d9d765ea108476213467c41bac730bd934d695beca653c87a15ac64736f6c634300080c0033
Deployed ByteCode
0x60806040526004361061013c5760003560e01c8063068bcd8d1461014157806308b1e6b9146101775780632b3ba681146101a55780632e17de78146101bb5780633659cfe6146101dd5780634f1ef286146101fd57806358e9a815146102105780635dcc939114610230578063602ae8a8146102485780636099ecb21461027557806366783250146102ad578063673a2a1f1461030f57806367c041e314610332578063715018a614610352578063716f02c0146103675780637b0472f0146103875780638129fc1c146103a757806385ac165a146103bc5780638da5cb5b146103dc578063aaf5eb68146103fe578063ab3c7e521461041a578063ac4afa3814610430578063bdd071fb146104c5578063bdf2a43c146104e5578063c84aae1714610525578063d68f265f14610552578063f2fde38b14610572575b600080fd5b34801561014d57600080fd5b5061016161015c366004611e4c565b610592565b60405161016e9190611eaa565b60405180910390f35b34801561018357600080fd5b50610197610192366004611ed4565b6105ff565b60405190815260200161016e565b3480156101b157600080fd5b5061019761271081565b3480156101c757600080fd5b506101db6101d6366004611e4c565b61073f565b005b3480156101e957600080fd5b506101db6101f8366004611efe565b61089e565b6101db61020b366004611f86565b610967565b34801561021c57600080fd5b506101db61022b366004612016565b610a21565b34801561023c57600080fd5b506101976301e1338081565b34801561025457600080fd5b50610197610263366004611e4c565b60cc6020526000908152604090205481565b34801561028157600080fd5b50610197610290366004611ed4565b60ce60209081526000928352604080842090915290825290205481565b3480156102b957600080fd5b506102f46102c8366004612049565b60cb60209081526000928352604080842090915290825290208054600182015460029092015490919083565b6040805193845260208401929092529082015260600161016e565b34801561031b57600080fd5b50610324610a31565b60405161016e9291906120cd565b34801561033e57600080fd5b506101db61034d36600461217d565b610cd4565b34801561035e57600080fd5b506101db610d23565b34801561037357600080fd5b506101db610382366004611e4c565b610d5e565b34801561039357600080fd5b506101db6103a23660046121ad565b610dc1565b3480156103b357600080fd5b506101db610dcc565b3480156103c857600080fd5b506101db6103d73660046121cf565b610e94565b3480156103e857600080fd5b506103f1611011565b60405161016e919061221c565b34801561040a57600080fd5b50610197670de0b6b3a764000081565b34801561042657600080fd5b5061019760ca5481565b34801561043c57600080fd5b5061048d61044b366004611e4c565b60c9602052600090815260409020805460018201546002830154600384015460048501546005909501546001600160a01b039485169593909416939192909186565b604080516001600160a01b039788168152969095166020870152938501929092526060840152608083015260a082015260c00161016e565b3480156104d157600080fd5b506101db6104e03660046121ad565b611020565b3480156104f157600080fd5b50610515610500366004611e4c565b60cd6020526000908152604090205460ff1681565b604051901515815260200161016e565b34801561053157600080fd5b50610545610540366004611efe565b6110ab565b60405161016e9190612230565b34801561055e57600080fd5b506101db61056d366004612274565b61115b565b34801561057e57600080fd5b506101db61058d366004611efe565b61120d565b61059a611e04565b50600090815260c96020908152604091829020825160c08101845281546001600160a01b03908116825260018301541692810192909252600281015492820192909252600382015460608201526004820154608082015260059091015460a082015290565b600081815260c960209081526040808320815160c08101835281546001600160a01b0390811682526001808401548216838701526002808501548487015260038501546060808601919091526004860154608086015260059095015460a0850190815289895260cb8852868920938b168952928752858820865195860187528054865291820154968501969096529094015492820192909252915190919083904211156106b1575060a08201516106b4565b50425b6000670de0b6b3a76400006106cf6301e133806127106122bf565b670de0b6b3a764000086604001516106e791906122bf565b60208601516106f690866122de565b61070091906122bf565b61070a91906122f5565b845161071691906122bf565b61072091906122f5565b90508260400151816107329190612317565b9450505050505b92915050565b600081815260c960209081526040808320815160c08101835281546001600160a01b03908116825260018301541681850152600282015481840152600382015460608201526004820154608082015260059091015460a082015284845260cb83528184203385529092529091208054806107ea5760405162461bcd60e51b815260206004820152600760248201526630205374616b6560c81b60448201526064015b60405180910390fd5b600084815260c960205260408120600301805483929061080b9084906122de565b909155505060a083015142111561082c576108278484846112b0565b61083f565b6000600183018190556002830181905582555b8251610855906001600160a01b031633836113c0565b336001600160a01b03167f92ccf450a286a957af52509bc1c9939d1a6a481783e142e41e2499f0bb66ebc6828660405161089092919061232f565b60405180910390a250505050565b306001600160a01b037f0000000000000000000000007c464a0ab1f5ebf3e2dcccfec7ef41d02ed7a2f41614156108e75760405162461bcd60e51b81526004016107e19061233d565b7f0000000000000000000000007c464a0ab1f5ebf3e2dcccfec7ef41d02ed7a2f46001600160a01b0316610919611423565b6001600160a01b03161461093f5760405162461bcd60e51b81526004016107e190612377565b6109488161143f565b604080516000808252602082019092526109649183919061146e565b50565b306001600160a01b037f0000000000000000000000007c464a0ab1f5ebf3e2dcccfec7ef41d02ed7a2f41614156109b05760405162461bcd60e51b81526004016107e19061233d565b7f0000000000000000000000007c464a0ab1f5ebf3e2dcccfec7ef41d02ed7a2f46001600160a01b03166109e2611423565b6001600160a01b031614610a085760405162461bcd60e51b81526004016107e190612377565b610a118261143f565b610a1d8282600161146e565b5050565b610a2c8383836115ae565b505050565b60ca5460609081906000816001600160401b03811115610a5357610a53611f19565b604051908082528060200260200182016040528015610a8c57816020015b610a79611e04565b815260200190600190039081610a715790505b5090506000826001600160401b03811115610aa957610aa9611f19565b604051908082528060200260200182016040528015610adc57816020015b6060815260200190600190039081610ac75790505b50905060005b838114610cc957600081815260c96020908152604091829020825160c08101845281546001600160a01b03908116825260018301541692810192909252600281015492820192909252600382015460608201526004820154608082015260059091015460a08201528351849083908110610b5e57610b5e6123b1565b60200260200101819052506000838281518110610b7d57610b7d6123b1565b6020026020010151600001516001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015610bc6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610bee91908101906123c7565b90506000848381518110610c0457610c046123b1565b6020026020010151602001516001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015610c4d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610c7591908101906123c7565b90508181604051602001610c8a929190612434565b604051602081830303815290604052848481518110610cab57610cab6123b1565b6020026020010181905250505080610cc290612470565b9050610ae2565b509094909350915050565b33610cdd611011565b6001600160a01b031614610d035760405162461bcd60e51b81526004016107e19061248b565b600091825260cd6020526040909120805460ff1916911515919091179055565b33610d2c611011565b6001600160a01b031614610d525760405162461bcd60e51b81526004016107e19061248b565b610d5c60006117f0565b565b33600090815260ce60209081526040808320848452825280832080549084905560cc9092528220805491928392610d969084906122de565b9091555050600082815260c96020526040902060010154610a1d906001600160a01b031633836113c0565b610a1d3383836115ae565b600054610100900460ff16610de75760005460ff1615610deb565b303b155b610e4e5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016107e1565b600054610100900460ff16158015610e70576000805461ffff19166101011790555b610e78611842565b610e80611879565b8015610964576000805461ff001916905550565b33610e9d611011565b6001600160a01b031614610ec35760405162461bcd60e51b81526004016107e19061248b565b60ca54818310610efe5760405162461bcd60e51b81526004016107e19060208082526004908201526354494d4560e01b604082015260600190565b846001600160a01b0316866001600160a01b03161415610f495760405162461bcd60e51b81526004016107e19060208082526004908201526353414d4560e01b604082015260600190565b6040805160c0810182526001600160a01b03808916825287166020820152908101610f758660646122bf565b8152600060208083018290526040808401889052606093840187905285835260c9825291829020845181546001600160a01b039182166001600160a01b0319918216178355928601516001808401805492909316919094161790559184015160028301559183015160038201556080830151600482015560a090920151600590920191909155611006908290612317565b60ca55505050505050565b6033546001600160a01b031690565b600082815260cc60205260408120805483929061103e908490612317565b909155505060408051338152602081018490529081018290527f6e8a19c7bcac2f8ca75d80a333a2cfffd851001c55ba805c58cc66c70d92bd749060600160405180910390a1600082815260c96020526040902060010154610a1d906001600160a01b03163330846118b0565b60ca546060906000816001600160401b038111156110cb576110cb611f19565b6040519080825280602002602001820160405280156110f4578160200160208202803683370190505b50905060005b82811461115357600081815260cb602090815260408083206001600160a01b03891684529091529020548251839083908110611138576111386123b1565b602090810291909101015261114c81612470565b90506110fa565b509392505050565b33611164611011565b6001600160a01b03161461118a5760405162461bcd60e51b81526004016107e19061248b565b600083815260cc6020526040812080548492906111a89084906122de565b90915550506040517f630af8b49bb398089a74eacdb08106c528436090bdb35d7302152dc5117df9bd906111df908490869061232f565b60405180910390a1600083815260c96020526040902060010154610a2c906001600160a01b031682846113c0565b33611216611011565b6001600160a01b03161461123c5760405162461bcd60e51b81526004016107e19061248b565b6001600160a01b0381166112a15760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016107e1565b610964816117f0565b3b151590565b6112ba82826118ee565b6002810180546000918290558183556001830182905584825260cc602052604090912054818110611349576112ef82826122de565b600086815260cc6020526040908190209190915551339060008051602061257883398151915290611323908890869061232f565b60405180910390a26020840151611344906001600160a01b031633846113c0565b6113b9565b61135381836122de565b33600081815260ce602090815260408083208a845282528083209490945560cc905282812055905160008051602061257883398151915290611398908890859061232f565b60405180910390a260208401516113b9906001600160a01b031633836113c0565b5050505050565b6040516001600160a01b038316602482015260448101829052610a2c90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526119a3565b600080516020612598833981519152546001600160a01b031690565b33611448611011565b6001600160a01b0316146109645760405162461bcd60e51b81526004016107e19061248b565b6000611478611423565b905061148384611a75565b6000835111806114905750815b156114a15761149f8484611b08565b505b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143805460ff166113b957805460ff1916600117815560405161151c9086906114ed90859060240161221c565b60408051601f198184030181529190526020810180516001600160e01b0316631b2ce7f360e11b179052611b08565b50805460ff1916815561152d611423565b6001600160a01b0316826001600160a01b0316146115a55760405162461bcd60e51b815260206004820152602f60248201527f45524331393637557067726164653a207570677261646520627265616b73206660448201526e75727468657220757067726164657360881b60648201526084016107e1565b6113b985611bf3565b600082116115ef5760405162461bcd60e51b815260206004820152600e60248201526d043616e6e6f74207374616b6520360941b60448201526064016107e1565b600081815260c960209081526040808320815160c08101835281546001600160a01b03908116825260018301548116828601526002830154828501526003830154606083015260048301546080830190815260059093015460a083015286865260cb85528386209089168652909352922091519091904210156116aa5760405162461bcd60e51b815260206004820152601360248201527214dd185ada5b99c81b9bdd081cdd185c9d1959606a1b60448201526064016107e1565b600083815260cd602052604090205460ff16156116fa5760405162461bcd60e51b815260206004820152600e60248201526d14dd185ada5b99c814185d5cd95960921b60448201526064016107e1565b8160a0015142106117465760405162461bcd60e51b815260206004820152601660248201527529ba30b5b4b733902832b934b7b21034b99037bb32b960511b60448201526064016107e1565b61175082826118ee565b838160000160008282546117649190612317565b9091555050600083815260c960205260408120600301805486929061178a908490612317565b909155505081516117a6906001600160a01b03163330876118b0565b846001600160a01b03167f1449c6dd7851abc30abf37f57715f492010519147cc2652fbc38202c18a6ee9085856040516117e192919061232f565b60405180910390a25050505050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff166118695760405162461bcd60e51b81526004016107e1906124c0565b611871611c33565b610d5c611c33565b600054610100900460ff166118a05760405162461bcd60e51b81526004016107e1906124c0565b6118a8611c33565b610d5c611c5a565b6040516001600160a01b03808516602483015283166044820152606481018290526118e89085906323b872dd60e01b906084016113ec565b50505050565b60008260a00151421115611907575060a082015161190a565b50425b81546000811561199857670de0b6b3a764000061192d6301e133806127106122bf565b670de0b6b3a7640000876040015161194591906122bf565b600187015461195490876122de565b61195e91906122bf565b61196891906122f5565b61197290846122bf565b61197c91906122f5565b9050808460020160008282546119929190612317565b90915550505b505060019091015550565b60006119f8826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611c8a9092919063ffffffff16565b805190915015610a2c5780806020019051810190611a16919061250b565b610a2c5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016107e1565b803b611ad95760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016107e1565b60008051602061259883398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6060823b611b675760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016107e1565b600080846001600160a01b031684604051611b829190612528565b600060405180830381855af49150503d8060008114611bbd576040519150601f19603f3d011682016040523d82523d6000602084013e611bc2565b606091505b5091509150611bea82826040518060600160405280602781526020016125b860279139611ca3565b95945050505050565b611bfc81611a75565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b600054610100900460ff16610d5c5760405162461bcd60e51b81526004016107e1906124c0565b600054610100900460ff16611c815760405162461bcd60e51b81526004016107e1906124c0565b610d5c336117f0565b6060611c998484600085611cdc565b90505b9392505050565b60608315611cb2575081611c9c565b825115611cc25782518084602001fd5b8160405162461bcd60e51b81526004016107e19190612544565b606082471015611d3d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016107e1565b843b611d8b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016107e1565b600080866001600160a01b03168587604051611da79190612528565b60006040518083038185875af1925050503d8060008114611de4576040519150601f19603f3d011682016040523d82523d6000602084013e611de9565b606091505b5091509150611df9828286611ca3565b979650505050505050565b6040518060c0016040528060006001600160a01b0316815260200160006001600160a01b03168152602001600081526020016000815260200160008152602001600081525090565b600060208284031215611e5e57600080fd5b5035919050565b80516001600160a01b0390811683526020808301519091169083015260408082015190830152606080820151908301526080808201519083015260a090810151910152565b60c081016107398284611e65565b80356001600160a01b0381168114611ecf57600080fd5b919050565b60008060408385031215611ee757600080fd5b611ef083611eb8565b946020939093013593505050565b600060208284031215611f1057600080fd5b611c9c82611eb8565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715611f5757611f57611f19565b604052919050565b60006001600160401b03821115611f7857611f78611f19565b50601f01601f191660200190565b60008060408385031215611f9957600080fd5b611fa283611eb8565b915060208301356001600160401b03811115611fbd57600080fd5b8301601f81018513611fce57600080fd5b8035611fe1611fdc82611f5f565b611f2f565b818152866020838501011115611ff657600080fd5b816020840160208301376000602083830101528093505050509250929050565b60008060006060848603121561202b57600080fd5b61203484611eb8565b95602085013595506040909401359392505050565b6000806040838503121561205c57600080fd5b8235915061206c60208401611eb8565b90509250929050565b60005b83811015612090578181015183820152602001612078565b838111156118e85750506000910152565b600081518084526120b9816020860160208601612075565b601f01601f19169290920160200192915050565b604080825283519082018190526000906020906060840190828701845b82811015612110576120fd848351611e65565b60c09390930192908401906001016120ea565b50505083810382850152845180825282820190600581901b8301840187850160005b8381101561216057601f1986840301855261214e8383516120a1565b94870194925090860190600101612132565b50909998505050505050505050565b801515811461096457600080fd5b6000806040838503121561219057600080fd5b8235915060208301356121a28161216f565b809150509250929050565b600080604083850312156121c057600080fd5b50508035926020909101359150565b600080600080600060a086880312156121e757600080fd5b6121f086611eb8565b94506121fe60208701611eb8565b94979496505050506040830135926060810135926080909101359150565b6001600160a01b0391909116815260200190565b6020808252825182820181905260009190848201906040850190845b818110156122685783518352928401929184019160010161224c565b50909695505050505050565b60008060006060848603121561228957600080fd5b83359250602084013591506122a060408501611eb8565b90509250925092565b634e487b7160e01b600052601160045260246000fd5b60008160001904831182151516156122d9576122d96122a9565b500290565b6000828210156122f0576122f06122a9565b500390565b60008261231257634e487b7160e01b600052601260045260246000fd5b500490565b6000821982111561232a5761232a6122a9565b500190565b918252602082015260400190565b6020808252602c9082015260008051602061255883398151915260408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c9082015260008051602061255883398151915260408201526b6163746976652070726f787960a01b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b6000602082840312156123d957600080fd5b81516001600160401b038111156123ef57600080fd5b8201601f8101841361240057600080fd5b805161240e611fdc82611f5f565b81815285602083850101111561242357600080fd5b611bea826020830160208601612075565b60008351612446818460208801612075565b602f60f81b9083019081528351612464816001840160208801612075565b01600101949350505050565b6000600019821415612484576124846122a9565b5060010190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60006020828403121561251d57600080fd5b8151611c9c8161216f565b6000825161253a818460208701612075565b9190910192915050565b602081526000611c9c60208301846120a156fe46756e6374696f6e206d7573742062652063616c6c6564207468726f75676820d6f2c8500df5b44f11e9e48b91ff9f1b9d81bc496d55570c2b1b75bf65243f51360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220dc0d171e3d1d9d765ea108476213467c41bac730bd934d695beca653c87a15ac64736f6c634300080c0033