MNT Price: $0.86 (+1.28%)

Contract

0x2d5718EaA54e5b2db5c54BB9aC10dceb01b54A6C
 

Overview

MNT Balance

Mantle Mainnet Network LogoMantle Mainnet Network LogoMantle Mainnet Network Logo0 MNT

MNT Value

$0.00

More Info

Private Name Tags

Multichain Info

No addresses found
Age:90D
Reset Filter

Transaction Hash
Block
From
To

There are no matching entries

Update your filters to view other transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:

Cross-Chain Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
StrategyManager

Compiler Version
v0.8.20+commit.a1b79de6

Optimization Enabled:
Yes with 1500 runs

Other Settings:
berlin EvmVersion
// SPDX-License-Identifier: LGPL-3.0
pragma solidity 0.8.20;

import '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol';
import '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol';
import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
import '../permissions/Pausable.sol';
import './StrategyManagerStorage.sol';
import '../libraries/EIP1271SignatureUtils.sol';

/**
 * @title The primary entry- and exit-point for funds into and out of Pell.
 *
 * @notice This contract is for managing deposits in different strategies. The main
 * functionalities are:
 * - adding and removing strategies that any delegator can deposit into
 * - enabling deposit of assets into specified strategy(s)
 */
contract StrategyManager is Initializable, OwnableUpgradeable, ReentrancyGuardUpgradeable, Pausable, StrategyManagerStorage {
  using SafeERC20 for IERC20;

  // index for flag that pauses deposits when set
  uint8 internal constant PAUSED_DEPOSITS = 0;

  // chain id at the time of contract deployment
  uint256 internal immutable ORIGINAL_CHAIN_ID;

  modifier onlyStrategyWhitelister() {
    require(msg.sender == strategyWhitelister, 'StrategyManager.onlyStrategyWhitelister: not the strategyWhitelister');
    _;
  }

  modifier onlyStrategiesWhitelistedForDeposit(IStrategy strategy) {
    require(strategyIsWhitelistedForDeposit[strategy], 'StrategyManager.onlyStrategiesWhitelistedForDeposit: strategy not whitelisted');
    _;
  }

  modifier onlyDelegationManager() {
    require(msg.sender == address(delegation), 'StrategyManager.onlyDelegationManager: not the DelegationManager');
    _;
  }

  /**
   * @param _delegation The delegation contract of Pell.
   * @param _slasher The primary slashing contract of Pell.
   */
  constructor(IDelegationManager _delegation, ISlasher _slasher) StrategyManagerStorage(_delegation, _slasher) {
    _disableInitializers();
    ORIGINAL_CHAIN_ID = block.chainid;
  }

  // EXTERNAL FUNCTIONS

  /**
   * @notice Initializes the strategy manager contract. Sets the `pauserRegistry` (currently **not** modifiable after being set),
   * and transfers contract ownership to the specified `initialOwner`.
   * @param _pauserRegistry Used for access control of pausing.
   * @param initialOwner Ownership of this contract is transferred to this address.
   * @param initialStrategyWhitelister The initial value of `strategyWhitelister` to set.
   * @param  initialPausedStatus The initial value of `_paused` to set.
   */
  function initialize(
    address initialOwner,
    address initialStrategyWhitelister,
    IPauserRegistry _pauserRegistry,
    uint256 initialPausedStatus
  ) external initializer {
    _DOMAIN_SEPARATOR = _calculateDomainSeparator();
    _initializePauser(_pauserRegistry, initialPausedStatus);
    _transferOwnership(initialOwner);
    _setStrategyWhitelister(initialStrategyWhitelister);
  }

  /**
   * @notice Deposits `amount` of `token` into the specified `strategy`, with the resultant shares credited to `msg.sender`
   * @param strategy is the specified strategy where deposit is to be made,
   * @param token is the denomination in which the deposit is to be made,
   * @param amount is the amount of token to be deposited in the strategy by the staker
   * @return shares The amount of new shares in the `strategy` created as part of the action.
   * @dev The `msg.sender` must have previously approved this contract to transfer at least `amount` of `token` on their behalf.
   *
   * WARNING: Depositing tokens that allow reentrancy (eg. ERC-777) into a strategy is not recommended.  This can lead to attack vectors
   *          where the token balance and corresponding strategy shares are not in sync upon reentrancy.
   */
  function depositIntoStrategy(
    IStrategy strategy,
    IERC20 token,
    uint256 amount
  ) external onlyWhenNotPaused(PAUSED_DEPOSITS) nonReentrant returns (uint256 shares) {
    shares = _depositIntoStrategy(msg.sender, strategy, token, amount);
  }

  /**
   * @notice Used for depositing an asset into the specified strategy with the resultant shares credited to `staker`,
   * who must sign off on the action.
   * Note that the assets are transferred out/from the `msg.sender`, not from the `staker`; this function is explicitly designed
   * purely to help one address deposit 'for' another.
   * @param strategy is the specified strategy where deposit is to be made,
   * @param token is the denomination in which the deposit is to be made,
   * @param amount is the amount of token to be deposited in the strategy by the staker
   * @param staker the staker that the deposited assets will be credited to
   * @param expiry the timestamp at which the signature expires
   * @param signature is a valid signature from the `staker`. either an ECDSA signature if the `staker` is an EOA, or data to forward
   * following EIP-1271 if the `staker` is a contract
   * @return shares The amount of new shares in the `strategy` created as part of the action.
   * @dev The `msg.sender` must have previously approved this contract to transfer at least `amount` of `token` on their behalf.
   * @dev A signature is required for this function to eliminate the possibility of griefing attacks, specifically those
   * targeting stakers who may be attempting to undelegate.
   * @dev Cannot be called if thirdPartyTransfersForbidden is set to true for this strategy
   *
   *  WARNING: Depositing tokens that allow reentrancy (eg. ERC-777) into a strategy is not recommended.  This can lead to attack vectors
   *          where the token balance and corresponding strategy shares are not in sync upon reentrancy
   */
  function depositIntoStrategyWithSignature(
    IStrategy strategy,
    IERC20 token,
    uint256 amount,
    address staker,
    uint256 expiry,
    bytes memory signature
  ) external onlyWhenNotPaused(PAUSED_DEPOSITS) nonReentrant returns (uint256 shares) {
    require(!thirdPartyTransfersForbidden[strategy], 'StrategyManager.depositIntoStrategyWithSignature: third transfers disabled');
    require(expiry >= block.timestamp, 'StrategyManager.depositIntoStrategyWithSignature: signature expired');
    // calculate struct hash, then increment `staker`'s nonce
    uint256 nonce = nonces[staker];
    bytes32 structHash = keccak256(abi.encode(DEPOSIT_TYPEHASH, staker, strategy, token, amount, nonce, expiry));
    unchecked {
      nonces[staker] = nonce + 1;
    }

    // calculate the digest hash
    bytes32 digestHash = keccak256(abi.encodePacked('\x19\x01', domainSeparator(), structHash));

    /**
     * check validity of signature:
     * 1) if `staker` is an EOA, then `signature` must be a valid ECDSA signature from `staker`,
     * indicating their intention for this action
     * 2) if `staker` is a contract, then `signature` will be checked according to EIP-1271
     */
    EIP1271SignatureUtils.checkSignature_EIP1271(staker, digestHash, signature);

    // deposit the tokens (from the `msg.sender`) and credit the new shares to the `staker`
    shares = _depositIntoStrategy(staker, strategy, token, amount);
  }

  /// @notice Used by the DelegationManager to remove a Staker's shares from a particular strategy when entering the withdrawal queue
  function removeShares(address staker, IStrategy strategy, uint256 shares) external onlyDelegationManager {
    _removeShares(staker, strategy, shares);
  }

  /// @notice Used by the DelegationManager to award a Staker some shares that have passed through the withdrawal queue
  function addShares(address staker, IERC20 token, IStrategy strategy, uint256 shares) external onlyDelegationManager {
    _addShares(staker, token, strategy, shares);
  }

  /// @notice Used by the DelegationManager to convert withdrawn shares to tokens and send them to a recipient
  function withdrawSharesAsTokens(address recipient, IStrategy strategy, uint256 shares, IERC20 token) external onlyDelegationManager {
    strategy.withdraw(recipient, token, shares);
  }

  /**
   * If true for a strategy, a user cannot depositIntoStrategyWithSignature into that strategy for another staker
   * and also when performing DelegationManager.queueWithdrawals, a staker can only withdraw to themselves.
   * Defaulted to false for all existing strategies.
   * @param strategy The strategy to set `thirdPartyTransfersForbidden` value to
   * @param value bool value to set `thirdPartyTransfersForbidden` to
   */
  function setThirdPartyTransfersForbidden(IStrategy strategy, bool value) external onlyStrategyWhitelister {
    _setThirdPartyTransfersForbidden(strategy, value);
  }

  /**
   * @notice Owner-only function to change the `strategyWhitelister` address.
   * @param newStrategyWhitelister new address for the `strategyWhitelister`.
   */
  function setStrategyWhitelister(address newStrategyWhitelister) external onlyOwner {
    _setStrategyWhitelister(newStrategyWhitelister);
  }

  /**
   * @notice Owner-only function that adds the provided Strategies to the 'whitelist' of strategies that stakers can deposit into
   * @param strategiesToWhitelist Strategies that will be added to the `strategyIsWhitelistedForDeposit` mapping (if they aren't in it already)
   * @param thirdPartyTransfersForbiddenValues bool values to set `thirdPartyTransfersForbidden` to for each strategy
   */
  function addStrategiesToDepositWhitelist(
    IStrategy[] calldata strategiesToWhitelist,
    bool[] calldata thirdPartyTransfersForbiddenValues
  ) external onlyStrategyWhitelister {
    require(
      strategiesToWhitelist.length == thirdPartyTransfersForbiddenValues.length,
      'StrategyManager.addStrategiesToDepositWhitelist: array lengths do not match'
    );
    uint256 strategiesToWhitelistLength = strategiesToWhitelist.length;
    for (uint256 i = 0; i < strategiesToWhitelistLength; ) {
      // change storage and emit event only if strategy is not already in whitelist
      if (!strategyIsWhitelistedForDeposit[strategiesToWhitelist[i]]) {
        strategyIsWhitelistedForDeposit[strategiesToWhitelist[i]] = true;
        emit StrategyAddedToDepositWhitelist(strategiesToWhitelist[i]);
        _setThirdPartyTransfersForbidden(strategiesToWhitelist[i], thirdPartyTransfersForbiddenValues[i]);
      }
      unchecked {
        ++i;
      }
    }
  }

  /**
   * @notice Owner-only function that removes the provided Strategies from the 'whitelist' of strategies that stakers can deposit into
   * @param strategiesToRemoveFromWhitelist Strategies that will be removed to the `strategyIsWhitelistedForDeposit` mapping (if they are in it)
   */
  function removeStrategiesFromDepositWhitelist(IStrategy[] calldata strategiesToRemoveFromWhitelist) external onlyStrategyWhitelister {
    uint256 strategiesToRemoveFromWhitelistLength = strategiesToRemoveFromWhitelist.length;
    for (uint256 i = 0; i < strategiesToRemoveFromWhitelistLength; ) {
      // change storage and emit event only if strategy is already in whitelist
      if (strategyIsWhitelistedForDeposit[strategiesToRemoveFromWhitelist[i]]) {
        strategyIsWhitelistedForDeposit[strategiesToRemoveFromWhitelist[i]] = false;
        emit StrategyRemovedFromDepositWhitelist(strategiesToRemoveFromWhitelist[i]);
        // Set mapping value to default false value
        _setThirdPartyTransfersForbidden(strategiesToRemoveFromWhitelist[i], false);
      }
      unchecked {
        ++i;
      }
    }
  }

  // INTERNAL FUNCTIONS

  /**
   * @notice This function adds `shares` for a given `strategy` to the `staker` and runs through the necessary update logic.
   * @param staker The address to add shares to
   * @param token The token that is being deposited (used for indexing)
   * @param strategy The Strategy in which the `staker` is receiving shares
   * @param shares The amount of shares to grant to the `staker`
   * @dev In particular, this function calls `delegation.increaseDelegatedShares(staker, strategy, shares)` to ensure that all
   * delegated shares are tracked, increases the stored share amount in `stakerStrategyShares[staker][strategy]`, and adds `strategy`
   * to the `staker`'s list of strategies, if it is not in the list already.
   */
  function _addShares(address staker, IERC20 token, IStrategy strategy, uint256 shares) internal {
    // sanity checks on inputs
    require(staker != address(0), 'StrategyManager._addShares: staker cannot be zero address');
    require(shares != 0, 'StrategyManager._addShares: shares should not be zero!');

    // if they dont have existing shares of this strategy, add it to their strats
    if (stakerStrategyShares[staker][strategy] == 0) {
      require(
        stakerStrategyList[staker].length < MAX_STAKER_STRATEGY_LIST_LENGTH,
        'StrategyManager._addShares: deposit would exceed MAX_STAKER_STRATEGY_LIST_LENGTH'
      );
      stakerStrategyList[staker].push(strategy);
    }

    // add the returned shares to their existing shares for this strategy
    stakerStrategyShares[staker][strategy] += shares;

    emit Deposit(staker, token, strategy, shares);
  }

  /**
   * @notice Internal function in which `amount` of ERC20 `token` is transferred from `msg.sender` to the Strategy-type contract
   * `strategy`, with the resulting shares credited to `staker`.
   * @param staker The address that will be credited with the new shares.
   * @param strategy The Strategy contract to deposit into.
   * @param token The ERC20 token to deposit.
   * @param amount The amount of `token` to deposit.
   * @return shares The amount of *new* shares in `strategy` that have been credited to the `staker`.
   */
  function _depositIntoStrategy(
    address staker,
    IStrategy strategy,
    IERC20 token,
    uint256 amount
  ) internal onlyStrategiesWhitelistedForDeposit(strategy) returns (uint256 shares) {
    // transfer tokens from the sender to the strategy
    token.safeTransferFrom(msg.sender, address(strategy), amount);

    // deposit the assets into the specified strategy and get the equivalent amount of shares in that strategy
    shares = strategy.deposit(token, amount);

    // add the returned shares to the staker's existing shares for this strategy
    _addShares(staker, token, strategy, shares);

    // Increase shares delegated to operator, if needed
    delegation.increaseDelegatedShares(staker, strategy, shares);

    return shares;
  }

  /**
   * @notice Decreases the shares that `staker` holds in `strategy` by `shareAmount`.
   * @param staker The address to decrement shares from
   * @param strategy The strategy for which the `staker`'s shares are being decremented
   * @param shareAmount The amount of shares to decrement
   * @dev If the amount of shares represents all of the staker`s shares in said strategy,
   * then the strategy is removed from stakerStrategyList[staker] and 'true' is returned. Otherwise 'false' is returned.
   */
  function _removeShares(address staker, IStrategy strategy, uint256 shareAmount) internal returns (bool) {
    // sanity checks on inputs
    require(shareAmount != 0, 'StrategyManager._removeShares: shareAmount should not be zero!');

    //check that the user has sufficient shares
    uint256 userShares = stakerStrategyShares[staker][strategy];

    require(shareAmount <= userShares, 'StrategyManager._removeShares: shareAmount too high');
    //unchecked arithmetic since we just checked this above
    unchecked {
      userShares = userShares - shareAmount;
    }

    // subtract the shares from the staker's existing shares for this strategy
    stakerStrategyShares[staker][strategy] = userShares;

    // if no existing shares, remove the strategy from the staker's dynamic array of strategies
    if (userShares == 0) {
      _removeStrategyFromStakerStrategyList(staker, strategy);

      // return true in the event that the strategy was removed from stakerStrategyList[staker]
      return true;
    }
    // return false in the event that the strategy was *not* removed from stakerStrategyList[staker]
    return false;
  }

  /**
   * @notice Removes `strategy` from `staker`'s dynamic array of strategies, i.e. from `stakerStrategyList[staker]`
   * @param staker The user whose array will have an entry removed
   * @param strategy The Strategy to remove from `stakerStrategyList[staker]`
   */
  function _removeStrategyFromStakerStrategyList(address staker, IStrategy strategy) internal {
    //loop through all of the strategies, find the right one, then replace
    uint256 stratsLength = stakerStrategyList[staker].length;
    uint256 j = 0;
    for (; j < stratsLength; ) {
      if (stakerStrategyList[staker][j] == strategy) {
        //replace the strategy with the last strategy in the list
        stakerStrategyList[staker][j] = stakerStrategyList[staker][stakerStrategyList[staker].length - 1];
        break;
      }
      unchecked {
        ++j;
      }
    }
    // if we didn't find the strategy, revert
    require(j != stratsLength, 'StrategyManager._removeStrategyFromStakerStrategyList: strategy not found');
    // pop off the last entry in the list of strategies
    stakerStrategyList[staker].pop();
  }

  /**
   * @notice Internal function for modifying `thirdPartyTransfersForbidden`.
   * Used inside of the `setThirdPartyTransfersForbidden` and `addStrategiesToDepositWhitelist` functions.
   * @param strategy The strategy to set `thirdPartyTransfersForbidden` value to
   * @param value bool value to set `thirdPartyTransfersForbidden` to
   */
  function _setThirdPartyTransfersForbidden(IStrategy strategy, bool value) internal {
    emit UpdatedThirdPartyTransfersForbidden(strategy, value);
    thirdPartyTransfersForbidden[strategy] = value;
  }

  /**
   * @notice Internal function for modifying the `strategyWhitelister`. Used inside of the `setStrategyWhitelister` and `initialize` functions.
   * @param newStrategyWhitelister The new address for the `strategyWhitelister` to take.
   */
  function _setStrategyWhitelister(address newStrategyWhitelister) internal {
    emit StrategyWhitelisterChanged(strategyWhitelister, newStrategyWhitelister);
    strategyWhitelister = newStrategyWhitelister;
  }

  // VIEW FUNCTIONS
  /**
   * @notice Get all details on the staker's deposits and corresponding shares
   * @param staker The staker of interest, whose deposits this function will fetch
   * @return (staker's strategies, shares in these strategies)
   */
  function getDeposits(address staker) external view returns (IStrategy[] memory, uint256[] memory) {
    uint256 strategiesLength = stakerStrategyList[staker].length;
    uint256[] memory shares = new uint256[](strategiesLength);

    for (uint256 i = 0; i < strategiesLength; ) {
      shares[i] = stakerStrategyShares[staker][stakerStrategyList[staker][i]];
      unchecked {
        ++i;
      }
    }
    return (stakerStrategyList[staker], shares);
  }

  /// @notice Simple getter function that returns `stakerStrategyList[staker].length`.
  function stakerStrategyListLength(address staker) external view returns (uint256) {
    return stakerStrategyList[staker].length;
  }

  /**
   * @notice Getter function for the current EIP-712 domain separator for this contract.
   * @dev The domain separator will change in the event of a fork that changes the ChainID.
   */
  function domainSeparator() public view returns (bytes32) {
    if (block.chainid == ORIGINAL_CHAIN_ID) {
      return _DOMAIN_SEPARATOR;
    } else {
      return _calculateDomainSeparator();
    }
  }

  // @notice Internal function for calculating the current domain separator of this contract
  function _calculateDomainSeparator() internal view returns (bytes32) {
    return keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes('Pell')), block.chainid, address(this)));
  }
}

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

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
    address private _owner;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal onlyInitializing {
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal onlyInitializing {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. 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);
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```solidity
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 *
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint8 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
     * constructor.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 1;
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: setting the version to 255 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized != type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint8) {
        return _initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _initializing;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;
import {Initializable} from "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuardUpgradeable is Initializable {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    function __ReentrancyGuard_init() internal onlyInitializing {
        __ReentrancyGuard_init_unchained();
    }

    function __ReentrancyGuard_init_unchained() internal onlyInitializing {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == _ENTERED;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)

pragma solidity ^0.8.0;
import {Initializable} from "../proxy/utils/Initializable.sol";

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract ContextUpgradeable is Initializable {
    function __Context_init() internal onlyInitializing {
    }

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

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

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC1271.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC1271 standard signature validation method for
 * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].
 *
 * _Available since v4.1._
 */
interface IERC1271 {
    /**
     * @dev Should return whether the signature provided is valid for the provided data
     * @param hash      Hash of the data to be signed
     * @param signature Signature byte array associated with _data
     */
    function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 amount) external returns (bool);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     *
     * CAUTION: See Security Considerations above.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return
            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

// SPDX-License-Identifier: 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));
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV // Deprecated in v4.8
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            /// @solidity memory-safe-assembly
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) {
        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
        uint8 v = uint8((uint256(vs) >> 255) + 27);
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, "\x19Ethereum Signed Message:\n32")
            mstore(0x1c, hash)
            message := keccak256(0x00, 0x3c)
        }
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from `s`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, "\x19\x01")
            mstore(add(ptr, 0x02), domainSeparator)
            mstore(add(ptr, 0x22), structHash)
            data := keccak256(ptr, 0x42)
        }
    }

    /**
     * @dev Returns an Ethereum Signed Data with intended validator, created from a
     * `validator` and `data` according to the version 0 of EIP-191.
     *
     * See {recover}.
     */
    function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x00", validator, data));
    }
}

// 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);
        }
    }
}

// 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 16 of 25 : StrategyManagerStorage.sol
// SPDX-License-Identifier: LGPL-3.0
pragma solidity 0.8.20;

import '../interfaces/IStrategyManager.sol';
import '../interfaces/IStrategy.sol';
import '../interfaces/IDelegationManager.sol';
import '../interfaces/ISlasher.sol';

/**
 * @title Storage variables for the `StrategyManager` contract.
 * @notice This storage contract is separate from the logic to simplify the upgrade process.
 */
abstract contract StrategyManagerStorage is IStrategyManager {
  /// @notice The EIP-712 typehash for the contract's domain
  bytes32 public constant DOMAIN_TYPEHASH = keccak256('EIP712Domain(string name,uint256 chainId,address verifyingContract)');
  /// @notice The EIP-712 typehash for the deposit struct used by the contract
  bytes32 public constant DEPOSIT_TYPEHASH =
    keccak256('Deposit(address staker,address strategy,address token,uint256 amount,uint256 nonce,uint256 expiry)');
  // maximum length of dynamic arrays in `stakerStrategyList` mapping, for sanity's sake
  uint8 internal constant MAX_STAKER_STRATEGY_LIST_LENGTH = 32;

  // system contracts
  IDelegationManager public immutable delegation;
  ISlasher public immutable slasher;

  /**
   * @notice Original EIP-712 Domain separator for this contract.
   * @dev The domain separator may change in the event of a fork that modifies the ChainID.
   * Use the getter function `domainSeparator` to get the current domain separator for this contract.
   */
  bytes32 internal _DOMAIN_SEPARATOR;
  // staker => number of signed deposit nonce (used in depositIntoStrategyWithSignature)
  mapping(address => uint256) public nonces;
  /// @notice Permissioned role, which can be changed by the contract owner. Has the ability to edit the strategy whitelist
  address public strategyWhitelister;
  /// @notice Mapping: staker => Strategy => number of shares which they currently hold
  mapping(address => mapping(IStrategy => uint256)) public stakerStrategyShares;
  /// @notice Mapping: staker => array of strategies in which they have nonzero shares
  mapping(address => IStrategy[]) public stakerStrategyList;
  /// @notice Mapping: strategy => whether or not stakers are allowed to deposit into it
  mapping(IStrategy => bool) public strategyIsWhitelistedForDeposit;

  /**
   * @notice Mapping: strategy => whether or not stakers are allowed to transfer strategy shares to another address
   * if true for a strategy, a user cannot depositIntoStrategyWithSignature into that strategy for another staker
   * and also when performing queueWithdrawals, a staker can only withdraw to themselves
   */
  mapping(IStrategy => bool) public thirdPartyTransfersForbidden;

  constructor(IDelegationManager _delegation, ISlasher _slasher) {
    delegation = _delegation;
    slasher = _slasher;
  }

  /**
   * @dev This empty reserved space is put in place to allow future versions to add new
   * variables without shifting down storage in the inheritance chain.
   * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
   */
  uint256[49] private __gap;
}

File 17 of 25 : IDelegationManager.sol
// SPDX-License-Identifier: LGPL-3.0
pragma solidity 0.8.20;

import './IStrategy.sol';
import './ISignatureUtils.sol';
import './IStrategyManager.sol';

/**
 * @title DelegationManager
 * @notice  This is the contract for delegation in Pell. The main functionalities of this contract are
 * - enabling anyone to register as an operator in Pell
 * - allowing operators to specify parameters related to stakers who delegate to them
 * - enabling any staker to delegate its stake to the operator of its choice (a given staker can only delegate to a single operator at a time)
 * - enabling a staker to undelegate its assets from the operator it is delegated to (performed as part of the withdrawal process, initiated through the StrategyManager)
 */
interface IDelegationManager is ISignatureUtils {
  // @notice Struct used for storing information about a single operator who has registered with Pell
  struct OperatorDetails {
    // @notice address to receive the rewards that the operator earns via serving applications built on Pell.
    address earningsReceiver;
    /**
     * @notice Address to verify signatures when a staker wishes to delegate to the operator, as well as controlling "forced undelegations".
     * @dev Signature verification follows these rules:
     * 1) If this address is left as address(0), then any staker will be free to delegate to the operator, i.e. no signature verification will be performed.
     * 2) If this address is an EOA (i.e. it has no code), then we follow standard ECDSA signature verification for delegations to the operator.
     * 3) If this address is a contract (i.e. it has code) then we forward a call to the contract and verify that it returns the correct EIP-1271 "magic value".
     */
    address delegationApprover;
    /**
     * @notice A minimum delay -- enforced between:
     * 1) the operator signalling their intent to register for a service, via calling `Slasher.optIntoSlashing`
     * and
     * 2) the operator completing registration for the service, via the service ultimately calling `Slasher.recordFirstStakeUpdate`
     * @dev note that for a specific operator, this value *cannot decrease*, i.e. if the operator wishes to modify their OperatorDetails,
     * then they are only allowed to either increase this value or keep it the same.
     */
    uint32 stakerOptOutWindow;
  }

  /**
   * @notice Abstract struct used in calculating an EIP712 signature for a staker to approve that they (the staker themselves) delegate to a specific operator.
   * @dev Used in computing the `STAKER_DELEGATION_TYPEHASH` and as a reference in the computation of the stakerDigestHash in the `delegateToBySignature` function.
   */
  struct StakerDelegation {
    // the staker who is delegating
    address staker;
    // the operator being delegated to
    address operator;
    // the staker's nonce
    uint256 nonce;
    // the expiration timestamp (UTC) of the signature
    uint256 expiry;
  }

  /**
   * @notice Abstract struct used in calculating an EIP712 signature for an operator's delegationApprover to approve that a specific staker delegate to the operator.
   * @dev Used in computing the `DELEGATION_APPROVAL_TYPEHASH` and as a reference in the computation of the approverDigestHash in the `_delegate` function.
   */
  struct DelegationApproval {
    // the staker who is delegating
    address staker;
    // the operator being delegated to
    address operator;
    // the operator's provided salt
    bytes32 salt;
    // the expiration timestamp (UTC) of the signature
    uint256 expiry;
  }

  /**
   * Struct type used to specify an existing queued withdrawal. Rather than storing the entire struct, only a hash is stored.
   * In functions that operate on existing queued withdrawals -- e.g. completeQueuedWithdrawal`, the data is resubmitted and the hash of the submitted
   * data is computed by `calculateWithdrawalRoot` and checked against the stored hash in order to confirm the integrity of the submitted data.
   */
  struct Withdrawal {
    // The address that originated the Withdrawal
    address staker;
    // The address that the staker was delegated to at the time that the Withdrawal was created
    address delegatedTo;
    // The address that can complete the Withdrawal + will receive funds when completing the withdrawal
    address withdrawer;
    // Nonce used to guarantee that otherwise identical withdrawals have unique hashes
    uint256 nonce;
    // Block timestamp when the Withdrawal was created
    uint32 startTimestamp;
    // Array of strategies that the Withdrawal contains
    IStrategy[] strategies;
    // Array containing the amount of shares in each Strategy in the `strategies` array
    uint256[] shares;
  }

  struct QueuedWithdrawalParams {
    // Array of strategies that the QueuedWithdrawal contains
    IStrategy[] strategies;
    // Array containing the amount of shares in each Strategy in the `strategies` array
    uint256[] shares;
    // The address of the withdrawer
    address withdrawer;
  }

  // @notice Emitted when a new operator registers in Pell and provides their OperatorDetails.
  event OperatorRegistered(address indexed operator, OperatorDetails operatorDetails);

  /// @notice Emitted when an operator updates their OperatorDetails to @param newOperatorDetails
  event OperatorDetailsModified(address indexed operator, OperatorDetails newOperatorDetails);

  /**
   * @notice Emitted when @param operator indicates that they are updating their MetadataURI string
   * @dev Note that these strings are *never stored in storage* and are instead purely emitted in events for off-chain indexing
   */
  event OperatorMetadataURIUpdated(address indexed operator, string metadataURI);

  /// @notice Emitted whenever an operator's shares are increased for a given strategy. Note that shares is the delta in the operator's shares.
  event OperatorSharesIncreased(address indexed operator, address staker, IStrategy strategy, uint256 shares);

  /// @notice Emitted whenever an operator's shares are decreased for a given strategy. Note that shares is the delta in the operator's shares.
  event OperatorSharesDecreased(address indexed operator, address staker, IStrategy strategy, uint256 shares);

  /// @notice Emitted when @param staker delegates to @param operator.
  event StakerDelegated(address indexed staker, address indexed operator);

  /// @notice Emitted when @param staker undelegates from @param operator.
  event StakerUndelegated(address indexed staker, address indexed operator);

  /// @notice Emitted when @param staker is undelegated via a call not originating from the staker themself
  event StakerForceUndelegated(address indexed staker, address indexed operator);

  /**
   * @notice Emitted when a new withdrawal is queued.
   * @param withdrawalRoot Is the hash of the `withdrawal`.
   * @param withdrawal Is the withdrawal itself.
   */
  event WithdrawalQueued(bytes32 withdrawalRoot, Withdrawal withdrawal);

  /// @notice Emitted when a queued withdrawal is completed
  event WithdrawalCompleted(bytes32 withdrawalRoot);

  /// @notice Emitted when the `minWithdrawalDelay` variable is modified from `previousValue` to `newValue`.
  event MinWithdrawalDelaySet(uint256 previousValue, uint256 newValue);

  /// @notice Emitted when the `strategyWithdrawalDelay` variable is modified from `previousValue` to `newValue`.
  event StrategyWithdrawalDelaySet(IStrategy strategy, uint256 previousValue, uint256 newValue);

  event UpdateWrappedTokenGateway(address previousGateway, address currentGateway);

  /**
   * @notice Registers the caller as an operator in Pell.
   * @param registeringOperatorDetails is the `OperatorDetails` for the operator.
   * @param metadataURI is a URI for the operator's metadata, i.e. a link providing more details on the operator.
   *
   * @dev Once an operator is registered, they cannot 'deregister' as an operator, and they will forever be considered "delegated to themself".
   * @dev This function will revert if the caller attempts to set their `earningsReceiver` to address(0).
   * @dev Note that the `metadataURI` is *never stored * and is only emitted in the `OperatorMetadataURIUpdated` event
   */
  function registerAsOperator(OperatorDetails calldata registeringOperatorDetails, string calldata metadataURI) external;

  /**
   * @notice Updates an operator's stored `OperatorDetails`.
   * @param newOperatorDetails is the updated `OperatorDetails` for the operator, to replace their current OperatorDetails`.
   *
   * @dev The caller must have previously registered as an operator in Pell.
   * @dev This function will revert if the caller attempts to set their `earningsReceiver` to address(0).
   */
  function modifyOperatorDetails(OperatorDetails calldata newOperatorDetails) external;

  /**
   * @notice Called by an operator to emit an `OperatorMetadataURIUpdated` event indicating the information has updated.
   * @param metadataURI The URI for metadata associated with an operator
   * @dev Note that the `metadataURI` is *never stored * and is only emitted in the `OperatorMetadataURIUpdated` event
   */
  function updateOperatorMetadataURI(string calldata metadataURI) external;

  /**
   * @notice Caller delegates their stake to an operator.
   * @param operator The account (`msg.sender`) is delegating its assets to for use in serving applications built on Pell.
   * @param approverSignatureAndExpiry Verifies the operator approves of this delegation
   * @param approverSalt A unique single use value tied to an individual signature.
   * @dev The approverSignatureAndExpiry is used in the event that:
   *          1) the operator's `delegationApprover` address is set to a non-zero value.
   *                  AND
   *          2) neither the operator nor their `delegationApprover` is the `msg.sender`, since in the event that the operator
   *             or their delegationApprover is the `msg.sender`, then approval is assumed.
   * @dev In the event that `approverSignatureAndExpiry` is not checked, its content is ignored entirely; it's recommended to use an empty input
   * in this case to save on complexity + gas costs
   */
  function delegateTo(address operator, SignatureWithExpiry memory approverSignatureAndExpiry, bytes32 approverSalt) external;

  /**
   * @notice Caller delegates a staker's stake to an operator with valid signatures from both parties.
   * @param staker The account delegating stake to an `operator` account
   * @param operator The account (`staker`) is delegating its assets to for use in serving applications built on Pell.
   * @param stakerSignatureAndExpiry Signed data from the staker authorizing delegating stake to an operator
   * @param approverSignatureAndExpiry is a parameter that will be used for verifying that the operator approves of this delegation action in the event that:
   * @param approverSalt Is a salt used to help guarantee signature uniqueness. Each salt can only be used once by a given approver.
   *
   * @dev If `staker` is an EOA, then `stakerSignature` is verified to be a valid ECDSA stakerSignature from `staker`, indicating their intention for this action.
   * @dev If `staker` is a contract, then `stakerSignature` will be checked according to EIP-1271.
   * @dev the operator's `delegationApprover` address is set to a non-zero value.
   * @dev neither the operator nor their `delegationApprover` is the `msg.sender`, since in the event that the operator or their delegationApprover
   * is the `msg.sender`, then approval is assumed.
   * @dev This function will revert if the current `block.timestamp` is equal to or exceeds the expiry
   * @dev In the case that `approverSignatureAndExpiry` is not checked, its content is ignored entirely; it's recommended to use an empty input
   * in this case to save on complexity + gas costs
   */
  function delegateToBySignature(
    address staker,
    address operator,
    SignatureWithExpiry memory stakerSignatureAndExpiry,
    SignatureWithExpiry memory approverSignatureAndExpiry,
    bytes32 approverSalt
  ) external;

  /**
   * @notice Undelegates the staker from the operator who they are delegated to. Puts the staker into the "undelegation limbo" mode of the EigenPodManager
   * and queues a withdrawal of all of the staker's shares in the StrategyManager (to the staker), if necessary.
   * @param staker The account to be undelegated.
   * @return withdrawalRoot The root of the newly queued withdrawal, if a withdrawal was queued. Otherwise just bytes32(0).
   *
   * @dev Reverts if the `staker` is also an operator, since operators are not allowed to undelegate from themselves.
   * @dev Reverts if the caller is not the staker, nor the operator who the staker is delegated to, nor the operator's specified "delegationApprover"
   * @dev Reverts if the `staker` is already undelegated.
   */
  function undelegate(address staker) external returns (bytes32[] memory withdrawalRoot);

  /**
   * Allows a staker to withdraw some shares. Withdrawn shares/strategies are immediately removed
   * from the staker. If the staker is delegated, withdrawn shares/strategies are also removed from
   * their operator.
   *
   * All withdrawn shares/strategies are placed in a queue and can be fully withdrawn after a delay.
   */
  function queueWithdrawals(QueuedWithdrawalParams[] calldata queuedWithdrawalParams) external returns (bytes32[] memory);

  /**
   * @notice Used to complete the specified `withdrawal`. The caller must match `withdrawal.withdrawer`
   * @param withdrawal The Withdrawal to complete.
   * @param tokens Array in which the i-th entry specifies the `token` input to the 'withdraw' function of the i-th Strategy in the `withdrawal.strategies` array.
   * This input can be provided with zero length if `receiveAsTokens` is set to 'false' (since in that case, this input will be unused)
   * @param middlewareTimesIndex is the index in the operator that the staker who triggered the withdrawal was delegated to's middleware times array
   * @param receiveAsTokens If true, the shares specified in the withdrawal will be withdrawn from the specified strategies themselves
   * and sent to the caller, through calls to `withdrawal.strategies[i].withdraw`. If false, then the shares in the specified strategies
   * will simply be transferred to the caller directly.
   * @dev middlewareTimesIndex should be calculated off chain before calling this function by finding the first index that satisfies `slasher.canWithdraw`
   * @dev beaconChainETHStrategy shares are non-transferrable, so if `receiveAsTokens = false` and `withdrawal.withdrawer != withdrawal.staker`, note that
   * any beaconChainETHStrategy shares in the `withdrawal` will be _returned to the staker_, rather than transferred to the withdrawer, unlike shares in
   * any other strategies, which will be transferred to the withdrawer.
   */
  function completeQueuedWithdrawal(
    Withdrawal calldata withdrawal,
    IERC20[] calldata tokens,
    uint256 middlewareTimesIndex,
    bool receiveAsTokens
  ) external;

  /**
   * @notice Array-ified version of `completeQueuedWithdrawal`.
   * Used to complete the specified `withdrawals`. The function caller must match `withdrawals[...].withdrawer`
   * @param withdrawals The Withdrawals to complete.
   * @param tokens Array of tokens for each Withdrawal. See `completeQueuedWithdrawal` for the usage of a single array.
   * @param middlewareTimesIndexes One index to reference per Withdrawal. See `completeQueuedWithdrawal` for the usage of a single index.
   * @param receiveAsTokens Whether or not to complete each withdrawal as tokens. See `completeQueuedWithdrawal` for the usage of a single boolean.
   * @dev See `completeQueuedWithdrawal` for relevant dev tags
   */
  function completeQueuedWithdrawals(
    Withdrawal[] calldata withdrawals,
    IERC20[][] calldata tokens,
    uint256[] calldata middlewareTimesIndexes,
    bool[] calldata receiveAsTokens
  ) external;

  /**
   * @notice Increases a staker's delegated share balance in a strategy.
   * @param staker The address to increase the delegated shares for their operator.
   * @param strategy The strategy in which to increase the delegated shares.
   * @param shares The number of shares to increase.
   *
   * @dev *If the staker is actively delegated*, then increases the `staker`'s delegated shares in `strategy` by `shares`. Otherwise does nothing.
   * @dev Callable only by the StrategyManager or EigenPodManager.
   */
  function increaseDelegatedShares(address staker, IStrategy strategy, uint256 shares) external;

  /**
   * @notice Decreases a staker's delegated share balance in a strategy.
   * @param staker The address to increase the delegated shares for their operator.
   * @param strategy The strategy in which to decrease the delegated shares.
   * @param shares The number of shares to decrease.
   *
   * @dev *If the staker is actively delegated*, then decreases the `staker`'s delegated shares in `strategy` by `shares`. Otherwise does nothing.
   * @dev Callable only by the StrategyManager or EigenPodManager.
   */
  function decreaseDelegatedShares(address staker, IStrategy strategy, uint256 shares) external;

  /**
   * @notice returns the address of the operator that `staker` is delegated to.
   * @notice Mapping: staker => operator whom the staker is currently delegated to.
   * @dev Note that returning address(0) indicates that the staker is not actively delegated to any operator.
   */
  function delegatedTo(address staker) external view returns (address);

  /**
   * @notice Returns the OperatorDetails struct associated with an `operator`.
   */
  function operatorDetails(address operator) external view returns (OperatorDetails memory);

  /*
   * @notice Returns the earnings receiver address for an operator
   */
  function earningsReceiver(address operator) external view returns (address);

  /**
   * @notice Returns the delegationApprover account for an operator
   */
  function delegationApprover(address operator) external view returns (address);

  /**
   * @notice Returns the stakerOptOutWindow for an operator
   */
  function stakerOptOutWindow(address operator) external view returns (uint256);

  /**
   * @notice Given array of strategies, returns array of shares for the operator
   */
  function getOperatorShares(address operator, IStrategy[] memory strategies) external view returns (uint256[] memory);

  /**
   * @notice Given a list of strategies, return the minimum cooldown that must pass to withdraw
   * from all the inputted strategies. Return value is >= minWithdrawalDelay as this is the global min withdrawal delay.
   * @param strategies The strategies to check withdrawal delays for
   */
  function getWithdrawalDelay(IStrategy[] calldata strategies) external view returns (uint256);

  /**
   * @notice returns the total number of shares in `strategy` that are delegated to `operator`.
   * @notice Mapping: operator => strategy => total number of shares in the strategy delegated to the operator.
   * @dev By design, the following invariant should hold for each Strategy:
   * (operator's shares in delegation manager) = sum (shares above zero of all stakers delegated to operator)
   * = sum (delegateable shares of all stakers delegated to the operator)
   */
  function operatorShares(address operator, IStrategy strategy) external view returns (uint256);

  /**
   * @notice Returns 'true' if `staker` *is* actively delegated, and 'false' otherwise.
   */
  function isDelegated(address staker) external view returns (bool);

  /**
   * @notice Returns true is an operator has previously registered for delegation.
   */
  function isOperator(address operator) external view returns (bool);

  /// @notice Mapping: staker => number of signed delegation nonces (used in `delegateToBySignature`) from the staker that the contract has already checked
  function stakerNonce(address staker) external view returns (uint256);

  /**
   * @notice Mapping: delegationApprover => 32-byte salt => whether or not the salt has already been used by the delegationApprover.
   * @dev Salts are used in the `delegateTo` and `delegateToBySignature` functions. Note that these functions only process the delegationApprover's
   * signature + the provided salt if the operator being delegated to has specified a nonzero address as their `delegationApprover`.
   */
  function delegationApproverSaltIsSpent(address _delegationApprover, bytes32 salt) external view returns (bool);

  /**
   * @notice Minimum delay enforced by this contract for completing queued withdrawals. Cooldown, and adjustable by this contract's owner,
   * up to a maximum of `MAX_WITHDRAWAL_DELAY`. Minimum value is 0 (i.e. no delay enforced).
   * Note that strategies each have a separate withdrawal delay, which can be greater than this value. So the minimum cooldown that must pass
   * to withdraw a strategy is MAX(minWithdrawalDelay, strategyWithdrawalDelay[strategy])
   */
  function minWithdrawalDelay() external view returns (uint256);

  /**
   * @notice Minimum delay enforced by this contract per Strategy for completing queued withdrawals. Cooldown, and adjustable by this contract's owner,
   * up to a maximum of `MAX_WITHDRAWAL_DELAY`. Minimum value is 0 (i.e. no delay enforced).
   */
  function strategyWithdrawalDelay(IStrategy strategy) external view returns (uint256);

  /**
   * @notice Calculates the digestHash for a `staker` to sign to delegate to an `operator`
   * @param staker The signing staker
   * @param operator The operator who is being delegated to
   * @param expiry The desired expiry time of the staker's signature
   */
  function calculateCurrentStakerDelegationDigestHash(address staker, address operator, uint256 expiry) external view returns (bytes32);

  /**
   * @notice Calculates the digest hash to be signed and used in the `delegateToBySignature` function
   * @param staker The signing staker
   * @param _stakerNonce The nonce of the staker. In practice we use the staker's current nonce, stored at `stakerNonce[staker]`
   * @param operator The operator who is being delegated to
   * @param expiry The desired expiry time of the staker's signature
   */
  function calculateStakerDelegationDigestHash(
    address staker,
    uint256 _stakerNonce,
    address operator,
    uint256 expiry
  ) external view returns (bytes32);

  /**
   * @notice Calculates the digest hash to be signed by the operator's delegationApprove and used in the `delegateTo` and `delegateToBySignature` functions.
   * @param staker The account delegating their stake
   * @param operator The account receiving delegated stake
   * @param _delegationApprover the operator's `delegationApprover` who will be signing the delegationHash (in general)
   * @param approverSalt A unique and single use value associated with the approver signature.
   * @param expiry Time after which the approver's signature becomes invalid
   */
  function calculateDelegationApprovalDigestHash(
    address staker,
    address operator,
    address _delegationApprover,
    bytes32 approverSalt,
    uint256 expiry
  ) external view returns (bytes32);

  /// @notice The EIP-712 typehash for the contract's domain
  function DOMAIN_TYPEHASH() external view returns (bytes32);

  /// @notice The EIP-712 typehash for the StakerDelegation struct used by the contract
  function STAKER_DELEGATION_TYPEHASH() external view returns (bytes32);

  /// @notice The EIP-712 typehash for the DelegationApproval struct used by the contract
  function DELEGATION_APPROVAL_TYPEHASH() external view returns (bytes32);

  /**
   * @notice Getter function for the current EIP-712 domain separator for this contract.
   *
   * @dev The domain separator will change in the event of a fork that changes the ChainID.
   * @dev By introducing a domain separator the DApp developers are guaranteed that there can be no signature collision.
   * for more detailed information please read EIP-712.
   */
  function domainSeparator() external view returns (bytes32);

  /// @notice Mapping: staker => cumulative number of queued withdrawals they have ever initiated.
  /// @dev This only increments (doesn't decrement), and is used to help ensure that otherwise identical withdrawals have unique hashes.
  function cumulativeWithdrawalsQueued(address staker) external view returns (uint256);

  /// @notice Returns the keccak256 hash of `withdrawal`.
  function calculateWithdrawalRoot(Withdrawal memory withdrawal) external pure returns (bytes32);
}

// SPDX-License-Identifier: LGPL-3.0
pragma solidity 0.8.20;

import '../interfaces/IPauserRegistry.sol';

/**
 * @title Adds pausability to a contract, with pausing & unpausing controlled by the `pauser` and `unpauser` of a PauserRegistry contract.
 * @notice Contracts that inherit from this contract may define their own `pause` and `unpause` (and/or related) functions.
 * These functions should be permissioned as "onlyPauser" which defers to a `PauserRegistry` for determining access control.
 * @dev Pausability is implemented using a uint256, which allows up to 256 different single bit-flags; each bit can potentially pause different functionality.
 * Inspiration for this was taken from the NearBridge design here https://etherscan.io/address/0x3FEFc5A4B1c02f21cBc8D3613643ba0635b9a873#code.
 * For the `pause` and `unpause` functions we've implemented, if you pause, you can only flip (any number of) switches to on/1 (aka "paused"), and if you unpause,
 * you can only flip (any number of) switches to off/0 (aka "paused").
 * If you want a pauseXYZ function that just flips a single bit / "pausing flag", it will:
 * 1) 'bit-wise and' (aka `&`) a flag with the current paused state (as a uint256)
 * 2) update the paused state to this new value
 * @dev We note as well that we have chosen to identify flags by their *bit index* as opposed to their numerical value, so, e.g. defining `DEPOSITS_PAUSED = 3`
 * indicates specifically that if the *third bit* of `_paused` is flipped -- i.e. it is a '1' -- then deposits should be paused
 */

interface IPausable {
  /// @notice Emitted when the `pauserRegistry` is set to `newPauserRegistry`.
  event PauserRegistrySet(IPauserRegistry pauserRegistry, IPauserRegistry newPauserRegistry);

  /// @notice Emitted when the pause is triggered by `account`, and changed to `newPausedStatus`.
  event Paused(address indexed account, uint256 newPausedStatus);

  /// @notice Emitted when the pause is lifted by `account`, and changed to `newPausedStatus`.
  event Unpaused(address indexed account, uint256 newPausedStatus);

  /// @notice Address of the `PauserRegistry` contract that this contract defers to for determining access control (for pausing).
  function pauserRegistry() external view returns (IPauserRegistry);

  /**
   * @notice This function is used to pause an Pell contract's functionality.
   * It is permissioned to the `pauser` address, which is expected to be a low threshold multisig.
   * @param newPausedStatus represents the new value for `_paused` to take, which means it may flip several bits at once.
   * @dev This function can only pause functionality, and thus cannot 'unflip' any bit in `_paused` from 1 to 0.
   */
  function pause(uint256 newPausedStatus) external;

  /**
   * @notice Alias for `pause(type(uint256).max)`.
   */
  function pauseAll() external;

  /**
   * @notice This function is used to unpause an Pell contract's functionality.
   * It is permissioned to the `unpauser` address, which is expected to be a high threshold multisig or governance contract.
   * @param newPausedStatus represents the new value for `_paused` to take, which means it may flip several bits at once.
   * @dev This function can only unpause functionality, and thus cannot 'flip' any bit in `_paused` from 0 to 1.
   */
  function unpause(uint256 newPausedStatus) external;

  /// @notice Returns the current paused status as a uint256.
  function paused() external view returns (uint256);

  /// @notice Returns 'true' if the `indexed`th bit of `_paused` is 1, and 'false' otherwise
  function paused(uint8 index) external view returns (bool);

  /// @notice Allows the unpauser to set a new pauser registry
  function setPauserRegistry(IPauserRegistry newPauserRegistry) external;
}

// SPDX-License-Identifier: LGPL-3.0
pragma solidity 0.8.20;

/**
 * @title Interface for the `PauserRegistry` contract.
 */
interface IPauserRegistry {
  event PauserStatusChanged(address pauser, bool canPause);

  event UnpauserChanged(address previousUnpauser, address newUnpauser);

  /// @notice Mapping of addresses to whether they hold the pauser role.
  function isPauser(address pauser) external view returns (bool);

  /// @notice Unique address that holds the unpauser role. Capable of changing *both* the pauser and unpauser addresses.
  function unpauser() external view returns (address);
}

File 20 of 25 : ISignatureUtils.sol
// SPDX-License-Identifier: LGPL-3.0
pragma solidity 0.8.20;

/**
 * @title The interface for common signature utilities.
 */
interface ISignatureUtils {
  // @notice Struct that bundles together a signature and an expiration time for the signature. Used primarily for stack management.
  struct SignatureWithExpiry {
    // the signature itself, formatted as a single bytes object
    bytes signature;
    // the expiration timestamp (UTC) of the signature
    uint256 expiry;
  }

  // @notice Struct that bundles together a signature, a salt for uniqueness, and an expiration time for the signature. Used primarily for stack management.
  struct SignatureWithSaltAndExpiry {
    // the signature itself, formatted as a single bytes object
    bytes signature;
    // the salt used to generate the signature
    bytes32 salt;
    // the expiration timestamp (UTC) of the signature
    uint256 expiry;
  }
}

// SPDX-License-Identifier: LGPL-3.0
pragma solidity 0.8.20;

import './IStrategyManager.sol';
import './IDelegationManager.sol';

/**
 * @title Interface for the primary 'slashing' contract for Pell.
 * @notice See the `Slasher` contract itself for implementation details.
 */
interface ISlasher {
  // struct used to store information about the current state of an operator's obligations to middlewares they are serving
  struct MiddlewareTimes {
    // The update timestamp for the middleware whose most recent update was earliest, i.e. the 'stalest' update out of all middlewares the operator is serving
    uint32 stalestUpdateTimestamp;
    // The latest 'serveUntilTimestamp' from all of the middleware that the operator is serving
    uint32 latestServeUntilTimestamp;
  }

  // struct used to store details relevant to a single middleware that an operator has opted-in to serving
  struct MiddlewareDetails {
    // the timestamp at which the contract begins being able to finalize the operator's registration with the service via calling `recordFirstStakeUpdate`
    uint32 registrationMayBeginAtTimestamp;
    // the timestamp before which the contract is allowed to slash the user
    uint32 contractCanSlashOperatorUntilTimestamp;
    // the timestamp at which the middleware's view of the operator's stake was most recently updated
    uint32 latestUpdateTimestamp;
  }

  /// @notice Emitted when a middleware times is added to `operator`'s array.
  event MiddlewareTimesAdded(address operator, uint256 index, uint32 stalestUpdateTimestamp, uint32 latestServeUntilTimestamp);

  /// @notice Emitted when `operator` begins to allow `contractAddress` to slash them.
  event OptedIntoSlashing(address indexed operator, address indexed contractAddress);

  /// @notice Emitted when `contractAddress` signals that it will no longer be able to slash `operator` after the `contractCanSlashOperatorUntilTimestamp`.
  event SlashingAbilityRevoked(address indexed operator, address indexed contractAddress, uint32 contractCanSlashOperatorUntilTimestamp);

  /**
   * @notice Emitted when `slashingContract` 'freezes' the `slashedOperator`.
   * @dev The `slashingContract` must have permission to slash the `slashedOperator`, i.e. `canSlash(slasherOperator, slashingContract)` must return 'true'.
   */
  event OperatorFrozen(address indexed slashedOperator, address indexed slashingContract);

  /// @notice Emitted when `previouslySlashedAddress` is 'unfrozen', allowing them to again move deposited funds within Pell.
  event FrozenStatusReset(address indexed previouslySlashedAddress);

  /**
   * @notice Gives the `contractAddress` permission to slash the funds of the caller.
   * @dev Typically, this function must be called prior to registering for a middleware.
   */
  function optIntoSlashing(address contractAddress) external;

  /**
   * @notice Used for 'slashing' a certain operator.
   * @param toBeFrozen The operator to be frozen.
   * @dev Technically the operator is 'frozen' (hence the name of this function), and then subject to slashing pending a decision by a human-in-the-loop.
   * @dev The operator must have previously given the caller (which should be a contract) the ability to slash them, through a call to `optIntoSlashing`.
   */
  function freezeOperator(address toBeFrozen) external;

  /**
   * @notice Removes the 'frozen' status from each of the `frozenAddresses`
   * @dev Callable only by the contract owner (i.e. governance).
   */
  function resetFrozenStatus(address[] calldata frozenAddresses) external;

  /**
   * @notice this function is a called by middlewares during an operator's registration to make sure the operator's stake at registration
   *         is slashable until serveUntil
   * @param operator the operator whose stake update is being recorded
   * @param serveUntilTimestamp the timestamp until which the operator's stake at the current timestamp is slashable
   * @dev adds the middleware's slashing contract to the operator's linked list
   */
  function recordFirstStakeUpdate(address operator, uint32 serveUntilTimestamp) external;

  /**
   * @notice this function is a called by middlewares during a stake update for an operator (perhaps to free pending withdrawals)
   *         to make sure the operator's stake at updateTimestamp is slashable until serveUntil
   * @param operator the operator whose stake update is being recorded
   * @param updateTimestamp the timestamp for which the stake update is being recorded
   * @param serveUntilTimestamp the timestamp until which the operator's stake at updateTimestamp is slashable
   * @param insertAfter the element of the operators linked list that the currently updating middleware should be inserted after
   * @dev insertAfter should be calculated offchain before making the transaction that calls this. this is subject to race conditions,
   *      but it is anticipated to be rare and not detrimental.
   */
  function recordStakeUpdate(address operator, uint32 updateTimestamp, uint32 serveUntilTimestamp, uint256 insertAfter) external;

  /**
   * @notice this function is a called by middlewares during an operator's deregistration to make sure the operator's stake at deregistration
   *         is slashable until serveUntil
   * @param operator the operator whose stake update is being recorded
   * @param serveUntilTimestamp the timestamp until which the operator's stake at the current timestamp is slashable
   * @dev removes the middleware's slashing contract to the operator's linked list and revokes the middleware's (i.e. caller's) ability to
   * slash `operator` once `serveUntil` is reached
   */
  function recordLastStakeUpdateAndRevokeSlashingAbility(address operator, uint32 serveUntilTimestamp) external;

  /// @notice The StrategyManager contract of Pell
  function strategyManager() external view returns (IStrategyManager);

  /// @notice The DelegationManager contract of Pell
  function delegation() external view returns (IDelegationManager);

  /**
   * @notice Used to determine whether `staker` is actively 'frozen'. If a staker is frozen, then they are potentially subject to
   * slashing of their funds, and cannot cannot deposit or withdraw from the strategyManager until the slashing process is completed
   * and the staker's status is reset (to 'unfrozen').
   * @param staker The staker of interest.
   * @return Returns 'true' if `staker` themselves has their status set to frozen, OR if the staker is delegated
   * to an operator who has their status set to frozen. Otherwise returns 'false'.
   */
  function isFrozen(address staker) external view returns (bool);

  /// @notice Returns true if `slashingContract` is currently allowed to slash `toBeSlashed`.
  function canSlash(address toBeSlashed, address slashingContract) external view returns (bool);

  /// @notice Returns the timestamp until which `serviceContract` is allowed to slash the `operator`.
  function contractCanSlashOperatorUntilTimestamp(address operator, address serviceContract) external view returns (uint32);

  /// @notice Returns the timestamp at which the `serviceContract` last updated its view of the `operator`'s stake
  function latestUpdateTimestamp(address operator, address serviceContract) external view returns (uint32);

  /// @notice A search routine for finding the correct input value of `insertAfter` to `recordStakeUpdate` / `_updateMiddlewareList`.
  function getCorrectValueForInsertAfter(address operator, uint32 updateTimestamp) external view returns (uint256);

  /**
   * @notice Returns 'true' if `operator` can currently complete a withdrawal started at the `withdrawalStartTimestamp`, with `middlewareTimesIndex` used
   * to specify the index of a `MiddlewareTimes` struct in the operator's list (i.e. an index in `operatorToMiddlewareTimes[operator]`). The specified
   * struct is consulted as proof of the `operator`'s ability (or lack thereof) to complete the withdrawal.
   * This function will return 'false' if the operator cannot currently complete a withdrawal started at the `withdrawalStartTimestamp`, *or* in the event
   * that an incorrect `middlewareTimesIndex` is supplied, even if one or more correct inputs exist.
   * @param operator Either the operator who queued the withdrawal themselves, or if the withdrawing party is a staker who delegated to an operator,
   * this address is the operator *who the staker was delegated to* at the time of the `withdrawalStartTimestamp`.
   * @param withdrawalStartTimestamp The timestamp at which the withdrawal was initiated.
   * @param middlewareTimesIndex Indicates an index in `operatorToMiddlewareTimes[operator]` to consult as proof of the `operator`'s ability to withdraw
   * @dev The correct `middlewareTimesIndex` input should be computable off-chain.
   */
  function canWithdraw(address operator, uint32 withdrawalStartTimestamp, uint256 middlewareTimesIndex) external returns (bool);

  /**
   * operator =>
   *  [
   *      (
   *          the least recent update timestamp of all of the middlewares it's serving/served,
   *          latest time that the stake bonded at that update needed to serve until
   *      )
   *  ]
   */
  function operatorToMiddlewareTimes(address operator, uint256 arrayIndex) external view returns (MiddlewareTimes memory);

  /// @notice Getter function for fetching `operatorToMiddlewareTimes[operator].length`
  function middlewareTimesLength(address operator) external view returns (uint256);

  /// @notice Getter function for fetching `operatorToMiddlewareTimes[operator][index].stalestUpdateTimestamp`.
  function getMiddlewareTimesIndexStalestUpdateTimestamp(address operator, uint32 index) external view returns (uint32);

  /// @notice Getter function for fetching `operatorToMiddlewareTimes[operator][index].latestServeUntil`.
  function getMiddlewareTimesIndexServeUntilTimestamp(address operator, uint32 index) external view returns (uint32);

  /// @notice Getter function for fetching `_operatorToWhitelistedContractsByUpdate[operator].size`.
  function operatorWhitelistedContractsLinkedListSize(address operator) external view returns (uint256);

  /// @notice Getter function for fetching a single node in the operator's linked list (`_operatorToWhitelistedContractsByUpdate[operator]`).
  function operatorWhitelistedContractsLinkedListEntry(address operator, address node) external view returns (bool, uint256, uint256);
}

// SPDX-License-Identifier: LGPL-3.0
pragma solidity 0.8.20;

import '@openzeppelin/contracts/token/ERC20/IERC20.sol';

/**
 * @title Minimal interface for an `Strategy` contract.
 * @notice Custom `Strategy` implementations may expand extensively on this interface.
 */
interface IStrategy {
  /**
   * @notice Used to deposit tokens into this Strategy
   * @param token is the ERC20 token being deposited
   * @param amount is the amount of token being deposited
   * @dev This function is only callable by the strategyManager contract. It is invoked inside of the strategyManager's
   * `depositIntoStrategy` function, and individual share balances are recorded in the strategyManager as well.
   * @return newShares is the number of new shares issued at the current exchange ratio.
   */
  function deposit(IERC20 token, uint256 amount) external returns (uint256);

  /**
   * @notice Used to withdraw tokens from this Strategy, to the `recipient`'s address
   * @param recipient is the address to receive the withdrawn funds
   * @param token is the ERC20 token being transferred out
   * @param amountShares is the amount of shares being withdrawn
   * @dev This function is only callable by the strategyManager contract. It is invoked inside of the strategyManager's
   * other functions, and individual share balances are recorded in the strategyManager as well.
   */
  function withdraw(address recipient, IERC20 token, uint256 amountShares) external;

  /**
   * @notice Used to convert a number of shares to the equivalent amount of underlying tokens for this strategy.
   * @notice In contrast to `sharesToUnderlyingView`, this function **may** make state modifications
   * @param amountShares is the amount of shares to calculate its conversion into the underlying token
   * @return The amount of underlying tokens corresponding to the input `amountShares`
   * @dev Implementation for these functions in particular may vary significantly for different strategies
   */
  function sharesToUnderlying(uint256 amountShares) external returns (uint256);

  /**
   * @notice Used to convert an amount of underlying tokens to the equivalent amount of shares in this strategy.
   * @notice In contrast to `underlyingToSharesView`, this function **may** make state modifications
   * @param amountUnderlying is the amount of `underlyingToken` to calculate its conversion into strategy shares
   * @return The amount of underlying tokens corresponding to the input `amountShares`
   * @dev Implementation for these functions in particular may vary significantly for different strategies
   */
  function underlyingToShares(uint256 amountUnderlying) external returns (uint256);

  /**
   * @notice convenience function for fetching the current underlying value of all of the `user`'s shares in
   * this strategy. In contrast to `userUnderlyingView`, this function **may** make state modifications
   */
  function userUnderlying(address user) external returns (uint256);

  /**
   * @notice convenience function for fetching the current total shares of `user` in this strategy, by
   * querying the `strategyManager` contract
   */
  function shares(address user) external view returns (uint256);

  /**
   * @notice Used to convert a number of shares to the equivalent amount of underlying tokens for this strategy.
   * @notice In contrast to `sharesToUnderlying`, this function guarantees no state modifications
   * @param amountShares is the amount of shares to calculate its conversion into the underlying token
   * @return The amount of shares corresponding to the input `amountUnderlying`
   * @dev Implementation for these functions in particular may vary significantly for different strategies
   */
  function sharesToUnderlyingView(uint256 amountShares) external view returns (uint256);

  /**
   * @notice Used to convert an amount of underlying tokens to the equivalent amount of shares in this strategy.
   * @notice In contrast to `underlyingToShares`, this function guarantees no state modifications
   * @param amountUnderlying is the amount of `underlyingToken` to calculate its conversion into strategy shares
   * @return The amount of shares corresponding to the input `amountUnderlying`
   * @dev Implementation for these functions in particular may vary significantly for different strategies
   */
  function underlyingToSharesView(uint256 amountUnderlying) external view returns (uint256);

  /**
   * @notice convenience function for fetching the current underlying value of all of the `user`'s shares in
   * this strategy. In contrast to `userUnderlying`, this function guarantees no state modifications
   */
  function userUnderlyingView(address user) external view returns (uint256);

  /// @notice The underlying token for shares in this Strategy
  function underlyingToken() external view returns (IERC20);

  /// @notice The total number of extant shares in this Strategy
  function totalShares() external view returns (uint256);

  /// @notice Returns either a brief string explaining the strategy's goal & purpose, or a link to metadata that explains in more detail.
  function explanation() external view returns (string memory);
}

// SPDX-License-Identifier: LGPL-3.0
pragma solidity 0.8.20;

import './IStrategy.sol';
import './ISlasher.sol';
import './IDelegationManager.sol';

/**
 * @title Interface for the primary entrypoint for funds into Pell.
 * @notice See the `StrategyManager` contract itself for implementation details.
 */
interface IStrategyManager {
  /**
   * @notice Emitted when a new deposit occurs on behalf of `staker`.
   * @param staker Is the staker who is depositing funds into Pell.
   * @param strategy Is the strategy that `staker` has deposited into.
   * @param token Is the token that `staker` deposited.
   * @param shares Is the number of new shares `staker` has been granted in `strategy`.
   */
  event Deposit(address staker, IERC20 token, IStrategy strategy, uint256 shares);

  /// @notice Emitted when `thirdPartyTransfersForbidden` is updated for a strategy and value by the owner
  event UpdatedThirdPartyTransfersForbidden(IStrategy strategy, bool value);

  /// @notice Emitted when the `strategyWhitelister` is changed
  event StrategyWhitelisterChanged(address previousAddress, address newAddress);

  /// @notice Emitted when a strategy is added to the approved list of strategies for deposit
  event StrategyAddedToDepositWhitelist(IStrategy strategy);

  /// @notice Emitted when a strategy is removed from the approved list of strategies for deposit
  event StrategyRemovedFromDepositWhitelist(IStrategy strategy);

  /**
   * @notice Deposits `amount` of `token` into the specified `strategy`, with the resultant shares credited to `msg.sender`
   * @param strategy is the specified strategy where deposit is to be made,
   * @param token is the denomination in which the deposit is to be made,
   * @param amount is the amount of token to be deposited in the strategy by the staker
   * @return shares The amount of new shares in the `strategy` created as part of the action.
   * @dev The `msg.sender` must have previously approved this contract to transfer at least `amount` of `token` on their behalf.
   * @dev Cannot be called by an address that is 'frozen' (this function will revert if the `msg.sender` is frozen).
   *
   * WARNING: Depositing tokens that allow reentrancy (eg. ERC-777) into a strategy is not recommended.  This can lead to attack vectors
   *          where the token balance and corresponding strategy shares are not in sync upon reentrancy.
   */
  function depositIntoStrategy(IStrategy strategy, IERC20 token, uint256 amount) external returns (uint256 shares);

  /**
   * @notice Used for depositing an asset into the specified strategy with the resultant shares credited to `staker`,
   * who must sign off on the action.
   * Note that the assets are transferred out/from the `msg.sender`, not from the `staker`; this function is explicitly designed
   * purely to help one address deposit 'for' another.
   * @param strategy is the specified strategy where deposit is to be made,
   * @param token is the denomination in which the deposit is to be made,
   * @param amount is the amount of token to be deposited in the strategy by the staker
   * @param staker the staker that the deposited assets will be credited to
   * @param expiry the timestamp at which the signature expires
   * @param signature is a valid signature from the `staker`. either an ECDSA signature if the `staker` is an EOA, or data to forward
   * following EIP-1271 if the `staker` is a contract
   * @return shares The amount of new shares in the `strategy` created as part of the action.
   * @dev The `msg.sender` must have previously approved this contract to transfer at least `amount` of `token` on their behalf.
   * @dev A signature is required for this function to eliminate the possibility of griefing attacks, specifically those
   * targeting stakers who may be attempting to undelegate.
   * @dev Cannot be called if thirdPartyTransfersForbidden is set to true for this strategy
   *
   *  WARNING: Depositing tokens that allow reentrancy (eg. ERC-777) into a strategy is not recommended.  This can lead to attack vectors
   *          where the token balance and corresponding strategy shares are not in sync upon reentrancy
   */
  function depositIntoStrategyWithSignature(
    IStrategy strategy,
    IERC20 token,
    uint256 amount,
    address staker,
    uint256 expiry,
    bytes memory signature
  ) external returns (uint256 shares);

  /// @notice Used by the DelegationManager to remove a Staker's shares from a particular strategy when entering the withdrawal queue
  function removeShares(address staker, IStrategy strategy, uint256 shares) external;

  /// @notice Used by the DelegationManager to award a Staker some shares that have passed through the withdrawal queue
  function addShares(address staker, IERC20 token, IStrategy strategy, uint256 shares) external;

  /// @notice Used by the DelegationManager to convert withdrawn shares to tokens and send them to a recipient
  function withdrawSharesAsTokens(address recipient, IStrategy strategy, uint256 shares, IERC20 token) external;

  /// @notice Returns the current shares of `user` in `strategy`
  function stakerStrategyShares(address user, IStrategy strategy) external view returns (uint256 shares);

  /**
   * @notice Get all details on the staker's deposits and corresponding shares
   * @return (staker's strategies, shares in these strategies)
   */
  function getDeposits(address staker) external view returns (IStrategy[] memory, uint256[] memory);

  /// @notice Simple getter function that returns `stakerStrategyList[staker].length`.
  function stakerStrategyListLength(address staker) external view returns (uint256);

  /**
   * @notice Owner-only function that adds the provided Strategies to the 'whitelist' of strategies that stakers can deposit into
   * @param strategiesToWhitelist Strategies that will be added to the `strategyIsWhitelistedForDeposit` mapping (if they aren't in it already)
   * @param thirdPartyTransfersForbiddenValues bool values to set `thirdPartyTransfersForbidden` to for each strategy
   */
  function addStrategiesToDepositWhitelist(
    IStrategy[] calldata strategiesToWhitelist,
    bool[] calldata thirdPartyTransfersForbiddenValues
  ) external;

  /**
   * @notice Owner-only function that removes the provided Strategies from the 'whitelist' of strategies that stakers can deposit into
   * @param strategiesToRemoveFromWhitelist Strategies that will be removed to the `strategyIsWhitelistedForDeposit` mapping (if they are in it)
   */
  function removeStrategiesFromDepositWhitelist(IStrategy[] calldata strategiesToRemoveFromWhitelist) external;

  /// @notice Returns the single, central Delegation contract of Pell
  function delegation() external view returns (IDelegationManager);

  /// @notice Returns the single, central Slasher contract of Pell
  function slasher() external view returns (ISlasher);

  /// @notice Returns the address of the `strategyWhitelister`
  function strategyWhitelister() external view returns (address);

  /**
   * @notice Returns bool for whether or not `strategy` enables credit transfers. i.e enabling
   * depositIntoStrategyWithSignature calls or queueing withdrawals to a different address than the staker.
   */
  function thirdPartyTransfersForbidden(IStrategy strategy) external view returns (bool);
}

// SPDX-License-Identifier: LGPL-3.0
pragma solidity 0.8.20;

import '@openzeppelin/contracts/interfaces/IERC1271.sol';
import '@openzeppelin/contracts/utils/Address.sol';
import '@openzeppelin/contracts/utils/cryptography/ECDSA.sol';

/**
 * @title Library of utilities for making EIP1271-compliant signature checks.
 */
library EIP1271SignatureUtils {
  // bytes4(keccak256("isValidSignature(bytes32,bytes)")
  bytes4 internal constant EIP1271_MAGICVALUE = 0x1626ba7e;

  /**
   * @notice Checks @param signature is a valid signature of @param digestHash from @param signer.
   * If the `signer` contains no code -- i.e. it is not (yet, at least) a contract address, then checks using standard ECDSA logic
   * Otherwise, passes on the signature to the signer to verify the signature and checks that it returns the `EIP1271_MAGICVALUE`.
   */
  function checkSignature_EIP1271(address signer, bytes32 digestHash, bytes memory signature) internal view {
    /**
     * check validity of signature:
     * 1) if `signer` is an EOA, then `signature` must be a valid ECDSA signature from `signer`,
     * indicating their intention for this action
     * 2) if `signer` is a contract, then `signature` must will be checked according to EIP-1271
     */
    if (Address.isContract(signer)) {
      require(
        IERC1271(signer).isValidSignature(digestHash, signature) == EIP1271_MAGICVALUE,
        'EIP1271SignatureUtils.checkSignature_EIP1271: ERC1271 signature verification failed'
      );
    } else {
      require(ECDSA.recover(digestHash, signature) == signer, 'EIP1271SignatureUtils.checkSignature_EIP1271: signature not from signer');
    }
  }
}

// SPDX-License-Identifier: LGPL-3.0

pragma solidity 0.8.20;

import '../interfaces/IPausable.sol';

/**
 * @title Adds pausability to a contract, with pausing & unpausing controlled by the `pauser` and `unpauser` of a PauserRegistry contract.
 * @notice Contracts that inherit from this contract may define their own `pause` and `unpause` (and/or related) functions.
 * These functions should be permissioned as "onlyPauser" which defers to a `PauserRegistry` for determining access control.
 * @dev Pausability is implemented using a uint256, which allows up to 256 different single bit-flags; each bit can potentially pause different functionality.
 * Inspiration for this was taken from the NearBridge design here https://etherscan.io/address/0x3FEFc5A4B1c02f21cBc8D3613643ba0635b9a873#code.
 * For the `pause` and `unpause` functions we've implemented, if you pause, you can only flip (any number of) switches to on/1 (aka "paused"), and if you unpause,
 * you can only flip (any number of) switches to off/0 (aka "paused").
 * If you want a pauseXYZ function that just flips a single bit / "pausing flag", it will:
 * 1) 'bit-wise and' (aka `&`) a flag with the current paused state (as a uint256)
 * 2) update the paused state to this new value
 * @dev We note as well that we have chosen to identify flags by their *bit index* as opposed to their numerical value, so, e.g. defining `DEPOSITS_PAUSED = 3`
 * indicates specifically that if the *third bit* of `_paused` is flipped -- i.e. it is a '1' -- then deposits should be paused
 */
contract Pausable is IPausable {
  /// @notice Address of the `PauserRegistry` contract that this contract defers to for determining access control (for pausing).
  IPauserRegistry public pauserRegistry;

  /// @dev whether or not the contract is currently paused
  uint256 private _paused;

  uint256 internal constant UNPAUSE_ALL = 0;
  uint256 internal constant PAUSE_ALL = type(uint256).max;

  /// @notice
  modifier onlyPauser() {
    require(pauserRegistry.isPauser(msg.sender), 'msg.sender is not permissioned as pauser');
    _;
  }

  modifier onlyUnpauser() {
    require(msg.sender == pauserRegistry.unpauser(), 'msg.sender is not permissioned as unpauser');
    _;
  }

  /// @notice Throws if the contract is paused, i.e. if any of the bits in `_paused` is flipped to 1.
  modifier whenNotPaused() {
    require(_paused == 0, 'Pausable: contract is paused');
    _;
  }

  /// @notice Throws if the `indexed`th bit of `_paused` is 1, i.e. if the `index`th pause switch is flipped.
  modifier onlyWhenNotPaused(uint8 index) {
    require(!paused(index), 'Pausable: index is paused');
    _;
  }

  /// @notice One-time function for setting the `pauserRegistry` and initializing the value of `_paused`.
  function _initializePauser(IPauserRegistry _pauserRegistry, uint256 initPausedStatus) internal {
    require(
      address(pauserRegistry) == address(0) && address(_pauserRegistry) != address(0),
      'Pausable._initializePauser: _initializePauser() can only be called once'
    );
    _paused = initPausedStatus;
    emit Paused(msg.sender, initPausedStatus);
    _setPauserRegistry(_pauserRegistry);
  }

  /**
   * @notice This function is used to pause an Pell contract's functionality.
   * It is permissioned to the `pauser` address, which is expected to be a low threshold multisig.
   * @param newPausedStatus represents the new value for `_paused` to take, which means it may flip several bits at once.
   * @dev This function can only pause functionality, and thus cannot 'unflip' any bit in `_paused` from 1 to 0.
   */
  function pause(uint256 newPausedStatus) external onlyPauser {
    // verify that the `newPausedStatus` does not *unflip* any bits (i.e. doesn't unpause anything, all 1 bits remain)
    require((_paused & newPausedStatus) == _paused, 'Pausable.pause: invalid attempt to unpause functionality');
    _paused = newPausedStatus;
    emit Paused(msg.sender, newPausedStatus);
  }

  /**
   * @notice Alias for `pause(type(uint256).max)`.
   */
  function pauseAll() external onlyPauser {
    _paused = type(uint256).max;
    emit Paused(msg.sender, type(uint256).max);
  }

  /**
   * @notice This function is used to unpause an Pell contract's functionality.
   * It is permissioned to the `unpauser` address, which is expected to be a high threshold multisig or governance contract.
   * @param newPausedStatus represents the new value for `_paused` to take, which means it may flip several bits at once.
   * @dev This function can only unpause functionality, and thus cannot 'flip' any bit in `_paused` from 0 to 1.
   */
  function unpause(uint256 newPausedStatus) external onlyUnpauser {
    // verify that the `newPausedStatus` does not *flip* any bits (i.e. doesn't pause anything, all 0 bits remain)
    require(((~_paused) & (~newPausedStatus)) == (~_paused), 'Pausable.unpause: invalid attempt to pause functionality');
    _paused = newPausedStatus;
    emit Unpaused(msg.sender, newPausedStatus);
  }

  /// @notice Returns the current paused status as a uint256.
  function paused() public view virtual returns (uint256) {
    return _paused;
  }

  /// @notice Returns 'true' if the `indexed`th bit of `_paused` is 1, and 'false' otherwise
  function paused(uint8 index) public view virtual returns (bool) {
    uint256 mask = 1 << index;
    return ((_paused & mask) == mask);
  }

  /// @notice Allows the unpauser to set a new pauser registry
  function setPauserRegistry(IPauserRegistry newPauserRegistry) external onlyUnpauser {
    _setPauserRegistry(newPauserRegistry);
  }

  /// internal function for setting pauser registry
  function _setPauserRegistry(IPauserRegistry newPauserRegistry) internal {
    require(address(newPauserRegistry) != address(0), 'Pausable._setPauserRegistry: newPauserRegistry cannot be the zero address');
    emit PauserRegistrySet(pauserRegistry, newPauserRegistry);
    pauserRegistry = newPauserRegistry;
  }

  /**
   * @dev This empty reserved space is put in place to allow future versions to add new
   * variables without shifting down storage in the inheritance chain.
   * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
   */
  uint256[49] private __gap;
}

Settings
{
  "evmVersion": "berlin",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs",
    "useLiteralContent": true
  },
  "optimizer": {
    "enabled": true,
    "runs": 1500
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"contract IDelegationManager","name":"_delegation","type":"address"},{"internalType":"contract ISlasher","name":"_slasher","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"staker","type":"address"},{"indexed":false,"internalType":"contract IERC20","name":"token","type":"address"},{"indexed":false,"internalType":"contract IStrategy","name":"strategy","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"newPausedStatus","type":"uint256"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IPauserRegistry","name":"pauserRegistry","type":"address"},{"indexed":false,"internalType":"contract IPauserRegistry","name":"newPauserRegistry","type":"address"}],"name":"PauserRegistrySet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IStrategy","name":"strategy","type":"address"}],"name":"StrategyAddedToDepositWhitelist","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IStrategy","name":"strategy","type":"address"}],"name":"StrategyRemovedFromDepositWhitelist","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAddress","type":"address"},{"indexed":false,"internalType":"address","name":"newAddress","type":"address"}],"name":"StrategyWhitelisterChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"newPausedStatus","type":"uint256"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IStrategy","name":"strategy","type":"address"},{"indexed":false,"internalType":"bool","name":"value","type":"bool"}],"name":"UpdatedThirdPartyTransfersForbidden","type":"event"},{"inputs":[],"name":"DEPOSIT_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DOMAIN_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"staker","type":"address"},{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"contract IStrategy","name":"strategy","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"addShares","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IStrategy[]","name":"strategiesToWhitelist","type":"address[]"},{"internalType":"bool[]","name":"thirdPartyTransfersForbiddenValues","type":"bool[]"}],"name":"addStrategiesToDepositWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"delegation","outputs":[{"internalType":"contract IDelegationManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IStrategy","name":"strategy","type":"address"},{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"depositIntoStrategy","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IStrategy","name":"strategy","type":"address"},{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"staker","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"depositIntoStrategyWithSignature","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"domainSeparator","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"staker","type":"address"}],"name":"getDeposits","outputs":[{"internalType":"contract IStrategy[]","name":"","type":"address[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"initialOwner","type":"address"},{"internalType":"address","name":"initialStrategyWhitelister","type":"address"},{"internalType":"contract IPauserRegistry","name":"_pauserRegistry","type":"address"},{"internalType":"uint256","name":"initialPausedStatus","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"newPausedStatus","type":"uint256"}],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pauseAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"index","type":"uint8"}],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pauserRegistry","outputs":[{"internalType":"contract IPauserRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"staker","type":"address"},{"internalType":"contract IStrategy","name":"strategy","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"removeShares","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IStrategy[]","name":"strategiesToRemoveFromWhitelist","type":"address[]"}],"name":"removeStrategiesFromDepositWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IPauserRegistry","name":"newPauserRegistry","type":"address"}],"name":"setPauserRegistry","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newStrategyWhitelister","type":"address"}],"name":"setStrategyWhitelister","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IStrategy","name":"strategy","type":"address"},{"internalType":"bool","name":"value","type":"bool"}],"name":"setThirdPartyTransfersForbidden","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"slasher","outputs":[{"internalType":"contract ISlasher","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"stakerStrategyList","outputs":[{"internalType":"contract IStrategy","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"staker","type":"address"}],"name":"stakerStrategyListLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"contract IStrategy","name":"","type":"address"}],"name":"stakerStrategyShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IStrategy","name":"","type":"address"}],"name":"strategyIsWhitelistedForDeposit","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"strategyWhitelister","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IStrategy","name":"","type":"address"}],"name":"thirdPartyTransfersForbidden","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newPausedStatus","type":"uint256"}],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"contract IStrategy","name":"strategy","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"contract IERC20","name":"token","type":"address"}],"name":"withdrawSharesAsTokens","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60e06040523480156200001157600080fd5b506040516200370f3803806200370f833981016040819052620000349162000137565b6001600160a01b03808316608052811660a052620000516200005d565b50504660c05262000176565b600054610100900460ff1615620000ca5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff908116146200011c576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b6001600160a01b03811681146200013457600080fd5b50565b600080604083850312156200014b57600080fd5b825162000158816200011e565b60208401519092506200016b816200011e565b809150509250929050565b60805160a05160c05161354d620001c2600039600061185c0152600061044c0152600081816104f801528181610cc5015281816110ce0152818161117a0152611ff9015261354d6000f3fe608060405234801561001057600080fd5b506004361061020b5760003560e01c80638da5cb5b1161012a578063c6656702116100bd578063df5cf7231161008c578063f2fde38b11610071578063f2fde38b1461052d578063f698da2514610540578063fabc1cbc1461054857600080fd5b8063df5cf723146104f3578063e7a050aa1461051a57600080fd5b8063c6656702146104a7578063cbc2bd62146104ba578063cf756fdf146104cd578063df5b3547146104e057600080fd5b8063b1344271116100f9578063b134427114610447578063b5d8b5b81461046e578063c4623ea114610481578063c608c7f31461049457600080fd5b80638da5cb5b146103df57806394f649dd146103f0578063967fc0d2146104115780639b4da03d1461042457600080fd5b80635c975abb116101a25780637ecebe00116101715780637ecebe0014610358578063886f1195146103785780638b8aac3c146103a35780638c80d4e5146103cc57600080fd5b80635c975abb146102fa578063663c1de414610302578063715018a6146103255780637a7e0d921461032d57600080fd5b806348825e94116101de57806348825e94146102855780634e5a4263146102ac578063595c6a67146102bf5780635ac86ab7146102c757600080fd5b806310d67a2f14610210578063136439dd1461022557806320606b701461023857806332e89ace14610272575b600080fd5b61022361021e366004612ee8565b61055b565b005b610223610233366004612f05565b610669565b61025f7f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a86681565b6040519081526020015b60405180910390f35b61025f610280366004612f34565b6107fe565b61025f7f4337f82d142e41f2a8c10547cd8c859bddb92262a61058e77842e24d9dea922481565b6102236102ba36600461303d565b610aed565b610223610b89565b6102ea6102d5366004613076565b609854600160ff9092169190911b9081161490565b6040519015158152602001610269565b60985461025f565b6102ea610310366004612ee8565b60cf6020526000908152604090205460ff1681565b610223610ca6565b61025f61033b366004613099565b60cd60209081526000928352604080842090915290825290205481565b61025f610366366004612ee8565b60cb6020526000908152604090205481565b60975461038b906001600160a01b031681565b6040516001600160a01b039091168152602001610269565b61025f6103b1366004612ee8565b6001600160a01b0316600090815260ce602052604090205490565b6102236103da3660046130c7565b610cba565b6033546001600160a01b031661038b565b6104036103fe366004612ee8565b610d6b565b604051610269929190613108565b60cc5461038b906001600160a01b031681565b6102ea610432366004612ee8565b60d06020526000908152604090205460ff1681565b61038b7f000000000000000000000000000000000000000000000000000000000000000081565b61022361047c3660046131d1565b610eeb565b61022361048f366004613213565b6110c3565b6102236104a2366004613264565b61116f565b6102236104b5366004612ee8565b611298565b61038b6104c83660046132b7565b6112a9565b6102236104db366004613213565b6112e1565b6102236104ee3660046132e3565b6114aa565b61038b7f000000000000000000000000000000000000000000000000000000000000000081565b61025f6105283660046130c7565b611749565b61022361053b366004612ee8565b6117cb565b61025f611858565b610223610556366004612f05565b61191a565b609760009054906101000a90046001600160a01b03166001600160a01b031663eab66d7a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156105ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105d2919061334f565b6001600160a01b0316336001600160a01b03161461065d5760405162461bcd60e51b815260206004820152602a60248201527f6d73672e73656e646572206973206e6f74207065726d697373696f6e6564206160448201527f7320756e7061757365720000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b61066681611acc565b50565b60975460405163237dfb4760e11b81523360048201526001600160a01b03909116906346fbf68e90602401602060405180830381865afa1580156106b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106d5919061336c565b6107475760405162461bcd60e51b815260206004820152602860248201527f6d73672e73656e646572206973206e6f74207065726d697373696f6e6564206160448201527f73207061757365720000000000000000000000000000000000000000000000006064820152608401610654565b609854818116146107c05760405162461bcd60e51b815260206004820152603860248201527f5061757361626c652e70617573653a20696e76616c696420617474656d70742060448201527f746f20756e70617573652066756e6374696f6e616c69747900000000000000006064820152608401610654565b609881905560405181815233907fab40a374bc51de372200a8bc981af8c9ecdc08dfdaef0bb6e09f88f3c616ef3d906020015b60405180910390a250565b60985460009081906001908116036108585760405162461bcd60e51b815260206004820152601960248201527f5061757361626c653a20696e64657820697320706175736564000000000000006044820152606401610654565b610860611be4565b6001600160a01b038816600090815260d0602052604090205460ff16156109155760405162461bcd60e51b815260206004820152604a60248201527f53747261746567794d616e616765722e6465706f736974496e746f537472617460448201527f656779576974685369676e61747572653a207468697264207472616e7366657260648201527f732064697361626c656400000000000000000000000000000000000000000000608482015260a401610654565b428410156109b15760405162461bcd60e51b815260206004820152604360248201527f53747261746567794d616e616765722e6465706f736974496e746f537472617460448201527f656779576974685369676e61747572653a207369676e6174757265206578706960648201527f7265640000000000000000000000000000000000000000000000000000000000608482015260a401610654565b6001600160a01b03858116600081815260cb602090815260408083205481517f4337f82d142e41f2a8c10547cd8c859bddb92262a61058e77842e24d9dea922493810193909352908201939093528b84166060820152928a16608084015260a0830189905260c0830182905260e0830187905290916101000160408051601f1981840301815291815281516020928301206001600160a01b038a16600090815260cb9093529082206001850190559150610a69611858565b6040517f19010000000000000000000000000000000000000000000000000000000000006020820152602281019190915260428101839052606201604051602081830303815290604052805190602001209050610ac7888288611c3d565b610ad3888c8c8c611e4d565b9450505050610ae26001606555565b509695505050505050565b60cc546001600160a01b03163314610b7b5760405162461bcd60e51b8152602060048201526044602482018190527f53747261746567794d616e616765722e6f6e6c79537472617465677957686974908201527f656c69737465723a206e6f742074686520737472617465677957686974656c6960648201526339ba32b960e11b608482015260a401610654565b610b85828261205e565b5050565b60975460405163237dfb4760e11b81523360048201526001600160a01b03909116906346fbf68e90602401602060405180830381865afa158015610bd1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf5919061336c565b610c675760405162461bcd60e51b815260206004820152602860248201527f6d73672e73656e646572206973206e6f74207065726d697373696f6e6564206160448201527f73207061757365720000000000000000000000000000000000000000000000006064820152608401610654565b600019609881905560405190815233907fab40a374bc51de372200a8bc981af8c9ecdc08dfdaef0bb6e09f88f3c616ef3d9060200160405180910390a2565b610cae6120cc565b610cb86000612126565b565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610d5a576040805162461bcd60e51b81526020600482015260248101919091527f53747261746567794d616e616765722e6f6e6c7944656c65676174696f6e4d6160448201527f6e616765723a206e6f74207468652044656c65676174696f6e4d616e616765726064820152608401610654565b610d65838383612185565b50505050565b6001600160a01b038116600090815260ce60205260408120546060918291908167ffffffffffffffff811115610da357610da3612f1e565b604051908082528060200260200182016040528015610dcc578160200160208202803683370190505b50905060005b82811015610e5d576001600160a01b038616600090815260cd6020908152604080832060ce9092528220805491929184908110610e1157610e11613389565b60009182526020808320909101546001600160a01b031683528201929092526040019020548251839083908110610e4a57610e4a613389565b6020908102919091010152600101610dd2565b5060ce6000866001600160a01b03166001600160a01b031681526020019081526020016000208181805480602002602001604051908101604052809291908181526020018280548015610ed957602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610ebb575b50505050509150935093505050915091565b60cc546001600160a01b03163314610f795760405162461bcd60e51b8152602060048201526044602482018190527f53747261746567794d616e616765722e6f6e6c79537472617465677957686974908201527f656c69737465723a206e6f742074686520737472617465677957686974656c6960648201526339ba32b960e11b608482015260a401610654565b8060005b81811015610d655760cf6000858584818110610f9b57610f9b613389565b9050602002016020810190610fb09190612ee8565b6001600160a01b0316815260208101919091526040016000205460ff16156110bb57600060cf6000868685818110610fea57610fea613389565b9050602002016020810190610fff9190612ee8565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790557f4074413b4b443e4e58019f2855a8765113358c7c72e39509c6af45fc0f5ba03084848381811061105a5761105a613389565b905060200201602081019061106f9190612ee8565b6040516001600160a01b03909116815260200160405180910390a16110bb84848381811061109f5761109f613389565b90506020020160208101906110b49190612ee8565b600061205e565b600101610f7d565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614611163576040805162461bcd60e51b81526020600482015260248101919091527f53747261746567794d616e616765722e6f6e6c7944656c65676174696f6e4d6160448201527f6e616765723a206e6f74207468652044656c65676174696f6e4d616e616765726064820152608401610654565b610d65848484846122f0565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461120f576040805162461bcd60e51b81526020600482015260248101919091527f53747261746567794d616e616765722e6f6e6c7944656c65676174696f6e4d6160448201527f6e616765723a206e6f74207468652044656c65676174696f6e4d616e616765726064820152608401610654565b6040517fd9caed120000000000000000000000000000000000000000000000000000000081526001600160a01b03858116600483015282811660248301526044820184905284169063d9caed1290606401600060405180830381600087803b15801561127a57600080fd5b505af115801561128e573d6000803e3d6000fd5b5050505050505050565b6112a06120cc565b610666816125a5565b60ce60205281600052604060002081815481106112c557600080fd5b6000918252602090912001546001600160a01b03169150829050565b600054610100900460ff16158080156113015750600054600160ff909116105b8061131b5750303b15801561131b575060005460ff166001145b61138d5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610654565b6000805460ff1916600117905580156113b0576000805461ff0019166101001790555b604080518082018252600481526314195b1b60e21b60209182015281517f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a866818301527f0e0f546b3087f7e4405d37b8de121d34252412874bf985c456311dd7eca663b681840152466060820152306080808301919091528351808303909101815260a0909101909252815191012060ca5561144b838361261b565b61145485612126565b61145d846125a5565b80156114a3576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050565b60cc546001600160a01b031633146115385760405162461bcd60e51b8152602060048201526044602482018190527f53747261746567794d616e616765722e6f6e6c79537472617465677957686974908201527f656c69737465723a206e6f742074686520737472617465677957686974656c6960648201526339ba32b960e11b608482015260a401610654565b8281146115d35760405162461bcd60e51b815260206004820152604b60248201527f53747261746567794d616e616765722e61646453747261746567696573546f4460448201527f65706f73697457686974656c6973743a206172726179206c656e67746873206460648201527f6f206e6f74206d61746368000000000000000000000000000000000000000000608482015260a401610654565b8260005b818110156117415760cf60008787848181106115f5576115f5613389565b905060200201602081019061160a9190612ee8565b6001600160a01b0316815260208101919091526040016000205460ff1661173957600160cf600088888581811061164357611643613389565b90506020020160208101906116589190612ee8565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790557f0c35b17d91c96eb2751cd456e1252f42a386e524ef9ff26ecc9950859fdc04fe8686838181106116b3576116b3613389565b90506020020160208101906116c89190612ee8565b6040516001600160a01b03909116815260200160405180910390a16117398686838181106116f8576116f8613389565b905060200201602081019061170d9190612ee8565b85858481811061171f5761171f613389565b9050602002016020810190611734919061339f565b61205e565b6001016115d7565b505050505050565b60985460009081906001908116036117a35760405162461bcd60e51b815260206004820152601960248201527f5061757361626c653a20696e64657820697320706175736564000000000000006044820152606401610654565b6117ab611be4565b6117b733868686611e4d565b91506117c36001606555565b509392505050565b6117d36120cc565b6001600160a01b03811661184f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610654565b61066681612126565b60007f00000000000000000000000000000000000000000000000000000000000000004603611888575060ca5490565b50604080518082018252600481526314195b1b60e21b60209182015281517f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a866818301527f0e0f546b3087f7e4405d37b8de121d34252412874bf985c456311dd7eca663b681840152466060820152306080808301919091528351808303909101815260a0909101909252815191012090565b609760009054906101000a90046001600160a01b03166001600160a01b031663eab66d7a6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561196d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611991919061334f565b6001600160a01b0316336001600160a01b031614611a175760405162461bcd60e51b815260206004820152602a60248201527f6d73672e73656e646572206973206e6f74207065726d697373696f6e6564206160448201527f7320756e706175736572000000000000000000000000000000000000000000006064820152608401610654565b609854198119609854191614611a955760405162461bcd60e51b815260206004820152603860248201527f5061757361626c652e756e70617573653a20696e76616c696420617474656d7060448201527f7420746f2070617573652066756e6374696f6e616c69747900000000000000006064820152608401610654565b609881905560405181815233907f3582d1828e26bf56bd801502bc021ac0bc8afb57c826e4986b45593c8fad389c906020016107f3565b6001600160a01b038116611b6e5760405162461bcd60e51b815260206004820152604960248201527f5061757361626c652e5f73657450617573657252656769737472793a206e657760448201527f50617573657252656769737472792063616e6e6f7420626520746865207a657260648201527f6f20616464726573730000000000000000000000000000000000000000000000608482015260a401610654565b609754604080516001600160a01b03928316815291831660208301527f6e9fcd539896fca60e8b0f01dd580233e48a6b0f7df013b89ba7f565869acdb6910160405180910390a16097805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b600260655403611c365760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610654565b6002606555565b6001600160a01b0383163b15611d97576040517f1626ba7e00000000000000000000000000000000000000000000000000000000808252906001600160a01b03851690631626ba7e90611c96908690869060040161340c565b602060405180830381865afa158015611cb3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cd79190613425565b7fffffffff000000000000000000000000000000000000000000000000000000001614611d925760405162461bcd60e51b815260206004820152605360248201527f454950313237315369676e61747572655574696c732e636865636b5369676e6160448201527f747572655f454950313237313a2045524331323731207369676e61747572652060648201527f766572696669636174696f6e206661696c656400000000000000000000000000608482015260a401610654565b505050565b826001600160a01b0316611dab8383612717565b6001600160a01b031614611d925760405162461bcd60e51b815260206004820152604760248201527f454950313237315369676e61747572655574696c732e636865636b5369676e6160448201527f747572655f454950313237313a207369676e6174757265206e6f742066726f6d60648201527f207369676e657200000000000000000000000000000000000000000000000000608482015260a401610654565b6001600160a01b038316600090815260cf6020526040812054849060ff16611f035760405162461bcd60e51b815260206004820152604d60248201527f53747261746567794d616e616765722e6f6e6c7953747261746567696573576860448201527f6974656c6973746564466f724465706f7369743a207374726174656779206e6f60648201527f742077686974656c697374656400000000000000000000000000000000000000608482015260a401610654565b611f186001600160a01b03851633878661273d565b6040517f47e7ef240000000000000000000000000000000000000000000000000000000081526001600160a01b038581166004830152602482018590528616906347e7ef24906044016020604051808303816000875af1158015611f80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fa49190613467565b9150611fb2868587856122f0565b6040517f28a573ae0000000000000000000000000000000000000000000000000000000081526001600160a01b0387811660048301528681166024830152604482018490527f000000000000000000000000000000000000000000000000000000000000000016906328a573ae90606401600060405180830381600087803b15801561203d57600080fd5b505af1158015612051573d6000803e3d6000fd5b5050505050949350505050565b604080516001600160a01b038416815282151560208201527f77d930df4937793473a95024d87a98fd2ccb9e92d3c2463b3dacd65d3e6a5786910160405180910390a16001600160a01b0391909116600090815260d060205260409020805460ff1916911515919091179055565b6033546001600160a01b03163314610cb85760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610654565b603380546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000816000036121fd5760405162461bcd60e51b815260206004820152603e60248201527f53747261746567794d616e616765722e5f72656d6f76655368617265733a207360448201527f68617265416d6f756e742073686f756c64206e6f74206265207a65726f2100006064820152608401610654565b6001600160a01b03808516600090815260cd6020908152604080832093871683529290522054808311156122995760405162461bcd60e51b815260206004820152603360248201527f53747261746567794d616e616765722e5f72656d6f76655368617265733a207360448201527f68617265416d6f756e7420746f6f2068696768000000000000000000000000006064820152608401610654565b6001600160a01b03808616600090815260cd60209081526040808320938816835292905290812091849003918290558190036122e3576122d985856127c5565b60019150506122e9565b60009150505b9392505050565b6001600160a01b03841661236c5760405162461bcd60e51b815260206004820152603960248201527f53747261746567794d616e616765722e5f6164645368617265733a207374616b60448201527f65722063616e6e6f74206265207a65726f2061646472657373000000000000006064820152608401610654565b806000036123e25760405162461bcd60e51b815260206004820152603660248201527f53747261746567794d616e616765722e5f6164645368617265733a207368617260448201527f65732073686f756c64206e6f74206265207a65726f21000000000000000000006064820152608401610654565b6001600160a01b03808516600090815260cd602090815260408083209386168352929052908120549003612511576001600160a01b038416600090815260ce6020908152604090912054106124c55760405162461bcd60e51b815260206004820152605060248201527f53747261746567794d616e616765722e5f6164645368617265733a206465706f60448201527f73697420776f756c6420657863656564204d41585f5354414b45525f5354524160648201527f544547595f4c4953545f4c454e47544800000000000000000000000000000000608482015260a401610654565b6001600160a01b03848116600090815260ce6020908152604082208054600181018255908352912001805473ffffffffffffffffffffffffffffffffffffffff19169184169190911790555b6001600160a01b03808516600090815260cd6020908152604080832093861683529290529081208054839290612548908490613496565b9091555050604080516001600160a01b03868116825285811660208301528416818301526060810183905290517f7cfff908a4b583f36430b25d75964c458d8ede8a99bd61be750e97ee1b2f3a969181900360800190a150505050565b60cc54604080516001600160a01b03928316815291831660208301527f4264275e593955ff9d6146a51a4525f6ddace2e81db9391abcc9d1ca48047d29910160405180910390a160cc805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6097546001600160a01b031615801561263c57506001600160a01b03821615155b6126d45760405162461bcd60e51b815260206004820152604760248201527f5061757361626c652e5f696e697469616c697a655061757365723a205f696e6960448201527f7469616c697a6550617573657228292063616e206f6e6c792062652063616c6c60648201527f6564206f6e636500000000000000000000000000000000000000000000000000608482015260a401610654565b609881905560405181815233907fab40a374bc51de372200a8bc981af8c9ecdc08dfdaef0bb6e09f88f3c616ef3d9060200160405180910390a2610b8582611acc565b600080600061272685856129d6565b9150915061273381612a1b565b5090505b92915050565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd00000000000000000000000000000000000000000000000000000000179052610d65908590612b80565b6001600160a01b038216600090815260ce6020526040812054905b818110156128df576001600160a01b03848116600090815260ce602052604090208054918516918390811061281757612817613389565b6000918252602090912001546001600160a01b0316036128d7576001600160a01b038416600090815260ce602052604090208054612857906001906134a9565b8154811061286757612867613389565b60009182526020808320909101546001600160a01b03878116845260ce90925260409092208054919092169190839081106128a4576128a4613389565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506128df565b6001016127e0565b81810361297a5760405162461bcd60e51b815260206004820152604960248201527f53747261746567794d616e616765722e5f72656d6f766553747261746567794660448201527f726f6d5374616b657253747261746567794c6973743a2073747261746567792060648201527f6e6f7420666f756e640000000000000000000000000000000000000000000000608482015260a401610654565b6001600160a01b038416600090815260ce602052604090208054806129a1576129a16134bc565b6000828152602090208101600019908101805473ffffffffffffffffffffffffffffffffffffffff1916905501905550505050565b6000808251604103612a0c5760208301516040840151606085015160001a612a0087828585612c68565b94509450505050612a14565b506000905060025b9250929050565b6000816004811115612a2f57612a2f6134d2565b03612a375750565b6001816004811115612a4b57612a4b6134d2565b03612a985760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610654565b6002816004811115612aac57612aac6134d2565b03612af95760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610654565b6003816004811115612b0d57612b0d6134d2565b036106665760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152608401610654565b6000612bd5826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612d2c9092919063ffffffff16565b9050805160001480612bf6575080806020019051810190612bf6919061336c565b611d925760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610654565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115612c9f5750600090506003612d23565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612cf3573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116612d1c57600060019250925050612d23565b9150600090505b94509492505050565b6060612d3b8484600085612d43565b949350505050565b606082471015612dbb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610654565b600080866001600160a01b03168587604051612dd791906134e8565b60006040518083038185875af1925050503d8060008114612e14576040519150601f19603f3d011682016040523d82523d6000602084013e612e19565b606091505b5091509150612e2a87838387612e35565b979650505050505050565b60608315612ea4578251600003612e9d576001600160a01b0385163b612e9d5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610654565b5081612d3b565b612d3b8383815115612eb95781518083602001fd5b8060405162461bcd60e51b81526004016106549190613504565b6001600160a01b038116811461066657600080fd5b600060208284031215612efa57600080fd5b81356122e981612ed3565b600060208284031215612f1757600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b60008060008060008060c08789031215612f4d57600080fd5b8635612f5881612ed3565b95506020870135612f6881612ed3565b9450604087013593506060870135612f7f81612ed3565b92506080870135915060a087013567ffffffffffffffff80821115612fa357600080fd5b818901915089601f830112612fb757600080fd5b813581811115612fc957612fc9612f1e565b604051601f8201601f19908116603f01168101908382118183101715612ff157612ff1612f1e565b816040528281528c602084870101111561300a57600080fd5b8260208601602083013760006020848301015280955050505050509295509295509295565b801515811461066657600080fd5b6000806040838503121561305057600080fd5b823561305b81612ed3565b9150602083013561306b8161302f565b809150509250929050565b60006020828403121561308857600080fd5b813560ff811681146122e957600080fd5b600080604083850312156130ac57600080fd5b82356130b781612ed3565b9150602083013561306b81612ed3565b6000806000606084860312156130dc57600080fd5b83356130e781612ed3565b925060208401356130f781612ed3565b929592945050506040919091013590565b604080825283519082018190526000906020906060840190828701845b8281101561314a5781516001600160a01b031684529284019290840190600101613125565b5050508381038285015284518082528583019183019060005b8181101561317f57835183529284019291840191600101613163565b5090979650505050505050565b60008083601f84011261319e57600080fd5b50813567ffffffffffffffff8111156131b657600080fd5b6020830191508360208260051b8501011115612a1457600080fd5b600080602083850312156131e457600080fd5b823567ffffffffffffffff8111156131fb57600080fd5b6132078582860161318c565b90969095509350505050565b6000806000806080858703121561322957600080fd5b843561323481612ed3565b9350602085013561324481612ed3565b9250604085013561325481612ed3565b9396929550929360600135925050565b6000806000806080858703121561327a57600080fd5b843561328581612ed3565b9350602085013561329581612ed3565b92506040850135915060608501356132ac81612ed3565b939692955090935050565b600080604083850312156132ca57600080fd5b82356132d581612ed3565b946020939093013593505050565b600080600080604085870312156132f957600080fd5b843567ffffffffffffffff8082111561331157600080fd5b61331d8883890161318c565b9096509450602087013591508082111561333657600080fd5b506133438782880161318c565b95989497509550505050565b60006020828403121561336157600080fd5b81516122e981612ed3565b60006020828403121561337e57600080fd5b81516122e98161302f565b634e487b7160e01b600052603260045260246000fd5b6000602082840312156133b157600080fd5b81356122e98161302f565b60005b838110156133d75781810151838201526020016133bf565b50506000910152565b600081518084526133f88160208601602086016133bc565b601f01601f19169290920160200192915050565b828152604060208201526000612d3b60408301846133e0565b60006020828403121561343757600080fd5b81517fffffffff00000000000000000000000000000000000000000000000000000000811681146122e957600080fd5b60006020828403121561347957600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561273757612737613480565b8181038181111561273757612737613480565b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052602160045260246000fd5b600082516134fa8184602087016133bc565b9190910192915050565b6020815260006122e960208301846133e056fea2646970667358221220cc2e8563945f779b8a690d46d0c0d832b76b68c2b5f5bc753f4dbe040910cb6664736f6c63430008140033000000000000000000000000230b442c0802fe83daf3d2656aadfd16ca1e1f66000000000000000000000000f5a3ee38ed6a60fb9632f2e894421ce84a6a78b8

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061020b5760003560e01c80638da5cb5b1161012a578063c6656702116100bd578063df5cf7231161008c578063f2fde38b11610071578063f2fde38b1461052d578063f698da2514610540578063fabc1cbc1461054857600080fd5b8063df5cf723146104f3578063e7a050aa1461051a57600080fd5b8063c6656702146104a7578063cbc2bd62146104ba578063cf756fdf146104cd578063df5b3547146104e057600080fd5b8063b1344271116100f9578063b134427114610447578063b5d8b5b81461046e578063c4623ea114610481578063c608c7f31461049457600080fd5b80638da5cb5b146103df57806394f649dd146103f0578063967fc0d2146104115780639b4da03d1461042457600080fd5b80635c975abb116101a25780637ecebe00116101715780637ecebe0014610358578063886f1195146103785780638b8aac3c146103a35780638c80d4e5146103cc57600080fd5b80635c975abb146102fa578063663c1de414610302578063715018a6146103255780637a7e0d921461032d57600080fd5b806348825e94116101de57806348825e94146102855780634e5a4263146102ac578063595c6a67146102bf5780635ac86ab7146102c757600080fd5b806310d67a2f14610210578063136439dd1461022557806320606b701461023857806332e89ace14610272575b600080fd5b61022361021e366004612ee8565b61055b565b005b610223610233366004612f05565b610669565b61025f7f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a86681565b6040519081526020015b60405180910390f35b61025f610280366004612f34565b6107fe565b61025f7f4337f82d142e41f2a8c10547cd8c859bddb92262a61058e77842e24d9dea922481565b6102236102ba36600461303d565b610aed565b610223610b89565b6102ea6102d5366004613076565b609854600160ff9092169190911b9081161490565b6040519015158152602001610269565b60985461025f565b6102ea610310366004612ee8565b60cf6020526000908152604090205460ff1681565b610223610ca6565b61025f61033b366004613099565b60cd60209081526000928352604080842090915290825290205481565b61025f610366366004612ee8565b60cb6020526000908152604090205481565b60975461038b906001600160a01b031681565b6040516001600160a01b039091168152602001610269565b61025f6103b1366004612ee8565b6001600160a01b0316600090815260ce602052604090205490565b6102236103da3660046130c7565b610cba565b6033546001600160a01b031661038b565b6104036103fe366004612ee8565b610d6b565b604051610269929190613108565b60cc5461038b906001600160a01b031681565b6102ea610432366004612ee8565b60d06020526000908152604090205460ff1681565b61038b7f000000000000000000000000f5a3ee38ed6a60fb9632f2e894421ce84a6a78b881565b61022361047c3660046131d1565b610eeb565b61022361048f366004613213565b6110c3565b6102236104a2366004613264565b61116f565b6102236104b5366004612ee8565b611298565b61038b6104c83660046132b7565b6112a9565b6102236104db366004613213565b6112e1565b6102236104ee3660046132e3565b6114aa565b61038b7f000000000000000000000000230b442c0802fe83daf3d2656aadfd16ca1e1f6681565b61025f6105283660046130c7565b611749565b61022361053b366004612ee8565b6117cb565b61025f611858565b610223610556366004612f05565b61191a565b609760009054906101000a90046001600160a01b03166001600160a01b031663eab66d7a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156105ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105d2919061334f565b6001600160a01b0316336001600160a01b03161461065d5760405162461bcd60e51b815260206004820152602a60248201527f6d73672e73656e646572206973206e6f74207065726d697373696f6e6564206160448201527f7320756e7061757365720000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b61066681611acc565b50565b60975460405163237dfb4760e11b81523360048201526001600160a01b03909116906346fbf68e90602401602060405180830381865afa1580156106b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106d5919061336c565b6107475760405162461bcd60e51b815260206004820152602860248201527f6d73672e73656e646572206973206e6f74207065726d697373696f6e6564206160448201527f73207061757365720000000000000000000000000000000000000000000000006064820152608401610654565b609854818116146107c05760405162461bcd60e51b815260206004820152603860248201527f5061757361626c652e70617573653a20696e76616c696420617474656d70742060448201527f746f20756e70617573652066756e6374696f6e616c69747900000000000000006064820152608401610654565b609881905560405181815233907fab40a374bc51de372200a8bc981af8c9ecdc08dfdaef0bb6e09f88f3c616ef3d906020015b60405180910390a250565b60985460009081906001908116036108585760405162461bcd60e51b815260206004820152601960248201527f5061757361626c653a20696e64657820697320706175736564000000000000006044820152606401610654565b610860611be4565b6001600160a01b038816600090815260d0602052604090205460ff16156109155760405162461bcd60e51b815260206004820152604a60248201527f53747261746567794d616e616765722e6465706f736974496e746f537472617460448201527f656779576974685369676e61747572653a207468697264207472616e7366657260648201527f732064697361626c656400000000000000000000000000000000000000000000608482015260a401610654565b428410156109b15760405162461bcd60e51b815260206004820152604360248201527f53747261746567794d616e616765722e6465706f736974496e746f537472617460448201527f656779576974685369676e61747572653a207369676e6174757265206578706960648201527f7265640000000000000000000000000000000000000000000000000000000000608482015260a401610654565b6001600160a01b03858116600081815260cb602090815260408083205481517f4337f82d142e41f2a8c10547cd8c859bddb92262a61058e77842e24d9dea922493810193909352908201939093528b84166060820152928a16608084015260a0830189905260c0830182905260e0830187905290916101000160408051601f1981840301815291815281516020928301206001600160a01b038a16600090815260cb9093529082206001850190559150610a69611858565b6040517f19010000000000000000000000000000000000000000000000000000000000006020820152602281019190915260428101839052606201604051602081830303815290604052805190602001209050610ac7888288611c3d565b610ad3888c8c8c611e4d565b9450505050610ae26001606555565b509695505050505050565b60cc546001600160a01b03163314610b7b5760405162461bcd60e51b8152602060048201526044602482018190527f53747261746567794d616e616765722e6f6e6c79537472617465677957686974908201527f656c69737465723a206e6f742074686520737472617465677957686974656c6960648201526339ba32b960e11b608482015260a401610654565b610b85828261205e565b5050565b60975460405163237dfb4760e11b81523360048201526001600160a01b03909116906346fbf68e90602401602060405180830381865afa158015610bd1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf5919061336c565b610c675760405162461bcd60e51b815260206004820152602860248201527f6d73672e73656e646572206973206e6f74207065726d697373696f6e6564206160448201527f73207061757365720000000000000000000000000000000000000000000000006064820152608401610654565b600019609881905560405190815233907fab40a374bc51de372200a8bc981af8c9ecdc08dfdaef0bb6e09f88f3c616ef3d9060200160405180910390a2565b610cae6120cc565b610cb86000612126565b565b336001600160a01b037f000000000000000000000000230b442c0802fe83daf3d2656aadfd16ca1e1f661614610d5a576040805162461bcd60e51b81526020600482015260248101919091527f53747261746567794d616e616765722e6f6e6c7944656c65676174696f6e4d6160448201527f6e616765723a206e6f74207468652044656c65676174696f6e4d616e616765726064820152608401610654565b610d65838383612185565b50505050565b6001600160a01b038116600090815260ce60205260408120546060918291908167ffffffffffffffff811115610da357610da3612f1e565b604051908082528060200260200182016040528015610dcc578160200160208202803683370190505b50905060005b82811015610e5d576001600160a01b038616600090815260cd6020908152604080832060ce9092528220805491929184908110610e1157610e11613389565b60009182526020808320909101546001600160a01b031683528201929092526040019020548251839083908110610e4a57610e4a613389565b6020908102919091010152600101610dd2565b5060ce6000866001600160a01b03166001600160a01b031681526020019081526020016000208181805480602002602001604051908101604052809291908181526020018280548015610ed957602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610ebb575b50505050509150935093505050915091565b60cc546001600160a01b03163314610f795760405162461bcd60e51b8152602060048201526044602482018190527f53747261746567794d616e616765722e6f6e6c79537472617465677957686974908201527f656c69737465723a206e6f742074686520737472617465677957686974656c6960648201526339ba32b960e11b608482015260a401610654565b8060005b81811015610d655760cf6000858584818110610f9b57610f9b613389565b9050602002016020810190610fb09190612ee8565b6001600160a01b0316815260208101919091526040016000205460ff16156110bb57600060cf6000868685818110610fea57610fea613389565b9050602002016020810190610fff9190612ee8565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790557f4074413b4b443e4e58019f2855a8765113358c7c72e39509c6af45fc0f5ba03084848381811061105a5761105a613389565b905060200201602081019061106f9190612ee8565b6040516001600160a01b03909116815260200160405180910390a16110bb84848381811061109f5761109f613389565b90506020020160208101906110b49190612ee8565b600061205e565b600101610f7d565b336001600160a01b037f000000000000000000000000230b442c0802fe83daf3d2656aadfd16ca1e1f661614611163576040805162461bcd60e51b81526020600482015260248101919091527f53747261746567794d616e616765722e6f6e6c7944656c65676174696f6e4d6160448201527f6e616765723a206e6f74207468652044656c65676174696f6e4d616e616765726064820152608401610654565b610d65848484846122f0565b336001600160a01b037f000000000000000000000000230b442c0802fe83daf3d2656aadfd16ca1e1f66161461120f576040805162461bcd60e51b81526020600482015260248101919091527f53747261746567794d616e616765722e6f6e6c7944656c65676174696f6e4d6160448201527f6e616765723a206e6f74207468652044656c65676174696f6e4d616e616765726064820152608401610654565b6040517fd9caed120000000000000000000000000000000000000000000000000000000081526001600160a01b03858116600483015282811660248301526044820184905284169063d9caed1290606401600060405180830381600087803b15801561127a57600080fd5b505af115801561128e573d6000803e3d6000fd5b5050505050505050565b6112a06120cc565b610666816125a5565b60ce60205281600052604060002081815481106112c557600080fd5b6000918252602090912001546001600160a01b03169150829050565b600054610100900460ff16158080156113015750600054600160ff909116105b8061131b5750303b15801561131b575060005460ff166001145b61138d5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610654565b6000805460ff1916600117905580156113b0576000805461ff0019166101001790555b604080518082018252600481526314195b1b60e21b60209182015281517f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a866818301527f0e0f546b3087f7e4405d37b8de121d34252412874bf985c456311dd7eca663b681840152466060820152306080808301919091528351808303909101815260a0909101909252815191012060ca5561144b838361261b565b61145485612126565b61145d846125a5565b80156114a3576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050565b60cc546001600160a01b031633146115385760405162461bcd60e51b8152602060048201526044602482018190527f53747261746567794d616e616765722e6f6e6c79537472617465677957686974908201527f656c69737465723a206e6f742074686520737472617465677957686974656c6960648201526339ba32b960e11b608482015260a401610654565b8281146115d35760405162461bcd60e51b815260206004820152604b60248201527f53747261746567794d616e616765722e61646453747261746567696573546f4460448201527f65706f73697457686974656c6973743a206172726179206c656e67746873206460648201527f6f206e6f74206d61746368000000000000000000000000000000000000000000608482015260a401610654565b8260005b818110156117415760cf60008787848181106115f5576115f5613389565b905060200201602081019061160a9190612ee8565b6001600160a01b0316815260208101919091526040016000205460ff1661173957600160cf600088888581811061164357611643613389565b90506020020160208101906116589190612ee8565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790557f0c35b17d91c96eb2751cd456e1252f42a386e524ef9ff26ecc9950859fdc04fe8686838181106116b3576116b3613389565b90506020020160208101906116c89190612ee8565b6040516001600160a01b03909116815260200160405180910390a16117398686838181106116f8576116f8613389565b905060200201602081019061170d9190612ee8565b85858481811061171f5761171f613389565b9050602002016020810190611734919061339f565b61205e565b6001016115d7565b505050505050565b60985460009081906001908116036117a35760405162461bcd60e51b815260206004820152601960248201527f5061757361626c653a20696e64657820697320706175736564000000000000006044820152606401610654565b6117ab611be4565b6117b733868686611e4d565b91506117c36001606555565b509392505050565b6117d36120cc565b6001600160a01b03811661184f5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610654565b61066681612126565b60007f00000000000000000000000000000000000000000000000000000000000013884603611888575060ca5490565b50604080518082018252600481526314195b1b60e21b60209182015281517f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a866818301527f0e0f546b3087f7e4405d37b8de121d34252412874bf985c456311dd7eca663b681840152466060820152306080808301919091528351808303909101815260a0909101909252815191012090565b609760009054906101000a90046001600160a01b03166001600160a01b031663eab66d7a6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561196d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611991919061334f565b6001600160a01b0316336001600160a01b031614611a175760405162461bcd60e51b815260206004820152602a60248201527f6d73672e73656e646572206973206e6f74207065726d697373696f6e6564206160448201527f7320756e706175736572000000000000000000000000000000000000000000006064820152608401610654565b609854198119609854191614611a955760405162461bcd60e51b815260206004820152603860248201527f5061757361626c652e756e70617573653a20696e76616c696420617474656d7060448201527f7420746f2070617573652066756e6374696f6e616c69747900000000000000006064820152608401610654565b609881905560405181815233907f3582d1828e26bf56bd801502bc021ac0bc8afb57c826e4986b45593c8fad389c906020016107f3565b6001600160a01b038116611b6e5760405162461bcd60e51b815260206004820152604960248201527f5061757361626c652e5f73657450617573657252656769737472793a206e657760448201527f50617573657252656769737472792063616e6e6f7420626520746865207a657260648201527f6f20616464726573730000000000000000000000000000000000000000000000608482015260a401610654565b609754604080516001600160a01b03928316815291831660208301527f6e9fcd539896fca60e8b0f01dd580233e48a6b0f7df013b89ba7f565869acdb6910160405180910390a16097805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b600260655403611c365760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610654565b6002606555565b6001600160a01b0383163b15611d97576040517f1626ba7e00000000000000000000000000000000000000000000000000000000808252906001600160a01b03851690631626ba7e90611c96908690869060040161340c565b602060405180830381865afa158015611cb3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cd79190613425565b7fffffffff000000000000000000000000000000000000000000000000000000001614611d925760405162461bcd60e51b815260206004820152605360248201527f454950313237315369676e61747572655574696c732e636865636b5369676e6160448201527f747572655f454950313237313a2045524331323731207369676e61747572652060648201527f766572696669636174696f6e206661696c656400000000000000000000000000608482015260a401610654565b505050565b826001600160a01b0316611dab8383612717565b6001600160a01b031614611d925760405162461bcd60e51b815260206004820152604760248201527f454950313237315369676e61747572655574696c732e636865636b5369676e6160448201527f747572655f454950313237313a207369676e6174757265206e6f742066726f6d60648201527f207369676e657200000000000000000000000000000000000000000000000000608482015260a401610654565b6001600160a01b038316600090815260cf6020526040812054849060ff16611f035760405162461bcd60e51b815260206004820152604d60248201527f53747261746567794d616e616765722e6f6e6c7953747261746567696573576860448201527f6974656c6973746564466f724465706f7369743a207374726174656779206e6f60648201527f742077686974656c697374656400000000000000000000000000000000000000608482015260a401610654565b611f186001600160a01b03851633878661273d565b6040517f47e7ef240000000000000000000000000000000000000000000000000000000081526001600160a01b038581166004830152602482018590528616906347e7ef24906044016020604051808303816000875af1158015611f80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fa49190613467565b9150611fb2868587856122f0565b6040517f28a573ae0000000000000000000000000000000000000000000000000000000081526001600160a01b0387811660048301528681166024830152604482018490527f000000000000000000000000230b442c0802fe83daf3d2656aadfd16ca1e1f6616906328a573ae90606401600060405180830381600087803b15801561203d57600080fd5b505af1158015612051573d6000803e3d6000fd5b5050505050949350505050565b604080516001600160a01b038416815282151560208201527f77d930df4937793473a95024d87a98fd2ccb9e92d3c2463b3dacd65d3e6a5786910160405180910390a16001600160a01b0391909116600090815260d060205260409020805460ff1916911515919091179055565b6033546001600160a01b03163314610cb85760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610654565b603380546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000816000036121fd5760405162461bcd60e51b815260206004820152603e60248201527f53747261746567794d616e616765722e5f72656d6f76655368617265733a207360448201527f68617265416d6f756e742073686f756c64206e6f74206265207a65726f2100006064820152608401610654565b6001600160a01b03808516600090815260cd6020908152604080832093871683529290522054808311156122995760405162461bcd60e51b815260206004820152603360248201527f53747261746567794d616e616765722e5f72656d6f76655368617265733a207360448201527f68617265416d6f756e7420746f6f2068696768000000000000000000000000006064820152608401610654565b6001600160a01b03808616600090815260cd60209081526040808320938816835292905290812091849003918290558190036122e3576122d985856127c5565b60019150506122e9565b60009150505b9392505050565b6001600160a01b03841661236c5760405162461bcd60e51b815260206004820152603960248201527f53747261746567794d616e616765722e5f6164645368617265733a207374616b60448201527f65722063616e6e6f74206265207a65726f2061646472657373000000000000006064820152608401610654565b806000036123e25760405162461bcd60e51b815260206004820152603660248201527f53747261746567794d616e616765722e5f6164645368617265733a207368617260448201527f65732073686f756c64206e6f74206265207a65726f21000000000000000000006064820152608401610654565b6001600160a01b03808516600090815260cd602090815260408083209386168352929052908120549003612511576001600160a01b038416600090815260ce6020908152604090912054106124c55760405162461bcd60e51b815260206004820152605060248201527f53747261746567794d616e616765722e5f6164645368617265733a206465706f60448201527f73697420776f756c6420657863656564204d41585f5354414b45525f5354524160648201527f544547595f4c4953545f4c454e47544800000000000000000000000000000000608482015260a401610654565b6001600160a01b03848116600090815260ce6020908152604082208054600181018255908352912001805473ffffffffffffffffffffffffffffffffffffffff19169184169190911790555b6001600160a01b03808516600090815260cd6020908152604080832093861683529290529081208054839290612548908490613496565b9091555050604080516001600160a01b03868116825285811660208301528416818301526060810183905290517f7cfff908a4b583f36430b25d75964c458d8ede8a99bd61be750e97ee1b2f3a969181900360800190a150505050565b60cc54604080516001600160a01b03928316815291831660208301527f4264275e593955ff9d6146a51a4525f6ddace2e81db9391abcc9d1ca48047d29910160405180910390a160cc805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6097546001600160a01b031615801561263c57506001600160a01b03821615155b6126d45760405162461bcd60e51b815260206004820152604760248201527f5061757361626c652e5f696e697469616c697a655061757365723a205f696e6960448201527f7469616c697a6550617573657228292063616e206f6e6c792062652063616c6c60648201527f6564206f6e636500000000000000000000000000000000000000000000000000608482015260a401610654565b609881905560405181815233907fab40a374bc51de372200a8bc981af8c9ecdc08dfdaef0bb6e09f88f3c616ef3d9060200160405180910390a2610b8582611acc565b600080600061272685856129d6565b9150915061273381612a1b565b5090505b92915050565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd00000000000000000000000000000000000000000000000000000000179052610d65908590612b80565b6001600160a01b038216600090815260ce6020526040812054905b818110156128df576001600160a01b03848116600090815260ce602052604090208054918516918390811061281757612817613389565b6000918252602090912001546001600160a01b0316036128d7576001600160a01b038416600090815260ce602052604090208054612857906001906134a9565b8154811061286757612867613389565b60009182526020808320909101546001600160a01b03878116845260ce90925260409092208054919092169190839081106128a4576128a4613389565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506128df565b6001016127e0565b81810361297a5760405162461bcd60e51b815260206004820152604960248201527f53747261746567794d616e616765722e5f72656d6f766553747261746567794660448201527f726f6d5374616b657253747261746567794c6973743a2073747261746567792060648201527f6e6f7420666f756e640000000000000000000000000000000000000000000000608482015260a401610654565b6001600160a01b038416600090815260ce602052604090208054806129a1576129a16134bc565b6000828152602090208101600019908101805473ffffffffffffffffffffffffffffffffffffffff1916905501905550505050565b6000808251604103612a0c5760208301516040840151606085015160001a612a0087828585612c68565b94509450505050612a14565b506000905060025b9250929050565b6000816004811115612a2f57612a2f6134d2565b03612a375750565b6001816004811115612a4b57612a4b6134d2565b03612a985760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610654565b6002816004811115612aac57612aac6134d2565b03612af95760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610654565b6003816004811115612b0d57612b0d6134d2565b036106665760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152608401610654565b6000612bd5826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612d2c9092919063ffffffff16565b9050805160001480612bf6575080806020019051810190612bf6919061336c565b611d925760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610654565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115612c9f5750600090506003612d23565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612cf3573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116612d1c57600060019250925050612d23565b9150600090505b94509492505050565b6060612d3b8484600085612d43565b949350505050565b606082471015612dbb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610654565b600080866001600160a01b03168587604051612dd791906134e8565b60006040518083038185875af1925050503d8060008114612e14576040519150601f19603f3d011682016040523d82523d6000602084013e612e19565b606091505b5091509150612e2a87838387612e35565b979650505050505050565b60608315612ea4578251600003612e9d576001600160a01b0385163b612e9d5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610654565b5081612d3b565b612d3b8383815115612eb95781518083602001fd5b8060405162461bcd60e51b81526004016106549190613504565b6001600160a01b038116811461066657600080fd5b600060208284031215612efa57600080fd5b81356122e981612ed3565b600060208284031215612f1757600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b60008060008060008060c08789031215612f4d57600080fd5b8635612f5881612ed3565b95506020870135612f6881612ed3565b9450604087013593506060870135612f7f81612ed3565b92506080870135915060a087013567ffffffffffffffff80821115612fa357600080fd5b818901915089601f830112612fb757600080fd5b813581811115612fc957612fc9612f1e565b604051601f8201601f19908116603f01168101908382118183101715612ff157612ff1612f1e565b816040528281528c602084870101111561300a57600080fd5b8260208601602083013760006020848301015280955050505050509295509295509295565b801515811461066657600080fd5b6000806040838503121561305057600080fd5b823561305b81612ed3565b9150602083013561306b8161302f565b809150509250929050565b60006020828403121561308857600080fd5b813560ff811681146122e957600080fd5b600080604083850312156130ac57600080fd5b82356130b781612ed3565b9150602083013561306b81612ed3565b6000806000606084860312156130dc57600080fd5b83356130e781612ed3565b925060208401356130f781612ed3565b929592945050506040919091013590565b604080825283519082018190526000906020906060840190828701845b8281101561314a5781516001600160a01b031684529284019290840190600101613125565b5050508381038285015284518082528583019183019060005b8181101561317f57835183529284019291840191600101613163565b5090979650505050505050565b60008083601f84011261319e57600080fd5b50813567ffffffffffffffff8111156131b657600080fd5b6020830191508360208260051b8501011115612a1457600080fd5b600080602083850312156131e457600080fd5b823567ffffffffffffffff8111156131fb57600080fd5b6132078582860161318c565b90969095509350505050565b6000806000806080858703121561322957600080fd5b843561323481612ed3565b9350602085013561324481612ed3565b9250604085013561325481612ed3565b9396929550929360600135925050565b6000806000806080858703121561327a57600080fd5b843561328581612ed3565b9350602085013561329581612ed3565b92506040850135915060608501356132ac81612ed3565b939692955090935050565b600080604083850312156132ca57600080fd5b82356132d581612ed3565b946020939093013593505050565b600080600080604085870312156132f957600080fd5b843567ffffffffffffffff8082111561331157600080fd5b61331d8883890161318c565b9096509450602087013591508082111561333657600080fd5b506133438782880161318c565b95989497509550505050565b60006020828403121561336157600080fd5b81516122e981612ed3565b60006020828403121561337e57600080fd5b81516122e98161302f565b634e487b7160e01b600052603260045260246000fd5b6000602082840312156133b157600080fd5b81356122e98161302f565b60005b838110156133d75781810151838201526020016133bf565b50506000910152565b600081518084526133f88160208601602086016133bc565b601f01601f19169290920160200192915050565b828152604060208201526000612d3b60408301846133e0565b60006020828403121561343757600080fd5b81517fffffffff00000000000000000000000000000000000000000000000000000000811681146122e957600080fd5b60006020828403121561347957600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561273757612737613480565b8181038181111561273757612737613480565b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052602160045260246000fd5b600082516134fa8184602087016133bc565b9190910192915050565b6020815260006122e960208301846133e056fea2646970667358221220cc2e8563945f779b8a690d46d0c0d832b76b68c2b5f5bc753f4dbe040910cb6664736f6c63430008140033

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

000000000000000000000000230b442c0802fe83daf3d2656aadfd16ca1e1f66000000000000000000000000f5a3ee38ed6a60fb9632f2e894421ce84a6a78b8

-----Decoded View---------------
Arg [0] : _delegation (address): 0x230B442c0802fE83DAf3d2656aaDFD16ca1E1F66
Arg [1] : _slasher (address): 0xF5A3ee38Ed6A60FB9632f2E894421cE84A6A78b8

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000230b442c0802fe83daf3d2656aadfd16ca1e1f66
Arg [1] : 000000000000000000000000f5a3ee38ed6a60fb9632f2e894421ce84a6a78b8


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

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