Address Details
contract

0x4C0caE94Eda1658E7Bd359D496E18619523B8961

Contract Name
Faucet
Creator
0xdf3e98–a141cd at 0x92f41d–55c0f3
Balance
0 CELO ( )
Locked CELO Balance
0.00 CELO
Voting CELO Balance
0.00 CELO
Pending Unlocked Gold
0.00 CELO
Tokens
Fetching tokens...
Transactions
0 Transactions
Transfers
0 Transfers
Gas Used
Fetching gas used...
Last Balance Update
18866008
This contract has been partially verified via Sourcify. View contract in Sourcify repository
Contract name:
Faucet




Optimization enabled
true
Compiler version
v0.8.16+commit.07a7930e




Optimization runs
0
EVM Version
london




Verified at
2023-03-08T13:57:13.546568Z

project:/contracts/fuseFaucet/Faucet.sol

//SPDX-License-Identifier: MIT

pragma solidity >=0.8.0;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "../Interfaces.sol";
import "../utils/NameService.sol";

/**
 * @title FuseFaucet contract that can top up users wallets
 */
contract Faucet is Initializable, UUPSUpgradeable, AccessControlUpgradeable {
	bytes32 public constant RELAYER_ROLE = keccak256("relayer");

	event WalletTopped(
		address indexed account, //address topped
		uint256 amount,
		address whitelistedRoot, //if account is connected to a whitelisted account, this will be it
		address indexed relayerOrWhitelisted //the sender of the tx
	);

	uint256 public perDayRoughLimit;
	uint256 public gasTopping;
	uint256 public gasRefund;
	uint256 public startTime;
	uint256 public currentDay;

	NameService public nameService;

	mapping(uint256 => mapping(address => uint256)) public toppings;
	mapping(address => bool) public notFirstTime;

	struct Wallet {
		uint128 lastDayTopped;
		uint32 dailyToppingCount;
		uint128[7] lastWeekToppings;
	}

	mapping(address => Wallet) public wallets;
	uint32 public maxDailyToppings;
	uint64 public gasPrice;
	uint32 public maxPerWeekMultiplier;
	uint32 public maxSwapAmount;
	address public goodDollar_unused; //kept because of upgrades
	uint64 public maxDailyNewWallets;
	uint64 public dailyNewWalletsCount;
	uint32 public version;

	function initialize(
		NameService _ns,
		uint64 _gasPrice,
		address relayer,
		address owner
	) public initializer {
		__AccessControl_init_unchained();
		_setupRole(DEFAULT_ADMIN_ROLE, owner);
		if (relayer != address(0)) _setupRole(RELAYER_ROLE, relayer);
		gasPrice = _gasPrice;
		setGasTopping(600000); //0.6M gwei
		maxDailyToppings = 3;
		startTime = block.timestamp;
		nameService = _ns;
		maxPerWeekMultiplier = 2;
		maxSwapAmount = 1000;
		maxDailyNewWallets = 5000;
	}

	function _authorizeUpgrade(address newImplementation)
		internal
		override
		onlyRole(DEFAULT_ADMIN_ROLE)
	{}

	function getIdentity() public view returns (IIdentityV2) {
		return IIdentityV2(nameService.getAddress("IDENTITY"));
	}

	function upgrade() public {
		require(version == 0, "already upgraded");
		if (maxDailyNewWallets == 0) maxDailyNewWallets = 5000;
		version++;
		setGasTopping(gasTopping / gasPrice);
	}

	modifier reimburseGas() {
		uint256 _gasRefund = gasleft();
		_;
		_gasRefund = _gasRefund - gasleft() + 42000;
		payable(msg.sender).transfer(_gasRefund * gasPrice); //gas price assumed 1e9 = 1gwei
	}

	receive() external payable {}

	/*
	 * only whitelisted account or relayer can top non whitelisted accounts
	 * if target account is whitelisted anyone can top it
	 */
	modifier onlyAuthorized(address toTop) {
		require(
			getIdentity().getWhitelistedRoot(toTop) != address(0) ||
				getIdentity().getWhitelistedRoot(msg.sender) != address(0) ||
				hasRole(RELAYER_ROLE, msg.sender),
			"not authorized"
		);
		_;
	}

	modifier toppingLimit(address _user) {
		//switch wallet to the account we do the accounting for
		address whitelistedRoot = getIdentity().getWhitelistedRoot(_user);
		_user = whitelistedRoot == address(0) ? _user : payable(whitelistedRoot);

		uint256 prevDay = currentDay;

		setDay();
		if (currentDay != prevDay) dailyNewWalletsCount = 0;

		require(
			wallets[_user].lastDayTopped != uint128(currentDay) ||
				wallets[_user].dailyToppingCount < maxDailyToppings,
			"max daily toppings"
		);

		require(
			(notFirstTime[_user] == false &&
				dailyNewWalletsCount < maxDailyNewWallets) ||
				whitelistedRoot != address(0),
			"User not whitelisted or not first time"
		);

		//reset inactive days
		uint256 dayOfWeek = currentDay % 7;
		uint256 dayDiff = (currentDay - wallets[_user].lastDayTopped);
		dayDiff = dayDiff > 7 ? 7 : dayDiff;
		dayDiff = dayDiff > dayOfWeek ? dayOfWeek + 1 : dayDiff;
		for (uint256 day = dayOfWeek + 1 - dayDiff; day <= dayOfWeek; day++) {
			wallets[_user].lastWeekToppings[day] = 0;
		}

		uint128 weekTotal = 0;
		for (uint256 i = 0; i <= dayOfWeek; i++) {
			weekTotal += wallets[_user].lastWeekToppings[uint256(i)];
		}

		require(
			weekTotal < perDayRoughLimit * gasPrice * maxPerWeekMultiplier,
			"User wallet has been topped too many times this week"
		);
		_;
	}

	/* @dev Internal function that sets current day
	 */
	function setDay() internal {
		currentDay = (block.timestamp - startTime) / 1 days;
	}

	function canTop(address _user) external view returns (bool) {
		if (getToppingAmount() < address(_user).balance) return false;

		address whitelistedRoot = getIdentity().getWhitelistedRoot(_user);
		_user = whitelistedRoot == address(0) ? _user : whitelistedRoot;

		uint256 _currentDay = (block.timestamp - startTime) / 1 days;
		bool can = (wallets[_user].lastDayTopped != uint128(_currentDay) ||
			wallets[_user].dailyToppingCount < 3) &&
			((notFirstTime[_user] == false &&
				dailyNewWalletsCount < maxDailyNewWallets) ||
				whitelistedRoot != address(0));

		uint128[7] memory lastWeekToppings = wallets[_user].lastWeekToppings;
		//reset inactive days
		uint256 dayOfWeek = _currentDay % 7;
		uint256 dayDiff = (_currentDay - wallets[_user].lastDayTopped);
		dayDiff = dayDiff > 7 ? 7 : dayDiff;
		dayDiff = dayDiff > dayOfWeek ? dayOfWeek + 1 : dayDiff;

		for (uint256 day = dayOfWeek + 1 - dayDiff; day <= dayOfWeek; day++) {
			lastWeekToppings[day] = 0;
		}

		uint128 weekTotal = 0;
		for (uint256 i = 0; i <= dayOfWeek; i++) {
			weekTotal += lastWeekToppings[uint256(i)];
		}
		can = can && weekTotal < perDayRoughLimit * gasPrice * maxPerWeekMultiplier;
		return can;
	}

	/* @dev Function to top given address with amount of G$ given in constructor
	 * can only be done by admin the amount of times specified in constructor per day
	 * @param _user The address to transfer to
	 */
	function topWallet(address payable _user)
		public
		reimburseGas
		toppingLimit(_user)
		onlyAuthorized(_user)
	{
		_topWallet(_user);
	}

	function _topWallet(address payable _wallet) internal {
		address payable target = _wallet;

		//switch wallet to the account we do the accounting for
		address whitelistedRoot = getIdentity().getWhitelistedRoot(_wallet);
		_wallet = whitelistedRoot == address(0)
			? _wallet
			: payable(whitelistedRoot);

		require(getToppingAmount() > address(_wallet).balance);
		uint256 toTop = getToppingAmount() - address(_wallet).balance;

		uint256 dayOfWeek = currentDay % 7;

		if (wallets[_wallet].lastDayTopped == uint128(currentDay))
			wallets[_wallet].dailyToppingCount += 1;
		else wallets[_wallet].dailyToppingCount = 1;
		wallets[_wallet].lastDayTopped = uint128(currentDay);
		wallets[_wallet].lastWeekToppings[dayOfWeek] += uint128(toTop);

		if (notFirstTime[_wallet] == false && whitelistedRoot == address(0)) {
			dailyNewWalletsCount++;
		}
		notFirstTime[_wallet] = true;

		target.transfer(toTop);
		emit WalletTopped(target, toTop, whitelistedRoot, msg.sender);
	}

	function onTokenTransfer(
		address payable _from,
		uint256 amount,
		bytes calldata data
	) external returns (bool) {
		require(amount <= maxSwapAmount, "slippage");
		address uniswapLike = abi.decode(data, (address));
		Uniswap uniswap = Uniswap(uniswapLike);
		address[] memory path = new address[](2);
		path[0] = address(msg.sender);
		path[1] = uniswap.WETH();

		cERC20(msg.sender).approve(address(uniswapLike), type(uint256).max);
		uniswap.swapExactTokensForETH(amount, 0, path, _from, block.timestamp);
		return true;
	}

	function getToppingAmount() public view returns (uint256) {
		return gasTopping * gasPrice;
	}

	function setGasTopping(uint256 _gasUnits)
		public
		onlyRole(DEFAULT_ADMIN_ROLE)
	{
		gasTopping = _gasUnits;
		perDayRoughLimit = 2 * gasTopping;
	}

	function setGasPrice(uint64 _price) external onlyRole(DEFAULT_ADMIN_ROLE) {
		gasPrice = _price;
	}
}
        

/_openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol

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

pragma solidity ^0.8.0;

import "./IAccessControlUpgradeable.sol";
import "../utils/ContextUpgradeable.sol";
import "../utils/StringsUpgradeable.sol";
import "../utils/introspection/ERC165Upgradeable.sol";
import "../proxy/utils/Initializable.sol";

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

    function __AccessControl_init_unchained() internal onlyInitializing {
    }
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

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

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

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

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

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

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

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

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

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

        _revokeRole(role, account);
    }

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

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

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

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

    /**
     * @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;
}
          

/_openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

/_openzeppelin/contracts-upgradeable/interfaces/draft-IERC1822Upgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)

pragma solidity ^0.8.0;

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

/_openzeppelin/contracts-upgradeable/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)

pragma solidity ^0.8.2;

import "../beacon/IBeaconUpgradeable.sol";
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import "../utils/Initializable.sol";

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 *
 * _Available since v4.1._
 *
 * @custom:oz-upgrades-unsafe-allow delegatecall
 */
abstract contract ERC1967UpgradeUpgradeable is Initializable {
    function __ERC1967Upgrade_init() internal onlyInitializing {
    }

    function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
    }
    // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {
        require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed");
    }

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

/_openzeppelin/contracts-upgradeable/proxy/beacon/IBeaconUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)

pragma solidity ^0.8.0;

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

/_openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol

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

pragma solidity ^0.8.2;

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

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * 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;
    }
}
          

/_openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol

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

pragma solidity ^0.8.0;

import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import "./Initializable.sol";

/**
 * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
 * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
 *
 * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
 * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
 * `UUPSUpgradeable` with a custom implementation of upgrades.
 *
 * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
 *
 * _Available since v4.1._
 */
abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {
    function __UUPSUpgradeable_init() internal onlyInitializing {
    }

    function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
    }
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
    address private immutable __self = address(this);

    /**
     * @dev Check that the execution is being performed through a delegatecall call and that the execution context is
     * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
     * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
     * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
     * fail.
     */
    modifier onlyProxy() {
        require(address(this) != __self, "Function must be called through delegatecall");
        require(_getImplementation() == __self, "Function must be called through active proxy");
        _;
    }

    /**
     * @dev Check that the execution is not being performed through a delegate call. This allows a function to be
     * callable on the implementing contract but not through proxies.
     */
    modifier notDelegated() {
        require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall");
        _;
    }

    /**
     * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
     * implementation. It is used to validate the implementation's compatibility when performing an upgrade.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
     */
    function proxiableUUID() external view virtual override notDelegated returns (bytes32) {
        return _IMPLEMENTATION_SLOT;
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeTo(address newImplementation) external virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
     * encoded in `data`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, data, true);
    }

    /**
     * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
     * {upgradeTo} and {upgradeToAndCall}.
     *
     * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
     *
     * ```solidity
     * function _authorizeUpgrade(address) internal override onlyOwner {}
     * ```
     */
    function _authorizeUpgrade(address newImplementation) internal virtual;

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

/_openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

/_openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol

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

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

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

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

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

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

/_openzeppelin/contracts-upgradeable/utils/StorageSlotUpgradeable.sol

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

pragma solidity ^0.8.0;

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

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

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

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

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

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

/_openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol

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

pragma solidity ^0.8.0;

import "./math/MathUpgradeable.sol";

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

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

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

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

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

/_openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol

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

pragma solidity ^0.8.0;

import "./IERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";

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

    function __ERC165_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165Upgradeable).interfaceId;
    }

    /**
     * @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;
}
          

/_openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165Upgradeable {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
          

/_openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library MathUpgradeable {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

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

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator,
        Rounding rounding
    ) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10**64) {
                value /= 10**64;
                result += 64;
            }
            if (value >= 10**32) {
                value /= 10**32;
                result += 32;
            }
            if (value >= 10**16) {
                value /= 10**16;
                result += 16;
            }
            if (value >= 10**8) {
                value /= 10**8;
                result += 8;
            }
            if (value >= 10**4) {
                value /= 10**4;
                result += 4;
            }
            if (value >= 10**2) {
                value /= 10**2;
                result += 2;
            }
            if (value >= 10**1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
        }
    }
}
          

/project_/contracts/DAOStackInterfaces.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0;

interface Avatar {
	function nativeToken() external view returns (address);

	function nativeReputation() external view returns (address);

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

interface Controller {
	event RegisterScheme(address indexed _sender, address indexed _scheme);
	event UnregisterScheme(address indexed _sender, address indexed _scheme);

	function genericCall(
		address _contract,
		bytes calldata _data,
		address _avatar,
		uint256 _value
	) external returns (bool, bytes memory);

	function avatar() external view returns (address);

	function unregisterScheme(address _scheme, address _avatar)
		external
		returns (bool);

	function unregisterSelf(address _avatar) external returns (bool);

	function registerScheme(
		address _scheme,
		bytes32 _paramsHash,
		bytes4 _permissions,
		address _avatar
	) external returns (bool);

	function isSchemeRegistered(address _scheme, address _avatar)
		external
		view
		returns (bool);

	function getSchemePermissions(address _scheme, address _avatar)
		external
		view
		returns (bytes4);

	function addGlobalConstraint(
		address _constraint,
		bytes32 _paramHash,
		address _avatar
	) external returns (bool);

	function mintTokens(
		uint256 _amount,
		address _beneficiary,
		address _avatar
	) external returns (bool);

	function externalTokenTransfer(
		address _token,
		address _recipient,
		uint256 _amount,
		address _avatar
	) external returns (bool);

	function sendEther(
		uint256 _amountInWei,
		address payable _to,
		address _avatar
	) external returns (bool);
}

interface GlobalConstraintInterface {
	enum CallPhase {
		Pre,
		Post,
		PreAndPost
	}

	function pre(
		address _scheme,
		bytes32 _params,
		bytes32 _method
	) external returns (bool);

	/**
	 * @dev when return if this globalConstraints is pre, post or both.
	 * @return CallPhase enum indication  Pre, Post or PreAndPost.
	 */
	function when() external returns (CallPhase);
}

interface ReputationInterface {
	function balanceOf(address _user) external view returns (uint256);

	function balanceOfAt(address _user, uint256 _blockNumber)
		external
		view
		returns (uint256);

	function getVotes(address _user) external view returns (uint256);

	function getVotesAt(
		address _user,
		bool _global,
		uint256 _blockNumber
	) external view returns (uint256);

	function totalSupply() external view returns (uint256);

	function totalSupplyAt(uint256 _blockNumber)
		external
		view
		returns (uint256);

	function delegateOf(address _user) external returns (address);
}

interface SchemeRegistrar {
	function proposeScheme(
		Avatar _avatar,
		address _scheme,
		bytes32 _parametersHash,
		bytes4 _permissions,
		string memory _descriptionHash
	) external returns (bytes32);

	event NewSchemeProposal(
		address indexed _avatar,
		bytes32 indexed _proposalId,
		address indexed _intVoteInterface,
		address _scheme,
		bytes32 _parametersHash,
		bytes4 _permissions,
		string _descriptionHash
	);
}

interface IntVoteInterface {
	event NewProposal(
		bytes32 indexed _proposalId,
		address indexed _organization,
		uint256 _numOfChoices,
		address _proposer,
		bytes32 _paramsHash
	);

	event ExecuteProposal(
		bytes32 indexed _proposalId,
		address indexed _organization,
		uint256 _decision,
		uint256 _totalReputation
	);

	event VoteProposal(
		bytes32 indexed _proposalId,
		address indexed _organization,
		address indexed _voter,
		uint256 _vote,
		uint256 _reputation
	);

	event CancelProposal(
		bytes32 indexed _proposalId,
		address indexed _organization
	);
	event CancelVoting(
		bytes32 indexed _proposalId,
		address indexed _organization,
		address indexed _voter
	);

	/**
	 * @dev register a new proposal with the given parameters. Every proposal has a unique ID which is being
	 * generated by calculating keccak256 of a incremented counter.
	 * @param _numOfChoices number of voting choices
	 * @param _proposalParameters defines the parameters of the voting machine used for this proposal
	 * @param _proposer address
	 * @param _organization address - if this address is zero the msg.sender will be used as the organization address.
	 * @return proposal's id.
	 */
	function propose(
		uint256 _numOfChoices,
		bytes32 _proposalParameters,
		address _proposer,
		address _organization
	) external returns (bytes32);

	function vote(
		bytes32 _proposalId,
		uint256 _vote,
		uint256 _rep,
		address _voter
	) external returns (bool);

	function cancelVote(bytes32 _proposalId) external;

	function getNumberOfChoices(bytes32 _proposalId)
		external
		view
		returns (uint256);

	function isVotable(bytes32 _proposalId) external view returns (bool);

	/**
	 * @dev voteStatus returns the reputation voted for a proposal for a specific voting choice.
	 * @param _proposalId the ID of the proposal
	 * @param _choice the index in the
	 * @return voted reputation for the given choice
	 */
	function voteStatus(bytes32 _proposalId, uint256 _choice)
		external
		view
		returns (uint256);

	/**
	 * @dev isAbstainAllow returns if the voting machine allow abstain (0)
	 * @return bool true or false
	 */
	function isAbstainAllow() external pure returns (bool);

	/**
     * @dev getAllowedRangeOfChoices returns the allowed range of choices for a voting machine.
     * @return min - minimum number of choices
               max - maximum number of choices
     */
	function getAllowedRangeOfChoices()
		external
		pure
		returns (uint256 min, uint256 max);
}
          

/project_/contracts/Interfaces.sol

// SPDX-License-Identifier: MIT
import { DataTypes } from "./utils/DataTypes.sol";
pragma solidity >=0.8.0;

pragma experimental ABIEncoderV2;

interface ERC20 {
	function balanceOf(address addr) external view returns (uint256);

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

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

	function decimals() external view returns (uint8);

	function mint(address to, uint256 mintAmount) external returns (uint256);

	function burn(uint256 amount) external;

	function totalSupply() external view returns (uint256);

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

	function transferFrom(
		address sender,
		address recipient,
		uint256 amount
	) external returns (bool);

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

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

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

interface cERC20 is ERC20 {
	function mint(uint256 mintAmount) external returns (uint256);

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

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

	function exchangeRateCurrent() external returns (uint256);

	function exchangeRateStored() external view returns (uint256);

	function underlying() external returns (address);
}

interface IGoodDollar is ERC20 {
	// view functions
	function feeRecipient() external view returns (address);

	function getFees(
		uint256 value,
		address sender,
		address recipient
	) external view returns (uint256 fee, bool senderPays);

	function cap() external view returns (uint256);

	function isPauser(address _pauser) external view returns (bool);

	function getFees(uint256 value) external view returns (uint256, bool);

	function isMinter(address minter) external view returns (bool);

	function formula() external view returns (address);

	function identity() external view returns (address);

	function owner() external view returns (address);

	// state changing functions
	function setFeeRecipient(address _feeRecipient) external;

	function setFormula(address _formula) external;

	function transferOwnership(address _owner) external;

	function addPauser(address _pauser) external;

	function pause() external;

	function unpause() external;

	function burn(uint256 amount) external;

	function burnFrom(address account, uint256 amount) external;

	function renounceMinter() external;

	function addMinter(address minter) external;

	function transferAndCall(
		address to,
		uint256 value,
		bytes calldata data
	) external returns (bool);

	function setIdentity(address identity) external;
}

interface IERC2917 is ERC20 {
	/// @dev This emit when interests amount per block is changed by the owner of the contract.
	/// It emits with the old interests amount and the new interests amount.
	event InterestRatePerBlockChanged(uint256 oldValue, uint256 newValue);

	/// @dev This emit when a users' productivity has changed
	/// It emits with the user's address and the the value after the change.
	event ProductivityIncreased(address indexed user, uint256 value);

	/// @dev This emit when a users' productivity has changed
	/// It emits with the user's address and the the value after the change.
	event ProductivityDecreased(address indexed user, uint256 value);

	/// @dev Return the current contract's interests rate per block.
	/// @return The amount of interests currently producing per each block.
	function interestsPerBlock() external view returns (uint256);

	/// @notice Change the current contract's interests rate.
	/// @dev Note the best practice will be restrict the gross product provider's contract address to call this.
	/// @return The true/fase to notice that the value has successfully changed or not, when it succeed, it will emite the InterestRatePerBlockChanged event.
	function changeInterestRatePerBlock(uint256 value) external returns (bool);

	/// @notice It will get the productivity of given user.
	/// @dev it will return 0 if user has no productivity proved in the contract.
	/// @return user's productivity and overall productivity.
	function getProductivity(address user)
		external
		view
		returns (uint256, uint256);

	/// @notice increase a user's productivity.
	/// @dev Note the best practice will be restrict the callee to prove of productivity's contract address.
	/// @return true to confirm that the productivity added success.
	function increaseProductivity(address user, uint256 value)
		external
		returns (bool);

	/// @notice decrease a user's productivity.
	/// @dev Note the best practice will be restrict the callee to prove of productivity's contract address.
	/// @return true to confirm that the productivity removed success.
	function decreaseProductivity(address user, uint256 value)
		external
		returns (bool);

	/// @notice take() will return the interests that callee will get at current block height.
	/// @dev it will always calculated by block.number, so it will change when block height changes.
	/// @return amount of the interests that user are able to mint() at current block height.
	function take() external view returns (uint256);

	/// @notice similar to take(), but with the block height joined to calculate return.
	/// @dev for instance, it returns (_amount, _block), which means at block height _block, the callee has accumulated _amount of interests.
	/// @return amount of interests and the block height.
	function takeWithBlock() external view returns (uint256, uint256);

	/// @notice mint the avaiable interests to callee.
	/// @dev once it mint, the amount of interests will transfer to callee's address.
	/// @return the amount of interests minted.
	function mint() external returns (uint256);
}

interface Staking {
	struct Staker {
		// The staked DAI amount
		uint256 stakedDAI;
		// The latest block number which the
		// staker has staked tokens
		uint256 lastStake;
	}

	function stakeDAI(uint256 amount) external;

	function withdrawStake() external;

	function stakers(address staker) external view returns (Staker memory);
}

interface Uniswap {
	function swapExactETHForTokens(
		uint256 amountOutMin,
		address[] calldata path,
		address to,
		uint256 deadline
	) external payable returns (uint256[] memory amounts);

	function swapExactTokensForETH(
		uint256 amountIn,
		uint256 amountOutMin,
		address[] calldata path,
		address to,
		uint256 deadline
	) external returns (uint256[] memory amounts);

	function swapExactTokensForTokens(
		uint256 amountIn,
		uint256 amountOutMin,
		address[] calldata path,
		address to,
		uint256 deadline
	) external returns (uint256[] memory amounts);

	function WETH() external pure returns (address);

	function factory() external pure returns (address);

	function quote(
		uint256 amountA,
		uint256 reserveA,
		uint256 reserveB
	) external pure returns (uint256 amountB);

	function getAmountIn(
		uint256 amountOut,
		uint256 reserveIn,
		uint256 reserveOut
	) external pure returns (uint256 amountIn);

	function getAmountOut(
		uint256 amountI,
		uint256 reserveIn,
		uint256 reserveOut
	) external pure returns (uint256 amountOut);

	function getAmountsOut(uint256 amountIn, address[] memory path)
		external
		pure
		returns (uint256[] memory amounts);
}

interface UniswapFactory {
	function getPair(address tokenA, address tokenB)
		external
		view
		returns (address);
}

interface UniswapPair {
	function getReserves()
		external
		view
		returns (
			uint112 reserve0,
			uint112 reserve1,
			uint32 blockTimestampLast
		);

	function kLast() external view returns (uint256);

	function token0() external view returns (address);

	function token1() external view returns (address);

	function totalSupply() external view returns (uint256);

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

interface Reserve {
	function buy(
		address _buyWith,
		uint256 _tokenAmount,
		uint256 _minReturn
	) external returns (uint256);
}

interface IIdentity {
	function isWhitelisted(address user) external view returns (bool);

	function addWhitelistedWithDID(address account, string memory did) external;

	function removeWhitelisted(address account) external;

	function addBlacklisted(address account) external;

	function removeBlacklisted(address account) external;

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

	function addIdentityAdmin(address account) external returns (bool);

	function setAvatar(address _avatar) external;

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

	function owner() external view returns (address);

	function removeContract(address account) external;

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

	function addrToDID(address account) external view returns (string memory);

	function didHashToAddress(bytes32 hash) external view returns (address);

	event WhitelistedAdded(address user);
}

interface IIdentityV2 is IIdentity {
	function addWhitelistedWithDIDAndChain(
		address account,
		string memory did,
		uint256 orgChainId,
		uint256 dateAuthenticated
	) external;

	function getWhitelistedRoot(address account)
		external
		view
		returns (address root);
}

interface IUBIScheme {
	function currentDay() external view returns (uint256);

	function periodStart() external view returns (uint256);

	function hasClaimed(address claimer) external view returns (bool);
}

interface IFirstClaimPool {
	function awardUser(address user) external returns (uint256);

	function claimAmount() external view returns (uint256);
}

interface ProxyAdmin {
	function getProxyImplementation(address proxy)
		external
		view
		returns (address);

	function getProxyAdmin(address proxy) external view returns (address);

	function upgrade(address proxy, address implementation) external;

	function owner() external view returns (address);

	function transferOwnership(address newOwner) external;

	function upgradeAndCall(
		address proxy,
		address implementation,
		bytes memory data
	) external;
}

/**
 * @dev Interface for chainlink oracles to obtain price datas
 */
interface AggregatorV3Interface {
	function decimals() external view returns (uint8);

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

	function version() external view returns (uint256);

	// getRoundData and latestRoundData should both raise "No data present"
	// if they do not have data to report, instead of returning unset values
	// which could be misinterpreted as actual reported values.
	function getRoundData(uint80 _roundId)
		external
		view
		returns (
			uint80 roundId,
			int256 answer,
			uint256 startedAt,
			uint256 updatedAt,
			uint80 answeredInRound
		);

	function latestAnswer() external view returns (int256);
}

/**
	@dev interface for AAVE lending Pool
 */
interface ILendingPool {
	/**
	 * @dev Deposits an `amount` of underlying asset into the reserve, receiving in return overlying aTokens.
	 * - E.g. User deposits 100 USDC and gets in return 100 aUSDC
	 * @param asset The address of the underlying asset to deposit
	 * @param amount The amount to be deposited
	 * @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user
	 *   wants to receive them on his own wallet, or a different address if the beneficiary of aTokens
	 *   is a different wallet
	 * @param referralCode Code used to register the integrator originating the operation, for potential rewards.
	 *   0 if the action is executed directly by the user, without any middle-man
	 **/
	function deposit(
		address asset,
		uint256 amount,
		address onBehalfOf,
		uint16 referralCode
	) external;

	/**
	 * @dev Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned
	 * E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC
	 * @param asset The address of the underlying asset to withdraw
	 * @param amount The underlying amount to be withdrawn
	 *   - Send the value type(uint256).max in order to withdraw the whole aToken balance
	 * @param to Address that will receive the underlying, same as msg.sender if the user
	 *   wants to receive it on his own wallet, or a different address if the beneficiary is a
	 *   different wallet
	 * @return The final amount withdrawn
	 **/
	function withdraw(
		address asset,
		uint256 amount,
		address to
	) external returns (uint256);

	/**
	 * @dev Returns the state and configuration of the reserve
	 * @param asset The address of the underlying asset of the reserve
	 * @return The state of the reserve
	 **/
	function getReserveData(address asset)
		external
		view
		returns (DataTypes.ReserveData memory);
}

interface IDonationStaking {
	function stakeDonations() external payable;
}

interface INameService {
	function getAddress(string memory _name) external view returns (address);
}

interface IAaveIncentivesController {
	/**
	 * @dev Claims reward for an user, on all the assets of the lending pool, accumulating the pending rewards
	 * @param amount Amount of rewards to claim
	 * @param to Address that will be receiving the rewards
	 * @return Rewards claimed
	 **/
	function claimRewards(
		address[] calldata assets,
		uint256 amount,
		address to
	) external returns (uint256);

	/**
	 * @dev Returns the total of rewards of an user, already accrued + not yet accrued
	 * @param user The address of the user
	 * @return The rewards
	 **/
	function getRewardsBalance(address[] calldata assets, address user)
		external
		view
		returns (uint256);
}

interface IGoodStaking {
	function collectUBIInterest(address recipient)
		external
		returns (
			uint256,
			uint256,
			uint256
		);

	function iToken() external view returns (address);

	function currentGains(
		bool _returnTokenBalanceInUSD,
		bool _returnTokenGainsInUSD
	)
		external
		view
		returns (
			uint256,
			uint256,
			uint256,
			uint256,
			uint256
		);

	function getRewardEarned(address user) external view returns (uint256);

	function getGasCostForInterestTransfer() external view returns (uint256);

	function rewardsMinted(
		address user,
		uint256 rewardsPerBlock,
		uint256 blockStart,
		uint256 blockEnd
	) external returns (uint256);
}

interface IHasRouter {
	function getRouter() external view returns (Uniswap);
}

interface IAdminWallet {
	function addAdmins(address payable[] memory _admins) external;

	function removeAdmins(address[] memory _admins) external;

	function owner() external view returns (address);

	function transferOwnership(address _owner) external;
}

interface IMultichainRouter {
	// Swaps `amount` `token` from this chain to `toChainID` chain with recipient `to`
	function anySwapOut(
		address token,
		address to,
		uint256 amount,
		uint256 toChainID
	) external;

	// Swaps `amount` `token` from this chain to `toChainID` chain with recipient `to`
	function anySwapOutUnderlying(
		address token,
		address to,
		uint256 amount,
		uint256 toChainID
	) external;
}
          

/project_/contracts/utils/DataTypes.sol

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;

library DataTypes {
	// refer to the whitepaper, section 1.1 basic concepts for a formal description of these properties.
	struct ReserveData {
		//stores the reserve configuration
		ReserveConfigurationMap configuration;
		//the liquidity index. Expressed in ray
		uint128 liquidityIndex;
		//variable borrow index. Expressed in ray
		uint128 variableBorrowIndex;
		//the current supply rate. Expressed in ray
		uint128 currentLiquidityRate;
		//the current variable borrow rate. Expressed in ray
		uint128 currentVariableBorrowRate;
		//the current stable borrow rate. Expressed in ray
		uint128 currentStableBorrowRate;
		uint40 lastUpdateTimestamp;
		//tokens addresses
		address aTokenAddress;
		address stableDebtTokenAddress;
		address variableDebtTokenAddress;
		//address of the interest rate strategy
		address interestRateStrategyAddress;
		//the id of the reserve. Represents the position in the list of the active reserves
		uint8 id;
	}

	struct ReserveConfigurationMap {
		//bit 0-15: LTV
		//bit 16-31: Liq. threshold
		//bit 32-47: Liq. bonus
		//bit 48-55: Decimals
		//bit 56: Reserve is active
		//bit 57: reserve is frozen
		//bit 58: borrowing is enabled
		//bit 59: stable rate borrowing enabled
		//bit 60-63: reserved
		//bit 64-79: reserve factor
		uint256 data;
	}
	enum InterestRateMode { NONE, STABLE, VARIABLE }
}
          

/project_/contracts/utils/NameService.sol

// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";

import "../DAOStackInterfaces.sol";

/**
@title Simple name to address resolver
*/

contract NameService is Initializable, UUPSUpgradeable {
	mapping(bytes32 => address) public addresses;

	Controller public dao;
	event AddressChanged(string name ,address addr);
	function initialize(
		Controller _dao,
		bytes32[] memory _nameHashes,
		address[] memory _addresses
	) public virtual initializer {
		dao = _dao;
		for (uint256 i = 0; i < _nameHashes.length; i++) {
			addresses[_nameHashes[i]] = _addresses[i];
		}
		addresses[keccak256(bytes("CONTROLLER"))] = address(_dao);
		addresses[keccak256(bytes("AVATAR"))] = address(_dao.avatar());
	}

	function _authorizeUpgrade(address) internal override {
		_onlyAvatar();
	}

	function _onlyAvatar() internal view {
		require(
			address(dao.avatar()) == msg.sender,
			"only avatar can call this method"
		);
	}

	function setAddress(string memory name, address addr) external {
		_onlyAvatar();
		addresses[keccak256(bytes(name))] = addr;
		emit AddressChanged(name, addr);
	}

	function setAddresses(bytes32[] calldata hash, address[] calldata addrs)
		external
	{
		_onlyAvatar();
		for (uint256 i = 0; i < hash.length; i++) {
			addresses[hash[i]] = addrs[i];
		}
	}

	function getAddress(string memory name) external view returns (address) {
		return addresses[keccak256(bytes(name))];
	}
}
          

Contract ABI

[{"type":"event","name":"AdminChanged","inputs":[{"type":"address","name":"previousAdmin","internalType":"address","indexed":false},{"type":"address","name":"newAdmin","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"BeaconUpgraded","inputs":[{"type":"address","name":"beacon","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Initialized","inputs":[{"type":"uint8","name":"version","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"event","name":"RoleAdminChanged","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"previousAdminRole","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"newAdminRole","internalType":"bytes32","indexed":true}],"anonymous":false},{"type":"event","name":"RoleGranted","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RoleRevoked","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Upgraded","inputs":[{"type":"address","name":"implementation","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"WalletTopped","inputs":[{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false},{"type":"address","name":"whitelistedRoot","internalType":"address","indexed":false},{"type":"address","name":"relayerOrWhitelisted","internalType":"address","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"DEFAULT_ADMIN_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"RELAYER_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"canTop","inputs":[{"type":"address","name":"_user","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"currentDay","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint64","name":"","internalType":"uint64"}],"name":"dailyNewWalletsCount","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint64","name":"","internalType":"uint64"}],"name":"gasPrice","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"gasRefund","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"gasTopping","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IIdentityV2"}],"name":"getIdentity","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getRoleAdmin","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getToppingAmount","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"goodDollar_unused","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"grantRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_ns","internalType":"contract NameService"},{"type":"uint64","name":"_gasPrice","internalType":"uint64"},{"type":"address","name":"relayer","internalType":"address"},{"type":"address","name":"owner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint64","name":"","internalType":"uint64"}],"name":"maxDailyNewWallets","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint32","name":"","internalType":"uint32"}],"name":"maxDailyToppings","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint32","name":"","internalType":"uint32"}],"name":"maxPerWeekMultiplier","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint32","name":"","internalType":"uint32"}],"name":"maxSwapAmount","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract NameService"}],"name":"nameService","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"notFirstTime","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"onTokenTransfer","inputs":[{"type":"address","name":"_from","internalType":"address payable"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"bytes","name":"data","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"perDayRoughLimit","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"proxiableUUID","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"revokeRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setGasPrice","inputs":[{"type":"uint64","name":"_price","internalType":"uint64"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setGasTopping","inputs":[{"type":"uint256","name":"_gasUnits","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"startTime","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"interfaceId","internalType":"bytes4"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"topWallet","inputs":[{"type":"address","name":"_user","internalType":"address payable"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"toppings","inputs":[{"type":"uint256","name":"","internalType":"uint256"},{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"upgrade","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"upgradeTo","inputs":[{"type":"address","name":"newImplementation","internalType":"address"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"upgradeToAndCall","inputs":[{"type":"address","name":"newImplementation","internalType":"address"},{"type":"bytes","name":"data","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint32","name":"","internalType":"uint32"}],"name":"version","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint128","name":"lastDayTopped","internalType":"uint128"},{"type":"uint32","name":"dailyToppingCount","internalType":"uint32"}],"name":"wallets","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"receive","stateMutability":"payable"}]
              

Contract Creation Code

Verify & Publish
0x60a06040523060805234801561001457600080fd5b50608051612c5561004c600039600081816107fd0152818161083d01528181610f6801528181610fa801526110200152612c556000f3fe6080604052600436106101ae5760003560e01c806301ffc9a7146101ba57806315126799146101ef5780631ece9b1214610212578063248a9ca3146102405780632f2ff15d146102605780632f5a3d151461028257806336568abe146102985780633659cfe6146102b857806336afc6fa146102d85780633771dcf8146102ed5780633e6326fc1461030d5780634f1ef2861461032e57806352d1902d1461034157806354fd4d50146103565780635b61e2c1146103905780635bc758e2146103d05780635c9302c9146103e65780636294c311146103fc5780636bdd72421461041c57806370c635911461043c57806378e979251461045c5780637befab101461047257806389b08f111461049757806391d1485414610501578063926d7d7f1461052157806393a08de414610543578063a217fddf14610561578063a4c0ed3614610576578063aa31e45914610596578063c573cb40146105c7578063c5da1033146105e8578063cce987d414610621578063d547741f14610646578063d55ec69714610666578063e97eefd21461067b578063f84b40f51461069b578063fe173b97146106b157600080fd5b366101b557005b600080fd5b3480156101c657600080fd5b506101da6101d53660046124ab565b6106d9565b60405190151581526020015b60405180910390f35b3480156101fb57600080fd5b50610204610710565b6040519081526020016101e6565b34801561021e57600080fd5b5061010554610233906001600160a01b031681565b6040516101e691906124d5565b34801561024c57600080fd5b5061020461025b3660046124e9565b61073a565b34801561026c57600080fd5b5061028061027b366004612517565b61074f565b005b34801561028e57600080fd5b5061020460fc5481565b3480156102a457600080fd5b506102806102b3366004612517565b610770565b3480156102c457600080fd5b506102806102d3366004612547565b6107f3565b3480156102e457600080fd5b506102336108bb565b3480156102f957600080fd5b50610280610308366004612547565b610942565b34801561031957600080fd5b5061010054610233906001600160a01b031681565b61028061033c3660046125aa565b610f5e565b34801561034d57600080fd5b50610204611013565b34801561036257600080fd5b506101065461037b90600160401b900463ffffffff1681565b60405163ffffffff90911681526020016101e6565b34801561039c57600080fd5b50610105546103b890600160a01b90046001600160401b031681565b6040516001600160401b0390911681526020016101e6565b3480156103dc57600080fd5b5061020460fd5481565b3480156103f257600080fd5b5061020460ff5481565b34801561040857600080fd5b5061028061041736600461266d565b6110c1565b34801561042857600080fd5b506102806104373660046126c7565b6112a3565b34801561044857600080fd5b506102806104573660046124e9565b6112dc565b34801561046857600080fd5b5061020460fe5481565b34801561047e57600080fd5b506101045461037b90600160601b900463ffffffff1681565b3480156104a357600080fd5b506104dd6104b2366004612547565b610103602052600090815260409020546001600160801b03811690600160801b900463ffffffff1682565b604080516001600160801b03909316835263ffffffff9091166020830152016101e6565b34801561050d57600080fd5b506101da61051c366004612517565b6112fe565b34801561052d57600080fd5b50610204600080516020612bd983398151915281565b34801561054f57600080fd5b506101045461037b9063ffffffff1681565b34801561056d57600080fd5b50610204600081565b34801561058257600080fd5b506101da6105913660046126e2565b611329565b3480156105a257600080fd5b506101da6105b1366004612547565b6101026020526000908152604090205460ff1681565b3480156105d357600080fd5b50610106546103b8906001600160401b031681565b3480156105f457600080fd5b50610204610603366004612517565b61010160209081526000928352604080842090915290825290205481565b34801561062d57600080fd5b506101045461037b90600160801b900463ffffffff1681565b34801561065257600080fd5b50610280610661366004612517565b611561565b34801561067257600080fd5b5061028061157d565b34801561068757600080fd5b506101da610696366004612547565b611674565b3480156106a757600080fd5b5061020460fb5481565b3480156106bd57600080fd5b50610104546103b890600160201b90046001600160401b031681565b60006001600160e01b03198216637965db0b60e01b148061070a57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6101045460fc5460009161073591600160201b9091046001600160401b031690612780565b905090565b600090815260c9602052604090206001015490565b6107588261073a565b610761816119e7565b61076b83836119f1565b505050565b6001600160a01b03811633146107e55760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b6107ef8282611a77565b5050565b6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016300361083b5760405162461bcd60e51b81526004016107dc9061279f565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661086d611ade565b6001600160a01b0316146108935760405162461bcd60e51b81526004016107dc906127d9565b61089c81611afa565b604080516000808252602082019092526108b891839190611b05565b50565b6101005460405163bf40fac160e01b81526020600482015260086024820152674944454e5449545960c01b60448201526000916001600160a01b03169063bf40fac190606401602060405180830381865afa15801561091e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107359190612813565b60005a90508160006109526108bb565b6001600160a01b0316632d0e9b46836040518263ffffffff1660e01b815260040161097d91906124d5565b602060405180830381865afa15801561099a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109be9190612813565b90506001600160a01b038116156109d557806109d7565b815b60ff549092506109e5611c70565b8060ff5414610a005761010680546001600160401b03191690555b60ff546001600160a01b038416600090815261010360205260409020546001600160801b039081169116141580610a655750610104546001600160a01b0384166000908152610103602052604090205463ffffffff918216600160801b909104909116105b610aa65760405162461bcd60e51b81526020600482015260126024820152716d6178206461696c7920746f7070696e677360701b60448201526064016107dc565b6001600160a01b0383166000908152610102602052604090205460ff16158015610ae9575061010554610106546001600160401b03600160a01b90920482169116105b80610afc57506001600160a01b03821615155b610b575760405162461bcd60e51b815260206004820152602660248201527f55736572206e6f742077686974656c6973746564206f72206e6f742066697273604482015265742074696d6560d01b60648201526084016107dc565b6000600760ff54610b689190612846565b6001600160a01b0385166000908152610103602052604081205460ff549293509091610b9d916001600160801b03169061285a565b905060078111610bad5780610bb0565b60075b9050818111610bbf5780610bca565b610bca82600161286d565b9050600081610bda84600161286d565b610be4919061285a565b90505b828111610c5d576001600160a01b0386166000908152610103602052604081206001018260078110610c1b57610c1b612880565b600291828204019190066010026101000a8154816001600160801b0302191690836001600160801b031602179055508080610c5590612896565b915050610be7565b506000805b838111610cd4576001600160a01b0387166000908152610103602052604090206001018160078110610c9657610c96612880565b600291828204019190066010029054906101000a90046001600160801b031682610cc091906128af565b915080610ccc81612896565b915050610c62565b506101045460fb54600160601b820463ffffffff1691610d0591600160201b9091046001600160401b031690612780565b610d0f9190612780565b816001600160801b031610610d835760405162461bcd60e51b815260206004820152603460248201527f557365722077616c6c657420686173206265656e20746f7070656420746f6f206044820152736d616e792074696d65732074686973207765656b60601b60648201526084016107dc565b876000610d8e6108bb565b6001600160a01b0316632d0e9b46836040518263ffffffff1660e01b8152600401610db991906124d5565b602060405180830381865afa158015610dd6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dfa9190612813565b6001600160a01b0316141580610e8d57506000610e156108bb565b6001600160a01b0316632d0e9b46336040518263ffffffff1660e01b8152600401610e4091906124d5565b602060405180830381865afa158015610e5d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e819190612813565b6001600160a01b031614155b80610eab5750610eab600080516020612bd9833981519152336112fe565b610ee85760405162461bcd60e51b815260206004820152600e60248201526d1b9bdd08185d5d1a1bdc9a5e995960921b60448201526064016107dc565b610ef189611c91565b505050505050505a610f03908261285a565b610f0f9061a41061286d565b6101045490915033906108fc90610f3690600160201b90046001600160401b031684612780565b6040518115909202916000818181858888f1935050505015801561076b573d6000803e3d6000fd5b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163003610fa65760405162461bcd60e51b81526004016107dc9061279f565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610fd8611ade565b6001600160a01b031614610ffe5760405162461bcd60e51b81526004016107dc906127d9565b61100782611afa565b6107ef82826001611b05565b6000306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146110ae5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c6044820152771b1959081d1a1c9bdd59da0819195b1959d85d1958d85b1b60421b60648201526084016107dc565b50600080516020612bb983398151915290565b600054610100900460ff16158080156110e15750600054600160ff909116105b8061110257506110f030611fe5565b158015611102575060005460ff166001145b6111655760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016107dc565b6000805460ff191660011790558015611188576000805461ff0019166101001790555b611190611ff4565b61119b60008361205f565b6001600160a01b038316156111c2576111c2600080516020612bd98339815191528461205f565b6101048054600160201b600160601b031916600160201b6001600160401b038716021790556111f3620927c06112dc565b61010480544260fe5561010080546001600160a01b0319166001600160a01b03891617905563ffffffff600160601b03600160a01b03191660036501f40000000160611b011790556101058054600160a01b600160e01b03191661027160a31b179055801561129c576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050565b60006112ae816119e7565b5061010480546001600160401b03909216600160201b02600160201b600160601b0319909216919091179055565b60006112e7816119e7565b60fc8290556112f7826002612780565b60fb555050565b600091825260c9602090815260408084206001600160a01b0393909316845291905290205460ff1690565b61010454600090600160801b900463ffffffff168411156113775760405162461bcd60e51b8152602060048201526008602482015267736c69707061676560c01b60448201526064016107dc565b600061138583850185612547565b604080516002808252606082018352929350839260009260208301908036833701905050905033816000815181106113bf576113bf612880565b60200260200101906001600160a01b031690816001600160a01b031681525050816001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa15801561141d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114419190612813565b8160018151811061145457611454612880565b6001600160a01b03928316602091820292909201015260405163095ea7b360e01b815290841660048201526000196024820152339063095ea7b3906044016020604051808303816000875af11580156114b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114d591906128d6565b506040516318cbafe560e01b81526001600160a01b038316906318cbafe59061150b908a9060009086908e9042906004016128f8565b6000604051808303816000875af115801561152a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526115529190810190612969565b50600198975050505050505050565b61156a8261073a565b611573816119e7565b61076b8383611a77565b61010654600160401b900463ffffffff16156115ce5760405162461bcd60e51b815260206004820152601060248201526f185b1c9958591e481d5c19dc9859195960821b60448201526064016107dc565b61010554600160a01b90046001600160401b0316600003611605576101058054600160a01b600160e01b03191661027160a31b1790555b6101068054600160401b900463ffffffff1690600861162383612a0e565b91906101000a81548163ffffffff021916908363ffffffff1602179055505061167261010460049054906101000a90046001600160401b03166001600160401b031660fc546104579190612a31565b565b6000816001600160a01b031631611689610710565b101561169757506000919050565b60006116a16108bb565b6001600160a01b0316632d0e9b46846040518263ffffffff1660e01b81526004016116cc91906124d5565b602060405180830381865afa1580156116e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061170d9190612813565b90506001600160a01b038116156117245780611726565b825b925060006201518060fe544261173c919061285a565b6117469190612a31565b6001600160a01b03851660009081526101036020526040812054919250906001600160801b0380841691161415806117a557506001600160a01b038516600090815261010360205260409020546003600160801b90910463ffffffff16105b801561180257506001600160a01b0385166000908152610102602052604090205460ff161580156117ef575061010554610106546001600160401b03600160a01b90920482169116105b8061180257506001600160a01b03831615155b6001600160a01b03861660009081526101036020526040808220815160e0810192839052939450919291600101906007908285855b82829054906101000a90046001600160801b03166001600160801b031681526020019060100190602082600f0104928301926001038202915080841161183757905050505050509050600060078461188f9190612846565b6001600160a01b03881660009081526101036020526040812054919250906118c0906001600160801b03168661285a565b9050600781116118d057806118d3565b60075b90508181116118e257806118ed565b6118ed82600161286d565b90506000816118fd84600161286d565b611907919061285a565b90505b82811161194a57600084826007811061192557611925612880565b6001600160801b0390921660209290920201528061194281612896565b91505061190a565b506000805b83811161198b5784816007811061196857611968612880565b602002015161197790836128af565b91508061198381612896565b91505061194f565b508480156119da57506101045460fb54600160601b820463ffffffff16916119c491600160201b9091046001600160401b031690612780565b6119ce9190612780565b816001600160801b0316105b9998505050505050505050565b6108b88133612069565b6119fb82826112fe565b6107ef57600082815260c9602090815260408083206001600160a01b03851684529091529020805460ff19166001179055611a333390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b611a8182826112fe565b156107ef57600082815260c9602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600080516020612bb9833981519152546001600160a01b031690565b60006107ef816119e7565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615611b385761076b836120c2565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611b92575060408051601f3d908101601f19168201909252611b8f91810190612a45565b60015b611bf55760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b60648201526084016107dc565b600080516020612bb98339815191528114611c645760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b60648201526084016107dc565b5061076b83838361215c565b6201518060fe5442611c82919061285a565b611c8c9190612a31565b60ff55565b806000611c9c6108bb565b6001600160a01b0316632d0e9b46846040518263ffffffff1660e01b8152600401611cc791906124d5565b602060405180830381865afa158015611ce4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d089190612813565b90506001600160a01b03811615611d1f5780611d21565b825b9250826001600160a01b031631611d36610710565b11611d4057600080fd5b6000836001600160a01b031631611d55610710565b611d5f919061285a565b90506000600760ff54611d729190612846565b60ff546001600160a01b038716600090815261010360205260409020549192506001600160801b03908116911603611e01576001600160a01b038516600090815261010360205260409020805460019190601090611dde908490600160801b900463ffffffff16612a5e565b92506101000a81548163ffffffff021916908363ffffffff160217905550611e2f565b6001600160a01b038516600090815261010360205260409020805463ffffffff60801b1916600160801b1790555b60ff546001600160a01b03861660009081526101036020526040902080546001600160801b0319166001600160801b0390921691909117815582906001018260078110611e7e57611e7e612880565b600291828204019190066010028282829054906101000a90046001600160801b0316611eaa91906128af565b82546001600160801b039182166101009390930a9283029190920219909116179055506001600160a01b0385166000908152610102602052604090205460ff16158015611efe57506001600160a01b038316155b15611f435761010680546001600160401b0316906000611f1d83612a7b565b91906101000a8154816001600160401b0302191690836001600160401b03160217905550505b6001600160a01b0380861660009081526101026020526040808220805460ff19166001179055519186169184156108fc0291859190818181858888f19350505050158015611f95573d6000803e3d6000fd5b50604080518381526001600160a01b0385811660208301523392908716917f7872034fbcc87890e73d66eac55389e0ffdba157b89a73bd2011157ebac1d66e910160405180910390a35050505050565b6001600160a01b03163b151590565b600054610100900460ff166116725760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016107dc565b6107ef82826119f1565b61207382826112fe565b6107ef5761208081612187565b61208b836020612199565b60405160200161209c929190612ac3565b60408051601f198184030181529082905262461bcd60e51b82526107dc91600401612b32565b6120cb81611fe5565b61212d5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016107dc565b600080516020612bb983398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6121658361233b565b6000825111806121725750805b1561076b57612181838361237b565b50505050565b606061070a6001600160a01b03831660145b606060006121a8836002612780565b6121b390600261286d565b6001600160401b038111156121ca576121ca612564565b6040519080825280601f01601f1916602001820160405280156121f4576020820181803683370190505b509050600360fc1b8160008151811061220f5761220f612880565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061223e5761223e612880565b60200101906001600160f81b031916908160001a9053506000612262846002612780565b61226d90600161286d565b90505b60018111156122e5576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106122a1576122a1612880565b1a60f81b8282815181106122b7576122b7612880565b60200101906001600160f81b031916908160001a90535060049490941c936122de81612b65565b9050612270565b5083156123345760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016107dc565b9392505050565b612344816120c2565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606061238683611fe5565b6123e15760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016107dc565b600080846001600160a01b0316846040516123fc9190612b7c565b600060405180830381855af49150503d8060008114612437576040519150601f19603f3d011682016040523d82523d6000602084013e61243c565b606091505b50915091506124648282604051806060016040528060278152602001612bf96027913961246d565b95945050505050565b6060831561247c575081612334565b61233483838151156124915781518083602001fd5b8060405162461bcd60e51b81526004016107dc9190612b32565b6000602082840312156124bd57600080fd5b81356001600160e01b03198116811461233457600080fd5b6001600160a01b0391909116815260200190565b6000602082840312156124fb57600080fd5b5035919050565b6001600160a01b03811681146108b857600080fd5b6000806040838503121561252a57600080fd5b82359150602083013561253c81612502565b809150509250929050565b60006020828403121561255957600080fd5b813561233481612502565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b03811182821017156125a2576125a2612564565b604052919050565b600080604083850312156125bd57600080fd5b82356125c881612502565b91506020838101356001600160401b03808211156125e557600080fd5b818601915086601f8301126125f957600080fd5b81358181111561260b5761260b612564565b61261d601f8201601f1916850161257a565b9150808252878482850101111561263357600080fd5b80848401858401376000848284010152508093505050509250929050565b80356001600160401b038116811461266857600080fd5b919050565b6000806000806080858703121561268357600080fd5b843561268e81612502565b935061269c60208601612651565b925060408501356126ac81612502565b915060608501356126bc81612502565b939692955090935050565b6000602082840312156126d957600080fd5b61233482612651565b600080600080606085870312156126f857600080fd5b843561270381612502565b93506020850135925060408501356001600160401b038082111561272657600080fd5b818701915087601f83011261273a57600080fd5b81358181111561274957600080fd5b88602082850101111561275b57600080fd5b95989497505060200194505050565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561279a5761279a61276a565b500290565b6020808252602c90820152600080516020612b9983398151915260408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c90820152600080516020612b9983398151915260408201526b6163746976652070726f787960a01b606082015260800190565b60006020828403121561282557600080fd5b815161233481612502565b634e487b7160e01b600052601260045260246000fd5b60008261285557612855612830565b500690565b8181038181111561070a5761070a61276a565b8082018082111561070a5761070a61276a565b634e487b7160e01b600052603260045260246000fd5b6000600182016128a8576128a861276a565b5060010190565b6001600160801b038181168382160190808211156128cf576128cf61276a565b5092915050565b6000602082840312156128e857600080fd5b8151801515811461233457600080fd5b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156129485784516001600160a01b031683529383019391830191600101612923565b50506001600160a01b03969096166060850152505050608001529392505050565b6000602080838503121561297c57600080fd5b82516001600160401b038082111561299357600080fd5b818501915085601f8301126129a757600080fd5b8151818111156129b9576129b9612564565b8060051b91506129ca84830161257a565b81815291830184019184810190888411156129e457600080fd5b938501935b83851015612a02578451825293850193908501906129e9565b98975050505050505050565b600063ffffffff808316818103612a2757612a2761276a565b6001019392505050565b600082612a4057612a40612830565b500490565b600060208284031215612a5757600080fd5b5051919050565b63ffffffff8181168382160190808211156128cf576128cf61276a565b60006001600160401b038281166002600160401b03198101612a2757612a2761276a565b60005b83811015612aba578181015183820152602001612aa2565b50506000910152565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260008351612af5816017850160208801612a9f565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351612b26816028840160208801612a9f565b01602801949350505050565b6020815260008251806020840152612b51816040850160208701612a9f565b601f01601f19169190910160400192915050565b600081612b7457612b7461276a565b506000190190565b60008251612b8e818460208701612a9f565b919091019291505056fe46756e6374696f6e206d7573742062652063616c6c6564207468726f75676820360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc802cf867c2da464d4ff0ebc4dfcccdfbd65d75a8bc1c273fb02e80bf3446b516416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a86086f205bf34112d77a2562bcef0fe49e40c66b29e087d8524b48bbcb85a5164736f6c63430008100033

Deployed ByteCode

0x6080604052600436106101ae5760003560e01c806301ffc9a7146101ba57806315126799146101ef5780631ece9b1214610212578063248a9ca3146102405780632f2ff15d146102605780632f5a3d151461028257806336568abe146102985780633659cfe6146102b857806336afc6fa146102d85780633771dcf8146102ed5780633e6326fc1461030d5780634f1ef2861461032e57806352d1902d1461034157806354fd4d50146103565780635b61e2c1146103905780635bc758e2146103d05780635c9302c9146103e65780636294c311146103fc5780636bdd72421461041c57806370c635911461043c57806378e979251461045c5780637befab101461047257806389b08f111461049757806391d1485414610501578063926d7d7f1461052157806393a08de414610543578063a217fddf14610561578063a4c0ed3614610576578063aa31e45914610596578063c573cb40146105c7578063c5da1033146105e8578063cce987d414610621578063d547741f14610646578063d55ec69714610666578063e97eefd21461067b578063f84b40f51461069b578063fe173b97146106b157600080fd5b366101b557005b600080fd5b3480156101c657600080fd5b506101da6101d53660046124ab565b6106d9565b60405190151581526020015b60405180910390f35b3480156101fb57600080fd5b50610204610710565b6040519081526020016101e6565b34801561021e57600080fd5b5061010554610233906001600160a01b031681565b6040516101e691906124d5565b34801561024c57600080fd5b5061020461025b3660046124e9565b61073a565b34801561026c57600080fd5b5061028061027b366004612517565b61074f565b005b34801561028e57600080fd5b5061020460fc5481565b3480156102a457600080fd5b506102806102b3366004612517565b610770565b3480156102c457600080fd5b506102806102d3366004612547565b6107f3565b3480156102e457600080fd5b506102336108bb565b3480156102f957600080fd5b50610280610308366004612547565b610942565b34801561031957600080fd5b5061010054610233906001600160a01b031681565b61028061033c3660046125aa565b610f5e565b34801561034d57600080fd5b50610204611013565b34801561036257600080fd5b506101065461037b90600160401b900463ffffffff1681565b60405163ffffffff90911681526020016101e6565b34801561039c57600080fd5b50610105546103b890600160a01b90046001600160401b031681565b6040516001600160401b0390911681526020016101e6565b3480156103dc57600080fd5b5061020460fd5481565b3480156103f257600080fd5b5061020460ff5481565b34801561040857600080fd5b5061028061041736600461266d565b6110c1565b34801561042857600080fd5b506102806104373660046126c7565b6112a3565b34801561044857600080fd5b506102806104573660046124e9565b6112dc565b34801561046857600080fd5b5061020460fe5481565b34801561047e57600080fd5b506101045461037b90600160601b900463ffffffff1681565b3480156104a357600080fd5b506104dd6104b2366004612547565b610103602052600090815260409020546001600160801b03811690600160801b900463ffffffff1682565b604080516001600160801b03909316835263ffffffff9091166020830152016101e6565b34801561050d57600080fd5b506101da61051c366004612517565b6112fe565b34801561052d57600080fd5b50610204600080516020612bd983398151915281565b34801561054f57600080fd5b506101045461037b9063ffffffff1681565b34801561056d57600080fd5b50610204600081565b34801561058257600080fd5b506101da6105913660046126e2565b611329565b3480156105a257600080fd5b506101da6105b1366004612547565b6101026020526000908152604090205460ff1681565b3480156105d357600080fd5b50610106546103b8906001600160401b031681565b3480156105f457600080fd5b50610204610603366004612517565b61010160209081526000928352604080842090915290825290205481565b34801561062d57600080fd5b506101045461037b90600160801b900463ffffffff1681565b34801561065257600080fd5b50610280610661366004612517565b611561565b34801561067257600080fd5b5061028061157d565b34801561068757600080fd5b506101da610696366004612547565b611674565b3480156106a757600080fd5b5061020460fb5481565b3480156106bd57600080fd5b50610104546103b890600160201b90046001600160401b031681565b60006001600160e01b03198216637965db0b60e01b148061070a57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6101045460fc5460009161073591600160201b9091046001600160401b031690612780565b905090565b600090815260c9602052604090206001015490565b6107588261073a565b610761816119e7565b61076b83836119f1565b505050565b6001600160a01b03811633146107e55760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b6107ef8282611a77565b5050565b6001600160a01b037f0000000000000000000000004c0cae94eda1658e7bd359d496e18619523b896116300361083b5760405162461bcd60e51b81526004016107dc9061279f565b7f0000000000000000000000004c0cae94eda1658e7bd359d496e18619523b89616001600160a01b031661086d611ade565b6001600160a01b0316146108935760405162461bcd60e51b81526004016107dc906127d9565b61089c81611afa565b604080516000808252602082019092526108b891839190611b05565b50565b6101005460405163bf40fac160e01b81526020600482015260086024820152674944454e5449545960c01b60448201526000916001600160a01b03169063bf40fac190606401602060405180830381865afa15801561091e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107359190612813565b60005a90508160006109526108bb565b6001600160a01b0316632d0e9b46836040518263ffffffff1660e01b815260040161097d91906124d5565b602060405180830381865afa15801561099a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109be9190612813565b90506001600160a01b038116156109d557806109d7565b815b60ff549092506109e5611c70565b8060ff5414610a005761010680546001600160401b03191690555b60ff546001600160a01b038416600090815261010360205260409020546001600160801b039081169116141580610a655750610104546001600160a01b0384166000908152610103602052604090205463ffffffff918216600160801b909104909116105b610aa65760405162461bcd60e51b81526020600482015260126024820152716d6178206461696c7920746f7070696e677360701b60448201526064016107dc565b6001600160a01b0383166000908152610102602052604090205460ff16158015610ae9575061010554610106546001600160401b03600160a01b90920482169116105b80610afc57506001600160a01b03821615155b610b575760405162461bcd60e51b815260206004820152602660248201527f55736572206e6f742077686974656c6973746564206f72206e6f742066697273604482015265742074696d6560d01b60648201526084016107dc565b6000600760ff54610b689190612846565b6001600160a01b0385166000908152610103602052604081205460ff549293509091610b9d916001600160801b03169061285a565b905060078111610bad5780610bb0565b60075b9050818111610bbf5780610bca565b610bca82600161286d565b9050600081610bda84600161286d565b610be4919061285a565b90505b828111610c5d576001600160a01b0386166000908152610103602052604081206001018260078110610c1b57610c1b612880565b600291828204019190066010026101000a8154816001600160801b0302191690836001600160801b031602179055508080610c5590612896565b915050610be7565b506000805b838111610cd4576001600160a01b0387166000908152610103602052604090206001018160078110610c9657610c96612880565b600291828204019190066010029054906101000a90046001600160801b031682610cc091906128af565b915080610ccc81612896565b915050610c62565b506101045460fb54600160601b820463ffffffff1691610d0591600160201b9091046001600160401b031690612780565b610d0f9190612780565b816001600160801b031610610d835760405162461bcd60e51b815260206004820152603460248201527f557365722077616c6c657420686173206265656e20746f7070656420746f6f206044820152736d616e792074696d65732074686973207765656b60601b60648201526084016107dc565b876000610d8e6108bb565b6001600160a01b0316632d0e9b46836040518263ffffffff1660e01b8152600401610db991906124d5565b602060405180830381865afa158015610dd6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dfa9190612813565b6001600160a01b0316141580610e8d57506000610e156108bb565b6001600160a01b0316632d0e9b46336040518263ffffffff1660e01b8152600401610e4091906124d5565b602060405180830381865afa158015610e5d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e819190612813565b6001600160a01b031614155b80610eab5750610eab600080516020612bd9833981519152336112fe565b610ee85760405162461bcd60e51b815260206004820152600e60248201526d1b9bdd08185d5d1a1bdc9a5e995960921b60448201526064016107dc565b610ef189611c91565b505050505050505a610f03908261285a565b610f0f9061a41061286d565b6101045490915033906108fc90610f3690600160201b90046001600160401b031684612780565b6040518115909202916000818181858888f1935050505015801561076b573d6000803e3d6000fd5b6001600160a01b037f0000000000000000000000004c0cae94eda1658e7bd359d496e18619523b8961163003610fa65760405162461bcd60e51b81526004016107dc9061279f565b7f0000000000000000000000004c0cae94eda1658e7bd359d496e18619523b89616001600160a01b0316610fd8611ade565b6001600160a01b031614610ffe5760405162461bcd60e51b81526004016107dc906127d9565b61100782611afa565b6107ef82826001611b05565b6000306001600160a01b037f0000000000000000000000004c0cae94eda1658e7bd359d496e18619523b896116146110ae5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c6044820152771b1959081d1a1c9bdd59da0819195b1959d85d1958d85b1b60421b60648201526084016107dc565b50600080516020612bb983398151915290565b600054610100900460ff16158080156110e15750600054600160ff909116105b8061110257506110f030611fe5565b158015611102575060005460ff166001145b6111655760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016107dc565b6000805460ff191660011790558015611188576000805461ff0019166101001790555b611190611ff4565b61119b60008361205f565b6001600160a01b038316156111c2576111c2600080516020612bd98339815191528461205f565b6101048054600160201b600160601b031916600160201b6001600160401b038716021790556111f3620927c06112dc565b61010480544260fe5561010080546001600160a01b0319166001600160a01b03891617905563ffffffff600160601b03600160a01b03191660036501f40000000160611b011790556101058054600160a01b600160e01b03191661027160a31b179055801561129c576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050565b60006112ae816119e7565b5061010480546001600160401b03909216600160201b02600160201b600160601b0319909216919091179055565b60006112e7816119e7565b60fc8290556112f7826002612780565b60fb555050565b600091825260c9602090815260408084206001600160a01b0393909316845291905290205460ff1690565b61010454600090600160801b900463ffffffff168411156113775760405162461bcd60e51b8152602060048201526008602482015267736c69707061676560c01b60448201526064016107dc565b600061138583850185612547565b604080516002808252606082018352929350839260009260208301908036833701905050905033816000815181106113bf576113bf612880565b60200260200101906001600160a01b031690816001600160a01b031681525050816001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa15801561141d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114419190612813565b8160018151811061145457611454612880565b6001600160a01b03928316602091820292909201015260405163095ea7b360e01b815290841660048201526000196024820152339063095ea7b3906044016020604051808303816000875af11580156114b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114d591906128d6565b506040516318cbafe560e01b81526001600160a01b038316906318cbafe59061150b908a9060009086908e9042906004016128f8565b6000604051808303816000875af115801561152a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526115529190810190612969565b50600198975050505050505050565b61156a8261073a565b611573816119e7565b61076b8383611a77565b61010654600160401b900463ffffffff16156115ce5760405162461bcd60e51b815260206004820152601060248201526f185b1c9958591e481d5c19dc9859195960821b60448201526064016107dc565b61010554600160a01b90046001600160401b0316600003611605576101058054600160a01b600160e01b03191661027160a31b1790555b6101068054600160401b900463ffffffff1690600861162383612a0e565b91906101000a81548163ffffffff021916908363ffffffff1602179055505061167261010460049054906101000a90046001600160401b03166001600160401b031660fc546104579190612a31565b565b6000816001600160a01b031631611689610710565b101561169757506000919050565b60006116a16108bb565b6001600160a01b0316632d0e9b46846040518263ffffffff1660e01b81526004016116cc91906124d5565b602060405180830381865afa1580156116e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061170d9190612813565b90506001600160a01b038116156117245780611726565b825b925060006201518060fe544261173c919061285a565b6117469190612a31565b6001600160a01b03851660009081526101036020526040812054919250906001600160801b0380841691161415806117a557506001600160a01b038516600090815261010360205260409020546003600160801b90910463ffffffff16105b801561180257506001600160a01b0385166000908152610102602052604090205460ff161580156117ef575061010554610106546001600160401b03600160a01b90920482169116105b8061180257506001600160a01b03831615155b6001600160a01b03861660009081526101036020526040808220815160e0810192839052939450919291600101906007908285855b82829054906101000a90046001600160801b03166001600160801b031681526020019060100190602082600f0104928301926001038202915080841161183757905050505050509050600060078461188f9190612846565b6001600160a01b03881660009081526101036020526040812054919250906118c0906001600160801b03168661285a565b9050600781116118d057806118d3565b60075b90508181116118e257806118ed565b6118ed82600161286d565b90506000816118fd84600161286d565b611907919061285a565b90505b82811161194a57600084826007811061192557611925612880565b6001600160801b0390921660209290920201528061194281612896565b91505061190a565b506000805b83811161198b5784816007811061196857611968612880565b602002015161197790836128af565b91508061198381612896565b91505061194f565b508480156119da57506101045460fb54600160601b820463ffffffff16916119c491600160201b9091046001600160401b031690612780565b6119ce9190612780565b816001600160801b0316105b9998505050505050505050565b6108b88133612069565b6119fb82826112fe565b6107ef57600082815260c9602090815260408083206001600160a01b03851684529091529020805460ff19166001179055611a333390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b611a8182826112fe565b156107ef57600082815260c9602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600080516020612bb9833981519152546001600160a01b031690565b60006107ef816119e7565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615611b385761076b836120c2565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611b92575060408051601f3d908101601f19168201909252611b8f91810190612a45565b60015b611bf55760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b60648201526084016107dc565b600080516020612bb98339815191528114611c645760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b60648201526084016107dc565b5061076b83838361215c565b6201518060fe5442611c82919061285a565b611c8c9190612a31565b60ff55565b806000611c9c6108bb565b6001600160a01b0316632d0e9b46846040518263ffffffff1660e01b8152600401611cc791906124d5565b602060405180830381865afa158015611ce4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d089190612813565b90506001600160a01b03811615611d1f5780611d21565b825b9250826001600160a01b031631611d36610710565b11611d4057600080fd5b6000836001600160a01b031631611d55610710565b611d5f919061285a565b90506000600760ff54611d729190612846565b60ff546001600160a01b038716600090815261010360205260409020549192506001600160801b03908116911603611e01576001600160a01b038516600090815261010360205260409020805460019190601090611dde908490600160801b900463ffffffff16612a5e565b92506101000a81548163ffffffff021916908363ffffffff160217905550611e2f565b6001600160a01b038516600090815261010360205260409020805463ffffffff60801b1916600160801b1790555b60ff546001600160a01b03861660009081526101036020526040902080546001600160801b0319166001600160801b0390921691909117815582906001018260078110611e7e57611e7e612880565b600291828204019190066010028282829054906101000a90046001600160801b0316611eaa91906128af565b82546001600160801b039182166101009390930a9283029190920219909116179055506001600160a01b0385166000908152610102602052604090205460ff16158015611efe57506001600160a01b038316155b15611f435761010680546001600160401b0316906000611f1d83612a7b565b91906101000a8154816001600160401b0302191690836001600160401b03160217905550505b6001600160a01b0380861660009081526101026020526040808220805460ff19166001179055519186169184156108fc0291859190818181858888f19350505050158015611f95573d6000803e3d6000fd5b50604080518381526001600160a01b0385811660208301523392908716917f7872034fbcc87890e73d66eac55389e0ffdba157b89a73bd2011157ebac1d66e910160405180910390a35050505050565b6001600160a01b03163b151590565b600054610100900460ff166116725760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016107dc565b6107ef82826119f1565b61207382826112fe565b6107ef5761208081612187565b61208b836020612199565b60405160200161209c929190612ac3565b60408051601f198184030181529082905262461bcd60e51b82526107dc91600401612b32565b6120cb81611fe5565b61212d5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016107dc565b600080516020612bb983398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6121658361233b565b6000825111806121725750805b1561076b57612181838361237b565b50505050565b606061070a6001600160a01b03831660145b606060006121a8836002612780565b6121b390600261286d565b6001600160401b038111156121ca576121ca612564565b6040519080825280601f01601f1916602001820160405280156121f4576020820181803683370190505b509050600360fc1b8160008151811061220f5761220f612880565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061223e5761223e612880565b60200101906001600160f81b031916908160001a9053506000612262846002612780565b61226d90600161286d565b90505b60018111156122e5576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106122a1576122a1612880565b1a60f81b8282815181106122b7576122b7612880565b60200101906001600160f81b031916908160001a90535060049490941c936122de81612b65565b9050612270565b5083156123345760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016107dc565b9392505050565b612344816120c2565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606061238683611fe5565b6123e15760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016107dc565b600080846001600160a01b0316846040516123fc9190612b7c565b600060405180830381855af49150503d8060008114612437576040519150601f19603f3d011682016040523d82523d6000602084013e61243c565b606091505b50915091506124648282604051806060016040528060278152602001612bf96027913961246d565b95945050505050565b6060831561247c575081612334565b61233483838151156124915781518083602001fd5b8060405162461bcd60e51b81526004016107dc9190612b32565b6000602082840312156124bd57600080fd5b81356001600160e01b03198116811461233457600080fd5b6001600160a01b0391909116815260200190565b6000602082840312156124fb57600080fd5b5035919050565b6001600160a01b03811681146108b857600080fd5b6000806040838503121561252a57600080fd5b82359150602083013561253c81612502565b809150509250929050565b60006020828403121561255957600080fd5b813561233481612502565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b03811182821017156125a2576125a2612564565b604052919050565b600080604083850312156125bd57600080fd5b82356125c881612502565b91506020838101356001600160401b03808211156125e557600080fd5b818601915086601f8301126125f957600080fd5b81358181111561260b5761260b612564565b61261d601f8201601f1916850161257a565b9150808252878482850101111561263357600080fd5b80848401858401376000848284010152508093505050509250929050565b80356001600160401b038116811461266857600080fd5b919050565b6000806000806080858703121561268357600080fd5b843561268e81612502565b935061269c60208601612651565b925060408501356126ac81612502565b915060608501356126bc81612502565b939692955090935050565b6000602082840312156126d957600080fd5b61233482612651565b600080600080606085870312156126f857600080fd5b843561270381612502565b93506020850135925060408501356001600160401b038082111561272657600080fd5b818701915087601f83011261273a57600080fd5b81358181111561274957600080fd5b88602082850101111561275b57600080fd5b95989497505060200194505050565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561279a5761279a61276a565b500290565b6020808252602c90820152600080516020612b9983398151915260408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c90820152600080516020612b9983398151915260408201526b6163746976652070726f787960a01b606082015260800190565b60006020828403121561282557600080fd5b815161233481612502565b634e487b7160e01b600052601260045260246000fd5b60008261285557612855612830565b500690565b8181038181111561070a5761070a61276a565b8082018082111561070a5761070a61276a565b634e487b7160e01b600052603260045260246000fd5b6000600182016128a8576128a861276a565b5060010190565b6001600160801b038181168382160190808211156128cf576128cf61276a565b5092915050565b6000602082840312156128e857600080fd5b8151801515811461233457600080fd5b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156129485784516001600160a01b031683529383019391830191600101612923565b50506001600160a01b03969096166060850152505050608001529392505050565b6000602080838503121561297c57600080fd5b82516001600160401b038082111561299357600080fd5b818501915085601f8301126129a757600080fd5b8151818111156129b9576129b9612564565b8060051b91506129ca84830161257a565b81815291830184019184810190888411156129e457600080fd5b938501935b83851015612a02578451825293850193908501906129e9565b98975050505050505050565b600063ffffffff808316818103612a2757612a2761276a565b6001019392505050565b600082612a4057612a40612830565b500490565b600060208284031215612a5757600080fd5b5051919050565b63ffffffff8181168382160190808211156128cf576128cf61276a565b60006001600160401b038281166002600160401b03198101612a2757612a2761276a565b60005b83811015612aba578181015183820152602001612aa2565b50506000910152565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260008351612af5816017850160208801612a9f565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351612b26816028840160208801612a9f565b01602801949350505050565b6020815260008251806020840152612b51816040850160208701612a9f565b601f01601f19169190910160400192915050565b600081612b7457612b7461276a565b506000190190565b60008251612b8e818460208701612a9f565b919091019291505056fe46756e6374696f6e206d7573742062652063616c6c6564207468726f75676820360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc802cf867c2da464d4ff0ebc4dfcccdfbd65d75a8bc1c273fb02e80bf3446b516416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a86086f205bf34112d77a2562bcef0fe49e40c66b29e087d8524b48bbcb85a5164736f6c63430008100033