Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
LiquidityPool
Compiler Version
v0.8.24+commit.e11b9ed9
Optimization Enabled:
Yes with 2000 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol";
import "@openzeppelin-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin-upgradeable/contracts/token/ERC721/IERC721ReceiverUpgradeable.sol";
import "@openzeppelin-upgradeable/contracts/proxy/utils/Initializable.sol";
import "@openzeppelin-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin-upgradeable/contracts/access/OwnableUpgradeable.sol";
import "./interfaces/IRegulationsManager.sol";
import "./interfaces/IEtherFiNodesManager.sol";
import "./interfaces/IeETH.sol";
import "./interfaces/IStakingManager.sol";
import "./interfaces/IMembershipManager.sol";
import "./interfaces/ITNFT.sol";
import "./interfaces/IWithdrawRequestNFT.sol";
import "./interfaces/ILiquidityPool.sol";
import "./interfaces/IEtherFiAdmin.sol";
import "./interfaces/IAuctionManager.sol";
import "./interfaces/ILiquifier.sol";
import "./RoleRegistry.sol";
import "./EtherFiRedemptionManager.sol";
contract LiquidityPool is Initializable, OwnableUpgradeable, UUPSUpgradeable, ILiquidityPool {
using SafeERC20 for IERC20;
//--------------------------------------------------------------------------------------
//--------------------------------- STATE-VARIABLES ----------------------------------
//--------------------------------------------------------------------------------------
IStakingManager public stakingManager;
IEtherFiNodesManager public nodesManager;
IRegulationsManager public DEPRECATED_regulationsManager;
IMembershipManager public membershipManager;
ITNFT public tNft;
IeETH public eETH;
bool public DEPRECATED_eEthliquidStakingOpened;
uint128 public totalValueOutOfLp;
uint128 public totalValueInLp;
address public feeRecipient;
uint32 public numPendingDeposits; // number of validator deposits, which needs 'registerValidator'
address public DEPRECATED_bNftTreasury;
IWithdrawRequestNFT public withdrawRequestNFT;
BnftHolder[] public DEPRECATED_bnftHolders;
uint128 public DEPRECATED_maxValidatorsPerOwner;
uint128 public DEPRECATED_schedulingPeriodInSeconds;
HoldersUpdate public DEPRECATED_holdersUpdate;
mapping(address => bool) public DEPRECATED_admins;
mapping(SourceOfFunds => FundStatistics) public DEPRECATED_fundStatistics;
mapping(uint256 => bytes32) public depositDataRootForApprovalDeposits;
address public etherFiAdminContract;
bool public DEPRECATED_whitelistEnabled;
mapping(address => bool) public DEPRECATED_whitelisted;
mapping(address => ValidatorSpawner) public validatorSpawner;
bool public restakeBnftDeposits;
uint128 public ethAmountLockedForWithdrawal;
bool public paused;
IAuctionManager public auctionManager;
ILiquifier public liquifier;
bool private DEPRECATED_isLpBnftHolder;
EtherFiRedemptionManager public etherFiRedemptionManager;
RoleRegistry public roleRegistry;
//--------------------------------------------------------------------------------------
//------------------------------------- ROLES ---------------------------------------
//--------------------------------------------------------------------------------------
bytes32 public constant LIQUIDITY_POOL_ADMIN_ROLE = keccak256("LIQUIDITY_POOL_ADMIN_ROLE");
//--------------------------------------------------------------------------------------
//------------------------------------- EVENTS ---------------------------------------
//--------------------------------------------------------------------------------------
event Paused(address account);
event Unpaused(address account);
event Deposit(address indexed sender, uint256 amount, SourceOfFunds source, address referral);
event Withdraw(address indexed sender, address recipient, uint256 amount, SourceOfFunds source);
event UpdatedWhitelist(address userAddress, bool value);
event UpdatedTreasury(address newTreasury);
event UpdatedFeeRecipient(address newFeeRecipient);
event BnftHolderDeregistered(address user, uint256 index);
event BnftHolderRegistered(address user, uint256 index);
event ValidatorSpawnerRegistered(address user);
event ValidatorSpawnerUnregistered(address user);
event ValidatorRegistered(uint256 indexed validatorId, bytes signature, bytes pubKey, bytes32 depositRoot);
event ValidatorApproved(uint256 indexed validatorId);
event ValidatorRegistrationCanceled(uint256 indexed validatorId);
event Rebase(uint256 totalEthLocked, uint256 totalEEthShares);
event ProtocolFeePaid(uint128 protocolFees);
event WhitelistStatusUpdated(bool value);
error IncorrectCaller();
error InvalidAmount();
error DataNotSet();
error InsufficientLiquidity();
error SendFail();
error IncorrectRole();
//--------------------------------------------------------------------------------------
//---------------------------- STATE-CHANGING FUNCTIONS ------------------------------
//--------------------------------------------------------------------------------------
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}
receive() external payable {
if (msg.value > type(uint128).max) revert InvalidAmount();
totalValueOutOfLp -= uint128(msg.value);
totalValueInLp += uint128(msg.value);
}
function initialize(address _eEthAddress, address _stakingManagerAddress, address _nodesManagerAddress, address _membershipManagerAddress, address _tNftAddress, address _etherFiAdminContract, address _withdrawRequestNFT) external initializer {
if (_eEthAddress == address(0) || _stakingManagerAddress == address(0) || _nodesManagerAddress == address(0) || _membershipManagerAddress == address(0) || _tNftAddress == address(0)) revert DataNotSet();
__Ownable_init();
__UUPSUpgradeable_init();
eETH = IeETH(_eEthAddress);
stakingManager = IStakingManager(_stakingManagerAddress);
nodesManager = IEtherFiNodesManager(_nodesManagerAddress);
membershipManager = IMembershipManager(_membershipManagerAddress);
tNft = ITNFT(_tNftAddress);
paused = true;
restakeBnftDeposits = false;
ethAmountLockedForWithdrawal = 0;
etherFiAdminContract = _etherFiAdminContract;
withdrawRequestNFT = IWithdrawRequestNFT(_withdrawRequestNFT);
DEPRECATED_isLpBnftHolder = false;
}
function initializeOnUpgrade(address _auctionManager, address _liquifier) external onlyOwner {
require(_auctionManager != address(0) && _liquifier != address(0) && address(auctionManager) == address(0) && address(liquifier) == address(0), "Invalid");
auctionManager = IAuctionManager(_auctionManager);
liquifier = ILiquifier(_liquifier);
}
// Note: Call this function when no validators to approve
function initializeVTwoDotFourNine(address _roleRegistry, address _etherFiRedemptionManager) external onlyOwner {
require(address(etherFiRedemptionManager) == address(0) && _etherFiRedemptionManager != address(0), "Invalid");
require(address(roleRegistry) == address(0x00), "already initialized");
etherFiRedemptionManager = EtherFiRedemptionManager(payable(_etherFiRedemptionManager));
roleRegistry = RoleRegistry(_roleRegistry);
//correct splits
uint128 tvl = uint128(getTotalPooledEther());
totalValueInLp = uint128(address(this).balance);
totalValueOutOfLp = tvl - totalValueInLp;
if(tvl != getTotalPooledEther()) revert();
}
// Used by eETH staking flow
function deposit() external payable returns (uint256) {
return deposit(address(0));
}
// Used by eETH staking flow
function deposit(address _referral) public payable whenNotPaused returns (uint256) {
emit Deposit(msg.sender, msg.value, SourceOfFunds.EETH, _referral);
return _deposit(msg.sender, msg.value, 0);
}
// Used by eETH staking flow through Liquifier contract; deVamp or to pay protocol fees
function depositToRecipient(address _recipient, uint256 _amount, address _referral) public whenNotPaused returns (uint256) {
require(msg.sender == address(liquifier) || msg.sender == address(etherFiAdminContract), "Incorrect Caller");
emit Deposit(_recipient, _amount, SourceOfFunds.EETH, _referral);
return _deposit(_recipient, 0, _amount);
}
// Used by ether.fan staking flow
function deposit(address _user, address _referral) external payable whenNotPaused returns (uint256) {
require(msg.sender == address(membershipManager), "Incorrect Caller");
emit Deposit(msg.sender, msg.value, SourceOfFunds.ETHER_FAN, _referral);
return _deposit(msg.sender, msg.value, 0);
}
/// @notice withdraw from pool
/// @dev Burns user share from msg.senders account & Sends equivalent amount of ETH back to the recipient
/// @param _recipient the recipient who will receives the ETH
/// @param _amount the amount to withdraw from contract
/// it returns the amount of shares burned
function withdraw(address _recipient, uint256 _amount) external whenNotPaused returns (uint256) {
uint256 share = sharesForWithdrawalAmount(_amount);
require(msg.sender == address(withdrawRequestNFT) || msg.sender == address(membershipManager) || msg.sender == address(etherFiRedemptionManager), "Incorrect Caller");
if (totalValueInLp < _amount || (msg.sender == address(withdrawRequestNFT) && ethAmountLockedForWithdrawal < _amount) || eETH.balanceOf(msg.sender) < _amount) revert InsufficientLiquidity();
if (_amount > type(uint128).max || _amount == 0 || share == 0) revert InvalidAmount();
totalValueInLp -= uint128(_amount);
if (msg.sender == address(withdrawRequestNFT)) {
ethAmountLockedForWithdrawal -= uint128(_amount);
}
eETH.burnShares(msg.sender, share);
_sendFund(_recipient, _amount);
return share;
}
/// @notice request withdraw from pool and receive a WithdrawRequestNFT
/// @dev Transfers the amount of eETH from msg.senders account to the WithdrawRequestNFT contract & mints an NFT to the msg.sender
/// @param recipient address that will be issued the NFT
/// @param amount requested amount to withdraw from contract
/// @return uint256 requestId of the WithdrawRequestNFT
function requestWithdraw(address recipient, uint256 amount) public whenNotPaused returns (uint256) {
uint256 share = sharesForAmount(amount);
if (amount > type(uint96).max || amount == 0 || share == 0) revert InvalidAmount();
// transfer shares to WithdrawRequestNFT contract from this contract
IERC20(address(eETH)).safeTransferFrom(msg.sender, address(withdrawRequestNFT), amount);
uint256 requestId = withdrawRequestNFT.requestWithdraw(uint96(amount), uint96(share), recipient, 0);
emit Withdraw(msg.sender, recipient, amount, SourceOfFunds.EETH);
return requestId;
}
/// @notice request withdraw from pool with signed permit data and receive a WithdrawRequestNFT
/// @dev accepts PermitInput signed data to approve transfer of eETH (EIP-2612) so withdraw request can happen in 1 tx
/// @param _owner address that will be issued the NFT
/// @param _amount requested amount to withdraw from contract
/// @param _permit signed permit data to approve transfer of eETH
/// @return uint256 requestId of the WithdrawRequestNFT
function requestWithdrawWithPermit(address _owner, uint256 _amount, PermitInput calldata _permit)
external
whenNotPaused
returns (uint256)
{
try eETH.permit(msg.sender, address(this), _permit.value, _permit.deadline, _permit.v, _permit.r, _permit.s) {} catch {}
return requestWithdraw(_owner, _amount);
}
/// @notice request withdraw of some or all of the eETH backing a MembershipNFT and receive a WithdrawRequestNFT
/// @dev Transfers the amount of eETH from MembershipManager to the WithdrawRequestNFT contract & mints an NFT to the recipient
/// @param recipient address that will be issued the NFT
/// @param amount requested amount to withdraw from contract
/// @param fee the burn fee to be paid by the recipient when the withdrawal is claimed (WithdrawRequestNFT.claimWithdraw)
/// @return uint256 requestId of the WithdrawRequestNFT
function requestMembershipNFTWithdraw(address recipient, uint256 amount, uint256 fee) public whenNotPaused returns (uint256) {
if (msg.sender != address(membershipManager)) revert IncorrectCaller();
uint256 share = sharesForAmount(amount);
if (amount > type(uint96).max || amount == 0 || share == 0) revert InvalidAmount();
// transfer shares to WithdrawRequestNFT contract
IERC20(address(eETH)).safeTransferFrom(msg.sender, address(withdrawRequestNFT), amount);
uint256 requestId = withdrawRequestNFT.requestWithdraw(uint96(amount), uint96(share), recipient, fee);
emit Withdraw(msg.sender, recipient, amount, SourceOfFunds.ETHER_FAN);
return requestId;
}
// [Liquidty Pool Staking flow]
// Step 1: [Deposit] initiate spinning up the validators & allocate withdrawal safe contracts
// Step 2: (Off-chain) create the keys using the desktop app
// Step 3: [Register] register the validator keys sending 1 ETH to the eth deposit contract
// Step 4: wait for the oracle to approve and send the rest 31 ETH to the eth deposit contract
/// Step 1. [Deposit]
/// @param _candidateBidIds validator IDs that have been matched with the BNFT holder on the FE
/// @param _numberOfValidators how many validators the user wants to spin up. This can be less than the candidateBidIds length.
function batchDeposit(uint256[] calldata _candidateBidIds, uint256 _numberOfValidators) external whenNotPaused returns (uint256[] memory) {
return batchDeposit(_candidateBidIds, _numberOfValidators, 0);
}
/// @param _candidateBidIds the bid IDs of the node operators that the spawner wants to spin up validators for
/// @param _numberOfValidators how many validators the user wants to spin up; `len(_candidateBidIds)` must be >= `_numberOfValidators`
/// @param _validatorIdToShareSafeWith the validator ID of the validator that the spawner wants to shafe the withdrawal safe with
/// @return Array of bid IDs that were successfully processed.
function batchDeposit(uint256[] calldata _candidateBidIds, uint256 _numberOfValidators, uint256 _validatorIdToShareSafeWith) public whenNotPaused returns (uint256[] memory) {
address tnftHolder = address(this);
address bnftHolder = address(this);
require(validatorSpawner[msg.sender].registered, "Incorrect Caller");
require(totalValueInLp >= 32 ether * _numberOfValidators, "Not enough balance");
uint256[] memory newValidators = stakingManager.batchDepositWithBidIds(_candidateBidIds, _numberOfValidators, msg.sender, tnftHolder, bnftHolder, SourceOfFunds.EETH, restakeBnftDeposits, _validatorIdToShareSafeWith);
numPendingDeposits += uint32(newValidators.length);
return newValidators;
}
/// Step 3. [Register]
/// @notice register validators' keys and trigger a 1 ETH transaction to the beacon chain.
/// @param _validatorIds the ids of the validators to register
/// @param _registerValidatorDepositData the signature and deposit data root for a 1 ETH deposit
/// @param _depositDataRootApproval the root hash of the deposit data for the 31 ETH deposit which will happen in the approval step
/// @param _signaturesForApprovalDeposit the signature for the 31 ETH deposit which will happen in the approval step.
function batchRegister(
bytes32 _depositRoot,
uint256[] calldata _validatorIds,
IStakingManager.DepositData[] calldata _registerValidatorDepositData,
bytes32[] calldata _depositDataRootApproval,
bytes[] calldata _signaturesForApprovalDeposit
) external whenNotPaused {
address _bnftRecipient = address(this);
require(validatorSpawner[msg.sender].registered, "Incorrect Caller");
require(_validatorIds.length == _registerValidatorDepositData.length && _validatorIds.length == _depositDataRootApproval.length && _validatorIds.length == _signaturesForApprovalDeposit.length, "lengths differ");
numPendingDeposits -= uint32(_validatorIds.length);
// As the LP is the B-nft holder, the 1 ether (for each validator) is taken from the LP
uint256 outboundEthAmountFromLp = 1 ether * _validatorIds.length;
_accountForEthSentOut(outboundEthAmountFromLp);
stakingManager.batchRegisterValidators{value: outboundEthAmountFromLp}(_depositRoot, _validatorIds, _bnftRecipient, address(this), _registerValidatorDepositData, msg.sender);
for(uint256 i; i < _validatorIds.length; i++) {
depositDataRootForApprovalDeposits[_validatorIds[i]] = _depositDataRootApproval[i];
emit ValidatorRegistered(_validatorIds[i], _signaturesForApprovalDeposit[i], _registerValidatorDepositData[i].publicKey, _depositDataRootApproval[i]);
}
}
//. Step 4. [Approve]
/// @notice Approves validators and triggers the 31 ETH deposit to the beacon chain
/// @dev This gets called by the Oracle only when it has confirmed the withdraw credentials of the 1 ETH deposit in the registration
/// phase match the withdraw credentials stored on the beacon chain. This prevents a front-running attack.
/// @param _validatorIds the IDs of the validators to be approved
/// @param _pubKey the pubKey for each validator being spun up.
/// @param _signature the signatures for each validator for the 31 ETH deposit that were emitted in the register phase
function batchApproveRegistration(
uint256[] memory _validatorIds,
bytes[] calldata _pubKey,
bytes[] calldata _signature
) external whenNotPaused {
if (!roleRegistry.hasRole(LIQUIDITY_POOL_ADMIN_ROLE, msg.sender)) revert IncorrectRole();
require(_validatorIds.length == _pubKey.length && _validatorIds.length == _signature.length, "lengths differ");
bytes32[] memory depositDataRootApproval = new bytes32[](_validatorIds.length);
for(uint256 i; i < _validatorIds.length; i++) {
depositDataRootApproval[i] = depositDataRootForApprovalDeposits[_validatorIds[i]];
delete depositDataRootForApprovalDeposits[_validatorIds[i]];
emit ValidatorApproved(_validatorIds[i]);
}
// As the LP is the T-NFT holder, the 31 ETH is taken from the LP for each validator
uint256 outboundEthAmountFromLp = 31 ether * _validatorIds.length;
_accountForEthSentOut(outboundEthAmountFromLp);
stakingManager.batchApproveRegistration{value: outboundEthAmountFromLp}(_validatorIds, _pubKey, _signature, depositDataRootApproval);
}
/// @notice Cancels the process
/// @param _validatorIds the IDs to be cancelled
/// Note that if the spawner cancels the flow after the registration (where the 1 ETH deposit is made), the 1 ETH refund must be made manually
/// Until then the 1 ETH is considered as a loss
/// Be careful not to cancel the registration after the approval phase
function batchCancelDeposit(uint256[] calldata _validatorIds) external whenNotPaused {
address bnftHolder = address(this);
for (uint256 i = 0; i < _validatorIds.length; i++) {
if(nodesManager.phase(_validatorIds[i]) == IEtherFiNode.VALIDATOR_PHASE.WAITING_FOR_APPROVAL) {
totalValueOutOfLp -= 1 ether;
emit ValidatorRegistrationCanceled(_validatorIds[i]);
}
else numPendingDeposits -= 1;
}
stakingManager.batchCancelDepositAsBnftHolder(_validatorIds, msg.sender);
}
/// @notice The admin can register an address to become a BNFT holder
/// @param _user The address of the Validator Spawner to register
function registerValidatorSpawner(address _user) public {
if (!roleRegistry.hasRole(LIQUIDITY_POOL_ADMIN_ROLE, msg.sender)) revert IncorrectRole();
require(!validatorSpawner[_user].registered, "Already registered");
validatorSpawner[_user] = ValidatorSpawner({registered: true});
emit ValidatorSpawnerRegistered(_user);
}
/// @notice Removes a Validator Spawner
/// @param _user the address of the Validator Spawner to remove
function unregisterValidatorSpawner(address _user) external {
require(validatorSpawner[_user].registered, "Not registered");
require(roleRegistry.hasRole(LIQUIDITY_POOL_ADMIN_ROLE, msg.sender), "Incorrect Caller");
delete validatorSpawner[_user];
emit ValidatorSpawnerUnregistered(_user);
}
/// @notice Send the exit requests as the T-NFT holder of the LiquidityPool validators
function sendExitRequests(uint256[] calldata _validatorIds) external {
if (!roleRegistry.hasRole(LIQUIDITY_POOL_ADMIN_ROLE, msg.sender)) revert IncorrectRole();
nodesManager.batchSendExitRequest(_validatorIds);
}
/// @notice Rebase by ether.fi
function rebase(int128 _accruedRewards) public {
if (msg.sender != address(membershipManager)) revert IncorrectCaller();
totalValueOutOfLp = uint128(int128(totalValueOutOfLp) + _accruedRewards);
emit Rebase(getTotalPooledEther(), eETH.totalShares());
}
/// @notice pay protocol fees including 5% to treaury, 5% to node operator and ethfund bnft holders
/// @param _protocolFees The amount of protocol fees to pay in ether
function payProtocolFees(uint128 _protocolFees) external {
if (msg.sender != address(etherFiAdminContract)) revert IncorrectCaller();
emit ProtocolFeePaid(_protocolFees);
depositToRecipient(feeRecipient, _protocolFees, address(0));
}
/// @notice Set the fee recipient address
/// @param _feeRecipient The address to set as the fee recipient
function setFeeRecipient(address _feeRecipient) external {
if (!roleRegistry.hasRole(LIQUIDITY_POOL_ADMIN_ROLE, msg.sender)) revert IncorrectRole();
feeRecipient = _feeRecipient;
emit UpdatedFeeRecipient(_feeRecipient);
}
/// @notice Whether or not nodes created via bNFT deposits should be restaked
function setRestakeBnftDeposits(bool _restake) external {
if (!roleRegistry.hasRole(LIQUIDITY_POOL_ADMIN_ROLE, msg.sender)) revert IncorrectRole();
restakeBnftDeposits = _restake;
}
// Pauses the contract
function pauseContract() external {
if (!roleRegistry.hasRole(roleRegistry.PROTOCOL_PAUSER(), msg.sender)) revert IncorrectRole();
if (paused) revert("Pausable: already paused");
paused = true;
emit Paused(msg.sender);
}
// Unpauses the contract
function unPauseContract() external {
if (!roleRegistry.hasRole(roleRegistry.PROTOCOL_UNPAUSER(), msg.sender)) revert IncorrectRole();
if (!paused) revert("Pausable: not paused");
paused = false;
emit Unpaused(msg.sender);
}
// Deprecated, just existing not to touch EtherFiAdmin contract
function setStakingTargetWeights(uint32 _eEthWeight, uint32 _etherFanWeight) external {
}
function addEthAmountLockedForWithdrawal(uint128 _amount) external {
if (!(msg.sender == address(etherFiAdminContract))) revert IncorrectCaller();
ethAmountLockedForWithdrawal += _amount;
}
function burnEEthShares(uint256 shares) external {
if (msg.sender != address(etherFiRedemptionManager) && msg.sender != address(withdrawRequestNFT)) revert IncorrectCaller();
eETH.burnShares(msg.sender, shares);
}
//--------------------------------------------------------------------------------------
//------------------------------ INTERNAL FUNCTIONS ----------------------------------
//--------------------------------------------------------------------------------------
function _deposit(address _recipient, uint256 _amountInLp, uint256 _amountOutOfLp) internal returns (uint256) {
totalValueInLp += uint128(_amountInLp);
totalValueOutOfLp += uint128(_amountOutOfLp);
uint256 amount = _amountInLp + _amountOutOfLp;
uint256 share = _sharesForDepositAmount(amount);
if (amount > type(uint128).max || amount == 0 || share == 0) revert InvalidAmount();
eETH.mintShares(_recipient, share);
return share;
}
function _sharesForDepositAmount(uint256 _depositAmount) internal view returns (uint256) {
uint256 totalPooledEther = getTotalPooledEther() - _depositAmount;
if (totalPooledEther == 0) {
return _depositAmount;
}
return (_depositAmount * eETH.totalShares()) / totalPooledEther;
}
function _sendFund(address _recipient, uint256 _amount) internal {
uint256 balance = address(this).balance;
(bool sent, ) = _recipient.call{value: _amount}("");
require(sent && address(this).balance >= balance - _amount, "SendFail");
}
function _accountForEthSentOut(uint256 _amount) internal {
totalValueOutOfLp += uint128(_amount);
totalValueInLp -= uint128(_amount);
}
function _authorizeUpgrade(address newImplementation) internal override {
roleRegistry.onlyProtocolUpgrader(msg.sender);
}
//--------------------------------------------------------------------------------------
//------------------------------------ GETTERS ---------------------------------------
//--------------------------------------------------------------------------------------
function getTotalEtherClaimOf(address _user) external view returns (uint256) {
uint256 staked;
uint256 totalShares = eETH.totalShares();
if (totalShares > 0) {
staked = (getTotalPooledEther() * eETH.shares(_user)) / totalShares;
}
return staked;
}
function getTotalPooledEther() public view returns (uint256) {
return totalValueOutOfLp + totalValueInLp;
}
function sharesForAmount(uint256 _amount) public view returns (uint256) {
uint256 totalPooledEther = getTotalPooledEther();
if (totalPooledEther == 0) {
return 0;
}
return (_amount * eETH.totalShares()) / totalPooledEther;
}
/// @dev withdrawal rounding errors favor the protocol by rounding up
function sharesForWithdrawalAmount(uint256 _amount) public view returns (uint256) {
uint256 totalPooledEther = getTotalPooledEther();
if (totalPooledEther == 0) {
return 0;
}
// ceiling division so rounding errors favor the protocol
uint256 numerator = _amount * eETH.totalShares();
return (numerator + totalPooledEther - 1) / totalPooledEther;
}
function amountForShare(uint256 _share) public view returns (uint256) {
uint256 totalShares = eETH.totalShares();
if (totalShares == 0) {
return 0;
}
return (_share * getTotalPooledEther()) / totalShares;
}
function getImplementation() external view returns (address) {return _getImplementation();}
function _requireNotPaused() internal view virtual {
require(!paused, "Pausable: paused");
}
//--------------------------------------------------------------------------------------
//----------------------------------- MODIFIERS --------------------------------------
//--------------------------------------------------------------------------------------
modifier whenNotPaused() {
_requireNotPaused();
_;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @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.
*/
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].
*/
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 v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20Upgradeable {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721ReceiverUpgradeable {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/AddressUpgradeable.sol";
/**
* @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]
* ```
* 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 Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 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 functions marked with `initializer` can be nested in the context of a
* constructor.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_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 255 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_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() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @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 {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized < type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint8) {
return _initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _initializing;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.0;
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import "./Initializable.sol";
/**
* @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
* {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
*
* A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
* reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
* `UUPSUpgradeable` with a custom implementation of upgrades.
*
* The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
*
* _Available since v4.1._
*/
abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {
function __UUPSUpgradeable_init() internal onlyInitializing {
}
function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
}
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
address private immutable __self = address(this);
/**
* @dev Check that the execution is being performed through a delegatecall call and that the execution context is
* a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
* for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
* function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
* fail.
*/
modifier onlyProxy() {
require(address(this) != __self, "Function must be called through delegatecall");
require(_getImplementation() == __self, "Function must be called through active proxy");
_;
}
/**
* @dev Check that the execution is not being performed through a delegate call. This allows a function to be
* callable on the implementing contract but not through proxies.
*/
modifier notDelegated() {
require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall");
_;
}
/**
* @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
* implementation. It is used to validate the implementation's compatibility when performing an upgrade.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
*/
function proxiableUUID() external view virtual override notDelegated returns (bytes32) {
return _IMPLEMENTATION_SLOT;
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*/
function upgradeTo(address newImplementation) external virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*/
function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, data, true);
}
/**
* @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeTo} and {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal override onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../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.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
function __Ownable_init() internal onlyInitializing {
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal onlyInitializing {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
interface IRegulationsManager {
function initialize() external;
function confirmEligibility(bytes32 hash) external;
function removeFromWhitelist(address _user) external;
function initializeNewWhitelist(bytes32 _newVersionHash) external;
function isEligible(uint32 _whitelistVersion, address _user) external view returns (bool);
function whitelistVersion() external view returns (uint32);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import "./IEtherFiNode.sol";
import "../eigenlayer-interfaces/IEigenPodManager.sol";
import "../eigenlayer-interfaces/IDelegationManager.sol";
import "../eigenlayer-interfaces/IDelayedWithdrawalRouter.sol";
interface IEtherFiNodesManager {
struct ValidatorInfo {
uint32 validatorIndex;
uint32 exitRequestTimestamp;
uint32 exitTimestamp;
IEtherFiNode.VALIDATOR_PHASE phase;
}
struct RewardsSplit {
uint64 treasury;
uint64 nodeOperator;
uint64 tnft;
uint64 bnft;
}
// VIEW functions
function delayedWithdrawalRouter() external view returns (IDelayedWithdrawalRouter);
function eigenPodManager() external view returns (IEigenPodManager);
function delegationManager() external view returns (IDelegationManager);
function treasuryContract() external view returns (address);
function unusedWithdrawalSafes(uint256 _index) external view returns (address);
function etherfiNodeAddress(uint256 _validatorId) external view returns (address);
function calculateTVL(uint256 _validatorId, uint256 _beaconBalance) external view returns (uint256, uint256, uint256, uint256);
function getFullWithdrawalPayouts(uint256 _validatorId) external view returns (uint256, uint256, uint256, uint256);
function getNonExitPenalty(uint256 _validatorId) external view returns (uint256);
function getRewardsPayouts(uint256 _validatorId) external view returns (uint256, uint256, uint256, uint256);
function getWithdrawalCredentials(uint256 _validatorId) external view returns (bytes memory);
function getValidatorInfo(uint256 _validatorId) external view returns (ValidatorInfo memory);
function numAssociatedValidators(uint256 _validatorId) external view returns (uint256);
function phase(uint256 _validatorId) external view returns (IEtherFiNode.VALIDATOR_PHASE phase);
function generateWithdrawalCredentials(address _address) external view returns (bytes memory);
function nonExitPenaltyDailyRate() external view returns (uint64);
function nonExitPenaltyPrincipal() external view returns (uint64);
function numberOfValidators() external view returns (uint64);
function maxEigenlayerWithdrawals() external view returns (uint8);
function admins(address _address) external view returns (bool);
function operatingAdmin(address _address) external view returns (bool);
// Non-VIEW functions
function updateEtherFiNode(uint256 _validatorId) external;
function batchQueueRestakedWithdrawal(uint256[] calldata _validatorIds) external;
function batchSendExitRequest(uint256[] calldata _validatorIds) external;
function batchFullWithdraw(uint256[] calldata _validatorIds) external;
function batchPartialWithdraw(uint256[] calldata _validatorIds) external;
function fullWithdraw(uint256 _validatorId) external;
function getUnusedWithdrawalSafesLength() external view returns (uint256);
function incrementNumberOfValidators(uint64 _count) external;
function markBeingSlashed(uint256[] calldata _validatorIds) external;
function partialWithdraw(uint256 _validatorId) external;
function processNodeExit(uint256[] calldata _validatorIds, uint32[] calldata _exitTimestamp) external;
function allocateEtherFiNode(bool _enableRestaking) external returns (address);
function registerValidator(uint256 _validatorId, bool _enableRestaking, address _withdrawalSafeAddress) external;
function setValidatorPhase(uint256 _validatorId, IEtherFiNode.VALIDATOR_PHASE _phase) external;
function setNonExitPenalty(uint64 _nonExitPenaltyDailyRate, uint64 _nonExitPenaltyPrincipal) external;
function setStakingRewardsSplit(uint64 _treasury, uint64 _nodeOperator, uint64 _tnft, uint64 _bnf) external;
function unregisterValidator(uint256 _validatorId) external;
function updateAdmin(address _address, bool _isAdmin) external;
function pauseContract() external;
function unPauseContract() external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
interface IeETH {
struct PermitInput {
uint256 value;
uint256 deadline;
uint8 v;
bytes32 r;
bytes32 s;
}
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalShares() external view returns (uint256);
function shares(address _user) external view returns (uint256);
function balanceOf(address _user) external view returns (uint256);
function initialize(address _liquidityPool) external;
function mintShares(address _user, uint256 _share) external;
function burnShares(address _user, uint256 _share) external;
function transferFrom(address _sender, address _recipient, uint256 _amount) external returns (bool);
function transfer(address _recipient, uint256 _amount) external returns (bool);
function approve(address _spender, uint256 _amount) external returns (bool);
function increaseAllowance(address _spender, uint256 _increaseAmount) external returns (bool);
function decreaseAllowance(address _spender, uint256 _decreaseAmount) external returns (bool);
function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import "./ILiquidityPool.sol";
interface IStakingManager {
struct DepositData {
bytes publicKey;
bytes signature;
bytes32 depositDataRoot;
string ipfsHashForEncryptedValidatorKey;
}
struct StakerInfo {
address staker;
ILiquidityPool.SourceOfFunds sourceOfFund;
}
function bidIdToStaker(uint256 id) external view returns (address);
function getEtherFiNodeBeacon() external view returns (address);
function initialize(address _auctionAddress, address _depositContractAddress) external;
function setEtherFiNodesManagerAddress(address _managerAddress) external;
function setLiquidityPoolAddress(address _liquidityPoolAddress) external;
function batchDepositWithBidIds(uint256[] calldata _candidateBidIds, uint256 _numberOfValidators, address _staker, address _tnftHolder, address _bnftHolder, ILiquidityPool.SourceOfFunds source, bool _enableRestaking, uint256 _validatorIdToCoUseWithdrawalSafe) external returns (uint256[] memory);
function batchDepositWithBidIds(uint256[] calldata _candidateBidIds, bool _enableRestaking) external payable returns (uint256[] memory);
function batchRegisterValidators(bytes32 _depositRoot, uint256[] calldata _validatorId, DepositData[] calldata _depositData) external;
function batchRegisterValidators(bytes32 _depositRoot, uint256[] calldata _validatorId, address _bNftRecipient, address _tNftRecipient, DepositData[] calldata _depositData, address _user) external payable;
function batchApproveRegistration(uint256[] memory _validatorId, bytes[] calldata _pubKey, bytes[] calldata _signature, bytes32[] calldata _depositDataRootApproval) external payable;
function batchCancelDeposit(uint256[] calldata _validatorIds) external;
function batchCancelDepositAsBnftHolder(uint256[] calldata _validatorIds, address _caller) external;
function instantiateEtherFiNode(bool _createEigenPod) external returns (address);
function updateAdmin(address _address, bool _isAdmin) external;
function pauseContract() external;
function unPauseContract() external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
interface IMembershipManager {
struct TokenDeposit {
uint128 amounts;
uint128 shares;
}
struct TokenData {
uint96 vaultShare;
uint40 baseLoyaltyPoints;
uint40 baseTierPoints;
uint32 prevPointsAccrualTimestamp;
uint32 prevTopUpTimestamp;
uint8 tier;
uint8 version;
}
// Used for V1
struct TierVault {
uint128 totalPooledEEthShares; // total share of eEth in the tier vault
uint128 totalVaultShares; // total share of the tier vault
}
// Used for V0
struct TierDeposit {
uint128 amounts; // total pooled eth amount
uint128 shares; // total pooled eEth shares
}
struct TierData {
uint96 rewardsGlobalIndex;
uint40 requiredTierPoints;
uint24 weight;
uint96 __gap;
}
// State-changing functions
function wrapEthForEap(uint256 _amount, uint256 _amountForPoint, uint32 _eapDepositBlockNumber, uint256 _snapshotEthAmount, uint256 _points, bytes32[] calldata _merkleProof) external payable returns (uint256);
function wrapEth(uint256 _amount, uint256 _amountForPoint) external payable returns (uint256);
function wrapEth(uint256 _amount, uint256 _amountForPoint, address _referral) external payable returns (uint256);
function topUpDepositWithEth(uint256 _tokenId, uint128 _amount, uint128 _amountForPoints) external payable;
function requestWithdraw(uint256 _tokenId, uint256 _amount) external returns (uint256);
function requestWithdrawAndBurn(uint256 _tokenId) external returns (uint256);
function claim(uint256 _tokenId) external;
function migrateFromV0ToV1(uint256 _tokenId) external;
// Getter functions
function tokenDeposits(uint256) external view returns (uint128, uint128);
function tokenData(uint256) external view returns (uint96, uint40, uint40, uint32, uint32, uint8, uint8);
function tierDeposits(uint256) external view returns (uint128, uint128);
function tierData(uint256) external view returns (uint96, uint40, uint24, uint96);
function rewardsGlobalIndex(uint8 _tier) external view returns (uint256);
function allTimeHighDepositAmount(uint256 _tokenId) external view returns (uint256);
function tierForPoints(uint40 _tierPoints) external view returns (uint8);
function canTopUp(uint256 _tokenId, uint256 _totalAmount, uint128 _amount, uint128 _amountForPoints) external view returns (bool);
function pointsBoostFactor() external view returns (uint16);
function pointsGrowthRate() external view returns (uint16);
function maxDepositTopUpPercent() external view returns (uint8);
function numberOfTiers() external view returns (uint8);
function getImplementation() external view returns (address);
function minimumAmountForMint() external view returns (uint256);
function eEthShareForVaultShare(uint8 _tier, uint256 _vaultShare) external view returns (uint256);
function vaultShareForEEthShare(uint8 _tier, uint256 _eEthShare) external view returns (uint256);
function ethAmountForVaultShare(uint8 _tier, uint256 _vaultShare) external view returns (uint256);
function vaultShareForEthAmount(uint8 _tier, uint256 _ethAmount) external view returns (uint256);
// only Owner
function initializeOnUpgrade(address _etherFiAdminAddress, uint256 _fanBoostThresholdAmount, uint16 _burnFeeWaiverPeriodInDays) external;
function setWithdrawalLockBlocks(uint32 _blocks) external;
function updatePointsParams(uint16 _newPointsBoostFactor, uint16 _newPointsGrowthRate) external;
function rebase(int128 _accruedRewards) external;
function addNewTier(uint40 _requiredTierPoints, uint24 _weight) external;
function updateTier(uint8 _tier, uint40 _requiredTierPoints, uint24 _weight) external;
function setPoints(uint256 _tokenId, uint40 _loyaltyPoints, uint40 _tierPoints) external;
function setDepositAmountParams(uint56 _minDepositGwei, uint8 _maxDepositTopUpPercent) external;
function setTopUpCooltimePeriod(uint32 _newWaitTime) external;
function updateAdmin(address _address, bool _isAdmin) external;
function pauseContract() external;
function unPauseContract() external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import "@openzeppelin-upgradeable/contracts/token/ERC721/IERC721Upgradeable.sol";
interface ITNFT is IERC721Upgradeable {
function burnFromWithdrawal(uint256 _validatorId) external;
function initialize() external;
function initializeOnUpgrade(address _etherFiNodesManagerAddress) external;
function mint(address _receiver, uint256 _validatorId) external;
function burnFromCancelBNftFlow(uint256 _validatorId) external;
function upgradeTo(address _newImplementation) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
interface IWithdrawRequestNFT {
struct WithdrawRequest {
uint96 amountOfEEth;
uint96 shareOfEEth;
bool isValid;
uint32 feeGwei;
}
function initialize(address _liquidityPoolAddress, address _eEthAddress, address _membershipManager) external;
function requestWithdraw(uint96 amountOfEEth, uint96 shareOfEEth, address requester, uint256 fee) external payable returns (uint256);
function claimWithdraw(uint256 requestId) external;
function getRequest(uint256 requestId) external view returns (WithdrawRequest memory);
function isFinalized(uint256 requestId) external view returns (bool);
function invalidateRequest(uint256 requestId) external;
function finalizeRequests(uint256 upperBound) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import "./IStakingManager.sol";
import "./IeETH.sol";
interface ILiquidityPool {
struct PermitInput {
uint256 value;
uint256 deadline;
uint8 v;
bytes32 r;
bytes32 s;
}
enum SourceOfFunds {
UNDEFINED,
EETH,
ETHER_FAN,
DELEGATED_STAKING
}
struct FundStatistics {
uint32 numberOfValidators;
uint32 targetWeight;
}
// Necessary to preserve "statelessness" of dutyForWeek().
// Handles case where new users join/leave holder list during an active slot
struct HoldersUpdate {
uint32 timestamp;
uint32 startOfSlotNumOwners;
}
struct BnftHolder {
address holder;
}
struct ValidatorSpawner {
bool registered;
}
function numPendingDeposits() external view returns (uint32);
function totalValueOutOfLp() external view returns (uint128);
function totalValueInLp() external view returns (uint128);
function getTotalEtherClaimOf(address _user) external view returns (uint256);
function getTotalPooledEther() external view returns (uint256);
function sharesForAmount(uint256 _amount) external view returns (uint256);
function sharesForWithdrawalAmount(uint256 _amount) external view returns (uint256);
function amountForShare(uint256 _share) external view returns (uint256);
function eETH() external view returns (IeETH);
function ethAmountLockedForWithdrawal() external view returns (uint128);
function deposit() external payable returns (uint256);
function deposit(address _referral) external payable returns (uint256);
function deposit(address _user, address _referral) external payable returns (uint256);
function depositToRecipient(address _recipient, uint256 _amount, address _referral) external returns (uint256);
function withdraw(address _recipient, uint256 _amount) external returns (uint256);
function requestWithdraw(address recipient, uint256 amount) external returns (uint256);
function requestWithdrawWithPermit(address _owner, uint256 _amount, PermitInput calldata _permit) external returns (uint256);
function requestMembershipNFTWithdraw(address recipient, uint256 amount, uint256 fee) external returns (uint256);
function batchDeposit(uint256[] calldata _candidateBidIds, uint256 _numberOfValidators) external returns (uint256[] memory);
function batchDeposit(uint256[] calldata _candidateBidIds, uint256 _numberOfValidators, uint256 _validatorIdToCoUseWithdrawalSafe) external returns (uint256[] memory);
function batchRegister(bytes32 _depositRoot, uint256[] calldata _validatorIds, IStakingManager.DepositData[] calldata _registerValidatorDepositData, bytes32[] calldata _depositDataRootApproval, bytes[] calldata _signaturesForApprovalDeposit) external;
function batchApproveRegistration(uint256[] memory _validatorIds, bytes[] calldata _pubKey, bytes[] calldata _signature) external;
function batchCancelDeposit(uint256[] calldata _validatorIds) external;
function sendExitRequests(uint256[] calldata _validatorIds) external;
function registerValidatorSpawner(address _user) external;
function unregisterValidatorSpawner(address _user) external;
function rebase(int128 _accruedRewards) external;
function payProtocolFees(uint128 _protocolFees) external;
function addEthAmountLockedForWithdrawal(uint128 _amount) external;
function pauseContract() external;
function burnEEthShares(uint256 shares) external;
function unPauseContract() external;
function setStakingTargetWeights(uint32 _eEthWeight, uint32 _etherFanWeight) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
interface IEtherFiAdmin {
function lastHandledReportRefSlot() external view returns (uint32);
function lastHandledReportRefBlock() external view returns (uint32);
function lastAdminExecutionBlock() external view returns (uint32);
function numValidatorsToSpinUp() external view returns (uint32);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
interface IAuctionManager {
struct Bid {
uint256 amount;
uint64 bidderPubKeyIndex;
address bidderAddress;
bool isActive;
}
function initialize(address _nodeOperatorManagerContract) external;
function getBidOwner(uint256 _bidId) external view returns (address);
function numberOfActiveBids() external view returns (uint256);
function isBidActive(uint256 _bidId) external view returns (bool);
function createBid(
uint256 _bidSize,
uint256 _bidAmount
) external payable returns (uint256[] memory);
function cancelBidBatch(uint256[] calldata _bidIds) external;
function cancelBid(uint256 _bidId) external;
function reEnterAuction(uint256 _bidId) external;
function updateSelectedBidInformation(uint256 _bidId) external;
function processAuctionFeeTransfer(uint256 _validatorId) external;
function setStakingManagerContractAddress(
address _stakingManagerContractAddress
) external;
function setAccumulatedRevenueThreshold(uint128 _newThreshold) external;
function updateAdmin(address _address, bool _isAdmin) external;
function pauseContract() external;
function unPauseContract() external;
function transferAccumulatedRevenue() external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import "../eigenlayer-interfaces/IStrategyManager.sol";
import "../eigenlayer-interfaces/IStrategy.sol";
import "../eigenlayer-interfaces/IPauserRegistry.sol";
// cbETH-ETH mainnet: 0x5FAE7E604FC3e24fd43A72867ceBaC94c65b404A
// wBETH-ETH mainnet: 0xBfAb6FA95E0091ed66058ad493189D2cB29385E6
// stETH-ETH mainnet: 0xDC24316b9AE028F1497c275EB9192a3Ea0f67022
interface ICurvePool {
function exchange_underlying(uint256 i, uint256 j, uint256 dx, uint256 min_dy) external returns (uint256);
function exchange(int128 i, int128 j, uint256 dx, uint256 min_dy) external returns (uint256);
function get_virtual_price() external view returns (uint256);
}
interface ICurvePoolQuoter1 {
function get_dy(int128 i, int128 j, uint256 dx) external view returns (uint256); // wBETH-ETH, stETH-ETH
}
interface ICurvePoolQuoter2 {
function get_dy(uint256 i, uint256 j, uint256 dx) external view returns (uint256); // cbETH-ETH
}
// mint forwarder: 0xfae23c30d383DF59D3E031C325a73d454e8721a6
// mainnet: 0xBe9895146f7AF43049ca1c1AE358B0541Ea49704
interface IcbETH is IERC20 {
function mint(address _to, uint256 _amount) external;
function exchangeRate() external view returns (uint256 _exchangeRate);
}
// mainnet: 0xa2E3356610840701BDf5611a53974510Ae27E2e1
interface IwBETH is IERC20 {
function deposit(address referral) payable external;
function mint(address _to, uint256 _amount) external;
function exchangeRate() external view returns (uint256 _exchangeRate);
}
// mainnet: 0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84
interface ILido is IERC20 {
function getTotalPooledEther() external view returns (uint256);
function getTotalShares() external view returns (uint256);
function submit(address _referral) external payable returns (uint256);
function nonces(address _user) external view returns (uint256);
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
// mainnet: 0x858646372CC42E1A627fcE94aa7A7033e7CF075A
interface IEigenLayerStrategyManager is IStrategyManager {
function withdrawalRootPending(bytes32 _withdrawalRoot) external view returns (bool);
function numWithdrawalsQueued(address _user) external view returns (uint96);
function pauserRegistry() external returns (IPauserRegistry);
function paused(uint8 index) external view returns (bool);
function unpause(uint256 newPausedStatus) external;
// For testing
function queueWithdrawal( uint256[] calldata strategyIndexes, IStrategy[] calldata strategies, uint256[] calldata shares, address withdrawer, bool undelegateIfPossible ) external returns(bytes32);
}
interface IEigenLayerStrategyTVLLimits is IStrategy {
function getTVLLimits() external view returns (uint256, uint256);
function setTVLLimits(uint256 newMaxPerDeposit, uint256 newMaxTotalDeposits) external;
function pauserRegistry() external returns (IPauserRegistry);
function paused(uint8 index) external view returns (bool);
function unpause(uint256 newPausedStatus) external;
}
// mainnet: 0x889edC2eDab5f40e902b864aD4d7AdE8E412F9B1
interface ILidoWithdrawalQueue {
struct WithdrawalRequestStatus {
/// @notice stETH token amount that was locked on withdrawal queue for this request
uint256 amountOfStETH;
/// @notice amount of stETH shares locked on withdrawal queue for this request
uint256 amountOfShares;
/// @notice address that can claim or transfer this request
address owner;
/// @notice timestamp of when the request was created, in seconds
uint256 timestamp;
/// @notice true, if request is finalized
bool isFinalized;
/// @notice true, if request is claimed. Request is claimable if (isFinalized && !isClaimed)
bool isClaimed;
}
function FINALIZE_ROLE() external view returns (bytes32);
function MAX_STETH_WITHDRAWAL_AMOUNT() external view returns (uint256);
function MIN_STETH_WITHDRAWAL_AMOUNT() external view returns (uint256);
function requestWithdrawals(uint256[] calldata _amount, address _depositor) external returns (uint256[] memory);
function claimWithdrawals(uint256[] calldata _requestIds, uint256[] calldata _hints) external;
function finalize(uint256 _lastRequestIdToBeFinalized, uint256 _maxShareRate) external payable;
function prefinalize(uint256[] calldata _batches, uint256 _maxShareRate) external view returns (uint256 ethToLock, uint256 sharesToBurn);
function findCheckpointHints(uint256[] calldata _requestIds, uint256 _firstIndex, uint256 _lastIndex) external view returns (uint256[] memory hintIds);
function getRoleMember(bytes32 _role, uint256 _index) external view returns (address);
function getLastRequestId() external view returns (uint256);
function getLastCheckpointIndex() external view returns (uint256);
function getWithdrawalRequests(address _owner) external view returns (uint256[] memory requestsIds);
function getWithdrawalStatus(uint256[] memory _requestIds) external view returns (WithdrawalRequestStatus[] memory statuses);
}
interface ILiquifier {
struct PermitInput {
uint256 value;
uint256 deadline;
uint8 v;
bytes32 r;
bytes32 s;
}
struct TokenInfo {
uint128 strategyShare;
uint128 ethAmountPendingForWithdrawals;
IStrategy strategy;
bool isWhitelisted;
uint16 discountInBasisPoints;
uint32 timeBoundCapClockStartTime;
uint32 timeBoundCapInEther;
uint32 totalCapInEther;
uint96 totalDepositedThisPeriod;
uint96 totalDeposited;
bool isL2Eth;
}
function depositWithERC20(address _token, uint256 _amount, address _referral) external returns (uint256);
function quoteByFairValue(address _token, uint256 _amount) external view returns (uint256);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import {Ownable2StepUpgradeable} from "@openzeppelin-upgradeable/contracts/access/Ownable2StepUpgradeable.sol";
import {UUPSUpgradeable, Initializable} from "@openzeppelin-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol";
import {EnumerableRoles} from "solady/auth/EnumerableRoles.sol";
/// @title RoleRegistry - An upgradeable role-based access control system
/// @notice Provides functionality for managing and querying roles with enumeration capabilities
/// @dev Implements UUPS upgradeability pattern and uses Solady's EnumerableRoles for efficient role management
/// @author EtherFi
contract RoleRegistry is Initializable, Ownable2StepUpgradeable, UUPSUpgradeable, EnumerableRoles {
bytes32 public constant PROTOCOL_PAUSER = keccak256("PROTOCOL_PAUSER");
bytes32 public constant PROTOCOL_UNPAUSER = keccak256("PROTOCOL_UNPAUSER");
error OnlyProtocolUpgrader();
/// @notice Returns the maximum allowed role value
/// @dev This is used by EnumerableRoles._validateRole to ensure roles are within valid range
/// @return uint256 The maximum role value
function MAX_ROLE() public pure returns (uint256) {
return type(uint256).max;
}
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}
function initialize(address _owner) public initializer {
__Ownable2Step_init();
__UUPSUpgradeable_init();
_transferOwnership(_owner);
}
/// @notice Checks if an account has any of the specified roles
/// @dev Reverts if the account doesn't have at least one of the roles
/// @param account The address to check roles for
/// @param encodedRoles ABI encoded roles (abi.encode(ROLE_1, ROLE_2, ...))
function checkRoles(address account, bytes memory encodedRoles) public view {
if (!_hasAnyRoles(account, encodedRoles)) __revertEnumerableRolesUnauthorized();
}
/// @notice Checks if an account has a specific role
/// @param role The role to check (as bytes32)
/// @param account The address to check the role for
/// @return bool True if the account has the role, false otherwise
function hasRole(bytes32 role, address account) public view returns (bool) {
return hasRole(account, uint256(role));
}
/// @notice Grants a role to an account
/// @dev Only callable by the contract owner (handled in setRole function)
/// @param role The role to grant (as bytes32)
/// @param account The address to grant the role to
function grantRole(bytes32 role, address account) public {
setRole(account, uint256(role), true);
}
/// @notice Revokes a role from an account
/// @dev Only callable by the contract owner (handled in setRole function)
/// @param role The role to revoke (as bytes32)
/// @param account The address to revoke the role from
function revokeRole(bytes32 role, address account) public {
setRole(account, uint256(role), false);
}
/// @notice Gets all addresses that have a specific role
/// @dev Wrapper around EnumerableRoles roleHolders function converting bytes32 to uint256
/// @param role The role to query (as bytes32)
/// @return address[] Array of addresses that have the specified role
function roleHolders(bytes32 role) public view returns (address[] memory) {
return roleHolders(uint256(role));
}
function onlyProtocolUpgrader(address account) public view {
if (owner() != account) revert OnlyProtocolUpgrader();
}
function __revertEnumerableRolesUnauthorized() private pure {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, 0x99152cca) // `EnumerableRolesUnauthorized()`.
revert(0x1c, 0x04)
}
}
function _authorizeUpgrade(address newImplementation) internal override onlyOwner {}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import "@openzeppelin/contracts/utils/math/SafeCast.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol";
import "@openzeppelin-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin-upgradeable/contracts/proxy/utils/Initializable.sol";
import "@openzeppelin-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin-upgradeable/contracts/security/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin-upgradeable/contracts/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/math/Math.sol";
import "./interfaces/ILiquidityPool.sol";
import "./interfaces/IeETH.sol";
import "./interfaces/IWeETH.sol";
import "lib/BucketLimiter.sol";
import "./RoleRegistry.sol";
/*
The contract allows instant redemption of eETH and weETH tokens to ETH with an exit fee.
- It has the exit fee as a percentage of the total amount redeemed.
- It has a rate limiter to limit the total amount that can be redeemed in a given time period.
*/
contract EtherFiRedemptionManager is Initializable, PausableUpgradeable, ReentrancyGuardUpgradeable, UUPSUpgradeable {
using SafeERC20 for IERC20;
using Math for uint256;
uint256 private constant BUCKET_UNIT_SCALE = 1e12;
uint256 private constant BASIS_POINT_SCALE = 1e4;
bytes32 public constant ETHERFI_REDEMPTION_MANAGER_ADMIN_ROLE = keccak256("ETHERFI_REDEMPTION_MANAGER_ADMIN_ROLE");
RoleRegistry public immutable roleRegistry;
address public immutable treasury;
IeETH public immutable eEth;
IWeETH public immutable weEth;
ILiquidityPool public immutable liquidityPool;
BucketLimiter.Limit public limit;
uint16 public exitFeeSplitToTreasuryInBps;
uint16 public exitFeeInBps;
uint16 public lowWatermarkInBpsOfTvl; // bps of TVL
event Redeemed(address indexed receiver, uint256 redemptionAmount, uint256 feeAmountToTreasury, uint256 feeAmountToStakers);
receive() external payable {}
/// @custom:oz-upgrades-unsafe-allow constructor
constructor(address _liquidityPool, address _eEth, address _weEth, address _treasury, address _roleRegistry) {
roleRegistry = RoleRegistry(_roleRegistry);
treasury = _treasury;
liquidityPool = ILiquidityPool(payable(_liquidityPool));
eEth = IeETH(_eEth);
weEth = IWeETH(_weEth);
_disableInitializers();
}
function initialize(uint16 _exitFeeSplitToTreasuryInBps, uint16 _exitFeeInBps, uint16 _lowWatermarkInBpsOfTvl, uint256 _bucketCapacity, uint256 _bucketRefillRate) external initializer {
require(_exitFeeInBps <= BASIS_POINT_SCALE, "INVALID");
require(_exitFeeSplitToTreasuryInBps <= BASIS_POINT_SCALE, "INVALID");
require(_lowWatermarkInBpsOfTvl <= BASIS_POINT_SCALE, "INVALID");
__UUPSUpgradeable_init();
__Pausable_init();
__ReentrancyGuard_init();
limit = BucketLimiter.create(_convertToBucketUnit(_bucketCapacity, Math.Rounding.Down), _convertToBucketUnit(_bucketRefillRate, Math.Rounding.Down));
exitFeeSplitToTreasuryInBps = _exitFeeSplitToTreasuryInBps;
exitFeeInBps = _exitFeeInBps;
lowWatermarkInBpsOfTvl = _lowWatermarkInBpsOfTvl;
}
/**
* @notice Redeems eETH for ETH.
* @param eEthAmount The amount of eETH to redeem after the exit fee.
* @param receiver The address to receive the redeemed ETH.
*/
function redeemEEth(uint256 eEthAmount, address receiver) public whenNotPaused nonReentrant {
_redeemEEth(eEthAmount, receiver);
}
/**
* @notice Redeems weETH for ETH.
* @param weEthAmount The amount of weETH to redeem after the exit fee.
* @param receiver The address to receive the redeemed ETH.
*/
function redeemWeEth(uint256 weEthAmount, address receiver) public whenNotPaused nonReentrant {
_redeemWeEth(weEthAmount, receiver);
}
/**
* @notice Redeems eETH for ETH with permit.
* @param eEthAmount The amount of eETH to redeem after the exit fee.
* @param receiver The address to receive the redeemed ETH.
* @param permit The permit params.
*/
function redeemEEthWithPermit(uint256 eEthAmount, address receiver, IeETH.PermitInput calldata permit) external whenNotPaused nonReentrant {
try eEth.permit(msg.sender, address(this), permit.value, permit.deadline, permit.v, permit.r, permit.s) {} catch {}
_redeemEEth(eEthAmount, receiver);
}
/**
* @notice Redeems weETH for ETH.
* @param weEthAmount The amount of weETH to redeem after the exit fee.
* @param receiver The address to receive the redeemed ETH.
* @param permit The permit params.
*/
function redeemWeEthWithPermit(uint256 weEthAmount, address receiver, IWeETH.PermitInput calldata permit) external whenNotPaused nonReentrant {
try weEth.permit(msg.sender, address(this), permit.value, permit.deadline, permit.v, permit.r, permit.s) {} catch {}
_redeemWeEth(weEthAmount, receiver);
}
/**
* @notice Redeems ETH.
* @param ethAmount The amount of ETH to redeem after the exit fee.
* @param receiver The address to receive the redeemed ETH.
*/
function _redeem(uint256 ethAmount, uint256 eEthShares, address receiver, uint256 eEthAmountToReceiver, uint256 eEthFeeAmountToTreasury, uint256 sharesToBurn, uint256 feeShareToTreasury) internal {
_updateRateLimit(ethAmount);
// Derive additionals
uint256 eEthShareFee = eEthShares - sharesToBurn;
uint256 feeShareToStakers = eEthShareFee - feeShareToTreasury;
// Snapshot balances & shares for sanity check at the end
uint256 prevBalance = address(this).balance;
uint256 prevLpBalance = address(liquidityPool).balance;
uint256 totalEEthShare = eEth.totalShares();
// Withdraw ETH from the liquidity pool
require(liquidityPool.withdraw(address(this), eEthAmountToReceiver) == sharesToBurn, "invalid num shares burnt");
uint256 ethReceived = address(this).balance - prevBalance;
// To Stakers by burning shares
liquidityPool.burnEEthShares(feeShareToStakers);
// To Treasury by transferring eETH
IERC20(address(eEth)).safeTransfer(treasury, eEthFeeAmountToTreasury);
// uint256 totalShares = eEth.totalShares();
require(eEth.totalShares() >= 1 gwei && eEth.totalShares() == totalEEthShare - (sharesToBurn + feeShareToStakers), "EtherFiRedemptionManager: Invalid total shares");
// To Receiver by transferring ETH, using gas 10k for additional safety
(bool success, ) = receiver.call{value: ethReceived, gas: 10_000}("");
require(success, "EtherFiRedemptionManager: Transfer failed");
// Make sure the liquidity pool balance is correct && total shares are correct
require(address(liquidityPool).balance == prevLpBalance - ethReceived, "EtherFiRedemptionManager: Invalid liquidity pool balance");
// require(eEth.totalShares() >= 1 gwei && eEth.totalShares() == totalEEthShare - (sharesToBurn + feeShareToStakers), "EtherFiRedemptionManager: Invalid total shares");
emit Redeemed(receiver, ethAmount, eEthFeeAmountToTreasury, eEthAmountToReceiver);
}
/**
* @dev if the contract has less than the low watermark, it will not allow any instant redemption.
*/
function lowWatermarkInETH() public view returns (uint256) {
return liquidityPool.getTotalPooledEther().mulDiv(lowWatermarkInBpsOfTvl, BASIS_POINT_SCALE);
}
/**
* @dev Returns the total amount that can be redeemed.
*/
function totalRedeemableAmount() external view returns (uint256) {
uint256 liquidEthAmount = address(liquidityPool).balance - liquidityPool.ethAmountLockedForWithdrawal();
if (liquidEthAmount < lowWatermarkInETH()) {
return 0;
}
uint64 consumableBucketUnits = BucketLimiter.consumable(limit);
uint256 consumableAmount = _convertFromBucketUnit(consumableBucketUnits);
return Math.min(consumableAmount, liquidEthAmount);
}
/**
* @dev Returns whether the given amount can be redeemed.
* @param amount The ETH or eETH amount to check.
*/
function canRedeem(uint256 amount) public view returns (bool) {
uint256 liquidEthAmount = address(liquidityPool).balance - liquidityPool.ethAmountLockedForWithdrawal();
if (liquidEthAmount < lowWatermarkInETH()) {
return false;
}
uint64 bucketUnit = _convertToBucketUnit(amount, Math.Rounding.Up);
bool consumable = BucketLimiter.canConsume(limit, bucketUnit);
return consumable && amount <= liquidEthAmount;
}
/**
* @dev Sets the maximum size of the bucket that can be consumed in a given time period.
* @param capacity The capacity of the bucket.
*/
function setCapacity(uint256 capacity) external hasRole(ETHERFI_REDEMPTION_MANAGER_ADMIN_ROLE) {
// max capacity = max(uint64) * 1e12 ~= 16 * 1e18 * 1e12 = 16 * 1e12 ether, which is practically enough
uint64 bucketUnit = _convertToBucketUnit(capacity, Math.Rounding.Down);
BucketLimiter.setCapacity(limit, bucketUnit);
}
/**
* @dev Sets the rate at which the bucket is refilled per second.
* @param refillRate The rate at which the bucket is refilled per second.
*/
function setRefillRatePerSecond(uint256 refillRate) external hasRole(ETHERFI_REDEMPTION_MANAGER_ADMIN_ROLE) {
// max refillRate = max(uint64) * 1e12 ~= 16 * 1e18 * 1e12 = 16 * 1e12 ether per second, which is practically enough
uint64 bucketUnit = _convertToBucketUnit(refillRate, Math.Rounding.Down);
BucketLimiter.setRefillRate(limit, bucketUnit);
}
/**
* @dev Sets the exit fee.
* @param _exitFeeInBps The exit fee.
*/
function setExitFeeBasisPoints(uint16 _exitFeeInBps) external hasRole(ETHERFI_REDEMPTION_MANAGER_ADMIN_ROLE) {
require(_exitFeeInBps <= BASIS_POINT_SCALE, "INVALID");
exitFeeInBps = _exitFeeInBps;
}
function setLowWatermarkInBpsOfTvl(uint16 _lowWatermarkInBpsOfTvl) external hasRole(ETHERFI_REDEMPTION_MANAGER_ADMIN_ROLE) {
require(_lowWatermarkInBpsOfTvl <= BASIS_POINT_SCALE, "INVALID");
lowWatermarkInBpsOfTvl = _lowWatermarkInBpsOfTvl;
}
function setExitFeeSplitToTreasuryInBps(uint16 _exitFeeSplitToTreasuryInBps) external hasRole(ETHERFI_REDEMPTION_MANAGER_ADMIN_ROLE) {
require(_exitFeeSplitToTreasuryInBps <= BASIS_POINT_SCALE, "INVALID");
exitFeeSplitToTreasuryInBps = _exitFeeSplitToTreasuryInBps;
}
function pauseContract() external hasRole(roleRegistry.PROTOCOL_PAUSER()) {
_pause();
}
function unPauseContract() external hasRole(roleRegistry.PROTOCOL_UNPAUSER()) {
_unpause();
}
function _redeemEEth(uint256 eEthAmount, address receiver) internal {
require(eEthAmount <= eEth.balanceOf(msg.sender), "EtherFiRedemptionManager: Insufficient balance");
require(canRedeem(eEthAmount), "EtherFiRedemptionManager: Exceeded total redeemable amount");
(uint256 eEthShares, uint256 eEthAmountToReceiver, uint256 eEthFeeAmountToTreasury, uint256 sharesToBurn, uint256 feeShareToTreasury) = _calcRedemption(eEthAmount);
IERC20(address(eEth)).safeTransferFrom(msg.sender, address(this), eEthAmount);
_redeem(eEthAmount, eEthShares, receiver, eEthAmountToReceiver, eEthFeeAmountToTreasury, sharesToBurn, feeShareToTreasury);
}
function _redeemWeEth(uint256 weEthAmount, address receiver) internal {
uint256 eEthAmount = weEth.getEETHByWeETH(weEthAmount);
require(weEthAmount <= weEth.balanceOf(msg.sender), "EtherFiRedemptionManager: Insufficient balance");
require(canRedeem(eEthAmount), "EtherFiRedemptionManager: Exceeded total redeemable amount");
(uint256 eEthShares, uint256 eEthAmountToReceiver, uint256 eEthFeeAmountToTreasury, uint256 sharesToBurn, uint256 feeShareToTreasury) = _calcRedemption(eEthAmount);
IERC20(address(weEth)).safeTransferFrom(msg.sender, address(this), weEthAmount);
weEth.unwrap(weEthAmount);
_redeem(eEthAmount, eEthShares, receiver, eEthAmountToReceiver, eEthFeeAmountToTreasury, sharesToBurn, feeShareToTreasury);
}
function _updateRateLimit(uint256 amount) internal {
uint64 bucketUnit = _convertToBucketUnit(amount, Math.Rounding.Up);
require(BucketLimiter.consume(limit, bucketUnit), "BucketRateLimiter: rate limit exceeded");
}
function _convertToBucketUnit(uint256 amount, Math.Rounding rounding) internal pure returns (uint64) {
require(amount < type(uint64).max * BUCKET_UNIT_SCALE, "EtherFiRedemptionManager: Amount too large");
return (rounding == Math.Rounding.Up) ? SafeCast.toUint64((amount + BUCKET_UNIT_SCALE - 1) / BUCKET_UNIT_SCALE) : SafeCast.toUint64(amount / BUCKET_UNIT_SCALE);
}
function _convertFromBucketUnit(uint64 bucketUnit) internal pure returns (uint256) {
return bucketUnit * BUCKET_UNIT_SCALE;
}
function _calcRedemption(uint256 ethAmount) internal view returns (uint256 eEthShares, uint256 eEthAmountToReceiver, uint256 eEthFeeAmountToTreasury, uint256 sharesToBurn, uint256 feeShareToTreasury) {
eEthShares = liquidityPool.sharesForAmount(ethAmount);
eEthAmountToReceiver = liquidityPool.amountForShare(eEthShares.mulDiv(BASIS_POINT_SCALE - exitFeeInBps, BASIS_POINT_SCALE)); // ethShareToReceiver
sharesToBurn = liquidityPool.sharesForWithdrawalAmount(eEthAmountToReceiver);
uint256 eEthShareFee = eEthShares - sharesToBurn;
feeShareToTreasury = eEthShareFee.mulDiv(exitFeeSplitToTreasuryInBps, BASIS_POINT_SCALE);
eEthFeeAmountToTreasury = liquidityPool.amountForShare(feeShareToTreasury);
}
/**
* @dev Preview taking an exit fee on redeem. See {IERC4626-previewRedeem}.
*/
// redeemable amount after exit fee
function previewRedeem(uint256 shares) public view returns (uint256) {
uint256 amountInEth = liquidityPool.amountForShare(shares);
return amountInEth - _fee(amountInEth, exitFeeInBps);
}
function _fee(uint256 assets, uint256 feeBasisPoints) internal pure virtual returns (uint256) {
return assets.mulDiv(feeBasisPoints, BASIS_POINT_SCALE, Math.Rounding.Up);
}
function _authorizeUpgrade(address newImplementation) internal override {
roleRegistry.onlyProtocolUpgrader(msg.sender);
}
function getImplementation() external view returns (address) {
return _getImplementation();
}
function _hasRole(bytes32 role, address account) internal view returns (bool) {
require(roleRegistry.hasRole(role, account), "EtherFiRedemptionManager: Unauthorized");
}
modifier hasRole(bytes32 role) {
_hasRole(role, msg.sender);
_;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @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://diligence.consensys.net/posts/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.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @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, it is bubbled up by this
* function (like regular Solidity function calls).
*
* 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.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @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`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) 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(errorMessage);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)
pragma solidity ^0.8.0;
/**
* @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822ProxiableUpgradeable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)
pragma solidity ^0.8.2;
import "../beacon/IBeaconUpgradeable.sol";
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import "../utils/Initializable.sol";
/**
* @dev This abstract contract provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
*
* _Available since v4.1._
*
* @custom:oz-upgrades-unsafe-allow delegatecall
*/
abstract contract ERC1967UpgradeUpgradeable is Initializable {
function __ERC1967Upgrade_init() internal onlyInitializing {
}
function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
}
// This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Returns the current implementation address.
*/
function _getImplementation() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Perform implementation upgrade
*
* Emits an {Upgraded} event.
*/
function _upgradeTo(address newImplementation) internal {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
}
/**
* @dev Perform implementation upgrade with additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCall(
address newImplementation,
bytes memory data,
bool forceCall
) internal {
_upgradeTo(newImplementation);
if (data.length > 0 || forceCall) {
_functionDelegateCall(newImplementation, data);
}
}
/**
* @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCallUUPS(
address newImplementation,
bytes memory data,
bool forceCall
) internal {
// Upgrades from old implementations will perform a rollback test. This test requires the new
// implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
// this special case will break upgrade paths from old UUPS implementation to new ones.
if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {
_setImplementation(newImplementation);
} else {
try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {
require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
} catch {
revert("ERC1967Upgrade: new implementation is not UUPS");
}
_upgradeToAndCall(newImplementation, data, forceCall);
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Returns the current admin.
*/
function _getAdmin() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
require(newAdmin != address(0), "ERC1967: new admin is the zero address");
StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {AdminChanged} event.
*/
function _changeAdmin(address newAdmin) internal {
emit AdminChanged(_getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
*/
bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Emitted when the beacon is upgraded.
*/
event BeaconUpgraded(address indexed beacon);
/**
* @dev Returns the current beacon.
*/
function _getBeacon() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the EIP1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
require(
AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
"ERC1967: beacon implementation is not a contract"
);
StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
}
/**
* @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
* not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
*
* Emits a {BeaconUpgraded} event.
*/
function _upgradeBeaconToAndCall(
address newBeacon,
bytes memory data,
bool forceCall
) internal {
_setBeacon(newBeacon);
emit BeaconUpgraded(newBeacon);
if (data.length > 0 || forceCall) {
_functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
}
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {
require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed");
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
import "../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;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import "./IEtherFiNodesManager.sol";
import "../eigenlayer-interfaces/IDelegationManager.sol";
interface IEtherFiNode {
// State Transition Diagram for StateMachine contract:
//
// NOT_INITIALIZED <-
// | |
// ↓ |
// STAKE_DEPOSITED --
// / \ |
// ↓ ↓ |
// LIVE <- WAITING_FOR_APPROVAL
// | \
// | ↓
// | BEING_SLASHED
// | /
// ↓ ↓
// EXITED
// |
// ↓
// FULLY_WITHDRAWN
//
// Transitions are only allowed as directed above.
// For instance, a transition from STAKE_DEPOSITED to either LIVE or CANCELLED is allowed,
// but a transition from LIVE to NOT_INITIALIZED is not.
//
// All phase transitions should be made through the setPhase function,
// which validates transitions based on these rules.
//
enum VALIDATOR_PHASE {
NOT_INITIALIZED,
STAKE_DEPOSITED,
LIVE,
EXITED,
FULLY_WITHDRAWN,
DEPRECATED_CANCELLED,
BEING_SLASHED,
DEPRECATED_EVICTED,
WAITING_FOR_APPROVAL,
DEPRECATED_READY_FOR_DEPOSIT
}
// VIEW functions
function numAssociatedValidators() external view returns (uint256);
function numExitRequestsByTnft() external view returns (uint16);
function numExitedValidators() external view returns (uint16);
function version() external view returns (uint16);
function eigenPod() external view returns (address);
function calculateTVL(uint256 _beaconBalance, IEtherFiNodesManager.ValidatorInfo memory _info, IEtherFiNodesManager.RewardsSplit memory _SRsplits, bool _onlyWithdrawable) external view returns (uint256, uint256, uint256, uint256);
function getNonExitPenalty(uint32 _tNftExitRequestTimestamp, uint32 _bNftExitRequestTimestamp) external view returns (uint256);
function getRewardsPayouts(uint32 _exitRequestTimestamp, IEtherFiNodesManager.RewardsSplit memory _splits) external view returns (uint256, uint256, uint256, uint256);
function getFullWithdrawalPayouts(IEtherFiNodesManager.ValidatorInfo memory _info, IEtherFiNodesManager.RewardsSplit memory _SRsplits) external view returns (uint256, uint256, uint256, uint256);
function associatedValidatorIds(uint256 _index) external view returns (uint256);
function associatedValidatorIndices(uint256 _validatorId) external view returns (uint256);
function validatePhaseTransition(VALIDATOR_PHASE _currentPhase, VALIDATOR_PHASE _newPhase) external pure returns (bool);
function DEPRECATED_exitRequestTimestamp() external view returns (uint32);
function DEPRECATED_exitTimestamp() external view returns (uint32);
function DEPRECATED_phase() external view returns (VALIDATOR_PHASE);
// Non-VIEW functions
function initialize(address _etherFiNodesManager) external;
function DEPRECATED_claimDelayedWithdrawalRouterWithdrawals() external;
function createEigenPod() external;
function isRestakingEnabled() external view returns (bool);
function processNodeExit(uint256 _validatorId) external returns (bytes32[] memory withdrawalRoots);
function processFullWithdraw(uint256 _validatorId) external;
function queueEigenpodFullWithdrawal() external returns (bytes32[] memory withdrawalRoots);
function completeQueuedWithdrawals(IDelegationManager.Withdrawal[] memory withdrawals, uint256[] calldata middlewareTimesIndexes, bool _receiveAsTokens) external;
function completeQueuedWithdrawal(IDelegationManager.Withdrawal memory withdrawals, uint256 middlewareTimesIndexes, bool _receiveAsTokens) external;
function updateNumberOfAssociatedValidators(uint16 _up, uint16 _down) external;
function updateNumExitedValidators(uint16 _up, uint16 _down) external;
function registerValidator(uint256 _validatorId, bool _enableRestaking) external;
function unRegisterValidator(uint256 _validatorId, IEtherFiNodesManager.ValidatorInfo memory _info) external returns (bool);
function splitBalanceInExecutionLayer() external view returns (uint256 _withdrawalSafe, uint256 _eigenPod, uint256 _delayedWithdrawalRouter);
function totalBalanceInExecutionLayer() external view returns (uint256);
function withdrawableBalanceInExecutionLayer() external view returns (uint256);
function updateNumExitRequests(uint16 _up, uint16 _down) external;
function migrateVersion(uint256 _validatorId, IEtherFiNodesManager.ValidatorInfo memory _info) external;
function startCheckpoint(bool _revertIfNoBalance) external;
function setProofSubmitter(address _newProofSubmitter) external;
function callEigenPod(bytes memory data) external returns (bytes memory);
function forwardCall(address to, bytes memory data) external returns (bytes memory);
function withdrawFunds(
address _treasury,
uint256 _treasuryAmount,
address _operator,
uint256 _operatorAmount,
address _tnftHolder,
uint256 _tnftAmount,
address _bnftHolder,
uint256 _bnftAmount
) external;
function moveFundsToManager(uint256 _amount) external;
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.5.0;
import "@openzeppelin/contracts/proxy/beacon/IBeacon.sol";
import "./IETHPOSDeposit.sol";
import "./IStrategyManager.sol";
import "./IEigenPod.sol";
import "./IBeaconChainOracle.sol";
import "./IPausable.sol";
import "./ISlasher.sol";
import "./IStrategy.sol";
/**
* @title Interface for factory that creates and manages solo staking pods that have their withdrawal credentials pointed to EigenLayer.
* @author Layr Labs, Inc.
* @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
*/
interface IEigenPodManager is IPausable {
/// @notice Emitted to notify the update of the beaconChainOracle address
event BeaconOracleUpdated(address indexed newOracleAddress);
/// @notice Emitted to notify the deployment of an EigenPod
event PodDeployed(address indexed eigenPod, address indexed podOwner);
/// @notice Emitted to notify a deposit of beacon chain ETH recorded in the strategy manager
event BeaconChainETHDeposited(address indexed podOwner, uint256 amount);
/// @notice Emitted when the balance of an EigenPod is updated
event PodSharesUpdated(address indexed podOwner, int256 sharesDelta);
/// @notice Emitted when a withdrawal of beacon chain ETH is completed
event BeaconChainETHWithdrawalCompleted(
address indexed podOwner,
uint256 shares,
uint96 nonce,
address delegatedAddress,
address withdrawer,
bytes32 withdrawalRoot
);
event DenebForkTimestampUpdated(uint64 newValue);
/**
* @notice Creates an EigenPod for the sender.
* @dev Function will revert if the `msg.sender` already has an EigenPod.
* @dev Returns EigenPod address
*/
function createPod() external returns (address);
/**
* @notice Stakes for a new beacon chain validator on the sender's EigenPod.
* Also creates an EigenPod for the sender if they don't have one already.
* @param pubkey The 48 bytes public key of the beacon chain validator.
* @param signature The validator's signature of the deposit data.
* @param depositDataRoot The root/hash of the deposit data for the validator's deposit.
*/
function stake(bytes calldata pubkey, bytes calldata signature, bytes32 depositDataRoot) external payable;
/**
* @notice Changes the `podOwner`'s shares by `sharesDelta` and performs a call to the DelegationManager
* to ensure that delegated shares are also tracked correctly
* @param podOwner is the pod owner whose balance is being updated.
* @param sharesDelta is the change in podOwner's beaconChainETHStrategy shares
* @dev Callable only by the podOwner's EigenPod contract.
* @dev Reverts if `sharesDelta` is not a whole Gwei amount
*/
function recordBeaconChainETHBalanceUpdate(address podOwner, int256 sharesDelta) external;
/**
* @notice Updates the oracle contract that provides the beacon chain state root
* @param newBeaconChainOracle is the new oracle contract being pointed to
* @dev Callable only by the owner of this contract (i.e. governance)
*/
function updateBeaconChainOracle(IBeaconChainOracle newBeaconChainOracle) external;
/// @notice Returns the address of the `podOwner`'s EigenPod if it has been deployed.
function ownerToPod(address podOwner) external view returns (IEigenPod);
/// @notice Returns the address of the `podOwner`'s EigenPod (whether it is deployed yet or not).
function getPod(address podOwner) external view returns (IEigenPod);
/// @notice The ETH2 Deposit Contract
function ethPOS() external view returns (IETHPOSDeposit);
/// @notice Beacon proxy to which the EigenPods point
function eigenPodBeacon() external view returns (IBeacon);
/// @notice Oracle contract that provides updates to the beacon chain's state
function beaconChainOracle() external view returns (IBeaconChainOracle);
/// @notice Returns the beacon block root at `timestamp`. Reverts if the Beacon block root at `timestamp` has not yet been finalized.
function getBlockRootAtTimestamp(uint64 timestamp) external view returns (bytes32);
/// @notice EigenLayer's StrategyManager contract
function strategyManager() external view returns (IStrategyManager);
/// @notice EigenLayer's Slasher contract
function slasher() external view returns (ISlasher);
/// @notice Returns 'true' if the `podOwner` has created an EigenPod, and 'false' otherwise.
function hasPod(address podOwner) external view returns (bool);
/// @notice Returns the number of EigenPods that have been created
function numPods() external view returns (uint256);
/**
* @notice Mapping from Pod owner owner to the number of shares they have in the virtual beacon chain ETH strategy.
* @dev The share amount can become negative. This is necessary to accommodate the fact that a pod owner's virtual beacon chain ETH shares can
* decrease between the pod owner queuing and completing a withdrawal.
* When the pod owner's shares would otherwise increase, this "deficit" is decreased first _instead_.
* Likewise, when a withdrawal is completed, this "deficit" is decreased and the withdrawal amount is decreased; We can think of this
* as the withdrawal "paying off the deficit".
*/
function podOwnerShares(address podOwner) external view returns (int256);
/// @notice returns canonical, virtual beaconChainETH strategy
function beaconChainETHStrategy() external view returns (IStrategy);
/**
* @notice Used by the DelegationManager to remove a pod owner's shares while they're in the withdrawal queue.
* Simply decreases the `podOwner`'s shares by `shares`, down to a minimum of zero.
* @dev This function reverts if it would result in `podOwnerShares[podOwner]` being less than zero, i.e. it is forbidden for this function to
* result in the `podOwner` incurring a "share deficit". This behavior prevents a Staker from queuing a withdrawal which improperly removes excessive
* shares from the operator to whom the staker is delegated.
* @dev Reverts if `shares` is not a whole Gwei amount
*/
function removeShares(address podOwner, uint256 shares) external;
/**
* @notice Increases the `podOwner`'s shares by `shares`, paying off deficit if possible.
* Used by the DelegationManager to award a pod owner shares on exiting the withdrawal queue
* @dev Returns the number of shares added to `podOwnerShares[podOwner]` above zero, which will be less than the `shares` input
* in the event that the podOwner has an existing shares deficit (i.e. `podOwnerShares[podOwner]` starts below zero)
* @dev Reverts if `shares` is not a whole Gwei amount
*/
function addShares(address podOwner, uint256 shares) external returns (uint256);
/**
* @notice Used by the DelegationManager to complete a withdrawal, sending tokens to some destination address
* @dev Prioritizes decreasing the podOwner's share deficit, if they have one
* @dev Reverts if `shares` is not a whole Gwei amount
*/
function withdrawSharesAsTokens(address podOwner, address destination, uint256 shares) external;
/**
* @notice the deneb hard fork timestamp used to determine which proof path to use for proving a withdrawal
*/
function denebForkTimestamp() external view returns (uint64);
/**
* setting the deneb hard fork timestamp by the eigenPodManager owner
* @dev this function is designed to be called twice. Once, it is set to type(uint64).max
* prior to the actual deneb fork timestamp being set, and then the second time it is set
* to the actual deneb fork timestamp.
*/
function setDenebForkTimestamp(uint64 newDenebForkTimestamp) external;
function owner() external returns (address);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.5.0;
import "./IStrategy.sol";
import "./ISignatureUtils.sol";
import "./IStrategyManager.sol";
/**
* @title DelegationManager
* @author Layr Labs, Inc.
* @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
* @notice This is the contract for delegation in EigenLayer. The main functionalities of this contract are
* - enabling anyone to register as an operator in EigenLayer
* - allowing operators to specify parameters related to stakers who delegate to them
* - enabling any staker to delegate its stake to the operator of its choice (a given staker can only delegate to a single operator at a time)
* - enabling a staker to undelegate its assets from the operator it is delegated to (performed as part of the withdrawal process, initiated through the StrategyManager)
*/
interface IDelegationManager is ISignatureUtils {
// @notice Struct used for storing information about a single operator who has registered with EigenLayer
struct OperatorDetails {
// @notice address to receive the rewards that the operator earns via serving applications built on EigenLayer.
address earningsReceiver;
/**
* @notice Address to verify signatures when a staker wishes to delegate to the operator, as well as controlling "forced undelegations".
* @dev Signature verification follows these rules:
* 1) If this address is left as address(0), then any staker will be free to delegate to the operator, i.e. no signature verification will be performed.
* 2) If this address is an EOA (i.e. it has no code), then we follow standard ECDSA signature verification for delegations to the operator.
* 3) If this address is a contract (i.e. it has code) then we forward a call to the contract and verify that it returns the correct EIP-1271 "magic value".
*/
address delegationApprover;
/**
* @notice A minimum delay -- measured in blocks -- enforced between:
* 1) the operator signalling their intent to register for a service, via calling `Slasher.optIntoSlashing`
* and
* 2) the operator completing registration for the service, via the service ultimately calling `Slasher.recordFirstStakeUpdate`
* @dev note that for a specific operator, this value *cannot decrease*, i.e. if the operator wishes to modify their OperatorDetails,
* then they are only allowed to either increase this value or keep it the same.
*/
uint32 stakerOptOutWindowBlocks;
}
/**
* @notice Abstract struct used in calculating an EIP712 signature for a staker to approve that they (the staker themselves) delegate to a specific operator.
* @dev Used in computing the `STAKER_DELEGATION_TYPEHASH` and as a reference in the computation of the stakerDigestHash in the `delegateToBySignature` function.
*/
struct StakerDelegation {
// the staker who is delegating
address staker;
// the operator being delegated to
address operator;
// the staker's nonce
uint256 nonce;
// the expiration timestamp (UTC) of the signature
uint256 expiry;
}
/**
* @notice Abstract struct used in calculating an EIP712 signature for an operator's delegationApprover to approve that a specific staker delegate to the operator.
* @dev Used in computing the `DELEGATION_APPROVAL_TYPEHASH` and as a reference in the computation of the approverDigestHash in the `_delegate` function.
*/
struct DelegationApproval {
// the staker who is delegating
address staker;
// the operator being delegated to
address operator;
// the operator's provided salt
bytes32 salt;
// the expiration timestamp (UTC) of the signature
uint256 expiry;
}
/**
* Struct type used to specify an existing queued withdrawal. Rather than storing the entire struct, only a hash is stored.
* In functions that operate on existing queued withdrawals -- e.g. completeQueuedWithdrawal`, the data is resubmitted and the hash of the submitted
* data is computed by `calculateWithdrawalRoot` and checked against the stored hash in order to confirm the integrity of the submitted data.
*/
struct Withdrawal {
// The address that originated the Withdrawal
address staker;
// The address that the staker was delegated to at the time that the Withdrawal was created
address delegatedTo;
// The address that can complete the Withdrawal + will receive funds when completing the withdrawal
address withdrawer;
// Nonce used to guarantee that otherwise identical withdrawals have unique hashes
uint256 nonce;
// Block number when the Withdrawal was created
uint32 startBlock;
// Array of strategies that the Withdrawal contains
IStrategy[] strategies;
// Array containing the amount of shares in each Strategy in the `strategies` array
uint256[] shares;
}
struct QueuedWithdrawalParams {
// Array of strategies that the QueuedWithdrawal contains
IStrategy[] strategies;
// Array containing the amount of shares in each Strategy in the `strategies` array
uint256[] shares;
// The address of the withdrawer
address withdrawer;
}
// @notice Emitted when a new operator registers in EigenLayer and provides their OperatorDetails.
event OperatorRegistered(address indexed operator, OperatorDetails operatorDetails);
/// @notice Emitted when an operator updates their OperatorDetails to @param newOperatorDetails
event OperatorDetailsModified(address indexed operator, OperatorDetails newOperatorDetails);
/**
* @notice Emitted when @param operator indicates that they are updating their MetadataURI string
* @dev Note that these strings are *never stored in storage* and are instead purely emitted in events for off-chain indexing
*/
event OperatorMetadataURIUpdated(address indexed operator, string metadataURI);
/// @notice Emitted whenever an operator's shares are increased for a given strategy. Note that shares is the delta in the operator's shares.
event OperatorSharesIncreased(address indexed operator, address staker, IStrategy strategy, uint256 shares);
/// @notice Emitted whenever an operator's shares are decreased for a given strategy. Note that shares is the delta in the operator's shares.
event OperatorSharesDecreased(address indexed operator, address staker, IStrategy strategy, uint256 shares);
/// @notice Emitted when @param staker delegates to @param operator.
event StakerDelegated(address indexed staker, address indexed operator);
/// @notice Emitted when @param staker undelegates from @param operator.
event StakerUndelegated(address indexed staker, address indexed operator);
/// @notice Emitted when @param staker is undelegated via a call not originating from the staker themself
event StakerForceUndelegated(address indexed staker, address indexed operator);
/**
* @notice Emitted when a new withdrawal is queued.
* @param withdrawalRoot Is the hash of the `withdrawal`.
* @param withdrawal Is the withdrawal itself.
*/
event WithdrawalQueued(bytes32 withdrawalRoot, Withdrawal withdrawal);
/// @notice Emitted when a queued withdrawal is completed
event WithdrawalCompleted(bytes32 withdrawalRoot);
/// @notice Emitted when a queued withdrawal is *migrated* from the StrategyManager to the DelegationManager
event WithdrawalMigrated(bytes32 oldWithdrawalRoot, bytes32 newWithdrawalRoot);
/// @notice Emitted when the `minWithdrawalDelayBlocks` variable is modified from `previousValue` to `newValue`.
event MinWithdrawalDelayBlocksSet(uint256 previousValue, uint256 newValue);
/// @notice Emitted when the `strategyWithdrawalDelayBlocks` variable is modified from `previousValue` to `newValue`.
event StrategyWithdrawalDelayBlocksSet(IStrategy strategy, uint256 previousValue, uint256 newValue);
/**
* @notice Registers the caller as an operator in EigenLayer.
* @param registeringOperatorDetails is the `OperatorDetails` for the operator.
* @param metadataURI is a URI for the operator's metadata, i.e. a link providing more details on the operator.
*
* @dev Once an operator is registered, they cannot 'deregister' as an operator, and they will forever be considered "delegated to themself".
* @dev This function will revert if the caller attempts to set their `earningsReceiver` to address(0).
* @dev Note that the `metadataURI` is *never stored * and is only emitted in the `OperatorMetadataURIUpdated` event
*/
function registerAsOperator(
OperatorDetails calldata registeringOperatorDetails,
string calldata metadataURI
) external;
/**
* @notice Updates an operator's stored `OperatorDetails`.
* @param newOperatorDetails is the updated `OperatorDetails` for the operator, to replace their current OperatorDetails`.
*
* @dev The caller must have previously registered as an operator in EigenLayer.
* @dev This function will revert if the caller attempts to set their `earningsReceiver` to address(0).
*/
function modifyOperatorDetails(OperatorDetails calldata newOperatorDetails) external;
/**
* @notice Called by an operator to emit an `OperatorMetadataURIUpdated` event indicating the information has updated.
* @param metadataURI The URI for metadata associated with an operator
* @dev Note that the `metadataURI` is *never stored * and is only emitted in the `OperatorMetadataURIUpdated` event
*/
function updateOperatorMetadataURI(string calldata metadataURI) external;
/**
* @notice Caller delegates their stake to an operator.
* @param operator The account (`msg.sender`) is delegating its assets to for use in serving applications built on EigenLayer.
* @param approverSignatureAndExpiry Verifies the operator approves of this delegation
* @param approverSalt A unique single use value tied to an individual signature.
* @dev The approverSignatureAndExpiry is used in the event that:
* 1) the operator's `delegationApprover` address is set to a non-zero value.
* AND
* 2) neither the operator nor their `delegationApprover` is the `msg.sender`, since in the event that the operator
* or their delegationApprover is the `msg.sender`, then approval is assumed.
* @dev In the event that `approverSignatureAndExpiry` is not checked, its content is ignored entirely; it's recommended to use an empty input
* in this case to save on complexity + gas costs
*/
function delegateTo(
address operator,
SignatureWithExpiry memory approverSignatureAndExpiry,
bytes32 approverSalt
) external;
/**
* @notice Caller delegates a staker's stake to an operator with valid signatures from both parties.
* @param staker The account delegating stake to an `operator` account
* @param operator The account (`staker`) is delegating its assets to for use in serving applications built on EigenLayer.
* @param stakerSignatureAndExpiry Signed data from the staker authorizing delegating stake to an operator
* @param approverSignatureAndExpiry is a parameter that will be used for verifying that the operator approves of this delegation action in the event that:
* @param approverSalt Is a salt used to help guarantee signature uniqueness. Each salt can only be used once by a given approver.
*
* @dev If `staker` is an EOA, then `stakerSignature` is verified to be a valid ECDSA stakerSignature from `staker`, indicating their intention for this action.
* @dev If `staker` is a contract, then `stakerSignature` will be checked according to EIP-1271.
* @dev the operator's `delegationApprover` address is set to a non-zero value.
* @dev neither the operator nor their `delegationApprover` is the `msg.sender`, since in the event that the operator or their delegationApprover
* is the `msg.sender`, then approval is assumed.
* @dev This function will revert if the current `block.timestamp` is equal to or exceeds the expiry
* @dev In the case that `approverSignatureAndExpiry` is not checked, its content is ignored entirely; it's recommended to use an empty input
* in this case to save on complexity + gas costs
*/
function delegateToBySignature(
address staker,
address operator,
SignatureWithExpiry memory stakerSignatureAndExpiry,
SignatureWithExpiry memory approverSignatureAndExpiry,
bytes32 approverSalt
) external;
/**
* @notice Undelegates the staker from the operator who they are delegated to. Puts the staker into the "undelegation limbo" mode of the EigenPodManager
* and queues a withdrawal of all of the staker's shares in the StrategyManager (to the staker), if necessary.
* @param staker The account to be undelegated.
* @return withdrawalRoot The root of the newly queued withdrawal, if a withdrawal was queued. Otherwise just bytes32(0).
*
* @dev Reverts if the `staker` is also an operator, since operators are not allowed to undelegate from themselves.
* @dev Reverts if the caller is not the staker, nor the operator who the staker is delegated to, nor the operator's specified "delegationApprover"
* @dev Reverts if the `staker` is already undelegated.
*/
function undelegate(address staker) external returns (bytes32[] memory withdrawalRoot);
/**
* Allows a staker to withdraw some shares. Withdrawn shares/strategies are immediately removed
* from the staker. If the staker is delegated, withdrawn shares/strategies are also removed from
* their operator.
*
* All withdrawn shares/strategies are placed in a queue and can be fully withdrawn after a delay.
*/
function queueWithdrawals(
QueuedWithdrawalParams[] calldata queuedWithdrawalParams
) external returns (bytes32[] memory);
/**
* @notice Used to complete the specified `withdrawal`. The caller must match `withdrawal.withdrawer`
* @param withdrawal The Withdrawal to complete.
* @param tokens Array in which the i-th entry specifies the `token` input to the 'withdraw' function of the i-th Strategy in the `withdrawal.strategies` array.
* This input can be provided with zero length if `receiveAsTokens` is set to 'false' (since in that case, this input will be unused)
* @param middlewareTimesIndex is the index in the operator that the staker who triggered the withdrawal was delegated to's middleware times array
* @param receiveAsTokens If true, the shares specified in the withdrawal will be withdrawn from the specified strategies themselves
* and sent to the caller, through calls to `withdrawal.strategies[i].withdraw`. If false, then the shares in the specified strategies
* will simply be transferred to the caller directly.
* @dev middlewareTimesIndex should be calculated off chain before calling this function by finding the first index that satisfies `slasher.canWithdraw`
* @dev beaconChainETHStrategy shares are non-transferrable, so if `receiveAsTokens = false` and `withdrawal.withdrawer != withdrawal.staker`, note that
* any beaconChainETHStrategy shares in the `withdrawal` will be _returned to the staker_, rather than transferred to the withdrawer, unlike shares in
* any other strategies, which will be transferred to the withdrawer.
*/
function completeQueuedWithdrawal(
Withdrawal calldata withdrawal,
IERC20[] calldata tokens,
uint256 middlewareTimesIndex,
bool receiveAsTokens
) external;
/**
* @notice Array-ified version of `completeQueuedWithdrawal`.
* Used to complete the specified `withdrawals`. The function caller must match `withdrawals[...].withdrawer`
* @param withdrawals The Withdrawals to complete.
* @param tokens Array of tokens for each Withdrawal. See `completeQueuedWithdrawal` for the usage of a single array.
* @param middlewareTimesIndexes One index to reference per Withdrawal. See `completeQueuedWithdrawal` for the usage of a single index.
* @param receiveAsTokens Whether or not to complete each withdrawal as tokens. See `completeQueuedWithdrawal` for the usage of a single boolean.
* @dev See `completeQueuedWithdrawal` for relevant dev tags
*/
function completeQueuedWithdrawals(
Withdrawal[] calldata withdrawals,
IERC20[][] calldata tokens,
uint256[] calldata middlewareTimesIndexes,
bool[] calldata receiveAsTokens
) external;
/**
* @notice Increases a staker's delegated share balance in a strategy.
* @param staker The address to increase the delegated shares for their operator.
* @param strategy The strategy in which to increase the delegated shares.
* @param shares The number of shares to increase.
*
* @dev *If the staker is actively delegated*, then increases the `staker`'s delegated shares in `strategy` by `shares`. Otherwise does nothing.
* @dev Callable only by the StrategyManager or EigenPodManager.
*/
function increaseDelegatedShares(
address staker,
IStrategy strategy,
uint256 shares
) external;
/**
* @notice Decreases a staker's delegated share balance in a strategy.
* @param staker The address to increase the delegated shares for their operator.
* @param strategy The strategy in which to decrease the delegated shares.
* @param shares The number of shares to decrease.
*
* @dev *If the staker is actively delegated*, then decreases the `staker`'s delegated shares in `strategy` by `shares`. Otherwise does nothing.
* @dev Callable only by the StrategyManager or EigenPodManager.
*/
function decreaseDelegatedShares(
address staker,
IStrategy strategy,
uint256 shares
) external;
/**
* @notice returns the address of the operator that `staker` is delegated to.
* @notice Mapping: staker => operator whom the staker is currently delegated to.
* @dev Note that returning address(0) indicates that the staker is not actively delegated to any operator.
*/
function delegatedTo(address staker) external view returns (address);
/**
* @notice Returns the OperatorDetails struct associated with an `operator`.
*/
function operatorDetails(address operator) external view returns (OperatorDetails memory);
/*
* @notice Returns the earnings receiver address for an operator
*/
function earningsReceiver(address operator) external view returns (address);
/**
* @notice Returns the delegationApprover account for an operator
*/
function delegationApprover(address operator) external view returns (address);
/**
* @notice Returns the stakerOptOutWindowBlocks for an operator
*/
function stakerOptOutWindowBlocks(address operator) external view returns (uint256);
/**
* @notice Given array of strategies, returns array of shares for the operator
*/
function getOperatorShares(
address operator,
IStrategy[] memory strategies
) external view returns (uint256[] memory);
/**
* @notice Given a list of strategies, return the minimum number of blocks that must pass to withdraw
* from all the inputted strategies. Return value is >= minWithdrawalDelayBlocks as this is the global min withdrawal delay.
* @param strategies The strategies to check withdrawal delays for
*/
function getWithdrawalDelay(IStrategy[] calldata strategies) external view returns (uint256);
/**
* @notice returns the total number of shares in `strategy` that are delegated to `operator`.
* @notice Mapping: operator => strategy => total number of shares in the strategy delegated to the operator.
* @dev By design, the following invariant should hold for each Strategy:
* (operator's shares in delegation manager) = sum (shares above zero of all stakers delegated to operator)
* = sum (delegateable shares of all stakers delegated to the operator)
*/
function operatorShares(address operator, IStrategy strategy) external view returns (uint256);
/**
* @notice Returns 'true' if `staker` *is* actively delegated, and 'false' otherwise.
*/
function isDelegated(address staker) external view returns (bool);
/**
* @notice Returns true is an operator has previously registered for delegation.
*/
function isOperator(address operator) external view returns (bool);
/// @notice Mapping: staker => number of signed delegation nonces (used in `delegateToBySignature`) from the staker that the contract has already checked
function stakerNonce(address staker) external view returns (uint256);
/**
* @notice Mapping: delegationApprover => 32-byte salt => whether or not the salt has already been used by the delegationApprover.
* @dev Salts are used in the `delegateTo` and `delegateToBySignature` functions. Note that these functions only process the delegationApprover's
* signature + the provided salt if the operator being delegated to has specified a nonzero address as their `delegationApprover`.
*/
function delegationApproverSaltIsSpent(address _delegationApprover, bytes32 salt) external view returns (bool);
/**
* @notice Minimum delay enforced by this contract for completing queued withdrawals. Measured in blocks, and adjustable by this contract's owner,
* up to a maximum of `MAX_WITHDRAWAL_DELAY_BLOCKS`. Minimum value is 0 (i.e. no delay enforced).
* Note that strategies each have a separate withdrawal delay, which can be greater than this value. So the minimum number of blocks that must pass
* to withdraw a strategy is MAX(minWithdrawalDelayBlocks, strategyWithdrawalDelayBlocks[strategy])
*/
function minWithdrawalDelayBlocks() external view returns (uint256);
/**
* @notice Minimum delay enforced by this contract per Strategy for completing queued withdrawals. Measured in blocks, and adjustable by this contract's owner,
* up to a maximum of `MAX_WITHDRAWAL_DELAY_BLOCKS`. Minimum value is 0 (i.e. no delay enforced).
*/
function strategyWithdrawalDelayBlocks(IStrategy strategy) external view returns (uint256);
/**
* @notice Calculates the digestHash for a `staker` to sign to delegate to an `operator`
* @param staker The signing staker
* @param operator The operator who is being delegated to
* @param expiry The desired expiry time of the staker's signature
*/
function calculateCurrentStakerDelegationDigestHash(
address staker,
address operator,
uint256 expiry
) external view returns (bytes32);
/**
* @notice Calculates the digest hash to be signed and used in the `delegateToBySignature` function
* @param staker The signing staker
* @param _stakerNonce The nonce of the staker. In practice we use the staker's current nonce, stored at `stakerNonce[staker]`
* @param operator The operator who is being delegated to
* @param expiry The desired expiry time of the staker's signature
*/
function calculateStakerDelegationDigestHash(
address staker,
uint256 _stakerNonce,
address operator,
uint256 expiry
) external view returns (bytes32);
/**
* @notice Calculates the digest hash to be signed by the operator's delegationApprove and used in the `delegateTo` and `delegateToBySignature` functions.
* @param staker The account delegating their stake
* @param operator The account receiving delegated stake
* @param _delegationApprover the operator's `delegationApprover` who will be signing the delegationHash (in general)
* @param approverSalt A unique and single use value associated with the approver signature.
* @param expiry Time after which the approver's signature becomes invalid
*/
function calculateDelegationApprovalDigestHash(
address staker,
address operator,
address _delegationApprover,
bytes32 approverSalt,
uint256 expiry
) external view returns (bytes32);
/// @notice The EIP-712 typehash for the contract's domain
function DOMAIN_TYPEHASH() external view returns (bytes32);
/// @notice The EIP-712 typehash for the StakerDelegation struct used by the contract
function STAKER_DELEGATION_TYPEHASH() external view returns (bytes32);
/// @notice The EIP-712 typehash for the DelegationApproval struct used by the contract
function DELEGATION_APPROVAL_TYPEHASH() external view returns (bytes32);
/**
* @notice Getter function for the current EIP-712 domain separator for this contract.
*
* @dev The domain separator will change in the event of a fork that changes the ChainID.
* @dev By introducing a domain separator the DApp developers are guaranteed that there can be no signature collision.
* for more detailed information please read EIP-712.
*/
function domainSeparator() external view returns (bytes32);
/// @notice Mapping: staker => cumulative number of queued withdrawals they have ever initiated.
/// @dev This only increments (doesn't decrement), and is used to help ensure that otherwise identical withdrawals have unique hashes.
function cumulativeWithdrawalsQueued(address staker) external view returns (uint256);
/// @notice Returns the keccak256 hash of `withdrawal`.
function calculateWithdrawalRoot(Withdrawal memory withdrawal) external pure returns (bytes32);
function migrateQueuedWithdrawals(IStrategyManager.DeprecatedStruct_QueuedWithdrawal[] memory withdrawalsToQueue) external;
function pendingWithdrawals(bytes32 withdrawalRoot) external view returns (bool);
function beaconChainETHStrategy() external view returns (IStrategy);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.5.0;
interface IDelayedWithdrawalRouter {
// struct used to pack data into a single storage slot
struct DelayedWithdrawal {
uint224 amount;
uint32 blockCreated;
}
// struct used to store a single users delayedWithdrawal data
struct UserDelayedWithdrawals {
uint256 delayedWithdrawalsCompleted;
DelayedWithdrawal[] delayedWithdrawals;
}
/// @notice event for delayedWithdrawal creation
event DelayedWithdrawalCreated(address podOwner, address recipient, uint256 amount, uint256 index);
/// @notice event for the claiming of delayedWithdrawals
event DelayedWithdrawalsClaimed(address recipient, uint256 amountClaimed, uint256 delayedWithdrawalsCompleted);
/// @notice Emitted when the `withdrawalDelayBlocks` variable is modified from `previousValue` to `newValue`.
event WithdrawalDelayBlocksSet(uint256 previousValue, uint256 newValue);
/**
* @notice Creates an delayed withdrawal for `msg.value` to the `recipient`.
* @dev Only callable by the `podOwner`'s EigenPod contract.
*/
function createDelayedWithdrawal(address podOwner, address recipient) external payable;
/**
* @notice Called in order to withdraw delayed withdrawals made to the `recipient` that have passed the `withdrawalDelayBlocks` period.
* @param recipient The address to claim delayedWithdrawals for.
* @param maxNumberOfWithdrawalsToClaim Used to limit the maximum number of withdrawals to loop through claiming.
*/
function claimDelayedWithdrawals(address recipient, uint256 maxNumberOfWithdrawalsToClaim) external;
/**
* @notice Called in order to withdraw delayed withdrawals made to the caller that have passed the `withdrawalDelayBlocks` period.
* @param maxNumberOfWithdrawalsToClaim Used to limit the maximum number of withdrawals to loop through claiming.
*/
function claimDelayedWithdrawals(uint256 maxNumberOfWithdrawalsToClaim) external;
/// @notice Owner-only function for modifying the value of the `withdrawalDelayBlocks` variable.
function setWithdrawalDelayBlocks(uint256 newValue) external;
/// @notice Getter function for the mapping `_userWithdrawals`
function userWithdrawals(address user) external view returns (UserDelayedWithdrawals memory);
/// @notice Getter function to get all delayedWithdrawals of the `user`
function getUserDelayedWithdrawals(address user) external view returns (DelayedWithdrawal[] memory);
/// @notice Getter function to get all delayedWithdrawals that are currently claimable by the `user`
function getClaimableUserDelayedWithdrawals(address user) external view returns (DelayedWithdrawal[] memory);
/// @notice Getter function for fetching the delayedWithdrawal at the `index`th entry from the `_userWithdrawals[user].delayedWithdrawals` array
function userDelayedWithdrawalByIndex(address user, uint256 index) external view returns (DelayedWithdrawal memory);
/// @notice Getter function for fetching the length of the delayedWithdrawals array of a specific user
function userWithdrawalsLength(address user) external view returns (uint256);
/// @notice Convenience function for checking whether or not the delayedWithdrawal at the `index`th entry from the `_userWithdrawals[user].delayedWithdrawals` array is currently claimable
function canClaimDelayedWithdrawal(address user, uint256 index) external view returns (bool);
/**
* @notice Delay enforced by this contract for completing any delayedWithdrawal. Measured in blocks, and adjustable by this contract's owner,
* up to a maximum of `MAX_WITHDRAWAL_DELAY_BLOCKS`. Minimum value is 0 (i.e. no delay enforced).
*/
function withdrawalDelayBlocks() external view returns (uint256);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165Upgradeable.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721Upgradeable is IERC165Upgradeable {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.5.0;
import "./IStrategy.sol";
import "./ISlasher.sol";
import "./IDelegationManager.sol";
import "./IEigenPodManager.sol";
/**
* @title Interface for the primary entrypoint for funds into EigenLayer.
* @author Layr Labs, Inc.
* @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
* @notice See the `StrategyManager` contract itself for implementation details.
*/
interface IStrategyManager {
/**
* @notice Emitted when a new deposit occurs on behalf of `staker`.
* @param staker Is the staker who is depositing funds into EigenLayer.
* @param strategy Is the strategy that `staker` has deposited into.
* @param token Is the token that `staker` deposited.
* @param shares Is the number of new shares `staker` has been granted in `strategy`.
*/
event Deposit(address staker, IERC20 token, IStrategy strategy, uint256 shares);
/// @notice Emitted when `thirdPartyTransfersForbidden` is updated for a strategy and value by the owner
event UpdatedThirdPartyTransfersForbidden(IStrategy strategy, bool value);
/// @notice Emitted when the `strategyWhitelister` is changed
event StrategyWhitelisterChanged(address previousAddress, address newAddress);
/// @notice Emitted when a strategy is added to the approved list of strategies for deposit
event StrategyAddedToDepositWhitelist(IStrategy strategy);
/// @notice Emitted when a strategy is removed from the approved list of strategies for deposit
event StrategyRemovedFromDepositWhitelist(IStrategy strategy);
/**
* @notice Deposits `amount` of `token` into the specified `strategy`, with the resultant shares credited to `msg.sender`
* @param strategy is the specified strategy where deposit is to be made,
* @param token is the denomination in which the deposit is to be made,
* @param amount is the amount of token to be deposited in the strategy by the staker
* @return shares The amount of new shares in the `strategy` created as part of the action.
* @dev The `msg.sender` must have previously approved this contract to transfer at least `amount` of `token` on their behalf.
* @dev Cannot be called by an address that is 'frozen' (this function will revert if the `msg.sender` is frozen).
*
* WARNING: Depositing tokens that allow reentrancy (eg. ERC-777) into a strategy is not recommended. This can lead to attack vectors
* where the token balance and corresponding strategy shares are not in sync upon reentrancy.
*/
function depositIntoStrategy(IStrategy strategy, IERC20 token, uint256 amount) external returns (uint256 shares);
/**
* @notice Used for depositing an asset into the specified strategy with the resultant shares credited to `staker`,
* who must sign off on the action.
* Note that the assets are transferred out/from the `msg.sender`, not from the `staker`; this function is explicitly designed
* purely to help one address deposit 'for' another.
* @param strategy is the specified strategy where deposit is to be made,
* @param token is the denomination in which the deposit is to be made,
* @param amount is the amount of token to be deposited in the strategy by the staker
* @param staker the staker that the deposited assets will be credited to
* @param expiry the timestamp at which the signature expires
* @param signature is a valid signature from the `staker`. either an ECDSA signature if the `staker` is an EOA, or data to forward
* following EIP-1271 if the `staker` is a contract
* @return shares The amount of new shares in the `strategy` created as part of the action.
* @dev The `msg.sender` must have previously approved this contract to transfer at least `amount` of `token` on their behalf.
* @dev A signature is required for this function to eliminate the possibility of griefing attacks, specifically those
* targeting stakers who may be attempting to undelegate.
* @dev Cannot be called if thirdPartyTransfersForbidden is set to true for this strategy
*
* WARNING: Depositing tokens that allow reentrancy (eg. ERC-777) into a strategy is not recommended. This can lead to attack vectors
* where the token balance and corresponding strategy shares are not in sync upon reentrancy
*/
function depositIntoStrategyWithSignature(
IStrategy strategy,
IERC20 token,
uint256 amount,
address staker,
uint256 expiry,
bytes memory signature
) external returns (uint256 shares);
/// @notice Used by the DelegationManager to remove a Staker's shares from a particular strategy when entering the withdrawal queue
function removeShares(address staker, IStrategy strategy, uint256 shares) external;
/// @notice Used by the DelegationManager to award a Staker some shares that have passed through the withdrawal queue
function addShares(address staker, IERC20 token, IStrategy strategy, uint256 shares) external;
/// @notice Used by the DelegationManager to convert withdrawn shares to tokens and send them to a recipient
function withdrawSharesAsTokens(address recipient, IStrategy strategy, uint256 shares, IERC20 token) external;
/// @notice Returns the current shares of `user` in `strategy`
function stakerStrategyShares(address user, IStrategy strategy) external view returns (uint256 shares);
/**
* @notice Get all details on the staker's deposits and corresponding shares
* @return (staker's strategies, shares in these strategies)
*/
function getDeposits(address staker) external view returns (IStrategy[] memory, uint256[] memory);
/// @notice Simple getter function that returns `stakerStrategyList[staker].length`.
function stakerStrategyListLength(address staker) external view returns (uint256);
/**
* @notice Owner-only function that adds the provided Strategies to the 'whitelist' of strategies that stakers can deposit into
* @param strategiesToWhitelist Strategies that will be added to the `strategyIsWhitelistedForDeposit` mapping (if they aren't in it already)
* @param thirdPartyTransfersForbiddenValues bool values to set `thirdPartyTransfersForbidden` to for each strategy
*/
function addStrategiesToDepositWhitelist(
IStrategy[] calldata strategiesToWhitelist,
bool[] calldata thirdPartyTransfersForbiddenValues
) external;
/**
* @notice Owner-only function that removes the provided Strategies from the 'whitelist' of strategies that stakers can deposit into
* @param strategiesToRemoveFromWhitelist Strategies that will be removed to the `strategyIsWhitelistedForDeposit` mapping (if they are in it)
*/
function removeStrategiesFromDepositWhitelist(IStrategy[] calldata strategiesToRemoveFromWhitelist) external;
/// @notice Returns the single, central Delegation contract of EigenLayer
function delegation() external view returns (IDelegationManager);
/// @notice Returns the single, central Slasher contract of EigenLayer
function slasher() external view returns (ISlasher);
/// @notice Returns the EigenPodManager contract of EigenLayer
function eigenPodManager() external view returns (IEigenPodManager);
/// @notice Returns the address of the `strategyWhitelister`
function strategyWhitelister() external view returns (address);
/**
* @notice Returns bool for whether or not `strategy` enables credit transfers. i.e enabling
* depositIntoStrategyWithSignature calls or queueing withdrawals to a different address than the staker.
*/
function thirdPartyTransfersForbidden(IStrategy strategy) external view returns (bool);
// LIMITED BACKWARDS-COMPATIBILITY FOR DEPRECATED FUNCTIONALITY
// packed struct for queued withdrawals; helps deal with stack-too-deep errors
struct DeprecatedStruct_WithdrawerAndNonce {
address withdrawer;
uint96 nonce;
}
/**
* Struct type used to specify an existing queued withdrawal. Rather than storing the entire struct, only a hash is stored.
* In functions that operate on existing queued withdrawals -- e.g. `startQueuedWithdrawalWaitingPeriod` or `completeQueuedWithdrawal`,
* the data is resubmitted and the hash of the submitted data is computed by `calculateWithdrawalRoot` and checked against the
* stored hash in order to confirm the integrity of the submitted data.
*/
struct DeprecatedStruct_QueuedWithdrawal {
IStrategy[] strategies;
uint256[] shares;
address staker;
DeprecatedStruct_WithdrawerAndNonce withdrawerAndNonce;
uint32 withdrawalStartBlock;
address delegatedAddress;
}
function migrateQueuedWithdrawal(DeprecatedStruct_QueuedWithdrawal memory queuedWithdrawal) external returns (bool, bytes32);
function calculateWithdrawalRoot(DeprecatedStruct_QueuedWithdrawal memory queuedWithdrawal) external pure returns (bytes32);
function withdrawalRootPending(bytes32 _withdrawalRoot) external view returns (bool);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.5.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
/**
* @title Minimal interface for an `Strategy` contract.
* @author Layr Labs, Inc.
* @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
* @notice Custom `Strategy` implementations may expand extensively on this interface.
*/
interface IStrategy {
/**
* @notice Used to deposit tokens into this Strategy
* @param token is the ERC20 token being deposited
* @param amount is the amount of token being deposited
* @dev This function is only callable by the strategyManager contract. It is invoked inside of the strategyManager's
* `depositIntoStrategy` function, and individual share balances are recorded in the strategyManager as well.
* @return newShares is the number of new shares issued at the current exchange ratio.
*/
function deposit(IERC20 token, uint256 amount) external returns (uint256);
/**
* @notice Used to withdraw tokens from this Strategy, to the `recipient`'s address
* @param recipient is the address to receive the withdrawn funds
* @param token is the ERC20 token being transferred out
* @param amountShares is the amount of shares being withdrawn
* @dev This function is only callable by the strategyManager contract. It is invoked inside of the strategyManager's
* other functions, and individual share balances are recorded in the strategyManager as well.
*/
function withdraw(address recipient, IERC20 token, uint256 amountShares) external;
/**
* @notice Used to convert a number of shares to the equivalent amount of underlying tokens for this strategy.
* @notice In contrast to `sharesToUnderlyingView`, this function **may** make state modifications
* @param amountShares is the amount of shares to calculate its conversion into the underlying token
* @return The amount of underlying tokens corresponding to the input `amountShares`
* @dev Implementation for these functions in particular may vary significantly for different strategies
*/
function sharesToUnderlying(uint256 amountShares) external returns (uint256);
/**
* @notice Used to convert an amount of underlying tokens to the equivalent amount of shares in this strategy.
* @notice In contrast to `underlyingToSharesView`, this function **may** make state modifications
* @param amountUnderlying is the amount of `underlyingToken` to calculate its conversion into strategy shares
* @return The amount of underlying tokens corresponding to the input `amountShares`
* @dev Implementation for these functions in particular may vary significantly for different strategies
*/
function underlyingToShares(uint256 amountUnderlying) external returns (uint256);
/**
* @notice convenience function for fetching the current underlying value of all of the `user`'s shares in
* this strategy. In contrast to `userUnderlyingView`, this function **may** make state modifications
*/
function userUnderlying(address user) external returns (uint256);
/**
* @notice convenience function for fetching the current total shares of `user` in this strategy, by
* querying the `strategyManager` contract
*/
function shares(address user) external view returns (uint256);
/**
* @notice Used to convert a number of shares to the equivalent amount of underlying tokens for this strategy.
* @notice In contrast to `sharesToUnderlying`, this function guarantees no state modifications
* @param amountShares is the amount of shares to calculate its conversion into the underlying token
* @return The amount of shares corresponding to the input `amountUnderlying`
* @dev Implementation for these functions in particular may vary significantly for different strategies
*/
function sharesToUnderlyingView(uint256 amountShares) external view returns (uint256);
/**
* @notice Used to convert an amount of underlying tokens to the equivalent amount of shares in this strategy.
* @notice In contrast to `underlyingToShares`, this function guarantees no state modifications
* @param amountUnderlying is the amount of `underlyingToken` to calculate its conversion into strategy shares
* @return The amount of shares corresponding to the input `amountUnderlying`
* @dev Implementation for these functions in particular may vary significantly for different strategies
*/
function underlyingToSharesView(uint256 amountUnderlying) external view returns (uint256);
/**
* @notice convenience function for fetching the current underlying value of all of the `user`'s shares in
* this strategy. In contrast to `userUnderlying`, this function guarantees no state modifications
*/
function userUnderlyingView(address user) external view returns (uint256);
/// @notice The underlying token for shares in this Strategy
function underlyingToken() external view returns (IERC20);
/// @notice The total number of extant shares in this Strategy
function totalShares() external view returns (uint256);
/// @notice Returns either a brief string explaining the strategy's goal & purpose, or a link to metadata that explains in more detail.
function explanation() external view returns (string memory);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.5.0;
/**
* @title Interface for the `PauserRegistry` contract.
* @author Layr Labs, Inc.
* @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
*/
interface IPauserRegistry {
event PauserStatusChanged(address pauser, bool canPause);
event UnpauserChanged(address previousUnpauser, address newUnpauser);
/// @notice Mapping of addresses to whether they hold the pauser role.
function isPauser(address pauser) external view returns (bool);
/// @notice Unique address that holds the unpauser role. Capable of changing *both* the pauser and unpauser addresses.
function unpauser() external view returns (address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (access/Ownable2Step.sol)
pragma solidity ^0.8.0;
import "./OwnableUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which provides access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership} and {acceptOwnership}.
*
* This module is used through inheritance. It will make available all functions
* from parent (Ownable).
*/
abstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable {
function __Ownable2Step_init() internal onlyInitializing {
__Ownable_init_unchained();
}
function __Ownable2Step_init_unchained() internal onlyInitializing {
}
address private _pendingOwner;
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
/**
* @dev Returns the address of the pending owner.
*/
function pendingOwner() public view virtual returns (address) {
return _pendingOwner;
}
/**
* @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual override onlyOwner {
_pendingOwner = newOwner;
emit OwnershipTransferStarted(owner(), newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual override {
delete _pendingOwner;
super._transferOwnership(newOwner);
}
/**
* @dev The new owner accepts the ownership transfer.
*/
function acceptOwnership() external {
address sender = _msgSender();
require(pendingOwner() == sender, "Ownable2Step: caller is not the new owner");
_transferOwnership(sender);
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
/// @notice Enumerable multiroles authorization mixin.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/auth/EnumerableRoles.sol)
///
/// @dev Note:
/// This implementation is agnostic to the Ownable that the contract inherits from.
/// It performs a self-staticcall to the `owner()` function to determine the owner.
/// This is useful for situations where the contract inherits from
/// OpenZeppelin's Ownable, such as in LayerZero's OApp contracts.
///
/// This implementation performs a self-staticcall to `MAX_ROLE()` to determine
/// the maximum role that can be set/unset. If the inheriting contract does not
/// have `MAX_ROLE()`, then any role can be set/unset.
///
/// This implementation allows for any uint256 role,
/// it does NOT take in a bitmask of roles.
/// This is to accommodate teams that are allergic to bitwise flags.
///
/// By default, the `owner()` is the only account that is authorized to set roles.
/// This behavior can be changed via overrides.
///
/// This implementation is compatible with any Ownable.
/// This implementation is NOT compatible with OwnableRoles.
abstract contract EnumerableRoles {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* EVENTS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev The status of `role` for `holder` has been set to `active`.
event RoleSet(address indexed holder, uint256 indexed role, bool indexed active);
/// @dev `keccak256(bytes("RoleSet(address,uint256,bool)"))`.
uint256 private constant _ROLE_SET_EVENT_SIGNATURE =
0xaddc47d7e02c95c00ec667676636d772a589ffbf0663cfd7cd4dd3d4758201b8;
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CUSTOM ERRORS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev The index is out of bounds of the role holders array.
error RoleHoldersIndexOutOfBounds();
/// @dev Cannot set the role of the zero address.
error RoleHolderIsZeroAddress();
/// @dev The role has exceeded the maximum role.
error InvalidRole();
/// @dev Unauthorized to perform the action.
error EnumerableRolesUnauthorized();
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* STORAGE */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev The storage layout of the holders enumerable mapping is given by:
/// ```
/// mstore(0x18, holder)
/// mstore(0x04, _ENUMERABLE_ROLES_SLOT_SEED)
/// mstore(0x00, role)
/// let rootSlot := keccak256(0x00, 0x24)
/// let positionSlot := keccak256(0x00, 0x38)
/// let holderSlot := add(rootSlot, sload(positionSlot))
/// let holderInStorage := shr(96, sload(holderSlot))
/// let length := shr(160, shl(160, sload(rootSlot)))
/// ```
uint256 private constant _ENUMERABLE_ROLES_SLOT_SEED = 0xee9853bb;
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* PUBLIC UPDATE FUNCTIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Sets the status of `role` of `holder` to `active`.
function setRole(address holder, uint256 role, bool active) public payable virtual {
_authorizeSetRole(holder, role, active);
_setRole(holder, role, active);
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* PUBLIC READ FUNCTIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Returns if `holder` has active `role`.
function hasRole(address holder, uint256 role) public view virtual returns (bool result) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x18, holder)
mstore(0x04, _ENUMERABLE_ROLES_SLOT_SEED)
mstore(0x00, role)
result := iszero(iszero(sload(keccak256(0x00, 0x38))))
}
}
/// @dev Returns an array of the holders of `role`.
function roleHolders(uint256 role) public view virtual returns (address[] memory result) {
/// @solidity memory-safe-assembly
assembly {
result := mload(0x40)
mstore(0x04, _ENUMERABLE_ROLES_SLOT_SEED)
mstore(0x00, role)
let rootSlot := keccak256(0x00, 0x24)
let rootPacked := sload(rootSlot)
let n := shr(160, shl(160, rootPacked))
let o := add(0x20, result)
mstore(o, shr(96, rootPacked))
for { let i := 1 } lt(i, n) { i := add(i, 1) } {
mstore(add(o, shl(5, i)), shr(96, sload(add(rootSlot, i))))
}
mstore(result, n)
mstore(0x40, add(o, shl(5, n)))
}
}
/// @dev Returns the total number of holders of `role`.
function roleHolderCount(uint256 role) public view virtual returns (uint256 result) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x04, _ENUMERABLE_ROLES_SLOT_SEED)
mstore(0x00, role)
result := shr(160, shl(160, sload(keccak256(0x00, 0x24))))
}
}
/// @dev Returns the holder of `role` at the index `i`.
function roleHolderAt(uint256 role, uint256 i) public view virtual returns (address result) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x04, _ENUMERABLE_ROLES_SLOT_SEED)
mstore(0x00, role)
let rootSlot := keccak256(0x00, 0x24)
let rootPacked := sload(rootSlot)
if iszero(lt(i, shr(160, shl(160, rootPacked)))) {
mstore(0x00, 0x5694da8e) // `RoleHoldersIndexOutOfBounds()`.
revert(0x1c, 0x04)
}
result := shr(96, rootPacked)
if i { result := shr(96, sload(add(rootSlot, i))) }
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* INTERNAL FUNCTIONS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Set the role for holder directly without authorization guard.
function _setRole(address holder, uint256 role, bool active) internal virtual {
_validateRole(role);
/// @solidity memory-safe-assembly
assembly {
let holder_ := shl(96, holder)
if iszero(holder_) {
mstore(0x00, 0x82550143) // `RoleHolderIsZeroAddress()`.
revert(0x1c, 0x04)
}
mstore(0x18, holder)
mstore(0x04, _ENUMERABLE_ROLES_SLOT_SEED)
mstore(0x00, role)
let rootSlot := keccak256(0x00, 0x24)
let n := shr(160, shl(160, sload(rootSlot)))
let positionSlot := keccak256(0x00, 0x38)
let position := sload(positionSlot)
for {} 1 {} {
if iszero(active) {
if iszero(position) { break }
let nSub := sub(n, 1)
if iszero(eq(sub(position, 1), nSub)) {
let lastHolder_ := shl(96, shr(96, sload(add(rootSlot, nSub))))
sstore(add(rootSlot, sub(position, 1)), lastHolder_)
sstore(add(rootSlot, nSub), 0)
mstore(0x24, lastHolder_)
sstore(keccak256(0x00, 0x38), position)
}
sstore(rootSlot, or(shl(96, shr(96, sload(rootSlot))), nSub))
sstore(positionSlot, 0)
break
}
if iszero(position) {
sstore(add(rootSlot, n), holder_)
sstore(positionSlot, add(n, 1))
sstore(rootSlot, add(sload(rootSlot), 1))
}
break
}
// forgefmt: disable-next-item
log4(0x00, 0x00, _ROLE_SET_EVENT_SIGNATURE, shr(96, holder_), role, iszero(iszero(active)))
}
}
/// @dev Requires the role is not greater than `MAX_ROLE()`.
/// If `MAX_ROLE()` is not implemented, this is an no-op.
function _validateRole(uint256 role) internal view virtual {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, 0xd24f19d5) // `MAX_ROLE()`.
if and(
and(gt(role, mload(0x00)), gt(returndatasize(), 0x1f)),
staticcall(gas(), address(), 0x1c, 0x04, 0x00, 0x20)
) {
mstore(0x00, 0xd954416a) // `InvalidRole()`.
revert(0x1c, 0x04)
}
}
}
/// @dev Checks that the caller is authorized to set the role.
function _authorizeSetRole(address holder, uint256 role, bool active) internal virtual {
if (!_enumerableRolesSenderIsContractOwner()) _revertEnumerableRolesUnauthorized();
// Silence compiler warning on unused variables.
(holder, role, active) = (holder, role, active);
}
/// @dev Returns if `holder` has any roles in `encodedRoles`.
/// `encodedRoles` is `abi.encode(SAMPLE_ROLE_0, SAMPLE_ROLE_1, ...)`.
function _hasAnyRoles(address holder, bytes memory encodedRoles)
internal
view
virtual
returns (bool result)
{
/// @solidity memory-safe-assembly
assembly {
mstore(0x18, holder)
mstore(0x04, _ENUMERABLE_ROLES_SLOT_SEED)
let end := add(encodedRoles, shl(5, shr(5, mload(encodedRoles))))
for {} lt(result, lt(encodedRoles, end)) {} {
encodedRoles := add(0x20, encodedRoles)
mstore(0x00, mload(encodedRoles))
result := sload(keccak256(0x00, 0x38))
}
result := iszero(iszero(result))
}
}
/// @dev Reverts if `msg.sender` does not have `role`.
function _checkRole(uint256 role) internal view virtual {
if (!hasRole(msg.sender, role)) _revertEnumerableRolesUnauthorized();
}
/// @dev Reverts if `msg.sender` does not have any role in `encodedRoles`.
function _checkRoles(bytes memory encodedRoles) internal view virtual {
if (!_hasAnyRoles(msg.sender, encodedRoles)) _revertEnumerableRolesUnauthorized();
}
/// @dev Reverts if `msg.sender` is not the contract owner and does not have `role`.
function _checkOwnerOrRole(uint256 role) internal view virtual {
if (!_enumerableRolesSenderIsContractOwner()) _checkRole(role);
}
/// @dev Reverts if `msg.sender` is not the contract owner and
/// does not have any role in `encodedRoles`.
function _checkOwnerOrRoles(bytes memory encodedRoles) internal view virtual {
if (!_enumerableRolesSenderIsContractOwner()) _checkRoles(encodedRoles);
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* MODIFIERS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Marks a function as only callable by an account with `role`.
modifier onlyRole(uint256 role) virtual {
_checkRole(role);
_;
}
/// @dev Marks a function as only callable by an account with any role in `encodedRoles`.
/// `encodedRoles` is `abi.encode(SAMPLE_ROLE_0, SAMPLE_ROLE_1, ...)`.
modifier onlyRoles(bytes memory encodedRoles) virtual {
_checkRoles(encodedRoles);
_;
}
/// @dev Marks a function as only callable by the owner or by an account with `role`.
modifier onlyOwnerOrRole(uint256 role) virtual {
_checkOwnerOrRole(role);
_;
}
/// @dev Marks a function as only callable by the owner or
/// by an account with any role in `encodedRoles`.
/// Checks for ownership first, then checks for roles.
/// `encodedRoles` is `abi.encode(SAMPLE_ROLE_0, SAMPLE_ROLE_1, ...)`.
modifier onlyOwnerOrRoles(bytes memory encodedRoles) virtual {
_checkOwnerOrRoles(encodedRoles);
_;
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* PRIVATE HELPERS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Returns if the `msg.sender` is equal to `owner()` on this contract.
/// If the contract does not have `owner()` implemented, returns false.
function _enumerableRolesSenderIsContractOwner() private view returns (bool result) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, 0x8da5cb5b) // `owner()`.
result :=
and(
and(eq(caller(), mload(0x00)), gt(returndatasize(), 0x1f)),
staticcall(gas(), address(), 0x1c, 0x04, 0x00, 0x20)
)
}
}
/// @dev Reverts with `EnumerableRolesUnauthorized()`.
function _revertEnumerableRolesUnauthorized() private pure {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, 0x99152cca) // `EnumerableRolesUnauthorized()`.
revert(0x1c, 0x04)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.0;
/**
* @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.
*
* Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
* all math on `uint256` and `int256` and then downcasting.
*/
library SafeCast {
/**
* @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
*
* _Available since v4.7._
*/
function toUint248(uint256 value) internal pure returns (uint248) {
require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits");
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
*
* _Available since v4.7._
*/
function toUint240(uint256 value) internal pure returns (uint240) {
require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits");
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
*
* _Available since v4.7._
*/
function toUint232(uint256 value) internal pure returns (uint232) {
require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits");
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
*
* _Available since v4.2._
*/
function toUint224(uint256 value) internal pure returns (uint224) {
require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits");
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
*
* _Available since v4.7._
*/
function toUint216(uint256 value) internal pure returns (uint216) {
require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits");
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
*
* _Available since v4.7._
*/
function toUint208(uint256 value) internal pure returns (uint208) {
require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits");
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
*
* _Available since v4.7._
*/
function toUint200(uint256 value) internal pure returns (uint200) {
require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits");
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
*
* _Available since v4.7._
*/
function toUint192(uint256 value) internal pure returns (uint192) {
require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits");
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
*
* _Available since v4.7._
*/
function toUint184(uint256 value) internal pure returns (uint184) {
require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits");
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
*
* _Available since v4.7._
*/
function toUint176(uint256 value) internal pure returns (uint176) {
require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits");
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
*
* _Available since v4.7._
*/
function toUint168(uint256 value) internal pure returns (uint168) {
require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits");
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
*
* _Available since v4.7._
*/
function toUint160(uint256 value) internal pure returns (uint160) {
require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits");
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
*
* _Available since v4.7._
*/
function toUint152(uint256 value) internal pure returns (uint152) {
require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits");
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
*
* _Available since v4.7._
*/
function toUint144(uint256 value) internal pure returns (uint144) {
require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits");
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
*
* _Available since v4.7._
*/
function toUint136(uint256 value) internal pure returns (uint136) {
require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits");
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
*
* _Available since v2.5._
*/
function toUint128(uint256 value) internal pure returns (uint128) {
require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits");
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
*
* _Available since v4.7._
*/
function toUint120(uint256 value) internal pure returns (uint120) {
require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits");
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
*
* _Available since v4.7._
*/
function toUint112(uint256 value) internal pure returns (uint112) {
require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits");
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
*
* _Available since v4.7._
*/
function toUint104(uint256 value) internal pure returns (uint104) {
require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits");
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
*
* _Available since v4.2._
*/
function toUint96(uint256 value) internal pure returns (uint96) {
require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits");
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
*
* _Available since v4.7._
*/
function toUint88(uint256 value) internal pure returns (uint88) {
require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits");
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
*
* _Available since v4.7._
*/
function toUint80(uint256 value) internal pure returns (uint80) {
require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits");
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
*
* _Available since v4.7._
*/
function toUint72(uint256 value) internal pure returns (uint72) {
require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits");
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
*
* _Available since v2.5._
*/
function toUint64(uint256 value) internal pure returns (uint64) {
require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits");
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
*
* _Available since v4.7._
*/
function toUint56(uint256 value) internal pure returns (uint56) {
require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits");
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
*
* _Available since v4.7._
*/
function toUint48(uint256 value) internal pure returns (uint48) {
require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits");
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
*
* _Available since v4.7._
*/
function toUint40(uint256 value) internal pure returns (uint40) {
require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits");
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
*
* _Available since v2.5._
*/
function toUint32(uint256 value) internal pure returns (uint32) {
require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits");
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
*
* _Available since v4.7._
*/
function toUint24(uint256 value) internal pure returns (uint24) {
require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits");
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
*
* _Available since v2.5._
*/
function toUint16(uint256 value) internal pure returns (uint16) {
require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits");
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
*
* _Available since v2.5._
*/
function toUint8(uint256 value) internal pure returns (uint8) {
require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits");
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*
* _Available since v3.0._
*/
function toUint256(int256 value) internal pure returns (uint256) {
require(value >= 0, "SafeCast: value must be positive");
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
*
* _Available since v4.7._
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
require(downcasted == value, "SafeCast: value doesn't fit in 248 bits");
}
/**
* @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
*
* _Available since v4.7._
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
require(downcasted == value, "SafeCast: value doesn't fit in 240 bits");
}
/**
* @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
*
* _Available since v4.7._
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
require(downcasted == value, "SafeCast: value doesn't fit in 232 bits");
}
/**
* @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
*
* _Available since v4.7._
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
require(downcasted == value, "SafeCast: value doesn't fit in 224 bits");
}
/**
* @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
*
* _Available since v4.7._
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
require(downcasted == value, "SafeCast: value doesn't fit in 216 bits");
}
/**
* @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
*
* _Available since v4.7._
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
require(downcasted == value, "SafeCast: value doesn't fit in 208 bits");
}
/**
* @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
*
* _Available since v4.7._
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
require(downcasted == value, "SafeCast: value doesn't fit in 200 bits");
}
/**
* @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
*
* _Available since v4.7._
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
require(downcasted == value, "SafeCast: value doesn't fit in 192 bits");
}
/**
* @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
*
* _Available since v4.7._
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
require(downcasted == value, "SafeCast: value doesn't fit in 184 bits");
}
/**
* @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
*
* _Available since v4.7._
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
require(downcasted == value, "SafeCast: value doesn't fit in 176 bits");
}
/**
* @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
*
* _Available since v4.7._
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
require(downcasted == value, "SafeCast: value doesn't fit in 168 bits");
}
/**
* @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
*
* _Available since v4.7._
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
require(downcasted == value, "SafeCast: value doesn't fit in 160 bits");
}
/**
* @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
*
* _Available since v4.7._
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
require(downcasted == value, "SafeCast: value doesn't fit in 152 bits");
}
/**
* @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
*
* _Available since v4.7._
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
require(downcasted == value, "SafeCast: value doesn't fit in 144 bits");
}
/**
* @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
*
* _Available since v4.7._
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
require(downcasted == value, "SafeCast: value doesn't fit in 136 bits");
}
/**
* @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
*
* _Available since v3.1._
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
require(downcasted == value, "SafeCast: value doesn't fit in 128 bits");
}
/**
* @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
*
* _Available since v4.7._
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
require(downcasted == value, "SafeCast: value doesn't fit in 120 bits");
}
/**
* @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
*
* _Available since v4.7._
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
require(downcasted == value, "SafeCast: value doesn't fit in 112 bits");
}
/**
* @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
*
* _Available since v4.7._
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
require(downcasted == value, "SafeCast: value doesn't fit in 104 bits");
}
/**
* @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
*
* _Available since v4.7._
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
require(downcasted == value, "SafeCast: value doesn't fit in 96 bits");
}
/**
* @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
*
* _Available since v4.7._
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
require(downcasted == value, "SafeCast: value doesn't fit in 88 bits");
}
/**
* @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
*
* _Available since v4.7._
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
require(downcasted == value, "SafeCast: value doesn't fit in 80 bits");
}
/**
* @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
*
* _Available since v4.7._
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
require(downcasted == value, "SafeCast: value doesn't fit in 72 bits");
}
/**
* @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
*
* _Available since v3.1._
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
require(downcasted == value, "SafeCast: value doesn't fit in 64 bits");
}
/**
* @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
*
* _Available since v4.7._
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
require(downcasted == value, "SafeCast: value doesn't fit in 56 bits");
}
/**
* @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
*
* _Available since v4.7._
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
require(downcasted == value, "SafeCast: value doesn't fit in 48 bits");
}
/**
* @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
*
* _Available since v4.7._
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
require(downcasted == value, "SafeCast: value doesn't fit in 40 bits");
}
/**
* @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
*
* _Available since v3.1._
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
require(downcasted == value, "SafeCast: value doesn't fit in 32 bits");
}
/**
* @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
*
* _Available since v4.7._
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
require(downcasted == value, "SafeCast: value doesn't fit in 24 bits");
}
/**
* @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
*
* _Available since v3.1._
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
require(downcasted == value, "SafeCast: value doesn't fit in 16 bits");
}
/**
* @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
*
* _Available since v3.1._
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
require(downcasted == value, "SafeCast: value doesn't fit in 8 bits");
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*
* _Available since v3.0._
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256");
return int256(value);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
import "../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;
uint256 private _status;
function __ReentrancyGuard_init() internal onlyInitializing {
__ReentrancyGuard_init_unchained();
}
function __ReentrancyGuard_init_unchained() internal onlyInitializing {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
function __Pausable_init() internal onlyInitializing {
__Pausable_init_unchained();
}
function __Pausable_init_unchained() internal onlyInitializing {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.sol";
import "../../../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;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @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, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1);
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator,
Rounding rounding
) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10**64) {
value /= 10**64;
result += 64;
}
if (value >= 10**32) {
value /= 10**32;
result += 32;
}
if (value >= 10**16) {
value /= 10**16;
result += 16;
}
if (value >= 10**8) {
value /= 10**8;
result += 8;
}
if (value >= 10**4) {
value /= 10**4;
result += 4;
}
if (value >= 10**2) {
value /= 10**2;
result += 2;
}
if (value >= 10**1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
import "@openzeppelin-upgradeable/contracts/token/ERC20/IERC20Upgradeable.sol";
import "./ILiquidityPool.sol";
import "./IeETH.sol";
interface IWeETH is IERC20Upgradeable {
struct PermitInput {
uint256 value;
uint256 deadline;
uint8 v;
bytes32 r;
bytes32 s;
}
// STATE VARIABLES
function eETH() external view returns (IeETH);
function liquidityPool() external view returns (ILiquidityPool);
function whitelistedSpender(address spender) external view returns (bool);
function blacklistedRecipient(address recipient) external view returns (bool);
// STATE-CHANGING FUNCTIONS
function initialize(address _liquidityPool, address _eETH) external;
function wrap(uint256 _eETHAmount) external returns (uint256);
function wrapWithPermit(uint256 _eETHAmount, ILiquidityPool.PermitInput calldata _permit) external returns (uint256);
function unwrap(uint256 _weETHAmount) external returns (uint256);
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
function setWhitelistedSpender(address[] calldata _spenders, bool _isWhitelisted) external;
function setBlacklistedRecipient(address[] calldata _recipients, bool _isBlacklisted) external;
// GETTER FUNCTIONS
function getWeETHByeETH(uint256 _eETHAmount) external view returns (uint256);
function getEETHByWeETH(uint256 _weETHAmount) external view returns (uint256);
function getRate() external view returns (uint256);
function getImplementation() external view returns (address);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* The BucketLimiter contract is used to limit the rate of some action.
*
* Buckets refill at a constant rate, and have a maximum capacity. Each time
* the consume function is called, the bucket gets depleted by the provided
* amount. If the bucket is empty, the consume function will return false
* and the bucket will not be depleted. Rates are measured in units per
* second.
*
* To limit storage usage to a single slot, the Bucket struct is packed into
* a single word, meaning all fields are uint64.
*
* Examples:
*
* ```sol
* BucketLimiter.Limit storage limit = BucketLimiter.create(100, 1);
* limit.consume(10); // returns true, remaining = 90
* limit.consume(80); // returns true, remaining = 10
* limit.consume(20); // returns false, remaining = 10
* // Wait 10 seconds (10 tokens get refilled)
* limit.consume(20); // returns true, remaining = 0)
* // Increase capacity
* limit.setCapacity(200); // remaining = 0, capacity = 200
* // Increase refill rate
* limit.setRefillRate(2); // remaining = 0, capacity = 200, refillRate = 2
* // Wait 10 seconds (20 tokens get refilled)
* limit.consume(20); // returns true, remaining = 0
* ```
*
* Developers should notice that rate-limits are vulnerable to two attacks:
* 1. Sybil-attacks: Rate limits should typically be global across all user
* accounts, otherwise an attacker can simply create many accounts to
* bypass the rate limit.
* 2. DoS attacks: Rate limits should typically apply to actions with a
* friction such as a fee or a minimum stake time. Otherwise, an
* attacker can simply spam the action to deplete the rate limit.
*/
library BucketLimiter {
struct Limit {
// The maximum capacity of the bucket, in consumable units (eg. tokens)
uint64 capacity;
// The remaining capacity in the bucket, that can be consumed
uint64 remaining;
// The timestamp of the last time the bucket was refilled
uint64 lastRefill;
// The rate at which the bucket refills, in units per second
uint64 refillRate;
}
/*
* Creates a new bucket with the given capacity and refill rate.
*
* @param capacity The maximum capacity of the bucket, in consumable units (eg. tokens)
* @param refillRate The rate at which the bucket refills, in units per second
* @return The created bucket
*/
function create(uint64 capacity, uint64 refillRate) internal view returns (Limit memory) {
return Limit({
capacity: capacity,
remaining: capacity,
lastRefill: uint64(block.timestamp),
refillRate: refillRate
});
}
function canConsume(Limit memory limit, uint64 amount) external view returns (bool) {
_refill(limit);
return limit.remaining >= amount;
}
function consumable(Limit memory limit) external view returns (uint64) {
_refill(limit);
return limit.remaining;
}
/*
* Consumes the given amount from the bucket, if there is sufficient capacity, and returns
* whether the bucket had enough remaining capacity to consume the amount.
*
* @param limit The bucket to consume from
* @param amount The amount to consume
* @return True if the bucket had enough remaining capacity to consume the amount, false otherwise
*/
function consume(Limit storage limit, uint64 amount) internal returns (bool) {
Limit memory _limit = limit;
_refill(_limit);
if (_limit.remaining < amount) {
return false;
}
limit.remaining = _limit.remaining - amount;
limit.lastRefill = _limit.lastRefill;
return true;
}
/*
* Refills the bucket based on the time elapsed since the last refill. This effectively simulates
* the idea of the bucket continuously refilling at a constant rate.
*
* @param limit The bucket to refill
*/
function refill(Limit storage limit) internal {
Limit memory _limit = limit;
_refill(_limit);
limit.remaining = _limit.remaining;
limit.lastRefill = _limit.lastRefill;
}
function _refill(Limit memory limit) internal view {
uint64 now_ = uint64(block.timestamp);
if (now_ == limit.lastRefill) {
return;
}
uint256 delta;
unchecked {
delta = now_ - limit.lastRefill;
}
uint256 tokens = delta * uint256(limit.refillRate);
uint256 newRemaining = uint256(limit.remaining) + tokens;
if (newRemaining > limit.capacity) {
limit.remaining = limit.capacity;
} else {
limit.remaining = uint64(newRemaining);
}
limit.lastRefill = now_;
}
/*
* Sets the capacity of the bucket. If the new capacity is less than the remaining capacity,
* the remaining capacity is set to the new capacity.
*
* @param limit The bucket to set the capacity of
* @param capacity The new capacity
*/
function setCapacity(Limit storage limit, uint64 capacity) internal {
refill(limit);
limit.capacity = capacity;
if (limit.remaining > capacity) {
limit.remaining = capacity;
}
}
/*
* Sets the refill rate of the bucket, in units per second.
*
* @param limit The bucket to set the refill rate of
* @param refillRate The new refill rate
*/
function setRefillRate(Limit storage limit, uint64 refillRate) internal {
refill(limit);
limit.refillRate = refillRate;
}
/*
* Sets the remaining capacity of the bucket. If the new remaining capacity is greater than
* the capacity, the remaining capacity is set to the capacity.
*
* @param limit The bucket to set the remaining capacity of
* @param remaining The new remaining capacity
*/
function setRemaining(Limit storage limit, uint64 remaining) internal {
refill(limit);
limit.remaining = remaining;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.0;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeaconUpgradeable {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {BeaconProxy} will check that this address is a contract.
*/
function implementation() external view returns (address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)
pragma solidity ^0.8.0;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC1967 implementation slot:
* ```
* contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
*/
library StorageSlotUpgradeable {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.0;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeacon {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {BeaconProxy} will check that this address is a contract.
*/
function implementation() external view returns (address);
}// ┏━━━┓━┏┓━┏┓━━┏━━━┓━━┏━━━┓━━━━┏━━━┓━━━━━━━━━━━━━━━━━━━┏┓━━━━━┏━━━┓━━━━━━━━━┏┓━━━━━━━━━━━━━━┏┓━
// ┃┏━━┛┏┛┗┓┃┃━━┃┏━┓┃━━┃┏━┓┃━━━━┗┓┏┓┃━━━━━━━━━━━━━━━━━━┏┛┗┓━━━━┃┏━┓┃━━━━━━━━┏┛┗┓━━━━━━━━━━━━┏┛┗┓
// ┃┗━━┓┗┓┏┛┃┗━┓┗┛┏┛┃━━┃┃━┃┃━━━━━┃┃┃┃┏━━┓┏━━┓┏━━┓┏━━┓┏┓┗┓┏┛━━━━┃┃━┗┛┏━━┓┏━┓━┗┓┏┛┏━┓┏━━┓━┏━━┓┗┓┏┛
// ┃┏━━┛━┃┃━┃┏┓┃┏━┛┏┛━━┃┃━┃┃━━━━━┃┃┃┃┃┏┓┃┃┏┓┃┃┏┓┃┃━━┫┣┫━┃┃━━━━━┃┃━┏┓┃┏┓┃┃┏┓┓━┃┃━┃┏┛┗━┓┃━┃┏━┛━┃┃━
// ┃┗━━┓━┃┗┓┃┃┃┃┃┃┗━┓┏┓┃┗━┛┃━━━━┏┛┗┛┃┃┃━┫┃┗┛┃┃┗┛┃┣━━┃┃┃━┃┗┓━━━━┃┗━┛┃┃┗┛┃┃┃┃┃━┃┗┓┃┃━┃┗┛┗┓┃┗━┓━┃┗┓
// ┗━━━┛━┗━┛┗┛┗┛┗━━━┛┗┛┗━━━┛━━━━┗━━━┛┗━━┛┃┏━┛┗━━┛┗━━┛┗┛━┗━┛━━━━┗━━━┛┗━━┛┗┛┗┛━┗━┛┗┛━┗━━━┛┗━━┛━┗━┛
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┃┃━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┗┛━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// SPDX-License-Identifier: CC0-1.0
pragma solidity >=0.5.0;
// This interface is designed to be compatible with the Vyper version.
/// @notice This is the Ethereum 2.0 deposit contract interface.
/// For more information see the Phase 0 specification under https://github.com/ethereum/eth2.0-specs
interface IETHPOSDeposit {
/// @notice A processed deposit event.
event DepositEvent(bytes pubkey, bytes withdrawal_credentials, bytes amount, bytes signature, bytes index);
/// @notice Submit a Phase 0 DepositData object.
/// @param pubkey A BLS12-381 public key.
/// @param withdrawal_credentials Commitment to a public key for withdrawals.
/// @param signature A BLS12-381 signature.
/// @param deposit_data_root The SHA-256 hash of the SSZ-encoded DepositData object.
/// Used as a protection against malformed input.
function deposit(
bytes calldata pubkey,
bytes calldata withdrawal_credentials,
bytes calldata signature,
bytes32 deposit_data_root
) external payable;
/// @notice Query the current deposit root hash.
/// @return The deposit root hash.
function get_deposit_root() external view returns (bytes32);
/// @notice Query the current deposit count.
/// @return The deposit count encoded as a little endian 64-bit number.
function get_deposit_count() external view returns (bytes memory);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.5.0;
import "src/eigenlayer-libraries/LegacyBeaconChainProofs.sol";
import "src/eigenlayer-libraries/BeaconChainProofs.sol";
import "./IEigenPodManager.sol";
import "./IBeaconChainOracle.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
/**
* @title The implementation contract used for restaking beacon chain ETH on EigenLayer
* @author Layr Labs, Inc.
* @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
* @notice The main functionalities are:
* - creating new ETH validators with their withdrawal credentials pointed to this contract
* - proving from beacon chain state roots that withdrawal credentials are pointed to this contract
* - proving from beacon chain state roots the balances of ETH validators with their withdrawal credentials
* pointed to this contract
* - updating aggregate balances in the EigenPodManager
* - withdrawing eth when withdrawals are initiated
* @dev Note that all beacon chain balances are stored as gwei within the beacon chain datastructures. We choose
* to account balances in terms of gwei in the EigenPod contract and convert to wei when making calls to other contracts
*/
interface IEigenPod {
enum VALIDATOR_STATUS {
INACTIVE, // doesnt exist
ACTIVE, // staked on ethpos and withdrawal credentials are pointed to the EigenPod
WITHDRAWN // withdrawn from the Beacon Chain
}
struct ValidatorInfo {
// index of the validator in the beacon chain
uint64 validatorIndex;
// amount of beacon chain ETH restaked on EigenLayer in gwei
uint64 restakedBalanceGwei;
//timestamp of the validator's most recent balance update
uint64 mostRecentBalanceUpdateTimestamp;
// status of the validator
VALIDATOR_STATUS status;
}
/**
* @notice struct used to store amounts related to proven withdrawals in memory. Used to help
* manage stack depth and optimize the number of external calls, when batching withdrawal operations.
*/
struct VerifiedWithdrawal {
// amount to send to a podOwner from a proven withdrawal
uint256 amountToSendGwei;
// difference in shares to be recorded in the eigenPodManager, as a result of the withdrawal
int256 sharesDeltaGwei;
}
enum PARTIAL_WITHDRAWAL_CLAIM_STATUS {
REDEEMED,
PENDING,
FAILED
}
/// @notice Emitted when an ETH validator stakes via this eigenPod
event EigenPodStaked(bytes pubkey);
/// @notice Emitted when an ETH validator's withdrawal credentials are successfully verified to be pointed to this eigenPod
event ValidatorRestaked(uint40 validatorIndex);
/// @notice Emitted when an ETH validator's balance is proven to be updated. Here newValidatorBalanceGwei
// is the validator's balance that is credited on EigenLayer.
event ValidatorBalanceUpdated(uint40 validatorIndex, uint64 balanceTimestamp, uint64 newValidatorBalanceGwei);
/// @notice Emitted when an ETH validator is prove to have withdrawn from the beacon chain
event FullWithdrawalRedeemed(
uint40 validatorIndex,
uint64 withdrawalTimestamp,
address indexed recipient,
uint64 withdrawalAmountGwei
);
/// @notice Emitted when a partial withdrawal claim is successfully redeemed
event PartialWithdrawalRedeemed(
uint40 validatorIndex,
uint64 withdrawalTimestamp,
address indexed recipient,
uint64 partialWithdrawalAmountGwei
);
/// @notice Emitted when restaked beacon chain ETH is withdrawn from the eigenPod.
event RestakedBeaconChainETHWithdrawn(address indexed recipient, uint256 amount);
/// @notice Emitted when podOwner enables restaking
event RestakingActivated(address indexed podOwner);
/// @notice Emitted when ETH is received via the `receive` fallback
event NonBeaconChainETHReceived(uint256 amountReceived);
/// @notice Emitted when ETH that was previously received via the `receive` fallback is withdrawn
event NonBeaconChainETHWithdrawn(address indexed recipient, uint256 amountWithdrawn);
/// @notice The max amount of eth, in gwei, that can be restaked per validator
function MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR() external view returns (uint64);
/// @notice the amount of execution layer ETH in this contract that is staked in EigenLayer (i.e. withdrawn from beaconchain but not EigenLayer),
function withdrawableRestakedExecutionLayerGwei() external view returns (uint64);
/// @notice any ETH deposited into the EigenPod contract via the `receive` fallback function
function nonBeaconChainETHBalanceWei() external view returns (uint256);
/// @notice Used to initialize the pointers to contracts crucial to the pod's functionality, in beacon proxy construction from EigenPodManager
function initialize(address owner) external;
/// @notice Called by EigenPodManager when the owner wants to create another ETH validator.
function stake(bytes calldata pubkey, bytes calldata signature, bytes32 depositDataRoot) external payable;
/**
* @notice Transfers `amountWei` in ether from this contract to the specified `recipient` address
* @notice Called by EigenPodManager to withdrawBeaconChainETH that has been added to the EigenPod's balance due to a withdrawal from the beacon chain.
* @dev The podOwner must have already proved sufficient withdrawals, so that this pod's `withdrawableRestakedExecutionLayerGwei` exceeds the
* `amountWei` input (when converted to GWEI).
* @dev Reverts if `amountWei` is not a whole Gwei amount
*/
function withdrawRestakedBeaconChainETH(address recipient, uint256 amount) external;
/// @notice The single EigenPodManager for EigenLayer
function eigenPodManager() external view returns (IEigenPodManager);
/// @notice The owner of this EigenPod
function podOwner() external view returns (address);
/// @notice an indicator of whether or not the podOwner has ever "fully restaked" by successfully calling `verifyCorrectWithdrawalCredentials`.
function hasRestaked() external view returns (bool);
/**
* @notice The latest timestamp at which the pod owner withdrew the balance of the pod, via calling `withdrawBeforeRestaking`.
* @dev This variable is only updated when the `withdrawBeforeRestaking` function is called, which can only occur before `hasRestaked` is set to true for this pod.
* Proofs for this pod are only valid against Beacon Chain state roots corresponding to timestamps after the stored `mostRecentWithdrawalTimestamp`.
*/
function mostRecentWithdrawalTimestamp() external view returns (uint64);
/// @notice Returns the validatorInfo struct for the provided pubkeyHash
function validatorPubkeyHashToInfo(bytes32 validatorPubkeyHash) external view returns (ValidatorInfo memory);
/// @notice Returns the validatorInfo struct for the provided pubkey
function validatorPubkeyToInfo(bytes calldata validatorPubkey) external view returns (ValidatorInfo memory);
///@notice mapping that tracks proven withdrawals
function provenWithdrawal(bytes32 validatorPubkeyHash, uint64 slot) external view returns (bool);
/// @notice This returns the status of a given validator
function validatorStatus(bytes32 pubkeyHash) external view returns (VALIDATOR_STATUS);
/// @notice This returns the status of a given validator pubkey
function validatorStatus(bytes calldata validatorPubkey) external view returns (VALIDATOR_STATUS);
/**
* @notice This function verifies that the withdrawal credentials of validator(s) owned by the podOwner are pointed to
* this contract. It also verifies the effective balance of the validator. It verifies the provided proof of the ETH validator against the beacon chain state
* root, marks the validator as 'active' in EigenLayer, and credits the restaked ETH in Eigenlayer.
* @param oracleTimestamp is the Beacon Chain timestamp whose state root the `proof` will be proven against.
* @param validatorIndices is the list of indices of the validators being proven, refer to consensus specs
* @param withdrawalCredentialProofs is an array of proofs, where each proof proves each ETH validator's balance and withdrawal credentials
* against a beacon chain state root
* @param validatorFields are the fields of the "Validator Container", refer to consensus specs
* for details: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#validator
*/
function verifyWithdrawalCredentials(
uint64 oracleTimestamp,
LegacyBeaconChainProofs.StateRootProof calldata stateRootProof,
uint40[] calldata validatorIndices,
bytes[] calldata withdrawalCredentialProofs,
bytes32[][] calldata validatorFields
)
external;
/**
* @notice This function records an update (either increase or decrease) in the pod's balance in the StrategyManager.
It also verifies a merkle proof of the validator's current beacon chain balance.
* @param oracleTimestamp The oracleTimestamp whose state root the `proof` will be proven against.
* Must be within `VERIFY_BALANCE_UPDATE_WINDOW_SECONDS` of the current block.
* @param validatorIndices is the list of indices of the validators being proven, refer to consensus specs
* @param validatorFieldsProofs proofs against the `beaconStateRoot` for each validator in `validatorFields`
* @param validatorFields are the fields of the "Validator Container", refer to consensus specs
* @dev For more details on the Beacon Chain spec, see: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#validator
*/
function verifyBalanceUpdates(
uint64 oracleTimestamp,
uint40[] calldata validatorIndices,
LegacyBeaconChainProofs.StateRootProof calldata stateRootProof,
bytes[] calldata validatorFieldsProofs,
bytes32[][] calldata validatorFields
) external;
/**
* @notice This function records full and partial withdrawals on behalf of one of the Ethereum validators for this EigenPod
* @param oracleTimestamp is the timestamp of the oracle slot that the withdrawal is being proven against
* @param withdrawalProofs is the information needed to check the veracity of the block numbers and withdrawals being proven
* @param validatorFieldsProofs is the proof of the validator's fields' in the validator tree
* @param withdrawalFields are the fields of the withdrawals being proven
* @param validatorFields are the fields of the validators being proven
*/
function verifyAndProcessWithdrawals(
uint64 oracleTimestamp,
LegacyBeaconChainProofs.StateRootProof calldata stateRootProof,
LegacyBeaconChainProofs.WithdrawalProof[] calldata withdrawalProofs,
bytes[] calldata validatorFieldsProofs,
bytes32[][] calldata validatorFields,
bytes32[][] calldata withdrawalFields
) external;
/**
* @notice Called by the pod owner to activate restaking by withdrawing
* all existing ETH from the pod and preventing further withdrawals via
* "withdrawBeforeRestaking()"
*/
function activateRestaking() external;
/// @notice Called by the pod owner to withdraw the balance of the pod when `hasRestaked` is set to false
function withdrawBeforeRestaking() external;
/// @notice Called by the pod owner to withdraw the nonBeaconChainETHBalanceWei
function withdrawNonBeaconChainETHBalanceWei(address recipient, uint256 amountToWithdraw) external;
/// @notice called by owner of a pod to remove any ERC20s deposited in the pod
function recoverTokens(IERC20[] memory tokenList, uint256[] memory amountsToWithdraw, address recipient) external;
//--------------------------------------------------------------------------------------
//--------------------------------- PEPE UPDATES ------------------------------------
//--------------------------------------------------------------------------------------
// TODO(Dave): Once we are no longer in between the 2 updates, we can fully replace this file with
// the new version
/// State-changing methods
function startCheckpoint(bool revertIfNoBalance) external;
function verifyCheckpointProofs(
BeaconChainProofs.BalanceContainerProof calldata balanceContainerProof,
BeaconChainProofs.BalanceProof[] calldata proofs
) external;
function setProofSubmitter(address newProofSubmitter) external;
/// Events
/// @notice Emitted when a checkpoint is created
event CheckpointCreated(uint64 indexed checkpointTimestamp, bytes32 indexed beaconBlockRoot);
/// @notice Emitted when a checkpoint is finalized
event CheckpointFinalized(uint64 indexed checkpointTimestamp, int256 totalShareDeltaWei);
/// @notice Emitted when a validator is proven for a given checkpoint
event ValidatorCheckpointed(uint64 indexed checkpointTimestamp, uint40 indexed validatorIndex);
/// @notice Emitted when a validaor is proven to have 0 balance at a given checkpoint
event ValidatorWithdrawn(uint64 indexed checkpointTimestamp, uint40 indexed validatorIndex);
/// Structs
struct Checkpoint {
bytes32 beaconBlockRoot;
uint24 proofsRemaining;
uint64 podBalanceGwei;
int128 balanceDeltasGwei;
}
/// View methods
function activeValidatorCount() external view returns (uint256); // note - this variable already exists in M2; this change just makes it public!
function lastCheckpointTimestamp() external view returns (uint64);
function currentCheckpointTimestamp() external view returns (uint64);
function currentCheckpoint() external view returns (Checkpoint memory);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.5.0;
/**
* @title Interface for the BeaconStateOracle contract.
* @author Layr Labs, Inc.
* @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
*/
interface IBeaconChainOracle {
/// @notice The block number to state root mapping.
function timestampToBlockRoot(uint256 timestamp) external view returns (bytes32);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.5.0;
import "src/eigenlayer-interfaces/IPauserRegistry.sol";
/**
* @title Adds pausability to a contract, with pausing & unpausing controlled by the `pauser` and `unpauser` of a PauserRegistry contract.
* @author Layr Labs, Inc.
* @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
* @notice Contracts that inherit from this contract may define their own `pause` and `unpause` (and/or related) functions.
* These functions should be permissioned as "onlyPauser" which defers to a `PauserRegistry` for determining access control.
* @dev Pausability is implemented using a uint256, which allows up to 256 different single bit-flags; each bit can potentially pause different functionality.
* Inspiration for this was taken from the NearBridge design here https://etherscan.io/address/0x3FEFc5A4B1c02f21cBc8D3613643ba0635b9a873#code.
* For the `pause` and `unpause` functions we've implemented, if you pause, you can only flip (any number of) switches to on/1 (aka "paused"), and if you unpause,
* you can only flip (any number of) switches to off/0 (aka "paused").
* If you want a pauseXYZ function that just flips a single bit / "pausing flag", it will:
* 1) 'bit-wise and' (aka `&`) a flag with the current paused state (as a uint256)
* 2) update the paused state to this new value
* @dev We note as well that we have chosen to identify flags by their *bit index* as opposed to their numerical value, so, e.g. defining `DEPOSITS_PAUSED = 3`
* indicates specifically that if the *third bit* of `_paused` is flipped -- i.e. it is a '1' -- then deposits should be paused
*/
interface IPausable {
/// @notice Emitted when the `pauserRegistry` is set to `newPauserRegistry`.
event PauserRegistrySet(IPauserRegistry pauserRegistry, IPauserRegistry newPauserRegistry);
/// @notice Emitted when the pause is triggered by `account`, and changed to `newPausedStatus`.
event Paused(address indexed account, uint256 newPausedStatus);
/// @notice Emitted when the pause is lifted by `account`, and changed to `newPausedStatus`.
event Unpaused(address indexed account, uint256 newPausedStatus);
/// @notice Address of the `PauserRegistry` contract that this contract defers to for determining access control (for pausing).
function pauserRegistry() external view returns (IPauserRegistry);
/**
* @notice This function is used to pause an EigenLayer contract's functionality.
* It is permissioned to the `pauser` address, which is expected to be a low threshold multisig.
* @param newPausedStatus represents the new value for `_paused` to take, which means it may flip several bits at once.
* @dev This function can only pause functionality, and thus cannot 'unflip' any bit in `_paused` from 1 to 0.
*/
function pause(uint256 newPausedStatus) external;
/**
* @notice Alias for `pause(type(uint256).max)`.
*/
function pauseAll() external;
/**
* @notice This function is used to unpause an EigenLayer contract's functionality.
* It is permissioned to the `unpauser` address, which is expected to be a high threshold multisig or governance contract.
* @param newPausedStatus represents the new value for `_paused` to take, which means it may flip several bits at once.
* @dev This function can only unpause functionality, and thus cannot 'flip' any bit in `_paused` from 0 to 1.
*/
function unpause(uint256 newPausedStatus) external;
/// @notice Returns the current paused status as a uint256.
function paused() external view returns (uint256);
/// @notice Returns 'true' if the `indexed`th bit of `_paused` is 1, and 'false' otherwise
function paused(uint8 index) external view returns (bool);
/// @notice Allows the unpauser to set a new pauser registry
function setPauserRegistry(IPauserRegistry newPauserRegistry) external;
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.5.0;
import "./IStrategyManager.sol";
import "./IDelegationManager.sol";
/**
* @title Interface for the primary 'slashing' contract for EigenLayer.
* @author Layr Labs, Inc.
* @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
* @notice See the `Slasher` contract itself for implementation details.
*/
interface ISlasher {
// struct used to store information about the current state of an operator's obligations to middlewares they are serving
struct MiddlewareTimes {
// The update block for the middleware whose most recent update was earliest, i.e. the 'stalest' update out of all middlewares the operator is serving
uint32 stalestUpdateBlock;
// The latest 'serveUntilBlock' from all of the middleware that the operator is serving
uint32 latestServeUntilBlock;
}
// struct used to store details relevant to a single middleware that an operator has opted-in to serving
struct MiddlewareDetails {
// the block at which the contract begins being able to finalize the operator's registration with the service via calling `recordFirstStakeUpdate`
uint32 registrationMayBeginAtBlock;
// the block before which the contract is allowed to slash the user
uint32 contractCanSlashOperatorUntilBlock;
// the block at which the middleware's view of the operator's stake was most recently updated
uint32 latestUpdateBlock;
}
/// @notice Emitted when a middleware times is added to `operator`'s array.
event MiddlewareTimesAdded(
address operator,
uint256 index,
uint32 stalestUpdateBlock,
uint32 latestServeUntilBlock
);
/// @notice Emitted when `operator` begins to allow `contractAddress` to slash them.
event OptedIntoSlashing(address indexed operator, address indexed contractAddress);
/// @notice Emitted when `contractAddress` signals that it will no longer be able to slash `operator` after the `contractCanSlashOperatorUntilBlock`.
event SlashingAbilityRevoked(
address indexed operator,
address indexed contractAddress,
uint32 contractCanSlashOperatorUntilBlock
);
/**
* @notice Emitted when `slashingContract` 'freezes' the `slashedOperator`.
* @dev The `slashingContract` must have permission to slash the `slashedOperator`, i.e. `canSlash(slasherOperator, slashingContract)` must return 'true'.
*/
event OperatorFrozen(address indexed slashedOperator, address indexed slashingContract);
/// @notice Emitted when `previouslySlashedAddress` is 'unfrozen', allowing them to again move deposited funds within EigenLayer.
event FrozenStatusReset(address indexed previouslySlashedAddress);
/**
* @notice Gives the `contractAddress` permission to slash the funds of the caller.
* @dev Typically, this function must be called prior to registering for a middleware.
*/
function optIntoSlashing(address contractAddress) external;
/**
* @notice Used for 'slashing' a certain operator.
* @param toBeFrozen The operator to be frozen.
* @dev Technically the operator is 'frozen' (hence the name of this function), and then subject to slashing pending a decision by a human-in-the-loop.
* @dev The operator must have previously given the caller (which should be a contract) the ability to slash them, through a call to `optIntoSlashing`.
*/
function freezeOperator(address toBeFrozen) external;
/**
* @notice Removes the 'frozen' status from each of the `frozenAddresses`
* @dev Callable only by the contract owner (i.e. governance).
*/
function resetFrozenStatus(address[] calldata frozenAddresses) external;
/**
* @notice this function is a called by middlewares during an operator's registration to make sure the operator's stake at registration
* is slashable until serveUntil
* @param operator the operator whose stake update is being recorded
* @param serveUntilBlock the block until which the operator's stake at the current block is slashable
* @dev adds the middleware's slashing contract to the operator's linked list
*/
function recordFirstStakeUpdate(address operator, uint32 serveUntilBlock) external;
/**
* @notice this function is a called by middlewares during a stake update for an operator (perhaps to free pending withdrawals)
* to make sure the operator's stake at updateBlock is slashable until serveUntil
* @param operator the operator whose stake update is being recorded
* @param updateBlock the block for which the stake update is being recorded
* @param serveUntilBlock the block until which the operator's stake at updateBlock is slashable
* @param insertAfter the element of the operators linked list that the currently updating middleware should be inserted after
* @dev insertAfter should be calculated offchain before making the transaction that calls this. this is subject to race conditions,
* but it is anticipated to be rare and not detrimental.
*/
function recordStakeUpdate(
address operator,
uint32 updateBlock,
uint32 serveUntilBlock,
uint256 insertAfter
) external;
/**
* @notice this function is a called by middlewares during an operator's deregistration to make sure the operator's stake at deregistration
* is slashable until serveUntil
* @param operator the operator whose stake update is being recorded
* @param serveUntilBlock the block until which the operator's stake at the current block is slashable
* @dev removes the middleware's slashing contract to the operator's linked list and revokes the middleware's (i.e. caller's) ability to
* slash `operator` once `serveUntil` is reached
*/
function recordLastStakeUpdateAndRevokeSlashingAbility(address operator, uint32 serveUntilBlock) external;
/// @notice The StrategyManager contract of EigenLayer
function strategyManager() external view returns (IStrategyManager);
/// @notice The DelegationManager contract of EigenLayer
function delegation() external view returns (IDelegationManager);
/**
* @notice Used to determine whether `staker` is actively 'frozen'. If a staker is frozen, then they are potentially subject to
* slashing of their funds, and cannot cannot deposit or withdraw from the strategyManager until the slashing process is completed
* and the staker's status is reset (to 'unfrozen').
* @param staker The staker of interest.
* @return Returns 'true' if `staker` themselves has their status set to frozen, OR if the staker is delegated
* to an operator who has their status set to frozen. Otherwise returns 'false'.
*/
function isFrozen(address staker) external view returns (bool);
/// @notice Returns true if `slashingContract` is currently allowed to slash `toBeSlashed`.
function canSlash(address toBeSlashed, address slashingContract) external view returns (bool);
/// @notice Returns the block until which `serviceContract` is allowed to slash the `operator`.
function contractCanSlashOperatorUntilBlock(
address operator,
address serviceContract
) external view returns (uint32);
/// @notice Returns the block at which the `serviceContract` last updated its view of the `operator`'s stake
function latestUpdateBlock(address operator, address serviceContract) external view returns (uint32);
/// @notice A search routine for finding the correct input value of `insertAfter` to `recordStakeUpdate` / `_updateMiddlewareList`.
function getCorrectValueForInsertAfter(address operator, uint32 updateBlock) external view returns (uint256);
/**
* @notice Returns 'true' if `operator` can currently complete a withdrawal started at the `withdrawalStartBlock`, with `middlewareTimesIndex` used
* to specify the index of a `MiddlewareTimes` struct in the operator's list (i.e. an index in `operatorToMiddlewareTimes[operator]`). The specified
* struct is consulted as proof of the `operator`'s ability (or lack thereof) to complete the withdrawal.
* This function will return 'false' if the operator cannot currently complete a withdrawal started at the `withdrawalStartBlock`, *or* in the event
* that an incorrect `middlewareTimesIndex` is supplied, even if one or more correct inputs exist.
* @param operator Either the operator who queued the withdrawal themselves, or if the withdrawing party is a staker who delegated to an operator,
* this address is the operator *who the staker was delegated to* at the time of the `withdrawalStartBlock`.
* @param withdrawalStartBlock The block number at which the withdrawal was initiated.
* @param middlewareTimesIndex Indicates an index in `operatorToMiddlewareTimes[operator]` to consult as proof of the `operator`'s ability to withdraw
* @dev The correct `middlewareTimesIndex` input should be computable off-chain.
*/
function canWithdraw(
address operator,
uint32 withdrawalStartBlock,
uint256 middlewareTimesIndex
) external returns (bool);
/**
* operator =>
* [
* (
* the least recent update block of all of the middlewares it's serving/served,
* latest time that the stake bonded at that update needed to serve until
* )
* ]
*/
function operatorToMiddlewareTimes(
address operator,
uint256 arrayIndex
) external view returns (MiddlewareTimes memory);
/// @notice Getter function for fetching `operatorToMiddlewareTimes[operator].length`
function middlewareTimesLength(address operator) external view returns (uint256);
/// @notice Getter function for fetching `operatorToMiddlewareTimes[operator][index].stalestUpdateBlock`.
function getMiddlewareTimesIndexStalestUpdateBlock(address operator, uint32 index) external view returns (uint32);
/// @notice Getter function for fetching `operatorToMiddlewareTimes[operator][index].latestServeUntil`.
function getMiddlewareTimesIndexServeUntilBlock(address operator, uint32 index) external view returns (uint32);
/// @notice Getter function for fetching `_operatorToWhitelistedContractsByUpdate[operator].size`.
function operatorWhitelistedContractsLinkedListSize(address operator) external view returns (uint256);
/// @notice Getter function for fetching a single node in the operator's linked list (`_operatorToWhitelistedContractsByUpdate[operator]`).
function operatorWhitelistedContractsLinkedListEntry(
address operator,
address node
) external view returns (bool, uint256, uint256);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.5.0;
/**
* @title The interface for common signature utilities.
* @author Layr Labs, Inc.
* @notice Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service
*/
interface ISignatureUtils {
// @notice Struct that bundles together a signature and an expiration time for the signature. Used primarily for stack management.
struct SignatureWithExpiry {
// the signature itself, formatted as a single bytes object
bytes signature;
// the expiration timestamp (UTC) of the signature
uint256 expiry;
}
// @notice Struct that bundles together a signature, a salt for uniqueness, and an expiration time for the signature. Used primarily for stack management.
struct SignatureWithSaltAndExpiry {
// the signature itself, formatted as a single bytes object
bytes signature;
// the salt used to generate the signature
bytes32 salt;
// the expiration timestamp (UTC) of the signature
uint256 expiry;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @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 IERC165Upgradeable {
/**
* @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);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @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://diligence.consensys.net/posts/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.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @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, it is bubbled up by this
* function (like regular Solidity function calls).
*
* 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.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @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`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) 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(errorMessage);
}
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
import "./EigenlayerMerkle.sol";
import "./Endian.sol";
//Utility library for parsing and PHASE0 beacon chain block headers
//SSZ Spec: https://github.com/ethereum/consensus-specs/blob/dev/ssz/simple-serialize.md#merkleization
//BeaconBlockHeader Spec: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#beaconblockheader
//BeaconState Spec: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#beaconstate
library LegacyBeaconChainProofs {
// constants are the number of fields and the heights of the different merkle trees used in merkleizing beacon chain containers
uint256 internal constant NUM_BEACON_BLOCK_HEADER_FIELDS = 5;
uint256 internal constant BEACON_BLOCK_HEADER_FIELD_TREE_HEIGHT = 3;
uint256 internal constant NUM_BEACON_BLOCK_BODY_FIELDS = 11;
uint256 internal constant BEACON_BLOCK_BODY_FIELD_TREE_HEIGHT = 4;
uint256 internal constant NUM_BEACON_STATE_FIELDS = 21;
uint256 internal constant BEACON_STATE_FIELD_TREE_HEIGHT = 5;
uint256 internal constant NUM_ETH1_DATA_FIELDS = 3;
uint256 internal constant ETH1_DATA_FIELD_TREE_HEIGHT = 2;
uint256 internal constant NUM_VALIDATOR_FIELDS = 8;
uint256 internal constant VALIDATOR_FIELD_TREE_HEIGHT = 3;
uint256 internal constant NUM_EXECUTION_PAYLOAD_HEADER_FIELDS = 15;
uint256 internal constant EXECUTION_PAYLOAD_HEADER_FIELD_TREE_HEIGHT = 4;
uint256 internal constant NUM_EXECUTION_PAYLOAD_FIELDS = 15;
uint256 internal constant EXECUTION_PAYLOAD_FIELD_TREE_HEIGHT = 4;
// HISTORICAL_ROOTS_LIMIT = 2**24, so tree height is 24
uint256 internal constant HISTORICAL_ROOTS_TREE_HEIGHT = 24;
// HISTORICAL_BATCH is root of state_roots and block_root, so number of leaves = 2^1
uint256 internal constant HISTORICAL_BATCH_TREE_HEIGHT = 1;
// SLOTS_PER_HISTORICAL_ROOT = 2**13, so tree height is 13
uint256 internal constant STATE_ROOTS_TREE_HEIGHT = 13;
uint256 internal constant BLOCK_ROOTS_TREE_HEIGHT = 13;
//HISTORICAL_ROOTS_LIMIT = 2**24, so tree height is 24
uint256 internal constant HISTORICAL_SUMMARIES_TREE_HEIGHT = 24;
//Index of block_summary_root in historical_summary container
uint256 internal constant BLOCK_SUMMARY_ROOT_INDEX = 0;
uint256 internal constant NUM_WITHDRAWAL_FIELDS = 4;
// tree height for hash tree of an individual withdrawal container
uint256 internal constant WITHDRAWAL_FIELD_TREE_HEIGHT = 2;
uint256 internal constant VALIDATOR_TREE_HEIGHT = 40;
// MAX_WITHDRAWALS_PER_PAYLOAD = 2**4, making tree height = 4
uint256 internal constant WITHDRAWALS_TREE_HEIGHT = 4;
//in beacon block body https://github.com/ethereum/consensus-specs/blob/dev/specs/capella/beacon-chain.md#beaconblockbody
uint256 internal constant EXECUTION_PAYLOAD_INDEX = 9;
// in beacon block header https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#beaconblockheader
uint256 internal constant SLOT_INDEX = 0;
uint256 internal constant PROPOSER_INDEX_INDEX = 1;
uint256 internal constant STATE_ROOT_INDEX = 3;
uint256 internal constant BODY_ROOT_INDEX = 4;
// in beacon state https://github.com/ethereum/consensus-specs/blob/dev/specs/capella/beacon-chain.md#beaconstate
uint256 internal constant HISTORICAL_BATCH_STATE_ROOT_INDEX = 1;
uint256 internal constant BEACON_STATE_SLOT_INDEX = 2;
uint256 internal constant LATEST_BLOCK_HEADER_ROOT_INDEX = 4;
uint256 internal constant BLOCK_ROOTS_INDEX = 5;
uint256 internal constant STATE_ROOTS_INDEX = 6;
uint256 internal constant HISTORICAL_ROOTS_INDEX = 7;
uint256 internal constant ETH_1_ROOT_INDEX = 8;
uint256 internal constant VALIDATOR_TREE_ROOT_INDEX = 11;
uint256 internal constant EXECUTION_PAYLOAD_HEADER_INDEX = 24;
uint256 internal constant HISTORICAL_SUMMARIES_INDEX = 27;
// in validator https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#validator
uint256 internal constant VALIDATOR_PUBKEY_INDEX = 0;
uint256 internal constant VALIDATOR_WITHDRAWAL_CREDENTIALS_INDEX = 1;
uint256 internal constant VALIDATOR_BALANCE_INDEX = 2;
uint256 internal constant VALIDATOR_SLASHED_INDEX = 3;
uint256 internal constant VALIDATOR_WITHDRAWABLE_EPOCH_INDEX = 7;
// in execution payload header
uint256 internal constant TIMESTAMP_INDEX = 9;
uint256 internal constant WITHDRAWALS_ROOT_INDEX = 14;
//in execution payload
uint256 internal constant WITHDRAWALS_INDEX = 14;
// in withdrawal
uint256 internal constant WITHDRAWAL_VALIDATOR_INDEX_INDEX = 1;
uint256 internal constant WITHDRAWAL_VALIDATOR_AMOUNT_INDEX = 3;
//In historicalBatch
uint256 internal constant HISTORICALBATCH_STATEROOTS_INDEX = 1;
//Misc Constants
/// @notice The number of slots each epoch in the beacon chain
uint64 internal constant SLOTS_PER_EPOCH = 32;
/// @notice The number of seconds in a slot in the beacon chain
uint64 internal constant SECONDS_PER_SLOT = 12;
/// @notice Number of seconds per epoch: 384 == 32 slots/epoch * 12 seconds/slot
uint64 internal constant SECONDS_PER_EPOCH = SLOTS_PER_EPOCH * SECONDS_PER_SLOT;
bytes8 internal constant UINT64_MASK = 0xffffffffffffffff;
/// @notice This struct contains the merkle proofs and leaves needed to verify a partial/full withdrawal
struct WithdrawalProof {
bytes withdrawalProof;
bytes slotProof;
bytes executionPayloadProof;
bytes timestampProof;
bytes historicalSummaryBlockRootProof;
uint64 blockRootIndex;
uint64 historicalSummaryIndex;
uint64 withdrawalIndex;
bytes32 blockRoot;
bytes32 slotRoot;
bytes32 timestampRoot;
bytes32 executionPayloadRoot;
}
/// @notice This struct contains the root and proof for verifying the state root against the oracle block root
struct StateRootProof {
bytes32 beaconStateRoot;
bytes proof;
}
/**
* @notice This function verifies merkle proofs of the fields of a certain validator against a beacon chain state root
* @param validatorIndex the index of the proven validator
* @param beaconStateRoot is the beacon chain state root to be proven against.
* @param validatorFieldsProof is the data used in proving the validator's fields
* @param validatorFields the claimed fields of the validator
*/
function verifyValidatorFields(
bytes32 beaconStateRoot,
bytes32[] calldata validatorFields,
bytes calldata validatorFieldsProof,
uint40 validatorIndex
) internal view {
require(
validatorFields.length == 2 ** VALIDATOR_FIELD_TREE_HEIGHT,
"BeaconChainProofs.verifyValidatorFields: Validator fields has incorrect length"
);
/**
* Note: the length of the validator merkle proof is BeaconChainProofs.VALIDATOR_TREE_HEIGHT + 1.
* There is an additional layer added by hashing the root with the length of the validator list
*/
require(
validatorFieldsProof.length == 32 * ((VALIDATOR_TREE_HEIGHT + 1) + BEACON_STATE_FIELD_TREE_HEIGHT),
"BeaconChainProofs.verifyValidatorFields: Proof has incorrect length"
);
uint256 index = (VALIDATOR_TREE_ROOT_INDEX << (VALIDATOR_TREE_HEIGHT + 1)) | uint256(validatorIndex);
// merkleize the validatorFields to get the leaf to prove
bytes32 validatorRoot = EigenlayerMerkle.merkleizeSha256(validatorFields);
// verify the proof of the validatorRoot against the beaconStateRoot
require(
EigenlayerMerkle.verifyInclusionSha256({
proof: validatorFieldsProof,
root: beaconStateRoot,
leaf: validatorRoot,
index: index
}),
"BeaconChainProofs.verifyValidatorFields: Invalid merkle proof"
);
}
/**
* @notice This function verifies the latestBlockHeader against the state root. the latestBlockHeader is
* a tracked in the beacon state.
* @param beaconStateRoot is the beacon chain state root to be proven against.
* @param stateRootProof is the provided merkle proof
* @param latestBlockRoot is hashtree root of the latest block header in the beacon state
*/
function verifyStateRootAgainstLatestBlockRoot(
bytes32 latestBlockRoot,
bytes32 beaconStateRoot,
bytes calldata stateRootProof
) internal view {
require(
stateRootProof.length == 32 * (BEACON_BLOCK_HEADER_FIELD_TREE_HEIGHT),
"BeaconChainProofs.verifyStateRootAgainstLatestBlockRoot: Proof has incorrect length"
);
//Next we verify the slot against the blockRoot
require(
EigenlayerMerkle.verifyInclusionSha256({
proof: stateRootProof,
root: latestBlockRoot,
leaf: beaconStateRoot,
index: STATE_ROOT_INDEX
}),
"BeaconChainProofs.verifyStateRootAgainstLatestBlockRoot: Invalid latest block header root merkle proof"
);
}
/**
* @notice This function verifies the slot and the withdrawal fields for a given withdrawal
* @param withdrawalProof is the provided set of merkle proofs
* @param withdrawalFields is the serialized withdrawal container to be proven
*/
function verifyWithdrawal(
bytes32 beaconStateRoot,
bytes32[] calldata withdrawalFields,
WithdrawalProof calldata withdrawalProof
) internal view {
require(
withdrawalFields.length == 2 ** WITHDRAWAL_FIELD_TREE_HEIGHT,
"BeaconChainProofs.verifyWithdrawal: withdrawalFields has incorrect length"
);
require(
withdrawalProof.blockRootIndex < 2 ** BLOCK_ROOTS_TREE_HEIGHT,
"BeaconChainProofs.verifyWithdrawal: blockRootIndex is too large"
);
require(
withdrawalProof.withdrawalIndex < 2 ** WITHDRAWALS_TREE_HEIGHT,
"BeaconChainProofs.verifyWithdrawal: withdrawalIndex is too large"
);
require(
withdrawalProof.historicalSummaryIndex < 2 ** HISTORICAL_SUMMARIES_TREE_HEIGHT,
"BeaconChainProofs.verifyWithdrawal: historicalSummaryIndex is too large"
);
require(
withdrawalProof.withdrawalProof.length ==
32 * (EXECUTION_PAYLOAD_HEADER_FIELD_TREE_HEIGHT + WITHDRAWALS_TREE_HEIGHT + 1),
"BeaconChainProofs.verifyWithdrawal: withdrawalProof has incorrect length"
);
require(
withdrawalProof.executionPayloadProof.length ==
32 * (BEACON_BLOCK_HEADER_FIELD_TREE_HEIGHT + BEACON_BLOCK_BODY_FIELD_TREE_HEIGHT),
"BeaconChainProofs.verifyWithdrawal: executionPayloadProof has incorrect length"
);
require(
withdrawalProof.slotProof.length == 32 * (BEACON_BLOCK_HEADER_FIELD_TREE_HEIGHT),
"BeaconChainProofs.verifyWithdrawal: slotProof has incorrect length"
);
require(
withdrawalProof.timestampProof.length == 32 * (EXECUTION_PAYLOAD_HEADER_FIELD_TREE_HEIGHT),
"BeaconChainProofs.verifyWithdrawal: timestampProof has incorrect length"
);
require(
withdrawalProof.historicalSummaryBlockRootProof.length ==
32 *
(BEACON_STATE_FIELD_TREE_HEIGHT +
(HISTORICAL_SUMMARIES_TREE_HEIGHT + 1) +
1 +
(BLOCK_ROOTS_TREE_HEIGHT)),
"BeaconChainProofs.verifyWithdrawal: historicalSummaryBlockRootProof has incorrect length"
);
/**
* Note: Here, the "1" in "1 + (BLOCK_ROOTS_TREE_HEIGHT)" signifies that extra step of choosing the "block_root_summary" within the individual
* "historical_summary". Everywhere else it signifies merkelize_with_mixin, where the length of an array is hashed with the root of the array,
* but not here.
*/
uint256 historicalBlockHeaderIndex = (HISTORICAL_SUMMARIES_INDEX <<
((HISTORICAL_SUMMARIES_TREE_HEIGHT + 1) + 1 + (BLOCK_ROOTS_TREE_HEIGHT))) |
(uint256(withdrawalProof.historicalSummaryIndex) << (1 + (BLOCK_ROOTS_TREE_HEIGHT))) |
(BLOCK_SUMMARY_ROOT_INDEX << (BLOCK_ROOTS_TREE_HEIGHT)) |
uint256(withdrawalProof.blockRootIndex);
require(
EigenlayerMerkle.verifyInclusionSha256({
proof: withdrawalProof.historicalSummaryBlockRootProof,
root: beaconStateRoot,
leaf: withdrawalProof.blockRoot,
index: historicalBlockHeaderIndex
}),
"BeaconChainProofs.verifyWithdrawal: Invalid historicalsummary merkle proof"
);
//Next we verify the slot against the blockRoot
require(
EigenlayerMerkle.verifyInclusionSha256({
proof: withdrawalProof.slotProof,
root: withdrawalProof.blockRoot,
leaf: withdrawalProof.slotRoot,
index: SLOT_INDEX
}),
"BeaconChainProofs.verifyWithdrawal: Invalid slot merkle proof"
);
{
// Next we verify the executionPayloadRoot against the blockRoot
uint256 executionPayloadIndex = (BODY_ROOT_INDEX << (BEACON_BLOCK_BODY_FIELD_TREE_HEIGHT)) |
EXECUTION_PAYLOAD_INDEX;
require(
EigenlayerMerkle.verifyInclusionSha256({
proof: withdrawalProof.executionPayloadProof,
root: withdrawalProof.blockRoot,
leaf: withdrawalProof.executionPayloadRoot,
index: executionPayloadIndex
}),
"BeaconChainProofs.verifyWithdrawal: Invalid executionPayload merkle proof"
);
}
// Next we verify the timestampRoot against the executionPayload root
require(
EigenlayerMerkle.verifyInclusionSha256({
proof: withdrawalProof.timestampProof,
root: withdrawalProof.executionPayloadRoot,
leaf: withdrawalProof.timestampRoot,
index: TIMESTAMP_INDEX
}),
"BeaconChainProofs.verifyWithdrawal: Invalid blockNumber merkle proof"
);
{
/**
* Next we verify the withdrawal fields against the blockRoot:
* First we compute the withdrawal_index relative to the blockRoot by concatenating the indexes of all the
* intermediate root indexes from the bottom of the sub trees (the withdrawal container) to the top, the blockRoot.
* Then we calculate merkleize the withdrawalFields container to calculate the the withdrawalRoot.
* Finally we verify the withdrawalRoot against the executionPayloadRoot.
*
*
* Note: EigenlayerMerkleization of the withdrawals root tree uses EigenlayerMerkleizeWithMixin, i.e., the length of the array is hashed with the root of
* the array. Thus we shift the WITHDRAWALS_INDEX over by WITHDRAWALS_TREE_HEIGHT + 1 and not just WITHDRAWALS_TREE_HEIGHT.
*/
uint256 withdrawalIndex = (WITHDRAWALS_INDEX << (WITHDRAWALS_TREE_HEIGHT + 1)) |
uint256(withdrawalProof.withdrawalIndex);
bytes32 withdrawalRoot = EigenlayerMerkle.merkleizeSha256(withdrawalFields);
require(
EigenlayerMerkle.verifyInclusionSha256({
proof: withdrawalProof.withdrawalProof,
root: withdrawalProof.executionPayloadRoot,
leaf: withdrawalRoot,
index: withdrawalIndex
}),
"BeaconChainProofs.verifyWithdrawal: Invalid withdrawal merkle proof"
);
}
}
/**
* @notice This function replicates the ssz hashing of a validator's pubkey, outlined below:
* hh := ssz.NewHasher()
* hh.PutBytes(validatorPubkey[:])
* validatorPubkeyHash := hh.Hash()
* hh.Reset()
*/
function hashValidatorBLSPubkey(bytes memory validatorPubkey) internal pure returns (bytes32 pubkeyHash) {
require(validatorPubkey.length == 48, "Input should be 48 bytes in length");
return sha256(abi.encodePacked(validatorPubkey, bytes16(0)));
}
/**
* @dev Retrieve the withdrawal timestamp
*/
function getWithdrawalTimestamp(WithdrawalProof memory withdrawalProof) internal pure returns (uint64) {
return
Endian.fromLittleEndianUint64(withdrawalProof.timestampRoot);
}
/**
* @dev Converts the withdrawal's slot to an epoch
*/
function getWithdrawalEpoch(WithdrawalProof memory withdrawalProof) internal pure returns (uint64) {
return
Endian.fromLittleEndianUint64(withdrawalProof.slotRoot) / SLOTS_PER_EPOCH;
}
/**
* Indices for validator fields (refer to consensus specs):
* 0: pubkey
* 1: withdrawal credentials
* 2: effective balance
* 3: slashed?
* 4: activation elligibility epoch
* 5: activation epoch
* 6: exit epoch
* 7: withdrawable epoch
*/
/**
* @dev Retrieves a validator's pubkey hash
*/
function getPubkeyHash(bytes32[] memory validatorFields) internal pure returns (bytes32) {
return
validatorFields[VALIDATOR_PUBKEY_INDEX];
}
function getWithdrawalCredentials(bytes32[] memory validatorFields) internal pure returns (bytes32) {
return
validatorFields[VALIDATOR_WITHDRAWAL_CREDENTIALS_INDEX];
}
/**
* @dev Retrieves a validator's effective balance (in gwei)
*/
function getEffectiveBalanceGwei(bytes32[] memory validatorFields) internal pure returns (uint64) {
return
Endian.fromLittleEndianUint64(validatorFields[VALIDATOR_BALANCE_INDEX]);
}
/**
* @dev Retrieves a validator's withdrawable epoch
*/
function getWithdrawableEpoch(bytes32[] memory validatorFields) internal pure returns (uint64) {
return
Endian.fromLittleEndianUint64(validatorFields[VALIDATOR_WITHDRAWABLE_EPOCH_INDEX]);
}
/**
* Indices for withdrawal fields (refer to consensus specs):
* 0: withdrawal index
* 1: validator index
* 2: execution address
* 3: withdrawal amount
*/
/**
* @dev Retrieves a withdrawal's validator index
*/
function getValidatorIndex(bytes32[] memory withdrawalFields) internal pure returns (uint40) {
return
uint40(Endian.fromLittleEndianUint64(withdrawalFields[WITHDRAWAL_VALIDATOR_INDEX_INDEX]));
}
/**
* @dev Retrieves a withdrawal's withdrawal amount (in gwei)
*/
function getWithdrawalAmountGwei(bytes32[] memory withdrawalFields) internal pure returns (uint64) {
return
Endian.fromLittleEndianUint64(withdrawalFields[WITHDRAWAL_VALIDATOR_AMOUNT_INDEX]);
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
import "./EigenlayerMerkle.sol";
import "./Endian.sol";
//Utility library for parsing and PHASE0 beacon chain block headers
//SSZ Spec: https://github.com/ethereum/consensus-specs/blob/dev/ssz/simple-serialize.md#merkleization
//BeaconBlockHeader Spec: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#beaconblockheader
//BeaconState Spec: https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#beaconstate
library BeaconChainProofs {
/// @notice Heights of various merkle trees in the beacon chain
/// - beaconBlockRoot
/// | HEIGHT: BEACON_BLOCK_HEADER_TREE_HEIGHT
/// -- beaconStateRoot
/// | HEIGHT: BEACON_STATE_TREE_HEIGHT
/// validatorContainerRoot, balanceContainerRoot
/// | | HEIGHT: BALANCE_TREE_HEIGHT
/// | individual balances
/// | HEIGHT: VALIDATOR_TREE_HEIGHT
/// individual validators
uint256 internal constant BEACON_BLOCK_HEADER_TREE_HEIGHT = 3;
uint256 internal constant BEACON_STATE_TREE_HEIGHT = 5;
uint256 internal constant BALANCE_TREE_HEIGHT = 38;
uint256 internal constant VALIDATOR_TREE_HEIGHT = 40;
/// @notice Index of the beaconStateRoot in the `BeaconBlockHeader` container
///
/// BeaconBlockHeader = [..., state_root, ...]
/// 0... 3
///
/// (See https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#beaconblockheader)
uint256 internal constant STATE_ROOT_INDEX = 3;
/// @notice Indices for fields in the `BeaconState` container
///
/// BeaconState = [..., validators, balances, ...]
/// 0... 11 12
///
/// (See https://github.com/ethereum/consensus-specs/blob/dev/specs/capella/beacon-chain.md#beaconstate)
uint256 internal constant VALIDATOR_CONTAINER_INDEX = 11;
uint256 internal constant BALANCE_CONTAINER_INDEX = 12;
/// @notice Number of fields in the `Validator` container
/// (See https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#validator)
uint256 internal constant VALIDATOR_FIELDS_LENGTH = 8;
/// @notice Indices for fields in the `Validator` container
uint256 internal constant VALIDATOR_PUBKEY_INDEX = 0;
uint256 internal constant VALIDATOR_WITHDRAWAL_CREDENTIALS_INDEX = 1;
uint256 internal constant VALIDATOR_BALANCE_INDEX = 2;
uint256 internal constant VALIDATOR_SLASHED_INDEX = 3;
uint256 internal constant VALIDATOR_EXIT_EPOCH_INDEX = 6;
/// @notice Slot/Epoch timings
uint64 internal constant SECONDS_PER_SLOT = 12;
uint64 internal constant SLOTS_PER_EPOCH = 32;
uint64 internal constant SECONDS_PER_EPOCH = SLOTS_PER_EPOCH * SECONDS_PER_SLOT;
/// @notice `FAR_FUTURE_EPOCH` is used as the default value for certain `Validator`
/// fields when a `Validator` is first created on the beacon chain
uint64 internal constant FAR_FUTURE_EPOCH = type(uint64).max;
bytes8 internal constant UINT64_MASK = 0xffffffffffffffff;
/// @notice Contains a beacon state root and a merkle proof verifying its inclusion under a beacon block root
struct StateRootProof {
bytes32 beaconStateRoot;
bytes proof;
}
/// @notice Contains a validator's fields and a merkle proof of their inclusion under a beacon state root
struct ValidatorProof {
bytes32[] validatorFields;
bytes proof;
}
/// @notice Contains a beacon balance container root and a proof of this root under a beacon block root
struct BalanceContainerProof {
bytes32 balanceContainerRoot;
bytes proof;
}
/// @notice Contains a validator balance root and a proof of its inclusion under a balance container root
struct BalanceProof {
bytes32 pubkeyHash;
bytes32 balanceRoot;
bytes proof;
}
/*******************************************************************************
VALIDATOR FIELDS -> BEACON STATE ROOT -> BEACON BLOCK ROOT
*******************************************************************************/
/// @notice Verify a merkle proof of the beacon state root against a beacon block root
/// @param beaconBlockRoot merkle root of the beacon block
/// @param proof the beacon state root and merkle proof of its inclusion under `beaconBlockRoot`
function verifyStateRoot(
bytes32 beaconBlockRoot,
StateRootProof calldata proof
) internal view {
require(
proof.proof.length == 32 * (BEACON_BLOCK_HEADER_TREE_HEIGHT),
"BeaconChainProofs.verifyStateRoot: Proof has incorrect length"
);
/// This merkle proof verifies the `beaconStateRoot` under the `beaconBlockRoot`
/// - beaconBlockRoot
/// | HEIGHT: BEACON_BLOCK_HEADER_TREE_HEIGHT
/// -- beaconStateRoot
require(
EigenlayerMerkle.verifyInclusionSha256({
proof: proof.proof,
root: beaconBlockRoot,
leaf: proof.beaconStateRoot,
index: STATE_ROOT_INDEX
}),
"BeaconChainProofs.verifyStateRoot: Invalid state root merkle proof"
);
}
/// @notice Verify a merkle proof of a validator container against a `beaconStateRoot`
/// @dev This proof starts at a validator's container root, proves through the validator container root,
/// and continues proving to the root of the `BeaconState`
/// @dev See https://eth2book.info/capella/part3/containers/dependencies/#validator for info on `Validator` containers
/// @dev See https://eth2book.info/capella/part3/containers/state/#beaconstate for info on `BeaconState` containers
/// @param beaconStateRoot merkle root of the `BeaconState` container
/// @param validatorFields an individual validator's fields. These are merklized to form a `validatorRoot`,
/// which is used as the leaf to prove against `beaconStateRoot`
/// @param validatorFieldsProof a merkle proof of inclusion of `validatorFields` under `beaconStateRoot`
/// @param validatorIndex the validator's unique index
function verifyValidatorFields(
bytes32 beaconStateRoot,
bytes32[] calldata validatorFields,
bytes calldata validatorFieldsProof,
uint40 validatorIndex
) internal view {
require(
validatorFields.length == VALIDATOR_FIELDS_LENGTH,
"BeaconChainProofs.verifyValidatorFields: Validator fields has incorrect length"
);
/// Note: the reason we use `VALIDATOR_TREE_HEIGHT + 1` here is because the merklization process for
/// this container includes hashing the root of the validator tree with the length of the validator list
require(
validatorFieldsProof.length == 32 * ((VALIDATOR_TREE_HEIGHT + 1) + BEACON_STATE_TREE_HEIGHT),
"BeaconChainProofs.verifyValidatorFields: Proof has incorrect length"
);
// Merkleize `validatorFields` to get the leaf to prove
bytes32 validatorRoot = EigenlayerMerkle.merkleizeSha256(validatorFields);
/// This proof combines two proofs, so its index accounts for the relative position of leaves in two trees:
/// - beaconStateRoot
/// | HEIGHT: BEACON_STATE_TREE_HEIGHT
/// -- validatorContainerRoot
/// | HEIGHT: VALIDATOR_TREE_HEIGHT + 1
/// ---- validatorRoot
uint256 index = (VALIDATOR_CONTAINER_INDEX << (VALIDATOR_TREE_HEIGHT + 1)) | uint256(validatorIndex);
require(
EigenlayerMerkle.verifyInclusionSha256({
proof: validatorFieldsProof,
root: beaconStateRoot,
leaf: validatorRoot,
index: index
}),
"BeaconChainProofs.verifyValidatorFields: Invalid merkle proof"
);
}
/*******************************************************************************
VALIDATOR BALANCE -> BALANCE CONTAINER ROOT -> BEACON BLOCK ROOT
*******************************************************************************/
/// @notice Verify a merkle proof of the beacon state's balances container against the beacon block root
/// @dev This proof starts at the balance container root, proves through the beacon state root, and
/// continues proving through the beacon block root. As a result, this proof will contain elements
/// of a `StateRootProof` under the same block root, with the addition of proving the balances field
/// within the beacon state.
/// @dev This is used to make checkpoint proofs more efficient, as a checkpoint will verify multiple balances
/// against the same balance container root.
/// @param beaconBlockRoot merkle root of the beacon block
/// @param proof a beacon balance container root and merkle proof of its inclusion under `beaconBlockRoot`
function verifyBalanceContainer(
bytes32 beaconBlockRoot,
BalanceContainerProof calldata proof
) internal view {
require(
proof.proof.length == 32 * (BEACON_BLOCK_HEADER_TREE_HEIGHT + BEACON_STATE_TREE_HEIGHT),
"BeaconChainProofs.verifyBalanceContainer: Proof has incorrect length"
);
/// This proof combines two proofs, so its index accounts for the relative position of leaves in two trees:
/// - beaconBlockRoot
/// | HEIGHT: BEACON_BLOCK_HEADER_TREE_HEIGHT
/// -- beaconStateRoot
/// | HEIGHT: BEACON_STATE_TREE_HEIGHT
/// ---- balancesContainerRoot
uint256 index = (STATE_ROOT_INDEX << (BEACON_STATE_TREE_HEIGHT)) | BALANCE_CONTAINER_INDEX;
require(
EigenlayerMerkle.verifyInclusionSha256({
proof: proof.proof,
root: beaconBlockRoot,
leaf: proof.balanceContainerRoot,
index: index
}),
"BeaconChainProofs.verifyBalanceContainer: invalid balance container proof"
);
}
/// @notice Verify a merkle proof of a validator's balance against the beacon state's `balanceContainerRoot`
/// @param balanceContainerRoot the merkle root of all validators' current balances
/// @param validatorIndex the index of the validator whose balance we are proving
/// @param proof the validator's associated balance root and a merkle proof of inclusion under `balanceContainerRoot`
/// @return validatorBalanceGwei the validator's current balance (in gwei)
function verifyValidatorBalance(
bytes32 balanceContainerRoot,
uint40 validatorIndex,
BalanceProof calldata proof
) internal view returns (uint64 validatorBalanceGwei) {
/// Note: the reason we use `BALANCE_TREE_HEIGHT + 1` here is because the merklization process for
/// this container includes hashing the root of the balances tree with the length of the balances list
require(
proof.proof.length == 32 * (BALANCE_TREE_HEIGHT + 1),
"BeaconChainProofs.verifyValidatorBalance: Proof has incorrect length"
);
/// When merkleized, beacon chain balances are combined into groups of 4 called a `balanceRoot`. The merkle
/// proof here verifies that this validator's `balanceRoot` is included in the `balanceContainerRoot`
/// - balanceContainerRoot
/// | HEIGHT: BALANCE_TREE_HEIGHT
/// -- balanceRoot
uint256 balanceIndex = uint256(validatorIndex / 4);
require(
EigenlayerMerkle.verifyInclusionSha256({
proof: proof.proof,
root: balanceContainerRoot,
leaf: proof.balanceRoot,
index: balanceIndex
}),
"BeaconChainProofs.verifyValidatorBalance: Invalid merkle proof"
);
/// Extract the individual validator's balance from the `balanceRoot`
return getBalanceAtIndex(proof.balanceRoot, validatorIndex);
}
/**
* @notice Parses a balanceRoot to get the uint64 balance of a validator.
* @dev During merkleization of the beacon state balance tree, four uint64 values are treated as a single
* leaf in the merkle tree. We use validatorIndex % 4 to determine which of the four uint64 values to
* extract from the balanceRoot.
* @param balanceRoot is the combination of 4 validator balances being proven for
* @param validatorIndex is the index of the validator being proven for
* @return The validator's balance, in Gwei
*/
function getBalanceAtIndex(bytes32 balanceRoot, uint40 validatorIndex) internal pure returns (uint64) {
uint256 bitShiftAmount = (validatorIndex % 4) * 64;
return
Endian.fromLittleEndianUint64(bytes32((uint256(balanceRoot) << bitShiftAmount)));
}
/// @notice Indices for fields in the `Validator` container:
/// 0: pubkey
/// 1: withdrawal credentials
/// 2: effective balance
/// 3: slashed?
/// 4: activation elligibility epoch
/// 5: activation epoch
/// 6: exit epoch
/// 7: withdrawable epoch
///
/// (See https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#validator)
/// @dev Retrieves a validator's pubkey hash
function getPubkeyHash(bytes32[] memory validatorFields) internal pure returns (bytes32) {
return
validatorFields[VALIDATOR_PUBKEY_INDEX];
}
/// @dev Retrieves a validator's withdrawal credentials
function getWithdrawalCredentials(bytes32[] memory validatorFields) internal pure returns (bytes32) {
return
validatorFields[VALIDATOR_WITHDRAWAL_CREDENTIALS_INDEX];
}
/// @dev Retrieves a validator's effective balance (in gwei)
function getEffectiveBalanceGwei(bytes32[] memory validatorFields) internal pure returns (uint64) {
return
Endian.fromLittleEndianUint64(validatorFields[VALIDATOR_BALANCE_INDEX]);
}
/// @dev Retrieves true IFF a validator is marked slashed
function isValidatorSlashed(bytes32[] memory validatorFields) internal pure returns (bool) {
return validatorFields[VALIDATOR_SLASHED_INDEX] != 0;
}
/// @dev Retrieves a validator's exit epoch
function getExitEpoch(bytes32[] memory validatorFields) internal pure returns (uint64) {
return
Endian.fromLittleEndianUint64(validatorFields[VALIDATOR_EXIT_EPOCH_INDEX]);
}
}// SPDX-License-Identifier: BUSL-1.1
// Adapted from OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/MerkleProof.sol)
pragma solidity ^0.8.0;
/**
* @dev These functions deal with verification of Merkle Tree proofs.
*
* The tree and the proofs can be generated using our
* https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
* You will find a quickstart guide in the readme.
*
* WARNING: You should avoid using leaf values that are 64 bytes long prior to
* hashing, or use a hash function other than keccak256 for hashing leaves.
* This is because the concatenation of a sorted pair of internal nodes in
* the merkle tree could be reinterpreted as a leaf value.
* OpenZeppelin's JavaScript library generates merkle trees that are safe
* against this attack out of the box.
*/
library EigenlayerMerkle {
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. The tree is built assuming `leaf` is
* the 0 indexed `index`'th leaf from the bottom left of the tree.
*
* Note this is for a Merkle tree using the keccak/sha3 hash function
*/
function verifyInclusionKeccak(
bytes memory proof,
bytes32 root,
bytes32 leaf,
uint256 index
) internal pure returns (bool) {
return processInclusionProofKeccak(proof, leaf, index) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. The tree is built assuming `leaf` is
* the 0 indexed `index`'th leaf from the bottom left of the tree.
*
* _Available since v4.4._
*
* Note this is for a Merkle tree using the keccak/sha3 hash function
*/
function processInclusionProofKeccak(
bytes memory proof,
bytes32 leaf,
uint256 index
) internal pure returns (bytes32) {
require(
proof.length != 0 && proof.length % 32 == 0,
"Merkle.processInclusionProofKeccak: proof length should be a non-zero multiple of 32"
);
bytes32 computedHash = leaf;
for (uint256 i = 32; i <= proof.length; i += 32) {
if (index % 2 == 0) {
// if ith bit of index is 0, then computedHash is a left sibling
assembly {
mstore(0x00, computedHash)
mstore(0x20, mload(add(proof, i)))
computedHash := keccak256(0x00, 0x40)
index := div(index, 2)
}
} else {
// if ith bit of index is 1, then computedHash is a right sibling
assembly {
mstore(0x00, mload(add(proof, i)))
mstore(0x20, computedHash)
computedHash := keccak256(0x00, 0x40)
index := div(index, 2)
}
}
}
return computedHash;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. The tree is built assuming `leaf` is
* the 0 indexed `index`'th leaf from the bottom left of the tree.
*
* Note this is for a Merkle tree using the sha256 hash function
*/
function verifyInclusionSha256(
bytes memory proof,
bytes32 root,
bytes32 leaf,
uint256 index
) internal view returns (bool) {
return processInclusionProofSha256(proof, leaf, index) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. The tree is built assuming `leaf` is
* the 0 indexed `index`'th leaf from the bottom left of the tree.
*
* _Available since v4.4._
*
* Note this is for a Merkle tree using the sha256 hash function
*/
function processInclusionProofSha256(
bytes memory proof,
bytes32 leaf,
uint256 index
) internal view returns (bytes32) {
require(
proof.length != 0 && proof.length % 32 == 0,
"Merkle.processInclusionProofSha256: proof length should be a non-zero multiple of 32"
);
bytes32[1] memory computedHash = [leaf];
for (uint256 i = 32; i <= proof.length; i += 32) {
if (index % 2 == 0) {
// if ith bit of index is 0, then computedHash is a left sibling
assembly {
mstore(0x00, mload(computedHash))
mstore(0x20, mload(add(proof, i)))
if iszero(staticcall(sub(gas(), 2000), 2, 0x00, 0x40, computedHash, 0x20)) {
revert(0, 0)
}
index := div(index, 2)
}
} else {
// if ith bit of index is 1, then computedHash is a right sibling
assembly {
mstore(0x00, mload(add(proof, i)))
mstore(0x20, mload(computedHash))
if iszero(staticcall(sub(gas(), 2000), 2, 0x00, 0x40, computedHash, 0x20)) {
revert(0, 0)
}
index := div(index, 2)
}
}
}
return computedHash[0];
}
/**
@notice this function returns the merkle root of a tree created from a set of leaves using sha256 as its hash function
@param leaves the leaves of the merkle tree
@return The computed Merkle root of the tree.
@dev A pre-condition to this function is that leaves.length is a power of two. If not, the function will merkleize the inputs incorrectly.
*/
function merkleizeSha256(bytes32[] memory leaves) internal pure returns (bytes32) {
//there are half as many nodes in the layer above the leaves
uint256 numNodesInLayer = leaves.length / 2;
//create a layer to store the internal nodes
bytes32[] memory layer = new bytes32[](numNodesInLayer);
//fill the layer with the pairwise hashes of the leaves
for (uint256 i = 0; i < numNodesInLayer; i++) {
layer[i] = sha256(abi.encodePacked(leaves[2 * i], leaves[2 * i + 1]));
}
//the next layer above has half as many nodes
numNodesInLayer /= 2;
//while we haven't computed the root
while (numNodesInLayer != 0) {
//overwrite the first numNodesInLayer nodes in layer with the pairwise hashes of their children
for (uint256 i = 0; i < numNodesInLayer; i++) {
layer[i] = sha256(abi.encodePacked(layer[2 * i], layer[2 * i + 1]));
}
//the next layer above has half as many nodes
numNodesInLayer /= 2;
}
//the first node in the layer is the root
return layer[0];
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
library Endian {
/**
* @notice Converts a little endian-formatted uint64 to a big endian-formatted uint64
* @param lenum little endian-formatted uint64 input, provided as 'bytes32' type
* @return n The big endian-formatted uint64
* @dev Note that the input is formatted as a 'bytes32' type (i.e. 256 bits), but it is immediately truncated to a uint64 (i.e. 64 bits)
* through a right-shift/shr operation.
*/
function fromLittleEndianUint64(bytes32 lenum) internal pure returns (uint64 n) {
// the number needs to be stored in little-endian encoding (ie in bytes 0-8)
n = uint64(uint256(lenum >> 192));
return
(n >> 56) |
((0x00FF000000000000 & n) >> 40) |
((0x0000FF0000000000 & n) >> 24) |
((0x000000FF00000000 & n) >> 8) |
((0x00000000FF000000 & n) << 8) |
((0x0000000000FF0000 & n) << 24) |
((0x000000000000FF00 & n) << 40) |
((0x00000000000000FF & n) << 56);
}
}{
"remappings": [
"forge-std/=lib/forge-std/src/",
"@openzeppelin/=lib/openzeppelin-contracts/",
"@openzeppelin-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
"@uniswap/=lib/",
"@eigenlayer/=lib/eigenlayer-contracts/src/",
"@layerzerolabs/lz-evm-oapp-v2/contracts/=lib/Etherfi-SyncPools/node_modules/@layerzerolabs/lz-evm-oapp-v2/contracts/",
"@layerzerolabs/lz-evm-protocol-v2/contracts/=lib/Etherfi-SyncPools/node_modules/@layerzerolabs/lz-evm-protocol-v2/contracts/",
"@layerzerolabs/lz-evm-messagelib-v2/contracts/=lib/Etherfi-SyncPools/node_modules/@layerzerolabs/lz-evm-messagelib-v2/contracts/",
"@layerzerolabs/lz-evm-oapp-v2/contracts-upgradeable/=lib/Etherfi-SyncPools/node_modules/layerzero-v2/oapp/contracts/",
"ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"solady/=lib/solady/src/",
"v3-core/=lib/v3-core/",
"v3-periphery/=lib/v3-periphery/contracts/"
],
"optimizer": {
"enabled": true,
"runs": 2000
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "none",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "cancun",
"viaIR": false,
"libraries": {
"lib/BucketLimiter.sol": {
"BucketLimiter": "0x9B526fE8c080D8F7824CF58cD070640228E59F4A"
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"DataNotSet","type":"error"},{"inputs":[],"name":"IncorrectCaller","type":"error"},{"inputs":[],"name":"IncorrectRole","type":"error"},{"inputs":[],"name":"InsufficientLiquidity","type":"error"},{"inputs":[],"name":"InvalidAmount","type":"error"},{"inputs":[],"name":"SendFail","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"}],"name":"BnftHolderDeregistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"index","type":"uint256"}],"name":"BnftHolderRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"enum ILiquidityPool.SourceOfFunds","name":"source","type":"uint8"},{"indexed":false,"internalType":"address","name":"referral","type":"address"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","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":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint128","name":"protocolFees","type":"uint128"}],"name":"ProtocolFeePaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"totalEthLocked","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalEEthShares","type":"uint256"}],"name":"Rebase","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newFeeRecipient","type":"address"}],"name":"UpdatedFeeRecipient","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newTreasury","type":"address"}],"name":"UpdatedTreasury","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"userAddress","type":"address"},{"indexed":false,"internalType":"bool","name":"value","type":"bool"}],"name":"UpdatedWhitelist","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"validatorId","type":"uint256"}],"name":"ValidatorApproved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"validatorId","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"signature","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"pubKey","type":"bytes"},{"indexed":false,"internalType":"bytes32","name":"depositRoot","type":"bytes32"}],"name":"ValidatorRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"validatorId","type":"uint256"}],"name":"ValidatorRegistrationCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"}],"name":"ValidatorSpawnerRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"}],"name":"ValidatorSpawnerUnregistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"value","type":"bool"}],"name":"WhitelistStatusUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"enum ILiquidityPool.SourceOfFunds","name":"source","type":"uint8"}],"name":"Withdraw","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"DEPRECATED_admins","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEPRECATED_bNftTreasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"DEPRECATED_bnftHolders","outputs":[{"internalType":"address","name":"holder","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEPRECATED_eEthliquidStakingOpened","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"enum ILiquidityPool.SourceOfFunds","name":"","type":"uint8"}],"name":"DEPRECATED_fundStatistics","outputs":[{"internalType":"uint32","name":"numberOfValidators","type":"uint32"},{"internalType":"uint32","name":"targetWeight","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEPRECATED_holdersUpdate","outputs":[{"internalType":"uint32","name":"timestamp","type":"uint32"},{"internalType":"uint32","name":"startOfSlotNumOwners","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEPRECATED_maxValidatorsPerOwner","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEPRECATED_regulationsManager","outputs":[{"internalType":"contract IRegulationsManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEPRECATED_schedulingPeriodInSeconds","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEPRECATED_whitelistEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"DEPRECATED_whitelisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LIQUIDITY_POOL_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint128","name":"_amount","type":"uint128"}],"name":"addEthAmountLockedForWithdrawal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_share","type":"uint256"}],"name":"amountForShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"auctionManager","outputs":[{"internalType":"contract IAuctionManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_validatorIds","type":"uint256[]"},{"internalType":"bytes[]","name":"_pubKey","type":"bytes[]"},{"internalType":"bytes[]","name":"_signature","type":"bytes[]"}],"name":"batchApproveRegistration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_validatorIds","type":"uint256[]"}],"name":"batchCancelDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_candidateBidIds","type":"uint256[]"},{"internalType":"uint256","name":"_numberOfValidators","type":"uint256"},{"internalType":"uint256","name":"_validatorIdToShareSafeWith","type":"uint256"}],"name":"batchDeposit","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_candidateBidIds","type":"uint256[]"},{"internalType":"uint256","name":"_numberOfValidators","type":"uint256"}],"name":"batchDeposit","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_depositRoot","type":"bytes32"},{"internalType":"uint256[]","name":"_validatorIds","type":"uint256[]"},{"components":[{"internalType":"bytes","name":"publicKey","type":"bytes"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"bytes32","name":"depositDataRoot","type":"bytes32"},{"internalType":"string","name":"ipfsHashForEncryptedValidatorKey","type":"string"}],"internalType":"struct IStakingManager.DepositData[]","name":"_registerValidatorDepositData","type":"tuple[]"},{"internalType":"bytes32[]","name":"_depositDataRootApproval","type":"bytes32[]"},{"internalType":"bytes[]","name":"_signaturesForApprovalDeposit","type":"bytes[]"}],"name":"batchRegister","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"burnEEthShares","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"deposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_referral","type":"address"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"address","name":"_referral","type":"address"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"depositDataRootForApprovalDeposits","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_referral","type":"address"}],"name":"depositToRecipient","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"eETH","outputs":[{"internalType":"contract IeETH","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ethAmountLockedForWithdrawal","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"etherFiAdminContract","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"etherFiRedemptionManager","outputs":[{"internalType":"contract EtherFiRedemptionManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeRecipient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getImplementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"getTotalEtherClaimOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTotalPooledEther","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_eEthAddress","type":"address"},{"internalType":"address","name":"_stakingManagerAddress","type":"address"},{"internalType":"address","name":"_nodesManagerAddress","type":"address"},{"internalType":"address","name":"_membershipManagerAddress","type":"address"},{"internalType":"address","name":"_tNftAddress","type":"address"},{"internalType":"address","name":"_etherFiAdminContract","type":"address"},{"internalType":"address","name":"_withdrawRequestNFT","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_auctionManager","type":"address"},{"internalType":"address","name":"_liquifier","type":"address"}],"name":"initializeOnUpgrade","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_roleRegistry","type":"address"},{"internalType":"address","name":"_etherFiRedemptionManager","type":"address"}],"name":"initializeVTwoDotFourNine","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"liquifier","outputs":[{"internalType":"contract ILiquifier","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"membershipManager","outputs":[{"internalType":"contract IMembershipManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nodesManager","outputs":[{"internalType":"contract IEtherFiNodesManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"numPendingDeposits","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pauseContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint128","name":"_protocolFees","type":"uint128"}],"name":"payProtocolFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"int128","name":"_accruedRewards","type":"int128"}],"name":"rebase","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"registerValidatorSpawner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"fee","type":"uint256"}],"name":"requestMembershipNFTWithdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"requestWithdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct ILiquidityPool.PermitInput","name":"_permit","type":"tuple"}],"name":"requestWithdrawWithPermit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"restakeBnftDeposits","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"roleRegistry","outputs":[{"internalType":"contract RoleRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_validatorIds","type":"uint256[]"}],"name":"sendExitRequests","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feeRecipient","type":"address"}],"name":"setFeeRecipient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_restake","type":"bool"}],"name":"setRestakeBnftDeposits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_eEthWeight","type":"uint32"},{"internalType":"uint32","name":"_etherFanWeight","type":"uint32"}],"name":"setStakingTargetWeights","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"sharesForAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"sharesForWithdrawalAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stakingManager","outputs":[{"internalType":"contract IStakingManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tNft","outputs":[{"internalType":"contract ITNFT","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalValueInLp","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalValueOutOfLp","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unPauseContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"unregisterValidatorSpawner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"validatorSpawner","outputs":[{"internalType":"bool","name":"registered","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawRequestNFT","outputs":[{"internalType":"contract IWithdrawRequestNFT","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
60a06040523060805234801562000014575f80fd5b506200001f62000025565b620000e4565b5f54610100900460ff1615620000915760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b5f5460ff9081161015620000e2575f805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b608051615563620001195f395f8181611d0a01528181611da001528181612551015281816125e7015261280701526155635ff3fe608060405260043610610486575f3560e01c8063561bddf811610251578063c00c2d731161013c578063e74b981b116100b7578063f31f6aeb11610087578063f3fef3a31161006d578063f3fef3a314610e35578063f9609f0814610e54578063fc6dfe4e14610e67575f80fd5b8063f31f6aeb14610e03578063f340fa0114610e22575f80fd5b8063e74b981b14610d87578063ee30511614610da6578063f2c5998a14610dc5578063f2fde38b14610de4575f80fd5b8063d6951aa91161010c578063da8ed1f7116100f2578063da8ed1f714610d11578063dcbfb6c314610d30578063e453793414610d4f575f80fd5b8063d6951aa914610cce578063da79205814610ced575f80fd5b8063c00c2d7314610c60578063c98bea5b14610c7f578063caf4b5a414610ca7578063d0e30db014610cc6575f80fd5b8063917266fa116101cc578063b0192f9a1161019c578063bac1520311610182578063bac1520314610c01578063beed30a114610c15578063c00b2d6114610c41575f80fd5b8063b0192f9a14610bc3578063b46a130e14610be2575f80fd5b8063917266fa14610b435780639795947314610b625780639a8a302b14610b90578063aaf10f4214610baf575f80fd5b806371cb700f116102215780637c90fbf0116102075780637c90fbf014610ae157806389a8d9f514610b075780638da5cb5b14610b26575f80fd5b806371cb700f14610aa25780637346f1aa14610ac1575f80fd5b8063561bddf814610a3057806356f1199b14610a4f5780635c975abb14610a6e578063715018a614610a8e575f80fd5b806326d5d54a11610371578063456a23a6116102ec5780634c73f498116102bc57806351199700116102a257806351199700146109e457806352d1902d14610a0357806353f3fcb114610a17575f80fd5b80634c73f498146109b25780634f1ef286146109d1575f80fd5b8063456a23a6146109365780634690484014610955578063469963aa1461097457806346d4b71414610993575f80fd5b80633659cfe611610341578063397a1b2811610327578063397a1b28146108e45780633a53acb014610903578063439766ce14610922575f80fd5b80633659cfe6146108b157806337cfdaca146108d0575f80fd5b806326d5d54a146107ee57806328ac82e7146108485780632db004a3146108675780633587647614610892575f80fd5b806312c53c9b116104015780631991c225116103d15780631c6b4ed9116103b75780631c6b4ed9146107915780631e95e60e146107b057806322828cc2146107cf575f80fd5b80631991c225146107535780631aab9ef114610772575f80fd5b806312c53c9b146106d6578063158f8f59146106f65780631665f66d146107155780631729d10b14610734575f80fd5b806308c73259116104565780630ea9e8521161043c5780630ea9e85214610646578063109f51161461067957806310ddce8e14610698575f80fd5b806308c73259146105f05780630de371e214610627575f80fd5b806303dcfbdc1461054157806308061aeb1461057357806308388426146105b1578063086e16c0146105d2575f80fd5b3661053d576001600160801b033411156104b35760405163162908e360e11b815260040160405180910390fd5b60cf80543491905f906104d09084906001600160801b031661475b565b92506101000a8154816001600160801b0302191690836001600160801b031602179055503460cf60108282829054906101000a90046001600160801b0316610518919061477b565b92506101000a8154816001600160801b0302191690836001600160801b031602179055005b5f80fd5b34801561054c575f80fd5b5061056061055b3660046147b1565b610e95565b6040519081526020015b60405180910390f35b34801561057e575f80fd5b506105a161058d366004614813565b60db6020525f908152604090205460ff1681565b604051901515815260200161056a565b3480156105bc575f80fd5b506105d06105cb3660046148dc565b610f76565b005b3480156105dd575f80fd5b506105d06105ec3660046149d5565b5050565b3480156105fb575f80fd5b5060e05461060f906001600160a01b031681565b6040516001600160a01b03909116815260200161056a565b348015610632575f80fd5b5060ce5461060f906001600160a01b031681565b348015610651575f80fd5b506105607f0e8d94121b3383f03d9ae60b39295aa793469d7230d51a3f62cbf47cd45481d981565b348015610684575f80fd5b506105d0610693366004614a06565b611251565b3480156106a3575f80fd5b5060d4546106be90600160801b90046001600160801b031681565b6040516001600160801b03909116815260200161056a565b3480156106e1575f80fd5b5060ce546105a190600160a01b900460ff1681565b348015610701575f80fd5b506105d0610710366004614813565b611507565b348015610720575f80fd5b506105d061072f366004614acc565b611694565b34801561073f575f80fd5b5060de5461060f906001600160a01b031681565b34801561075e575f80fd5b506105d061076d366004614acc565b61170a565b34801561077d575f80fd5b5061056061078c366004614af2565b611791565b34801561079c575f80fd5b506105d06107ab366004614b22565b611929565b3480156107bb575f80fd5b5061060f6107ca366004614b61565b611a52565b3480156107da575f80fd5b5060c95461060f906001600160a01b031681565b3480156107f9575f80fd5b5061082b610808366004614b78565b60d76020525f908152604090205463ffffffff8082169164010000000090041682565b6040805163ffffffff93841681529290911660208301520161056a565b348015610853575f80fd5b5060cb5461060f906001600160a01b031681565b348015610872575f80fd5b50610560610881366004614b61565b60d86020525f908152604090205481565b34801561089d575f80fd5b506105d06108ac366004614b96565b611a7a565b3480156108bc575f80fd5b506105d06108cb366004614813565b611d00565b3480156108db575f80fd5b50610560611e9c565b3480156108ef575f80fd5b506105606108fe366004614c17565b611ecb565b34801561090e575f80fd5b5061056061091d366004614b61565b612039565b34801561092d575f80fd5b506105d06120ec565b348015610941575f80fd5b5060cf546106be906001600160801b031681565b348015610960575f80fd5b5060d05461060f906001600160a01b031681565b34801561097f575f80fd5b5060ca5461060f906001600160a01b031681565b34801561099e575f80fd5b506105d06109ad366004614c3f565b6122d0565b3480156109bd575f80fd5b506105d06109cc366004614c3f565b61246e565b6105d06109df366004614c67565b612547565b3480156109ef575f80fd5b506105606109fe366004614813565b6126d1565b348015610a0e575f80fd5b506105606127fb565b348015610a22575f80fd5b5060dc546105a19060ff1681565b348015610a3b575f80fd5b50610560610a4a366004614b61565b6128bf565b348015610a5a575f80fd5b506105d0610a69366004614813565b61294f565b348015610a79575f80fd5b5060dc546105a190600160881b900460ff1681565b348015610a99575f80fd5b506105d0612ac4565b348015610aad575f80fd5b5060d25461060f906001600160a01b031681565b348015610acc575f80fd5b5060d9546105a190600160a01b900460ff1681565b348015610aec575f80fd5b5060cf546106be90600160801b90046001600160801b031681565b348015610b12575f80fd5b506105d0610b21366004614b22565b612ad7565b348015610b31575f80fd5b506033546001600160a01b031661060f565b348015610b4e575f80fd5b50610560610b5d366004614b61565b612ce5565b348015610b6d575f80fd5b506105a1610b7c366004614813565b60da6020525f908152604090205460ff1681565b348015610b9b575f80fd5b5060d15461060f906001600160a01b031681565b348015610bba575f80fd5b5061060f612db9565b348015610bce575f80fd5b5060dd5461060f906001600160a01b031681565b348015610bed575f80fd5b50610560610bfc366004614d07565b612df0565b348015610c0c575f80fd5b506105d0612eac565b348015610c20575f80fd5b50610c34610c2f366004614d40565b613083565b60405161056a9190614dc7565b348015610c4c575f80fd5b506105d0610c5b366004614dd9565b613248565b348015610c6b575f80fd5b5060d95461060f906001600160a01b031681565b348015610c8a575f80fd5b5060d55461082b9063ffffffff8082169164010000000090041682565b348015610cb2575f80fd5b50610c34610cc1366004614df9565b613374565b61056061338a565b348015610cd9575f80fd5b5060d4546106be906001600160801b031681565b348015610cf8575f80fd5b5060dc546106be9061010090046001600160801b031681565b348015610d1c575f80fd5b506105d0610d2b366004614e4e565b613394565b348015610d3b575f80fd5b5060df5461060f906001600160a01b031681565b348015610d5a575f80fd5b5060d054610d7290600160a01b900463ffffffff1681565b60405163ffffffff909116815260200161056a565b348015610d92575f80fd5b506105d0610da1366004614813565b613454565b348015610db1575f80fd5b5060cc5461060f906001600160a01b031681565b348015610dd0575f80fd5b506105d0610ddf366004614b61565b61355c565b348015610def575f80fd5b506105d0610dfe366004614813565b61361b565b348015610e0e575f80fd5b5060cd5461060f906001600160a01b031681565b610560610e30366004614813565b6136a8565b348015610e40575f80fd5b50610560610e4f366004614c17565b61370a565b610560610e62366004614c3f565b6139fb565b348015610e72575f80fd5b506105a1610e81366004614813565b60d66020525f908152604090205460ff1681565b5f610e9e613aa2565b60ce546001600160a01b031663d505accf333085356020870135610ec86060890160408a01614e69565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e088901b1681526001600160a01b0395861660048201529490931660248501526044840191909152606483015260ff166084820152606085013560a4820152608085013560c482015260e4015f604051808303815f87803b158015610f50575f80fd5b505af1925050508015610f61575060015b50610f6c8484611ecb565b90505b9392505050565b610f7e613aa2565b60e054604051632474521560e21b81527f0e8d94121b3383f03d9ae60b39295aa793469d7230d51a3f62cbf47cd45481d960048201523360248201526001600160a01b03909116906391d1485490604401602060405180830381865afa158015610fea573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061100e9190614e89565b61102b5760405163209296a360e01b815260040160405180910390fd5b84518314801561103b5750845181145b61108c5760405162461bcd60e51b815260206004820152600e60248201527f6c656e677468732064696666657200000000000000000000000000000000000060448201526064015b60405180910390fd5b5f855167ffffffffffffffff8111156110a7576110a761482c565b6040519080825280602002602001820160405280156110d0578160200160208202803683370190505b5090505f5b86518110156111a25760d85f8883815181106110f3576110f3614ea4565b602002602001015181526020019081526020015f205482828151811061111b5761111b614ea4565b60200260200101818152505060d85f88838151811061113c5761113c614ea4565b602002602001015181526020019081526020015f205f905586818151811061116657611166614ea4565b60200260200101517f3a45f0697c2ad042d28b6679f70d695b90d55438dfbf3f43a44bba9dcf061c1960405160405180910390a26001016110d5565b505f86516801ae361fc1451c00006111ba9190614eb8565b90506111c581613afc565b60c9546040517f4cfc6c730000000000000000000000000000000000000000000000000000000081526001600160a01b0390911690634cfc6c7390839061121a908b908b908b908b908b908b90600401614f99565b5f604051808303818588803b158015611231575f80fd5b505af1158015611243573d5f803e3d5ffd5b505050505050505050505050565b611259613aa2565b335f90815260db6020526040902054309060ff166112ac5760405162461bcd60e51b815260206004820152601060248201526f24b731b7b93932b1ba1021b0b63632b960811b6044820152606401611083565b87861480156112ba57508784145b80156112c557508782145b6113115760405162461bcd60e51b815260206004820152600e60248201527f6c656e67746873206469666665720000000000000000000000000000000000006044820152606401611083565b60d08054899190601490611333908490600160a01b900463ffffffff1661501c565b92506101000a81548163ffffffff021916908363ffffffff1602179055505f89899050670de0b6b3a76400006113699190614eb8565b905061137481613afc565b60c95f9054906101000a90046001600160a01b03166001600160a01b0316636413cc08828d8d8d87308f8f336040518a63ffffffff1660e01b81526004016113c3989796959493929190615082565b5f604051808303818588803b1580156113da575f80fd5b505af11580156113ec573d5f803e3d5ffd5b50505050505f5b898110156112435786868281811061140d5761140d614ea4565b9050602002013560d85f8d8d8581811061142957611429614ea4565b9050602002013581526020019081526020015f20819055508a8a8281811061145357611453614ea4565b905060200201357f7c6ee2c19ea9869a56eee5e68fe853d4e5a0171b0c02203d09df4c414fe8488286868481811061148d5761148d614ea4565b905060200281019061149f91906151a6565b8c8c868181106114b1576114b1614ea4565b90506020028101906114c391906151e9565b6114cd90806151a6565b8c8c888181106114df576114df614ea4565b905060200201356040516114f7959493929190615207565b60405180910390a26001016113f3565b6001600160a01b0381165f90815260db602052604090205460ff1661156e5760405162461bcd60e51b815260206004820152600e60248201527f4e6f7420726567697374657265640000000000000000000000000000000000006044820152606401611083565b60e054604051632474521560e21b81527f0e8d94121b3383f03d9ae60b39295aa793469d7230d51a3f62cbf47cd45481d960048201523360248201526001600160a01b03909116906391d1485490604401602060405180830381865afa1580156115da573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115fe9190614e89565b61163d5760405162461bcd60e51b815260206004820152601060248201526f24b731b7b93932b1ba1021b0b63632b960811b6044820152606401611083565b6001600160a01b0381165f81815260db6020908152604091829020805460ff1916905590519182527f8a5afe4e68ed1b812242442424ef608ee7b0a23b6111c6183e781ac4656e817391015b60405180910390a150565b60d9546001600160a01b031633146116bf576040516317fe949f60e01b815260040160405180910390fd5b8060dc60018282829054906101000a90046001600160801b03166116e3919061477b565b92506101000a8154816001600160801b0302191690836001600160801b0316021790555050565b60d9546001600160a01b03163314611735576040516317fe949f60e01b815260040160405180910390fd5b6040516001600160801b03821681527fafea3ee583ed00355634c0a2f47d947b6af95fda2bc1dbe0ff919c45166789d49060200160405180910390a160d0546105ec906001600160a01b03166001600160801b0383165f612df0565b5f61179a613aa2565b60cc546001600160a01b031633146117c5576040516317fe949f60e01b815260040160405180910390fd5b5f6117cf84612039565b90506bffffffffffffffffffffffff8411806117e9575083155b806117f2575080155b156118105760405163162908e360e11b815260040160405180910390fd5b60d25460ce5461182f916001600160a01b039182169133911687613b61565b60d2546040517f19691cb00000000000000000000000000000000000000000000000000000000081526bffffffffffffffffffffffff8087166004830152831660248201526001600160a01b038781166044830152606482018690525f9216906319691cb0906084016020604051808303815f875af11580156118b4573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906118d89190615240565b9050336001600160a01b03167fb9da3f3df62c28aca604806cc6ee9678189d7591ef511a77bb040fa8361e9e02878760026040516119189392919061528b565b60405180910390a295945050505050565b60e054604051632474521560e21b81527f0e8d94121b3383f03d9ae60b39295aa793469d7230d51a3f62cbf47cd45481d960048201523360248201526001600160a01b03909116906391d1485490604401602060405180830381865afa158015611995573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906119b99190614e89565b6119d65760405163209296a360e01b815260040160405180910390fd5b60ca546040517ffb63cf5c0000000000000000000000000000000000000000000000000000000081526001600160a01b039091169063fb63cf5c90611a2190859085906004016152af565b5f604051808303815f87803b158015611a38575f80fd5b505af1158015611a4a573d5f803e3d5ffd5b505050505050565b60d38181548110611a61575f80fd5b5f918252602090912001546001600160a01b0316905081565b5f54610100900460ff1615808015611a9857505f54600160ff909116105b80611ab15750303b158015611ab157505f5460ff166001145b611b235760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401611083565b5f805460ff191660011790558015611b44575f805461ff0019166101001790555b6001600160a01b0388161580611b6157506001600160a01b038716155b80611b7357506001600160a01b038616155b80611b8557506001600160a01b038516155b80611b9757506001600160a01b038416155b15611bce576040517fbaca868900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611bd6613bef565b611bde613c73565b60ce805473ffffffffffffffffffffffffffffffffffffffff199081166001600160a01b038b81169190911790925560c9805482168a841617905560ca8054821689841617905560cc8054821688841617905560cd8054821687841617905560dc8054600160881b7fffffffffffffffffffffffffffff00000000000000000000000000000000000090911617905560d98054821686841617905560d2805490911691841691909117905560de80547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1690558015611cf6575f805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050505050565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163003611d9e5760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c00000000000000000000000000000000000000006064820152608401611083565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316611df97f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b031614611e755760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f787900000000000000000000000000000000000000006064820152608401611083565b611e7e81613cef565b604080515f80825260208201909252611e9991839190613d5b565b50565b60cf545f90611ebd906001600160801b03600160801b82048116911661477b565b6001600160801b0316905090565b5f611ed4613aa2565b5f611ede83612039565b90506bffffffffffffffffffffffff831180611ef8575082155b80611f01575080155b15611f1f5760405163162908e360e11b815260040160405180910390fd5b60d25460ce54611f3e916001600160a01b039182169133911686613b61565b60d2546040517f19691cb00000000000000000000000000000000000000000000000000000000081526bffffffffffffffffffffffff8086166004830152831660248201526001600160a01b0386811660448301525f606483018190529216906319691cb0906084016020604051808303815f875af1158015611fc3573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611fe79190615240565b9050336001600160a01b03167fb9da3f3df62c28aca604806cc6ee9678189d7591ef511a77bb040fa8361e9e02868660016040516120279392919061528b565b60405180910390a29150505b92915050565b5f80612043611e9c565b9050805f0361205457505f92915050565b60ce54604080517f3a98ef39000000000000000000000000000000000000000000000000000000008152905183926001600160a01b031691633a98ef399160048083019260209291908290030181865afa1580156120b4573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906120d89190615240565b6120e29085614eb8565b610f6f91906152c2565b60e054604080517f77a9193e00000000000000000000000000000000000000000000000000000000815290516001600160a01b03909216916391d148549183916377a9193e916004808201926020929091908290030181865afa158015612155573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906121799190615240565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526004810191909152336024820152604401602060405180830381865afa1580156121d1573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906121f59190614e89565b6122125760405163209296a360e01b815260040160405180910390fd5b60dc54600160881b900460ff161561226c5760405162461bcd60e51b815260206004820152601860248201527f5061757361626c653a20616c72656164792070617573656400000000000000006044820152606401611083565b60dc80547fffffffffffffffffffffffffffff00ffffffffffffffffffffffffffffffffff16600160881b1790556040513381527f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258906020015b60405180910390a1565b6122d8613efb565b60df546001600160a01b03161580156122f957506001600160a01b03811615155b6123455760405162461bcd60e51b815260206004820152600760248201527f496e76616c6964000000000000000000000000000000000000000000000000006044820152606401611083565b60e0546001600160a01b03161561239e5760405162461bcd60e51b815260206004820152601360248201527f616c726561647920696e697469616c697a6564000000000000000000000000006044820152606401611083565b60df80546001600160a01b0380841673ffffffffffffffffffffffffffffffffffffffff199283161790925560e08054928516929091169190911790555f6123e4611e9c565b60cf80546001600160801b03478116600160801b9081029282169290921792839055929350612416929104168261475b565b60cf80547fffffffffffffffffffffffffffffffff00000000000000000000000000000000166001600160801b0392909216919091179055612456611e9c565b816001600160801b031614612469575f80fd5b505050565b612476613efb565b6001600160a01b0382161580159061249657506001600160a01b03811615155b80156124ab575060dd546001600160a01b0316155b80156124c0575060de546001600160a01b0316155b61250c5760405162461bcd60e51b815260206004820152600760248201527f496e76616c6964000000000000000000000000000000000000000000000000006044820152606401611083565b60dd80546001600160a01b0393841673ffffffffffffffffffffffffffffffffffffffff199182161790915560de8054929093169116179055565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630036125e55760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c00000000000000000000000000000000000000006064820152608401611083565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166126407f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b0316146126bc5760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f787900000000000000000000000000000000000000006064820152608401611083565b6126c582613cef565b6105ec82826001613d5b565b5f805f60ce5f9054906101000a90046001600160a01b03166001600160a01b0316633a98ef396040518163ffffffff1660e01b8152600401602060405180830381865afa158015612724573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906127489190615240565b905080156127f45760ce546040517fce7c2ac20000000000000000000000000000000000000000000000000000000081526001600160a01b0386811660048301528392169063ce7c2ac290602401602060405180830381865afa1580156127b1573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906127d59190615240565b6127dd611e9c565b6127e79190614eb8565b6127f191906152c2565b91505b5092915050565b5f306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461289a5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401611083565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b5f8060ce5f9054906101000a90046001600160a01b03166001600160a01b0316633a98ef396040518163ffffffff1660e01b8152600401602060405180830381865afa158015612911573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906129359190615240565b9050805f0361294657505f92915050565b806120d8611e9c565b60e054604051632474521560e21b81527f0e8d94121b3383f03d9ae60b39295aa793469d7230d51a3f62cbf47cd45481d960048201523360248201526001600160a01b03909116906391d1485490604401602060405180830381865afa1580156129bb573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906129df9190614e89565b6129fc5760405163209296a360e01b815260040160405180910390fd5b6001600160a01b0381165f90815260db602052604090205460ff1615612a645760405162461bcd60e51b815260206004820152601260248201527f416c7265616479207265676973746572656400000000000000000000000000006044820152606401611083565b6040805160208082018352600182526001600160a01b0384165f81815260db83528490209251835460ff19169015151790925591519081527f8bef88cac8d05094711d367d04bf4f2fcb4b589ca12a6ed8c8f375000e1e848e9101611689565b612acc613efb565b612ad55f613f55565b565b612adf613aa2565b305f5b82811015612c6557600860ca546001600160a01b031663135f8aa7868685818110612b0f57612b0f614ea4565b905060200201356040518263ffffffff1660e01b8152600401612b3491815260200190565b602060405180830381865afa158015612b4f573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612b7391906152e1565b6009811115612b8457612b84615257565b03612c1c5760cf8054670de0b6b3a764000091905f90612bae9084906001600160801b031661475b565b92506101000a8154816001600160801b0302191690836001600160801b03160217905550838382818110612be457612be4614ea4565b905060200201357f93078fc8e25f8a1cf1f7267fc8b9e164b79add4272948f78faf310b3787d7f8060405160405180910390a2612c5d565b600160d060148282829054906101000a900463ffffffff16612c3e919061501c565b92506101000a81548163ffffffff021916908363ffffffff1602179055505b600101612ae2565b5060c9546040517f915152810000000000000000000000000000000000000000000000000000000081526001600160a01b0390911690639151528190612cb3908690869033906004016152ff565b5f604051808303815f87803b158015612cca575f80fd5b505af1158015612cdc573d5f803e3d5ffd5b50505050505050565b5f80612cef611e9c565b9050805f03612d0057505f92915050565b60ce54604080517f3a98ef3900000000000000000000000000000000000000000000000000000000815290515f926001600160a01b031691633a98ef399160048083019260209291908290030181865afa158015612d60573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612d849190615240565b612d8e9085614eb8565b9050816001612d9d828461532b565b612da7919061533e565b612db191906152c2565b949350505050565b5f612deb7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b5f612df9613aa2565b60de546001600160a01b0316331480612e1c575060d9546001600160a01b031633145b612e5b5760405162461bcd60e51b815260206004820152601060248201526f24b731b7b93932b1ba1021b0b63632b960811b6044820152606401611083565b836001600160a01b03167fa241faf62e66ce518d1934ce4c936d806a02289ba483fac23beb8c15755be90d84600185604051612e9993929190615351565b60405180910390a2610f6c845f85613fb3565b60e054604080517f421d0eb300000000000000000000000000000000000000000000000000000000815290516001600160a01b03909216916391d1485491839163421d0eb3916004808201926020929091908290030181865afa158015612f15573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612f399190615240565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526004810191909152336024820152604401602060405180830381865afa158015612f91573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612fb59190614e89565b612fd25760405163209296a360e01b815260040160405180910390fd5b60dc54600160881b900460ff1661302b5760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401611083565b60dc80547fffffffffffffffffffffffffffff00ffffffffffffffffffffffffffffffffff1690556040513381527f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa906020016122c6565b606061308d613aa2565b335f90815260db60205260409020543090819060ff166130e25760405162461bcd60e51b815260206004820152601060248201526f24b731b7b93932b1ba1021b0b63632b960811b6044820152606401611083565b6130f5856801bc16d674ec800000614eb8565b60cf54600160801b90046001600160801b031610156131565760405162461bcd60e51b815260206004820152601260248201527f4e6f7420656e6f7567682062616c616e636500000000000000000000000000006044820152606401611083565b5f60c95f9054906101000a90046001600160a01b03166001600160a01b03166347d67886898989338888600160dc5f9054906101000a900460ff168e6040518a63ffffffff1660e01b81526004016131b69998979695949392919061537c565b5f604051808303815f875af11580156131d1573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526131f891908101906153de565b9050805160d060148282829054906101000a900463ffffffff1661321c919061545f565b92506101000a81548163ffffffff021916908363ffffffff160217905550809350505050949350505050565b60cc546001600160a01b03163314613273576040516317fe949f60e01b815260040160405180910390fd5b60cf5461328a9082906001600160801b031661547c565b60cf80547fffffffffffffffffffffffffffffffff00000000000000000000000000000000166001600160801b03929092169190911790557f11c6bf55864ff83827df712625d7a80e5583eef0264921025e7cd22003a215116132eb611e9c565b60ce5f9054906101000a90046001600160a01b03166001600160a01b0316633a98ef396040518163ffffffff1660e01b8152600401602060405180830381865afa15801561333b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061335f9190615240565b60408051928352602083019190915201611689565b606061337e613aa2565b610f6c8484845f613083565b5f612deb5f6136a8565b60e054604051632474521560e21b81527f0e8d94121b3383f03d9ae60b39295aa793469d7230d51a3f62cbf47cd45481d960048201523360248201526001600160a01b03909116906391d1485490604401602060405180830381865afa158015613400573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906134249190614e89565b6134415760405163209296a360e01b815260040160405180910390fd5b60dc805460ff1916911515919091179055565b60e054604051632474521560e21b81527f0e8d94121b3383f03d9ae60b39295aa793469d7230d51a3f62cbf47cd45481d960048201523360248201526001600160a01b03909116906391d1485490604401602060405180830381865afa1580156134c0573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906134e49190614e89565b6135015760405163209296a360e01b815260040160405180910390fd5b60d0805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383169081179091556040519081527fbf5406678e9fe702eaea01d92d3b62ac5be0a14e1802562e2a428364d30d1b1190602001611689565b60df546001600160a01b03163314801590613582575060d2546001600160a01b03163314155b156135a0576040516317fe949f60e01b815260040160405180910390fd5b60ce546040517fee7a7c04000000000000000000000000000000000000000000000000000000008152336004820152602481018390526001600160a01b039091169063ee7a7c04906044015f604051808303815f87803b158015613602575f80fd5b505af1158015613614573d5f803e3d5ffd5b5050505050565b613623613efb565b6001600160a01b03811661369f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401611083565b611e9981613f55565b5f6136b1613aa2565b336001600160a01b03167fa241faf62e66ce518d1934ce4c936d806a02289ba483fac23beb8c15755be90d346001856040516136ef93929190615351565b60405180910390a261370233345f613fb3565b90505b919050565b5f613713613aa2565b5f61371d83612ce5565b60d2549091506001600160a01b0316331480613743575060cc546001600160a01b031633145b80613758575060df546001600160a01b031633145b6137975760405162461bcd60e51b815260206004820152601060248201526f24b731b7b93932b1ba1021b0b63632b960811b6044820152606401611083565b60cf54600160801b90046001600160801b03168311806137db575060d2546001600160a01b0316331480156137db575060dc5461010090046001600160801b031683115b80613866575060ce546040517f70a0823100000000000000000000000000000000000000000000000000000000815233600482015284916001600160a01b0316906370a0823190602401602060405180830381865afa158015613840573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906138649190615240565b105b1561389d576040517fbb55fd2700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160801b038311806138b0575082155b806138b9575080155b156138d75760405163162908e360e11b815260040160405180910390fd5b8260cf60108282829054906101000a90046001600160801b03166138fb919061475b565b82546001600160801b039182166101009390930a92830291909202199091161790555060d2546001600160a01b03163303613979578260dc60018282829054906101000a90046001600160801b0316613954919061475b565b92506101000a8154816001600160801b0302191690836001600160801b031602179055505b60ce546040517fee7a7c04000000000000000000000000000000000000000000000000000000008152336004820152602481018390526001600160a01b039091169063ee7a7c04906044015f604051808303815f87803b1580156139db575f80fd5b505af11580156139ed573d5f803e3d5ffd5b50505050610f6f848461411c565b5f613a04613aa2565b60cc546001600160a01b03163314613a515760405162461bcd60e51b815260206004820152601060248201526f24b731b7b93932b1ba1021b0b63632b960811b6044820152606401611083565b336001600160a01b03167fa241faf62e66ce518d1934ce4c936d806a02289ba483fac23beb8c15755be90d34600285604051613a8f93929190615351565b60405180910390a2610f6f33345f613fb3565b60dc54600160881b900460ff1615612ad55760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606401611083565b60cf80548291905f90613b199084906001600160801b031661477b565b92506101000a8154816001600160801b0302191690836001600160801b031602179055508060cf60108282829054906101000a90046001600160801b03166116e3919061475b565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd00000000000000000000000000000000000000000000000000000000179052613be99085906141d1565b50505050565b5f54610100900460ff16613c6b5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401611083565b612ad56142b5565b5f54610100900460ff16612ad55760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401611083565b60e0546040517f5006bb7b0000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b0390911690635006bb7b906024015f6040518083038186803b158015613d49575f80fd5b505afa158015613614573d5f803e3d5ffd5b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615613d8e576124698361433a565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015613de8575060408051601f3d908101601f19168201909252613de591810190615240565b60015b613e5a5760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201527f6f6e206973206e6f7420555550530000000000000000000000000000000000006064820152608401611083565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8114613eef5760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f7860448201527f6961626c655555494400000000000000000000000000000000000000000000006064820152608401611083565b50612469838383614405565b6033546001600160a01b03163314612ad55760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401611083565b603380546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b5f8260cf60108282829054906101000a90046001600160801b0316613fd8919061477b565b92506101000a8154816001600160801b0302191690836001600160801b031602179055508160cf5f8282829054906101000a90046001600160801b031661401f919061477b565b92506101000a8154816001600160801b0302191690836001600160801b031602179055505f8284614050919061532b565b90505f61405c82614429565b90506001600160801b03821180614071575081155b8061407a575080155b156140985760405163162908e360e11b815260040160405180910390fd5b60ce546040517f528c198a0000000000000000000000000000000000000000000000000000000081526001600160a01b038881166004830152602482018490529091169063528c198a906044015f604051808303815f87803b1580156140fc575f80fd5b505af115801561410e573d5f803e3d5ffd5b509298975050505050505050565b60405147905f906001600160a01b0385169084908381818185875af1925050503d805f8114614166576040519150601f19603f3d011682016040523d82523d5f602084013e61416b565b606091505b505090508080156141855750614181838361533e565b4710155b613be95760405162461bcd60e51b815260206004820152600860248201527f53656e644661696c0000000000000000000000000000000000000000000000006044820152606401611083565b5f614225826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661444e9092919063ffffffff16565b80519091501561246957808060200190518101906142439190614e89565b6124695760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401611083565b5f54610100900460ff166143315760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401611083565b612ad533613f55565b6001600160a01b0381163b6143b75760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e7472616374000000000000000000000000000000000000006064820152608401611083565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b61440e8361445c565b5f8251118061441a5750805b1561246957613be9838361449b565b5f8082614434611e9c565b61443e919061533e565b9050805f03612054575090919050565b6060610f6c84845f856145a2565b6144658161433a565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a250565b60606001600160a01b0383163b61451a5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e747261637400000000000000000000000000000000000000000000000000006064820152608401611083565b5f80846001600160a01b03168460405161453491906154ec565b5f60405180830381855af49150503d805f811461456c576040519150601f19603f3d011682016040523d82523d5f602084013e614571565b606091505b5091509150614599828260405180606001604052806027815260200161553060279139614690565b95945050505050565b60608247101561461a5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401611083565b5f80866001600160a01b0316858760405161463591906154ec565b5f6040518083038185875af1925050503d805f811461466f576040519150601f19603f3d011682016040523d82523d5f602084013e614674565b606091505b5091509150614685878383876146a9565b979650505050505050565b6060831561469f575081610f6f565b610f6f838361471d565b606083156147175782515f03614710576001600160a01b0385163b6147105760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401611083565b5081612db1565b612db183835b81511561472d5781518083602001fd5b8060405162461bcd60e51b815260040161108391906154fd565b634e487b7160e01b5f52601160045260245ffd5b6001600160801b038281168282160390808211156127f4576127f4614747565b6001600160801b038181168382160190808211156127f4576127f4614747565b80356001600160a01b0381168114613705575f80fd5b5f805f83850360e08112156147c4575f80fd5b6147cd8561479b565b93506020850135925060a07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc082011215614805575f80fd5b506040840190509250925092565b5f60208284031215614823575f80fd5b610f6f8261479b565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f1916810167ffffffffffffffff811182821017156148695761486961482c565b604052919050565b5f67ffffffffffffffff82111561488a5761488a61482c565b5060051b60200190565b5f8083601f8401126148a4575f80fd5b50813567ffffffffffffffff8111156148bb575f80fd5b6020830191508360208260051b85010111156148d5575f80fd5b9250929050565b5f805f805f606086880312156148f0575f80fd5b853567ffffffffffffffff80821115614907575f80fd5b818801915088601f83011261491a575f80fd5b8135602061492f61492a83614871565b614840565b82815260059290921b8401810191818101908c84111561494d575f80fd5b948201945b8386101561496b57853582529482019490820190614952565b99505089013592505080821115614980575f80fd5b61498c89838a01614894565b909650945060408801359150808211156149a4575f80fd5b506149b188828901614894565b969995985093965092949392505050565b803563ffffffff81168114613705575f80fd5b5f80604083850312156149e6575f80fd5b6149ef836149c2565b91506149fd602084016149c2565b90509250929050565b5f805f805f805f805f60a08a8c031215614a1e575f80fd5b8935985060208a013567ffffffffffffffff80821115614a3c575f80fd5b614a488d838e01614894565b909a50985060408c0135915080821115614a60575f80fd5b614a6c8d838e01614894565b909850965060608c0135915080821115614a84575f80fd5b614a908d838e01614894565b909650945060808c0135915080821115614aa8575f80fd5b50614ab58c828d01614894565b915080935050809150509295985092959850929598565b5f60208284031215614adc575f80fd5b81356001600160801b0381168114610f6f575f80fd5b5f805f60608486031215614b04575f80fd5b614b0d8461479b565b95602085013595506040909401359392505050565b5f8060208385031215614b33575f80fd5b823567ffffffffffffffff811115614b49575f80fd5b614b5585828601614894565b90969095509350505050565b5f60208284031215614b71575f80fd5b5035919050565b5f60208284031215614b88575f80fd5b813560048110610f6f575f80fd5b5f805f805f805f60e0888a031215614bac575f80fd5b614bb58861479b565b9650614bc36020890161479b565b9550614bd16040890161479b565b9450614bdf6060890161479b565b9350614bed6080890161479b565b9250614bfb60a0890161479b565b9150614c0960c0890161479b565b905092959891949750929550565b5f8060408385031215614c28575f80fd5b614c318361479b565b946020939093013593505050565b5f8060408385031215614c50575f80fd5b614c598361479b565b91506149fd6020840161479b565b5f8060408385031215614c78575f80fd5b614c818361479b565b915060208084013567ffffffffffffffff80821115614c9e575f80fd5b818601915086601f830112614cb1575f80fd5b813581811115614cc357614cc361482c565b614cd584601f19601f84011601614840565b91508082528784828501011115614cea575f80fd5b80848401858401375f848284010152508093505050509250929050565b5f805f60608486031215614d19575f80fd5b614d228461479b565b925060208401359150614d376040850161479b565b90509250925092565b5f805f8060608587031215614d53575f80fd5b843567ffffffffffffffff811115614d69575f80fd5b614d7587828801614894565b90989097506020870135966040013595509350505050565b5f815180845260208085019450602084015f5b83811015614dbc57815187529582019590820190600101614da0565b509495945050505050565b602081525f610f6f6020830184614d8d565b5f60208284031215614de9575f80fd5b813580600f0b8114610f6f575f80fd5b5f805f60408486031215614e0b575f80fd5b833567ffffffffffffffff811115614e21575f80fd5b614e2d86828701614894565b909790965060209590950135949350505050565b8015158114611e99575f80fd5b5f60208284031215614e5e575f80fd5b8135610f6f81614e41565b5f60208284031215614e79575f80fd5b813560ff81168114610f6f575f80fd5b5f60208284031215614e99575f80fd5b8151610f6f81614e41565b634e487b7160e01b5f52603260045260245ffd5b808202811582820484141761203357612033614747565b81835281816020850137505f602082840101525f6020601f19601f840116840101905092915050565b5f808335601e19843603018112614f0d575f80fd5b830160208101925035905067ffffffffffffffff811115614f2c575f80fd5b8036038213156148d5575f80fd5b5f838385526020808601955060208560051b830101845f5b87811015614f8c57601f19858403018952614f6d8288614ef8565b614f78858284614ecf565b9a86019a9450505090830190600101614f52565b5090979650505050505050565b608081525f614fab6080830189614d8d565b60208382036020850152614fc082898b614f3a565b91508382036040850152614fd5828789614f3a565b8481036060860152855180825260208088019450909101905f5b8181101561500b57845183529383019391830191600101614fef565b50909b9a5050505050505050505050565b63ffffffff8281168282160390808211156127f4576127f4614747565b8183525f7f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff831115615069575f80fd5b8260051b80836020870137939093016020019392505050565b8881525f602060c08184015261509c60c084018a8c615039565b60406001600160a01b03808b1660408701526060818b166060880152608091508684036080880152838985528585019050858a60051b8601018b5f5b8c81101561517a57601f198884030184528135607e198f36030181126150fc575f80fd5b8e016151088180614ef8565b8886526151188987018284614ecf565b9150506151278b830183614ef8565b8683038d880152615139838284614ecf565b92505050888201358986015261515187830183614ef8565b925085820388870152615165828483614ecf565b968c01969550505091890191506001016150d8565b50506001600160a01b038a1660a08a0152965061519995505050505050565b9998505050505050505050565b5f808335601e198436030181126151bb575f80fd5b83018035915067ffffffffffffffff8211156151d5575f80fd5b6020019150368190038213156148d5575f80fd5b5f8235607e198336030181126151fd575f80fd5b9190910192915050565b606081525f61521a606083018789614ecf565b828103602084015261522d818688614ecf565b9150508260408301529695505050505050565b5f60208284031215615250575f80fd5b5051919050565b634e487b7160e01b5f52602160045260245ffd5b6004811061528757634e487b7160e01b5f52602160045260245ffd5b9052565b6001600160a01b03841681526020810183905260608101612db1604083018461526b565b602081525f610f6c602083018486615039565b5f826152dc57634e487b7160e01b5f52601260045260245ffd5b500490565b5f602082840312156152f1575f80fd5b8151600a8110610f6f575f80fd5b604081525f615312604083018587615039565b90506001600160a01b0383166020830152949350505050565b8082018082111561203357612033614747565b8181038181111561203357612033614747565b83815260608101615365602083018561526b565b6001600160a01b0383166040830152949350505050565b5f6101008083526153908184018c8e615039565b9150508860208301526001600160a01b03808916604084015280881660608401528087166080840152506153c760a083018661526b565b92151560c082015260e00152979650505050505050565b5f60208083850312156153ef575f80fd5b825167ffffffffffffffff811115615405575f80fd5b8301601f81018513615415575f80fd5b805161542361492a82614871565b81815260059190911b82018301908381019087831115615441575f80fd5b928401925b8284101561468557835182529284019290840190615446565b63ffffffff8181168382160190808211156127f4576127f4614747565b600f81810b9083900b016f7fffffffffffffffffffffffffffffff81137fffffffffffffffffffffffffffffffff800000000000000000000000000000008212171561203357612033614747565b5f5b838110156154e45781810151838201526020016154cc565b50505f910152565b5f82516151fd8184602087016154ca565b602081525f825180602084015261551b8160408501602087016154ca565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a164736f6c6343000818000a
Deployed Bytecode
0x608060405260043610610486575f3560e01c8063561bddf811610251578063c00c2d731161013c578063e74b981b116100b7578063f31f6aeb11610087578063f3fef3a31161006d578063f3fef3a314610e35578063f9609f0814610e54578063fc6dfe4e14610e67575f80fd5b8063f31f6aeb14610e03578063f340fa0114610e22575f80fd5b8063e74b981b14610d87578063ee30511614610da6578063f2c5998a14610dc5578063f2fde38b14610de4575f80fd5b8063d6951aa91161010c578063da8ed1f7116100f2578063da8ed1f714610d11578063dcbfb6c314610d30578063e453793414610d4f575f80fd5b8063d6951aa914610cce578063da79205814610ced575f80fd5b8063c00c2d7314610c60578063c98bea5b14610c7f578063caf4b5a414610ca7578063d0e30db014610cc6575f80fd5b8063917266fa116101cc578063b0192f9a1161019c578063bac1520311610182578063bac1520314610c01578063beed30a114610c15578063c00b2d6114610c41575f80fd5b8063b0192f9a14610bc3578063b46a130e14610be2575f80fd5b8063917266fa14610b435780639795947314610b625780639a8a302b14610b90578063aaf10f4214610baf575f80fd5b806371cb700f116102215780637c90fbf0116102075780637c90fbf014610ae157806389a8d9f514610b075780638da5cb5b14610b26575f80fd5b806371cb700f14610aa25780637346f1aa14610ac1575f80fd5b8063561bddf814610a3057806356f1199b14610a4f5780635c975abb14610a6e578063715018a614610a8e575f80fd5b806326d5d54a11610371578063456a23a6116102ec5780634c73f498116102bc57806351199700116102a257806351199700146109e457806352d1902d14610a0357806353f3fcb114610a17575f80fd5b80634c73f498146109b25780634f1ef286146109d1575f80fd5b8063456a23a6146109365780634690484014610955578063469963aa1461097457806346d4b71414610993575f80fd5b80633659cfe611610341578063397a1b2811610327578063397a1b28146108e45780633a53acb014610903578063439766ce14610922575f80fd5b80633659cfe6146108b157806337cfdaca146108d0575f80fd5b806326d5d54a146107ee57806328ac82e7146108485780632db004a3146108675780633587647614610892575f80fd5b806312c53c9b116104015780631991c225116103d15780631c6b4ed9116103b75780631c6b4ed9146107915780631e95e60e146107b057806322828cc2146107cf575f80fd5b80631991c225146107535780631aab9ef114610772575f80fd5b806312c53c9b146106d6578063158f8f59146106f65780631665f66d146107155780631729d10b14610734575f80fd5b806308c73259116104565780630ea9e8521161043c5780630ea9e85214610646578063109f51161461067957806310ddce8e14610698575f80fd5b806308c73259146105f05780630de371e214610627575f80fd5b806303dcfbdc1461054157806308061aeb1461057357806308388426146105b1578063086e16c0146105d2575f80fd5b3661053d576001600160801b033411156104b35760405163162908e360e11b815260040160405180910390fd5b60cf80543491905f906104d09084906001600160801b031661475b565b92506101000a8154816001600160801b0302191690836001600160801b031602179055503460cf60108282829054906101000a90046001600160801b0316610518919061477b565b92506101000a8154816001600160801b0302191690836001600160801b031602179055005b5f80fd5b34801561054c575f80fd5b5061056061055b3660046147b1565b610e95565b6040519081526020015b60405180910390f35b34801561057e575f80fd5b506105a161058d366004614813565b60db6020525f908152604090205460ff1681565b604051901515815260200161056a565b3480156105bc575f80fd5b506105d06105cb3660046148dc565b610f76565b005b3480156105dd575f80fd5b506105d06105ec3660046149d5565b5050565b3480156105fb575f80fd5b5060e05461060f906001600160a01b031681565b6040516001600160a01b03909116815260200161056a565b348015610632575f80fd5b5060ce5461060f906001600160a01b031681565b348015610651575f80fd5b506105607f0e8d94121b3383f03d9ae60b39295aa793469d7230d51a3f62cbf47cd45481d981565b348015610684575f80fd5b506105d0610693366004614a06565b611251565b3480156106a3575f80fd5b5060d4546106be90600160801b90046001600160801b031681565b6040516001600160801b03909116815260200161056a565b3480156106e1575f80fd5b5060ce546105a190600160a01b900460ff1681565b348015610701575f80fd5b506105d0610710366004614813565b611507565b348015610720575f80fd5b506105d061072f366004614acc565b611694565b34801561073f575f80fd5b5060de5461060f906001600160a01b031681565b34801561075e575f80fd5b506105d061076d366004614acc565b61170a565b34801561077d575f80fd5b5061056061078c366004614af2565b611791565b34801561079c575f80fd5b506105d06107ab366004614b22565b611929565b3480156107bb575f80fd5b5061060f6107ca366004614b61565b611a52565b3480156107da575f80fd5b5060c95461060f906001600160a01b031681565b3480156107f9575f80fd5b5061082b610808366004614b78565b60d76020525f908152604090205463ffffffff8082169164010000000090041682565b6040805163ffffffff93841681529290911660208301520161056a565b348015610853575f80fd5b5060cb5461060f906001600160a01b031681565b348015610872575f80fd5b50610560610881366004614b61565b60d86020525f908152604090205481565b34801561089d575f80fd5b506105d06108ac366004614b96565b611a7a565b3480156108bc575f80fd5b506105d06108cb366004614813565b611d00565b3480156108db575f80fd5b50610560611e9c565b3480156108ef575f80fd5b506105606108fe366004614c17565b611ecb565b34801561090e575f80fd5b5061056061091d366004614b61565b612039565b34801561092d575f80fd5b506105d06120ec565b348015610941575f80fd5b5060cf546106be906001600160801b031681565b348015610960575f80fd5b5060d05461060f906001600160a01b031681565b34801561097f575f80fd5b5060ca5461060f906001600160a01b031681565b34801561099e575f80fd5b506105d06109ad366004614c3f565b6122d0565b3480156109bd575f80fd5b506105d06109cc366004614c3f565b61246e565b6105d06109df366004614c67565b612547565b3480156109ef575f80fd5b506105606109fe366004614813565b6126d1565b348015610a0e575f80fd5b506105606127fb565b348015610a22575f80fd5b5060dc546105a19060ff1681565b348015610a3b575f80fd5b50610560610a4a366004614b61565b6128bf565b348015610a5a575f80fd5b506105d0610a69366004614813565b61294f565b348015610a79575f80fd5b5060dc546105a190600160881b900460ff1681565b348015610a99575f80fd5b506105d0612ac4565b348015610aad575f80fd5b5060d25461060f906001600160a01b031681565b348015610acc575f80fd5b5060d9546105a190600160a01b900460ff1681565b348015610aec575f80fd5b5060cf546106be90600160801b90046001600160801b031681565b348015610b12575f80fd5b506105d0610b21366004614b22565b612ad7565b348015610b31575f80fd5b506033546001600160a01b031661060f565b348015610b4e575f80fd5b50610560610b5d366004614b61565b612ce5565b348015610b6d575f80fd5b506105a1610b7c366004614813565b60da6020525f908152604090205460ff1681565b348015610b9b575f80fd5b5060d15461060f906001600160a01b031681565b348015610bba575f80fd5b5061060f612db9565b348015610bce575f80fd5b5060dd5461060f906001600160a01b031681565b348015610bed575f80fd5b50610560610bfc366004614d07565b612df0565b348015610c0c575f80fd5b506105d0612eac565b348015610c20575f80fd5b50610c34610c2f366004614d40565b613083565b60405161056a9190614dc7565b348015610c4c575f80fd5b506105d0610c5b366004614dd9565b613248565b348015610c6b575f80fd5b5060d95461060f906001600160a01b031681565b348015610c8a575f80fd5b5060d55461082b9063ffffffff8082169164010000000090041682565b348015610cb2575f80fd5b50610c34610cc1366004614df9565b613374565b61056061338a565b348015610cd9575f80fd5b5060d4546106be906001600160801b031681565b348015610cf8575f80fd5b5060dc546106be9061010090046001600160801b031681565b348015610d1c575f80fd5b506105d0610d2b366004614e4e565b613394565b348015610d3b575f80fd5b5060df5461060f906001600160a01b031681565b348015610d5a575f80fd5b5060d054610d7290600160a01b900463ffffffff1681565b60405163ffffffff909116815260200161056a565b348015610d92575f80fd5b506105d0610da1366004614813565b613454565b348015610db1575f80fd5b5060cc5461060f906001600160a01b031681565b348015610dd0575f80fd5b506105d0610ddf366004614b61565b61355c565b348015610def575f80fd5b506105d0610dfe366004614813565b61361b565b348015610e0e575f80fd5b5060cd5461060f906001600160a01b031681565b610560610e30366004614813565b6136a8565b348015610e40575f80fd5b50610560610e4f366004614c17565b61370a565b610560610e62366004614c3f565b6139fb565b348015610e72575f80fd5b506105a1610e81366004614813565b60d66020525f908152604090205460ff1681565b5f610e9e613aa2565b60ce546001600160a01b031663d505accf333085356020870135610ec86060890160408a01614e69565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e088901b1681526001600160a01b0395861660048201529490931660248501526044840191909152606483015260ff166084820152606085013560a4820152608085013560c482015260e4015f604051808303815f87803b158015610f50575f80fd5b505af1925050508015610f61575060015b50610f6c8484611ecb565b90505b9392505050565b610f7e613aa2565b60e054604051632474521560e21b81527f0e8d94121b3383f03d9ae60b39295aa793469d7230d51a3f62cbf47cd45481d960048201523360248201526001600160a01b03909116906391d1485490604401602060405180830381865afa158015610fea573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061100e9190614e89565b61102b5760405163209296a360e01b815260040160405180910390fd5b84518314801561103b5750845181145b61108c5760405162461bcd60e51b815260206004820152600e60248201527f6c656e677468732064696666657200000000000000000000000000000000000060448201526064015b60405180910390fd5b5f855167ffffffffffffffff8111156110a7576110a761482c565b6040519080825280602002602001820160405280156110d0578160200160208202803683370190505b5090505f5b86518110156111a25760d85f8883815181106110f3576110f3614ea4565b602002602001015181526020019081526020015f205482828151811061111b5761111b614ea4565b60200260200101818152505060d85f88838151811061113c5761113c614ea4565b602002602001015181526020019081526020015f205f905586818151811061116657611166614ea4565b60200260200101517f3a45f0697c2ad042d28b6679f70d695b90d55438dfbf3f43a44bba9dcf061c1960405160405180910390a26001016110d5565b505f86516801ae361fc1451c00006111ba9190614eb8565b90506111c581613afc565b60c9546040517f4cfc6c730000000000000000000000000000000000000000000000000000000081526001600160a01b0390911690634cfc6c7390839061121a908b908b908b908b908b908b90600401614f99565b5f604051808303818588803b158015611231575f80fd5b505af1158015611243573d5f803e3d5ffd5b505050505050505050505050565b611259613aa2565b335f90815260db6020526040902054309060ff166112ac5760405162461bcd60e51b815260206004820152601060248201526f24b731b7b93932b1ba1021b0b63632b960811b6044820152606401611083565b87861480156112ba57508784145b80156112c557508782145b6113115760405162461bcd60e51b815260206004820152600e60248201527f6c656e67746873206469666665720000000000000000000000000000000000006044820152606401611083565b60d08054899190601490611333908490600160a01b900463ffffffff1661501c565b92506101000a81548163ffffffff021916908363ffffffff1602179055505f89899050670de0b6b3a76400006113699190614eb8565b905061137481613afc565b60c95f9054906101000a90046001600160a01b03166001600160a01b0316636413cc08828d8d8d87308f8f336040518a63ffffffff1660e01b81526004016113c3989796959493929190615082565b5f604051808303818588803b1580156113da575f80fd5b505af11580156113ec573d5f803e3d5ffd5b50505050505f5b898110156112435786868281811061140d5761140d614ea4565b9050602002013560d85f8d8d8581811061142957611429614ea4565b9050602002013581526020019081526020015f20819055508a8a8281811061145357611453614ea4565b905060200201357f7c6ee2c19ea9869a56eee5e68fe853d4e5a0171b0c02203d09df4c414fe8488286868481811061148d5761148d614ea4565b905060200281019061149f91906151a6565b8c8c868181106114b1576114b1614ea4565b90506020028101906114c391906151e9565b6114cd90806151a6565b8c8c888181106114df576114df614ea4565b905060200201356040516114f7959493929190615207565b60405180910390a26001016113f3565b6001600160a01b0381165f90815260db602052604090205460ff1661156e5760405162461bcd60e51b815260206004820152600e60248201527f4e6f7420726567697374657265640000000000000000000000000000000000006044820152606401611083565b60e054604051632474521560e21b81527f0e8d94121b3383f03d9ae60b39295aa793469d7230d51a3f62cbf47cd45481d960048201523360248201526001600160a01b03909116906391d1485490604401602060405180830381865afa1580156115da573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115fe9190614e89565b61163d5760405162461bcd60e51b815260206004820152601060248201526f24b731b7b93932b1ba1021b0b63632b960811b6044820152606401611083565b6001600160a01b0381165f81815260db6020908152604091829020805460ff1916905590519182527f8a5afe4e68ed1b812242442424ef608ee7b0a23b6111c6183e781ac4656e817391015b60405180910390a150565b60d9546001600160a01b031633146116bf576040516317fe949f60e01b815260040160405180910390fd5b8060dc60018282829054906101000a90046001600160801b03166116e3919061477b565b92506101000a8154816001600160801b0302191690836001600160801b0316021790555050565b60d9546001600160a01b03163314611735576040516317fe949f60e01b815260040160405180910390fd5b6040516001600160801b03821681527fafea3ee583ed00355634c0a2f47d947b6af95fda2bc1dbe0ff919c45166789d49060200160405180910390a160d0546105ec906001600160a01b03166001600160801b0383165f612df0565b5f61179a613aa2565b60cc546001600160a01b031633146117c5576040516317fe949f60e01b815260040160405180910390fd5b5f6117cf84612039565b90506bffffffffffffffffffffffff8411806117e9575083155b806117f2575080155b156118105760405163162908e360e11b815260040160405180910390fd5b60d25460ce5461182f916001600160a01b039182169133911687613b61565b60d2546040517f19691cb00000000000000000000000000000000000000000000000000000000081526bffffffffffffffffffffffff8087166004830152831660248201526001600160a01b038781166044830152606482018690525f9216906319691cb0906084016020604051808303815f875af11580156118b4573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906118d89190615240565b9050336001600160a01b03167fb9da3f3df62c28aca604806cc6ee9678189d7591ef511a77bb040fa8361e9e02878760026040516119189392919061528b565b60405180910390a295945050505050565b60e054604051632474521560e21b81527f0e8d94121b3383f03d9ae60b39295aa793469d7230d51a3f62cbf47cd45481d960048201523360248201526001600160a01b03909116906391d1485490604401602060405180830381865afa158015611995573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906119b99190614e89565b6119d65760405163209296a360e01b815260040160405180910390fd5b60ca546040517ffb63cf5c0000000000000000000000000000000000000000000000000000000081526001600160a01b039091169063fb63cf5c90611a2190859085906004016152af565b5f604051808303815f87803b158015611a38575f80fd5b505af1158015611a4a573d5f803e3d5ffd5b505050505050565b60d38181548110611a61575f80fd5b5f918252602090912001546001600160a01b0316905081565b5f54610100900460ff1615808015611a9857505f54600160ff909116105b80611ab15750303b158015611ab157505f5460ff166001145b611b235760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401611083565b5f805460ff191660011790558015611b44575f805461ff0019166101001790555b6001600160a01b0388161580611b6157506001600160a01b038716155b80611b7357506001600160a01b038616155b80611b8557506001600160a01b038516155b80611b9757506001600160a01b038416155b15611bce576040517fbaca868900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611bd6613bef565b611bde613c73565b60ce805473ffffffffffffffffffffffffffffffffffffffff199081166001600160a01b038b81169190911790925560c9805482168a841617905560ca8054821689841617905560cc8054821688841617905560cd8054821687841617905560dc8054600160881b7fffffffffffffffffffffffffffff00000000000000000000000000000000000090911617905560d98054821686841617905560d2805490911691841691909117905560de80547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff1690558015611cf6575f805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050505050565b6001600160a01b037f000000000000000000000000a6099d83a67a2c653feb5e4e48ec24c5aee1c515163003611d9e5760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c00000000000000000000000000000000000000006064820152608401611083565b7f000000000000000000000000a6099d83a67a2c653feb5e4e48ec24c5aee1c5156001600160a01b0316611df97f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b031614611e755760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f787900000000000000000000000000000000000000006064820152608401611083565b611e7e81613cef565b604080515f80825260208201909252611e9991839190613d5b565b50565b60cf545f90611ebd906001600160801b03600160801b82048116911661477b565b6001600160801b0316905090565b5f611ed4613aa2565b5f611ede83612039565b90506bffffffffffffffffffffffff831180611ef8575082155b80611f01575080155b15611f1f5760405163162908e360e11b815260040160405180910390fd5b60d25460ce54611f3e916001600160a01b039182169133911686613b61565b60d2546040517f19691cb00000000000000000000000000000000000000000000000000000000081526bffffffffffffffffffffffff8086166004830152831660248201526001600160a01b0386811660448301525f606483018190529216906319691cb0906084016020604051808303815f875af1158015611fc3573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611fe79190615240565b9050336001600160a01b03167fb9da3f3df62c28aca604806cc6ee9678189d7591ef511a77bb040fa8361e9e02868660016040516120279392919061528b565b60405180910390a29150505b92915050565b5f80612043611e9c565b9050805f0361205457505f92915050565b60ce54604080517f3a98ef39000000000000000000000000000000000000000000000000000000008152905183926001600160a01b031691633a98ef399160048083019260209291908290030181865afa1580156120b4573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906120d89190615240565b6120e29085614eb8565b610f6f91906152c2565b60e054604080517f77a9193e00000000000000000000000000000000000000000000000000000000815290516001600160a01b03909216916391d148549183916377a9193e916004808201926020929091908290030181865afa158015612155573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906121799190615240565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526004810191909152336024820152604401602060405180830381865afa1580156121d1573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906121f59190614e89565b6122125760405163209296a360e01b815260040160405180910390fd5b60dc54600160881b900460ff161561226c5760405162461bcd60e51b815260206004820152601860248201527f5061757361626c653a20616c72656164792070617573656400000000000000006044820152606401611083565b60dc80547fffffffffffffffffffffffffffff00ffffffffffffffffffffffffffffffffff16600160881b1790556040513381527f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258906020015b60405180910390a1565b6122d8613efb565b60df546001600160a01b03161580156122f957506001600160a01b03811615155b6123455760405162461bcd60e51b815260206004820152600760248201527f496e76616c6964000000000000000000000000000000000000000000000000006044820152606401611083565b60e0546001600160a01b03161561239e5760405162461bcd60e51b815260206004820152601360248201527f616c726561647920696e697469616c697a6564000000000000000000000000006044820152606401611083565b60df80546001600160a01b0380841673ffffffffffffffffffffffffffffffffffffffff199283161790925560e08054928516929091169190911790555f6123e4611e9c565b60cf80546001600160801b03478116600160801b9081029282169290921792839055929350612416929104168261475b565b60cf80547fffffffffffffffffffffffffffffffff00000000000000000000000000000000166001600160801b0392909216919091179055612456611e9c565b816001600160801b031614612469575f80fd5b505050565b612476613efb565b6001600160a01b0382161580159061249657506001600160a01b03811615155b80156124ab575060dd546001600160a01b0316155b80156124c0575060de546001600160a01b0316155b61250c5760405162461bcd60e51b815260206004820152600760248201527f496e76616c6964000000000000000000000000000000000000000000000000006044820152606401611083565b60dd80546001600160a01b0393841673ffffffffffffffffffffffffffffffffffffffff199182161790915560de8054929093169116179055565b6001600160a01b037f000000000000000000000000a6099d83a67a2c653feb5e4e48ec24c5aee1c5151630036125e55760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f64656c656761746563616c6c00000000000000000000000000000000000000006064820152608401611083565b7f000000000000000000000000a6099d83a67a2c653feb5e4e48ec24c5aee1c5156001600160a01b03166126407f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b0316146126bc5760405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201527f6163746976652070726f787900000000000000000000000000000000000000006064820152608401611083565b6126c582613cef565b6105ec82826001613d5b565b5f805f60ce5f9054906101000a90046001600160a01b03166001600160a01b0316633a98ef396040518163ffffffff1660e01b8152600401602060405180830381865afa158015612724573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906127489190615240565b905080156127f45760ce546040517fce7c2ac20000000000000000000000000000000000000000000000000000000081526001600160a01b0386811660048301528392169063ce7c2ac290602401602060405180830381865afa1580156127b1573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906127d59190615240565b6127dd611e9c565b6127e79190614eb8565b6127f191906152c2565b91505b5092915050565b5f306001600160a01b037f000000000000000000000000a6099d83a67a2c653feb5e4e48ec24c5aee1c515161461289a5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401611083565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b5f8060ce5f9054906101000a90046001600160a01b03166001600160a01b0316633a98ef396040518163ffffffff1660e01b8152600401602060405180830381865afa158015612911573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906129359190615240565b9050805f0361294657505f92915050565b806120d8611e9c565b60e054604051632474521560e21b81527f0e8d94121b3383f03d9ae60b39295aa793469d7230d51a3f62cbf47cd45481d960048201523360248201526001600160a01b03909116906391d1485490604401602060405180830381865afa1580156129bb573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906129df9190614e89565b6129fc5760405163209296a360e01b815260040160405180910390fd5b6001600160a01b0381165f90815260db602052604090205460ff1615612a645760405162461bcd60e51b815260206004820152601260248201527f416c7265616479207265676973746572656400000000000000000000000000006044820152606401611083565b6040805160208082018352600182526001600160a01b0384165f81815260db83528490209251835460ff19169015151790925591519081527f8bef88cac8d05094711d367d04bf4f2fcb4b589ca12a6ed8c8f375000e1e848e9101611689565b612acc613efb565b612ad55f613f55565b565b612adf613aa2565b305f5b82811015612c6557600860ca546001600160a01b031663135f8aa7868685818110612b0f57612b0f614ea4565b905060200201356040518263ffffffff1660e01b8152600401612b3491815260200190565b602060405180830381865afa158015612b4f573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612b7391906152e1565b6009811115612b8457612b84615257565b03612c1c5760cf8054670de0b6b3a764000091905f90612bae9084906001600160801b031661475b565b92506101000a8154816001600160801b0302191690836001600160801b03160217905550838382818110612be457612be4614ea4565b905060200201357f93078fc8e25f8a1cf1f7267fc8b9e164b79add4272948f78faf310b3787d7f8060405160405180910390a2612c5d565b600160d060148282829054906101000a900463ffffffff16612c3e919061501c565b92506101000a81548163ffffffff021916908363ffffffff1602179055505b600101612ae2565b5060c9546040517f915152810000000000000000000000000000000000000000000000000000000081526001600160a01b0390911690639151528190612cb3908690869033906004016152ff565b5f604051808303815f87803b158015612cca575f80fd5b505af1158015612cdc573d5f803e3d5ffd5b50505050505050565b5f80612cef611e9c565b9050805f03612d0057505f92915050565b60ce54604080517f3a98ef3900000000000000000000000000000000000000000000000000000000815290515f926001600160a01b031691633a98ef399160048083019260209291908290030181865afa158015612d60573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612d849190615240565b612d8e9085614eb8565b9050816001612d9d828461532b565b612da7919061533e565b612db191906152c2565b949350505050565b5f612deb7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b5f612df9613aa2565b60de546001600160a01b0316331480612e1c575060d9546001600160a01b031633145b612e5b5760405162461bcd60e51b815260206004820152601060248201526f24b731b7b93932b1ba1021b0b63632b960811b6044820152606401611083565b836001600160a01b03167fa241faf62e66ce518d1934ce4c936d806a02289ba483fac23beb8c15755be90d84600185604051612e9993929190615351565b60405180910390a2610f6c845f85613fb3565b60e054604080517f421d0eb300000000000000000000000000000000000000000000000000000000815290516001600160a01b03909216916391d1485491839163421d0eb3916004808201926020929091908290030181865afa158015612f15573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612f399190615240565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b1681526004810191909152336024820152604401602060405180830381865afa158015612f91573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612fb59190614e89565b612fd25760405163209296a360e01b815260040160405180910390fd5b60dc54600160881b900460ff1661302b5760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401611083565b60dc80547fffffffffffffffffffffffffffff00ffffffffffffffffffffffffffffffffff1690556040513381527f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa906020016122c6565b606061308d613aa2565b335f90815260db60205260409020543090819060ff166130e25760405162461bcd60e51b815260206004820152601060248201526f24b731b7b93932b1ba1021b0b63632b960811b6044820152606401611083565b6130f5856801bc16d674ec800000614eb8565b60cf54600160801b90046001600160801b031610156131565760405162461bcd60e51b815260206004820152601260248201527f4e6f7420656e6f7567682062616c616e636500000000000000000000000000006044820152606401611083565b5f60c95f9054906101000a90046001600160a01b03166001600160a01b03166347d67886898989338888600160dc5f9054906101000a900460ff168e6040518a63ffffffff1660e01b81526004016131b69998979695949392919061537c565b5f604051808303815f875af11580156131d1573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526131f891908101906153de565b9050805160d060148282829054906101000a900463ffffffff1661321c919061545f565b92506101000a81548163ffffffff021916908363ffffffff160217905550809350505050949350505050565b60cc546001600160a01b03163314613273576040516317fe949f60e01b815260040160405180910390fd5b60cf5461328a9082906001600160801b031661547c565b60cf80547fffffffffffffffffffffffffffffffff00000000000000000000000000000000166001600160801b03929092169190911790557f11c6bf55864ff83827df712625d7a80e5583eef0264921025e7cd22003a215116132eb611e9c565b60ce5f9054906101000a90046001600160a01b03166001600160a01b0316633a98ef396040518163ffffffff1660e01b8152600401602060405180830381865afa15801561333b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061335f9190615240565b60408051928352602083019190915201611689565b606061337e613aa2565b610f6c8484845f613083565b5f612deb5f6136a8565b60e054604051632474521560e21b81527f0e8d94121b3383f03d9ae60b39295aa793469d7230d51a3f62cbf47cd45481d960048201523360248201526001600160a01b03909116906391d1485490604401602060405180830381865afa158015613400573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906134249190614e89565b6134415760405163209296a360e01b815260040160405180910390fd5b60dc805460ff1916911515919091179055565b60e054604051632474521560e21b81527f0e8d94121b3383f03d9ae60b39295aa793469d7230d51a3f62cbf47cd45481d960048201523360248201526001600160a01b03909116906391d1485490604401602060405180830381865afa1580156134c0573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906134e49190614e89565b6135015760405163209296a360e01b815260040160405180910390fd5b60d0805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383169081179091556040519081527fbf5406678e9fe702eaea01d92d3b62ac5be0a14e1802562e2a428364d30d1b1190602001611689565b60df546001600160a01b03163314801590613582575060d2546001600160a01b03163314155b156135a0576040516317fe949f60e01b815260040160405180910390fd5b60ce546040517fee7a7c04000000000000000000000000000000000000000000000000000000008152336004820152602481018390526001600160a01b039091169063ee7a7c04906044015f604051808303815f87803b158015613602575f80fd5b505af1158015613614573d5f803e3d5ffd5b5050505050565b613623613efb565b6001600160a01b03811661369f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401611083565b611e9981613f55565b5f6136b1613aa2565b336001600160a01b03167fa241faf62e66ce518d1934ce4c936d806a02289ba483fac23beb8c15755be90d346001856040516136ef93929190615351565b60405180910390a261370233345f613fb3565b90505b919050565b5f613713613aa2565b5f61371d83612ce5565b60d2549091506001600160a01b0316331480613743575060cc546001600160a01b031633145b80613758575060df546001600160a01b031633145b6137975760405162461bcd60e51b815260206004820152601060248201526f24b731b7b93932b1ba1021b0b63632b960811b6044820152606401611083565b60cf54600160801b90046001600160801b03168311806137db575060d2546001600160a01b0316331480156137db575060dc5461010090046001600160801b031683115b80613866575060ce546040517f70a0823100000000000000000000000000000000000000000000000000000000815233600482015284916001600160a01b0316906370a0823190602401602060405180830381865afa158015613840573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906138649190615240565b105b1561389d576040517fbb55fd2700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160801b038311806138b0575082155b806138b9575080155b156138d75760405163162908e360e11b815260040160405180910390fd5b8260cf60108282829054906101000a90046001600160801b03166138fb919061475b565b82546001600160801b039182166101009390930a92830291909202199091161790555060d2546001600160a01b03163303613979578260dc60018282829054906101000a90046001600160801b0316613954919061475b565b92506101000a8154816001600160801b0302191690836001600160801b031602179055505b60ce546040517fee7a7c04000000000000000000000000000000000000000000000000000000008152336004820152602481018390526001600160a01b039091169063ee7a7c04906044015f604051808303815f87803b1580156139db575f80fd5b505af11580156139ed573d5f803e3d5ffd5b50505050610f6f848461411c565b5f613a04613aa2565b60cc546001600160a01b03163314613a515760405162461bcd60e51b815260206004820152601060248201526f24b731b7b93932b1ba1021b0b63632b960811b6044820152606401611083565b336001600160a01b03167fa241faf62e66ce518d1934ce4c936d806a02289ba483fac23beb8c15755be90d34600285604051613a8f93929190615351565b60405180910390a2610f6f33345f613fb3565b60dc54600160881b900460ff1615612ad55760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606401611083565b60cf80548291905f90613b199084906001600160801b031661477b565b92506101000a8154816001600160801b0302191690836001600160801b031602179055508060cf60108282829054906101000a90046001600160801b03166116e3919061475b565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd00000000000000000000000000000000000000000000000000000000179052613be99085906141d1565b50505050565b5f54610100900460ff16613c6b5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401611083565b612ad56142b5565b5f54610100900460ff16612ad55760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401611083565b60e0546040517f5006bb7b0000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b0390911690635006bb7b906024015f6040518083038186803b158015613d49575f80fd5b505afa158015613614573d5f803e3d5ffd5b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615613d8e576124698361433a565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015613de8575060408051601f3d908101601f19168201909252613de591810190615240565b60015b613e5a5760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201527f6f6e206973206e6f7420555550530000000000000000000000000000000000006064820152608401611083565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8114613eef5760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f7860448201527f6961626c655555494400000000000000000000000000000000000000000000006064820152608401611083565b50612469838383614405565b6033546001600160a01b03163314612ad55760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401611083565b603380546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b5f8260cf60108282829054906101000a90046001600160801b0316613fd8919061477b565b92506101000a8154816001600160801b0302191690836001600160801b031602179055508160cf5f8282829054906101000a90046001600160801b031661401f919061477b565b92506101000a8154816001600160801b0302191690836001600160801b031602179055505f8284614050919061532b565b90505f61405c82614429565b90506001600160801b03821180614071575081155b8061407a575080155b156140985760405163162908e360e11b815260040160405180910390fd5b60ce546040517f528c198a0000000000000000000000000000000000000000000000000000000081526001600160a01b038881166004830152602482018490529091169063528c198a906044015f604051808303815f87803b1580156140fc575f80fd5b505af115801561410e573d5f803e3d5ffd5b509298975050505050505050565b60405147905f906001600160a01b0385169084908381818185875af1925050503d805f8114614166576040519150601f19603f3d011682016040523d82523d5f602084013e61416b565b606091505b505090508080156141855750614181838361533e565b4710155b613be95760405162461bcd60e51b815260206004820152600860248201527f53656e644661696c0000000000000000000000000000000000000000000000006044820152606401611083565b5f614225826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661444e9092919063ffffffff16565b80519091501561246957808060200190518101906142439190614e89565b6124695760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401611083565b5f54610100900460ff166143315760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401611083565b612ad533613f55565b6001600160a01b0381163b6143b75760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201527f6f74206120636f6e7472616374000000000000000000000000000000000000006064820152608401611083565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b61440e8361445c565b5f8251118061441a5750805b1561246957613be9838361449b565b5f8082614434611e9c565b61443e919061533e565b9050805f03612054575090919050565b6060610f6c84845f856145a2565b6144658161433a565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a250565b60606001600160a01b0383163b61451a5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e747261637400000000000000000000000000000000000000000000000000006064820152608401611083565b5f80846001600160a01b03168460405161453491906154ec565b5f60405180830381855af49150503d805f811461456c576040519150601f19603f3d011682016040523d82523d5f602084013e614571565b606091505b5091509150614599828260405180606001604052806027815260200161553060279139614690565b95945050505050565b60608247101561461a5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401611083565b5f80866001600160a01b0316858760405161463591906154ec565b5f6040518083038185875af1925050503d805f811461466f576040519150601f19603f3d011682016040523d82523d5f602084013e614674565b606091505b5091509150614685878383876146a9565b979650505050505050565b6060831561469f575081610f6f565b610f6f838361471d565b606083156147175782515f03614710576001600160a01b0385163b6147105760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401611083565b5081612db1565b612db183835b81511561472d5781518083602001fd5b8060405162461bcd60e51b815260040161108391906154fd565b634e487b7160e01b5f52601160045260245ffd5b6001600160801b038281168282160390808211156127f4576127f4614747565b6001600160801b038181168382160190808211156127f4576127f4614747565b80356001600160a01b0381168114613705575f80fd5b5f805f83850360e08112156147c4575f80fd5b6147cd8561479b565b93506020850135925060a07fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc082011215614805575f80fd5b506040840190509250925092565b5f60208284031215614823575f80fd5b610f6f8261479b565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f1916810167ffffffffffffffff811182821017156148695761486961482c565b604052919050565b5f67ffffffffffffffff82111561488a5761488a61482c565b5060051b60200190565b5f8083601f8401126148a4575f80fd5b50813567ffffffffffffffff8111156148bb575f80fd5b6020830191508360208260051b85010111156148d5575f80fd5b9250929050565b5f805f805f606086880312156148f0575f80fd5b853567ffffffffffffffff80821115614907575f80fd5b818801915088601f83011261491a575f80fd5b8135602061492f61492a83614871565b614840565b82815260059290921b8401810191818101908c84111561494d575f80fd5b948201945b8386101561496b57853582529482019490820190614952565b99505089013592505080821115614980575f80fd5b61498c89838a01614894565b909650945060408801359150808211156149a4575f80fd5b506149b188828901614894565b969995985093965092949392505050565b803563ffffffff81168114613705575f80fd5b5f80604083850312156149e6575f80fd5b6149ef836149c2565b91506149fd602084016149c2565b90509250929050565b5f805f805f805f805f60a08a8c031215614a1e575f80fd5b8935985060208a013567ffffffffffffffff80821115614a3c575f80fd5b614a488d838e01614894565b909a50985060408c0135915080821115614a60575f80fd5b614a6c8d838e01614894565b909850965060608c0135915080821115614a84575f80fd5b614a908d838e01614894565b909650945060808c0135915080821115614aa8575f80fd5b50614ab58c828d01614894565b915080935050809150509295985092959850929598565b5f60208284031215614adc575f80fd5b81356001600160801b0381168114610f6f575f80fd5b5f805f60608486031215614b04575f80fd5b614b0d8461479b565b95602085013595506040909401359392505050565b5f8060208385031215614b33575f80fd5b823567ffffffffffffffff811115614b49575f80fd5b614b5585828601614894565b90969095509350505050565b5f60208284031215614b71575f80fd5b5035919050565b5f60208284031215614b88575f80fd5b813560048110610f6f575f80fd5b5f805f805f805f60e0888a031215614bac575f80fd5b614bb58861479b565b9650614bc36020890161479b565b9550614bd16040890161479b565b9450614bdf6060890161479b565b9350614bed6080890161479b565b9250614bfb60a0890161479b565b9150614c0960c0890161479b565b905092959891949750929550565b5f8060408385031215614c28575f80fd5b614c318361479b565b946020939093013593505050565b5f8060408385031215614c50575f80fd5b614c598361479b565b91506149fd6020840161479b565b5f8060408385031215614c78575f80fd5b614c818361479b565b915060208084013567ffffffffffffffff80821115614c9e575f80fd5b818601915086601f830112614cb1575f80fd5b813581811115614cc357614cc361482c565b614cd584601f19601f84011601614840565b91508082528784828501011115614cea575f80fd5b80848401858401375f848284010152508093505050509250929050565b5f805f60608486031215614d19575f80fd5b614d228461479b565b925060208401359150614d376040850161479b565b90509250925092565b5f805f8060608587031215614d53575f80fd5b843567ffffffffffffffff811115614d69575f80fd5b614d7587828801614894565b90989097506020870135966040013595509350505050565b5f815180845260208085019450602084015f5b83811015614dbc57815187529582019590820190600101614da0565b509495945050505050565b602081525f610f6f6020830184614d8d565b5f60208284031215614de9575f80fd5b813580600f0b8114610f6f575f80fd5b5f805f60408486031215614e0b575f80fd5b833567ffffffffffffffff811115614e21575f80fd5b614e2d86828701614894565b909790965060209590950135949350505050565b8015158114611e99575f80fd5b5f60208284031215614e5e575f80fd5b8135610f6f81614e41565b5f60208284031215614e79575f80fd5b813560ff81168114610f6f575f80fd5b5f60208284031215614e99575f80fd5b8151610f6f81614e41565b634e487b7160e01b5f52603260045260245ffd5b808202811582820484141761203357612033614747565b81835281816020850137505f602082840101525f6020601f19601f840116840101905092915050565b5f808335601e19843603018112614f0d575f80fd5b830160208101925035905067ffffffffffffffff811115614f2c575f80fd5b8036038213156148d5575f80fd5b5f838385526020808601955060208560051b830101845f5b87811015614f8c57601f19858403018952614f6d8288614ef8565b614f78858284614ecf565b9a86019a9450505090830190600101614f52565b5090979650505050505050565b608081525f614fab6080830189614d8d565b60208382036020850152614fc082898b614f3a565b91508382036040850152614fd5828789614f3a565b8481036060860152855180825260208088019450909101905f5b8181101561500b57845183529383019391830191600101614fef565b50909b9a5050505050505050505050565b63ffffffff8281168282160390808211156127f4576127f4614747565b8183525f7f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff831115615069575f80fd5b8260051b80836020870137939093016020019392505050565b8881525f602060c08184015261509c60c084018a8c615039565b60406001600160a01b03808b1660408701526060818b166060880152608091508684036080880152838985528585019050858a60051b8601018b5f5b8c81101561517a57601f198884030184528135607e198f36030181126150fc575f80fd5b8e016151088180614ef8565b8886526151188987018284614ecf565b9150506151278b830183614ef8565b8683038d880152615139838284614ecf565b92505050888201358986015261515187830183614ef8565b925085820388870152615165828483614ecf565b968c01969550505091890191506001016150d8565b50506001600160a01b038a1660a08a0152965061519995505050505050565b9998505050505050505050565b5f808335601e198436030181126151bb575f80fd5b83018035915067ffffffffffffffff8211156151d5575f80fd5b6020019150368190038213156148d5575f80fd5b5f8235607e198336030181126151fd575f80fd5b9190910192915050565b606081525f61521a606083018789614ecf565b828103602084015261522d818688614ecf565b9150508260408301529695505050505050565b5f60208284031215615250575f80fd5b5051919050565b634e487b7160e01b5f52602160045260245ffd5b6004811061528757634e487b7160e01b5f52602160045260245ffd5b9052565b6001600160a01b03841681526020810183905260608101612db1604083018461526b565b602081525f610f6c602083018486615039565b5f826152dc57634e487b7160e01b5f52601260045260245ffd5b500490565b5f602082840312156152f1575f80fd5b8151600a8110610f6f575f80fd5b604081525f615312604083018587615039565b90506001600160a01b0383166020830152949350505050565b8082018082111561203357612033614747565b8181038181111561203357612033614747565b83815260608101615365602083018561526b565b6001600160a01b0383166040830152949350505050565b5f6101008083526153908184018c8e615039565b9150508860208301526001600160a01b03808916604084015280881660608401528087166080840152506153c760a083018661526b565b92151560c082015260e00152979650505050505050565b5f60208083850312156153ef575f80fd5b825167ffffffffffffffff811115615405575f80fd5b8301601f81018513615415575f80fd5b805161542361492a82614871565b81815260059190911b82018301908381019087831115615441575f80fd5b928401925b8284101561468557835182529284019290840190615446565b63ffffffff8181168382160190808211156127f4576127f4614747565b600f81810b9083900b016f7fffffffffffffffffffffffffffffff81137fffffffffffffffffffffffffffffffff800000000000000000000000000000008212171561203357612033614747565b5f5b838110156154e45781810151838201526020016154cc565b50505f910152565b5f82516151fd8184602087016154ca565b602081525f825180602084015261551b8160408501602087016154ca565b601f01601f1916919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a164736f6c6343000818000a
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 33 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.