ETH Price: $3,475.48 (+4.93%)

Contract

0xD664b74274DfEB538d9baC494F3a4760828B02b0
 

Overview

ETH Balance

5,719.897978928268936346 ETH

Eth Value

$19,879,371.72 (@ $3,475.48/ETH)

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Deposit212487162024-11-23 6:42:239 hrs ago1732344143IN
Dinero: Pirex ETH
2.175 ETH0.0017422110.7
Deposit212485352024-11-23 6:06:119 hrs ago1732341971IN
Dinero: Pirex ETH
0.011 ETH0.0010547710.97478851
Deposit212485052024-11-23 6:00:1110 hrs ago1732341611IN
Dinero: Pirex ETH
0.01 ETH0.000970710.1
Deposit212433002024-11-22 12:33:5927 hrs ago1732278839IN
Dinero: Pirex ETH
6 ETH0.0023787113.22065332
Deposit212422802024-11-22 9:09:1130 hrs ago1732266551IN
Dinero: Pirex ETH
0.013 ETH0.000980699.91709933
Deposit212421682024-11-22 8:46:3531 hrs ago1732265195IN
Dinero: Pirex ETH
0.012 ETH0.0010790810.91203916
Deposit212414802024-11-22 6:27:5933 hrs ago1732256879IN
Dinero: Pirex ETH
3.85 ETH0.001547629.50489838
Deposit212382842024-11-21 19:45:5944 hrs ago1732218359IN
Dinero: Pirex ETH
0.011 ETH0.0023066124
Deposit212357122024-11-21 11:09:472 days ago1732187387IN
Dinero: Pirex ETH
1.6 ETH0.0020415112.53910875
Deposit212330932024-11-21 2:21:592 days ago1732155719IN
Dinero: Pirex ETH
15 ETH0.0016614410.2039218
Redeem With Upx ...212285912024-11-20 11:16:113 days ago1732101371IN
Dinero: Pirex ETH
0 ETH0.0006247810.29593988
Redeem With Upx ...212285882024-11-20 11:15:353 days ago1732101335IN
Dinero: Pirex ETH
0 ETH0.0006428510.59360917
Redeem With Upx ...212285852024-11-20 11:14:593 days ago1732101299IN
Dinero: Pirex ETH
0 ETH0.0006280110.34504371
Deposit212262502024-11-20 3:25:353 days ago1732073135IN
Dinero: Pirex ETH
0.01 ETH0.0010549610.66814628
Deposit212251142024-11-19 23:37:473 days ago1732059467IN
Dinero: Pirex ETH
0.96413813 ETH0.0014718110.1
Deposit212238702024-11-19 19:27:593 days ago1732044479IN
Dinero: Pirex ETH
0.0001 ETH0.001766421.59711271
Deposit212233542024-11-19 17:44:353 days ago1732038275IN
Dinero: Pirex ETH
0.003 ETH0.0038592823.70391193
Deposit212233482024-11-19 17:43:233 days ago1732038203IN
Dinero: Pirex ETH
0.003 ETH0.0023752424.02217542
Deposit212162852024-11-18 18:06:114 days ago1731953171IN
Dinero: Pirex ETH
0.0001 ETH0.0020833421.06751879
Instant Redeem W...212162062024-11-18 17:50:114 days ago1731952211IN
Dinero: Pirex ETH
0 ETH0.0019330719.93761578
Deposit212129902024-11-18 7:04:235 days ago1731913463IN
Dinero: Pirex ETH
10.61 ETH0.0019179611.77940513
Deposit212121052024-11-18 4:06:595 days ago1731902819IN
Dinero: Pirex ETH
0.04455703 ETH0.0020515812.6
Deposit212102962024-11-17 22:04:235 days ago1731881063IN
Dinero: Pirex ETH
0.01 ETH0.0017443610.71318224
Deposit212100532024-11-17 21:15:475 days ago1731878147IN
Dinero: Pirex ETH
0.195 ETH0.000980079.91087124
Deposit212095232024-11-17 19:29:235 days ago1731871763IN
Dinero: Pirex ETH
0.01 ETH0.0011536511.66755848
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
212466052024-11-22 23:38:4716 hrs ago1732318727
Dinero: Pirex ETH
31 ETH
212466052024-11-22 23:38:4716 hrs ago1732318727
Dinero: Pirex ETH
31 ETH
212466052024-11-22 23:38:4716 hrs ago1732318727
Dinero: Pirex ETH
31 ETH
212466052024-11-22 23:38:4716 hrs ago1732318727
Dinero: Pirex ETH
31 ETH
212466052024-11-22 23:38:4716 hrs ago1732318727
Dinero: Pirex ETH
31 ETH
212466052024-11-22 23:38:4716 hrs ago1732318727
Dinero: Pirex ETH
31 ETH
212466052024-11-22 23:38:4716 hrs ago1732318727
Dinero: Pirex ETH
31 ETH
212466052024-11-22 23:38:4716 hrs ago1732318727
Dinero: Pirex ETH
31 ETH
212466052024-11-22 23:38:4716 hrs ago1732318727
Dinero: Pirex ETH
31 ETH
212466052024-11-22 23:38:4716 hrs ago1732318727
Dinero: Pirex ETH
31 ETH
212466052024-11-22 23:38:4716 hrs ago1732318727
Dinero: Pirex ETH
31 ETH
212466052024-11-22 23:38:4716 hrs ago1732318727
Dinero: Pirex ETH
31 ETH
212466052024-11-22 23:38:4716 hrs ago1732318727
Dinero: Pirex ETH
31 ETH
212466052024-11-22 23:38:4716 hrs ago1732318727
Dinero: Pirex ETH
31 ETH
212466052024-11-22 23:38:4716 hrs ago1732318727
Dinero: Pirex ETH
31 ETH
212466052024-11-22 23:38:4716 hrs ago1732318727
Dinero: Pirex ETH
31 ETH
212466052024-11-22 23:38:4716 hrs ago1732318727
Dinero: Pirex ETH
31 ETH
212466052024-11-22 23:38:4716 hrs ago1732318727
Dinero: Pirex ETH
31 ETH
212466052024-11-22 23:38:4716 hrs ago1732318727
Dinero: Pirex ETH
31 ETH
212466052024-11-22 23:38:4716 hrs ago1732318727
Dinero: Pirex ETH
31 ETH
212466052024-11-22 23:38:4716 hrs ago1732318727
Dinero: Pirex ETH
31 ETH
212466052024-11-22 23:38:4716 hrs ago1732318727
Dinero: Pirex ETH
31 ETH
212466052024-11-22 23:38:4716 hrs ago1732318727
Dinero: Pirex ETH
31 ETH
212466052024-11-22 23:38:4716 hrs ago1732318727
Dinero: Pirex ETH
31 ETH
212466052024-11-22 23:38:4716 hrs ago1732318727
Dinero: Pirex ETH
31 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
PirexEth

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
File 1 of 33 : PirexEth.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import {ERC20} from "solmate/tokens/ERC20.sol";
import {SafeTransferLib} from "solmate/utils/SafeTransferLib.sol";
import {Errors} from "./libraries/Errors.sol";
import {DataTypes} from "./libraries/DataTypes.sol";
import {IPirexFees} from "./interfaces/IPirexFees.sol";
import {PirexEthValidators} from "./PirexEthValidators.sol";

/**
 * @title  Main contract for handling interactions with pxETH
 * @notice This contract manages various interactions with pxETH, such as deposits, redemptions, and fee adjustments.
 * @dev    This contract inherits from PirexEthValidators and utilizes SafeTransferLib for ERC20 token transfers.
 * @author redactedcartel.finance
 */
contract PirexEth is PirexEthValidators {
    /**
     * @notice Smart contract uses the SafeTransferLib library for secure ERC20 token transfers.
     * @dev    The SafeTransferLib library provides enhanced safety checks and error handling for ERC20 token transfers,
     *         reducing the risk of common vulnerabilities such as reentrancy attacks. By using this library,
     *         the smart contract ensures safer and more reliable interactions with ERC20 tokens.
     */
    using SafeTransferLib for ERC20;

    /**
     * @notice Immutable reference to the Pirex fee repository and distribution contract.
     * @dev    The `pirexFees` variable holds the address of the Pirex fee repository and distribution contract (IPirexFees).
     *         This contract is responsible for managing and distributing fees collected within the Pirex ecosystem.
     *         As an immutable variable, its value is set at deployment and cannot be changed thereafter.
     */
    IPirexFees public immutable pirexFees;

    /**
     * @notice Mapping of maximum fees allowed for different operations in the contract.
     * @dev    The `maxFees` mapping associates each fee type (Deposit, Redemption, InstantRedemption) with its corresponding maximum fee percentage.
     *         For example, a value of 200000 represents a maximum fee of 20% (200000 / 1000000).
     *         Developers can access and modify these maximum fees directly through this public mapping.
     */
    mapping(DataTypes.Fees => uint32) public maxFees;

    /**
     * @notice Mapping of fees for different operations in the contract.
     * @dev    The `fees` mapping associates each fee type (Deposit, Redemption, InstantRedemption) with its corresponding fee percentage.
     *         For example, a value of 5000 represents a 0.5% fee (5000 / 1000000).
     *         Developers can access and modify these fees directly through this public mapping.
     */
    mapping(DataTypes.Fees => uint32) public fees;

    /**
     * @notice Current pause state of the contract.
     * @dev    The `paused` state variable indicates whether certain functionalities of the contract are currently paused or active.
     *         A value of 1 denotes a paused state, while 0 indicates the contract is not paused.
     */
    uint256 public paused;

    // Events
    /**
     * @notice Event emitted when ETH is deposited, minting pxETH, and optionally compounding into the vault.
     * @dev    Use this event to log details about the deposit, including the caller's address, the receiver's address, whether compounding occurred, the deposited amount, received pxETH amount, and fee amount.
     * @param  caller          address  indexed  Address of the entity initiating the deposit.
     * @param  receiver        address  indexed  Address of the receiver of the minted pxETH or apxEth.
     * @param  shouldCompound  bool     indexed  Boolean indicating whether compounding into the vault occurred.
     * @param  deposited       uint256           Amount of ETH deposited.
     * @param  receivedAmount  uint256           Amount of pxETH minted for the receiver.
     * @param  feeAmount       uint256           Amount of pxETH distributed as fees.
     */
    event Deposit(
        address indexed caller,
        address indexed receiver,
        bool indexed shouldCompound,
        uint256 deposited,
        uint256 receivedAmount,
        uint256 feeAmount
    );

    /**
     * @notice Event emitted when a redemption is initiated by burning pxETH in return for upxETH.
     * @dev    Use this event to log details about the redemption initiation, including the redeemed asset amount, post-fee amount, and the receiver's address.
     * @param  assets         uint256           Amount of pxETH burnt for the redemption.
     * @param  postFeeAmount  uint256           Amount of pxETH distributed to the receiver after deducting fees.
     * @param  receiver       address  indexed  Address of the receiver of the upxETH.
     */
    event InitiateRedemption(
        uint256 assets,
        uint256 postFeeAmount,
        address indexed receiver
    );

    /**
     * @notice Event emitted when ETH is redeemed using UpxETH.
     * @dev    Use this event to log details about the redemption, including the tokenId, redeemed asset amount, and the receiver's address.
     * @param  tokenId   uint256           Identifier for the redemption batch.
     * @param  assets    uint256           Amount of ETH redeemed.
     * @param  receiver  address  indexed  Address of the receiver of the redeemed ETH.
     */
    event RedeemWithUpxEth(
        uint256 tokenId,
        uint256 assets,
        address indexed receiver
    );

    /**
     * @notice Event emitted when pxETH is redeemed for ETH with fees.
     * @dev    Use this event to log details about pxETH redemption, including the redeemed asset amount, post-fee amount, and the receiver's address.
     * @param  assets         uint256           Amount of pxETH redeemed.
     * @param  postFeeAmount  uint256           Amount of ETH received by the receiver after deducting fees.
     * @param  _receiver      address  indexed  Address of the receiver of the redeemed ETH.
     */
    event RedeemWithPxEth(
        uint256 assets,
        uint256 postFeeAmount,
        address indexed _receiver
    );

    /**
     * @notice Event emitted when the fee amount for a specific fee type is set.
     * @dev    Use this event to log changes in the fee amount for a particular fee type, including the fee type and the new fee amount.
     * @param  f    DataTypes.Fees  indexed (Deposit, Redemption, InstantRedemption) for which the fee amount is being set.
     * @param  fee  uint32                  New fee amount for the specified fee type.
     */
    event SetFee(DataTypes.Fees indexed f, uint32 fee);

    /**
     * @notice Event emitted when the maximum fee for a specific fee type is set.
     * @dev    Use this event to log changes in the maximum fee for a particular fee type, including the fee type and the new maximum fee.
     * @param  f       DataTypes.Fees  indexed  Deposit, Redemption or InstantRedemption for which the maximum fee is being set.
     * @param  maxFee  uint32                   New maximum fee amount for the specified fee type.
     */
    event SetMaxFee(DataTypes.Fees indexed f, uint32 maxFee);

    /**
     * @notice Event emitted when the contract's pause state is toggled.
     * @dev    Use this event to log changes in the contract's pause state, including the account triggering the change and the new state.
     * @param  account  address  Address of the entity toggling the pause state.
     * @param  state    uint256  New pause state: 1 for paused, 0 for not paused.
     */
    event SetPauseState(address account, uint256 state);

    /**
     * @notice Event emitted when an emergency withdrawal occurs.
     * @dev    Use this event to log details about emergency withdrawals, including the receiver's address, the token involved, and the withdrawn amount.
     * @param  receiver address  indexed  Address of the receiver of the emergency withdrawal.
     * @param  token    address  indexed  Address of the token involved in the emergency withdrawal.
     * @param  amount   uint256           Amount withdrawn in the emergency withdrawal.
     */
    event EmergencyWithdrawal(
        address indexed receiver,
        address indexed token,
        uint256 amount
    );

    // Modifiers
    /**
     * @dev Use this modifier to check if the contract is not currently paused before allowing function execution.
     */
    modifier whenNotPaused() {
        if (paused == _PAUSED) revert Errors.Paused();
        _;
    }

    /**
     * @notice Contract constructor to initialize PirexEthValidator with necessary parameters and configurations.
     * @dev    This constructor sets up the PirexEthValidator contract, configuring key parameters and initializing state variables.
     * @param  _pxEth                      address  PxETH contract address
     * @param  _admin                      address  Admin address
     * @param  _beaconChainDepositContract address  The address of the beacon chain deposit contract
     * @param  _upxEth                     address  UpxETH address
     * @param  _depositSize                uint256  Amount of eth to stake
     * @param  _preDepositAmount           uint256  Amount of ETH for pre-deposit
     * @param  _pirexFees                  address  PirexFees contract address
     * @param  _initialDelay               uint48   Delay required to schedule the acceptance
     *                                              of an access control transfer started
     */
    constructor(
        address _pxEth,
        address _admin,
        address _beaconChainDepositContract,
        address _upxEth,
        uint256 _depositSize,
        uint256 _preDepositAmount,
        address _pirexFees,
        uint48 _initialDelay
    )
        PirexEthValidators(
            _pxEth,
            _admin,
            _beaconChainDepositContract,
            _upxEth,
            _depositSize,
            _preDepositAmount,
            _initialDelay
        )
    {
        if (_pirexFees == address(0)) revert Errors.ZeroAddress();

        pirexFees = IPirexFees(_pirexFees);
        maxFees[DataTypes.Fees.Deposit] = 200_000;
        maxFees[DataTypes.Fees.Redemption] = 200_000;
        maxFees[DataTypes.Fees.InstantRedemption] = 200_000;
        paused = _NOT_PAUSED;
    }

    /*//////////////////////////////////////////////////////////////
                            MUTATIVE FUNCTIONS
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Set fee
     * @dev    This function allows an entity with the GOVERNANCE_ROLE to set the fee amount for a specific fee type.
     * @param  f    DataTypes.Fees  Fee
     * @param  fee  uint32          Fee amount
     */
    function setFee(
        DataTypes.Fees f,
        uint32 fee
    ) external onlyRole(GOVERNANCE_ROLE) {
        if (fee > maxFees[f]) revert Errors.InvalidFee();

        fees[f] = fee;

        emit SetFee(f, fee);
    }

    /**
     * @notice Set Max fee
     * @dev    This function allows an entity with the GOVERNANCE_ROLE to set the maximum fee for a specific fee type.
     * @param  f       DataTypes.Fees  Fee
     * @param  maxFee  uint32          Max fee amount
     */
    function setMaxFee(
        DataTypes.Fees f,
        uint32 maxFee
    ) external onlyRole(GOVERNANCE_ROLE) {
        if (maxFee < fees[f] || maxFee > DENOMINATOR) revert Errors.InvalidMaxFee();

        maxFees[f] = maxFee;

        emit SetMaxFee(f, maxFee);
    }

    /**
     * @notice Toggle the contract's pause state
     * @dev    This function allows an entity with the GOVERNANCE_ROLE to toggle the contract's pause state.
     */
    function togglePauseState() external onlyRole(GOVERNANCE_ROLE) {
        paused = paused == _PAUSED ? _NOT_PAUSED : _PAUSED;

        emit SetPauseState(msg.sender, paused);
    }

    /**
     * @notice Emergency withdrawal for all ERC20 tokens (except pxETH) and ETH
     * @dev    This function should only be called under major emergency
     * @param  receiver address  Receiver address
     * @param  token    address  Token address
     * @param  amount   uint256  Token amount
     */
    function emergencyWithdraw(
        address receiver,
        address token,
        uint256 amount
    ) external onlyRole(GOVERNANCE_ROLE) onlyWhenDepositEtherPaused {
        if (paused == _NOT_PAUSED) revert Errors.NotPaused();
        if (receiver == address(0)) revert Errors.ZeroAddress();
        if (amount == 0) revert Errors.ZeroAmount();
        if (token == address(pxEth)) revert Errors.InvalidToken();

        if (token == address(0)) {
            // Update pendingDeposit when affected by emergency withdrawal
            uint256 remainingBalance = address(this).balance - amount;
            if (pendingDeposit > remainingBalance) {
                pendingDeposit = remainingBalance;
            }

            // Handle ETH withdrawal
            (bool _success, ) = payable(receiver).call{value: amount}("");
            assert(_success);
        } else {
            ERC20(token).safeTransfer(receiver, amount);
        }

        emit EmergencyWithdrawal(receiver, token, amount);
    }

    /**
     * @notice Handle pxETH minting in return for ETH deposits
     * @dev    This function handles the minting of pxETH in return for ETH deposits.
     * @param  receiver        address  Receiver of the minted pxETH or apxEth
     * @param  shouldCompound  bool     Whether to also compound into the vault
     * @return postFeeAmount   uint256  pxETH minted for the receiver
     * @return feeAmount       uint256  pxETH distributed as fees
     */
    function deposit(
        address receiver,
        bool shouldCompound
    )
        external
        payable
        whenNotPaused
        nonReentrant
        returns (uint256 postFeeAmount, uint256 feeAmount)
    {
        if (msg.value == 0) revert Errors.ZeroAmount();
        if (receiver == address(0)) revert Errors.ZeroAddress();

        // Get the pxETH amounts for the receiver and the protocol (fees)
        (postFeeAmount, feeAmount) = _computeAssetAmounts(
            DataTypes.Fees.Deposit,
            msg.value
        );

        // Mint pxETH for the receiver (or this contract if compounding) excluding fees
        _mintPxEth(shouldCompound ? address(this) : receiver, postFeeAmount);

        if (shouldCompound) {
            // Deposit pxETH excluding fees into the autocompounding vault
            // then mint shares (apxETH) for the user
            autoPxEth.deposit(postFeeAmount, receiver);
        }

        // Mint pxETH for fee distribution contract
        if (feeAmount != 0) {
            _mintPxEth(address(pirexFees), feeAmount);
        }

        // Redirect the deposit to beacon chain deposit contract
        _addPendingDeposit(msg.value);

        emit Deposit(
            msg.sender,
            receiver,
            shouldCompound,
            msg.value,
            postFeeAmount,
            feeAmount
        );
    }

    /**
     * @notice Initiate redemption by burning pxETH in return for upxETH
     * @dev    This function is used to initiate redemption by burning pxETH and receiving upxETH.
     * @param  _assets                      uint256  If caller is AutoPxEth then apxETH; pxETH otherwise.
     * @param  _receiver                    address  Receiver for upxETH.
     * @param  _shouldTriggerValidatorExit  bool     Whether the initiation should trigger voluntary exit.
     * @return postFeeAmount                uint256  pxETH burnt for the receiver.
     * @return feeAmount                    uint256  pxETH distributed as fees.
     */
    function initiateRedemption(
        uint256 _assets,
        address _receiver,
        bool _shouldTriggerValidatorExit
    )
        external
        override
        whenNotPaused
        nonReentrant
        returns (uint256 postFeeAmount, uint256 feeAmount)
    {
        if (_assets == 0) revert Errors.ZeroAmount();
        if (_receiver == address(0)) revert Errors.ZeroAddress();

        uint256 _pxEthAmount;

        if (msg.sender == address(autoPxEth)) {
            // The pxETH amount is calculated as per apxETH-ETH ratio during current block
            _pxEthAmount = autoPxEth.redeem(
                _assets,
                address(this),
                address(this)
            );
        } else {
            _pxEthAmount = _assets;
        }

        // Get the pxETH amounts for the receiver and the protocol (fees)
        (postFeeAmount, feeAmount) = _computeAssetAmounts(
            DataTypes.Fees.Redemption,
            _pxEthAmount
        );

        uint256 _requiredValidators = (pendingWithdrawal + postFeeAmount) /
            DEPOSIT_SIZE;

        if (_shouldTriggerValidatorExit && _requiredValidators == 0)
            revert Errors.NoValidatorExit();

        if (_requiredValidators > getStakingValidatorCount())
            revert Errors.NotEnoughValidators();

        emit InitiateRedemption(_pxEthAmount, postFeeAmount, _receiver);

        address _owner = msg.sender == address(autoPxEth)
            ? address(this)
            : msg.sender;

        _burnPxEth(_owner, postFeeAmount);

        if (feeAmount != 0) {
            // Allow PirexFees to distribute fees directly from sender
            pxEth.operatorApprove(_owner, address(pirexFees), feeAmount);

            // Distribute fees
            pirexFees.distributeFees(_owner, address(pxEth), feeAmount);
        }

        _initiateRedemption(
            postFeeAmount,
            _receiver,
            _shouldTriggerValidatorExit
        );
    }

    /**
     * @notice Bulk redeem back ETH using a set of upxEth identifiers
     * @dev    This function allows the bulk redemption of ETH using upxEth tokens.
     * @param  _tokenIds  uint256[]  Redeem batch identifiers
     * @param  _amounts   uint256[]  Amounts of ETH to redeem for each identifier
     * @param  _receiver  address    Address of the ETH receiver
     */
    function bulkRedeemWithUpxEth(
        uint256[] calldata _tokenIds,
        uint256[] calldata _amounts,
        address _receiver
    ) external whenNotPaused nonReentrant {
        uint256 tLen = _tokenIds.length;
        uint256 aLen = _amounts.length;

        if (tLen == 0) revert Errors.EmptyArray();
        if (tLen != aLen) revert Errors.MismatchedArrayLengths();

        for (uint256 i; i < tLen; ++i) {
            _redeemWithUpxEth(_tokenIds[i], _amounts[i], _receiver);
        }
    }

    /**
     * @notice Redeem back ETH using a single upxEth identifier
     * @dev    This function allows the redemption of ETH using upxEth tokens.
     * @param  _tokenId  uint256  Redeem batch identifier
     * @param  _assets   uint256  Amount of ETH to redeem
     * @param  _receiver  address  Address of the ETH receiver
     */
    function redeemWithUpxEth(
        uint256 _tokenId,
        uint256 _assets,
        address _receiver
    ) external whenNotPaused nonReentrant {
        _redeemWithUpxEth(_tokenId, _assets, _receiver);
    }

    /**
     * @notice Instant redeem back ETH using pxETH
     * @dev    This function burns pxETH, calculates fees, and transfers ETH to the receiver.
     * @param  _assets        uint256   Amount of pxETH to redeem.
     * @param  _receiver      address   Address of the ETH receiver.
     * @return postFeeAmount  uint256   Post-fee amount for the receiver.
     * @return feeAmount      uinit256  Fee amount sent to the PirexFees.
     */
    function instantRedeemWithPxEth(
        uint256 _assets,
        address _receiver
    )
        external
        whenNotPaused
        nonReentrant
        returns (uint256 postFeeAmount, uint256 feeAmount)
    {
        if (_assets == 0) revert Errors.ZeroAmount();
        if (_receiver == address(0)) revert Errors.ZeroAddress();

        // Get the pxETH amounts for the receiver and the protocol (fees)
        (postFeeAmount, feeAmount) = _computeAssetAmounts(
            DataTypes.Fees.InstantRedemption,
            _assets
        );

        if (postFeeAmount > buffer) revert Errors.NotEnoughBuffer();

        if (feeAmount != 0) {
            // Allow PirexFees to distribute fees directly from sender
            pxEth.operatorApprove(msg.sender, address(pirexFees), feeAmount);

            // Distribute fees
            pirexFees.distributeFees(msg.sender, address(pxEth), feeAmount);
        }

        _burnPxEth(msg.sender, postFeeAmount);
        buffer -= postFeeAmount;

        (bool _success, ) = payable(_receiver).call{value: postFeeAmount}("");
        assert(_success);

        emit RedeemWithPxEth(_assets, postFeeAmount, _receiver);
    }

    /*//////////////////////////////////////////////////////////////
                        INTERNAL FUNCTIONS
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Redeem back ETH using upxEth
     * @dev    This function allows the redemption of ETH using upxEth tokens.
     * @param  _tokenId  uint256  Redeem batch identifier
     * @param  _assets   uint256  Amount of ETH to redeem
     * @param  _receiver  address  Address of the ETH receiver
     */
    function _redeemWithUpxEth(
        uint256 _tokenId,
        uint256 _assets,
        address _receiver
    ) internal {
        if (_assets == 0) revert Errors.ZeroAmount();
        if (_receiver == address(0)) revert Errors.ZeroAddress();

        DataTypes.ValidatorStatus _validatorStatus = status[
            batchIdToValidator[_tokenId]
        ];

        if (
            _validatorStatus != DataTypes.ValidatorStatus.Dissolved &&
            _validatorStatus != DataTypes.ValidatorStatus.Slashed
        ) {
            revert Errors.StatusNotDissolvedOrSlashed();
        }

        if (outstandingRedemptions < _assets) revert Errors.NotEnoughETH();

        outstandingRedemptions -= _assets;
        upxEth.burn(msg.sender, _tokenId, _assets);

        (bool _success, ) = payable(_receiver).call{value: _assets}("");
        assert(_success);

        emit RedeemWithUpxEth(_tokenId, _assets, _receiver);
    }

    /**
     * @dev     This function calculates the post-fee asset amount and fee amount based on the specified fee type and total assets.
     * @param   f              DataTypes.Fees  representing the fee type.
     * @param   assets         uint256         Total ETH or pxETH asset amount.
     * @return  postFeeAmount  uint256         Post-fee asset amount (for mint/burn/claim/etc.).
     * @return  feeAmount      uint256         Fee amount.
     */
    function _computeAssetAmounts(
        DataTypes.Fees f,
        uint256 assets
    ) internal view returns (uint256 postFeeAmount, uint256 feeAmount) {
        feeAmount = (assets * fees[f]) / DENOMINATOR;
        postFeeAmount = assets - feeAmount;
    }
}

File 2 of 33 : ERC20.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)
/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)
/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.
abstract contract ERC20 {
    /*//////////////////////////////////////////////////////////////
                                 EVENTS
    //////////////////////////////////////////////////////////////*/

    event Transfer(address indexed from, address indexed to, uint256 amount);

    event Approval(address indexed owner, address indexed spender, uint256 amount);

    /*//////////////////////////////////////////////////////////////
                            METADATA STORAGE
    //////////////////////////////////////////////////////////////*/

    string public name;

    string public symbol;

    uint8 public immutable decimals;

    /*//////////////////////////////////////////////////////////////
                              ERC20 STORAGE
    //////////////////////////////////////////////////////////////*/

    uint256 public totalSupply;

    mapping(address => uint256) public balanceOf;

    mapping(address => mapping(address => uint256)) public allowance;

    /*//////////////////////////////////////////////////////////////
                            EIP-2612 STORAGE
    //////////////////////////////////////////////////////////////*/

    uint256 internal immutable INITIAL_CHAIN_ID;

    bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;

    mapping(address => uint256) public nonces;

    /*//////////////////////////////////////////////////////////////
                               CONSTRUCTOR
    //////////////////////////////////////////////////////////////*/

    constructor(
        string memory _name,
        string memory _symbol,
        uint8 _decimals
    ) {
        name = _name;
        symbol = _symbol;
        decimals = _decimals;

        INITIAL_CHAIN_ID = block.chainid;
        INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();
    }

    /*//////////////////////////////////////////////////////////////
                               ERC20 LOGIC
    //////////////////////////////////////////////////////////////*/

    function approve(address spender, uint256 amount) public virtual returns (bool) {
        allowance[msg.sender][spender] = amount;

        emit Approval(msg.sender, spender, amount);

        return true;
    }

    function transfer(address to, uint256 amount) public virtual returns (bool) {
        balanceOf[msg.sender] -= amount;

        // Cannot overflow because the sum of all user
        // balances can't exceed the max uint256 value.
        unchecked {
            balanceOf[to] += amount;
        }

        emit Transfer(msg.sender, to, amount);

        return true;
    }

    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) public virtual returns (bool) {
        uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.

        if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;

        balanceOf[from] -= amount;

        // Cannot overflow because the sum of all user
        // balances can't exceed the max uint256 value.
        unchecked {
            balanceOf[to] += amount;
        }

        emit Transfer(from, to, amount);

        return true;
    }

    /*//////////////////////////////////////////////////////////////
                             EIP-2612 LOGIC
    //////////////////////////////////////////////////////////////*/

    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) public virtual {
        require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED");

        // Unchecked because the only math done is incrementing
        // the owner's nonce which cannot realistically overflow.
        unchecked {
            address recoveredAddress = ecrecover(
                keccak256(
                    abi.encodePacked(
                        "\x19\x01",
                        DOMAIN_SEPARATOR(),
                        keccak256(
                            abi.encode(
                                keccak256(
                                    "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
                                ),
                                owner,
                                spender,
                                value,
                                nonces[owner]++,
                                deadline
                            )
                        )
                    )
                ),
                v,
                r,
                s
            );

            require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER");

            allowance[recoveredAddress][spender] = value;
        }

        emit Approval(owner, spender, value);
    }

    function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {
        return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();
    }

    function computeDomainSeparator() internal view virtual returns (bytes32) {
        return
            keccak256(
                abi.encode(
                    keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
                    keccak256(bytes(name)),
                    keccak256("1"),
                    block.chainid,
                    address(this)
                )
            );
    }

    /*//////////////////////////////////////////////////////////////
                        INTERNAL MINT/BURN LOGIC
    //////////////////////////////////////////////////////////////*/

    function _mint(address to, uint256 amount) internal virtual {
        totalSupply += amount;

        // Cannot overflow because the sum of all user
        // balances can't exceed the max uint256 value.
        unchecked {
            balanceOf[to] += amount;
        }

        emit Transfer(address(0), to, amount);
    }

    function _burn(address from, uint256 amount) internal virtual {
        balanceOf[from] -= amount;

        // Cannot underflow because a user's balance
        // will never be larger than the total supply.
        unchecked {
            totalSupply -= amount;
        }

        emit Transfer(from, address(0), amount);
    }
}

File 3 of 33 : SafeTransferLib.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

import {ERC20} from "../tokens/ERC20.sol";

/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)
/// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.
/// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller.
library SafeTransferLib {
    /*//////////////////////////////////////////////////////////////
                             ETH OPERATIONS
    //////////////////////////////////////////////////////////////*/

    function safeTransferETH(address to, uint256 amount) internal {
        bool success;

        /// @solidity memory-safe-assembly
        assembly {
            // Transfer the ETH and store if it succeeded or not.
            success := call(gas(), to, amount, 0, 0, 0, 0)
        }

        require(success, "ETH_TRANSFER_FAILED");
    }

    /*//////////////////////////////////////////////////////////////
                            ERC20 OPERATIONS
    //////////////////////////////////////////////////////////////*/

    function safeTransferFrom(
        ERC20 token,
        address from,
        address to,
        uint256 amount
    ) internal {
        bool success;

        /// @solidity memory-safe-assembly
        assembly {
            // Get a pointer to some free memory.
            let freeMemoryPointer := mload(0x40)

            // Write the abi-encoded calldata into memory, beginning with the function selector.
            mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
            mstore(add(freeMemoryPointer, 4), from) // Append the "from" argument.
            mstore(add(freeMemoryPointer, 36), to) // Append the "to" argument.
            mstore(add(freeMemoryPointer, 68), amount) // Append the "amount" argument.

            success := and(
                // Set success to whether the call reverted, if not we check it either
                // returned exactly 1 (can't just be non-zero data), or had no return data.
                or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
                // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3.
                // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
                // Counterintuitively, this call must be positioned second to the or() call in the
                // surrounding and() call or else returndatasize() will be zero during the computation.
                call(gas(), token, 0, freeMemoryPointer, 100, 0, 32)
            )
        }

        require(success, "TRANSFER_FROM_FAILED");
    }

    function safeTransfer(
        ERC20 token,
        address to,
        uint256 amount
    ) internal {
        bool success;

        /// @solidity memory-safe-assembly
        assembly {
            // Get a pointer to some free memory.
            let freeMemoryPointer := mload(0x40)

            // Write the abi-encoded calldata into memory, beginning with the function selector.
            mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)
            mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument.
            mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument.

            success := and(
                // Set success to whether the call reverted, if not we check it either
                // returned exactly 1 (can't just be non-zero data), or had no return data.
                or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
                // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
                // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
                // Counterintuitively, this call must be positioned second to the or() call in the
                // surrounding and() call or else returndatasize() will be zero during the computation.
                call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)
            )
        }

        require(success, "TRANSFER_FAILED");
    }

    function safeApprove(
        ERC20 token,
        address to,
        uint256 amount
    ) internal {
        bool success;

        /// @solidity memory-safe-assembly
        assembly {
            // Get a pointer to some free memory.
            let freeMemoryPointer := mload(0x40)

            // Write the abi-encoded calldata into memory, beginning with the function selector.
            mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000)
            mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument.
            mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument.

            success := and(
                // Set success to whether the call reverted, if not we check it either
                // returned exactly 1 (can't just be non-zero data), or had no return data.
                or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
                // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
                // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
                // Counterintuitively, this call must be positioned second to the or() call in the
                // surrounding and() call or else returndatasize() will be zero during the computation.
                call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)
            )
        }

        require(success, "APPROVE_FAILED");
    }
}

File 4 of 33 : Errors.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

library Errors {
    /**
     * @dev Zero address specified
     */
    error ZeroAddress();

    /**
     * @dev Zero amount specified
     */
    error ZeroAmount();

    /**
     * @dev Invalid fee specified
     */
    error InvalidFee();

    /**
     * @dev Invalid max fee specified
     */
    error InvalidMaxFee();

    /**
     * @dev Zero multiplier used
     */
    error ZeroMultiplier();

    /**
     * @dev ETH deposit is paused
     */
    error DepositingEtherPaused();

    /**
     * @dev ETH deposit is not paused
     */
    error DepositingEtherNotPaused();

    /**
     * @dev Contract is paused
     */
    error Paused();

    /**
     * @dev Contract is not paused
     */
    error NotPaused();

    /**
     * @dev Validator not yet dissolved
     */
    error NotDissolved();

    /**
     * @dev Validator not yet withdrawable
     */
    error NotWithdrawable();

    /**
     * @dev Validator has been previously used before
     */
    error NoUsedValidator();

    /**
     * @dev Not oracle adapter
     */
    error NotOracleAdapter();

    /**
     * @dev Not reward recipient
     */
    error NotRewardRecipient();

    /**
     * @dev Exceeding max value
     */
    error ExceedsMax();

    /**
     * @dev No rewards available
     */
    error NoRewards();

    /**
     * @dev Not PirexEth
     */
    error NotPirexEth();

    /**
     * @dev Not minter
     */
    error NotMinter();

    /**
     * @dev Not burner
     */
    error NotBurner();

    /**
     * @dev Empty string
     */
    error EmptyString();

    /**
     * @dev Validator is Not Staking
     */
    error ValidatorNotStaking();

    /**
     * @dev not enough buffer
     */
    error NotEnoughBuffer();

    /**
     * @dev validator queue empty
     */
    error ValidatorQueueEmpty();

    /**
     * @dev out of bounds
     */
    error OutOfBounds();

    /**
     * @dev cannot trigger validator exit
     */
    error NoValidatorExit();

    /**
     * @dev cannot initiate redemption partially
     */
    error NoPartialInitiateRedemption();

    /**
     * @dev not enough validators
     */
    error NotEnoughValidators();

    /**
     * @dev not enough ETH
     */
    error NotEnoughETH();

    /**
     * @dev max processed count is invalid (< 1)
     */
    error InvalidMaxProcessedCount();

    /**
     * @dev fromIndex and toIndex are invalid
     */
    error InvalidIndexRanges();

    /**
     * @dev ETH is not allowed
     */
    error NoETHAllowed();

    /**
     * @dev ETH is not passed
     */
    error NoETH();

    /**
     * @dev validator status is neither dissolved nor slashed
     */
    error StatusNotDissolvedOrSlashed();

    /**
     * @dev validator status is neither withdrawable nor staking
     */
    error StatusNotWithdrawableOrStaking();

    /**
     * @dev account is not approved
     */
    error AccountNotApproved();

    /**
     * @dev invalid token specified
     */
    error InvalidToken();

    /**
     * @dev not same as deposit size
     */
    error InvalidAmount();

    /**
     * @dev contract not recognised
     */
    error UnrecorgnisedContract();

    /**
     * @dev empty array
     */
    error EmptyArray();

    /**
     * @dev arrays length mismatch
     */
    error MismatchedArrayLengths();
}

File 5 of 33 : DataTypes.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.19;

/**
 * @title DataTypes
 * @notice Library containing various data structures and enums for the PirexEth.
 * @dev This library provides data structures and enums crucial for the functionality of the Pirex protocol.
 * @author redactedcartel.finance
 */
library DataTypes {
    // Validator struct type
    struct Validator {
        // Publickey of the validator
        bytes pubKey;
        // Signature associated with the validator
        bytes signature;
        // Root hash of deposit data for the validator
        bytes32 depositDataRoot;
        // beneficiazry address to receive pxEth against preDeposit
        address receiver;
    }

    // ValidatorDeque struct type
    struct ValidatorDeque {
        // Beginning index of the validator deque
        int128 _begin;
        // End index of the validator deque
        int128 _end;
        // Mapping of validator index to Validator struct
        mapping(int128 => Validator) _validators;
    }

    // Burner Account Type
    struct BurnerAccount {
        // Address of the burner account
        address account;
        // Amount associated with the burner account
        uint256 amount;
    }

    // Configurable fees
    enum Fees {
        // Fee type for deposit
        Deposit,
        // Fee type for redemption
        Redemption,
        // Fee type for instant redemption
        InstantRedemption
    }

    // Configurable contracts
    enum Contract {
        // PxEth contract
        PxEth,
        // UpxEth contract
        UpxEth,
        // AutoPxEth contract
        AutoPxEth,
        // OracleAdapter contract
        OracleAdapter,
        // PirexEth contract
        PirexEth,
        // RewardRecipient contract
        RewardRecipient
    }

    // Validator statuses
    enum ValidatorStatus {
        // The validator is not staking and has no defined status.
        None,
        // The validator is actively participating in the staking process.
        // It could be in one of the following states: pending_initialized, pending_queued, or active_ongoing.
        Staking,
        // The validator has proceed with the withdrawal process.
        // It represents a meta state for active_exiting, exited_unslashed, and the withdrawal process being possible.
        Withdrawable,
        // The validator's status indicating that ETH is released to the pirexEthValidators
        // It represents the withdrawal_done status.
        Dissolved,
        // The validator's status indicating that it has been slashed due to misbehavior.
        // It serves as a meta state encompassing active_slashed, exited_slashed,
        // and the possibility of starting the withdrawal process (withdrawal_possible) or already completed (withdrawal_done)
        // with the release of ETH, subject to a penalty for the misbehavior.
        Slashed
    }
}

File 6 of 33 : IPirexFees.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

/**
 * @title IPirexFees
 * @notice Interface for managing fee distribution in the PirexEth.
 * @dev This interface defines functions related to the distribution of fees in the Pirex protocol.
 * @author redactedcartel.finance
 */
interface IPirexFees {
    /**
     * @notice Distributes fees from a specified source.
     * @dev This function is responsible for distributing fees in the specified token amount.
     * @param from   address Address representing the source of fees.
     * @param token  address Address of the fee token.
     * @param amount uint256 The amount of the fee token to be distributed.
     */
    function distributeFees(
        address from,
        address token,
        uint256 amount
    ) external;
}

File 7 of 33 : PirexEthValidators.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import {ReentrancyGuard} from "solmate/utils/ReentrancyGuard.sol";
import {ERC20} from "solmate/tokens/ERC20.sol";
import {SafeTransferLib} from "solmate/utils/SafeTransferLib.sol";
import {AccessControlDefaultAdminRules} from "openzeppelin-contracts/contracts/access/AccessControlDefaultAdminRules.sol";
import {UpxEth} from "./tokens/UpxEth.sol";
import {Errors} from "./libraries/Errors.sol";
import {DataTypes} from "./libraries/DataTypes.sol";
import {ValidatorQueue} from "./libraries/ValidatorQueue.sol";
import {IOracleAdapter} from "./interfaces/IOracleAdapter.sol";
import {IPirexEth} from "./interfaces/IPirexEth.sol";
import {IDepositContract} from "./interfaces/IDepositContract.sol";
import {AutoPxEth} from "./AutoPxEth.sol";
import {PxEth} from "./PxEth.sol";

/**
 * @title  PirexEthValidators
 * @notice Manages validators and deposits for the Eth2.0 deposit contract
 * @dev    This contract includes functionality for handling validator-related operations and deposits.
 * @author redactedcartel.finance
 */
abstract contract PirexEthValidators is
    ReentrancyGuard,
    AccessControlDefaultAdminRules,
    IPirexEth
{
    /**
     * @dev This library provides enhanced safety features for ERC20 token transfers, reducing the risk of common vulnerabilities.
     */
    using ValidatorQueue for DataTypes.ValidatorDeque;
    /**
     * @dev This library extends the functionality of the DataTypes.ValidatorDeque data structure to facilitate validator management.
     */
    using SafeTransferLib for ERC20;

    /**
     * @notice Denominator used for mathematical calculations.
     * @dev    This constant is used as a divisor in various mathematical calculations
     *         throughout the contract to achieve precise percentages and ratios.
     */
    uint256 internal constant DENOMINATOR = 1_000_000;

    // Roles
    /**
     * @notice The role assigned to external keepers responsible for specific protocol functions.
     * @dev    This role is assigned to external entities that are responsible for performing specific
     *         functions within the protocol, such as validator upkeep and maintenance.
     */
    bytes32 internal constant KEEPER_ROLE = keccak256("KEEPER_ROLE");

    /**
     * @notice The role assigned to governance entities responsible for managing protocol parameters.
     * @dev    This role is assigned to governance entities that have the authority to manage and
     *         update various protocol parameters, ensuring the smooth operation and evolution of the protocol.
     */
    bytes32 internal constant GOVERNANCE_ROLE = keccak256("GOVERNANCE_ROLE");

    /**
     * @notice Paused status indicator when depositing Ether is not paused.
     * @dev    This constant represents the status indicator when depositing Ether is not paused.
     *         It is used as a reference for the depositEtherPaused state variable to determine whether
     *         depositing Ether is currently allowed or paused.
     */
    uint256 internal constant _NOT_PAUSED = 1;

    /**
     * @notice Paused status indicator when depositing Ether is paused.
     * @dev    This constant represents the status indicator when depositing Ether is paused.
     *         It is used as a reference for the depositEtherPaused state variable to determine
     *         whether depositing Ether is currently allowed or paused.
     */
    uint256 internal constant _PAUSED = 2;

    /**
     * @notice The address of the external beacon chain deposit contract.
     * @dev    This variable holds the immutable address of the external beacon chain deposit contract.
     *         It is used to interact with the contract for depositing validators to the Ethereum 2.0 beacon chain.
     */
    address public immutable beaconChainDepositContract;

    /**
     * @notice The amount of Ether that a validator must deposit before being added to the initialized validator queue.
     * @dev    This variable represents the immutable pre-deposit amount required for a validator to be added to the initialized validator queue.
     *         Validators need to deposit this amount of Ether to be put in initialized validator queue.
     */
    uint256 public immutable preDepositAmount;

    /**
     * @notice The default deposit size for validators, set once during contract initialization.
     * @dev    This variable represents the immutable default deposit size for validators.
     *         It is set during the contract initialization and represents the amount of Ether a validator needs to deposit
     *         to participate in the Ethereum 2.0 staking process.
     */
    uint256 public immutable DEPOSIT_SIZE;

    /**
     * @notice The withdrawal credentials used when processing validator withdrawals.
     * @dev    This variable holds the withdrawal credentials, which are used to receive valdiator rewards
     */
    bytes public withdrawalCredentials;

    /**
     * @notice Buffer for instant withdrawals and emergency top-ups.
     * @dev    This variable represents the buffer amount,
     *         which is utilized for immediate withdrawals and emergency top-ups.
     *         It serves as a reserve to facilitate rapid withdrawals or cover unexpected events within the protocol.
     */
    uint256 public buffer;

    /**
     * @notice Maximum buffer size for instant withdrawals and emergency top-ups.
     * @dev    This variable represents the upper limit for the buffer size,
     *         determining the maximum amount that can be reserved for immediate withdrawals,
     *         and emergency top-ups in the protocol.
     */
    uint256 public maxBufferSize;

    /**
     * @notice Percentage of pxEth total supply allocated to determine the max buffer size.
     * @dev    This variable represents the percentage of the total supply of pxEth that is allocated
     *         to determine the maximum buffer size. It influences the dynamic adjustment of the buffer
     *         size based on the total supply of pxEth in the protocol.
     */
    uint256 public maxBufferSizePct;

    /**
     * @notice Maximum count of validators to be processed in a single `_deposit` call.
     * @dev    This variable determines the maximum number of validators that can be processed in a single call to the `_deposit` function.
     *         It helps control the efficiency and gas cost of the depositing process.
     */
    uint256 public maxProcessedValidatorCount = 20;

    // Pirex contracts
    /**
     * @notice The UpxEth contract responsible for managing the upxEth token.
     * @dev    This variable holds the address of the UpxEth contract,
     *         which represents pending redemption.
     */
    UpxEth public upxEth;

    /**
     * @notice The PxEth contract responsible for managing the pxEth token.
     * @dev    This variable holds the address of the PxEth contract,
     *         which represents ETH deposit made to Dinero protocol.
     */
    PxEth public pxEth;

    /**
     * @notice The AutoPxEth contract responsible for automated management of the pxEth token.
     * @dev    This variable holds the address of the AutoPxEth contract,
     *         which represents pxEth deposit to auto compounding vault.
     */
    AutoPxEth public autoPxEth;

    /**
     * @notice The OracleAdapter contract responsible for interfacing with the oracle for protocol data.
     * @dev    This variable holds the address of the OracleAdapter contract,
     *         which is used to request validator exit and update its status to dissolves or slashed.
     */
    IOracleAdapter public oracleAdapter;

    /**
     * @notice The address designated as the reward recipient for protocol incentives.
     * @dev    This variable holds the address of the entity designated to receive consensus,
     *         execution and MEV rewards.
     */
    address public rewardRecipient;

    /**
     * @notice Indicator for whether depositing Ether to the beacon chain deposit contract is paused or not.
     * @dev    This variable holds the status indicator (paused or not) for depositing Ether to the beacon chain deposit contract.
     */
    uint256 public depositEtherPaused;

    /**
     * @notice Buffer for pending deposits to be staked, r
     *         equired to be greater than or equal to multiples of DEPOSIT_SIZE, including preDepositAmount.
     * @dev    This variable holds the amount of pending deposits that are waiting to be staked.
     *         It ensures that the buffer size is sufficient for multiples of DEPOSIT_SIZE, including preDepositAmount.
     */
    uint256 public pendingDeposit;

    /**
     * @notice Queue to prioritize validator spinning on a FIFO basis.
     * @dev    This internal variable represents a deque (double-ended queue) used to prioritize validator
     *         spinning based on a First-In-First-Out (FIFO) basis.
     */
    DataTypes.ValidatorDeque internal _initializedValidators;

    /**
     * @notice Queue to prioritize the next validator to be exited when required on a FIFO basis.
     * @dev    This internal variable represents a deque (double-ended queue) used to prioritize validators
     *         for exiting based on a First-In-First-Out (FIFO) basis.
     */
    DataTypes.ValidatorDeque internal _stakingValidators;

    /**
     * @notice Buffer for withdrawals to be unstaked, required to be greater than or equal to multiples of DEPOSIT_SIZE.
     * @dev    This variable holds the amount of Ether that is pending withdrawal,
     *         and it must be greater than or equal to multiples of DEPOSIT_SIZE.
     */
    uint256 public pendingWithdrawal;

    /**
     * @notice ETH available for redemptions.
     * @dev    This variable represents the amount of Ether available for redemptions by burning upxEth.
     */
    uint256 public outstandingRedemptions;

    /**
     * @notice Batch Id for validator's voluntary exit.
     * @dev    This variable represents the batch ID for a validator's voluntary exit.
     */
    uint256 public batchId;

    /**
     * @notice End block for the ETH rewards calculation.
     * @dev    This variable represents the block number until which ETH rewards are computed.
     */
    uint256 public endBlock;

    /**
     * @notice Validator statuses, mapping from validator public key to their status.
     * @dev    This mapping tracks the status of each validator, using their public key as the identifier.
     */
    mapping(bytes => DataTypes.ValidatorStatus) public status;

    /**
     * @notice Mapping from batchId to validator public key.
     * @dev    This mapping tracks the batch ID of each unstaked validator
     */
    mapping(uint256 => bytes) public batchIdToValidator;

    /**
     * @notice Accounts designated for burning pxEth when the buffer is used for top-up and the validator is slashed.
     * @dev    This mapping identifies accounts designated for burning pxEth under specific conditions.
     */
    mapping(address => bool) public burnerAccounts;

    // Events
    /**
     * @notice Emitted when a validator is deposited, indicating the addition of a new validator.
     * @dev    This event is triggered when a user deposits ETH for staking, creating a new validator.
     *         Validators play a crucial role in the proof-of-stake consensus mechanism and contribute
     *         to the security and functionality of the network. The `pubKey` parameter represents the public key of the deposited validator.
     * @param pubKey bytes Public key of the deposited validator.
     */
    event ValidatorDeposit(bytes pubKey);

    /**
     * @notice Emitted when a contract address is set.
     * @dev    This event is triggered when a contract address is set for a specific contract type.
     * @param  c                DataTypes.Contract  The type of the contract being set.
     * @param  contractAddress  address             The address of the contract being set.
     */
    event SetContract(DataTypes.Contract indexed c, address contractAddress);

    /**
     * @notice Emitted when the status of depositing Ether is paused or unpaused.
     * @dev    This event is triggered when there is a change in the status of depositing Ether.
     *         The `newStatus` parameter indicates whether depositing Ether is currently paused or unpaused.
     *         Pausing depositing Ether can be useful in certain scenarios, such as during contract upgrades or emergency situations.
     * @param  newStatus  uint256  The new status indicating whether depositing Ether is paused or unpaused.
     */
    event DepositEtherPaused(uint256 newStatus);

    /**
     * @notice Emitted when harvesting rewards.
     * @dev    This event is triggered when rewards are harvested. The `amount` parameter indicates the amount of rewards harvested,
     *         and the `endBlock` parameter specifies the block until which ETH rewards are computed.
     * @param  amount    uint256  The amount of rewards harvested.
     * @param  endBlock  uint256  The block until which ETH rewards are computed.
     */
    event Harvest(uint256 amount, uint256 endBlock);

    /**
     * @notice Emitted when the max buffer size percentage is set.
     * @dev    This event is triggered when the max buffer size percentage is updated.
     *         The `pct` parameter represents the new max buffer size percentage.
     * @param  pct  uint256  The new max buffer size percentage.
     */
    event SetMaxBufferSizePct(uint256 pct);

    /**
     * @notice Emitted when a burner account is approved.
     * @dev    This event is triggered when a burner account is approved.
     *         The `account` parameter represents the approved burner account.
     * @param  account  address  The approved burner account.
     */
    event ApproveBurnerAccount(address indexed account);

    /**
     * @notice Emitted when a burner account is revoked.
     * @dev    This event is triggered when a burner account is revoked.
     *         The `account` parameter represents the revoked burner account.
     * @param  account  address  The revoked burner account.
     */
    event RevokeBurnerAccount(address indexed account);

    /**
     * @notice Emitted when a validator is dissolved.
     * @dev    This event is triggered when a validator is dissolved, indicating the update of the validator state.
     * @param  pubKey  bytes  Public key of the dissolved validator.
     */
    event DissolveValidator(bytes pubKey);

    /**
     * @notice Emitted when a validator is slashed.
     * @dev    This event is triggered when a validator is slashed, indicating the slashing action and its details.
     * @param  pubKey          bytes    Public key of the slashed validator.
     * @param  useBuffer       bool     Indicates whether a buffer is used during slashing.
     * @param  releasedAmount  uint256  Amount released from the Beacon chain.
     * @param  penalty         uint256  Penalty amount.
     */
    event SlashValidator(
        bytes pubKey,
        bool useBuffer,
        uint256 releasedAmount,
        uint256 penalty
    );

    /**
     * @notice Emitted when a validator's stake is topped up.
     * @dev    This event is triggered when a validator's stake is topped up, indicating the top-up action and its details.
     * @param  pubKey       bytes    Public key of the topped-up validator.
     * @param  useBuffer    bool     Indicates whether a buffer is used during topping up.
     * @param  topUpAmount  uint256  Amount topped up.
     */
    event TopUp(bytes pubKey, bool useBuffer, uint256 topUpAmount);

    /**
     * @notice Emitted when the maximum processed validator count is set.
     * @dev    This event is triggered when the maximum count of processed validators is set, indicating a change in the processing limit.
     * @param  count  uint256  The new maximum count of processed validators.
     */
    event SetMaxProcessedValidatorCount(uint256 count);

    /**
     * @notice Emitted when the max buffer size is updated.
     * @dev    This event is triggered when max buffer size is updated
     * @param  maxBufferSize  uint256  The updated maximum buffer size.
     */
    event UpdateMaxBufferSize(uint256 maxBufferSize);

    /**
     * @notice Emitted when the withdrawal credentials are set.
     * @dev    This event is triggered when the withdrawal credentials are updated, indicating a change in the credentials used for validator withdrawals.
     * @param  withdrawalCredentials  bytes  The new withdrawal credentials.
     */
    event SetWithdrawCredentials(bytes withdrawalCredentials);

    // Modifiers
    /**
     * @dev Reverts if the sender is not the specified reward recipient. Used to control access to functions that
     *      are intended for the designated recipient of rewards.
     */
    modifier onlyRewardRecipient() {
        if (msg.sender != rewardRecipient) revert Errors.NotRewardRecipient();
        _;
    }

    /**
     * @dev Reverts if depositing Ether is not paused. Used to control access to functions that should only be
     *      callable when depositing Ether is in a paused state.
     */
    modifier onlyWhenDepositEtherPaused() {
        if (depositEtherPaused == _NOT_PAUSED)
            revert Errors.DepositingEtherNotPaused();
        _;
    }

    /*//////////////////////////////////////////////////////////////
                        CONSTRUCTOR/INITIALIZATION LOGIC
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Initializes the PirexEthValidators contract.
     * @dev    Initializes the contract with the provided parameters and sets up the initial state.
     * @param  _pxEth                      address  PxETH contract address
     * @param  _admin                      address  Admin address
     * @param  _beaconChainDepositContract address  The address of the deposit precompile
     * @param  _upxEth                     address  UpxETH address
     * @param  _depositSize                uint256  Amount of ETH to stake
     * @param  _preDepositAmount           uint256  Amount of ETH for pre-deposit
     * @param  _initialDelay               uint48   Delay required to schedule the acceptance
     *                                              of an access control transfer started
     */
    constructor(
        address _pxEth,
        address _admin,
        address _beaconChainDepositContract,
        address _upxEth,
        uint256 _depositSize,
        uint256 _preDepositAmount,
        uint48 _initialDelay
    ) AccessControlDefaultAdminRules(_initialDelay, _admin) {
        if (_pxEth == address(0)) revert Errors.ZeroAddress();
        if (_beaconChainDepositContract == address(0))
            revert Errors.ZeroAddress();
        if (_upxEth == address(0)) revert Errors.ZeroAddress();
        if (_depositSize < 1 ether && _depositSize % 1 gwei != 0)
            revert Errors.ZeroMultiplier();
        if (
            _preDepositAmount > _depositSize ||
            _preDepositAmount < 1 ether ||
            _preDepositAmount % 1 gwei != 0
        ) revert Errors.ZeroMultiplier();

        pxEth = PxEth(_pxEth);
        DEPOSIT_SIZE = _depositSize;
        beaconChainDepositContract = _beaconChainDepositContract;
        preDepositAmount = _preDepositAmount;
        upxEth = UpxEth(_upxEth);
        depositEtherPaused = _NOT_PAUSED;
    }

    /*//////////////////////////////////////////////////////////////
                                VIEW
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Get the number of initialized validators
     * @dev    Returns the count of validators that are ready to be staked.
     * @return uint256 count of validators ready to be staked
     */
    function getInitializedValidatorCount() external view returns (uint256) {
        return _initializedValidators.count();
    }

    /**
     * @notice Get the number of staked validators
     * @dev    Returns the count of validators with staking status.
     * @return uint256 count of validators with staking status
     */
    function getStakingValidatorCount() public view returns (uint256) {
        return _stakingValidators.count();
    }

    /**
     * @notice Get the initialized validator info at the specified index
     * @dev    Returns the details of the initialized validator at the given index.
     * @param  _i  uint256  Index
     * @return     bytes    Public key
     * @return     bytes    Withdrawal credentials
     * @return     bytes    Signature
     * @return     bytes32  Deposit data root hash
     * @return     address  pxETH receiver
     */
    function getInitializedValidatorAt(
        uint256 _i
    )
        external
        view
        returns (bytes memory, bytes memory, bytes memory, bytes32, address)
    {
        return _initializedValidators.get(withdrawalCredentials, _i);
    }

    /**
     * @notice Get the staking validator info at the specified index
     * @dev    Returns the details of the staking validator at the given index.
     * @param  _i  uint256  Index
     * @return     bytes    Public key
     * @return     bytes    Withdrawal credentials
     * @return     bytes    Signature
     * @return     bytes32  Deposit data root hash
     * @return     address  pxETH receiver
     */
    function getStakingValidatorAt(
        uint256 _i
    )
        external
        view
        returns (bytes memory, bytes memory, bytes memory, bytes32, address)
    {
        return _stakingValidators.get(withdrawalCredentials, _i);
    }

    /*//////////////////////////////////////////////////////////////
                        RESTRICTED FUNCTIONS
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Set a contract address
     * @dev    Allows the governance role to set the address for a contract in the system.
     * @param  _contract        DataTypes.Contract  Contract
     * @param  contractAddress  address             Contract address
     */
    function setContract(
        DataTypes.Contract _contract,
        address contractAddress
    ) external onlyRole(GOVERNANCE_ROLE) {
        if (contractAddress == address(0)) revert Errors.ZeroAddress();

        emit SetContract(_contract, contractAddress);

        if (_contract == DataTypes.Contract.UpxEth) {
            upxEth = UpxEth(contractAddress);
        } else if (_contract == DataTypes.Contract.PxEth) {
            pxEth = PxEth(contractAddress);
        } else if (_contract == DataTypes.Contract.AutoPxEth) {
            ERC20 pxEthERC20 = ERC20(address(pxEth));
            address oldVault = address(autoPxEth);

            if (oldVault != address(0)) {
                pxEthERC20.safeApprove(oldVault, 0);
            }

            autoPxEth = AutoPxEth(contractAddress);
            pxEthERC20.safeApprove(address(autoPxEth), type(uint256).max);
        } else if (_contract == DataTypes.Contract.OracleAdapter) {
            oracleAdapter = IOracleAdapter(contractAddress);
        } else if (_contract == DataTypes.Contract.RewardRecipient) {
            rewardRecipient = contractAddress;
            withdrawalCredentials = abi.encodePacked(
                bytes1(0x01),
                bytes11(0x0),
                contractAddress
            );

            emit SetWithdrawCredentials(withdrawalCredentials);
        } else {
            revert Errors.UnrecorgnisedContract();
        }
    }

    /**
     * @notice Set the percentage that will be applied to total supply of pxEth to determine maxBufferSize
     * @dev    Allows the governance role to set the percentage of the total supply of pxEth that will be used as maxBufferSize.
     * @param  _pct  uint256  Max buffer size percentage
     */
    function setMaxBufferSizePct(
        uint256 _pct
    ) external onlyRole(GOVERNANCE_ROLE) {
        if (_pct > DENOMINATOR) {
            revert Errors.ExceedsMax();
        }

        maxBufferSizePct = _pct;

        emit SetMaxBufferSizePct(_pct);
    }

    /**
     * @notice Set the maximum count of validators to be processed in a single _deposit call
     * @dev    Only the role with the GOVERNANCE_ROLE can execute this function.
     * @param _count  uint256  Maximum count of validators to be processed
     */
    function setMaxProcessedValidatorCount(
        uint256 _count
    ) external onlyRole(GOVERNANCE_ROLE) {
        if (_count == 0) {
            revert Errors.InvalidMaxProcessedCount();
        }

        maxProcessedValidatorCount = _count;

        emit SetMaxProcessedValidatorCount(_count);
    }

    /**
     * @notice Toggle the ability to deposit ETH to validators
     * @dev    Only the role with the GOVERNANCE_ROLE can execute this function.
     */
    function togglePauseDepositEther() external onlyRole(GOVERNANCE_ROLE) {
        depositEtherPaused = depositEtherPaused == _NOT_PAUSED
            ? _PAUSED
            : _NOT_PAUSED;

        emit DepositEtherPaused(depositEtherPaused);
    }

    /**
     * @notice Approve or revoke addresses as burner accounts
     * @dev    Only the role with the GOVERNANCE_ROLE can execute this function.
     * @param _accounts  address[]  An array of addresses to be approved or revoked as burner accounts.
     * @param _state     bool       A boolean indicating whether to approve (true) or revoke (false) the burner account state.
     */
    function toggleBurnerAccounts(
        address[] calldata _accounts,
        bool _state
    ) external onlyRole(GOVERNANCE_ROLE) {
        uint256 _len = _accounts.length;

        for (uint256 _i; _i < _len; ) {
            address account = _accounts[_i];

            burnerAccounts[account] = _state;

            if (_state) {
                emit ApproveBurnerAccount(account);
            } else {
                emit RevokeBurnerAccount(account);
            }

            unchecked {
                ++_i;
            }
        }
    }

    /*//////////////////////////////////////////////////////////////
                            MUTATIVE FUNCTIONS
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Update validator to Dissolve once Oracle confirms ETH release
     * @dev    Only the reward recipient can initiate the dissolution process.
     * @param  _pubKey  bytes  The public key of the validator to be dissolved.
     */
    function dissolveValidator(
        bytes calldata _pubKey
    ) external payable override onlyRewardRecipient {
        uint256 _amount = msg.value;
        if (_amount != DEPOSIT_SIZE) revert Errors.InvalidAmount();
        if (status[_pubKey] != DataTypes.ValidatorStatus.Withdrawable)
            revert Errors.NotWithdrawable();

        status[_pubKey] = DataTypes.ValidatorStatus.Dissolved;

        outstandingRedemptions += _amount;

        emit DissolveValidator(_pubKey);
    }

    /**
     * @notice Update validator state to be slashed
     * @dev    Only the reward recipient can initiate the slashing process.
     * @param  _pubKey          bytes                      The public key of the validator to be slashed.
     * @param  _removeIndex     uint256                    Index of the validator to be slashed.
     * @param  _amount          uint256                    ETH amount released from the Beacon chain.
     * @param  _unordered       bool                       Whether to remove from the staking validator queue in order or not.
     * @param  _useBuffer       bool                       Whether to use the buffer to compensate for the loss.
     * @param  _burnerAccounts  DataTypes.BurnerAccount[]  Burner accounts providing additional compensation.
     */
    function slashValidator(
        bytes calldata _pubKey,
        uint256 _removeIndex,
        uint256 _amount,
        bool _unordered,
        bool _useBuffer,
        DataTypes.BurnerAccount[] calldata _burnerAccounts
    ) external payable override onlyRewardRecipient {
        uint256 _ethAmount = msg.value;
        uint256 _defaultDepositSize = DEPOSIT_SIZE;
        DataTypes.ValidatorStatus _status = status[_pubKey];

        if (
            _status != DataTypes.ValidatorStatus.Staking &&
            _status != DataTypes.ValidatorStatus.Withdrawable
        ) revert Errors.StatusNotWithdrawableOrStaking();

        if (_useBuffer) {
            _updateBuffer(_defaultDepositSize - _ethAmount, _burnerAccounts);
        } else if (_ethAmount != _defaultDepositSize) {
            revert Errors.InvalidAmount();
        }

        // It is possible that validator can be slashed while exiting
        if (_status == DataTypes.ValidatorStatus.Staking) {
            bytes memory _removedPubKey;

            if (!_unordered) {
                _removedPubKey = _stakingValidators.removeOrdered(_removeIndex);
            } else {
                _removedPubKey = _stakingValidators.removeUnordered(
                    _removeIndex
                );
            }

            assert(keccak256(_pubKey) == keccak256(_removedPubKey));

            _addPendingDeposit(_defaultDepositSize);
        } else {
            outstandingRedemptions += _defaultDepositSize;
        }
        status[_pubKey] = DataTypes.ValidatorStatus.Slashed;

        emit SlashValidator(
            _pubKey,
            _useBuffer,
            _amount,
            DEPOSIT_SIZE - _amount
        );
    }

    /**
     * @notice Add multiple synced validators in the queue to be ready for staking.
     * @dev    Only callable when depositing Ether is paused and by a user with the GOVERNANCE_ROLE.
     * @param  _validators  DataTypes.Validator[]  An array of validator details (public key, withdrawal credentials, etc.).
     */
    function addInitializedValidators(
        DataTypes.Validator[] memory _validators
    ) external onlyWhenDepositEtherPaused onlyRole(GOVERNANCE_ROLE) {
        uint256 _arrayLength = _validators.length;
        for (uint256 _i; _i < _arrayLength; ) {
            if (
                status[_validators[_i].pubKey] != DataTypes.ValidatorStatus.None
            ) revert Errors.NoUsedValidator();

            _initializedValidators.add(_validators[_i], withdrawalCredentials);

            unchecked {
                ++_i;
            }
        }
    }

    /**
     * @notice Swap initialized validators specified by the indexes.
     * @dev    Only callable when depositing Ether is paused and by a user with the GOVERNANCE_ROLE.
     * @param  _fromIndex  uint256  The index of the validator to be swapped from.
     * @param  _toIndex    uint256  The index of the validator to be swapped to.
     */
    function swapInitializedValidator(
        uint256 _fromIndex,
        uint256 _toIndex
    ) external onlyWhenDepositEtherPaused onlyRole(GOVERNANCE_ROLE) {
        _initializedValidators.swap(_fromIndex, _toIndex);
    }

    /**
     * @notice Pop initialized validators from the queue.
     * @dev    Only callable when depositing Ether is paused and by a user with the GOVERNANCE_ROLE.
     * @param  _times  uint256  The count of pop operations to be performed.
     */
    function popInitializedValidator(
        uint256 _times
    ) external onlyWhenDepositEtherPaused onlyRole(GOVERNANCE_ROLE) {
        _initializedValidators.pop(_times);
    }

    /**
     * @notice Remove an initialized validator from the queue.
     * @dev    Only callable when depositing Ether is paused and by a user with the GOVERNANCE_ROLE.
     * @param  _pubKey       bytes    The public key of the validator to be removed.
     * @param  _removeIndex  uint256  The index of the validator to be removed.
     * @param  _unordered    bool     A flag indicating whether removal should be unordered (true) or ordered (false).
     */
    function removeInitializedValidator(
        bytes calldata _pubKey,
        uint256 _removeIndex,
        bool _unordered
    ) external onlyWhenDepositEtherPaused onlyRole(GOVERNANCE_ROLE) {
        bytes memory _removedPubKey;

        if (_unordered) {
            _removedPubKey = _initializedValidators.removeUnordered(
                _removeIndex
            );
        } else {
            _removedPubKey = _initializedValidators.removeOrdered(_removeIndex);
        }

        assert(keccak256(_removedPubKey) == keccak256(_pubKey));
    }

    /**
     * @notice Clear all initialized validators from the queue.
     * @dev    Only callable when depositing Ether is paused and by a user with the GOVERNANCE_ROLE.
     */
    function clearInitializedValidator()
        external
        onlyWhenDepositEtherPaused
        onlyRole(GOVERNANCE_ROLE)
    {
        _initializedValidators.clear();
    }

    /**
     * @notice Trigger a privileged deposit to the ETH 2.0 deposit contract.
     * @dev    Only callable by a user with the KEEPER_ROLE and ensures that depositing Ether is not paused.
     *         This function initiates the deposit process to the ETH 2.0 deposit contract.
     */
    function depositPrivileged() external nonReentrant onlyRole(KEEPER_ROLE) {
        // Initial pause check
        if (depositEtherPaused == _PAUSED)
            revert Errors.DepositingEtherPaused();

        _deposit();
    }

    /**
     * @notice Top up ETH to a staking validator if the current balance drops below the effective balance.
     * @dev    Only callable by a user with the KEEPER_ROLE.
     * @param  _pubKey           bytes                      Validator public key.
     * @param  _signature        bytes                      A BLS12-381 signature.
     * @param  _depositDataRoot  bytes32                    The SHA-256 hash of the SSZ-encoded DepositData object.
     * @param  _topUpAmount      uint256                    Top-up amount in ETH.
     * @param  _useBuffer        bool                       Whether to use a buffer to compensate for the loss.
     * @param  _burnerAccounts   DataTypes.BurnerAccount[]  Array of burner accounts.
     */
    function topUpStake(
        bytes calldata _pubKey,
        bytes calldata _signature,
        bytes32 _depositDataRoot,
        uint256 _topUpAmount,
        bool _useBuffer,
        DataTypes.BurnerAccount[] calldata _burnerAccounts
    ) external payable nonReentrant onlyRole(KEEPER_ROLE) {
        if (status[_pubKey] != DataTypes.ValidatorStatus.Staking)
            revert Errors.ValidatorNotStaking();

        if (_useBuffer) {
            if (msg.value > 0) {
                revert Errors.NoETHAllowed();
            }
            _updateBuffer(_topUpAmount, _burnerAccounts);
        } else if (msg.value != _topUpAmount) {
            revert Errors.NoETH();
        }

        (bool success, ) = beaconChainDepositContract.call{value: _topUpAmount}(
            abi.encodeCall(
                IDepositContract.deposit,
                (_pubKey, withdrawalCredentials, _signature, _depositDataRoot)
            )
        );

        assert(success);

        emit TopUp(_pubKey, _useBuffer, _topUpAmount);
    }

    /**
     * @notice Harvest and mint staking rewards when available.
     * @dev    Only callable by the reward recipient.
     * @param  _endBlock  uint256  Block until which ETH rewards are computed.
     */
    function harvest(
        uint256 _endBlock
    ) external payable override onlyRewardRecipient {
        if (msg.value != 0) {
            // update end block
            endBlock = _endBlock;

            // Mint pxETH directly for the vault
            _mintPxEth(address(autoPxEth), msg.value);

            // Update rewards tracking with the newly added rewards
            autoPxEth.notifyRewardAmount();

            // Direct the excess balance for pending deposit
            _addPendingDeposit(msg.value);

            emit Harvest(msg.value, _endBlock);
        }
    }

    /*//////////////////////////////////////////////////////////////
                        INTERNAL FUNCTIONS
    //////////////////////////////////////////////////////////////*/

    /**
     * @dev   Mints the specified amount of pxETH and updates the maximum buffer size.
     * @param _account  address  The address to which pxETH will be minted.
     * @param _amount   uint256  The amount of pxETH to be minted.
     */
    function _mintPxEth(address _account, uint256 _amount) internal {
        pxEth.mint(_account, _amount);
        uint256 _maxBufferSize = (pxEth.totalSupply() * maxBufferSizePct) /
            DENOMINATOR;
        maxBufferSize = _maxBufferSize;
        emit UpdateMaxBufferSize(_maxBufferSize);
    }

    /**
     * @dev   Burns the specified amount of pxETH from the given account and updates the maximum buffer size.
     * @param _account  address  The address from which pxETH will be burned.
     * @param _amount   uint256  The amount of pxETH to be burned.
     */
    function _burnPxEth(address _account, uint256 _amount) internal {
        pxEth.burn(_account, _amount);
        uint256 _maxBufferSize = (pxEth.totalSupply() * maxBufferSizePct) /
            DENOMINATOR;
        maxBufferSize = _maxBufferSize;
        emit UpdateMaxBufferSize(_maxBufferSize);
    }

    /**
     * @dev Processes the deposit of validators, taking into account the maximum processed validator count,
     *      the remaining deposit amount, and the status of initialized validators. It iterates through initialized
     *      validators, deposits them into the Beacon chain, mints pxETH if needed, and updates the validator status.
     */
    function _deposit() internal {
        uint256 remainingCount = maxProcessedValidatorCount;
        uint256 _remainingdepositAmount = DEPOSIT_SIZE - preDepositAmount;

        while (
            _initializedValidators.count() != 0 &&
            pendingDeposit >= _remainingdepositAmount &&
            remainingCount > 0
        ) {
            // Get validator information
            (
                bytes memory _pubKey,
                bytes memory _withdrawalCredentials,
                bytes memory _signature,
                bytes32 _depositDataRoot,
                address _receiver
            ) = _initializedValidators.getNext(withdrawalCredentials);

            // Make sure the validator hasn't been deposited into already
            // to prevent sending an extra eth equal to `_remainingdepositAmount`
            // until withdrawals are allowed
            if (status[_pubKey] != DataTypes.ValidatorStatus.None)
                revert Errors.NoUsedValidator();

            (bool success, ) = beaconChainDepositContract.call{
                value: _remainingdepositAmount
            }(
                abi.encodeCall(
                    IDepositContract.deposit,
                    (
                        _pubKey,
                        _withdrawalCredentials,
                        _signature,
                        _depositDataRoot
                    )
                )
            );

            assert(success);

            pendingDeposit -= _remainingdepositAmount;

            if (preDepositAmount != 0) {
                _mintPxEth(_receiver, preDepositAmount);
            }

            unchecked {
                --remainingCount;
            }

            status[_pubKey] = DataTypes.ValidatorStatus.Staking;

            _stakingValidators.add(
                DataTypes.Validator(
                    _pubKey,
                    _signature,
                    _depositDataRoot,
                    _receiver
                ),
                _withdrawalCredentials
            );

            emit ValidatorDeposit(_pubKey);
        }
    }

    /**
     * @dev   Adds the specified amount to the pending deposit, considering the available buffer space and deposit pause status.
     *        If the buffer space is available, it may be fully or partially utilized. The method then checks if depositing
     *        ETH is not paused and spins up a validator if conditions are met.
     * @param _amount  uint256  The amount of ETH to be added to the pending deposit.
     */
    function _addPendingDeposit(uint256 _amount) internal virtual {
        uint256 _remainingBufferSpace = (
            maxBufferSize > buffer ? maxBufferSize - buffer : 0
        );
        uint256 _remainingAmount = _amount;

        if (_remainingBufferSpace != 0) {
            bool _canBufferSpaceFullyUtilized = _remainingBufferSpace <=
                _remainingAmount;
            buffer += _canBufferSpaceFullyUtilized
                ? _remainingBufferSpace
                : _remainingAmount;
            _remainingAmount -= _canBufferSpaceFullyUtilized
                ? _remainingBufferSpace
                : _remainingAmount;
        }

        pendingDeposit += _remainingAmount;

        if (depositEtherPaused == _NOT_PAUSED) {
            // Spin up a validator when possible
            _deposit();
        }
    }

    /**
     * @dev   Initiates the redemption process by adding the specified amount of pxETH to the pending withdrawal.
     *        Iteratively processes pending withdrawals in multiples of DEPOSIT_SIZE, triggering validator exits, updating
     *        batch information, and changing validator statuses accordingly. The process continues until the remaining
     *        pending withdrawal is less than DEPOSIT_SIZE. If `_shouldTriggerValidatorExit` is true and there's remaining
     *        pxETH after the redemption process, the function reverts, preventing partial initiation of redemption.
     * @param _pxEthAmount                 uint256  The amount of pxETH to be redeemed.
     * @param _receiver                    address  The receiver address for upxETH.
     * @param _shouldTriggerValidatorExit  bool     Whether to initiate partial redemption with a validator exit or not.
     */
    function _initiateRedemption(
        uint256 _pxEthAmount,
        address _receiver,
        bool _shouldTriggerValidatorExit
    ) internal {
        pendingWithdrawal += _pxEthAmount;

        while (pendingWithdrawal / DEPOSIT_SIZE != 0) {
            uint256 _allocationPossible = DEPOSIT_SIZE +
                _pxEthAmount -
                pendingWithdrawal;

            upxEth.mint(_receiver, batchId, _allocationPossible, "");

            (bytes memory _pubKey, , , , ) = _stakingValidators.getNext(
                withdrawalCredentials
            );

            pendingWithdrawal -= DEPOSIT_SIZE;
            _pxEthAmount -= _allocationPossible;

            oracleAdapter.requestVoluntaryExit(_pubKey);

            batchIdToValidator[batchId++] = _pubKey;
            status[_pubKey] = DataTypes.ValidatorStatus.Withdrawable;
        }

        if (_shouldTriggerValidatorExit && _pxEthAmount > 0)
            revert Errors.NoPartialInitiateRedemption();

        if (_pxEthAmount > 0) {
            upxEth.mint(_receiver, batchId, _pxEthAmount, "");
        }
    }

    /**
     * @dev   Checks if the contract has enough buffer to cover the specified amount. Iterates through the provided
     *        `_burnerAccounts`, verifies each account's approval status, burns the corresponding amount of pxETH, and
     *        updates the buffer accordingly. Reverts if there is insufficient buffer, if an account is not approved, or
     *        if the sum of burned amounts does not match the specified amount.
     * @param _amount          uint256                    The amount to be updated in the buffer.
     * @param _burnerAccounts  DataTypes.BurnerAccount[]  An array of burner account details (account and amount).
     */
    function _updateBuffer(
        uint256 _amount,
        DataTypes.BurnerAccount[] calldata _burnerAccounts
    ) private {
        if (buffer < _amount) {
            revert Errors.NotEnoughBuffer();
        }
        uint256 _len = _burnerAccounts.length;
        uint256 _sum;

        for (uint256 _i; _i < _len; ) {
            if (!burnerAccounts[_burnerAccounts[_i].account])
                revert Errors.AccountNotApproved();

            _sum += _burnerAccounts[_i].amount;

            _burnPxEth(_burnerAccounts[_i].account, _burnerAccounts[_i].amount);

            unchecked {
                ++_i;
            }
        }

        assert(_sum == _amount);
        buffer -= _amount;
    }
}

File 8 of 33 : ReentrancyGuard.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

/// @notice Gas optimized reentrancy protection for smart contracts.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/ReentrancyGuard.sol)
/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/security/ReentrancyGuard.sol)
abstract contract ReentrancyGuard {
    uint256 private locked = 1;

    modifier nonReentrant() virtual {
        require(locked == 1, "REENTRANCY");

        locked = 2;

        _;

        locked = 1;
    }
}

File 9 of 33 : AccessControlDefaultAdminRules.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControlDefaultAdminRules.sol)

pragma solidity ^0.8.0;

import "./AccessControl.sol";
import "./IAccessControlDefaultAdminRules.sol";
import "../utils/math/SafeCast.sol";
import "../interfaces/IERC5313.sol";

/**
 * @dev Extension of {AccessControl} that allows specifying special rules to manage
 * the `DEFAULT_ADMIN_ROLE` holder, which is a sensitive role with special permissions
 * over other roles that may potentially have privileged rights in the system.
 *
 * If a specific role doesn't have an admin role assigned, the holder of the
 * `DEFAULT_ADMIN_ROLE` will have the ability to grant it and revoke it.
 *
 * This contract implements the following risk mitigations on top of {AccessControl}:
 *
 * * Only one account holds the `DEFAULT_ADMIN_ROLE` since deployment until it's potentially renounced.
 * * Enforces a 2-step process to transfer the `DEFAULT_ADMIN_ROLE` to another account.
 * * Enforces a configurable delay between the two steps, with the ability to cancel before the transfer is accepted.
 * * The delay can be changed by scheduling, see {changeDefaultAdminDelay}.
 * * It is not possible to use another role to manage the `DEFAULT_ADMIN_ROLE`.
 *
 * Example usage:
 *
 * ```solidity
 * contract MyToken is AccessControlDefaultAdminRules {
 *   constructor() AccessControlDefaultAdminRules(
 *     3 days,
 *     msg.sender // Explicit initial `DEFAULT_ADMIN_ROLE` holder
 *    ) {}
 * }
 * ```
 *
 * _Available since v4.9._
 */
abstract contract AccessControlDefaultAdminRules is IAccessControlDefaultAdminRules, IERC5313, AccessControl {
    // pending admin pair read/written together frequently
    address private _pendingDefaultAdmin;
    uint48 private _pendingDefaultAdminSchedule; // 0 == unset

    uint48 private _currentDelay;
    address private _currentDefaultAdmin;

    // pending delay pair read/written together frequently
    uint48 private _pendingDelay;
    uint48 private _pendingDelaySchedule; // 0 == unset

    /**
     * @dev Sets the initial values for {defaultAdminDelay} and {defaultAdmin} address.
     */
    constructor(uint48 initialDelay, address initialDefaultAdmin) {
        require(initialDefaultAdmin != address(0), "AccessControl: 0 default admin");
        _currentDelay = initialDelay;
        _grantRole(DEFAULT_ADMIN_ROLE, initialDefaultAdmin);
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControlDefaultAdminRules).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC5313-owner}.
     */
    function owner() public view virtual returns (address) {
        return defaultAdmin();
    }

    ///
    /// Override AccessControl role management
    ///

    /**
     * @dev See {AccessControl-grantRole}. Reverts for `DEFAULT_ADMIN_ROLE`.
     */
    function grantRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) {
        require(role != DEFAULT_ADMIN_ROLE, "AccessControl: can't directly grant default admin role");
        super.grantRole(role, account);
    }

    /**
     * @dev See {AccessControl-revokeRole}. Reverts for `DEFAULT_ADMIN_ROLE`.
     */
    function revokeRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) {
        require(role != DEFAULT_ADMIN_ROLE, "AccessControl: can't directly revoke default admin role");
        super.revokeRole(role, account);
    }

    /**
     * @dev See {AccessControl-renounceRole}.
     *
     * For the `DEFAULT_ADMIN_ROLE`, it only allows renouncing in two steps by first calling
     * {beginDefaultAdminTransfer} to the `address(0)`, so it's required that the {pendingDefaultAdmin} schedule
     * has also passed when calling this function.
     *
     * After its execution, it will not be possible to call `onlyRole(DEFAULT_ADMIN_ROLE)` functions.
     *
     * NOTE: Renouncing `DEFAULT_ADMIN_ROLE` will leave the contract without a {defaultAdmin},
     * thereby disabling any functionality that is only available for it, and the possibility of reassigning a
     * non-administrated role.
     */
    function renounceRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) {
        if (role == DEFAULT_ADMIN_ROLE && account == defaultAdmin()) {
            (address newDefaultAdmin, uint48 schedule) = pendingDefaultAdmin();
            require(
                newDefaultAdmin == address(0) && _isScheduleSet(schedule) && _hasSchedulePassed(schedule),
                "AccessControl: only can renounce in two delayed steps"
            );
            delete _pendingDefaultAdminSchedule;
        }
        super.renounceRole(role, account);
    }

    /**
     * @dev See {AccessControl-_grantRole}.
     *
     * For `DEFAULT_ADMIN_ROLE`, it only allows granting if there isn't already a {defaultAdmin} or if the
     * role has been previously renounced.
     *
     * NOTE: Exposing this function through another mechanism may make the `DEFAULT_ADMIN_ROLE`
     * assignable again. Make sure to guarantee this is the expected behavior in your implementation.
     */
    function _grantRole(bytes32 role, address account) internal virtual override {
        if (role == DEFAULT_ADMIN_ROLE) {
            require(defaultAdmin() == address(0), "AccessControl: default admin already granted");
            _currentDefaultAdmin = account;
        }
        super._grantRole(role, account);
    }

    /**
     * @dev See {AccessControl-_revokeRole}.
     */
    function _revokeRole(bytes32 role, address account) internal virtual override {
        if (role == DEFAULT_ADMIN_ROLE && account == defaultAdmin()) {
            delete _currentDefaultAdmin;
        }
        super._revokeRole(role, account);
    }

    /**
     * @dev See {AccessControl-_setRoleAdmin}. Reverts for `DEFAULT_ADMIN_ROLE`.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual override {
        require(role != DEFAULT_ADMIN_ROLE, "AccessControl: can't violate default admin rules");
        super._setRoleAdmin(role, adminRole);
    }

    ///
    /// AccessControlDefaultAdminRules accessors
    ///

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function defaultAdmin() public view virtual returns (address) {
        return _currentDefaultAdmin;
    }

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function pendingDefaultAdmin() public view virtual returns (address newAdmin, uint48 schedule) {
        return (_pendingDefaultAdmin, _pendingDefaultAdminSchedule);
    }

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function defaultAdminDelay() public view virtual returns (uint48) {
        uint48 schedule = _pendingDelaySchedule;
        return (_isScheduleSet(schedule) && _hasSchedulePassed(schedule)) ? _pendingDelay : _currentDelay;
    }

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function pendingDefaultAdminDelay() public view virtual returns (uint48 newDelay, uint48 schedule) {
        schedule = _pendingDelaySchedule;
        return (_isScheduleSet(schedule) && !_hasSchedulePassed(schedule)) ? (_pendingDelay, schedule) : (0, 0);
    }

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function defaultAdminDelayIncreaseWait() public view virtual returns (uint48) {
        return 5 days;
    }

    ///
    /// AccessControlDefaultAdminRules public and internal setters for defaultAdmin/pendingDefaultAdmin
    ///

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function beginDefaultAdminTransfer(address newAdmin) public virtual onlyRole(DEFAULT_ADMIN_ROLE) {
        _beginDefaultAdminTransfer(newAdmin);
    }

    /**
     * @dev See {beginDefaultAdminTransfer}.
     *
     * Internal function without access restriction.
     */
    function _beginDefaultAdminTransfer(address newAdmin) internal virtual {
        uint48 newSchedule = SafeCast.toUint48(block.timestamp) + defaultAdminDelay();
        _setPendingDefaultAdmin(newAdmin, newSchedule);
        emit DefaultAdminTransferScheduled(newAdmin, newSchedule);
    }

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function cancelDefaultAdminTransfer() public virtual onlyRole(DEFAULT_ADMIN_ROLE) {
        _cancelDefaultAdminTransfer();
    }

    /**
     * @dev See {cancelDefaultAdminTransfer}.
     *
     * Internal function without access restriction.
     */
    function _cancelDefaultAdminTransfer() internal virtual {
        _setPendingDefaultAdmin(address(0), 0);
    }

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function acceptDefaultAdminTransfer() public virtual {
        (address newDefaultAdmin, ) = pendingDefaultAdmin();
        require(_msgSender() == newDefaultAdmin, "AccessControl: pending admin must accept");
        _acceptDefaultAdminTransfer();
    }

    /**
     * @dev See {acceptDefaultAdminTransfer}.
     *
     * Internal function without access restriction.
     */
    function _acceptDefaultAdminTransfer() internal virtual {
        (address newAdmin, uint48 schedule) = pendingDefaultAdmin();
        require(_isScheduleSet(schedule) && _hasSchedulePassed(schedule), "AccessControl: transfer delay not passed");
        _revokeRole(DEFAULT_ADMIN_ROLE, defaultAdmin());
        _grantRole(DEFAULT_ADMIN_ROLE, newAdmin);
        delete _pendingDefaultAdmin;
        delete _pendingDefaultAdminSchedule;
    }

    ///
    /// AccessControlDefaultAdminRules public and internal setters for defaultAdminDelay/pendingDefaultAdminDelay
    ///

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function changeDefaultAdminDelay(uint48 newDelay) public virtual onlyRole(DEFAULT_ADMIN_ROLE) {
        _changeDefaultAdminDelay(newDelay);
    }

    /**
     * @dev See {changeDefaultAdminDelay}.
     *
     * Internal function without access restriction.
     */
    function _changeDefaultAdminDelay(uint48 newDelay) internal virtual {
        uint48 newSchedule = SafeCast.toUint48(block.timestamp) + _delayChangeWait(newDelay);
        _setPendingDelay(newDelay, newSchedule);
        emit DefaultAdminDelayChangeScheduled(newDelay, newSchedule);
    }

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function rollbackDefaultAdminDelay() public virtual onlyRole(DEFAULT_ADMIN_ROLE) {
        _rollbackDefaultAdminDelay();
    }

    /**
     * @dev See {rollbackDefaultAdminDelay}.
     *
     * Internal function without access restriction.
     */
    function _rollbackDefaultAdminDelay() internal virtual {
        _setPendingDelay(0, 0);
    }

    /**
     * @dev Returns the amount of seconds to wait after the `newDelay` will
     * become the new {defaultAdminDelay}.
     *
     * The value returned guarantees that if the delay is reduced, it will go into effect
     * after a wait that honors the previously set delay.
     *
     * See {defaultAdminDelayIncreaseWait}.
     */
    function _delayChangeWait(uint48 newDelay) internal view virtual returns (uint48) {
        uint48 currentDelay = defaultAdminDelay();

        // When increasing the delay, we schedule the delay change to occur after a period of "new delay" has passed, up
        // to a maximum given by defaultAdminDelayIncreaseWait, by default 5 days. For example, if increasing from 1 day
        // to 3 days, the new delay will come into effect after 3 days. If increasing from 1 day to 10 days, the new
        // delay will come into effect after 5 days. The 5 day wait period is intended to be able to fix an error like
        // using milliseconds instead of seconds.
        //
        // When decreasing the delay, we wait the difference between "current delay" and "new delay". This guarantees
        // that an admin transfer cannot be made faster than "current delay" at the time the delay change is scheduled.
        // For example, if decreasing from 10 days to 3 days, the new delay will come into effect after 7 days.
        return
            newDelay > currentDelay
                ? uint48(Math.min(newDelay, defaultAdminDelayIncreaseWait())) // no need to safecast, both inputs are uint48
                : currentDelay - newDelay;
    }

    ///
    /// Private setters
    ///

    /**
     * @dev Setter of the tuple for pending admin and its schedule.
     *
     * May emit a DefaultAdminTransferCanceled event.
     */
    function _setPendingDefaultAdmin(address newAdmin, uint48 newSchedule) private {
        (, uint48 oldSchedule) = pendingDefaultAdmin();

        _pendingDefaultAdmin = newAdmin;
        _pendingDefaultAdminSchedule = newSchedule;

        // An `oldSchedule` from `pendingDefaultAdmin()` is only set if it hasn't been accepted.
        if (_isScheduleSet(oldSchedule)) {
            // Emit for implicit cancellations when another default admin was scheduled.
            emit DefaultAdminTransferCanceled();
        }
    }

    /**
     * @dev Setter of the tuple for pending delay and its schedule.
     *
     * May emit a DefaultAdminDelayChangeCanceled event.
     */
    function _setPendingDelay(uint48 newDelay, uint48 newSchedule) private {
        uint48 oldSchedule = _pendingDelaySchedule;

        if (_isScheduleSet(oldSchedule)) {
            if (_hasSchedulePassed(oldSchedule)) {
                // Materialize a virtual delay
                _currentDelay = _pendingDelay;
            } else {
                // Emit for implicit cancellations when another delay was scheduled.
                emit DefaultAdminDelayChangeCanceled();
            }
        }

        _pendingDelay = newDelay;
        _pendingDelaySchedule = newSchedule;
    }

    ///
    /// Private helpers
    ///

    /**
     * @dev Defines if an `schedule` is considered set. For consistency purposes.
     */
    function _isScheduleSet(uint48 schedule) private pure returns (bool) {
        return schedule != 0;
    }

    /**
     * @dev Defines if an `schedule` is considered passed. For consistency purposes.
     */
    function _hasSchedulePassed(uint48 schedule) private view returns (bool) {
        return schedule < block.timestamp;
    }
}

File 10 of 33 : UpxEth.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/presets/ERC1155PresetMinterPauser.sol)

pragma solidity 0.8.19;

import {ERC1155} from "solmate/tokens/ERC1155.sol";
import {AccessControlDefaultAdminRules} from "openzeppelin-contracts/contracts/access/AccessControlDefaultAdminRules.sol";

/**
 * @title UpxEth
 * @notice Semi Fungible token contract used as an IOU by user 
 * @dev ERC1155 token contract with minting and burning capabilities, using AccessControl for role-based access.
 *
 * UpxEth contract includes:
 * - Total supply tracking for each token ID
 * - Token burning functionality for holders
 * - Minter role for token creation
 *
 * The contract deploys with the default admin role, allowing it to grant minter and burner roles to other accounts.
 * The contract uses AccessControl for role-based access control.
 *
 * Deprecated in favor of [Contracts Wizard](https://wizard.openzeppelin.com/).
 * @author redactedcartel.finance
 */
contract UpxEth is AccessControlDefaultAdminRules, ERC1155 {
    /**
     * @dev Bytes32 constant representing the role to mint new tokens.
     */
    bytes32 internal constant MINTER_ROLE = keccak256("MINTER_ROLE");

    /**
     * @dev Bytes32 constant representing the role to burn (destroy) tokens.
     */
    bytes32 internal constant BURNER_ROLE = keccak256("BURNER_ROLE");

    /**
     * @dev Constructor to initialize the UpxEth contract.
     * @param _initialDelay uint48 Initial delay for AccessControl's admin lock, set by the contract deployer.
     */
    constructor(
        uint48 _initialDelay
    ) AccessControlDefaultAdminRules(_initialDelay, msg.sender) {}

    /**
     * @notice Mints new tokens for a specific address.
     * @dev Restricted to accounts with the MINTER_ROLE.
     * @param to     address Address to receive the minted tokens.
     * @param id     uint256 Token ID to mint.
     * @param amount uint256 Amount of tokens to mint.
     * @param data   bytes   Additional data to include in the minting transaction.
     */
    function mint(
        address to,
        uint256 id,
        uint256 amount,
        bytes calldata data
    ) external onlyRole(MINTER_ROLE) {
        _mint(to, id, amount, data);
    }

    /**
     * @notice Mints a batch of new tokens for a specific address.
     * @dev Restricted to accounts with the MINTER_ROLE.
     * @param to      address   Address to receive the minted tokens.
     * @param ids     uint256[] Array of token IDs to mint.
     * @param amounts uint256[] Array of amounts of tokens to mint.
     * @param data    bytes     Additional data to include in the minting transaction.
     */
    function mintBatch(
        address to,
        uint256[] calldata ids,
        uint256[] calldata amounts,
        bytes calldata data
    ) external onlyRole(MINTER_ROLE) {
        _batchMint(to, ids, amounts, data);
    }

    /**
     * @notice Burns a batch of tokens from a specific address.
     * @dev Restricted to accounts with the BURNER_ROLE.
     * @param from    address   Address from which to burn tokens.
     * @param ids     uint256[] Array of token IDs to burn.
     * @param amounts uint256[] Array of amounts of tokens to burn.
     */
    function burnBatch(
        address from,
        uint256[] calldata ids,
        uint256[] calldata amounts
    ) external onlyRole(BURNER_ROLE) {
        _batchBurn(from, ids, amounts);
    }

    /**
     * @notice Burns a specific amount of tokens from a specific address.
     * @dev Restricted to accounts with the BURNER_ROLE.
     * @param from   address Address from which to burn tokens.
     * @param id     uint256 Token ID to burn.
     * @param amount uint256 Amount of tokens to burn.
     */
    function burn(
        address from,
        uint256 id,
        uint256 amount
    ) external onlyRole(BURNER_ROLE) {
        _burn(from, id, amount);
    }

    /**
     * @inheritdoc ERC1155
     * @dev Not implemented due to semi-fungible only requirement
     */
    function uri(uint256 id) public view override returns (string memory) {}

    /**
     * @inheritdoc ERC1155
     */
    function supportsInterface(
        bytes4 interfaceId
    )
        public
        view
        override(AccessControlDefaultAdminRules, ERC1155)
        returns (bool)
    {
        return super.supportsInterface(interfaceId);
    }
}

File 11 of 33 : ValidatorQueue.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import {SafeCast} from "openzeppelin-contracts/contracts/utils/math/SafeCast.sol";
import {DataTypes} from "./DataTypes.sol";
import {Errors} from "./Errors.sol";

/**
 * @title ValidatorQueue
 * @notice Library for managing a FIFO queue of validators in the Pirex protocol.
 * @dev This library provides functions for adding, swapping, and removing validators in the validator queue.
 * It also includes functions for popping validators from the end of the queue, retrieving validator information, and clearing the entire queue.
 * @author redactedcartel.finance
 */
library ValidatorQueue {
    /**
     * @notice Emitted when a validator is added to the queue.
     * @dev This event is emitted when a validator is successfully added to the end of the queue.
     * @param pubKey               bytes Public key of the added validator.
     * @param withdrawalCredential bytes Withdrawal credentials associated with the added validator.
     */
    event ValidatorAdded(bytes pubKey, bytes withdrawalCredential);

    /**
     * @notice Emitted when the entire validator queue is cleared.
     * @dev This event is emitted when all validators are removed from the queue, clearing it completely.
     */
    event ValidatorQueueCleared();

    /**
     * @notice Emitted when a validator is removed from the queue.
     * @dev This event is emitted when a validator is successfully removed from the queue, either ordered or unordered.
     * @param pubKey      bytes   Public key of the removed validator.
     * @param removeIndex uint256 Index of the removed validator.
     * @param unordered   bool    Indicates whether the removal was unordered.
     */
    event ValidatorRemoved(bytes pubKey, uint256 removeIndex, bool unordered);

    /**
     * @notice Emitted when validators are popped from the front of the queue.
     * @dev This event is emitted when validators are successfully popped from the front of the queue.
     * @param times uint256 Number of pop operations performed.
     */
    event ValidatorsPopped(uint256 times);

    /**
     * @notice Emitted when two validators are swapped in the queue.
     * @dev This event is emitted when two validators are successfully swapped in the queue.
     * @param fromPubKey bytes   Public key of the first validator being swapped.
     * @param toPubKey   bytes   Public key of the second validator being swapped.
     * @param fromIndex  uint256 Index of the first validator.
     * @param toIndex    uint256 Index of the second validator.
     */
    event ValidatorsSwapped(
        bytes fromPubKey,
        bytes toPubKey,
        uint256 fromIndex,
        uint256 toIndex
    );

    /**
     * @notice Adds a synchronized validator to the FIFO queue, ready for staking.
     * @dev This function adds a validator to the end of the queue with the associated withdrawal credentials.
     * @param deque                 DataTypes.ValidatorDeque Storage reference to the validator deque.
     * @param validator             DataTypes.Validator      Validator information to be added.
     * @param withdrawalCredentials bytes                    Withdrawal credentials associated with the validator.
     */
    function add(
        DataTypes.ValidatorDeque storage deque,
        DataTypes.Validator memory validator,
        bytes memory withdrawalCredentials
    ) external {
        int128 backIndex = deque._end;
        deque._validators[backIndex] = validator;

        unchecked {
            deque._end = backIndex + 1;
        }

        emit ValidatorAdded(validator.pubKey, withdrawalCredentials);
    }

    /**
     * @notice Swaps the location of one validator with another.
     * @dev This function swaps the position of two validators in the queue.
     * @param deque     DataTypes.ValidatorDeque Storage reference to the validator deque.
     * @param fromIndex uint256                  Index of the validator to be swapped.
     * @param toIndex   uint256                  Index of the validator to swap with.
     */
    function swap(
        DataTypes.ValidatorDeque storage deque,
        uint256 fromIndex,
        uint256 toIndex
    ) public {
        if (fromIndex == toIndex) revert Errors.InvalidIndexRanges();
        if (empty(deque)) revert Errors.ValidatorQueueEmpty();

        int128 fromidx = SafeCast.toInt128(
            int256(deque._begin) + SafeCast.toInt256(fromIndex)
        );

        if (fromidx >= deque._end) revert Errors.OutOfBounds();

        int128 toidx = SafeCast.toInt128(
            int256(deque._begin) + SafeCast.toInt256(toIndex)
        );

        if (toidx >= deque._end) revert Errors.OutOfBounds();

        // Get the original values
        DataTypes.Validator memory fromVal = deque._validators[fromidx];
        DataTypes.Validator memory toVal = deque._validators[toidx];

        // Set the swapped values
        deque._validators[toidx] = fromVal;
        deque._validators[fromidx] = toVal;

        emit ValidatorsSwapped(
            fromVal.pubKey,
            toVal.pubKey,
            fromIndex,
            toIndex
        );
    }

    /**
     * @notice Removes validators from the end of the queue, in case they were added in error.
     * @dev This function removes validators from the end of the queue, specified by the number of times to pop.
     * @param  deque     DataTypes.ValidatorDeque Storage reference to the validator deque.
     * @param  times     uint256                  Number of pop operations to perform.
     * @return validator DataTypes.Validator      Removed and returned validator.
     */
    function pop(
        DataTypes.ValidatorDeque storage deque,
        uint256 times
    ) public returns (DataTypes.Validator memory validator) {
        // Loop through and remove validator entries at the end
        for (uint256 _i; _i < times; ) {
            if (empty(deque)) revert Errors.ValidatorQueueEmpty();

            int128 backIndex;

            unchecked {
                backIndex = deque._end - 1;
                ++_i;
            }

            validator = deque._validators[backIndex];
            delete deque._validators[backIndex];
            deque._end = backIndex;
        }

        emit ValidatorsPopped(times);
    }

    /**
     * @notice Check if the deque is empty
     * @dev Returns true if the validator deque is empty, otherwise false.
     * @param deque DataTypes.ValidatorDeque Storage reference to the validator deque.
     * @return      bool                     True if the deque is empty, otherwise false.
     */
    function empty(
        DataTypes.ValidatorDeque storage deque
    ) public view returns (bool) {
        return deque._end <= deque._begin;
    }

    /**
     * @notice Remove a validator from the array using a more gas-efficient loop.
     * @dev Removes a validator at the specified index and emits an event.
     * @param  deque         DataTypes.ValidatorDeque Storage reference to the validator deque.
     * @param  removeIndex   uint256                  Index of the validator to remove.
     * @return removedPubKey bytes                    Public key of the removed validator.
     */
    function removeOrdered(
        DataTypes.ValidatorDeque storage deque,
        uint256 removeIndex
    ) external returns (bytes memory removedPubKey) {
        int128 idx = SafeCast.toInt128(
            int256(deque._begin) + SafeCast.toInt256(removeIndex)
        );

        if (idx >= deque._end) revert Errors.OutOfBounds();

        // Get the pubkey for the validator to remove (for informational purposes)
        removedPubKey = deque._validators[idx].pubKey;

        for (int128 _i = idx; _i < deque._end - 1; ) {
            deque._validators[_i] = deque._validators[_i + 1];

            unchecked {
                ++_i;
            }
        }

        pop(deque, 1);

        emit ValidatorRemoved(removedPubKey, removeIndex, false);
    }

    /**
     * @notice Remove a validator from the array using swap and pop.
     * @dev Removes a validator at the specified index by swapping it with the last validator and then popping the last validator.
     * @param  deque         DataTypes.ValidatorDeque Storage reference to the validator deque.
     * @param  removeIndex   uint256                  Index of the validator to remove.
     * @return removedPubkey bytes                    Public key of the removed validator.
     */
    function removeUnordered(
        DataTypes.ValidatorDeque storage deque,
        uint256 removeIndex
    ) external returns (bytes memory removedPubkey) {
        int128 idx = SafeCast.toInt128(
            int256(deque._begin) + SafeCast.toInt256(removeIndex)
        );

        if (idx >= deque._end) revert Errors.OutOfBounds();

        // Get the pubkey for the validator to remove (for informational purposes)
        removedPubkey = deque._validators[idx].pubKey;

        // Swap the (validator to remove) with the last validator in the array if needed
        uint256 lastIndex = count(deque) - 1;
        if (removeIndex != lastIndex) {
            swap(deque, removeIndex, lastIndex);
        }

        // Pop off the validator to remove, which is now at the end of the array
        pop(deque, 1);

        emit ValidatorRemoved(removedPubkey, removeIndex, true);
    }

    /**
     * @notice Remove the last validator from the validators array and return its information
     * @dev Removes and returns information about the last validator in the queue.
     * @param  deque                   DataTypes.ValidatorDeque  Deque
     * @param  _withdrawalCredentials  bytes                     Credentials
     * @return pubKey                  bytes                     Key
     * @return withdrawalCredentials   bytes                     Credentials
     * @return signature               bytes                     Signature
     * @return depositDataRoot         bytes32                   Deposit data root
     * @return receiver                address                   account to receive pxEth
     */
    function getNext(
        DataTypes.ValidatorDeque storage deque,
        bytes memory _withdrawalCredentials
    )
        external
        returns (
            bytes memory pubKey,
            bytes memory withdrawalCredentials,
            bytes memory signature,
            bytes32 depositDataRoot,
            address receiver
        )
    {
        if (empty(deque)) revert Errors.ValidatorQueueEmpty();

        int128 frontIndex = deque._begin;
        DataTypes.Validator memory popped = deque._validators[frontIndex];
        delete deque._validators[frontIndex];

        unchecked {
            deque._begin = frontIndex + 1;
        }

        // Return the validator's information
        pubKey = popped.pubKey;
        withdrawalCredentials = _withdrawalCredentials;
        signature = popped.signature;
        depositDataRoot = popped.depositDataRoot;
        receiver = popped.receiver;
    }

    /**
     * @notice Return the information of the i'th validator in the registry
     * @dev Returns information about the validator at the specified index without removing it from the deque.
     * @param  deque                   DataTypes.ValidatorDeque  Deque
     * @param  _withdrawalCredentials  bytes                     Credentials
     * @param  _index                  uint256                   Index
     * @return pubKey                  bytes                     Key
     * @return withdrawalCredentials   bytes                     Credentials
     * @return signature               bytes                     Signature
     * @return depositDataRoot         bytes32                   Deposit data root
     * @return receiver                address                   account to receive pxEth
     */
    function get(
        DataTypes.ValidatorDeque storage deque,
        bytes memory _withdrawalCredentials,
        uint256 _index
    )
        external
        view
        returns (
            bytes memory pubKey,
            bytes memory withdrawalCredentials,
            bytes memory signature,
            bytes32 depositDataRoot,
            address receiver
        )
    {
        // int256(deque._begin) is a safe upcast
        int128 idx = SafeCast.toInt128(
            int256(deque._begin) + SafeCast.toInt256(_index)
        );

        if (idx >= deque._end) revert Errors.OutOfBounds();

        DataTypes.Validator memory _v = deque._validators[idx];

        // Return the validator's information
        pubKey = _v.pubKey;
        withdrawalCredentials = _withdrawalCredentials;
        signature = _v.signature;
        depositDataRoot = _v.depositDataRoot;
        receiver = _v.receiver;
    }

    /**
     * @notice Empties the validator queue.
     * @dev Clears the entire validator deque, setting both begin and end to 0.
     *      Emits an event to signal the clearing of the queue.
     * @param deque DataTypes.ValidatorDeque Storage reference to the validator deque.
     */
    function clear(DataTypes.ValidatorDeque storage deque) external {
        deque._begin = 0;
        deque._end = 0;

        emit ValidatorQueueCleared();
    }

    /**
     * @notice Returns the number of validators in the queue.
     * @dev Calculates and returns the number of validators in the deque.
     * @param deque DataTypes.ValidatorDeque Storage reference to the validator deque.
     * @return      uint256                  Number of validators in the deque.
     */
    function count(
        DataTypes.ValidatorDeque storage deque
    ) public view returns (uint256) {
        // The interface preserves the invariant that begin <= end so we assume this will not overflow.
        // We also assume there are at most int256.max items in the queue.
        unchecked {
            return uint256(int256(deque._end) - int256(deque._begin));
        }
    }
}

File 12 of 33 : IOracleAdapter.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

/**
 * @title IOracleAdapter
 * @notice Interface for Oracle Adapters
 * @dev This interface defines the methods for interacting with OracleAdapter.
 * @author redactedcartel.finance
 */

interface IOracleAdapter {
    /**
     * @notice Requests a voluntary exit for a specific public key
     * @dev This function is used to initiate a voluntary exit process.
     * @param _pubKey bytes The public key of the entity requesting the exit.
     */
    function requestVoluntaryExit(bytes calldata _pubKey) external;
}

File 13 of 33 : IPirexEth.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.19;

import {DataTypes} from "../libraries/DataTypes.sol";

/**
 * @title IPirexEth
 * @notice Interface for the PirexEth contract
 * @dev This interface defines the methods for interacting with PirexEth.
 * @author redactedcartel.finance
 */
interface IPirexEth {
    /**
     * @notice Initiate redemption by burning pxETH in return for upxETH
     * @dev This function allows the initiation of redemption by burning pxETH in exchange for upxETH.
     * @param _assets                     uint256 The amount of assets to burn. If the caller is AutoPxEth, then apxETH; pxETH otherwise.
     * @param _receiver                   address The address to receive upxETH.
     * @param _shouldTriggerValidatorExit bool    Whether the initiation should trigger voluntary exit.
     * @return postFeeAmount              uint256 The amount of pxETH burnt for the receiver.
     * @return feeAmount                  uint256 The amount of pxETH distributed as fees.
     */
    function initiateRedemption(
        uint256 _assets,
        address _receiver,
        bool _shouldTriggerValidatorExit
    ) external returns (uint256 postFeeAmount, uint256 feeAmount);

    /**
     * @notice Dissolve validator
     * @dev This function dissolves a validator.
     * @param _pubKey bytes The public key of the validator.
     */
    function dissolveValidator(bytes calldata _pubKey) external payable;

    /**
     * @notice Update validator state to be slashed
     * @dev This function updates the validator state to be slashed.
     * @param _pubKey         bytes                     The public key of the validator.
     * @param _removeIndex    uint256                   The index of the validator to be slashed.
     * @param _amount         uint256                   The ETH amount released from the Beacon chain.
     * @param _unordered      bool                      Whether to remove from the staking validator queue in order or not.
     * @param _useBuffer      bool                      Whether to use a buffer to compensate for the loss.
     * @param _burnerAccounts DataTypes.BurnerAccount[] Burner accounts.
     */
    function slashValidator(
        bytes calldata _pubKey,
        uint256 _removeIndex,
        uint256 _amount,
        bool _unordered,
        bool _useBuffer,
        DataTypes.BurnerAccount[] calldata _burnerAccounts
    ) external payable;

    /**
     * @notice Harvest and mint staking rewards when available
     * @dev This function harvests and mints staking rewards when available.
     * @param _endBlock uint256 The block until which ETH rewards are computed.
     */
    function harvest(uint256 _endBlock) external payable;
}

File 14 of 33 : IDepositContract.sol
// SPDX-License-Identifier: CC0-1.0
pragma solidity 0.8.19;

// 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 IDepositContract {
    /// @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 count.
    /// @return The deposit count encoded as a little endian 64-bit number.
    function get_deposit_count() external view returns (bytes memory);
}

File 15 of 33 : AutoPxEth.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import {Ownable2Step} from "openzeppelin-contracts/contracts/access/Ownable2Step.sol";
import {ERC4626} from "solmate/mixins/ERC4626.sol";
import {ERC20} from "solmate/tokens/ERC20.sol";
import {FixedPointMathLib} from "solmate/utils/FixedPointMathLib.sol";
import {SafeTransferLib} from "solmate/utils/SafeTransferLib.sol";
import {Errors} from "./libraries/Errors.sol";
import {IPirexEth} from "./interfaces/IPirexEth.sol";

/**
 * @title AutoPxEth
 * @notice Autocompounding vault for (staked) pxETH, adapted from pxCVX vault system
 * @dev This contract enables autocompounding for pxETH assets and includes various fee mechanisms.
 * @author redactedcartel.finance
 */
contract AutoPxEth is Ownable2Step, ERC4626 {
    /**
     * @dev Library: SafeTransferLib - Provides safe transfer functions for ERC20 tokens.
     */
    using SafeTransferLib for ERC20;

    /**
     * @dev Library: FixedPointMathLib - Provides fixed-point arithmetic for uint256.
     */
    using FixedPointMathLib for uint256;

    // Constants

    /**
     * @dev Maximum withdrawal penalty percentage.
     */
    uint256 private constant MAX_WITHDRAWAL_PENALTY = 50_000;
    

    /**
     * @dev Maximum platform fee percentage.
     */
    uint256 private constant MAX_PLATFORM_FEE = 200_000;

    /**
     * @dev Fee denominator for precise fee calculations.
     */
    uint256 private constant FEE_DENOMINATOR = 1_000_000;

    /**
     * @dev Duration of the rewards period.
     */
    uint256 private constant REWARDS_DURATION = 7 days;

    // State variables for tracking rewards and actively staked assets

    /**
     * @notice Reference to the PirexEth contract.
     */
    IPirexEth public pirexEth;
    
    /**
     * @notice Timestamp when the current rewards period will end.
     */
    uint256 public periodFinish;
    
    /**
     * @notice Rate at which rewards are distributed per second.
     */
    uint256 public rewardRate;
    
    /**
     * @notice Timestamp of the last update to the reward variables.
     */
    uint256 public lastUpdateTime;
    
    /**
     * @notice Accumulated reward per token stored.
     */
    uint256 public rewardPerTokenStored;
    
    /**
     * @notice Last calculated reward per token paid to stakers.
     */
    uint256 public rewardPerTokenPaid;
    
    /**
     * @notice Total rewards available for distribution.
     */
    uint256 public rewards;
    
    /**
     * @notice Total assets actively staked in the vault.
     */
    uint256 public totalStaked;

    // State variables related to fees
    /**
     * @notice Withdrawal penalty percentage.
     */
    uint256 public withdrawalPenalty = 30_000;
    
    /**
     * @notice Platform fee percentage.
     */
    uint256 public platformFee = 100_000;
    
    /**
     * @notice Address of the platform that receives fees.
     */
    address public platform;

    // Events

    /**
     * @notice Emitted when rewards are harvested and staked.
     * @dev This event is emitted when a user triggers the harvest function.
     * @param caller address indexed Address that triggered the harvest.
     * @param value  uint256         Amount of rewards harvested.
     */
    event Harvest(address indexed caller, uint256 value);

    /**
     * @notice Emitted when the withdrawal penalty is updated.
     * @dev This event is emitted when the withdrawal penalty is modified.
     * @param penalty uint256 New withdrawal penalty percentage.
     */
    event WithdrawalPenaltyUpdated(uint256 penalty);

    /**
     * @notice Emitted when the platform fee is updated.
     * @dev This event is emitted when the platform fee is modified.
     * @param fee uint256 New platform fee percentage.
     */
    event PlatformFeeUpdated(uint256 fee);
    
    /**
     * @notice Emitted when the platform address is updated.
     * @dev This event is emitted when the platform address is modified.
     * @param _platform address New platform address.
     */
    event PlatformUpdated(address _platform);

    /**
     * @notice Emitted when new rewards are added to the vault.
     * @dev This event is emitted when new rewards are added to the vault.
     * @param reward uint256 Amount of rewards added.
     */
    event RewardAdded(uint256 reward);

    /**
     * @notice Emitted when the PirexEth contract address is set.
     * @dev This event is emitted when the PirexEth contract address is set.
     * @param _pirexEth address New PirexEth contract address.
     */
    event SetPirexEth(address _pirexEth);

    // Modifiers
    /**
     * @dev Update reward states modifier
     * @param updateEarned bool Whether to update earned amount so far
     */
    modifier updateReward(bool updateEarned) {
        rewardPerTokenStored = rewardPerToken();
        lastUpdateTime = lastTimeRewardApplicable();

        if (updateEarned) {
            rewards = earned();
            rewardPerTokenPaid = rewardPerTokenStored;
        }
        _;
    }

    /**
     * @dev Contract constructor
     * @param _asset address Asset contract address
     * @param _platform address Platform address
     */
    constructor(
        address _asset,
        address _platform
    ) ERC4626(ERC20(_asset), "Autocompounding Pirex Ether", "apxETH") {
        if (_platform == address(0)) revert Errors.ZeroAddress();

        platform = _platform;
    }

    /*//////////////////////////////////////////////////////////////
                        RESTRICTED FUNCTIONS
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Set the PirexEth contract address
     * @dev Function access restricted to only owner
     * @param _pirexEth address PirexEth contract address
     */
    function setPirexEth(address _pirexEth) external onlyOwner {
        if (_pirexEth == address(0)) revert Errors.ZeroAddress();

        emit SetPirexEth(_pirexEth);

        pirexEth = IPirexEth(_pirexEth);
    }

    /**
     * @notice Set the withdrawal penalty
     * @dev Function access restricted to only owner
     * @param penalty uint256 Withdrawal penalty
     */
    function setWithdrawalPenalty(uint256 penalty) external onlyOwner {
        if (penalty > MAX_WITHDRAWAL_PENALTY) revert Errors.ExceedsMax();

        withdrawalPenalty = penalty;

        emit WithdrawalPenaltyUpdated(penalty);
    }

    /**
     * @notice Set the platform fee
     * @dev Function access restricted to only owner
     * @param fee uint256 Platform fee
     */
    function setPlatformFee(uint256 fee) external onlyOwner {
        if (fee > MAX_PLATFORM_FEE) revert Errors.ExceedsMax();

        platformFee = fee;

        emit PlatformFeeUpdated(fee);
    }

    /**
     * @notice Set the platform
     * @dev Function access restricted to only owner
     * @param _platform address Platform
     */
    function setPlatform(address _platform) external onlyOwner {
        if (_platform == address(0)) revert Errors.ZeroAddress();

        platform = _platform;

        emit PlatformUpdated(_platform);
    }

    /**
     * @notice Notify and sync the newly added rewards to be streamed over time
     * @dev Rewards are streamed following the duration set in REWARDS_DURATION
     */
    function notifyRewardAmount() external updateReward(false) {
        if (msg.sender != address(pirexEth)) revert Errors.NotPirexEth();

        // Rewards transferred directly to this contract are not added to totalStaked
        // To get the rewards w/o relying on a potentially incorrect passed in arg,
        // we can use the difference between the asset balance and totalStaked.
        // Additionally, to avoid re-distributing rewards, deduct the output of `earned`
        uint256 rewardBalance = asset.balanceOf(address(this)) -
            totalStaked -
            earned();

        rewardRate = rewardBalance / REWARDS_DURATION;

        if (rewardRate == 0) revert Errors.NoRewards();

        lastUpdateTime = block.timestamp;
        periodFinish = block.timestamp + REWARDS_DURATION;

        emit RewardAdded(rewardBalance);
    }

    /*//////////////////////////////////////////////////////////////
                                VIEWS
    //////////////////////////////////////////////////////////////*/

    /**
     * @inheritdoc ERC4626
     * @notice Get the amount of available pxETH in the contract
     * @dev Rewards are streamed for the duration set in REWARDS_DURATION
     */
    function totalAssets() public view override returns (uint256) {
        // Based on the current totalStaked and available rewards
        uint256 _totalStaked = totalStaked;
        uint256 _rewards = ((_totalStaked *
            (rewardPerToken() - rewardPerTokenPaid)) / 1e18) + rewards;

        // Deduct the exact reward amount staked (after fees are deducted when calling `harvest`)
        return
            _totalStaked +
            (
                _rewards == 0
                    ? 0
                    : (_rewards - ((_rewards * platformFee) / FEE_DENOMINATOR))
            );
    }

    /**
     * @notice Returns the last effective timestamp of the current reward period
     * @return uint256 Timestamp
     */
    function lastTimeRewardApplicable() public view returns (uint256) {
        return block.timestamp < periodFinish ? block.timestamp : periodFinish;
    }

    /**
     * @notice Returns the amount of rewards per staked token/asset
     * @return uint256 Rewards amount
     */
    function rewardPerToken() public view returns (uint256) {
        if (totalStaked == 0) {
            return rewardPerTokenStored;
        }

        return
            rewardPerTokenStored +
            ((((lastTimeRewardApplicable() - lastUpdateTime) * rewardRate) *
                1e18) / totalStaked);
    }

    /**
     * @notice Returns the earned rewards amount so far
     * @return uint256 Rewards amount
     */
    function earned() public view returns (uint256) {
        return
            ((totalStaked * (rewardPerToken() - rewardPerTokenPaid)) / 1e18) +
            rewards;
    }

    /**
     * @notice Return the amount of assets per 1 (1e18) share
     * @return uint256 Assets
     */
    function assetsPerShare() external view returns (uint256) {
        return previewRedeem(1e18);
    }

    /*//////////////////////////////////////////////////////////////
                            INTERNAL FUNCTIONS
    //////////////////////////////////////////////////////////////*/

    /**
     * @dev Internal method to keep track of the total amount of staked token/asset on deposit/mint
     */
    function _stake(uint256 amount) internal updateReward(true) {
        totalStaked += amount;
    }

    /**
     * @dev Internal method to keep track of the total amount of staked token/asset on withdrawal/redeem
     */
    function _withdraw(uint256 amount) internal updateReward(true) {
        totalStaked -= amount;
    }

    /*//////////////////////////////////////////////////////////////
                            ERC4626 OVERRIDES
    //////////////////////////////////////////////////////////////*/

    /**
     * @inheritdoc ERC4626
     * @dev Deduct the specified amount of assets from totalStaked to prepare for transfer to the user
     * @param assets uint256 Assets
     */
    function beforeWithdraw(uint256 assets, uint256) internal override {
        // Perform harvest to make sure that totalStaked is always equal or larger than assets to be withdrawn
        if (assets > totalStaked) harvest();

        _withdraw(assets);
    }

    /**
     * @inheritdoc ERC4626
     * @dev Include the new assets in totalStaked so that rewards can be properly distributed
     * @param assets uint256 Assets
     */
    function afterDeposit(uint256 assets, uint256) internal override {
        _stake(assets);
    }

    /**
     * @inheritdoc ERC4626
     * @dev Preview the amount of assets a user would receive from redeeming shares
     */
    function previewRedeem(
        uint256 shares
    ) public view override returns (uint256) {
        // Calculate assets based on a user's % ownership of vault shares
        uint256 assets = convertToAssets(shares);

        uint256 _totalSupply = totalSupply;

        // Calculate a penalty - zero if user is the last to withdraw.
        uint256 penalty = (_totalSupply == 0 || _totalSupply - shares == 0)
            ? 0
            : assets.mulDivUp(withdrawalPenalty, FEE_DENOMINATOR); // Round up the penalty in favour of the protocol.

        // Redeemable amount is the post-penalty amount
        return assets - penalty;
    }

    /**
     * @inheritdoc ERC4626
     * @notice Preview the amount of shares a user would need to redeem the specified asset amount
     * @dev This modified version takes into consideration the withdrawal fee
     */
    function previewWithdraw(
        uint256 assets
    ) public view override returns (uint256) {
        // Calculate shares based on the specified assets' proportion of the pool
        uint256 shares = convertToShares(assets);

        // Save 1 SLOAD
        uint256 _totalSupply = totalSupply;

        // Factor in additional shares to fulfill withdrawal if user is not the last to withdraw
        return
            (_totalSupply == 0 || _totalSupply - shares == 0)
                ? shares
                : (shares * FEE_DENOMINATOR) /
                    (FEE_DENOMINATOR - withdrawalPenalty);
    }

    /*//////////////////////////////////////////////////////////////
                            MUTATIVE FUNCTIONS
    //////////////////////////////////////////////////////////////*/

    /**
     * @notice Harvest and stake available rewards after distributing fees to the platform
     * @dev This function claims and stakes the available rewards, deducting a fee for the platform.
     */
    function harvest() public updateReward(true) {
        uint256 _rewards = rewards;

        if (_rewards != 0) {
            rewards = 0;

            // Fee for platform
            uint256 feeAmount = (_rewards * platformFee) / FEE_DENOMINATOR;

            // Deduct fee from reward balance
            _rewards -= feeAmount;

            // Claimed rewards should be in pxETH
            asset.safeTransfer(platform, feeAmount);

            // Stake rewards sans fee
            _stake(_rewards);

            emit Harvest(msg.sender, _rewards);
        }
    }

    /**
     * @notice Override transfer logic to trigger direct `initiateRedemption`.
     * @dev This function overrides the standard transfer logic to initiate redemption when transferring to the PirexEth contract.
     * @param to     address Transfer destination
     * @param amount uint256 Amount
     * @return       bool
     */
    function transfer(
        address to,
        uint256 amount
    ) public override returns (bool) {
        super.transfer(to, amount);

        if (to == address(pirexEth)) {
            pirexEth.initiateRedemption(amount, msg.sender, false);
        }

        return true;
    }

    /**
     * @notice Override transferFrom logic to trigger direct `initiateRedemption`.
     * @dev This function overrides the standard transferFrom logic to initiate redemption when transferring from the PirexEth contract.
     * @param from   Address of the transfer origin.
     * @param to     Address of the transfer destination.
     * @param amount Amount of tokens to transfer.
     * @return       A boolean indicating the success of the transfer.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) public override returns (bool) {
        super.transferFrom(from, to, amount);

        if (to == address(pirexEth)) {
            pirexEth.initiateRedemption(amount, from, false);
        }

        return true;
    }
}

File 16 of 33 : PxEth.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import {DineroERC20} from "./DineroERC20.sol";
import {Errors} from "./libraries/Errors.sol";

/**
 * @title  PxEth
 * @notice The PxEth token, the main token for the PirexEth system used in the Dinero ecosystem.
 * @dev    Extends the DineroERC20 contract and includes additional functionality.
 * @author redactedcartel.finance
 */
contract PxEth is DineroERC20 {
    // Roles
    /**
     * @notice The OPERATOR_ROLE role assigned for operator functions in the PxEth token contract.
     * @dev    Used to control access to critical functions.
     */
    bytes32 private constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE");

    /**
     * @notice Constructor to initialize the PxEth token.
     * @dev    Inherits from the DineroERC20 contract and sets the name, symbol, decimals, admin, and initial delay.
     * @param  _admin         address  Admin address.
     * @param  _initialDelay  uint48   Delay required to schedule the acceptance of an access control transfer started.
     */
    constructor(
        address _admin,
        uint48 _initialDelay
    ) DineroERC20("Pirex Ether", "pxETH", 18, _admin, _initialDelay) {}

    /**
     * @notice Operator function to approve allowances for specified accounts and amounts.
     * @dev    Only callable by the operator role.
     * @param  _from    address  Owner of the tokens.
     * @param  _to      address  Account to be approved.
     * @param  _amount  uint256  Amount to be approved.
     */
    function operatorApprove(
        address _from,
        address _to,
        uint256 _amount
    ) external onlyRole(OPERATOR_ROLE) {
        if (_from == address(0)) revert Errors.ZeroAddress();
        if (_to == address(0)) revert Errors.ZeroAddress();

        allowance[_from][_to] = _amount;

        emit Approval(_from, _to, _amount);
    }
}

File 17 of 33 : AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```solidity
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```solidity
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
 * to enforce additional security measures for this role.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `_msgSender()` is missing `role`.
     * Overriding this function changes the behavior of the {onlyRole} modifier.
     *
     * Format of the revert message is described in {_checkRole}.
     *
     * _Available since v4.6._
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        Strings.toHexString(account),
                        " is missing role ",
                        Strings.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * May emit a {RoleGranted} event.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}

File 18 of 33 : IAccessControlDefaultAdminRules.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/IAccessControlDefaultAdminRules.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";

/**
 * @dev External interface of AccessControlDefaultAdminRules declared to support ERC165 detection.
 *
 * _Available since v4.9._
 */
interface IAccessControlDefaultAdminRules is IAccessControl {
    /**
     * @dev Emitted when a {defaultAdmin} transfer is started, setting `newAdmin` as the next
     * address to become the {defaultAdmin} by calling {acceptDefaultAdminTransfer} only after `acceptSchedule`
     * passes.
     */
    event DefaultAdminTransferScheduled(address indexed newAdmin, uint48 acceptSchedule);

    /**
     * @dev Emitted when a {pendingDefaultAdmin} is reset if it was never accepted, regardless of its schedule.
     */
    event DefaultAdminTransferCanceled();

    /**
     * @dev Emitted when a {defaultAdminDelay} change is started, setting `newDelay` as the next
     * delay to be applied between default admin transfer after `effectSchedule` has passed.
     */
    event DefaultAdminDelayChangeScheduled(uint48 newDelay, uint48 effectSchedule);

    /**
     * @dev Emitted when a {pendingDefaultAdminDelay} is reset if its schedule didn't pass.
     */
    event DefaultAdminDelayChangeCanceled();

    /**
     * @dev Returns the address of the current `DEFAULT_ADMIN_ROLE` holder.
     */
    function defaultAdmin() external view returns (address);

    /**
     * @dev Returns a tuple of a `newAdmin` and an accept schedule.
     *
     * After the `schedule` passes, the `newAdmin` will be able to accept the {defaultAdmin} role
     * by calling {acceptDefaultAdminTransfer}, completing the role transfer.
     *
     * A zero value only in `acceptSchedule` indicates no pending admin transfer.
     *
     * NOTE: A zero address `newAdmin` means that {defaultAdmin} is being renounced.
     */
    function pendingDefaultAdmin() external view returns (address newAdmin, uint48 acceptSchedule);

    /**
     * @dev Returns the delay required to schedule the acceptance of a {defaultAdmin} transfer started.
     *
     * This delay will be added to the current timestamp when calling {beginDefaultAdminTransfer} to set
     * the acceptance schedule.
     *
     * NOTE: If a delay change has been scheduled, it will take effect as soon as the schedule passes, making this
     * function returns the new delay. See {changeDefaultAdminDelay}.
     */
    function defaultAdminDelay() external view returns (uint48);

    /**
     * @dev Returns a tuple of `newDelay` and an effect schedule.
     *
     * After the `schedule` passes, the `newDelay` will get into effect immediately for every
     * new {defaultAdmin} transfer started with {beginDefaultAdminTransfer}.
     *
     * A zero value only in `effectSchedule` indicates no pending delay change.
     *
     * NOTE: A zero value only for `newDelay` means that the next {defaultAdminDelay}
     * will be zero after the effect schedule.
     */
    function pendingDefaultAdminDelay() external view returns (uint48 newDelay, uint48 effectSchedule);

    /**
     * @dev Starts a {defaultAdmin} transfer by setting a {pendingDefaultAdmin} scheduled for acceptance
     * after the current timestamp plus a {defaultAdminDelay}.
     *
     * Requirements:
     *
     * - Only can be called by the current {defaultAdmin}.
     *
     * Emits a DefaultAdminRoleChangeStarted event.
     */
    function beginDefaultAdminTransfer(address newAdmin) external;

    /**
     * @dev Cancels a {defaultAdmin} transfer previously started with {beginDefaultAdminTransfer}.
     *
     * A {pendingDefaultAdmin} not yet accepted can also be cancelled with this function.
     *
     * Requirements:
     *
     * - Only can be called by the current {defaultAdmin}.
     *
     * May emit a DefaultAdminTransferCanceled event.
     */
    function cancelDefaultAdminTransfer() external;

    /**
     * @dev Completes a {defaultAdmin} transfer previously started with {beginDefaultAdminTransfer}.
     *
     * After calling the function:
     *
     * - `DEFAULT_ADMIN_ROLE` should be granted to the caller.
     * - `DEFAULT_ADMIN_ROLE` should be revoked from the previous holder.
     * - {pendingDefaultAdmin} should be reset to zero values.
     *
     * Requirements:
     *
     * - Only can be called by the {pendingDefaultAdmin}'s `newAdmin`.
     * - The {pendingDefaultAdmin}'s `acceptSchedule` should've passed.
     */
    function acceptDefaultAdminTransfer() external;

    /**
     * @dev Initiates a {defaultAdminDelay} update by setting a {pendingDefaultAdminDelay} scheduled for getting
     * into effect after the current timestamp plus a {defaultAdminDelay}.
     *
     * This function guarantees that any call to {beginDefaultAdminTransfer} done between the timestamp this
     * method is called and the {pendingDefaultAdminDelay} effect schedule will use the current {defaultAdminDelay}
     * set before calling.
     *
     * The {pendingDefaultAdminDelay}'s effect schedule is defined in a way that waiting until the schedule and then
     * calling {beginDefaultAdminTransfer} with the new delay will take at least the same as another {defaultAdmin}
     * complete transfer (including acceptance).
     *
     * The schedule is designed for two scenarios:
     *
     * - When the delay is changed for a larger one the schedule is `block.timestamp + newDelay` capped by
     * {defaultAdminDelayIncreaseWait}.
     * - When the delay is changed for a shorter one, the schedule is `block.timestamp + (current delay - new delay)`.
     *
     * A {pendingDefaultAdminDelay} that never got into effect will be canceled in favor of a new scheduled change.
     *
     * Requirements:
     *
     * - Only can be called by the current {defaultAdmin}.
     *
     * Emits a DefaultAdminDelayChangeScheduled event and may emit a DefaultAdminDelayChangeCanceled event.
     */
    function changeDefaultAdminDelay(uint48 newDelay) external;

    /**
     * @dev Cancels a scheduled {defaultAdminDelay} change.
     *
     * Requirements:
     *
     * - Only can be called by the current {defaultAdmin}.
     *
     * May emit a DefaultAdminDelayChangeCanceled event.
     */
    function rollbackDefaultAdminDelay() external;

    /**
     * @dev Maximum time in seconds for an increase to {defaultAdminDelay} (that is scheduled using {changeDefaultAdminDelay})
     * to take effect. Default to 5 days.
     *
     * When the {defaultAdminDelay} is scheduled to be increased, it goes into effect after the new delay has passed with
     * the purpose of giving enough time for reverting any accidental change (i.e. using milliseconds instead of seconds)
     * that may lock the contract. However, to avoid excessive schedules, the wait is capped by this function and it can
     * be overrode for a custom {defaultAdminDelay} increase scheduling.
     *
     * IMPORTANT: Make sure to add a reasonable amount of time while overriding this value, otherwise,
     * there's a risk of setting a high new delay that goes into effect almost immediately without the
     * possibility of human intervention in the case of an input error (eg. set milliseconds instead of seconds).
     */
    function defaultAdminDelayIncreaseWait() external view returns (uint48);
}

File 19 of 33 : SafeCast.sol
// 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);
    }
}

File 20 of 33 : IERC5313.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC5313.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface for the Light Contract Ownership Standard.
 *
 * A standardized minimal interface required to identify an account that controls a contract
 *
 * _Available since v4.9._
 */
interface IERC5313 {
    /**
     * @dev Gets the address of the owner.
     */
    function owner() external view returns (address);
}

File 21 of 33 : ERC1155.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

/// @notice Minimalist and gas efficient standard ERC1155 implementation.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC1155.sol)
abstract contract ERC1155 {
    /*//////////////////////////////////////////////////////////////
                                 EVENTS
    //////////////////////////////////////////////////////////////*/

    event TransferSingle(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256 id,
        uint256 amount
    );

    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] amounts
    );

    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    event URI(string value, uint256 indexed id);

    /*//////////////////////////////////////////////////////////////
                             ERC1155 STORAGE
    //////////////////////////////////////////////////////////////*/

    mapping(address => mapping(uint256 => uint256)) public balanceOf;

    mapping(address => mapping(address => bool)) public isApprovedForAll;

    /*//////////////////////////////////////////////////////////////
                             METADATA LOGIC
    //////////////////////////////////////////////////////////////*/

    function uri(uint256 id) public view virtual returns (string memory);

    /*//////////////////////////////////////////////////////////////
                              ERC1155 LOGIC
    //////////////////////////////////////////////////////////////*/

    function setApprovalForAll(address operator, bool approved) public virtual {
        isApprovedForAll[msg.sender][operator] = approved;

        emit ApprovalForAll(msg.sender, operator, approved);
    }

    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes calldata data
    ) public virtual {
        require(msg.sender == from || isApprovedForAll[from][msg.sender], "NOT_AUTHORIZED");

        balanceOf[from][id] -= amount;
        balanceOf[to][id] += amount;

        emit TransferSingle(msg.sender, from, to, id, amount);

        require(
            to.code.length == 0
                ? to != address(0)
                : ERC1155TokenReceiver(to).onERC1155Received(msg.sender, from, id, amount, data) ==
                    ERC1155TokenReceiver.onERC1155Received.selector,
            "UNSAFE_RECIPIENT"
        );
    }

    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata amounts,
        bytes calldata data
    ) public virtual {
        require(ids.length == amounts.length, "LENGTH_MISMATCH");

        require(msg.sender == from || isApprovedForAll[from][msg.sender], "NOT_AUTHORIZED");

        // Storing these outside the loop saves ~15 gas per iteration.
        uint256 id;
        uint256 amount;

        for (uint256 i = 0; i < ids.length; ) {
            id = ids[i];
            amount = amounts[i];

            balanceOf[from][id] -= amount;
            balanceOf[to][id] += amount;

            // An array can't have a total length
            // larger than the max uint256 value.
            unchecked {
                ++i;
            }
        }

        emit TransferBatch(msg.sender, from, to, ids, amounts);

        require(
            to.code.length == 0
                ? to != address(0)
                : ERC1155TokenReceiver(to).onERC1155BatchReceived(msg.sender, from, ids, amounts, data) ==
                    ERC1155TokenReceiver.onERC1155BatchReceived.selector,
            "UNSAFE_RECIPIENT"
        );
    }

    function balanceOfBatch(address[] calldata owners, uint256[] calldata ids)
        public
        view
        virtual
        returns (uint256[] memory balances)
    {
        require(owners.length == ids.length, "LENGTH_MISMATCH");

        balances = new uint256[](owners.length);

        // Unchecked because the only math done is incrementing
        // the array index counter which cannot possibly overflow.
        unchecked {
            for (uint256 i = 0; i < owners.length; ++i) {
                balances[i] = balanceOf[owners[i]][ids[i]];
            }
        }
    }

    /*//////////////////////////////////////////////////////////////
                              ERC165 LOGIC
    //////////////////////////////////////////////////////////////*/

    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return
            interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
            interfaceId == 0xd9b67a26 || // ERC165 Interface ID for ERC1155
            interfaceId == 0x0e89341c; // ERC165 Interface ID for ERC1155MetadataURI
    }

    /*//////////////////////////////////////////////////////////////
                        INTERNAL MINT/BURN LOGIC
    //////////////////////////////////////////////////////////////*/

    function _mint(
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) internal virtual {
        balanceOf[to][id] += amount;

        emit TransferSingle(msg.sender, address(0), to, id, amount);

        require(
            to.code.length == 0
                ? to != address(0)
                : ERC1155TokenReceiver(to).onERC1155Received(msg.sender, address(0), id, amount, data) ==
                    ERC1155TokenReceiver.onERC1155Received.selector,
            "UNSAFE_RECIPIENT"
        );
    }

    function _batchMint(
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {
        uint256 idsLength = ids.length; // Saves MLOADs.

        require(idsLength == amounts.length, "LENGTH_MISMATCH");

        for (uint256 i = 0; i < idsLength; ) {
            balanceOf[to][ids[i]] += amounts[i];

            // An array can't have a total length
            // larger than the max uint256 value.
            unchecked {
                ++i;
            }
        }

        emit TransferBatch(msg.sender, address(0), to, ids, amounts);

        require(
            to.code.length == 0
                ? to != address(0)
                : ERC1155TokenReceiver(to).onERC1155BatchReceived(msg.sender, address(0), ids, amounts, data) ==
                    ERC1155TokenReceiver.onERC1155BatchReceived.selector,
            "UNSAFE_RECIPIENT"
        );
    }

    function _batchBurn(
        address from,
        uint256[] memory ids,
        uint256[] memory amounts
    ) internal virtual {
        uint256 idsLength = ids.length; // Saves MLOADs.

        require(idsLength == amounts.length, "LENGTH_MISMATCH");

        for (uint256 i = 0; i < idsLength; ) {
            balanceOf[from][ids[i]] -= amounts[i];

            // An array can't have a total length
            // larger than the max uint256 value.
            unchecked {
                ++i;
            }
        }

        emit TransferBatch(msg.sender, from, address(0), ids, amounts);
    }

    function _burn(
        address from,
        uint256 id,
        uint256 amount
    ) internal virtual {
        balanceOf[from][id] -= amount;

        emit TransferSingle(msg.sender, from, address(0), id, amount);
    }
}

/// @notice A generic interface for a contract which properly accepts ERC1155 tokens.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC1155.sol)
abstract contract ERC1155TokenReceiver {
    function onERC1155Received(
        address,
        address,
        uint256,
        uint256,
        bytes calldata
    ) external virtual returns (bytes4) {
        return ERC1155TokenReceiver.onERC1155Received.selector;
    }

    function onERC1155BatchReceived(
        address,
        address,
        uint256[] calldata,
        uint256[] calldata,
        bytes calldata
    ) external virtual returns (bytes4) {
        return ERC1155TokenReceiver.onERC1155BatchReceived.selector;
    }
}

File 22 of 33 : Ownable2Step.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol)

pragma solidity ^0.8.0;

import "./Ownable.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 Ownable2Step is Ownable {
    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() public virtual {
        address sender = _msgSender();
        require(pendingOwner() == sender, "Ownable2Step: caller is not the new owner");
        _transferOwnership(sender);
    }
}

File 23 of 33 : ERC4626.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

import {ERC20} from "../tokens/ERC20.sol";
import {SafeTransferLib} from "../utils/SafeTransferLib.sol";
import {FixedPointMathLib} from "../utils/FixedPointMathLib.sol";

/// @notice Minimal ERC4626 tokenized Vault implementation.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/mixins/ERC4626.sol)
abstract contract ERC4626 is ERC20 {
    using SafeTransferLib for ERC20;
    using FixedPointMathLib for uint256;

    /*//////////////////////////////////////////////////////////////
                                 EVENTS
    //////////////////////////////////////////////////////////////*/

    event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares);

    event Withdraw(
        address indexed caller,
        address indexed receiver,
        address indexed owner,
        uint256 assets,
        uint256 shares
    );

    /*//////////////////////////////////////////////////////////////
                               IMMUTABLES
    //////////////////////////////////////////////////////////////*/

    ERC20 public immutable asset;

    constructor(
        ERC20 _asset,
        string memory _name,
        string memory _symbol
    ) ERC20(_name, _symbol, _asset.decimals()) {
        asset = _asset;
    }

    /*//////////////////////////////////////////////////////////////
                        DEPOSIT/WITHDRAWAL LOGIC
    //////////////////////////////////////////////////////////////*/

    function deposit(uint256 assets, address receiver) public virtual returns (uint256 shares) {
        // Check for rounding error since we round down in previewDeposit.
        require((shares = previewDeposit(assets)) != 0, "ZERO_SHARES");

        // Need to transfer before minting or ERC777s could reenter.
        asset.safeTransferFrom(msg.sender, address(this), assets);

        _mint(receiver, shares);

        emit Deposit(msg.sender, receiver, assets, shares);

        afterDeposit(assets, shares);
    }

    function mint(uint256 shares, address receiver) public virtual returns (uint256 assets) {
        assets = previewMint(shares); // No need to check for rounding error, previewMint rounds up.

        // Need to transfer before minting or ERC777s could reenter.
        asset.safeTransferFrom(msg.sender, address(this), assets);

        _mint(receiver, shares);

        emit Deposit(msg.sender, receiver, assets, shares);

        afterDeposit(assets, shares);
    }

    function withdraw(
        uint256 assets,
        address receiver,
        address owner
    ) public virtual returns (uint256 shares) {
        shares = previewWithdraw(assets); // No need to check for rounding error, previewWithdraw rounds up.

        if (msg.sender != owner) {
            uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals.

            if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares;
        }

        beforeWithdraw(assets, shares);

        _burn(owner, shares);

        emit Withdraw(msg.sender, receiver, owner, assets, shares);

        asset.safeTransfer(receiver, assets);
    }

    function redeem(
        uint256 shares,
        address receiver,
        address owner
    ) public virtual returns (uint256 assets) {
        if (msg.sender != owner) {
            uint256 allowed = allowance[owner][msg.sender]; // Saves gas for limited approvals.

            if (allowed != type(uint256).max) allowance[owner][msg.sender] = allowed - shares;
        }

        // Check for rounding error since we round down in previewRedeem.
        require((assets = previewRedeem(shares)) != 0, "ZERO_ASSETS");

        beforeWithdraw(assets, shares);

        _burn(owner, shares);

        emit Withdraw(msg.sender, receiver, owner, assets, shares);

        asset.safeTransfer(receiver, assets);
    }

    /*//////////////////////////////////////////////////////////////
                            ACCOUNTING LOGIC
    //////////////////////////////////////////////////////////////*/

    function totalAssets() public view virtual returns (uint256);

    function convertToShares(uint256 assets) public view virtual returns (uint256) {
        uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.

        return supply == 0 ? assets : assets.mulDivDown(supply, totalAssets());
    }

    function convertToAssets(uint256 shares) public view virtual returns (uint256) {
        uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.

        return supply == 0 ? shares : shares.mulDivDown(totalAssets(), supply);
    }

    function previewDeposit(uint256 assets) public view virtual returns (uint256) {
        return convertToShares(assets);
    }

    function previewMint(uint256 shares) public view virtual returns (uint256) {
        uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.

        return supply == 0 ? shares : shares.mulDivUp(totalAssets(), supply);
    }

    function previewWithdraw(uint256 assets) public view virtual returns (uint256) {
        uint256 supply = totalSupply; // Saves an extra SLOAD if totalSupply is non-zero.

        return supply == 0 ? assets : assets.mulDivUp(supply, totalAssets());
    }

    function previewRedeem(uint256 shares) public view virtual returns (uint256) {
        return convertToAssets(shares);
    }

    /*//////////////////////////////////////////////////////////////
                     DEPOSIT/WITHDRAWAL LIMIT LOGIC
    //////////////////////////////////////////////////////////////*/

    function maxDeposit(address) public view virtual returns (uint256) {
        return type(uint256).max;
    }

    function maxMint(address) public view virtual returns (uint256) {
        return type(uint256).max;
    }

    function maxWithdraw(address owner) public view virtual returns (uint256) {
        return convertToAssets(balanceOf[owner]);
    }

    function maxRedeem(address owner) public view virtual returns (uint256) {
        return balanceOf[owner];
    }

    /*//////////////////////////////////////////////////////////////
                          INTERNAL HOOKS LOGIC
    //////////////////////////////////////////////////////////////*/

    function beforeWithdraw(uint256 assets, uint256 shares) internal virtual {}

    function afterDeposit(uint256 assets, uint256 shares) internal virtual {}
}

File 24 of 33 : FixedPointMathLib.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

/// @notice Arithmetic library with operations for fixed-point numbers.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/FixedPointMathLib.sol)
/// @author Inspired by USM (https://github.com/usmfum/USM/blob/master/contracts/WadMath.sol)
library FixedPointMathLib {
    /*//////////////////////////////////////////////////////////////
                    SIMPLIFIED FIXED POINT OPERATIONS
    //////////////////////////////////////////////////////////////*/

    uint256 internal constant MAX_UINT256 = 2**256 - 1;

    uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s.

    function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) {
        return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down.
    }

    function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) {
        return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up.
    }

    function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) {
        return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down.
    }

    function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) {
        return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up.
    }

    /*//////////////////////////////////////////////////////////////
                    LOW LEVEL FIXED POINT OPERATIONS
    //////////////////////////////////////////////////////////////*/

    function mulDivDown(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            // Equivalent to require(denominator != 0 && (y == 0 || x <= type(uint256).max / y))
            if iszero(mul(denominator, iszero(mul(y, gt(x, div(MAX_UINT256, y)))))) {
                revert(0, 0)
            }

            // Divide x * y by the denominator.
            z := div(mul(x, y), denominator)
        }
    }

    function mulDivUp(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            // Equivalent to require(denominator != 0 && (y == 0 || x <= type(uint256).max / y))
            if iszero(mul(denominator, iszero(mul(y, gt(x, div(MAX_UINT256, y)))))) {
                revert(0, 0)
            }

            // If x * y modulo the denominator is strictly greater than 0,
            // 1 is added to round up the division of x * y by the denominator.
            z := add(gt(mod(mul(x, y), denominator), 0), div(mul(x, y), denominator))
        }
    }

    function rpow(
        uint256 x,
        uint256 n,
        uint256 scalar
    ) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            switch x
            case 0 {
                switch n
                case 0 {
                    // 0 ** 0 = 1
                    z := scalar
                }
                default {
                    // 0 ** n = 0
                    z := 0
                }
            }
            default {
                switch mod(n, 2)
                case 0 {
                    // If n is even, store scalar in z for now.
                    z := scalar
                }
                default {
                    // If n is odd, store x in z for now.
                    z := x
                }

                // Shifting right by 1 is like dividing by 2.
                let half := shr(1, scalar)

                for {
                    // Shift n right by 1 before looping to halve it.
                    n := shr(1, n)
                } n {
                    // Shift n right by 1 each iteration to halve it.
                    n := shr(1, n)
                } {
                    // Revert immediately if x ** 2 would overflow.
                    // Equivalent to iszero(eq(div(xx, x), x)) here.
                    if shr(128, x) {
                        revert(0, 0)
                    }

                    // Store x squared.
                    let xx := mul(x, x)

                    // Round to the nearest number.
                    let xxRound := add(xx, half)

                    // Revert if xx + half overflowed.
                    if lt(xxRound, xx) {
                        revert(0, 0)
                    }

                    // Set x to scaled xxRound.
                    x := div(xxRound, scalar)

                    // If n is even:
                    if mod(n, 2) {
                        // Compute z * x.
                        let zx := mul(z, x)

                        // If z * x overflowed:
                        if iszero(eq(div(zx, x), z)) {
                            // Revert if x is non-zero.
                            if iszero(iszero(x)) {
                                revert(0, 0)
                            }
                        }

                        // Round to the nearest number.
                        let zxRound := add(zx, half)

                        // Revert if zx + half overflowed.
                        if lt(zxRound, zx) {
                            revert(0, 0)
                        }

                        // Return properly scaled zxRound.
                        z := div(zxRound, scalar)
                    }
                }
            }
        }
    }

    /*//////////////////////////////////////////////////////////////
                        GENERAL NUMBER UTILITIES
    //////////////////////////////////////////////////////////////*/

    function sqrt(uint256 x) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            let y := x // We start y at x, which will help us make our initial estimate.

            z := 181 // The "correct" value is 1, but this saves a multiplication later.

            // This segment is to get a reasonable initial estimate for the Babylonian method. With a bad
            // start, the correct # of bits increases ~linearly each iteration instead of ~quadratically.

            // We check y >= 2^(k + 8) but shift right by k bits
            // each branch to ensure that if x >= 256, then y >= 256.
            if iszero(lt(y, 0x10000000000000000000000000000000000)) {
                y := shr(128, y)
                z := shl(64, z)
            }
            if iszero(lt(y, 0x1000000000000000000)) {
                y := shr(64, y)
                z := shl(32, z)
            }
            if iszero(lt(y, 0x10000000000)) {
                y := shr(32, y)
                z := shl(16, z)
            }
            if iszero(lt(y, 0x1000000)) {
                y := shr(16, y)
                z := shl(8, z)
            }

            // Goal was to get z*z*y within a small factor of x. More iterations could
            // get y in a tighter range. Currently, we will have y in [256, 256*2^16).
            // We ensured y >= 256 so that the relative difference between y and y+1 is small.
            // That's not possible if x < 256 but we can just verify those cases exhaustively.

            // Now, z*z*y <= x < z*z*(y+1), and y <= 2^(16+8), and either y >= 256, or x < 256.
            // Correctness can be checked exhaustively for x < 256, so we assume y >= 256.
            // Then z*sqrt(y) is within sqrt(257)/sqrt(256) of sqrt(x), or about 20bps.

            // For s in the range [1/256, 256], the estimate f(s) = (181/1024) * (s+1) is in the range
            // (1/2.84 * sqrt(s), 2.84 * sqrt(s)), with largest error when s = 1 and when s = 256 or 1/256.

            // Since y is in [256, 256*2^16), let a = y/65536, so that a is in [1/256, 256). Then we can estimate
            // sqrt(y) using sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2^18.

            // There is no overflow risk here since y < 2^136 after the first branch above.
            z := shr(18, mul(z, add(y, 65536))) // A mul() is saved from starting z at 181.

            // Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough.
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))
            z := shr(1, add(z, div(x, z)))

            // If x+1 is a perfect square, the Babylonian method cycles between
            // floor(sqrt(x)) and ceil(sqrt(x)). This statement ensures we return floor.
            // See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division
            // Since the ceil is rare, we save gas on the assignment and repeat division in the rare case.
            // If you don't care whether the floor or ceil square root is returned, you can remove this statement.
            z := sub(z, lt(div(x, z), z))
        }
    }

    function unsafeMod(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            // Mod x by y. Note this will return
            // 0 instead of reverting if y is zero.
            z := mod(x, y)
        }
    }

    function unsafeDiv(uint256 x, uint256 y) internal pure returns (uint256 r) {
        /// @solidity memory-safe-assembly
        assembly {
            // Divide x by y. Note this will return
            // 0 instead of reverting if y is zero.
            r := div(x, y)
        }
    }

    function unsafeDivUp(uint256 x, uint256 y) internal pure returns (uint256 z) {
        /// @solidity memory-safe-assembly
        assembly {
            // Add 1 to x * y if x % y > 0. Note this will
            // return 0 instead of reverting if y is zero.
            z := add(gt(mod(x, y), 0), div(x, y))
        }
    }
}

File 25 of 33 : DineroERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import {ERC20} from "solmate/tokens/ERC20.sol";
import {AccessControlDefaultAdminRules} from "openzeppelin-contracts/contracts/access/AccessControlDefaultAdminRules.sol";
import {Errors} from "./libraries/Errors.sol";

/**
 * @title DineroERC20
 * @dev A Standard ERC20 token with minting and burning with access control.
 * @author redactedcartel.finance
 */
contract DineroERC20 is ERC20, AccessControlDefaultAdminRules {
    // Roles
    /**
     * @dev Bytes32 constant representing the role to mint new tokens.
     */
    bytes32 private constant MINTER_ROLE = keccak256("MINTER_ROLE");

    /**
     * @dev Bytes32 constant representing the role to burn (destroy) tokens.
     */
    bytes32 private constant BURNER_ROLE = keccak256("BURNER_ROLE");

    /**
     * @notice Constructor to initialize ERC20 token with access control.
     * @param _name          string   Token name.
     * @param _symbol        string   Token symbol.
     * @param _decimals      uint8    Token decimals.
     * @param _admin         address  Admin address.
     * @param _initialDelay  uint48   Delay required to schedule the acceptance
     *                                of an access control transfer started.
     */
    constructor(
        string memory _name,
        string memory _symbol,
        uint8 _decimals,
        address _admin,
        uint48 _initialDelay
    )
        AccessControlDefaultAdminRules(_initialDelay, _admin)
        ERC20(_name, _symbol, _decimals)
    {
        if (bytes(_name).length == 0) revert Errors.EmptyString();
        if (bytes(_symbol).length == 0) revert Errors.EmptyString();
        if (_decimals == 0) revert Errors.ZeroAmount();
    }

    /**
     * @notice Mints tokens to an address.
     * @dev Only callable by minters.
     * @param _to      address  Address to mint tokens to.
     * @param _amount  uint256  Amount of tokens to mint.
     */
    function mint(address _to, uint256 _amount) external onlyRole(MINTER_ROLE) {
        if (_to == address(0)) revert Errors.ZeroAddress();
        if (_amount == 0) revert Errors.ZeroAmount();

        _mint(_to, _amount);
    }

    /**
     * @notice Burns tokens from an address.
     * @dev Only callable by burners.
     * @param _from    address  Address to burn tokens from.
     * @param _amount  uint256  Amount of tokens to burn.
     */
    function burn(
        address _from,
        uint256 _amount
    ) external onlyRole(BURNER_ROLE) {
        if (_from == address(0)) revert Errors.ZeroAddress();
        if (_amount == 0) revert Errors.ZeroAmount();

        _burn(_from, _amount);
    }
}

File 26 of 33 : IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}

File 27 of 33 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @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 Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

File 28 of 33 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";
import "./math/SignedMath.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toString(int256 value) internal pure returns (string memory) {
        return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return keccak256(bytes(a)) == keccak256(bytes(b));
    }
}

File 29 of 33 : ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

File 30 of 33 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.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 Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _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. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        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);
    }
}

File 31 of 33 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1, "Math: mulDiv overflow");

            ///////////////////////////////////////////////
            // 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 256, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
        }
    }
}

File 32 of 33 : SignedMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard signed math utilities missing in the Solidity language.
 */
library SignedMath {
    /**
     * @dev Returns the largest of two signed numbers.
     */
    function max(int256 a, int256 b) internal pure returns (int256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two signed numbers.
     */
    function min(int256 a, int256 b) internal pure returns (int256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
}

File 33 of 33 : IERC165.sol
// 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 IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

Settings
{
  "remappings": [
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "forge-std/=lib/forge-std/src/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "solmate/=lib/solmate/src/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "openzeppelin/=lib/openzeppelin-contracts/contracts/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "paris",
  "libraries": {
    "src/libraries/ValidatorQueue.sol": {
      "ValidatorQueue": "0x9e0d7d79735e1c63333128149c7b616a0dc0bbdb"
    }
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_pxEth","type":"address"},{"internalType":"address","name":"_admin","type":"address"},{"internalType":"address","name":"_beaconChainDepositContract","type":"address"},{"internalType":"address","name":"_upxEth","type":"address"},{"internalType":"uint256","name":"_depositSize","type":"uint256"},{"internalType":"uint256","name":"_preDepositAmount","type":"uint256"},{"internalType":"address","name":"_pirexFees","type":"address"},{"internalType":"uint48","name":"_initialDelay","type":"uint48"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccountNotApproved","type":"error"},{"inputs":[],"name":"DepositingEtherNotPaused","type":"error"},{"inputs":[],"name":"DepositingEtherPaused","type":"error"},{"inputs":[],"name":"EmptyArray","type":"error"},{"inputs":[],"name":"ExceedsMax","type":"error"},{"inputs":[],"name":"InvalidAmount","type":"error"},{"inputs":[],"name":"InvalidFee","type":"error"},{"inputs":[],"name":"InvalidMaxFee","type":"error"},{"inputs":[],"name":"InvalidMaxProcessedCount","type":"error"},{"inputs":[],"name":"InvalidToken","type":"error"},{"inputs":[],"name":"MismatchedArrayLengths","type":"error"},{"inputs":[],"name":"NoETH","type":"error"},{"inputs":[],"name":"NoETHAllowed","type":"error"},{"inputs":[],"name":"NoPartialInitiateRedemption","type":"error"},{"inputs":[],"name":"NoUsedValidator","type":"error"},{"inputs":[],"name":"NoValidatorExit","type":"error"},{"inputs":[],"name":"NotEnoughBuffer","type":"error"},{"inputs":[],"name":"NotEnoughETH","type":"error"},{"inputs":[],"name":"NotEnoughValidators","type":"error"},{"inputs":[],"name":"NotPaused","type":"error"},{"inputs":[],"name":"NotRewardRecipient","type":"error"},{"inputs":[],"name":"NotWithdrawable","type":"error"},{"inputs":[],"name":"Paused","type":"error"},{"inputs":[],"name":"StatusNotDissolvedOrSlashed","type":"error"},{"inputs":[],"name":"StatusNotWithdrawableOrStaking","type":"error"},{"inputs":[],"name":"UnrecorgnisedContract","type":"error"},{"inputs":[],"name":"ValidatorNotStaking","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"inputs":[],"name":"ZeroAmount","type":"error"},{"inputs":[],"name":"ZeroMultiplier","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"ApproveBurnerAccount","type":"event"},{"anonymous":false,"inputs":[],"name":"DefaultAdminDelayChangeCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint48","name":"newDelay","type":"uint48"},{"indexed":false,"internalType":"uint48","name":"effectSchedule","type":"uint48"}],"name":"DefaultAdminDelayChangeScheduled","type":"event"},{"anonymous":false,"inputs":[],"name":"DefaultAdminTransferCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newAdmin","type":"address"},{"indexed":false,"internalType":"uint48","name":"acceptSchedule","type":"uint48"}],"name":"DefaultAdminTransferScheduled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"bool","name":"shouldCompound","type":"bool"},{"indexed":false,"internalType":"uint256","name":"deposited","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"receivedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feeAmount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newStatus","type":"uint256"}],"name":"DepositEtherPaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"pubKey","type":"bytes"}],"name":"DissolveValidator","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"EmergencyWithdrawal","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"endBlock","type":"uint256"}],"name":"Harvest","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"postFeeAmount","type":"uint256"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"}],"name":"InitiateRedemption","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"postFeeAmount","type":"uint256"},{"indexed":true,"internalType":"address","name":"_receiver","type":"address"}],"name":"RedeemWithPxEth","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"}],"name":"RedeemWithUpxEth","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"RevokeBurnerAccount","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"enum DataTypes.Contract","name":"c","type":"uint8"},{"indexed":false,"internalType":"address","name":"contractAddress","type":"address"}],"name":"SetContract","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"enum DataTypes.Fees","name":"f","type":"uint8"},{"indexed":false,"internalType":"uint32","name":"fee","type":"uint32"}],"name":"SetFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"pct","type":"uint256"}],"name":"SetMaxBufferSizePct","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"enum DataTypes.Fees","name":"f","type":"uint8"},{"indexed":false,"internalType":"uint32","name":"maxFee","type":"uint32"}],"name":"SetMaxFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"count","type":"uint256"}],"name":"SetMaxProcessedValidatorCount","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"state","type":"uint256"}],"name":"SetPauseState","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"withdrawalCredentials","type":"bytes"}],"name":"SetWithdrawCredentials","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"pubKey","type":"bytes"},{"indexed":false,"internalType":"bool","name":"useBuffer","type":"bool"},{"indexed":false,"internalType":"uint256","name":"releasedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"penalty","type":"uint256"}],"name":"SlashValidator","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"pubKey","type":"bytes"},{"indexed":false,"internalType":"bool","name":"useBuffer","type":"bool"},{"indexed":false,"internalType":"uint256","name":"topUpAmount","type":"uint256"}],"name":"TopUp","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"maxBufferSize","type":"uint256"}],"name":"UpdateMaxBufferSize","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"pubKey","type":"bytes"}],"name":"ValidatorDeposit","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEPOSIT_SIZE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptDefaultAdminTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes","name":"pubKey","type":"bytes"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"bytes32","name":"depositDataRoot","type":"bytes32"},{"internalType":"address","name":"receiver","type":"address"}],"internalType":"struct DataTypes.Validator[]","name":"_validators","type":"tuple[]"}],"name":"addInitializedValidators","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"autoPxEth","outputs":[{"internalType":"contract AutoPxEth","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"batchId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"batchIdToValidator","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"beaconChainDepositContract","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newAdmin","type":"address"}],"name":"beginDefaultAdminTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"buffer","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"_amounts","type":"uint256[]"},{"internalType":"address","name":"_receiver","type":"address"}],"name":"bulkRedeemWithUpxEth","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"burnerAccounts","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cancelDefaultAdminTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint48","name":"newDelay","type":"uint48"}],"name":"changeDefaultAdminDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"clearInitializedValidator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"defaultAdmin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultAdminDelay","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultAdminDelayIncreaseWait","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"bool","name":"shouldCompound","type":"bool"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"postFeeAmount","type":"uint256"},{"internalType":"uint256","name":"feeAmount","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"depositEtherPaused","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"depositPrivileged","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"_pubKey","type":"bytes"}],"name":"dissolveValidator","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"emergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"endBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"enum DataTypes.Fees","name":"","type":"uint8"}],"name":"fees","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_i","type":"uint256"}],"name":"getInitializedValidatorAt","outputs":[{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getInitializedValidatorCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_i","type":"uint256"}],"name":"getStakingValidatorAt","outputs":[{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStakingValidatorCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_endBlock","type":"uint256"}],"name":"harvest","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_assets","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"bool","name":"_shouldTriggerValidatorExit","type":"bool"}],"name":"initiateRedemption","outputs":[{"internalType":"uint256","name":"postFeeAmount","type":"uint256"},{"internalType":"uint256","name":"feeAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_assets","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"}],"name":"instantRedeemWithPxEth","outputs":[{"internalType":"uint256","name":"postFeeAmount","type":"uint256"},{"internalType":"uint256","name":"feeAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maxBufferSize","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxBufferSizePct","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"enum DataTypes.Fees","name":"","type":"uint8"}],"name":"maxFees","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxProcessedValidatorCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oracleAdapter","outputs":[{"internalType":"contract IOracleAdapter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"outstandingRedemptions","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingDefaultAdmin","outputs":[{"internalType":"address","name":"newAdmin","type":"address"},{"internalType":"uint48","name":"schedule","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingDefaultAdminDelay","outputs":[{"internalType":"uint48","name":"newDelay","type":"uint48"},{"internalType":"uint48","name":"schedule","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingWithdrawal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pirexFees","outputs":[{"internalType":"contract IPirexFees","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_times","type":"uint256"}],"name":"popInitializedValidator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"preDepositAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pxEth","outputs":[{"internalType":"contract PxEth","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_assets","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"}],"name":"redeemWithUpxEth","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"_pubKey","type":"bytes"},{"internalType":"uint256","name":"_removeIndex","type":"uint256"},{"internalType":"bool","name":"_unordered","type":"bool"}],"name":"removeInitializedValidator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardRecipient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rollbackDefaultAdminDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum DataTypes.Contract","name":"_contract","type":"uint8"},{"internalType":"address","name":"contractAddress","type":"address"}],"name":"setContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum DataTypes.Fees","name":"f","type":"uint8"},{"internalType":"uint32","name":"fee","type":"uint32"}],"name":"setFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pct","type":"uint256"}],"name":"setMaxBufferSizePct","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum DataTypes.Fees","name":"f","type":"uint8"},{"internalType":"uint32","name":"maxFee","type":"uint32"}],"name":"setMaxFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_count","type":"uint256"}],"name":"setMaxProcessedValidatorCount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"_pubKey","type":"bytes"},{"internalType":"uint256","name":"_removeIndex","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bool","name":"_unordered","type":"bool"},{"internalType":"bool","name":"_useBuffer","type":"bool"},{"components":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct DataTypes.BurnerAccount[]","name":"_burnerAccounts","type":"tuple[]"}],"name":"slashValidator","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"status","outputs":[{"internalType":"enum DataTypes.ValidatorStatus","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_fromIndex","type":"uint256"},{"internalType":"uint256","name":"_toIndex","type":"uint256"}],"name":"swapInitializedValidator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_accounts","type":"address[]"},{"internalType":"bool","name":"_state","type":"bool"}],"name":"toggleBurnerAccounts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"togglePauseDepositEther","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"togglePauseState","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"_pubKey","type":"bytes"},{"internalType":"bytes","name":"_signature","type":"bytes"},{"internalType":"bytes32","name":"_depositDataRoot","type":"bytes32"},{"internalType":"uint256","name":"_topUpAmount","type":"uint256"},{"internalType":"bool","name":"_useBuffer","type":"bool"},{"components":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct DataTypes.BurnerAccount[]","name":"_burnerAccounts","type":"tuple[]"}],"name":"topUpStake","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"upxEth","outputs":[{"internalType":"contract UpxEth","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdrawalCredentials","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"}]

610100604052600160005560146008553480156200001c57600080fd5b50604051620061e3380380620061e38339810160408190526200003f916200044d565b8787878787878680866001600160a01b038116620000a45760405162461bcd60e51b815260206004820152601e60248201527f416363657373436f6e74726f6c3a20302064656661756c742061646d696e000060448201526064015b60405180910390fd5b600280546001600160d01b0316600160d01b65ffffffffffff851602179055620000d0600082620002f4565b50506001600160a01b038716620000fa5760405163d92e233d60e01b815260040160405180910390fd5b6001600160a01b038516620001225760405163d92e233d60e01b815260040160405180910390fd5b6001600160a01b0384166200014a5760405163d92e233d60e01b815260040160405180910390fd5b670de0b6b3a7640000831080156200017057506200016d633b9aca0084620004f1565b15155b156200018f576040516303373dc760e61b815260040160405180910390fd5b82821180620001a55750670de0b6b3a764000082105b80620001bf5750620001bc633b9aca0083620004f1565b15155b15620001de576040516303373dc760e61b815260040160405180910390fd5b50600a80546001600160a01b03199081166001600160a01b039889161790915560c09290925292851660805260a09290925260098054909216908416179055506001600e558216620002435760405163d92e233d60e01b815260040160405180910390fd5b506001600160a01b031660e0525050601b60205250507f584f46c60af19681376031579adb04a2416e54ee5505351c2a8435e3766026ea805462030d4063ffffffff1991821681179092557f9fafca4c9c0d5c2cbf85f49fd8ab8212430ce78c2a0cb75b51e0f9c4f9ace003805482168317905560026000527f1dd2f4b94a51cfb409e6e317a497f7cfd9013960a1c723f830c49c05a25f08a58054909116909117905550506001601d5562000514565b81620003985760006200030f6003546001600160a01b031690565b6001600160a01b0316146200037c5760405162461bcd60e51b815260206004820152602c60248201527f416363657373436f6e74726f6c3a2064656661756c742061646d696e20616c7260448201526b1958591e4819dc985b9d195960a21b60648201526084016200009b565b600380546001600160a01b0319166001600160a01b0383161790555b620003a48282620003a8565b5050565b60008281526001602090815260408083206001600160a01b038516845290915290205460ff16620003a45760008281526001602081815260408084206001600160a01b0386168086529252808420805460ff19169093179092559051339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b80516001600160a01b03811681146200044857600080fd5b919050565b600080600080600080600080610100898b0312156200046b57600080fd5b620004768962000430565b97506200048660208a0162000430565b96506200049660408a0162000430565b9550620004a660608a0162000430565b94506080890151935060a08901519250620004c460c08a0162000430565b915060e089015165ffffffffffff81168114620004e057600080fd5b809150509295985092959890939650565b6000826200050f57634e487b7160e01b600052601260045260246000fd5b500690565b60805160a05160c05160e051615c17620005cc60003960008181610b1a01528181611788015281816117fc0152818161281901528181612a190152612a8d0152600081816106c301528181611663015281816118b701528181611c8e01528181611f4f015281816139320152818161396f01528181613aa70152613c9c015260008181610cd701528181613c7b01528181613f260152613f500152600081816109cd0152818161110e0152613e450152615c176000f3fe60806040526004361061041a5760003560e01c80638b4d434b1161021e578063bebaeabe11610123578063d602b9fd116100ab578063eb2b01c31161007a578063eb2b01c314610cc5578063edaafe2014610cf9578063f64c6f3214610d0f578063f7a1f5ff14610d25578063fe196cf814610d3b57600080fd5b8063d602b9fd14610c5d578063d65ea23214610c72578063ddc6326214610c92578063e63ea40814610ca557600080fd5b8063cc8463c8116100f2578063cc8463c814610bc2578063cefc142914610bd7578063cf6eefb714610bec578063d547741f14610c27578063d58ac11f14610c4757600080fd5b8063bebaeabe14610b3c578063c34d97d114610b5c578063c8ad10fb14610b8c578063ca72be2914610ba257600080fd5b8063a62277f0116101a6578063b4a2656911610175578063b4a2656914610a8a578063b5e5e64c14610aaa578063babd37eb14610abf578063bb807e7514610af2578063bc8a72b614610b0857600080fd5b8063a62277f0146109ef578063ad45517d14610a0f578063adc9740c14610a57578063b09c18d714610a6a57600080fd5b806391d14854116101ed57806391d14854146109325780639a82c61514610952578063a1eda53c14610972578063a217fddf146109a6578063a5eb31bf146109bb57600080fd5b80638b4d434b146108bd5780638bdd9beb146108dd5780638da5cb5b146108fd57806390abccf41461091257600080fd5b806336568abe116103245780635c975abb116102ac5780636b4f0b771161027b5780636b4f0b77146108365780637e28882214610849578063842d96f31461085f57806384ef8ffc1461087f578063865e6fd31461089d57600080fd5b80635c975abb146107cb5780635fb8bc56146107e1578063634e93da146107f6578063649a5ec71461081657600080fd5b80634573e3b3116102f35780634573e3b31461073a57806348b6ce5e1461074d5780634972134a146107625780634cd79e0a146107785780634df8a5e71461079a57600080fd5b806336568abe1461069157806336bf3325146106b15780633d9f3163146106e55780633faae3441461070557600080fd5b806310f4686b116103a757806326d976191161037657806326d97619146105d45780632da2c826146105f45780632f2ff15d1461060957806331f50da914610629578063357c13541461064957600080fd5b806310f4686b1461053557806317f3334014610555578063206583ac1461058d578063248a9ca3146105a357600080fd5b806305c9399c116103ee57806305c9399c146104b7578063083c6323146104d75780630aa6220b146104ed5780630dcb8c1a1461050257806310cf3f851461052257600080fd5b80628803d31461041f5780630154cd981461043657806301ffc9a71461045e578063022d63fb1461048e575b600080fd5b34801561042b57600080fd5b50610434610d5b565b005b34801561044257600080fd5b5061044b610dca565b6040519081526020015b60405180910390f35b34801561046a57600080fd5b5061047e6104793660046149f5565b610e46565b6040519015158152602001610455565b34801561049a57600080fd5b50620697805b60405165ffffffffffff9091168152602001610455565b3480156104c357600080fd5b506104346104d2366004614a33565b610e71565b3480156104e357600080fd5b5061044b60175481565b3480156104f957600080fd5b50610434610f90565b34801561050e57600080fd5b5061043461051d366004614a88565b610fa6565b610434610530366004614b5d565b61100e565b34801561054157600080fd5b50610434610550366004614d0a565b61122a565b34801561056157600080fd5b50600d54610575906001600160a01b031681565b6040516001600160a01b039091168152602001610455565b34801561059957600080fd5b5061044b600e5481565b3480156105af57600080fd5b5061044b6105be366004614e47565b6000908152600160208190526040909120015490565b3480156105e057600080fd5b50600a54610575906001600160a01b031681565b34801561060057600080fd5b5061044b61137c565b34801561061557600080fd5b50610434610624366004614e60565b6113b6565b34801561063557600080fd5b50600b54610575906001600160a01b031681565b34801561065557600080fd5b5061067c610664366004614e85565b601c6020526000908152604090205463ffffffff1681565b60405163ffffffff9091168152602001610455565b34801561069d57600080fd5b506104346106ac366004614e60565b611430565b3480156106bd57600080fd5b5061044b7f000000000000000000000000000000000000000000000000000000000000000081565b3480156106f157600080fd5b50600c54610575906001600160a01b031681565b34801561071157600080fd5b50610725610720366004614ea0565b61151a565b60408051928352602083019190915201610455565b610434610748366004614ede565b611889565b34801561075957600080fd5b506104346119e3565b34801561076e57600080fd5b5061044b60165481565b34801561078457600080fd5b5061078d611a84565b6040516104559190614f6f565b3480156107a657600080fd5b506107ba6107b5366004614e47565b611b12565b604051610455959493929190614f82565b3480156107d757600080fd5b5061044b601d5481565b3480156107ed57600080fd5b50610434611bb0565b34801561080257600080fd5b50610434610811366004614fde565b611c34565b34801561082257600080fd5b50610434610831366004614ffb565b611c48565b610434610844366004615023565b611c5c565b34801561085557600080fd5b5061044b60145481565b34801561086b57600080fd5b5061043461087a366004614e47565b611f99565b34801561088b57600080fd5b506003546001600160a01b0316610575565b3480156108a957600080fd5b506104346108b83660046150c9565b612058565b3480156108c957600080fd5b506104346108d836600461513f565b6122d4565b3480156108e957600080fd5b50600954610575906001600160a01b031681565b34801561090957600080fd5b506105756123d0565b34801561091e57600080fd5b5061043461092d366004615189565b6123e4565b34801561093e57600080fd5b5061047e61094d366004614e60565b612495565b34801561095e57600080fd5b506107ba61096d366004614e47565b6124c0565b34801561097e57600080fd5b50610987612507565b6040805165ffffffffffff938416815292909116602083015201610455565b3480156109b257600080fd5b5061044b600081565b3480156109c757600080fd5b506105757f000000000000000000000000000000000000000000000000000000000000000081565b3480156109fb57600080fd5b50610434610a0a3660046151ab565b61255b565b348015610a1b57600080fd5b50610a4a610a2a366004615207565b805160208183018101805160188252928201919093012091525460ff1681565b6040516104559190615259565b610725610a65366004615281565b6126d3565b348015610a7657600080fd5b50610434610a85366004614e47565b6128a7565b348015610a9657600080fd5b50610725610aa5366004614e60565b612920565b348015610ab657600080fd5b50610434612bd2565b348015610acb57600080fd5b5061067c610ada366004614e85565b601b6020526000908152604090205463ffffffff1681565b348015610afe57600080fd5b5061044b60075481565b348015610b1457600080fd5b506105757f000000000000000000000000000000000000000000000000000000000000000081565b348015610b4857600080fd5b50610434610b573660046152b6565b612c33565b348015610b6857600080fd5b5061047e610b77366004614fde565b601a6020526000908152604090205460ff1681565b348015610b9857600080fd5b5061044b60065481565b348015610bae57600080fd5b50610434610bbd366004614e47565b612d28565b348015610bce57600080fd5b506104a0612d96565b348015610be357600080fd5b50610434612df5565b348015610bf857600080fd5b50610c01612e73565b604080516001600160a01b03909316835265ffffffffffff909116602083015201610455565b348015610c3357600080fd5b50610434610c42366004614e60565b612e94565b348015610c5357600080fd5b5061044b60085481565b348015610c6957600080fd5b50610434612f11565b348015610c7e57600080fd5b50610434610c8d366004614a33565b612f24565b610434610ca0366004614e47565b61304d565b348015610cb157600080fd5b50610434610cc0366004615339565b613140565b348015610cd157600080fd5b5061044b7f000000000000000000000000000000000000000000000000000000000000000081565b348015610d0557600080fd5b5061044b60055481565b348015610d1b57600080fd5b5061044b600f5481565b348015610d3157600080fd5b5061044b60155481565b348015610d4757600080fd5b5061078d610d56366004614e47565b613312565b600080516020615bc2833981519152610d738161332b565b6002601d5414610d84576002610d87565b60015b601d8190556040805133815260208101929092527f2d9e22b609aa013375d7aa3ea850989ca303c2abf9fc24c5f45975e1e3753a9191015b60405180910390a150565b6040516284499160e81b815260106004820152600090739e0d7d79735e1c63333128149c7b616a0dc0bbdb906384499100906024015b602060405180830381865af4158015610e1d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e41919061537a565b905090565b60006001600160e01b031982166318a4c3c360e11b1480610e6b5750610e6b82613335565b92915050565b600080516020615bc2833981519152610e898161332b565b601b6000846002811115610e9f57610e9f615243565b6002811115610eb057610eb0615243565b815260208101919091526040016000205463ffffffff9081169083161115610eeb576040516358d620b360e01b815260040160405180910390fd5b81601c6000856002811115610f0257610f02615243565b6002811115610f1357610f13615243565b815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff160217905550826002811115610f5157610f51615243565b60405163ffffffff841681527f60cca38ba894e5ddc4db50e39d1e729d5ae76ddbd3874395ead72add5125bc0f906020015b60405180910390a2505050565b6000610f9b8161332b565b610fa361336a565b50565b6002601d5403610fc9576040516313d0ff5960e31b815260040160405180910390fd5b600054600114610ff45760405162461bcd60e51b8152600401610feb90615393565b60405180910390fd5b6002600055611004838383613377565b5050600160005550565b6000546001146110305760405162461bcd60e51b8152600401610feb90615393565b60026000557ffc8737ab85eb45125971625a9ebdb75cc78e01d5c1fa80c4c6e5203f47bc4fab61105f8161332b565b600160188b8b6040516110739291906153b7565b9081526040519081900360200190205460ff16600481111561109757611097615243565b146110b55760405163fbce7d8f60e01b815260040160405180910390fd5b83156110ea5734156110da5760405163a64d921760e01b815260040160405180910390fd5b6110e5858484613596565b61110a565b84341461110a5760405163b66458d760e01b815260040160405180910390fd5b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316868c8c60048d8d8d604051602401611153969594939291906154a7565b60408051601f198184030181529181526020820180516001600160e01b03166304512a2360e31b1790525161118891906154f6565b60006040518083038185875af1925050503d80600081146111c5576040519150601f19603f3d011682016040523d82523d6000602084013e6111ca565b606091505b50509050806111db576111db615512565b7fd46a7d25717262ee24042f45e4cc24e830907282b10be8c30177e24aab5e55be8b8b87896040516112109493929190615528565b60405180910390a150506001600055505050505050505050565b6001600e540361124d57604051638a4560db60e01b815260040160405180910390fd5b600080516020615bc28339815191526112658161332b565b815160005b8181101561137657600060188583815181106112885761128861554f565b6020026020010151600001516040516112a191906154f6565b9081526040519081900360200190205460ff1660048111156112c5576112c5615243565b146112e3576040516348921c7b60e11b815260040160405180910390fd5b6010739e0d7d79735e1c63333128149c7b616a0dc0bbdb6376f5c13990918684815181106113135761131361554f565b602002602001015160046040518463ffffffff1660e01b815260040161133b939291906155bc565b60006040518083038186803b15801561135357600080fd5b505af4158015611367573d6000803e3d6000fd5b5050505080600101905061126a565b50505050565b6040516284499160e81b815260126004820152600090739e0d7d79735e1c63333128149c7b616a0dc0bbdb90638449910090602401610e00565b816114225760405162461bcd60e51b815260206004820152603660248201527f416363657373436f6e74726f6c3a2063616e2774206469726563746c79206772604482015275616e742064656661756c742061646d696e20726f6c6560501b6064820152608401610feb565b61142c82826136d7565b5050565b8115801561144b57506003546001600160a01b038281169116145b156115105760008061145b612e73565b90925090506001600160a01b03821615801561147e575065ffffffffffff811615155b801561149157504265ffffffffffff8216105b6114fb5760405162461bcd60e51b815260206004820152603560248201527f416363657373436f6e74726f6c3a206f6e6c792063616e2072656e6f756e636560448201527420696e2074776f2064656c6179656420737465707360581b6064820152608401610feb565b50506002805465ffffffffffff60a01b191690555b61142c82826136fd565b6000806002601d5403611540576040516313d0ff5960e31b815260040160405180910390fd5b6000546001146115625760405162461bcd60e51b8152600401610feb90615393565b6002600090815585900361158957604051631f2a200560e01b815260040160405180910390fd5b6001600160a01b0384166115b05760405163d92e233d60e01b815260040160405180910390fd5b600b546000906001600160a01b0316330361164857600b54604051635d043b2960e11b815260048101889052306024820181905260448201526001600160a01b039091169063ba087652906064016020604051808303816000875af115801561161d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611641919061537a565b905061164b565b50845b611656600182613777565b60145491945092506000907f00000000000000000000000000000000000000000000000000000000000000009061168e908690615607565b611698919061561a565b90508480156116a5575080155b156116c357604051635fa4c85d60e01b815260040160405180910390fd5b6116cb61137c565b8111156116eb576040516315caeb5160e31b815260040160405180910390fd5b60408051838152602081018690526001600160a01b038816917fa126fc6d7777e110f6fc53f11f34b4695af73524f2b2f5585dc81b4e148733f2910160405180910390a2600b546000906001600160a01b0316331461174a573361174c565b305b905061175881866137e5565b831561186c57600a54604051630c29702960e01b81526001600160a01b0390911690630c297029906117b29084907f000000000000000000000000000000000000000000000000000000000000000090899060040161563c565b600060405180830381600087803b1580156117cc57600080fd5b505af11580156117e0573d6000803e3d6000fd5b5050600a54604051631e75e2a960e11b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081169450633cebc5529350611839928692911690899060040161563c565b600060405180830381600087803b15801561185357600080fd5b505af1158015611867573d6000803e3d6000fd5b505050505b611877858888613918565b50506001600055509094909350915050565b600d546001600160a01b031633146118b45760405163b5674cfd60e01b815260040160405180910390fd5b347f000000000000000000000000000000000000000000000000000000000000000081146118f55760405163162908e360e11b815260040160405180910390fd5b6002601884846040516119099291906153b7565b9081526040519081900360200190205460ff16600481111561192d5761192d615243565b1461194b576040516328c5214b60e01b815260040160405180910390fd5b60036018848460405161195f9291906153b7565b908152604051908190036020019020805460ff1916600183600481111561198857611988615243565b0217905550806015600082825461199f9190615607565b90915550506040517f4697c5b19666f0fa70dd3d4b8b68758069307e15f2dff52de0708f9ab0eacaff906119d69085908590615660565b60405180910390a1505050565b6001600e5403611a0657604051638a4560db60e01b815260040160405180910390fd5b600080516020615bc2833981519152611a1e8161332b565b604051631e9708a560e31b815260106004820152739e0d7d79735e1c63333128149c7b616a0dc0bbdb9063f4b845289060240160006040518083038186803b158015611a6957600080fd5b505af4158015611a7d573d6000803e3d6000fd5b5050505050565b60048054611a91906153f0565b80601f0160208091040260200160405190810160405280929190818152602001828054611abd906153f0565b8015611b0a5780601f10611adf57610100808354040283529160200191611b0a565b820191906000526020600020905b815481529060010190602001808311611aed57829003601f168201915b505050505081565b60608060606000806010739e0d7d79735e1c63333128149c7b616a0dc0bbdb6388d5ab9290916004896040518463ffffffff1660e01b8152600401611b5993929190615674565b600060405180830381865af4158015611b76573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611b9e91908101906156e2565b939a9299509097509550909350915050565b600054600114611bd25760405162461bcd60e51b8152600401610feb90615393565b60026000557ffc8737ab85eb45125971625a9ebdb75cc78e01d5c1fa80c4c6e5203f47bc4fab611c018161332b565b6002600e5403611c24576040516378b5fe1360e01b815260040160405180910390fd5b611c2c613c71565b506001600055565b6000611c3f8161332b565b61142c8261408f565b6000611c538161332b565b61142c82614102565b600d546001600160a01b03163314611c875760405163b5674cfd60e01b815260040160405180910390fd5b60405134907f000000000000000000000000000000000000000000000000000000000000000090600090601890611cc1908d908d906153b7565b9081526040519081900360200190205460ff1690506001816004811115611cea57611cea615243565b14158015611d0a57506002816004811115611d0757611d07615243565b14155b15611d28576040516321f03be760e21b815260040160405180910390fd5b8515611d4757611d42611d3b848461577a565b8686613596565b611d67565b818314611d675760405163162908e360e11b815260040160405180910390fd5b6001816004811115611d7b57611d7b615243565b03611eca57606087611e0d57604051635442791360e01b815260126004820152602481018b9052739e0d7d79735e1c63333128149c7b616a0dc0bbdb90635442791390604401600060405180830381865af4158015611dde573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611e06919081019061578d565b9050611e8f565b60405163176d231d60e21b815260126004820152602481018b9052739e0d7d79735e1c63333128149c7b616a0dc0bbdb90635db48c7490604401600060405180830381865af4158015611e64573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611e8c919081019061578d565b90505b80516020820120604051611ea6908e908e906153b7565b604051809103902014611ebb57611ebb615512565b611ec48361416b565b50611ee2565b8160156000828254611edc9190615607565b90915550505b600460188c8c604051611ef69291906153b7565b908152604051908190036020019020805460ff19166001836004811115611f1f57611f1f615243565b02179055507f38dfdd34943d912ef1591f414fa0fd6acbd0ef9b5b6d071908764e7da03c80b68b8b888b611f73817f000000000000000000000000000000000000000000000000000000000000000061577a565b604051611f849594939291906157c1565b60405180910390a15050505050505050505050565b6001600e5403611fbc57604051638a4560db60e01b815260040160405180910390fd5b600080516020615bc2833981519152611fd48161332b565b60405163f3c723c760e01b81526010600482015260248101839052739e0d7d79735e1c63333128149c7b616a0dc0bbdb9063f3c723c790604401600060405180830381865af415801561202b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261205391908101906157f2565b505050565b600080516020615bc28339815191526120708161332b565b6001600160a01b0382166120975760405163d92e233d60e01b815260040160405180910390fd5b8260058111156120a9576120a9615243565b6040516001600160a01b03841681527e0961cd4320f350803f764de4992b70c8fc5c948b5881a151f883df0af333579060200160405180910390a260018360058111156120f8576120f8615243565b0361211f57600980546001600160a01b0384166001600160a01b0319909116179055505050565b600083600581111561213357612133615243565b0361215a57600a80546001600160a01b0384166001600160a01b0319909116179055505050565b600283600581111561216e5761216e615243565b036121cf57600a54600b546001600160a01b03918216911680156121a1576121a16001600160a01b038316826000614205565b600b80546001600160a01b0319166001600160a01b03868116918217909255611a7d91841690600019614205565b60038360058111156121e3576121e3615243565b0361220a57600c80546001600160a01b0384166001600160a01b0319909116179055505050565b600583600581111561221e5761221e615243565b036122bb57600d80546001600160a01b0319166001600160a01b03841617905560408051600160f81b6020820152600060218201526bffffffffffffffffffffffff19606085901b16602c820152016040516020818303038152906040526004908161228a91906158e9565b507f8f746a1079cc65ea9cd881479b0267d00dc3dceebfa5d13c9beb36863a8741bc60046040516119d691906159a8565b60405163dca3e0e560e01b815260040160405180910390fd5b600080516020615bc28339815191526122ec8161332b565b8260005b818110156123c857600086868381811061230c5761230c61554f565b90506020020160208101906123219190614fde565b6001600160a01b0381166000908152601a60205260409020805460ff1916871580159190911790915590915061238a576040516001600160a01b038216907f0cf877f176d079d5bfa8093032c2b7c02bebde4c25b92a30f796e60f8f3919a090600090a26123bf565b6040516001600160a01b038216907f40bad7be9dd2ade74f56f2ebe2ffe63101f45fea53b5b3309cf7c789c690514590600090a25b506001016122f0565b505050505050565b6000610e416003546001600160a01b031690565b6001600e540361240757604051638a4560db60e01b815260040160405180910390fd5b600080516020615bc283398151915261241f8161332b565b6040516304ab817f60e01b8152601060048201526024810184905260448101839052739e0d7d79735e1c63333128149c7b616a0dc0bbdb906304ab817f9060640160006040518083038186803b15801561247857600080fd5b505af415801561248c573d6000803e3d6000fd5b50505050505050565b60009182526001602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60608060606000806012739e0d7d79735e1c63333128149c7b616a0dc0bbdb6388d5ab9290916004896040518463ffffffff1660e01b8152600401611b5993929190615674565b600354600090600160d01b900465ffffffffffff16801515801561253357504265ffffffffffff821610155b61253f57600080612553565b600354600160a01b900465ffffffffffff16815b915091509091565b6001600e540361257e57604051638a4560db60e01b815260040160405180910390fd5b600080516020615bc28339815191526125968161332b565b606082156126245760405163176d231d60e21b81526010600482015260248101859052739e0d7d79735e1c63333128149c7b616a0dc0bbdb90635db48c7490604401600060405180830381865af41580156125f5573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261261d919081019061578d565b90506126a6565b604051635442791360e01b81526010600482015260248101859052739e0d7d79735e1c63333128149c7b616a0dc0bbdb90635442791390604401600060405180830381865af415801561267b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526126a3919081019061578d565b90505b85856040516126b69291906153b7565b60405180910390208180519060200120146123c8576123c8615512565b6000806002601d54036126f9576040516313d0ff5960e31b815260040160405180910390fd5b60005460011461271b5760405162461bcd60e51b8152600401610feb90615393565b6002600090815534900361274257604051631f2a200560e01b815260040160405180910390fd5b6001600160a01b0384166127695760405163d92e233d60e01b815260040160405180910390fd5b612774600034613777565b909250905061278f836127875784612789565b305b8361427c565b821561280e57600b54604051636e553f6560e01b8152600481018490526001600160a01b03868116602483015290911690636e553f65906044016020604051808303816000875af11580156127e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061280c919061537a565b505b801561283e5761283e7f00000000000000000000000000000000000000000000000000000000000000008261427c565b6128473461416b565b6040805134815260208101849052908101829052831515906001600160a01b0386169033907f53688f4835c0a3d757a2c2fb4f73147d7fb253f5d5ca9f0b420e6831704c74bd9060600160405180910390a4600160005590939092509050565b600080516020615bc28339815191526128bf8161332b565b620f42408211156128e3576040516395e28b8560e01b815260040160405180910390fd5b60078290556040518281527f60e884e0954bf3325b419fc0af3a6a75091d749f3a2af01d8657bb94ffc4beff906020015b60405180910390a15050565b6000806002601d5403612946576040516313d0ff5960e31b815260040160405180910390fd5b6000546001146129685760405162461bcd60e51b8152600401610feb90615393565b6002600090815584900361298f57604051631f2a200560e01b815260040160405180910390fd5b6001600160a01b0383166129b65760405163d92e233d60e01b815260040160405180910390fd5b6129c1600285613777565b60055491935091508211156129e95760405163664f459f60e11b815260040160405180910390fd5b8015612afd57600a54604051630c29702960e01b81526001600160a01b0390911690630c29702990612a439033907f000000000000000000000000000000000000000000000000000000000000000090869060040161563c565b600060405180830381600087803b158015612a5d57600080fd5b505af1158015612a71573d6000803e3d6000fd5b5050600a54604051631e75e2a960e11b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081169450633cebc5529350612aca923392911690869060040161563c565b600060405180830381600087803b158015612ae457600080fd5b505af1158015612af8573d6000803e3d6000fd5b505050505b612b0733836137e5565b8160056000828254612b19919061577a565b90915550506040516000906001600160a01b0385169084908381818185875af1925050503d8060008114612b69576040519150601f19603f3d011682016040523d82523d6000602084013e612b6e565b606091505b5050905080612b7f57612b7f615512565b60408051868152602081018590526001600160a01b038616917fef65d72849d1cca64b0040a01907b1f330f86a9d3e01856ce6bd55cdb8a16e0c910160405180910390a250600160005590939092509050565b600080516020615bc2833981519152612bea8161332b565b6001600e5414612bfb576001612bfe565b60025b600e8190556040519081527f66397ea162e103ec543314596384be5631955c423f5e2ca581e800e9592b608190602001610dbf565b6002601d5403612c56576040516313d0ff5960e31b815260040160405180910390fd5b600054600114612c785760405162461bcd60e51b8152600401610feb90615393565b6002600090815584908390829003612ca35760405163521299a960e01b815260040160405180910390fd5b808214612cc357604051632b477e7160e11b815260040160405180910390fd5b60005b82811015612d1957612d09888883818110612ce357612ce361554f565b90506020020135878784818110612cfc57612cfc61554f565b9050602002013586613377565b612d12816159bb565b9050612cc6565b50506001600055505050505050565b600080516020615bc2833981519152612d408161332b565b81600003612d61576040516375463e0d60e01b815260040160405180910390fd5b60088290556040518281527f52880fce23cacdff91c59389d5388b972e58527b17524a84addefcfea80ce9a190602001612914565b600354600090600160d01b900465ffffffffffff168015158015612dc157504265ffffffffffff8216105b612ddc57600254600160d01b900465ffffffffffff16612def565b600354600160a01b900465ffffffffffff165b91505090565b6000612dff612e73565b509050336001600160a01b03821614612e6b5760405162461bcd60e51b815260206004820152602860248201527f416363657373436f6e74726f6c3a2070656e64696e672061646d696e206d75736044820152671d081858d8d95c1d60c21b6064820152608401610feb565b610fa36142b5565b6002546001600160a01b03811691600160a01b90910465ffffffffffff1690565b81612f075760405162461bcd60e51b815260206004820152603760248201527f416363657373436f6e74726f6c3a2063616e2774206469726563746c7920726560448201527f766f6b652064656661756c742061646d696e20726f6c650000000000000000006064820152608401610feb565b61142c8282614380565b6000612f1c8161332b565b610fa36143a6565b600080516020615bc2833981519152612f3c8161332b565b601c6000846002811115612f5257612f52615243565b6002811115612f6357612f63615243565b815260208101919091526040016000205463ffffffff9081169083161080612f935750620f42408263ffffffff16115b15612fb15760405163a51d0c8160e01b815260040160405180910390fd5b81601b6000856002811115612fc857612fc8615243565b6002811115612fd957612fd9615243565b815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff16021790555082600281111561301757613017615243565b60405163ffffffff841681527f2c8a1b11f988520b010608bf85a9a26038b520fdad549d3b58433a5ca5fba15190602001610f83565b600d546001600160a01b031633146130785760405163b5674cfd60e01b815260040160405180910390fd5b3415610fa3576017819055600b54613099906001600160a01b03163461427c565b600b60009054906101000a90046001600160a01b03166001600160a01b0316630c51dde46040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156130e957600080fd5b505af11580156130fd573d6000803e3d6000fd5b5050505061310a3461416b565b60408051348152602081018390527f6c8433a8e155f0af04dba058d4e4695f7da554578963d876bdf4a6d8d6399d9c9101610dbf565b600080516020615bc28339815191526131588161332b565b6001600e540361317b57604051638a4560db60e01b815260040160405180910390fd5b6001601d540361319e57604051636cd6020160e01b815260040160405180910390fd5b6001600160a01b0384166131c55760405163d92e233d60e01b815260040160405180910390fd5b816000036131e657604051631f2a200560e01b815260040160405180910390fd5b600a546001600160a01b03908116908416036132155760405163c1ab6dc160e01b815260040160405180910390fd5b6001600160a01b0383166132ab57600061322f834761577a565b905080600f54111561324157600f8190555b6000856001600160a01b03168460405160006040518083038185875af1925050503d806000811461328e576040519150601f19603f3d011682016040523d82523d6000602084013e613293565b606091505b50509050806132a4576132a4615512565b50506132bf565b6132bf6001600160a01b03841685846143b1565b826001600160a01b0316846001600160a01b03167f9495d03190a79a43e534c9e328ff322f6283261383f5f19c809564f6ad5a57b38460405161330491815260200190565b60405180910390a350505050565b60196020526000908152604090208054611a91906153f0565b610fa38133614429565b60006001600160e01b03198216637965db0b60e01b1480610e6b57506301ffc9a760e01b6001600160e01b0319831614610e6b565b613375600080614482565b565b8160000361339857604051631f2a200560e01b815260040160405180910390fd5b6001600160a01b0381166133bf5760405163d92e233d60e01b815260040160405180910390fd5b60008381526019602052604080822090516018916133dc916159d4565b9081526040519081900360200190205460ff169050600381600481111561340557613405615243565b141580156134255750600481600481111561342257613422615243565b14155b15613443576040516314cb5a8b60e01b815260040160405180910390fd5b82601554101561346657604051632c1d501360e11b815260040160405180910390fd5b8260156000828254613478919061577a565b9091555050600954604051637a94c56560e11b815233600482015260248101869052604481018590526001600160a01b039091169063f5298aca90606401600060405180830381600087803b1580156134d057600080fd5b505af11580156134e4573d6000803e3d6000fd5b505050506000826001600160a01b03168460405160006040518083038185875af1925050503d8060008114613535576040519150601f19603f3d011682016040523d82523d6000602084013e61353a565b606091505b505090508061354b5761354b615512565b60408051868152602081018690526001600160a01b038516917fb12ec230ea9bdc2847d084f44c404df9f15811b22a0b58c4f869e1c56e14bf3b910160405180910390a25050505050565b8260055410156135b95760405163664f459f60e11b815260040160405180910390fd5b806000805b828110156136a957601a60008686848181106135dc576135dc61554f565b6135f29260206040909202019081019150614fde565b6001600160a01b0316815260208101919091526040016000205460ff1661362c576040516309e58bbb60e11b815260040160405180910390fd5b84848281811061363e5761363e61554f565b90506040020160200135826136539190615607565b91506136a185858381811061366a5761366a61554f565b6136809260206040909202019081019150614fde565b8686848181106136925761369261554f565b905060400201602001356137e5565b6001016135be565b508481146136b9576136b9615512565b84600560008282546136cb919061577a565b90915550505050505050565b600082815260016020819052604090912001546136f38161332b565b6120538383614542565b6001600160a01b038116331461376d5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610feb565b61142c82826145ec565b600080620f4240601c600086600281111561379457613794615243565b60028111156137a5576137a5615243565b81526020810191909152604001600020546137c69063ffffffff1685615a4a565b6137d0919061561a565b90506137dc818461577a565b91509250929050565b600a54604051632770a7eb60e21b81526001600160a01b0384811660048301526024820184905290911690639dc29fac906044015b600060405180830381600087803b15801561383457600080fd5b505af1158015613848573d6000803e3d6000fd5b505050506000620f4240600754600a60009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156138a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138cc919061537a565b6138d69190615a4a565b6138e0919061561a565b60068190556040518181529091507f8b1dd71841cb6ebc4652591239fb967e36b753ee615f32360a27d22ad66df73f906020016119d6565b826014600082825461392a9190615607565b90915550505b7f000000000000000000000000000000000000000000000000000000000000000060145461395e919061561a565b15613bc657601454600090613993857f0000000000000000000000000000000000000000000000000000000000000000615607565b61399d919061577a565b60095460165460405163731133e960e01b81526001600160a01b0387811660048301526024820192909252604481018490526080606482015260006084820152929350169063731133e99060a401600060405180830381600087803b158015613a0557600080fd5b505af1158015613a19573d6000803e3d6000fd5b505060405163031af78360e21b815260009250739e0d7d79735e1c63333128149c7b616a0dc0bbdb9150630c6bde0c90613a5a906012906004908101615a61565b600060405180830381865af4158015613a77573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052613a9f91908101906156e2565b5050505090507f000000000000000000000000000000000000000000000000000000000000000060146000828254613ad7919061577a565b90915550613ae79050828661577a565b600c54604051631ca9451360e11b81529196506001600160a01b0316906339528a2690613b18908490600401614f6f565b600060405180830381600087803b158015613b3257600080fd5b505af1158015613b46573d6000803e3d6000fd5b5050601680548493506019925060009182613b60836159bb565b9190505581526020019081526020016000209081613b7e91906158e9565b506002601882604051613b9191906154f6565b908152604051908190036020019020805460ff19166001836004811115613bba57613bba615243565b02179055505050613930565b808015613bd35750600083115b15613bf157604051633352735960e11b815260040160405180910390fd5b82156120535760095460165460405163731133e960e01b81526001600160a01b038581166004830152602482019290925260448101869052608060648201526000608482015291169063731133e99060a401600060405180830381600087803b158015613c5d57600080fd5b505af115801561248c573d6000803e3d6000fd5b6008546000613cc07f00000000000000000000000000000000000000000000000000000000000000007f000000000000000000000000000000000000000000000000000000000000000061577a565b90505b6040516284499160e81b815260106004820152739e0d7d79735e1c63333128149c7b616a0dc0bbdb90638449910090602401602060405180830381865af4158015613d12573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d36919061537a565b15801590613d46575080600f5410155b8015613d525750600082115b1561142c5760008060008060006010739e0d7d79735e1c63333128149c7b616a0dc0bbdb630c6bde0c909160046040518363ffffffff1660e01b8152600401613d9c929190615a61565b600060405180830381865af4158015613db9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052613de191908101906156e2565b9398509196509450925090506000601886604051613dff91906154f6565b9081526040519081900360200190205460ff166004811115613e2357613e23615243565b14613e41576040516348921c7b60e11b815260040160405180910390fd5b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168787878787604051602401613e859493929190615a7a565b60408051601f198184030181529181526020820180516001600160e01b03166304512a2360e31b17905251613eba91906154f6565b60006040518083038185875af1925050503d8060008114613ef7576040519150601f19603f3d011682016040523d82523d6000602084013e613efc565b606091505b5050905080613f0d57613f0d615512565b86600f6000828254613f1f919061577a565b90915550507f000000000000000000000000000000000000000000000000000000000000000015613f7457613f74827f000000000000000000000000000000000000000000000000000000000000000061427c565b876001900397506001601887604051613f8d91906154f6565b908152604051908190036020019020805460ff19166001836004811115613fb657613fb6615243565b021790555060408051608081018252878152602081018690528082018590526001600160a01b038416606082015290516376f5c13960e01b8152739e0d7d79735e1c63333128149c7b616a0dc0bbdb916376f5c1399161401d916012918a90600401615ac5565b60006040518083038186803b15801561403557600080fd5b505af4158015614049573d6000803e3d6000fd5b505050507f9990dac99d880d1fcaac485cb74ce1cad6b3fc2eecb7d6550bf6760432b8cdf48660405161407c9190614f6f565b60405180910390a1505050505050613cc3565b6000614099612d96565b6140a242614627565b6140ac9190615af0565b90506140b88282614692565b60405165ffffffffffff821681526001600160a01b038316907f3377dc44241e779dd06afab5b788a35ca5f3b778836e2990bdb26a2a4b2e5ed69060200160405180910390a25050565b600061410d82614711565b61411642614627565b6141209190615af0565b905061412c8282614482565b6040805165ffffffffffff8085168252831660208201527ff1038c18cf84a56e432fdbfaf746924b7ea511dfe03a6506a0ceba4888788d9b9101612914565b60006005546006541161417f57600061418f565b60055460065461418f919061577a565b90508181156141db5780821115806141a757816141a9565b825b600560008282546141ba9190615607565b909155508190506141cb57816141cd565b825b6141d7908361577a565b9150505b80600f60008282546141ed9190615607565b9091555050600e546000190161205357612053613c71565b600060405163095ea7b360e01b8152836004820152826024820152602060006044836000895af13d15601f3d11600160005114161716915050806113765760405162461bcd60e51b815260206004820152600e60248201526d1054141493d59157d1905253115160921b6044820152606401610feb565b600a546040516340c10f1960e01b81526001600160a01b03848116600483015260248201849052909116906340c10f199060440161381a565b6000806142c0612e73565b915091506142d58165ffffffffffff16151590565b80156142e857504265ffffffffffff8216105b6143455760405162461bcd60e51b815260206004820152602860248201527f416363657373436f6e74726f6c3a207472616e736665722064656c6179206e6f6044820152671d081c185cdcd95960c21b6064820152608401610feb565b614361600061435c6003546001600160a01b031690565b6145ec565b61436c600083614542565b5050600280546001600160d01b0319169055565b6000828152600160208190526040909120015461439c8161332b565b61205383836145ec565b613375600080614692565b600060405163a9059cbb60e01b8152836004820152826024820152602060006044836000895af13d15601f3d11600160005114161716915050806113765760405162461bcd60e51b815260206004820152600f60248201526e1514905394d1915497d19052531151608a1b6044820152606401610feb565b6144338282612495565b61142c5761444081614760565b61444b836020614772565b60405160200161445c929190615b16565b60408051601f198184030181529082905262461bcd60e51b8252610feb91600401614f6f565b600354600160d01b900465ffffffffffff168015614505574265ffffffffffff821610156144db57600354600280546001600160d01b0316600160a01b90920465ffffffffffff16600160d01b02919091179055614505565b6040517f2b1fa2edafe6f7b9e97c1a9e0c3660e645beb2dcaa2d45bdbf9beaf5472e1ec590600090a15b50600380546001600160a01b0316600160a01b65ffffffffffff948516026001600160d01b031617600160d01b9290931691909102919091179055565b816145e257600061455b6003546001600160a01b031690565b6001600160a01b0316146145c65760405162461bcd60e51b815260206004820152602c60248201527f416363657373436f6e74726f6c3a2064656661756c742061646d696e20616c7260448201526b1958591e4819dc985b9d195960a21b6064820152608401610feb565b600380546001600160a01b0319166001600160a01b0383161790555b61142c828261490d565b8115801561460757506003546001600160a01b038281169116145b1561461d57600380546001600160a01b03191690555b61142c8282614978565b600065ffffffffffff82111561468e5760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203460448201526538206269747360d01b6064820152608401610feb565b5090565b600061469c612e73565b6002805465ffffffffffff8616600160a01b026001600160d01b03199091166001600160a01b0388161717905591506146de90508165ffffffffffff16151590565b15612053576040517f8886ebfc4259abdbc16601dd8fb5678e54878f47b3c34836cfc51154a960510990600090a1505050565b60008061471c612d96565b90508065ffffffffffff168365ffffffffffff16116147445761473f8382615b8b565b614759565b61475965ffffffffffff8416620697806149df565b9392505050565b6060610e6b6001600160a01b03831660145b60606000614781836002615a4a565b61478c906002615607565b6001600160401b038111156147a3576147a3614c1f565b6040519080825280601f01601f1916602001820160405280156147cd576020820181803683370190505b509050600360fc1b816000815181106147e8576147e861554f565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106148175761481761554f565b60200101906001600160f81b031916908160001a905350600061483b846002615a4a565b614846906001615607565b90505b60018111156148be576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061487a5761487a61554f565b1a60f81b8282815181106148905761489061554f565b60200101906001600160f81b031916908160001a90535060049490941c936148b781615baa565b9050614849565b5083156147595760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610feb565b6149178282612495565b61142c5760008281526001602081815260408084206001600160a01b0386168086529252808420805460ff19169093179092559051339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b6149828282612495565b1561142c5760008281526001602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60008183106149ee5781614759565b5090919050565b600060208284031215614a0757600080fd5b81356001600160e01b03198116811461475957600080fd5b803560038110614a2e57600080fd5b919050565b60008060408385031215614a4657600080fd5b614a4f83614a1f565b9150602083013563ffffffff81168114614a6857600080fd5b809150509250929050565b6001600160a01b0381168114610fa357600080fd5b600080600060608486031215614a9d57600080fd5b83359250602084013591506040840135614ab681614a73565b809150509250925092565b60008083601f840112614ad357600080fd5b5081356001600160401b03811115614aea57600080fd5b602083019150836020828501011115614b0257600080fd5b9250929050565b80358015158114614a2e57600080fd5b60008083601f840112614b2b57600080fd5b5081356001600160401b03811115614b4257600080fd5b6020830191508360208260061b8501011115614b0257600080fd5b600080600080600080600080600060c08a8c031215614b7b57600080fd5b89356001600160401b0380821115614b9257600080fd5b614b9e8d838e01614ac1565b909b50995060208c0135915080821115614bb757600080fd5b614bc38d838e01614ac1565b909950975060408c0135965060608c01359550879150614be560808d01614b09565b945060a08c0135915080821115614bfb57600080fd5b50614c088c828d01614b19565b915080935050809150509295985092959850929598565b634e487b7160e01b600052604160045260246000fd5b604051608081016001600160401b0381118282101715614c5757614c57614c1f565b60405290565b604051601f8201601f191681016001600160401b0381118282101715614c8557614c85614c1f565b604052919050565b60006001600160401b03821115614ca657614ca6614c1f565b50601f01601f191660200190565b600082601f830112614cc557600080fd5b8135614cd8614cd382614c8d565b614c5d565b818152846020838601011115614ced57600080fd5b816020850160208301376000918101602001919091529392505050565b60006020808385031215614d1d57600080fd5b82356001600160401b0380821115614d3457600080fd5b818501915085601f830112614d4857600080fd5b813581811115614d5a57614d5a614c1f565b8060051b614d69858201614c5d565b9182528381018501918581019089841115614d8357600080fd5b86860192505b83831015614e3a57823585811115614da15760008081fd5b86016080818c03601f1901811315614db95760008081fd5b614dc1614c35565b8983013588811115614dd35760008081fd5b614de18e8c83870101614cb4565b82525060408084013589811115614df85760008081fd5b614e068f8d83880101614cb4565b838d015250606084810135828401529383013593614e2385614a73565b820193909352845250509186019190860190614d89565b9998505050505050505050565b600060208284031215614e5957600080fd5b5035919050565b60008060408385031215614e7357600080fd5b823591506020830135614a6881614a73565b600060208284031215614e9757600080fd5b61475982614a1f565b600080600060608486031215614eb557600080fd5b833592506020840135614ec781614a73565b9150614ed560408501614b09565b90509250925092565b60008060208385031215614ef157600080fd5b82356001600160401b03811115614f0757600080fd5b614f1385828601614ac1565b90969095509350505050565b60005b83811015614f3a578181015183820152602001614f22565b50506000910152565b60008151808452614f5b816020860160208601614f1f565b601f01601f19169290920160200192915050565b6020815260006147596020830184614f43565b60a081526000614f9560a0830188614f43565b8281036020840152614fa78188614f43565b90508281036040840152614fbb8187614f43565b606084019590955250506001600160a01b03919091166080909101529392505050565b600060208284031215614ff057600080fd5b813561475981614a73565b60006020828403121561500d57600080fd5b813565ffffffffffff8116811461475957600080fd5b60008060008060008060008060c0898b03121561503f57600080fd5b88356001600160401b038082111561505657600080fd5b6150628c838d01614ac1565b909a50985060208b0135975060408b0135965088915061508460608c01614b09565b955061509260808c01614b09565b945060a08b01359150808211156150a857600080fd5b506150b58b828c01614b19565b999c989b5096995094979396929594505050565b600080604083850312156150dc57600080fd5b8235600681106150eb57600080fd5b91506020830135614a6881614a73565b60008083601f84011261510d57600080fd5b5081356001600160401b0381111561512457600080fd5b6020830191508360208260051b8501011115614b0257600080fd5b60008060006040848603121561515457600080fd5b83356001600160401b0381111561516a57600080fd5b615176868287016150fb565b9094509250614ed5905060208501614b09565b6000806040838503121561519c57600080fd5b50508035926020909101359150565b600080600080606085870312156151c157600080fd5b84356001600160401b038111156151d757600080fd5b6151e387828801614ac1565b909550935050602085013591506151fc60408601614b09565b905092959194509250565b60006020828403121561521957600080fd5b81356001600160401b0381111561522f57600080fd5b61523b84828501614cb4565b949350505050565b634e487b7160e01b600052602160045260246000fd5b602081016005831061527b57634e487b7160e01b600052602160045260246000fd5b91905290565b6000806040838503121561529457600080fd5b823561529f81614a73565b91506152ad60208401614b09565b90509250929050565b6000806000806000606086880312156152ce57600080fd5b85356001600160401b03808211156152e557600080fd5b6152f189838a016150fb565b9097509550602088013591508082111561530a57600080fd5b50615317888289016150fb565b909450925050604086013561532b81614a73565b809150509295509295909350565b60008060006060848603121561534e57600080fd5b833561535981614a73565b9250602084013561536981614a73565b929592945050506040919091013590565b60006020828403121561538c57600080fd5b5051919050565b6020808252600a90820152695245454e5452414e435960b01b604082015260600190565b8183823760009101908152919050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b600181811c9082168061540457607f821691505b60208210810361542457634e487b7160e01b600052602260045260246000fd5b50919050565b60008154615437816153f0565b808552602060018381168015615454576001811461546e5761549c565b60ff1985168884015283151560051b88018301955061549c565b866000528260002060005b858110156154945781548a8201860152908301908401615479565b890184019650505b505050505092915050565b6080815260006154bb60808301888a6153c7565b82810360208401526154cd818861542a565b905082810360408401526154e28186886153c7565b915050826060830152979650505050505050565b60008251615508818460208701614f1f565b9190910192915050565b634e487b7160e01b600052600160045260246000fd5b60608152600061553c6060830186886153c7565b9315156020830152506040015292915050565b634e487b7160e01b600052603260045260246000fd5b600081516080845261557a6080850182614f43565b9050602083015184820360208601526155938282614f43565b604085810151908701526060948501516001600160a01b03169490950193909352509192915050565b8381526060602082015260006155d56060830185615565565b82810360408401526155e7818561542a565b9695505050505050565b634e487b7160e01b600052601160045260246000fd5b80820180821115610e6b57610e6b6155f1565b60008261563757634e487b7160e01b600052601260045260246000fd5b500490565b6001600160a01b039384168152919092166020820152604081019190915260600190565b60208152600061523b6020830184866153c7565b83815260606020820152600061568d606083018561542a565b9050826040830152949350505050565b600082601f8301126156ae57600080fd5b81516156bc614cd382614c8d565b8181528460208386010111156156d157600080fd5b61523b826020830160208701614f1f565b600080600080600060a086880312156156fa57600080fd5b85516001600160401b038082111561571157600080fd5b61571d89838a0161569d565b9650602088015191508082111561573357600080fd5b61573f89838a0161569d565b9550604088015191508082111561575557600080fd5b506157628882890161569d565b93505060608601519150608086015161532b81614a73565b81810381811115610e6b57610e6b6155f1565b60006020828403121561579f57600080fd5b81516001600160401b038111156157b557600080fd5b61523b8482850161569d565b6080815260006157d56080830187896153c7565b941515602083015250604081019290925260609091015292915050565b60006020828403121561580457600080fd5b81516001600160401b038082111561581b57600080fd5b908301906080828603121561582f57600080fd5b615837614c35565b82518281111561584657600080fd5b6158528782860161569d565b82525060208301518281111561586757600080fd5b6158738782860161569d565b602083015250604083015160408201526060830151925061589383614a73565b6060810192909252509392505050565b601f82111561205357600081815260208120601f850160051c810160208610156158ca5750805b601f850160051c820191505b818110156123c8578281556001016158d6565b81516001600160401b0381111561590257615902614c1f565b6159168161591084546153f0565b846158a3565b602080601f83116001811461594b57600084156159335750858301515b600019600386901b1c1916600185901b1785556123c8565b600085815260208120601f198616915b8281101561597a5788860151825594840194600190910190840161595b565b50858210156159985787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b602081526000614759602083018461542a565b6000600182016159cd576159cd6155f1565b5060010190565b60008083546159e2816153f0565b600182811680156159fa5760018114615a0f57615a3e565b60ff1984168752821515830287019450615a3e565b8760005260208060002060005b85811015615a355781548a820152908401908201615a1c565b50505082870194505b50929695505050505050565b8082028115828204841417610e6b57610e6b6155f1565b82815260406020820152600061523b604083018461542a565b608081526000615a8d6080830187614f43565b8281036020840152615a9f8187614f43565b90508281036040840152615ab38186614f43565b91505082606083015295945050505050565b838152606060208201526000615ade6060830185615565565b82810360408401526155e78185614f43565b65ffffffffffff818116838216019080821115615b0f57615b0f6155f1565b5092915050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351615b4e816017850160208801614f1f565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351615b7f816028840160208801614f1f565b01602801949350505050565b65ffffffffffff828116828216039080821115615b0f57615b0f6155f1565b600081615bb957615bb96155f1565b50600019019056fe71840dc4906352362b0cdaf79870196c8e42acafade72d5d5a6d59291253ceb1a2646970667358221220784919cd6d3a2513dfc7d963c8632c35067de96881fb62cec6993f9e7a1ec00b64736f6c6343000813003300000000000000000000000004c154b66cb340f3ae24111cc767e0184ed00cc6000000000000000000000000e8ea8990643a0431e4b28f7f7f6878aab88fe42400000000000000000000000000000000219ab540356cbb839cbe05303d7705fa0000000000000000000000005bf2419a33f82f4c1f075b4006d7fc4104c43868000000000000000000000000000000000000000000000001bc16d674ec8000000000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000177d685384aa1ac5aba41b7e649f9fa0be717fdb0000000000000000000000000000000000000000000000000000000000000000

Deployed Bytecode

0x60806040526004361061041a5760003560e01c80638b4d434b1161021e578063bebaeabe11610123578063d602b9fd116100ab578063eb2b01c31161007a578063eb2b01c314610cc5578063edaafe2014610cf9578063f64c6f3214610d0f578063f7a1f5ff14610d25578063fe196cf814610d3b57600080fd5b8063d602b9fd14610c5d578063d65ea23214610c72578063ddc6326214610c92578063e63ea40814610ca557600080fd5b8063cc8463c8116100f2578063cc8463c814610bc2578063cefc142914610bd7578063cf6eefb714610bec578063d547741f14610c27578063d58ac11f14610c4757600080fd5b8063bebaeabe14610b3c578063c34d97d114610b5c578063c8ad10fb14610b8c578063ca72be2914610ba257600080fd5b8063a62277f0116101a6578063b4a2656911610175578063b4a2656914610a8a578063b5e5e64c14610aaa578063babd37eb14610abf578063bb807e7514610af2578063bc8a72b614610b0857600080fd5b8063a62277f0146109ef578063ad45517d14610a0f578063adc9740c14610a57578063b09c18d714610a6a57600080fd5b806391d14854116101ed57806391d14854146109325780639a82c61514610952578063a1eda53c14610972578063a217fddf146109a6578063a5eb31bf146109bb57600080fd5b80638b4d434b146108bd5780638bdd9beb146108dd5780638da5cb5b146108fd57806390abccf41461091257600080fd5b806336568abe116103245780635c975abb116102ac5780636b4f0b771161027b5780636b4f0b77146108365780637e28882214610849578063842d96f31461085f57806384ef8ffc1461087f578063865e6fd31461089d57600080fd5b80635c975abb146107cb5780635fb8bc56146107e1578063634e93da146107f6578063649a5ec71461081657600080fd5b80634573e3b3116102f35780634573e3b31461073a57806348b6ce5e1461074d5780634972134a146107625780634cd79e0a146107785780634df8a5e71461079a57600080fd5b806336568abe1461069157806336bf3325146106b15780633d9f3163146106e55780633faae3441461070557600080fd5b806310f4686b116103a757806326d976191161037657806326d97619146105d45780632da2c826146105f45780632f2ff15d1461060957806331f50da914610629578063357c13541461064957600080fd5b806310f4686b1461053557806317f3334014610555578063206583ac1461058d578063248a9ca3146105a357600080fd5b806305c9399c116103ee57806305c9399c146104b7578063083c6323146104d75780630aa6220b146104ed5780630dcb8c1a1461050257806310cf3f851461052257600080fd5b80628803d31461041f5780630154cd981461043657806301ffc9a71461045e578063022d63fb1461048e575b600080fd5b34801561042b57600080fd5b50610434610d5b565b005b34801561044257600080fd5b5061044b610dca565b6040519081526020015b60405180910390f35b34801561046a57600080fd5b5061047e6104793660046149f5565b610e46565b6040519015158152602001610455565b34801561049a57600080fd5b50620697805b60405165ffffffffffff9091168152602001610455565b3480156104c357600080fd5b506104346104d2366004614a33565b610e71565b3480156104e357600080fd5b5061044b60175481565b3480156104f957600080fd5b50610434610f90565b34801561050e57600080fd5b5061043461051d366004614a88565b610fa6565b610434610530366004614b5d565b61100e565b34801561054157600080fd5b50610434610550366004614d0a565b61122a565b34801561056157600080fd5b50600d54610575906001600160a01b031681565b6040516001600160a01b039091168152602001610455565b34801561059957600080fd5b5061044b600e5481565b3480156105af57600080fd5b5061044b6105be366004614e47565b6000908152600160208190526040909120015490565b3480156105e057600080fd5b50600a54610575906001600160a01b031681565b34801561060057600080fd5b5061044b61137c565b34801561061557600080fd5b50610434610624366004614e60565b6113b6565b34801561063557600080fd5b50600b54610575906001600160a01b031681565b34801561065557600080fd5b5061067c610664366004614e85565b601c6020526000908152604090205463ffffffff1681565b60405163ffffffff9091168152602001610455565b34801561069d57600080fd5b506104346106ac366004614e60565b611430565b3480156106bd57600080fd5b5061044b7f000000000000000000000000000000000000000000000001bc16d674ec80000081565b3480156106f157600080fd5b50600c54610575906001600160a01b031681565b34801561071157600080fd5b50610725610720366004614ea0565b61151a565b60408051928352602083019190915201610455565b610434610748366004614ede565b611889565b34801561075957600080fd5b506104346119e3565b34801561076e57600080fd5b5061044b60165481565b34801561078457600080fd5b5061078d611a84565b6040516104559190614f6f565b3480156107a657600080fd5b506107ba6107b5366004614e47565b611b12565b604051610455959493929190614f82565b3480156107d757600080fd5b5061044b601d5481565b3480156107ed57600080fd5b50610434611bb0565b34801561080257600080fd5b50610434610811366004614fde565b611c34565b34801561082257600080fd5b50610434610831366004614ffb565b611c48565b610434610844366004615023565b611c5c565b34801561085557600080fd5b5061044b60145481565b34801561086b57600080fd5b5061043461087a366004614e47565b611f99565b34801561088b57600080fd5b506003546001600160a01b0316610575565b3480156108a957600080fd5b506104346108b83660046150c9565b612058565b3480156108c957600080fd5b506104346108d836600461513f565b6122d4565b3480156108e957600080fd5b50600954610575906001600160a01b031681565b34801561090957600080fd5b506105756123d0565b34801561091e57600080fd5b5061043461092d366004615189565b6123e4565b34801561093e57600080fd5b5061047e61094d366004614e60565b612495565b34801561095e57600080fd5b506107ba61096d366004614e47565b6124c0565b34801561097e57600080fd5b50610987612507565b6040805165ffffffffffff938416815292909116602083015201610455565b3480156109b257600080fd5b5061044b600081565b3480156109c757600080fd5b506105757f00000000000000000000000000000000219ab540356cbb839cbe05303d7705fa81565b3480156109fb57600080fd5b50610434610a0a3660046151ab565b61255b565b348015610a1b57600080fd5b50610a4a610a2a366004615207565b805160208183018101805160188252928201919093012091525460ff1681565b6040516104559190615259565b610725610a65366004615281565b6126d3565b348015610a7657600080fd5b50610434610a85366004614e47565b6128a7565b348015610a9657600080fd5b50610725610aa5366004614e60565b612920565b348015610ab657600080fd5b50610434612bd2565b348015610acb57600080fd5b5061067c610ada366004614e85565b601b6020526000908152604090205463ffffffff1681565b348015610afe57600080fd5b5061044b60075481565b348015610b1457600080fd5b506105757f000000000000000000000000177d685384aa1ac5aba41b7e649f9fa0be717fdb81565b348015610b4857600080fd5b50610434610b573660046152b6565b612c33565b348015610b6857600080fd5b5061047e610b77366004614fde565b601a6020526000908152604090205460ff1681565b348015610b9857600080fd5b5061044b60065481565b348015610bae57600080fd5b50610434610bbd366004614e47565b612d28565b348015610bce57600080fd5b506104a0612d96565b348015610be357600080fd5b50610434612df5565b348015610bf857600080fd5b50610c01612e73565b604080516001600160a01b03909316835265ffffffffffff909116602083015201610455565b348015610c3357600080fd5b50610434610c42366004614e60565b612e94565b348015610c5357600080fd5b5061044b60085481565b348015610c6957600080fd5b50610434612f11565b348015610c7e57600080fd5b50610434610c8d366004614a33565b612f24565b610434610ca0366004614e47565b61304d565b348015610cb157600080fd5b50610434610cc0366004615339565b613140565b348015610cd157600080fd5b5061044b7f0000000000000000000000000000000000000000000000000de0b6b3a764000081565b348015610d0557600080fd5b5061044b60055481565b348015610d1b57600080fd5b5061044b600f5481565b348015610d3157600080fd5b5061044b60155481565b348015610d4757600080fd5b5061078d610d56366004614e47565b613312565b600080516020615bc2833981519152610d738161332b565b6002601d5414610d84576002610d87565b60015b601d8190556040805133815260208101929092527f2d9e22b609aa013375d7aa3ea850989ca303c2abf9fc24c5f45975e1e3753a9191015b60405180910390a150565b6040516284499160e81b815260106004820152600090739e0d7d79735e1c63333128149c7b616a0dc0bbdb906384499100906024015b602060405180830381865af4158015610e1d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e41919061537a565b905090565b60006001600160e01b031982166318a4c3c360e11b1480610e6b5750610e6b82613335565b92915050565b600080516020615bc2833981519152610e898161332b565b601b6000846002811115610e9f57610e9f615243565b6002811115610eb057610eb0615243565b815260208101919091526040016000205463ffffffff9081169083161115610eeb576040516358d620b360e01b815260040160405180910390fd5b81601c6000856002811115610f0257610f02615243565b6002811115610f1357610f13615243565b815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff160217905550826002811115610f5157610f51615243565b60405163ffffffff841681527f60cca38ba894e5ddc4db50e39d1e729d5ae76ddbd3874395ead72add5125bc0f906020015b60405180910390a2505050565b6000610f9b8161332b565b610fa361336a565b50565b6002601d5403610fc9576040516313d0ff5960e31b815260040160405180910390fd5b600054600114610ff45760405162461bcd60e51b8152600401610feb90615393565b60405180910390fd5b6002600055611004838383613377565b5050600160005550565b6000546001146110305760405162461bcd60e51b8152600401610feb90615393565b60026000557ffc8737ab85eb45125971625a9ebdb75cc78e01d5c1fa80c4c6e5203f47bc4fab61105f8161332b565b600160188b8b6040516110739291906153b7565b9081526040519081900360200190205460ff16600481111561109757611097615243565b146110b55760405163fbce7d8f60e01b815260040160405180910390fd5b83156110ea5734156110da5760405163a64d921760e01b815260040160405180910390fd5b6110e5858484613596565b61110a565b84341461110a5760405163b66458d760e01b815260040160405180910390fd5b60007f00000000000000000000000000000000219ab540356cbb839cbe05303d7705fa6001600160a01b0316868c8c60048d8d8d604051602401611153969594939291906154a7565b60408051601f198184030181529181526020820180516001600160e01b03166304512a2360e31b1790525161118891906154f6565b60006040518083038185875af1925050503d80600081146111c5576040519150601f19603f3d011682016040523d82523d6000602084013e6111ca565b606091505b50509050806111db576111db615512565b7fd46a7d25717262ee24042f45e4cc24e830907282b10be8c30177e24aab5e55be8b8b87896040516112109493929190615528565b60405180910390a150506001600055505050505050505050565b6001600e540361124d57604051638a4560db60e01b815260040160405180910390fd5b600080516020615bc28339815191526112658161332b565b815160005b8181101561137657600060188583815181106112885761128861554f565b6020026020010151600001516040516112a191906154f6565b9081526040519081900360200190205460ff1660048111156112c5576112c5615243565b146112e3576040516348921c7b60e11b815260040160405180910390fd5b6010739e0d7d79735e1c63333128149c7b616a0dc0bbdb6376f5c13990918684815181106113135761131361554f565b602002602001015160046040518463ffffffff1660e01b815260040161133b939291906155bc565b60006040518083038186803b15801561135357600080fd5b505af4158015611367573d6000803e3d6000fd5b5050505080600101905061126a565b50505050565b6040516284499160e81b815260126004820152600090739e0d7d79735e1c63333128149c7b616a0dc0bbdb90638449910090602401610e00565b816114225760405162461bcd60e51b815260206004820152603660248201527f416363657373436f6e74726f6c3a2063616e2774206469726563746c79206772604482015275616e742064656661756c742061646d696e20726f6c6560501b6064820152608401610feb565b61142c82826136d7565b5050565b8115801561144b57506003546001600160a01b038281169116145b156115105760008061145b612e73565b90925090506001600160a01b03821615801561147e575065ffffffffffff811615155b801561149157504265ffffffffffff8216105b6114fb5760405162461bcd60e51b815260206004820152603560248201527f416363657373436f6e74726f6c3a206f6e6c792063616e2072656e6f756e636560448201527420696e2074776f2064656c6179656420737465707360581b6064820152608401610feb565b50506002805465ffffffffffff60a01b191690555b61142c82826136fd565b6000806002601d5403611540576040516313d0ff5960e31b815260040160405180910390fd5b6000546001146115625760405162461bcd60e51b8152600401610feb90615393565b6002600090815585900361158957604051631f2a200560e01b815260040160405180910390fd5b6001600160a01b0384166115b05760405163d92e233d60e01b815260040160405180910390fd5b600b546000906001600160a01b0316330361164857600b54604051635d043b2960e11b815260048101889052306024820181905260448201526001600160a01b039091169063ba087652906064016020604051808303816000875af115801561161d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611641919061537a565b905061164b565b50845b611656600182613777565b60145491945092506000907f000000000000000000000000000000000000000000000001bc16d674ec8000009061168e908690615607565b611698919061561a565b90508480156116a5575080155b156116c357604051635fa4c85d60e01b815260040160405180910390fd5b6116cb61137c565b8111156116eb576040516315caeb5160e31b815260040160405180910390fd5b60408051838152602081018690526001600160a01b038816917fa126fc6d7777e110f6fc53f11f34b4695af73524f2b2f5585dc81b4e148733f2910160405180910390a2600b546000906001600160a01b0316331461174a573361174c565b305b905061175881866137e5565b831561186c57600a54604051630c29702960e01b81526001600160a01b0390911690630c297029906117b29084907f000000000000000000000000177d685384aa1ac5aba41b7e649f9fa0be717fdb90899060040161563c565b600060405180830381600087803b1580156117cc57600080fd5b505af11580156117e0573d6000803e3d6000fd5b5050600a54604051631e75e2a960e11b81526001600160a01b037f000000000000000000000000177d685384aa1ac5aba41b7e649f9fa0be717fdb81169450633cebc5529350611839928692911690899060040161563c565b600060405180830381600087803b15801561185357600080fd5b505af1158015611867573d6000803e3d6000fd5b505050505b611877858888613918565b50506001600055509094909350915050565b600d546001600160a01b031633146118b45760405163b5674cfd60e01b815260040160405180910390fd5b347f000000000000000000000000000000000000000000000001bc16d674ec80000081146118f55760405163162908e360e11b815260040160405180910390fd5b6002601884846040516119099291906153b7565b9081526040519081900360200190205460ff16600481111561192d5761192d615243565b1461194b576040516328c5214b60e01b815260040160405180910390fd5b60036018848460405161195f9291906153b7565b908152604051908190036020019020805460ff1916600183600481111561198857611988615243565b0217905550806015600082825461199f9190615607565b90915550506040517f4697c5b19666f0fa70dd3d4b8b68758069307e15f2dff52de0708f9ab0eacaff906119d69085908590615660565b60405180910390a1505050565b6001600e5403611a0657604051638a4560db60e01b815260040160405180910390fd5b600080516020615bc2833981519152611a1e8161332b565b604051631e9708a560e31b815260106004820152739e0d7d79735e1c63333128149c7b616a0dc0bbdb9063f4b845289060240160006040518083038186803b158015611a6957600080fd5b505af4158015611a7d573d6000803e3d6000fd5b5050505050565b60048054611a91906153f0565b80601f0160208091040260200160405190810160405280929190818152602001828054611abd906153f0565b8015611b0a5780601f10611adf57610100808354040283529160200191611b0a565b820191906000526020600020905b815481529060010190602001808311611aed57829003601f168201915b505050505081565b60608060606000806010739e0d7d79735e1c63333128149c7b616a0dc0bbdb6388d5ab9290916004896040518463ffffffff1660e01b8152600401611b5993929190615674565b600060405180830381865af4158015611b76573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611b9e91908101906156e2565b939a9299509097509550909350915050565b600054600114611bd25760405162461bcd60e51b8152600401610feb90615393565b60026000557ffc8737ab85eb45125971625a9ebdb75cc78e01d5c1fa80c4c6e5203f47bc4fab611c018161332b565b6002600e5403611c24576040516378b5fe1360e01b815260040160405180910390fd5b611c2c613c71565b506001600055565b6000611c3f8161332b565b61142c8261408f565b6000611c538161332b565b61142c82614102565b600d546001600160a01b03163314611c875760405163b5674cfd60e01b815260040160405180910390fd5b60405134907f000000000000000000000000000000000000000000000001bc16d674ec80000090600090601890611cc1908d908d906153b7565b9081526040519081900360200190205460ff1690506001816004811115611cea57611cea615243565b14158015611d0a57506002816004811115611d0757611d07615243565b14155b15611d28576040516321f03be760e21b815260040160405180910390fd5b8515611d4757611d42611d3b848461577a565b8686613596565b611d67565b818314611d675760405163162908e360e11b815260040160405180910390fd5b6001816004811115611d7b57611d7b615243565b03611eca57606087611e0d57604051635442791360e01b815260126004820152602481018b9052739e0d7d79735e1c63333128149c7b616a0dc0bbdb90635442791390604401600060405180830381865af4158015611dde573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611e06919081019061578d565b9050611e8f565b60405163176d231d60e21b815260126004820152602481018b9052739e0d7d79735e1c63333128149c7b616a0dc0bbdb90635db48c7490604401600060405180830381865af4158015611e64573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611e8c919081019061578d565b90505b80516020820120604051611ea6908e908e906153b7565b604051809103902014611ebb57611ebb615512565b611ec48361416b565b50611ee2565b8160156000828254611edc9190615607565b90915550505b600460188c8c604051611ef69291906153b7565b908152604051908190036020019020805460ff19166001836004811115611f1f57611f1f615243565b02179055507f38dfdd34943d912ef1591f414fa0fd6acbd0ef9b5b6d071908764e7da03c80b68b8b888b611f73817f000000000000000000000000000000000000000000000001bc16d674ec80000061577a565b604051611f849594939291906157c1565b60405180910390a15050505050505050505050565b6001600e5403611fbc57604051638a4560db60e01b815260040160405180910390fd5b600080516020615bc2833981519152611fd48161332b565b60405163f3c723c760e01b81526010600482015260248101839052739e0d7d79735e1c63333128149c7b616a0dc0bbdb9063f3c723c790604401600060405180830381865af415801561202b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261205391908101906157f2565b505050565b600080516020615bc28339815191526120708161332b565b6001600160a01b0382166120975760405163d92e233d60e01b815260040160405180910390fd5b8260058111156120a9576120a9615243565b6040516001600160a01b03841681527e0961cd4320f350803f764de4992b70c8fc5c948b5881a151f883df0af333579060200160405180910390a260018360058111156120f8576120f8615243565b0361211f57600980546001600160a01b0384166001600160a01b0319909116179055505050565b600083600581111561213357612133615243565b0361215a57600a80546001600160a01b0384166001600160a01b0319909116179055505050565b600283600581111561216e5761216e615243565b036121cf57600a54600b546001600160a01b03918216911680156121a1576121a16001600160a01b038316826000614205565b600b80546001600160a01b0319166001600160a01b03868116918217909255611a7d91841690600019614205565b60038360058111156121e3576121e3615243565b0361220a57600c80546001600160a01b0384166001600160a01b0319909116179055505050565b600583600581111561221e5761221e615243565b036122bb57600d80546001600160a01b0319166001600160a01b03841617905560408051600160f81b6020820152600060218201526bffffffffffffffffffffffff19606085901b16602c820152016040516020818303038152906040526004908161228a91906158e9565b507f8f746a1079cc65ea9cd881479b0267d00dc3dceebfa5d13c9beb36863a8741bc60046040516119d691906159a8565b60405163dca3e0e560e01b815260040160405180910390fd5b600080516020615bc28339815191526122ec8161332b565b8260005b818110156123c857600086868381811061230c5761230c61554f565b90506020020160208101906123219190614fde565b6001600160a01b0381166000908152601a60205260409020805460ff1916871580159190911790915590915061238a576040516001600160a01b038216907f0cf877f176d079d5bfa8093032c2b7c02bebde4c25b92a30f796e60f8f3919a090600090a26123bf565b6040516001600160a01b038216907f40bad7be9dd2ade74f56f2ebe2ffe63101f45fea53b5b3309cf7c789c690514590600090a25b506001016122f0565b505050505050565b6000610e416003546001600160a01b031690565b6001600e540361240757604051638a4560db60e01b815260040160405180910390fd5b600080516020615bc283398151915261241f8161332b565b6040516304ab817f60e01b8152601060048201526024810184905260448101839052739e0d7d79735e1c63333128149c7b616a0dc0bbdb906304ab817f9060640160006040518083038186803b15801561247857600080fd5b505af415801561248c573d6000803e3d6000fd5b50505050505050565b60009182526001602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60608060606000806012739e0d7d79735e1c63333128149c7b616a0dc0bbdb6388d5ab9290916004896040518463ffffffff1660e01b8152600401611b5993929190615674565b600354600090600160d01b900465ffffffffffff16801515801561253357504265ffffffffffff821610155b61253f57600080612553565b600354600160a01b900465ffffffffffff16815b915091509091565b6001600e540361257e57604051638a4560db60e01b815260040160405180910390fd5b600080516020615bc28339815191526125968161332b565b606082156126245760405163176d231d60e21b81526010600482015260248101859052739e0d7d79735e1c63333128149c7b616a0dc0bbdb90635db48c7490604401600060405180830381865af41580156125f5573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261261d919081019061578d565b90506126a6565b604051635442791360e01b81526010600482015260248101859052739e0d7d79735e1c63333128149c7b616a0dc0bbdb90635442791390604401600060405180830381865af415801561267b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526126a3919081019061578d565b90505b85856040516126b69291906153b7565b60405180910390208180519060200120146123c8576123c8615512565b6000806002601d54036126f9576040516313d0ff5960e31b815260040160405180910390fd5b60005460011461271b5760405162461bcd60e51b8152600401610feb90615393565b6002600090815534900361274257604051631f2a200560e01b815260040160405180910390fd5b6001600160a01b0384166127695760405163d92e233d60e01b815260040160405180910390fd5b612774600034613777565b909250905061278f836127875784612789565b305b8361427c565b821561280e57600b54604051636e553f6560e01b8152600481018490526001600160a01b03868116602483015290911690636e553f65906044016020604051808303816000875af11580156127e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061280c919061537a565b505b801561283e5761283e7f000000000000000000000000177d685384aa1ac5aba41b7e649f9fa0be717fdb8261427c565b6128473461416b565b6040805134815260208101849052908101829052831515906001600160a01b0386169033907f53688f4835c0a3d757a2c2fb4f73147d7fb253f5d5ca9f0b420e6831704c74bd9060600160405180910390a4600160005590939092509050565b600080516020615bc28339815191526128bf8161332b565b620f42408211156128e3576040516395e28b8560e01b815260040160405180910390fd5b60078290556040518281527f60e884e0954bf3325b419fc0af3a6a75091d749f3a2af01d8657bb94ffc4beff906020015b60405180910390a15050565b6000806002601d5403612946576040516313d0ff5960e31b815260040160405180910390fd5b6000546001146129685760405162461bcd60e51b8152600401610feb90615393565b6002600090815584900361298f57604051631f2a200560e01b815260040160405180910390fd5b6001600160a01b0383166129b65760405163d92e233d60e01b815260040160405180910390fd5b6129c1600285613777565b60055491935091508211156129e95760405163664f459f60e11b815260040160405180910390fd5b8015612afd57600a54604051630c29702960e01b81526001600160a01b0390911690630c29702990612a439033907f000000000000000000000000177d685384aa1ac5aba41b7e649f9fa0be717fdb90869060040161563c565b600060405180830381600087803b158015612a5d57600080fd5b505af1158015612a71573d6000803e3d6000fd5b5050600a54604051631e75e2a960e11b81526001600160a01b037f000000000000000000000000177d685384aa1ac5aba41b7e649f9fa0be717fdb81169450633cebc5529350612aca923392911690869060040161563c565b600060405180830381600087803b158015612ae457600080fd5b505af1158015612af8573d6000803e3d6000fd5b505050505b612b0733836137e5565b8160056000828254612b19919061577a565b90915550506040516000906001600160a01b0385169084908381818185875af1925050503d8060008114612b69576040519150601f19603f3d011682016040523d82523d6000602084013e612b6e565b606091505b5050905080612b7f57612b7f615512565b60408051868152602081018590526001600160a01b038616917fef65d72849d1cca64b0040a01907b1f330f86a9d3e01856ce6bd55cdb8a16e0c910160405180910390a250600160005590939092509050565b600080516020615bc2833981519152612bea8161332b565b6001600e5414612bfb576001612bfe565b60025b600e8190556040519081527f66397ea162e103ec543314596384be5631955c423f5e2ca581e800e9592b608190602001610dbf565b6002601d5403612c56576040516313d0ff5960e31b815260040160405180910390fd5b600054600114612c785760405162461bcd60e51b8152600401610feb90615393565b6002600090815584908390829003612ca35760405163521299a960e01b815260040160405180910390fd5b808214612cc357604051632b477e7160e11b815260040160405180910390fd5b60005b82811015612d1957612d09888883818110612ce357612ce361554f565b90506020020135878784818110612cfc57612cfc61554f565b9050602002013586613377565b612d12816159bb565b9050612cc6565b50506001600055505050505050565b600080516020615bc2833981519152612d408161332b565b81600003612d61576040516375463e0d60e01b815260040160405180910390fd5b60088290556040518281527f52880fce23cacdff91c59389d5388b972e58527b17524a84addefcfea80ce9a190602001612914565b600354600090600160d01b900465ffffffffffff168015158015612dc157504265ffffffffffff8216105b612ddc57600254600160d01b900465ffffffffffff16612def565b600354600160a01b900465ffffffffffff165b91505090565b6000612dff612e73565b509050336001600160a01b03821614612e6b5760405162461bcd60e51b815260206004820152602860248201527f416363657373436f6e74726f6c3a2070656e64696e672061646d696e206d75736044820152671d081858d8d95c1d60c21b6064820152608401610feb565b610fa36142b5565b6002546001600160a01b03811691600160a01b90910465ffffffffffff1690565b81612f075760405162461bcd60e51b815260206004820152603760248201527f416363657373436f6e74726f6c3a2063616e2774206469726563746c7920726560448201527f766f6b652064656661756c742061646d696e20726f6c650000000000000000006064820152608401610feb565b61142c8282614380565b6000612f1c8161332b565b610fa36143a6565b600080516020615bc2833981519152612f3c8161332b565b601c6000846002811115612f5257612f52615243565b6002811115612f6357612f63615243565b815260208101919091526040016000205463ffffffff9081169083161080612f935750620f42408263ffffffff16115b15612fb15760405163a51d0c8160e01b815260040160405180910390fd5b81601b6000856002811115612fc857612fc8615243565b6002811115612fd957612fd9615243565b815260200190815260200160002060006101000a81548163ffffffff021916908363ffffffff16021790555082600281111561301757613017615243565b60405163ffffffff841681527f2c8a1b11f988520b010608bf85a9a26038b520fdad549d3b58433a5ca5fba15190602001610f83565b600d546001600160a01b031633146130785760405163b5674cfd60e01b815260040160405180910390fd5b3415610fa3576017819055600b54613099906001600160a01b03163461427c565b600b60009054906101000a90046001600160a01b03166001600160a01b0316630c51dde46040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156130e957600080fd5b505af11580156130fd573d6000803e3d6000fd5b5050505061310a3461416b565b60408051348152602081018390527f6c8433a8e155f0af04dba058d4e4695f7da554578963d876bdf4a6d8d6399d9c9101610dbf565b600080516020615bc28339815191526131588161332b565b6001600e540361317b57604051638a4560db60e01b815260040160405180910390fd5b6001601d540361319e57604051636cd6020160e01b815260040160405180910390fd5b6001600160a01b0384166131c55760405163d92e233d60e01b815260040160405180910390fd5b816000036131e657604051631f2a200560e01b815260040160405180910390fd5b600a546001600160a01b03908116908416036132155760405163c1ab6dc160e01b815260040160405180910390fd5b6001600160a01b0383166132ab57600061322f834761577a565b905080600f54111561324157600f8190555b6000856001600160a01b03168460405160006040518083038185875af1925050503d806000811461328e576040519150601f19603f3d011682016040523d82523d6000602084013e613293565b606091505b50509050806132a4576132a4615512565b50506132bf565b6132bf6001600160a01b03841685846143b1565b826001600160a01b0316846001600160a01b03167f9495d03190a79a43e534c9e328ff322f6283261383f5f19c809564f6ad5a57b38460405161330491815260200190565b60405180910390a350505050565b60196020526000908152604090208054611a91906153f0565b610fa38133614429565b60006001600160e01b03198216637965db0b60e01b1480610e6b57506301ffc9a760e01b6001600160e01b0319831614610e6b565b613375600080614482565b565b8160000361339857604051631f2a200560e01b815260040160405180910390fd5b6001600160a01b0381166133bf5760405163d92e233d60e01b815260040160405180910390fd5b60008381526019602052604080822090516018916133dc916159d4565b9081526040519081900360200190205460ff169050600381600481111561340557613405615243565b141580156134255750600481600481111561342257613422615243565b14155b15613443576040516314cb5a8b60e01b815260040160405180910390fd5b82601554101561346657604051632c1d501360e11b815260040160405180910390fd5b8260156000828254613478919061577a565b9091555050600954604051637a94c56560e11b815233600482015260248101869052604481018590526001600160a01b039091169063f5298aca90606401600060405180830381600087803b1580156134d057600080fd5b505af11580156134e4573d6000803e3d6000fd5b505050506000826001600160a01b03168460405160006040518083038185875af1925050503d8060008114613535576040519150601f19603f3d011682016040523d82523d6000602084013e61353a565b606091505b505090508061354b5761354b615512565b60408051868152602081018690526001600160a01b038516917fb12ec230ea9bdc2847d084f44c404df9f15811b22a0b58c4f869e1c56e14bf3b910160405180910390a25050505050565b8260055410156135b95760405163664f459f60e11b815260040160405180910390fd5b806000805b828110156136a957601a60008686848181106135dc576135dc61554f565b6135f29260206040909202019081019150614fde565b6001600160a01b0316815260208101919091526040016000205460ff1661362c576040516309e58bbb60e11b815260040160405180910390fd5b84848281811061363e5761363e61554f565b90506040020160200135826136539190615607565b91506136a185858381811061366a5761366a61554f565b6136809260206040909202019081019150614fde565b8686848181106136925761369261554f565b905060400201602001356137e5565b6001016135be565b508481146136b9576136b9615512565b84600560008282546136cb919061577a565b90915550505050505050565b600082815260016020819052604090912001546136f38161332b565b6120538383614542565b6001600160a01b038116331461376d5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610feb565b61142c82826145ec565b600080620f4240601c600086600281111561379457613794615243565b60028111156137a5576137a5615243565b81526020810191909152604001600020546137c69063ffffffff1685615a4a565b6137d0919061561a565b90506137dc818461577a565b91509250929050565b600a54604051632770a7eb60e21b81526001600160a01b0384811660048301526024820184905290911690639dc29fac906044015b600060405180830381600087803b15801561383457600080fd5b505af1158015613848573d6000803e3d6000fd5b505050506000620f4240600754600a60009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156138a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138cc919061537a565b6138d69190615a4a565b6138e0919061561a565b60068190556040518181529091507f8b1dd71841cb6ebc4652591239fb967e36b753ee615f32360a27d22ad66df73f906020016119d6565b826014600082825461392a9190615607565b90915550505b7f000000000000000000000000000000000000000000000001bc16d674ec80000060145461395e919061561a565b15613bc657601454600090613993857f000000000000000000000000000000000000000000000001bc16d674ec800000615607565b61399d919061577a565b60095460165460405163731133e960e01b81526001600160a01b0387811660048301526024820192909252604481018490526080606482015260006084820152929350169063731133e99060a401600060405180830381600087803b158015613a0557600080fd5b505af1158015613a19573d6000803e3d6000fd5b505060405163031af78360e21b815260009250739e0d7d79735e1c63333128149c7b616a0dc0bbdb9150630c6bde0c90613a5a906012906004908101615a61565b600060405180830381865af4158015613a77573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052613a9f91908101906156e2565b5050505090507f000000000000000000000000000000000000000000000001bc16d674ec80000060146000828254613ad7919061577a565b90915550613ae79050828661577a565b600c54604051631ca9451360e11b81529196506001600160a01b0316906339528a2690613b18908490600401614f6f565b600060405180830381600087803b158015613b3257600080fd5b505af1158015613b46573d6000803e3d6000fd5b5050601680548493506019925060009182613b60836159bb565b9190505581526020019081526020016000209081613b7e91906158e9565b506002601882604051613b9191906154f6565b908152604051908190036020019020805460ff19166001836004811115613bba57613bba615243565b02179055505050613930565b808015613bd35750600083115b15613bf157604051633352735960e11b815260040160405180910390fd5b82156120535760095460165460405163731133e960e01b81526001600160a01b038581166004830152602482019290925260448101869052608060648201526000608482015291169063731133e99060a401600060405180830381600087803b158015613c5d57600080fd5b505af115801561248c573d6000803e3d6000fd5b6008546000613cc07f0000000000000000000000000000000000000000000000000de0b6b3a76400007f000000000000000000000000000000000000000000000001bc16d674ec80000061577a565b90505b6040516284499160e81b815260106004820152739e0d7d79735e1c63333128149c7b616a0dc0bbdb90638449910090602401602060405180830381865af4158015613d12573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d36919061537a565b15801590613d46575080600f5410155b8015613d525750600082115b1561142c5760008060008060006010739e0d7d79735e1c63333128149c7b616a0dc0bbdb630c6bde0c909160046040518363ffffffff1660e01b8152600401613d9c929190615a61565b600060405180830381865af4158015613db9573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052613de191908101906156e2565b9398509196509450925090506000601886604051613dff91906154f6565b9081526040519081900360200190205460ff166004811115613e2357613e23615243565b14613e41576040516348921c7b60e11b815260040160405180910390fd5b60007f00000000000000000000000000000000219ab540356cbb839cbe05303d7705fa6001600160a01b03168787878787604051602401613e859493929190615a7a565b60408051601f198184030181529181526020820180516001600160e01b03166304512a2360e31b17905251613eba91906154f6565b60006040518083038185875af1925050503d8060008114613ef7576040519150601f19603f3d011682016040523d82523d6000602084013e613efc565b606091505b5050905080613f0d57613f0d615512565b86600f6000828254613f1f919061577a565b90915550507f0000000000000000000000000000000000000000000000000de0b6b3a764000015613f7457613f74827f0000000000000000000000000000000000000000000000000de0b6b3a764000061427c565b876001900397506001601887604051613f8d91906154f6565b908152604051908190036020019020805460ff19166001836004811115613fb657613fb6615243565b021790555060408051608081018252878152602081018690528082018590526001600160a01b038416606082015290516376f5c13960e01b8152739e0d7d79735e1c63333128149c7b616a0dc0bbdb916376f5c1399161401d916012918a90600401615ac5565b60006040518083038186803b15801561403557600080fd5b505af4158015614049573d6000803e3d6000fd5b505050507f9990dac99d880d1fcaac485cb74ce1cad6b3fc2eecb7d6550bf6760432b8cdf48660405161407c9190614f6f565b60405180910390a1505050505050613cc3565b6000614099612d96565b6140a242614627565b6140ac9190615af0565b90506140b88282614692565b60405165ffffffffffff821681526001600160a01b038316907f3377dc44241e779dd06afab5b788a35ca5f3b778836e2990bdb26a2a4b2e5ed69060200160405180910390a25050565b600061410d82614711565b61411642614627565b6141209190615af0565b905061412c8282614482565b6040805165ffffffffffff8085168252831660208201527ff1038c18cf84a56e432fdbfaf746924b7ea511dfe03a6506a0ceba4888788d9b9101612914565b60006005546006541161417f57600061418f565b60055460065461418f919061577a565b90508181156141db5780821115806141a757816141a9565b825b600560008282546141ba9190615607565b909155508190506141cb57816141cd565b825b6141d7908361577a565b9150505b80600f60008282546141ed9190615607565b9091555050600e546000190161205357612053613c71565b600060405163095ea7b360e01b8152836004820152826024820152602060006044836000895af13d15601f3d11600160005114161716915050806113765760405162461bcd60e51b815260206004820152600e60248201526d1054141493d59157d1905253115160921b6044820152606401610feb565b600a546040516340c10f1960e01b81526001600160a01b03848116600483015260248201849052909116906340c10f199060440161381a565b6000806142c0612e73565b915091506142d58165ffffffffffff16151590565b80156142e857504265ffffffffffff8216105b6143455760405162461bcd60e51b815260206004820152602860248201527f416363657373436f6e74726f6c3a207472616e736665722064656c6179206e6f6044820152671d081c185cdcd95960c21b6064820152608401610feb565b614361600061435c6003546001600160a01b031690565b6145ec565b61436c600083614542565b5050600280546001600160d01b0319169055565b6000828152600160208190526040909120015461439c8161332b565b61205383836145ec565b613375600080614692565b600060405163a9059cbb60e01b8152836004820152826024820152602060006044836000895af13d15601f3d11600160005114161716915050806113765760405162461bcd60e51b815260206004820152600f60248201526e1514905394d1915497d19052531151608a1b6044820152606401610feb565b6144338282612495565b61142c5761444081614760565b61444b836020614772565b60405160200161445c929190615b16565b60408051601f198184030181529082905262461bcd60e51b8252610feb91600401614f6f565b600354600160d01b900465ffffffffffff168015614505574265ffffffffffff821610156144db57600354600280546001600160d01b0316600160a01b90920465ffffffffffff16600160d01b02919091179055614505565b6040517f2b1fa2edafe6f7b9e97c1a9e0c3660e645beb2dcaa2d45bdbf9beaf5472e1ec590600090a15b50600380546001600160a01b0316600160a01b65ffffffffffff948516026001600160d01b031617600160d01b9290931691909102919091179055565b816145e257600061455b6003546001600160a01b031690565b6001600160a01b0316146145c65760405162461bcd60e51b815260206004820152602c60248201527f416363657373436f6e74726f6c3a2064656661756c742061646d696e20616c7260448201526b1958591e4819dc985b9d195960a21b6064820152608401610feb565b600380546001600160a01b0319166001600160a01b0383161790555b61142c828261490d565b8115801561460757506003546001600160a01b038281169116145b1561461d57600380546001600160a01b03191690555b61142c8282614978565b600065ffffffffffff82111561468e5760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203460448201526538206269747360d01b6064820152608401610feb565b5090565b600061469c612e73565b6002805465ffffffffffff8616600160a01b026001600160d01b03199091166001600160a01b0388161717905591506146de90508165ffffffffffff16151590565b15612053576040517f8886ebfc4259abdbc16601dd8fb5678e54878f47b3c34836cfc51154a960510990600090a1505050565b60008061471c612d96565b90508065ffffffffffff168365ffffffffffff16116147445761473f8382615b8b565b614759565b61475965ffffffffffff8416620697806149df565b9392505050565b6060610e6b6001600160a01b03831660145b60606000614781836002615a4a565b61478c906002615607565b6001600160401b038111156147a3576147a3614c1f565b6040519080825280601f01601f1916602001820160405280156147cd576020820181803683370190505b509050600360fc1b816000815181106147e8576147e861554f565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106148175761481761554f565b60200101906001600160f81b031916908160001a905350600061483b846002615a4a565b614846906001615607565b90505b60018111156148be576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061487a5761487a61554f565b1a60f81b8282815181106148905761489061554f565b60200101906001600160f81b031916908160001a90535060049490941c936148b781615baa565b9050614849565b5083156147595760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610feb565b6149178282612495565b61142c5760008281526001602081815260408084206001600160a01b0386168086529252808420805460ff19169093179092559051339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b6149828282612495565b1561142c5760008281526001602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60008183106149ee5781614759565b5090919050565b600060208284031215614a0757600080fd5b81356001600160e01b03198116811461475957600080fd5b803560038110614a2e57600080fd5b919050565b60008060408385031215614a4657600080fd5b614a4f83614a1f565b9150602083013563ffffffff81168114614a6857600080fd5b809150509250929050565b6001600160a01b0381168114610fa357600080fd5b600080600060608486031215614a9d57600080fd5b83359250602084013591506040840135614ab681614a73565b809150509250925092565b60008083601f840112614ad357600080fd5b5081356001600160401b03811115614aea57600080fd5b602083019150836020828501011115614b0257600080fd5b9250929050565b80358015158114614a2e57600080fd5b60008083601f840112614b2b57600080fd5b5081356001600160401b03811115614b4257600080fd5b6020830191508360208260061b8501011115614b0257600080fd5b600080600080600080600080600060c08a8c031215614b7b57600080fd5b89356001600160401b0380821115614b9257600080fd5b614b9e8d838e01614ac1565b909b50995060208c0135915080821115614bb757600080fd5b614bc38d838e01614ac1565b909950975060408c0135965060608c01359550879150614be560808d01614b09565b945060a08c0135915080821115614bfb57600080fd5b50614c088c828d01614b19565b915080935050809150509295985092959850929598565b634e487b7160e01b600052604160045260246000fd5b604051608081016001600160401b0381118282101715614c5757614c57614c1f565b60405290565b604051601f8201601f191681016001600160401b0381118282101715614c8557614c85614c1f565b604052919050565b60006001600160401b03821115614ca657614ca6614c1f565b50601f01601f191660200190565b600082601f830112614cc557600080fd5b8135614cd8614cd382614c8d565b614c5d565b818152846020838601011115614ced57600080fd5b816020850160208301376000918101602001919091529392505050565b60006020808385031215614d1d57600080fd5b82356001600160401b0380821115614d3457600080fd5b818501915085601f830112614d4857600080fd5b813581811115614d5a57614d5a614c1f565b8060051b614d69858201614c5d565b9182528381018501918581019089841115614d8357600080fd5b86860192505b83831015614e3a57823585811115614da15760008081fd5b86016080818c03601f1901811315614db95760008081fd5b614dc1614c35565b8983013588811115614dd35760008081fd5b614de18e8c83870101614cb4565b82525060408084013589811115614df85760008081fd5b614e068f8d83880101614cb4565b838d015250606084810135828401529383013593614e2385614a73565b820193909352845250509186019190860190614d89565b9998505050505050505050565b600060208284031215614e5957600080fd5b5035919050565b60008060408385031215614e7357600080fd5b823591506020830135614a6881614a73565b600060208284031215614e9757600080fd5b61475982614a1f565b600080600060608486031215614eb557600080fd5b833592506020840135614ec781614a73565b9150614ed560408501614b09565b90509250925092565b60008060208385031215614ef157600080fd5b82356001600160401b03811115614f0757600080fd5b614f1385828601614ac1565b90969095509350505050565b60005b83811015614f3a578181015183820152602001614f22565b50506000910152565b60008151808452614f5b816020860160208601614f1f565b601f01601f19169290920160200192915050565b6020815260006147596020830184614f43565b60a081526000614f9560a0830188614f43565b8281036020840152614fa78188614f43565b90508281036040840152614fbb8187614f43565b606084019590955250506001600160a01b03919091166080909101529392505050565b600060208284031215614ff057600080fd5b813561475981614a73565b60006020828403121561500d57600080fd5b813565ffffffffffff8116811461475957600080fd5b60008060008060008060008060c0898b03121561503f57600080fd5b88356001600160401b038082111561505657600080fd5b6150628c838d01614ac1565b909a50985060208b0135975060408b0135965088915061508460608c01614b09565b955061509260808c01614b09565b945060a08b01359150808211156150a857600080fd5b506150b58b828c01614b19565b999c989b5096995094979396929594505050565b600080604083850312156150dc57600080fd5b8235600681106150eb57600080fd5b91506020830135614a6881614a73565b60008083601f84011261510d57600080fd5b5081356001600160401b0381111561512457600080fd5b6020830191508360208260051b8501011115614b0257600080fd5b60008060006040848603121561515457600080fd5b83356001600160401b0381111561516a57600080fd5b615176868287016150fb565b9094509250614ed5905060208501614b09565b6000806040838503121561519c57600080fd5b50508035926020909101359150565b600080600080606085870312156151c157600080fd5b84356001600160401b038111156151d757600080fd5b6151e387828801614ac1565b909550935050602085013591506151fc60408601614b09565b905092959194509250565b60006020828403121561521957600080fd5b81356001600160401b0381111561522f57600080fd5b61523b84828501614cb4565b949350505050565b634e487b7160e01b600052602160045260246000fd5b602081016005831061527b57634e487b7160e01b600052602160045260246000fd5b91905290565b6000806040838503121561529457600080fd5b823561529f81614a73565b91506152ad60208401614b09565b90509250929050565b6000806000806000606086880312156152ce57600080fd5b85356001600160401b03808211156152e557600080fd5b6152f189838a016150fb565b9097509550602088013591508082111561530a57600080fd5b50615317888289016150fb565b909450925050604086013561532b81614a73565b809150509295509295909350565b60008060006060848603121561534e57600080fd5b833561535981614a73565b9250602084013561536981614a73565b929592945050506040919091013590565b60006020828403121561538c57600080fd5b5051919050565b6020808252600a90820152695245454e5452414e435960b01b604082015260600190565b8183823760009101908152919050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b600181811c9082168061540457607f821691505b60208210810361542457634e487b7160e01b600052602260045260246000fd5b50919050565b60008154615437816153f0565b808552602060018381168015615454576001811461546e5761549c565b60ff1985168884015283151560051b88018301955061549c565b866000528260002060005b858110156154945781548a8201860152908301908401615479565b890184019650505b505050505092915050565b6080815260006154bb60808301888a6153c7565b82810360208401526154cd818861542a565b905082810360408401526154e28186886153c7565b915050826060830152979650505050505050565b60008251615508818460208701614f1f565b9190910192915050565b634e487b7160e01b600052600160045260246000fd5b60608152600061553c6060830186886153c7565b9315156020830152506040015292915050565b634e487b7160e01b600052603260045260246000fd5b600081516080845261557a6080850182614f43565b9050602083015184820360208601526155938282614f43565b604085810151908701526060948501516001600160a01b03169490950193909352509192915050565b8381526060602082015260006155d56060830185615565565b82810360408401526155e7818561542a565b9695505050505050565b634e487b7160e01b600052601160045260246000fd5b80820180821115610e6b57610e6b6155f1565b60008261563757634e487b7160e01b600052601260045260246000fd5b500490565b6001600160a01b039384168152919092166020820152604081019190915260600190565b60208152600061523b6020830184866153c7565b83815260606020820152600061568d606083018561542a565b9050826040830152949350505050565b600082601f8301126156ae57600080fd5b81516156bc614cd382614c8d565b8181528460208386010111156156d157600080fd5b61523b826020830160208701614f1f565b600080600080600060a086880312156156fa57600080fd5b85516001600160401b038082111561571157600080fd5b61571d89838a0161569d565b9650602088015191508082111561573357600080fd5b61573f89838a0161569d565b9550604088015191508082111561575557600080fd5b506157628882890161569d565b93505060608601519150608086015161532b81614a73565b81810381811115610e6b57610e6b6155f1565b60006020828403121561579f57600080fd5b81516001600160401b038111156157b557600080fd5b61523b8482850161569d565b6080815260006157d56080830187896153c7565b941515602083015250604081019290925260609091015292915050565b60006020828403121561580457600080fd5b81516001600160401b038082111561581b57600080fd5b908301906080828603121561582f57600080fd5b615837614c35565b82518281111561584657600080fd5b6158528782860161569d565b82525060208301518281111561586757600080fd5b6158738782860161569d565b602083015250604083015160408201526060830151925061589383614a73565b6060810192909252509392505050565b601f82111561205357600081815260208120601f850160051c810160208610156158ca5750805b601f850160051c820191505b818110156123c8578281556001016158d6565b81516001600160401b0381111561590257615902614c1f565b6159168161591084546153f0565b846158a3565b602080601f83116001811461594b57600084156159335750858301515b600019600386901b1c1916600185901b1785556123c8565b600085815260208120601f198616915b8281101561597a5788860151825594840194600190910190840161595b565b50858210156159985787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b602081526000614759602083018461542a565b6000600182016159cd576159cd6155f1565b5060010190565b60008083546159e2816153f0565b600182811680156159fa5760018114615a0f57615a3e565b60ff1984168752821515830287019450615a3e565b8760005260208060002060005b85811015615a355781548a820152908401908201615a1c565b50505082870194505b50929695505050505050565b8082028115828204841417610e6b57610e6b6155f1565b82815260406020820152600061523b604083018461542a565b608081526000615a8d6080830187614f43565b8281036020840152615a9f8187614f43565b90508281036040840152615ab38186614f43565b91505082606083015295945050505050565b838152606060208201526000615ade6060830185615565565b82810360408401526155e78185614f43565b65ffffffffffff818116838216019080821115615b0f57615b0f6155f1565b5092915050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351615b4e816017850160208801614f1f565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351615b7f816028840160208801614f1f565b01602801949350505050565b65ffffffffffff828116828216039080821115615b0f57615b0f6155f1565b600081615bb957615bb96155f1565b50600019019056fe71840dc4906352362b0cdaf79870196c8e42acafade72d5d5a6d59291253ceb1a2646970667358221220784919cd6d3a2513dfc7d963c8632c35067de96881fb62cec6993f9e7a1ec00b64736f6c63430008130033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

00000000000000000000000004c154b66cb340f3ae24111cc767e0184ed00cc6000000000000000000000000e8ea8990643a0431e4b28f7f7f6878aab88fe42400000000000000000000000000000000219ab540356cbb839cbe05303d7705fa0000000000000000000000005bf2419a33f82f4c1f075b4006d7fc4104c43868000000000000000000000000000000000000000000000001bc16d674ec8000000000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000177d685384aa1ac5aba41b7e649f9fa0be717fdb0000000000000000000000000000000000000000000000000000000000000000

-----Decoded View---------------
Arg [0] : _pxEth (address): 0x04C154b66CB340F3Ae24111CC767e0184Ed00Cc6
Arg [1] : _admin (address): 0xe8eA8990643A0431E4B28F7F7f6878aaB88fE424
Arg [2] : _beaconChainDepositContract (address): 0x00000000219ab540356cBB839Cbe05303d7705Fa
Arg [3] : _upxEth (address): 0x5BF2419a33f82F4C1f075B4006d7fC4104C43868
Arg [4] : _depositSize (uint256): 32000000000000000000
Arg [5] : _preDepositAmount (uint256): 1000000000000000000
Arg [6] : _pirexFees (address): 0x177D685384AA1Ac5ABA41b7E649F9fA0Be717fdb
Arg [7] : _initialDelay (uint48): 0

-----Encoded View---------------
8 Constructor Arguments found :
Arg [0] : 00000000000000000000000004c154b66cb340f3ae24111cc767e0184ed00cc6
Arg [1] : 000000000000000000000000e8ea8990643a0431e4b28f7f7f6878aab88fe424
Arg [2] : 00000000000000000000000000000000219ab540356cbb839cbe05303d7705fa
Arg [3] : 0000000000000000000000005bf2419a33f82f4c1f075b4006d7fc4104c43868
Arg [4] : 000000000000000000000000000000000000000000000001bc16d674ec800000
Arg [5] : 0000000000000000000000000000000000000000000000000de0b6b3a7640000
Arg [6] : 000000000000000000000000177d685384aa1ac5aba41b7e649f9fa0be717fdb
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000000


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.