Source Code
Overview
ETH Balance
0 ETH
More Info
ContractCreator
Multichain Info
N/A
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
0x61012034 | 2072257 | 64 days ago | IN | 0 ETH | 0.00001672 |
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:
VetoSlasher
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 {BaseSlasher} from "./BaseSlasher.sol"; import {IBaseDelegator} from "src/interfaces/delegator/IBaseDelegator.sol"; import {IRegistry} from "src/interfaces/common/IRegistry.sol"; import {IVault} from "src/interfaces/vault/IVault.sol"; import {IVetoSlasher} from "src/interfaces/slasher/IVetoSlasher.sol"; import {Checkpoints} from "src/contracts/libraries/Checkpoints.sol"; import {Subnetwork} from "src/contracts/libraries/Subnetwork.sol"; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol"; import {Time} from "@openzeppelin/contracts/utils/types/Time.sol"; contract VetoSlasher is BaseSlasher, IVetoSlasher { using Math for uint256; using SafeCast for uint256; using Checkpoints for Checkpoints.Trace208; using Subnetwork for address; /** * @inheritdoc IVetoSlasher */ address public immutable NETWORK_REGISTRY; /** * @inheritdoc IVetoSlasher */ SlashRequest[] public slashRequests; /** * @inheritdoc IVetoSlasher */ uint48 public vetoDuration; /** * @inheritdoc IVetoSlasher */ uint256 public resolverSetEpochsDelay; mapping(bytes32 subnetwork => Checkpoints.Trace208 value) internal _resolver; constructor( address vaultFactory, address networkMiddlewareService, address networkRegistry, address slasherFactory, uint64 entityType ) BaseSlasher(vaultFactory, networkMiddlewareService, slasherFactory, entityType) { NETWORK_REGISTRY = networkRegistry; } /** * @inheritdoc IVetoSlasher */ function slashRequestsLength() external view returns (uint256) { return slashRequests.length; } /** * @inheritdoc IVetoSlasher */ function resolverAt(bytes32 subnetwork, uint48 timestamp, bytes memory hint) public view returns (address) { return address(uint160(_resolver[subnetwork].upperLookupRecent(timestamp, hint))); } /** * @inheritdoc IVetoSlasher */ function resolver(bytes32 subnetwork, bytes memory hint) public view returns (address) { return resolverAt(subnetwork, Time.timestamp(), hint); } /** * @inheritdoc IVetoSlasher */ function requestSlash( bytes32 subnetwork, address operator, uint256 amount, uint48 captureTimestamp, bytes calldata hints ) external onlyNetworkMiddleware(subnetwork) returns (uint256 slashIndex) { RequestSlashHints memory requestSlashHints; if (hints.length > 0) { requestSlashHints = abi.decode(hints, (RequestSlashHints)); } if ( captureTimestamp < Time.timestamp() + vetoDuration - IVault(vault).epochDuration() || captureTimestamp >= Time.timestamp() ) { revert InvalidCaptureTimestamp(); } _checkLatestSlashedCaptureTimestamp(subnetwork, captureTimestamp); amount = Math.min( amount, slashableStake(subnetwork, operator, captureTimestamp, requestSlashHints.slashableStakeHints) ); if (amount == 0) { revert InsufficientSlash(); } uint48 vetoDeadline = Time.timestamp() + vetoDuration; slashIndex = slashRequests.length; slashRequests.push( SlashRequest({ subnetwork: subnetwork, operator: operator, amount: amount, captureTimestamp: captureTimestamp, vetoDeadline: vetoDeadline, completed: false }) ); emit RequestSlash(slashIndex, subnetwork, operator, amount, captureTimestamp, vetoDeadline); } /** * @inheritdoc IVetoSlasher */ function executeSlash(uint256 slashIndex, bytes calldata hints) external returns (uint256 slashedAmount) { ExecuteSlashHints memory executeSlashHints; if (hints.length > 0) { executeSlashHints = abi.decode(hints, (ExecuteSlashHints)); } if (slashIndex >= slashRequests.length) { revert SlashRequestNotExist(); } SlashRequest storage request = slashRequests[slashIndex]; if ( request.vetoDeadline > Time.timestamp() && resolverAt(request.subnetwork, request.captureTimestamp, executeSlashHints.resolverHint) != address(0) ) { revert VetoPeriodNotEnded(); } address vault_ = vault; if (Time.timestamp() - request.captureTimestamp > IVault(vault_).epochDuration()) { revert SlashPeriodEnded(); } _checkLatestSlashedCaptureTimestamp(request.subnetwork, request.captureTimestamp); if (request.completed) { revert SlashRequestCompleted(); } request.completed = true; if (latestSlashedCaptureTimestamp[request.subnetwork] < request.captureTimestamp) { latestSlashedCaptureTimestamp[request.subnetwork] = request.captureTimestamp; } slashedAmount = Math.min( request.amount, slashableStake( request.subnetwork, request.operator, request.captureTimestamp, executeSlashHints.slashableStakeHints ) ); if (slashedAmount > 0) { _updateCumulativeSlash(request.subnetwork, request.operator, slashedAmount); } IBaseDelegator(IVault(vault_).delegator()).onSlash( request.subnetwork, request.operator, slashedAmount, request.captureTimestamp, abi.encode(slashIndex) ); if (slashedAmount > 0) { IVault(vault_).onSlash(slashedAmount, request.captureTimestamp); } emit ExecuteSlash(slashIndex, slashedAmount); } /** * @inheritdoc IVetoSlasher */ function vetoSlash(uint256 slashIndex, bytes calldata hints) external { VetoSlashHints memory vetoSlashHints; if (hints.length > 0) { vetoSlashHints = abi.decode(hints, (VetoSlashHints)); } if (slashIndex >= slashRequests.length) { revert SlashRequestNotExist(); } SlashRequest storage request = slashRequests[slashIndex]; if (msg.sender != resolverAt(request.subnetwork, request.captureTimestamp, vetoSlashHints.resolverHint)) { revert NotResolver(); } if (request.vetoDeadline <= Time.timestamp()) { revert VetoPeriodEnded(); } if (request.completed) { revert SlashRequestCompleted(); } request.completed = true; emit VetoSlash(slashIndex, msg.sender); } function setResolver(uint96 identifier, address resolver_, bytes calldata hints) external { SetResolverHints memory setResolverHints; if (hints.length > 0) { setResolverHints = abi.decode(hints, (SetResolverHints)); } if (!IRegistry(NETWORK_REGISTRY).isEntity(msg.sender)) { revert NotNetwork(); } address vault_ = vault; bytes32 subnetwork = (msg.sender).subnetwork(identifier); uint48 timestamp = resolver(subnetwork, setResolverHints.resolverHint) == address(0) ? Time.timestamp() : (IVault(vault_).currentEpochStart() + resolverSetEpochsDelay * IVault(vault_).epochDuration()).toUint48(); (, uint48 latestTimestamp,) = _resolver[subnetwork].latestCheckpoint(); if (latestTimestamp > Time.timestamp()) { _resolver[subnetwork].pop(); } _resolver[subnetwork].push(timestamp, uint160(resolver_)); emit SetResolver(subnetwork, resolver_); } function ___initialize(address vault_, bytes memory data) internal override { (InitParams memory params) = abi.decode(data, (InitParams)); uint48 epochDuration = IVault(vault_).epochDuration(); if (epochDuration == 0) { revert VaultNotInitialized(); } if (params.vetoDuration >= epochDuration) { revert InvalidVetoDuration(); } if (params.resolverSetEpochsDelay < 3) { revert InvalidResolverSetEpochsDelay(); } vetoDuration = params.vetoDuration; resolverSetEpochsDelay = params.resolverSetEpochsDelay; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.25; import {Entity} from "src/contracts/common/Entity.sol"; import {StaticDelegateCallable} from "src/contracts/common/StaticDelegateCallable.sol"; import {IBaseDelegator} from "src/interfaces/delegator/IBaseDelegator.sol"; import {IBaseSlasher} from "src/interfaces/slasher/IBaseSlasher.sol"; import {INetworkMiddlewareService} from "src/interfaces/service/INetworkMiddlewareService.sol"; import {IRegistry} from "src/interfaces/common/IRegistry.sol"; import {IVault} from "src/interfaces/vault/IVault.sol"; import {Checkpoints} from "src/contracts/libraries/Checkpoints.sol"; import {Subnetwork} from "src/contracts/libraries/Subnetwork.sol"; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {Time} from "@openzeppelin/contracts/utils/types/Time.sol"; abstract contract BaseSlasher is Entity, StaticDelegateCallable, IBaseSlasher { using Checkpoints for Checkpoints.Trace256; using Subnetwork for bytes32; /** * @inheritdoc IBaseSlasher */ address public immutable VAULT_FACTORY; /** * @inheritdoc IBaseSlasher */ address public immutable NETWORK_MIDDLEWARE_SERVICE; /** * @inheritdoc IBaseSlasher */ address public vault; /** * @inheritdoc IBaseSlasher */ mapping(bytes32 subnetwork => uint48 value) public latestSlashedCaptureTimestamp; mapping(bytes32 subnetwork => mapping(address operator => Checkpoints.Trace256 amount)) internal _cumulativeSlash; modifier onlyNetworkMiddleware(bytes32 subnetwork) { if (INetworkMiddlewareService(NETWORK_MIDDLEWARE_SERVICE).middleware(subnetwork.network()) != msg.sender) { revert NotNetworkMiddleware(); } _; } constructor( address vaultFactory, address networkMiddlewareService, address slasherFactory, uint64 entityType ) Entity(slasherFactory, entityType) { VAULT_FACTORY = vaultFactory; NETWORK_MIDDLEWARE_SERVICE = networkMiddlewareService; } /** * @inheritdoc IBaseSlasher */ function cumulativeSlashAt( bytes32 subnetwork, address operator, uint48 timestamp, bytes memory hint ) public view returns (uint256) { return _cumulativeSlash[subnetwork][operator].upperLookupRecent(timestamp, hint); } /** * @inheritdoc IBaseSlasher */ function cumulativeSlash(bytes32 subnetwork, address operator) public view returns (uint256) { return _cumulativeSlash[subnetwork][operator].latest(); } /** * @inheritdoc IBaseSlasher */ function slashableStake( bytes32 subnetwork, address operator, uint48 captureTimestamp, bytes memory hints ) public view returns (uint256) { SlashableStakeHints memory slashableStakeHints; if (hints.length > 0) { slashableStakeHints = abi.decode(hints, (SlashableStakeHints)); } if (captureTimestamp < Time.timestamp() - IVault(vault).epochDuration() || captureTimestamp >= Time.timestamp()) { return 0; } uint256 stakeAmount = IBaseDelegator(IVault(vault).delegator()).stakeAt( subnetwork, operator, captureTimestamp, slashableStakeHints.stakeHints ); return stakeAmount - Math.min( cumulativeSlash(subnetwork, operator) - cumulativeSlashAt(subnetwork, operator, captureTimestamp, slashableStakeHints.cumulativeSlashFromHint), stakeAmount ); } function _checkLatestSlashedCaptureTimestamp(bytes32 subnetwork, uint48 captureTimestamp) internal view { if (captureTimestamp < latestSlashedCaptureTimestamp[subnetwork]) { revert OutdatedCaptureTimestamp(); } } function _updateCumulativeSlash(bytes32 subnetwork, address operator, uint256 amount) internal { _cumulativeSlash[subnetwork][operator].push(Time.timestamp(), cumulativeSlash(subnetwork, operator) + amount); } 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(); } vault = vault_; ___initialize(vault_, data_); } function ___initialize(address vault_, bytes memory data) internal virtual {} }
pragma solidity 0.8.25; interface IBaseDelegator { error AlreadySet(); 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 happened. * @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier) * @param operator address of the operator * @param slashedAmount amount of the collateral slashed */ event OnSlash(bytes32 indexed subnetwork, address indexed operator, uint256 slashedAmount); /** * @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); 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 slashedAmount 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 slashedAmount, uint48 captureTimestamp, bytes calldata data ) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.25; 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: BUSL-1.1 pragma solidity 0.8.25; import {IVaultStorage} from "./IVaultStorage.sol"; interface IVault is IVaultStorage { error AlreadyClaimed(); error AlreadySet(); error InsufficientClaim(); error InsufficientDeposit(); error InsufficientWithdrawal(); error InvalidAccount(); error InvalidCaptureEpoch(); error InvalidClaimer(); error InvalidCollateral(); error InvalidEpoch(); error InvalidEpochDuration(); error InvalidLengthEpochs(); error InvalidOnBehalfOf(); error InvalidRecipient(); error MissingRoles(); error NoDepositWhitelist(); error NotDelegator(); error NotSlasher(); error NotWhitelistedDepositor(); error TooMuchWithdraw(); /** * @notice Initial parameters needed for a vault deployment. * @param collateral vault's underlying collateral * @param delegator vault's delegator to delegate the stake to networks and operators * @param slasher vault's slasher to provide a slashing mechanism to networks * @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 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 */ struct InitParams { address collateral; address delegator; address slasher; address burner; uint48 epochDuration; bool depositWhitelist; address defaultAdminRoleHolder; address depositWhitelistSetRoleHolder; address depositorWhitelistRoleHolder; } /** * @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 happened. * @param slasher address of the slasher * @param slashedAmount amount of the collateral slashed */ event OnSlash(address indexed slasher, uint256 slashedAmount); /** * @notice Emitted when a deposit whitelist status is enabled/disabled. * @param depositWhitelist if enabled deposit whitelist */ event SetDepositWhitelist(bool depositWhitelist); /** * @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 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. * @return total amount of the slashable collateral */ function balanceOf(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 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 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 slashedAmount amount to slash * @param captureTimestamp time point when the stake was captured * @dev Only the slasher can call this function. */ function onSlash(uint256 slashedAmount, uint48 captureTimestamp) external; /** * @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; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.25; interface IVetoSlasher { error InsufficientSlash(); error InvalidCaptureTimestamp(); error InvalidResolverSetEpochsDelay(); error InvalidVetoDuration(); error NotNetwork(); error NotResolver(); error SlashPeriodEnded(); error SlashRequestCompleted(); error SlashRequestNotExist(); error VaultNotInitialized(); error VetoPeriodEnded(); error VetoPeriodNotEnded(); /** * @notice Initial parameters needed for a slasher deployment. * @param vetoDuration duration of the veto period for a slash request * @param resolverSetEpochsDelay delay in epochs for a network to update a resolver */ struct InitParams { uint48 vetoDuration; uint256 resolverSetEpochsDelay; } /** * @notice Structure for a slash request. * @param subnetwork subnetwork that requested the slash * @param operator operator that could be slashed (if the request is not vetoed) * @param amount maximum amount of the collateral to be slashed * @param captureTimestamp time point when the stake was captured * @param vetoDeadline deadline for the resolver to veto the slash (exclusively) * @param completed if the slash was vetoed/executed */ struct SlashRequest { bytes32 subnetwork; address operator; uint256 amount; uint48 captureTimestamp; uint48 vetoDeadline; bool completed; } /** * @notice Hints for a slash request. * @param slashableStakeHints hints for the slashable stake checkpoints */ struct RequestSlashHints { bytes slashableStakeHints; } /** * @notice Hints for a slash execute. * @param resolverHint hint for the resolver checkpoint * @param slashableStakeHints hints for the slashable stake checkpoints */ struct ExecuteSlashHints { bytes resolverHint; bytes slashableStakeHints; } /** * @notice Hints for a slash veto. * @param resolverHint hint for the resolver checkpoint */ struct VetoSlashHints { bytes resolverHint; } /** * @notice Hints for a resolver set. * @param resolverHint hint for the resolver checkpoint */ struct SetResolverHints { bytes resolverHint; } /** * @notice Emitted when a slash request is created. * @param slashIndex index of the slash request * @param subnetwork subnetwork that requested the slash * @param operator operator that could be slashed (if the request is not vetoed) * @param slashAmount maximum amount of the collateral to be slashed * @param captureTimestamp time point when the stake was captured * @param vetoDeadline deadline for the resolver to veto the slash (exclusively) */ event RequestSlash( uint256 indexed slashIndex, bytes32 indexed subnetwork, address indexed operator, uint256 slashAmount, uint48 captureTimestamp, uint48 vetoDeadline ); /** * @notice Emitted when a slash request is executed. * @param slashIndex index of the slash request * @param slashedAmount amount of the collateral slashed */ event ExecuteSlash(uint256 indexed slashIndex, uint256 slashedAmount); /** * @notice Emitted when a slash request is vetoed. * @param slashIndex index of the slash request * @param resolver address of the resolver that vetoed the slash */ event VetoSlash(uint256 indexed slashIndex, address indexed resolver); /** * @notice Emitted when a resolver is set. * @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier) * @param resolver address of the resolver */ event SetResolver(bytes32 indexed subnetwork, address resolver); /** * @notice Get the network registry's address. * @return address of the network registry */ function NETWORK_REGISTRY() external view returns (address); /** * @notice Get a duration during which resolvers can veto slash requests. * @return duration of the veto period */ function vetoDuration() external view returns (uint48); /** * @notice Get a total number of slash requests. * @return total number of slash requests */ function slashRequestsLength() external view returns (uint256); /** * @notice Get a particular slash request. * @param slashIndex index of the slash request * @return subnetwork subnetwork that requested the slash * @return operator operator that could be slashed (if the request is not vetoed) * @return amount maximum amount of the collateral to be slashed * @return captureTimestamp time point when the stake was captured * @return vetoDeadline deadline for the resolver to veto the slash (exclusively) * @return completed if the slash was vetoed/executed */ function slashRequests(uint256 slashIndex) external view returns ( bytes32 subnetwork, address operator, uint256 amount, uint48 captureTimestamp, uint48 vetoDeadline, bool completed ); /** * @notice Get a delay for networks in epochs to update a resolver. * @return updating resolver delay in epochs */ function resolverSetEpochsDelay() external view returns (uint256); /** * @notice Get a resolver for a given subnetwork at a particular timestamp using a hint. * @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier) * @param timestamp timestamp to get the resolver at * @param hints hints for the checkpoint index * @return address of the resolver */ function resolverAt(bytes32 subnetwork, uint48 timestamp, bytes memory hints) external view returns (address); /** * @notice Get a resolver for a given subnetwork using a hint. * @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier) * @param hint hint for the checkpoint index * @return address of the resolver */ function resolver(bytes32 subnetwork, bytes memory hint) external view returns (address); /** * @notice Request a slash using a subnetwork for a particular operator by a given amount using hints. * @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier) * @param operator address of the operator * @param amount maximum amount of the collateral to be slashed * @param captureTimestamp time point when the stake was captured * @param hints hints for checkpoints' indexes * @return slashIndex index of the slash request * @dev Only network middleware can call this function. */ function requestSlash( bytes32 subnetwork, address operator, uint256 amount, uint48 captureTimestamp, bytes calldata hints ) external returns (uint256 slashIndex); /** * @notice Execute a slash with a given slash index using hints. * @param slashIndex index of the slash request * @param hints hints for checkpoints' indexes * @return slashedAmount amount of the collateral slashed * @dev Anyone can call this function. */ function executeSlash(uint256 slashIndex, bytes calldata hints) external returns (uint256 slashedAmount); /** * @notice Veto a slash with a given slash index using hints. * @param slashIndex index of the slash request * @param hints hints for checkpoints' indexes * @dev Only a resolver can call this function. */ function vetoSlash(uint256 slashIndex, bytes calldata hints) external; /** * @notice Set a resolver for a subnetwork using hints. * identifier identifier of the subnetwork * @param resolver address of the resolver * @param hints hints for checkpoints' indexes * @dev Only a network can call this function. */ function setResolver(uint96 identifier, address resolver, bytes calldata hints) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.25; 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); } uint256 len = self._values.length; self._trace.push(key, uint208(len)); self._values.push(value); return (self._values[len - 1], 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, self._values[checkpoint._value], hint); } if (checkpoint._key < key && (hint == length(self) - 1 || at(self, hint + 1)._key > key)) { return (true, checkpoint._key, self._values[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(); } /** * @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, 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 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: BUSL-1.1 pragma solidity 0.8.25; /** * @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) (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/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) (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 "src/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) internal virtual {} }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.25; abstract contract StaticDelegateCallable { 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: BUSL-1.1 pragma solidity 0.8.25; interface IBaseSlasher { error NotNetworkMiddleware(); error NotVault(); error OutdatedCaptureTimestamp(); /** * @notice Hints for a slashable stake. * @param stakeHints hints for the stake checkpoints * @param cumulativeSlashFromHint hint for the cumulative slash amount at a capture timestamp */ struct SlashableStakeHints { bytes stakeHints; bytes cumulativeSlashFromHint; } /** * @notice Get the vault factory's address. * @return address of the vault factory */ function VAULT_FACTORY() external view returns (address); /** * @notice Get the network middleware service's address. * @return address of the network middleware service */ function NETWORK_MIDDLEWARE_SERVICE() external view returns (address); /** * @notice Get the vault's address. * @return address of the vault to perform slashings on */ function vault() external view returns (address); /** * @notice Get the latest capture timestamp that was slashed on a subnetwork. * @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier) * @return latest capture timestamp that was slashed */ function latestSlashedCaptureTimestamp(bytes32 subnetwork) external view returns (uint48); /** * @notice Get a cumulative slash amount for an operator on a subnetwork until a given timestamp (inclusively) using a hint. * @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 cumulative slash amount until (inclusively) * @param hint hint for the checkpoint index * @return cumulative slash amount until the given timestamp (inclusively) */ function cumulativeSlashAt( bytes32 subnetwork, address operator, uint48 timestamp, bytes memory hint ) external view returns (uint256); /** * @notice Get a cumulative slash amount for an operator on a subnetwork. * @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier) * @param operator address of the operator * @return cumulative slash amount */ function cumulativeSlash(bytes32 subnetwork, address operator) external view returns (uint256); /** * @notice Get a slashable amount of a stake got at a given capture timestamp using hints. * @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier) * @param operator address of the operator * @param captureTimestamp time point to get the stake amount at * @param hints hints for the checkpoints' indexes * @return slashable amount of the stake */ function slashableStake( bytes32 subnetwork, address operator, uint48 captureTimestamp, bytes memory hints ) external view returns (uint256); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.25; interface INetworkMiddlewareService { error AlreadySet(); error NotNetwork(); /** * @notice Emitted when a middleware is set for a network. * @param network address of the network * @param middleware new middleware of the network */ event SetMiddleware(address indexed network, address middleware); /** * @notice Get the network registry's address. * @return address of the network registry */ function NETWORK_REGISTRY() external view returns (address); /** * @notice Get a given network's middleware. * @param network address of the network * @return middleware of the network */ function middleware(address network) external view returns (address); /** * @notice Set a new middleware for a calling network. * @param middleware new middleware of the network */ function setMiddleware(address middleware) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.25; 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 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); /** * @dev 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 a slasher (it provides networks a slashing mechanism). * @return address of the slasher */ function slasher() external view returns (address); /** * @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 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: BUSL-1.1 pragma solidity 0.8.25; interface IEntity { /** * @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 // 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 } } }
{ "remappings": [ "forge-std/=lib/forge-std/src/", "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", "ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/", "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/", "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":"vaultFactory","type":"address"},{"internalType":"address","name":"networkMiddlewareService","type":"address"},{"internalType":"address","name":"networkRegistry","type":"address"},{"internalType":"address","name":"slasherFactory","type":"address"},{"internalType":"uint64","name":"entityType","type":"uint64"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"CheckpointUnorderedInsertion","type":"error"},{"inputs":[],"name":"InsufficientSlash","type":"error"},{"inputs":[],"name":"InvalidCaptureTimestamp","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"InvalidResolverSetEpochsDelay","type":"error"},{"inputs":[],"name":"InvalidVetoDuration","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"NotNetwork","type":"error"},{"inputs":[],"name":"NotNetworkMiddleware","type":"error"},{"inputs":[],"name":"NotResolver","type":"error"},{"inputs":[],"name":"NotVault","type":"error"},{"inputs":[],"name":"OutdatedCaptureTimestamp","type":"error"},{"inputs":[{"internalType":"uint8","name":"bits","type":"uint8"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"SafeCastOverflowedUintDowncast","type":"error"},{"inputs":[],"name":"SlashPeriodEnded","type":"error"},{"inputs":[],"name":"SlashRequestCompleted","type":"error"},{"inputs":[],"name":"SlashRequestNotExist","type":"error"},{"inputs":[],"name":"VaultNotInitialized","type":"error"},{"inputs":[],"name":"VetoPeriodEnded","type":"error"},{"inputs":[],"name":"VetoPeriodNotEnded","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"slashIndex","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"slashedAmount","type":"uint256"}],"name":"ExecuteSlash","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"slashIndex","type":"uint256"},{"indexed":true,"internalType":"bytes32","name":"subnetwork","type":"bytes32"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"uint256","name":"slashAmount","type":"uint256"},{"indexed":false,"internalType":"uint48","name":"captureTimestamp","type":"uint48"},{"indexed":false,"internalType":"uint48","name":"vetoDeadline","type":"uint48"}],"name":"RequestSlash","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"subnetwork","type":"bytes32"},{"indexed":false,"internalType":"address","name":"resolver","type":"address"}],"name":"SetResolver","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"slashIndex","type":"uint256"},{"indexed":true,"internalType":"address","name":"resolver","type":"address"}],"name":"VetoSlash","type":"event"},{"inputs":[],"name":"FACTORY","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NETWORK_MIDDLEWARE_SERVICE","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NETWORK_REGISTRY","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":[{"internalType":"bytes32","name":"subnetwork","type":"bytes32"},{"internalType":"address","name":"operator","type":"address"}],"name":"cumulativeSlash","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":"cumulativeSlashAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"slashIndex","type":"uint256"},{"internalType":"bytes","name":"hints","type":"bytes"}],"name":"executeSlash","outputs":[{"internalType":"uint256","name":"slashedAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"data","type":"bytes"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"subnetwork","type":"bytes32"}],"name":"latestSlashedCaptureTimestamp","outputs":[{"internalType":"uint48","name":"value","type":"uint48"}],"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":"hints","type":"bytes"}],"name":"requestSlash","outputs":[{"internalType":"uint256","name":"slashIndex","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"subnetwork","type":"bytes32"},{"internalType":"bytes","name":"hint","type":"bytes"}],"name":"resolver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"subnetwork","type":"bytes32"},{"internalType":"uint48","name":"timestamp","type":"uint48"},{"internalType":"bytes","name":"hint","type":"bytes"}],"name":"resolverAt","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"resolverSetEpochsDelay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint96","name":"identifier","type":"uint96"},{"internalType":"address","name":"resolver_","type":"address"},{"internalType":"bytes","name":"hints","type":"bytes"}],"name":"setResolver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"slashRequests","outputs":[{"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":"uint48","name":"vetoDeadline","type":"uint48"},{"internalType":"bool","name":"completed","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"slashRequestsLength","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":"captureTimestamp","type":"uint48"},{"internalType":"bytes","name":"hints","type":"bytes"}],"name":"slashableStake","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":[],"name":"vault","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vetoDuration","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"slashIndex","type":"uint256"},{"internalType":"bytes","name":"hints","type":"bytes"}],"name":"vetoSlash","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
6101203461017057601f61292438819003918201601f19168301916001600160401b039182841185851017610175578160a092869260409687528339810103126101705761004c8361018b565b6100586020850161018b565b9161006484860161018b565b9460806100736060830161018b565b910151918083168303610170577ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a009081549060ff82891c1661015f57808083160361011b575b50505060805260a05260c05260e0526101009182525161278491826101a0833960805182610295015260a05182611103015260c0518281816101a20152611d9b015260e05182818161025001526106310152518181816107c1015261115b0152f35b6001600160401b0319909116811790915585519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a13880806100b9565b875163f92ee8a960e01b8152600490fd5b600080fd5b634e487b7160e01b600052604160045260246000fd5b51906001600160a01b03821682036101705756fe6080604052600436101561001257600080fd5b60003560e01c8063103f2907146101775780631a2be2c4146101725780632c9d45b31461016d5780632dd310001461016857806331ce4dfe14610163578063439fab911461015e578063545ce3891461015957806362a01e8d146101545780638f42f9ab1461014f5780639168f9d21461014a5780639a896551146101455780639f86fd8514610140578063aa8e64891461013b578063aab3595f14610136578063b94c386e14610131578063bb24fe8a1461012c578063bc6eac5b14610127578063c0cd7c3e14610122578063cd05b8a11461011d578063e054e08b14610118578063f9268d18146101135763fbfa77cf1461010e57600080fd5b611316565b611208565b6111e2565b61118a565b611145565b611127565b6110e3565b610ce9565b610c9a565b610c58565b610b50565b610ac5565b61072b565b61070d565b6106d9565b6105bc565b610480565b6103e9565b61027f565b61023a565b6101e2565b61018c565b600091031261018757565b600080fd5b34610187576000366003190112610187576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b6001600160a01b0381160361018757565b3461018757604036600319011261018757602061023261022d602435610207816101d1565b6004356000526002845260406000209060018060a01b0316600052602052604060002090565b611be4565b604051908152f35b34610187576000366003190112610187576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b34610187576000366003190112610187576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b65ffffffffffff81160361018757565b634e487b7160e01b600052604160045260246000fd5b6001600160401b0381116102fd57604052565b6102d4565b602081019081106001600160401b038211176102fd57604052565b604081019081106001600160401b038211176102fd57604052565b90601f801991011681019081106001600160401b038211176102fd57604052565b6040519060c082018281106001600160401b038211176102fd57604052565b604051906103858261031d565b565b6001600160401b0381116102fd57601f01601f191660200190565b81601f82011215610187578035906103b982610387565b926103c76040519485610338565b8284526020838301011161018757816000926020809301838601378301015290565b3461018757606036600319011261018757602435610406816102c4565b604435906001600160401b0382116101875761044a61042b60209336906004016103a2565b600435600090815260068552604090206001600160a01b039390611c4a565b16604051908152f35b9181601f84011215610187578235916001600160401b038311610187576020838186019501011161018757565b34610187576020366003190112610187576001600160401b03600435818111610187576104b1903690600401610453565b60008051602061272f833981519152549260ff8460401c16159316801590816105b4575b60011490816105aa575b1590816105a1575b5061058f5760008051602061272f833981519152805467ffffffffffffffff1916600117905561051b918361056a57611d38565b61052157005b60008051602061272f833981519152805460ff60401b19169055604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a1005b60008051602061272f833981519152805460ff60401b1916600160401b179055611d38565b60405163f92ee8a960e01b8152600490fd5b905015386104e7565b303b1591506104df565b8491506104d5565b346101875760a0366003190112610187576004356024356105dc816101d1565b6064356105e8816102c4565b6084356001600160401b03811161018757610607903690600401610453565b604051635daf681960e11b8152606086901c60048201529092906001600160a01b036020826024817f000000000000000000000000000000000000000000000000000000000000000085165afa9182156106d4576000926106a3575b50339116036106915761068d9461067d9460443591611546565b6040519081529081906020820190565b0390f35b60405163227bf64d60e01b8152600490fd5b6106c691925060203d6020116106cd575b6106be8183610338565b810190611365565b9038610663565b503d6106b4565b61137a565b34610187576020366003190112610187576004356000526001602052602065ffffffffffff60406000205416604051908152f35b34610187576000366003190112610187576020600354604051908152f35b3461018757606036600319011261018757600480356bffffffffffffffffffffffff8116810361018757602435610761816101d1565b6044356001600160401b0381116101875761077f9036908501610453565b9390610789611386565b9480610a5a575b50506040516302910f8b60e31b8152338282019081526001600160a01b0394602092909183908290819083010381897f0000000000000000000000000000000000000000000000000000000000000000165afa9081156106d457600091610a2d575b5015610a1c57600054859061083c90610834906001600160a01b0316936bffffffffffffffffffffffff166bffffffffffffffffffffffff193360601b161790565b975188611bb8565b1661091b575050506108f4906108d87f7b0b759b513b299fd2811f51926dca8854222a675557e8d544ce0933bf5b75709361087642611e6b565b61089261088d886000526006602052604060002090565b61228b565b50905065ffffffffffff6108b36108a842611e6b565b65ffffffffffff1690565b9116116108f9575b6108cf876000526006602052604060002090565b918416916124b2565b50506040516001600160a01b0390911681529081906020820190565b0390a2005b610915610910886000526006602052604060002090565b611e9d565b506108bb565b60405163186a323160e21b815294919392908216919084868281865afa9586156106d4576000966109fd575b508460055493604051928380926327f843b560e11b82525afa9485156106d4577f7b0b759b513b299fd2811f51926dca8854222a675557e8d544ce0933bf5b7570966108f4966108d8956109c3946109be946000936109c8575b50506109b79065ffffffffffff80931690611752565b9116611773565b611e6b565b610876565b6109b792935090816109ee92903d106109f6575b6109e68183610338565b81019061141c565b9190386109a1565b503d6109dc565b610a15919650853d87116109f6576109e68183610338565b9438610947565b6040516323d53b9760e21b81528390fd5b610a4d9150833d8511610a53575b610a458183610338565b81019061173a565b386107f2565b503d610a3b565b610a68929550810190611399565b923880610790565b634e487b7160e01b600052603260045260246000fd5b600354811015610ac057600360005260021b7fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b0190600090565b610a70565b346101875760203660031901126101875760043560035481101561018757610aec90610a86565b50805460018201546002830154600390930154604080519384526001600160a01b0390921660208401529082019290925265ffffffffffff808316606080840191909152603084901c90911660808301529190911c60ff16151560a082015260c090f35b346101875760408060031936011261018757600435610b6e816101d1565b602435906001600160401b0382116101875760008091610b95610bfa943690600401610453565b908187519283928337810184815203915af43d15610c0257610bec3d610bba81610387565b90610bc786519283610338565b81523d6000602083013e5b8451948593151560208501528084015260608301906117a3565b03601f198101835282610338565b805190602001fd5b610bec6060610bd2565b9060806003198301126101875760043591602435610c29816101d1565b91604435610c36816102c4565b91606435906001600160401b03821161018757610c55916004016103a2565b90565b34610187576020610232610c95610c6e36610c0c565b939190926000526002865260406000209060018060a01b0316600052602052604060002090565b611ee0565b34610187576020610232610cad36610c0c565b9291909161191d565b9060406003198301126101875760043591602435906001600160401b03821161018757610ce591600401610453565b9091565b3461018757610cf736610cb6565b90610d006117f5565b91806110cf575b50506003548210156110bd57610d1c82610a86565b5090600382019283549165ffffffffffff94610d3a6108a842611e6b565b868560301c161180611099575b611087576000546001600160a01b031691610d6142611e6b565b92610d6f8887168095611431565b9060018060a01b038091169860409788519687946327f843b560e11b8652858d602097889160049c8d915afa9081156106d4578591829160009161106a575b501691161161105a5790610dc560ff928c54611e27565b60601c1661104a57845460ff60601b1916600160601b178555885490610e04610df8836000526001602052604060002090565b5465ffffffffffff1690565b865465ffffffffffff1691808316911610611013575b50506002880154885498610e626001820192610e5c8c610e40865460018060a01b031690565b988989610e538d5465ffffffffffff1690565b9201519261191d565b90611e59565b998a8015159687611002575b50508951630ce9b79360e41b81529050848189818f5afa9384156106d4578994610eae92600091610fe5575b50925493549216916001600160a01b031690565b91610edd610ec2885465ffffffffffff1690565b8b519687019586529486900380875294959460200185610338565b813b1561018757600088610f0882968e988e51998a988997889663724ab0f760e11b88528701611b80565b03925af180156106d457610fd2575b50610f5d575b5050815183815261068d94507f5cc28df3b54da9d06f805d87616ebf969c81310f2aa8369cb14ca50f815d411190602090a2519081529081906020820190565b5465ffffffffffff16853b15610187578351631c9e38c760e21b815291820185815265ffffffffffff9091166020820152909460009186919082908490829060400103925af19384156106d45761068d94610fb9575b80610f1d565b80610fc6610fcc926102ea565b8061017c565b38610fb3565b80610fc6610fdf926102ea565b38610f17565b610ffc9150873d89116106cd576106be8183610338565b38610e9a565b61100b92611fac565b388a81610e6e565b61102a611043926000526001602052604060002090565b9065ffffffffffff1665ffffffffffff19825416179055565b3880610e1a565b8751633428e90760e01b81528690fd5b8951639ea153eb60e01b81528890fd5b6110819150893d8b116109f6576109e68183610338565b38610dae565b60405163b62b15c760e01b8152600490fd5b50845482516001600160a01b03916110b59190878a169061133f565b161515610d47565b604051637822972360e11b8152600490fd5b6110dc9250810190611b1d565b3880610d07565b346101875760003660031901126101875760206040516001600160401b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b34610187576000366003190112610187576020600554604051908152f35b34610187576000366003190112610187576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b34610187576040366003190112610187576024356001600160401b038111610187576111d06111bf60209236906004016103a2565b6111c842611e6b565b60043561133f565b6040516001600160a01b039091168152f35b3461018757600036600319011261018757602065ffffffffffff60045416604051908152f35b346101875761121636610cb6565b9061121f611386565b9180611302575b50506003548210156110bd5761123b82610a86565b506003815491019161126b61125f84549365ffffffffffff9351908486169061133f565b6001600160a01b031690565b33036112f05761127d6108a842611e6b565b908260301c1611156112df5760601c60ff166112cd57805460ff60601b1916600160601b17905533907f7d3d269c851b72257a5194a401d151902e9be4347d555996dcff3ff86a077e92600080a3005b604051633428e90760e01b8152600490fd5b60405162c457e560e81b8152600490fd5b604051635d154fe160e11b8152600490fd5b61130f9250810190611399565b3880611226565b34610187576000366003190112610187576000546040516001600160a01b039091168152602090f35b60009081526006602052604090206001600160a01b0392611361929091611c4a565b1690565b908160209103126101875751610c55816101d1565b6040513d6000823e3d90fd5b6040519061139382610302565b60608252565b906020828203126101875781356001600160401b039283821161018757019060208282031261018757604051926113cf84610302565b8235908111610187576113e292016103a2565b815290565b634e487b7160e01b600052601160045260246000fd5b91909165ffffffffffff8080941691160191821161141757565b6113e7565b908160209103126101875751610c55816102c4565b65ffffffffffff918216908216039190821161141757565b634e487b7160e01b600052600060045260246000fd5b600354600160401b8110156102fd5780600161147e9201600355610a86565b919091611541578051825560208101516001830180546001600160a01b0319166001600160a01b0392909216919091179055610385916115279060a0906003906040850151600282015501926114f465ffffffffffff606083015116859065ffffffffffff1665ffffffffffff19825416179055565b60808101516bffffffffffff00000000000085549160301b16906bffffffffffff00000000000019161784550151151590565b815460ff60601b191690151560601b60ff60601b16179055565b611449565b929594909193611554611386565b9180611726575b505061156642611e6b565b9361158261157b60045465ffffffffffff1690565b80966113fd565b60005460049060209061159f9061125f906001600160a01b031681565b6040516327f843b560e11b815292839182905afa80156106d4576115cf926108a892600092611705575b50611431565b65ffffffffffff88169081109081156116ef575b506116dd57610e5c611602926115f98987611e27565b5188858761191d565b9283156116cb576116c6956116407f3cb7f4ff6cecf74cee0eb9ae3ebf8933fa60a53014cce52f96da72a78dba84649261163b42611e6b565b6113fd565b92600354978894611693611652610359565b8881526001600160a01b0385166020820152604081018a905265ffffffffffff8616606082015265ffffffffffff83166080820152600060a082015261145f565b6040805198895265ffffffffffff94851660208a01529316928701929092526001600160a01b0316949081906060820190565b0390a4565b60405163167f871760e31b8152600490fd5b604051631357ac9160e11b8152600490fd5b90506116fd6108a842611e6b565b1115386115e3565b61171f91925060203d6020116109f6576109e68183610338565b90386115c9565b6117339250810190611399565b388061155b565b90816020910312610187575180151581036101875790565b8181029291811591840414171561141757565b906001820180921161141757565b9190820180921161141757565b60005b8381106117935750506000910152565b8181015183820152602001611783565b906020916117bc81518092818552858086019101611780565b601f01601f1916010190565b60009081526002602090815260408083206001600160a01b03909416835292905220610c55929190611ee0565b604051906118028261031d565b60606020838281520152565b81601f8201121561018757805161182481610387565b926118326040519485610338565b8184526020828401011161018757610c559160208085019101611780565b906020828203126101875781516001600160401b039283821161018757019060408282031261018757604051926118868461031d565b8251818111610187578261189b91850161180e565b84526020830151908111610187576118b3920161180e565b602082015290565b90816020910312610187575190565b9081526001600160a01b03909116602082015265ffffffffffff9091166040820152608060608201819052610c55929101906117a3565b60001981019190821161141757565b9190820391821161141757565b9290926119286117f5565b91805180611b01575b505061193c42611e6b565b6000549093906119569061125f906001600160a01b031681565b94604051946327f843b560e11b865260209586816004818b5afa80156106d45761198b926108a892600092611ae95750611431565b65ffffffffffff8316908110908115611ad3575b50611ac8578460049660405197888092630ce9b79360e41b82525afa9586156106d4576119f2968691600091611aab575b5085519060405180809a819463e02f693760e01b835288888b600486016118ca565b03916001600160a01b03165afa9485156106d457610c5596600096611a68575b5083611a639383611a5d93611a5461022d611a5d9a97611a3d8d9b6000526002602052604060002090565b9060018060a01b0316600052602052604060002090565b950151926117c8565b90611910565b611e59565b611a5d9592965093611a6393611a978396611a5d943d8911611aa4575b611a8f8183610338565b8101906118bb565b9793965093509390611a12565b503d611a85565b611ac29150823d84116106cd576106be8183610338565b386119d0565b505050505050600090565b9050611ae16108a842611e6b565b11153861199f565b61171f919250893d8b116109f6576109e68183610338565b611b15929350602080918301019101611850565b903880611931565b906020828203126101875781356001600160401b03928382116101875701906040828203126101875760405192611b538461031d565b82358181116101875782611b689185016103a2565b84526020830135908111610187576118b392016103a2565b919360a093610c55969565ffffffffffff938552600180871b03166020850152604084015216606082015281608082015201906117a3565b90610c5591611bc642611e6b565b9061133f565b8054821015610ac05760005260206000200190600090565b611bed81612099565b6001600160d01b03811615611c12576001611c089201611bcc565b90549060031b1c90565b5050600090565b90816020910312610187575163ffffffff811681036101875790565b90600163ffffffff8093160191821161141757565b91805115611d2e5780602080611c6593518301019101611c19565b91611c7083826120de565b92611c81845165ffffffffffff1690565b9065ffffffffffff8085169216828114611d155782119182611cc0575b5050611cae57610c559250612382565b5050602001516001600160d01b031690565b909150611ccd8354611901565b63ffffffff831614918215611ce6575b50503880611c9e565b611d0d919250611d01611cfb6108a892611c35565b856120de565b5165ffffffffffff1690565b113880611cdd565b50505050602091909101516001600160d01b0316905090565b50610c5591612382565b9081019060408183031261018757803591611d52836101d1565b60208201356001600160401b03811161018757611d6f92016103a2565b6040516302910f8b60e31b81526001600160a01b039283166004820181905292602090829060249082907f0000000000000000000000000000000000000000000000000000000000000000165afa9081156106d457600091611e08575b5015611df657600080546001600160a01b0319166001600160a01b03841617905561038591612163565b6040516362df054560e01b8152600490fd5b611e21915060203d602011610a5357610a458183610338565b38611dcc565b600052600160205265ffffffffffff8060406000205416911610611e4757565b604051633f64d76b60e01b8152600490fd5b9080821015611e66575090565b905090565b65ffffffffffff90818111611e7e571690565b604490604051906306dfcc6560e41b8252603060048301526024820152fd5b90611ea782612099565b9180548015611eca576000190190611ebf8282611bcc565b611541576000905555565b634e487b7160e01b600052603160045260246000fd5b91805115611fa25780602080611efb93518301019101611c19565b91611f0683826122eb565b92611f17845165ffffffffffff1690565b9065ffffffffffff8085169216828114611f965782119182611f4d575b5050611f4457610c5592506122e0565b50506020015190565b909150611f5a8354611901565b63ffffffff831614918215611f73575b50503880611f34565b611f8e919250611d01611f886108a892611c35565b856122eb565b113880611f6a565b50505050506020015190565b50610c55916122e0565b9081600052600260205261200b61022d611fdc8360406000209060018060a01b0316600052602052604060002090565b92611fe642611e6b565b94600052600260205260406000209060018060a01b0316600052602052604060002090565b92830180931161141757600181019283548015612060575b508354926120479261203f916001600160d01b038616916124b2565b50508361234d565b60001981019081116114175761205c91611bcc565b5050565b600160401b8110156102fd576120479261208382600161203f9401885587611bcc565b8154906000199060031b1b191690559250612023565b8054806120a7575050600090565b60001991818381011161141757600052602060002001015460301c90565b604051906120d28261031d565b60006020838281520152565b612103916120fd916120ee6120c5565b506120f76120c5565b50611bcc565b50612267565b65ffffffffffff81511690602060018060d01b0391015116604051916121288361031d565b8252602082015290565b908160409103126101875760206040519161214c8361031d565b8051612157816102c4565b83520151602082015290565b906004815161217c602093848080948301019101612132565b6040516327f843b560e11b815290949092839182906001600160a01b03165afa80156106d45765ffffffffffff9160009161224a575b50168015612238576121cd6108a8845165ffffffffffff1690565b101561222657810160038151106122145761220e6121f4610385935165ffffffffffff1690565b65ffffffffffff1665ffffffffffff196004541617600455565b51600555565b6040516354f778f360e01b8152600490fd5b6040516367d5e3df60e11b8152600490fd5b604051639a09fd8760e01b8152600490fd5b6122619150833d85116109f6576109e68183610338565b386121b2565b906040516122748161031d565b915465ffffffffffff8116835260301c6020830152565b80548061229f575050600090600090600090565b600019908082810111611417576122bf9260005260206000200101612267565b9065ffffffffffff82511691602060018060d01b0391015116906001929190565b90611bed9082612382565b9061230e6120fd61232f926122fe6120c5565b506123076120c5565b5084611bcc565b91600165ffffffffffff845116936020828060d01b03910151169101611bcc565b9054906040519261233f8461031d565b835260031b1c602082015290565b8054600160401b8110156102fd5761236a91600182018155611bcc565b819291549060031b91821b91600019901b1916179055565b90815490600091806005811161241f575b50915b8281106123cf575050806123ab575050600090565b610c55916123bb6123c892611901565b9060005260206000200190565b5460301c90565b90918082169080831860011c8201809211611417578460005265ffffffffffff808360206000200154169085161060001461240d5750915b90612396565b92915061241990611765565b90612407565b90612429826125f4565b8203918211611417578460005265ffffffffffff808360206000200154169084161060001461245a57505b38612393565b925061246590611765565b91612454565b8054600160401b8110156102fd5761248891600182018155611bcc565b61154157815160209092015160301b65ffffffffffff191665ffffffffffff909216919091179055565b8054929392919082156125aa576124e06124db6124ce85611901565b8360005260206000200190565b612267565b906124f1825165ffffffffffff1690565b65ffffffffffff848116911681106125985761255c94602094889261251f6108a8875165ffffffffffff1690565b03612560575061254e926123bb61253592611901565b9065ffffffffffff82549181199060301b169116179055565b01516001600160d01b031690565b9190565b91505061259391612580612572610378565b65ffffffffffff9093168352565b6001600160d01b0388168286015261246b565b61254e565b604051632520601d60e01b8152600490fd5b6125ce92506125ba612572610378565b6001600160d01b038516602083015261246b565b60009190565b81156125de570490565b634e487b7160e01b600052601260045260246000fd5b80156127285780610e5c6126c06126b66126ac6126a261269861268e6126846001610c559a6000908b60801c8061271c575b508060401c8061270f575b508060201c80612702575b508060101c806126f5575b508060081c806126e8575b508060041c806126db575b508060021c806126ce575b50821c6126c7575b811c1b61267d818b6125d4565b0160011c90565b61267d818a6125d4565b61267d81896125d4565b61267d81886125d4565b61267d81876125d4565b61267d81866125d4565b61267d81856125d4565b80926125d4565b8101612670565b6002915091019038612668565b600491509101903861265d565b6008915091019038612652565b6010915091019038612647565b602091509101903861263c565b6040915091019038612631565b91505060809038612626565b5060009056fef0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00a2646970667358221220bc65af583ee342faf6c95dda4f2392f105fe9b6af3be77203686d0acf2aa24d664736f6c634300081900330000000000000000000000005035c15f3cb4364cf2cf35ca53e3d6fc45fc889900000000000000000000000070818a53dde5c2e78edfb6f6b277be9a71fa894e0000000000000000000000005dea088d2be1473d948895cc26104bcf103cef3e00000000000000000000000030d46bc158e90f48edb97c1d7ba1077f6de836250000000000000000000000000000000000000000000000000000000000000001
Deployed Bytecode
0x6080604052600436101561001257600080fd5b60003560e01c8063103f2907146101775780631a2be2c4146101725780632c9d45b31461016d5780632dd310001461016857806331ce4dfe14610163578063439fab911461015e578063545ce3891461015957806362a01e8d146101545780638f42f9ab1461014f5780639168f9d21461014a5780639a896551146101455780639f86fd8514610140578063aa8e64891461013b578063aab3595f14610136578063b94c386e14610131578063bb24fe8a1461012c578063bc6eac5b14610127578063c0cd7c3e14610122578063cd05b8a11461011d578063e054e08b14610118578063f9268d18146101135763fbfa77cf1461010e57600080fd5b611316565b611208565b6111e2565b61118a565b611145565b611127565b6110e3565b610ce9565b610c9a565b610c58565b610b50565b610ac5565b61072b565b61070d565b6106d9565b6105bc565b610480565b6103e9565b61027f565b61023a565b6101e2565b61018c565b600091031261018757565b600080fd5b34610187576000366003190112610187576040517f0000000000000000000000005035c15f3cb4364cf2cf35ca53e3d6fc45fc88996001600160a01b03168152602090f35b6001600160a01b0381160361018757565b3461018757604036600319011261018757602061023261022d602435610207816101d1565b6004356000526002845260406000209060018060a01b0316600052602052604060002090565b611be4565b604051908152f35b34610187576000366003190112610187576040517f00000000000000000000000070818a53dde5c2e78edfb6f6b277be9a71fa894e6001600160a01b03168152602090f35b34610187576000366003190112610187576040517f00000000000000000000000030d46bc158e90f48edb97c1d7ba1077f6de836256001600160a01b03168152602090f35b65ffffffffffff81160361018757565b634e487b7160e01b600052604160045260246000fd5b6001600160401b0381116102fd57604052565b6102d4565b602081019081106001600160401b038211176102fd57604052565b604081019081106001600160401b038211176102fd57604052565b90601f801991011681019081106001600160401b038211176102fd57604052565b6040519060c082018281106001600160401b038211176102fd57604052565b604051906103858261031d565b565b6001600160401b0381116102fd57601f01601f191660200190565b81601f82011215610187578035906103b982610387565b926103c76040519485610338565b8284526020838301011161018757816000926020809301838601378301015290565b3461018757606036600319011261018757602435610406816102c4565b604435906001600160401b0382116101875761044a61042b60209336906004016103a2565b600435600090815260068552604090206001600160a01b039390611c4a565b16604051908152f35b9181601f84011215610187578235916001600160401b038311610187576020838186019501011161018757565b34610187576020366003190112610187576001600160401b03600435818111610187576104b1903690600401610453565b60008051602061272f833981519152549260ff8460401c16159316801590816105b4575b60011490816105aa575b1590816105a1575b5061058f5760008051602061272f833981519152805467ffffffffffffffff1916600117905561051b918361056a57611d38565b61052157005b60008051602061272f833981519152805460ff60401b19169055604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a1005b60008051602061272f833981519152805460ff60401b1916600160401b179055611d38565b60405163f92ee8a960e01b8152600490fd5b905015386104e7565b303b1591506104df565b8491506104d5565b346101875760a0366003190112610187576004356024356105dc816101d1565b6064356105e8816102c4565b6084356001600160401b03811161018757610607903690600401610453565b604051635daf681960e11b8152606086901c60048201529092906001600160a01b036020826024817f00000000000000000000000070818a53dde5c2e78edfb6f6b277be9a71fa894e85165afa9182156106d4576000926106a3575b50339116036106915761068d9461067d9460443591611546565b6040519081529081906020820190565b0390f35b60405163227bf64d60e01b8152600490fd5b6106c691925060203d6020116106cd575b6106be8183610338565b810190611365565b9038610663565b503d6106b4565b61137a565b34610187576020366003190112610187576004356000526001602052602065ffffffffffff60406000205416604051908152f35b34610187576000366003190112610187576020600354604051908152f35b3461018757606036600319011261018757600480356bffffffffffffffffffffffff8116810361018757602435610761816101d1565b6044356001600160401b0381116101875761077f9036908501610453565b9390610789611386565b9480610a5a575b50506040516302910f8b60e31b8152338282019081526001600160a01b0394602092909183908290819083010381897f0000000000000000000000005dea088d2be1473d948895cc26104bcf103cef3e165afa9081156106d457600091610a2d575b5015610a1c57600054859061083c90610834906001600160a01b0316936bffffffffffffffffffffffff166bffffffffffffffffffffffff193360601b161790565b975188611bb8565b1661091b575050506108f4906108d87f7b0b759b513b299fd2811f51926dca8854222a675557e8d544ce0933bf5b75709361087642611e6b565b61089261088d886000526006602052604060002090565b61228b565b50905065ffffffffffff6108b36108a842611e6b565b65ffffffffffff1690565b9116116108f9575b6108cf876000526006602052604060002090565b918416916124b2565b50506040516001600160a01b0390911681529081906020820190565b0390a2005b610915610910886000526006602052604060002090565b611e9d565b506108bb565b60405163186a323160e21b815294919392908216919084868281865afa9586156106d4576000966109fd575b508460055493604051928380926327f843b560e11b82525afa9485156106d4577f7b0b759b513b299fd2811f51926dca8854222a675557e8d544ce0933bf5b7570966108f4966108d8956109c3946109be946000936109c8575b50506109b79065ffffffffffff80931690611752565b9116611773565b611e6b565b610876565b6109b792935090816109ee92903d106109f6575b6109e68183610338565b81019061141c565b9190386109a1565b503d6109dc565b610a15919650853d87116109f6576109e68183610338565b9438610947565b6040516323d53b9760e21b81528390fd5b610a4d9150833d8511610a53575b610a458183610338565b81019061173a565b386107f2565b503d610a3b565b610a68929550810190611399565b923880610790565b634e487b7160e01b600052603260045260246000fd5b600354811015610ac057600360005260021b7fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b0190600090565b610a70565b346101875760203660031901126101875760043560035481101561018757610aec90610a86565b50805460018201546002830154600390930154604080519384526001600160a01b0390921660208401529082019290925265ffffffffffff808316606080840191909152603084901c90911660808301529190911c60ff16151560a082015260c090f35b346101875760408060031936011261018757600435610b6e816101d1565b602435906001600160401b0382116101875760008091610b95610bfa943690600401610453565b908187519283928337810184815203915af43d15610c0257610bec3d610bba81610387565b90610bc786519283610338565b81523d6000602083013e5b8451948593151560208501528084015260608301906117a3565b03601f198101835282610338565b805190602001fd5b610bec6060610bd2565b9060806003198301126101875760043591602435610c29816101d1565b91604435610c36816102c4565b91606435906001600160401b03821161018757610c55916004016103a2565b90565b34610187576020610232610c95610c6e36610c0c565b939190926000526002865260406000209060018060a01b0316600052602052604060002090565b611ee0565b34610187576020610232610cad36610c0c565b9291909161191d565b9060406003198301126101875760043591602435906001600160401b03821161018757610ce591600401610453565b9091565b3461018757610cf736610cb6565b90610d006117f5565b91806110cf575b50506003548210156110bd57610d1c82610a86565b5090600382019283549165ffffffffffff94610d3a6108a842611e6b565b868560301c161180611099575b611087576000546001600160a01b031691610d6142611e6b565b92610d6f8887168095611431565b9060018060a01b038091169860409788519687946327f843b560e11b8652858d602097889160049c8d915afa9081156106d4578591829160009161106a575b501691161161105a5790610dc560ff928c54611e27565b60601c1661104a57845460ff60601b1916600160601b178555885490610e04610df8836000526001602052604060002090565b5465ffffffffffff1690565b865465ffffffffffff1691808316911610611013575b50506002880154885498610e626001820192610e5c8c610e40865460018060a01b031690565b988989610e538d5465ffffffffffff1690565b9201519261191d565b90611e59565b998a8015159687611002575b50508951630ce9b79360e41b81529050848189818f5afa9384156106d4578994610eae92600091610fe5575b50925493549216916001600160a01b031690565b91610edd610ec2885465ffffffffffff1690565b8b519687019586529486900380875294959460200185610338565b813b1561018757600088610f0882968e988e51998a988997889663724ab0f760e11b88528701611b80565b03925af180156106d457610fd2575b50610f5d575b5050815183815261068d94507f5cc28df3b54da9d06f805d87616ebf969c81310f2aa8369cb14ca50f815d411190602090a2519081529081906020820190565b5465ffffffffffff16853b15610187578351631c9e38c760e21b815291820185815265ffffffffffff9091166020820152909460009186919082908490829060400103925af19384156106d45761068d94610fb9575b80610f1d565b80610fc6610fcc926102ea565b8061017c565b38610fb3565b80610fc6610fdf926102ea565b38610f17565b610ffc9150873d89116106cd576106be8183610338565b38610e9a565b61100b92611fac565b388a81610e6e565b61102a611043926000526001602052604060002090565b9065ffffffffffff1665ffffffffffff19825416179055565b3880610e1a565b8751633428e90760e01b81528690fd5b8951639ea153eb60e01b81528890fd5b6110819150893d8b116109f6576109e68183610338565b38610dae565b60405163b62b15c760e01b8152600490fd5b50845482516001600160a01b03916110b59190878a169061133f565b161515610d47565b604051637822972360e11b8152600490fd5b6110dc9250810190611b1d565b3880610d07565b346101875760003660031901126101875760206040516001600160401b037f0000000000000000000000000000000000000000000000000000000000000001168152f35b34610187576000366003190112610187576020600554604051908152f35b34610187576000366003190112610187576040517f0000000000000000000000005dea088d2be1473d948895cc26104bcf103cef3e6001600160a01b03168152602090f35b34610187576040366003190112610187576024356001600160401b038111610187576111d06111bf60209236906004016103a2565b6111c842611e6b565b60043561133f565b6040516001600160a01b039091168152f35b3461018757600036600319011261018757602065ffffffffffff60045416604051908152f35b346101875761121636610cb6565b9061121f611386565b9180611302575b50506003548210156110bd5761123b82610a86565b506003815491019161126b61125f84549365ffffffffffff9351908486169061133f565b6001600160a01b031690565b33036112f05761127d6108a842611e6b565b908260301c1611156112df5760601c60ff166112cd57805460ff60601b1916600160601b17905533907f7d3d269c851b72257a5194a401d151902e9be4347d555996dcff3ff86a077e92600080a3005b604051633428e90760e01b8152600490fd5b60405162c457e560e81b8152600490fd5b604051635d154fe160e11b8152600490fd5b61130f9250810190611399565b3880611226565b34610187576000366003190112610187576000546040516001600160a01b039091168152602090f35b60009081526006602052604090206001600160a01b0392611361929091611c4a565b1690565b908160209103126101875751610c55816101d1565b6040513d6000823e3d90fd5b6040519061139382610302565b60608252565b906020828203126101875781356001600160401b039283821161018757019060208282031261018757604051926113cf84610302565b8235908111610187576113e292016103a2565b815290565b634e487b7160e01b600052601160045260246000fd5b91909165ffffffffffff8080941691160191821161141757565b6113e7565b908160209103126101875751610c55816102c4565b65ffffffffffff918216908216039190821161141757565b634e487b7160e01b600052600060045260246000fd5b600354600160401b8110156102fd5780600161147e9201600355610a86565b919091611541578051825560208101516001830180546001600160a01b0319166001600160a01b0392909216919091179055610385916115279060a0906003906040850151600282015501926114f465ffffffffffff606083015116859065ffffffffffff1665ffffffffffff19825416179055565b60808101516bffffffffffff00000000000085549160301b16906bffffffffffff00000000000019161784550151151590565b815460ff60601b191690151560601b60ff60601b16179055565b611449565b929594909193611554611386565b9180611726575b505061156642611e6b565b9361158261157b60045465ffffffffffff1690565b80966113fd565b60005460049060209061159f9061125f906001600160a01b031681565b6040516327f843b560e11b815292839182905afa80156106d4576115cf926108a892600092611705575b50611431565b65ffffffffffff88169081109081156116ef575b506116dd57610e5c611602926115f98987611e27565b5188858761191d565b9283156116cb576116c6956116407f3cb7f4ff6cecf74cee0eb9ae3ebf8933fa60a53014cce52f96da72a78dba84649261163b42611e6b565b6113fd565b92600354978894611693611652610359565b8881526001600160a01b0385166020820152604081018a905265ffffffffffff8616606082015265ffffffffffff83166080820152600060a082015261145f565b6040805198895265ffffffffffff94851660208a01529316928701929092526001600160a01b0316949081906060820190565b0390a4565b60405163167f871760e31b8152600490fd5b604051631357ac9160e11b8152600490fd5b90506116fd6108a842611e6b565b1115386115e3565b61171f91925060203d6020116109f6576109e68183610338565b90386115c9565b6117339250810190611399565b388061155b565b90816020910312610187575180151581036101875790565b8181029291811591840414171561141757565b906001820180921161141757565b9190820180921161141757565b60005b8381106117935750506000910152565b8181015183820152602001611783565b906020916117bc81518092818552858086019101611780565b601f01601f1916010190565b60009081526002602090815260408083206001600160a01b03909416835292905220610c55929190611ee0565b604051906118028261031d565b60606020838281520152565b81601f8201121561018757805161182481610387565b926118326040519485610338565b8184526020828401011161018757610c559160208085019101611780565b906020828203126101875781516001600160401b039283821161018757019060408282031261018757604051926118868461031d565b8251818111610187578261189b91850161180e565b84526020830151908111610187576118b3920161180e565b602082015290565b90816020910312610187575190565b9081526001600160a01b03909116602082015265ffffffffffff9091166040820152608060608201819052610c55929101906117a3565b60001981019190821161141757565b9190820391821161141757565b9290926119286117f5565b91805180611b01575b505061193c42611e6b565b6000549093906119569061125f906001600160a01b031681565b94604051946327f843b560e11b865260209586816004818b5afa80156106d45761198b926108a892600092611ae95750611431565b65ffffffffffff8316908110908115611ad3575b50611ac8578460049660405197888092630ce9b79360e41b82525afa9586156106d4576119f2968691600091611aab575b5085519060405180809a819463e02f693760e01b835288888b600486016118ca565b03916001600160a01b03165afa9485156106d457610c5596600096611a68575b5083611a639383611a5d93611a5461022d611a5d9a97611a3d8d9b6000526002602052604060002090565b9060018060a01b0316600052602052604060002090565b950151926117c8565b90611910565b611e59565b611a5d9592965093611a6393611a978396611a5d943d8911611aa4575b611a8f8183610338565b8101906118bb565b9793965093509390611a12565b503d611a85565b611ac29150823d84116106cd576106be8183610338565b386119d0565b505050505050600090565b9050611ae16108a842611e6b565b11153861199f565b61171f919250893d8b116109f6576109e68183610338565b611b15929350602080918301019101611850565b903880611931565b906020828203126101875781356001600160401b03928382116101875701906040828203126101875760405192611b538461031d565b82358181116101875782611b689185016103a2565b84526020830135908111610187576118b392016103a2565b919360a093610c55969565ffffffffffff938552600180871b03166020850152604084015216606082015281608082015201906117a3565b90610c5591611bc642611e6b565b9061133f565b8054821015610ac05760005260206000200190600090565b611bed81612099565b6001600160d01b03811615611c12576001611c089201611bcc565b90549060031b1c90565b5050600090565b90816020910312610187575163ffffffff811681036101875790565b90600163ffffffff8093160191821161141757565b91805115611d2e5780602080611c6593518301019101611c19565b91611c7083826120de565b92611c81845165ffffffffffff1690565b9065ffffffffffff8085169216828114611d155782119182611cc0575b5050611cae57610c559250612382565b5050602001516001600160d01b031690565b909150611ccd8354611901565b63ffffffff831614918215611ce6575b50503880611c9e565b611d0d919250611d01611cfb6108a892611c35565b856120de565b5165ffffffffffff1690565b113880611cdd565b50505050602091909101516001600160d01b0316905090565b50610c5591612382565b9081019060408183031261018757803591611d52836101d1565b60208201356001600160401b03811161018757611d6f92016103a2565b6040516302910f8b60e31b81526001600160a01b039283166004820181905292602090829060249082907f0000000000000000000000005035c15f3cb4364cf2cf35ca53e3d6fc45fc8899165afa9081156106d457600091611e08575b5015611df657600080546001600160a01b0319166001600160a01b03841617905561038591612163565b6040516362df054560e01b8152600490fd5b611e21915060203d602011610a5357610a458183610338565b38611dcc565b600052600160205265ffffffffffff8060406000205416911610611e4757565b604051633f64d76b60e01b8152600490fd5b9080821015611e66575090565b905090565b65ffffffffffff90818111611e7e571690565b604490604051906306dfcc6560e41b8252603060048301526024820152fd5b90611ea782612099565b9180548015611eca576000190190611ebf8282611bcc565b611541576000905555565b634e487b7160e01b600052603160045260246000fd5b91805115611fa25780602080611efb93518301019101611c19565b91611f0683826122eb565b92611f17845165ffffffffffff1690565b9065ffffffffffff8085169216828114611f965782119182611f4d575b5050611f4457610c5592506122e0565b50506020015190565b909150611f5a8354611901565b63ffffffff831614918215611f73575b50503880611f34565b611f8e919250611d01611f886108a892611c35565b856122eb565b113880611f6a565b50505050506020015190565b50610c55916122e0565b9081600052600260205261200b61022d611fdc8360406000209060018060a01b0316600052602052604060002090565b92611fe642611e6b565b94600052600260205260406000209060018060a01b0316600052602052604060002090565b92830180931161141757600181019283548015612060575b508354926120479261203f916001600160d01b038616916124b2565b50508361234d565b60001981019081116114175761205c91611bcc565b5050565b600160401b8110156102fd576120479261208382600161203f9401885587611bcc565b8154906000199060031b1b191690559250612023565b8054806120a7575050600090565b60001991818381011161141757600052602060002001015460301c90565b604051906120d28261031d565b60006020838281520152565b612103916120fd916120ee6120c5565b506120f76120c5565b50611bcc565b50612267565b65ffffffffffff81511690602060018060d01b0391015116604051916121288361031d565b8252602082015290565b908160409103126101875760206040519161214c8361031d565b8051612157816102c4565b83520151602082015290565b906004815161217c602093848080948301019101612132565b6040516327f843b560e11b815290949092839182906001600160a01b03165afa80156106d45765ffffffffffff9160009161224a575b50168015612238576121cd6108a8845165ffffffffffff1690565b101561222657810160038151106122145761220e6121f4610385935165ffffffffffff1690565b65ffffffffffff1665ffffffffffff196004541617600455565b51600555565b6040516354f778f360e01b8152600490fd5b6040516367d5e3df60e11b8152600490fd5b604051639a09fd8760e01b8152600490fd5b6122619150833d85116109f6576109e68183610338565b386121b2565b906040516122748161031d565b915465ffffffffffff8116835260301c6020830152565b80548061229f575050600090600090600090565b600019908082810111611417576122bf9260005260206000200101612267565b9065ffffffffffff82511691602060018060d01b0391015116906001929190565b90611bed9082612382565b9061230e6120fd61232f926122fe6120c5565b506123076120c5565b5084611bcc565b91600165ffffffffffff845116936020828060d01b03910151169101611bcc565b9054906040519261233f8461031d565b835260031b1c602082015290565b8054600160401b8110156102fd5761236a91600182018155611bcc565b819291549060031b91821b91600019901b1916179055565b90815490600091806005811161241f575b50915b8281106123cf575050806123ab575050600090565b610c55916123bb6123c892611901565b9060005260206000200190565b5460301c90565b90918082169080831860011c8201809211611417578460005265ffffffffffff808360206000200154169085161060001461240d5750915b90612396565b92915061241990611765565b90612407565b90612429826125f4565b8203918211611417578460005265ffffffffffff808360206000200154169084161060001461245a57505b38612393565b925061246590611765565b91612454565b8054600160401b8110156102fd5761248891600182018155611bcc565b61154157815160209092015160301b65ffffffffffff191665ffffffffffff909216919091179055565b8054929392919082156125aa576124e06124db6124ce85611901565b8360005260206000200190565b612267565b906124f1825165ffffffffffff1690565b65ffffffffffff848116911681106125985761255c94602094889261251f6108a8875165ffffffffffff1690565b03612560575061254e926123bb61253592611901565b9065ffffffffffff82549181199060301b169116179055565b01516001600160d01b031690565b9190565b91505061259391612580612572610378565b65ffffffffffff9093168352565b6001600160d01b0388168286015261246b565b61254e565b604051632520601d60e01b8152600490fd5b6125ce92506125ba612572610378565b6001600160d01b038516602083015261246b565b60009190565b81156125de570490565b634e487b7160e01b600052601260045260246000fd5b80156127285780610e5c6126c06126b66126ac6126a261269861268e6126846001610c559a6000908b60801c8061271c575b508060401c8061270f575b508060201c80612702575b508060101c806126f5575b508060081c806126e8575b508060041c806126db575b508060021c806126ce575b50821c6126c7575b811c1b61267d818b6125d4565b0160011c90565b61267d818a6125d4565b61267d81896125d4565b61267d81886125d4565b61267d81876125d4565b61267d81866125d4565b61267d81856125d4565b80926125d4565b8101612670565b6002915091019038612668565b600491509101903861265d565b6008915091019038612652565b6010915091019038612647565b602091509101903861263c565b6040915091019038612631565b91505060809038612626565b5060009056fef0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00a2646970667358221220bc65af583ee342faf6c95dda4f2392f105fe9b6af3be77203686d0acf2aa24d664736f6c63430008190033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000005035c15f3cb4364cf2cf35ca53e3d6fc45fc889900000000000000000000000070818a53dde5c2e78edfb6f6b277be9a71fa894e0000000000000000000000005dea088d2be1473d948895cc26104bcf103cef3e00000000000000000000000030d46bc158e90f48edb97c1d7ba1077f6de836250000000000000000000000000000000000000000000000000000000000000001
-----Decoded View---------------
Arg [0] : vaultFactory (address): 0x5035c15F3cb4364CF2cF35ca53E3d6FC45FC8899
Arg [1] : networkMiddlewareService (address): 0x70818a53ddE5c2e78Edfb6f6b277Be9a71fa894E
Arg [2] : networkRegistry (address): 0x5dEA088d2Be1473d948895cc26104bcf103CEf3E
Arg [3] : slasherFactory (address): 0x30D46BC158e90F48eDb97C1d7BA1077f6de83625
Arg [4] : entityType (uint64): 1
-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 0000000000000000000000005035c15f3cb4364cf2cf35ca53e3d6fc45fc8899
Arg [1] : 00000000000000000000000070818a53dde5c2e78edfb6f6b277be9a71fa894e
Arg [2] : 0000000000000000000000005dea088d2be1473d948895cc26104bcf103cef3e
Arg [3] : 00000000000000000000000030d46bc158e90f48edb97c1d7ba1077f6de83625
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000001
Loading...
Loading
[ Download: CSV Export ]
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.