Source Code
Overview
ETH Balance
0 ETH
More Info
ContractCreator
Multichain Info
N/A
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
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 Source Code Verified (Exact Match)
Contract Name:
NetworkRestakeDelegator
Compiler Version
v0.8.25+commit.b61c2a91
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.25; import {BaseDelegator} from "./BaseDelegator.sol"; import {IBaseDelegator} from "../../interfaces/delegator/IBaseDelegator.sol"; import {INetworkRestakeDelegator} from "../../interfaces/delegator/INetworkRestakeDelegator.sol"; import {IVault} from "../../interfaces/vault/IVault.sol"; import {Checkpoints} from "../libraries/Checkpoints.sol"; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {Time} from "@openzeppelin/contracts/utils/types/Time.sol"; contract NetworkRestakeDelegator is BaseDelegator, INetworkRestakeDelegator { using Checkpoints for Checkpoints.Trace256; using Math for uint256; /** * @inheritdoc INetworkRestakeDelegator */ bytes32 public constant NETWORK_LIMIT_SET_ROLE = keccak256("NETWORK_LIMIT_SET_ROLE"); /** * @inheritdoc INetworkRestakeDelegator */ bytes32 public constant OPERATOR_NETWORK_SHARES_SET_ROLE = keccak256("OPERATOR_NETWORK_SHARES_SET_ROLE"); mapping(bytes32 subnetwork => Checkpoints.Trace256 value) internal _networkLimit; mapping(bytes32 subnetwork => Checkpoints.Trace256 shares) internal _totalOperatorNetworkShares; mapping(bytes32 subnetwork => mapping(address operator => Checkpoints.Trace256 shares)) internal _operatorNetworkShares; constructor( address networkRegistry, address vaultFactory, address operatorVaultOptInService, address operatorNetworkOptInService, address delegatorFactory, uint64 entityType ) BaseDelegator( networkRegistry, vaultFactory, operatorVaultOptInService, operatorNetworkOptInService, delegatorFactory, entityType ) {} /** * @inheritdoc INetworkRestakeDelegator */ function networkLimitAt(bytes32 subnetwork, uint48 timestamp, bytes memory hint) public view returns (uint256) { return _networkLimit[subnetwork].upperLookupRecent(timestamp, hint); } /** * @inheritdoc INetworkRestakeDelegator */ function networkLimit( bytes32 subnetwork ) public view returns (uint256) { return _networkLimit[subnetwork].latest(); } /** * @inheritdoc INetworkRestakeDelegator */ function totalOperatorNetworkSharesAt( bytes32 subnetwork, uint48 timestamp, bytes memory hint ) public view returns (uint256) { return _totalOperatorNetworkShares[subnetwork].upperLookupRecent(timestamp, hint); } /** * @inheritdoc INetworkRestakeDelegator */ function totalOperatorNetworkShares( bytes32 subnetwork ) public view returns (uint256) { return _totalOperatorNetworkShares[subnetwork].latest(); } /** * @inheritdoc INetworkRestakeDelegator */ function operatorNetworkSharesAt( bytes32 subnetwork, address operator, uint48 timestamp, bytes memory hint ) public view returns (uint256) { return _operatorNetworkShares[subnetwork][operator].upperLookupRecent(timestamp, hint); } /** * @inheritdoc INetworkRestakeDelegator */ function operatorNetworkShares(bytes32 subnetwork, address operator) public view returns (uint256) { return _operatorNetworkShares[subnetwork][operator].latest(); } /** * @inheritdoc INetworkRestakeDelegator */ function setNetworkLimit(bytes32 subnetwork, uint256 amount) external onlyRole(NETWORK_LIMIT_SET_ROLE) { if (amount > maxNetworkLimit[subnetwork]) { revert ExceedsMaxNetworkLimit(); } if (networkLimit(subnetwork) == amount) { revert AlreadySet(); } _networkLimit[subnetwork].push(Time.timestamp(), amount); emit SetNetworkLimit(subnetwork, amount); } /** * @inheritdoc INetworkRestakeDelegator */ function setOperatorNetworkShares( bytes32 subnetwork, address operator, uint256 shares ) external onlyRole(OPERATOR_NETWORK_SHARES_SET_ROLE) { uint256 operatorNetworkShares_ = operatorNetworkShares(subnetwork, operator); if (operatorNetworkShares_ == shares) { revert AlreadySet(); } _totalOperatorNetworkShares[subnetwork].push( Time.timestamp(), totalOperatorNetworkShares(subnetwork) - operatorNetworkShares_ + shares ); _operatorNetworkShares[subnetwork][operator].push(Time.timestamp(), shares); emit SetOperatorNetworkShares(subnetwork, operator, shares); } function _stakeAt( bytes32 subnetwork, address operator, uint48 timestamp, bytes memory hints ) internal view override returns (uint256, bytes memory) { StakeHints memory stakesHints; if (hints.length > 0) { stakesHints = abi.decode(hints, (StakeHints)); } uint256 totalOperatorNetworkSharesAt_ = totalOperatorNetworkSharesAt(subnetwork, timestamp, stakesHints.totalOperatorNetworkSharesHint); return totalOperatorNetworkSharesAt_ == 0 ? (0, stakesHints.baseHints) : ( operatorNetworkSharesAt(subnetwork, operator, timestamp, stakesHints.operatorNetworkSharesHint).mulDiv( Math.min( IVault(vault).activeStakeAt(timestamp, stakesHints.activeStakeHint), networkLimitAt(subnetwork, timestamp, stakesHints.networkLimitHint) ), totalOperatorNetworkSharesAt_ ), stakesHints.baseHints ); } function _stake(bytes32 subnetwork, address operator) internal view override returns (uint256) { uint256 totalOperatorNetworkShares_ = totalOperatorNetworkShares(subnetwork); return totalOperatorNetworkShares_ == 0 ? 0 : operatorNetworkShares(subnetwork, operator).mulDiv( Math.min(IVault(vault).activeStake(), networkLimit(subnetwork)), totalOperatorNetworkShares_ ); } function _setMaxNetworkLimit(bytes32 subnetwork, uint256 amount) internal override { (bool exists,, uint256 latestValue) = _networkLimit[subnetwork].latestCheckpoint(); if (exists && latestValue > amount) { _networkLimit[subnetwork].push(Time.timestamp(), amount); } } function __initialize(address, bytes memory data) internal override returns (IBaseDelegator.BaseParams memory) { InitParams memory params = abi.decode(data, (InitParams)); if ( params.baseParams.defaultAdminRoleHolder == address(0) && (params.networkLimitSetRoleHolders.length == 0 || params.operatorNetworkSharesSetRoleHolders.length == 0) ) { revert MissingRoleHolders(); } for (uint256 i; i < params.networkLimitSetRoleHolders.length; ++i) { if (params.networkLimitSetRoleHolders[i] == address(0)) { revert ZeroAddressRoleHolder(); } if (!_grantRole(NETWORK_LIMIT_SET_ROLE, params.networkLimitSetRoleHolders[i])) { revert DuplicateRoleHolder(); } } for (uint256 i; i < params.operatorNetworkSharesSetRoleHolders.length; ++i) { if (params.operatorNetworkSharesSetRoleHolders[i] == address(0)) { revert ZeroAddressRoleHolder(); } if (!_grantRole(OPERATOR_NETWORK_SHARES_SET_ROLE, params.operatorNetworkSharesSetRoleHolders[i])) { revert DuplicateRoleHolder(); } } return params.baseParams; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.25; import {Entity} from "../common/Entity.sol"; import {StaticDelegateCallable} from "../common/StaticDelegateCallable.sol"; import {IBaseDelegator} from "../../interfaces/delegator/IBaseDelegator.sol"; import {IDelegatorHook} from "../../interfaces/delegator/IDelegatorHook.sol"; import {IOptInService} from "../../interfaces/service/IOptInService.sol"; import {IRegistry} from "../../interfaces/common/IRegistry.sol"; import {IVault} from "../../interfaces/vault/IVault.sol"; import {Subnetwork} from "../libraries/Subnetwork.sol"; import {AccessControlUpgradeable} from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol"; abstract contract BaseDelegator is Entity, StaticDelegateCallable, AccessControlUpgradeable, ReentrancyGuardUpgradeable, IBaseDelegator { using Subnetwork for bytes32; using Subnetwork for address; /** * @inheritdoc IBaseDelegator */ uint256 public constant HOOK_GAS_LIMIT = 250_000; /** * @inheritdoc IBaseDelegator */ uint256 public constant HOOK_RESERVE = 20_000; /** * @inheritdoc IBaseDelegator */ bytes32 public constant HOOK_SET_ROLE = keccak256("HOOK_SET_ROLE"); /** * @inheritdoc IBaseDelegator */ address public immutable NETWORK_REGISTRY; /** * @inheritdoc IBaseDelegator */ address public immutable VAULT_FACTORY; /** * @inheritdoc IBaseDelegator */ address public immutable OPERATOR_VAULT_OPT_IN_SERVICE; /** * @inheritdoc IBaseDelegator */ address public immutable OPERATOR_NETWORK_OPT_IN_SERVICE; /** * @inheritdoc IBaseDelegator */ address public vault; /** * @inheritdoc IBaseDelegator */ address public hook; /** * @inheritdoc IBaseDelegator */ mapping(bytes32 subnetwork => uint256 value) public maxNetworkLimit; constructor( address networkRegistry, address vaultFactory, address operatorVaultOptInService, address operatorNetworkOptInService, address delegatorFactory, uint64 entityType ) Entity(delegatorFactory, entityType) { NETWORK_REGISTRY = networkRegistry; VAULT_FACTORY = vaultFactory; OPERATOR_VAULT_OPT_IN_SERVICE = operatorVaultOptInService; OPERATOR_NETWORK_OPT_IN_SERVICE = operatorNetworkOptInService; } /** * @inheritdoc IBaseDelegator */ function VERSION() external pure returns (uint64) { return 1; } /** * @inheritdoc IBaseDelegator */ function stakeAt( bytes32 subnetwork, address operator, uint48 timestamp, bytes memory hints ) public view returns (uint256) { (uint256 stake_, bytes memory baseHints) = _stakeAt(subnetwork, operator, timestamp, hints); StakeBaseHints memory stakeBaseHints; if (baseHints.length > 0) { stakeBaseHints = abi.decode(baseHints, (StakeBaseHints)); } if ( stake_ == 0 || !IOptInService(OPERATOR_VAULT_OPT_IN_SERVICE).isOptedInAt( operator, vault, timestamp, stakeBaseHints.operatorVaultOptInHint ) || !IOptInService(OPERATOR_NETWORK_OPT_IN_SERVICE).isOptedInAt( operator, subnetwork.network(), timestamp, stakeBaseHints.operatorNetworkOptInHint ) ) { return 0; } return stake_; } /** * @inheritdoc IBaseDelegator */ function stake(bytes32 subnetwork, address operator) external view returns (uint256) { if ( !IOptInService(OPERATOR_VAULT_OPT_IN_SERVICE).isOptedIn(operator, vault) || !IOptInService(OPERATOR_NETWORK_OPT_IN_SERVICE).isOptedIn(operator, subnetwork.network()) ) { return 0; } return _stake(subnetwork, operator); } /** * @inheritdoc IBaseDelegator */ function setMaxNetworkLimit(uint96 identifier, uint256 amount) external nonReentrant { if (!IRegistry(NETWORK_REGISTRY).isEntity(msg.sender)) { revert NotNetwork(); } bytes32 subnetwork = (msg.sender).subnetwork(identifier); if (maxNetworkLimit[subnetwork] == amount) { revert AlreadySet(); } maxNetworkLimit[subnetwork] = amount; _setMaxNetworkLimit(subnetwork, amount); emit SetMaxNetworkLimit(subnetwork, amount); } /** * @inheritdoc IBaseDelegator */ function setHook( address hook_ ) external nonReentrant onlyRole(HOOK_SET_ROLE) { if (hook == hook_) { revert AlreadySet(); } hook = hook_; emit SetHook(hook_); } /** * @inheritdoc IBaseDelegator */ function onSlash( bytes32 subnetwork, address operator, uint256 amount, uint48 captureTimestamp, bytes memory data ) external nonReentrant { if (msg.sender != IVault(vault).slasher()) { revert NotSlasher(); } address hook_ = hook; if (hook_ != address(0)) { bytes memory calldata_ = abi.encodeCall(IDelegatorHook.onSlash, (subnetwork, operator, amount, captureTimestamp, data)); if (gasleft() < HOOK_RESERVE + HOOK_GAS_LIMIT * 64 / 63) { revert InsufficientHookGas(); } assembly ("memory-safe") { pop(call(HOOK_GAS_LIMIT, hook_, 0, add(calldata_, 0x20), mload(calldata_), 0, 0)) } } emit OnSlash(subnetwork, operator, amount, captureTimestamp); } function _initialize( bytes calldata data ) internal override { (address vault_, bytes memory data_) = abi.decode(data, (address, bytes)); if (!IRegistry(VAULT_FACTORY).isEntity(vault_)) { revert NotVault(); } __ReentrancyGuard_init(); vault = vault_; BaseParams memory baseParams = __initialize(vault_, data_); hook = baseParams.hook; if (baseParams.defaultAdminRoleHolder != address(0)) { _grantRole(DEFAULT_ADMIN_ROLE, baseParams.defaultAdminRoleHolder); } if (baseParams.hookSetRoleHolder != address(0)) { _grantRole(HOOK_SET_ROLE, baseParams.hookSetRoleHolder); } } function _stakeAt( bytes32 subnetwork, address operator, uint48 timestamp, bytes memory hints ) internal view virtual returns (uint256, bytes memory) {} function _stake(bytes32 subnetwork, address operator) internal view virtual returns (uint256) {} function _setMaxNetworkLimit(bytes32 subnetwork, uint256 amount) internal virtual {} function __initialize(address vault_, bytes memory data) internal virtual returns (BaseParams memory) {} }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {IEntity} from "../common/IEntity.sol"; interface IBaseDelegator is IEntity { error AlreadySet(); error InsufficientHookGas(); error NotNetwork(); error NotSlasher(); error NotVault(); /** * @notice Base parameters needed for delegators' deployment. * @param defaultAdminRoleHolder address of the initial DEFAULT_ADMIN_ROLE holder * @param hook address of the hook contract * @param hookSetRoleHolder address of the initial HOOK_SET_ROLE holder */ struct BaseParams { address defaultAdminRoleHolder; address hook; address hookSetRoleHolder; } /** * @notice Base hints for a stake. * @param operatorVaultOptInHint hint for the operator-vault opt-in * @param operatorNetworkOptInHint hint for the operator-network opt-in */ struct StakeBaseHints { bytes operatorVaultOptInHint; bytes operatorNetworkOptInHint; } /** * @notice Emitted when a subnetwork's maximum limit is set. * @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier) * @param amount new maximum subnetwork's limit (how much stake the subnetwork is ready to get) */ event SetMaxNetworkLimit(bytes32 indexed subnetwork, uint256 amount); /** * @notice Emitted when a slash happens. * @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier) * @param operator address of the operator * @param amount amount of the collateral to be slashed * @param captureTimestamp time point when the stake was captured */ event OnSlash(bytes32 indexed subnetwork, address indexed operator, uint256 amount, uint48 captureTimestamp); /** * @notice Emitted when a hook is set. * @param hook address of the hook */ event SetHook(address indexed hook); /** * @notice Get a version of the delegator (different versions mean different interfaces). * @return version of the delegator * @dev Must return 1 for this one. */ function VERSION() external view returns (uint64); /** * @notice Get the network registry's address. * @return address of the network registry */ function NETWORK_REGISTRY() external view returns (address); /** * @notice Get the vault factory's address. * @return address of the vault factory */ function VAULT_FACTORY() external view returns (address); /** * @notice Get the operator-vault opt-in service's address. * @return address of the operator-vault opt-in service */ function OPERATOR_VAULT_OPT_IN_SERVICE() external view returns (address); /** * @notice Get the operator-network opt-in service's address. * @return address of the operator-network opt-in service */ function OPERATOR_NETWORK_OPT_IN_SERVICE() external view returns (address); /** * @notice Get a gas limit for the hook. * @return value of the hook gas limit */ function HOOK_GAS_LIMIT() external view returns (uint256); /** * @notice Get a reserve gas between the gas limit check and the hook's execution. * @return value of the reserve gas */ function HOOK_RESERVE() external view returns (uint256); /** * @notice Get a hook setter's role. * @return identifier of the hook setter role */ function HOOK_SET_ROLE() external view returns (bytes32); /** * @notice Get the vault's address. * @return address of the vault */ function vault() external view returns (address); /** * @notice Get the hook's address. * @return address of the hook * @dev The hook can have arbitrary logic under certain functions, however, it doesn't affect the stake guarantees. */ function hook() external view returns (address); /** * @notice Get a particular subnetwork's maximum limit * (meaning the subnetwork is not ready to get more as a stake). * @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier) * @return maximum limit of the subnetwork */ function maxNetworkLimit( bytes32 subnetwork ) external view returns (uint256); /** * @notice Get a stake that a given subnetwork could be able to slash for a certain operator at a given timestamp * until the end of the consequent epoch using hints (if no cross-slashing and no slashings by the subnetwork). * @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier) * @param operator address of the operator * @param timestamp time point to capture the stake at * @param hints hints for the checkpoints' indexes * @return slashable stake at the given timestamp until the end of the consequent epoch * @dev Warning: it is not safe to use timestamp >= current one for the stake capturing, as it can change later. */ function stakeAt( bytes32 subnetwork, address operator, uint48 timestamp, bytes memory hints ) external view returns (uint256); /** * @notice Get a stake that a given subnetwork will be able to slash * for a certain operator until the end of the next epoch (if no cross-slashing and no slashings by the subnetwork). * @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier) * @param operator address of the operator * @return slashable stake until the end of the next epoch * @dev Warning: this function is not safe to use for stake capturing, as it can change by the end of the block. */ function stake(bytes32 subnetwork, address operator) external view returns (uint256); /** * @notice Set a maximum limit for a subnetwork (how much stake the subnetwork is ready to get). * identifier identifier of the subnetwork * @param amount new maximum subnetwork's limit * @dev Only a network can call this function. */ function setMaxNetworkLimit(uint96 identifier, uint256 amount) external; /** * @notice Set a new hook. * @param hook address of the hook * @dev Only a HOOK_SET_ROLE holder can call this function. * The hook can have arbitrary logic under certain functions, however, it doesn't affect the stake guarantees. */ function setHook( address hook ) external; /** * @notice Called when a slash happens. * @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier) * @param operator address of the operator * @param amount amount of the collateral slashed * @param captureTimestamp time point when the stake was captured * @param data some additional data * @dev Only the vault's slasher can call this function. */ function onSlash( bytes32 subnetwork, address operator, uint256 amount, uint48 captureTimestamp, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {IBaseDelegator} from "./IBaseDelegator.sol"; interface INetworkRestakeDelegator is IBaseDelegator { error DuplicateRoleHolder(); error ExceedsMaxNetworkLimit(); error MissingRoleHolders(); error ZeroAddressRoleHolder(); /** * @notice Hints for a stake. * @param baseHints base hints * @param activeStakeHint hint for the active stake checkpoint * @param networkLimitHint hint for the subnetwork limit checkpoint * @param totalOperatorNetworkSharesHint hint for the total operator-subnetwork shares checkpoint * @param operatorNetworkSharesHint hint for the operator-subnetwork shares checkpoint */ struct StakeHints { bytes baseHints; bytes activeStakeHint; bytes networkLimitHint; bytes totalOperatorNetworkSharesHint; bytes operatorNetworkSharesHint; } /** * @notice Initial parameters needed for a full restaking delegator deployment. * @param baseParams base parameters for delegators' deployment * @param networkLimitSetRoleHolders array of addresses of the initial NETWORK_LIMIT_SET_ROLE holders * @param operatorNetworkSharesSetRoleHolders array of addresses of the initial OPERATOR_NETWORK_SHARES_SET_ROLE holders */ struct InitParams { IBaseDelegator.BaseParams baseParams; address[] networkLimitSetRoleHolders; address[] operatorNetworkSharesSetRoleHolders; } /** * @notice Emitted when a subnetwork's limit is set. * @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier) * @param amount new subnetwork's limit (how much stake the vault curator is ready to give to the subnetwork) */ event SetNetworkLimit(bytes32 indexed subnetwork, uint256 amount); /** * @notice Emitted when an operator's shares inside a subnetwork are set. * @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier) * @param operator address of the operator * @param shares new operator's shares inside the subnetwork (what percentage, * which is equal to the shares divided by the total operators' shares, * of the subnetwork's stake the vault curator is ready to give to the operator) */ event SetOperatorNetworkShares(bytes32 indexed subnetwork, address indexed operator, uint256 shares); /** * @notice Get a subnetwork limit setter's role. * @return identifier of the subnetwork limit setter role */ function NETWORK_LIMIT_SET_ROLE() external view returns (bytes32); /** * @notice Get an operator-subnetwork shares setter's role. * @return identifier of the operator-subnetwork shares setter role */ function OPERATOR_NETWORK_SHARES_SET_ROLE() external view returns (bytes32); /** * @notice Get a subnetwork's limit at a given timestamp using a hint * (how much stake the vault curator is ready to give to the subnetwork). * @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier) * @param timestamp time point to get the subnetwork limit at * @param hint hint for checkpoint index * @return limit of the subnetwork at the given timestamp */ function networkLimitAt(bytes32 subnetwork, uint48 timestamp, bytes memory hint) external view returns (uint256); /** * @notice Get a subnetwork's limit (how much stake the vault curator is ready to give to the subnetwork). * @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier) * @return limit of the subnetwork */ function networkLimit( bytes32 subnetwork ) external view returns (uint256); /** * @notice Get a sum of operators' shares for a subnetwork at a given timestamp using a hint. * @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier) * @param timestamp time point to get the total operators' shares at * @param hint hint for checkpoint index * @return total shares of the operators for the subnetwork at the given timestamp */ function totalOperatorNetworkSharesAt( bytes32 subnetwork, uint48 timestamp, bytes memory hint ) external view returns (uint256); /** * @notice Get a sum of operators' shares for a subnetwork. * @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier) * @return total shares of the operators for the subnetwork */ function totalOperatorNetworkShares( bytes32 subnetwork ) external view returns (uint256); /** * @notice Get an operator's shares for a subnetwork at a given timestamp using a hint (what percentage, * which is equal to the shares divided by the total operators' shares, * of the subnetwork's stake the vault curator is ready to give to the operator). * @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier) * @param operator address of the operator * @param timestamp time point to get the operator's shares at * @param hint hint for checkpoint index * @return shares of the operator for the subnetwork at the given timestamp */ function operatorNetworkSharesAt( bytes32 subnetwork, address operator, uint48 timestamp, bytes memory hint ) external view returns (uint256); /** * @notice Get an operator's shares for a subnetwork (what percentage, * which is equal to the shares divided by the total operators' shares, * of the subnetwork's stake the vault curator is ready to give to the operator). * @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier) * @param operator address of the operator * @return shares of the operator for the subnetwork */ function operatorNetworkShares(bytes32 subnetwork, address operator) external view returns (uint256); /** * @notice Set a subnetwork's limit (how much stake the vault curator is ready to give to the subnetwork). * @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier) * @param amount new limit of the subnetwork * @dev Only a NETWORK_LIMIT_SET_ROLE holder can call this function. */ function setNetworkLimit(bytes32 subnetwork, uint256 amount) external; /** * @notice Set an operator's shares for a subnetwork (what percentage, * which is equal to the shares divided by the total operators' shares, * of the subnetwork's stake the vault curator is ready to give to the operator). * @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier) * @param operator address of the operator * @param shares new shares of the operator for the subnetwork * @dev Only an OPERATOR_NETWORK_SHARES_SET_ROLE holder can call this function. */ function setOperatorNetworkShares(bytes32 subnetwork, address operator, uint256 shares) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {IMigratableEntity} from "../common/IMigratableEntity.sol"; import {IVaultStorage} from "./IVaultStorage.sol"; interface IVault is IMigratableEntity, IVaultStorage { error AlreadyClaimed(); error AlreadySet(); error DelegatorAlreadyInitialized(); error DepositLimitReached(); error InsufficientClaim(); error InsufficientDeposit(); error InsufficientRedemption(); error InsufficientWithdrawal(); error InvalidAccount(); error InvalidCaptureEpoch(); error InvalidClaimer(); error InvalidCollateral(); error InvalidDelegator(); error InvalidEpoch(); error InvalidEpochDuration(); error InvalidLengthEpochs(); error InvalidOnBehalfOf(); error InvalidRecipient(); error InvalidSlasher(); error MissingRoles(); error NotDelegator(); error NotSlasher(); error NotWhitelistedDepositor(); error SlasherAlreadyInitialized(); error TooMuchRedeem(); error TooMuchWithdraw(); /** * @notice Initial parameters needed for a vault deployment. * @param collateral vault's underlying collateral * @param burner vault's burner to issue debt to (e.g., 0xdEaD or some unwrapper contract) * @param epochDuration duration of the vault epoch (it determines sync points for withdrawals) * @param depositWhitelist if enabling deposit whitelist * @param isDepositLimit if enabling deposit limit * @param depositLimit deposit limit (maximum amount of the collateral that can be in the vault simultaneously) * @param defaultAdminRoleHolder address of the initial DEFAULT_ADMIN_ROLE holder * @param depositWhitelistSetRoleHolder address of the initial DEPOSIT_WHITELIST_SET_ROLE holder * @param depositorWhitelistRoleHolder address of the initial DEPOSITOR_WHITELIST_ROLE holder * @param isDepositLimitSetRoleHolder address of the initial IS_DEPOSIT_LIMIT_SET_ROLE holder * @param depositLimitSetRoleHolder address of the initial DEPOSIT_LIMIT_SET_ROLE holder */ struct InitParams { address collateral; address burner; uint48 epochDuration; bool depositWhitelist; bool isDepositLimit; uint256 depositLimit; address defaultAdminRoleHolder; address depositWhitelistSetRoleHolder; address depositorWhitelistRoleHolder; address isDepositLimitSetRoleHolder; address depositLimitSetRoleHolder; } /** * @notice Hints for an active balance. * @param activeSharesOfHint hint for the active shares of checkpoint * @param activeStakeHint hint for the active stake checkpoint * @param activeSharesHint hint for the active shares checkpoint */ struct ActiveBalanceOfHints { bytes activeSharesOfHint; bytes activeStakeHint; bytes activeSharesHint; } /** * @notice Emitted when a deposit is made. * @param depositor account that made the deposit * @param onBehalfOf account the deposit was made on behalf of * @param amount amount of the collateral deposited * @param shares amount of the active shares minted */ event Deposit(address indexed depositor, address indexed onBehalfOf, uint256 amount, uint256 shares); /** * @notice Emitted when a withdrawal is made. * @param withdrawer account that made the withdrawal * @param claimer account that needs to claim the withdrawal * @param amount amount of the collateral withdrawn * @param burnedShares amount of the active shares burned * @param mintedShares amount of the epoch withdrawal shares minted */ event Withdraw( address indexed withdrawer, address indexed claimer, uint256 amount, uint256 burnedShares, uint256 mintedShares ); /** * @notice Emitted when a claim is made. * @param claimer account that claimed * @param recipient account that received the collateral * @param epoch epoch the collateral was claimed for * @param amount amount of the collateral claimed */ event Claim(address indexed claimer, address indexed recipient, uint256 epoch, uint256 amount); /** * @notice Emitted when a batch claim is made. * @param claimer account that claimed * @param recipient account that received the collateral * @param epochs epochs the collateral was claimed for * @param amount amount of the collateral claimed */ event ClaimBatch(address indexed claimer, address indexed recipient, uint256[] epochs, uint256 amount); /** * @notice Emitted when a slash happens. * @param amount amount of the collateral to slash * @param captureTimestamp time point when the stake was captured * @param slashedAmount real amount of the collateral slashed */ event OnSlash(uint256 amount, uint48 captureTimestamp, uint256 slashedAmount); /** * @notice Emitted when a deposit whitelist status is enabled/disabled. * @param status if enabled deposit whitelist */ event SetDepositWhitelist(bool status); /** * @notice Emitted when a depositor whitelist status is set. * @param account account for which the whitelist status is set * @param status if whitelisted the account */ event SetDepositorWhitelistStatus(address indexed account, bool status); /** * @notice Emitted when a deposit limit status is enabled/disabled. * @param status if enabled deposit limit */ event SetIsDepositLimit(bool status); /** * @notice Emitted when a deposit limit is set. * @param limit deposit limit (maximum amount of the collateral that can be in the vault simultaneously) */ event SetDepositLimit(uint256 limit); /** * @notice Emitted when a delegator is set. * @param delegator vault's delegator to delegate the stake to networks and operators * @dev Can be set only once. */ event SetDelegator(address indexed delegator); /** * @notice Emitted when a slasher is set. * @param slasher vault's slasher to provide a slashing mechanism to networks * @dev Can be set only once. */ event SetSlasher(address indexed slasher); /** * @notice Check if the vault is fully initialized (a delegator and a slasher are set). * @return if the vault is fully initialized */ function isInitialized() external view returns (bool); /** * @notice Get a total amount of the collateral that can be slashed. * @return total amount of the slashable collateral */ function totalStake() external view returns (uint256); /** * @notice Get an active balance for a particular account at a given timestamp using hints. * @param account account to get the active balance for * @param timestamp time point to get the active balance for the account at * @param hints hints for checkpoints' indexes * @return active balance for the account at the timestamp */ function activeBalanceOfAt( address account, uint48 timestamp, bytes calldata hints ) external view returns (uint256); /** * @notice Get an active balance for a particular account. * @param account account to get the active balance for * @return active balance for the account */ function activeBalanceOf( address account ) external view returns (uint256); /** * @notice Get withdrawals for a particular account at a given epoch (zero if claimed). * @param epoch epoch to get the withdrawals for the account at * @param account account to get the withdrawals for * @return withdrawals for the account at the epoch */ function withdrawalsOf(uint256 epoch, address account) external view returns (uint256); /** * @notice Get a total amount of the collateral that can be slashed for a given account. * @param account account to get the slashable collateral for * @return total amount of the account's slashable collateral */ function slashableBalanceOf( address account ) external view returns (uint256); /** * @notice Deposit collateral into the vault. * @param onBehalfOf account the deposit is made on behalf of * @param amount amount of the collateral to deposit * @return depositedAmount real amount of the collateral deposited * @return mintedShares amount of the active shares minted */ function deposit( address onBehalfOf, uint256 amount ) external returns (uint256 depositedAmount, uint256 mintedShares); /** * @notice Withdraw collateral from the vault (it will be claimable after the next epoch). * @param claimer account that needs to claim the withdrawal * @param amount amount of the collateral to withdraw * @return burnedShares amount of the active shares burned * @return mintedShares amount of the epoch withdrawal shares minted */ function withdraw(address claimer, uint256 amount) external returns (uint256 burnedShares, uint256 mintedShares); /** * @notice Redeem collateral from the vault (it will be claimable after the next epoch). * @param claimer account that needs to claim the withdrawal * @param shares amount of the active shares to redeem * @return withdrawnAssets amount of the collateral withdrawn * @return mintedShares amount of the epoch withdrawal shares minted */ function redeem(address claimer, uint256 shares) external returns (uint256 withdrawnAssets, uint256 mintedShares); /** * @notice Claim collateral from the vault. * @param recipient account that receives the collateral * @param epoch epoch to claim the collateral for * @return amount amount of the collateral claimed */ function claim(address recipient, uint256 epoch) external returns (uint256 amount); /** * @notice Claim collateral from the vault for multiple epochs. * @param recipient account that receives the collateral * @param epochs epochs to claim the collateral for * @return amount amount of the collateral claimed */ function claimBatch(address recipient, uint256[] calldata epochs) external returns (uint256 amount); /** * @notice Slash callback for burning collateral. * @param amount amount to slash * @param captureTimestamp time point when the stake was captured * @return slashedAmount real amount of the collateral slashed * @dev Only the slasher can call this function. */ function onSlash(uint256 amount, uint48 captureTimestamp) external returns (uint256 slashedAmount); /** * @notice Enable/disable deposit whitelist. * @param status if enabling deposit whitelist * @dev Only a DEPOSIT_WHITELIST_SET_ROLE holder can call this function. */ function setDepositWhitelist( bool status ) external; /** * @notice Set a depositor whitelist status. * @param account account for which the whitelist status is set * @param status if whitelisting the account * @dev Only a DEPOSITOR_WHITELIST_ROLE holder can call this function. */ function setDepositorWhitelistStatus(address account, bool status) external; /** * @notice Enable/disable deposit limit. * @param status if enabling deposit limit * @dev Only a IS_DEPOSIT_LIMIT_SET_ROLE holder can call this function. */ function setIsDepositLimit( bool status ) external; /** * @notice Set a deposit limit. * @param limit deposit limit (maximum amount of the collateral that can be in the vault simultaneously) * @dev Only a DEPOSIT_LIMIT_SET_ROLE holder can call this function. */ function setDepositLimit( uint256 limit ) external; /** * @notice Set a delegator. * @param delegator vault's delegator to delegate the stake to networks and operators * @dev Can be set only once. */ function setDelegator( address delegator ) external; /** * @notice Set a slasher. * @param slasher vault's slasher to provide a slashing mechanism to networks * @dev Can be set only once. */ function setSlasher( address slasher ) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {Checkpoints as OZCheckpoints} from "@openzeppelin/contracts/utils/structs/Checkpoints.sol"; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; /** * @dev This library defines the `Trace*` struct, for checkpointing values as they change at different points in * time, and later looking up past values by key. */ library Checkpoints { using OZCheckpoints for OZCheckpoints.Trace208; error SystemCheckpoint(); struct Trace208 { OZCheckpoints.Trace208 _trace; } struct Checkpoint208 { uint48 _key; uint208 _value; } struct Trace256 { OZCheckpoints.Trace208 _trace; uint256[] _values; } struct Checkpoint256 { uint48 _key; uint256 _value; } /** * @dev Pushes a (`key`, `value`) pair into a Trace208 so that it is stored as the checkpoint. * * Returns previous value and new value. */ function push(Trace208 storage self, uint48 key, uint208 value) internal returns (uint208, uint208) { return self._trace.push(key, value); } /** * @dev Returns the value in the last (most recent) checkpoint with a key lower or equal than the search key, or zero * if there is none. */ function upperLookupRecent(Trace208 storage self, uint48 key) internal view returns (uint208) { return self._trace.upperLookupRecent(key); } /** * @dev Returns the value in the last (most recent) checkpoint with a key lower or equal than the search key, or zero * if there is none. * * NOTE: This is a variant of {upperLookupRecent} that can be optimized by getting the hint * (index of the checkpoint with a key lower or equal than the search key). */ function upperLookupRecent(Trace208 storage self, uint48 key, bytes memory hint_) internal view returns (uint208) { if (hint_.length == 0) { return upperLookupRecent(self, key); } uint32 hint = abi.decode(hint_, (uint32)); Checkpoint208 memory checkpoint = at(self, hint); if (checkpoint._key == key) { return checkpoint._value; } if (checkpoint._key < key && (hint == length(self) - 1 || at(self, hint + 1)._key > key)) { return checkpoint._value; } return upperLookupRecent(self, key); } /** * @dev Returns whether there is a checkpoint with a key lower or equal than the search key in the structure (i.e. it is not empty), * and if so the key and value in the checkpoint, and its position in the trace. */ function upperLookupRecentCheckpoint( Trace208 storage self, uint48 key ) internal view returns (bool, uint48, uint208, uint32) { uint256 len = self._trace._checkpoints.length; uint256 low = 0; uint256 high = len; if (len > 5) { uint256 mid = len - Math.sqrt(len); if (key < _unsafeAccess(self._trace._checkpoints, mid)._key) { high = mid; } else { low = mid + 1; } } uint256 pos = _upperBinaryLookup(self._trace._checkpoints, key, low, high); if (pos == 0) { return (false, 0, 0, 0); } OZCheckpoints.Checkpoint208 memory checkpoint = _unsafeAccess(self._trace._checkpoints, pos - 1); return (true, checkpoint._key, checkpoint._value, uint32(pos - 1)); } /** * @dev Returns whether there is a checkpoint with a key lower or equal than the search key in the structure (i.e. it is not empty), * and if so the key and value in the checkpoint, and its position in the trace. * * NOTE: This is a variant of {upperLookupRecentCheckpoint} that can be optimized by getting the hint * (index of the checkpoint with a key lower or equal than the search key). */ function upperLookupRecentCheckpoint( Trace208 storage self, uint48 key, bytes memory hint_ ) internal view returns (bool, uint48, uint208, uint32) { if (hint_.length == 0) { return upperLookupRecentCheckpoint(self, key); } uint32 hint = abi.decode(hint_, (uint32)); Checkpoint208 memory checkpoint = at(self, hint); if (checkpoint._key == key) { return (true, checkpoint._key, checkpoint._value, hint); } if (checkpoint._key < key && (hint == length(self) - 1 || at(self, hint + 1)._key > key)) { return (true, checkpoint._key, checkpoint._value, hint); } return upperLookupRecentCheckpoint(self, key); } /** * @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints. */ function latest( Trace208 storage self ) internal view returns (uint208) { return self._trace.latest(); } /** * @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value * in the most recent checkpoint. */ function latestCheckpoint( Trace208 storage self ) internal view returns (bool, uint48, uint208) { return self._trace.latestCheckpoint(); } /** * @dev Returns a total number of checkpoints. */ function length( Trace208 storage self ) internal view returns (uint256) { return self._trace.length(); } /** * @dev Returns checkpoint at a given position. */ function at(Trace208 storage self, uint32 pos) internal view returns (Checkpoint208 memory) { OZCheckpoints.Checkpoint208 memory checkpoint = self._trace.at(pos); return Checkpoint208({_key: checkpoint._key, _value: checkpoint._value}); } /** * @dev Pops the last (most recent) checkpoint. */ function pop( Trace208 storage self ) internal returns (uint208 value) { value = self._trace.latest(); self._trace._checkpoints.pop(); } /** * @dev Pushes a (`key`, `value`) pair into a Trace256 so that it is stored as the checkpoint. * * Returns previous value and new value. */ function push(Trace256 storage self, uint48 key, uint256 value) internal returns (uint256, uint256) { if (self._values.length == 0) { self._values.push(0); } (bool exists, uint48 lastKey,) = self._trace.latestCheckpoint(); uint256 len = self._values.length; uint256 lastValue = latest(self); if (exists && key == lastKey) { self._values[len - 1] = value; } else { self._trace.push(key, uint208(len)); self._values.push(value); } return (lastValue, value); } /** * @dev Returns the value in the last (most recent) checkpoint with a key lower or equal than the search key, or zero * if there is none. */ function upperLookupRecent(Trace256 storage self, uint48 key) internal view returns (uint256) { uint208 idx = self._trace.upperLookupRecent(key); return idx > 0 ? self._values[idx] : 0; } /** * @dev Returns the value in the last (most recent) checkpoint with a key lower or equal than the search key, or zero * if there is none. * * NOTE: This is a variant of {upperLookupRecent} that can be optimized by getting the hint * (index of the checkpoint with a key lower or equal than the search key). */ function upperLookupRecent(Trace256 storage self, uint48 key, bytes memory hint_) internal view returns (uint256) { if (hint_.length == 0) { return upperLookupRecent(self, key); } uint32 hint = abi.decode(hint_, (uint32)); Checkpoint256 memory checkpoint = at(self, hint); if (checkpoint._key == key) { return checkpoint._value; } if (checkpoint._key < key && (hint == length(self) - 1 || at(self, hint + 1)._key > key)) { return checkpoint._value; } return upperLookupRecent(self, key); } /** * @dev Returns whether there is a checkpoint with a key lower or equal than the search key in the structure (i.e. it is not empty), * and if so the key and value in the checkpoint, and its position in the trace. */ function upperLookupRecentCheckpoint( Trace256 storage self, uint48 key ) internal view returns (bool, uint48, uint256, uint32) { uint256 len = self._trace._checkpoints.length; uint256 low = 0; uint256 high = len; if (len > 5) { uint256 mid = len - Math.sqrt(len); if (key < _unsafeAccess(self._trace._checkpoints, mid)._key) { high = mid; } else { low = mid + 1; } } uint256 pos = _upperBinaryLookup(self._trace._checkpoints, key, low, high); if (pos == 0) { return (false, 0, 0, 0); } OZCheckpoints.Checkpoint208 memory checkpoint = _unsafeAccess(self._trace._checkpoints, pos - 1); return (true, checkpoint._key, self._values[checkpoint._value], uint32(pos - 1)); } /** * @dev Returns whether there is a checkpoint with a key lower or equal than the search key in the structure (i.e. it is not empty), * and if so the key and value in the checkpoint, and its position in the trace. * * NOTE: This is a variant of {upperLookupRecentCheckpoint} that can be optimized by getting the hint * (index of the checkpoint with a key lower or equal than the search key). */ function upperLookupRecentCheckpoint( Trace256 storage self, uint48 key, bytes memory hint_ ) internal view returns (bool, uint48, uint256, uint32) { if (hint_.length == 0) { return upperLookupRecentCheckpoint(self, key); } uint32 hint = abi.decode(hint_, (uint32)); Checkpoint256 memory checkpoint = at(self, hint); if (checkpoint._key == key) { return (true, checkpoint._key, checkpoint._value, hint); } if (checkpoint._key < key && (hint == length(self) - 1 || at(self, hint + 1)._key > key)) { return (true, checkpoint._key, checkpoint._value, hint); } return upperLookupRecentCheckpoint(self, key); } /** * @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints. */ function latest( Trace256 storage self ) internal view returns (uint256) { uint208 idx = self._trace.latest(); return idx > 0 ? self._values[idx] : 0; } /** * @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value * in the most recent checkpoint. */ function latestCheckpoint( Trace256 storage self ) internal view returns (bool exists, uint48 _key, uint256 _value) { uint256 idx; (exists, _key, idx) = self._trace.latestCheckpoint(); _value = exists ? self._values[idx] : 0; } /** * @dev Returns a total number of checkpoints. */ function length( Trace256 storage self ) internal view returns (uint256) { return self._trace.length(); } /** * @dev Returns checkpoint at a given position. */ function at(Trace256 storage self, uint32 pos) internal view returns (Checkpoint256 memory) { OZCheckpoints.Checkpoint208 memory checkpoint = self._trace.at(pos); return Checkpoint256({_key: checkpoint._key, _value: self._values[checkpoint._value]}); } /** * @dev Pops the last (most recent) checkpoint. */ function pop( Trace256 storage self ) internal returns (uint256 value) { uint208 idx = self._trace.latest(); if (idx == 0) { revert SystemCheckpoint(); } value = self._values[idx]; self._trace._checkpoints.pop(); self._values.pop(); } /** * @dev Return the index of the last (most recent) checkpoint with a key lower or equal than the search key, or `high` * if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive * `high`. * * WARNING: `high` should not be greater than the array's length. */ function _upperBinaryLookup( OZCheckpoints.Checkpoint208[] storage self, uint48 key, uint256 low, uint256 high ) private view returns (uint256) { while (low < high) { uint256 mid = Math.average(low, high); if (_unsafeAccess(self, mid)._key > key) { high = mid; } else { low = mid + 1; } } return high; } /** * @dev Access an element of the array without performing a bounds check. The position is assumed to be within bounds. */ function _unsafeAccess( OZCheckpoints.Checkpoint208[] storage self, uint256 pos ) private pure returns (OZCheckpoints.Checkpoint208 storage result) { assembly { mstore(0, self.slot) result.slot := add(keccak256(0, 0x20), pos) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol) pragma solidity ^0.8.20; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Muldiv operation overflow. */ error MathOverflowedMulDiv(); enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an overflow flag. */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. return a / b; } // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by * Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. if (denominator <= prod1) { revert MathOverflowedMulDiv(); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. // Always >= 1. See https://cs.stackexchange.com/q/138556/92363. uint256 twos = denominator & (0 - denominator); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also // works in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/types/Time.sol) pragma solidity ^0.8.20; import {Math} from "../math/Math.sol"; import {SafeCast} from "../math/SafeCast.sol"; /** * @dev This library provides helpers for manipulating time-related objects. * * It uses the following types: * - `uint48` for timepoints * - `uint32` for durations * * While the library doesn't provide specific types for timepoints and duration, it does provide: * - a `Delay` type to represent duration that can be programmed to change value automatically at a given point * - additional helper functions */ library Time { using Time for *; /** * @dev Get the block timestamp as a Timepoint. */ function timestamp() internal view returns (uint48) { return SafeCast.toUint48(block.timestamp); } /** * @dev Get the block number as a Timepoint. */ function blockNumber() internal view returns (uint48) { return SafeCast.toUint48(block.number); } // ==================================================== Delay ===================================================== /** * @dev A `Delay` is a uint32 duration that can be programmed to change value automatically at a given point in the * future. The "effect" timepoint describes when the transitions happens from the "old" value to the "new" value. * This allows updating the delay applied to some operation while keeping some guarantees. * * In particular, the {update} function guarantees that if the delay is reduced, the old delay still applies for * some time. For example if the delay is currently 7 days to do an upgrade, the admin should not be able to set * the delay to 0 and upgrade immediately. If the admin wants to reduce the delay, the old delay (7 days) should * still apply for some time. * * * The `Delay` type is 112 bits long, and packs the following: * * ``` * | [uint48]: effect date (timepoint) * | | [uint32]: value before (duration) * ↓ ↓ ↓ [uint32]: value after (duration) * 0xAAAAAAAAAAAABBBBBBBBCCCCCCCC * ``` * * NOTE: The {get} and {withUpdate} functions operate using timestamps. Block number based delays are not currently * supported. */ type Delay is uint112; /** * @dev Wrap a duration into a Delay to add the one-step "update in the future" feature */ function toDelay(uint32 duration) internal pure returns (Delay) { return Delay.wrap(duration); } /** * @dev Get the value at a given timepoint plus the pending value and effect timepoint if there is a scheduled * change after this timepoint. If the effect timepoint is 0, then the pending value should not be considered. */ function _getFullAt(Delay self, uint48 timepoint) private pure returns (uint32, uint32, uint48) { (uint32 valueBefore, uint32 valueAfter, uint48 effect) = self.unpack(); return effect <= timepoint ? (valueAfter, 0, 0) : (valueBefore, valueAfter, effect); } /** * @dev Get the current value plus the pending value and effect timepoint if there is a scheduled change. If the * effect timepoint is 0, then the pending value should not be considered. */ function getFull(Delay self) internal view returns (uint32, uint32, uint48) { return _getFullAt(self, timestamp()); } /** * @dev Get the current value. */ function get(Delay self) internal view returns (uint32) { (uint32 delay, , ) = self.getFull(); return delay; } /** * @dev Update a Delay object so that it takes a new duration after a timepoint that is automatically computed to * enforce the old delay at the moment of the update. Returns the updated Delay object and the timestamp when the * new delay becomes effective. */ function withUpdate( Delay self, uint32 newValue, uint32 minSetback ) internal view returns (Delay updatedDelay, uint48 effect) { uint32 value = self.get(); uint32 setback = uint32(Math.max(minSetback, value > newValue ? value - newValue : 0)); effect = timestamp() + setback; return (pack(value, newValue, effect), effect); } /** * @dev Split a delay into its components: valueBefore, valueAfter and effect (transition timepoint). */ function unpack(Delay self) internal pure returns (uint32 valueBefore, uint32 valueAfter, uint48 effect) { uint112 raw = Delay.unwrap(self); valueAfter = uint32(raw); valueBefore = uint32(raw >> 32); effect = uint48(raw >> 64); return (valueBefore, valueAfter, effect); } /** * @dev pack the components into a Delay object. */ function pack(uint32 valueBefore, uint32 valueAfter, uint48 effect) internal pure returns (Delay) { return Delay.wrap((uint112(effect) << 64) | (uint112(valueBefore) << 32) | uint112(valueAfter)); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.25; import {IEntity} from "../../interfaces/common/IEntity.sol"; import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; abstract contract Entity is Initializable, IEntity { /** * @inheritdoc IEntity */ address public immutable FACTORY; /** * @inheritdoc IEntity */ uint64 public immutable TYPE; constructor(address factory, uint64 type_) { _disableInitializers(); FACTORY = factory; TYPE = type_; } /** * @inheritdoc IEntity */ function initialize( bytes calldata data ) external initializer { _initialize(data); } function _initialize( bytes calldata /* data */ ) internal virtual {} }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.25; import {IStaticDelegateCallable} from "../../interfaces/common/IStaticDelegateCallable.sol"; abstract contract StaticDelegateCallable is IStaticDelegateCallable { /** * @inheritdoc IStaticDelegateCallable */ function staticDelegateCall(address target, bytes calldata data) external { (bool success, bytes memory returndata) = target.delegatecall(data); bytes memory revertData = abi.encode(success, returndata); assembly { revert(add(32, revertData), mload(revertData)) } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IDelegatorHook { /** * @notice Called when a slash happens. * @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier) * @param operator address of the operator * @param amount amount of the collateral to be slashed * @param captureTimestamp time point when the stake was captured * @param data some additional data */ function onSlash( bytes32 subnetwork, address operator, uint256 amount, uint48 captureTimestamp, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IOptInService { error AlreadyOptedIn(); error ExpiredSignature(); error InvalidSignature(); error NotOptedIn(); error NotWhereEntity(); error NotWho(); error OptOutCooldown(); /** * @notice Emitted when a "who" opts into a "where" entity. * @param who address of the "who" * @param where address of the "where" entity */ event OptIn(address indexed who, address indexed where); /** * @notice Emitted when a "who" opts out from a "where" entity. * @param who address of the "who" * @param where address of the "where" entity */ event OptOut(address indexed who, address indexed where); /** * @notice Emitted when the nonce of a "who" to a "where" entity is increased. * @param who address of the "who" * @param where address of the "where" entity */ event IncreaseNonce(address indexed who, address indexed where); /** * @notice Get the "who" registry's address. * @return address of the "who" registry */ function WHO_REGISTRY() external view returns (address); /** * @notice Get the address of the registry where to opt-in. * @return address of the "where" registry */ function WHERE_REGISTRY() external view returns (address); /** * @notice Get if a given "who" is opted-in to a particular "where" entity at a given timestamp using a hint. * @param who address of the "who" * @param where address of the "where" entity * @param timestamp time point to get if the "who" is opted-in at * @param hint hint for the checkpoint index * @return if the "who" is opted-in at the given timestamp */ function isOptedInAt( address who, address where, uint48 timestamp, bytes calldata hint ) external view returns (bool); /** * @notice Check if a given "who" is opted-in to a particular "where" entity. * @param who address of the "who" * @param where address of the "where" entity * @return if the "who" is opted-in */ function isOptedIn(address who, address where) external view returns (bool); /** * @notice Get the nonce of a given "who" to a particular "where" entity. * @param who address of the "who" * @param where address of the "where" entity * @return nonce */ function nonces(address who, address where) external view returns (uint256); /** * @notice Opt-in a calling "who" to a particular "where" entity. * @param where address of the "where" entity */ function optIn( address where ) external; /** * @notice Opt-in a "who" to a particular "where" entity with a signature. * @param who address of the "who" * @param where address of the "where" entity * @param deadline time point until the signature is valid (inclusively) * @param signature signature of the "who" */ function optIn(address who, address where, uint48 deadline, bytes calldata signature) external; /** * @notice Opt-out a calling "who" from a particular "where" entity. * @param where address of the "where" entity */ function optOut( address where ) external; /** * @notice Opt-out a "who" from a particular "where" entity with a signature. * @param who address of the "who" * @param where address of the "where" entity * @param deadline time point until the signature is valid (inclusively) * @param signature signature of the "who" */ function optOut(address who, address where, uint48 deadline, bytes calldata signature) external; /** * @notice Increase the nonce of a given "who" to a particular "where" entity. * @param where address of the "where" entity * @dev It can be used to invalidate a given signature. */ function increaseNonce( address where ) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IRegistry { error EntityNotExist(); /** * @notice Emitted when an entity is added. * @param entity address of the added entity */ event AddEntity(address indexed entity); /** * @notice Get if a given address is an entity. * @param account address to check * @return if the given address is an entity */ function isEntity( address account ) external view returns (bool); /** * @notice Get a total number of entities. * @return total number of entities added */ function totalEntities() external view returns (uint256); /** * @notice Get an entity given its index. * @param index index of the entity to get * @return address of the entity */ function entity( uint256 index ) external view returns (address); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev This library adds functions to work with subnetworks. */ library Subnetwork { function subnetwork(address network_, uint96 identifier_) internal pure returns (bytes32) { return bytes32(uint256(uint160(network_)) << 96 | identifier_); } function network( bytes32 subnetwork_ ) internal pure returns (address) { return address(uint160(uint256(subnetwork_ >> 96))); } function identifier( bytes32 subnetwork_ ) internal pure returns (uint96) { return uint96(uint256(subnetwork_)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol) pragma solidity ^0.8.20; import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol"; import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol"; import {ERC165Upgradeable} from "../utils/introspection/ERC165Upgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ```solidity * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ```solidity * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} * to enforce additional security measures for this role. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable { struct RoleData { mapping(address account => bool) hasRole; bytes32 adminRole; } bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /// @custom:storage-location erc7201:openzeppelin.storage.AccessControl struct AccessControlStorage { mapping(bytes32 role => RoleData) _roles; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControl")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800; function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) { assembly { $.slot := AccessControlStorageLocation } } /** * @dev Modifier that checks that an account has a specific role. Reverts * with an {AccessControlUnauthorizedAccount} error including the required role. */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } function __AccessControl_init() internal onlyInitializing { } function __AccessControl_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual returns (bool) { AccessControlStorage storage $ = _getAccessControlStorage(); return $._roles[role].hasRole[account]; } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()` * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier. */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account` * is missing `role`. */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert AccessControlUnauthorizedAccount(account, role); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) { AccessControlStorage storage $ = _getAccessControlStorage(); return $._roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `callerConfirmation`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address callerConfirmation) public virtual { if (callerConfirmation != _msgSender()) { revert AccessControlBadConfirmation(); } _revokeRole(role, callerConfirmation); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { AccessControlStorage storage $ = _getAccessControlStorage(); bytes32 previousAdminRole = getRoleAdmin(role); $._roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual returns (bool) { AccessControlStorage storage $ = _getAccessControlStorage(); if (!hasRole(role, account)) { $._roles[role].hasRole[account] = true; emit RoleGranted(role, account, _msgSender()); return true; } else { return false; } } /** * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual returns (bool) { AccessControlStorage storage $ = _getAccessControlStorage(); if (hasRole(role, account)) { $._roles[role].hasRole[account] = false; emit RoleRevoked(role, account, _msgSender()); return true; } else { return false; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol) pragma solidity ^0.8.20; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant NOT_ENTERED = 1; uint256 private constant ENTERED = 2; /// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard struct ReentrancyGuardStorage { uint256 _status; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00; function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) { assembly { $.slot := ReentrancyGuardStorageLocation } } /** * @dev Unauthorized reentrant call. */ error ReentrancyGuardReentrantCall(); function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); $._status = NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); // On the first call to nonReentrant, _status will be NOT_ENTERED if ($._status == ENTERED) { revert ReentrancyGuardReentrantCall(); } // Any calls to nonReentrant after this point will fail $._status = ENTERED; } function _nonReentrantAfter() private { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) $._status = NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); return $._status == ENTERED; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IEntity { error NotInitialized(); /** * @notice Get the factory's address. * @return address of the factory */ function FACTORY() external view returns (address); /** * @notice Get the entity's type. * @return type of the entity */ function TYPE() external view returns (uint64); /** * @notice Initialize this entity contract by using a given data. * @param data some data to use */ function initialize( bytes calldata data ) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IMigratableEntity { error AlreadyInitialized(); error NotFactory(); error NotInitialized(); /** * @notice Get the factory's address. * @return address of the factory */ function FACTORY() external view returns (address); /** * @notice Get the entity's version. * @return version of the entity * @dev Starts from 1. */ function version() external view returns (uint64); /** * @notice Initialize this entity contract by using a given data and setting a particular version and owner. * @param initialVersion initial version of the entity * @param owner initial owner of the entity * @param data some data to use */ function initialize(uint64 initialVersion, address owner, bytes calldata data) external; /** * @notice Migrate this entity to a particular newer version using a given data. * @param newVersion new version of the entity * @param data some data to use */ function migrate(uint64 newVersion, bytes calldata data) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IVaultStorage { error InvalidTimestamp(); error NoPreviousEpoch(); /** * @notice Get a deposit whitelist enabler/disabler's role. * @return identifier of the whitelist enabler/disabler role */ function DEPOSIT_WHITELIST_SET_ROLE() external view returns (bytes32); /** * @notice Get a depositor whitelist status setter's role. * @return identifier of the depositor whitelist status setter role */ function DEPOSITOR_WHITELIST_ROLE() external view returns (bytes32); /** * @notice Get a deposit limit enabler/disabler's role. * @return identifier of the deposit limit enabler/disabler role */ function IS_DEPOSIT_LIMIT_SET_ROLE() external view returns (bytes32); /** * @notice Get a deposit limit setter's role. * @return identifier of the deposit limit setter role */ function DEPOSIT_LIMIT_SET_ROLE() external view returns (bytes32); /** * @notice Get the delegator factory's address. * @return address of the delegator factory */ function DELEGATOR_FACTORY() external view returns (address); /** * @notice Get the slasher factory's address. * @return address of the slasher factory */ function SLASHER_FACTORY() external view returns (address); /** * @notice Get a vault collateral. * @return address of the underlying collateral */ function collateral() external view returns (address); /** * @notice Get a burner to issue debt to (e.g., 0xdEaD or some unwrapper contract). * @return address of the burner */ function burner() external view returns (address); /** * @notice Get a delegator (it delegates the vault's stake to networks and operators). * @return address of the delegator */ function delegator() external view returns (address); /** * @notice Get if the delegator is initialized. * @return if the delegator is initialized */ function isDelegatorInitialized() external view returns (bool); /** * @notice Get a slasher (it provides networks a slashing mechanism). * @return address of the slasher */ function slasher() external view returns (address); /** * @notice Get if the slasher is initialized. * @return if the slasher is initialized */ function isSlasherInitialized() external view returns (bool); /** * @notice Get a time point of the epoch duration set. * @return time point of the epoch duration set */ function epochDurationInit() external view returns (uint48); /** * @notice Get a duration of the vault epoch. * @return duration of the epoch */ function epochDuration() external view returns (uint48); /** * @notice Get an epoch at a given timestamp. * @param timestamp time point to get the epoch at * @return epoch at the timestamp * @dev Reverts if the timestamp is less than the start of the epoch 0. */ function epochAt( uint48 timestamp ) external view returns (uint256); /** * @notice Get a current vault epoch. * @return current epoch */ function currentEpoch() external view returns (uint256); /** * @notice Get a start of the current vault epoch. * @return start of the current epoch */ function currentEpochStart() external view returns (uint48); /** * @notice Get a start of the previous vault epoch. * @return start of the previous epoch * @dev Reverts if the current epoch is 0. */ function previousEpochStart() external view returns (uint48); /** * @notice Get a start of the next vault epoch. * @return start of the next epoch */ function nextEpochStart() external view returns (uint48); /** * @notice Get if the deposit whitelist is enabled. * @return if the deposit whitelist is enabled */ function depositWhitelist() external view returns (bool); /** * @notice Get if a given account is whitelisted as a depositor. * @param account address to check * @return if the account is whitelisted as a depositor */ function isDepositorWhitelisted( address account ) external view returns (bool); /** * @notice Get if the deposit limit is set. * @return if the deposit limit is set */ function isDepositLimit() external view returns (bool); /** * @notice Get a deposit limit (maximum amount of the active stake that can be in the vault simultaneously). * @return deposit limit */ function depositLimit() external view returns (uint256); /** * @notice Get a total number of active shares in the vault at a given timestamp using a hint. * @param timestamp time point to get the total number of active shares at * @param hint hint for the checkpoint index * @return total number of active shares at the timestamp */ function activeSharesAt(uint48 timestamp, bytes memory hint) external view returns (uint256); /** * @notice Get a total number of active shares in the vault. * @return total number of active shares */ function activeShares() external view returns (uint256); /** * @notice Get a total amount of active stake in the vault at a given timestamp using a hint. * @param timestamp time point to get the total active stake at * @param hint hint for the checkpoint index * @return total amount of active stake at the timestamp */ function activeStakeAt(uint48 timestamp, bytes memory hint) external view returns (uint256); /** * @notice Get a total amount of active stake in the vault. * @return total amount of active stake */ function activeStake() external view returns (uint256); /** * @notice Get a total number of active shares for a particular account at a given timestamp using a hint. * @param account account to get the number of active shares for * @param timestamp time point to get the number of active shares for the account at * @param hint hint for the checkpoint index * @return number of active shares for the account at the timestamp */ function activeSharesOfAt(address account, uint48 timestamp, bytes memory hint) external view returns (uint256); /** * @notice Get a number of active shares for a particular account. * @param account account to get the number of active shares for * @return number of active shares for the account */ function activeSharesOf( address account ) external view returns (uint256); /** * @notice Get a total amount of the withdrawals at a given epoch. * @param epoch epoch to get the total amount of the withdrawals at * @return total amount of the withdrawals at the epoch */ function withdrawals( uint256 epoch ) external view returns (uint256); /** * @notice Get a total number of withdrawal shares at a given epoch. * @param epoch epoch to get the total number of withdrawal shares at * @return total number of withdrawal shares at the epoch */ function withdrawalShares( uint256 epoch ) external view returns (uint256); /** * @notice Get a number of withdrawal shares for a particular account at a given epoch (zero if claimed). * @param epoch epoch to get the number of withdrawal shares for the account at * @param account account to get the number of withdrawal shares for * @return number of withdrawal shares for the account at the epoch */ function withdrawalSharesOf(uint256 epoch, address account) external view returns (uint256); /** * @notice Get if the withdrawals are claimed for a particular account at a given epoch. * @param epoch epoch to check the withdrawals for the account at * @param account account to check the withdrawals for * @return if the withdrawals are claimed for the account at the epoch */ function isWithdrawalsClaimed(uint256 epoch, address account) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/Checkpoints.sol) // This file was procedurally generated from scripts/generate/templates/Checkpoints.js. pragma solidity ^0.8.20; import {Math} from "../math/Math.sol"; /** * @dev This library defines the `Trace*` struct, for checkpointing values as they change at different points in * time, and later looking up past values by block number. See {Votes} as an example. * * To create a history of checkpoints define a variable type `Checkpoints.Trace*` in your contract, and store a new * checkpoint for the current transaction block using the {push} function. */ library Checkpoints { /** * @dev A value was attempted to be inserted on a past checkpoint. */ error CheckpointUnorderedInsertion(); struct Trace224 { Checkpoint224[] _checkpoints; } struct Checkpoint224 { uint32 _key; uint224 _value; } /** * @dev Pushes a (`key`, `value`) pair into a Trace224 so that it is stored as the checkpoint. * * Returns previous value and new value. * * IMPORTANT: Never accept `key` as a user input, since an arbitrary `type(uint32).max` key set will disable the * library. */ function push(Trace224 storage self, uint32 key, uint224 value) internal returns (uint224, uint224) { return _insert(self._checkpoints, key, value); } /** * @dev Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if * there is none. */ function lowerLookup(Trace224 storage self, uint32 key) internal view returns (uint224) { uint256 len = self._checkpoints.length; uint256 pos = _lowerBinaryLookup(self._checkpoints, key, 0, len); return pos == len ? 0 : _unsafeAccess(self._checkpoints, pos)._value; } /** * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero * if there is none. */ function upperLookup(Trace224 storage self, uint32 key) internal view returns (uint224) { uint256 len = self._checkpoints.length; uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, len); return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value; } /** * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero * if there is none. * * NOTE: This is a variant of {upperLookup} that is optimised to find "recent" checkpoint (checkpoints with high * keys). */ function upperLookupRecent(Trace224 storage self, uint32 key) internal view returns (uint224) { uint256 len = self._checkpoints.length; uint256 low = 0; uint256 high = len; if (len > 5) { uint256 mid = len - Math.sqrt(len); if (key < _unsafeAccess(self._checkpoints, mid)._key) { high = mid; } else { low = mid + 1; } } uint256 pos = _upperBinaryLookup(self._checkpoints, key, low, high); return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value; } /** * @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints. */ function latest(Trace224 storage self) internal view returns (uint224) { uint256 pos = self._checkpoints.length; return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value; } /** * @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value * in the most recent checkpoint. */ function latestCheckpoint(Trace224 storage self) internal view returns (bool exists, uint32 _key, uint224 _value) { uint256 pos = self._checkpoints.length; if (pos == 0) { return (false, 0, 0); } else { Checkpoint224 memory ckpt = _unsafeAccess(self._checkpoints, pos - 1); return (true, ckpt._key, ckpt._value); } } /** * @dev Returns the number of checkpoint. */ function length(Trace224 storage self) internal view returns (uint256) { return self._checkpoints.length; } /** * @dev Returns checkpoint at given position. */ function at(Trace224 storage self, uint32 pos) internal view returns (Checkpoint224 memory) { return self._checkpoints[pos]; } /** * @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint, * or by updating the last one. */ function _insert(Checkpoint224[] storage self, uint32 key, uint224 value) private returns (uint224, uint224) { uint256 pos = self.length; if (pos > 0) { // Copying to memory is important here. Checkpoint224 memory last = _unsafeAccess(self, pos - 1); // Checkpoint keys must be non-decreasing. if (last._key > key) { revert CheckpointUnorderedInsertion(); } // Update or push new checkpoint if (last._key == key) { _unsafeAccess(self, pos - 1)._value = value; } else { self.push(Checkpoint224({_key: key, _value: value})); } return (last._value, value); } else { self.push(Checkpoint224({_key: key, _value: value})); return (0, value); } } /** * @dev Return the index of the last (most recent) checkpoint with key lower or equal than the search key, or `high` * if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive * `high`. * * WARNING: `high` should not be greater than the array's length. */ function _upperBinaryLookup( Checkpoint224[] storage self, uint32 key, uint256 low, uint256 high ) private view returns (uint256) { while (low < high) { uint256 mid = Math.average(low, high); if (_unsafeAccess(self, mid)._key > key) { high = mid; } else { low = mid + 1; } } return high; } /** * @dev Return the index of the first (oldest) checkpoint with key is greater or equal than the search key, or * `high` if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and * exclusive `high`. * * WARNING: `high` should not be greater than the array's length. */ function _lowerBinaryLookup( Checkpoint224[] storage self, uint32 key, uint256 low, uint256 high ) private view returns (uint256) { while (low < high) { uint256 mid = Math.average(low, high); if (_unsafeAccess(self, mid)._key < key) { low = mid + 1; } else { high = mid; } } return high; } /** * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds. */ function _unsafeAccess( Checkpoint224[] storage self, uint256 pos ) private pure returns (Checkpoint224 storage result) { assembly { mstore(0, self.slot) result.slot := add(keccak256(0, 0x20), pos) } } struct Trace208 { Checkpoint208[] _checkpoints; } struct Checkpoint208 { uint48 _key; uint208 _value; } /** * @dev Pushes a (`key`, `value`) pair into a Trace208 so that it is stored as the checkpoint. * * Returns previous value and new value. * * IMPORTANT: Never accept `key` as a user input, since an arbitrary `type(uint48).max` key set will disable the * library. */ function push(Trace208 storage self, uint48 key, uint208 value) internal returns (uint208, uint208) { return _insert(self._checkpoints, key, value); } /** * @dev Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if * there is none. */ function lowerLookup(Trace208 storage self, uint48 key) internal view returns (uint208) { uint256 len = self._checkpoints.length; uint256 pos = _lowerBinaryLookup(self._checkpoints, key, 0, len); return pos == len ? 0 : _unsafeAccess(self._checkpoints, pos)._value; } /** * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero * if there is none. */ function upperLookup(Trace208 storage self, uint48 key) internal view returns (uint208) { uint256 len = self._checkpoints.length; uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, len); return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value; } /** * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero * if there is none. * * NOTE: This is a variant of {upperLookup} that is optimised to find "recent" checkpoint (checkpoints with high * keys). */ function upperLookupRecent(Trace208 storage self, uint48 key) internal view returns (uint208) { uint256 len = self._checkpoints.length; uint256 low = 0; uint256 high = len; if (len > 5) { uint256 mid = len - Math.sqrt(len); if (key < _unsafeAccess(self._checkpoints, mid)._key) { high = mid; } else { low = mid + 1; } } uint256 pos = _upperBinaryLookup(self._checkpoints, key, low, high); return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value; } /** * @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints. */ function latest(Trace208 storage self) internal view returns (uint208) { uint256 pos = self._checkpoints.length; return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value; } /** * @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value * in the most recent checkpoint. */ function latestCheckpoint(Trace208 storage self) internal view returns (bool exists, uint48 _key, uint208 _value) { uint256 pos = self._checkpoints.length; if (pos == 0) { return (false, 0, 0); } else { Checkpoint208 memory ckpt = _unsafeAccess(self._checkpoints, pos - 1); return (true, ckpt._key, ckpt._value); } } /** * @dev Returns the number of checkpoint. */ function length(Trace208 storage self) internal view returns (uint256) { return self._checkpoints.length; } /** * @dev Returns checkpoint at given position. */ function at(Trace208 storage self, uint32 pos) internal view returns (Checkpoint208 memory) { return self._checkpoints[pos]; } /** * @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint, * or by updating the last one. */ function _insert(Checkpoint208[] storage self, uint48 key, uint208 value) private returns (uint208, uint208) { uint256 pos = self.length; if (pos > 0) { // Copying to memory is important here. Checkpoint208 memory last = _unsafeAccess(self, pos - 1); // Checkpoint keys must be non-decreasing. if (last._key > key) { revert CheckpointUnorderedInsertion(); } // Update or push new checkpoint if (last._key == key) { _unsafeAccess(self, pos - 1)._value = value; } else { self.push(Checkpoint208({_key: key, _value: value})); } return (last._value, value); } else { self.push(Checkpoint208({_key: key, _value: value})); return (0, value); } } /** * @dev Return the index of the last (most recent) checkpoint with key lower or equal than the search key, or `high` * if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive * `high`. * * WARNING: `high` should not be greater than the array's length. */ function _upperBinaryLookup( Checkpoint208[] storage self, uint48 key, uint256 low, uint256 high ) private view returns (uint256) { while (low < high) { uint256 mid = Math.average(low, high); if (_unsafeAccess(self, mid)._key > key) { high = mid; } else { low = mid + 1; } } return high; } /** * @dev Return the index of the first (oldest) checkpoint with key is greater or equal than the search key, or * `high` if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and * exclusive `high`. * * WARNING: `high` should not be greater than the array's length. */ function _lowerBinaryLookup( Checkpoint208[] storage self, uint48 key, uint256 low, uint256 high ) private view returns (uint256) { while (low < high) { uint256 mid = Math.average(low, high); if (_unsafeAccess(self, mid)._key < key) { low = mid + 1; } else { high = mid; } } return high; } /** * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds. */ function _unsafeAccess( Checkpoint208[] storage self, uint256 pos ) private pure returns (Checkpoint208 storage result) { assembly { mstore(0, self.slot) result.slot := add(keccak256(0, 0x20), pos) } } struct Trace160 { Checkpoint160[] _checkpoints; } struct Checkpoint160 { uint96 _key; uint160 _value; } /** * @dev Pushes a (`key`, `value`) pair into a Trace160 so that it is stored as the checkpoint. * * Returns previous value and new value. * * IMPORTANT: Never accept `key` as a user input, since an arbitrary `type(uint96).max` key set will disable the * library. */ function push(Trace160 storage self, uint96 key, uint160 value) internal returns (uint160, uint160) { return _insert(self._checkpoints, key, value); } /** * @dev Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if * there is none. */ function lowerLookup(Trace160 storage self, uint96 key) internal view returns (uint160) { uint256 len = self._checkpoints.length; uint256 pos = _lowerBinaryLookup(self._checkpoints, key, 0, len); return pos == len ? 0 : _unsafeAccess(self._checkpoints, pos)._value; } /** * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero * if there is none. */ function upperLookup(Trace160 storage self, uint96 key) internal view returns (uint160) { uint256 len = self._checkpoints.length; uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, len); return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value; } /** * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero * if there is none. * * NOTE: This is a variant of {upperLookup} that is optimised to find "recent" checkpoint (checkpoints with high * keys). */ function upperLookupRecent(Trace160 storage self, uint96 key) internal view returns (uint160) { uint256 len = self._checkpoints.length; uint256 low = 0; uint256 high = len; if (len > 5) { uint256 mid = len - Math.sqrt(len); if (key < _unsafeAccess(self._checkpoints, mid)._key) { high = mid; } else { low = mid + 1; } } uint256 pos = _upperBinaryLookup(self._checkpoints, key, low, high); return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value; } /** * @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints. */ function latest(Trace160 storage self) internal view returns (uint160) { uint256 pos = self._checkpoints.length; return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value; } /** * @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value * in the most recent checkpoint. */ function latestCheckpoint(Trace160 storage self) internal view returns (bool exists, uint96 _key, uint160 _value) { uint256 pos = self._checkpoints.length; if (pos == 0) { return (false, 0, 0); } else { Checkpoint160 memory ckpt = _unsafeAccess(self._checkpoints, pos - 1); return (true, ckpt._key, ckpt._value); } } /** * @dev Returns the number of checkpoint. */ function length(Trace160 storage self) internal view returns (uint256) { return self._checkpoints.length; } /** * @dev Returns checkpoint at given position. */ function at(Trace160 storage self, uint32 pos) internal view returns (Checkpoint160 memory) { return self._checkpoints[pos]; } /** * @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint, * or by updating the last one. */ function _insert(Checkpoint160[] storage self, uint96 key, uint160 value) private returns (uint160, uint160) { uint256 pos = self.length; if (pos > 0) { // Copying to memory is important here. Checkpoint160 memory last = _unsafeAccess(self, pos - 1); // Checkpoint keys must be non-decreasing. if (last._key > key) { revert CheckpointUnorderedInsertion(); } // Update or push new checkpoint if (last._key == key) { _unsafeAccess(self, pos - 1)._value = value; } else { self.push(Checkpoint160({_key: key, _value: value})); } return (last._value, value); } else { self.push(Checkpoint160({_key: key, _value: value})); return (0, value); } } /** * @dev Return the index of the last (most recent) checkpoint with key lower or equal than the search key, or `high` * if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive * `high`. * * WARNING: `high` should not be greater than the array's length. */ function _upperBinaryLookup( Checkpoint160[] storage self, uint96 key, uint256 low, uint256 high ) private view returns (uint256) { while (low < high) { uint256 mid = Math.average(low, high); if (_unsafeAccess(self, mid)._key > key) { high = mid; } else { low = mid + 1; } } return high; } /** * @dev Return the index of the first (oldest) checkpoint with key is greater or equal than the search key, or * `high` if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and * exclusive `high`. * * WARNING: `high` should not be greater than the array's length. */ function _lowerBinaryLookup( Checkpoint160[] storage self, uint96 key, uint256 low, uint256 high ) private view returns (uint256) { while (low < high) { uint256 mid = Math.average(low, high); if (_unsafeAccess(self, mid)._key < key) { low = mid + 1; } else { high = mid; } } return high; } /** * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds. */ function _unsafeAccess( Checkpoint160[] storage self, uint256 pos ) private pure returns (Checkpoint160 storage result) { assembly { mstore(0, self.slot) result.slot := add(keccak256(0, 0x20), pos) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.20; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeCast { /** * @dev Value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value); /** * @dev An int value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedIntToUint(int256 value); /** * @dev Value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedIntDowncast(uint8 bits, int256 value); /** * @dev An uint value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedUintToInt(uint256 value); /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits */ function toUint248(uint256 value) internal pure returns (uint248) { if (value > type(uint248).max) { revert SafeCastOverflowedUintDowncast(248, value); } return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits */ function toUint240(uint256 value) internal pure returns (uint240) { if (value > type(uint240).max) { revert SafeCastOverflowedUintDowncast(240, value); } return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits */ function toUint232(uint256 value) internal pure returns (uint232) { if (value > type(uint232).max) { revert SafeCastOverflowedUintDowncast(232, value); } return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits */ function toUint224(uint256 value) internal pure returns (uint224) { if (value > type(uint224).max) { revert SafeCastOverflowedUintDowncast(224, value); } return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits */ function toUint216(uint256 value) internal pure returns (uint216) { if (value > type(uint216).max) { revert SafeCastOverflowedUintDowncast(216, value); } return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits */ function toUint208(uint256 value) internal pure returns (uint208) { if (value > type(uint208).max) { revert SafeCastOverflowedUintDowncast(208, value); } return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits */ function toUint200(uint256 value) internal pure returns (uint200) { if (value > type(uint200).max) { revert SafeCastOverflowedUintDowncast(200, value); } return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits */ function toUint192(uint256 value) internal pure returns (uint192) { if (value > type(uint192).max) { revert SafeCastOverflowedUintDowncast(192, value); } return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits */ function toUint184(uint256 value) internal pure returns (uint184) { if (value > type(uint184).max) { revert SafeCastOverflowedUintDowncast(184, value); } return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits */ function toUint176(uint256 value) internal pure returns (uint176) { if (value > type(uint176).max) { revert SafeCastOverflowedUintDowncast(176, value); } return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits */ function toUint168(uint256 value) internal pure returns (uint168) { if (value > type(uint168).max) { revert SafeCastOverflowedUintDowncast(168, value); } return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits */ function toUint160(uint256 value) internal pure returns (uint160) { if (value > type(uint160).max) { revert SafeCastOverflowedUintDowncast(160, value); } return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits */ function toUint152(uint256 value) internal pure returns (uint152) { if (value > type(uint152).max) { revert SafeCastOverflowedUintDowncast(152, value); } return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits */ function toUint144(uint256 value) internal pure returns (uint144) { if (value > type(uint144).max) { revert SafeCastOverflowedUintDowncast(144, value); } return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits */ function toUint136(uint256 value) internal pure returns (uint136) { if (value > type(uint136).max) { revert SafeCastOverflowedUintDowncast(136, value); } return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { if (value > type(uint128).max) { revert SafeCastOverflowedUintDowncast(128, value); } return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits */ function toUint120(uint256 value) internal pure returns (uint120) { if (value > type(uint120).max) { revert SafeCastOverflowedUintDowncast(120, value); } return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits */ function toUint112(uint256 value) internal pure returns (uint112) { if (value > type(uint112).max) { revert SafeCastOverflowedUintDowncast(112, value); } return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits */ function toUint104(uint256 value) internal pure returns (uint104) { if (value > type(uint104).max) { revert SafeCastOverflowedUintDowncast(104, value); } return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits */ function toUint96(uint256 value) internal pure returns (uint96) { if (value > type(uint96).max) { revert SafeCastOverflowedUintDowncast(96, value); } return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits */ function toUint88(uint256 value) internal pure returns (uint88) { if (value > type(uint88).max) { revert SafeCastOverflowedUintDowncast(88, value); } return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits */ function toUint80(uint256 value) internal pure returns (uint80) { if (value > type(uint80).max) { revert SafeCastOverflowedUintDowncast(80, value); } return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits */ function toUint72(uint256 value) internal pure returns (uint72) { if (value > type(uint72).max) { revert SafeCastOverflowedUintDowncast(72, value); } return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { if (value > type(uint64).max) { revert SafeCastOverflowedUintDowncast(64, value); } return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits */ function toUint56(uint256 value) internal pure returns (uint56) { if (value > type(uint56).max) { revert SafeCastOverflowedUintDowncast(56, value); } return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits */ function toUint48(uint256 value) internal pure returns (uint48) { if (value > type(uint48).max) { revert SafeCastOverflowedUintDowncast(48, value); } return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits */ function toUint40(uint256 value) internal pure returns (uint40) { if (value > type(uint40).max) { revert SafeCastOverflowedUintDowncast(40, value); } return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { if (value > type(uint32).max) { revert SafeCastOverflowedUintDowncast(32, value); } return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits */ function toUint24(uint256 value) internal pure returns (uint24) { if (value > type(uint24).max) { revert SafeCastOverflowedUintDowncast(24, value); } return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { if (value > type(uint16).max) { revert SafeCastOverflowedUintDowncast(16, value); } return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits */ function toUint8(uint256 value) internal pure returns (uint8) { if (value > type(uint8).max) { revert SafeCastOverflowedUintDowncast(8, value); } return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { if (value < 0) { revert SafeCastOverflowedIntToUint(value); } return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(248, value); } } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(240, value); } } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(232, value); } } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(224, value); } } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(216, value); } } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(208, value); } } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(200, value); } } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(192, value); } } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(184, value); } } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(176, value); } } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(168, value); } } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(160, value); } } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(152, value); } } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(144, value); } } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(136, value); } } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(128, value); } } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(120, value); } } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(112, value); } } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(104, value); } } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(96, value); } } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(88, value); } } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(80, value); } } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(72, value); } } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(64, value); } } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(56, value); } } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(48, value); } } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(40, value); } } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(32, value); } } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(24, value); } } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(16, value); } } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(8, value); } } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive if (value > uint256(type(int256).max)) { revert SafeCastOverflowedUintToInt(value); } return int256(value); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.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 reininitialization) 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 Returns a pointer to the storage namespace. */ // solhint-disable-next-line var-name-mixedcase function _getInitializableStorage() private pure returns (InitializableStorage storage $) { assembly { $.slot := INITIALIZABLE_STORAGE } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IStaticDelegateCallable { /** * @notice Make a delegatecall from this contract to a given target contract with a particular data (always reverts with a return data). * @param target address of the contract to make a delegatecall to * @param data data to make a delegatecall with * @dev It allows to use this contract's storage on-chain. */ function staticDelegateCall(address target, bytes calldata data) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol) pragma solidity ^0.8.20; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev The `account` is missing a role. */ error AccessControlUnauthorizedAccount(address account, bytes32 neededRole); /** * @dev The caller of a function is not the expected one. * * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}. */ error AccessControlBadConfirmation(); /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `callerConfirmation`. */ function renounceRole(bytes32 role, address callerConfirmation) external; }
// 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.0.0) (utils/introspection/ERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import {Initializable} from "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` */ abstract contract ERC165Upgradeable is Initializable, IERC165 { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
{ "remappings": [ "forge-std/=lib/forge-std/src/", "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/", "openzeppelin-contracts/=lib/openzeppelin-contracts/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "paris", "viaIR": true, "libraries": {} }
[{"inputs":[{"internalType":"address","name":"networkRegistry","type":"address"},{"internalType":"address","name":"vaultFactory","type":"address"},{"internalType":"address","name":"operatorVaultOptInService","type":"address"},{"internalType":"address","name":"operatorNetworkOptInService","type":"address"},{"internalType":"address","name":"delegatorFactory","type":"address"},{"internalType":"uint64","name":"entityType","type":"uint64"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[],"name":"AlreadySet","type":"error"},{"inputs":[],"name":"CheckpointUnorderedInsertion","type":"error"},{"inputs":[],"name":"DuplicateRoleHolder","type":"error"},{"inputs":[],"name":"ExceedsMaxNetworkLimit","type":"error"},{"inputs":[],"name":"InsufficientHookGas","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"MathOverflowedMulDiv","type":"error"},{"inputs":[],"name":"MissingRoleHolders","type":"error"},{"inputs":[],"name":"NotInitialized","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"NotNetwork","type":"error"},{"inputs":[],"name":"NotSlasher","type":"error"},{"inputs":[],"name":"NotVault","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"uint8","name":"bits","type":"uint8"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"SafeCastOverflowedUintDowncast","type":"error"},{"inputs":[],"name":"ZeroAddressRoleHolder","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"subnetwork","type":"bytes32"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint48","name":"captureTimestamp","type":"uint48"}],"name":"OnSlash","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"hook","type":"address"}],"name":"SetHook","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"subnetwork","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"SetMaxNetworkLimit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"subnetwork","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"SetNetworkLimit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"subnetwork","type":"bytes32"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"SetOperatorNetworkShares","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FACTORY","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"HOOK_GAS_LIMIT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"HOOK_RESERVE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"HOOK_SET_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NETWORK_LIMIT_SET_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NETWORK_REGISTRY","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OPERATOR_NETWORK_OPT_IN_SERVICE","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OPERATOR_NETWORK_SHARES_SET_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OPERATOR_VAULT_OPT_IN_SERVICE","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TYPE","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VAULT_FACTORY","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"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":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hook","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"data","type":"bytes"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"subnetwork","type":"bytes32"}],"name":"maxNetworkLimit","outputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"subnetwork","type":"bytes32"}],"name":"networkLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"subnetwork","type":"bytes32"},{"internalType":"uint48","name":"timestamp","type":"uint48"},{"internalType":"bytes","name":"hint","type":"bytes"}],"name":"networkLimitAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"subnetwork","type":"bytes32"},{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint48","name":"captureTimestamp","type":"uint48"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onSlash","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"subnetwork","type":"bytes32"},{"internalType":"address","name":"operator","type":"address"}],"name":"operatorNetworkShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"subnetwork","type":"bytes32"},{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint48","name":"timestamp","type":"uint48"},{"internalType":"bytes","name":"hint","type":"bytes"}],"name":"operatorNetworkSharesAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","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":"address","name":"hook_","type":"address"}],"name":"setHook","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint96","name":"identifier","type":"uint96"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"setMaxNetworkLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"subnetwork","type":"bytes32"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"setNetworkLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"subnetwork","type":"bytes32"},{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"setOperatorNetworkShares","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"subnetwork","type":"bytes32"},{"internalType":"address","name":"operator","type":"address"}],"name":"stake","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"subnetwork","type":"bytes32"},{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint48","name":"timestamp","type":"uint48"},{"internalType":"bytes","name":"hints","type":"bytes"}],"name":"stakeAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"staticDelegateCall","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"subnetwork","type":"bytes32"}],"name":"totalOperatorNetworkShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"subnetwork","type":"bytes32"},{"internalType":"uint48","name":"timestamp","type":"uint48"},{"internalType":"bytes","name":"hint","type":"bytes"}],"name":"totalOperatorNetworkSharesAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vault","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
610140346101a1576001600160401b0390601f612f9a38819003918201601f191683019190848311848410176101a6578160c092859260409586528339810103126101a15761004d826101bc565b610059602084016101bc565b906100658385016101bc565b94610072606086016101bc565b9460a0610081608083016101bc565b9101519180831683036101a1577ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a009081549060ff82891c1661019057808083160361014c575b50505060805260a05260c05260e0526101009283526101209182525190612dc992836101d1843960805183610803015260a05183610f75015260c0518381816106780152610faf015260e0518381816103a801526120750152518281816103ed0152818161168301526117a40152518181816105f6015281816115e801526118240152f35b6001600160401b0319909116811790915585519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a13880806100c7565b875163f92ee8a960e01b8152600490fd5b600080fd5b634e487b7160e01b600052604160045260246000fd5b51906001600160a01b03821682036101a15756fe6080604052600436101561001257600080fd5b60003560e01c806301ffc9a7146102675780630214534814610262578063103f29071461025d578063128e5d82146102585780631a7a7044146102535780631a80e5001461024e57806323f752d514610249578063248a9ca3146102445780632dd310001461023f5780632f2ff15d1461023a57806336568abe146102355780633dfd3873146102305780633eb22c0f1461022b57806342c53e3314610226578063439fab9114610221578063557cab441461021c5780635d32a1c9146102175780636679191e146102125780637d24bb271461020d5780637f5a7c7b146102085780638b3f10b01461020357806391d14854146101fe5780639f86fd85146101f9578063a217fddf146101f4578063a33bc287146101ef578063bb24fe8a146101ea578063c0cd7c3e146101e5578063c43dc03f146101e0578063d15b740e146101db578063d547741f146101d6578063e02f6937146101d1578063e49561ee146101cc578063e78eb6ae146101c7578063fbfa77cf146101c2578063fd4d447c146101bd578063ff54740f146101b85763ffa1ad74146101b357600080fd5b61133c565b61131e565b6112f4565b6112cb565b611290565b6110a0565b611084565b611035565b611009565b610fde565b610f99565b610f55565b610e30565b610e14565b610d58565b610cf5565b610cd0565b610ca7565b610c6d565b610c32565b610c0d565b610baf565b610a73565b6109f6565b6109cb565b6108cc565b610881565b610832565b6107ed565b6107b1565b610625565b6105e0565b610596565b6103d7565b610392565b6102c2565b346102bd5760203660031901126102bd5760043563ffffffff60e01b81168091036102bd57602090637965db0b60e01b81149081156102ac575b506040519015158152f35b6301ffc9a760e01b149050386102a1565b600080fd5b346102bd576040806003193601126102bd576004356024356102e261189a565b60009282845260026020528084205482116103825782845260036020528161030b828620611fb7565b14610372578161036c9161035c7e899d104fc3d8820bd96540612bcc5c448c8837b13b9f7faa43ad0728f0c14f9461034d876000526003602052604060002090565b6103564261247d565b906119ec565b5050519081529081906020820190565b0390a280f35b5163a741a04560e01b8152600490fd5b51631eefc06360e31b8152600490fd5b346102bd5760003660031901126102bd576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b346102bd5760003660031901126102bd576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b6001600160a01b038116036102bd57565b6064359065ffffffffffff821682036102bd57565b634e487b7160e01b600052604160045260246000fd5b604081019081106001600160401b0382111761047357604052565b610442565b606081019081106001600160401b0382111761047357604052565b90601f801991011681019081106001600160401b0382111761047357604052565b6040519060a082018281106001600160401b0382111761047357604052565b604051906104e082610458565b565b6001600160401b03811161047357601f01601f191660200190565b81601f820112156102bd57803590610514826104e2565b926105226040519485610493565b828452602083830101116102bd57816000926020809301838601378301015290565b9060806003198301126102bd57600435916024356105618161041c565b9160443565ffffffffffff811681036102bd5791606435906001600160401b0382116102bd57610593916004016104fd565b90565b346102bd5760206105d86105d36105ac36610544565b939190926000526005865260406000209060018060a01b0316600052602052604060002090565b611ae1565b604051908152f35b346102bd5760003660031901126102bd576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b346102bd5760403660031901126102bd576004356001600160601b03811681036102bd5760243590610655611bc4565b6040516302910f8b60e31b81523360048201526020816024816001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000165afa9081156107ac5760009161077d575b501561076b576001600160601b03166bffffffffffffffffffffffff193360601b161790806106e2836000526002602052604060002090565b54146107595761073d817fc67e7929681aa1bccd63f52b3799bf5805f3009f197db6fdf584b14f7fbf608c92610722856000526002602052604060002090565b5561072d8185611bf4565b6040519081529081906020820190565b0390a26107576001600080516020612d5483398151915255565b005b60405163a741a04560e01b8152600490fd5b6040516323d53b9760e21b8152600490fd5b61079f915060203d6020116107a5575b6107978183610493565b810190611385565b386106a9565b503d61078d565b61139d565b346102bd5760203660031901126102bd57600435600052600080516020612d348339815191526020526020600160406000200154604051908152f35b346102bd5760003660031901126102bd576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b346102bd5760403660031901126102bd576107576024356004356108558261041c565b80600052600080516020612d3483398151915260205261087c60016040600020015461194f565b611ee5565b346102bd5760403660031901126102bd5760243561089e8161041c565b336001600160a01b038216036108ba5761075790600435611f1f565b60405163334bd91960e11b8152600490fd5b346102bd5760203660031901126102bd576004356108e98161041c565b6108f1611bc4565b3360009081527f9ebbcbe0d2961d3fbe56ca6f679bc753bd848d3e6bb3eaf9041c51b286881d2c60205260408120549091907fd1c1f6fa6bf27d54c5e54c7c1dc6e5004d3c027ea1994fe68b29c1b51b69c36c9060ff16156109ad57506001546001600160a01b039182169181168214610759576001600160a01b03191681176001557f5bbb1d3ebb6a3ad2a0f17ff35e579a83af60604d1d3c2a4c83c62adecadf666d8280a26001600080516020612d548339815191525580f35b6044906040519063e2517d3f60e01b82523360048301526024820152fd5b346102bd5760203660031901126102bd57600435600052600360205260206105d86040600020611fb7565b346102bd5760403660031901126102bd5760206105d8610a41602435610a1b8161041c565b6004356000526005845260406000209060018060a01b0316600052602052604060002090565b611fb7565b9181601f840112156102bd578235916001600160401b0383116102bd57602083818601950101116102bd57565b346102bd5760203660031901126102bd576001600160401b036004358181116102bd57610aa4903690600401610a46565b600080516020612d74833981519152549260ff8460401c1615931680159081610ba7575b6001149081610b9d575b159081610b94575b50610b8257600080516020612d74833981519152805467ffffffffffffffff19166001179055610b0e9183610b5d57612040565b610b1457005b600080516020612d74833981519152805460ff60401b19169055604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a1005b600080516020612d74833981519152805460ff60401b1916600160401b179055612040565b60405163f92ee8a960e01b8152600490fd5b90501538610ada565b303b159150610ad2565b849150610ac8565b346102bd5760003660031901126102bd576020604051614e208152f35b60606003198201126102bd576004359160243565ffffffffffff811681036102bd5791604435906001600160401b0382116102bd57610593916004016104fd565b346102bd5760206105d8610c2036610bcc565b91600052600384526040600020611ae1565b346102bd5760003660031901126102bd5760206040517fd1c1f6fa6bf27d54c5e54c7c1dc6e5004d3c027ea1994fe68b29c1b51b69c36c8152f35b346102bd5760003660031901126102bd5760206040517e8b9b1e5fa9cf3b14f87f435649268146305ddf689f082e5961a335b07a9abf8152f35b346102bd5760003660031901126102bd576001546040516001600160a01b039091168152602090f35b346102bd5760206105d8610ce336610bcc565b91600052600484526040600020611ae1565b346102bd5760403660031901126102bd57602060ff610d4c602435610d198161041c565b600435600052600080516020612d34833981519152845260406000209060018060a01b0316600052602052604060002090565b54166040519015158152f35b346102bd576040806003193601126102bd57600435610d768161041c565b602435906001600160401b0382116102bd5760008091610d9d610e02943690600401610a46565b908187519283928337810184815203915af43d15610e0a57610df43d610dc2816104e2565b90610dcf86519283610493565b81523d6000602083013e5b8451948593151560208501528084015260608301906113fc565b03601f198101835282610493565b805190602001fd5b610df46060610dda565b346102bd5760003660031901126102bd57602060405160008152f35b346102bd5760603660031901126102bd57602435600435610e508261041c565b60443590610e5c6118f7565b6000928184526005602052610e89610a4182604087209060018060a01b0316600052602052604060002090565b838114610759577f739a5a3ec0ff71e2386d0013deac5f44e0935a98def2e2a5ddf9a709518c829491610efe610f4f9285885260046020526040882090610ef888610ef3610ed64261247d565b93610eee610a418c6000526004602052604060002090565b61144b565b611466565b916119ec565b5050610f338561034d83610f1c886000526005602052604060002090565b9060018060a01b0316600052602052604060002090565b50506040519485526001600160a01b0316939081906020820190565b0390a380f35b346102bd5760003660031901126102bd5760206040516001600160401b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b346102bd5760003660031901126102bd576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b346102bd5760203660031901126102bd57600435600052600460205260206105d86040600020611fb7565b346102bd5760203660031901126102bd5760043560005260026020526020604060002054604051908152f35b346102bd5760403660031901126102bd576107576024356004356110588261041c565b80600052600080516020612d3483398151915260205261107f60016040600020015461194f565b611f1f565b346102bd5760206105d861109736610544565b92919091611571565b346102bd5760a03660031901126102bd576024356004356110c08261041c565b604435906110cc61042d565b6084356001600160401b0381116102bd576110ec600491369083016104fd565b946110f5611bc4565b600095602061111c6111106111108a5460018060a01b031690565b6001600160a01b031690565b60405163b134427160e01b815294859182905afa9283156107ac57879361125f575b506001600160a01b03928316330361124d576001546001600160a01b03168381166111c2575b50506040805195865265ffffffffffff909316602086015216927f741a5de99085c0d660f3e4192217b0ffb0ea4e35a0480de48e857a4bc3ee36ed91819081015b0390a36111bf6001600080516020612d5483398151915255565b80f35b9093604051946111f9866111eb602082019363724ab0f760e11b8552858c898d60248701611714565b03601f198101885287610493565b62042e305a1061123b57886111a5938192827f741a5de99085c0d660f3e4192217b0ffb0ea4e35a0480de48e857a4bc3ee36ed9951926203d090f15093611164565b604051638072475160e01b8152600490fd5b60405163dabc4ad960e01b8152600490fd5b61128291935060203d602011611289575b61127a8183610493565b8101906116ff565b913861113e565b503d611270565b346102bd5760003660031901126102bd5760206040517f1312a1cf530e56add9be4fd84db9051dcc7635952f09f735f9a29405b55846258152f35b346102bd5760003660031901126102bd576000546040516001600160a01b039091168152602090f35b346102bd5760403660031901126102bd5760206105d86024356113168161041c565b60043561176c565b346102bd5760003660031901126102bd5760206040516203d0908152f35b346102bd5760003660031901126102bd57602060405160018152f35b60009081526005602090815260408083206001600160a01b03909416835292905220610593929190611ae1565b908160209103126102bd575180151581036102bd5790565b6040513d6000823e3d90fd5b90610593929160005260036020526040600020611ae1565b90610593929160005260046020526040600020611ae1565b60005b8381106113ec5750506000910152565b81810151838201526020016113dc565b90602091611415815180928185528580860191016113d9565b601f01601f1916010190565b634e487b7160e01b600052601160045260246000fd5b60001981019190821161144657565b611421565b9190820391821161144657565b906001820180921161144657565b9190820180921161144657565b6040519061148082610458565b60606020838281520152565b81601f820112156102bd5780516114a2816104e2565b926114b06040519485610493565b818452602082840101116102bd5761059391602080850191016113d9565b906020828203126102bd5781516001600160401b03928382116102bd5701906040828203126102bd576040519261150484610458565b82518181116102bd578261151991850161148c565b845260208301519081116102bd57611531920161148c565b602082015290565b6001600160a01b0391821681529116602082015265ffffffffffff9091166040820152608060608201819052610593929101906113fc565b92611581909291928284866122a8565b92909361158c611473565b938051806116e3575b5050841593841561164b575b84156115b9575b505050506115b35790565b50600090565b6020809495506115e4910151604051958694859463530e1d4360e01b865260601c9060048601611539565b03817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa9081156107ac5760009161162c575b5015388080806115a8565b611645915060203d6020116107a5576107978183610493565b38611621565b6000549094506001600160a01b031660208486519261167f604051948593849363530e1d4360e01b85528960048601611539565b03817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa9081156107ac576000916116c4575b5015936115a1565b6116dd915060203d6020116107a5576107978183610493565b386116bc565b6116f79295506020809183010191016114ce565b923880611595565b908160209103126102bd57516105938161041c565b919360a093610593969565ffffffffffff938552600180871b03166020850152604084015216606082015281608082015201906113fc565b8115611756570490565b634e487b7160e01b600052601260045260246000fd5b6000546040516308834cb560e21b8082526001600160a01b0385811660048401529283166024830152929392602092909183816044817f000000000000000000000000000000000000000000000000000000000000000086165afa9081156107ac5760009161187d575b50159182156117f8575b505090506117f157610593916123bf565b5050600090565b6040519081526001600160a01b0385166004820152606086901c602482015291508290829060449082907f0000000000000000000000000000000000000000000000000000000000000000165afa9182156107ac57600092611860575b5050158038806117e0565b6118769250803d106107a5576107978183610493565b3880611855565b6118949150843d86116107a5576107978183610493565b386117d6565b3360009081527f72a65082a5691803ab2b62c9bc729b34205ba1b183d950896526b2fd8714d0c7602052604090207e8b9b1e5fa9cf3b14f87f435649268146305ddf689f082e5961a335b07a9abf9060ff905b5416156109ad5750565b3360009081527f8f2dae99798887da307a4daa2c2d11f840b0cb9a6a67822660c531e9ad14dd00602052604090207f1312a1cf530e56add9be4fd84db9051dcc7635952f09f735f9a29405b55846259060ff906118ed565b6000818152600080516020612d3483398151915260209081526040808320338452909152902060ff906118ed565b634e487b7160e01b600052603260045260246000fd5b80548210156119ab5760005260206000200190600090565b61197d565b90815491600160401b83101561047357826119d39160016104e095018155611993565b90919082549060031b91821b91600019901b1916179055565b90929192600182019081548015611a7f575b5084611a09846124d3565b50949092845493611a1983611fb7565b9681611a6a575b5015611a47575050506000198101908111611446576119d38591611a4393611993565b9190565b611a43949293611a63926001600160d01b039091169190612a51565b50506119b0565b65ffffffffffff838116911614905038611a20565b600160401b81101561047357806001611a9b9201845583611993565b8154906000199060031b1b19169055386119fe565b908160209103126102bd575163ffffffff811681036102bd5790565b90600163ffffffff8093160191821161144657565b91805115611bba5780602080611afc93518301019101611ab0565b91611b078382612600565b92611b18845165ffffffffffff1690565b9065ffffffffffff8085169216828114611bae5782119182611b4e575b5050611b45576105939250612528565b50506020015190565b909150611b5b8354611437565b63ffffffff831614918215611b74575b50503880611b35565b611ba6919250611b8f611b89611b9b92611acc565b85612600565b5165ffffffffffff1690565b65ffffffffffff1690565b113880611b6b565b50505050506020015190565b5061059391612528565b600080516020612d548339815191526002815414611be25760029055565b604051633ee5aeb560e01b8152600490fd5b9060009180835260036020526040832082611c0e826124d3565b919390508315611c6d57611c2e916001600160d01b031690600101611993565b90549060031b1c5b82611c63575b5050611c4757505050565b82604091611c5f94526003602052206103564261247d565b5050565b1190508238611c3c565b505084611c36565b6001600160a01b03811660009081527fb7db2dd08fcb62d0c9e08c51941cae53c267786a0b75803fb7960902fc8ef97d6020526040812054600080516020612d348339815191529060ff16611d2457818052602090815260408083206001600160a01b038516600090815292529020805460ff1916600117905533916001600160a01b0316907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d8180a4600190565b50905090565b6001600160a01b03811660009081527f9ebbcbe0d2961d3fbe56ca6f679bc753bd848d3e6bb3eaf9041c51b286881d2c602052604081207fd1c1f6fa6bf27d54c5e54c7c1dc6e5004d3c027ea1994fe68b29c1b51b69c36c90600080516020612d348339815191529060ff905b5416611dfd57818352602090815260408084206001600160a01b038616600090815292529020805460ff1916600117905533926001600160a01b0316917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9080a4600190565b5050905090565b6001600160a01b03811660009081527f72a65082a5691803ab2b62c9bc729b34205ba1b183d950896526b2fd8714d0c7602052604081207e8b9b1e5fa9cf3b14f87f435649268146305ddf689f082e5961a335b07a9abf90600080516020612d348339815191529060ff90611d97565b6001600160a01b03811660009081527f8f2dae99798887da307a4daa2c2d11f840b0cb9a6a67822660c531e9ad14dd00602052604081207f1312a1cf530e56add9be4fd84db9051dcc7635952f09f735f9a29405b558462590600080516020612d348339815191529060ff90611d97565b6000818152600080516020612d34833981519152602081815260408084206001600160a01b0387168552909152822091929160ff90611d97565b6000818152600080516020612d34833981519152602081815260408084206001600160a01b038716855290915282205491929160ff1615611dfd57818352602090815260408084206001600160a01b038616600090815292529020805460ff1916905533926001600160a01b0316917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9080a4600190565b805460009080611feb57505060005b6001600160d01b038116156117f1576001611fe19201611993565b90549060031b1c90565b600019918183810111611446578084602092522001015460301c611fc6565b9190916040818403126102bd5780356120228161041c565b9260208201356001600160401b0381116102bd5761059392016104fd565b61204c9181019061200a565b6040516302910f8b60e31b81526001600160a01b039283166004820181905291906020816024817f000000000000000000000000000000000000000000000000000000000000000088165afa9081156107ac57600091612162575b5015612150576120e46040916120df61212a946120c2612668565b60018060a01b03166001600160601b0360a01b6000541617600055565b6127ea565b6020810151600180546001600160a01b0319166001600160a01b0390921691909117905580516001600160a01b0316848116612140575b5001516001600160a01b031690565b9081166121345750565b61213d90611d2a565b50565b61214990611c75565b503861211b565b6040516362df054560e01b8152600490fd5b61217b915060203d6020116107a5576107978183610493565b386120a7565b6040519060a082018281106001600160401b038211176104735760405281608060609182815282602082015282604082015282808201520152565b906020828203126102bd5781516001600160401b03928382116102bd57019060a0828203126102bd576121ed6104b4565b9282518181116102bd578261220391850161148c565b845260208301518181116102bd578261221d91850161148c565b602085015260408301518181116102bd578261223a91850161148c565b604085015260608301518181116102bd578261225791850161148c565b606085015260808301519081116102bd57612272920161148c565b608082015290565b908160209103126102bd575190565b60409065ffffffffffff610593949316815281602082015201906113fc565b93929190936122b5612181565b928051806123a3575b50506122cf606084015183836113c1565b91600090836122e657505091516000945092915050565b6122fb85978260806123359801519186611358565b926020612314611110611110865460018060a01b031690565b818a01519060405180809a819463810da75d60e01b83528860048401612289565b03915afa9081156107ac5761236b966123659492612370575b5061235f919260408a0151916113a9565b9061294c565b9061295e565b915190565b61235f92506123969060203d60201161239c575b61238e8183610493565b81019061227a565b9161234e565b503d612384565b6123b79294506020809183010191016121bc565b9138806122be565b906123d7610a41836000526004602052604060002090565b90816123e557505050600090565b610a4161240091610f1c856000526005602052604060002090565b60005460405163bd49c35f60e01b815290602090829060049082906001600160a01b03165afa80156107ac576105939461236592600092612454575b50610a4161235f916000526003602052604060002090565b61235f919250612475610a419160203d60201161239c5761238e8183610493565b92915061243c565b65ffffffffffff90818111612490571690565b604490604051906306dfcc6560e41b8252603060048301526024820152fd5b906040516124bc81610458565b915465ffffffffffff8116835260301c6020830152565b8054806124e7575050600090600090600090565b6000199080828101116114465761250792600052602060002001016124af565b9065ffffffffffff82511691602060018060d01b0391015116906001929190565b908154906000829160058411612596575b612544935084612cd2565b8061256d57506000905b6001600160d01b038216156117f157610593916001611fe19201611993565b61258961257c61259092611437565b8360005260206000200190565b5460301c90565b9061254e565b91926125a181612b9e565b810390811161144657612544938560005265ffffffffffff80836020600020015416908516106000146125d5575091612539565b9291506125e190611458565b90612539565b604051906125f482610458565b60006020838281520152565b9061262961262361264a926126136125e7565b5061261c6125e7565b5084611993565b506124af565b91600165ffffffffffff845116936020828060d01b03910151169101611993565b9054906040519261265a84610458565b835260031b1c602082015290565b612670612b6f565b612678612b6f565b6001600080516020612d5483398151915255565b6040519061269982610478565b60006040838281528260208201520152565b81601f820112156102bd578051916020916001600160401b038411610473578360051b90604051946126df85840187610493565b855283808601928201019283116102bd578301905b828210612702575050505090565b83809183516127108161041c565b8152019101906126f4565b906020828203126102bd5781516001600160401b03928382116102bd5701908181039260a084126102bd5760606040519461275586610478565b126102bd5760405161276681610478565b83516127718161041c565b815260208401516127818161041c565b602082015260408401516127948161041c565b6040820152845260608301518181116102bd57826127b39185016126ab565b602085015260808301519081116102bd576127ce92016126ab565b604082015290565b80518210156119ab5760209160051b010190565b612806906127f661268c565b506020808251830101910161271b565b8051519091906001600160a01b03161580612932575b6129205790602081019060005b825180518210156128a35761111061284483612851936127d6565b516001600160a01b031690565b156128915761287361286f61286a6128448487516127d6565b611e04565b1590565b61287f57600101612829565b604051635140fefd60e11b8152600490fd5b6040516323cda06760e01b8152600490fd5b5060409250508181019060005b8251805182101561291757611110612844836128cb936127d6565b15612906576128e961286f6128e46128448487516127d6565b611e74565b6128f5576001016128b0565b8351635140fefd60e11b8152600490fd5b83516323cda06760e01b8152600490fd5b50509150505190565b6040516303501f5960e11b8152600490fd5b50602082015151158061281c57506040820151511561281c565b9080821015612959575090565b905090565b909182820291600019848209938380861095039480860395146129e657848311156129d45782910981600003821680920460028082600302188083028203028083028203028083028203028083028203028083028203028092029003029360018380600003040190848311900302920304170290565b60405163227bc15360e01b8152600490fd5b505090610593925061174c565b8054600160401b81101561047357612a1091600182018155611993565b612a3b57815160209092015160301b65ffffffffffff191665ffffffffffff92909216919091179055565b634e487b7160e01b600052600060045260246000fd5b805492939291908215612b4557612a72612a6d61257c85611437565b6124af565b90612a83825165ffffffffffff1690565b65ffffffffffff84811691168110612b3357611a43946020948892612ab1611b9b875165ffffffffffff1690565b03612afb5750612aed92612ac7612ad492611437565b9060005260206000200190565b9065ffffffffffff82549181199060301b169116179055565b01516001600160d01b031690565b915050612b2e91612b1b612b0d6104d3565b65ffffffffffff9093168352565b6001600160d01b038816828601526129f3565b612aed565b604051632520601d60e01b8152600490fd5b612b699250612b55612b0d6104d3565b6001600160d01b03851660208301526129f3565b60009190565b60ff600080516020612d748339815191525460401c1615612b8c57565b604051631afcd79f60e31b8152600490fd5b80156115b3578061235f612c6a612c60612c56612c4c612c42612c38612c2e60016105939a6000908b60801c80612cc6575b508060401c80612cb9575b508060201c80612cac575b508060101c80612c9f575b508060081c80612c92575b508060041c80612c85575b508060021c80612c78575b50821c612c71575b811c1b612c27818b61174c565b0160011c90565b612c27818a61174c565b612c27818961174c565b612c27818861174c565b612c27818761174c565b612c27818661174c565b612c27818561174c565b809261174c565b8101612c1a565b6002915091019038612c12565b6004915091019038612c07565b6008915091019038612bfc565b6010915091019038612bf1565b6020915091019038612be6565b6040915091019038612bdb565b91505060809038612bd0565b91905b838210612ce25750505090565b9091928083169080841860011c82018092116114465760008581526020902082015465ffffffffffff9081169084161015612d215750925b9190612cd5565b939250612d2d90611458565b91612d1a56fe02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268009b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00a2646970667358221220ed0b9f601fd23e22c77520bccb40c884385a55386b3e90213263e53be0769eac64736f6c634300081900330000000000000000000000007d03b7343bf8d5cec7c0c27ece084a20113d15c9000000000000000000000000407a039d94948484d356efb765b3c74382a050b400000000000000000000000095cc0a052ae33941877c9619835a233d21d5735100000000000000000000000058973d16ffa900d11fc22e5e2b6840d9f7e13401000000000000000000000000890ca3f95e0f40a79885b7400926544b2214b03f0000000000000000000000000000000000000000000000000000000000000000
Deployed Bytecode
0x6080604052600436101561001257600080fd5b60003560e01c806301ffc9a7146102675780630214534814610262578063103f29071461025d578063128e5d82146102585780631a7a7044146102535780631a80e5001461024e57806323f752d514610249578063248a9ca3146102445780632dd310001461023f5780632f2ff15d1461023a57806336568abe146102355780633dfd3873146102305780633eb22c0f1461022b57806342c53e3314610226578063439fab9114610221578063557cab441461021c5780635d32a1c9146102175780636679191e146102125780637d24bb271461020d5780637f5a7c7b146102085780638b3f10b01461020357806391d14854146101fe5780639f86fd85146101f9578063a217fddf146101f4578063a33bc287146101ef578063bb24fe8a146101ea578063c0cd7c3e146101e5578063c43dc03f146101e0578063d15b740e146101db578063d547741f146101d6578063e02f6937146101d1578063e49561ee146101cc578063e78eb6ae146101c7578063fbfa77cf146101c2578063fd4d447c146101bd578063ff54740f146101b85763ffa1ad74146101b357600080fd5b61133c565b61131e565b6112f4565b6112cb565b611290565b6110a0565b611084565b611035565b611009565b610fde565b610f99565b610f55565b610e30565b610e14565b610d58565b610cf5565b610cd0565b610ca7565b610c6d565b610c32565b610c0d565b610baf565b610a73565b6109f6565b6109cb565b6108cc565b610881565b610832565b6107ed565b6107b1565b610625565b6105e0565b610596565b6103d7565b610392565b6102c2565b346102bd5760203660031901126102bd5760043563ffffffff60e01b81168091036102bd57602090637965db0b60e01b81149081156102ac575b506040519015158152f35b6301ffc9a760e01b149050386102a1565b600080fd5b346102bd576040806003193601126102bd576004356024356102e261189a565b60009282845260026020528084205482116103825782845260036020528161030b828620611fb7565b14610372578161036c9161035c7e899d104fc3d8820bd96540612bcc5c448c8837b13b9f7faa43ad0728f0c14f9461034d876000526003602052604060002090565b6103564261247d565b906119ec565b5050519081529081906020820190565b0390a280f35b5163a741a04560e01b8152600490fd5b51631eefc06360e31b8152600490fd5b346102bd5760003660031901126102bd576040517f000000000000000000000000407a039d94948484d356efb765b3c74382a050b46001600160a01b03168152602090f35b346102bd5760003660031901126102bd576040517f00000000000000000000000095cc0a052ae33941877c9619835a233d21d573516001600160a01b03168152602090f35b6001600160a01b038116036102bd57565b6064359065ffffffffffff821682036102bd57565b634e487b7160e01b600052604160045260246000fd5b604081019081106001600160401b0382111761047357604052565b610442565b606081019081106001600160401b0382111761047357604052565b90601f801991011681019081106001600160401b0382111761047357604052565b6040519060a082018281106001600160401b0382111761047357604052565b604051906104e082610458565b565b6001600160401b03811161047357601f01601f191660200190565b81601f820112156102bd57803590610514826104e2565b926105226040519485610493565b828452602083830101116102bd57816000926020809301838601378301015290565b9060806003198301126102bd57600435916024356105618161041c565b9160443565ffffffffffff811681036102bd5791606435906001600160401b0382116102bd57610593916004016104fd565b90565b346102bd5760206105d86105d36105ac36610544565b939190926000526005865260406000209060018060a01b0316600052602052604060002090565b611ae1565b604051908152f35b346102bd5760003660031901126102bd576040517f00000000000000000000000058973d16ffa900d11fc22e5e2b6840d9f7e134016001600160a01b03168152602090f35b346102bd5760403660031901126102bd576004356001600160601b03811681036102bd5760243590610655611bc4565b6040516302910f8b60e31b81523360048201526020816024816001600160a01b037f0000000000000000000000007d03b7343bf8d5cec7c0c27ece084a20113d15c9165afa9081156107ac5760009161077d575b501561076b576001600160601b03166bffffffffffffffffffffffff193360601b161790806106e2836000526002602052604060002090565b54146107595761073d817fc67e7929681aa1bccd63f52b3799bf5805f3009f197db6fdf584b14f7fbf608c92610722856000526002602052604060002090565b5561072d8185611bf4565b6040519081529081906020820190565b0390a26107576001600080516020612d5483398151915255565b005b60405163a741a04560e01b8152600490fd5b6040516323d53b9760e21b8152600490fd5b61079f915060203d6020116107a5575b6107978183610493565b810190611385565b386106a9565b503d61078d565b61139d565b346102bd5760203660031901126102bd57600435600052600080516020612d348339815191526020526020600160406000200154604051908152f35b346102bd5760003660031901126102bd576040517f000000000000000000000000890ca3f95e0f40a79885b7400926544b2214b03f6001600160a01b03168152602090f35b346102bd5760403660031901126102bd576107576024356004356108558261041c565b80600052600080516020612d3483398151915260205261087c60016040600020015461194f565b611ee5565b346102bd5760403660031901126102bd5760243561089e8161041c565b336001600160a01b038216036108ba5761075790600435611f1f565b60405163334bd91960e11b8152600490fd5b346102bd5760203660031901126102bd576004356108e98161041c565b6108f1611bc4565b3360009081527f9ebbcbe0d2961d3fbe56ca6f679bc753bd848d3e6bb3eaf9041c51b286881d2c60205260408120549091907fd1c1f6fa6bf27d54c5e54c7c1dc6e5004d3c027ea1994fe68b29c1b51b69c36c9060ff16156109ad57506001546001600160a01b039182169181168214610759576001600160a01b03191681176001557f5bbb1d3ebb6a3ad2a0f17ff35e579a83af60604d1d3c2a4c83c62adecadf666d8280a26001600080516020612d548339815191525580f35b6044906040519063e2517d3f60e01b82523360048301526024820152fd5b346102bd5760203660031901126102bd57600435600052600360205260206105d86040600020611fb7565b346102bd5760403660031901126102bd5760206105d8610a41602435610a1b8161041c565b6004356000526005845260406000209060018060a01b0316600052602052604060002090565b611fb7565b9181601f840112156102bd578235916001600160401b0383116102bd57602083818601950101116102bd57565b346102bd5760203660031901126102bd576001600160401b036004358181116102bd57610aa4903690600401610a46565b600080516020612d74833981519152549260ff8460401c1615931680159081610ba7575b6001149081610b9d575b159081610b94575b50610b8257600080516020612d74833981519152805467ffffffffffffffff19166001179055610b0e9183610b5d57612040565b610b1457005b600080516020612d74833981519152805460ff60401b19169055604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a1005b600080516020612d74833981519152805460ff60401b1916600160401b179055612040565b60405163f92ee8a960e01b8152600490fd5b90501538610ada565b303b159150610ad2565b849150610ac8565b346102bd5760003660031901126102bd576020604051614e208152f35b60606003198201126102bd576004359160243565ffffffffffff811681036102bd5791604435906001600160401b0382116102bd57610593916004016104fd565b346102bd5760206105d8610c2036610bcc565b91600052600384526040600020611ae1565b346102bd5760003660031901126102bd5760206040517fd1c1f6fa6bf27d54c5e54c7c1dc6e5004d3c027ea1994fe68b29c1b51b69c36c8152f35b346102bd5760003660031901126102bd5760206040517e8b9b1e5fa9cf3b14f87f435649268146305ddf689f082e5961a335b07a9abf8152f35b346102bd5760003660031901126102bd576001546040516001600160a01b039091168152602090f35b346102bd5760206105d8610ce336610bcc565b91600052600484526040600020611ae1565b346102bd5760403660031901126102bd57602060ff610d4c602435610d198161041c565b600435600052600080516020612d34833981519152845260406000209060018060a01b0316600052602052604060002090565b54166040519015158152f35b346102bd576040806003193601126102bd57600435610d768161041c565b602435906001600160401b0382116102bd5760008091610d9d610e02943690600401610a46565b908187519283928337810184815203915af43d15610e0a57610df43d610dc2816104e2565b90610dcf86519283610493565b81523d6000602083013e5b8451948593151560208501528084015260608301906113fc565b03601f198101835282610493565b805190602001fd5b610df46060610dda565b346102bd5760003660031901126102bd57602060405160008152f35b346102bd5760603660031901126102bd57602435600435610e508261041c565b60443590610e5c6118f7565b6000928184526005602052610e89610a4182604087209060018060a01b0316600052602052604060002090565b838114610759577f739a5a3ec0ff71e2386d0013deac5f44e0935a98def2e2a5ddf9a709518c829491610efe610f4f9285885260046020526040882090610ef888610ef3610ed64261247d565b93610eee610a418c6000526004602052604060002090565b61144b565b611466565b916119ec565b5050610f338561034d83610f1c886000526005602052604060002090565b9060018060a01b0316600052602052604060002090565b50506040519485526001600160a01b0316939081906020820190565b0390a380f35b346102bd5760003660031901126102bd5760206040516001600160401b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b346102bd5760003660031901126102bd576040517f0000000000000000000000007d03b7343bf8d5cec7c0c27ece084a20113d15c96001600160a01b03168152602090f35b346102bd5760203660031901126102bd57600435600052600460205260206105d86040600020611fb7565b346102bd5760203660031901126102bd5760043560005260026020526020604060002054604051908152f35b346102bd5760403660031901126102bd576107576024356004356110588261041c565b80600052600080516020612d3483398151915260205261107f60016040600020015461194f565b611f1f565b346102bd5760206105d861109736610544565b92919091611571565b346102bd5760a03660031901126102bd576024356004356110c08261041c565b604435906110cc61042d565b6084356001600160401b0381116102bd576110ec600491369083016104fd565b946110f5611bc4565b600095602061111c6111106111108a5460018060a01b031690565b6001600160a01b031690565b60405163b134427160e01b815294859182905afa9283156107ac57879361125f575b506001600160a01b03928316330361124d576001546001600160a01b03168381166111c2575b50506040805195865265ffffffffffff909316602086015216927f741a5de99085c0d660f3e4192217b0ffb0ea4e35a0480de48e857a4bc3ee36ed91819081015b0390a36111bf6001600080516020612d5483398151915255565b80f35b9093604051946111f9866111eb602082019363724ab0f760e11b8552858c898d60248701611714565b03601f198101885287610493565b62042e305a1061123b57886111a5938192827f741a5de99085c0d660f3e4192217b0ffb0ea4e35a0480de48e857a4bc3ee36ed9951926203d090f15093611164565b604051638072475160e01b8152600490fd5b60405163dabc4ad960e01b8152600490fd5b61128291935060203d602011611289575b61127a8183610493565b8101906116ff565b913861113e565b503d611270565b346102bd5760003660031901126102bd5760206040517f1312a1cf530e56add9be4fd84db9051dcc7635952f09f735f9a29405b55846258152f35b346102bd5760003660031901126102bd576000546040516001600160a01b039091168152602090f35b346102bd5760403660031901126102bd5760206105d86024356113168161041c565b60043561176c565b346102bd5760003660031901126102bd5760206040516203d0908152f35b346102bd5760003660031901126102bd57602060405160018152f35b60009081526005602090815260408083206001600160a01b03909416835292905220610593929190611ae1565b908160209103126102bd575180151581036102bd5790565b6040513d6000823e3d90fd5b90610593929160005260036020526040600020611ae1565b90610593929160005260046020526040600020611ae1565b60005b8381106113ec5750506000910152565b81810151838201526020016113dc565b90602091611415815180928185528580860191016113d9565b601f01601f1916010190565b634e487b7160e01b600052601160045260246000fd5b60001981019190821161144657565b611421565b9190820391821161144657565b906001820180921161144657565b9190820180921161144657565b6040519061148082610458565b60606020838281520152565b81601f820112156102bd5780516114a2816104e2565b926114b06040519485610493565b818452602082840101116102bd5761059391602080850191016113d9565b906020828203126102bd5781516001600160401b03928382116102bd5701906040828203126102bd576040519261150484610458565b82518181116102bd578261151991850161148c565b845260208301519081116102bd57611531920161148c565b602082015290565b6001600160a01b0391821681529116602082015265ffffffffffff9091166040820152608060608201819052610593929101906113fc565b92611581909291928284866122a8565b92909361158c611473565b938051806116e3575b5050841593841561164b575b84156115b9575b505050506115b35790565b50600090565b6020809495506115e4910151604051958694859463530e1d4360e01b865260601c9060048601611539565b03817f00000000000000000000000058973d16ffa900d11fc22e5e2b6840d9f7e134016001600160a01b03165afa9081156107ac5760009161162c575b5015388080806115a8565b611645915060203d6020116107a5576107978183610493565b38611621565b6000549094506001600160a01b031660208486519261167f604051948593849363530e1d4360e01b85528960048601611539565b03817f00000000000000000000000095cc0a052ae33941877c9619835a233d21d573516001600160a01b03165afa9081156107ac576000916116c4575b5015936115a1565b6116dd915060203d6020116107a5576107978183610493565b386116bc565b6116f79295506020809183010191016114ce565b923880611595565b908160209103126102bd57516105938161041c565b919360a093610593969565ffffffffffff938552600180871b03166020850152604084015216606082015281608082015201906113fc565b8115611756570490565b634e487b7160e01b600052601260045260246000fd5b6000546040516308834cb560e21b8082526001600160a01b0385811660048401529283166024830152929392602092909183816044817f00000000000000000000000095cc0a052ae33941877c9619835a233d21d5735186165afa9081156107ac5760009161187d575b50159182156117f8575b505090506117f157610593916123bf565b5050600090565b6040519081526001600160a01b0385166004820152606086901c602482015291508290829060449082907f00000000000000000000000058973d16ffa900d11fc22e5e2b6840d9f7e13401165afa9182156107ac57600092611860575b5050158038806117e0565b6118769250803d106107a5576107978183610493565b3880611855565b6118949150843d86116107a5576107978183610493565b386117d6565b3360009081527f72a65082a5691803ab2b62c9bc729b34205ba1b183d950896526b2fd8714d0c7602052604090207e8b9b1e5fa9cf3b14f87f435649268146305ddf689f082e5961a335b07a9abf9060ff905b5416156109ad5750565b3360009081527f8f2dae99798887da307a4daa2c2d11f840b0cb9a6a67822660c531e9ad14dd00602052604090207f1312a1cf530e56add9be4fd84db9051dcc7635952f09f735f9a29405b55846259060ff906118ed565b6000818152600080516020612d3483398151915260209081526040808320338452909152902060ff906118ed565b634e487b7160e01b600052603260045260246000fd5b80548210156119ab5760005260206000200190600090565b61197d565b90815491600160401b83101561047357826119d39160016104e095018155611993565b90919082549060031b91821b91600019901b1916179055565b90929192600182019081548015611a7f575b5084611a09846124d3565b50949092845493611a1983611fb7565b9681611a6a575b5015611a47575050506000198101908111611446576119d38591611a4393611993565b9190565b611a43949293611a63926001600160d01b039091169190612a51565b50506119b0565b65ffffffffffff838116911614905038611a20565b600160401b81101561047357806001611a9b9201845583611993565b8154906000199060031b1b19169055386119fe565b908160209103126102bd575163ffffffff811681036102bd5790565b90600163ffffffff8093160191821161144657565b91805115611bba5780602080611afc93518301019101611ab0565b91611b078382612600565b92611b18845165ffffffffffff1690565b9065ffffffffffff8085169216828114611bae5782119182611b4e575b5050611b45576105939250612528565b50506020015190565b909150611b5b8354611437565b63ffffffff831614918215611b74575b50503880611b35565b611ba6919250611b8f611b89611b9b92611acc565b85612600565b5165ffffffffffff1690565b65ffffffffffff1690565b113880611b6b565b50505050506020015190565b5061059391612528565b600080516020612d548339815191526002815414611be25760029055565b604051633ee5aeb560e01b8152600490fd5b9060009180835260036020526040832082611c0e826124d3565b919390508315611c6d57611c2e916001600160d01b031690600101611993565b90549060031b1c5b82611c63575b5050611c4757505050565b82604091611c5f94526003602052206103564261247d565b5050565b1190508238611c3c565b505084611c36565b6001600160a01b03811660009081527fb7db2dd08fcb62d0c9e08c51941cae53c267786a0b75803fb7960902fc8ef97d6020526040812054600080516020612d348339815191529060ff16611d2457818052602090815260408083206001600160a01b038516600090815292529020805460ff1916600117905533916001600160a01b0316907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d8180a4600190565b50905090565b6001600160a01b03811660009081527f9ebbcbe0d2961d3fbe56ca6f679bc753bd848d3e6bb3eaf9041c51b286881d2c602052604081207fd1c1f6fa6bf27d54c5e54c7c1dc6e5004d3c027ea1994fe68b29c1b51b69c36c90600080516020612d348339815191529060ff905b5416611dfd57818352602090815260408084206001600160a01b038616600090815292529020805460ff1916600117905533926001600160a01b0316917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9080a4600190565b5050905090565b6001600160a01b03811660009081527f72a65082a5691803ab2b62c9bc729b34205ba1b183d950896526b2fd8714d0c7602052604081207e8b9b1e5fa9cf3b14f87f435649268146305ddf689f082e5961a335b07a9abf90600080516020612d348339815191529060ff90611d97565b6001600160a01b03811660009081527f8f2dae99798887da307a4daa2c2d11f840b0cb9a6a67822660c531e9ad14dd00602052604081207f1312a1cf530e56add9be4fd84db9051dcc7635952f09f735f9a29405b558462590600080516020612d348339815191529060ff90611d97565b6000818152600080516020612d34833981519152602081815260408084206001600160a01b0387168552909152822091929160ff90611d97565b6000818152600080516020612d34833981519152602081815260408084206001600160a01b038716855290915282205491929160ff1615611dfd57818352602090815260408084206001600160a01b038616600090815292529020805460ff1916905533926001600160a01b0316917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9080a4600190565b805460009080611feb57505060005b6001600160d01b038116156117f1576001611fe19201611993565b90549060031b1c90565b600019918183810111611446578084602092522001015460301c611fc6565b9190916040818403126102bd5780356120228161041c565b9260208201356001600160401b0381116102bd5761059392016104fd565b61204c9181019061200a565b6040516302910f8b60e31b81526001600160a01b039283166004820181905291906020816024817f000000000000000000000000407a039d94948484d356efb765b3c74382a050b488165afa9081156107ac57600091612162575b5015612150576120e46040916120df61212a946120c2612668565b60018060a01b03166001600160601b0360a01b6000541617600055565b6127ea565b6020810151600180546001600160a01b0319166001600160a01b0390921691909117905580516001600160a01b0316848116612140575b5001516001600160a01b031690565b9081166121345750565b61213d90611d2a565b50565b61214990611c75565b503861211b565b6040516362df054560e01b8152600490fd5b61217b915060203d6020116107a5576107978183610493565b386120a7565b6040519060a082018281106001600160401b038211176104735760405281608060609182815282602082015282604082015282808201520152565b906020828203126102bd5781516001600160401b03928382116102bd57019060a0828203126102bd576121ed6104b4565b9282518181116102bd578261220391850161148c565b845260208301518181116102bd578261221d91850161148c565b602085015260408301518181116102bd578261223a91850161148c565b604085015260608301518181116102bd578261225791850161148c565b606085015260808301519081116102bd57612272920161148c565b608082015290565b908160209103126102bd575190565b60409065ffffffffffff610593949316815281602082015201906113fc565b93929190936122b5612181565b928051806123a3575b50506122cf606084015183836113c1565b91600090836122e657505091516000945092915050565b6122fb85978260806123359801519186611358565b926020612314611110611110865460018060a01b031690565b818a01519060405180809a819463810da75d60e01b83528860048401612289565b03915afa9081156107ac5761236b966123659492612370575b5061235f919260408a0151916113a9565b9061294c565b9061295e565b915190565b61235f92506123969060203d60201161239c575b61238e8183610493565b81019061227a565b9161234e565b503d612384565b6123b79294506020809183010191016121bc565b9138806122be565b906123d7610a41836000526004602052604060002090565b90816123e557505050600090565b610a4161240091610f1c856000526005602052604060002090565b60005460405163bd49c35f60e01b815290602090829060049082906001600160a01b03165afa80156107ac576105939461236592600092612454575b50610a4161235f916000526003602052604060002090565b61235f919250612475610a419160203d60201161239c5761238e8183610493565b92915061243c565b65ffffffffffff90818111612490571690565b604490604051906306dfcc6560e41b8252603060048301526024820152fd5b906040516124bc81610458565b915465ffffffffffff8116835260301c6020830152565b8054806124e7575050600090600090600090565b6000199080828101116114465761250792600052602060002001016124af565b9065ffffffffffff82511691602060018060d01b0391015116906001929190565b908154906000829160058411612596575b612544935084612cd2565b8061256d57506000905b6001600160d01b038216156117f157610593916001611fe19201611993565b61258961257c61259092611437565b8360005260206000200190565b5460301c90565b9061254e565b91926125a181612b9e565b810390811161144657612544938560005265ffffffffffff80836020600020015416908516106000146125d5575091612539565b9291506125e190611458565b90612539565b604051906125f482610458565b60006020838281520152565b9061262961262361264a926126136125e7565b5061261c6125e7565b5084611993565b506124af565b91600165ffffffffffff845116936020828060d01b03910151169101611993565b9054906040519261265a84610458565b835260031b1c602082015290565b612670612b6f565b612678612b6f565b6001600080516020612d5483398151915255565b6040519061269982610478565b60006040838281528260208201520152565b81601f820112156102bd578051916020916001600160401b038411610473578360051b90604051946126df85840187610493565b855283808601928201019283116102bd578301905b828210612702575050505090565b83809183516127108161041c565b8152019101906126f4565b906020828203126102bd5781516001600160401b03928382116102bd5701908181039260a084126102bd5760606040519461275586610478565b126102bd5760405161276681610478565b83516127718161041c565b815260208401516127818161041c565b602082015260408401516127948161041c565b6040820152845260608301518181116102bd57826127b39185016126ab565b602085015260808301519081116102bd576127ce92016126ab565b604082015290565b80518210156119ab5760209160051b010190565b612806906127f661268c565b506020808251830101910161271b565b8051519091906001600160a01b03161580612932575b6129205790602081019060005b825180518210156128a35761111061284483612851936127d6565b516001600160a01b031690565b156128915761287361286f61286a6128448487516127d6565b611e04565b1590565b61287f57600101612829565b604051635140fefd60e11b8152600490fd5b6040516323cda06760e01b8152600490fd5b5060409250508181019060005b8251805182101561291757611110612844836128cb936127d6565b15612906576128e961286f6128e46128448487516127d6565b611e74565b6128f5576001016128b0565b8351635140fefd60e11b8152600490fd5b83516323cda06760e01b8152600490fd5b50509150505190565b6040516303501f5960e11b8152600490fd5b50602082015151158061281c57506040820151511561281c565b9080821015612959575090565b905090565b909182820291600019848209938380861095039480860395146129e657848311156129d45782910981600003821680920460028082600302188083028203028083028203028083028203028083028203028083028203028092029003029360018380600003040190848311900302920304170290565b60405163227bc15360e01b8152600490fd5b505090610593925061174c565b8054600160401b81101561047357612a1091600182018155611993565b612a3b57815160209092015160301b65ffffffffffff191665ffffffffffff92909216919091179055565b634e487b7160e01b600052600060045260246000fd5b805492939291908215612b4557612a72612a6d61257c85611437565b6124af565b90612a83825165ffffffffffff1690565b65ffffffffffff84811691168110612b3357611a43946020948892612ab1611b9b875165ffffffffffff1690565b03612afb5750612aed92612ac7612ad492611437565b9060005260206000200190565b9065ffffffffffff82549181199060301b169116179055565b01516001600160d01b031690565b915050612b2e91612b1b612b0d6104d3565b65ffffffffffff9093168352565b6001600160d01b038816828601526129f3565b612aed565b604051632520601d60e01b8152600490fd5b612b699250612b55612b0d6104d3565b6001600160d01b03851660208301526129f3565b60009190565b60ff600080516020612d748339815191525460401c1615612b8c57565b604051631afcd79f60e31b8152600490fd5b80156115b3578061235f612c6a612c60612c56612c4c612c42612c38612c2e60016105939a6000908b60801c80612cc6575b508060401c80612cb9575b508060201c80612cac575b508060101c80612c9f575b508060081c80612c92575b508060041c80612c85575b508060021c80612c78575b50821c612c71575b811c1b612c27818b61174c565b0160011c90565b612c27818a61174c565b612c27818961174c565b612c27818861174c565b612c27818761174c565b612c27818661174c565b612c27818561174c565b809261174c565b8101612c1a565b6002915091019038612c12565b6004915091019038612c07565b6008915091019038612bfc565b6010915091019038612bf1565b6020915091019038612be6565b6040915091019038612bdb565b91505060809038612bd0565b91905b838210612ce25750505090565b9091928083169080841860011c82018092116114465760008581526020902082015465ffffffffffff9081169084161015612d215750925b9190612cd5565b939250612d2d90611458565b91612d1a56fe02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268009b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00a2646970667358221220ed0b9f601fd23e22c77520bccb40c884385a55386b3e90213263e53be0769eac64736f6c63430008190033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000007d03b7343bf8d5cec7c0c27ece084a20113d15c9000000000000000000000000407a039d94948484d356efb765b3c74382a050b400000000000000000000000095cc0a052ae33941877c9619835a233d21d5735100000000000000000000000058973d16ffa900d11fc22e5e2b6840d9f7e13401000000000000000000000000890ca3f95e0f40a79885b7400926544b2214b03f0000000000000000000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : networkRegistry (address): 0x7d03b7343BF8d5cEC7C0C27ecE084a20113D15C9
Arg [1] : vaultFactory (address): 0x407A039D94948484D356eFB765b3c74382A050B4
Arg [2] : operatorVaultOptInService (address): 0x95CC0a052ae33941877c9619835A233D21D57351
Arg [3] : operatorNetworkOptInService (address): 0x58973d16FFA900D11fC22e5e2B6840d9f7e13401
Arg [4] : delegatorFactory (address): 0x890CA3f95E0f40a79885B7400926544B2214B03f
Arg [5] : entityType (uint64): 0
-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 0000000000000000000000007d03b7343bf8d5cec7c0c27ece084a20113d15c9
Arg [1] : 000000000000000000000000407a039d94948484d356efb765b3c74382a050b4
Arg [2] : 00000000000000000000000095cc0a052ae33941877c9619835a233d21d57351
Arg [3] : 00000000000000000000000058973d16ffa900d11fc22e5e2b6840d9f7e13401
Arg [4] : 000000000000000000000000890ca3f95e0f40a79885b7400926544b2214b03f
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000000
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.