Transactions
Token Transfers
Tokens
Internal Transactions
Coin Balance History
Logs
Code
Read Contract
Write Contract
- Contract name:
- Pepper
- Optimization enabled
- true
- Compiler version
- v0.8.19+commit.7dd6d404
- Optimization runs
- 200
- EVM Version
- default
- Verified at
- 2024-09-27T15:22:28.246134Z
Constructor Arguments
0x000000000000000000000000000000000000000000000000000000000107b2fa000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000006504550504552000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000065045505045520000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b0000000000000000000000008d9b6ab3fe8ebf16d9242e48fefb89360fa62820000000000000000000000000a90da6fba59d0ba2fb1348fd2f03b880742fa00e000000000000000000000000ecb60190a0bf9f4d8aa8cc2f0293aa91192d318700000000000000000000000031db81188a5cc391857624f668dda57ba7f2b074000000000000000000000000a4c22224c33fcbf204841399df1f268d13de0339000000000000000000000000f84aed72066e635fd9b0f2fbddbdb77a8761d02800000000000000000000000031dd5a7429ae591d2d73935c001dd148fabdd2cf00000000000000000000000084af28c88be1916ceb199394dd6a1493a1287ada000000000000000000000000bf968b8a455da0dfc0852899c334b6f5f6e20b5f000000000000000000000000f57c7a5bcb023ab18683a46fa25a00fb19d651be000000000000000000000000579391c9865545000d8922acf71a660521cc6404
Arg [0] (uint256) : 17281786
Arg [1] (string) : PEPPER
Arg [2] (string) : PEPPER
Arg [3] (address[]) : [0x8d9b6ab3fe8ebf16d9242e48fefb89360fa62820, 0xa90da6fba59d0ba2fb1348fd2f03b880742fa00e, 0xecb60190a0bf9f4d8aa8cc2f0293aa91192d3187, 0x31db81188a5cc391857624f668dda57ba7f2b074, 0xa4c22224c33fcbf204841399df1f268d13de0339, 0xf84aed72066e635fd9b0f2fbddbdb77a8761d028, 0x31dd5a7429ae591d2d73935c001dd148fabdd2cf, 0x84af28c88be1916ceb199394dd6a1493a1287ada, 0xbf968b8a455da0dfc0852899c334b6f5f6e20b5f, 0xf57c7a5bcb023ab18683a46fa25a00fb19d651be, 0x579391c9865545000d8922acf71a660521cc6404]
Contract source code
// SPDX-License-Identifier: MIT
pragma solidity =0.8.19 ^0.8.0;
// lib/openzeppelin-contracts/contracts/access/IAccessControl.sol
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) external;
}
// lib/openzeppelin-contracts/contracts/security/ReentrancyGuard.sol
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
}
// lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol
// OpenZeppelin Contracts (last updated v4.9.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);
}
// lib/openzeppelin-contracts/contracts/utils/Context.sol
// OpenZeppelin Contracts (last updated v4.9.4) (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;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
// lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// lib/openzeppelin-contracts/contracts/utils/math/Math.sol
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @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;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1, "Math: mulDiv overflow");
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
}
}
}
// lib/openzeppelin-contracts/contracts/utils/math/SignedMath.sol
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}
// src/interfaces/IStakingPoolPepper.sol
interface IStakingPool {
struct ValidatorPool {
address validatorAddress;
uint256 sharesSupply;
uint256 totalStakedAmount;
uint256 dustRewards;
uint256 pendingUnstake;
}
function getStakedAmount(address validator, address staker) external view returns (uint256);
function getShares(address validator, address staker) external view returns (uint256);
function getValidatorPool(address validator) external view returns (ValidatorPool memory);
function getValidatorPoolWithoutRewards(address validator) external view returns (ValidatorPool memory);
function stake(address validator) external payable;
function unstake(address validator, uint256 amount) external;
function claimableRewards(address validator, address staker) external view returns (uint256);
function claim(address validator) external;
}
// src/interfaces/IValidatorSet.sol
interface IValidatorSet {
function getValidators() external view returns (address[] memory);
function deposit(address validator) external payable;
}
// lib/openzeppelin-contracts/contracts/access/Ownable.sol
// OpenZeppelin Contracts (last updated v4.9.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. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling 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);
}
}
// lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.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);
}
// lib/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
// src/interfaces/IStaking.sol
interface IStaking is IValidatorSet {
function currentEpoch() external view returns (uint64);
function nextEpoch() external view returns (uint64);
function isValidatorActive(address validator) external view returns (bool);
function isValidator(address validator) external view returns (bool);
function getValidatorStatus(address validator) external view returns (
address ownerAddress,
uint8 status,
uint256 totalDelegated,
uint32 slashesCount,
uint64 changedAt,
uint64 jailedBefore,
uint64 claimedAt,
uint16 commissionRate,
uint96 totalRewards
);
function getValidatorStatusAtEpoch(address validator, uint64 epoch) external view returns (
address ownerAddress,
uint8 status,
uint256 totalDelegated,
uint32 slashesCount,
uint64 changedAt,
uint64 jailedBefore,
uint64 claimedAt,
uint16 commissionRate,
uint96 totalRewards
);
function getValidatorByOwner(address owner) external view returns (address);
function registerValidator(address validator, uint16 commissionRate) payable external;
function addValidator(address validator) external;
function removeValidator(address validator) external;
function activateValidator(address validator) external;
function disableValidator(address validator) external;
function releaseValidatorFromJail(address validator) external;
function changeValidatorCommissionRate(address validator, uint16 commissionRate) external;
function changeValidatorOwner(address validator, address newOwner) external;
function getValidatorDelegation(address validator, address delegator) external view returns (
uint256 delegatedAmount,
uint64 atEpoch
);
function delegate(address validator) payable external;
function undelegate(address validator, uint256 amount) external;
function getValidatorFee(address validator) external view returns (uint256);
function getValidatorFeeAtEpoch(address validator, uint64 beforeEpoch) external view returns (uint256);
function getPendingValidatorFee(address validator) external view returns (uint256);
function claimValidatorFee(address validator) external;
function claimValidatorFeeAtEpoch(address validator, uint64 beforeEpoch) external;
function getDelegatorFee(address validator, address delegator) external view returns (uint256);
function getDelegatorFeeAtEpoch(address validator, address delegator, uint64) external view returns (uint256);
function getPendingDelegatorFee(address validator, address delegator) external view returns (uint256);
function claimDelegatorFee(address validator) external;
function calcAvailableForRedelegateAmount(address validator, address delegator) external view returns (uint256 amountToStake, uint256 rewardsDust);
function claimPendingUndelegates(address validator) external;
function redelegateDelegatorFee(address validator) external returns (uint256 amountToStake, uint256 rewardsDust);
function claimDelegatorFeeAtEpoch(address validator, uint64 beforeEpoch) external;
function slash(address validator) external;
}
// lib/openzeppelin-contracts/contracts/utils/Strings.sol
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toString(int256 value) internal pure returns (string memory) {
return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return keccak256(bytes(a)) == keccak256(bytes(b));
}
}
// lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
* - the caller must have allowance for ``from``'s tokens of at least
* `amount`.
*/
function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(address from, address to, uint256 amount) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
// decrementing then incrementing.
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
// Overflow not possible: amount <= accountBalance <= totalSupply.
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
}
// lib/openzeppelin-contracts/contracts/token/ERC20/extensions/ERC20Capped.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/ERC20Capped.sol)
/**
* @dev Extension of {ERC20} that adds a cap to the supply of tokens.
*/
abstract contract ERC20Capped is ERC20 {
uint256 private immutable _cap;
/**
* @dev Sets the value of the `cap`. This value is immutable, it can only be
* set once during construction.
*/
constructor(uint256 cap_) {
require(cap_ > 0, "ERC20Capped: cap is 0");
_cap = cap_;
}
/**
* @dev Returns the cap on the token's total supply.
*/
function cap() public view virtual returns (uint256) {
return _cap;
}
/**
* @dev See {ERC20-_mint}.
*/
function _mint(address account, uint256 amount) internal virtual override {
require(ERC20.totalSupply() + amount <= cap(), "ERC20Capped: cap exceeded");
super._mint(account, amount);
}
}
// lib/openzeppelin-contracts/contracts/access/AccessControl.sol
// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `_msgSender()` is missing `role`.
* Overriding this function changes the behavior of the {onlyRole} modifier.
*
* Format of the revert message is described in {_checkRole}.
*
* _Available since v4.6._
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(account),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* May emit a {RoleGranted} event.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*
* NOTE: This function is deprecated in favor of {_grantRole}.
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Grants `role` to `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
/**
* @dev Revokes `role` from `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
}
// src/Pepper.sol
contract Pepper is ERC20Capped, Ownable, AccessControl, ReentrancyGuard {
uint256 public constant MAX_SUPPLY = 8888888888000000 * 10 ** 18;
uint256 public constant MINT_LIMIT = (MAX_SUPPLY * 40) / 100;
uint16 public EPOCH_LENGTH = 28800; // 1 day
bool public claimEnabled = true;
uint256 public minCHZStaked = 100 * 10 ** 18;
uint256 public CHZStakedRewards = 250000;
uint256 public minterRoleMintedAmount = 0;
uint256 public claimStartBlock = 0;
IStaking public stakingContract = IStaking(0x0000000000000000000000000000000000001000);
IStakingPool public stakingPoolContract = IStakingPool(0x0000000000000000000000000000000000007001);
struct Claim {
uint256 amountStakingPoolClaimed;
uint256 amountStakingClaimed;
uint256 blockNumber;
}
// user => epoch => Claim
mapping(address => mapping(uint256 => Claim)) public claims;
// List of validator addresses
address[] internal validators;
// Define a new role identifier for the minter role
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
modifier onlyMinter() {
require(hasRole(MINTER_ROLE, msg.sender), "Must have minter role to mint");
_;
}
event Claimed(address indexed account, uint256 indexed amountStakingPool, uint256 indexed amountStaking);
event StakingContractChanged(address indexed newStakingContract);
event StakingPoolContractChanged(address indexed newStakingPoolContract);
event MinimumCHZStakedAmountChanged(uint256 indexed chzAmount);
event EpochLengthChanged(uint16 indexed epochLength);
event ClaimStartBlockChanged(uint256 indexed newStartBlock);
event RewardsCHZStakedAmountChanged(uint256 indexed pepperAmount);
event ClaimEnabledStatusChanged(bool indexed status);
constructor(
uint256 _claimStartBlock,
string memory _tokenName,
string memory _tokenSymbol,
address[] memory initialValidators
) ERC20(_tokenName, _tokenSymbol) ERC20Capped(MAX_SUPPLY) {
require(_claimStartBlock != uint256(0), "_claimStartBlock cannot be 0");
claimStartBlock = _claimStartBlock;
// Set initial validators
validators = initialValidators;
// Grant the contract deployer the default admin role: it will be able to grant and revoke any roles
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(MINTER_ROLE, msg.sender);
}
// ================================ Setters ==================================
function changeStakingContract(address newStakingContract) public onlyOwner {
require(newStakingContract != address(0), "Invalid staking contract");
stakingContract = IStaking(newStakingContract);
emit StakingContractChanged(newStakingContract);
}
function changeStakingPoolContract(address newStakingPoolContract) public onlyOwner {
require(newStakingPoolContract != address(0), "Invalid staking pool contract");
stakingPoolContract = IStakingPool(newStakingPoolContract);
emit StakingPoolContractChanged(newStakingPoolContract);
}
// NOTE:- The minCHZStaked should be stored in Wei
function changeMinimumCHZStakedAmount(uint256 chzAmount) public onlyOwner {
minCHZStaked = chzAmount;
emit MinimumCHZStakedAmountChanged(chzAmount);
}
function changeRewardsCHZStakedAmount(uint256 pepperAmount) public onlyOwner {
CHZStakedRewards = pepperAmount;
emit RewardsCHZStakedAmountChanged(pepperAmount);
}
function addMinter(address minter) public onlyOwner {
grantRole(MINTER_ROLE, minter);
}
function removeMinter(address minter) public onlyOwner {
revokeRole(MINTER_ROLE, minter);
}
function setClaimEnabled(bool enabled) public onlyOwner {
require(enabled != claimEnabled, "Claim status already in the desired status");
claimEnabled = enabled;
emit ClaimEnabledStatusChanged(enabled);
}
// ================================ Validator Management ==================================
function addValidator(address validator) external onlyOwner {
require(!isValidator(validator), "Validator already exists");
require(validator != address(0), "Invalid validator address");
validators.push(validator);
}
function isValidator(address validator) public view returns (bool) {
uint256 validatorCount = validators.length;
for (uint256 i = 0; i < validatorCount; i++) {
if (validators[i] == validator) {
return true;
}
}
return false;
}
function removeValidator(address validator) external onlyOwner {
require(validator != address(0), "Invalid validator address");
uint256 validatorCount = validators.length;
for (uint256 i = 0; i < validatorCount; i++) {
if (validators[i] == validator) {
validators[i] = validators[validators.length - 1];
validators.pop();
break;
}
}
}
function getValidators() external view returns (address[] memory) {
return validators;
}
function getNumberOfValidators() external view returns (uint256) {
return validators.length;
}
function changeClaimStartBlock(uint256 newStartBlock) public onlyOwner {
require(!claimEnabled, "Claim currently active");
require(newStartBlock != uint256(0), "Claim start block cannot be 0");
require(block.number < newStartBlock, "Claim is enabled and ongoing");
claimStartBlock = newStartBlock;
emit ClaimStartBlockChanged(newStartBlock);
}
// ================================ Functionalities ==================================
function mint(address to, uint256 amount) public onlyMinter nonReentrant {
uint256 newMinterRoleMintedAmount = minterRoleMintedAmount + amount;
require(newMinterRoleMintedAmount <= MINT_LIMIT, "Minting exceeds 40% of total supply for the minter role");
uint256 newTotalSupply = totalSupply() + amount;
require(newTotalSupply <= MAX_SUPPLY, "Max supply reached");
minterRoleMintedAmount = newMinterRoleMintedAmount;
_mint(to, amount);
}
function burn(uint256 amount) public onlyOwner {
_burn(msg.sender, amount);
}
function getCurrentEpoch() public view returns (uint256 _epoch) {
return (block.number - claimStartBlock) / EPOCH_LENGTH;
}
/*
Logic to summarize rewards for a given address
*/
function calculateRewards(address account)
public
view
returns (uint256 rewardStakingPoolAmount, uint256 rewardStakingAmount)
{
uint256 stakingPoolStakes = 0;
uint256 stakingContractStakes = 0;
uint256 rewardStakingPool = 0;
uint256 rewardStaking = 0;
for (uint256 i = 0; i < validators.length; i++) {
// Check stakes in StakingPool
uint256 stakedAmount = stakingPoolContract.getStakedAmount(validators[i], account);
stakingPoolStakes += stakedAmount;
// Check stakes in Staking
(uint256 delegatedAmount,) = stakingContract.getValidatorDelegation(validators[i], account);
stakingContractStakes += delegatedAmount;
}
// Check rewards for stakes: (CHZStakedRewards)
if (stakingPoolStakes + stakingContractStakes >= minCHZStaked) {
rewardStakingPool = stakingPoolStakes * CHZStakedRewards;
rewardStaking = stakingContractStakes * CHZStakedRewards;
}
return (rewardStakingPool, rewardStaking);
}
function calculateRewards2(address account)
public
view
returns (uint256 rewardStakingPoolAmount, uint256 rewardStakingAmount)
{
uint256 stakingPoolStakes = 0;
uint256 stakingContractStakes = 0;
uint256 rewardStakingPool = 0;
uint256 rewardStaking = 0;
for (uint256 i = 0; i < validators.length; i++) {
// Check stakes in StakingPool by usin the future getValidatorPoolWithoutRewards function instead
// it should cost less gas
IStakingPool.ValidatorPool memory pool = stakingPoolContract.getValidatorPoolWithoutRewards(validators[i]);
uint256 totalStakedInPool = pool.totalStakedAmount;
uint256 poolRatio = 1e18;
if (totalStakedInPool > 0) {
poolRatio = (pool.sharesSupply * 1e18 + totalStakedInPool - 1) / totalStakedInPool;
}
uint256 accountShares = stakingPoolContract.getShares(validators[i], account);
stakingPoolStakes += accountShares * 1e18 / poolRatio;
// Check stakes in Staking
(uint256 delegatedAmount,) = stakingContract.getValidatorDelegation(validators[i], account);
stakingContractStakes += delegatedAmount;
}
// Check rewards for stakes: (CHZStakedRewards)
if (stakingPoolStakes + stakingContractStakes >= minCHZStaked) {
rewardStakingPool = stakingPoolStakes * CHZStakedRewards;
rewardStaking = stakingContractStakes * CHZStakedRewards;
}
return (rewardStakingPool, rewardStaking);
}
function getClaimStatus() public view returns (bool) {
return block.number >= claimStartBlock && claimEnabled;
}
function _calculateRewards(
address account
) private view returns (uint256 rewardStakingPoolAmount, uint256 rewardStakingAmount) {
require(getClaimStatus(), "Claim is not enabled");
uint256 currentEpoch = getCurrentEpoch();
require(claims[account][currentEpoch].blockNumber == 0, "Already claimed for this epoch");
return calculateRewards(account);
}
function _calculateRewards2(
address account
) private view returns (uint256 rewardStakingPoolAmount, uint256 rewardStakingAmount) {
require(getClaimStatus(), "Claim is not enabled");
uint256 currentEpoch = getCurrentEpoch();
require(claims[account][currentEpoch].blockNumber == 0, "Already claimed for this epoch");
return calculateRewards2(account);
}
/*
Logic to fetch caller's total Pepper
*/
function getPendingClaim() external view returns (uint256 pendingHarvest) {
(uint256 rewardStakingPool, uint256 rewardStaking) = _calculateRewards(msg.sender);
return rewardStakingPool + rewardStaking;
}
function getPendingClaim2() external view returns (uint256 pendingHarvest) {
(uint256 rewardStakingPool, uint256 rewardStaking) = _calculateRewards2(msg.sender);
return rewardStakingPool + rewardStaking;
}
/*
Logic to harvest Pepper
*/
function claim() external nonReentrant {
(uint256 rewardStakingPool, uint256 rewardStaking) = _calculateRewards(msg.sender);
claims[msg.sender][getCurrentEpoch()] = Claim({
amountStakingPoolClaimed: rewardStakingPool,
amountStakingClaimed: rewardStaking,
blockNumber: block.number
});
emit Claimed(msg.sender, rewardStakingPool, rewardStaking);
_mint(msg.sender, rewardStakingPool + rewardStaking);
}
function claim2() external nonReentrant {
(uint256 rewardStakingPool, uint256 rewardStaking) = _calculateRewards2(msg.sender);
claims[msg.sender][getCurrentEpoch()] = Claim({
amountStakingPoolClaimed: rewardStakingPool,
amountStakingClaimed: rewardStaking,
blockNumber: block.number
});
emit Claimed(msg.sender, rewardStakingPool, rewardStaking);
_mint(msg.sender, rewardStakingPool + rewardStaking);
}
}
Contract ABI
[{"type":"constructor","inputs":[{"type":"uint256","name":"_claimStartBlock","internalType":"uint256"},{"type":"string","name":"_tokenName","internalType":"string"},{"type":"string","name":"_tokenSymbol","internalType":"string"},{"type":"address[]","name":"initialValidators","internalType":"address[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"CHZStakedRewards","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"DEFAULT_ADMIN_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint16","name":"","internalType":"uint16"}],"name":"EPOCH_LENGTH","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"MAX_SUPPLY","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"MINTER_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"MINT_LIMIT","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addMinter","inputs":[{"type":"address","name":"minter","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addValidator","inputs":[{"type":"address","name":"validator","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"allowance","inputs":[{"type":"address","name":"owner","internalType":"address"},{"type":"address","name":"spender","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"approve","inputs":[{"type":"address","name":"spender","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balanceOf","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"burn","inputs":[{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"rewardStakingPoolAmount","internalType":"uint256"},{"type":"uint256","name":"rewardStakingAmount","internalType":"uint256"}],"name":"calculateRewards","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"rewardStakingPoolAmount","internalType":"uint256"},{"type":"uint256","name":"rewardStakingAmount","internalType":"uint256"}],"name":"calculateRewards2","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"cap","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"changeClaimStartBlock","inputs":[{"type":"uint256","name":"newStartBlock","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"changeMinimumCHZStakedAmount","inputs":[{"type":"uint256","name":"chzAmount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"changeRewardsCHZStakedAmount","inputs":[{"type":"uint256","name":"pepperAmount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"changeStakingContract","inputs":[{"type":"address","name":"newStakingContract","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"changeStakingPoolContract","inputs":[{"type":"address","name":"newStakingPoolContract","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"claim","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"claim2","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"claimEnabled","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"claimStartBlock","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"amountStakingPoolClaimed","internalType":"uint256"},{"type":"uint256","name":"amountStakingClaimed","internalType":"uint256"},{"type":"uint256","name":"blockNumber","internalType":"uint256"}],"name":"claims","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint8","name":"","internalType":"uint8"}],"name":"decimals","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"decreaseAllowance","inputs":[{"type":"address","name":"spender","internalType":"address"},{"type":"uint256","name":"subtractedValue","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"getClaimStatus","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"_epoch","internalType":"uint256"}],"name":"getCurrentEpoch","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getNumberOfValidators","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"pendingHarvest","internalType":"uint256"}],"name":"getPendingClaim","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"pendingHarvest","internalType":"uint256"}],"name":"getPendingClaim2","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getRoleAdmin","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"","internalType":"address[]"}],"name":"getValidators","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"grantRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"increaseAllowance","inputs":[{"type":"address","name":"spender","internalType":"address"},{"type":"uint256","name":"addedValue","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isValidator","inputs":[{"type":"address","name":"validator","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"minCHZStaked","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"mint","inputs":[{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"minterRoleMintedAmount","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"name","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removeMinter","inputs":[{"type":"address","name":"minter","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removeValidator","inputs":[{"type":"address","name":"validator","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"revokeRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setClaimEnabled","inputs":[{"type":"bool","name":"enabled","internalType":"bool"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IStaking"}],"name":"stakingContract","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IStakingPool"}],"name":"stakingPoolContract","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"interfaceId","internalType":"bytes4"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"symbol","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalSupply","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"transfer","inputs":[{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"transferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"event","name":"Approval","inputs":[{"type":"address","name":"owner","indexed":true},{"type":"address","name":"spender","indexed":true},{"type":"uint256","name":"value","indexed":false}],"anonymous":false},{"type":"event","name":"ClaimEnabledStatusChanged","inputs":[{"type":"bool","name":"status","indexed":true}],"anonymous":false},{"type":"event","name":"ClaimStartBlockChanged","inputs":[{"type":"uint256","name":"newStartBlock","indexed":true}],"anonymous":false},{"type":"event","name":"Claimed","inputs":[{"type":"address","name":"account","indexed":true},{"type":"uint256","name":"amountStakingPool","indexed":true},{"type":"uint256","name":"amountStaking","indexed":true}],"anonymous":false},{"type":"event","name":"EpochLengthChanged","inputs":[{"type":"uint16","name":"epochLength","indexed":true}],"anonymous":false},{"type":"event","name":"MinimumCHZStakedAmountChanged","inputs":[{"type":"uint256","name":"chzAmount","indexed":true}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","indexed":true},{"type":"address","name":"newOwner","indexed":true}],"anonymous":false},{"type":"event","name":"RewardsCHZStakedAmountChanged","inputs":[{"type":"uint256","name":"pepperAmount","indexed":true}],"anonymous":false},{"type":"event","name":"RoleAdminChanged","inputs":[{"type":"bytes32","name":"role","indexed":true},{"type":"bytes32","name":"previousAdminRole","indexed":true},{"type":"bytes32","name":"newAdminRole","indexed":true}],"anonymous":false},{"type":"event","name":"RoleGranted","inputs":[{"type":"bytes32","name":"role","indexed":true},{"type":"address","name":"account","indexed":true},{"type":"address","name":"sender","indexed":true}],"anonymous":false},{"type":"event","name":"RoleRevoked","inputs":[{"type":"bytes32","name":"role","indexed":true},{"type":"address","name":"account","indexed":true},{"type":"address","name":"sender","indexed":true}],"anonymous":false},{"type":"event","name":"StakingContractChanged","inputs":[{"type":"address","name":"newStakingContract","indexed":true}],"anonymous":false},{"type":"event","name":"StakingPoolContractChanged","inputs":[{"type":"address","name":"newStakingPoolContract","indexed":true}],"anonymous":false},{"type":"event","name":"Transfer","inputs":[{"type":"address","name":"from","indexed":true},{"type":"address","name":"to","indexed":true},{"type":"uint256","name":"value","indexed":false}],"anonymous":false}]
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106103835760003560e01c806370a08231116101de578063a9059cbb1161010f578063d547741f116100ad578063ea514eed1161007c578063ea514eed146107b3578063ee99205c146107bc578063f2fde38b146107cf578063facd743b146107e257600080fd5b8063d547741f14610767578063dd62ed3e1461077a578063e4dcf95c1461078d578063e5c0e502146107a057600080fd5b8063b7ab4db5116100e9578063b7ab4db51461072d578063b97dd9e214610742578063ce5ae4a01461074a578063d53913931461075257600080fd5b8063a9059cbb146106a4578063ab541a85146106b7578063ac4746ab1461070c57600080fd5b806394db4d051161017c5780639b77c21a116101565780639b77c21a14610679578063a217fddf14610681578063a457c2d714610689578063a67d8ffc1461069c57600080fd5b806394db4d051461064b57806395d89b411461065e578063983b2d561461066657600080fd5b80638da5cb5b116101b85780638da5cb5b1461060c5780639031d9131461061d57806391d148541461062557806392929a091461063857600080fd5b806370a08231146105c8578063715018a6146105f15780638d46a247146105f957600080fd5b806332cb6b0c116102b857806342966c68116102565780634e71d92d116102305780634e71d92d1461057c5780635320369a14610584578063594f40581461059757806364ab8675146105a057600080fd5b806342966c681461054d5780634d238c8e146105605780634e1373b81461057357600080fd5b806336568abe1161029257806336568abe14610501578063395093511461051457806340a141ff1461052757806340c10f191461053a57600080fd5b806332cb6b0c146104bc57806333af312c146104d2578063355274ea146104db57600080fd5b8063248a9ca3116103255780632f2ff15d116102ff5780632f2ff15d146104745780633092afd51461048757806330cae5e81461049a578063313ce567146104ad57600080fd5b8063248a9ca3146104135780632866ed21146104365780632a9535ff1461044957600080fd5b806306fdde031161036157806306fdde03146103d0578063095ea7b3146103e557806318160ddd146103f857806323b872dd1461040057600080fd5b806301eaaec41461038857806301ffc9a71461039257806302775240146103ba575b600080fd5b6103906107f5565b005b6103a56103a03660046125cc565b6108bc565b60405190151581526020015b60405180910390f35b6103c26108f3565b6040519081526020016103b1565b6103d861091c565b6040516103b1919061261a565b6103a56103f3366004612662565b6109ae565b6002546103c2565b6103a561040e36600461268e565b6109c6565b6103c26104213660046126cf565b60009081526006602052604090206001015490565b6008546103a59062010000900460ff1681565b600e5461045c906001600160a01b031681565b6040516001600160a01b0390911681526020016103b1565b6103906104823660046126e8565b6109ea565b610390610495366004612718565b610a14565b6103906104a83660046126cf565b610a37565b604051601281526020016103b1565b6103c26e01b6418d0b4aa8fc37c8693800000081565b6103c2600b5481565b7f000000000000000000000000000000000001b6418d0b4aa8fc37c869380000006103c2565b61039061050f3660046126e8565b610b65565b6103a5610522366004612662565b610be3565b610390610535366004612718565b610c05565b610390610548366004612662565b610d68565b61039061055b3660046126cf565b610f08565b61039061056e366004612718565b610f1a565b6103c2600a5481565b61039061101c565b6103906105923660046126cf565b611030565b6103c2600c5481565b6105b36105ae366004612718565b61106b565b604080519283526020830191909152016103b1565b6103c26105d6366004612718565b6001600160a01b031660009081526020819052604090205490565b610390611241565b6103906106073660046126cf565b611253565b6005546001600160a01b031661045c565b6010546103c2565b6103a56106333660046126e8565b61128e565b610390610646366004612735565b6112b9565b610390610659366004612718565b611379565b6103d8611421565b610390610674366004612718565b611430565b6103a5611450565b6103c2600081565b6103a5610697366004612662565b611471565b6103c26114ec565b6103a56106b2366004612662565b611510565b6106f16106c5366004612662565b600f60209081526000928352604080842090915290825290208054600182015460029092015490919083565b604080519384526020840192909252908201526060016103b1565b60085461071a9061ffff1681565b60405161ffff90911681526020016103b1565b61073561151e565b6040516103b19190612757565b6103c261157f565b6103c26115a1565b6103c2600080516020612a3b83398151915281565b6103906107753660046126e8565b6115af565b6103c26107883660046127a4565b6115d4565b6105b361079b366004612718565b6115ff565b6103906107ae366004612718565b6118bd565b6103c260095481565b600d5461045c906001600160a01b031681565b6103906107dd366004612718565b611965565b6103a56107f0366004612718565b6119db565b6107fd611a48565b60008061080933611aa1565b6040805160608101825283815260208082018490524382840152336000908152600f90915291822093955091935090919061084261157f565b8152602080820192909252604090810160009081208451815592840151600184015592810151600290920191909155518291849133917f987d620f307ff6b94d58743cb7a7509f24071586a77759b77c2d4e29f75a2f9a91a46108ae336108a983856127e8565b611b83565b50506108ba6001600755565b565b60006001600160e01b03198216637965db0b60e01b14806108ed57506301ffc9a760e01b6001600160e01b03198316145b92915050565b606461090f6e01b6418d0b4aa8fc37c8693800000060286127fb565b6109199190612812565b81565b60606003805461092b90612834565b80601f016020809104026020016040519081016040528092919081815260200182805461095790612834565b80156109a45780601f10610979576101008083540402835291602001916109a4565b820191906000526020600020905b81548152906001019060200180831161098757829003601f168201915b5050505050905090565b6000336109bc818585611c10565b5060019392505050565b6000336109d4858285611d34565b6109df858585611dae565b506001949350505050565b600082815260066020526040902060010154610a0581611f52565b610a0f8383611f5c565b505050565b610a1c611fe2565b610a34600080516020612a3b833981519152826115af565b50565b610a3f611fe2565b60085462010000900460ff1615610a965760405162461bcd60e51b8152602060048201526016602482015275436c61696d2063757272656e746c792061637469766560501b60448201526064015b60405180910390fd5b80610ae35760405162461bcd60e51b815260206004820152601d60248201527f436c61696d20737461727420626c6f636b2063616e6e6f7420626520300000006044820152606401610a8d565b804310610b325760405162461bcd60e51b815260206004820152601c60248201527f436c61696d20697320656e61626c656420616e64206f6e676f696e67000000006044820152606401610a8d565b600c81905560405181907f4d61aab65c28454ffd178520e449822939366e6fa1a43242fdfd0543bf0a4f1890600090a250565b6001600160a01b0381163314610bd55760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610a8d565b610bdf828261203c565b5050565b6000336109bc818585610bf683836115d4565b610c0091906127e8565b611c10565b610c0d611fe2565b6001600160a01b038116610c5f5760405162461bcd60e51b8152602060048201526019602482015278496e76616c69642076616c696461746f72206164647265737360381b6044820152606401610a8d565b60105460005b81811015610a0f57826001600160a01b031660108281548110610c8a57610c8a61286e565b6000918252602090912001546001600160a01b031603610d565760108054610cb490600190612884565b81548110610cc457610cc461286e565b600091825260209091200154601080546001600160a01b039092169183908110610cf057610cf061286e565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506010805480610d2f57610d2f612897565b600082815260209020810160001990810180546001600160a01b0319169055019055505050565b80610d60816128ad565b915050610c65565b610d80600080516020612a3b8339815191523361128e565b610dcc5760405162461bcd60e51b815260206004820152601d60248201527f4d7573742068617665206d696e74657220726f6c6520746f206d696e740000006044820152606401610a8d565b610dd4611a48565b600081600b54610de491906127e8565b90506064610e026e01b6418d0b4aa8fc37c8693800000060286127fb565b610e0c9190612812565b811115610e815760405162461bcd60e51b815260206004820152603760248201527f4d696e74696e67206578636565647320343025206f6620746f74616c2073757060448201527f706c7920666f7220746865206d696e74657220726f6c650000000000000000006064820152608401610a8d565b600082610e8d60025490565b610e9791906127e8565b90506e01b6418d0b4aa8fc37c86938000000811115610eed5760405162461bcd60e51b815260206004820152601260248201527113585e081cdd5c1c1b1e481c995858da195960721b6044820152606401610a8d565b600b829055610efc8484611b83565b5050610bdf6001600755565b610f10611fe2565b610a3433826120a3565b610f22611fe2565b610f2b816119db565b15610f785760405162461bcd60e51b815260206004820152601860248201527f56616c696461746f7220616c72656164792065786973747300000000000000006044820152606401610a8d565b6001600160a01b038116610fca5760405162461bcd60e51b8152602060048201526019602482015278496e76616c69642076616c696461746f72206164647265737360381b6044820152606401610a8d565b601080546001810182556000919091527f1b6847dc741a1b0cd08d278845f9d819d87b734759afb55fe2de5cb82a9ae6720180546001600160a01b0319166001600160a01b0392909216919091179055565b611024611a48565b600080610809336121d5565b611038611fe2565b600a81905560405181907ff0da7e4400ffb9a73d632307598d9c16e2f0a6b98e79dd26ebe70b74a7579a9e90600090a250565b60008060008060008060005b60105481101561120257600e54601080546000926001600160a01b031691630db14e9591859081106110ab576110ab61286e565b60009182526020909120015460405160e083901b6001600160e01b03191681526001600160a01b039182166004820152908c166024820152604401602060405180830381865afa158015611103573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061112791906128c6565b905061113381876127e8565b600d54601080549298506000926001600160a01b039092169163d951e1869190869081106111635761116361286e565b60009182526020909120015460405160e083901b6001600160e01b03191681526001600160a01b039182166004820152908d1660248201526044016040805180830381865afa1580156111ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111de91906128df565b5090506111eb81876127e8565b9550505080806111fa906128ad565b915050611077565b5060095461121084866127e8565b1061123557600a5461122290856127fb565b9150600a548361123291906127fb565b90505b90969095509350505050565b611249611fe2565b6108ba60006122ad565b61125b611fe2565b600981905560405181907fcd324b825f49ff1345797ef03209b7fbd6af60771e8a72ea8e6abf6bd692280d90600090a250565b60009182526006602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6112c1611fe2565b60085462010000900460ff161515811515036113325760405162461bcd60e51b815260206004820152602a60248201527f436c61696d2073746174757320616c726561647920696e2074686520646573696044820152697265642073746174757360b01b6064820152608401610a8d565b6008805462ff0000191662010000831515908102919091179091556040517f92922068bb8f4f833e752cb194f2370680631e994ae4a71e3a59398a12fb8eff90600090a250565b611381611fe2565b6001600160a01b0381166113d75760405162461bcd60e51b815260206004820152601860248201527f496e76616c6964207374616b696e6720636f6e747261637400000000000000006044820152606401610a8d565b600d80546001600160a01b0319166001600160a01b0383169081179091556040517f37f339b442273d59b9ccb58c1ed2c06e695bd9b0a68db21495afb7fc86de692c90600090a250565b60606004805461092b90612834565b611438611fe2565b610a34600080516020612a3b833981519152826109ea565b6000600c54431015801561146c575060085462010000900460ff165b905090565b6000338161147f82866115d4565b9050838110156114df5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610a8d565b6109df8286868403611c10565b60008060006114fa33611aa1565b909250905061150981836127e8565b9250505090565b6000336109bc818585611dae565b606060108054806020026020016040519081016040528092919081815260200182805480156109a457602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611558575050505050905090565b600854600c5460009161ffff16906115979043612884565b61146c9190612812565b60008060006114fa336121d5565b6000828152600660205260409020600101546115ca81611f52565b610a0f838361203c565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60008060008060008060005b60105481101561120257600e54601080546000926001600160a01b03169163e2cba695918590811061163f5761163f61286e565b60009182526020909120015460405160e083901b6001600160e01b03191681526001600160a01b03909116600482015260240160a060405180830381865afa15801561168f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116b39190612927565b6040810151909150670de0b6b3a7640000811561170757816001838560200151670de0b6b3a76400006116e691906127fb565b6116f091906127e8565b6116fa9190612884565b6117049190612812565b90505b600e54601080546000926001600160a01b0316916239204091889081106117305761173061286e565b6000918252602090912001546040516001600160e01b031960e084901b1681526001600160a01b039182166004820152908f166024820152604401602060405180830381865afa158015611788573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117ac91906128c6565b9050816117c182670de0b6b3a76400006127fb565b6117cb9190612812565b6117d5908a6127e8565b600d5460108054929b506000926001600160a01b039092169163d951e1869190899081106118055761180561286e565b9060005260206000200160009054906101000a90046001600160a01b03168f6040518363ffffffff1660e01b81526004016118569291906001600160a01b0392831681529116602082015260400190565b6040805180830381865afa158015611872573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189691906128df565b5090506118a3818a6127e8565b9850505050505080806118b5906128ad565b91505061160b565b6118c5611fe2565b6001600160a01b03811661191b5760405162461bcd60e51b815260206004820152601d60248201527f496e76616c6964207374616b696e6720706f6f6c20636f6e74726163740000006044820152606401610a8d565b600e80546001600160a01b0319166001600160a01b0383169081179091556040517fb7ec326f57583d37beeb67766b3cae136849c8de0c9dc3ab1ec5bdea3fb4669190600090a250565b61196d611fe2565b6001600160a01b0381166119d25760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610a8d565b610a34816122ad565b601054600090815b81811015611a3e57836001600160a01b031660108281548110611a0857611a0861286e565b6000918252602090912001546001600160a01b031603611a2c575060019392505050565b80611a36816128ad565b9150506119e3565b5060009392505050565b600260075403611a9a5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610a8d565b6002600755565b600080611aac611450565b611aef5760405162461bcd60e51b815260206004820152601460248201527310db185a5b481a5cc81b9bdd08195b98589b195960621b6044820152606401610a8d565b6000611af961157f565b6001600160a01b0385166000908152600f6020908152604080832084845290915290206002015490915015611b705760405162461bcd60e51b815260206004820152601e60248201527f416c726561647920636c61696d656420666f7220746869732065706f636800006044820152606401610a8d565b611b79846115ff565b9250925050915091565b7f000000000000000000000000000000000001b6418d0b4aa8fc37c8693800000081611bae60025490565b611bb891906127e8565b1115611c065760405162461bcd60e51b815260206004820152601960248201527f45524332304361707065643a20636170206578636565646564000000000000006044820152606401610a8d565b610bdf82826122ff565b6001600160a01b038316611c725760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610a8d565b6001600160a01b038216611cd35760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610a8d565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6000611d4084846115d4565b90506000198114611da85781811015611d9b5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610a8d565b611da88484848403611c10565b50505050565b6001600160a01b038316611e125760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610a8d565b6001600160a01b038216611e745760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610a8d565b6001600160a01b03831660009081526020819052604090205481811015611eec5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610a8d565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3611da8565b610a3481336123be565b611f66828261128e565b610bdf5760008281526006602090815260408083206001600160a01b03851684529091529020805460ff19166001179055611f9e3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6005546001600160a01b031633146108ba5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610a8d565b612046828261128e565b15610bdf5760008281526006602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6001600160a01b0382166121035760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610a8d565b6001600160a01b038216600090815260208190526040902054818110156121775760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610a8d565b6001600160a01b0383166000818152602081815260408083208686039055600280548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3505050565b6000806121e0611450565b6122235760405162461bcd60e51b815260206004820152601460248201527310db185a5b481a5cc81b9bdd08195b98589b195960621b6044820152606401610a8d565b600061222d61157f565b6001600160a01b0385166000908152600f60209081526040808320848452909152902060020154909150156122a45760405162461bcd60e51b815260206004820152601e60248201527f416c726561647920636c61696d656420666f7220746869732065706f636800006044820152606401610a8d565b611b798461106b565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b0382166123555760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610a8d565b806002600082825461236791906127e8565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b6123c8828261128e565b610bdf576123d581612417565b6123e0836020612429565b6040516020016123f19291906129ae565b60408051601f198184030181529082905262461bcd60e51b8252610a8d9160040161261a565b60606108ed6001600160a01b03831660145b606060006124388360026127fb565b6124439060026127e8565b67ffffffffffffffff81111561245b5761245b612911565b6040519080825280601f01601f191660200182016040528015612485576020820181803683370190505b509050600360fc1b816000815181106124a0576124a061286e565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106124cf576124cf61286e565b60200101906001600160f81b031916908160001a90535060006124f38460026127fb565b6124fe9060016127e8565b90505b6001811115612576576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106125325761253261286e565b1a60f81b8282815181106125485761254861286e565b60200101906001600160f81b031916908160001a90535060049490941c9361256f81612a23565b9050612501565b5083156125c55760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610a8d565b9392505050565b6000602082840312156125de57600080fd5b81356001600160e01b0319811681146125c557600080fd5b60005b838110156126115781810151838201526020016125f9565b50506000910152565b60208152600082518060208401526126398160408501602087016125f6565b601f01601f19169190910160400192915050565b6001600160a01b0381168114610a3457600080fd5b6000806040838503121561267557600080fd5b82356126808161264d565b946020939093013593505050565b6000806000606084860312156126a357600080fd5b83356126ae8161264d565b925060208401356126be8161264d565b929592945050506040919091013590565b6000602082840312156126e157600080fd5b5035919050565b600080604083850312156126fb57600080fd5b82359150602083013561270d8161264d565b809150509250929050565b60006020828403121561272a57600080fd5b81356125c58161264d565b60006020828403121561274757600080fd5b813580151581146125c557600080fd5b6020808252825182820181905260009190848201906040850190845b818110156127985783516001600160a01b031683529284019291840191600101612773565b50909695505050505050565b600080604083850312156127b757600080fd5b82356127c28161264d565b9150602083013561270d8161264d565b634e487b7160e01b600052601160045260246000fd5b808201808211156108ed576108ed6127d2565b80820281158282048414176108ed576108ed6127d2565b60008261282f57634e487b7160e01b600052601260045260246000fd5b500490565b600181811c9082168061284857607f821691505b60208210810361286857634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052603260045260246000fd5b818103818111156108ed576108ed6127d2565b634e487b7160e01b600052603160045260246000fd5b6000600182016128bf576128bf6127d2565b5060010190565b6000602082840312156128d857600080fd5b5051919050565b600080604083850312156128f257600080fd5b82519150602083015167ffffffffffffffff8116811461270d57600080fd5b634e487b7160e01b600052604160045260246000fd5b600060a0828403121561293957600080fd5b60405160a0810181811067ffffffffffffffff8211171561296a57634e487b7160e01b600052604160045260246000fd5b60405282516129788161264d565b80825250602083015160208201526040830151604082015260608301516060820152608083015160808201528091505092915050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516129e68160178501602088016125f6565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351612a178160288401602088016125f6565b01602801949350505050565b600081612a3257612a326127d2565b50600019019056fe9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6a26469706673582212204f79f818d9ef5418db2369ba8a0bd425aafec0a2acad7fee2e61f40479df69f364736f6c63430008130033