frxETH Price: $4,002.06 (+0.16%)

Token

ERC-20: Ionic Staked Frax Ether (ionsfrxETH)

Overview

Max Total Supply

2,984.79314517654916502 ionsfrxETH

Holders

8

Total Transfers

-

Market

Price

$0.00 @ 0.000000 frxETH

Onchain Market Cap

$0.00

Circulating Supply Market Cap

-

Other Info

Token Contract (WITH 18 Decimals)

Loading...
Loading
Loading...
Loading
Loading...
Loading

Click here to update the token information / general information

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0xDADd8556...0a1DE3070
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
CErc20Delegator

Compiler Version
v0.8.10+commit.fc410830

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, None license

Contract Source Code (Solidity)

/**
 *Submitted for verification at fraxscan.com on 2024-08-06
*/

// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.0 ^0.8.0 ^0.8.1 ^0.8.2;

// contracts/compound/EIP20Interface.sol

/**
 * @title ERC 20 Token Standard Interface
 *  https://eips.ethereum.org/EIPS/eip-20
 */
interface EIP20Interface {
  function name() external view returns (string memory);

  function symbol() external view returns (string memory);

  function decimals() external view returns (uint8);

  /**
   * @notice Get the total number of tokens in circulation
   * @return uint256 The supply of tokens
   */
  function totalSupply() external view returns (uint256);

  /**
   * @notice Gets the balance of the specified address
   * @param owner The address from which the balance will be retrieved
   * @return balance uint256 The balance
   */
  function balanceOf(address owner) external view returns (uint256 balance);

  /**
   * @notice Transfer `amount` tokens from `msg.sender` to `dst`
   * @param dst The address of the destination account
   * @param amount The number of tokens to transfer
   * @return success bool Whether or not the transfer succeeded
   */
  function transfer(address dst, uint256 amount) external returns (bool success);

  /**
   * @notice Transfer `amount` tokens from `src` to `dst`
   * @param src The address of the source account
   * @param dst The address of the destination account
   * @param amount The number of tokens to transfer
   * @return success bool Whether or not the transfer succeeded
   */
  function transferFrom(
    address src,
    address dst,
    uint256 amount
  ) external returns (bool success);

  /**
   * @notice Approve `spender` to transfer up to `amount` from `src`
   * @dev This will overwrite the approval amount for `spender`
   *  and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)
   * @param spender The address of the account which may transfer tokens
   * @param amount The number of tokens that are approved (-1 means infinite)
   * @return success bool Whether or not the approval succeeded
   */
  function approve(address spender, uint256 amount) external returns (bool success);

  /**
   * @notice Get the current allowance from `owner` for `spender`
   * @param owner The address of the account which owns the tokens to be spent
   * @param spender The address of the account which may transfer tokens
   * @return remaining uint256 The number of tokens allowed to be spent (-1 means infinite)
   */
  function allowance(address owner, address spender) external view returns (uint256 remaining);

  event Transfer(address indexed from, address indexed to, uint256 amount);
  event Approval(address indexed owner, address indexed spender, uint256 amount);
}

// contracts/compound/InterestRateModel.sol

/**
 * @title Compound's InterestRateModel Interface
 * @author Compound
 */
abstract contract InterestRateModel {
  /// @notice Indicator that this is an InterestRateModel contract (for inspection)
  bool public constant isInterestRateModel = true;

  /**
   * @notice Calculates the current borrow interest rate per block
   * @param cash The total amount of cash the market has
   * @param borrows The total amount of borrows the market has outstanding
   * @param reserves The total amount of reserves the market has
   * @return The borrow rate per block (as a percentage, and scaled by 1e18)
   */
  function getBorrowRate(
    uint256 cash,
    uint256 borrows,
    uint256 reserves
  ) public view virtual returns (uint256);

  /**
   * @notice Calculates the current supply interest rate per block
   * @param cash The total amount of cash the market has
   * @param borrows The total amount of borrows the market has outstanding
   * @param reserves The total amount of reserves the market has
   * @param reserveFactorMantissa The current reserve factor the market has
   * @return The supply rate per block (as a percentage, and scaled by 1e18)
   */
  function getSupplyRate(
    uint256 cash,
    uint256 borrows,
    uint256 reserves,
    uint256 reserveFactorMantissa
  ) public view virtual returns (uint256);
}

// contracts/ionic/DiamondExtension.sol

/**
 * @notice a base contract for logic extensions that use the diamond pattern storage
 * to map the functions when looking up the extension contract to delegate to.
 */
abstract contract DiamondExtension {
  /**
   * @return a list of all the function selectors that this logic extension exposes
   */
  function _getExtensionFunctions() external pure virtual returns (bytes4[] memory);
}

// When no function exists for function called
error FunctionNotFound(bytes4 _functionSelector);

// When no extension exists for function called
error ExtensionNotFound(bytes4 _functionSelector);

// When the function is already added
error FunctionAlreadyAdded(bytes4 _functionSelector, address _currentImpl);

abstract contract DiamondBase {
  /**
   * @dev register a logic extension
   * @param extensionToAdd the extension whose functions are to be added
   * @param extensionToReplace the extension whose functions are to be removed/replaced
   */
  function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external virtual;

  function _listExtensions() public view returns (address[] memory) {
    return LibDiamond.listExtensions();
  }

  fallback() external {
    address extension = LibDiamond.getExtensionForFunction(msg.sig);
    if (extension == address(0)) revert FunctionNotFound(msg.sig);
    // Execute external function from extension using delegatecall and return any value.
    assembly {
      // copy function selector and any arguments
      calldatacopy(0, 0, calldatasize())
      // execute function call using the extension
      let result := delegatecall(gas(), extension, 0, calldatasize(), 0, 0)
      // get any return value
      returndatacopy(0, 0, returndatasize())
      // return any return value or error back to the caller
      switch result
      case 0 {
        revert(0, returndatasize())
      }
      default {
        return(0, returndatasize())
      }
    }
  }
}

/**
 * @notice a library to use in a contract, whose logic is extended with diamond extension
 */
library LibDiamond {
  bytes32 constant DIAMOND_STORAGE_POSITION = keccak256("diamond.extensions.diamond.storage");

  struct Function {
    address extension;
    bytes4 selector;
  }

  struct LogicStorage {
    Function[] functions;
    address[] extensions;
  }

  function getExtensionForFunction(bytes4 msgSig) internal view returns (address) {
    return getExtensionForSelector(msgSig, diamondStorage());
  }

  function diamondStorage() internal pure returns (LogicStorage storage ds) {
    bytes32 position = DIAMOND_STORAGE_POSITION;
    assembly {
      ds.slot := position
    }
  }

  function listExtensions() internal view returns (address[] memory) {
    return diamondStorage().extensions;
  }

  function registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) internal {
    if (address(extensionToReplace) != address(0)) {
      removeExtension(extensionToReplace);
    }
    addExtension(extensionToAdd);
  }

  function removeExtension(DiamondExtension extension) internal {
    LogicStorage storage ds = diamondStorage();
    // remove all functions of the extension to replace
    removeExtensionFunctions(extension);
    for (uint8 i = 0; i < ds.extensions.length; i++) {
      if (ds.extensions[i] == address(extension)) {
        ds.extensions[i] = ds.extensions[ds.extensions.length - 1];
        ds.extensions.pop();
      }
    }
  }

  function addExtension(DiamondExtension extension) internal {
    LogicStorage storage ds = diamondStorage();
    for (uint8 i = 0; i < ds.extensions.length; i++) {
      require(ds.extensions[i] != address(extension), "extension already added");
    }
    addExtensionFunctions(extension);
    ds.extensions.push(address(extension));
  }

  function removeExtensionFunctions(DiamondExtension extension) internal {
    bytes4[] memory fnsToRemove = extension._getExtensionFunctions();
    LogicStorage storage ds = diamondStorage();
    for (uint16 i = 0; i < fnsToRemove.length; i++) {
      bytes4 selectorToRemove = fnsToRemove[i];
      // must never fail
      assert(address(extension) == getExtensionForSelector(selectorToRemove, ds));
      // swap with the last element in the selectorAtIndex array and remove the last element
      uint16 indexToKeep = getIndexForSelector(selectorToRemove, ds);
      ds.functions[indexToKeep] = ds.functions[ds.functions.length - 1];
      ds.functions.pop();
    }
  }

  function addExtensionFunctions(DiamondExtension extension) internal {
    bytes4[] memory fnsToAdd = extension._getExtensionFunctions();
    LogicStorage storage ds = diamondStorage();
    uint16 functionsCount = uint16(ds.functions.length);
    for (uint256 functionsIndex = 0; functionsIndex < fnsToAdd.length; functionsIndex++) {
      bytes4 selector = fnsToAdd[functionsIndex];
      address oldImplementation = getExtensionForSelector(selector, ds);
      if (oldImplementation != address(0)) revert FunctionAlreadyAdded(selector, oldImplementation);
      ds.functions.push(Function(address(extension), selector));
      functionsCount++;
    }
  }

  function getExtensionForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (address) {
    uint256 fnsLen = ds.functions.length;
    for (uint256 i = 0; i < fnsLen; i++) {
      if (ds.functions[i].selector == selector) return ds.functions[i].extension;
    }

    return address(0);
  }

  function getIndexForSelector(bytes4 selector, LogicStorage storage ds) internal view returns (uint16) {
    uint16 fnsLen = uint16(ds.functions.length);
    for (uint16 i = 0; i < fnsLen; i++) {
      if (ds.functions[i].selector == selector) return i;
    }

    return type(uint16).max;
  }
}

// lib/openzeppelin-contracts/contracts/interfaces/draft-IERC1822.sol

// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)

/**
 * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
 * proxy whose upgrades are fully controlled by the current implementation.
 */
interface IERC1822Proxiable {
    /**
     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
     * address.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy.
     */
    function proxiableUUID() external view returns (bytes32);
}

// lib/openzeppelin-contracts/contracts/proxy/Proxy.sol

// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)

/**
 * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
 * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
 * be specified by overriding the virtual {_implementation} function.
 *
 * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
 * different contract through the {_delegate} function.
 *
 * The success and return data of the delegated call will be returned back to the caller of the proxy.
 */
abstract contract Proxy {
    /**
     * @dev Delegates the current call to `implementation`.
     *
     * This function does not return to its internal call site, it will return directly to the external caller.
     */
    function _delegate(address implementation) internal virtual {
        assembly {
            // Copy msg.data. We take full control of memory in this inline assembly
            // block because it will not return to Solidity code. We overwrite the
            // Solidity scratch pad at memory position 0.
            calldatacopy(0, 0, calldatasize())

            // Call the implementation.
            // out and outsize are 0 because we don't know the size yet.
            let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)

            // Copy the returned data.
            returndatacopy(0, 0, returndatasize())

            switch result
            // delegatecall returns 0 on error.
            case 0 {
                revert(0, returndatasize())
            }
            default {
                return(0, returndatasize())
            }
        }
    }

    /**
     * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function
     * and {_fallback} should delegate.
     */
    function _implementation() internal view virtual returns (address);

    /**
     * @dev Delegates the current call to the address returned by `_implementation()`.
     *
     * This function does not return to its internal call site, it will return directly to the external caller.
     */
    function _fallback() internal virtual {
        _beforeFallback();
        _delegate(_implementation());
    }

    /**
     * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
     * function in the contract matches the call data.
     */
    fallback() external payable virtual {
        _fallback();
    }

    /**
     * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
     * is empty.
     */
    receive() external payable virtual {
        _fallback();
    }

    /**
     * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
     * call, or as part of the Solidity `fallback` or `receive` functions.
     *
     * If overridden should call `super._beforeFallback()`.
     */
    function _beforeFallback() internal virtual {}
}

// lib/openzeppelin-contracts/contracts/proxy/beacon/IBeacon.sol

// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)

/**
 * @dev This is the interface that {BeaconProxy} expects of its beacon.
 */
interface IBeacon {
    /**
     * @dev Must return an address that can be used as a delegate call target.
     *
     * {BeaconProxy} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}

// lib/openzeppelin-contracts/contracts/utils/Address.sol

// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)

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

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://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.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

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

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

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

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

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

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

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

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

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

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

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

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

// lib/openzeppelin-contracts/contracts/utils/StorageSlot.sol

// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC1967 implementation slot:
 * ```
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
 */
library StorageSlot {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }
}

// lib/openzeppelin-contracts/contracts/utils/structs/EnumerableSet.sol

// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 *
 * [WARNING]
 * ====
 * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
 * unusable.
 * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
 *
 * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
 * array of EnumerableSet.
 * ====
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping(bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            if (lastIndex != toDeleteIndex) {
                bytes32 lastValue = set._values[lastIndex];

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastValue;
                // Update the index for the moved value
                set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        bytes32[] memory store = _values(set._inner);
        bytes32[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }
}

// lib/openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol

// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)

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

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://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.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

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

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

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

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

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

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

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

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

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

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

// lib/solmate/src/auth/Auth.sol

/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)
/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)
abstract contract Auth {
    event OwnerUpdated(address indexed user, address indexed newOwner);

    event AuthorityUpdated(address indexed user, Authority indexed newAuthority);

    address public owner;

    Authority public authority;

    constructor(address _owner, Authority _authority) {
        owner = _owner;
        authority = _authority;

        emit OwnerUpdated(msg.sender, _owner);
        emit AuthorityUpdated(msg.sender, _authority);
    }

    modifier requiresAuth() virtual {
        require(isAuthorized(msg.sender, msg.sig), "UNAUTHORIZED");

        _;
    }

    function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {
        Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.

        // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be
        // aware that this makes protected functions uncallable even to the owner if the authority is out of order.
        return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;
    }

    function setAuthority(Authority newAuthority) public virtual {
        // We check if the caller is the owner first because we want to ensure they can
        // always swap out the authority even if it's reverting or using up a lot of gas.
        require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));

        authority = newAuthority;

        emit AuthorityUpdated(msg.sender, newAuthority);
    }

    function setOwner(address newOwner) public virtual requiresAuth {
        owner = newOwner;

        emit OwnerUpdated(msg.sender, newOwner);
    }
}

/// @notice A generic interface for a contract which provides authorization data to an Auth instance.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)
/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)
interface Authority {
    function canCall(
        address user,
        address target,
        bytes4 functionSig
    ) external view returns (bool);
}

// lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol

// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)

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

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

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

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

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

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

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

    /**
     * @dev Internal function that returns the initialized version. Returns `_initialized`
     */
    function _getInitializedVersion() internal view returns (uint8) {
        return _initialized;
    }

    /**
     * @dev Internal function that returns the initialized version. Returns `_initializing`
     */
    function _isInitializing() internal view returns (bool) {
        return _initializing;
    }
}

// lib/solmate/src/auth/authorities/RolesAuthority.sol

/// @notice Role based Authority that supports up to 256 roles.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/authorities/RolesAuthority.sol)
/// @author Modified from Dappsys (https://github.com/dapphub/ds-roles/blob/master/src/roles.sol)
contract RolesAuthority is Auth, Authority {
    /*//////////////////////////////////////////////////////////////
                                 EVENTS
    //////////////////////////////////////////////////////////////*/

    event UserRoleUpdated(address indexed user, uint8 indexed role, bool enabled);

    event PublicCapabilityUpdated(address indexed target, bytes4 indexed functionSig, bool enabled);

    event RoleCapabilityUpdated(uint8 indexed role, address indexed target, bytes4 indexed functionSig, bool enabled);

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

    constructor(address _owner, Authority _authority) Auth(_owner, _authority) {}

    /*//////////////////////////////////////////////////////////////
                            ROLE/USER STORAGE
    //////////////////////////////////////////////////////////////*/

    mapping(address => bytes32) public getUserRoles;

    mapping(address => mapping(bytes4 => bool)) public isCapabilityPublic;

    mapping(address => mapping(bytes4 => bytes32)) public getRolesWithCapability;

    function doesUserHaveRole(address user, uint8 role) public view virtual returns (bool) {
        return (uint256(getUserRoles[user]) >> role) & 1 != 0;
    }

    function doesRoleHaveCapability(
        uint8 role,
        address target,
        bytes4 functionSig
    ) public view virtual returns (bool) {
        return (uint256(getRolesWithCapability[target][functionSig]) >> role) & 1 != 0;
    }

    /*//////////////////////////////////////////////////////////////
                           AUTHORIZATION LOGIC
    //////////////////////////////////////////////////////////////*/

    function canCall(
        address user,
        address target,
        bytes4 functionSig
    ) public view virtual override returns (bool) {
        return
            isCapabilityPublic[target][functionSig] ||
            bytes32(0) != getUserRoles[user] & getRolesWithCapability[target][functionSig];
    }

    /*//////////////////////////////////////////////////////////////
                   ROLE CAPABILITY CONFIGURATION LOGIC
    //////////////////////////////////////////////////////////////*/

    function setPublicCapability(
        address target,
        bytes4 functionSig,
        bool enabled
    ) public virtual requiresAuth {
        isCapabilityPublic[target][functionSig] = enabled;

        emit PublicCapabilityUpdated(target, functionSig, enabled);
    }

    function setRoleCapability(
        uint8 role,
        address target,
        bytes4 functionSig,
        bool enabled
    ) public virtual requiresAuth {
        if (enabled) {
            getRolesWithCapability[target][functionSig] |= bytes32(1 << role);
        } else {
            getRolesWithCapability[target][functionSig] &= ~bytes32(1 << role);
        }

        emit RoleCapabilityUpdated(role, target, functionSig, enabled);
    }

    /*//////////////////////////////////////////////////////////////
                       USER ROLE ASSIGNMENT LOGIC
    //////////////////////////////////////////////////////////////*/

    function setUserRole(
        address user,
        uint8 role,
        bool enabled
    ) public virtual requiresAuth {
        if (enabled) {
            getUserRoles[user] |= bytes32(1 << role);
        } else {
            getUserRoles[user] &= ~bytes32(1 << role);
        }

        emit UserRoleUpdated(user, role, enabled);
    }
}

// lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol

// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

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

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

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

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

// lib/openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol

// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

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

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

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

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

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

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

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

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }

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

// contracts/ionic/SafeOwnableUpgradeable.sol

/**
 * @dev Ownable extension that requires a two-step process of setting the pending owner and the owner accepting it.
 * @notice Existing OwnableUpgradeable contracts cannot be upgraded due to the extra storage variable
 * that will shift the other.
 */
abstract contract SafeOwnableUpgradeable is OwnableUpgradeable {
  /**
   * @notice Pending owner of this contract
   */
  address public pendingOwner;

  function __SafeOwnable_init(address owner_) internal onlyInitializing {
    __Ownable_init();
    _transferOwnership(owner_);
  }

  struct AddressSlot {
    address value;
  }

  modifier onlyOwnerOrAdmin() {
    bool isOwner = owner() == _msgSender();
    if (!isOwner) {
      address admin = _getProxyAdmin();
      bool isAdmin = admin == _msgSender();
      require(isAdmin, "Ownable: caller is neither the owner nor the admin");
    }
    _;
  }

  /**
   * @notice Emitted when pendingOwner is changed
   */
  event NewPendingOwner(address oldPendingOwner, address newPendingOwner);

  /**
   * @notice Emitted when pendingOwner is accepted, which means owner is updated
   */
  event NewOwner(address oldOwner, address newOwner);

  /**
   * @notice Begins transfer of owner rights. The newPendingOwner must call `_acceptOwner` to finalize the transfer.
   * @dev Owner function to begin change of owner. The newPendingOwner must call `_acceptOwner` to finalize the transfer.
   * @param newPendingOwner New pending owner.
   */
  function _setPendingOwner(address newPendingOwner) public onlyOwner {
    // Save current value, if any, for inclusion in log
    address oldPendingOwner = pendingOwner;

    // Store pendingOwner with value newPendingOwner
    pendingOwner = newPendingOwner;

    // Emit NewPendingOwner(oldPendingOwner, newPendingOwner)
    emit NewPendingOwner(oldPendingOwner, newPendingOwner);
  }

  /**
   * @notice Accepts transfer of owner rights. msg.sender must be pendingOwner
   * @dev Owner function for pending owner to accept role and update owner
   */
  function _acceptOwner() public {
    // Check caller is pendingOwner and pendingOwner ≠ address(0)
    require(msg.sender == pendingOwner, "not the pending owner");

    // Save current values for inclusion in log
    address oldOwner = owner();
    address oldPendingOwner = pendingOwner;

    // Store owner with value pendingOwner
    _transferOwnership(pendingOwner);

    // Clear the pending value
    pendingOwner = address(0);

    emit NewOwner(oldOwner, pendingOwner);
    emit NewPendingOwner(oldPendingOwner, pendingOwner);
  }

  function renounceOwnership() public override onlyOwner {
    // do not remove this overriding fn
    revert("not used anymore");
  }

  function transferOwnership(address newOwner) public override onlyOwner {
    emit NewPendingOwner(pendingOwner, newOwner);
    pendingOwner = newOwner;
  }

  function _getProxyAdmin() internal view returns (address admin) {
    bytes32 _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
    AddressSlot storage adminSlot;
    assembly {
      adminSlot.slot := _ADMIN_SLOT
    }
    admin = adminSlot.value;
  }
}

// lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Upgrade.sol

// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 *
 * _Available since v4.1._
 *
 * @custom:oz-upgrades-unsafe-allow delegatecall
 */
abstract contract ERC1967Upgrade {
    // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;

    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Returns the current implementation address.
     */
    function _getImplementation() internal view returns (address) {
        return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
        StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Perform implementation upgrade
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeTo(address newImplementation) internal {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);
    }

    /**
     * @dev Perform implementation upgrade with additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCall(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        _upgradeTo(newImplementation);
        if (data.length > 0 || forceCall) {
            Address.functionDelegateCall(newImplementation, data);
        }
    }

    /**
     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCallUUPS(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        // Upgrades from old implementations will perform a rollback test. This test requires the new
        // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
        // this special case will break upgrade paths from old UUPS implementation to new ones.
        if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {
            _setImplementation(newImplementation);
        } else {
            try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
                require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
            } catch {
                revert("ERC1967Upgrade: new implementation is not UUPS");
            }
            _upgradeToAndCall(newImplementation, data, forceCall);
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Returns the current admin.
     */
    function _getAdmin() internal view returns (address) {
        return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        require(newAdmin != address(0), "ERC1967: new admin is the zero address");
        StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     */
    function _changeAdmin(address newAdmin) internal {
        emit AdminChanged(_getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
     */
    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Emitted when the beacon is upgraded.
     */
    event BeaconUpgraded(address indexed beacon);

    /**
     * @dev Returns the current beacon.
     */
    function _getBeacon() internal view returns (address) {
        return StorageSlot.getAddressSlot(_BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the EIP1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract");
        require(
            Address.isContract(IBeacon(newBeacon).implementation()),
            "ERC1967: beacon implementation is not a contract"
        );
        StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;
    }

    /**
     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
     *
     * Emits a {BeaconUpgraded} event.
     */
    function _upgradeBeaconToAndCall(
        address newBeacon,
        bytes memory data,
        bool forceCall
    ) internal {
        _setBeacon(newBeacon);
        emit BeaconUpgraded(newBeacon);
        if (data.length > 0 || forceCall) {
            Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
        }
    }
}

// contracts/ionic/AddressesProvider.sol

/**
 * @title AddressesProvider
 * @notice The Addresses Provider serves as a central storage of system internal and external
 *         contract addresses that change between deploys and across chains
 * @author Veliko Minkov <[email protected]>
 */
contract AddressesProvider is SafeOwnableUpgradeable {
  mapping(string => address) private _addresses;
  mapping(address => Contract) public plugins;
  mapping(address => Contract) public flywheelRewards;
  mapping(address => RedemptionStrategy) public redemptionStrategiesConfig;
  mapping(address => FundingStrategy) public fundingStrategiesConfig;
  JarvisPool[] public jarvisPoolsConfig;
  CurveSwapPool[] public curveSwapPoolsConfig;
  mapping(address => mapping(address => address)) public balancerPoolForTokens;

  /// @dev Initializer to set the admin that can set and change contracts addresses
  function initialize(address owner) public initializer {
    __SafeOwnable_init(owner);
  }

  /**
   * @dev The contract address and a string that uniquely identifies the contract's interface
   */
  struct Contract {
    address addr;
    string contractInterface;
  }

  struct RedemptionStrategy {
    address addr;
    string contractInterface;
    address outputToken;
  }

  struct FundingStrategy {
    address addr;
    string contractInterface;
    address inputToken;
  }

  struct JarvisPool {
    address syntheticToken;
    address collateralToken;
    address liquidityPool;
    uint256 expirationTime;
  }

  struct CurveSwapPool {
    address poolAddress;
    address[] coins;
  }

  /**
   * @dev sets the address and contract interface ID of the flywheel for the reward token
   * @param rewardToken the reward token address
   * @param flywheelRewardsModule the flywheel rewards module address
   * @param contractInterface a string that uniquely identifies the contract's interface
   */
  function setFlywheelRewards(
    address rewardToken,
    address flywheelRewardsModule,
    string calldata contractInterface
  ) public onlyOwner {
    flywheelRewards[rewardToken] = Contract(flywheelRewardsModule, contractInterface);
  }

  /**
   * @dev sets the address and contract interface ID of the ERC4626 plugin for the asset
   * @param asset the asset address
   * @param plugin the ERC4626 plugin address
   * @param contractInterface a string that uniquely identifies the contract's interface
   */
  function setPlugin(
    address asset,
    address plugin,
    string calldata contractInterface
  ) public onlyOwner {
    plugins[asset] = Contract(plugin, contractInterface);
  }

  /**
   * @dev sets the address and contract interface ID of the redemption strategy for the asset
   * @param asset the asset address
   * @param strategy redemption strategy address
   * @param contractInterface a string that uniquely identifies the contract's interface
   */
  function setRedemptionStrategy(
    address asset,
    address strategy,
    string calldata contractInterface,
    address outputToken
  ) public onlyOwner {
    redemptionStrategiesConfig[asset] = RedemptionStrategy(strategy, contractInterface, outputToken);
  }

  function getRedemptionStrategy(address asset) public view returns (RedemptionStrategy memory) {
    return redemptionStrategiesConfig[asset];
  }

  /**
   * @dev sets the address and contract interface ID of the funding strategy for the asset
   * @param asset the asset address
   * @param strategy funding strategy address
   * @param contractInterface a string that uniquely identifies the contract's interface
   */
  function setFundingStrategy(
    address asset,
    address strategy,
    string calldata contractInterface,
    address inputToken
  ) public onlyOwner {
    fundingStrategiesConfig[asset] = FundingStrategy(strategy, contractInterface, inputToken);
  }

  function getFundingStrategy(address asset) public view returns (FundingStrategy memory) {
    return fundingStrategiesConfig[asset];
  }

  /**
   * @dev configures the Jarvis pool of a Jarvis synthetic token
   * @param syntheticToken the synthetic token address
   * @param collateralToken the collateral token address
   * @param liquidityPool the liquidity pool address
   * @param expirationTime the operation expiration time
   */
  function setJarvisPool(
    address syntheticToken,
    address collateralToken,
    address liquidityPool,
    uint256 expirationTime
  ) public onlyOwner {
    jarvisPoolsConfig.push(JarvisPool(syntheticToken, collateralToken, liquidityPool, expirationTime));
  }

  function setCurveSwapPool(address poolAddress, address[] calldata coins) public onlyOwner {
    curveSwapPoolsConfig.push(CurveSwapPool(poolAddress, coins));
  }

  /**
   * @dev Sets an address for an id replacing the address saved in the addresses map
   * @param id The id
   * @param newAddress The address to set
   */
  function setAddress(string calldata id, address newAddress) external onlyOwner {
    _addresses[id] = newAddress;
  }

  /**
   * @dev Returns an address by id
   * @return The address
   */
  function getAddress(string calldata id) public view returns (address) {
    return _addresses[id];
  }

  function getCurveSwapPools() public view returns (CurveSwapPool[] memory) {
    return curveSwapPoolsConfig;
  }

  function getJarvisPools() public view returns (JarvisPool[] memory) {
    return jarvisPoolsConfig;
  }

  function setBalancerPoolForTokens(
    address inputToken,
    address outputToken,
    address pool
  ) external onlyOwner {
    balancerPoolForTokens[inputToken][outputToken] = pool;
  }

  function getBalancerPoolForTokens(address inputToken, address outputToken) external view returns (address) {
    return balancerPoolForTokens[inputToken][outputToken];
  }
}

// lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol

// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)

/**
 * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
 * implementation address that can be changed. This address is stored in storage in the location specified by
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the
 * implementation behind the proxy.
 */
contract ERC1967Proxy is Proxy, ERC1967Upgrade {
    /**
     * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.
     *
     * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded
     * function call, and allows initializing the storage of the proxy like a Solidity constructor.
     */
    constructor(address _logic, bytes memory _data) payable {
        _upgradeToAndCall(_logic, _data, false);
    }

    /**
     * @dev Returns the current implementation address.
     */
    function _implementation() internal view virtual override returns (address impl) {
        return ERC1967Upgrade._getImplementation();
    }
}

// lib/openzeppelin-contracts/contracts/proxy/transparent/TransparentUpgradeableProxy.sol

// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)

/**
 * @dev This contract implements a proxy that is upgradeable by an admin.
 *
 * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector
 * clashing], which can potentially be used in an attack, this contract uses the
 * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two
 * things that go hand in hand:
 *
 * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if
 * that call matches one of the admin functions exposed by the proxy itself.
 * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the
 * implementation. If the admin tries to call a function on the implementation it will fail with an error that says
 * "admin cannot fallback to proxy target".
 *
 * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing
 * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due
 * to sudden errors when trying to call a function from the proxy implementation.
 *
 * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,
 * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.
 */
contract TransparentUpgradeableProxy is ERC1967Proxy {
    /**
     * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and
     * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.
     */
    constructor(
        address _logic,
        address admin_,
        bytes memory _data
    ) payable ERC1967Proxy(_logic, _data) {
        _changeAdmin(admin_);
    }

    /**
     * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.
     */
    modifier ifAdmin() {
        if (msg.sender == _getAdmin()) {
            _;
        } else {
            _fallback();
        }
    }

    /**
     * @dev Returns the current admin.
     *
     * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.
     *
     * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
     * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
     * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
     */
    function admin() external ifAdmin returns (address admin_) {
        admin_ = _getAdmin();
    }

    /**
     * @dev Returns the current implementation.
     *
     * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.
     *
     * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
     * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
     * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
     */
    function implementation() external ifAdmin returns (address implementation_) {
        implementation_ = _implementation();
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     *
     * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.
     */
    function changeAdmin(address newAdmin) external virtual ifAdmin {
        _changeAdmin(newAdmin);
    }

    /**
     * @dev Upgrade the implementation of the proxy.
     *
     * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.
     */
    function upgradeTo(address newImplementation) external ifAdmin {
        _upgradeToAndCall(newImplementation, bytes(""), false);
    }

    /**
     * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified
     * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the
     * proxied contract.
     *
     * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.
     */
    function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {
        _upgradeToAndCall(newImplementation, data, true);
    }

    /**
     * @dev Returns the current admin.
     */
    function _admin() internal view virtual returns (address) {
        return _getAdmin();
    }

    /**
     * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.
     */
    function _beforeFallback() internal virtual override {
        require(msg.sender != _getAdmin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target");
        super._beforeFallback();
    }
}

// contracts/compound/CTokenInterfaces.sol

abstract contract CTokenAdminStorage {
  /*
   * Administrator for Ionic
   */
  address payable public ionicAdmin;
}

abstract contract CErc20Storage is CTokenAdminStorage {
  /**
   * @dev Guard variable for re-entrancy checks
   */
  bool internal _notEntered;

  /**
   * @notice EIP-20 token name for this token
   */
  string public name;

  /**
   * @notice EIP-20 token symbol for this token
   */
  string public symbol;

  /**
   * @notice EIP-20 token decimals for this token
   */
  uint8 public decimals;

  /*
   * Maximum borrow rate that can ever be applied (.0005% / block)
   */
  uint256 internal constant borrowRateMaxMantissa = 0.0005e16;

  /*
   * Maximum fraction of interest that can be set aside for reserves + fees
   */
  uint256 internal constant reserveFactorPlusFeesMaxMantissa = 1e18;

  /**
   * @notice Contract which oversees inter-cToken operations
   */
  IonicComptroller public comptroller;

  /**
   * @notice Model which tells what the current interest rate should be
   */
  InterestRateModel public interestRateModel;

  /*
   * Initial exchange rate used when minting the first CTokens (used when totalSupply = 0)
   */
  uint256 internal initialExchangeRateMantissa;

  /**
   * @notice Fraction of interest currently set aside for admin fees
   */
  uint256 public adminFeeMantissa;

  /**
   * @notice Fraction of interest currently set aside for Ionic fees
   */
  uint256 public ionicFeeMantissa;

  /**
   * @notice Fraction of interest currently set aside for reserves
   */
  uint256 public reserveFactorMantissa;

  /**
   * @notice Block number that interest was last accrued at
   */
  uint256 public accrualBlockNumber;

  /**
   * @notice Accumulator of the total earned interest rate since the opening of the market
   */
  uint256 public borrowIndex;

  /**
   * @notice Total amount of outstanding borrows of the underlying in this market
   */
  uint256 public totalBorrows;

  /**
   * @notice Total amount of reserves of the underlying held in this market
   */
  uint256 public totalReserves;

  /**
   * @notice Total amount of admin fees of the underlying held in this market
   */
  uint256 public totalAdminFees;

  /**
   * @notice Total amount of Ionic fees of the underlying held in this market
   */
  uint256 public totalIonicFees;

  /**
   * @notice Total number of tokens in circulation
   */
  uint256 public totalSupply;

  /*
   * Official record of token balances for each account
   */
  mapping(address => uint256) internal accountTokens;

  /*
   * Approved token transfer amounts on behalf of others
   */
  mapping(address => mapping(address => uint256)) internal transferAllowances;

  /**
   * @notice Container for borrow balance information
   * @member principal Total balance (with accrued interest), after applying the most recent balance-changing action
   * @member interestIndex Global borrowIndex as of the most recent balance-changing action
   */
  struct BorrowSnapshot {
    uint256 principal;
    uint256 interestIndex;
  }

  /*
   * Mapping of account addresses to outstanding borrow balances
   */
  mapping(address => BorrowSnapshot) internal accountBorrows;

  /*
   * Share of seized collateral that is added to reserves
   */
  uint256 public constant protocolSeizeShareMantissa = 2.8e16; //2.8%

  /*
   * Share of seized collateral taken as fees
   */
  uint256 public constant feeSeizeShareMantissa = 1e17; //10%

  /**
   * @notice Underlying asset for this CToken
   */
  address public underlying;

  /**
   * @notice Addresses Provider
   */
  AddressesProvider public ap;
}

abstract contract CTokenBaseEvents {
  /* ERC20 */

  /**
   * @notice EIP20 Transfer event
   */
  event Transfer(address indexed from, address indexed to, uint256 amount);

  /*** Admin Events ***/

  /**
   * @notice Event emitted when interestRateModel is changed
   */
  event NewMarketInterestRateModel(InterestRateModel oldInterestRateModel, InterestRateModel newInterestRateModel);

  /**
   * @notice Event emitted when the reserve factor is changed
   */
  event NewReserveFactor(uint256 oldReserveFactorMantissa, uint256 newReserveFactorMantissa);

  /**
   * @notice Event emitted when the admin fee is changed
   */
  event NewAdminFee(uint256 oldAdminFeeMantissa, uint256 newAdminFeeMantissa);

  /**
   * @notice Event emitted when the Ionic fee is changed
   */
  event NewIonicFee(uint256 oldIonicFeeMantissa, uint256 newIonicFeeMantissa);

  /**
   * @notice EIP20 Approval event
   */
  event Approval(address indexed owner, address indexed spender, uint256 amount);

  /**
   * @notice Event emitted when interest is accrued
   */
  event AccrueInterest(uint256 cashPrior, uint256 interestAccumulated, uint256 borrowIndex, uint256 totalBorrows);
}

abstract contract CTokenFirstExtensionEvents is CTokenBaseEvents {
  event Flash(address receiver, uint256 amount);
}

abstract contract CTokenSecondExtensionEvents is CTokenBaseEvents {
  /*** Market Events ***/

  /**
   * @notice Event emitted when tokens are minted
   */
  event Mint(address minter, uint256 mintAmount, uint256 mintTokens);

  /**
   * @notice Event emitted when tokens are redeemed
   */
  event Redeem(address redeemer, uint256 redeemAmount, uint256 redeemTokens);

  /**
   * @notice Event emitted when underlying is borrowed
   */
  event Borrow(address borrower, uint256 borrowAmount, uint256 accountBorrows, uint256 totalBorrows);

  /**
   * @notice Event emitted when a borrow is repaid
   */
  event RepayBorrow(address payer, address borrower, uint256 repayAmount, uint256 accountBorrows, uint256 totalBorrows);

  /**
   * @notice Event emitted when a borrow is liquidated
   */
  event LiquidateBorrow(
    address liquidator,
    address borrower,
    uint256 repayAmount,
    address cTokenCollateral,
    uint256 seizeTokens
  );

  /**
   * @notice Event emitted when the reserves are added
   */
  event ReservesAdded(address benefactor, uint256 addAmount, uint256 newTotalReserves);

  /**
   * @notice Event emitted when the reserves are reduced
   */
  event ReservesReduced(address admin, uint256 reduceAmount, uint256 newTotalReserves);
}

interface CTokenFirstExtensionInterface {
  /*** User Interface ***/

  function transfer(address dst, uint256 amount) external returns (bool);

  function transferFrom(
    address src,
    address dst,
    uint256 amount
  ) external returns (bool);

  function approve(address spender, uint256 amount) external returns (bool);

  function allowance(address owner, address spender) external view returns (uint256);

  function balanceOf(address owner) external view returns (uint256);

  /*** Admin Functions ***/

  function _setReserveFactor(uint256 newReserveFactorMantissa) external returns (uint256);

  function _setAdminFee(uint256 newAdminFeeMantissa) external returns (uint256);

  function _setInterestRateModel(InterestRateModel newInterestRateModel) external returns (uint256);

  function getAccountSnapshot(address account)
    external
    view
    returns (
      uint256,
      uint256,
      uint256,
      uint256
    );

  function borrowRatePerBlock() external view returns (uint256);

  function supplyRatePerBlock() external view returns (uint256);

  function exchangeRateCurrent() external view returns (uint256);

  function accrueInterest() external returns (uint256);

  function totalBorrowsCurrent() external view returns (uint256);

  function borrowBalanceCurrent(address account) external view returns (uint256);

  function getTotalUnderlyingSupplied() external view returns (uint256);

  function balanceOfUnderlying(address owner) external view returns (uint256);

  function multicall(bytes[] calldata data) external payable returns (bytes[] memory results);

  function flash(uint256 amount, bytes calldata data) external;

  function supplyRatePerBlockAfterDeposit(uint256 mintAmount) external view returns (uint256);

  function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256);

  function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256);

  function registerInSFS() external returns (uint256);
}

interface CTokenSecondExtensionInterface {
  function mint(uint256 mintAmount) external returns (uint256);

  function redeem(uint256 redeemTokens) external returns (uint256);

  function redeemUnderlying(uint256 redeemAmount) external returns (uint256);

  function borrow(uint256 borrowAmount) external returns (uint256);

  function repayBorrow(uint256 repayAmount) external returns (uint256);

  function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);

  function liquidateBorrow(
    address borrower,
    uint256 repayAmount,
    address cTokenCollateral
  ) external returns (uint256);

  function getCash() external view returns (uint256);

  function seize(
    address liquidator,
    address borrower,
    uint256 seizeTokens
  ) external returns (uint256);

  /*** Admin Functions ***/

  function _withdrawAdminFees(uint256 withdrawAmount) external returns (uint256);

  function _withdrawIonicFees(uint256 withdrawAmount) external returns (uint256);

  function selfTransferOut(address to, uint256 amount) external;

  function selfTransferIn(address from, uint256 amount) external returns (uint256);
}

interface CDelegatorInterface {
  function implementation() external view returns (address);

  /**
   * @notice Called by the admin to update the implementation of the delegator
   * @param implementation_ The address of the new implementation for delegation
   * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation
   */
  function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external;

  /**
   * @dev upgrades the implementation if necessary
   */
  function _upgrade() external;
}

interface CDelegateInterface {
  /**
   * @notice Called by the delegator on a delegate to initialize it for duty
   * @dev Should revert if any issues arise which make it unfit for delegation
   * @param data The encoded bytes data for any initialization
   */
  function _becomeImplementation(bytes calldata data) external;

  function delegateType() external pure returns (uint8);

  function contractType() external pure returns (string memory);
}

abstract contract CErc20AdminBase is CErc20Storage {
  /**
   * @notice Returns a boolean indicating if the sender has admin rights
   */
  function hasAdminRights() internal view returns (bool) {
    ComptrollerV3Storage comptrollerStorage = ComptrollerV3Storage(address(comptroller));
    return
      (msg.sender == comptrollerStorage.admin() && comptrollerStorage.adminHasRights()) ||
      (msg.sender == address(ionicAdmin) && comptrollerStorage.ionicAdminHasRights());
  }
}

abstract contract CErc20FirstExtensionBase is
  CErc20AdminBase,
  CTokenFirstExtensionEvents,
  CTokenFirstExtensionInterface
{}

abstract contract CTokenSecondExtensionBase is
  CErc20AdminBase,
  CTokenSecondExtensionEvents,
  CTokenSecondExtensionInterface,
  CDelegateInterface
{}

abstract contract CErc20DelegatorBase is CErc20AdminBase, CTokenSecondExtensionEvents, CDelegatorInterface {}

interface CErc20StorageInterface {
  function admin() external view returns (address);

  function adminHasRights() external view returns (bool);

  function ionicAdmin() external view returns (address);

  function ionicAdminHasRights() external view returns (bool);

  function comptroller() external view returns (IonicComptroller);

  function name() external view returns (string memory);

  function symbol() external view returns (string memory);

  function decimals() external view returns (uint8);

  function totalSupply() external view returns (uint256);

  function adminFeeMantissa() external view returns (uint256);

  function ionicFeeMantissa() external view returns (uint256);

  function reserveFactorMantissa() external view returns (uint256);

  function protocolSeizeShareMantissa() external view returns (uint256);

  function feeSeizeShareMantissa() external view returns (uint256);

  function totalReserves() external view returns (uint256);

  function totalAdminFees() external view returns (uint256);

  function totalIonicFees() external view returns (uint256);

  function totalBorrows() external view returns (uint256);

  function accrualBlockNumber() external view returns (uint256);

  function underlying() external view returns (address);

  function borrowIndex() external view returns (uint256);

  function interestRateModel() external view returns (address);
}

interface CErc20PluginStorageInterface is CErc20StorageInterface {
  function plugin() external view returns (address);
}

interface CErc20PluginRewardsInterface is CErc20PluginStorageInterface {
  function approve(address, address) external;
}

interface ICErc20 is
  CErc20StorageInterface,
  CTokenSecondExtensionInterface,
  CTokenFirstExtensionInterface,
  CDelegatorInterface,
  CDelegateInterface
{}

interface ICErc20Plugin is CErc20PluginStorageInterface, ICErc20 {
  function _updatePlugin(address _plugin) external;
}

interface ICErc20PluginRewards is CErc20PluginRewardsInterface, ICErc20 {}

// contracts/compound/ComptrollerInterface.sol

interface ComptrollerInterface {
  function isDeprecated(ICErc20 cToken) external view returns (bool);

  function _becomeImplementation() external;

  function _deployMarket(
    uint8 delegateType,
    bytes memory constructorData,
    bytes calldata becomeImplData,
    uint256 collateralFactorMantissa
  ) external returns (uint256);

  function getAssetsIn(address account) external view returns (ICErc20[] memory);

  function checkMembership(address account, ICErc20 cToken) external view returns (bool);

  function _setPriceOracle(BasePriceOracle newOracle) external returns (uint256);

  function _setCloseFactor(uint256 newCloseFactorMantissa) external returns (uint256);

  function _setCollateralFactor(ICErc20 market, uint256 newCollateralFactorMantissa) external returns (uint256);

  function _setLiquidationIncentive(uint256 newLiquidationIncentiveMantissa) external returns (uint256);

  function _setWhitelistEnforcement(bool enforce) external returns (uint256);

  function _setWhitelistStatuses(address[] calldata _suppliers, bool[] calldata statuses) external returns (uint256);

  function _addRewardsDistributor(address distributor) external returns (uint256);

  function getHypotheticalAccountLiquidity(
    address account,
    address cTokenModify,
    uint256 redeemTokens,
    uint256 borrowAmount,
    uint256 repayAmount
  )
    external
    view
    returns (
      uint256,
      uint256,
      uint256,
      uint256
    );

  function getMaxRedeemOrBorrow(
    address account,
    ICErc20 cToken,
    bool isBorrow
  ) external view returns (uint256);

  /*** Assets You Are In ***/

  function enterMarkets(address[] calldata cTokens) external returns (uint256[] memory);

  function exitMarket(address cToken) external returns (uint256);

  /*** Policy Hooks ***/

  function mintAllowed(
    address cToken,
    address minter,
    uint256 mintAmount
  ) external returns (uint256);

  function redeemAllowed(
    address cToken,
    address redeemer,
    uint256 redeemTokens
  ) external returns (uint256);

  function redeemVerify(
    address cToken,
    address redeemer,
    uint256 redeemAmount,
    uint256 redeemTokens
  ) external;

  function borrowAllowed(
    address cToken,
    address borrower,
    uint256 borrowAmount
  ) external returns (uint256);

  function borrowWithinLimits(address cToken, uint256 accountBorrowsNew) external view returns (uint256);

  function repayBorrowAllowed(
    address cToken,
    address payer,
    address borrower,
    uint256 repayAmount
  ) external returns (uint256);

  function liquidateBorrowAllowed(
    address cTokenBorrowed,
    address cTokenCollateral,
    address liquidator,
    address borrower,
    uint256 repayAmount
  ) external returns (uint256);

  function seizeAllowed(
    address cTokenCollateral,
    address cTokenBorrowed,
    address liquidator,
    address borrower,
    uint256 seizeTokens
  ) external returns (uint256);

  function transferAllowed(
    address cToken,
    address src,
    address dst,
    uint256 transferTokens
  ) external returns (uint256);

  function mintVerify(
    address cToken,
    address minter,
    uint256 actualMintAmount,
    uint256 mintTokens
  ) external;

  /*** Liquidity/Liquidation Calculations ***/

  function getAccountLiquidity(address account)
    external
    view
    returns (
      uint256 error,
      uint256 collateralValue,
      uint256 liquidity,
      uint256 shortfall
    );

  function liquidateCalculateSeizeTokens(
    address cTokenBorrowed,
    address cTokenCollateral,
    uint256 repayAmount
  ) external view returns (uint256, uint256);

  /*** Pool-Wide/Cross-Asset Reentrancy Prevention ***/

  function _beforeNonReentrant() external;

  function _afterNonReentrant() external;
}

interface ComptrollerStorageInterface {
  function admin() external view returns (address);

  function adminHasRights() external view returns (bool);

  function ionicAdmin() external view returns (address);

  function ionicAdminHasRights() external view returns (bool);

  function pendingAdmin() external view returns (address);

  function oracle() external view returns (BasePriceOracle);

  function pauseGuardian() external view returns (address);

  function closeFactorMantissa() external view returns (uint256);

  function liquidationIncentiveMantissa() external view returns (uint256);

  function isUserOfPool(address user) external view returns (bool);

  function whitelist(address account) external view returns (bool);

  function enforceWhitelist() external view returns (bool);

  function borrowCapForCollateral(address borrowed, address collateral) external view returns (uint256);

  function borrowingAgainstCollateralBlacklist(address borrowed, address collateral) external view returns (bool);

  function suppliers(address account) external view returns (bool);

  function cTokensByUnderlying(address) external view returns (address);

  function supplyCaps(address cToken) external view returns (uint256);

  function borrowCaps(address cToken) external view returns (uint256);

  function markets(address cToken) external view returns (bool, uint256);

  function accountAssets(address, uint256) external view returns (address);

  function borrowGuardianPaused(address cToken) external view returns (bool);

  function mintGuardianPaused(address cToken) external view returns (bool);

  function rewardsDistributors(uint256) external view returns (address);
}

interface SFSRegister {
  function register(address _recipient) external returns (uint256 tokenId);
}

interface ComptrollerExtensionInterface {
  function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied);

  function getWhitelistedBorrowersBorrows(address cToken) external view returns (uint256 borrowed);

  function getAllMarkets() external view returns (ICErc20[] memory);

  function getAllBorrowers() external view returns (address[] memory);

  function getAllBorrowersCount() external view returns (uint256);

  function getPaginatedBorrowers(uint256 page, uint256 pageSize)
    external
    view
    returns (uint256 _totalPages, address[] memory _pageOfBorrowers);

  function getRewardsDistributors() external view returns (address[] memory);

  function getAccruingFlywheels() external view returns (address[] memory);

  function _supplyCapWhitelist(
    address cToken,
    address account,
    bool whitelisted
  ) external;

  function _setBorrowCapForCollateral(
    address cTokenBorrow,
    address cTokenCollateral,
    uint256 borrowCap
  ) external;

  function _setBorrowCapForCollateralWhitelist(
    address cTokenBorrow,
    address cTokenCollateral,
    address account,
    bool whitelisted
  ) external;

  function isBorrowCapForCollateralWhitelisted(
    address cTokenBorrow,
    address cTokenCollateral,
    address account
  ) external view returns (bool);

  function _blacklistBorrowingAgainstCollateral(
    address cTokenBorrow,
    address cTokenCollateral,
    bool blacklisted
  ) external;

  function _blacklistBorrowingAgainstCollateralWhitelist(
    address cTokenBorrow,
    address cTokenCollateral,
    address account,
    bool whitelisted
  ) external;

  function isBlacklistBorrowingAgainstCollateralWhitelisted(
    address cTokenBorrow,
    address cTokenCollateral,
    address account
  ) external view returns (bool);

  function isSupplyCapWhitelisted(address cToken, address account) external view returns (bool);

  function _borrowCapWhitelist(
    address cToken,
    address account,
    bool whitelisted
  ) external;

  function isBorrowCapWhitelisted(address cToken, address account) external view returns (bool);

  function _removeFlywheel(address flywheelAddress) external returns (bool);

  function getWhitelist() external view returns (address[] memory);

  function addNonAccruingFlywheel(address flywheelAddress) external returns (bool);

  function _setMarketSupplyCaps(ICErc20[] calldata cTokens, uint256[] calldata newSupplyCaps) external;

  function _setMarketBorrowCaps(ICErc20[] calldata cTokens, uint256[] calldata newBorrowCaps) external;

  function _setBorrowCapGuardian(address newBorrowCapGuardian) external;

  function _setPauseGuardian(address newPauseGuardian) external returns (uint256);

  function _setMintPaused(ICErc20 cToken, bool state) external returns (bool);

  function _setBorrowPaused(ICErc20 cToken, bool state) external returns (bool);

  function _setTransferPaused(bool state) external returns (bool);

  function _setSeizePaused(bool state) external returns (bool);

  function _unsupportMarket(ICErc20 cToken) external returns (uint256);

  function getAssetAsCollateralValueCap(
    ICErc20 collateral,
    ICErc20 cTokenModify,
    bool redeeming,
    address account
  ) external view returns (uint256);

  function registerInSFS() external returns (uint256);
}

interface UnitrollerInterface {
  function comptrollerImplementation() external view returns (address);

  function _upgrade() external;

  function _acceptAdmin() external returns (uint256);

  function _setPendingAdmin(address newPendingAdmin) external returns (uint256);

  function _toggleAdminRights(bool hasRights) external returns (uint256);
}

interface IComptrollerExtension is ComptrollerExtensionInterface, ComptrollerStorageInterface {}

//interface IComptrollerBase is ComptrollerInterface, ComptrollerStorageInterface {}

interface IonicComptroller is
  ComptrollerInterface,
  ComptrollerExtensionInterface,
  UnitrollerInterface,
  ComptrollerStorageInterface
{

}

contract UnitrollerAdminStorage {
  /*
   * Administrator for Ionic
   */
  address payable public ionicAdmin;

  /**
   * @notice Administrator for this contract
   */
  address public admin;

  /**
   * @notice Pending administrator for this contract
   */
  address public pendingAdmin;

  /**
   * @notice Whether or not the Ionic admin has admin rights
   */
  bool public ionicAdminHasRights = true;

  /**
   * @notice Whether or not the admin has admin rights
   */
  bool public adminHasRights = true;

  /**
   * @notice Returns a boolean indicating if the sender has admin rights
   */
  function hasAdminRights() internal view returns (bool) {
    return (msg.sender == admin && adminHasRights) || (msg.sender == address(ionicAdmin) && ionicAdminHasRights);
  }
}

contract ComptrollerV1Storage is UnitrollerAdminStorage {
  /**
   * @notice Oracle which gives the price of any given asset
   */
  BasePriceOracle public oracle;

  /**
   * @notice Multiplier used to calculate the maximum repayAmount when liquidating a borrow
   */
  uint256 public closeFactorMantissa;

  /**
   * @notice Multiplier representing the discount on collateral that a liquidator receives
   */
  uint256 public liquidationIncentiveMantissa;

  /*
   * UNUSED AFTER UPGRADE: Max number of assets a single account can participate in (borrow or use as collateral)
   */
  uint256 internal maxAssets;

  /**
   * @notice Per-account mapping of "assets you are in", capped by maxAssets
   */
  mapping(address => ICErc20[]) public accountAssets;
}

contract ComptrollerV2Storage is ComptrollerV1Storage {
  struct Market {
    // Whether or not this market is listed
    bool isListed;
    // Multiplier representing the most one can borrow against their collateral in this market.
    // For instance, 0.9 to allow borrowing 90% of collateral value.
    // Must be between 0 and 1, and stored as a mantissa.
    uint256 collateralFactorMantissa;
    // Per-market mapping of "accounts in this asset"
    mapping(address => bool) accountMembership;
  }

  /**
   * @notice Official mapping of cTokens -> Market metadata
   * @dev Used e.g. to determine if a market is supported
   */
  mapping(address => Market) public markets;

  /// @notice A list of all markets
  ICErc20[] public allMarkets;

  /**
   * @dev Maps borrowers to booleans indicating if they have entered any markets
   */
  mapping(address => bool) internal borrowers;

  /// @notice A list of all borrowers who have entered markets
  address[] public allBorrowers;

  // Indexes of borrower account addresses in the `allBorrowers` array
  mapping(address => uint256) internal borrowerIndexes;

  /**
   * @dev Maps suppliers to booleans indicating if they have ever supplied to any markets
   */
  mapping(address => bool) public suppliers;

  /// @notice All cTokens addresses mapped by their underlying token addresses
  mapping(address => ICErc20) public cTokensByUnderlying;

  /// @notice Whether or not the supplier whitelist is enforced
  bool public enforceWhitelist;

  /// @notice Maps addresses to booleans indicating if they are allowed to supply assets (i.e., mint cTokens)
  mapping(address => bool) public whitelist;

  /// @notice An array of all whitelisted accounts
  address[] public whitelistArray;

  // Indexes of account addresses in the `whitelistArray` array
  mapping(address => uint256) internal whitelistIndexes;

  /**
   * @notice The Pause Guardian can pause certain actions as a safety mechanism.
   *  Actions which allow users to remove their own assets cannot be paused.
   *  Liquidation / seizing / transfer can only be paused globally, not by market.
   */
  address public pauseGuardian;
  bool public _mintGuardianPaused;
  bool public _borrowGuardianPaused;
  bool public transferGuardianPaused;
  bool public seizeGuardianPaused;
  mapping(address => bool) public mintGuardianPaused;
  mapping(address => bool) public borrowGuardianPaused;
}

contract ComptrollerV3Storage is ComptrollerV2Storage {
  /// @notice The borrowCapGuardian can set borrowCaps to any number for any market. Lowering the borrow cap could disable borrowing on the given market.
  address public borrowCapGuardian;

  /// @notice Borrow caps enforced by borrowAllowed for each cToken address. Defaults to zero which corresponds to unlimited borrowing.
  mapping(address => uint256) public borrowCaps;

  /// @notice Supply caps enforced by mintAllowed for each cToken address. Defaults to zero which corresponds to unlimited supplying.
  mapping(address => uint256) public supplyCaps;

  /// @notice RewardsDistributor contracts to notify of flywheel changes.
  address[] public rewardsDistributors;

  /// @dev Guard variable for pool-wide/cross-asset re-entrancy checks
  bool internal _notEntered;

  /// @dev Whether or not _notEntered has been initialized
  bool internal _notEnteredInitialized;

  /// @notice RewardsDistributor to list for claiming, but not to notify of flywheel changes.
  address[] public nonAccruingRewardsDistributors;

  /// @dev cap for each user's borrows against specific assets - denominated in the borrowed asset
  mapping(address => mapping(address => uint256)) public borrowCapForCollateral;

  /// @dev blacklist to disallow the borrowing of an asset against specific collateral
  mapping(address => mapping(address => bool)) public borrowingAgainstCollateralBlacklist;

  /// @dev set of whitelisted accounts that are allowed to bypass the borrowing against specific collateral cap
  mapping(address => mapping(address => EnumerableSet.AddressSet)) internal borrowCapForCollateralWhitelist;

  /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap
  mapping(address => mapping(address => EnumerableSet.AddressSet))
    internal borrowingAgainstCollateralBlacklistWhitelist;

  /// @dev set of whitelisted accounts that are allowed to bypass the supply cap
  mapping(address => EnumerableSet.AddressSet) internal supplyCapWhitelist;

  /// @dev set of whitelisted accounts that are allowed to bypass the borrow cap
  mapping(address => EnumerableSet.AddressSet) internal borrowCapWhitelist;
}

abstract contract ComptrollerBase is ComptrollerV3Storage {
  /// @notice Indicator that this is a Comptroller contract (for inspection)
  bool public constant isComptroller = true;
}

// contracts/compound/ComptrollerStorage.sol





// contracts/compound/IFeeDistributor.sol

interface IFeeDistributor {
  function minBorrowEth() external view returns (uint256);

  function maxUtilizationRate() external view returns (uint256);

  function interestFeeRate() external view returns (uint256);

  function latestComptrollerImplementation(address oldImplementation) external view returns (address);

  function latestCErc20Delegate(uint8 delegateType)
    external
    view
    returns (address cErc20Delegate, bytes memory becomeImplementationData);

  function latestPluginImplementation(address oldImplementation) external view returns (address);

  function getComptrollerExtensions(address comptroller) external view returns (address[] memory);

  function getCErc20DelegateExtensions(address cErc20Delegate) external view returns (address[] memory);

  function deployCErc20(
    uint8 delegateType,
    bytes calldata constructorData,
    bytes calldata becomeImplData
  ) external returns (address);

  function canCall(
    address pool,
    address user,
    address target,
    bytes4 functionSig
  ) external view returns (bool);

  function authoritiesRegistry() external view returns (AuthoritiesRegistry);

  fallback() external payable;

  receive() external payable;
}

// contracts/ionic/AuthoritiesRegistry.sol

contract AuthoritiesRegistry is SafeOwnableUpgradeable {
  mapping(address => PoolRolesAuthority) public poolsAuthorities;
  PoolRolesAuthority public poolAuthLogic;
  address public leveredPositionsFactory;
  bool public noAuthRequired;

  function initialize(address _leveredPositionsFactory) public initializer {
    __SafeOwnable_init(msg.sender);
    leveredPositionsFactory = _leveredPositionsFactory;
    poolAuthLogic = new PoolRolesAuthority();
  }

  function reinitialize(address _leveredPositionsFactory) public onlyOwnerOrAdmin {
    leveredPositionsFactory = _leveredPositionsFactory;
    poolAuthLogic = new PoolRolesAuthority();
    // for Neon the auth is not required
    noAuthRequired = block.chainid == 245022934;
  }

  function createPoolAuthority(address pool) public onlyOwner returns (PoolRolesAuthority auth) {
    require(address(poolsAuthorities[pool]) == address(0), "already created");

    TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(address(poolAuthLogic), _getProxyAdmin(), "");
    auth = PoolRolesAuthority(address(proxy));
    auth.initialize(address(this));
    poolsAuthorities[pool] = auth;

    auth.openPoolSupplierCapabilities(IonicComptroller(pool));
    auth.setUserRole(address(this), auth.REGISTRY_ROLE(), true);
    // sets the registry owner as the auth owner
    reconfigureAuthority(pool);
  }

  function reconfigureAuthority(address poolAddress) public {
    IonicComptroller pool = IonicComptroller(poolAddress);
    PoolRolesAuthority auth = poolsAuthorities[address(pool)];

    if (msg.sender != poolAddress || address(auth) != address(0)) {
      require(address(auth) != address(0), "no such authority");
      require(msg.sender == owner() || msg.sender == poolAddress, "not owner or pool");

      auth.configureRegistryCapabilities();
      auth.configurePoolSupplierCapabilities(pool);
      auth.configurePoolBorrowerCapabilities(pool);
      // everyone can be a liquidator
      auth.configureOpenPoolLiquidatorCapabilities(pool);
      auth.configureLeveredPositionCapabilities(pool);

      if (auth.owner() != owner()) {
        auth.setOwner(owner());
      }
    }
  }

  function canCall(
    address pool,
    address user,
    address target,
    bytes4 functionSig
  ) external view returns (bool) {
    PoolRolesAuthority authorityForPool = poolsAuthorities[pool];
    if (address(authorityForPool) == address(0)) {
      return noAuthRequired;
    } else {
      // allow only if an auth exists and it allows the action
      return authorityForPool.canCall(user, target, functionSig);
    }
  }

  function setUserRole(
    address pool,
    address user,
    uint8 role,
    bool enabled
  ) external {
    PoolRolesAuthority poolAuth = poolsAuthorities[pool];

    require(address(poolAuth) != address(0), "auth does not exist");
    require(msg.sender == owner() || msg.sender == leveredPositionsFactory, "not owner or factory");
    require(msg.sender != leveredPositionsFactory || role == poolAuth.LEVERED_POSITION_ROLE(), "only lev pos role");

    poolAuth.setUserRole(user, role, enabled);
  }
}

// contracts/ionic/PoolRolesAuthority.sol

contract PoolRolesAuthority is RolesAuthority, Initializable {
  constructor() RolesAuthority(address(0), Authority(address(0))) {
    _disableInitializers();
  }

  function initialize(address _owner) public initializer {
    owner = _owner;
    authority = this;
  }

  // up to 256 roles
  uint8 public constant REGISTRY_ROLE = 0;
  uint8 public constant SUPPLIER_ROLE = 1;
  uint8 public constant BORROWER_ROLE = 2;
  uint8 public constant LIQUIDATOR_ROLE = 3;
  uint8 public constant LEVERED_POSITION_ROLE = 4;

  function configureRegistryCapabilities() external requiresAuth {
    setRoleCapability(REGISTRY_ROLE, address(this), PoolRolesAuthority.configureRegistryCapabilities.selector, true);
    setRoleCapability(
      REGISTRY_ROLE,
      address(this),
      PoolRolesAuthority.configurePoolSupplierCapabilities.selector,
      true
    );
    setRoleCapability(
      REGISTRY_ROLE,
      address(this),
      PoolRolesAuthority.configurePoolBorrowerCapabilities.selector,
      true
    );
    setRoleCapability(
      REGISTRY_ROLE,
      address(this),
      PoolRolesAuthority.configureClosedPoolLiquidatorCapabilities.selector,
      true
    );
    setRoleCapability(
      REGISTRY_ROLE,
      address(this),
      PoolRolesAuthority.configureOpenPoolLiquidatorCapabilities.selector,
      true
    );
    setRoleCapability(
      REGISTRY_ROLE,
      address(this),
      PoolRolesAuthority.configureLeveredPositionCapabilities.selector,
      true
    );
    setRoleCapability(REGISTRY_ROLE, address(this), RolesAuthority.setUserRole.selector, true);
  }

  function openPoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {
    _setPublicPoolSupplierCapabilities(pool, true);
  }

  function closePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {
    _setPublicPoolSupplierCapabilities(pool, false);
  }

  function _setPublicPoolSupplierCapabilities(IonicComptroller pool, bool setPublic) internal {
    setPublicCapability(address(pool), pool.enterMarkets.selector, setPublic);
    setPublicCapability(address(pool), pool.exitMarket.selector, setPublic);
    ICErc20[] memory allMarkets = pool.getAllMarkets();
    for (uint256 i = 0; i < allMarkets.length; i++) {
      bytes4[] memory selectors = getSupplierMarketSelectors();
      for (uint256 j = 0; j < selectors.length; j++) {
        setPublicCapability(address(allMarkets[i]), selectors[j], setPublic);
      }
    }
  }

  function configurePoolSupplierCapabilities(IonicComptroller pool) external requiresAuth {
    _configurePoolSupplierCapabilities(pool, SUPPLIER_ROLE);
  }

  function getSupplierMarketSelectors() internal pure returns (bytes4[] memory selectors) {
    uint8 fnsCount = 6;
    selectors = new bytes4[](fnsCount);
    selectors[--fnsCount] = CTokenSecondExtensionInterface.mint.selector;
    selectors[--fnsCount] = CTokenSecondExtensionInterface.redeem.selector;
    selectors[--fnsCount] = CTokenSecondExtensionInterface.redeemUnderlying.selector;
    selectors[--fnsCount] = CTokenFirstExtensionInterface.transfer.selector;
    selectors[--fnsCount] = CTokenFirstExtensionInterface.transferFrom.selector;
    selectors[--fnsCount] = CTokenFirstExtensionInterface.approve.selector;

    require(fnsCount == 0, "use the correct array length");
    return selectors;
  }

  function _configurePoolSupplierCapabilities(IonicComptroller pool, uint8 role) internal {
    setRoleCapability(role, address(pool), pool.enterMarkets.selector, true);
    setRoleCapability(role, address(pool), pool.exitMarket.selector, true);
    ICErc20[] memory allMarkets = pool.getAllMarkets();
    for (uint256 i = 0; i < allMarkets.length; i++) {
      bytes4[] memory selectors = getSupplierMarketSelectors();
      for (uint256 j = 0; j < selectors.length; j++) {
        setRoleCapability(role, address(allMarkets[i]), selectors[j], true);
      }
    }
  }

  function openPoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {
    _setPublicPoolBorrowerCapabilities(pool, true);
  }

  function closePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {
    _setPublicPoolBorrowerCapabilities(pool, false);
  }

  function _setPublicPoolBorrowerCapabilities(IonicComptroller pool, bool setPublic) internal {
    ICErc20[] memory allMarkets = pool.getAllMarkets();
    for (uint256 i = 0; i < allMarkets.length; i++) {
      setPublicCapability(address(allMarkets[i]), allMarkets[i].borrow.selector, setPublic);
      setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrow.selector, setPublic);
      setPublicCapability(address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, setPublic);
      setPublicCapability(address(allMarkets[i]), allMarkets[i].flash.selector, setPublic);
    }
  }

  function configurePoolBorrowerCapabilities(IonicComptroller pool) external requiresAuth {
    // borrowers have the SUPPLIER_ROLE capabilities by default
    _configurePoolSupplierCapabilities(pool, BORROWER_ROLE);
    ICErc20[] memory allMarkets = pool.getAllMarkets();
    for (uint256 i = 0; i < allMarkets.length; i++) {
      setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);
      setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);
      setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrowBehalf.selector, true);
      setRoleCapability(BORROWER_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);
    }
  }

  function configureClosedPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {
    ICErc20[] memory allMarkets = pool.getAllMarkets();
    for (uint256 i = 0; i < allMarkets.length; i++) {
      setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, false);
      setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);
      setRoleCapability(LIQUIDATOR_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);
    }
  }

  function configureOpenPoolLiquidatorCapabilities(IonicComptroller pool) external requiresAuth {
    ICErc20[] memory allMarkets = pool.getAllMarkets();
    for (uint256 i = 0; i < allMarkets.length; i++) {
      setPublicCapability(address(allMarkets[i]), allMarkets[i].liquidateBorrow.selector, true);
      // TODO this leaves redeeming open for everyone
      setPublicCapability(address(allMarkets[i]), allMarkets[i].redeem.selector, true);
    }
  }

  function configureLeveredPositionCapabilities(IonicComptroller pool) external requiresAuth {
    setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.enterMarkets.selector, true);
    setRoleCapability(LEVERED_POSITION_ROLE, address(pool), pool.exitMarket.selector, true);
    ICErc20[] memory allMarkets = pool.getAllMarkets();
    for (uint256 i = 0; i < allMarkets.length; i++) {
      setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].mint.selector, true);
      setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeem.selector, true);
      setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].redeemUnderlying.selector, true);

      setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].borrow.selector, true);
      setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].repayBorrow.selector, true);
      setRoleCapability(LEVERED_POSITION_ROLE, address(allMarkets[i]), allMarkets[i].flash.selector, true);
    }
  }
}

// contracts/oracles/BasePriceOracle.sol

/**
 * @title BasePriceOracle
 * @notice Returns prices of underlying tokens directly without the caller having to specify a cToken address.
 * @dev Implements the `PriceOracle` interface.
 * @author David Lucid <[email protected]> (https://github.com/davidlucid)
 */
interface BasePriceOracle {
  /**
   * @notice Get the price of an underlying asset.
   * @param underlying The underlying asset to get the price of.
   * @return The underlying asset price in ETH as a mantissa (scaled by 1e18).
   * Zero means the price is unavailable.
   */
  function price(address underlying) external view returns (uint256);

  /**
   * @notice Get the underlying price of a cToken asset
   * @param cToken The cToken to get the underlying price of
   * @return The underlying asset price mantissa (scaled by 1e18).
   *  Zero means the price is unavailable.
   */
  function getUnderlyingPrice(ICErc20 cToken) external view returns (uint256);
}

// contracts/compound/CErc20Delegator.sol

/**
 * @title Compound's CErc20Delegator Contract
 * @notice CTokens which wrap an EIP-20 underlying and delegate to an implementation
 * @author Compound
 */
contract CErc20Delegator is CErc20DelegatorBase, DiamondBase {
  /**
   * @notice Emitted when implementation is changed
   */
  event NewImplementation(address oldImplementation, address newImplementation);

  /**
   * @notice Initialize the new money market
   * @param underlying_ The address of the underlying asset
   * @param comptroller_ The address of the Comptroller
   * @param ionicAdmin_ The FeeDistributor contract address.
   * @param interestRateModel_ The address of the interest rate model
   * @param name_ ERC-20 name of this token
   * @param symbol_ ERC-20 symbol of this token
   */
  constructor(
    address underlying_,
    IonicComptroller comptroller_,
    address payable ionicAdmin_,
    InterestRateModel interestRateModel_,
    string memory name_,
    string memory symbol_,
    uint256 reserveFactorMantissa_,
    uint256 adminFeeMantissa_
  ) {
    require(msg.sender == ionicAdmin_, "!admin");
    uint8 decimals_ = EIP20Interface(underlying_).decimals();
    {
      ionicAdmin = ionicAdmin_;

      // Set initial exchange rate
      initialExchangeRateMantissa = 0.2e18;

      // Set the comptroller
      comptroller = comptroller_;

      // Initialize block number and borrow index (block number mocks depend on comptroller being set)
      accrualBlockNumber = block.number;
      borrowIndex = 1e18;

      // Set the interest rate model (depends on block number / borrow index)
      require(interestRateModel_.isInterestRateModel(), "!notIrm");
      interestRateModel = interestRateModel_;
      emit NewMarketInterestRateModel(InterestRateModel(address(0)), interestRateModel_);

      name = name_;
      symbol = symbol_;
      decimals = decimals_;

      // Set reserve factor
      // Check newReserveFactor ≤ maxReserveFactor
      require(
        reserveFactorMantissa_ + adminFeeMantissa + ionicFeeMantissa <= reserveFactorPlusFeesMaxMantissa,
        "!rf:set"
      );
      reserveFactorMantissa = reserveFactorMantissa_;
      emit NewReserveFactor(0, reserveFactorMantissa_);

      // Set admin fee
      // Sanitize adminFeeMantissa_
      if (adminFeeMantissa_ == type(uint256).max) adminFeeMantissa_ = adminFeeMantissa;
      // Get latest Ionic fee
      uint256 newIonicFeeMantissa = IFeeDistributor(ionicAdmin).interestFeeRate();
      require(
        reserveFactorMantissa + adminFeeMantissa_ + newIonicFeeMantissa <= reserveFactorPlusFeesMaxMantissa,
        "!adminFee:set"
      );
      adminFeeMantissa = adminFeeMantissa_;
      emit NewAdminFee(0, adminFeeMantissa_);
      ionicFeeMantissa = newIonicFeeMantissa;
      emit NewIonicFee(0, newIonicFeeMantissa);

      // The counter starts true to prevent changing it from zero to non-zero (i.e. smaller cost/refund)
      _notEntered = true;
    }

    // Set underlying and sanity check it
    underlying = underlying_;
    EIP20Interface(underlying).totalSupply();
  }

  function implementation() public view returns (address) {
    return LibDiamond.getExtensionForFunction(bytes4(keccak256(bytes("delegateType()"))));
  }

  /**
   * @notice Called by the admin to update the implementation of the delegator
   * @param implementation_ The address of the new implementation for delegation
   * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation
   */
  function _setImplementationSafe(address implementation_, bytes calldata becomeImplementationData) external override {
    // Check admin rights
    require(hasAdminRights(), "!admin");

    // Set implementation
    _setImplementationInternal(implementation_, becomeImplementationData);
  }

  /**
   * @dev upgrades the implementation if necessary
   */
  function _upgrade() external override {
    require(msg.sender == address(this) || hasAdminRights(), "!self or admin");

    (bool success, bytes memory data) = address(this).staticcall(abi.encodeWithSignature("delegateType()"));
    require(success, "no delegate type");

    uint8 currentDelegateType = abi.decode(data, (uint8));
    (address latestCErc20Delegate, bytes memory becomeImplementationData) = IFeeDistributor(ionicAdmin)
      .latestCErc20Delegate(currentDelegateType);

    address currentDelegate = implementation();
    if (currentDelegate != latestCErc20Delegate) {
      _setImplementationInternal(latestCErc20Delegate, becomeImplementationData);
    } else {
      // only update the extensions without reinitializing with becomeImplementationData
      _updateExtensions(currentDelegate);
    }
  }

  /**
   * @dev register a logic extension
   * @param extensionToAdd the extension whose functions are to be added
   * @param extensionToReplace the extension whose functions are to be removed/replaced
   */
  function _registerExtension(DiamondExtension extensionToAdd, DiamondExtension extensionToReplace) external override {
    require(msg.sender == address(ionicAdmin), "!unauthorized");
    LibDiamond.registerExtension(extensionToAdd, extensionToReplace);
  }

  /**
   * @dev Internal function to update the implementation of the delegator
   * @param implementation_ The address of the new implementation for delegation
   * @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation
   */
  function _setImplementationInternal(address implementation_, bytes memory becomeImplementationData) internal {
    address delegateBefore = implementation();
    _updateExtensions(implementation_);

    _functionCall(
      address(this),
      abi.encodeWithSelector(CDelegateInterface._becomeImplementation.selector, becomeImplementationData),
      "!become impl"
    );

    emit NewImplementation(delegateBefore, implementation_);
  }

  function _updateExtensions(address newDelegate) internal {
    address[] memory latestExtensions = IFeeDistributor(ionicAdmin).getCErc20DelegateExtensions(newDelegate);
    address[] memory currentExtensions = LibDiamond.listExtensions();

    // removed the current (old) extensions
    for (uint256 i = 0; i < currentExtensions.length; i++) {
      LibDiamond.removeExtension(DiamondExtension(currentExtensions[i]));
    }
    // add the new extensions
    for (uint256 i = 0; i < latestExtensions.length; i++) {
      LibDiamond.addExtension(DiamondExtension(latestExtensions[i]));
    }
  }

  function _functionCall(
    address target,
    bytes memory data,
    string memory errorMessage
  ) internal returns (bytes memory) {
    (bool success, bytes memory returndata) = target.call(data);

    if (!success) {
      // 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

        // solhint-disable-next-line no-inline-assembly
        assembly {
          let returndata_size := mload(returndata)
          revert(add(32, returndata), returndata_size)
        }
      } else {
        revert(errorMessage);
      }
    }

    return returndata;
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"underlying_","type":"address"},{"internalType":"contract IonicComptroller","name":"comptroller_","type":"address"},{"internalType":"address payable","name":"ionicAdmin_","type":"address"},{"internalType":"contract InterestRateModel","name":"interestRateModel_","type":"address"},{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"uint256","name":"reserveFactorMantissa_","type":"uint256"},{"internalType":"uint256","name":"adminFeeMantissa_","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"bytes4","name":"_functionSelector","type":"bytes4"},{"internalType":"address","name":"_currentImpl","type":"address"}],"name":"FunctionAlreadyAdded","type":"error"},{"inputs":[{"internalType":"bytes4","name":"_functionSelector","type":"bytes4"}],"name":"FunctionNotFound","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"cashPrior","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"interestAccumulated","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"borrowIndex","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalBorrows","type":"uint256"}],"name":"AccrueInterest","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"borrower","type":"address"},{"indexed":false,"internalType":"uint256","name":"borrowAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"accountBorrows","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalBorrows","type":"uint256"}],"name":"Borrow","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"liquidator","type":"address"},{"indexed":false,"internalType":"address","name":"borrower","type":"address"},{"indexed":false,"internalType":"uint256","name":"repayAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"cTokenCollateral","type":"address"},{"indexed":false,"internalType":"uint256","name":"seizeTokens","type":"uint256"}],"name":"LiquidateBorrow","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"minter","type":"address"},{"indexed":false,"internalType":"uint256","name":"mintAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mintTokens","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldAdminFeeMantissa","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newAdminFeeMantissa","type":"uint256"}],"name":"NewAdminFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldImplementation","type":"address"},{"indexed":false,"internalType":"address","name":"newImplementation","type":"address"}],"name":"NewImplementation","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldIonicFeeMantissa","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newIonicFeeMantissa","type":"uint256"}],"name":"NewIonicFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract InterestRateModel","name":"oldInterestRateModel","type":"address"},{"indexed":false,"internalType":"contract InterestRateModel","name":"newInterestRateModel","type":"address"}],"name":"NewMarketInterestRateModel","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldReserveFactorMantissa","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newReserveFactorMantissa","type":"uint256"}],"name":"NewReserveFactor","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"redeemer","type":"address"},{"indexed":false,"internalType":"uint256","name":"redeemAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"redeemTokens","type":"uint256"}],"name":"Redeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"payer","type":"address"},{"indexed":false,"internalType":"address","name":"borrower","type":"address"},{"indexed":false,"internalType":"uint256","name":"repayAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"accountBorrows","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalBorrows","type":"uint256"}],"name":"RepayBorrow","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"benefactor","type":"address"},{"indexed":false,"internalType":"uint256","name":"addAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTotalReserves","type":"uint256"}],"name":"ReservesAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"admin","type":"address"},{"indexed":false,"internalType":"uint256","name":"reduceAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTotalReserves","type":"uint256"}],"name":"ReservesReduced","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Transfer","type":"event"},{"stateMutability":"nonpayable","type":"fallback"},{"inputs":[],"name":"_listExtensions","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract DiamondExtension","name":"extensionToAdd","type":"address"},{"internalType":"contract DiamondExtension","name":"extensionToReplace","type":"address"}],"name":"_registerExtension","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"implementation_","type":"address"},{"internalType":"bytes","name":"becomeImplementationData","type":"bytes"}],"name":"_setImplementationSafe","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"_upgrade","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"accrualBlockNumber","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"adminFeeMantissa","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ap","outputs":[{"internalType":"contract AddressesProvider","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"borrowIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"comptroller","outputs":[{"internalType":"contract IonicComptroller","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeSeizeShareMantissa","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"implementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"interestRateModel","outputs":[{"internalType":"contract InterestRateModel","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ionicAdmin","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ionicFeeMantissa","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"protocolSeizeShareMantissa","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"reserveFactorMantissa","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalAdminFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalBorrows","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalIonicFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalReserves","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"underlying","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

60806040523480156200001157600080fd5b50604051620020a2380380620020a28339810160408190526200003491620006b1565b336001600160a01b038716146200007b5760405162461bcd60e51b815260206004820152600660248201526510b0b236b4b760d11b60448201526064015b60405180910390fd5b6000886001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015620000bc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000e2919062000784565b600080546001600160a01b0319166001600160a01b038a8116919091179091556702c68af0bb14000060055560038054610100600160a81b0319166101008c84160217905543600955670de0b6b3a7640000600a55604080516310c8fc9560e11b8152905192935090881691632191f92a916004808201926020929091908290030181865afa1580156200017a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001a09190620007b0565b620001d85760405162461bcd60e51b8152602060048201526007602482015266216e6f7449726d60c81b604482015260640162000072565b600480546001600160a01b0319166001600160a01b038816908117909155604080516000815260208101929092527fedffc32e068c7c95dfd4bdfd5c4d939a084d6b11c4199eac8436ed234d72f926910160405180910390a184516200024690600190602088019062000525565b5083516200025c90600290602087019062000525565b506003805460ff191660ff8316179055600754600654670de0b6b3a76400009190620002899086620007d4565b620002959190620007d4565b1115620002cf5760405162461bcd60e51b8152602060048201526007602482015266085c998e9cd95d60ca1b604482015260640162000072565b60088390556040805160008152602081018590527faaa68312e2ea9d50e16af5068410ab56e1a1fd06037b1a35664812c30f821460910160405180910390a16000198214156200031f5760065491505b60008060009054906101000a90046001600160a01b03166001600160a01b031663dd86fea16040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000374573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200039a9190620007fb565b9050670de0b6b3a76400008184600854620003b69190620007d4565b620003c29190620007d4565b1115620004025760405162461bcd60e51b815260206004820152600d60248201526c0858591b5a5b9199594e9cd95d609a1b604482015260640162000072565b60068390556040805160008152602081018590527fcdd0b588250e1398549f79cfdb8217c186688822905d6715b0834ea1c865594a910160405180910390a160078190556040805160008152602081018390527fedec4b9c99c2cdb231e7fd036f861e0445b015916700f41b9835f984cb9be4cb910160405180910390a1506000805460ff60a01b1916600160a01b179055601380546001600160a01b038b166001600160a01b03199091168117909155604080516318160ddd60e01b815290516318160ddd916004808201926020929091908290030181865afa158015620004ef573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620005159190620007fb565b5050505050505050505062000852565b828054620005339062000815565b90600052602060002090601f016020900481019282620005575760008555620005a2565b82601f106200057257805160ff1916838001178555620005a2565b82800160010185558215620005a2579182015b82811115620005a257825182559160200191906001019062000585565b50620005b0929150620005b4565b5090565b5b80821115620005b05760008155600101620005b5565b6001600160a01b0381168114620005e157600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200060c57600080fd5b81516001600160401b0380821115620006295762000629620005e4565b604051601f8301601f19908116603f01168101908282118183101715620006545762000654620005e4565b816040528381526020925086838588010111156200067157600080fd5b600091505b8382101562000695578582018301518183018401529082019062000676565b83821115620006a75760008385830101525b9695505050505050565b600080600080600080600080610100898b031215620006cf57600080fd5b8851620006dc81620005cb565b60208a0151909850620006ef81620005cb565b60408a01519097506200070281620005cb565b60608a01519096506200071581620005cb565b60808a01519095506001600160401b03808211156200073357600080fd5b620007418c838d01620005fa565b955060a08b01519150808211156200075857600080fd5b50620007678b828c01620005fa565b60c08b015160e0909b0151999c989b509699959894979350505050565b6000602082840312156200079757600080fd5b815160ff81168114620007a957600080fd5b9392505050565b600060208284031215620007c357600080fd5b81518015158114620007a957600080fd5b60008219821115620007f657634e487b7160e01b600052601160045260246000fd5b500190565b6000602082840312156200080e57600080fd5b5051919050565b600181811c908216806200082a57607f821691505b602082108114156200084c57634e487b7160e01b600052602260045260246000fd5b50919050565b61184080620008626000396000f3fe608060405234801561001057600080fd5b50600436106101735760003560e01c80636f307dc3116100de578063aa5af0fd11610097578063c3bf11cd11610071578063c3bf11cd1461033b578063c91a424f14610344578063e207afe214610357578063f3fdb15a1461036a57610173565b8063aa5af0fd1461031b578063ba49f54a14610324578063be99f1191461032c57610173565b80636f307dc3146102d057806389cd9855146102e35780638d02d9a1146102f85780638f840ddd1461030157806395d89b411461030a5780639826394b1461031257610173565b80635c60da1b116101305780635c60da1b1461027b5780635fe3b5671461028357806361feacff1461029b5780636333d001146102a45780636752e702146102b95780636c540baf146102c757610173565b806306fdde03146101ea578063173b99041461020857806318160ddd1461021f578063313ce567146102285780633c4f743c1461024757806347bd371814610272575b600061018a6000356001600160e01b03191661037d565b90506001600160a01b0381166101c657604051630a82dd7360e31b81526001600160e01b03196000351660048201526024015b60405180910390fd5b3660008037600080366000845af43d6000803e8080156101e5573d6000f35b3d6000fd5b6101f261039d565b6040516101ff91906112d7565b60405180910390f35b61021160085481565b6040519081526020016101ff565b610211600f5481565b6003546102359060ff1681565b60405160ff90911681526020016101ff565b60145461025a906001600160a01b031681565b6040516001600160a01b0390911681526020016101ff565b610211600b5481565b61025a61042b565b60035461025a9061010090046001600160a01b031681565b610211600d5481565b6102ac610481565b6040516101ff91906112f1565b610211666379da05b6000081565b61021160095481565b60135461025a906001600160a01b031681565b6102f66102f1366004611356565b61048b565b005b61021160065481565b610211600c5481565b6101f26104e3565b610211600e5481565b610211600a5481565b6102f66104f0565b61021167016345785d8a000081565b61021160075481565b60005461025a906001600160a01b031681565b6102f661036536600461138f565b6106d5565b60045461025a906001600160a01b031681565b6000610397826000805160206117eb833981519152610757565b92915050565b600180546103aa90611414565b80601f01602080910402602001604051908101604052809291908181526020018280546103d690611414565b80156104235780601f106103f857610100808354040283529160200191610423565b820191906000526020600020905b81548152906001019060200180831161040657829003601f168201915b505050505081565b60408051808201909152600e81526d64656c656761746554797065282960901b602090910152600061047c7f2c436e5bba88e403c36d7a2822cd2b39b360d5c6296839bbf72c5a05167fd3ff61037d565b905090565b606061047c6107fd565b6000546001600160a01b031633146104d55760405162461bcd60e51b815260206004820152600d60248201526c085d5b985d5d1a1bdc9a5e9959609a1b60448201526064016101bd565b6104df828261086f565b5050565b600280546103aa90611414565b333014806105015750610501610890565b61053e5760405162461bcd60e51b815260206004820152600e60248201526d10b9b2b6331037b91030b236b4b760911b60448201526064016101bd565b60408051600481526024810182526020810180516001600160e01b0316632c436e5b60e01b1790529051600091829130916105789161144f565b600060405180830381855afa9150503d80600081146105b3576040519150601f19603f3d011682016040523d82523d6000602084013e6105b8565b606091505b5091509150816105fd5760405162461bcd60e51b815260206004820152601060248201526f6e6f2064656c6567617465207479706560801b60448201526064016101bd565b600081806020019051810190610613919061146b565b60008054604051632aa1058760e21b815260ff84166004820152929350909182916001600160a01b03169063aa84161c90602401600060405180830381865afa158015610664573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261068c91908101906114d5565b91509150600061069a61042b565b9050826001600160a01b0316816001600160a01b0316146106c4576106bf8383610a0d565b6106cd565b6106cd81610ae5565b505050505050565b6106dd610890565b6107125760405162461bcd60e51b815260206004820152600660248201526510b0b236b4b760d11b60448201526064016101bd565b6107528383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610a0d92505050565b505050565b8054600090815b818110156107f257846001600160e01b0319168460000182815481106107865761078661157f565b600091825260209091200154600160a01b900460e01b6001600160e01b03191614156107e0578360000181815481106107c1576107c161157f565b6000918252602090912001546001600160a01b03169250610397915050565b806107ea816115ab565b91505061075e565b506000949350505050565b60606000805160206117eb83398151915260010180548060200260200160405190810160405280929190818152602001828054801561086557602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610847575b5050505050905090565b6001600160a01b038116156108875761088781610bed565b6104df82610d1d565b600080600360019054906101000a90046001600160a01b03169050806001600160a01b031663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061090d91906115c6565b6001600160a01b0316336001600160a01b031614801561098a5750806001600160a01b0316630a755ec26040518163ffffffff1660e01b8152600401602060405180830381865afa158015610966573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098a91906115e3565b80610a0757506000546001600160a01b031633148015610a075750806001600160a01b031663cf6bfd2d6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156109e3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a0791906115e3565b91505090565b6000610a1761042b565b9050610a2283610ae5565b610a9c306356e6772860e01b84604051602401610a3f91906112d7565b604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b0383818316178352505050506040518060400160405280600c81526020016b08589958dbdb59481a5b5c1b60a21b815250610e15565b50604080516001600160a01b038084168252851660208201527fd604de94d45953f9138079ec1b82d533cb2160c906d1076d1f7ed54befbca97a910160405180910390a1505050565b600080546040516311a0e21760e01b81526001600160a01b038481166004830152909116906311a0e21790602401600060405180830381865afa158015610b30573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b589190810190611629565b90506000610b646107fd565b905060005b8151811015610ba657610b94828281518110610b8757610b8761157f565b6020026020010151610bed565b80610b9e816115ab565b915050610b69565b5060005b8251811015610be757610bd5838281518110610bc857610bc861157f565b6020026020010151610d1d565b80610bdf816115ab565b915050610baa565b50505050565b6000805160206117eb833981519152610c0582610eb1565b60005b600182015460ff8216101561075257826001600160a01b0316826001018260ff1681548110610c3957610c3961157f565b6000918252602090912001546001600160a01b03161415610d0b57600180830180549091610c66916116c8565b81548110610c7657610c7661157f565b6000918252602090912001546001830180546001600160a01b039092169160ff8416908110610ca757610ca761157f565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555081600101805480610ce857610ce86116df565b600082815260209020810160001990810180546001600160a01b03191690550190555b80610d15816116f5565b915050610c08565b6000805160206117eb83398151915260005b600182015460ff82161015610dd557826001600160a01b0316826001018260ff1681548110610d6057610d6061157f565b6000918252602090912001546001600160a01b03161415610dc35760405162461bcd60e51b815260206004820152601760248201527f657874656e73696f6e20616c726561647920616464656400000000000000000060448201526064016101bd565b80610dcd816116f5565b915050610d2f565b50610ddf82611070565b6001908101805491820181556000908152602090200180546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080856001600160a01b031685604051610e32919061144f565b6000604051808303816000865af19150503d8060008114610e6f576040519150601f19603f3d011682016040523d82523d6000602084013e610e74565b606091505b509150915081610ea857805115610e8e5780518082602001fd5b8360405162461bcd60e51b81526004016101bd91906112d7565b95945050505050565b6000816001600160a01b03166389f8132e6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610ef1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610f199190810190611715565b90506000805160206117eb83398151915260005b82518161ffff161015610be7576000838261ffff1681518110610f5257610f5261157f565b60200260200101519050610f668184610757565b6001600160a01b0316856001600160a01b031614610f8657610f866117b2565b6000610f9282856111f7565b84549091508490610fa5906001906116c8565b81548110610fb557610fb561157f565b90600052602060002001846000018261ffff1681548110610fd857610fd861157f565b600091825260209091208254910180546001600160a01b039092166001600160a01b031983168117825592546001600160c01b0319909216909217600160a01b9182900463ffffffff169091021790558354849080611039576110396116df565b600082815260209020810160001990810180546001600160c01b031916905501905550819050611068816117c8565b915050610f2d565b6000816001600160a01b03166389f8132e6040518163ffffffff1660e01b8152600401600060405180830381865afa1580156110b0573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526110d89190810190611715565b6000805160206117eb83398151915280549192509060005b83518110156111f057600084828151811061110d5761110d61157f565b6020026020010151905060006111238286610757565b90506001600160a01b0381161561116857604051632c18df3360e01b81526001600160e01b0319831660048201526001600160a01b03821660248201526044016101bd565b604080518082019091526001600160a01b0380891682526001600160e01b0319841660208084019182528854600181018a5560008a815291909120935193018054915160e01c600160a01b026001600160c01b03199092169390921692909217919091179055836111d8816117c8565b945050505080806111e8906115ab565b9150506110f0565b5050505050565b8054600090815b8161ffff168161ffff16101561127357846001600160e01b031916846000018261ffff16815481106112325761123261157f565b600091825260209091200154600160a01b900460e01b6001600160e01b03191614156112615791506103979050565b8061126b816117c8565b9150506111fe565b5061ffff949350505050565b60005b8381101561129a578181015183820152602001611282565b83811115610be75750506000910152565b600081518084526112c381602086016020860161127f565b601f01601f19169290920160200192915050565b6020815260006112ea60208301846112ab565b9392505050565b6020808252825182820181905260009190848201906040850190845b818110156113325783516001600160a01b03168352928401929184019160010161130d565b50909695505050505050565b6001600160a01b038116811461135357600080fd5b50565b6000806040838503121561136957600080fd5b82356113748161133e565b915060208301356113848161133e565b809150509250929050565b6000806000604084860312156113a457600080fd5b83356113af8161133e565b9250602084013567ffffffffffffffff808211156113cc57600080fd5b818601915086601f8301126113e057600080fd5b8135818111156113ef57600080fd5b87602082850101111561140157600080fd5b6020830194508093505050509250925092565b600181811c9082168061142857607f821691505b6020821081141561144957634e487b7160e01b600052602260045260246000fd5b50919050565b6000825161146181846020870161127f565b9190910192915050565b60006020828403121561147d57600080fd5b815160ff811681146112ea57600080fd5b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156114cd576114cd61148e565b604052919050565b600080604083850312156114e857600080fd5b82516114f38161133e565b602084015190925067ffffffffffffffff8082111561151157600080fd5b818501915085601f83011261152557600080fd5b8151818111156115375761153761148e565b61154a601f8201601f19166020016114a4565b915080825286602082850101111561156157600080fd5b61157281602084016020860161127f565b5080925050509250929050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006000198214156115bf576115bf611595565b5060010190565b6000602082840312156115d857600080fd5b81516112ea8161133e565b6000602082840312156115f557600080fd5b815180151581146112ea57600080fd5b600067ffffffffffffffff82111561161f5761161f61148e565b5060051b60200190565b6000602080838503121561163c57600080fd5b825167ffffffffffffffff81111561165357600080fd5b8301601f8101851361166457600080fd5b805161167761167282611605565b6114a4565b81815260059190911b8201830190838101908783111561169657600080fd5b928401925b828410156116bd5783516116ae8161133e565b8252928401929084019061169b565b979650505050505050565b6000828210156116da576116da611595565b500390565b634e487b7160e01b600052603160045260246000fd5b600060ff821660ff81141561170c5761170c611595565b60010192915050565b6000602080838503121561172857600080fd5b825167ffffffffffffffff81111561173f57600080fd5b8301601f8101851361175057600080fd5b805161175e61167282611605565b81815260059190911b8201830190838101908783111561177d57600080fd5b928401925b828410156116bd5783516001600160e01b0319811681146117a35760008081fd5b82529284019290840190611782565b634e487b7160e01b600052600160045260246000fd5b600061ffff808316818114156117e0576117e0611595565b600101939250505056fe234c809385eaba7c8e68b2a08341f3988117f4f9fae0fac38df439aa440b2615a26469706673582212209755ce9a28e8bf72743999c7d0a0478cdf26b67384376e4688ffabe0a0fec3b464736f6c634300080a0033000000000000000000000000fc00000000000000000000000000000000000002000000000000000000000000b5141403e811fffe02f4d49ea8d4a7b0b95906580000000000000000000000009bad1f7685f33ad855ae81089dfe79040864e2f6000000000000000000000000a6ba5f1164dc66f9c5bdce33a6d2fc70be8da10800000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000016345785d8a0000000000000000000000000000000000000000000000000000016345785d8a00000000000000000000000000000000000000000000000000000000000000000010496f6e69632046726178205368617265000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006696f6e4658530000000000000000000000000000000000000000000000000000

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101735760003560e01c80636f307dc3116100de578063aa5af0fd11610097578063c3bf11cd11610071578063c3bf11cd1461033b578063c91a424f14610344578063e207afe214610357578063f3fdb15a1461036a57610173565b8063aa5af0fd1461031b578063ba49f54a14610324578063be99f1191461032c57610173565b80636f307dc3146102d057806389cd9855146102e35780638d02d9a1146102f85780638f840ddd1461030157806395d89b411461030a5780639826394b1461031257610173565b80635c60da1b116101305780635c60da1b1461027b5780635fe3b5671461028357806361feacff1461029b5780636333d001146102a45780636752e702146102b95780636c540baf146102c757610173565b806306fdde03146101ea578063173b99041461020857806318160ddd1461021f578063313ce567146102285780633c4f743c1461024757806347bd371814610272575b600061018a6000356001600160e01b03191661037d565b90506001600160a01b0381166101c657604051630a82dd7360e31b81526001600160e01b03196000351660048201526024015b60405180910390fd5b3660008037600080366000845af43d6000803e8080156101e5573d6000f35b3d6000fd5b6101f261039d565b6040516101ff91906112d7565b60405180910390f35b61021160085481565b6040519081526020016101ff565b610211600f5481565b6003546102359060ff1681565b60405160ff90911681526020016101ff565b60145461025a906001600160a01b031681565b6040516001600160a01b0390911681526020016101ff565b610211600b5481565b61025a61042b565b60035461025a9061010090046001600160a01b031681565b610211600d5481565b6102ac610481565b6040516101ff91906112f1565b610211666379da05b6000081565b61021160095481565b60135461025a906001600160a01b031681565b6102f66102f1366004611356565b61048b565b005b61021160065481565b610211600c5481565b6101f26104e3565b610211600e5481565b610211600a5481565b6102f66104f0565b61021167016345785d8a000081565b61021160075481565b60005461025a906001600160a01b031681565b6102f661036536600461138f565b6106d5565b60045461025a906001600160a01b031681565b6000610397826000805160206117eb833981519152610757565b92915050565b600180546103aa90611414565b80601f01602080910402602001604051908101604052809291908181526020018280546103d690611414565b80156104235780601f106103f857610100808354040283529160200191610423565b820191906000526020600020905b81548152906001019060200180831161040657829003601f168201915b505050505081565b60408051808201909152600e81526d64656c656761746554797065282960901b602090910152600061047c7f2c436e5bba88e403c36d7a2822cd2b39b360d5c6296839bbf72c5a05167fd3ff61037d565b905090565b606061047c6107fd565b6000546001600160a01b031633146104d55760405162461bcd60e51b815260206004820152600d60248201526c085d5b985d5d1a1bdc9a5e9959609a1b60448201526064016101bd565b6104df828261086f565b5050565b600280546103aa90611414565b333014806105015750610501610890565b61053e5760405162461bcd60e51b815260206004820152600e60248201526d10b9b2b6331037b91030b236b4b760911b60448201526064016101bd565b60408051600481526024810182526020810180516001600160e01b0316632c436e5b60e01b1790529051600091829130916105789161144f565b600060405180830381855afa9150503d80600081146105b3576040519150601f19603f3d011682016040523d82523d6000602084013e6105b8565b606091505b5091509150816105fd5760405162461bcd60e51b815260206004820152601060248201526f6e6f2064656c6567617465207479706560801b60448201526064016101bd565b600081806020019051810190610613919061146b565b60008054604051632aa1058760e21b815260ff84166004820152929350909182916001600160a01b03169063aa84161c90602401600060405180830381865afa158015610664573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261068c91908101906114d5565b91509150600061069a61042b565b9050826001600160a01b0316816001600160a01b0316146106c4576106bf8383610a0d565b6106cd565b6106cd81610ae5565b505050505050565b6106dd610890565b6107125760405162461bcd60e51b815260206004820152600660248201526510b0b236b4b760d11b60448201526064016101bd565b6107528383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610a0d92505050565b505050565b8054600090815b818110156107f257846001600160e01b0319168460000182815481106107865761078661157f565b600091825260209091200154600160a01b900460e01b6001600160e01b03191614156107e0578360000181815481106107c1576107c161157f565b6000918252602090912001546001600160a01b03169250610397915050565b806107ea816115ab565b91505061075e565b506000949350505050565b60606000805160206117eb83398151915260010180548060200260200160405190810160405280929190818152602001828054801561086557602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610847575b5050505050905090565b6001600160a01b038116156108875761088781610bed565b6104df82610d1d565b600080600360019054906101000a90046001600160a01b03169050806001600160a01b031663f851a4406040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061090d91906115c6565b6001600160a01b0316336001600160a01b031614801561098a5750806001600160a01b0316630a755ec26040518163ffffffff1660e01b8152600401602060405180830381865afa158015610966573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098a91906115e3565b80610a0757506000546001600160a01b031633148015610a075750806001600160a01b031663cf6bfd2d6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156109e3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a0791906115e3565b91505090565b6000610a1761042b565b9050610a2283610ae5565b610a9c306356e6772860e01b84604051602401610a3f91906112d7565b604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b0383818316178352505050506040518060400160405280600c81526020016b08589958dbdb59481a5b5c1b60a21b815250610e15565b50604080516001600160a01b038084168252851660208201527fd604de94d45953f9138079ec1b82d533cb2160c906d1076d1f7ed54befbca97a910160405180910390a1505050565b600080546040516311a0e21760e01b81526001600160a01b038481166004830152909116906311a0e21790602401600060405180830381865afa158015610b30573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b589190810190611629565b90506000610b646107fd565b905060005b8151811015610ba657610b94828281518110610b8757610b8761157f565b6020026020010151610bed565b80610b9e816115ab565b915050610b69565b5060005b8251811015610be757610bd5838281518110610bc857610bc861157f565b6020026020010151610d1d565b80610bdf816115ab565b915050610baa565b50505050565b6000805160206117eb833981519152610c0582610eb1565b60005b600182015460ff8216101561075257826001600160a01b0316826001018260ff1681548110610c3957610c3961157f565b6000918252602090912001546001600160a01b03161415610d0b57600180830180549091610c66916116c8565b81548110610c7657610c7661157f565b6000918252602090912001546001830180546001600160a01b039092169160ff8416908110610ca757610ca761157f565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555081600101805480610ce857610ce86116df565b600082815260209020810160001990810180546001600160a01b03191690550190555b80610d15816116f5565b915050610c08565b6000805160206117eb83398151915260005b600182015460ff82161015610dd557826001600160a01b0316826001018260ff1681548110610d6057610d6061157f565b6000918252602090912001546001600160a01b03161415610dc35760405162461bcd60e51b815260206004820152601760248201527f657874656e73696f6e20616c726561647920616464656400000000000000000060448201526064016101bd565b80610dcd816116f5565b915050610d2f565b50610ddf82611070565b6001908101805491820181556000908152602090200180546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080856001600160a01b031685604051610e32919061144f565b6000604051808303816000865af19150503d8060008114610e6f576040519150601f19603f3d011682016040523d82523d6000602084013e610e74565b606091505b509150915081610ea857805115610e8e5780518082602001fd5b8360405162461bcd60e51b81526004016101bd91906112d7565b95945050505050565b6000816001600160a01b03166389f8132e6040518163ffffffff1660e01b8152600401600060405180830381865afa158015610ef1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610f199190810190611715565b90506000805160206117eb83398151915260005b82518161ffff161015610be7576000838261ffff1681518110610f5257610f5261157f565b60200260200101519050610f668184610757565b6001600160a01b0316856001600160a01b031614610f8657610f866117b2565b6000610f9282856111f7565b84549091508490610fa5906001906116c8565b81548110610fb557610fb561157f565b90600052602060002001846000018261ffff1681548110610fd857610fd861157f565b600091825260209091208254910180546001600160a01b039092166001600160a01b031983168117825592546001600160c01b0319909216909217600160a01b9182900463ffffffff169091021790558354849080611039576110396116df565b600082815260209020810160001990810180546001600160c01b031916905501905550819050611068816117c8565b915050610f2d565b6000816001600160a01b03166389f8132e6040518163ffffffff1660e01b8152600401600060405180830381865afa1580156110b0573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526110d89190810190611715565b6000805160206117eb83398151915280549192509060005b83518110156111f057600084828151811061110d5761110d61157f565b6020026020010151905060006111238286610757565b90506001600160a01b0381161561116857604051632c18df3360e01b81526001600160e01b0319831660048201526001600160a01b03821660248201526044016101bd565b604080518082019091526001600160a01b0380891682526001600160e01b0319841660208084019182528854600181018a5560008a815291909120935193018054915160e01c600160a01b026001600160c01b03199092169390921692909217919091179055836111d8816117c8565b945050505080806111e8906115ab565b9150506110f0565b5050505050565b8054600090815b8161ffff168161ffff16101561127357846001600160e01b031916846000018261ffff16815481106112325761123261157f565b600091825260209091200154600160a01b900460e01b6001600160e01b03191614156112615791506103979050565b8061126b816117c8565b9150506111fe565b5061ffff949350505050565b60005b8381101561129a578181015183820152602001611282565b83811115610be75750506000910152565b600081518084526112c381602086016020860161127f565b601f01601f19169290920160200192915050565b6020815260006112ea60208301846112ab565b9392505050565b6020808252825182820181905260009190848201906040850190845b818110156113325783516001600160a01b03168352928401929184019160010161130d565b50909695505050505050565b6001600160a01b038116811461135357600080fd5b50565b6000806040838503121561136957600080fd5b82356113748161133e565b915060208301356113848161133e565b809150509250929050565b6000806000604084860312156113a457600080fd5b83356113af8161133e565b9250602084013567ffffffffffffffff808211156113cc57600080fd5b818601915086601f8301126113e057600080fd5b8135818111156113ef57600080fd5b87602082850101111561140157600080fd5b6020830194508093505050509250925092565b600181811c9082168061142857607f821691505b6020821081141561144957634e487b7160e01b600052602260045260246000fd5b50919050565b6000825161146181846020870161127f565b9190910192915050565b60006020828403121561147d57600080fd5b815160ff811681146112ea57600080fd5b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156114cd576114cd61148e565b604052919050565b600080604083850312156114e857600080fd5b82516114f38161133e565b602084015190925067ffffffffffffffff8082111561151157600080fd5b818501915085601f83011261152557600080fd5b8151818111156115375761153761148e565b61154a601f8201601f19166020016114a4565b915080825286602082850101111561156157600080fd5b61157281602084016020860161127f565b5080925050509250929050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006000198214156115bf576115bf611595565b5060010190565b6000602082840312156115d857600080fd5b81516112ea8161133e565b6000602082840312156115f557600080fd5b815180151581146112ea57600080fd5b600067ffffffffffffffff82111561161f5761161f61148e565b5060051b60200190565b6000602080838503121561163c57600080fd5b825167ffffffffffffffff81111561165357600080fd5b8301601f8101851361166457600080fd5b805161167761167282611605565b6114a4565b81815260059190911b8201830190838101908783111561169657600080fd5b928401925b828410156116bd5783516116ae8161133e565b8252928401929084019061169b565b979650505050505050565b6000828210156116da576116da611595565b500390565b634e487b7160e01b600052603160045260246000fd5b600060ff821660ff81141561170c5761170c611595565b60010192915050565b6000602080838503121561172857600080fd5b825167ffffffffffffffff81111561173f57600080fd5b8301601f8101851361175057600080fd5b805161175e61167282611605565b81815260059190911b8201830190838101908783111561177d57600080fd5b928401925b828410156116bd5783516001600160e01b0319811681146117a35760008081fd5b82529284019290840190611782565b634e487b7160e01b600052600160045260246000fd5b600061ffff808316818114156117e0576117e0611595565b600101939250505056fe234c809385eaba7c8e68b2a08341f3988117f4f9fae0fac38df439aa440b2615a26469706673582212209755ce9a28e8bf72743999c7d0a0478cdf26b67384376e4688ffabe0a0fec3b464736f6c634300080a0033

Deployed Bytecode Sourcemap

132906:7157:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5475:17;5495:43;5530:7;;-1:-1:-1;;;;;;5530:7:0;5495:34;:43::i;:::-;5475:63;-1:-1:-1;;;;;;5549:23:0;;5545:61;;5581:25;;-1:-1:-1;;;5581:25:0;;-1:-1:-1;;;;;;5598:7:0;;;5581:25;;;158:52:1;131:18;;5581:25:0;;;;;;;;5545:61;5791:14;5788:1;5785;5772:34;5933:1;5930;5914:14;5911:1;5900:9;5893:5;5880:55;5995:16;5992:1;5989;5974:38;6089:6;6103:54;;;;6194:16;6191:1;6184:27;6103:54;6131:16;6128:1;6121:27;89489:18;;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;90742:36;;;;;;;;;1118:25:1;;;1106:2;1091:18;90742:36:0;972:177:1;91620:26:0;;;;;;89669:21;;;;;;;;;;;;1326:4:1;1314:17;;;1296:36;;1284:2;1269:18;89669:21:0;1154:184:1;92853:27:0;;;;;-1:-1:-1;;;;;92853:27:0;;;;;;-1:-1:-1;;;;;1533:32:1;;;1515:51;;1503:2;1488:18;92853:27:0;1343:229:1;91136:27:0;;;;;;135893:154;;;:::i;90082:35::-;;;;;;;;-1:-1:-1;;;;;90082:35:0;;;91389:29;;;;;;5329:113;;;:::i;:::-;;;;;;;:::i;92515:59::-;;92568:6;92515:59;;90860:33;;;;;;92774:25;;;;;-1:-1:-1;;;;;92774:25:0;;;137755:259;;;;;;:::i;:::-;;:::i;:::-;;90500:31;;;;;;91261:28;;;;;;89577:20;;;:::i;91518:29::-;;;;;;91006:26;;;;;;136696:838;;;:::i;92648:52::-;;92696:4;92648:52;;90622:31;;;;;;89233:33;;;;;-1:-1:-1;;;;;89233:33:0;;;136328:296;;;;;;:::i;:::-;;:::i;90211:42::-;;;;;-1:-1:-1;;;;;90211:42:0;;;6622:149;6693:7;6716:49;6740:6;-1:-1:-1;;;;;;;;;;;6716:23:0;:49::i;:::-;6709:56;6622:149;-1:-1:-1;;6622:149:0:o;89489:18::-;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;135893:154::-;136015:23;;;;;;;;;;;;-1:-1:-1;;;136015:23:0;;;;;135940:7;135963:78;136005:34;135963;:78::i;:::-;135956:85;;135893:154;:::o;5329:113::-;5377:16;5409:27;:25;:27::i;137755:259::-;137908:10;;-1:-1:-1;;;;;137908:10:0;137886;:33;137878:59;;;;-1:-1:-1;;;137878:59:0;;5105:2:1;137878:59:0;;;5087:21:1;5144:2;5124:18;;;5117:30;-1:-1:-1;;;5163:18:1;;;5156:43;5216:18;;137878:59:0;4903:337:1;137878:59:0;137944:64;137973:14;137989:18;137944:28;:64::i;:::-;137755:259;;:::o;89577:20::-;;;;;;;:::i;136696:838::-;136749:10;136771:4;136749:27;;:47;;;136780:16;:14;:16::i;:::-;136741:74;;;;-1:-1:-1;;;136741:74:0;;5447:2:1;136741:74:0;;;5429:21:1;5486:2;5466:18;;;5459:30;-1:-1:-1;;;5505:18:1;;;5498:44;5559:18;;136741:74:0;5245:338:1;136741:74:0;136885:41;;;;;;;;;;;;;;;;-1:-1:-1;;;;;136885:41:0;-1:-1:-1;;;136885:41:0;;;136860:67;;136825:12;;;;136868:4;;136860:67;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;136824:103;;;;136942:7;136934:36;;;;-1:-1:-1;;;136934:36:0;;6069:2:1;136934:36:0;;;6051:21:1;6108:2;6088:18;;;6081:30;-1:-1:-1;;;6127:18:1;;;6120:46;6183:18;;136934:36:0;5867:340:1;136934:36:0;136979:25;137018:4;137007:25;;;;;;;;;;;;:::i;:::-;137040:28;137127:10;;137111:77;;-1:-1:-1;;;137111:77:0;;1326:4:1;1314:17;;137111:77:0;;;1296:36:1;136979:53:0;;-1:-1:-1;137040:28:0;;;;-1:-1:-1;;;;;137127:10:0;;137111:56;;1269:18:1;;137111:77:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;137111:77:0;;;;;;;;;;;;:::i;:::-;137039:149;;;;137197:23;137223:16;:14;:16::i;:::-;137197:42;;137269:20;-1:-1:-1;;;;;137250:39:0;:15;-1:-1:-1;;;;;137250:39:0;;137246:283;;137300:74;137327:20;137349:24;137300:26;:74::i;:::-;137246:283;;;137487:34;137505:15;137487:17;:34::i;:::-;136734:800;;;;;;136696:838::o;136328:296::-;136486:16;:14;:16::i;:::-;136478:35;;;;-1:-1:-1;;;136478:35:0;;7960:2:1;136478:35:0;;;7942:21:1;7999:1;7979:18;;;7972:29;-1:-1:-1;;;8017:18:1;;;8010:36;8063:18;;136478:35:0;7758:329:1;136478:35:0;136549:69;136576:15;136593:24;;136549:69;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;136549:26:0;;-1:-1:-1;;;136549:69:0:i;:::-;136328:296;;;:::o;9499:316::-;9630:19;;9597:7;;;9656:128;9680:6;9676:1;:10;9656:128;;;9734:8;-1:-1:-1;;;;;9706:36:0;;:2;:12;;9719:1;9706:15;;;;;;;;:::i;:::-;;;;;;;;;;:24;-1:-1:-1;;;9706:24:0;;;;-1:-1:-1;;;;;;9706:36:0;;9702:74;;;9751:2;:12;;9764:1;9751:15;;;;;;;;:::i;:::-;;;;;;;;;;:25;-1:-1:-1;;;;;9751:25:0;;-1:-1:-1;9744:32:0;;-1:-1:-1;;9744:32:0;9702:74;9688:3;;;;:::i;:::-;;;;9656:128;;;-1:-1:-1;9807:1:0;;9499:316;-1:-1:-1;;;;9499:316:0:o;6963:114::-;7012:16;-1:-1:-1;;;;;;;;;;;7044:27:0;;7037:34;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;7037:34:0;;;;;;;;;;;;;;;;;;;;;;;6963:114;:::o;7083:252::-;-1:-1:-1;;;;;7200:41:0;;;7196:99;;7252:35;7268:18;7252:15;:35::i;:::-;7301:28;7314:14;7301:12;:28::i;100004:344::-;100053:4;100066:39;100137:11;;;;;;;;;-1:-1:-1;;;;;100137:11:0;100066:84;;100186:18;-1:-1:-1;;;;;100186:24:0;;:26;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;-1:-1:-1;;;;;100172:40:0;:10;-1:-1:-1;;;;;100172:40:0;;:79;;;;;100216:18;-1:-1:-1;;;;;100216:33:0;;:35;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;100171:171;;;-1:-1:-1;100286:10:0;;-1:-1:-1;;;;;100286:10:0;100264;:33;:77;;;;;100301:18;-1:-1:-1;;;;;100301:38:0;;:40;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;100157:185;;;100004:344;:::o;138290:450::-;138406:22;138431:16;:14;:16::i;:::-;138406:41;;138454:34;138472:15;138454:17;:34::i;:::-;138497:173;138527:4;138564:49;;;138615:24;138541:99;;;;;;;;:::i;:::-;;;;;;;;;;;;;;-1:-1:-1;;;;;138541:99:0;;;;;;;-1:-1:-1;;;;;138541:99:0;;;;;;;;;;;138497:173;;;;;;;;;;;;;-1:-1:-1;;;138497:173:0;;;:13;:173::i;:::-;-1:-1:-1;138684:50:0;;;-1:-1:-1;;;;;9505:15:1;;;9487:34;;9557:15;;9552:2;9537:18;;9530:43;138684:50:0;;9422:18:1;138684:50:0;;;;;;;138399:341;138290:450;;:::o;138746:606::-;138810:33;138862:10;;138846:68;;-1:-1:-1;;;138846:68:0;;-1:-1:-1;;;;;1533:32:1;;;138846:68:0;;;1515:51:1;138862:10:0;;;;138846:55;;1488:18:1;;138846:68:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;138846:68:0;;;;;;;;;;;;:::i;:::-;138810:104;;138921:34;138958:27;:25;:27::i;:::-;138921:64;;139044:9;139039:138;139063:17;:24;139059:1;:28;139039:138;;;139103:66;139147:17;139165:1;139147:20;;;;;;;;:::i;:::-;;;;;;;139103:26;:66::i;:::-;139089:3;;;;:::i;:::-;;;;139039:138;;;;139219:9;139214:133;139238:16;:23;139234:1;:27;139214:133;;;139277:62;139318:16;139335:1;139318:19;;;;;;;;:::i;:::-;;;;;;;139277:23;:62::i;:::-;139263:3;;;;:::i;:::-;;;;139214:133;;;;138803:549;;138746:606;:::o;7341:440::-;-1:-1:-1;;;;;;;;;;;7516:35:0;7541:9;7516:24;:35::i;:::-;7563:7;7558:218;7580:13;;;:20;7576:24;;;;7558:218;;;7648:9;-1:-1:-1;;;;;7620:38:0;:2;:13;;7634:1;7620:16;;;;;;;;;;:::i;:::-;;;;;;;;;;;-1:-1:-1;;;;;7620:16:0;:38;7616:153;;;7690:13;;;;7704:20;;7690:13;;7704:24;;;:::i;:::-;7690:39;;;;;;;;:::i;:::-;;;;;;;;;;;;7671:13;;:16;;-1:-1:-1;;;;;7690:39:0;;;;7671:16;;;;;;;;;;:::i;:::-;;;;;;;;;:58;;;;;-1:-1:-1;;;;;7671:58:0;;;;;-1:-1:-1;;;;;7671:58:0;;;;;;7740:2;:13;;:19;;;;;;;:::i;:::-;;;;;;;;;;-1:-1:-1;;7740:19:0;;;;;-1:-1:-1;;;;;;7740:19:0;;;;;;7616:153;7602:3;;;;:::i;:::-;;;;7558:218;;7787:344;-1:-1:-1;;;;;;;;;;;7853:23:0;7902:140;7924:13;;;:20;7920:24;;;;7902:140;;;7996:9;-1:-1:-1;;;;;7968:38:0;:2;:13;;7982:1;7968:16;;;;;;;;;;:::i;:::-;;;;;;;;;;;-1:-1:-1;;;;;7968:16:0;:38;;7960:74;;;;-1:-1:-1;;;7960:74:0;;11395:2:1;7960:74:0;;;11377:21:1;11434:2;11414:18;;;11407:30;11473:25;11453:18;;;11446:53;11516:18;;7960:74:0;11193:347:1;7960:74:0;7946:3;;;;:::i;:::-;;;;7902:140;;;;8048:32;8070:9;8048:21;:32::i;:::-;8087:13;;;;:38;;;;;;;-1:-1:-1;8087:38:0;;;;;;;;;-1:-1:-1;;;;;;8087:38:0;-1:-1:-1;;;;;8087:38:0;;;;;;;;;;7787:344::o;139358:702::-;139482:12;139504;139518:23;139545:6;-1:-1:-1;;;;;139545:11:0;139557:4;139545:17;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;139503:59;;;;139576:7;139571:458;;139659:17;;:21;139655:367;;139888:10;139882:17;139939:15;139926:10;139922:2;139918:19;139911:44;139655:367;139999:12;139992:20;;-1:-1:-1;;;139992:20:0;;;;;;;;:::i;139655:367::-;140044:10;139358:702;-1:-1:-1;;;;;139358:702:0:o;8137:684::-;8215:27;8245:9;-1:-1:-1;;;;;8245:32:0;;:34;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;8245:34:0;;;;;;;;;;;;:::i;:::-;8215:64;-1:-1:-1;;;;;;;;;;;;8286:23:0;8335:481;8358:11;:18;8354:1;:22;;;8335:481;;;8392:23;8418:11;8430:1;8418:14;;;;;;;;;;:::i;:::-;;;;;;;8392:40;;8496:45;8520:16;8538:2;8496:23;:45::i;:::-;-1:-1:-1;;;;;8474:67:0;8482:9;-1:-1:-1;;;;;8474:67:0;;8467:75;;;;:::i;:::-;8645:18;8666:41;8686:16;8704:2;8666:19;:41::i;:::-;8757:19;;8645:62;;-1:-1:-1;8744:2:0;;8757:23;;8779:1;;8757:23;:::i;:::-;8744:37;;;;;;;;:::i;:::-;;;;;;;;8716:2;:12;;8729:11;8716:25;;;;;;;;;;:::i;:::-;;;;;;;;;:65;;:25;;:65;;-1:-1:-1;;;;;8716:65:0;;;-1:-1:-1;;;;;;8716:65:0;;;;;;;;-1:-1:-1;;;;;;8716:65:0;;;;;;-1:-1:-1;;;8716:65:0;;;;;;;;;;;;8790:18;;;;;;;;;:::i;:::-;;;;;;;;;;-1:-1:-1;;8790:18:0;;;;;-1:-1:-1;;;;;;8790:18:0;;;;;;-1:-1:-1;8378:3:0;;-1:-1:-1;8378:3:0;;;:::i;:::-;;;;8335:481;;8827:666;8902:24;8929:9;-1:-1:-1;;;;;8929:32:0;;:34;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;8929:34:0;;;;;;;;;;;;:::i;:::-;-1:-1:-1;;;;;;;;;;;9050:19:0;;8902:61;;-1:-1:-1;6408:47:0;8970:23;9077:411;9127:8;:15;9110:14;:32;9077:411;;;9171:15;9189:8;9198:14;9189:24;;;;;;;;:::i;:::-;;;;;;;9171:42;;9222:25;9250:37;9274:8;9284:2;9250:23;:37::i;:::-;9222:65;-1:-1:-1;;;;;;9300:31:0;;;9296:93;;9340:49;;-1:-1:-1;;;9340:49:0;;-1:-1:-1;;;;;;13139:33:1;;9340:49:0;;;13121:52:1;-1:-1:-1;;;;;13209:32:1;;13189:18;;;13182:60;13094:18;;9340:49:0;12949:299:1;9296:93:0;9416:38;;;;;;;;;-1:-1:-1;;;;;9416:38:0;;;;;-1:-1:-1;;;;;;9416:38:0;;;;;;;;;9398:57;;;;;;;:12;:57;;;;;;;;;;;;;;;;;-1:-1:-1;;;9398:57:0;-1:-1:-1;;;;;;9398:57:0;;;;;;;;;;;;;;;;;9464:16;;;;:::i;:::-;;;;9162:326;;9144:16;;;;;:::i;:::-;;;;9077:411;;;;8895:598;;;8827:666;:::o;9821:299::-;9953:19;;9915:6;;;9980:103;10003:6;9999:10;;:1;:10;;;9980:103;;;10057:8;-1:-1:-1;;;;;10029:36:0;;:2;:12;;10042:1;10029:15;;;;;;;;;;:::i;:::-;;;;;;;;;;:24;-1:-1:-1;;;10029:24:0;;;;-1:-1:-1;;;;;;10029:36:0;;10025:50;;;10074:1;-1:-1:-1;10067:8:0;;-1:-1:-1;10067:8:0;10025:50;10011:3;;;;:::i;:::-;;;;9980:103;;;-1:-1:-1;10098:16:0;;9821:299;-1:-1:-1;;;;9821:299:0:o;221:258:1:-;293:1;303:113;317:6;314:1;311:13;303:113;;;393:11;;;387:18;374:11;;;367:39;339:2;332:10;303:113;;;434:6;431:1;428:13;425:48;;;-1:-1:-1;;469:1:1;451:16;;444:27;221:258::o;484:::-;526:3;564:5;558:12;591:6;586:3;579:19;607:63;663:6;656:4;651:3;647:14;640:4;633:5;629:16;607:63;:::i;:::-;724:2;703:15;-1:-1:-1;;699:29:1;690:39;;;;731:4;686:50;;484:258;-1:-1:-1;;484:258:1:o;747:220::-;896:2;885:9;878:21;859:4;916:45;957:2;946:9;942:18;934:6;916:45;:::i;:::-;908:53;747:220;-1:-1:-1;;;747:220:1:o;2018:658::-;2189:2;2241:21;;;2311:13;;2214:18;;;2333:22;;;2160:4;;2189:2;2412:15;;;;2386:2;2371:18;;;2160:4;2455:195;2469:6;2466:1;2463:13;2455:195;;;2534:13;;-1:-1:-1;;;;;2530:39:1;2518:52;;2625:15;;;;2590:12;;;;2566:1;2484:9;2455:195;;;-1:-1:-1;2667:3:1;;2018:658;-1:-1:-1;;;;;;2018:658:1:o;2681:149::-;-1:-1:-1;;;;;2774:31:1;;2764:42;;2754:70;;2820:1;2817;2810:12;2754:70;2681:149;:::o;2835:472::-;2951:6;2959;3012:2;3000:9;2991:7;2987:23;2983:32;2980:52;;;3028:1;3025;3018:12;2980:52;3067:9;3054:23;3086:49;3129:5;3086:49;:::i;:::-;3154:5;-1:-1:-1;3211:2:1;3196:18;;3183:32;3224:51;3183:32;3224:51;:::i;:::-;3294:7;3284:17;;;2835:472;;;;;:::o;3536:744::-;3615:6;3623;3631;3684:2;3672:9;3663:7;3659:23;3655:32;3652:52;;;3700:1;3697;3690:12;3652:52;3739:9;3726:23;3758:49;3801:5;3758:49;:::i;:::-;3826:5;-1:-1:-1;3882:2:1;3867:18;;3854:32;3905:18;3935:14;;;3932:34;;;3962:1;3959;3952:12;3932:34;4000:6;3989:9;3985:22;3975:32;;4045:7;4038:4;4034:2;4030:13;4026:27;4016:55;;4067:1;4064;4057:12;4016:55;4107:2;4094:16;4133:2;4125:6;4122:14;4119:34;;;4149:1;4146;4139:12;4119:34;4194:7;4189:2;4180:6;4176:2;4172:15;4168:24;4165:37;4162:57;;;4215:1;4212;4205:12;4162:57;4246:2;4242;4238:11;4228:21;;4268:6;4258:16;;;;;3536:744;;;;;:::o;4518:380::-;4597:1;4593:12;;;;4640;;;4661:61;;4715:4;4707:6;4703:17;4693:27;;4661:61;4768:2;4760:6;4757:14;4737:18;4734:38;4731:161;;;4814:10;4809:3;4805:20;4802:1;4795:31;4849:4;4846:1;4839:15;4877:4;4874:1;4867:15;4731:161;;4518:380;;;:::o;5588:274::-;5717:3;5755:6;5749:13;5771:53;5817:6;5812:3;5805:4;5797:6;5793:17;5771:53;:::i;:::-;5840:16;;;;;5588:274;-1:-1:-1;;5588:274:1:o;6212:273::-;6280:6;6333:2;6321:9;6312:7;6308:23;6304:32;6301:52;;;6349:1;6346;6339:12;6301:52;6381:9;6375:16;6431:4;6424:5;6420:16;6413:5;6410:27;6400:55;;6451:1;6448;6441:12;6490:127;6551:10;6546:3;6542:20;6539:1;6532:31;6582:4;6579:1;6572:15;6606:4;6603:1;6596:15;6622:275;6693:2;6687:9;6758:2;6739:13;;-1:-1:-1;;6735:27:1;6723:40;;6793:18;6778:34;;6814:22;;;6775:62;6772:88;;;6840:18;;:::i;:::-;6876:2;6869:22;6622:275;;-1:-1:-1;6622:275:1:o;6902:851::-;6990:6;6998;7051:2;7039:9;7030:7;7026:23;7022:32;7019:52;;;7067:1;7064;7057:12;7019:52;7099:9;7093:16;7118:49;7161:5;7118:49;:::i;:::-;7235:2;7220:18;;7214:25;7186:5;;-1:-1:-1;7258:18:1;7288:14;;;7285:34;;;7315:1;7312;7305:12;7285:34;7353:6;7342:9;7338:22;7328:32;;7398:7;7391:4;7387:2;7383:13;7379:27;7369:55;;7420:1;7417;7410:12;7369:55;7449:2;7443:9;7471:2;7467;7464:10;7461:36;;;7477:18;;:::i;:::-;7519:53;7562:2;7543:13;;-1:-1:-1;;7539:27:1;7568:2;7535:36;7519:53;:::i;:::-;7506:66;;7595:2;7588:5;7581:17;7635:7;7630:2;7625;7621;7617:11;7613:20;7610:33;7607:53;;;7656:1;7653;7646:12;7607:53;7669:54;7720:2;7715;7708:5;7704:14;7699:2;7695;7691:11;7669:54;:::i;:::-;;7742:5;7732:15;;;;6902:851;;;;;:::o;8092:127::-;8153:10;8148:3;8144:20;8141:1;8134:31;8184:4;8181:1;8174:15;8208:4;8205:1;8198:15;8224:127;8285:10;8280:3;8276:20;8273:1;8266:31;8316:4;8313:1;8306:15;8340:4;8337:1;8330:15;8356:135;8395:3;-1:-1:-1;;8416:17:1;;8413:43;;;8436:18;;:::i;:::-;-1:-1:-1;8483:1:1;8472:13;;8356:135::o;8496:269::-;8566:6;8619:2;8607:9;8598:7;8594:23;8590:32;8587:52;;;8635:1;8632;8625:12;8587:52;8667:9;8661:16;8686:49;8729:5;8686:49;:::i;8770:277::-;8837:6;8890:2;8878:9;8869:7;8865:23;8861:32;8858:52;;;8906:1;8903;8896:12;8858:52;8938:9;8932:16;8991:5;8984:13;8977:21;8970:5;8967:32;8957:60;;9013:1;9010;9003:12;9584:183;9644:4;9677:18;9669:6;9666:30;9663:56;;;9699:18;;:::i;:::-;-1:-1:-1;9744:1:1;9740:14;9756:4;9736:25;;9584:183::o;9772:974::-;9867:6;9898:2;9941;9929:9;9920:7;9916:23;9912:32;9909:52;;;9957:1;9954;9947:12;9909:52;9990:9;9984:16;10023:18;10015:6;10012:30;10009:50;;;10055:1;10052;10045:12;10009:50;10078:22;;10131:4;10123:13;;10119:27;-1:-1:-1;10109:55:1;;10160:1;10157;10150:12;10109:55;10189:2;10183:9;10212:60;10228:43;10268:2;10228:43;:::i;:::-;10212:60;:::i;:::-;10306:15;;;10388:1;10384:10;;;;10376:19;;10372:28;;;10337:12;;;;10412:19;;;10409:39;;;10444:1;10441;10434:12;10409:39;10468:11;;;;10488:228;10504:6;10499:3;10496:15;10488:228;;;10577:3;10571:10;10594:49;10637:5;10594:49;:::i;:::-;10656:18;;10521:12;;;;10694;;;;10488:228;;;10735:5;9772:974;-1:-1:-1;;;;;;;9772:974:1:o;10751:125::-;10791:4;10819:1;10816;10813:8;10810:34;;;10824:18;;:::i;:::-;-1:-1:-1;10861:9:1;;10751:125::o;10881:127::-;10942:10;10937:3;10933:20;10930:1;10923:31;10973:4;10970:1;10963:15;10997:4;10994:1;10987:15;11013:175;11050:3;11094:4;11087:5;11083:16;11123:4;11114:7;11111:17;11108:43;;;11131:18;;:::i;:::-;11180:1;11167:15;;11013:175;-1:-1:-1;;11013:175:1:o;11545:1065::-;11639:6;11670:2;11713;11701:9;11692:7;11688:23;11684:32;11681:52;;;11729:1;11726;11719:12;11681:52;11762:9;11756:16;11795:18;11787:6;11784:30;11781:50;;;11827:1;11824;11817:12;11781:50;11850:22;;11903:4;11895:13;;11891:27;-1:-1:-1;11881:55:1;;11932:1;11929;11922:12;11881:55;11961:2;11955:9;11984:60;12000:43;12040:2;12000:43;:::i;11984:60::-;12078:15;;;12160:1;12156:10;;;;12148:19;;12144:28;;;12109:12;;;;12184:19;;;12181:39;;;12216:1;12213;12206:12;12181:39;12240:11;;;;12260:320;12276:6;12271:3;12268:15;12260:320;;;12343:10;;-1:-1:-1;;;;;;12386:32:1;;12376:43;;12366:141;;12461:1;12490:2;12486;12479:14;12366:141;12520:18;;12293:12;;;;12558;;;;12260:320;;12615:127;12676:10;12671:3;12667:20;12664:1;12657:31;12707:4;12704:1;12697:15;12731:4;12728:1;12721:15;12747:197;12785:3;12813:6;12854:2;12847:5;12843:14;12881:2;12872:7;12869:15;12866:41;;;12887:18;;:::i;:::-;12936:1;12923:15;;12747:197;-1:-1:-1;;;12747:197:1:o

Swarm Source

ipfs://9755ce9a28e8bf72743999c7d0a0478cdf26b67384376e4688ffabe0a0fec3b4
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.