Note: Our ether balance display is temporarily unavailable. Please check back later.
Source Code
Overview
ETH Balance
Ether balance is temporarily unavailable. Please check back later.
More Info
ContractCreator
Multichain Info
N/A
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
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:
VaultTokenized
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 {Vault} from "./Vault.sol";
import {IVaultTokenized} from "../../interfaces/vault/IVaultTokenized.sol";
import {IVault} from "../../interfaces/vault/IVault.sol";
import {Checkpoints} from "../libraries/Checkpoints.sol";
import {ERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import {SafeERC20, IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {Time} from "@openzeppelin/contracts/utils/types/Time.sol";
contract VaultTokenized is Vault, ERC20Upgradeable, IVaultTokenized {
using Checkpoints for Checkpoints.Trace256;
using SafeERC20 for IERC20;
constructor(
address delegatorFactory,
address slasherFactory,
address vaultFactory
) Vault(delegatorFactory, slasherFactory, vaultFactory) {}
/**
* @inheritdoc ERC20Upgradeable
*/
function decimals() public view override returns (uint8) {
return IERC20Metadata(collateral).decimals();
}
/**
* @inheritdoc ERC20Upgradeable
*/
function totalSupply() public view override returns (uint256) {
return activeShares();
}
/**
* @inheritdoc ERC20Upgradeable
*/
function balanceOf(
address account
) public view override returns (uint256) {
return activeSharesOf(account);
}
/**
* @inheritdoc IVault
*/
function deposit(
address onBehalfOf,
uint256 amount
) public override(Vault, IVault) returns (uint256 depositedAmount, uint256 mintedShares) {
(depositedAmount, mintedShares) = super.deposit(onBehalfOf, amount);
emit Transfer(address(0), onBehalfOf, mintedShares);
}
function _withdraw(
address claimer,
uint256 withdrawnAssets,
uint256 burnedShares
) internal override returns (uint256 mintedShares) {
mintedShares = super._withdraw(claimer, withdrawnAssets, burnedShares);
emit Transfer(msg.sender, address(0), burnedShares);
}
/**
* @inheritdoc ERC20Upgradeable
*/
function _update(address from, address to, uint256 value) internal override {
if (from == address(0)) {
// Overflow check required: The rest of the code assumes that totalSupply never overflows
_activeShares.push(Time.timestamp(), totalSupply() + value);
} else {
uint256 fromBalance = balanceOf(from);
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
// Overflow not possible: value <= fromBalance <= totalSupply.
_activeSharesOf[from].push(Time.timestamp(), fromBalance - value);
}
}
if (to == address(0)) {
unchecked {
// Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
_activeShares.push(Time.timestamp(), totalSupply() - value);
}
} else {
unchecked {
// Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
_activeSharesOf[to].push(Time.timestamp(), balanceOf(to) + value);
}
}
emit Transfer(from, to, value);
}
function _initialize(uint64 initialVersion, address owner_, bytes memory data) internal override {
(InitParamsTokenized memory params) = abi.decode(data, (InitParamsTokenized));
super._initialize(initialVersion, owner_, abi.encode(params.baseParams));
__ERC20_init(params.name, params.symbol);
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
import {MigratableEntity} from "../common/MigratableEntity.sol";
import {VaultStorage} from "./VaultStorage.sol";
import {IBaseDelegator} from "../../interfaces/delegator/IBaseDelegator.sol";
import {IBaseSlasher} from "../../interfaces/slasher/IBaseSlasher.sol";
import {IRegistry} from "../../interfaces/common/IRegistry.sol";
import {IVault} from "../../interfaces/vault/IVault.sol";
import {Checkpoints} from "../libraries/Checkpoints.sol";
import {ERC4626Math} from "../libraries/ERC4626Math.sol";
import {AccessControlUpgradeable} from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";
import {SafeERC20, IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {Time} from "@openzeppelin/contracts/utils/types/Time.sol";
contract Vault is VaultStorage, MigratableEntity, AccessControlUpgradeable, IVault {
using Checkpoints for Checkpoints.Trace256;
using Math for uint256;
using SafeCast for uint256;
using SafeERC20 for IERC20;
constructor(
address delegatorFactory,
address slasherFactory,
address vaultFactory
) VaultStorage(delegatorFactory, slasherFactory) MigratableEntity(vaultFactory) {}
/**
* @inheritdoc IVault
*/
function isInitialized() external view returns (bool) {
return isDelegatorInitialized && isSlasherInitialized;
}
/**
* @inheritdoc IVault
*/
function totalStake() public view returns (uint256) {
uint256 epoch = currentEpoch();
return activeStake() + withdrawals[epoch] + withdrawals[epoch + 1];
}
/**
* @inheritdoc IVault
*/
function activeBalanceOfAt(address account, uint48 timestamp, bytes calldata hints) public view returns (uint256) {
ActiveBalanceOfHints memory activeBalanceOfHints;
if (hints.length > 0) {
activeBalanceOfHints = abi.decode(hints, (ActiveBalanceOfHints));
}
return ERC4626Math.previewRedeem(
activeSharesOfAt(account, timestamp, activeBalanceOfHints.activeSharesOfHint),
activeStakeAt(timestamp, activeBalanceOfHints.activeStakeHint),
activeSharesAt(timestamp, activeBalanceOfHints.activeSharesHint)
);
}
/**
* @inheritdoc IVault
*/
function activeBalanceOf(
address account
) public view returns (uint256) {
return ERC4626Math.previewRedeem(activeSharesOf(account), activeStake(), activeShares());
}
/**
* @inheritdoc IVault
*/
function withdrawalsOf(uint256 epoch, address account) public view returns (uint256) {
return
ERC4626Math.previewRedeem(withdrawalSharesOf[epoch][account], withdrawals[epoch], withdrawalShares[epoch]);
}
/**
* @inheritdoc IVault
*/
function slashableBalanceOf(
address account
) external view returns (uint256) {
uint256 epoch = currentEpoch();
return activeBalanceOf(account) + withdrawalsOf(epoch, account) + withdrawalsOf(epoch + 1, account);
}
/**
* @inheritdoc IVault
*/
function deposit(
address onBehalfOf,
uint256 amount
) public virtual nonReentrant returns (uint256 depositedAmount, uint256 mintedShares) {
if (onBehalfOf == address(0)) {
revert InvalidOnBehalfOf();
}
if (depositWhitelist && !isDepositorWhitelisted[msg.sender]) {
revert NotWhitelistedDepositor();
}
uint256 balanceBefore = IERC20(collateral).balanceOf(address(this));
IERC20(collateral).safeTransferFrom(msg.sender, address(this), amount);
depositedAmount = IERC20(collateral).balanceOf(address(this)) - balanceBefore;
if (depositedAmount == 0) {
revert InsufficientDeposit();
}
if (isDepositLimit && activeStake() + depositedAmount > depositLimit) {
revert DepositLimitReached();
}
uint256 activeStake_ = activeStake();
uint256 activeShares_ = activeShares();
mintedShares = ERC4626Math.previewDeposit(depositedAmount, activeShares_, activeStake_);
_activeStake.push(Time.timestamp(), activeStake_ + depositedAmount);
_activeShares.push(Time.timestamp(), activeShares_ + mintedShares);
_activeSharesOf[onBehalfOf].push(Time.timestamp(), activeSharesOf(onBehalfOf) + mintedShares);
emit Deposit(msg.sender, onBehalfOf, depositedAmount, mintedShares);
}
/**
* @inheritdoc IVault
*/
function withdraw(
address claimer,
uint256 amount
) external nonReentrant returns (uint256 burnedShares, uint256 mintedShares) {
if (claimer == address(0)) {
revert InvalidClaimer();
}
if (amount == 0) {
revert InsufficientWithdrawal();
}
burnedShares = ERC4626Math.previewWithdraw(amount, activeShares(), activeStake());
if (burnedShares > activeSharesOf(msg.sender)) {
revert TooMuchWithdraw();
}
mintedShares = _withdraw(claimer, amount, burnedShares);
}
/**
* @inheritdoc IVault
*/
function redeem(
address claimer,
uint256 shares
) external nonReentrant returns (uint256 withdrawnAssets, uint256 mintedShares) {
if (claimer == address(0)) {
revert InvalidClaimer();
}
if (shares > activeSharesOf(msg.sender)) {
revert TooMuchRedeem();
}
withdrawnAssets = ERC4626Math.previewRedeem(shares, activeStake(), activeShares());
if (withdrawnAssets == 0) {
revert InsufficientRedemption();
}
mintedShares = _withdraw(claimer, withdrawnAssets, shares);
}
/**
* @inheritdoc IVault
*/
function claim(address recipient, uint256 epoch) external nonReentrant returns (uint256 amount) {
if (recipient == address(0)) {
revert InvalidRecipient();
}
amount = _claim(epoch);
IERC20(collateral).safeTransfer(recipient, amount);
emit Claim(msg.sender, recipient, epoch, amount);
}
/**
* @inheritdoc IVault
*/
function claimBatch(address recipient, uint256[] calldata epochs) external nonReentrant returns (uint256 amount) {
if (recipient == address(0)) {
revert InvalidRecipient();
}
uint256 length = epochs.length;
if (length == 0) {
revert InvalidLengthEpochs();
}
for (uint256 i; i < length; ++i) {
amount += _claim(epochs[i]);
}
IERC20(collateral).safeTransfer(recipient, amount);
emit ClaimBatch(msg.sender, recipient, epochs, amount);
}
/**
* @inheritdoc IVault
*/
function onSlash(uint256 amount, uint48 captureTimestamp) external nonReentrant returns (uint256 slashedAmount) {
if (msg.sender != slasher) {
revert NotSlasher();
}
uint256 currentEpoch_ = currentEpoch();
uint256 captureEpoch = epochAt(captureTimestamp);
if ((currentEpoch_ > 0 && captureEpoch < currentEpoch_ - 1) || captureEpoch > currentEpoch_) {
revert InvalidCaptureEpoch();
}
uint256 activeStake_ = activeStake();
uint256 nextWithdrawals = withdrawals[currentEpoch_ + 1];
if (captureEpoch == currentEpoch_) {
uint256 slashableStake = activeStake_ + nextWithdrawals;
slashedAmount = Math.min(amount, slashableStake);
if (slashedAmount > 0) {
uint256 activeSlashed = slashedAmount.mulDiv(activeStake_, slashableStake);
uint256 nextWithdrawalsSlashed = slashedAmount - activeSlashed;
_activeStake.push(Time.timestamp(), activeStake_ - activeSlashed);
withdrawals[captureEpoch + 1] = nextWithdrawals - nextWithdrawalsSlashed;
}
} else {
uint256 withdrawals_ = withdrawals[currentEpoch_];
uint256 slashableStake = activeStake_ + withdrawals_ + nextWithdrawals;
slashedAmount = Math.min(amount, slashableStake);
if (slashedAmount > 0) {
uint256 activeSlashed = slashedAmount.mulDiv(activeStake_, slashableStake);
uint256 nextWithdrawalsSlashed = slashedAmount.mulDiv(nextWithdrawals, slashableStake);
uint256 withdrawalsSlashed = slashedAmount - activeSlashed - nextWithdrawalsSlashed;
if (withdrawals_ < withdrawalsSlashed) {
nextWithdrawalsSlashed += withdrawalsSlashed - withdrawals_;
withdrawalsSlashed = withdrawals_;
}
_activeStake.push(Time.timestamp(), activeStake_ - activeSlashed);
withdrawals[currentEpoch_ + 1] = nextWithdrawals - nextWithdrawalsSlashed;
withdrawals[currentEpoch_] = withdrawals_ - withdrawalsSlashed;
}
}
if (slashedAmount > 0) {
IERC20(collateral).safeTransfer(burner, slashedAmount);
}
emit OnSlash(amount, captureTimestamp, slashedAmount);
}
/**
* @inheritdoc IVault
*/
function setDepositWhitelist(
bool status
) external nonReentrant onlyRole(DEPOSIT_WHITELIST_SET_ROLE) {
if (depositWhitelist == status) {
revert AlreadySet();
}
depositWhitelist = status;
emit SetDepositWhitelist(status);
}
/**
* @inheritdoc IVault
*/
function setDepositorWhitelistStatus(
address account,
bool status
) external nonReentrant onlyRole(DEPOSITOR_WHITELIST_ROLE) {
if (account == address(0)) {
revert InvalidAccount();
}
if (isDepositorWhitelisted[account] == status) {
revert AlreadySet();
}
isDepositorWhitelisted[account] = status;
emit SetDepositorWhitelistStatus(account, status);
}
/**
* @inheritdoc IVault
*/
function setIsDepositLimit(
bool status
) external nonReentrant onlyRole(IS_DEPOSIT_LIMIT_SET_ROLE) {
if (isDepositLimit == status) {
revert AlreadySet();
}
isDepositLimit = status;
emit SetIsDepositLimit(status);
}
/**
* @inheritdoc IVault
*/
function setDepositLimit(
uint256 limit
) external nonReentrant onlyRole(DEPOSIT_LIMIT_SET_ROLE) {
if (depositLimit == limit) {
revert AlreadySet();
}
depositLimit = limit;
emit SetDepositLimit(limit);
}
function setDelegator(
address delegator_
) external nonReentrant {
if (isDelegatorInitialized) {
revert DelegatorAlreadyInitialized();
}
if (!IRegistry(DELEGATOR_FACTORY).isEntity(delegator_)) {
revert NotDelegator();
}
if (IBaseDelegator(delegator_).vault() != address(this)) {
revert InvalidDelegator();
}
delegator = delegator_;
isDelegatorInitialized = true;
emit SetDelegator(delegator_);
}
function setSlasher(
address slasher_
) external nonReentrant {
if (isSlasherInitialized) {
revert SlasherAlreadyInitialized();
}
if (slasher_ != address(0)) {
if (!IRegistry(SLASHER_FACTORY).isEntity(slasher_)) {
revert NotSlasher();
}
if (IBaseSlasher(slasher_).vault() != address(this)) {
revert InvalidSlasher();
}
slasher = slasher_;
}
isSlasherInitialized = true;
emit SetSlasher(slasher_);
}
function _withdraw(
address claimer,
uint256 withdrawnAssets,
uint256 burnedShares
) internal virtual returns (uint256 mintedShares) {
_activeSharesOf[msg.sender].push(Time.timestamp(), activeSharesOf(msg.sender) - burnedShares);
_activeShares.push(Time.timestamp(), activeShares() - burnedShares);
_activeStake.push(Time.timestamp(), activeStake() - withdrawnAssets);
uint256 epoch = currentEpoch() + 1;
uint256 withdrawals_ = withdrawals[epoch];
uint256 withdrawalsShares_ = withdrawalShares[epoch];
mintedShares = ERC4626Math.previewDeposit(withdrawnAssets, withdrawalsShares_, withdrawals_);
withdrawals[epoch] = withdrawals_ + withdrawnAssets;
withdrawalShares[epoch] = withdrawalsShares_ + mintedShares;
withdrawalSharesOf[epoch][claimer] += mintedShares;
emit Withdraw(msg.sender, claimer, withdrawnAssets, burnedShares, mintedShares);
}
function _claim(
uint256 epoch
) internal returns (uint256 amount) {
if (epoch >= currentEpoch()) {
revert InvalidEpoch();
}
if (isWithdrawalsClaimed[epoch][msg.sender]) {
revert AlreadyClaimed();
}
amount = withdrawalsOf(epoch, msg.sender);
if (amount == 0) {
revert InsufficientClaim();
}
isWithdrawalsClaimed[epoch][msg.sender] = true;
}
function _initialize(uint64, address, bytes memory data) internal virtual override {
(InitParams memory params) = abi.decode(data, (InitParams));
if (params.collateral == address(0)) {
revert InvalidCollateral();
}
if (params.epochDuration == 0) {
revert InvalidEpochDuration();
}
if (params.defaultAdminRoleHolder == address(0)) {
if (params.depositWhitelistSetRoleHolder == address(0)) {
if (params.depositWhitelist) {
if (params.depositorWhitelistRoleHolder == address(0)) {
revert MissingRoles();
}
} else if (params.depositorWhitelistRoleHolder != address(0)) {
revert MissingRoles();
}
}
if (params.isDepositLimitSetRoleHolder == address(0)) {
if (params.isDepositLimit) {
if (params.depositLimit == 0 && params.depositLimitSetRoleHolder == address(0)) {
revert MissingRoles();
}
} else if (params.depositLimit != 0 || params.depositLimitSetRoleHolder != address(0)) {
revert MissingRoles();
}
}
}
collateral = params.collateral;
burner = params.burner;
epochDurationInit = Time.timestamp();
epochDuration = params.epochDuration;
depositWhitelist = params.depositWhitelist;
isDepositLimit = params.isDepositLimit;
depositLimit = params.depositLimit;
if (params.defaultAdminRoleHolder != address(0)) {
_grantRole(DEFAULT_ADMIN_ROLE, params.defaultAdminRoleHolder);
}
if (params.depositWhitelistSetRoleHolder != address(0)) {
_grantRole(DEPOSIT_WHITELIST_SET_ROLE, params.depositWhitelistSetRoleHolder);
}
if (params.depositorWhitelistRoleHolder != address(0)) {
_grantRole(DEPOSITOR_WHITELIST_ROLE, params.depositorWhitelistRoleHolder);
}
if (params.isDepositLimitSetRoleHolder != address(0)) {
_grantRole(IS_DEPOSIT_LIMIT_SET_ROLE, params.isDepositLimitSetRoleHolder);
}
if (params.depositLimitSetRoleHolder != address(0)) {
_grantRole(DEPOSIT_LIMIT_SET_ROLE, params.depositLimitSetRoleHolder);
}
}
function _migrate(uint64, /* oldVersion */ uint64, /* newVersion */ bytes calldata /* data */ ) internal override {
revert();
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IVault} from "./IVault.sol";
interface IVaultTokenized is IVault {
/**
* @notice Initial parameters needed for a tokenized vault deployment.
* @param baseParams initial parameters needed for a vault deployment (InitParams)
* @param name name for the ERC20 tokenized vault
* @param symbol symbol for the ERC20 tokenized vault
*/
struct InitParamsTokenized {
InitParams baseParams;
string name;
string symbol;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IMigratableEntity} from "../common/IMigratableEntity.sol";
import {IVaultStorage} from "./IVaultStorage.sol";
interface IVault is IMigratableEntity, IVaultStorage {
error AlreadyClaimed();
error AlreadySet();
error DelegatorAlreadyInitialized();
error DepositLimitReached();
error InsufficientClaim();
error InsufficientDeposit();
error InsufficientRedemption();
error InsufficientWithdrawal();
error InvalidAccount();
error InvalidCaptureEpoch();
error InvalidClaimer();
error InvalidCollateral();
error InvalidDelegator();
error InvalidEpoch();
error InvalidEpochDuration();
error InvalidLengthEpochs();
error InvalidOnBehalfOf();
error InvalidRecipient();
error InvalidSlasher();
error MissingRoles();
error NotDelegator();
error NotSlasher();
error NotWhitelistedDepositor();
error SlasherAlreadyInitialized();
error TooMuchRedeem();
error TooMuchWithdraw();
/**
* @notice Initial parameters needed for a vault deployment.
* @param collateral vault's underlying collateral
* @param burner vault's burner to issue debt to (e.g., 0xdEaD or some unwrapper contract)
* @param epochDuration duration of the vault epoch (it determines sync points for withdrawals)
* @param depositWhitelist if enabling deposit whitelist
* @param isDepositLimit if enabling deposit limit
* @param depositLimit deposit limit (maximum amount of the collateral that can be in the vault simultaneously)
* @param defaultAdminRoleHolder address of the initial DEFAULT_ADMIN_ROLE holder
* @param depositWhitelistSetRoleHolder address of the initial DEPOSIT_WHITELIST_SET_ROLE holder
* @param depositorWhitelistRoleHolder address of the initial DEPOSITOR_WHITELIST_ROLE holder
* @param isDepositLimitSetRoleHolder address of the initial IS_DEPOSIT_LIMIT_SET_ROLE holder
* @param depositLimitSetRoleHolder address of the initial DEPOSIT_LIMIT_SET_ROLE holder
*/
struct InitParams {
address collateral;
address burner;
uint48 epochDuration;
bool depositWhitelist;
bool isDepositLimit;
uint256 depositLimit;
address defaultAdminRoleHolder;
address depositWhitelistSetRoleHolder;
address depositorWhitelistRoleHolder;
address isDepositLimitSetRoleHolder;
address depositLimitSetRoleHolder;
}
/**
* @notice Hints for an active balance.
* @param activeSharesOfHint hint for the active shares of checkpoint
* @param activeStakeHint hint for the active stake checkpoint
* @param activeSharesHint hint for the active shares checkpoint
*/
struct ActiveBalanceOfHints {
bytes activeSharesOfHint;
bytes activeStakeHint;
bytes activeSharesHint;
}
/**
* @notice Emitted when a deposit is made.
* @param depositor account that made the deposit
* @param onBehalfOf account the deposit was made on behalf of
* @param amount amount of the collateral deposited
* @param shares amount of the active shares minted
*/
event Deposit(address indexed depositor, address indexed onBehalfOf, uint256 amount, uint256 shares);
/**
* @notice Emitted when a withdrawal is made.
* @param withdrawer account that made the withdrawal
* @param claimer account that needs to claim the withdrawal
* @param amount amount of the collateral withdrawn
* @param burnedShares amount of the active shares burned
* @param mintedShares amount of the epoch withdrawal shares minted
*/
event Withdraw(
address indexed withdrawer, address indexed claimer, uint256 amount, uint256 burnedShares, uint256 mintedShares
);
/**
* @notice Emitted when a claim is made.
* @param claimer account that claimed
* @param recipient account that received the collateral
* @param epoch epoch the collateral was claimed for
* @param amount amount of the collateral claimed
*/
event Claim(address indexed claimer, address indexed recipient, uint256 epoch, uint256 amount);
/**
* @notice Emitted when a batch claim is made.
* @param claimer account that claimed
* @param recipient account that received the collateral
* @param epochs epochs the collateral was claimed for
* @param amount amount of the collateral claimed
*/
event ClaimBatch(address indexed claimer, address indexed recipient, uint256[] epochs, uint256 amount);
/**
* @notice Emitted when a slash happens.
* @param amount amount of the collateral to slash
* @param captureTimestamp time point when the stake was captured
* @param slashedAmount real amount of the collateral slashed
*/
event OnSlash(uint256 amount, uint48 captureTimestamp, uint256 slashedAmount);
/**
* @notice Emitted when a deposit whitelist status is enabled/disabled.
* @param status if enabled deposit whitelist
*/
event SetDepositWhitelist(bool status);
/**
* @notice Emitted when a depositor whitelist status is set.
* @param account account for which the whitelist status is set
* @param status if whitelisted the account
*/
event SetDepositorWhitelistStatus(address indexed account, bool status);
/**
* @notice Emitted when a deposit limit status is enabled/disabled.
* @param status if enabled deposit limit
*/
event SetIsDepositLimit(bool status);
/**
* @notice Emitted when a deposit limit is set.
* @param limit deposit limit (maximum amount of the collateral that can be in the vault simultaneously)
*/
event SetDepositLimit(uint256 limit);
/**
* @notice Emitted when a delegator is set.
* @param delegator vault's delegator to delegate the stake to networks and operators
* @dev Can be set only once.
*/
event SetDelegator(address indexed delegator);
/**
* @notice Emitted when a slasher is set.
* @param slasher vault's slasher to provide a slashing mechanism to networks
* @dev Can be set only once.
*/
event SetSlasher(address indexed slasher);
/**
* @notice Check if the vault is fully initialized (a delegator and a slasher are set).
* @return if the vault is fully initialized
*/
function isInitialized() external view returns (bool);
/**
* @notice Get a total amount of the collateral that can be slashed.
* @return total amount of the slashable collateral
*/
function totalStake() external view returns (uint256);
/**
* @notice Get an active balance for a particular account at a given timestamp using hints.
* @param account account to get the active balance for
* @param timestamp time point to get the active balance for the account at
* @param hints hints for checkpoints' indexes
* @return active balance for the account at the timestamp
*/
function activeBalanceOfAt(
address account,
uint48 timestamp,
bytes calldata hints
) external view returns (uint256);
/**
* @notice Get an active balance for a particular account.
* @param account account to get the active balance for
* @return active balance for the account
*/
function activeBalanceOf(
address account
) external view returns (uint256);
/**
* @notice Get withdrawals for a particular account at a given epoch (zero if claimed).
* @param epoch epoch to get the withdrawals for the account at
* @param account account to get the withdrawals for
* @return withdrawals for the account at the epoch
*/
function withdrawalsOf(uint256 epoch, address account) external view returns (uint256);
/**
* @notice Get a total amount of the collateral that can be slashed for a given account.
* @param account account to get the slashable collateral for
* @return total amount of the account's slashable collateral
*/
function slashableBalanceOf(
address account
) external view returns (uint256);
/**
* @notice Deposit collateral into the vault.
* @param onBehalfOf account the deposit is made on behalf of
* @param amount amount of the collateral to deposit
* @return depositedAmount real amount of the collateral deposited
* @return mintedShares amount of the active shares minted
*/
function deposit(
address onBehalfOf,
uint256 amount
) external returns (uint256 depositedAmount, uint256 mintedShares);
/**
* @notice Withdraw collateral from the vault (it will be claimable after the next epoch).
* @param claimer account that needs to claim the withdrawal
* @param amount amount of the collateral to withdraw
* @return burnedShares amount of the active shares burned
* @return mintedShares amount of the epoch withdrawal shares minted
*/
function withdraw(address claimer, uint256 amount) external returns (uint256 burnedShares, uint256 mintedShares);
/**
* @notice Redeem collateral from the vault (it will be claimable after the next epoch).
* @param claimer account that needs to claim the withdrawal
* @param shares amount of the active shares to redeem
* @return withdrawnAssets amount of the collateral withdrawn
* @return mintedShares amount of the epoch withdrawal shares minted
*/
function redeem(address claimer, uint256 shares) external returns (uint256 withdrawnAssets, uint256 mintedShares);
/**
* @notice Claim collateral from the vault.
* @param recipient account that receives the collateral
* @param epoch epoch to claim the collateral for
* @return amount amount of the collateral claimed
*/
function claim(address recipient, uint256 epoch) external returns (uint256 amount);
/**
* @notice Claim collateral from the vault for multiple epochs.
* @param recipient account that receives the collateral
* @param epochs epochs to claim the collateral for
* @return amount amount of the collateral claimed
*/
function claimBatch(address recipient, uint256[] calldata epochs) external returns (uint256 amount);
/**
* @notice Slash callback for burning collateral.
* @param amount amount to slash
* @param captureTimestamp time point when the stake was captured
* @return slashedAmount real amount of the collateral slashed
* @dev Only the slasher can call this function.
*/
function onSlash(uint256 amount, uint48 captureTimestamp) external returns (uint256 slashedAmount);
/**
* @notice Enable/disable deposit whitelist.
* @param status if enabling deposit whitelist
* @dev Only a DEPOSIT_WHITELIST_SET_ROLE holder can call this function.
*/
function setDepositWhitelist(
bool status
) external;
/**
* @notice Set a depositor whitelist status.
* @param account account for which the whitelist status is set
* @param status if whitelisting the account
* @dev Only a DEPOSITOR_WHITELIST_ROLE holder can call this function.
*/
function setDepositorWhitelistStatus(address account, bool status) external;
/**
* @notice Enable/disable deposit limit.
* @param status if enabling deposit limit
* @dev Only a IS_DEPOSIT_LIMIT_SET_ROLE holder can call this function.
*/
function setIsDepositLimit(
bool status
) external;
/**
* @notice Set a deposit limit.
* @param limit deposit limit (maximum amount of the collateral that can be in the vault simultaneously)
* @dev Only a DEPOSIT_LIMIT_SET_ROLE holder can call this function.
*/
function setDepositLimit(
uint256 limit
) external;
/**
* @notice Set a delegator.
* @param delegator vault's delegator to delegate the stake to networks and operators
* @dev Can be set only once.
*/
function setDelegator(
address delegator
) external;
/**
* @notice Set a slasher.
* @param slasher vault's slasher to provide a slashing mechanism to networks
* @dev Can be set only once.
*/
function setSlasher(
address slasher
) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {Checkpoints as OZCheckpoints} from "@openzeppelin/contracts/utils/structs/Checkpoints.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
/**
* @dev This library defines the `Trace*` struct, for checkpointing values as they change at different points in
* time, and later looking up past values by key.
*/
library Checkpoints {
using OZCheckpoints for OZCheckpoints.Trace208;
error SystemCheckpoint();
struct Trace208 {
OZCheckpoints.Trace208 _trace;
}
struct Checkpoint208 {
uint48 _key;
uint208 _value;
}
struct Trace256 {
OZCheckpoints.Trace208 _trace;
uint256[] _values;
}
struct Checkpoint256 {
uint48 _key;
uint256 _value;
}
/**
* @dev Pushes a (`key`, `value`) pair into a Trace208 so that it is stored as the checkpoint.
*
* Returns previous value and new value.
*/
function push(Trace208 storage self, uint48 key, uint208 value) internal returns (uint208, uint208) {
return self._trace.push(key, value);
}
/**
* @dev Returns the value in the last (most recent) checkpoint with a key lower or equal than the search key, or zero
* if there is none.
*/
function upperLookupRecent(Trace208 storage self, uint48 key) internal view returns (uint208) {
return self._trace.upperLookupRecent(key);
}
/**
* @dev Returns the value in the last (most recent) checkpoint with a key lower or equal than the search key, or zero
* if there is none.
*
* NOTE: This is a variant of {upperLookupRecent} that can be optimized by getting the hint
* (index of the checkpoint with a key lower or equal than the search key).
*/
function upperLookupRecent(Trace208 storage self, uint48 key, bytes memory hint_) internal view returns (uint208) {
if (hint_.length == 0) {
return upperLookupRecent(self, key);
}
uint32 hint = abi.decode(hint_, (uint32));
Checkpoint208 memory checkpoint = at(self, hint);
if (checkpoint._key == key) {
return checkpoint._value;
}
if (checkpoint._key < key && (hint == length(self) - 1 || at(self, hint + 1)._key > key)) {
return checkpoint._value;
}
return upperLookupRecent(self, key);
}
/**
* @dev Returns whether there is a checkpoint with a key lower or equal than the search key in the structure (i.e. it is not empty),
* and if so the key and value in the checkpoint, and its position in the trace.
*/
function upperLookupRecentCheckpoint(
Trace208 storage self,
uint48 key
) internal view returns (bool, uint48, uint208, uint32) {
uint256 len = self._trace._checkpoints.length;
uint256 low = 0;
uint256 high = len;
if (len > 5) {
uint256 mid = len - Math.sqrt(len);
if (key < _unsafeAccess(self._trace._checkpoints, mid)._key) {
high = mid;
} else {
low = mid + 1;
}
}
uint256 pos = _upperBinaryLookup(self._trace._checkpoints, key, low, high);
if (pos == 0) {
return (false, 0, 0, 0);
}
OZCheckpoints.Checkpoint208 memory checkpoint = _unsafeAccess(self._trace._checkpoints, pos - 1);
return (true, checkpoint._key, checkpoint._value, uint32(pos - 1));
}
/**
* @dev Returns whether there is a checkpoint with a key lower or equal than the search key in the structure (i.e. it is not empty),
* and if so the key and value in the checkpoint, and its position in the trace.
*
* NOTE: This is a variant of {upperLookupRecentCheckpoint} that can be optimized by getting the hint
* (index of the checkpoint with a key lower or equal than the search key).
*/
function upperLookupRecentCheckpoint(
Trace208 storage self,
uint48 key,
bytes memory hint_
) internal view returns (bool, uint48, uint208, uint32) {
if (hint_.length == 0) {
return upperLookupRecentCheckpoint(self, key);
}
uint32 hint = abi.decode(hint_, (uint32));
Checkpoint208 memory checkpoint = at(self, hint);
if (checkpoint._key == key) {
return (true, checkpoint._key, checkpoint._value, hint);
}
if (checkpoint._key < key && (hint == length(self) - 1 || at(self, hint + 1)._key > key)) {
return (true, checkpoint._key, checkpoint._value, hint);
}
return upperLookupRecentCheckpoint(self, key);
}
/**
* @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints.
*/
function latest(
Trace208 storage self
) internal view returns (uint208) {
return self._trace.latest();
}
/**
* @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value
* in the most recent checkpoint.
*/
function latestCheckpoint(
Trace208 storage self
) internal view returns (bool, uint48, uint208) {
return self._trace.latestCheckpoint();
}
/**
* @dev Returns a total number of checkpoints.
*/
function length(
Trace208 storage self
) internal view returns (uint256) {
return self._trace.length();
}
/**
* @dev Returns checkpoint at a given position.
*/
function at(Trace208 storage self, uint32 pos) internal view returns (Checkpoint208 memory) {
OZCheckpoints.Checkpoint208 memory checkpoint = self._trace.at(pos);
return Checkpoint208({_key: checkpoint._key, _value: checkpoint._value});
}
/**
* @dev Pops the last (most recent) checkpoint.
*/
function pop(
Trace208 storage self
) internal returns (uint208 value) {
value = self._trace.latest();
self._trace._checkpoints.pop();
}
/**
* @dev Pushes a (`key`, `value`) pair into a Trace256 so that it is stored as the checkpoint.
*
* Returns previous value and new value.
*/
function push(Trace256 storage self, uint48 key, uint256 value) internal returns (uint256, uint256) {
if (self._values.length == 0) {
self._values.push(0);
}
(bool exists, uint48 lastKey,) = self._trace.latestCheckpoint();
uint256 len = self._values.length;
uint256 lastValue = latest(self);
if (exists && key == lastKey) {
self._values[len - 1] = value;
} else {
self._trace.push(key, uint208(len));
self._values.push(value);
}
return (lastValue, value);
}
/**
* @dev Returns the value in the last (most recent) checkpoint with a key lower or equal than the search key, or zero
* if there is none.
*/
function upperLookupRecent(Trace256 storage self, uint48 key) internal view returns (uint256) {
uint208 idx = self._trace.upperLookupRecent(key);
return idx > 0 ? self._values[idx] : 0;
}
/**
* @dev Returns the value in the last (most recent) checkpoint with a key lower or equal than the search key, or zero
* if there is none.
*
* NOTE: This is a variant of {upperLookupRecent} that can be optimized by getting the hint
* (index of the checkpoint with a key lower or equal than the search key).
*/
function upperLookupRecent(Trace256 storage self, uint48 key, bytes memory hint_) internal view returns (uint256) {
if (hint_.length == 0) {
return upperLookupRecent(self, key);
}
uint32 hint = abi.decode(hint_, (uint32));
Checkpoint256 memory checkpoint = at(self, hint);
if (checkpoint._key == key) {
return checkpoint._value;
}
if (checkpoint._key < key && (hint == length(self) - 1 || at(self, hint + 1)._key > key)) {
return checkpoint._value;
}
return upperLookupRecent(self, key);
}
/**
* @dev Returns whether there is a checkpoint with a key lower or equal than the search key in the structure (i.e. it is not empty),
* and if so the key and value in the checkpoint, and its position in the trace.
*/
function upperLookupRecentCheckpoint(
Trace256 storage self,
uint48 key
) internal view returns (bool, uint48, uint256, uint32) {
uint256 len = self._trace._checkpoints.length;
uint256 low = 0;
uint256 high = len;
if (len > 5) {
uint256 mid = len - Math.sqrt(len);
if (key < _unsafeAccess(self._trace._checkpoints, mid)._key) {
high = mid;
} else {
low = mid + 1;
}
}
uint256 pos = _upperBinaryLookup(self._trace._checkpoints, key, low, high);
if (pos == 0) {
return (false, 0, 0, 0);
}
OZCheckpoints.Checkpoint208 memory checkpoint = _unsafeAccess(self._trace._checkpoints, pos - 1);
return (true, checkpoint._key, self._values[checkpoint._value], uint32(pos - 1));
}
/**
* @dev Returns whether there is a checkpoint with a key lower or equal than the search key in the structure (i.e. it is not empty),
* and if so the key and value in the checkpoint, and its position in the trace.
*
* NOTE: This is a variant of {upperLookupRecentCheckpoint} that can be optimized by getting the hint
* (index of the checkpoint with a key lower or equal than the search key).
*/
function upperLookupRecentCheckpoint(
Trace256 storage self,
uint48 key,
bytes memory hint_
) internal view returns (bool, uint48, uint256, uint32) {
if (hint_.length == 0) {
return upperLookupRecentCheckpoint(self, key);
}
uint32 hint = abi.decode(hint_, (uint32));
Checkpoint256 memory checkpoint = at(self, hint);
if (checkpoint._key == key) {
return (true, checkpoint._key, checkpoint._value, hint);
}
if (checkpoint._key < key && (hint == length(self) - 1 || at(self, hint + 1)._key > key)) {
return (true, checkpoint._key, checkpoint._value, hint);
}
return upperLookupRecentCheckpoint(self, key);
}
/**
* @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints.
*/
function latest(
Trace256 storage self
) internal view returns (uint256) {
uint208 idx = self._trace.latest();
return idx > 0 ? self._values[idx] : 0;
}
/**
* @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value
* in the most recent checkpoint.
*/
function latestCheckpoint(
Trace256 storage self
) internal view returns (bool exists, uint48 _key, uint256 _value) {
uint256 idx;
(exists, _key, idx) = self._trace.latestCheckpoint();
_value = exists ? self._values[idx] : 0;
}
/**
* @dev Returns a total number of checkpoints.
*/
function length(
Trace256 storage self
) internal view returns (uint256) {
return self._trace.length();
}
/**
* @dev Returns checkpoint at a given position.
*/
function at(Trace256 storage self, uint32 pos) internal view returns (Checkpoint256 memory) {
OZCheckpoints.Checkpoint208 memory checkpoint = self._trace.at(pos);
return Checkpoint256({_key: checkpoint._key, _value: self._values[checkpoint._value]});
}
/**
* @dev Pops the last (most recent) checkpoint.
*/
function pop(
Trace256 storage self
) internal returns (uint256 value) {
uint208 idx = self._trace.latest();
if (idx == 0) {
revert SystemCheckpoint();
}
value = self._values[idx];
self._trace._checkpoints.pop();
self._values.pop();
}
/**
* @dev Return the index of the last (most recent) checkpoint with a key lower or equal than the search key, or `high`
* if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive
* `high`.
*
* WARNING: `high` should not be greater than the array's length.
*/
function _upperBinaryLookup(
OZCheckpoints.Checkpoint208[] storage self,
uint48 key,
uint256 low,
uint256 high
) private view returns (uint256) {
while (low < high) {
uint256 mid = Math.average(low, high);
if (_unsafeAccess(self, mid)._key > key) {
high = mid;
} else {
low = mid + 1;
}
}
return high;
}
/**
* @dev Access an element of the array without performing a bounds check. The position is assumed to be within bounds.
*/
function _unsafeAccess(
OZCheckpoints.Checkpoint208[] storage self,
uint256 pos
) private pure returns (OZCheckpoints.Checkpoint208 storage result) {
assembly {
mstore(0, self.slot)
result.slot := add(keccak256(0, 0x20), pos)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import {ContextUpgradeable} from "../../utils/ContextUpgradeable.sol";
import {IERC20Errors} from "@openzeppelin/contracts/interfaces/draft-IERC6093.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*/
abstract contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20, IERC20Metadata, IERC20Errors {
/// @custom:storage-location erc7201:openzeppelin.storage.ERC20
struct ERC20Storage {
mapping(address account => uint256) _balances;
mapping(address account => mapping(address spender => uint256)) _allowances;
uint256 _totalSupply;
string _name;
string _symbol;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC20")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant ERC20StorageLocation = 0x52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00;
function _getERC20Storage() private pure returns (ERC20Storage storage $) {
assembly {
$.slot := ERC20StorageLocation
}
}
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {
__ERC20_init_unchained(name_, symbol_);
}
function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {
ERC20Storage storage $ = _getERC20Storage();
$._name = name_;
$._symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
ERC20Storage storage $ = _getERC20Storage();
return $._name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
ERC20Storage storage $ = _getERC20Storage();
return $._symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual returns (uint256) {
ERC20Storage storage $ = _getERC20Storage();
return $._totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual returns (uint256) {
ERC20Storage storage $ = _getERC20Storage();
return $._balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `value`.
*/
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual returns (uint256) {
ERC20Storage storage $ = _getERC20Storage();
return $._allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `value`.
* - the caller must have allowance for ``from``'s tokens of at least
* `value`.
*/
function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
/**
* @dev Moves a `value` amount of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _transfer(address from, address to, uint256 value) internal {
if (from == address(0)) {
revert ERC20InvalidSender(address(0));
}
if (to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(from, to, value);
}
/**
* @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
* (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
* this function.
*
* Emits a {Transfer} event.
*/
function _update(address from, address to, uint256 value) internal virtual {
ERC20Storage storage $ = _getERC20Storage();
if (from == address(0)) {
// Overflow check required: The rest of the code assumes that totalSupply never overflows
$._totalSupply += value;
} else {
uint256 fromBalance = $._balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
// Overflow not possible: value <= fromBalance <= totalSupply.
$._balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
// Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
$._totalSupply -= value;
}
} else {
unchecked {
// Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
$._balances[to] += value;
}
}
emit Transfer(from, to, value);
}
/**
* @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
* Relies on the `_update` mechanism
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(address(0), account, value);
}
/**
* @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
* Relies on the `_update` mechanism.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead
*/
function _burn(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidSender(address(0));
}
_update(account, address(0), value);
}
/**
* @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address owner, address spender, uint256 value) internal {
_approve(owner, spender, value, true);
}
/**
* @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
*
* By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
* `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
* `Approval` event during `transferFrom` operations.
*
* Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
* true using the following override:
* ```
* function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
* super._approve(owner, spender, value, true);
* }
* ```
*
* Requirements are the same as {_approve}.
*/
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
ERC20Storage storage $ = _getERC20Storage();
if (owner == address(0)) {
revert ERC20InvalidApprover(address(0));
}
if (spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
$._allowances[owner][spender] = value;
if (emitEvent) {
emit Approval(owner, spender, value);
}
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `value`.
*
* Does not update the allowance value in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Does not emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
if (currentAllowance < value) {
revert ERC20InsufficientAllowance(spender, currentAllowance, value);
}
unchecked {
_approve(owner, spender, currentAllowance - value, false);
}
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev An operation with an ERC20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data);
if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
}
}// 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 {IMigratableEntity} from "../../interfaces/common/IMigratableEntity.sol";
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
abstract contract MigratableEntity is
Initializable,
OwnableUpgradeable,
ReentrancyGuardUpgradeable,
IMigratableEntity
{
/**
* @inheritdoc IMigratableEntity
*/
address public immutable FACTORY;
modifier notInitialized() {
if (_getInitializedVersion() != 0) {
revert AlreadyInitialized();
}
_;
}
constructor(
address factory
) {
_disableInitializers();
FACTORY = factory;
}
/**
* @inheritdoc IMigratableEntity
*/
function version() external view returns (uint64) {
return _getInitializedVersion();
}
/**
* @inheritdoc IMigratableEntity
*/
function initialize(
uint64 initialVersion,
address owner_,
bytes calldata data
) external notInitialized reinitializer(initialVersion) {
__ReentrancyGuard_init();
if (owner_ != address(0)) {
__Ownable_init(owner_);
}
_initialize(initialVersion, owner_, data);
}
/**
* @inheritdoc IMigratableEntity
*/
function migrate(uint64 newVersion, bytes calldata data) external nonReentrant {
if (msg.sender != FACTORY) {
revert NotFactory();
}
_migrateInternal(_getInitializedVersion(), newVersion, data);
}
function _migrateInternal(
uint64 oldVersion,
uint64 newVersion,
bytes calldata data
) private reinitializer(newVersion) {
_migrate(oldVersion, newVersion, data);
}
function _initialize(uint64, /* initialVersion */ address, /* owner */ bytes memory /* data */ ) internal virtual {}
function _migrate(uint64, /* oldVersion */ uint64, /* newVersion */ bytes calldata /* data */ ) internal virtual {}
uint256[10] private __gap;
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
import {StaticDelegateCallable} from "../common/StaticDelegateCallable.sol";
import {IVaultStorage} from "../../interfaces/vault/IVaultStorage.sol";
import {Checkpoints} from "../libraries/Checkpoints.sol";
import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";
import {Time} from "@openzeppelin/contracts/utils/types/Time.sol";
abstract contract VaultStorage is StaticDelegateCallable, IVaultStorage {
using Checkpoints for Checkpoints.Trace256;
using SafeCast for uint256;
/**
* @inheritdoc IVaultStorage
*/
bytes32 public constant DEPOSIT_WHITELIST_SET_ROLE = keccak256("DEPOSIT_WHITELIST_SET_ROLE");
/**
* @inheritdoc IVaultStorage
*/
bytes32 public constant DEPOSITOR_WHITELIST_ROLE = keccak256("DEPOSITOR_WHITELIST_ROLE");
/**
* @inheritdoc IVaultStorage
*/
bytes32 public constant IS_DEPOSIT_LIMIT_SET_ROLE = keccak256("IS_DEPOSIT_LIMIT_SET_ROLE");
/**
* @inheritdoc IVaultStorage
*/
bytes32 public constant DEPOSIT_LIMIT_SET_ROLE = keccak256("DEPOSIT_LIMIT_SET_ROLE");
/**
* @inheritdoc IVaultStorage
*/
address public immutable DELEGATOR_FACTORY;
/**
* @inheritdoc IVaultStorage
*/
address public immutable SLASHER_FACTORY;
/**
* @inheritdoc IVaultStorage
*/
bool public depositWhitelist;
/**
* @inheritdoc IVaultStorage
*/
bool public isDepositLimit;
/**
* @inheritdoc IVaultStorage
*/
address public collateral;
/**
* @inheritdoc IVaultStorage
*/
address public burner;
/**
* @inheritdoc IVaultStorage
*/
uint48 public epochDurationInit;
/**
* @inheritdoc IVaultStorage
*/
uint48 public epochDuration;
/**
* @inheritdoc IVaultStorage
*/
address public delegator;
/**
* @inheritdoc IVaultStorage
*/
bool public isDelegatorInitialized;
/**
* @inheritdoc IVaultStorage
*/
address public slasher;
/**
* @inheritdoc IVaultStorage
*/
bool public isSlasherInitialized;
/**
* @inheritdoc IVaultStorage
*/
uint256 public depositLimit;
/**
* @inheritdoc IVaultStorage
*/
mapping(address account => bool value) public isDepositorWhitelisted;
/**
* @inheritdoc IVaultStorage
*/
mapping(uint256 epoch => uint256 amount) public withdrawals;
/**
* @inheritdoc IVaultStorage
*/
mapping(uint256 epoch => uint256 amount) public withdrawalShares;
/**
* @inheritdoc IVaultStorage
*/
mapping(uint256 epoch => mapping(address account => uint256 amount)) public withdrawalSharesOf;
/**
* @inheritdoc IVaultStorage
*/
mapping(uint256 epoch => mapping(address account => bool value)) public isWithdrawalsClaimed;
Checkpoints.Trace256 internal _activeShares;
Checkpoints.Trace256 internal _activeStake;
mapping(address account => Checkpoints.Trace256 shares) internal _activeSharesOf;
constructor(address delegatorFactory, address slasherFactory) {
DELEGATOR_FACTORY = delegatorFactory;
SLASHER_FACTORY = slasherFactory;
}
/**
* @inheritdoc IVaultStorage
*/
function epochAt(
uint48 timestamp
) public view returns (uint256) {
if (timestamp < epochDurationInit) {
revert InvalidTimestamp();
}
return (timestamp - epochDurationInit) / epochDuration;
}
/**
* @inheritdoc IVaultStorage
*/
function currentEpoch() public view returns (uint256) {
return (Time.timestamp() - epochDurationInit) / epochDuration;
}
/**
* @inheritdoc IVaultStorage
*/
function currentEpochStart() public view returns (uint48) {
return (epochDurationInit + currentEpoch() * epochDuration).toUint48();
}
/**
* @inheritdoc IVaultStorage
*/
function previousEpochStart() public view returns (uint48) {
uint256 epoch = currentEpoch();
if (epoch == 0) {
revert NoPreviousEpoch();
}
return (epochDurationInit + (epoch - 1) * epochDuration).toUint48();
}
/**
* @inheritdoc IVaultStorage
*/
function nextEpochStart() public view returns (uint48) {
return (epochDurationInit + (currentEpoch() + 1) * epochDuration).toUint48();
}
/**
* @inheritdoc IVaultStorage
*/
function activeSharesAt(uint48 timestamp, bytes memory hint) public view returns (uint256) {
return _activeShares.upperLookupRecent(timestamp, hint);
}
/**
* @inheritdoc IVaultStorage
*/
function activeShares() public view returns (uint256) {
return _activeShares.latest();
}
/**
* @inheritdoc IVaultStorage
*/
function activeStakeAt(uint48 timestamp, bytes memory hint) public view returns (uint256) {
return _activeStake.upperLookupRecent(timestamp, hint);
}
/**
* @inheritdoc IVaultStorage
*/
function activeStake() public view returns (uint256) {
return _activeStake.latest();
}
/**
* @inheritdoc IVaultStorage
*/
function activeSharesOfAt(address account, uint48 timestamp, bytes memory hint) public view returns (uint256) {
return _activeSharesOf[account].upperLookupRecent(timestamp, hint);
}
/**
* @inheritdoc IVaultStorage
*/
function activeSharesOf(
address account
) public view returns (uint256) {
return _activeSharesOf[account].latest();
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IEntity} from "../common/IEntity.sol";
interface IBaseDelegator is IEntity {
error AlreadySet();
error InsufficientHookGas();
error NotNetwork();
error NotSlasher();
error NotVault();
/**
* @notice Base parameters needed for delegators' deployment.
* @param defaultAdminRoleHolder address of the initial DEFAULT_ADMIN_ROLE holder
* @param hook address of the hook contract
* @param hookSetRoleHolder address of the initial HOOK_SET_ROLE holder
*/
struct BaseParams {
address defaultAdminRoleHolder;
address hook;
address hookSetRoleHolder;
}
/**
* @notice Base hints for a stake.
* @param operatorVaultOptInHint hint for the operator-vault opt-in
* @param operatorNetworkOptInHint hint for the operator-network opt-in
*/
struct StakeBaseHints {
bytes operatorVaultOptInHint;
bytes operatorNetworkOptInHint;
}
/**
* @notice Emitted when a subnetwork's maximum limit is set.
* @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier)
* @param amount new maximum subnetwork's limit (how much stake the subnetwork is ready to get)
*/
event SetMaxNetworkLimit(bytes32 indexed subnetwork, uint256 amount);
/**
* @notice Emitted when a slash happens.
* @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier)
* @param operator address of the operator
* @param amount amount of the collateral to be slashed
* @param captureTimestamp time point when the stake was captured
*/
event OnSlash(bytes32 indexed subnetwork, address indexed operator, uint256 amount, uint48 captureTimestamp);
/**
* @notice Emitted when a hook is set.
* @param hook address of the hook
*/
event SetHook(address indexed hook);
/**
* @notice Get a version of the delegator (different versions mean different interfaces).
* @return version of the delegator
* @dev Must return 1 for this one.
*/
function VERSION() external view returns (uint64);
/**
* @notice Get the network registry's address.
* @return address of the network registry
*/
function NETWORK_REGISTRY() external view returns (address);
/**
* @notice Get the vault factory's address.
* @return address of the vault factory
*/
function VAULT_FACTORY() external view returns (address);
/**
* @notice Get the operator-vault opt-in service's address.
* @return address of the operator-vault opt-in service
*/
function OPERATOR_VAULT_OPT_IN_SERVICE() external view returns (address);
/**
* @notice Get the operator-network opt-in service's address.
* @return address of the operator-network opt-in service
*/
function OPERATOR_NETWORK_OPT_IN_SERVICE() external view returns (address);
/**
* @notice Get a gas limit for the hook.
* @return value of the hook gas limit
*/
function HOOK_GAS_LIMIT() external view returns (uint256);
/**
* @notice Get a reserve gas between the gas limit check and the hook's execution.
* @return value of the reserve gas
*/
function HOOK_RESERVE() external view returns (uint256);
/**
* @notice Get a hook setter's role.
* @return identifier of the hook setter role
*/
function HOOK_SET_ROLE() external view returns (bytes32);
/**
* @notice Get the vault's address.
* @return address of the vault
*/
function vault() external view returns (address);
/**
* @notice Get the hook's address.
* @return address of the hook
* @dev The hook can have arbitrary logic under certain functions, however, it doesn't affect the stake guarantees.
*/
function hook() external view returns (address);
/**
* @notice Get a particular subnetwork's maximum limit
* (meaning the subnetwork is not ready to get more as a stake).
* @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier)
* @return maximum limit of the subnetwork
*/
function maxNetworkLimit(
bytes32 subnetwork
) external view returns (uint256);
/**
* @notice Get a stake that a given subnetwork could be able to slash for a certain operator at a given timestamp
* until the end of the consequent epoch using hints (if no cross-slashing and no slashings by the subnetwork).
* @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier)
* @param operator address of the operator
* @param timestamp time point to capture the stake at
* @param hints hints for the checkpoints' indexes
* @return slashable stake at the given timestamp until the end of the consequent epoch
* @dev Warning: it is not safe to use timestamp >= current one for the stake capturing, as it can change later.
*/
function stakeAt(
bytes32 subnetwork,
address operator,
uint48 timestamp,
bytes memory hints
) external view returns (uint256);
/**
* @notice Get a stake that a given subnetwork will be able to slash
* for a certain operator until the end of the next epoch (if no cross-slashing and no slashings by the subnetwork).
* @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier)
* @param operator address of the operator
* @return slashable stake until the end of the next epoch
* @dev Warning: this function is not safe to use for stake capturing, as it can change by the end of the block.
*/
function stake(bytes32 subnetwork, address operator) external view returns (uint256);
/**
* @notice Set a maximum limit for a subnetwork (how much stake the subnetwork is ready to get).
* identifier identifier of the subnetwork
* @param amount new maximum subnetwork's limit
* @dev Only a network can call this function.
*/
function setMaxNetworkLimit(uint96 identifier, uint256 amount) external;
/**
* @notice Set a new hook.
* @param hook address of the hook
* @dev Only a HOOK_SET_ROLE holder can call this function.
* The hook can have arbitrary logic under certain functions, however, it doesn't affect the stake guarantees.
*/
function setHook(
address hook
) external;
/**
* @notice Called when a slash happens.
* @param subnetwork full identifier of the subnetwork (address of the network concatenated with the uint96 identifier)
* @param operator address of the operator
* @param amount amount of the collateral slashed
* @param captureTimestamp time point when the stake was captured
* @param data some additional data
* @dev Only the vault's slasher can call this function.
*/
function onSlash(
bytes32 subnetwork,
address operator,
uint256 amount,
uint48 captureTimestamp,
bytes calldata data
) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IEntity} from "../common/IEntity.sol";
interface IBaseSlasher is IEntity {
error NoBurner();
error InsufficientBurnerGas();
error NotNetworkMiddleware();
error NotVault();
/**
* @notice Base parameters needed for slashers' deployment.
* @param isBurnerHook if the burner is needed to be called on a slashing
*/
struct BaseParams {
bool isBurnerHook;
}
/**
* @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 General data for the delegator.
* @param slasherType type of the slasher
* @param data slasher-dependent data for the delegator
*/
struct GeneralDelegatorData {
uint64 slasherType;
bytes data;
}
/**
* @notice Get a gas limit for the burner.
* @return value of the burner gas limit
*/
function BURNER_GAS_LIMIT() external view returns (uint256);
/**
* @notice Get a reserve gas between the gas limit check and the burner's execution.
* @return value of the reserve gas
*/
function BURNER_RESERVE() external view returns (uint256);
/**
* @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 if the burner is needed to be called on a slashing.
* @return if the burner is a hook
*/
function isBurnerHook() external view returns (bool);
/**
* @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)
* @param operator address of the operator
* @return latest capture timestamp that was slashed
*/
function latestSlashedCaptureTimestamp(bytes32 subnetwork, address operator) 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: MIT
pragma solidity ^0.8.0;
interface IRegistry {
error EntityNotExist();
/**
* @notice Emitted when an entity is added.
* @param entity address of the added entity
*/
event AddEntity(address indexed entity);
/**
* @notice Get if a given address is an entity.
* @param account address to check
* @return if the given address is an entity
*/
function isEntity(
address account
) external view returns (bool);
/**
* @notice Get a total number of entities.
* @return total number of entities added
*/
function totalEntities() external view returns (uint256);
/**
* @notice Get an entity given its index.
* @param index index of the entity to get
* @return address of the entity
*/
function entity(
uint256 index
) external view returns (address);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
/**
* @dev This library adds helper functions for ERC4626 math operations.
*/
library ERC4626Math {
using Math for uint256;
function previewDeposit(uint256 assets, uint256 totalShares, uint256 totalAssets) internal pure returns (uint256) {
return convertToShares(assets, totalShares, totalAssets, Math.Rounding.Floor);
}
function previewMint(uint256 shares, uint256 totalAssets, uint256 totalShares) internal pure returns (uint256) {
return convertToAssets(shares, totalAssets, totalShares, Math.Rounding.Ceil);
}
function previewWithdraw(
uint256 assets,
uint256 totalShares,
uint256 totalAssets
) internal pure returns (uint256) {
return convertToShares(assets, totalShares, totalAssets, Math.Rounding.Ceil);
}
function previewRedeem(uint256 shares, uint256 totalAssets, uint256 totalShares) internal pure returns (uint256) {
return convertToAssets(shares, totalAssets, totalShares, Math.Rounding.Floor);
}
/**
* @dev Internal conversion function (from assets to shares) with support for rounding direction.
*/
function convertToShares(
uint256 assets,
uint256 totalShares,
uint256 totalAssets,
Math.Rounding rounding
) internal pure returns (uint256) {
return assets.mulDiv(totalShares + 10 ** _decimalsOffset(), totalAssets + 1, rounding);
}
/**
* @dev Internal conversion function (from shares to assets) with support for rounding direction.
*/
function convertToAssets(
uint256 shares,
uint256 totalAssets,
uint256 totalShares,
Math.Rounding rounding
) internal pure returns (uint256) {
return shares.mulDiv(totalAssets + 1, totalShares + 10 ** _decimalsOffset(), rounding);
}
function _decimalsOffset() private pure returns (uint8) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {ERC165Upgradeable} from "../utils/introspection/ERC165Upgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {
struct RoleData {
mapping(address account => bool) hasRole;
bytes32 adminRole;
}
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/// @custom:storage-location erc7201:openzeppelin.storage.AccessControl
struct AccessControlStorage {
mapping(bytes32 role => RoleData) _roles;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControl")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;
function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {
assembly {
$.slot := AccessControlStorageLocation
}
}
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with an {AccessControlUnauthorizedAccount} error including the required role.
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
function __AccessControl_init() internal onlyInitializing {
}
function __AccessControl_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
return $._roles[role].hasRole[account];
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
* is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
* is missing `role`.
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert AccessControlUnauthorizedAccount(account, role);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
AccessControlStorage storage $ = _getAccessControlStorage();
return $._roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address callerConfirmation) public virtual {
if (callerConfirmation != _msgSender()) {
revert AccessControlBadConfirmation();
}
_revokeRole(role, callerConfirmation);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
AccessControlStorage storage $ = _getAccessControlStorage();
bytes32 previousAdminRole = getRoleAdmin(role);
$._roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
if (!hasRole(role, account)) {
$._roles[role].hasRole[account] = true;
emit RoleGranted(role, account, _msgSender());
return true;
} else {
return false;
}
}
/**
* @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
if (hasRole(role, account)) {
$._roles[role].hasRole[account] = false;
emit RoleRevoked(role, account, _msgSender());
return true;
} else {
return false;
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/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
pragma solidity ^0.8.0;
interface IMigratableEntity {
error AlreadyInitialized();
error NotFactory();
error NotInitialized();
/**
* @notice Get the factory's address.
* @return address of the factory
*/
function FACTORY() external view returns (address);
/**
* @notice Get the entity's version.
* @return version of the entity
* @dev Starts from 1.
*/
function version() external view returns (uint64);
/**
* @notice Initialize this entity contract by using a given data and setting a particular version and owner.
* @param initialVersion initial version of the entity
* @param owner initial owner of the entity
* @param data some data to use
*/
function initialize(uint64 initialVersion, address owner, bytes calldata data) external;
/**
* @notice Migrate this entity to a particular newer version using a given data.
* @param newVersion new version of the entity
* @param data some data to use
*/
function migrate(uint64 newVersion, bytes calldata data) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IVaultStorage {
error InvalidTimestamp();
error NoPreviousEpoch();
/**
* @notice Get a deposit whitelist enabler/disabler's role.
* @return identifier of the whitelist enabler/disabler role
*/
function DEPOSIT_WHITELIST_SET_ROLE() external view returns (bytes32);
/**
* @notice Get a depositor whitelist status setter's role.
* @return identifier of the depositor whitelist status setter role
*/
function DEPOSITOR_WHITELIST_ROLE() external view returns (bytes32);
/**
* @notice Get a deposit limit enabler/disabler's role.
* @return identifier of the deposit limit enabler/disabler role
*/
function IS_DEPOSIT_LIMIT_SET_ROLE() external view returns (bytes32);
/**
* @notice Get a deposit limit setter's role.
* @return identifier of the deposit limit setter role
*/
function DEPOSIT_LIMIT_SET_ROLE() external view returns (bytes32);
/**
* @notice Get the delegator factory's address.
* @return address of the delegator factory
*/
function DELEGATOR_FACTORY() external view returns (address);
/**
* @notice Get the slasher factory's address.
* @return address of the slasher factory
*/
function SLASHER_FACTORY() external view returns (address);
/**
* @notice Get a vault collateral.
* @return address of the underlying collateral
*/
function collateral() external view returns (address);
/**
* @notice Get a burner to issue debt to (e.g., 0xdEaD or some unwrapper contract).
* @return address of the burner
*/
function burner() external view returns (address);
/**
* @notice Get a delegator (it delegates the vault's stake to networks and operators).
* @return address of the delegator
*/
function delegator() external view returns (address);
/**
* @notice Get if the delegator is initialized.
* @return if the delegator is initialized
*/
function isDelegatorInitialized() external view returns (bool);
/**
* @notice Get a slasher (it provides networks a slashing mechanism).
* @return address of the slasher
*/
function slasher() external view returns (address);
/**
* @notice Get if the slasher is initialized.
* @return if the slasher is initialized
*/
function isSlasherInitialized() external view returns (bool);
/**
* @notice Get a time point of the epoch duration set.
* @return time point of the epoch duration set
*/
function epochDurationInit() external view returns (uint48);
/**
* @notice Get a duration of the vault epoch.
* @return duration of the epoch
*/
function epochDuration() external view returns (uint48);
/**
* @notice Get an epoch at a given timestamp.
* @param timestamp time point to get the epoch at
* @return epoch at the timestamp
* @dev Reverts if the timestamp is less than the start of the epoch 0.
*/
function epochAt(
uint48 timestamp
) external view returns (uint256);
/**
* @notice Get a current vault epoch.
* @return current epoch
*/
function currentEpoch() external view returns (uint256);
/**
* @notice Get a start of the current vault epoch.
* @return start of the current epoch
*/
function currentEpochStart() external view returns (uint48);
/**
* @notice Get a start of the previous vault epoch.
* @return start of the previous epoch
* @dev Reverts if the current epoch is 0.
*/
function previousEpochStart() external view returns (uint48);
/**
* @notice Get a start of the next vault epoch.
* @return start of the next epoch
*/
function nextEpochStart() external view returns (uint48);
/**
* @notice Get if the deposit whitelist is enabled.
* @return if the deposit whitelist is enabled
*/
function depositWhitelist() external view returns (bool);
/**
* @notice Get if a given account is whitelisted as a depositor.
* @param account address to check
* @return if the account is whitelisted as a depositor
*/
function isDepositorWhitelisted(
address account
) external view returns (bool);
/**
* @notice Get if the deposit limit is set.
* @return if the deposit limit is set
*/
function isDepositLimit() external view returns (bool);
/**
* @notice Get a deposit limit (maximum amount of the active stake that can be in the vault simultaneously).
* @return deposit limit
*/
function depositLimit() external view returns (uint256);
/**
* @notice Get a total number of active shares in the vault at a given timestamp using a hint.
* @param timestamp time point to get the total number of active shares at
* @param hint hint for the checkpoint index
* @return total number of active shares at the timestamp
*/
function activeSharesAt(uint48 timestamp, bytes memory hint) external view returns (uint256);
/**
* @notice Get a total number of active shares in the vault.
* @return total number of active shares
*/
function activeShares() external view returns (uint256);
/**
* @notice Get a total amount of active stake in the vault at a given timestamp using a hint.
* @param timestamp time point to get the total active stake at
* @param hint hint for the checkpoint index
* @return total amount of active stake at the timestamp
*/
function activeStakeAt(uint48 timestamp, bytes memory hint) external view returns (uint256);
/**
* @notice Get a total amount of active stake in the vault.
* @return total amount of active stake
*/
function activeStake() external view returns (uint256);
/**
* @notice Get a total number of active shares for a particular account at a given timestamp using a hint.
* @param account account to get the number of active shares for
* @param timestamp time point to get the number of active shares for the account at
* @param hint hint for the checkpoint index
* @return number of active shares for the account at the timestamp
*/
function activeSharesOfAt(address account, uint48 timestamp, bytes memory hint) external view returns (uint256);
/**
* @notice Get a number of active shares for a particular account.
* @param account account to get the number of active shares for
* @return number of active shares for the account
*/
function activeSharesOf(
address account
) external view returns (uint256);
/**
* @notice Get a total amount of the withdrawals at a given epoch.
* @param epoch epoch to get the total amount of the withdrawals at
* @return total amount of the withdrawals at the epoch
*/
function withdrawals(
uint256 epoch
) external view returns (uint256);
/**
* @notice Get a total number of withdrawal shares at a given epoch.
* @param epoch epoch to get the total number of withdrawal shares at
* @return total number of withdrawal shares at the epoch
*/
function withdrawalShares(
uint256 epoch
) external view returns (uint256);
/**
* @notice Get a number of withdrawal shares for a particular account at a given epoch (zero if claimed).
* @param epoch epoch to get the number of withdrawal shares for the account at
* @param account account to get the number of withdrawal shares for
* @return number of withdrawal shares for the account at the epoch
*/
function withdrawalSharesOf(uint256 epoch, address account) external view returns (uint256);
/**
* @notice Get if the withdrawals are claimed for a particular account at a given epoch.
* @param epoch epoch to check the withdrawals for the account at
* @param account account to check the withdrawals for
* @return if the withdrawals are claimed for the account at the epoch
*/
function isWithdrawalsClaimed(uint256 epoch, address account) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/Checkpoints.sol)
// This file was procedurally generated from scripts/generate/templates/Checkpoints.js.
pragma solidity ^0.8.20;
import {Math} from "../math/Math.sol";
/**
* @dev This library defines the `Trace*` struct, for checkpointing values as they change at different points in
* time, and later looking up past values by block number. See {Votes} as an example.
*
* To create a history of checkpoints define a variable type `Checkpoints.Trace*` in your contract, and store a new
* checkpoint for the current transaction block using the {push} function.
*/
library Checkpoints {
/**
* @dev A value was attempted to be inserted on a past checkpoint.
*/
error CheckpointUnorderedInsertion();
struct Trace224 {
Checkpoint224[] _checkpoints;
}
struct Checkpoint224 {
uint32 _key;
uint224 _value;
}
/**
* @dev Pushes a (`key`, `value`) pair into a Trace224 so that it is stored as the checkpoint.
*
* Returns previous value and new value.
*
* IMPORTANT: Never accept `key` as a user input, since an arbitrary `type(uint32).max` key set will disable the
* library.
*/
function push(Trace224 storage self, uint32 key, uint224 value) internal returns (uint224, uint224) {
return _insert(self._checkpoints, key, value);
}
/**
* @dev Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if
* there is none.
*/
function lowerLookup(Trace224 storage self, uint32 key) internal view returns (uint224) {
uint256 len = self._checkpoints.length;
uint256 pos = _lowerBinaryLookup(self._checkpoints, key, 0, len);
return pos == len ? 0 : _unsafeAccess(self._checkpoints, pos)._value;
}
/**
* @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
* if there is none.
*/
function upperLookup(Trace224 storage self, uint32 key) internal view returns (uint224) {
uint256 len = self._checkpoints.length;
uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, len);
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
* if there is none.
*
* NOTE: This is a variant of {upperLookup} that is optimised to find "recent" checkpoint (checkpoints with high
* keys).
*/
function upperLookupRecent(Trace224 storage self, uint32 key) internal view returns (uint224) {
uint256 len = self._checkpoints.length;
uint256 low = 0;
uint256 high = len;
if (len > 5) {
uint256 mid = len - Math.sqrt(len);
if (key < _unsafeAccess(self._checkpoints, mid)._key) {
high = mid;
} else {
low = mid + 1;
}
}
uint256 pos = _upperBinaryLookup(self._checkpoints, key, low, high);
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints.
*/
function latest(Trace224 storage self) internal view returns (uint224) {
uint256 pos = self._checkpoints.length;
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value
* in the most recent checkpoint.
*/
function latestCheckpoint(Trace224 storage self) internal view returns (bool exists, uint32 _key, uint224 _value) {
uint256 pos = self._checkpoints.length;
if (pos == 0) {
return (false, 0, 0);
} else {
Checkpoint224 memory ckpt = _unsafeAccess(self._checkpoints, pos - 1);
return (true, ckpt._key, ckpt._value);
}
}
/**
* @dev Returns the number of checkpoint.
*/
function length(Trace224 storage self) internal view returns (uint256) {
return self._checkpoints.length;
}
/**
* @dev Returns checkpoint at given position.
*/
function at(Trace224 storage self, uint32 pos) internal view returns (Checkpoint224 memory) {
return self._checkpoints[pos];
}
/**
* @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint,
* or by updating the last one.
*/
function _insert(Checkpoint224[] storage self, uint32 key, uint224 value) private returns (uint224, uint224) {
uint256 pos = self.length;
if (pos > 0) {
// Copying to memory is important here.
Checkpoint224 memory last = _unsafeAccess(self, pos - 1);
// Checkpoint keys must be non-decreasing.
if (last._key > key) {
revert CheckpointUnorderedInsertion();
}
// Update or push new checkpoint
if (last._key == key) {
_unsafeAccess(self, pos - 1)._value = value;
} else {
self.push(Checkpoint224({_key: key, _value: value}));
}
return (last._value, value);
} else {
self.push(Checkpoint224({_key: key, _value: value}));
return (0, value);
}
}
/**
* @dev Return the index of the last (most recent) checkpoint with key lower or equal than the search key, or `high`
* if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive
* `high`.
*
* WARNING: `high` should not be greater than the array's length.
*/
function _upperBinaryLookup(
Checkpoint224[] storage self,
uint32 key,
uint256 low,
uint256 high
) private view returns (uint256) {
while (low < high) {
uint256 mid = Math.average(low, high);
if (_unsafeAccess(self, mid)._key > key) {
high = mid;
} else {
low = mid + 1;
}
}
return high;
}
/**
* @dev Return the index of the first (oldest) checkpoint with key is greater or equal than the search key, or
* `high` if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and
* exclusive `high`.
*
* WARNING: `high` should not be greater than the array's length.
*/
function _lowerBinaryLookup(
Checkpoint224[] storage self,
uint32 key,
uint256 low,
uint256 high
) private view returns (uint256) {
while (low < high) {
uint256 mid = Math.average(low, high);
if (_unsafeAccess(self, mid)._key < key) {
low = mid + 1;
} else {
high = mid;
}
}
return high;
}
/**
* @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.
*/
function _unsafeAccess(
Checkpoint224[] storage self,
uint256 pos
) private pure returns (Checkpoint224 storage result) {
assembly {
mstore(0, self.slot)
result.slot := add(keccak256(0, 0x20), pos)
}
}
struct Trace208 {
Checkpoint208[] _checkpoints;
}
struct Checkpoint208 {
uint48 _key;
uint208 _value;
}
/**
* @dev Pushes a (`key`, `value`) pair into a Trace208 so that it is stored as the checkpoint.
*
* Returns previous value and new value.
*
* IMPORTANT: Never accept `key` as a user input, since an arbitrary `type(uint48).max` key set will disable the
* library.
*/
function push(Trace208 storage self, uint48 key, uint208 value) internal returns (uint208, uint208) {
return _insert(self._checkpoints, key, value);
}
/**
* @dev Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if
* there is none.
*/
function lowerLookup(Trace208 storage self, uint48 key) internal view returns (uint208) {
uint256 len = self._checkpoints.length;
uint256 pos = _lowerBinaryLookup(self._checkpoints, key, 0, len);
return pos == len ? 0 : _unsafeAccess(self._checkpoints, pos)._value;
}
/**
* @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
* if there is none.
*/
function upperLookup(Trace208 storage self, uint48 key) internal view returns (uint208) {
uint256 len = self._checkpoints.length;
uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, len);
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
* if there is none.
*
* NOTE: This is a variant of {upperLookup} that is optimised to find "recent" checkpoint (checkpoints with high
* keys).
*/
function upperLookupRecent(Trace208 storage self, uint48 key) internal view returns (uint208) {
uint256 len = self._checkpoints.length;
uint256 low = 0;
uint256 high = len;
if (len > 5) {
uint256 mid = len - Math.sqrt(len);
if (key < _unsafeAccess(self._checkpoints, mid)._key) {
high = mid;
} else {
low = mid + 1;
}
}
uint256 pos = _upperBinaryLookup(self._checkpoints, key, low, high);
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints.
*/
function latest(Trace208 storage self) internal view returns (uint208) {
uint256 pos = self._checkpoints.length;
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value
* in the most recent checkpoint.
*/
function latestCheckpoint(Trace208 storage self) internal view returns (bool exists, uint48 _key, uint208 _value) {
uint256 pos = self._checkpoints.length;
if (pos == 0) {
return (false, 0, 0);
} else {
Checkpoint208 memory ckpt = _unsafeAccess(self._checkpoints, pos - 1);
return (true, ckpt._key, ckpt._value);
}
}
/**
* @dev Returns the number of checkpoint.
*/
function length(Trace208 storage self) internal view returns (uint256) {
return self._checkpoints.length;
}
/**
* @dev Returns checkpoint at given position.
*/
function at(Trace208 storage self, uint32 pos) internal view returns (Checkpoint208 memory) {
return self._checkpoints[pos];
}
/**
* @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint,
* or by updating the last one.
*/
function _insert(Checkpoint208[] storage self, uint48 key, uint208 value) private returns (uint208, uint208) {
uint256 pos = self.length;
if (pos > 0) {
// Copying to memory is important here.
Checkpoint208 memory last = _unsafeAccess(self, pos - 1);
// Checkpoint keys must be non-decreasing.
if (last._key > key) {
revert CheckpointUnorderedInsertion();
}
// Update or push new checkpoint
if (last._key == key) {
_unsafeAccess(self, pos - 1)._value = value;
} else {
self.push(Checkpoint208({_key: key, _value: value}));
}
return (last._value, value);
} else {
self.push(Checkpoint208({_key: key, _value: value}));
return (0, value);
}
}
/**
* @dev Return the index of the last (most recent) checkpoint with key lower or equal than the search key, or `high`
* if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive
* `high`.
*
* WARNING: `high` should not be greater than the array's length.
*/
function _upperBinaryLookup(
Checkpoint208[] storage self,
uint48 key,
uint256 low,
uint256 high
) private view returns (uint256) {
while (low < high) {
uint256 mid = Math.average(low, high);
if (_unsafeAccess(self, mid)._key > key) {
high = mid;
} else {
low = mid + 1;
}
}
return high;
}
/**
* @dev Return the index of the first (oldest) checkpoint with key is greater or equal than the search key, or
* `high` if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and
* exclusive `high`.
*
* WARNING: `high` should not be greater than the array's length.
*/
function _lowerBinaryLookup(
Checkpoint208[] storage self,
uint48 key,
uint256 low,
uint256 high
) private view returns (uint256) {
while (low < high) {
uint256 mid = Math.average(low, high);
if (_unsafeAccess(self, mid)._key < key) {
low = mid + 1;
} else {
high = mid;
}
}
return high;
}
/**
* @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.
*/
function _unsafeAccess(
Checkpoint208[] storage self,
uint256 pos
) private pure returns (Checkpoint208 storage result) {
assembly {
mstore(0, self.slot)
result.slot := add(keccak256(0, 0x20), pos)
}
}
struct Trace160 {
Checkpoint160[] _checkpoints;
}
struct Checkpoint160 {
uint96 _key;
uint160 _value;
}
/**
* @dev Pushes a (`key`, `value`) pair into a Trace160 so that it is stored as the checkpoint.
*
* Returns previous value and new value.
*
* IMPORTANT: Never accept `key` as a user input, since an arbitrary `type(uint96).max` key set will disable the
* library.
*/
function push(Trace160 storage self, uint96 key, uint160 value) internal returns (uint160, uint160) {
return _insert(self._checkpoints, key, value);
}
/**
* @dev Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if
* there is none.
*/
function lowerLookup(Trace160 storage self, uint96 key) internal view returns (uint160) {
uint256 len = self._checkpoints.length;
uint256 pos = _lowerBinaryLookup(self._checkpoints, key, 0, len);
return pos == len ? 0 : _unsafeAccess(self._checkpoints, pos)._value;
}
/**
* @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
* if there is none.
*/
function upperLookup(Trace160 storage self, uint96 key) internal view returns (uint160) {
uint256 len = self._checkpoints.length;
uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, len);
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero
* if there is none.
*
* NOTE: This is a variant of {upperLookup} that is optimised to find "recent" checkpoint (checkpoints with high
* keys).
*/
function upperLookupRecent(Trace160 storage self, uint96 key) internal view returns (uint160) {
uint256 len = self._checkpoints.length;
uint256 low = 0;
uint256 high = len;
if (len > 5) {
uint256 mid = len - Math.sqrt(len);
if (key < _unsafeAccess(self._checkpoints, mid)._key) {
high = mid;
} else {
low = mid + 1;
}
}
uint256 pos = _upperBinaryLookup(self._checkpoints, key, low, high);
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints.
*/
function latest(Trace160 storage self) internal view returns (uint160) {
uint256 pos = self._checkpoints.length;
return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value;
}
/**
* @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value
* in the most recent checkpoint.
*/
function latestCheckpoint(Trace160 storage self) internal view returns (bool exists, uint96 _key, uint160 _value) {
uint256 pos = self._checkpoints.length;
if (pos == 0) {
return (false, 0, 0);
} else {
Checkpoint160 memory ckpt = _unsafeAccess(self._checkpoints, pos - 1);
return (true, ckpt._key, ckpt._value);
}
}
/**
* @dev Returns the number of checkpoint.
*/
function length(Trace160 storage self) internal view returns (uint256) {
return self._checkpoints.length;
}
/**
* @dev Returns checkpoint at given position.
*/
function at(Trace160 storage self, uint32 pos) internal view returns (Checkpoint160 memory) {
return self._checkpoints[pos];
}
/**
* @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint,
* or by updating the last one.
*/
function _insert(Checkpoint160[] storage self, uint96 key, uint160 value) private returns (uint160, uint160) {
uint256 pos = self.length;
if (pos > 0) {
// Copying to memory is important here.
Checkpoint160 memory last = _unsafeAccess(self, pos - 1);
// Checkpoint keys must be non-decreasing.
if (last._key > key) {
revert CheckpointUnorderedInsertion();
}
// Update or push new checkpoint
if (last._key == key) {
_unsafeAccess(self, pos - 1)._value = value;
} else {
self.push(Checkpoint160({_key: key, _value: value}));
}
return (last._value, value);
} else {
self.push(Checkpoint160({_key: key, _value: value}));
return (0, value);
}
}
/**
* @dev Return the index of the last (most recent) checkpoint with key lower or equal than the search key, or `high`
* if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive
* `high`.
*
* WARNING: `high` should not be greater than the array's length.
*/
function _upperBinaryLookup(
Checkpoint160[] storage self,
uint96 key,
uint256 low,
uint256 high
) private view returns (uint256) {
while (low < high) {
uint256 mid = Math.average(low, high);
if (_unsafeAccess(self, mid)._key > key) {
high = mid;
} else {
low = mid + 1;
}
}
return high;
}
/**
* @dev Return the index of the first (oldest) checkpoint with key is greater or equal than the search key, or
* `high` if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and
* exclusive `high`.
*
* WARNING: `high` should not be greater than the array's length.
*/
function _lowerBinaryLookup(
Checkpoint160[] storage self,
uint96 key,
uint256 low,
uint256 high
) private view returns (uint256) {
while (low < high) {
uint256 mid = Math.average(low, high);
if (_unsafeAccess(self, mid)._key < key) {
low = mid + 1;
} else {
high = mid;
}
}
return high;
}
/**
* @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds.
*/
function _unsafeAccess(
Checkpoint160[] storage self,
uint256 pos
) private pure returns (Checkpoint160 storage result) {
assembly {
mstore(0, self.slot)
result.slot := add(keccak256(0, 0x20), pos)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard ERC20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC20InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC20InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
* @param spender Address that may be allowed to operate on tokens without being their owner.
* @param allowance Amount of tokens a `spender` is allowed to operate with.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC20InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `spender` to be approved. Used in approvals.
* @param spender Address that may be allowed to operate on tokens without being their owner.
*/
error ERC20InvalidSpender(address spender);
}
/**
* @dev Standard ERC721 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.
*/
interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC721NonexistentToken(uint256 tokenId);
/**
* @dev Indicates an error related to the ownership over a particular token. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param tokenId Identifier number of a token.
* @param owner Address of the current owner of a token.
*/
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC721InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param tokenId Identifier number of a token.
*/
error ERC721InsufficientApproval(address operator, uint256 tokenId);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC721InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC721InvalidOperator(address operator);
}
/**
* @dev Standard ERC1155 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.
*/
interface IERC1155Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
* @param tokenId Identifier number of a token.
*/
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC1155InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC1155InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param owner Address of the current owner of a token.
*/
error ERC1155MissingApprovalForAll(address operator, address owner);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC1155InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC1155InvalidOperator(address operator);
/**
* @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
* Used in batch transfers.
* @param idsLength Length of the array of token identifiers
* @param valuesLength Length of the array of token amounts
*/
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.20;
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Storage of the initializable contract.
*
* It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
* when using with upgradeable contracts.
*
* @custom:storage-location erc7201:openzeppelin.storage.Initializable
*/
struct InitializableStorage {
/**
* @dev Indicates that the contract has been initialized.
*/
uint64 _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool _initializing;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
/**
* @dev The contract is already initialized.
*/
error InvalidInitialization();
/**
* @dev The contract is not initializing.
*/
error NotInitializing();
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint64 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
* number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
* production.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
// Cache values to avoid duplicated sloads
bool isTopLevelCall = !$._initializing;
uint64 initialized = $._initialized;
// Allowed calls:
// - initialSetup: the contract is not in the initializing state and no previous version was
// initialized
// - construction: the contract is initialized at version 1 (no reininitialization) and the
// current contract is just being deployed
bool initialSetup = initialized == 0 && isTopLevelCall;
bool construction = initialized == 1 && address(this).code.length == 0;
if (!initialSetup && !construction) {
revert InvalidInitialization();
}
$._initialized = 1;
if (isTopLevelCall) {
$._initializing = true;
}
_;
if (isTopLevelCall) {
$._initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint64 version) {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing || $._initialized >= version) {
revert InvalidInitialization();
}
$._initialized = version;
$._initializing = true;
_;
$._initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
_checkInitializing();
_;
}
/**
* @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
*/
function _checkInitializing() internal view virtual {
if (!_isInitializing()) {
revert NotInitializing();
}
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing) {
revert InvalidInitialization();
}
if ($._initialized != type(uint64).max) {
$._initialized = type(uint64).max;
emit Initialized(type(uint64).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint64) {
return _getInitializableStorage()._initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _getInitializableStorage()._initializing;
}
/**
* @dev Returns a pointer to the storage namespace.
*/
// solhint-disable-next-line var-name-mixedcase
function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
assembly {
$.slot := INITIALIZABLE_STORAGE
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {FailedInnerCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {FailedInnerCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert FailedInnerCall();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
/// @custom:storage-location erc7201:openzeppelin.storage.Ownable
struct OwnableStorage {
address _owner;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300;
function _getOwnableStorage() private pure returns (OwnableStorage storage $) {
assembly {
$.slot := OwnableStorageLocation
}
}
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
function __Ownable_init(address initialOwner) internal onlyInitializing {
__Ownable_init_unchained(initialOwner);
}
function __Ownable_init_unchained(address initialOwner) internal onlyInitializing {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
OwnableStorage storage $ = _getOwnableStorage();
return $._owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
OwnableStorage storage $ = _getOwnableStorage();
address oldOwner = $._owner;
$._owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuardUpgradeable is Initializable {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
/// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard
struct ReentrancyGuardStorage {
uint256 _status;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;
function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) {
assembly {
$.slot := ReentrancyGuardStorageLocation
}
}
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
function __ReentrancyGuard_init() internal onlyInitializing {
__ReentrancyGuard_init_unchained();
}
function __ReentrancyGuard_init_unchained() internal onlyInitializing {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
$._status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
// On the first call to nonReentrant, _status will be NOT_ENTERED
if ($._status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
$._status = ENTERED;
}
function _nonReentrantAfter() private {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
$._status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
return $._status == ENTERED;
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
import {IStaticDelegateCallable} from "../../interfaces/common/IStaticDelegateCallable.sol";
abstract contract StaticDelegateCallable is IStaticDelegateCallable {
/**
* @inheritdoc IStaticDelegateCallable
*/
function staticDelegateCall(address target, bytes calldata data) external {
(bool success, bytes memory returndata) = target.delegatecall(data);
bytes memory revertData = abi.encode(success, returndata);
assembly {
revert(add(32, revertData), mload(revertData))
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IEntity {
error NotInitialized();
/**
* @notice Get the factory's address.
* @return address of the factory
*/
function FACTORY() external view returns (address);
/**
* @notice Get the entity's type.
* @return type of the entity
*/
function TYPE() external view returns (uint64);
/**
* @notice Initialize this entity contract by using a given data.
* @param data some data to use
*/
function initialize(
bytes calldata data
) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)
pragma solidity ^0.8.20;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @dev The `account` is missing a role.
*/
error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);
/**
* @dev The caller of a function is not the expected one.
*
* NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
*/
error AccessControlBadConfirmation();
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*/
function renounceRole(bytes32 role, address callerConfirmation) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*/
abstract contract ERC165Upgradeable is Initializable, IERC165 {
function __ERC165_init() internal onlyInitializing {
}
function __ERC165_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IStaticDelegateCallable {
/**
* @notice Make a delegatecall from this contract to a given target contract with a particular data (always reverts with a return data).
* @param target address of the contract to make a delegatecall to
* @param data data to make a delegatecall with
* @dev It allows to use this contract's storage on-chain.
*/
function staticDelegateCall(address target, bytes calldata data) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}{
"remappings": [
"forge-std/=lib/forge-std/src/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "paris",
"viaIR": true,
"libraries": {}
}Contract ABI
API[{"inputs":[{"internalType":"address","name":"delegatorFactory","type":"address"},{"internalType":"address","name":"slasherFactory","type":"address"},{"internalType":"address","name":"vaultFactory","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"AlreadyClaimed","type":"error"},{"inputs":[],"name":"AlreadyInitialized","type":"error"},{"inputs":[],"name":"AlreadySet","type":"error"},{"inputs":[],"name":"CheckpointUnorderedInsertion","type":"error"},{"inputs":[],"name":"DelegatorAlreadyInitialized","type":"error"},{"inputs":[],"name":"DepositLimitReached","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"allowance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientAllowance","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC20InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC20InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC20InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"}],"name":"ERC20InvalidSpender","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"InsufficientClaim","type":"error"},{"inputs":[],"name":"InsufficientDeposit","type":"error"},{"inputs":[],"name":"InsufficientRedemption","type":"error"},{"inputs":[],"name":"InsufficientWithdrawal","type":"error"},{"inputs":[],"name":"InvalidAccount","type":"error"},{"inputs":[],"name":"InvalidCaptureEpoch","type":"error"},{"inputs":[],"name":"InvalidClaimer","type":"error"},{"inputs":[],"name":"InvalidCollateral","type":"error"},{"inputs":[],"name":"InvalidDelegator","type":"error"},{"inputs":[],"name":"InvalidEpoch","type":"error"},{"inputs":[],"name":"InvalidEpochDuration","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"InvalidLengthEpochs","type":"error"},{"inputs":[],"name":"InvalidOnBehalfOf","type":"error"},{"inputs":[],"name":"InvalidRecipient","type":"error"},{"inputs":[],"name":"InvalidSlasher","type":"error"},{"inputs":[],"name":"InvalidTimestamp","type":"error"},{"inputs":[],"name":"MathOverflowedMulDiv","type":"error"},{"inputs":[],"name":"MissingRoles","type":"error"},{"inputs":[],"name":"NoPreviousEpoch","type":"error"},{"inputs":[],"name":"NotDelegator","type":"error"},{"inputs":[],"name":"NotFactory","type":"error"},{"inputs":[],"name":"NotInitialized","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"NotSlasher","type":"error"},{"inputs":[],"name":"NotWhitelistedDepositor","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"uint8","name":"bits","type":"uint8"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"SafeCastOverflowedUintDowncast","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"SlasherAlreadyInitialized","type":"error"},{"inputs":[],"name":"TooMuchRedeem","type":"error"},{"inputs":[],"name":"TooMuchWithdraw","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"claimer","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"epoch","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Claim","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"claimer","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"epochs","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ClaimBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"depositor","type":"address"},{"indexed":true,"internalType":"address","name":"onBehalfOf","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint48","name":"captureTimestamp","type":"uint48"},{"indexed":false,"internalType":"uint256","name":"slashedAmount","type":"uint256"}],"name":"OnSlash","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"}],"name":"SetDelegator","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"limit","type":"uint256"}],"name":"SetDepositLimit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"status","type":"bool"}],"name":"SetDepositWhitelist","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"status","type":"bool"}],"name":"SetDepositorWhitelistStatus","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"status","type":"bool"}],"name":"SetIsDepositLimit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"slasher","type":"address"}],"name":"SetSlasher","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"withdrawer","type":"address"},{"indexed":true,"internalType":"address","name":"claimer","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"burnedShares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mintedShares","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DELEGATOR_FACTORY","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEPOSITOR_WHITELIST_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEPOSIT_LIMIT_SET_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEPOSIT_WHITELIST_SET_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FACTORY","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"IS_DEPOSIT_LIMIT_SET_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SLASHER_FACTORY","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"activeBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint48","name":"timestamp","type":"uint48"},{"internalType":"bytes","name":"hints","type":"bytes"}],"name":"activeBalanceOfAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"activeShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint48","name":"timestamp","type":"uint48"},{"internalType":"bytes","name":"hint","type":"bytes"}],"name":"activeSharesAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"activeSharesOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint48","name":"timestamp","type":"uint48"},{"internalType":"bytes","name":"hint","type":"bytes"}],"name":"activeSharesOfAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"activeStake","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint48","name":"timestamp","type":"uint48"},{"internalType":"bytes","name":"hint","type":"bytes"}],"name":"activeStakeAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"burner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"epoch","type":"uint256"}],"name":"claim","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256[]","name":"epochs","type":"uint256[]"}],"name":"claimBatch","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"collateral","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentEpoch","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentEpochStart","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"delegator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"onBehalfOf","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"depositedAmount","type":"uint256"},{"internalType":"uint256","name":"mintedShares","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"depositLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"depositWhitelist","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint48","name":"timestamp","type":"uint48"}],"name":"epochAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"epochDuration","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"epochDurationInit","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"initialVersion","type":"uint64"},{"internalType":"address","name":"owner_","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isDelegatorInitialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isDepositLimit","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isDepositorWhitelisted","outputs":[{"internalType":"bool","name":"value","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isInitialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isSlasherInitialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"epoch","type":"uint256"},{"internalType":"address","name":"account","type":"address"}],"name":"isWithdrawalsClaimed","outputs":[{"internalType":"bool","name":"value","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"newVersion","type":"uint64"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"migrate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextEpochStart","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint48","name":"captureTimestamp","type":"uint48"}],"name":"onSlash","outputs":[{"internalType":"uint256","name":"slashedAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"previousEpochStart","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"claimer","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"withdrawnAssets","type":"uint256"},{"internalType":"uint256","name":"mintedShares","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"delegator_","type":"address"}],"name":"setDelegator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"limit","type":"uint256"}],"name":"setDepositLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"status","type":"bool"}],"name":"setDepositWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"status","type":"bool"}],"name":"setDepositorWhitelistStatus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"status","type":"bool"}],"name":"setIsDepositLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"slasher_","type":"address"}],"name":"setSlasher","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"slashableBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"slasher","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"staticDelegateCall","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalStake","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"claimer","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"burnedShares","type":"uint256"},{"internalType":"uint256","name":"mintedShares","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"epoch","type":"uint256"}],"name":"withdrawalShares","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"epoch","type":"uint256"},{"internalType":"address","name":"account","type":"address"}],"name":"withdrawalSharesOf","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"epoch","type":"uint256"}],"name":"withdrawals","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"epoch","type":"uint256"},{"internalType":"address","name":"account","type":"address"}],"name":"withdrawalsOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]Contract Creation Code
60e03461013c57601f61593238819003918201601f1916830192916001600160401b03918285118486101761014157816060928592604097885283398101031261013c5761004c82610157565b916100648461005d60208401610157565b9201610157565b9260805260a0527ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a009081549060ff82861c1661012b5780808316036100e7575b50505060c052516157c6908161016c82396080518181816115f00152611bab015260a051818181611d190152612294015260c051818181610ad90152610d080152f35b6001600160401b0319909116811790915582519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a13880806100a4565b845163f92ee8a960e01b8152600490fd5b600080fd5b634e487b7160e01b600052604160045260246000fd5b51906001600160a01b038216820361013c5756fe6080604052600436101561001257600080fd5b60003560e01c806301ffc9a7146104bd57806306fdde03146104b8578063095ea7b3146104b35780631415519b146104ae57806318160ddd1461038c5780631b66c9e1146104a95780631e9a6950146104a457806323b872dd1461049f578063248a9ca31461049a57806327810b6e14610495578063281f5752146104905780632abe30481461048b5780632d73c69c146104865780632dd31000146104815780632f2ff15d1461047c578063313ce5671461047757806336568abe14610472578063392e53cd1461046d5780634105a7dd14610468578063463616711461046357806347e7ef241461045e57806348d3b775146104595780634ff0876a1461045457806350861adc1461044f57806350f220681461044a5780635346e34f1461044557806354fd4d501461044057806357ec83cc1461043b57806359f769a9146104365780635cc070761461043157806361a8c8c41461042c5780636da3e06d146104275780636ec1e3f81461042257806370a08231146103d7578063715018a61461041d5780637278e31c1461041857806373790ab314610413578063766718081461040e578063794b15b7146104095780637953b33b146104045780637c04c80a146103ff578063810da75d146103fa57806383cd9cc3146103f557806387df0788146103f05780638b0e9f3f146103eb5780638da5cb5b146103e657806391d14854146103e157806395d89b41146103dc5780639d66201b146103d75780639f86fd85146103d2578063a1b12202146103cd578063a217fddf146103c8578063a21a1df9146103c3578063a2861466146103be578063a3b54172146103b9578063a5d03223146103b4578063a9059cbb146103af578063aabc2496146103aa578063aad3ec96146103a5578063afba70ad146103a0578063b13442711461039b578063bd49c35f14610396578063bdc8144b14610391578063bfefcd7b1461038c578063c31e8dd714610387578063ce9b793014610382578063d547741f1461037d578063d8dfeb4514610378578063db38871514610373578063dd62ed3e1461036e578063ecf7085814610369578063efb559d614610364578063f2fde38b1461035f578063f3fef3a31461035a5763f5e7ee0f1461035557600080fd5b612961565b6128ba565b61288d565b61273e565b612720565b6126e9565b6126ae565b612681565b612632565b612609565b61259f565b61077d565b6124bf565b6124a4565b61247b565b61244f565b61238c565b6121d1565b61219c565b612152565b612101565b61200b565b611fd0565b611fb4565b611f8e565b611ef9565b611645565b611e45565b611de2565b611dac565b611d48565b611d03565b611b46565b611b2d565b611ac7565b611aa0565b611a5e565b611a0a565b6119c8565b6116ec565b611681565b61161f565b6115da565b611586565b61155a565b611533565b6113f8565b6113c4565b61132c565b611313565b6112b5565b611294565b611271565b610f80565b610f57565b610eb9565b610e73565b610e28565b610d88565b610d37565b610cf2565b610c85565b610a94565b6109c4565b61099b565b61095f565b6108c2565b6107db565b6107a0565b610742565b61067c565b610574565b346105135760203660031901126105135760043563ffffffff60e01b811680910361051357602090637965db0b60e01b8114908115610502575b506040519015158152f35b6301ffc9a760e01b149050386104f7565b600080fd5b60005b83811061052b5750506000910152565b818101518382015260200161051b565b9060209161055481518092818552858086019101610518565b601f01601f1916010190565b90602061057192818152019061053b565b90565b346105135760008060031936011261066857604051908060008051602061567183398151915280546105a58161298b565b8086529260209260019280841690811561063957506001146105e2575b6105de876105d281890382610bc8565b60405191829182610560565b0390f35b815293507f2ae08a8e29253f69ac5d979a101956ab8f8d9d7ded63fa7a83b16fc47648eab05b838510610626575050505081016020016105d2826105de38806105c2565b8054868601840152938201938101610608565b9150508695506105de969350602092506105d294915060ff191682840152151560051b820101929338806105c2565b80fd5b6001600160a01b0381160361051357565b34610513576040366003190112610513576004356106998161066b565b6024353315610729576001600160a01b038216918215610710576106d882916106c133611a25565b9060018060a01b0316600052602052604060002090565b556040519081527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560203392a3602060405160018152f35b604051634a1406b160e11b815260006004820152602490fd5b60405163e602df0560e01b815260006004820152602490fd5b346105135760003660031901126105135760206040517fc6aaadd7371d5e8f9ed6849dd66a66573a3ba37167d03f4352c9ba5693678fac8152f35b34610513576000366003190112610513576020610798614121565b604051908152f35b346105135760003660031901126105135760206040517f9c56d972d63cbb4195b3c1484691dfc220fa96a4c47e7b6613bd82a022029e068152f35b34610513576040366003190112610513576004356107f88161066b565b60243590610804612eed565b6001600160a01b038116156108b157336000908152600e602052604090206108309061421f565b61421f565b821161089f576108506108416141a3565b610849614121565b90846142a0565b91821561088a578261086192612f1d565b90610879600160008051602061575183398151915255565b604080519182526020820192909252f35b60405160016245ddc760e11b03198152600490fd5b604051632418411f60e11b8152600490fd5b6040516208978560e71b8152600490fd5b34610513576060366003190112610513576004356108df8161066b565b6024356108eb8161066b565b604435906108fc336106c185611a25565b54926001840161091d575b61091193506130b9565b60405160018152602090f35b828410610939576109348361091195033383614279565b610907565b604051637dc7a0d960e11b81523360048201526024810185905260448101849052606490fd5b34610513576020366003190112610513576004356000526000805160206157318339815191526020526020600160406000200154604051908152f35b34610513576000366003190112610513576001546040516001600160a01b039091168152602090f35b34610513576000366003190112610513576109dd612c02565b8015610a3f5760015465ffffffffffff8160a01c16916000198101908111610a3a57610a0c9160d01c906129f7565b8101809111610a3a57610a216105de9161321f565b60405165ffffffffffff90911681529081906020820190565b6129c5565b604051639fa56a5b60e01b8152600490fd5b600435906001600160401b038216820361051357565b9181601f84011215610513578235916001600160401b038311610513576020838186019501011161051357565b3461051357604036600319011261051357610aad610a51565b6001600160401b0360243581811161051357610acd903690600401610a67565b5050610ad7612eed565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303610b5557600080516020615771833981519152549060ff8260401c16928315610b45575b505050610b3357600080fd5b60405163f92ee8a960e01b8152600490fd5b8116911610159050388080610b27565b604051631966391b60e11b8152600490fd5b65ffffffffffff81160361051357565b634e487b7160e01b600052604160045260246000fd5b606081019081106001600160401b03821117610ba857604052565b610b77565b604081019081106001600160401b03821117610ba857604052565b90601f801991011681019081106001600160401b03821117610ba857604052565b6040519061016082018281106001600160401b03821117610ba857604052565b60405190610c1682610bad565b565b6001600160401b038111610ba857601f01601f191660200190565b929192610c3f82610c18565b91610c4d6040519384610bc8565b829481845281830111610513578281602093846000960137010152565b9080601f830112156105135781602061057193359101610c33565b3461051357606036600319011261051357600435610ca28161066b565b60243590610caf82610b67565b604435906001600160401b03821161051357602092610cd5610798933690600401610c6a565b6001600160a01b039092166000908152600e855260409020613418565b34610513576000366003190112610513576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b3461051357604036600319011261051357610d86602435600435610d5a8261066b565b80600052600080516020615731833981519152602052610d816001604060002001546135f2565b613902565b005b346105135760008060031936011261066857805460405163313ce56760e01b8152906020908290600490829060101c6001600160a01b03165afa908115610e23578291610dde575b60405160ff83168152602090f35b90506020813d602011610e1b575b81610df960209383610bc8565b81010312610e17575160ff81168103610e17576105de915038610dd0565b5080fd5b3d9150610dec565b612a47565b3461051357604036600319011261051357602435610e458161066b565b336001600160a01b03821603610e6157610d869060043561393c565b60405163334bd91960e11b8152600490fd5b346105135760003660031901126105135760ff60025460a01c1680610ea0575b6020906040519015158152f35b5060035460a01c60ff16610e93565b8015150361051357565b3461051357602036600319011261051357600435610ed681610eaf565b610ede612eed565b610ee66134e4565b600054901515908160ff8216151514610f455760ff191660ff8216176000556040519081527f3e12b7b36c75ac9609a3f58609b331210428e1a85909132638955ba0301eec3390602090a1600160008051602061575183398151915255005b60405163a741a04560e01b8152600490fd5b3461051357600036600319011261051357602065ffffffffffff60015460a01c16604051908152f35b3461051357604080600319360112610513576004803591610fa08361066b565b610fa8612eed565b6001600160a01b03918383169081156112635760005460ff811680611249575b61123a5783516370a0823160e01b808252308483019081529096602093909160109190911c82169084908490819083010381845afa928315610e2357600093611217575b5061101e906024359030903390614697565b60005486519788523085890190815290979184918391908290819060200103918b60101c165afa908115610e235761105f936000926111ea575b50506129ea565b9384156111db5760081c60ff16806111c6575b6111b85750906105de916111256110876141a3565b956110d0611093614121565b6110bb6110a18a838b6142a0565b996110b58a6110af4261321f565b92612a18565b90613db0565b50506110ca896110af4261321f565b90613e94565b50506001600160a01b0381166000908152600e602052604090209061111f8861111a61082b6110fe4261321f565b6001600160a01b039095166000908152600e6020526040902090565b612a18565b91613f74565b5050815184815260208101869052819033907fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d790604090a3611174600160008051602061575183398151915255565b81518581526000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90602090a35191825260208201929092529081906040820190565b8251632484557960e01b8152fd5b506111d38461111a6141a3565b815410611072565b50825163070f6eed60e11b8152fd5b6112099250803d10611210575b6112018183610bc8565b8101906139d4565b3880611058565b503d6111f7565b61101e91935061123390853d8711611210576112018183610bc8565b929061100c565b5082516304f63b8560e01b8152fd5b503360009081526005602052604090205460ff1615610fc8565b8251630d534ce360e11b8152fd5b3461051357600036600319011261051357602060ff600054166040519015158152f35b3461051357600036600319011261051357602060015460d01c604051908152f35b3461051357600036600319011261051357602060ff60025460a01c166040519015158152f35b906040600319830112610513576004356112f481610b67565b91602435906001600160401b0382116105135761057191600401610c6a565b34610513576020610798611326366112db565b90613282565b346105135760203660031901126105135760043561134981610eaf565b611351612eed565b611359613542565b600054901515908160ff8260081c16151514610f455761ff001916600882901b61ff0016176000556040519081527ffa7a25a0b611d4ba3c0ea990e90dc23d484a5dd7a1be4733fef2946ba74530c690602090a1610d86600160008051602061575183398151915255565b346105135760003660031901126105135760206001600160401b036000805160206157718339815191525416604051908152f35b3461051357606036600319011261051357611411610a51565b60243561141d8161066b565b6001600160401b03916044358381116105135761143e903690600401610a67565b6000805160206157718339815191529491855494838616806115225760ff8760401c16908115611515575b50610b33577fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d296611510966114d7958716906001600160401b0319161790556114d2600080516020615771833981519152600160401b68ff000000000000000019825416179055565b612a53565b600080516020615771833981519152805468ff0000000000000000191690556040516001600160401b0390911681529081906020820190565b0390a1005b9050848616111538611469565b60405162dc149f60e41b8152600490fd5b346105135760203660031901126105135760206107986004356115558161066b565b612b68565b346105135760203660031901126105135760043560005260066020526020604060002054604051908152f35b346105135760003660031901126105135760015465ffffffffffff6115bd818360a01c16926115b3612c02565b9060d01c906129f7565b8201809211610a3a576115d160209261321f565b60405191168152f35b34610513576000366003190112610513576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b3461051357600036600319011261051357602060ff60035460a01c166040519015158152f35b34610513576020366003190112610513576004356116628161066b565b60018060a01b0316600052600e6020526020610798604060002061421f565b34610513576000806003193601126106685761169b613bbc565b6000805160206156d183398151915280546001600160a01b0319811690915581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b346105135760403660031901126105135760043560243561170c81610b67565b611714612eed565b600354611731906001600160a01b03165b6001600160a01b031690565b33036119b65761173f612c02565b9061174981612c36565b90821515806119a5575b801561199c575b61198a576105de937ff9d090c096f71cd1659861a9ce5b6f384bceb4e2fa4e4a19edf6489a9b8d56c79261178c6141a3565b946117a961179982612a0a565b6000526006602052604060002090565b549082810361189f57506117bd8187612a18565b6117c78185613bf5565b968780611858575b50505050505b83611823575b6040805191825265ffffffffffff929092166020820152908101839052606090a1611813600160008051602061575183398151915255565b6040519081529081906020820190565b6000546118539085906118419060101c6001600160a01b0316611725565b6001546001600160a01b031690614034565b6117db565b61189493611058836110b561187e6118776117999861188e9888613c11565b80966129ea565b946118884261321f565b926129ea565b92612a0a565b5538808080876117cf565b91506118b5826000526006602052604060002090565b54906118c58161111a848a612a18565b906118d08286613bf5565b97886118e1575b50505050506117d5565b6119589383611909936119168c6119116118ff611947998884613c11565b9788958584613c11565b9485926129ea565b6129ea565b93848410611963575b611058906110b56119359596976118884261321f565b61194161179987612a0a565b556129ea565b916000526006602052604060002090565b5538808080806118d7565b9161197f611058916119798661193597986129ea565b90612a18565b85945092905061191f565b604051635e18d2a560e01b8152600490fd5b5082821161175a565b506119af836129db565b8210611753565b60405163dabc4ad960e01b8152600490fd5b346105135760003660031901126105135760015465ffffffffffff808260a01c16916119f2612c02565b60018101809111610a3a576115bd9160d01c906129f7565b34610513576000366003190112610513576020610798612c02565b6001600160a01b031660009081527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace016020526040902090565b3461051357602036600319011261051357600435611a7b8161066b565b60018060a01b03166000526005602052602060ff604060002054166040519015158152f35b34610513576020366003190112610513576020610798600435611ac281610b67565b612c36565b3461051357604036600319011261051357600435611ae48161066b565b6024356001600160401b038082116105135736602383011215610513578160040135908111610513573660248260051b84010111610513576105de926024611813930190612c71565b34610513576020610798611b40366112db565b90613363565b3461051357602080600319360112610513576004803590611b668261066b565b611b6e612eed565b60025460a01c60ff16611cf4576040516302910f8b60e31b81526001600160a01b03838116838301908152909491908290829081906020010381887f0000000000000000000000000000000000000000000000000000000000000000165afa908115610e2357600091611cc7575b5015611cb75760405163fbfa77cf60e01b8152838516949082818581895afa928315610e2357600093611c88575b505030911603611c795750600280546001600160a01b03929092166001600160a81b031990921691909117600160a01b1790557fdb2160616f776a37b24808115554e79439bf26cccbbd4438190cc6d28e80ecd1600080a2610d86600160008051602061575183398151915255565b60405163b9f0f17160e01b8152fd5b611ca8929350803d10611cb0575b611ca08183610bc8565b810190612dcf565b903880611c0a565b503d611c96565b506040516324e5af8d60e21b8152fd5b611ce79150823d8411611ced575b611cdf8183610bc8565b810190612daf565b38611bdc565b503d611cd5565b604051631380833b60e01b8152fd5b34610513576000366003190112610513576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b346105135760008060031936011261066857611d62612c02565b611d6a6141a3565b91818152600660205260408120548301809311610a3a5760018201809211610a3a576040918152600660205220548101809111610a3a57602090604051908152f35b34610513576000366003190112610513576000805160206156d1833981519152546040516001600160a01b039091168152602090f35b3461051357604036600319011261051357602060ff611e39602435611e068161066b565b600435600052600080516020615731833981519152845260406000209060018060a01b0316600052602052604060002090565b54166040519015158152f35b34610513576000806003193601126106685760405190806000805160206156b18339815191528054611e768161298b565b808652926020926001928084169081156106395750600114611ea2576105de876105d281890382610bc8565b815293507f46a2803e59a4de4e7a4c574b1243f25977ac4c77d5a1a4a609b5394cebb4a2aa5b838510611ee6575050505081016020016105d2826105de38806105c2565b8054868601840152938201938101611ec8565b3461051357604036600319011261051357600435611f168161066b565b6024356001600160401b03811161051357600091611f3983923690600401610a67565b90816040519283928337810184815203915af4611f86611f57612de4565b91611f7860405193849215156020840152604080840152606083019061053b565b03601f198101835282610bc8565b805190602001fd5b3461051357600036600319011261051357602060ff60005460081c166040519015158152f35b3461051357600036600319011261051357602060405160008152f35b346105135760003660031901126105135760206040517f4a634bc14d77baf979756509ef4298c6f6318af357828612545267ee2eb792338152f35b34610513576040366003190112610513576004356120288161066b565b60243561203481610eaf565b61203c612eed565b61204461359a565b6001600160a01b0382169182156120ef5760008381526005602052604090205460ff16151582151514610f45576001600160a01b031660009081526005602052604090207ff991b1ecfb5115cbb36a2b2e2240c058406d2acc2fcc6e9e2dc99d845ff70a62916120d5916120c3908260ff801983541691151516179055565b60405190151581529081906020820190565b0390a2610d86600160008051602061575183398151915255565b604051630da30f6560e31b8152600490fd5b346105135760403660031901126105135760206121496024356121238161066b565b6004356000526008835260406000209060018060a01b0316600052602052604060002090565b54604051908152f35b3461051357604036600319011261051357602060ff611e396024356121768161066b565b6004356000526009845260406000209060018060a01b0316600052602052604060002090565b34610513576040366003190112610513576121c66004356121bc8161066b565b60243590336130b9565b602060405160018152f35b34610513576020806003193601126105135760048035906121f18261066b565b6121f9612eed565b60035460a01c60ff1661237d576001600160a01b03828116939084612269575b6003805460ff60a01b1916600160a01b179055847fe7e4c932e03abddfe20f83af42c33627e816115c7ec2b168441f65dc14bfc3ba600080a2610d86600160008051602061575183398151915255565b6040516302910f8b60e31b81526001600160a01b0385168482019081528390829081906020010381857f0000000000000000000000000000000000000000000000000000000000000000165afa908115610e2357600091612360575b501561234f5760405163fbfa77cf60e01b815282818581895afa928315610e2357600093612330575b5050309116036123215750600380546001600160a01b0319166001600160a01b0390921691909117905538808080612219565b604051633f3e089160e21b8152fd5b612347929350803d10611cb057611ca08183610bc8565b9038806122ee565b60405163dabc4ad960e01b81528390fd5b6123779150833d8511611ced57611cdf8183610bc8565b386122c5565b60405163703fe2e560e01b8152fd5b34610513576040366003190112610513576004356123a98161066b565b602435906123b5612eed565b6001600160a01b039181831690811561243d576123e76105de946123d883614083565b94859160005460101c16614034565b604080519182526020820184905233917f865ca08d59f5cb456e85cd2f7ef63664ea4f73327414e9d8152c4158b0e946459190a36001600080516020615751833981519152556040519081529081906020820190565b604051634e46966960e11b8152600490fd5b346105135760203660031901126105135760043560005260076020526020604060002054604051908152f35b34610513576000366003190112610513576003546040516001600160a01b039091168152602090f35b346105135760003660031901126105135760206107986141a3565b34610513576020366003190112610513576004356124db612eed565b3360009081527f2d4ccbfe9f7672a6f2537c1e5bce6adacb73706879154bbab6ce096012d6721660205260409020547f4a634bc14d77baf979756509ef4298c6f6318af357828612545267ee2eb792339060ff161561258157508060045414610f45576020817f854df3eb95564502c8bc871ebdd15310ee26270f955f6c6bd8cea68e75045bc092600455604051908152a1600160008051602061575183398151915255005b6044906040519063e2517d3f60e01b82523360048301526024820152fd5b34610513576020366003190112610513576004356125bc8161066b565b6125c4612c02565b6125cd82612b68565b916125d88183612e88565b8301809311610a3a5760018201809211610a3a576125f591612e88565b8101809111610a3a57602090604051908152f35b34610513576000366003190112610513576002546040516001600160a01b039091168152602090f35b3461051357604036600319011261051357610d866024356004356126558261066b565b8060005260008051602061573183398151915260205261267c6001604060002001546135f2565b61393c565b346105135760003660031901126105135760005460405160109190911c6001600160a01b03168152602090f35b346105135760003660031901126105135760206040517fbae4ee3de6c709ff9a002e774c5b78cb381560b219213c88ae0f1e207c03c0238152f35b3461051357604036600319011261051357602061214960043561270b8161066b565b6106c16024359161271b8361066b565b611a25565b34610513576000366003190112610513576020600454604051908152f35b346105135760603660031901126105135760043561275b8161066b565b6024359061276882610b67565b6001600160401b039160443583811161051357612789903690600401610a67565b9092604093845161279981610b8d565b606081526060602082015260608682015292806127f8575b6105de866127e987876127e36127ca8984845191612a25565b92856127da602085015183613363565b93015190613282565b916142a0565b90519081529081906020820190565b8101939250602081850312610513578035908682116105135701926060848203126105135784519561282987610b8d565b8435818111610513578261283e918701610c6a565b875260208501358181116105135782612858918701610c6a565b602088015285850135908111610513576105de966128816127e3936127ca936127e99801610c6a565b878201529394506127b1565b3461051357602036600319011261051357610d866004356128ad8161066b565b6128b5613bbc565b612e14565b34610513576040366003190112610513576004356128d78161066b565b6024356128e2612eed565b6001600160a01b038216156108b157801561294f57612911612902614121565b61290a6141a3565b9083614da9565b336000908152600e6020526040902090929061292c9061421f565b831161293d57610861918391612f1d565b6040516321727a3760e11b8152600490fd5b604051636c6c627d60e11b8152600490fd5b346105135760403660031901126105135760206107986024356129838161066b565b600435612e88565b90600182811c921680156129bb575b60208310146129a557565b634e487b7160e01b600052602260045260246000fd5b91607f169161299a565b634e487b7160e01b600052601160045260246000fd5b600019810191908211610a3a57565b91908203918211610a3a57565b81810292918115918404141715610a3a57565b9060018201809211610a3a57565b91908201809211610a3a57565b6001600160a01b03166000908152600e60205260409020610571929190613418565b6040513d6000823e3d90fd5b91612a9192612a606146ef565b612a686146ef565b6001600080516020615751833981519152556001600160a01b038116612b4e575b503691610c33565b80516020908201818101828483031261051357828401516001600160401b039485821161051357019283926101a093849103126105135760405193612ad585610b8d565b612ae1838383016139ee565b8552610180810151868111610513578383612afe92840101613ab7565b9382860194855281015195861161051357612b26612b459383610c1698612b40940101613ab7565b94604081019586525191611f786040519384928301613af9565b614733565b51905190614af4565b612b6290612b5a6146ef565b6128b56146ef565b38612a89565b6001600160a01b03166000908152600e60205260409020612b889061421f565b612b906141a3565b612b98614121565b9060018101809111610a3a5760018201809211610a3a5761057192613c11565b65ffffffffffff9182169082160391908211610a3a57565b634e487b7160e01b600052601260045260246000fd5b9065ffffffffffff809116918215612bfd57160490565b612bd0565b612c0b4261321f565b612c32600154612c2865ffffffffffff93848360a01c1690612bb8565b9060d01c90612be6565b1690565b6001549065ffffffffffff91828160a01c16918284821610612c5f57612c3292612c2891612bb8565b60405163b7d0949760e01b8152600490fd5b90612c7a612eed565b6000926001600160a01b03831692831561243d578115612d3557845b828110612d1357506000547f326b6aff1cd2fb1c8234de4f9dcfb9047c5c36eb9ef2eb34af5121e969a75d279286929091612ce7918491612ce29060101c6001600160a01b0316611725565b614034565b612cf8604051928392339684612d72565b0390a390610c16600160008051602061575183398151915255565b94612d2e600191611979612d28898789612d5d565b35614083565b9501612c96565b60405163edf3b93360e01b8152600490fd5b634e487b7160e01b600052603260045260246000fd5b9190811015612d6d5760051b0190565b612d47565b604080825281018390529392916001600160fb1b0381116105135760209160609160051b809183880137850101930152565b5190610c1682610eaf565b90816020910312610513575161057181610eaf565b5190610c168261066b565b9081602091031261051357516105718161066b565b3d15612e0f573d90612df582610c18565b91612e036040519384610bc8565b82523d6000602084013e565b606090565b6001600160a01b03908116908115612e6f576000805160206156d183398151915280546001600160a01b031981168417909155167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b604051631e4fbdf760e01b815260006004820152602490fd5b90612eb29082600052600860205260406000209060018060a01b0316600052602052604060002090565b5490600052600660205260406000205460076020526040600020549060018101809111610a3a5760018201809211610a3a5761057192613c11565b6000805160206157518339815191526002815414612f0b5760029055565b604051633ee5aeb560e01b8152600490fd5b336000908152600e6020526040812093949390929190612f5e90612f404261321f565b336000908152600e6020526040902061111f9089906119119061421f565b5050612f78612f6c4261321f565b6110ca87611911614121565b5050612f92612f864261321f565b6110b5846119116141a3565b50508161302e826106c1612fac612fa7612c02565b612a0a565b613009612fc3826000526006602052604060002090565b54612fd8836000526007602052604060002090565b54612fef612fe783838b6142a0565b9a8b93612a18565b613003856000526006602052604060002090565b55612a18565b61301d826000526007602052604060002090565b556000526008602052604060002090565b613039848254612a18565b9055604080519182526020820187905281018390526001600160a01b03919091169033907febff2602b3f468259e1e99f613fed6691f3a6526effe6ef3e768ba7ae7a36c4f90606090a36040519384529233907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9080602081015b0390a3565b916001600160a01b03808416929083156132065781169384156131ed576001600160a01b0381166000908152600e602052604090206130f79061421f565b908382106131bb576130b49261315b7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef95936131486131a99460018060a01b0316600052600e602052604060002090565b90856131534261321f565b910391613f74565b50506001600160a01b0381166000908152600e6020526040902090836131a261082b6131864261321f565b6001600160a01b039094166000908152600e6020526040902090565b0191613f74565b50506040519081529081906020820190565b60405163391434e360e21b81526001600160a01b03919091166004820152602481019190915260448101839052606490fd5b60405163ec442f0560e01b815260006004820152602490fd5b604051634b637e8f60e11b815260006004820152602490fd5b65ffffffffffff90818111613232571690565b604490604051906306dfcc6560e41b8252603060048301526024820152fd5b90816020910312610513575163ffffffff811681036105135790565b90600163ffffffff80931601918211610a3a57565b90805115613359578060208061329d93518301019101613251565b6132a681614527565b906132b7825165ffffffffffff1690565b9065ffffffffffff808516921682811461334d57821191826132ed575b50506132e45750610571906142c1565b60209150015190565b9091506132fb600a546129db565b63ffffffff831614918215613314575b505038806132d4565b61334591925061332e61332961333a9261326d565b614527565b5165ffffffffffff1690565b65ffffffffffff1690565b11388061330b565b50505060209150015190565b50610571906142c1565b9080511561340e578060208061337e93518301019101613251565b613387816145b0565b90613398825165ffffffffffff1690565b9065ffffffffffff808516921682811461334d57821191826133c5575b50506132e457506105719061438f565b9091506133d3600c546129db565b63ffffffff8316149182156133ec575b505038806133b5565b61340691925061332e61340161333a9261326d565b6145b0565b1138806133e3565b506105719061438f565b918051156134da578060208061343393518301019101613251565b9161343e838261462f565b9261344f845165ffffffffffff1690565b9065ffffffffffff80851692168281146134ce5782119182613485575b505061347c576105719250614456565b50506020015190565b90915061349283546129db565b63ffffffff8316149182156134ab575b5050388061346c565b6134c691925061332e6134c061333a9261326d565b8561462f565b1138806134a2565b50505050506020015190565b5061057191614456565b3360009081527f03b26b53c87faa1058f30bb5d2fee64f717719a0d9b7e4f4df027aa5e9b6ed69602052604090207fbae4ee3de6c709ff9a002e774c5b78cb381560b219213c88ae0f1e207c03c0239060ff905b5416156125815750565b3360009081527fe41986b390c4ce6791b87f7423b5fab7a81a0e6d89660b6264f697d008b2243a602052604090207fc6aaadd7371d5e8f9ed6849dd66a66573a3ba37167d03f4352c9ba5693678fac9060ff90613538565b3360009081527f0287ab4cb376ea253d7b2ce0c2cbf458f7deae9458470d74afdfbbee484e9540602052604090207f9c56d972d63cbb4195b3c1484691dfc220fa96a4c47e7b6613bd82a022029e069060ff90613538565b600081815260008051602061573183398151915260209081526040808320338452909152902060ff90613538565b6001600160a01b03811660009081527fb7db2dd08fcb62d0c9e08c51941cae53c267786a0b75803fb7960902fc8ef97d60205260408120546000805160206157318339815191529060ff166136cf57818052602090815260408083206001600160a01b038516600090815292529020805460ff1916600117905533916001600160a01b0316907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d8180a4600190565b50905090565b6001600160a01b03811660009081527f03b26b53c87faa1058f30bb5d2fee64f717719a0d9b7e4f4df027aa5e9b6ed69602052604081207fbae4ee3de6c709ff9a002e774c5b78cb381560b219213c88ae0f1e207c03c023906000805160206157318339815191529060ff905b54166137a857818352602090815260408084206001600160a01b038616600090815292529020805460ff1916600117905533926001600160a01b0316917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9080a4600190565b5050905090565b6001600160a01b03811660009081527f0287ab4cb376ea253d7b2ce0c2cbf458f7deae9458470d74afdfbbee484e9540602052604081207f9c56d972d63cbb4195b3c1484691dfc220fa96a4c47e7b6613bd82a022029e06906000805160206157318339815191529060ff90613742565b6001600160a01b03811660009081527fe41986b390c4ce6791b87f7423b5fab7a81a0e6d89660b6264f697d008b2243a602052604081207fc6aaadd7371d5e8f9ed6849dd66a66573a3ba37167d03f4352c9ba5693678fac906000805160206157318339815191529060ff90613742565b6001600160a01b03811660009081527f2d4ccbfe9f7672a6f2537c1e5bce6adacb73706879154bbab6ce096012d67216602052604081207f4a634bc14d77baf979756509ef4298c6f6318af357828612545267ee2eb79233906000805160206157318339815191529060ff90613742565b6000818152600080516020615731833981519152602081815260408084206001600160a01b0387168552909152822091929160ff90613742565b6000818152600080516020615731833981519152602081815260408084206001600160a01b038716855290915282205491929160ff16156137a857818352602090815260408084206001600160a01b038616600090815292529020805460ff1916905533926001600160a01b0316917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9080a4600190565b90816020910312610513575190565b5190610c1682610b67565b91908261016091031261051357613a03610be9565b91613a0d81612dc4565b8352613a1b60208201612dc4565b6020840152613a2c604082016139e3565b6040840152613a3d60608201612da4565b6060840152613a4e60808201612da4565b608084015260a081015160a0840152613a6960c08201612dc4565b60c0840152613a7a60e08201612dc4565b60e0840152610100613a8d818301612dc4565b90840152610120613a9f818301612dc4565b90840152613ab1610140809201612dc4565b90830152565b81601f82011215610513578051613acd81610c18565b92613adb6040519485610bc8565b81845260208284010111610513576105719160208085019101610518565b81516001600160a01b0316815261016081019291610c1691906020818101516001600160a01b03169083015260408181015165ffffffffffff169083015260608181015115159083015260808181015115159083015260a0818101519083015260c0808201516001600160a01b03169083015260e0818101516001600160a01b031690830152610100818101516001600160a01b031690830152610120818101516001600160a01b031690830152610140908101516001600160a01b0316910152565b6000805160206156d1833981519152546001600160a01b03163303613bdd57565b60405163118cdaa760e01b8152336004820152602490fd5b9080821015613c02575090565b905090565b8115612bfd570490565b90918282029160001984820993838086109503948086039514613c995784831115613c875782910981600003821680920460028082600302188083028203028083028203028083028203028083028203028083028203028092029003029360018380600003040190848311900302920304170290565b60405163227bc15360e01b8152600490fd5b5050906105719250613c07565b600b54811015612d6d57600b6000526000805160206157118339815191520190600090565b600d54811015612d6d57600d6000526000805160206156f18339815191520190600090565b8054821015612d6d5760005260206000200190600090565b600d54600160401b811015610ba8576001810180600d55811015612d6d57600d6000526000805160206156f18339815191520155565b600b54600160401b811015610ba8576001810180600b55811015612d6d57600b6000526000805160206157118339815191520155565b90815491600160401b831015610ba85782613d97916001610c1695018155613cf0565b90919082549060031b91821b91600019901b1916179055565b919091600d9081548015613e5d575b50613dc8614c44565b50929091815492613dd76141a3565b9481613e48575b5015613e2557506000198201828111610a3a5781541115612d6d576000527fd7b6990105719101dabeb77144f2a3385c8033acd3af97e9423a695e81ad1eb4018390559190565b613e39926001600160d01b031691506150f7565b5050613e4483613d08565b9190565b65ffffffffffff838116911614905038613dde565b600160401b811015610ba85760018101808455811015612d6d576000908382526000805160206156f1833981519152015538613dbf565b919091600b9081548015613f3d575b50613eac614cb4565b50929091815492613ebb614121565b9481613f28575b5015613f0957506000198201828111610a3a5781541115612d6d576000527f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db8018390559190565b613f1d926001600160d01b031691506151f8565b5050613e4483613d3e565b65ffffffffffff838116911614905038613ec2565b600160401b811015610ba85760018101808455811015612d6d57600090838252600080516020615711833981519152015538613ea3565b90929192600182019081548015614003575b5084613f9184614d03565b50949092845493613fa18361421f565b9681613fee575b5015613fcb575050506000198101908111610a3a57613d978591613e4493613cf0565b613e44949293613fe7926001600160d01b0390911691906152a2565b5050613d74565b65ffffffffffff838116911614905038613fa8565b600160401b811015610ba85780600161401f9201845583613cf0565b8154906000199060031b1b1916905538613f86565b60405163a9059cbb60e01b60208201526001600160a01b03909216602483015260448083019390935291815260808101916001600160401b03831182841017610ba857610c1692604052614d37565b9061408c612c02565b82101561410f57600082815260096020908152604080832033845290915290205460ff166140fd576140be3383612e88565b9182156140eb5760009081526009602090815260408083203384529091529020805460ff19166001179055565b6040516366c0bcbf60e11b8152600490fd5b604051630c8d9eab60e31b8152600490fd5b60405163d5b25b6360e01b8152600490fd5b600a546000908061416957505060005b6001600160d01b0381161561416357600b54811015612d6d57600b600052600080516020615711833981519152015490565b50600090565b80600019810111610a3a57600a7fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a79252015460301c614131565b600c54600090806141e557505060005b6001600160d01b0381161561416357600d54811015612d6d57600d6000526000805160206156f1833981519152015490565b80600019810111610a3a57600c7fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c69252015460301c6141b3565b80546000908061425a57505060005b6001600160d01b038116156142535760016142499201613cf0565b90549060031b1c90565b5050600090565b600019918183810111610a3a578084602092522001015460301c61422e565b906001600160a01b038083161561072957811615610710576106c161429d92611a25565b55565b919060018101809111610a3a5760018201809211610a3a5761057192613c11565b600a54906000829160058411614333575b6142dc93506154b1565b80614300575060005b6001600160d01b038116156141635761424961057191613ca6565b61432761430f61432e926129db565b600a6000526000805160206156918339815191520190565b5460301c90565b6142e5565b919261433e81615377565b8103908111610a3a576142dc93600a60005265ffffffffffff80836000805160206156918339815191520154169085161060001461437d5750916142d2565b92915061438990612a0a565b906142d2565b600c549060008291600584116143fa575b6143aa935061551d565b806143ce575060005b6001600160d01b038116156141635761424961057191613ccb565b6143276143dd6143f5926129db565b600c6000526000805160206156518339815191520190565b6143b3565b919261440581615377565b8103908111610a3a576143aa93600c60005265ffffffffffff8083600080516020615651833981519152015416908516106000146144445750916143a0565b92915061445090612a0a565b906143a0565b9081549060008291600584116144bd575b614472935084615589565b8061449b57506000905b6001600160d01b03821615614253576105719160016142499201613cf0565b6143276144aa6144b7926129db565b8360005260206000200190565b9061447c565b91926144c881615377565b8103908111610a3a57614472938560005265ffffffffffff80836020600020015416908516106000146144fc575091614467565b92915061450890612a0a565b90614467565b6040519061451b82610bad565b60006020838281520152565b61452f61450e565b5061453861450e565b50600a54811015612d6d5761456190600a60005260008051602061569183398151915201614c20565b65ffffffffffff81511690602060018060d01b0391015116600b54811015612d6d57600b6000526000805160206157118339815191520154604051916145a683610bad565b8252602082015290565b6145b861450e565b506145c161450e565b50600c54811015612d6d576145ea90600c60005260008051602061565183398151915201614c20565b65ffffffffffff81511690602060018060d01b0391015116600d54811015612d6d57600d6000526000805160206156f18339815191520154604051916145a683610bad565b906146586146526146799261464261450e565b5061464b61450e565b5084613cf0565b50614c20565b91600165ffffffffffff845116936020828060d01b03910151169101613cf0565b9054906040519261468984610bad565b835260031b1c602082015290565b6040516323b872dd60e01b60208201526001600160a01b03928316602482015292909116604483015260648083019390935291815260a08101918183106001600160401b03841117610ba857610c1692604052614d37565b60ff6000805160206157718339815191525460401c161561470c57565b604051631afcd79f60e31b8152600490fd5b906101608282031261051357610571916139ee565b614746906020808251830101910161471e565b80516001600160a01b039190821615614ae257604080820165ffffffffffff614775825165ffffffffffff1690565b1615614ad15760c083018051909290614796906001600160a01b0316611725565b15614982575b50916148ce6101409261486961484461492c966147eb6147c2875160018060a01b031690565b6000805462010000600160b01b03191660109290921b62010000600160b01b0316919091179055565b6020860151600180546001600160a01b0319166001600160a01b0390921691909117905561332e61481b4261321f565b6001805465ffffffffffff60a01b191660a09290921b65ffffffffffff60a01b16919091179055565b600180546001600160d01b031660d09290921b6001600160d01b031916919091179055565b61488b6148796060850151151590565b60ff8019600054169115151617600055565b6148b461489b6080850151151590565b61ff0060005491151560081b169061ff00191617600055565b6148c160a0840151600455565b516001600160a01b031690565b848116614972575b5060e08101516001600160a01b0316848116614962575b506101008101516001600160a01b0316848116614952575b506101208101516001600160a01b0316848116614942575b5001516001600160a01b031690565b9081166149365750565b61493f90613891565b50565b61494b90613820565b503861491d565b61495b906137af565b5038614905565b61496b906136d5565b50386148ed565b61497b90613620565b50386148d6565b60e0840151614999906001600160a01b0316611725565b15614a6e575b6101208401516149b7906001600160a01b0316611725565b61479c57608084015115614a245760a08401511580614a05575b6149f55750916148ce6101409261486961484461492c965b9496505050925061479c565b5163183c854560e21b8152600490fd5b50610140840151614a1e906001600160a01b0316611725565b156149d1565b60a084015115801590614a4e575b6149f55750916148ce6101409261486961484461492c966149e9565b50610140840151614a67906001600160a01b0316611725565b1515614a32565b606084015115614aa457610100840151614a90906001600160a01b0316611725565b61499f575163183c854560e21b8152600490fd5b610100840151614abc906001600160a01b0316611725565b1561499f575163183c854560e21b8152600490fd5b81516368f5f8f160e11b8152600490fd5b6040516368f7a67560e11b8152600490fd5b9190614afe6146ef565b614b066146ef565b82516001600160401b038111610ba85760008051602061567183398151915290614b3981614b34845461298b565b614de9565b602080601f8311600114614b8257509080614b7092610c169697600092614b77575b50508160011b916000199060031b1c19161790565b9055614ee7565b015190503880614b5b565b90601f19831696614bc26000805160206156718339815191526000527f2ae08a8e29253f69ac5d979a101956ab8f8d9d7ded63fa7a83b16fc47648eab090565b926000905b898210614c0857505090839291600194610c16989910614bef575b505050811b019055614ee7565b015160001960f88460031b161c19169055388080614be2565b80600185968294968601518155019501930190614bc7565b90604051614c2d81610bad565b915465ffffffffffff8116835260301c6020830152565b600c5480614c585750600090600090600090565b80600019810111610a3a577fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c6614c9391600c60005201614c20565b9065ffffffffffff82511691602060018060d01b0391015116906001929190565b600a5480614cc85750600090600090600090565b80600019810111610a3a577fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a7614c9391600a60005201614c20565b805480614d17575050600090600090600090565b600019908082810111610a3a57614c939260005260206000200101614c20565b600080614d609260018060a01b03169360208151910182865af1614d59612de4565b90836155ed565b8051908115159182614d8e575b5050614d765750565b60249060405190635274afe760e01b82526004820152fd5b614da19250602080918301019101612daf565b153880614d6d565b919060018101809111610a3a5760018201809211610a3a57614dcc828285613c11565b928215612bfd5709614ddb5790565b60018101809111610a3a5790565b601f8111614df5575050565b6000906000805160206156718339815191526000527f2ae08a8e29253f69ac5d979a101956ab8f8d9d7ded63fa7a83b16fc47648eab0906020601f850160051c83019410614e5e575b601f0160051c01915b828110614e5357505050565b818155600101614e47565b9092508290614e3e565b601f8111614e74575050565b6000906000805160206156b18339815191526000527f46a2803e59a4de4e7a4c574b1243f25977ac4c77d5a1a4a609b5394cebb4a2aa906020601f850160051c83019410614edd575b601f0160051c01915b828110614ed257505050565b818155600101614ec6565b9092508290614ebd565b9081516001600160401b038111610ba8576000805160206156b183398151915290614f1b81614f16845461298b565b614e68565b602080601f8311600114614f5257508190614f4e939495600092614b775750508160011b916000199060031b1c19161790565b9055565b90601f19831695614f926000805160206156b18339815191526000527f46a2803e59a4de4e7a4c574b1243f25977ac4c77d5a1a4a609b5394cebb4a2aa90565b926000905b888210614fcf57505083600195969710614fb6575b505050811b019055565b015160001960f88460031b161c19169055388080614fac565b80600185968294968601518155019501930190614f97565b600c5490600160401b821015610ba8576001820180600c55821015612d6d57600c600052805160209091015160301b65ffffffffffff191665ffffffffffff919091161760008051602061565183398151915290910155565b600a5490600160401b821015610ba8576001820180600a55821015612d6d57600a600052805160209091015160301b65ffffffffffff191665ffffffffffff919091161760008051602061569183398151915290910155565b8054600160401b811015610ba8576150b691600182018155613cf0565b6150e157815160209092015160301b65ffffffffffff191665ffffffffffff92909216919091179055565b634e487b7160e01b600052600060045260246000fd5b600c549192919081156151ce576151186151136143dd846129db565b614c20565b805165ffffffffffff83811694911684106151bc5785602093613e449561514861333a865165ffffffffffff1690565b03615184575061515d6143dd615176936129db565b9065ffffffffffff82549181199060301b169116179055565b01516001600160d01b031690565b90506151b791506151a4615196610c09565b65ffffffffffff9092168252565b6001600160d01b03871681850152614fe7565b615176565b604051632520601d60e01b8152600490fd5b6151f291506151de615196610c09565b6001600160d01b0384166020820152614fe7565b60009190565b600a5491929190811561527e5761521461511361430f846129db565b805165ffffffffffff83811694911684106151bc5785602093613e449561524461333a865165ffffffffffff1690565b03615259575061515d61430f615176936129db565b90506151b7915061526b615196610c09565b6001600160d01b03871681850152615040565b6151f2915061528e615196610c09565b6001600160d01b0384166020820152615040565b805492939291908215615353576152be6151136144aa856129db565b906152cf825165ffffffffffff1690565b65ffffffffffff848116911681106151bc57613e449460209488926152fd61333a875165ffffffffffff1690565b0361532057506151769261531361515d926129db565b9060005260206000200190565b9150506151b791615340615332610c09565b65ffffffffffff9093168352565b6001600160d01b03881682860152615099565b6151f29250615363615332610c09565b6001600160d01b0385166020830152615099565b8015614163578061544a61544361543961542f61542561541b61541161540760016105719a6000908b60801c806154a5575b508060401c80615498575b508060201c8061548b575b508060101c8061547e575b508060081c80615471575b508060041c80615464575b508060021c80615457575b50821c615450575b811c1b615400818b613c07565b0160011c90565b615400818a613c07565b6154008189613c07565b6154008188613c07565b6154008187613c07565b6154008186613c07565b6154008185613c07565b8092613c07565b90613bf5565b81016153f3565b60029150910190386153eb565b60049150910190386153e0565b60089150910190386153d5565b60109150910190386153ca565b60209150910190386153bf565b60409150910190386153b4565b915050608090386153a9565b905b8281106154bf57505090565b9091808216906001818418811c8301809311610a3a57600a60005265ffffffffffff80846000805160206156918339815191520154169086161060001461550a575050915b906154b3565b909392508101809111610a3a5790615504565b905b82811061552b57505090565b9091808216906001818418811c8301809311610a3a57600c60005265ffffffffffff808460008051602061565183398151915201541690861610600014615576575050915b9061551f565b909392508101809111610a3a5790615570565b91905b8382106155995750505090565b909192808316906001818518811c8301809311610a3a5760008681526020902083015465ffffffffffff90811690851610156155da575050925b919061558c565b909493508101809111610a3a57916155d3565b90615614575080511561560257805190602001fd5b604051630a12f52160e11b8152600490fd5b81511580615647575b615625575090565b604051639996b31560e01b81526001600160a01b039091166004820152602490fd5b50803b1561561d56fedf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c752c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace03c65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a852c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace049016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300d7b6990105719101dabeb77144f2a3385c8033acd3af97e9423a695e81ad1eb50175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db902dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268009b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00a264697066735822122098ba609be7226fd1dc08c59c39d15b175e4125a89f30af71d6acd7087771cedb64736f6c63430008190033000000000000000000000000890ca3f95e0f40a79885b7400926544b2214b03f000000000000000000000000bf34bf75bb779c383267736c53a4ae86ac7bb299000000000000000000000000407a039d94948484d356efb765b3c74382a050b4
Deployed Bytecode
0x6080604052600436101561001257600080fd5b60003560e01c806301ffc9a7146104bd57806306fdde03146104b8578063095ea7b3146104b35780631415519b146104ae57806318160ddd1461038c5780631b66c9e1146104a95780631e9a6950146104a457806323b872dd1461049f578063248a9ca31461049a57806327810b6e14610495578063281f5752146104905780632abe30481461048b5780632d73c69c146104865780632dd31000146104815780632f2ff15d1461047c578063313ce5671461047757806336568abe14610472578063392e53cd1461046d5780634105a7dd14610468578063463616711461046357806347e7ef241461045e57806348d3b775146104595780634ff0876a1461045457806350861adc1461044f57806350f220681461044a5780635346e34f1461044557806354fd4d501461044057806357ec83cc1461043b57806359f769a9146104365780635cc070761461043157806361a8c8c41461042c5780636da3e06d146104275780636ec1e3f81461042257806370a08231146103d7578063715018a61461041d5780637278e31c1461041857806373790ab314610413578063766718081461040e578063794b15b7146104095780637953b33b146104045780637c04c80a146103ff578063810da75d146103fa57806383cd9cc3146103f557806387df0788146103f05780638b0e9f3f146103eb5780638da5cb5b146103e657806391d14854146103e157806395d89b41146103dc5780639d66201b146103d75780639f86fd85146103d2578063a1b12202146103cd578063a217fddf146103c8578063a21a1df9146103c3578063a2861466146103be578063a3b54172146103b9578063a5d03223146103b4578063a9059cbb146103af578063aabc2496146103aa578063aad3ec96146103a5578063afba70ad146103a0578063b13442711461039b578063bd49c35f14610396578063bdc8144b14610391578063bfefcd7b1461038c578063c31e8dd714610387578063ce9b793014610382578063d547741f1461037d578063d8dfeb4514610378578063db38871514610373578063dd62ed3e1461036e578063ecf7085814610369578063efb559d614610364578063f2fde38b1461035f578063f3fef3a31461035a5763f5e7ee0f1461035557600080fd5b612961565b6128ba565b61288d565b61273e565b612720565b6126e9565b6126ae565b612681565b612632565b612609565b61259f565b61077d565b6124bf565b6124a4565b61247b565b61244f565b61238c565b6121d1565b61219c565b612152565b612101565b61200b565b611fd0565b611fb4565b611f8e565b611ef9565b611645565b611e45565b611de2565b611dac565b611d48565b611d03565b611b46565b611b2d565b611ac7565b611aa0565b611a5e565b611a0a565b6119c8565b6116ec565b611681565b61161f565b6115da565b611586565b61155a565b611533565b6113f8565b6113c4565b61132c565b611313565b6112b5565b611294565b611271565b610f80565b610f57565b610eb9565b610e73565b610e28565b610d88565b610d37565b610cf2565b610c85565b610a94565b6109c4565b61099b565b61095f565b6108c2565b6107db565b6107a0565b610742565b61067c565b610574565b346105135760203660031901126105135760043563ffffffff60e01b811680910361051357602090637965db0b60e01b8114908115610502575b506040519015158152f35b6301ffc9a760e01b149050386104f7565b600080fd5b60005b83811061052b5750506000910152565b818101518382015260200161051b565b9060209161055481518092818552858086019101610518565b601f01601f1916010190565b90602061057192818152019061053b565b90565b346105135760008060031936011261066857604051908060008051602061567183398151915280546105a58161298b565b8086529260209260019280841690811561063957506001146105e2575b6105de876105d281890382610bc8565b60405191829182610560565b0390f35b815293507f2ae08a8e29253f69ac5d979a101956ab8f8d9d7ded63fa7a83b16fc47648eab05b838510610626575050505081016020016105d2826105de38806105c2565b8054868601840152938201938101610608565b9150508695506105de969350602092506105d294915060ff191682840152151560051b820101929338806105c2565b80fd5b6001600160a01b0381160361051357565b34610513576040366003190112610513576004356106998161066b565b6024353315610729576001600160a01b038216918215610710576106d882916106c133611a25565b9060018060a01b0316600052602052604060002090565b556040519081527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560203392a3602060405160018152f35b604051634a1406b160e11b815260006004820152602490fd5b60405163e602df0560e01b815260006004820152602490fd5b346105135760003660031901126105135760206040517fc6aaadd7371d5e8f9ed6849dd66a66573a3ba37167d03f4352c9ba5693678fac8152f35b34610513576000366003190112610513576020610798614121565b604051908152f35b346105135760003660031901126105135760206040517f9c56d972d63cbb4195b3c1484691dfc220fa96a4c47e7b6613bd82a022029e068152f35b34610513576040366003190112610513576004356107f88161066b565b60243590610804612eed565b6001600160a01b038116156108b157336000908152600e602052604090206108309061421f565b61421f565b821161089f576108506108416141a3565b610849614121565b90846142a0565b91821561088a578261086192612f1d565b90610879600160008051602061575183398151915255565b604080519182526020820192909252f35b60405160016245ddc760e11b03198152600490fd5b604051632418411f60e11b8152600490fd5b6040516208978560e71b8152600490fd5b34610513576060366003190112610513576004356108df8161066b565b6024356108eb8161066b565b604435906108fc336106c185611a25565b54926001840161091d575b61091193506130b9565b60405160018152602090f35b828410610939576109348361091195033383614279565b610907565b604051637dc7a0d960e11b81523360048201526024810185905260448101849052606490fd5b34610513576020366003190112610513576004356000526000805160206157318339815191526020526020600160406000200154604051908152f35b34610513576000366003190112610513576001546040516001600160a01b039091168152602090f35b34610513576000366003190112610513576109dd612c02565b8015610a3f5760015465ffffffffffff8160a01c16916000198101908111610a3a57610a0c9160d01c906129f7565b8101809111610a3a57610a216105de9161321f565b60405165ffffffffffff90911681529081906020820190565b6129c5565b604051639fa56a5b60e01b8152600490fd5b600435906001600160401b038216820361051357565b9181601f84011215610513578235916001600160401b038311610513576020838186019501011161051357565b3461051357604036600319011261051357610aad610a51565b6001600160401b0360243581811161051357610acd903690600401610a67565b5050610ad7612eed565b7f000000000000000000000000407a039d94948484d356efb765b3c74382a050b46001600160a01b03163303610b5557600080516020615771833981519152549060ff8260401c16928315610b45575b505050610b3357600080fd5b60405163f92ee8a960e01b8152600490fd5b8116911610159050388080610b27565b604051631966391b60e11b8152600490fd5b65ffffffffffff81160361051357565b634e487b7160e01b600052604160045260246000fd5b606081019081106001600160401b03821117610ba857604052565b610b77565b604081019081106001600160401b03821117610ba857604052565b90601f801991011681019081106001600160401b03821117610ba857604052565b6040519061016082018281106001600160401b03821117610ba857604052565b60405190610c1682610bad565b565b6001600160401b038111610ba857601f01601f191660200190565b929192610c3f82610c18565b91610c4d6040519384610bc8565b829481845281830111610513578281602093846000960137010152565b9080601f830112156105135781602061057193359101610c33565b3461051357606036600319011261051357600435610ca28161066b565b60243590610caf82610b67565b604435906001600160401b03821161051357602092610cd5610798933690600401610c6a565b6001600160a01b039092166000908152600e855260409020613418565b34610513576000366003190112610513576040517f000000000000000000000000407a039d94948484d356efb765b3c74382a050b46001600160a01b03168152602090f35b3461051357604036600319011261051357610d86602435600435610d5a8261066b565b80600052600080516020615731833981519152602052610d816001604060002001546135f2565b613902565b005b346105135760008060031936011261066857805460405163313ce56760e01b8152906020908290600490829060101c6001600160a01b03165afa908115610e23578291610dde575b60405160ff83168152602090f35b90506020813d602011610e1b575b81610df960209383610bc8565b81010312610e17575160ff81168103610e17576105de915038610dd0565b5080fd5b3d9150610dec565b612a47565b3461051357604036600319011261051357602435610e458161066b565b336001600160a01b03821603610e6157610d869060043561393c565b60405163334bd91960e11b8152600490fd5b346105135760003660031901126105135760ff60025460a01c1680610ea0575b6020906040519015158152f35b5060035460a01c60ff16610e93565b8015150361051357565b3461051357602036600319011261051357600435610ed681610eaf565b610ede612eed565b610ee66134e4565b600054901515908160ff8216151514610f455760ff191660ff8216176000556040519081527f3e12b7b36c75ac9609a3f58609b331210428e1a85909132638955ba0301eec3390602090a1600160008051602061575183398151915255005b60405163a741a04560e01b8152600490fd5b3461051357600036600319011261051357602065ffffffffffff60015460a01c16604051908152f35b3461051357604080600319360112610513576004803591610fa08361066b565b610fa8612eed565b6001600160a01b03918383169081156112635760005460ff811680611249575b61123a5783516370a0823160e01b808252308483019081529096602093909160109190911c82169084908490819083010381845afa928315610e2357600093611217575b5061101e906024359030903390614697565b60005486519788523085890190815290979184918391908290819060200103918b60101c165afa908115610e235761105f936000926111ea575b50506129ea565b9384156111db5760081c60ff16806111c6575b6111b85750906105de916111256110876141a3565b956110d0611093614121565b6110bb6110a18a838b6142a0565b996110b58a6110af4261321f565b92612a18565b90613db0565b50506110ca896110af4261321f565b90613e94565b50506001600160a01b0381166000908152600e602052604090209061111f8861111a61082b6110fe4261321f565b6001600160a01b039095166000908152600e6020526040902090565b612a18565b91613f74565b5050815184815260208101869052819033907fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d790604090a3611174600160008051602061575183398151915255565b81518581526000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90602090a35191825260208201929092529081906040820190565b8251632484557960e01b8152fd5b506111d38461111a6141a3565b815410611072565b50825163070f6eed60e11b8152fd5b6112099250803d10611210575b6112018183610bc8565b8101906139d4565b3880611058565b503d6111f7565b61101e91935061123390853d8711611210576112018183610bc8565b929061100c565b5082516304f63b8560e01b8152fd5b503360009081526005602052604090205460ff1615610fc8565b8251630d534ce360e11b8152fd5b3461051357600036600319011261051357602060ff600054166040519015158152f35b3461051357600036600319011261051357602060015460d01c604051908152f35b3461051357600036600319011261051357602060ff60025460a01c166040519015158152f35b906040600319830112610513576004356112f481610b67565b91602435906001600160401b0382116105135761057191600401610c6a565b34610513576020610798611326366112db565b90613282565b346105135760203660031901126105135760043561134981610eaf565b611351612eed565b611359613542565b600054901515908160ff8260081c16151514610f455761ff001916600882901b61ff0016176000556040519081527ffa7a25a0b611d4ba3c0ea990e90dc23d484a5dd7a1be4733fef2946ba74530c690602090a1610d86600160008051602061575183398151915255565b346105135760003660031901126105135760206001600160401b036000805160206157718339815191525416604051908152f35b3461051357606036600319011261051357611411610a51565b60243561141d8161066b565b6001600160401b03916044358381116105135761143e903690600401610a67565b6000805160206157718339815191529491855494838616806115225760ff8760401c16908115611515575b50610b33577fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d296611510966114d7958716906001600160401b0319161790556114d2600080516020615771833981519152600160401b68ff000000000000000019825416179055565b612a53565b600080516020615771833981519152805468ff0000000000000000191690556040516001600160401b0390911681529081906020820190565b0390a1005b9050848616111538611469565b60405162dc149f60e41b8152600490fd5b346105135760203660031901126105135760206107986004356115558161066b565b612b68565b346105135760203660031901126105135760043560005260066020526020604060002054604051908152f35b346105135760003660031901126105135760015465ffffffffffff6115bd818360a01c16926115b3612c02565b9060d01c906129f7565b8201809211610a3a576115d160209261321f565b60405191168152f35b34610513576000366003190112610513576040517f000000000000000000000000890ca3f95e0f40a79885b7400926544b2214b03f6001600160a01b03168152602090f35b3461051357600036600319011261051357602060ff60035460a01c166040519015158152f35b34610513576020366003190112610513576004356116628161066b565b60018060a01b0316600052600e6020526020610798604060002061421f565b34610513576000806003193601126106685761169b613bbc565b6000805160206156d183398151915280546001600160a01b0319811690915581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b346105135760403660031901126105135760043560243561170c81610b67565b611714612eed565b600354611731906001600160a01b03165b6001600160a01b031690565b33036119b65761173f612c02565b9061174981612c36565b90821515806119a5575b801561199c575b61198a576105de937ff9d090c096f71cd1659861a9ce5b6f384bceb4e2fa4e4a19edf6489a9b8d56c79261178c6141a3565b946117a961179982612a0a565b6000526006602052604060002090565b549082810361189f57506117bd8187612a18565b6117c78185613bf5565b968780611858575b50505050505b83611823575b6040805191825265ffffffffffff929092166020820152908101839052606090a1611813600160008051602061575183398151915255565b6040519081529081906020820190565b6000546118539085906118419060101c6001600160a01b0316611725565b6001546001600160a01b031690614034565b6117db565b61189493611058836110b561187e6118776117999861188e9888613c11565b80966129ea565b946118884261321f565b926129ea565b92612a0a565b5538808080876117cf565b91506118b5826000526006602052604060002090565b54906118c58161111a848a612a18565b906118d08286613bf5565b97886118e1575b50505050506117d5565b6119589383611909936119168c6119116118ff611947998884613c11565b9788958584613c11565b9485926129ea565b6129ea565b93848410611963575b611058906110b56119359596976118884261321f565b61194161179987612a0a565b556129ea565b916000526006602052604060002090565b5538808080806118d7565b9161197f611058916119798661193597986129ea565b90612a18565b85945092905061191f565b604051635e18d2a560e01b8152600490fd5b5082821161175a565b506119af836129db565b8210611753565b60405163dabc4ad960e01b8152600490fd5b346105135760003660031901126105135760015465ffffffffffff808260a01c16916119f2612c02565b60018101809111610a3a576115bd9160d01c906129f7565b34610513576000366003190112610513576020610798612c02565b6001600160a01b031660009081527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace016020526040902090565b3461051357602036600319011261051357600435611a7b8161066b565b60018060a01b03166000526005602052602060ff604060002054166040519015158152f35b34610513576020366003190112610513576020610798600435611ac281610b67565b612c36565b3461051357604036600319011261051357600435611ae48161066b565b6024356001600160401b038082116105135736602383011215610513578160040135908111610513573660248260051b84010111610513576105de926024611813930190612c71565b34610513576020610798611b40366112db565b90613363565b3461051357602080600319360112610513576004803590611b668261066b565b611b6e612eed565b60025460a01c60ff16611cf4576040516302910f8b60e31b81526001600160a01b03838116838301908152909491908290829081906020010381887f000000000000000000000000890ca3f95e0f40a79885b7400926544b2214b03f165afa908115610e2357600091611cc7575b5015611cb75760405163fbfa77cf60e01b8152838516949082818581895afa928315610e2357600093611c88575b505030911603611c795750600280546001600160a01b03929092166001600160a81b031990921691909117600160a01b1790557fdb2160616f776a37b24808115554e79439bf26cccbbd4438190cc6d28e80ecd1600080a2610d86600160008051602061575183398151915255565b60405163b9f0f17160e01b8152fd5b611ca8929350803d10611cb0575b611ca08183610bc8565b810190612dcf565b903880611c0a565b503d611c96565b506040516324e5af8d60e21b8152fd5b611ce79150823d8411611ced575b611cdf8183610bc8565b810190612daf565b38611bdc565b503d611cd5565b604051631380833b60e01b8152fd5b34610513576000366003190112610513576040517f000000000000000000000000bf34bf75bb779c383267736c53a4ae86ac7bb2996001600160a01b03168152602090f35b346105135760008060031936011261066857611d62612c02565b611d6a6141a3565b91818152600660205260408120548301809311610a3a5760018201809211610a3a576040918152600660205220548101809111610a3a57602090604051908152f35b34610513576000366003190112610513576000805160206156d1833981519152546040516001600160a01b039091168152602090f35b3461051357604036600319011261051357602060ff611e39602435611e068161066b565b600435600052600080516020615731833981519152845260406000209060018060a01b0316600052602052604060002090565b54166040519015158152f35b34610513576000806003193601126106685760405190806000805160206156b18339815191528054611e768161298b565b808652926020926001928084169081156106395750600114611ea2576105de876105d281890382610bc8565b815293507f46a2803e59a4de4e7a4c574b1243f25977ac4c77d5a1a4a609b5394cebb4a2aa5b838510611ee6575050505081016020016105d2826105de38806105c2565b8054868601840152938201938101611ec8565b3461051357604036600319011261051357600435611f168161066b565b6024356001600160401b03811161051357600091611f3983923690600401610a67565b90816040519283928337810184815203915af4611f86611f57612de4565b91611f7860405193849215156020840152604080840152606083019061053b565b03601f198101835282610bc8565b805190602001fd5b3461051357600036600319011261051357602060ff60005460081c166040519015158152f35b3461051357600036600319011261051357602060405160008152f35b346105135760003660031901126105135760206040517f4a634bc14d77baf979756509ef4298c6f6318af357828612545267ee2eb792338152f35b34610513576040366003190112610513576004356120288161066b565b60243561203481610eaf565b61203c612eed565b61204461359a565b6001600160a01b0382169182156120ef5760008381526005602052604090205460ff16151582151514610f45576001600160a01b031660009081526005602052604090207ff991b1ecfb5115cbb36a2b2e2240c058406d2acc2fcc6e9e2dc99d845ff70a62916120d5916120c3908260ff801983541691151516179055565b60405190151581529081906020820190565b0390a2610d86600160008051602061575183398151915255565b604051630da30f6560e31b8152600490fd5b346105135760403660031901126105135760206121496024356121238161066b565b6004356000526008835260406000209060018060a01b0316600052602052604060002090565b54604051908152f35b3461051357604036600319011261051357602060ff611e396024356121768161066b565b6004356000526009845260406000209060018060a01b0316600052602052604060002090565b34610513576040366003190112610513576121c66004356121bc8161066b565b60243590336130b9565b602060405160018152f35b34610513576020806003193601126105135760048035906121f18261066b565b6121f9612eed565b60035460a01c60ff1661237d576001600160a01b03828116939084612269575b6003805460ff60a01b1916600160a01b179055847fe7e4c932e03abddfe20f83af42c33627e816115c7ec2b168441f65dc14bfc3ba600080a2610d86600160008051602061575183398151915255565b6040516302910f8b60e31b81526001600160a01b0385168482019081528390829081906020010381857f000000000000000000000000bf34bf75bb779c383267736c53a4ae86ac7bb299165afa908115610e2357600091612360575b501561234f5760405163fbfa77cf60e01b815282818581895afa928315610e2357600093612330575b5050309116036123215750600380546001600160a01b0319166001600160a01b0390921691909117905538808080612219565b604051633f3e089160e21b8152fd5b612347929350803d10611cb057611ca08183610bc8565b9038806122ee565b60405163dabc4ad960e01b81528390fd5b6123779150833d8511611ced57611cdf8183610bc8565b386122c5565b60405163703fe2e560e01b8152fd5b34610513576040366003190112610513576004356123a98161066b565b602435906123b5612eed565b6001600160a01b039181831690811561243d576123e76105de946123d883614083565b94859160005460101c16614034565b604080519182526020820184905233917f865ca08d59f5cb456e85cd2f7ef63664ea4f73327414e9d8152c4158b0e946459190a36001600080516020615751833981519152556040519081529081906020820190565b604051634e46966960e11b8152600490fd5b346105135760203660031901126105135760043560005260076020526020604060002054604051908152f35b34610513576000366003190112610513576003546040516001600160a01b039091168152602090f35b346105135760003660031901126105135760206107986141a3565b34610513576020366003190112610513576004356124db612eed565b3360009081527f2d4ccbfe9f7672a6f2537c1e5bce6adacb73706879154bbab6ce096012d6721660205260409020547f4a634bc14d77baf979756509ef4298c6f6318af357828612545267ee2eb792339060ff161561258157508060045414610f45576020817f854df3eb95564502c8bc871ebdd15310ee26270f955f6c6bd8cea68e75045bc092600455604051908152a1600160008051602061575183398151915255005b6044906040519063e2517d3f60e01b82523360048301526024820152fd5b34610513576020366003190112610513576004356125bc8161066b565b6125c4612c02565b6125cd82612b68565b916125d88183612e88565b8301809311610a3a5760018201809211610a3a576125f591612e88565b8101809111610a3a57602090604051908152f35b34610513576000366003190112610513576002546040516001600160a01b039091168152602090f35b3461051357604036600319011261051357610d866024356004356126558261066b565b8060005260008051602061573183398151915260205261267c6001604060002001546135f2565b61393c565b346105135760003660031901126105135760005460405160109190911c6001600160a01b03168152602090f35b346105135760003660031901126105135760206040517fbae4ee3de6c709ff9a002e774c5b78cb381560b219213c88ae0f1e207c03c0238152f35b3461051357604036600319011261051357602061214960043561270b8161066b565b6106c16024359161271b8361066b565b611a25565b34610513576000366003190112610513576020600454604051908152f35b346105135760603660031901126105135760043561275b8161066b565b6024359061276882610b67565b6001600160401b039160443583811161051357612789903690600401610a67565b9092604093845161279981610b8d565b606081526060602082015260608682015292806127f8575b6105de866127e987876127e36127ca8984845191612a25565b92856127da602085015183613363565b93015190613282565b916142a0565b90519081529081906020820190565b8101939250602081850312610513578035908682116105135701926060848203126105135784519561282987610b8d565b8435818111610513578261283e918701610c6a565b875260208501358181116105135782612858918701610c6a565b602088015285850135908111610513576105de966128816127e3936127ca936127e99801610c6a565b878201529394506127b1565b3461051357602036600319011261051357610d866004356128ad8161066b565b6128b5613bbc565b612e14565b34610513576040366003190112610513576004356128d78161066b565b6024356128e2612eed565b6001600160a01b038216156108b157801561294f57612911612902614121565b61290a6141a3565b9083614da9565b336000908152600e6020526040902090929061292c9061421f565b831161293d57610861918391612f1d565b6040516321727a3760e11b8152600490fd5b604051636c6c627d60e11b8152600490fd5b346105135760403660031901126105135760206107986024356129838161066b565b600435612e88565b90600182811c921680156129bb575b60208310146129a557565b634e487b7160e01b600052602260045260246000fd5b91607f169161299a565b634e487b7160e01b600052601160045260246000fd5b600019810191908211610a3a57565b91908203918211610a3a57565b81810292918115918404141715610a3a57565b9060018201809211610a3a57565b91908201809211610a3a57565b6001600160a01b03166000908152600e60205260409020610571929190613418565b6040513d6000823e3d90fd5b91612a9192612a606146ef565b612a686146ef565b6001600080516020615751833981519152556001600160a01b038116612b4e575b503691610c33565b80516020908201818101828483031261051357828401516001600160401b039485821161051357019283926101a093849103126105135760405193612ad585610b8d565b612ae1838383016139ee565b8552610180810151868111610513578383612afe92840101613ab7565b9382860194855281015195861161051357612b26612b459383610c1698612b40940101613ab7565b94604081019586525191611f786040519384928301613af9565b614733565b51905190614af4565b612b6290612b5a6146ef565b6128b56146ef565b38612a89565b6001600160a01b03166000908152600e60205260409020612b889061421f565b612b906141a3565b612b98614121565b9060018101809111610a3a5760018201809211610a3a5761057192613c11565b65ffffffffffff9182169082160391908211610a3a57565b634e487b7160e01b600052601260045260246000fd5b9065ffffffffffff809116918215612bfd57160490565b612bd0565b612c0b4261321f565b612c32600154612c2865ffffffffffff93848360a01c1690612bb8565b9060d01c90612be6565b1690565b6001549065ffffffffffff91828160a01c16918284821610612c5f57612c3292612c2891612bb8565b60405163b7d0949760e01b8152600490fd5b90612c7a612eed565b6000926001600160a01b03831692831561243d578115612d3557845b828110612d1357506000547f326b6aff1cd2fb1c8234de4f9dcfb9047c5c36eb9ef2eb34af5121e969a75d279286929091612ce7918491612ce29060101c6001600160a01b0316611725565b614034565b612cf8604051928392339684612d72565b0390a390610c16600160008051602061575183398151915255565b94612d2e600191611979612d28898789612d5d565b35614083565b9501612c96565b60405163edf3b93360e01b8152600490fd5b634e487b7160e01b600052603260045260246000fd5b9190811015612d6d5760051b0190565b612d47565b604080825281018390529392916001600160fb1b0381116105135760209160609160051b809183880137850101930152565b5190610c1682610eaf565b90816020910312610513575161057181610eaf565b5190610c168261066b565b9081602091031261051357516105718161066b565b3d15612e0f573d90612df582610c18565b91612e036040519384610bc8565b82523d6000602084013e565b606090565b6001600160a01b03908116908115612e6f576000805160206156d183398151915280546001600160a01b031981168417909155167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b604051631e4fbdf760e01b815260006004820152602490fd5b90612eb29082600052600860205260406000209060018060a01b0316600052602052604060002090565b5490600052600660205260406000205460076020526040600020549060018101809111610a3a5760018201809211610a3a5761057192613c11565b6000805160206157518339815191526002815414612f0b5760029055565b604051633ee5aeb560e01b8152600490fd5b336000908152600e6020526040812093949390929190612f5e90612f404261321f565b336000908152600e6020526040902061111f9089906119119061421f565b5050612f78612f6c4261321f565b6110ca87611911614121565b5050612f92612f864261321f565b6110b5846119116141a3565b50508161302e826106c1612fac612fa7612c02565b612a0a565b613009612fc3826000526006602052604060002090565b54612fd8836000526007602052604060002090565b54612fef612fe783838b6142a0565b9a8b93612a18565b613003856000526006602052604060002090565b55612a18565b61301d826000526007602052604060002090565b556000526008602052604060002090565b613039848254612a18565b9055604080519182526020820187905281018390526001600160a01b03919091169033907febff2602b3f468259e1e99f613fed6691f3a6526effe6ef3e768ba7ae7a36c4f90606090a36040519384529233907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9080602081015b0390a3565b916001600160a01b03808416929083156132065781169384156131ed576001600160a01b0381166000908152600e602052604090206130f79061421f565b908382106131bb576130b49261315b7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef95936131486131a99460018060a01b0316600052600e602052604060002090565b90856131534261321f565b910391613f74565b50506001600160a01b0381166000908152600e6020526040902090836131a261082b6131864261321f565b6001600160a01b039094166000908152600e6020526040902090565b0191613f74565b50506040519081529081906020820190565b60405163391434e360e21b81526001600160a01b03919091166004820152602481019190915260448101839052606490fd5b60405163ec442f0560e01b815260006004820152602490fd5b604051634b637e8f60e11b815260006004820152602490fd5b65ffffffffffff90818111613232571690565b604490604051906306dfcc6560e41b8252603060048301526024820152fd5b90816020910312610513575163ffffffff811681036105135790565b90600163ffffffff80931601918211610a3a57565b90805115613359578060208061329d93518301019101613251565b6132a681614527565b906132b7825165ffffffffffff1690565b9065ffffffffffff808516921682811461334d57821191826132ed575b50506132e45750610571906142c1565b60209150015190565b9091506132fb600a546129db565b63ffffffff831614918215613314575b505038806132d4565b61334591925061332e61332961333a9261326d565b614527565b5165ffffffffffff1690565b65ffffffffffff1690565b11388061330b565b50505060209150015190565b50610571906142c1565b9080511561340e578060208061337e93518301019101613251565b613387816145b0565b90613398825165ffffffffffff1690565b9065ffffffffffff808516921682811461334d57821191826133c5575b50506132e457506105719061438f565b9091506133d3600c546129db565b63ffffffff8316149182156133ec575b505038806133b5565b61340691925061332e61340161333a9261326d565b6145b0565b1138806133e3565b506105719061438f565b918051156134da578060208061343393518301019101613251565b9161343e838261462f565b9261344f845165ffffffffffff1690565b9065ffffffffffff80851692168281146134ce5782119182613485575b505061347c576105719250614456565b50506020015190565b90915061349283546129db565b63ffffffff8316149182156134ab575b5050388061346c565b6134c691925061332e6134c061333a9261326d565b8561462f565b1138806134a2565b50505050506020015190565b5061057191614456565b3360009081527f03b26b53c87faa1058f30bb5d2fee64f717719a0d9b7e4f4df027aa5e9b6ed69602052604090207fbae4ee3de6c709ff9a002e774c5b78cb381560b219213c88ae0f1e207c03c0239060ff905b5416156125815750565b3360009081527fe41986b390c4ce6791b87f7423b5fab7a81a0e6d89660b6264f697d008b2243a602052604090207fc6aaadd7371d5e8f9ed6849dd66a66573a3ba37167d03f4352c9ba5693678fac9060ff90613538565b3360009081527f0287ab4cb376ea253d7b2ce0c2cbf458f7deae9458470d74afdfbbee484e9540602052604090207f9c56d972d63cbb4195b3c1484691dfc220fa96a4c47e7b6613bd82a022029e069060ff90613538565b600081815260008051602061573183398151915260209081526040808320338452909152902060ff90613538565b6001600160a01b03811660009081527fb7db2dd08fcb62d0c9e08c51941cae53c267786a0b75803fb7960902fc8ef97d60205260408120546000805160206157318339815191529060ff166136cf57818052602090815260408083206001600160a01b038516600090815292529020805460ff1916600117905533916001600160a01b0316907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d8180a4600190565b50905090565b6001600160a01b03811660009081527f03b26b53c87faa1058f30bb5d2fee64f717719a0d9b7e4f4df027aa5e9b6ed69602052604081207fbae4ee3de6c709ff9a002e774c5b78cb381560b219213c88ae0f1e207c03c023906000805160206157318339815191529060ff905b54166137a857818352602090815260408084206001600160a01b038616600090815292529020805460ff1916600117905533926001600160a01b0316917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9080a4600190565b5050905090565b6001600160a01b03811660009081527f0287ab4cb376ea253d7b2ce0c2cbf458f7deae9458470d74afdfbbee484e9540602052604081207f9c56d972d63cbb4195b3c1484691dfc220fa96a4c47e7b6613bd82a022029e06906000805160206157318339815191529060ff90613742565b6001600160a01b03811660009081527fe41986b390c4ce6791b87f7423b5fab7a81a0e6d89660b6264f697d008b2243a602052604081207fc6aaadd7371d5e8f9ed6849dd66a66573a3ba37167d03f4352c9ba5693678fac906000805160206157318339815191529060ff90613742565b6001600160a01b03811660009081527f2d4ccbfe9f7672a6f2537c1e5bce6adacb73706879154bbab6ce096012d67216602052604081207f4a634bc14d77baf979756509ef4298c6f6318af357828612545267ee2eb79233906000805160206157318339815191529060ff90613742565b6000818152600080516020615731833981519152602081815260408084206001600160a01b0387168552909152822091929160ff90613742565b6000818152600080516020615731833981519152602081815260408084206001600160a01b038716855290915282205491929160ff16156137a857818352602090815260408084206001600160a01b038616600090815292529020805460ff1916905533926001600160a01b0316917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9080a4600190565b90816020910312610513575190565b5190610c1682610b67565b91908261016091031261051357613a03610be9565b91613a0d81612dc4565b8352613a1b60208201612dc4565b6020840152613a2c604082016139e3565b6040840152613a3d60608201612da4565b6060840152613a4e60808201612da4565b608084015260a081015160a0840152613a6960c08201612dc4565b60c0840152613a7a60e08201612dc4565b60e0840152610100613a8d818301612dc4565b90840152610120613a9f818301612dc4565b90840152613ab1610140809201612dc4565b90830152565b81601f82011215610513578051613acd81610c18565b92613adb6040519485610bc8565b81845260208284010111610513576105719160208085019101610518565b81516001600160a01b0316815261016081019291610c1691906020818101516001600160a01b03169083015260408181015165ffffffffffff169083015260608181015115159083015260808181015115159083015260a0818101519083015260c0808201516001600160a01b03169083015260e0818101516001600160a01b031690830152610100818101516001600160a01b031690830152610120818101516001600160a01b031690830152610140908101516001600160a01b0316910152565b6000805160206156d1833981519152546001600160a01b03163303613bdd57565b60405163118cdaa760e01b8152336004820152602490fd5b9080821015613c02575090565b905090565b8115612bfd570490565b90918282029160001984820993838086109503948086039514613c995784831115613c875782910981600003821680920460028082600302188083028203028083028203028083028203028083028203028083028203028092029003029360018380600003040190848311900302920304170290565b60405163227bc15360e01b8152600490fd5b5050906105719250613c07565b600b54811015612d6d57600b6000526000805160206157118339815191520190600090565b600d54811015612d6d57600d6000526000805160206156f18339815191520190600090565b8054821015612d6d5760005260206000200190600090565b600d54600160401b811015610ba8576001810180600d55811015612d6d57600d6000526000805160206156f18339815191520155565b600b54600160401b811015610ba8576001810180600b55811015612d6d57600b6000526000805160206157118339815191520155565b90815491600160401b831015610ba85782613d97916001610c1695018155613cf0565b90919082549060031b91821b91600019901b1916179055565b919091600d9081548015613e5d575b50613dc8614c44565b50929091815492613dd76141a3565b9481613e48575b5015613e2557506000198201828111610a3a5781541115612d6d576000527fd7b6990105719101dabeb77144f2a3385c8033acd3af97e9423a695e81ad1eb4018390559190565b613e39926001600160d01b031691506150f7565b5050613e4483613d08565b9190565b65ffffffffffff838116911614905038613dde565b600160401b811015610ba85760018101808455811015612d6d576000908382526000805160206156f1833981519152015538613dbf565b919091600b9081548015613f3d575b50613eac614cb4565b50929091815492613ebb614121565b9481613f28575b5015613f0957506000198201828111610a3a5781541115612d6d576000527f0175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db8018390559190565b613f1d926001600160d01b031691506151f8565b5050613e4483613d3e565b65ffffffffffff838116911614905038613ec2565b600160401b811015610ba85760018101808455811015612d6d57600090838252600080516020615711833981519152015538613ea3565b90929192600182019081548015614003575b5084613f9184614d03565b50949092845493613fa18361421f565b9681613fee575b5015613fcb575050506000198101908111610a3a57613d978591613e4493613cf0565b613e44949293613fe7926001600160d01b0390911691906152a2565b5050613d74565b65ffffffffffff838116911614905038613fa8565b600160401b811015610ba85780600161401f9201845583613cf0565b8154906000199060031b1b1916905538613f86565b60405163a9059cbb60e01b60208201526001600160a01b03909216602483015260448083019390935291815260808101916001600160401b03831182841017610ba857610c1692604052614d37565b9061408c612c02565b82101561410f57600082815260096020908152604080832033845290915290205460ff166140fd576140be3383612e88565b9182156140eb5760009081526009602090815260408083203384529091529020805460ff19166001179055565b6040516366c0bcbf60e11b8152600490fd5b604051630c8d9eab60e31b8152600490fd5b60405163d5b25b6360e01b8152600490fd5b600a546000908061416957505060005b6001600160d01b0381161561416357600b54811015612d6d57600b600052600080516020615711833981519152015490565b50600090565b80600019810111610a3a57600a7fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a79252015460301c614131565b600c54600090806141e557505060005b6001600160d01b0381161561416357600d54811015612d6d57600d6000526000805160206156f1833981519152015490565b80600019810111610a3a57600c7fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c69252015460301c6141b3565b80546000908061425a57505060005b6001600160d01b038116156142535760016142499201613cf0565b90549060031b1c90565b5050600090565b600019918183810111610a3a578084602092522001015460301c61422e565b906001600160a01b038083161561072957811615610710576106c161429d92611a25565b55565b919060018101809111610a3a5760018201809211610a3a5761057192613c11565b600a54906000829160058411614333575b6142dc93506154b1565b80614300575060005b6001600160d01b038116156141635761424961057191613ca6565b61432761430f61432e926129db565b600a6000526000805160206156918339815191520190565b5460301c90565b6142e5565b919261433e81615377565b8103908111610a3a576142dc93600a60005265ffffffffffff80836000805160206156918339815191520154169085161060001461437d5750916142d2565b92915061438990612a0a565b906142d2565b600c549060008291600584116143fa575b6143aa935061551d565b806143ce575060005b6001600160d01b038116156141635761424961057191613ccb565b6143276143dd6143f5926129db565b600c6000526000805160206156518339815191520190565b6143b3565b919261440581615377565b8103908111610a3a576143aa93600c60005265ffffffffffff8083600080516020615651833981519152015416908516106000146144445750916143a0565b92915061445090612a0a565b906143a0565b9081549060008291600584116144bd575b614472935084615589565b8061449b57506000905b6001600160d01b03821615614253576105719160016142499201613cf0565b6143276144aa6144b7926129db565b8360005260206000200190565b9061447c565b91926144c881615377565b8103908111610a3a57614472938560005265ffffffffffff80836020600020015416908516106000146144fc575091614467565b92915061450890612a0a565b90614467565b6040519061451b82610bad565b60006020838281520152565b61452f61450e565b5061453861450e565b50600a54811015612d6d5761456190600a60005260008051602061569183398151915201614c20565b65ffffffffffff81511690602060018060d01b0391015116600b54811015612d6d57600b6000526000805160206157118339815191520154604051916145a683610bad565b8252602082015290565b6145b861450e565b506145c161450e565b50600c54811015612d6d576145ea90600c60005260008051602061565183398151915201614c20565b65ffffffffffff81511690602060018060d01b0391015116600d54811015612d6d57600d6000526000805160206156f18339815191520154604051916145a683610bad565b906146586146526146799261464261450e565b5061464b61450e565b5084613cf0565b50614c20565b91600165ffffffffffff845116936020828060d01b03910151169101613cf0565b9054906040519261468984610bad565b835260031b1c602082015290565b6040516323b872dd60e01b60208201526001600160a01b03928316602482015292909116604483015260648083019390935291815260a08101918183106001600160401b03841117610ba857610c1692604052614d37565b60ff6000805160206157718339815191525460401c161561470c57565b604051631afcd79f60e31b8152600490fd5b906101608282031261051357610571916139ee565b614746906020808251830101910161471e565b80516001600160a01b039190821615614ae257604080820165ffffffffffff614775825165ffffffffffff1690565b1615614ad15760c083018051909290614796906001600160a01b0316611725565b15614982575b50916148ce6101409261486961484461492c966147eb6147c2875160018060a01b031690565b6000805462010000600160b01b03191660109290921b62010000600160b01b0316919091179055565b6020860151600180546001600160a01b0319166001600160a01b0390921691909117905561332e61481b4261321f565b6001805465ffffffffffff60a01b191660a09290921b65ffffffffffff60a01b16919091179055565b600180546001600160d01b031660d09290921b6001600160d01b031916919091179055565b61488b6148796060850151151590565b60ff8019600054169115151617600055565b6148b461489b6080850151151590565b61ff0060005491151560081b169061ff00191617600055565b6148c160a0840151600455565b516001600160a01b031690565b848116614972575b5060e08101516001600160a01b0316848116614962575b506101008101516001600160a01b0316848116614952575b506101208101516001600160a01b0316848116614942575b5001516001600160a01b031690565b9081166149365750565b61493f90613891565b50565b61494b90613820565b503861491d565b61495b906137af565b5038614905565b61496b906136d5565b50386148ed565b61497b90613620565b50386148d6565b60e0840151614999906001600160a01b0316611725565b15614a6e575b6101208401516149b7906001600160a01b0316611725565b61479c57608084015115614a245760a08401511580614a05575b6149f55750916148ce6101409261486961484461492c965b9496505050925061479c565b5163183c854560e21b8152600490fd5b50610140840151614a1e906001600160a01b0316611725565b156149d1565b60a084015115801590614a4e575b6149f55750916148ce6101409261486961484461492c966149e9565b50610140840151614a67906001600160a01b0316611725565b1515614a32565b606084015115614aa457610100840151614a90906001600160a01b0316611725565b61499f575163183c854560e21b8152600490fd5b610100840151614abc906001600160a01b0316611725565b1561499f575163183c854560e21b8152600490fd5b81516368f5f8f160e11b8152600490fd5b6040516368f7a67560e11b8152600490fd5b9190614afe6146ef565b614b066146ef565b82516001600160401b038111610ba85760008051602061567183398151915290614b3981614b34845461298b565b614de9565b602080601f8311600114614b8257509080614b7092610c169697600092614b77575b50508160011b916000199060031b1c19161790565b9055614ee7565b015190503880614b5b565b90601f19831696614bc26000805160206156718339815191526000527f2ae08a8e29253f69ac5d979a101956ab8f8d9d7ded63fa7a83b16fc47648eab090565b926000905b898210614c0857505090839291600194610c16989910614bef575b505050811b019055614ee7565b015160001960f88460031b161c19169055388080614be2565b80600185968294968601518155019501930190614bc7565b90604051614c2d81610bad565b915465ffffffffffff8116835260301c6020830152565b600c5480614c585750600090600090600090565b80600019810111610a3a577fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c6614c9391600c60005201614c20565b9065ffffffffffff82511691602060018060d01b0391015116906001929190565b600a5480614cc85750600090600090600090565b80600019810111610a3a577fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a7614c9391600a60005201614c20565b805480614d17575050600090600090600090565b600019908082810111610a3a57614c939260005260206000200101614c20565b600080614d609260018060a01b03169360208151910182865af1614d59612de4565b90836155ed565b8051908115159182614d8e575b5050614d765750565b60249060405190635274afe760e01b82526004820152fd5b614da19250602080918301019101612daf565b153880614d6d565b919060018101809111610a3a5760018201809211610a3a57614dcc828285613c11565b928215612bfd5709614ddb5790565b60018101809111610a3a5790565b601f8111614df5575050565b6000906000805160206156718339815191526000527f2ae08a8e29253f69ac5d979a101956ab8f8d9d7ded63fa7a83b16fc47648eab0906020601f850160051c83019410614e5e575b601f0160051c01915b828110614e5357505050565b818155600101614e47565b9092508290614e3e565b601f8111614e74575050565b6000906000805160206156b18339815191526000527f46a2803e59a4de4e7a4c574b1243f25977ac4c77d5a1a4a609b5394cebb4a2aa906020601f850160051c83019410614edd575b601f0160051c01915b828110614ed257505050565b818155600101614ec6565b9092508290614ebd565b9081516001600160401b038111610ba8576000805160206156b183398151915290614f1b81614f16845461298b565b614e68565b602080601f8311600114614f5257508190614f4e939495600092614b775750508160011b916000199060031b1c19161790565b9055565b90601f19831695614f926000805160206156b18339815191526000527f46a2803e59a4de4e7a4c574b1243f25977ac4c77d5a1a4a609b5394cebb4a2aa90565b926000905b888210614fcf57505083600195969710614fb6575b505050811b019055565b015160001960f88460031b161c19169055388080614fac565b80600185968294968601518155019501930190614f97565b600c5490600160401b821015610ba8576001820180600c55821015612d6d57600c600052805160209091015160301b65ffffffffffff191665ffffffffffff919091161760008051602061565183398151915290910155565b600a5490600160401b821015610ba8576001820180600a55821015612d6d57600a600052805160209091015160301b65ffffffffffff191665ffffffffffff919091161760008051602061569183398151915290910155565b8054600160401b811015610ba8576150b691600182018155613cf0565b6150e157815160209092015160301b65ffffffffffff191665ffffffffffff92909216919091179055565b634e487b7160e01b600052600060045260246000fd5b600c549192919081156151ce576151186151136143dd846129db565b614c20565b805165ffffffffffff83811694911684106151bc5785602093613e449561514861333a865165ffffffffffff1690565b03615184575061515d6143dd615176936129db565b9065ffffffffffff82549181199060301b169116179055565b01516001600160d01b031690565b90506151b791506151a4615196610c09565b65ffffffffffff9092168252565b6001600160d01b03871681850152614fe7565b615176565b604051632520601d60e01b8152600490fd5b6151f291506151de615196610c09565b6001600160d01b0384166020820152614fe7565b60009190565b600a5491929190811561527e5761521461511361430f846129db565b805165ffffffffffff83811694911684106151bc5785602093613e449561524461333a865165ffffffffffff1690565b03615259575061515d61430f615176936129db565b90506151b7915061526b615196610c09565b6001600160d01b03871681850152615040565b6151f2915061528e615196610c09565b6001600160d01b0384166020820152615040565b805492939291908215615353576152be6151136144aa856129db565b906152cf825165ffffffffffff1690565b65ffffffffffff848116911681106151bc57613e449460209488926152fd61333a875165ffffffffffff1690565b0361532057506151769261531361515d926129db565b9060005260206000200190565b9150506151b791615340615332610c09565b65ffffffffffff9093168352565b6001600160d01b03881682860152615099565b6151f29250615363615332610c09565b6001600160d01b0385166020830152615099565b8015614163578061544a61544361543961542f61542561541b61541161540760016105719a6000908b60801c806154a5575b508060401c80615498575b508060201c8061548b575b508060101c8061547e575b508060081c80615471575b508060041c80615464575b508060021c80615457575b50821c615450575b811c1b615400818b613c07565b0160011c90565b615400818a613c07565b6154008189613c07565b6154008188613c07565b6154008187613c07565b6154008186613c07565b6154008185613c07565b8092613c07565b90613bf5565b81016153f3565b60029150910190386153eb565b60049150910190386153e0565b60089150910190386153d5565b60109150910190386153ca565b60209150910190386153bf565b60409150910190386153b4565b915050608090386153a9565b905b8281106154bf57505090565b9091808216906001818418811c8301809311610a3a57600a60005265ffffffffffff80846000805160206156918339815191520154169086161060001461550a575050915b906154b3565b909392508101809111610a3a5790615504565b905b82811061552b57505090565b9091808216906001818418811c8301809311610a3a57600c60005265ffffffffffff808460008051602061565183398151915201541690861610600014615576575050915b9061551f565b909392508101809111610a3a5790615570565b91905b8382106155995750505090565b909192808316906001818518811c8301809311610a3a5760008681526020902083015465ffffffffffff90811690851610156155da575050925b919061558c565b909493508101809111610a3a57916155d3565b90615614575080511561560257805190602001fd5b604051630a12f52160e11b8152600490fd5b81511580615647575b615625575090565b604051639996b31560e01b81526001600160a01b039091166004820152602490fd5b50803b1561561d56fedf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c752c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace03c65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a852c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace049016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300d7b6990105719101dabeb77144f2a3385c8033acd3af97e9423a695e81ad1eb50175b7a638427703f0dbe7bb9bbf987a2551717b34e79f33b5b1008d1fa01db902dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268009b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00a264697066735822122098ba609be7226fd1dc08c59c39d15b175e4125a89f30af71d6acd7087771cedb64736f6c63430008190033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000890ca3f95e0f40a79885b7400926544b2214b03f000000000000000000000000bf34bf75bb779c383267736c53a4ae86ac7bb299000000000000000000000000407a039d94948484d356efb765b3c74382a050b4
-----Decoded View---------------
Arg [0] : delegatorFactory (address): 0x890CA3f95E0f40a79885B7400926544B2214B03f
Arg [1] : slasherFactory (address): 0xbf34bf75bb779c383267736c53a4ae86ac7bB299
Arg [2] : vaultFactory (address): 0x407A039D94948484D356eFB765b3c74382A050B4
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 000000000000000000000000890ca3f95e0f40a79885b7400926544b2214b03f
Arg [1] : 000000000000000000000000bf34bf75bb779c383267736c53a4ae86ac7bb299
Arg [2] : 000000000000000000000000407a039d94948484d356efb765b3c74382a050b4
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.