Transactions
Token Transfers
Tokens
Internal Transactions
Coin Balance History
Logs
Code
Read Contract
Write Contract
- Contract name:
- ReceiveStakingPool
- Optimization enabled
- true
- Compiler version
- v0.8.7+commit.e28d00a7
- Optimization runs
- 200
- EVM Version
- default
- Verified at
- 2023-04-13 10:02:51.173636Z
Constructor Arguments
000000000000000000000000b02a3a7e29c97c001211b594aa3e93933c31ad52000000000000000000000000da0786df404b2e1da57d0ee495f87462b90ea7e1
Arg [0] (address) : 0xb02a3a7e29c97c001211b594aa3e93933c31ad52
Arg [1] (address) : 0xda0786df404b2e1da57d0ee495f87462b90ea7e1
Contract source code
pragma solidity ^0.8.7;
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.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 Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
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);
}
}
abstract contract OwnerOperator is Ownable {
mapping(address => bool) public operators;
constructor() Ownable() {}
modifier operatorOrOwner() {
require(operators[msg.sender] || owner() == msg.sender, "OwnerOperator: !operator, !owner");
_;
}
modifier onlyOperator() {
require(operators[msg.sender], "OwnerOperator: !operator");
_;
}
function addOperator(address operator) external virtual onlyOwner {
require(operator != address(0), "OwnerOperator: operator is the zero address");
operators[operator] = true;
}
function removeOperator(address operator) external virtual onlyOwner {
require(operator != address(0), "OwnerOperator: operator is the zero address");
operators[operator] = false;
}
}
// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
abstract contract VerifySignature {
uint256 public timeExpiredSignature = 10 minutes;
function _setTimeExpiredSignature(uint256 _number) internal {
timeExpiredSignature = _number;
}
modifier signatureIsExpired(uint256 timestamp) {
require(
(block.timestamp - timestamp) <= timeExpiredSignature,
"Signature is expired"
);
_;
}
function getMessageHash(
address _to,
uint256 _amount,
uint256 _timestamp,
string memory _msgHash
) public pure returns (bytes32) {
return keccak256(abi.encodePacked(_to, _amount, _timestamp, _msgHash));
}
function getMessageHashClaimReward(
address _to,
uint256 _maxAmount,
uint256 _amount,
uint256 _timestamp,
string memory _msgHash
) public pure returns (bytes32) {
return
keccak256(
abi.encodePacked(_to, _maxAmount, _amount, _timestamp, _msgHash)
);
}
function getEthSignedMessageHash(bytes32 _messageHash)
public
pure
returns (bytes32)
{
return
keccak256(
abi.encodePacked(
"\x19Ethereum Signed Message:\n32",
_messageHash
)
);
}
function verifySignature(
address _signer,
address _to,
uint256 _amount,
uint256 _timestamp,
string memory _msgHash,
bytes memory _signature
) public pure returns (bool) {
bytes32 messageHash = getMessageHash(
_to,
_amount,
_timestamp,
_msgHash
);
bytes32 ethSignedMessageHash = getEthSignedMessageHash(messageHash);
return recoverSigner(ethSignedMessageHash, _signature) == _signer;
}
function verifySignatureClaimReward(
address _signer,
address _to,
uint256 _maxAmount,
uint256 _amount,
uint256 _timestamp,
string memory _msgHash,
bytes memory _signature
) public pure returns (bool) {
bytes32 messageHash = getMessageHashClaimReward(
_to,
_maxAmount,
_amount,
_timestamp,
_msgHash
);
bytes32 ethSignedMessageHash = getEthSignedMessageHash(messageHash);
return recoverSigner(ethSignedMessageHash, _signature) == _signer;
}
function recoverSigner(
bytes32 _ethSignedMessageHash,
bytes memory _signature
) public pure returns (address) {
(bytes32 r, bytes32 s, uint8 v) = splitSignature(_signature);
return ecrecover(_ethSignedMessageHash, v, r, s);
}
function splitSignature(bytes memory _sig)
public
pure
returns (
bytes32 r,
bytes32 s,
uint8 v
)
{
require(_sig.length == 65, "invalid signature length");
assembly {
r := mload(add(_sig, 32))
s := mload(add(_sig, 64))
v := byte(0, mload(add(_sig, 96)))
}
}
}
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
/**
* @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 v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 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 Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(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
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 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));
}
}
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet.
* ====
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping(bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastValue;
// Update the index for the moved value
set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
return _values(set._inner);
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}
interface IRewardUser {
struct RewardUser {
uint256 balance;
uint256 timestamp;
}
}
library Math {
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
}
/** @title Stake Pool Receive */
contract ReceiveStakingPool is
IRewardUser,
OwnerOperator,
VerifySignature
{
using SafeMath for uint256;
using SafeERC20 for IERC20;
using EnumerableSet for EnumerableSet.AddressSet;
address public tokenStake;
address public signerAddress;
uint256 public totalStaked;
string public constant MESSAGE_HASH = "RECEIVE_STAKING";
uint8 private constant PERCENT = 100;
// mapping public balanceUsers;
mapping(address => uint256) public balanceUsers;
event NotifyStake(address sender, uint256 amount);
event NotifyUnstake(address sender, uint256 amount);
EnumerableSet.AddressSet internal whitelistStake;
constructor(address _tokenStake, address _signerAddress) {
require(_tokenStake != address(0x0), "Token stake is invalid");
require(_signerAddress != address(0x0), "Signer address is invalid");
tokenStake = _tokenStake;
signerAddress = _signerAddress;
}
/**
@dev set balance users
@param addressUsers address[]
@param balances uint256[]
*/
function setBalanceUsers(
address[] memory addressUsers,
uint256[] memory balances
) external onlyOwner {
require(
addressUsers.length == balances.length,
"Array length doesn't match"
);
for (uint256 idx = 0; idx < addressUsers.length; idx++) {
balanceUsers[addressUsers[idx]] = balances[idx];
}
}
/**
@dev set time expired signature
@param _number uint256
*/
function setTimeExpiredSignature(uint256 _number) external onlyOperator {
_setTimeExpiredSignature(_number);
}
/**
@dev set total staked
@param amount uint256
*/
function setTotalStaked(uint256 amount) external onlyOperator {
totalStaked = amount;
}
/**
@dev add staking pool
@param _address address
*/
function addStakingPool(address _address) external onlyOperator {
require(_address != address(0x0), "Stake contract is invalid");
require(
whitelistStake.contains(_address) == false,
"Stake contract is already used"
);
whitelistStake.add(_address);
}
/** @dev add staking pool */
function getStakingPools() external view returns (address[] memory) {
return whitelistStake.values();
}
/**
@dev remove staking pool
@param _address address
*/
function removeStakingPool(address _address) external onlyOperator {
require(
whitelistStake.contains(_address) == true,
"Stake contract is not exists"
);
whitelistStake.remove(_address);
}
/**
@dev change _signerAddress
@param _signerAddress address
*/
function setSignerAddress(address _signerAddress) external onlyOperator {
require(_signerAddress != address(0x0), "Signer address is invalid");
signerAddress = _signerAddress;
}
/**
@dev user send ERC20 (PRZ) for staking
@param amount uint256
@param timestamp uint256
@param signature bytes memory
*/
function sendStaking(
uint256 amount,
uint256 timestamp,
bytes memory signature
) external signatureIsExpired(timestamp) {
require(
verifySignature(
signerAddress,
msg.sender,
amount,
timestamp,
MESSAGE_HASH,
signature
),
"Signature is invalid"
);
IERC20 erc20Token = IERC20(tokenStake);
// check allowance user is valid
require(
erc20Token.allowance(msg.sender, address(this)) >= amount,
"Allowance insufficient"
);
// transfer token erc20 form user to this contract
erc20Token.safeTransferFrom(msg.sender, address(this), amount);
balanceUsers[msg.sender] += amount;
totalStaked += amount;
emit NotifyStake(msg.sender, amount);
}
/**
@dev user unstaking
@param amount uint256
@param timestamp uint256
@param signature bytes memory
*/
function unstake(
uint256 amount,
uint256 timestamp,
bytes memory signature
) external signatureIsExpired(timestamp) {
require(
verifySignature(
signerAddress,
msg.sender,
amount,
timestamp,
MESSAGE_HASH,
signature
),
"Signature is invalid"
);
uint256 balance = balanceUsers[msg.sender];
require(amount <= balance, "Insufficient balance user");
IERC20 erc20Token = IERC20(tokenStake);
// check balance this contract is valid
require(
erc20Token.balanceOf(address(this)) >= amount,
"Insufficient balance"
);
erc20Token.approve(msg.sender, amount);
erc20Token.safeTransfer(msg.sender, amount);
balanceUsers[msg.sender] -= amount;
totalStaked = totalStaked.sub(amount);
// remove user from stake if user withdraw all balance
if (balanceUsers[msg.sender] == 0) {
delete balanceUsers[msg.sender];
}
emit NotifyUnstake(msg.sender, amount);
}
/**
@dev operator withdraw token erc20
@param amount uint256
@param tokenAddress address
*/
function withdrawTokenERC20(address tokenAddress, uint256 amount)
external
onlyOwner
{
IERC20 erc20Token = IERC20(tokenAddress);
require(
erc20Token.balanceOf(address(this)) >= amount,
"Insufficient balance"
);
// transfer token erc20 form user to this contract
erc20Token.safeTransfer(msg.sender, amount);
}
/**
@dev owner withdraw token erc20
@param amount uint256
*/
function withdraw(uint256 amount) external onlyOwner {
require(address(this).balance >= amount, "Insufficient balance");
// transfer native token form contract to user
payable(msg.sender).transfer(amount);
}
/** @dev get metadata staking pool */
function getMetaDataStakingPoolByUser(address user)
external
view
returns (
uint256 currentStaking,
uint256 totalStakingPool,
address[] memory stakingPools,
uint256[] memory balancePools
)
{
// get current staking by user
uint256 balanceUser = balanceUsers[user];
address[] memory listStakingPools = whitelistStake.values();
uint256[] memory balanceStakingPools = new uint256[](
listStakingPools.length
);
for (uint256 idx = 0; idx < listStakingPools.length; idx++) {
// Init staking pool from address
BaseStaking stakingPool = BaseStaking(listStakingPools[idx]);
balanceStakingPools[idx] = stakingPool.getBalances();
}
return (
balanceUser,
totalStaked,
listStakingPools,
balanceStakingPools
);
}
}
/** @title Base Staking Pool Contract */
contract BaseStaking is OwnerOperator, VerifySignature {
using SafeMath for uint256;
using SafeERC20 for IERC20;
using EnumerableSet for EnumerableSet.AddressSet;
address public receiveStakingPoolAddress;
uint256 internal constant PRICE_PRECISION = 1e9;
uint256 public minAmountClaim;
uint256 public adminReceiveFee;
address public adminReceiveFeeAddress;
address public signerAddress;
bool public lockClaimReward;
// user address => balance claimed
mapping(address => uint256) public rewardsUserClaimed;
constructor(address _receiveStakingPoolAddress, address _signerAddress) {
require(
_receiveStakingPoolAddress != address(0x0),
"Receive pool is invalid"
);
receiveStakingPoolAddress = _receiveStakingPoolAddress;
signerAddress = _signerAddress;
}
event NotifyClaimReward(
address claimer,
uint256 amount,
address tokenAddress
);
modifier isUnLockClaimReward() {
require(lockClaimReward == false, "Claim reward is locked");
_;
}
/**
@dev set time expired signature
@param _number uint256
*/
function setTimeExpiredSignature(uint256 _number) external onlyOperator {
_setTimeExpiredSignature(_number);
}
/**
@dev change _signerAddress
@param _signerAddress address
*/
function setSignerAddress(address _signerAddress) external onlyOperator {
require(_signerAddress != address(0x0), "Signer address is invalid");
signerAddress = _signerAddress;
}
/**
@dev set min amount claim
@param amount uint256
*/
function setMinAmountClaim(uint256 amount) external onlyOperator {
minAmountClaim = amount;
}
/**
@dev set admin receive fee
@param fee uint256
*/
function setAdminReceiveFee(uint256 fee) external onlyOperator {
adminReceiveFee = fee;
}
/**
@dev set admin receive address
@param _address address
*/
function setAdminReceiveFeeAddress(address _address) external onlyOperator {
adminReceiveFeeAddress = _address;
}
/**
@dev set lock claim reward
@param isLock bool
*/
function setLockClaimReward(bool isLock) external onlyOperator {
lockClaimReward = isLock;
}
function setRewardsUserClaimed(address[] calldata addresses, uint256[] calldata amounts) external onlyOperator {
require(addresses.length == amounts.length, "Invalid input data");
for (uint i = 0; i < addresses.length; i++) {
rewardsUserClaimed[addresses[i]] = amounts[i];
}
}
/**
@dev get balances
*/
function getBalances() external view virtual returns (uint256) {}
}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_tokenStake","internalType":"address"},{"type":"address","name":"_signerAddress","internalType":"address"}]},{"type":"event","name":"NotifyStake","inputs":[{"type":"address","name":"sender","internalType":"address","indexed":false},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"NotifyUnstake","inputs":[{"type":"address","name":"sender","internalType":"address","indexed":false},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"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":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"MESSAGE_HASH","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addOperator","inputs":[{"type":"address","name":"operator","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addStakingPool","inputs":[{"type":"address","name":"_address","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balanceUsers","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getEthSignedMessageHash","inputs":[{"type":"bytes32","name":"_messageHash","internalType":"bytes32"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getMessageHash","inputs":[{"type":"address","name":"_to","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"},{"type":"uint256","name":"_timestamp","internalType":"uint256"},{"type":"string","name":"_msgHash","internalType":"string"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getMessageHashClaimReward","inputs":[{"type":"address","name":"_to","internalType":"address"},{"type":"uint256","name":"_maxAmount","internalType":"uint256"},{"type":"uint256","name":"_amount","internalType":"uint256"},{"type":"uint256","name":"_timestamp","internalType":"uint256"},{"type":"string","name":"_msgHash","internalType":"string"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"currentStaking","internalType":"uint256"},{"type":"uint256","name":"totalStakingPool","internalType":"uint256"},{"type":"address[]","name":"stakingPools","internalType":"address[]"},{"type":"uint256[]","name":"balancePools","internalType":"uint256[]"}],"name":"getMetaDataStakingPoolByUser","inputs":[{"type":"address","name":"user","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"","internalType":"address[]"}],"name":"getStakingPools","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"operators","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"pure","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"recoverSigner","inputs":[{"type":"bytes32","name":"_ethSignedMessageHash","internalType":"bytes32"},{"type":"bytes","name":"_signature","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removeOperator","inputs":[{"type":"address","name":"operator","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removeStakingPool","inputs":[{"type":"address","name":"_address","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"sendStaking","inputs":[{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"timestamp","internalType":"uint256"},{"type":"bytes","name":"signature","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setBalanceUsers","inputs":[{"type":"address[]","name":"addressUsers","internalType":"address[]"},{"type":"uint256[]","name":"balances","internalType":"uint256[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setSignerAddress","inputs":[{"type":"address","name":"_signerAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setTimeExpiredSignature","inputs":[{"type":"uint256","name":"_number","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setTotalStaked","inputs":[{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"signerAddress","inputs":[]},{"type":"function","stateMutability":"pure","outputs":[{"type":"bytes32","name":"r","internalType":"bytes32"},{"type":"bytes32","name":"s","internalType":"bytes32"},{"type":"uint8","name":"v","internalType":"uint8"}],"name":"splitSignature","inputs":[{"type":"bytes","name":"_sig","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"timeExpiredSignature","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"tokenStake","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalStaked","inputs":[]},{"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":"amount","internalType":"uint256"},{"type":"uint256","name":"timestamp","internalType":"uint256"},{"type":"bytes","name":"signature","internalType":"bytes"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"verifySignature","inputs":[{"type":"address","name":"_signer","internalType":"address"},{"type":"address","name":"_to","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"},{"type":"uint256","name":"_timestamp","internalType":"uint256"},{"type":"string","name":"_msgHash","internalType":"string"},{"type":"bytes","name":"_signature","internalType":"bytes"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"verifySignatureClaimReward","inputs":[{"type":"address","name":"_signer","internalType":"address"},{"type":"address","name":"_to","internalType":"address"},{"type":"uint256","name":"_maxAmount","internalType":"uint256"},{"type":"uint256","name":"_amount","internalType":"uint256"},{"type":"uint256","name":"_timestamp","internalType":"uint256"},{"type":"string","name":"_msgHash","internalType":"string"},{"type":"bytes","name":"_signature","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdraw","inputs":[{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawTokenERC20","inputs":[{"type":"address","name":"tokenAddress","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]}]
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106101e55760003560e01c80639b0ef9ed1161010f578063c76b45ec116100a2578063e17e7a2011610071578063e17e7a201461047c578063e49a55281461048f578063f2fde38b146104a2578063fa540801146104b557600080fd5b8063c76b45ec1461043a578063cba974b21461044d578063cd6ef9b114610460578063dd032d341461047357600080fd5b8063ac0f3386116100de578063ac0f3386146103ee578063ac8a584a14610401578063af51462b14610414578063b124eda91461042757600080fd5b80639b0ef9ed1461034c578063a195f0201461035f578063a7bb58031461039a578063ab64647d146103cb57600080fd5b80635b7633d0116101875780638da5cb5b116101565780638da5cb5b1461030257806397aba7f9146103135780639870d7fe146103265780639a5aea511461033957600080fd5b80635b7633d0146102b3578063715018a6146102de5780637bfce806146102e6578063817b1cd2146102f957600080fd5b80632597e944116101c35780632597e9441461024a5780632e1a7d4d1461025d57806339f60ca814610270578063417243c91461029e57600080fd5b8063046dc166146101ea57806313e7c9d8146101ff5780631e9ab75414610237575b600080fd5b6101fd6101f8366004611a0d565b6104c8565b005b61022261020d366004611a0d565b60016020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b6101fd610245366004611a0d565b610578565b610222610258366004611a28565b610612565b6101fd61026b366004611d40565b61065b565b61029061027e366004611a0d565b60066020526000908152604090205481565b60405190815260200161022e565b6102a66106b0565b60405161022e9190611f27565b6004546102c6906001600160a01b031681565b6040516001600160a01b03909116815260200161022e565b6101fd6106c1565b6101fd6102f4366004611c57565b6106d5565b61029060055481565b6000546001600160a01b03166102c6565b6102c6610321366004611d59565b6107ae565b6101fd610334366004611a0d565b61082e565b610222610347366004611abf565b610883565b6101fd61035a366004611de4565b6108ce565b61038d6040518060400160405280600f81526020016e524543454956455f5354414b494e4760881b81525081565b60405161022e9190611f3a565b6103ad6103a8366004611d96565b610b06565b60408051938452602084019290925260ff169082015260600161022e565b6103de6103d9366004611a0d565b610b7a565b60405161022e949392919061201d565b6101fd6103fc366004611b61565b610ccc565b6101fd61040f366004611a0d565b610d81565b6101fd610422366004611d40565b610dd0565b6101fd610435366004611a0d565b610e0b565b6003546102c6906001600160a01b031681565b61029061045b366004611bec565b610ef3565b6101fd61046e366004611de4565b610f2f565b61029060025481565b6101fd61048a366004611d40565b611235565b61029061049d366004611b8b565b611269565b6101fd6104b0366004611a0d565b6112a2565b6102906104c3366004611d40565b611318565b3360009081526001602052604090205460ff166105005760405162461bcd60e51b81526004016104f790611f6d565b60405180910390fd5b6001600160a01b0381166105565760405162461bcd60e51b815260206004820152601960248201527f5369676e6572206164647265737320697320696e76616c69640000000000000060448201526064016104f7565b600480546001600160a01b0319166001600160a01b0392909216919091179055565b3360009081526001602052604090205460ff166105a75760405162461bcd60e51b81526004016104f790611f6d565b6105b260078261136b565b15156001146106035760405162461bcd60e51b815260206004820152601c60248201527f5374616b6520636f6e7472616374206973206e6f74206578697374730000000060448201526064016104f7565b61060e600782611390565b5050565b60008061062187878787611269565b9050600061062e82611318565b9050886001600160a01b031661064482866107ae565b6001600160a01b0316149998505050505050505050565b6106636113a5565b804710156106835760405162461bcd60e51b81526004016104f790611fef565b604051339082156108fc029083906000818181858888f1935050505015801561060e573d6000803e3d6000fd5b60606106bc60076113ff565b905090565b6106c96113a5565b6106d3600061140c565b565b6106dd6113a5565b805182511461072e5760405162461bcd60e51b815260206004820152601a60248201527f4172726179206c656e67746820646f65736e2774206d6174636800000000000060448201526064016104f7565b60005b82518110156107a95781818151811061074c5761074c612176565b60200260200101516006600085848151811061076a5761076a612176565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000208190555080806107a19061212f565b915050610731565b505050565b6000806000806107bd85610b06565b6040805160008152602081018083528b905260ff8316918101919091526060810184905260808101839052929550909350915060019060a0016020604051602081039080840390855afa158015610818573d6000803e3d6000fd5b5050506020604051035193505050505b92915050565b6108366113a5565b6001600160a01b03811661085c5760405162461bcd60e51b81526004016104f790611fa4565b6001600160a01b03166000908152600160208190526040909120805460ff19169091179055565b6000806108938888888888610ef3565b905060006108a082611318565b9050896001600160a01b03166108b682866107ae565b6001600160a01b0316149a9950505050505050505050565b60025482906108dd82426120ec565b11156109225760405162461bcd60e51b815260206004820152601460248201527314da59db985d1d5c99481a5cc8195e1c1a5c995960621b60448201526064016104f7565b60045460408051808201909152600f81526e524543454956455f5354414b494e4760881b6020820152610965916001600160a01b03169033908790879087610612565b6109a85760405162461bcd60e51b815260206004820152601460248201527314da59db985d1d5c99481a5cc81a5b9d985b1a5960621b60448201526064016104f7565b600354604051636eb1769f60e11b81523360048201523060248201526001600160a01b03909116908590829063dd62ed3e9060440160206040518083038186803b1580156109f557600080fd5b505afa158015610a09573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a2d9190611dcb565b1015610a745760405162461bcd60e51b8152602060048201526016602482015275105b1b1bddd85b98d9481a5b9cdd59999a58da595b9d60521b60448201526064016104f7565b610a896001600160a01b03821633308861145c565b3360009081526006602052604081208054879290610aa89084906120d4565b925050819055508460056000828254610ac191906120d4565b909155505060408051338152602081018790527fee1c5a297c6127ab2403486b73254bcc1dd91a0da12802fa55fb8ac423c39b70910160405180910390a15050505050565b60008060008351604114610b5c5760405162461bcd60e51b815260206004820152601860248201527f696e76616c6964207369676e6174757265206c656e677468000000000000000060448201526064016104f7565b50505060208101516040820151606090920151909260009190911a90565b6001600160a01b0381166000908152600660205260408120548190606090819083610ba560076113ff565b90506000815167ffffffffffffffff811115610bc357610bc361218c565b604051908082528060200260200182016040528015610bec578160200160208202803683370190505b50905060005b8251811015610cb9576000838281518110610c0f57610c0f612176565b60200260200101519050806001600160a01b031662113e086040518163ffffffff1660e01b815260040160206040518083038186803b158015610c5157600080fd5b505afa158015610c65573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c899190611dcb565b838381518110610c9b57610c9b612176565b60209081029190910101525080610cb18161212f565b915050610bf2565b5060055492989297509095509350915050565b610cd46113a5565b6040516370a0823160e01b8152306004820152829082906001600160a01b038316906370a082319060240160206040518083038186803b158015610d1757600080fd5b505afa158015610d2b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d4f9190611dcb565b1015610d6d5760405162461bcd60e51b81526004016104f790611fef565b6107a96001600160a01b03821633846114cd565b610d896113a5565b6001600160a01b038116610daf5760405162461bcd60e51b81526004016104f790611fa4565b6001600160a01b03166000908152600160205260409020805460ff19169055565b3360009081526001602052604090205460ff16610dff5760405162461bcd60e51b81526004016104f790611f6d565b610e0881600255565b50565b3360009081526001602052604090205460ff16610e3a5760405162461bcd60e51b81526004016104f790611f6d565b6001600160a01b038116610e905760405162461bcd60e51b815260206004820152601960248201527f5374616b6520636f6e747261637420697320696e76616c69640000000000000060448201526064016104f7565b610e9b60078261136b565b15610ee85760405162461bcd60e51b815260206004820152601e60248201527f5374616b6520636f6e747261637420697320616c72656164792075736564000060448201526064016104f7565b61060e6007826114fd565b60008585858585604051602001610f0e959493929190611ebe565b60405160208183030381529060405280519060200120905095945050505050565b6002548290610f3e82426120ec565b1115610f835760405162461bcd60e51b815260206004820152601460248201527314da59db985d1d5c99481a5cc8195e1c1a5c995960621b60448201526064016104f7565b60045460408051808201909152600f81526e524543454956455f5354414b494e4760881b6020820152610fc6916001600160a01b03169033908790879087610612565b6110095760405162461bcd60e51b815260206004820152601460248201527314da59db985d1d5c99481a5cc81a5b9d985b1a5960621b60448201526064016104f7565b33600090815260066020526040902054808511156110695760405162461bcd60e51b815260206004820152601960248201527f496e73756666696369656e742062616c616e636520757365720000000000000060448201526064016104f7565b6003546040516370a0823160e01b81523060048201526001600160a01b0390911690869082906370a082319060240160206040518083038186803b1580156110b057600080fd5b505afa1580156110c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110e89190611dcb565b10156111065760405162461bcd60e51b81526004016104f790611fef565b60405163095ea7b360e01b8152336004820152602481018790526001600160a01b0382169063095ea7b390604401602060405180830381600087803b15801561114e57600080fd5b505af1158015611162573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111869190611d1e565b5061119b6001600160a01b03821633886114cd565b33600090815260066020526040812080548892906111ba9084906120ec565b90915550506005546111cc9087611512565b600555336000908152600660205260409020546111f457336000908152600660205260408120555b60408051338152602081018890527fcf2eb3f1c381efd5863bf6d0d09484b51a4ad9d778ba23edeb14a10c56aa41b9910160405180910390a1505050505050565b3360009081526001602052604090205460ff166112645760405162461bcd60e51b81526004016104f790611f6d565b600555565b6000848484846040516020016112829493929190611e78565b604051602081830303815290604052805190602001209050949350505050565b6112aa6113a5565b6001600160a01b03811661130f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016104f7565b610e088161140c565b6040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b6001600160a01b038116600090815260018301602052604081205415155b9392505050565b6000611389836001600160a01b03841661151e565b6000546001600160a01b031633146106d35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104f7565b6060600061138983611611565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040516001600160a01b03808516602483015283166044820152606481018290526114c79085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261166d565b50505050565b6040516001600160a01b0383166024820152604481018290526107a990849063a9059cbb60e01b90606401611490565b6000611389836001600160a01b03841661173f565b600061138982846120ec565b600081815260018301602052604081205480156116075760006115426001836120ec565b8554909150600090611556906001906120ec565b90508181146115bb57600086600001828154811061157657611576612176565b906000526020600020015490508087600001848154811061159957611599612176565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806115cc576115cc612160565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610828565b6000915050610828565b60608160000180548060200260200160405190810160405280929190818152602001828054801561166157602002820191906000526020600020905b81548152602001906001019080831161164d575b50505050509050919050565b60006116c2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661178e9092919063ffffffff16565b8051909150156107a957808060200190518101906116e09190611d1e565b6107a95760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016104f7565b600081815260018301602052604081205461178657508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610828565b506000610828565b606061179d84846000856117a5565b949350505050565b6060824710156118065760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016104f7565b6001600160a01b0385163b61185d5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016104f7565b600080866001600160a01b031685876040516118799190611f0b565b60006040518083038185875af1925050503d80600081146118b6576040519150601f19603f3d011682016040523d82523d6000602084013e6118bb565b606091505b50915091506118cb8282866118d6565b979650505050505050565b606083156118e5575081611389565b8251156118f55782518084602001fd5b8160405162461bcd60e51b81526004016104f79190611f3a565b80356001600160a01b038116811461192657600080fd5b919050565b600082601f83011261193c57600080fd5b8135602061195161194c836120b0565b61207f565b80838252828201915082860187848660051b890101111561197157600080fd5b60005b8581101561199057813584529284019290840190600101611974565b5090979650505050505050565b600082601f8301126119ae57600080fd5b813567ffffffffffffffff8111156119c8576119c861218c565b6119db601f8201601f191660200161207f565b8181528460208386010111156119f057600080fd5b816020850160208301376000918101602001919091529392505050565b600060208284031215611a1f57600080fd5b6113898261190f565b60008060008060008060c08789031215611a4157600080fd5b611a4a8761190f565b9550611a586020880161190f565b94506040870135935060608701359250608087013567ffffffffffffffff80821115611a8357600080fd5b611a8f8a838b0161199d565b935060a0890135915080821115611aa557600080fd5b50611ab289828a0161199d565b9150509295509295509295565b600080600080600080600060e0888a031215611ada57600080fd5b611ae38861190f565b9650611af16020890161190f565b955060408801359450606088013593506080880135925060a088013567ffffffffffffffff80821115611b2357600080fd5b611b2f8b838c0161199d565b935060c08a0135915080821115611b4557600080fd5b50611b528a828b0161199d565b91505092959891949750929550565b60008060408385031215611b7457600080fd5b611b7d8361190f565b946020939093013593505050565b60008060008060808587031215611ba157600080fd5b611baa8561190f565b93506020850135925060408501359150606085013567ffffffffffffffff811115611bd457600080fd5b611be08782880161199d565b91505092959194509250565b600080600080600060a08688031215611c0457600080fd5b611c0d8661190f565b9450602086013593506040860135925060608601359150608086013567ffffffffffffffff811115611c3e57600080fd5b611c4a8882890161199d565b9150509295509295909350565b60008060408385031215611c6a57600080fd5b823567ffffffffffffffff80821115611c8257600080fd5b818501915085601f830112611c9657600080fd5b81356020611ca661194c836120b0565b8083825282820191508286018a848660051b8901011115611cc657600080fd5b600096505b84871015611cf057611cdc8161190f565b835260019690960195918301918301611ccb565b5096505086013592505080821115611d0757600080fd5b50611d148582860161192b565b9150509250929050565b600060208284031215611d3057600080fd5b8151801515811461138957600080fd5b600060208284031215611d5257600080fd5b5035919050565b60008060408385031215611d6c57600080fd5b82359150602083013567ffffffffffffffff811115611d8a57600080fd5b611d148582860161199d565b600060208284031215611da857600080fd5b813567ffffffffffffffff811115611dbf57600080fd5b61179d8482850161199d565b600060208284031215611ddd57600080fd5b5051919050565b600080600060608486031215611df957600080fd5b8335925060208401359150604084013567ffffffffffffffff811115611e1e57600080fd5b611e2a8682870161199d565b9150509250925092565b600081518084526020808501945080840160005b83811015611e6d5781516001600160a01b031687529582019590820190600101611e48565b509495945050505050565b6bffffffffffffffffffffffff198560601b16815283601482015282603482015260008251611eae816054850160208701612103565b9190910160540195945050505050565b6bffffffffffffffffffffffff198660601b16815284601482015283603482015282605482015260008251611efa816074850160208701612103565b919091016074019695505050505050565b60008251611f1d818460208701612103565b9190910192915050565b6020815260006113896020830184611e34565b6020815260008251806020840152611f59816040850160208701612103565b601f01601f19169190910160400192915050565b60208082526018908201527f4f776e65724f70657261746f723a20216f70657261746f720000000000000000604082015260600190565b6020808252602b908201527f4f776e65724f70657261746f723a206f70657261746f7220697320746865207a60408201526a65726f206164647265737360a81b606082015260800190565b602080825260149082015273496e73756666696369656e742062616c616e636560601b604082015260600190565b8481526000602085818401526080604084015261203d6080840186611e34565b838103606085015284518082528286019183019060005b8181101561207057835183529284019291840191600101612054565b50909998505050505050505050565b604051601f8201601f1916810167ffffffffffffffff811182821017156120a8576120a861218c565b604052919050565b600067ffffffffffffffff8211156120ca576120ca61218c565b5060051b60200190565b600082198211156120e7576120e761214a565b500190565b6000828210156120fe576120fe61214a565b500390565b60005b8381101561211e578181015183820152602001612106565b838111156114c75750506000910152565b60006000198214156121435761214361214a565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfea2646970667358221220091bb8251e8d321f1648ef1e5ad5c17022fe2a389aa55d50d099e1426ee2629564736f6c63430008070033