Source Code
Overview
HYPE Balance
HYPE Value
$0.00View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Cross-Chain Transactions
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
RoleRegistry
Compiler Version
v0.8.24+commit.e11b9ed9
Optimization Enabled:
Yes with 200 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import {Ownable2StepUpgradeable} from "@openzeppelin-upgradeable/access/Ownable2StepUpgradeable.sol";
import {UUPSUpgradeable, Initializable} from "@openzeppelin-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {EnumerableRoles} from "solady/auth/EnumerableRoles.sol";
import {IWithdrawManager} from "./interfaces/IWithdrawManager.sol";
import {IStakingCore} from "./interfaces/IStakingCore.sol";
import {IRoleRegistry} from "./interfaces/IRoleRegistry.sol";
/// @title RoleRegistry - An upgradeable role-based access control system
/// @notice Provides functionality for managing and querying roles with enumeration capabilities
/// @dev Implements UUPS upgradeability pattern and uses Solady's EnumerableRoles for efficient role management
/// @author EtherFi
contract RoleRegistry is IRoleRegistry, Initializable, Ownable2StepUpgradeable, UUPSUpgradeable, EnumerableRoles {
bytes32 public constant PROTOCOL_PAUSER = keccak256("PROTOCOL_PAUSER");
bytes32 public constant PROTOCOL_ADMIN = keccak256("PROTOCOL_ADMIN");
bytes32 public constant PROTOCOL_GUARDIAN = keccak256("PROTOCOL_GUARDIAN");
IWithdrawManager public withdrawManager;
IStakingCore public stakingCore;
address public protocolTreasury;
/// @notice Returns the maximum allowed role value
/// @dev This is used by EnumerableRoles._validateRole to ensure roles are within valid range
/// @return uint256 The maximum role value
function MAX_ROLE() public pure returns (uint256) {
return type(uint256).max;
}
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}
function initialize(address _owner, address _withdrawManager, address _stakingCore, address _protocolTreasury) public initializer {
__Ownable2Step_init();
__UUPSUpgradeable_init();
_transferOwnership(_owner);
withdrawManager = IWithdrawManager(_withdrawManager);
stakingCore = IStakingCore(_stakingCore);
protocolTreasury = _protocolTreasury;
}
/// @notice Checks if an account has any of the specified roles
/// @dev Reverts if the account doesn't have at least one of the roles
/// @param account The address to check roles for
/// @param encodedRoles ABI encoded roles (abi.encode(ROLE_1, ROLE_2, ...))
function checkRoles(address account, bytes memory encodedRoles) public view {
if (!_hasAnyRoles(account, encodedRoles)) __revertEnumerableRolesUnauthorized();
}
/// @notice Checks if an account has a specific role
/// @param role The role to check (as bytes32)
/// @param account The address to check the role for
/// @return bool True if the account has the role, false otherwise
function hasRole(bytes32 role, address account) public view returns (bool) {
return hasRole(account, uint256(role));
}
/// @notice Grants a role to an account
/// @dev Only callable by the contract owner (handled in setRole function)
/// @param role The role to grant (as bytes32)
/// @param account The address to grant the role to
function grantRole(bytes32 role, address account) public {
setRole(account, uint256(role), true);
}
/// @notice Revokes a role from an account
/// @dev Only callable by the contract owner (handled in setRole function)
/// @param role The role to revoke (as bytes32)
/// @param account The address to revoke the role from
function revokeRole(bytes32 role, address account) public {
setRole(account, uint256(role), false);
}
/// @notice Gets all addresses that have a specific role
/// @dev Wrapper around EnumerableRoles roleHolders function converting bytes32 to uint256
/// @param role The role to query (as bytes32)
/// @return address[] Array of addresses that have the specified role
function roleHolders(bytes32 role) public view returns (address[] memory) {
return roleHolders(uint256(role));
}
/* ========== ADMIN FUNCTIONS ========== */
function setProtocolTreasury(address _protocolTreasury) public {
if (!hasRole(PROTOCOL_GUARDIAN, msg.sender)) revert NotAuthorized();
protocolTreasury = _protocolTreasury;
emit ProtocolTreasuryUpdated(_protocolTreasury);
}
function setWithdrawManager(address _withdrawManager) public {
if (!hasRole(PROTOCOL_GUARDIAN, msg.sender)) revert NotAuthorized();
withdrawManager = IWithdrawManager(_withdrawManager);
emit WithdrawManagerUpdated(_withdrawManager);
}
function setStakingCore(address _stakingCore) public {
if (!hasRole(PROTOCOL_GUARDIAN, msg.sender)) revert NotAuthorized();
stakingCore = IStakingCore(_stakingCore);
emit StakingCoreUpdated(_stakingCore);
}
function pauseProtocol() public {
if (!hasRole(PROTOCOL_PAUSER, msg.sender)) revert NotAuthorized();
withdrawManager.pauseWithdrawals();
stakingCore.pauseStaking();
emit ProtocolPaused();
}
function unpauseProtocol() public {
if (!hasRole(PROTOCOL_GUARDIAN, msg.sender)) revert NotAuthorized();
withdrawManager.unpauseWithdrawals();
stakingCore.unpauseStaking();
emit ProtocolUnpaused();
}
function onlyProtocolUpgrader(address account) public view {
if (owner() != account) revert OnlyProtocolUpgrader();
}
function __revertEnumerableRolesUnauthorized() private pure {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, 0x99152cca) // `EnumerableRolesUnauthorized()`.
revert(0x1c, 0x04)
}
}
function _authorizeUpgrade(address newImplementation) internal override onlyOwner {}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/Ownable2Step.sol)
pragma solidity ^0.8.20;
import {OwnableUpgradeable} from "./OwnableUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which provides access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* This extension of the {Ownable} contract includes a two-step mechanism to transfer
* ownership, where the new owner must call {acceptOwnership} in order to replace the
* old one. This can help prevent common mistakes, such as transfers of ownership to
* incorrect accounts, or to contracts that are unable to interact with the
* permission system.
*
* The initial owner is specified at deployment time in the constructor for `Ownable`. This
* can later be changed with {transferOwnership} and {acceptOwnership}.
*
* This module is used through inheritance. It will make available all functions
* from parent (Ownable).
*/
abstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable {
/// @custom:storage-location erc7201:openzeppelin.storage.Ownable2Step
struct Ownable2StepStorage {
address _pendingOwner;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable2Step")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant Ownable2StepStorageLocation = 0x237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c00;
function _getOwnable2StepStorage() private pure returns (Ownable2StepStorage storage $) {
assembly {
$.slot := Ownable2StepStorageLocation
}
}
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
function __Ownable2Step_init() internal onlyInitializing {
}
function __Ownable2Step_init_unchained() internal onlyInitializing {
}
/**
* @dev Returns the address of the pending owner.
*/
function pendingOwner() public view virtual returns (address) {
Ownable2StepStorage storage $ = _getOwnable2StepStorage();
return $._pendingOwner;
}
/**
* @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
* Can only be called by the current owner.
*
* Setting `newOwner` to the zero address is allowed; this can be used to cancel an initiated ownership transfer.
*/
function transferOwnership(address newOwner) public virtual override onlyOwner {
Ownable2StepStorage storage $ = _getOwnable2StepStorage();
$._pendingOwner = newOwner;
emit OwnershipTransferStarted(owner(), newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual override {
Ownable2StepStorage storage $ = _getOwnable2StepStorage();
delete $._pendingOwner;
super._transferOwnership(newOwner);
}
/**
* @dev The new owner accepts the ownership transfer.
*/
function acceptOwnership() public virtual {
address sender = _msgSender();
if (pendingOwner() != sender) {
revert OwnableUnauthorizedAccount(sender);
}
_transferOwnership(sender);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.22;
import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
import {Initializable} from "./Initializable.sol";
/**
* @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
* {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
*
* A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
* reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
* `UUPSUpgradeable` with a custom implementation of upgrades.
*
* The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
*/
abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable {
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
address private immutable __self = address(this);
/**
* @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)`
* and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,
* while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string.
* If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must
* be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
* during an upgrade.
*/
string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";
/**
* @dev The call is from an unauthorized context.
*/
error UUPSUnauthorizedCallContext();
/**
* @dev The storage `slot` is unsupported as a UUID.
*/
error UUPSUnsupportedProxiableUUID(bytes32 slot);
/**
* @dev Check that the execution is being performed through a delegatecall call and that the execution context is
* a proxy contract with an implementation (as defined in ERC-1967) pointing to self. This should only be the case
* for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
* function through ERC-1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
* fail.
*/
modifier onlyProxy() {
_checkProxy();
_;
}
/**
* @dev Check that the execution is not being performed through a delegate call. This allows a function to be
* callable on the implementing contract but not through proxies.
*/
modifier notDelegated() {
_checkNotDelegated();
_;
}
function __UUPSUpgradeable_init() internal onlyInitializing {
}
function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
}
/**
* @dev Implementation of the ERC-1822 {proxiableUUID} function. This returns the storage slot used by the
* implementation. It is used to validate the implementation's compatibility when performing an upgrade.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
*/
function proxiableUUID() external view virtual notDelegated returns (bytes32) {
return ERC1967Utils.IMPLEMENTATION_SLOT;
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, data);
}
/**
* @dev Reverts if the execution is not performed via delegatecall or the execution
* context is not of a proxy with an ERC-1967 compliant implementation pointing to self.
*/
function _checkProxy() internal view virtual {
if (
address(this) == __self || // Must be called through delegatecall
ERC1967Utils.getImplementation() != __self // Must be called through an active proxy
) {
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Reverts if the execution is performed via delegatecall.
* See {notDelegated}.
*/
function _checkNotDelegated() internal view virtual {
if (address(this) != __self) {
// Must not be called through delegatecall
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
/**
* @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call.
*
* As a security check, {proxiableUUID} is invoked in the new implementation, and the return value
* is expected to be the implementation slot in ERC-1967.
*
* Emits an {IERC1967-Upgraded} event.
*/
function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private {
try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) {
revert UUPSUnsupportedProxiableUUID(slot);
}
ERC1967Utils.upgradeToAndCall(newImplementation, data);
} catch {
// The implementation is not UUPS
revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation);
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
/// @notice Enumerable multiroles authorization mixin.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/auth/EnumerableRoles.sol)
///
/// @dev Note:
/// This implementation is agnostic to the Ownable that the contract inherits from.
/// It performs a self-staticcall to the `owner()` function to determine the owner.
/// This is useful for situations where the contract inherits from
/// OpenZeppelin's Ownable, such as in LayerZero's OApp contracts.
///
/// This implementation performs a self-staticcall to `MAX_ROLE()` to determine
/// the maximum role that can be set/unset. If the inheriting contract does not
/// have `MAX_ROLE()`, then any role can be set/unset.
///
/// This implementation allows for any uint256 role,
/// it does NOT take in a bitmask of roles.
/// This is to accommodate teams that are allergic to bitwise flags.
///
/// By default, the `owner()` is the only account that is authorized to set roles.
/// This behavior can be changed via overrides.
///
/// This implementation is compatible with any Ownable.
/// This implementation is NOT compatible with OwnableRoles.
abstract contract EnumerableRoles {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* EVENTS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev The status of `role` for `holder` has been set to `active`.
event RoleSet(address indexed holder, uint256 indexed role, bool indexed active);
/// @dev `keccak256(bytes("RoleSet(address,uint256,bool)"))`.
uint256 private constant _ROLE_SET_EVENT_SIGNATURE =
0xaddc47d7e02c95c00ec667676636d772a589ffbf0663cfd7cd4dd3d4758201b8;
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CUSTOM ERRORS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev The index is out of bounds of the role holders array.
error RoleHoldersIndexOutOfBounds();
/// @dev Cannot set the role of the zero address.
error RoleHolderIsZeroAddress();
/// @dev The role has exceeded the maximum role.
error InvalidRole();
/// @dev Unauthorized to perform the action.
error EnumerableRolesUnauthorized();
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* STORAGE */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev The storage layout of the holders enumerable mapping is given by:
/// ```
/// mstore(0x18, holder)
/// mstore(0x04, _ENUMERABLE_ROLES_SLOT_SEED)
/// mstore(0x00, role)
/// let rootSlot := keccak256(0x00, 0x24)
/// let positionSlot := keccak256(0x00, 0x38)
/// let holderSlot := add(rootSlot, sload(positionSlot))
/// let holderInStorage := shr(96, sload(holderSlot))
/// let length := shr(160, shl(160, sload(rootSlot)))
/// ```
uint256 private constant _ENUMERABLE_ROLES_SLOT_SEED = 0xee9853bb;
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* PUBLIC UPDATE FUNCTIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Sets the status of `role` of `holder` to `active`.
function setRole(address holder, uint256 role, bool active) public payable virtual {
_authorizeSetRole(holder, role, active);
_setRole(holder, role, active);
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* PUBLIC READ FUNCTIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Returns if `holder` has active `role`.
function hasRole(address holder, uint256 role) public view virtual returns (bool result) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x18, holder)
mstore(0x04, _ENUMERABLE_ROLES_SLOT_SEED)
mstore(0x00, role)
result := iszero(iszero(sload(keccak256(0x00, 0x38))))
}
}
/// @dev Returns an array of the holders of `role`.
function roleHolders(uint256 role) public view virtual returns (address[] memory result) {
/// @solidity memory-safe-assembly
assembly {
result := mload(0x40)
mstore(0x04, _ENUMERABLE_ROLES_SLOT_SEED)
mstore(0x00, role)
let rootSlot := keccak256(0x00, 0x24)
let rootPacked := sload(rootSlot)
let n := shr(160, shl(160, rootPacked))
let o := add(0x20, result)
mstore(o, shr(96, rootPacked))
for { let i := 1 } lt(i, n) { i := add(i, 1) } {
mstore(add(o, shl(5, i)), shr(96, sload(add(rootSlot, i))))
}
mstore(result, n)
mstore(0x40, add(o, shl(5, n)))
}
}
/// @dev Returns the total number of holders of `role`.
function roleHolderCount(uint256 role) public view virtual returns (uint256 result) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x04, _ENUMERABLE_ROLES_SLOT_SEED)
mstore(0x00, role)
result := shr(160, shl(160, sload(keccak256(0x00, 0x24))))
}
}
/// @dev Returns the holder of `role` at the index `i`.
function roleHolderAt(uint256 role, uint256 i) public view virtual returns (address result) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x04, _ENUMERABLE_ROLES_SLOT_SEED)
mstore(0x00, role)
let rootSlot := keccak256(0x00, 0x24)
let rootPacked := sload(rootSlot)
if iszero(lt(i, shr(160, shl(160, rootPacked)))) {
mstore(0x00, 0x5694da8e) // `RoleHoldersIndexOutOfBounds()`.
revert(0x1c, 0x04)
}
result := shr(96, rootPacked)
if i { result := shr(96, sload(add(rootSlot, i))) }
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* INTERNAL FUNCTIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Set the role for holder directly without authorization guard.
function _setRole(address holder, uint256 role, bool active) internal virtual {
_validateRole(role);
/// @solidity memory-safe-assembly
assembly {
let holder_ := shl(96, holder)
if iszero(holder_) {
mstore(0x00, 0x82550143) // `RoleHolderIsZeroAddress()`.
revert(0x1c, 0x04)
}
mstore(0x18, holder)
mstore(0x04, _ENUMERABLE_ROLES_SLOT_SEED)
mstore(0x00, role)
let rootSlot := keccak256(0x00, 0x24)
let n := shr(160, shl(160, sload(rootSlot)))
let positionSlot := keccak256(0x00, 0x38)
let position := sload(positionSlot)
for {} 1 {} {
if iszero(active) {
if iszero(position) { break }
let nSub := sub(n, 1)
if iszero(eq(sub(position, 1), nSub)) {
let lastHolder_ := shl(96, shr(96, sload(add(rootSlot, nSub))))
sstore(add(rootSlot, sub(position, 1)), lastHolder_)
sstore(add(rootSlot, nSub), 0)
mstore(0x24, lastHolder_)
sstore(keccak256(0x00, 0x38), position)
}
sstore(rootSlot, or(shl(96, shr(96, sload(rootSlot))), nSub))
sstore(positionSlot, 0)
break
}
if iszero(position) {
sstore(add(rootSlot, n), holder_)
sstore(positionSlot, add(n, 1))
sstore(rootSlot, add(sload(rootSlot), 1))
}
break
}
// forgefmt: disable-next-item
log4(0x00, 0x00, _ROLE_SET_EVENT_SIGNATURE, shr(96, holder_), role, iszero(iszero(active)))
}
}
/// @dev Requires the role is not greater than `MAX_ROLE()`.
/// If `MAX_ROLE()` is not implemented, this is an no-op.
function _validateRole(uint256 role) internal view virtual {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, 0xd24f19d5) // `MAX_ROLE()`.
if and(
and(gt(role, mload(0x00)), gt(returndatasize(), 0x1f)),
staticcall(gas(), address(), 0x1c, 0x04, 0x00, 0x20)
) {
mstore(0x00, 0xd954416a) // `InvalidRole()`.
revert(0x1c, 0x04)
}
}
}
/// @dev Checks that the caller is authorized to set the role.
function _authorizeSetRole(address holder, uint256 role, bool active) internal virtual {
if (!_enumerableRolesSenderIsContractOwner()) _revertEnumerableRolesUnauthorized();
// Silence compiler warning on unused variables.
(holder, role, active) = (holder, role, active);
}
/// @dev Returns if `holder` has any roles in `encodedRoles`.
/// `encodedRoles` is `abi.encode(SAMPLE_ROLE_0, SAMPLE_ROLE_1, ...)`.
function _hasAnyRoles(address holder, bytes memory encodedRoles)
internal
view
virtual
returns (bool result)
{
/// @solidity memory-safe-assembly
assembly {
mstore(0x18, holder)
mstore(0x04, _ENUMERABLE_ROLES_SLOT_SEED)
let end := add(encodedRoles, shl(5, shr(5, mload(encodedRoles))))
for {} lt(result, lt(encodedRoles, end)) {} {
encodedRoles := add(0x20, encodedRoles)
mstore(0x00, mload(encodedRoles))
result := sload(keccak256(0x00, 0x38))
}
result := iszero(iszero(result))
}
}
/// @dev Reverts if `msg.sender` does not have `role`.
function _checkRole(uint256 role) internal view virtual {
if (!hasRole(msg.sender, role)) _revertEnumerableRolesUnauthorized();
}
/// @dev Reverts if `msg.sender` does not have any role in `encodedRoles`.
function _checkRoles(bytes memory encodedRoles) internal view virtual {
if (!_hasAnyRoles(msg.sender, encodedRoles)) _revertEnumerableRolesUnauthorized();
}
/// @dev Reverts if `msg.sender` is not the contract owner and does not have `role`.
function _checkOwnerOrRole(uint256 role) internal view virtual {
if (!_enumerableRolesSenderIsContractOwner()) _checkRole(role);
}
/// @dev Reverts if `msg.sender` is not the contract owner and
/// does not have any role in `encodedRoles`.
function _checkOwnerOrRoles(bytes memory encodedRoles) internal view virtual {
if (!_enumerableRolesSenderIsContractOwner()) _checkRoles(encodedRoles);
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* MODIFIERS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Marks a function as only callable by an account with `role`.
modifier onlyRole(uint256 role) virtual {
_checkRole(role);
_;
}
/// @dev Marks a function as only callable by an account with any role in `encodedRoles`.
/// `encodedRoles` is `abi.encode(SAMPLE_ROLE_0, SAMPLE_ROLE_1, ...)`.
modifier onlyRoles(bytes memory encodedRoles) virtual {
_checkRoles(encodedRoles);
_;
}
/// @dev Marks a function as only callable by the owner or by an account with `role`.
modifier onlyOwnerOrRole(uint256 role) virtual {
_checkOwnerOrRole(role);
_;
}
/// @dev Marks a function as only callable by the owner or
/// by an account with any role in `encodedRoles`.
/// Checks for ownership first, then checks for roles.
/// `encodedRoles` is `abi.encode(SAMPLE_ROLE_0, SAMPLE_ROLE_1, ...)`.
modifier onlyOwnerOrRoles(bytes memory encodedRoles) virtual {
_checkOwnerOrRoles(encodedRoles);
_;
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* PRIVATE HELPERS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Returns if the `msg.sender` is equal to `owner()` on this contract.
/// If the contract does not have `owner()` implemented, returns false.
function _enumerableRolesSenderIsContractOwner() private view returns (bool result) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, 0x8da5cb5b) // `owner()`.
result :=
and(
and(eq(caller(), mload(0x00)), gt(returndatasize(), 0x1f)),
staticcall(gas(), address(), 0x1c, 0x04, 0x00, 0x20)
)
}
}
/// @dev Reverts with `EnumerableRolesUnauthorized()`.
function _revertEnumerableRolesUnauthorized() private pure {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, 0x99152cca) // `EnumerableRolesUnauthorized()`.
revert(0x1c, 0x04)
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import {IRoleRegistry} from "./IRoleRegistry.sol";
import {IBeHYPEToken} from "./IBeHYPE.sol";
import {IStakingCore} from "./IStakingCore.sol";
/**
* @title IWithdrawManager
* @notice Interface for the WithdrawalQueue contract
* @dev Defines all public and external functions for withdrawal management
*/
interface IWithdrawManager {
/* ========== STRUCTS ========== */
struct WithdrawalEntry {
address user; // Address of the user
uint256 beHypeAmount; // Amount of beHYPE tokens locked for withdrawal
uint256 hypeAmount; // Amount of HYPE to be withdrawn
bool claimed; // Whether the withdrawal has been claimed
}
/* ========== ERRORS ========== */
error WithdrawalsPaused();
error InvalidAmount();
error InsufficientBeHYPEBalance();
error NotAuthorized();
error IndexOutOfBounds();
error CanOnlyFinalizeForward();
error WithdrawalNotClaimable();
error InvalidWithdrawalID();
error TransferFailed();
error WithdrawalsNotPaused();
error InsufficientHYPELiquidity();
error InstantWithdrawalRateLimitExceeded();
error InvalidInstantWithdrawalFee();
error AlreadyClaimed();
error InsufficientMinimumAmountOut();
/* ========== EVENTS ========== */
event WithdrawalQueued(
address indexed user,
uint256 indexed withdrawalId,
uint256 beHypeAmount,
uint256 hypeAmount,
uint256 queueIndex
);
event WithdrawalsBatchFinalized(uint256 upToIndex);
event WithdrawalClaimed(
address indexed user,
uint256 indexed withdrawalId,
uint256 hypeAmount
);
event InstantWithdrawal(
address indexed user,
uint256 beHypeAmountWithdrawn,
uint256 hypeAmountReceived,
uint256 beHypeInstantWithdrawalFee
);
event InstantWithdrawalFeeInBpsUpdated(uint256 instantWithdrawalFeeInBps);
event InstantWithdrawalCapacityUpdated(uint256 capacity);
event InstantWithdrawalRefillRateUpdated(uint256 refillRate);
/* ========== MAIN FUNCTIONS ========== */
/**
* @notice Queue a withdrawal request
* @param beHYPEAmount Amount of beHYPE tokens to withdraw
* @param instant Whether to withdraw instantly for a fee or queue
* @param minAmountOut Minimum amount of HYPE to receive (protection against exchange rate changes)
* @return withdrawalId The ID of the withdrawal request
*/
function withdraw(uint256 beHYPEAmount, bool instant, uint256 minAmountOut) external returns (uint256 withdrawalId);
/**
* @notice Finalize withdrawals up to a specific index (protocol governor only)
* @param index Index up to which withdrawals should be finalized
*/
function finalizeWithdrawals(uint256 index) external;
/* ========== VIEW FUNCTIONS ========== */
/**
* @notice Get the count of pending (unfinalized) withdrawals
* @return uint256 Number of pending withdrawals
*/
function getPendingWithdrawalsCount() external view returns (uint256);
/**
* @notice Check if a withdrawal amount can be instant withdrawn
* @param beHYPEAmount Amount of beHYPE tokens to withdraw
* @return bool True if the withdrawal can be instant withdrawn
*/
function canInstantWithdraw(uint256 beHYPEAmount) external view returns (bool);
/**
* @notice Get a withdrawal entry from the queue
* @param index Index of the withdrawal entry
* @return WithdrawalEntry The withdrawal entry
*/
function getWithdrawalQueue(uint256 index) external view returns (WithdrawalEntry memory);
/**
* @notice Check if a withdrawal can be claimed
* @param withdrawalId The ID of the withdrawal
* @return bool True if the withdrawal can be claimed
*/
function canClaimWithdrawal(uint256 withdrawalId) external view returns (bool);
/**
* @notice Get the amount of hype requested for withdrawal
* @return uint256 The amount of hype requested for withdrawal
*/
function hypeRequestedForWithdraw() external view returns (uint256);
/* ========== ADMIN FUNCTIONS ========== */
/**
* @notice Pause withdrawals
* @dev Only callable by the role registry
*/
function pauseWithdrawals() external;
/**
* @notice Unpause withdrawals
* @dev Only callable by the role registry
*/
function unpauseWithdrawals() external;
/**
* @notice Set the instant withdrawal fee in basis points
* @param _instantWithdrawalFeeInBps The new instant withdrawal fee in basis points
* @dev Only callable by the protocol guardian
*/
function setInstantWithdrawalFeeInBps(uint16 _instantWithdrawalFeeInBps) external;
/**
* @notice Set the instant withdrawal capacity
* @param capacity The new instant withdrawal capacity
* @dev Only callable by the protocol admin
*/
function setInstantWithdrawalCapacity(uint256 capacity) external;
/**
* @notice Set the instant withdrawal refill rate per second
* @param refillRate The new instant withdrawal refill rate per second
* @dev Only callable by the protocol admin
*/
function setInstantWithdrawalRefillRatePerSecond(uint256 refillRate) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import {IRoleRegistry} from "./IRoleRegistry.sol";
import {IBeHYPEToken} from "./IBeHYPE.sol";
/**
* @title IStakingCore
* @notice Interface for the StakingCore contract that manages staking operations and exchange ratios
* @dev Provides functionality for staking deposits, withdrawals, token delegation, and exchange ratio management
* @author EtherFi
*/
interface IStakingCore {
/* ========== ERRORS ========== */
error NotAuthorized();
error ExchangeRatioChangeExceedsThreshold(uint16 yearlyRateInBps);
error FailedToFetchDelegatorSummary();
error AmountExceedsUint64Max();
error FailedToDepositToHyperCore();
error StakingPaused();
error ElapsedTimeCannotBeZero();
error FailedToSendFromWithdrawManager();
error WithdrawalCooldownNotMet();
error ExceedsLimit();
error PrecisionLossDetected(uint256 amount, uint256 truncatedAmount);
error ExchangeRatioUpdateTooSoon(uint256 blocksRequired, uint256 blocksPassed);
/* ========== EVENTS ========== */
/**
* @notice Emitted when the exchange ratio is updated
* @param oldRatio The previous exchange ratio
* @param newRatio The new exchange ratio
* @param yearlyRateInBps The absolute yearly rate in bps
*/
event ExchangeRatioUpdated(uint256 oldRatio, uint256 newRatio, uint16 yearlyRateInBps);
/**
* @notice Emitted when HYPE is deposited to HyperCore staking module from HyperCore spot account
* @param amount The amount of HYPE deposited
*/
event HyperCoreDeposit(uint256 amount);
/**
* @notice Emitted when HYPE is withdrawn from HyperCore staking module to HyperCore spot account
* @param amount The amount of HYPE withdrawn
*/
event HyperCoreWithdraw(uint256 amount);
/**
* @notice Emitted when HYPE is deposited to HyperCore staking module from HyperCore spot account
* @param amount The amount of HYPE deposited
*/
event HyperCoreStakingDeposit(uint256 amount);
/**
* @notice Emitted when HYPE is withdrawn from HyperCore staking module
* @param amount The amount of HYPE withdrawn
*/
event HyperCoreStakingWithdraw(uint256 amount);
/**
* @notice Emitted when HYPE is staked
* @param user Who minted the tokens
* @param amount The amount of HYPE staked
* @param communityCode The community code of the staked tokens
*/
event Deposit(address user, uint256 amount, string communityCode);
/**
* @notice Emitted when HYPE is delegated or undelegated
* @param validator The validator address
* @param amount The amount of HYPE delegated/undelegated
* @param isUndelegate True if undelegating, false if delegating
*/
event TokenDelegated(address validator, uint256 amount, bool isUndelegate);
/**
* @notice Emitted when the withdraw manager is updated
* @param withdrawManager The new withdraw manager
*/
event WithdrawManagerUpdated(address withdrawManager);
/**
* @notice Emitted when the withdrawal cooldown period is updated
* @param withdrawalCooldownPeriod The new withdrawal cooldown period in seconds
*/
event WithdrawalCooldownPeriodUpdated(uint256 withdrawalCooldownPeriod);
/**
* @notice Emitted when the acceptable APR is updated
* @param newAprInBps The new acceptable APR in basis points
*/
event AcceptableAprUpdated(uint16 newAprInBps);
/**
* @notice Emitted when the exchange rate guard is updated
* @param newExchangeRateGuard The new exchange rate guard value
*/
event ExchangeRateGuardUpdated(bool newExchangeRateGuard);
/* ========== MAIN FUNCTIONS ========== */
/**
* @notice Stakes HYPE
* @param communityCode The community code of the staked tokens
*/
function stake(string memory communityCode) external payable;
/* ========== ADMIN FUNCTIONS ========== */
/**
* @notice Updates the exchange ratio based on L1 delegator summary
* @dev Only callable by accounts with PROTOCOL_GOVERNOR role
* @dev Prevents negative rebases and enforces maximum APR change threshold
* @dev Emits ExchangeRatioUpdated event on successful update
*/
function updateExchangeRatio() external;
/**
* @notice Allows the withdraw manager to send HYPE to the user
* @param amount The amount of HYPE to send
* @param to The address to send the HYPE to
* @dev Only callable by the withdraw manager
*/
function sendFromWithdrawManager(uint256 amount, address to) external;
/**
* @notice Sets the withdraw manager
* @param _withdrawManager The new withdraw manager
* @dev Only callable by the protocol upgrader
*/
function setWithdrawManager(address _withdrawManager) external;
/**
* @notice Updates the acceptable APR
* @param _acceptablAprInBps The new acceptable APR
* @dev Only callable by the protocol guardian
*/
function updateAcceptableApr(uint16 _acceptablAprInBps) external;
/**
* @notice Updates the exchange rate guard
* @param _exchangeRateGuard The new exchange rate guard
* @dev Only callable by the protocol guardian
*/
function updateExchangeRateGuard(bool _exchangeRateGuard) external;
/**
* @notice Updates the withdrawal cooldown period
* @param _withdrawalCooldownPeriod The new cooldown period in seconds
* @dev Only callable by the protocol guardian
*/
function updateWithdrawalCooldownPeriod(uint256 _withdrawalCooldownPeriod) external;
/**
* @notice Deposits HYPE to HyperCore staking module from HyperCore spot account
* @param amount The amount of HYPE to deposit in wei
* @dev Only callable by the protocol admin
*/
function depositToHyperCore(uint256 amount) external;
/**
* @notice Withdraws HYPE from HyperCore
* @param amount The amount of HYPE to withdraw in wei
* @dev Only callable by accounts with PROTOCOL_GOVERNOR role
* @dev Sends Action 5 to CoreWriter for HyperCore processing
* @dev Emits StakingWithdraw event
* @dev Reverts if the amount is greater than the pending hype withdrawal amount
*/
function withdrawFromHyperCore(uint256 amount) external;
/**
* @notice Deposits HYPE to staking via CoreWriter Action 4
* @param amount The amount of HYPE to deposit in wei
* @dev Only callable by accounts with PROTOCOL_ADMIN role
* @dev Sends Action 4 to CoreWriter for HyperCore processing
* @dev Emits StakingDeposit event
*/
function depositToStaking(uint256 amount) external;
/**
* @notice Withdraws HYPE from staking via CoreWriter Action 5
* @param amount The amount of HYPE to withdraw in wei
* @dev Only callable by accounts with PROTOCOL_ADMIN role
* @dev Sends Action 5 to CoreWriter for HyperCore processing
* @dev Emits StakingWithdraw event
* @dev Reverts if the amount is greater than the pending hype withdrawal amount
*/
function withdrawFromStaking(uint256 amount) external;
/**
* @notice Emergency withdrawal of HYPE from staking via CoreWriter Action 5
* @param amount The amount of HYPE to withdraw in wei
* @dev Only callable by accounts with PROTOCOL_GUARDIAN role
* @dev Bypasses cooldown and pending withdrawal restrictions
* @dev Sends Action 5 to CoreWriter for HyperCore processing
* @dev Emits StakingWithdraw event
*/
function emergencyWithdrawFromStaking(uint256 amount) external;
/**
* @notice Delegates or undelegates tokens via CoreWriter Action 3
* @param validator The validator address to delegate/undelegate from
* @param amount The amount of tokens to delegate/undelegate in wei
* @param isUndelegate True if undelegating, false if delegating
* @dev Only callable by accounts with PROTOCOL_ADMIN role
* @dev Sends Action 3 to CoreWriter for HyperCore processing
* @dev Emits TokenDelegated event
*/
function delegateTokens(address validator, uint256 amount, bool isUndelegate) external;
/**
* @notice Pauses staking
* @dev Only callable by the role registry
*/
function pauseStaking() external;
/**
* @notice Unpauses staking
* @dev Only callable by the role registry
*/
function unpauseStaking() external;
/* ========== VIEW FUNCTIONS ========== */
/**
* @notice Converts beHYPE amount to HYPE using current exchange ratio
* @param beHYPEAmount The amount of beHYPE tokens to convert
* @return The equivalent amount of HYPE tokens
* @dev Uses current exchange ratio for conversion
*/
function BeHYPEToHYPE(uint256 beHYPEAmount) external view returns (uint256);
/**
* @notice Converts HYPE amount to kHYPE using current exchange ratio
* @param HYPEAmount The amount of HYPE tokens to convert
* @return The equivalent amount of kHYPE tokens
* @dev Uses current exchange ratio for conversion
*/
function HYPEToBeHYPE(uint256 HYPEAmount) external view returns (uint256);
/**
* @notice Returns the total amount of HYPE in the protocol
* @return The total amount of HYPE in the protocol
*/
function getTotalProtocolHype() external view returns (uint256);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import {IWithdrawManager} from "./IWithdrawManager.sol";
import {IStakingCore} from "./IStakingCore.sol";
/**
* @title IRoleRegistry
* @notice Interface for the RoleRegistry contract
* @dev Defines the external interface for RoleRegistry with role management functions
* @author ether.fi
*/
interface IRoleRegistry {
/**
* @dev Error thrown when a function is called by an account without the protocol upgrader role
*/
error OnlyProtocolUpgrader();
/**
* @dev Error thrown when a function is called by an unauthorized account
*/
error NotAuthorized();
/* ========== EVENTS ========== */
/**
* @notice Emitted when the protocol treasury is updated
* @param _protocolTreasury The new protocol treasury address
*/
event ProtocolTreasuryUpdated(address _protocolTreasury);
/**
* @notice Emitted when the withdraw manager is updated
* @param _withdrawManager The new withdraw manager address
*/
event WithdrawManagerUpdated(address _withdrawManager);
/**
* @notice Emitted when the staking core is updated
* @param _stakingCore The new staking core address
*/
event StakingCoreUpdated(address _stakingCore);
/**
* @notice Emitted when the protocol is paused
*/
event ProtocolPaused();
/**
* @notice Emitted when the protocol is unpaused
*/
event ProtocolUnpaused();
/**
* @notice Returns the maximum allowed role value
* @dev This is used by EnumerableRoles._validateRole to ensure roles are within valid range
* @return The maximum role value
*/
function MAX_ROLE() external pure returns (uint256);
/**
* @notice Initializes the contract with the specified parameters
* @param _owner The address that will be set as the initial owner
* @param _withdrawManager The address of the withdraw manager contract
* @param _stakingCore The address of the staking core contract
* @param _protocolTreasury The address of the protocol treasury
*/
function initialize(address _owner, address _withdrawManager, address _stakingCore, address _protocolTreasury) external;
/**
* @notice Checks if an account has any of the specified roles
* @dev Reverts if the account doesn't have at least one of the roles
* @param account The address to check roles for
* @param encodedRoles ABI encoded roles (abi.encode(ROLE_1, ROLE_2, ...))
*/
function checkRoles(address account, bytes memory encodedRoles) external view;
/**
* @notice Checks if an account has a specific role
* @param role The role to check (as bytes32)
* @param account The address to check the role for
* @return bool True if the account has the role, false otherwise
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @notice Grants a role to an account
* @dev Only callable by the contract owner
* @param role The role to grant (as bytes32)
* @param account The address to grant the role to
*/
function grantRole(bytes32 role, address account) external;
/**
* @notice Revokes a role from an account
* @dev Only callable by the contract owner
* @param role The role to revoke (as bytes32)
* @param account The address to revoke the role from
*/
function revokeRole(bytes32 role, address account) external;
/**
* @notice Gets all addresses that have a specific role
* @dev Wrapper around EnumerableRoles roleHolders function
* @param role The role to query (as bytes32)
* @return Array of addresses that have the specified role
*/
function roleHolders(bytes32 role) external view returns (address[] memory);
/**
* @notice Checks if an account is the protocol upgrader
* @dev Reverts if the account is not the protocol upgrader
* @param account The address to check
*/
function onlyProtocolUpgrader(address account) external view;
/**
* @notice Returns the PROTOCOL_PAUSER role identifier
* @return The bytes32 identifier for the PROTOCOL_PAUSER role
*/
function PROTOCOL_PAUSER() external view returns (bytes32);
/**
* @notice Returns the PROTOCOL_ADMIN role identifier
* @dev performs protocol admin actions
* @return The bytes32 identifier for the PROTOCOL_ADMIN role
*/
function PROTOCOL_ADMIN() external view returns (bytes32);
/**
* @notice Returns the PROTOCOL_GUARDIAN role identifier
* @dev performs protocol guardian actions
* @return The bytes32 identifier for the PROTOCOL_GUARDIAN role
*/
function PROTOCOL_GUARDIAN() external view returns (bytes32);
/**
* @notice Returns the withdraw manager contract address
* @return The address of the withdraw manager contract
*/
function withdrawManager() external view returns (IWithdrawManager);
/**
* @notice Returns the staking core contract address
* @return The address of the staking core contract
*/
function stakingCore() external view returns (IStakingCore);
/**
* @notice Returns the protocol treasury address
* @return The address of the protocol treasury
*/
function protocolTreasury() external view returns (address);
/* ========== ADMIN FUNCTIONS ========== */
/**
* @notice Sets the protocol treasury address
* @dev Only callable by accounts with PROTOCOL_GUARDIAN role
* @param _protocolTreasury The new protocol treasury address
*/
function setProtocolTreasury(address _protocolTreasury) external;
/**
* @notice Sets the withdraw manager contract address
* @dev Only callable by accounts with PROTOCOL_GUARDIAN role
* @param _withdrawManager The new withdraw manager contract address
*/
function setWithdrawManager(address _withdrawManager) external;
/**
* @notice Sets the staking core contract address
* @dev Only callable by accounts with PROTOCOL_GUARDIAN role
* @param _stakingCore The new staking core contract address
*/
function setStakingCore(address _stakingCore) external;
/**
* @notice Pauses the protocol by pausing withdrawals and staking
* @dev Only callable by accounts with PROTOCOL_PAUSER role
*/
function pauseProtocol() external;
/**
* @notice Unpauses the protocol by unpausing withdrawals and staking
* @dev Only callable by accounts with PROTOCOL_GUARDIAN role
*/
function unpauseProtocol() external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
/// @custom:storage-location erc7201:openzeppelin.storage.Ownable
struct OwnableStorage {
address _owner;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300;
function _getOwnableStorage() private pure returns (OwnableStorage storage $) {
assembly {
$.slot := OwnableStorageLocation
}
}
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
function __Ownable_init(address initialOwner) internal onlyInitializing {
__Ownable_init_unchained(initialOwner);
}
function __Ownable_init_unchained(address initialOwner) internal onlyInitializing {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @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) {
OwnableStorage storage $ = _getOwnableStorage();
return $._owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @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 {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
OwnableStorage storage $ = _getOwnableStorage();
address oldOwner = $._owner;
$._owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.20;
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Storage of the initializable contract.
*
* It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
* when using with upgradeable contracts.
*
* @custom:storage-location erc7201:openzeppelin.storage.Initializable
*/
struct InitializableStorage {
/**
* @dev Indicates that the contract has been initialized.
*/
uint64 _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool _initializing;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
/**
* @dev The contract is already initialized.
*/
error InvalidInitialization();
/**
* @dev The contract is not initializing.
*/
error NotInitializing();
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint64 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
* number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
* production.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
// Cache values to avoid duplicated sloads
bool isTopLevelCall = !$._initializing;
uint64 initialized = $._initialized;
// Allowed calls:
// - initialSetup: the contract is not in the initializing state and no previous version was
// initialized
// - construction: the contract is initialized at version 1 (no reinitialization) and the
// current contract is just being deployed
bool initialSetup = initialized == 0 && isTopLevelCall;
bool construction = initialized == 1 && address(this).code.length == 0;
if (!initialSetup && !construction) {
revert InvalidInitialization();
}
$._initialized = 1;
if (isTopLevelCall) {
$._initializing = true;
}
_;
if (isTopLevelCall) {
$._initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint64 version) {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing || $._initialized >= version) {
revert InvalidInitialization();
}
$._initialized = version;
$._initializing = true;
_;
$._initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
_checkInitializing();
_;
}
/**
* @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
*/
function _checkInitializing() internal view virtual {
if (!_isInitializing()) {
revert NotInitializing();
}
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing) {
revert InvalidInitialization();
}
if ($._initialized != type(uint64).max) {
$._initialized = type(uint64).max;
emit Initialized(type(uint64).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint64) {
return _getInitializableStorage()._initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _getInitializableStorage()._initializing;
}
/**
* @dev Pointer to storage slot. Allows integrators to override it with a custom storage location.
*
* NOTE: Consider following the ERC-7201 formula to derive storage locations.
*/
function _initializableStorageSlot() internal pure virtual returns (bytes32) {
return INITIALIZABLE_STORAGE;
}
/**
* @dev Returns a pointer to the storage namespace.
*/
// solhint-disable-next-line var-name-mixedcase
function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
bytes32 slot = _initializableStorageSlot();
assembly {
$.slot := slot
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/draft-IERC1822.sol)
pragma solidity >=0.4.16;
/**
* @dev ERC-1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822Proxiable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (proxy/ERC1967/ERC1967Utils.sol)
pragma solidity ^0.8.21;
import {IBeacon} from "../beacon/IBeacon.sol";
import {IERC1967} from "../../interfaces/IERC1967.sol";
import {Address} from "../../utils/Address.sol";
import {StorageSlot} from "../../utils/StorageSlot.sol";
/**
* @dev This library provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] slots.
*/
library ERC1967Utils {
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev The `implementation` of the proxy is invalid.
*/
error ERC1967InvalidImplementation(address implementation);
/**
* @dev The `admin` of the proxy is invalid.
*/
error ERC1967InvalidAdmin(address admin);
/**
* @dev The `beacon` of the proxy is invalid.
*/
error ERC1967InvalidBeacon(address beacon);
/**
* @dev An upgrade function sees `msg.value > 0` that may be lost.
*/
error ERC1967NonPayable();
/**
* @dev Returns the current implementation address.
*/
function getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the ERC-1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
if (newImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(newImplementation);
}
StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Performs implementation upgrade with additional setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-Upgraded} event.
*/
function upgradeToAndCall(address newImplementation, bytes memory data) internal {
_setImplementation(newImplementation);
emit IERC1967.Upgraded(newImplementation);
if (data.length > 0) {
Address.functionDelegateCall(newImplementation, data);
} else {
_checkNonPayable();
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using
* the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
*/
function getAdmin() internal view returns (address) {
return StorageSlot.getAddressSlot(ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the ERC-1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
if (newAdmin == address(0)) {
revert ERC1967InvalidAdmin(address(0));
}
StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {IERC1967-AdminChanged} event.
*/
function changeAdmin(address newAdmin) internal {
emit IERC1967.AdminChanged(getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Returns the current beacon.
*/
function getBeacon() internal view returns (address) {
return StorageSlot.getAddressSlot(BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the ERC-1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
if (newBeacon.code.length == 0) {
revert ERC1967InvalidBeacon(newBeacon);
}
StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;
address beaconImplementation = IBeacon(newBeacon).implementation();
if (beaconImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(beaconImplementation);
}
}
/**
* @dev Change the beacon and trigger a setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-BeaconUpgraded} event.
*
* CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since
* it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
* efficiency.
*/
function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {
_setBeacon(newBeacon);
emit IERC1967.BeaconUpgraded(newBeacon);
if (data.length > 0) {
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
} else {
_checkNonPayable();
}
}
/**
* @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract
* if an upgrade doesn't perform an initialization call.
*/
function _checkNonPayable() private {
if (msg.value > 0) {
revert ERC1967NonPayable();
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
/**
* @title IBeHYPEToken
* @notice Interface for the BeHYPE token contract
*/
interface IBeHYPEToken is IERC20 {
error Unauthorized();
event StakingCoreUpdated(address stakingCore);
event WithdrawManagerUpdated(address withdrawManager);
event FinalizerUserUpdated(address finalizerUser);
/**
* @notice Mints new tokens to the specified address
* @param to Address to receive the minted tokens
* @param amount Amount of tokens to mint
*/
function mint(address to, uint256 amount) external;
/**
* @notice Burns tokens from the specified address
* @param from Address to burn tokens fro
* @param amount Amount of tokens to burn
*/
function burn(address from, uint256 amount) external;
/**
* @notice Sets the finalizer / hyperCore deployer address
* @dev Only callable by PROTOCOL_GUARDIAN role. The finalizer address is stored
* in the storage slot at keccak256("HyperCore deployer") as required for
* contracts deployed by another contract (e.g. create2 via a multisig).
* https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/hyperevm/hypercore-less-than-greater-than-hyperevm-transfers#linking-core-and-evm-spot-assets
* @param _finalizerUser The address of the finalizer user
*/
function setFinalizer(address _finalizerUser) external;
/**
* @notice Gets the finalizer / hyperCore deployer address
* @dev Returns the address stored in the storage slot at keccak256("HyperCore deployer")
* https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/hyperevm/hypercore-less-than-greater-than-hyperevm-transfers#linking-core-and-evm-spot-assets
* @return The address of the finalizer / hyperCore deployer
*/
function getFinalizer() external view returns (address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (proxy/beacon/IBeacon.sol)
pragma solidity >=0.4.16;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeacon {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {UpgradeableBeacon} will check that this address is a contract.
*/
function implementation() external view returns (address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1967.sol)
pragma solidity >=0.4.11;
/**
* @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
*/
interface IERC1967 {
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Emitted when the beacon is changed.
*/
event BeaconUpgraded(address indexed beacon);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/Address.sol)
pragma solidity ^0.8.20;
import {Errors} from "./Errors.sol";
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert Errors.InsufficientBalance(address(this).balance, amount);
}
(bool success, bytes memory returndata) = recipient.call{value: amount}("");
if (!success) {
_revert(returndata);
}
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {Errors.FailedCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert Errors.InsufficientBalance(address(this).balance, value);
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case
* of an unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {Errors.FailedCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly ("memory-safe") {
revert(add(returndata, 0x20), mload(returndata))
}
} else {
revert Errors.FailedCall();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.20;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC-1967 implementation slot:
* ```solidity
* contract ERC1967 {
* // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(newImplementation.code.length > 0);
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* TIP: Consider using this library along with {SlotDerivation}.
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct Int256Slot {
int256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Int256Slot` with member `value` located at `slot`.
*/
function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
/**
* @dev Returns a `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
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 value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` 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 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of common custom errors used in multiple contracts
*
* IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.
* It is recommended to avoid relying on the error API for critical functionality.
*
* _Available since v5.1._
*/
library Errors {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error InsufficientBalance(uint256 balance, uint256 needed);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedCall();
/**
* @dev The deployment failed.
*/
error FailedDeployment();
/**
* @dev A necessary precompile is missing.
*/
error MissingPrecompile(address);
}{
"remappings": [
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"@openzeppelin-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
"forge-std/=lib/forge-std/src/",
"halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"solady/=lib/solady/src/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "cancun",
"viaIR": true
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"implementation","type":"address"}],"name":"ERC1967InvalidImplementation","type":"error"},{"inputs":[],"name":"ERC1967NonPayable","type":"error"},{"inputs":[],"name":"EnumerableRolesUnauthorized","type":"error"},{"inputs":[],"name":"FailedCall","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"InvalidRole","type":"error"},{"inputs":[],"name":"NotAuthorized","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"OnlyProtocolUpgrader","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"RoleHolderIsZeroAddress","type":"error"},{"inputs":[],"name":"RoleHoldersIndexOutOfBounds","type":"error"},{"inputs":[],"name":"UUPSUnauthorizedCallContext","type":"error"},{"inputs":[{"internalType":"bytes32","name":"slot","type":"bytes32"}],"name":"UUPSUnsupportedProxiableUUID","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[],"name":"ProtocolPaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_protocolTreasury","type":"address"}],"name":"ProtocolTreasuryUpdated","type":"event"},{"anonymous":false,"inputs":[],"name":"ProtocolUnpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"holder","type":"address"},{"indexed":true,"internalType":"uint256","name":"role","type":"uint256"},{"indexed":true,"internalType":"bool","name":"active","type":"bool"}],"name":"RoleSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_stakingCore","type":"address"}],"name":"StakingCoreUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_withdrawManager","type":"address"}],"name":"WithdrawManagerUpdated","type":"event"},{"inputs":[],"name":"MAX_ROLE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"PROTOCOL_ADMIN","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PROTOCOL_GUARDIAN","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PROTOCOL_PAUSER","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UPGRADE_INTERFACE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes","name":"encodedRoles","type":"bytes"}],"name":"checkRoles","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"holder","type":"address"},{"internalType":"uint256","name":"role","type":"uint256"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"result","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_withdrawManager","type":"address"},{"internalType":"address","name":"_stakingCore","type":"address"},{"internalType":"address","name":"_protocolTreasury","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"onlyProtocolUpgrader","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pauseProtocol","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"protocolTreasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"role","type":"uint256"},{"internalType":"uint256","name":"i","type":"uint256"}],"name":"roleHolderAt","outputs":[{"internalType":"address","name":"result","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"role","type":"uint256"}],"name":"roleHolderCount","outputs":[{"internalType":"uint256","name":"result","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"roleHolders","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"role","type":"uint256"}],"name":"roleHolders","outputs":[{"internalType":"address[]","name":"result","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_protocolTreasury","type":"address"}],"name":"setProtocolTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"holder","type":"address"},{"internalType":"uint256","name":"role","type":"uint256"},{"internalType":"bool","name":"active","type":"bool"}],"name":"setRole","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_stakingCore","type":"address"}],"name":"setStakingCore","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_withdrawManager","type":"address"}],"name":"setWithdrawManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakingCore","outputs":[{"internalType":"contract IStakingCore","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpauseProtocol","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"withdrawManager","outputs":[{"internalType":"contract IWithdrawManager","name":"","type":"address"}],"stateMutability":"view","type":"function"}]Contract Creation Code
60a080604052346100cc57306080527ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a009081549060ff8260401c166100bd57506001600160401b036002600160401b031982821601610078575b60405161165790816100d18239608051818181610d810152610e470152f35b6001600160401b031990911681179091556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a15f8080610059565b63f92ee8a960e01b8152600490fd5b5f80fdfe608060409080825260049182361015610016575f80fd5b5f915f3560e01c90816309d92fda1461128c575080630c5a61f8146111f757806317e3e2e8146111635780632f2ff15d1461107e578063492ba875146110495780634f1ef28614610e305780635006bb7b14610de557806352d1902d14610d6d5780635978cd2914610bfc5780635c97f4a214610bc2578063715018a614610b4557806375223fed14610a6157806377a9193e14610b0b57806379ba509714610ab8578063803db96d14610a9057806384cc10c514610a615780638da5cb5b14610a2d57806391d14854146109ec57806392a470691461095257806394658d7e14610918578063ad3cb1cc14610879578063c7c29cc814610822578063d24f19d514610807578063d547741f146106cb578063d598d1cf146106a4578063dbf624891461058a578063e30c397814610556578063e3b3ac43146104e2578063ec3e9da5146104bb578063f2fde38b14610435578063f8c8765e146102a45763f93b6be514610182575f80fd5b346102a057816003193601126102a0573360185263ee9853bb83525f805160206115c283398151915282526038822054156102915791819260018060a01b0380845416803b1561028d5784809185855180948193631c9897cb60e31b83525af180156102835790859161026f575b50506001541691823b1561026a5781516349fa5e6f60e11b81529284918491829084905af1908115610261575061024a575b50807f4cb3d6140b72ba86787ec31591f74ca57f8fd93a9ff34d2f6349365eb01f915f91a180f35b610253906112db565b61025e57805f610222565b80fd5b513d84823e3d90fd5b505050fd5b610278906112db565b61026a57835f6101f0565b83513d87823e3d90fd5b8480fd5b5163ea8e4eb560e01b81529050fd5b5080fd5b508234610431576080366003190112610431576102bf6112af565b906102c86112c5565b6001600160a01b03906044358281169081900361042d576064359280841680940361042d577ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0095865460ff818a1c16159667ffffffffffffffff821680159081610425575b600114908161041b575b159081610412575b50610404575067ffffffffffffffff19811660011788556103779190876103e5575b5061036a61151d565b61037261151d565b6114b2565b6001600160601b0360a01b92168288541617875581600154161760015560025416176002556103a4578280f35b805468ff00000000000000001916905551600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a181808280f35b68ffffffffffffffffff1916680100000000000000011788558a610361565b895163f92ee8a960e01b8152fd5b9050158c61033f565b303b159150610337565b89915061032d565b5f80fd5b8280fd5b823461025e57602036600319011261025e5761044f6112af565b61045761147a565b5f8051602061160283398151915280546001600160a01b0319166001600160a01b039283169081179091555f805160206115e2833981519152549091167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e227008380a380f35b50346102a057816003193601126102a057905490516001600160a01b039091168152602090f35b50346102a057806003193601126102a0576024359163ee9853bb84528335815260248120938454916001600160601b03831685101561054b575050602093839160601c9361053d575b5050516001600160a01b039091168152f35b015460601c91505f8061052b565b635694da8e9052601cfd5b50346102a057816003193601126102a0575f805160206116028339815191525490516001600160a01b039091168152602090f35b50913461042d575f36600319011261042d573360185263ee9853bb81527fe6ff4398839854a2087720a46165c7be195bc9de6f7a3c5a977d3b6917b76af25f5260385f205415610696575f546001600160a01b03908116803b1561042d575f8091848751809481936356bb54a760e01b83525af1801561068c57610679575b509282936001541691823b1561026a578151637ccce28360e11b81529284918491829084905af19081156102615750610665575b50807f442792558b9a96e0f079309b45d9c253e8c39f6394bd465b3c4ffa8f834de07991a180f35b61066e906112db565b61025e57805f61063d565b6106849193506112db565b5f915f610609565b85513d5f823e3d90fd5b825163ea8e4eb560e01b8152fd5b503461042d575f36600319011261042d57602090515f805160206115c28339815191528152f35b83823461042d5736600319011261042d5780356106e66112c5565b638da5cb5b5f5260205f84601c305afa601f3d115f5133141616156107fb5763d24f19d55f5260205f84601c305afa601f3d115f51841116166107ef578060601b156107e35763ee9853bb5f938260185252818352602483206001600160601b038154169060388520908154928361078b575b5050505060018060a01b03167faddc47d7e02c95c00ec667676636d772a589ffbf0663cfd7cd4dd3d4758201b88380a4005b869384198083019283828401036107b9575b5050506001600160601b03198254161790555583808080610759565b8187918601016001600160601b03198154168093858801015555602452603885205587808061079d565b8263825501435f52601cfd5b8263d954416a5f52601cfd5b826399152cca5f52601cfd5b503461042d575f36600319011261042d57515f198152602090f35b833461042d5761083136611341565b805f9260185263ee9853bb8452601f1981511601905b81811083106108645750501561085957005b6399152cca5f52601cfd5b60200180515f90815260389020549250610847565b83823461042d575f36600319011261042d578051918183019083821067ffffffffffffffff83111761090557508152600582526020640352e302e360dc1b60208401528151928391602083528151918260208501525f5b8381106108ef5750505f83830185015250601f01601f19168101030190f35b81810183015187820187015286945082016108d0565b604190634e487b7160e01b5f525260245ffd5b503461042d575f36600319011261042d57602090517f0245b6cbab6b03e029f6c88bff9595f9f5c30170f52598c3459ee71476ad59c18152f35b83823461042d57602036600319011261042d5761096d6112af565b913360185263ee9853bb81525f805160206115c28339815191525f5260385f2054156109de57600180546001600160a01b0319166001600160a01b03851690811790915582519081527feac50e01775d3d36adf70171804f10d9318c75be187e0d22f020893cad1c07c190602090a1005b905163ea8e4eb560e01b8152fd5b83823461042d578060031936011261042d57610a2460209235610a0d6112c5565b60185263ee9853bb6004525f5260385f2054151590565b90519015158152f35b503461042d575f36600319011261042d575f805160206115e28339815191525490516001600160a01b039091168152602090f35b83823461042d57602036600319011261042d57610a81610a8c9235611402565b9051918291826113be565b0390f35b503461042d575f36600319011261042d5760025490516001600160a01b039091168152602090f35b50823461042d575f36600319011261042d575f8051602061160283398151915254336001600160a01b0390911603610af557610af3336114b2565b005b602491519063118cdaa760e01b82523390820152fd5b503461042d575f36600319011261042d57602090517fe6ff4398839854a2087720a46165c7be195bc9de6f7a3c5a977d3b6917b76af28152f35b3461042d575f36600319011261042d57610b5d61147a565b5f8051602061160283398151915280546001600160a01b03199081169091555f805160206115e2833981519152805491821690555f906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b503461042d578060031936011261042d57602090610a24610be16112af565b6024359060185263ee9853bb6004525f5260385f2054151590565b83606036600319011261042d57610c116112af565b906024916024359160443593841590811580960361042d57638da5cb5b5f5260205f84601c305afa601f3d115f5133141616156107fb5763d24f19d55f5260205f84601c305afa601f3d115f51871116166107ef578360601b928315610d625763ee9853bb908560185252845f5260245f20926001600160601b038454169260389260385f2093845490811593610cf757505050610cde575b505050505b6001600160a01b03167faddc47d7e02c95c00ec667676636d772a589ffbf0663cfd7cd4dd3d4758201b85f80a4005b8284015560018092019055815401905583808080610caa565b91969495935091610d57575f955f1984810194909190808503610d2f575b50505050506001600160601b031982541617905555610caf565b8289918801016001600160601b03198154168094878a01015555528520558780808080610d15565b505050505050610caf565b63825501435f52601cfd5b83823461042d575f36600319011261042d577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163003610dd857602090517f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8152f35b5163703e46dd60e11b8152fd5b83823461042d57602036600319011261042d57610e006112af565b5f805160206115e2833981519152546001600160a01b03908116911603610e2357005b516334f8b7af60e21b8152fd5b5082610e3b36611341565b90926001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811630811490811561101b575b5061100b57610e8061147a565b8416918151946352d1902d60e01b865260209081878781885afa5f9781610fdc575b50610ebe578351634c9c8ce360e01b8152808701869052602490fd5b919490937f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc877fc9f76b5ec45e5cdef99837d7b6d2467235c1df8933c8ca56df5c35afa2c7d4448101610fc65750833b15610faf5780546001600160a01b031916821790558351907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b5f80a2855115610f965750505f808585610af397519101845af4913d15610f8c573d610f7e610f7582611325565b92519283611303565b81525f81943d92013e61155e565b506060925061155e565b93509350505034610fa357005b63b398979f60e01b8152fd5b8451634c9c8ce360e01b8152808401839052602490fd5b83602491875191632a87526960e21b8352820152fd5b9097508281813d8311611004575b610ff48183611303565b8101031261042d57519688610ea2565b503d610fea565b815163703e46dd60e11b81528490fd5b9050817f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5416141586610e73565b83823461042d57602036600319011261042d578163ee9853bb60209352355f526001600160601b0360245f2054169051908152f35b83823461042d5736600319011261042d5780356110996112c5565b638da5cb5b5f5260205f84601c305afa601f3d115f5133141616156107fb5763d24f19d55f5260205f84601c305afa601f3d115f51841116166107ef578060601b80156111575763ee9853bb6001948360185252825f5260245f20906001600160601b038254169060385f209182541561113f575b50505050828060a01b03167faddc47d7e02c95c00ec667676636d772a589ffbf0663cfd7cd4dd3d4758201b85f80a4005b8691818501550190558381540190558380808061110e565b8363825501435f52601cfd5b83823461042d57602036600319011261042d5761117e6112af565b916111a83360185263ee9853bb6004525f805160206115c28339815191525f5260385f2054151590565b156109de575f80546001600160a01b0319166001600160a01b03851690811790915582519081527fb7b4e63ea89107bd0b2ca900b65382e4a8e6b66b4498eb9cba2f7c0dc526d6c890602090a1005b83823461042d57602036600319011261042d576112126112af565b9161123c3360185263ee9853bb6004525f805160206115c28339815191525f5260385f2054151590565b156109de57600280546001600160a01b0319166001600160a01b03851690811790915582519081527fb141872ee67913e1bc546464f29b6b07a65159d45c6af64fdecf8b4129157faf90602090a1005b3461042d575f36600319011261042d576001546001600160a01b03168152602090f35b600435906001600160a01b038216820361042d57565b602435906001600160a01b038216820361042d57565b67ffffffffffffffff81116112ef57604052565b634e487b7160e01b5f52604160045260245ffd5b90601f8019910116810190811067ffffffffffffffff8211176112ef57604052565b67ffffffffffffffff81116112ef57601f01601f191660200190565b90604060031983011261042d576004356001600160a01b038116810361042d579160243567ffffffffffffffff811161042d578160238201121561042d5780600401359061138e82611325565b9261139c6040519485611303565b8284526024838301011161042d57815f92602460209301838601378301015290565b60209060206040818301928281528551809452019301915f5b8281106113e5575050505090565b83516001600160a01b0316855293810193928101926001016113d7565b906040519163ee9853bb6004525f5260245f208054906001600160601b038216906020906060918460601c876020015260019260015b85811061146357505050918552505060051b6c1fffffffffffffffffffffffe0168201602001604052565b808591850154831c848260051b8c01015201611438565b5f805160206115e2833981519152546001600160a01b0316330361149a57565b60405163118cdaa760e01b8152336004820152602490fd5b5f8051602061160283398151915280546001600160a01b03199081169091555f805160206115e283398151915280549182166001600160a01b0393841690811790915591167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3565b60ff7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460401c161561154c57565b604051631afcd79f60e31b8152600490fd5b90611585575080511561157357602081519101fd5b60405163d6bda27560e01b8152600490fd5b815115806115b8575b611596575090565b604051639996b31560e01b81526001600160a01b039091166004820152602490fd5b50803b1561158e56fee38989bfdd76ccae604177aa6d200932d5e64a593476f9f355ce0da558735af89016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c00a2646970667358221220bff0b577555daebab1a83cb5e5c30dfb6f3b2ddf15e7a8b37727ce14e57bfd6264736f6c63430008180033
Deployed Bytecode
0x608060409080825260049182361015610016575f80fd5b5f915f3560e01c90816309d92fda1461128c575080630c5a61f8146111f757806317e3e2e8146111635780632f2ff15d1461107e578063492ba875146110495780634f1ef28614610e305780635006bb7b14610de557806352d1902d14610d6d5780635978cd2914610bfc5780635c97f4a214610bc2578063715018a614610b4557806375223fed14610a6157806377a9193e14610b0b57806379ba509714610ab8578063803db96d14610a9057806384cc10c514610a615780638da5cb5b14610a2d57806391d14854146109ec57806392a470691461095257806394658d7e14610918578063ad3cb1cc14610879578063c7c29cc814610822578063d24f19d514610807578063d547741f146106cb578063d598d1cf146106a4578063dbf624891461058a578063e30c397814610556578063e3b3ac43146104e2578063ec3e9da5146104bb578063f2fde38b14610435578063f8c8765e146102a45763f93b6be514610182575f80fd5b346102a057816003193601126102a0573360185263ee9853bb83525f805160206115c283398151915282526038822054156102915791819260018060a01b0380845416803b1561028d5784809185855180948193631c9897cb60e31b83525af180156102835790859161026f575b50506001541691823b1561026a5781516349fa5e6f60e11b81529284918491829084905af1908115610261575061024a575b50807f4cb3d6140b72ba86787ec31591f74ca57f8fd93a9ff34d2f6349365eb01f915f91a180f35b610253906112db565b61025e57805f610222565b80fd5b513d84823e3d90fd5b505050fd5b610278906112db565b61026a57835f6101f0565b83513d87823e3d90fd5b8480fd5b5163ea8e4eb560e01b81529050fd5b5080fd5b508234610431576080366003190112610431576102bf6112af565b906102c86112c5565b6001600160a01b03906044358281169081900361042d576064359280841680940361042d577ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0095865460ff818a1c16159667ffffffffffffffff821680159081610425575b600114908161041b575b159081610412575b50610404575067ffffffffffffffff19811660011788556103779190876103e5575b5061036a61151d565b61037261151d565b6114b2565b6001600160601b0360a01b92168288541617875581600154161760015560025416176002556103a4578280f35b805468ff00000000000000001916905551600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a181808280f35b68ffffffffffffffffff1916680100000000000000011788558a610361565b895163f92ee8a960e01b8152fd5b9050158c61033f565b303b159150610337565b89915061032d565b5f80fd5b8280fd5b823461025e57602036600319011261025e5761044f6112af565b61045761147a565b5f8051602061160283398151915280546001600160a01b0319166001600160a01b039283169081179091555f805160206115e2833981519152549091167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e227008380a380f35b50346102a057816003193601126102a057905490516001600160a01b039091168152602090f35b50346102a057806003193601126102a0576024359163ee9853bb84528335815260248120938454916001600160601b03831685101561054b575050602093839160601c9361053d575b5050516001600160a01b039091168152f35b015460601c91505f8061052b565b635694da8e9052601cfd5b50346102a057816003193601126102a0575f805160206116028339815191525490516001600160a01b039091168152602090f35b50913461042d575f36600319011261042d573360185263ee9853bb81527fe6ff4398839854a2087720a46165c7be195bc9de6f7a3c5a977d3b6917b76af25f5260385f205415610696575f546001600160a01b03908116803b1561042d575f8091848751809481936356bb54a760e01b83525af1801561068c57610679575b509282936001541691823b1561026a578151637ccce28360e11b81529284918491829084905af19081156102615750610665575b50807f442792558b9a96e0f079309b45d9c253e8c39f6394bd465b3c4ffa8f834de07991a180f35b61066e906112db565b61025e57805f61063d565b6106849193506112db565b5f915f610609565b85513d5f823e3d90fd5b825163ea8e4eb560e01b8152fd5b503461042d575f36600319011261042d57602090515f805160206115c28339815191528152f35b83823461042d5736600319011261042d5780356106e66112c5565b638da5cb5b5f5260205f84601c305afa601f3d115f5133141616156107fb5763d24f19d55f5260205f84601c305afa601f3d115f51841116166107ef578060601b156107e35763ee9853bb5f938260185252818352602483206001600160601b038154169060388520908154928361078b575b5050505060018060a01b03167faddc47d7e02c95c00ec667676636d772a589ffbf0663cfd7cd4dd3d4758201b88380a4005b869384198083019283828401036107b9575b5050506001600160601b03198254161790555583808080610759565b8187918601016001600160601b03198154168093858801015555602452603885205587808061079d565b8263825501435f52601cfd5b8263d954416a5f52601cfd5b826399152cca5f52601cfd5b503461042d575f36600319011261042d57515f198152602090f35b833461042d5761083136611341565b805f9260185263ee9853bb8452601f1981511601905b81811083106108645750501561085957005b6399152cca5f52601cfd5b60200180515f90815260389020549250610847565b83823461042d575f36600319011261042d578051918183019083821067ffffffffffffffff83111761090557508152600582526020640352e302e360dc1b60208401528151928391602083528151918260208501525f5b8381106108ef5750505f83830185015250601f01601f19168101030190f35b81810183015187820187015286945082016108d0565b604190634e487b7160e01b5f525260245ffd5b503461042d575f36600319011261042d57602090517f0245b6cbab6b03e029f6c88bff9595f9f5c30170f52598c3459ee71476ad59c18152f35b83823461042d57602036600319011261042d5761096d6112af565b913360185263ee9853bb81525f805160206115c28339815191525f5260385f2054156109de57600180546001600160a01b0319166001600160a01b03851690811790915582519081527feac50e01775d3d36adf70171804f10d9318c75be187e0d22f020893cad1c07c190602090a1005b905163ea8e4eb560e01b8152fd5b83823461042d578060031936011261042d57610a2460209235610a0d6112c5565b60185263ee9853bb6004525f5260385f2054151590565b90519015158152f35b503461042d575f36600319011261042d575f805160206115e28339815191525490516001600160a01b039091168152602090f35b83823461042d57602036600319011261042d57610a81610a8c9235611402565b9051918291826113be565b0390f35b503461042d575f36600319011261042d5760025490516001600160a01b039091168152602090f35b50823461042d575f36600319011261042d575f8051602061160283398151915254336001600160a01b0390911603610af557610af3336114b2565b005b602491519063118cdaa760e01b82523390820152fd5b503461042d575f36600319011261042d57602090517fe6ff4398839854a2087720a46165c7be195bc9de6f7a3c5a977d3b6917b76af28152f35b3461042d575f36600319011261042d57610b5d61147a565b5f8051602061160283398151915280546001600160a01b03199081169091555f805160206115e2833981519152805491821690555f906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b503461042d578060031936011261042d57602090610a24610be16112af565b6024359060185263ee9853bb6004525f5260385f2054151590565b83606036600319011261042d57610c116112af565b906024916024359160443593841590811580960361042d57638da5cb5b5f5260205f84601c305afa601f3d115f5133141616156107fb5763d24f19d55f5260205f84601c305afa601f3d115f51871116166107ef578360601b928315610d625763ee9853bb908560185252845f5260245f20926001600160601b038454169260389260385f2093845490811593610cf757505050610cde575b505050505b6001600160a01b03167faddc47d7e02c95c00ec667676636d772a589ffbf0663cfd7cd4dd3d4758201b85f80a4005b8284015560018092019055815401905583808080610caa565b91969495935091610d57575f955f1984810194909190808503610d2f575b50505050506001600160601b031982541617905555610caf565b8289918801016001600160601b03198154168094878a01015555528520558780808080610d15565b505050505050610caf565b63825501435f52601cfd5b83823461042d575f36600319011261042d577f00000000000000000000000096a7b5e92f21ff7adfac333453eb10b96ea8acca6001600160a01b03163003610dd857602090517f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8152f35b5163703e46dd60e11b8152fd5b83823461042d57602036600319011261042d57610e006112af565b5f805160206115e2833981519152546001600160a01b03908116911603610e2357005b516334f8b7af60e21b8152fd5b5082610e3b36611341565b90926001600160a01b037f00000000000000000000000096a7b5e92f21ff7adfac333453eb10b96ea8acca811630811490811561101b575b5061100b57610e8061147a565b8416918151946352d1902d60e01b865260209081878781885afa5f9781610fdc575b50610ebe578351634c9c8ce360e01b8152808701869052602490fd5b919490937f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc877fc9f76b5ec45e5cdef99837d7b6d2467235c1df8933c8ca56df5c35afa2c7d4448101610fc65750833b15610faf5780546001600160a01b031916821790558351907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b5f80a2855115610f965750505f808585610af397519101845af4913d15610f8c573d610f7e610f7582611325565b92519283611303565b81525f81943d92013e61155e565b506060925061155e565b93509350505034610fa357005b63b398979f60e01b8152fd5b8451634c9c8ce360e01b8152808401839052602490fd5b83602491875191632a87526960e21b8352820152fd5b9097508281813d8311611004575b610ff48183611303565b8101031261042d57519688610ea2565b503d610fea565b815163703e46dd60e11b81528490fd5b9050817f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5416141586610e73565b83823461042d57602036600319011261042d578163ee9853bb60209352355f526001600160601b0360245f2054169051908152f35b83823461042d5736600319011261042d5780356110996112c5565b638da5cb5b5f5260205f84601c305afa601f3d115f5133141616156107fb5763d24f19d55f5260205f84601c305afa601f3d115f51841116166107ef578060601b80156111575763ee9853bb6001948360185252825f5260245f20906001600160601b038254169060385f209182541561113f575b50505050828060a01b03167faddc47d7e02c95c00ec667676636d772a589ffbf0663cfd7cd4dd3d4758201b85f80a4005b8691818501550190558381540190558380808061110e565b8363825501435f52601cfd5b83823461042d57602036600319011261042d5761117e6112af565b916111a83360185263ee9853bb6004525f805160206115c28339815191525f5260385f2054151590565b156109de575f80546001600160a01b0319166001600160a01b03851690811790915582519081527fb7b4e63ea89107bd0b2ca900b65382e4a8e6b66b4498eb9cba2f7c0dc526d6c890602090a1005b83823461042d57602036600319011261042d576112126112af565b9161123c3360185263ee9853bb6004525f805160206115c28339815191525f5260385f2054151590565b156109de57600280546001600160a01b0319166001600160a01b03851690811790915582519081527fb141872ee67913e1bc546464f29b6b07a65159d45c6af64fdecf8b4129157faf90602090a1005b3461042d575f36600319011261042d576001546001600160a01b03168152602090f35b600435906001600160a01b038216820361042d57565b602435906001600160a01b038216820361042d57565b67ffffffffffffffff81116112ef57604052565b634e487b7160e01b5f52604160045260245ffd5b90601f8019910116810190811067ffffffffffffffff8211176112ef57604052565b67ffffffffffffffff81116112ef57601f01601f191660200190565b90604060031983011261042d576004356001600160a01b038116810361042d579160243567ffffffffffffffff811161042d578160238201121561042d5780600401359061138e82611325565b9261139c6040519485611303565b8284526024838301011161042d57815f92602460209301838601378301015290565b60209060206040818301928281528551809452019301915f5b8281106113e5575050505090565b83516001600160a01b0316855293810193928101926001016113d7565b906040519163ee9853bb6004525f5260245f208054906001600160601b038216906020906060918460601c876020015260019260015b85811061146357505050918552505060051b6c1fffffffffffffffffffffffe0168201602001604052565b808591850154831c848260051b8c01015201611438565b5f805160206115e2833981519152546001600160a01b0316330361149a57565b60405163118cdaa760e01b8152336004820152602490fd5b5f8051602061160283398151915280546001600160a01b03199081169091555f805160206115e283398151915280549182166001600160a01b0393841690811790915591167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3565b60ff7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460401c161561154c57565b604051631afcd79f60e31b8152600490fd5b90611585575080511561157357602081519101fd5b60405163d6bda27560e01b8152600490fd5b815115806115b8575b611596575090565b604051639996b31560e01b81526001600160a01b039091166004820152602490fd5b50803b1561158e56fee38989bfdd76ccae604177aa6d200932d5e64a593476f9f355ce0da558735af89016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c00a2646970667358221220bff0b577555daebab1a83cb5e5c30dfb6f3b2ddf15e7a8b37727ce14e57bfd6264736f6c63430008180033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in HYPE
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.