ETH Price: $3,313.82 (+0.18%)
Gas: 12 Gwei

Contract

0xf4E0177905F70e3ddbe20723FD75d36Af15E718c
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Token Holdings

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Onboard Eth186782852023-11-29 15:53:35243 days ago1701273215IN
0xf4E01779...Af15E718c
150 ETH0.0172048542.49907294
Onboard Eth185911332023-11-17 10:54:47256 days ago1700218487IN
0xf4E01779...Af15E718c
135 ETH0.0092356322.81547305
Onboard Eth182610472023-10-02 6:26:59302 days ago1696228019IN
0xf4E01779...Af15E718c
60 ETH0.003102147.66324355
Onboard Eth180065202023-08-27 14:12:47338 days ago1693145567IN
0xf4E01779...Af15E718c
40 ETH0.0056671514
Onboard Eth179189362023-08-15 8:05:11350 days ago1692086711IN
0xf4E01779...Af15E718c
40 ETH0.0080965820
Onboard Eth178661292023-08-07 22:47:59357 days ago1691448479IN
0xf4E01779...Af15E718c
55 ETH0.0060719515
Onboard Eth178535502023-08-06 4:31:35359 days ago1691296295IN
0xf4E01779...Af15E718c
40 ETH0.0080162719
Onboard Eth177645392023-07-24 17:45:47371 days ago1690220747IN
0xf4E01779...Af15E718c
150 ETH0.018985945
Onboard Eth175722542023-06-27 17:45:23398 days ago1687887923IN
0xf4E01779...Af15E718c
50 ETH0.0068815417
Onboard Eth174847822023-06-15 10:46:35411 days ago1686825995IN
0xf4E01779...Af15E718c
100 ETH0.0068820917
Onboard Eth174491102023-06-10 10:14:11416 days ago1686392051IN
0xf4E01779...Af15E718c
50 ETH0.0072865618
Onboard Eth173437512023-05-26 14:06:11431 days ago1685109971IN
0xf4E01779...Af15E718c
60 ETH0.0157883339
Onboard Eth173307172023-05-24 18:05:59432 days ago1684951559IN
0xf4E01779...Af15E718c
60 ETH0.0329303481.34382843
Onboard Eth172899022023-05-19 0:09:23438 days ago1684454963IN
0xf4E01779...Af15E718c
60 ETH0.0157875539
Onboard Eth172199832023-05-09 2:39:47448 days ago1683599987IN
0xf4E01779...Af15E718c
10 ETH0.0299558674
Onboard Eth169204542023-03-27 18:18:35490 days ago1679941115IN
0xf4E01779...Af15E718c
20 ETH0.0163144340.30156104
Onboard Eth168406542023-03-16 13:18:47502 days ago1678972727IN
0xf4E01779...Af15E718c
50 ETH0.0093110623
Onboard Eth168344312023-03-15 16:18:23502 days ago1678897103IN
0xf4E01779...Af15E718c
60 ETH0.0250981562
Onboard167000532023-02-24 18:45:23521 days ago1677264323IN
0xf4E01779...Af15E718c
0 ETH0.0146690636
Onboard Eth166357322023-02-15 17:48:47530 days ago1676483327IN
0xf4E01779...Af15E718c
50 ETH0.0198366249
Onboard Eth165230602023-01-30 23:55:11546 days ago1675122911IN
0xf4E01779...Af15E718c
5 ETH0.0057890514.3
Onboard Eth164933282023-01-26 20:17:59550 days ago1674764279IN
0xf4E01779...Af15E718c
5 ETH0.0104017825.69554853
Onboard Eth164714182023-01-23 18:52:23553 days ago1674499943IN
0xf4E01779...Af15E718c
5 ETH0.0159684639.44690095
Onboard Eth163717722023-01-09 20:57:23567 days ago1673297843IN
0xf4E01779...Af15E718c
40 ETH0.0162532840.1528943
Onboard Eth161009582022-12-03 1:19:11605 days ago1670030351IN
0xf4E01779...Af15E718c
25 ETH0.0061521915.19777983
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
192633562024-02-19 17:48:11161 days ago1708364891
0xf4E01779...Af15E718c
40 ETH
192633562024-02-19 17:48:11161 days ago1708364891
0xf4E01779...Af15E718c
40 ETH
189778022024-01-10 16:40:23201 days ago1704904823
0xf4E01779...Af15E718c
50 ETH
189778022024-01-10 16:40:23201 days ago1704904823
0xf4E01779...Af15E718c
50 ETH
186782852023-11-29 15:53:35243 days ago1701273215
0xf4E01779...Af15E718c
150 ETH
185911332023-11-17 10:54:47256 days ago1700218487
0xf4E01779...Af15E718c
135 ETH
182644392023-10-02 17:48:11301 days ago1696268891
0xf4E01779...Af15E718c
130 ETH
182644392023-10-02 17:48:11301 days ago1696268891
0xf4E01779...Af15E718c
130 ETH
182610472023-10-02 6:26:59302 days ago1696228019
0xf4E01779...Af15E718c
60 ETH
180065202023-08-27 14:12:47338 days ago1693145567
0xf4E01779...Af15E718c
40 ETH
179189362023-08-15 8:05:11350 days ago1692086711
0xf4E01779...Af15E718c
40 ETH
178661292023-08-07 22:47:59357 days ago1691448479
0xf4E01779...Af15E718c
55 ETH
178535502023-08-06 4:31:35359 days ago1691296295
0xf4E01779...Af15E718c
40 ETH
177645392023-07-24 17:45:47371 days ago1690220747
0xf4E01779...Af15E718c
150 ETH
176140472023-07-03 14:31:59393 days ago1688394719
0xf4E01779...Af15E718c
50 ETH
176140472023-07-03 14:31:59393 days ago1688394719
0xf4E01779...Af15E718c
50 ETH
175722542023-06-27 17:45:23398 days ago1687887923
0xf4E01779...Af15E718c
50 ETH
175299772023-06-21 18:59:35404 days ago1687373975
0xf4E01779...Af15E718c
150 ETH
175299772023-06-21 18:59:35404 days ago1687373975
0xf4E01779...Af15E718c
150 ETH
174847822023-06-15 10:46:35411 days ago1686825995
0xf4E01779...Af15E718c
100 ETH
174491102023-06-10 10:14:11416 days ago1686392051
0xf4E01779...Af15E718c
50 ETH
173437512023-05-26 14:06:11431 days ago1685109971
0xf4E01779...Af15E718c
60 ETH
173307172023-05-24 18:05:59432 days ago1684951559
0xf4E01779...Af15E718c
60 ETH
172899022023-05-19 0:09:23438 days ago1684454963
0xf4E01779...Af15E718c
60 ETH
172199832023-05-09 2:39:47448 days ago1683599987
0xf4E01779...Af15E718c
10 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
KycOnboardingContract

Compiler Version
v0.8.9+commit.e5eed63a

Optimization Enabled:
Yes with 10000 runs

Other Settings:
default evmVersion
File 1 of 18 : KycOnboarding.sol
pragma solidity ^0.8.0;

// SPDX-License-Identifier: MIT

import "../utils/PotentialNewMember.sol";
import "../core/DaoRegistry.sol";
import "../extensions/bank/Bank.sol";
import "../guards/AdapterGuard.sol";
import "../utils/Signatures.sol";
import "../helpers/WETH.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

/**
MIT License

Copyright (c) 2021 Openlaw

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
 */

contract KycOnboardingContract is
    PotentialNewMember,
    AdapterGuard,
    MemberGuard,
    Signatures
{
    using Address for address payable;
    using SafeERC20 for IERC20;

    event Onboarded(DaoRegistry dao, address member, uint256 units);
    struct Coupon {
        address kycedMember;
        uint256 memberNonce;
    }

    struct OnboardingDetails {
        uint88 chunkSize;
        uint88 numberOfChunks;
        uint88 unitsPerChunk;
        uint88 unitsRequested;
        uint88 maximumTotalUnits;
        uint160 amount;
    }

    string public constant COUPON_MESSAGE_TYPE =
        "Message(address kycedMember,uint256 memberNonce)";
    bytes32 public constant COUPON_MESSAGE_TYPEHASH =
        keccak256(abi.encodePacked(COUPON_MESSAGE_TYPE));

    bytes32 constant SignerAddressConfig =
        keccak256("kyc-onboarding.signerAddress");

    bytes32 constant ChunkSize = keccak256("kyc-onboarding.chunkSize");
    bytes32 constant UnitsPerChunk = keccak256("kyc-onboarding.unitsPerChunk");
    bytes32 constant MaximumChunks = keccak256("kyc-onboarding.maximumChunks");
    bytes32 constant MaximumUnits =
        keccak256("kyc-onboarding.maximumTotalUnits");
    bytes32 constant MaxMembers = keccak256("kyc-onboarding.maxMembers");
    bytes32 constant CanTopUp = keccak256("kyc-onboarding.canTopUp");
    bytes32 constant FundTargetAddress =
        keccak256("kyc-onboarding.fundTargetAddress");
    bytes32 constant TokensToMint = keccak256("kyc-onboarding.tokensToMint");

    WETH private _weth;
    IERC20 private _weth20;

    mapping(DaoRegistry => mapping(address => uint256)) public totalUnits;

    // memberAddress => uint256
    mapping(address => uint256) public memberNonces;

    constructor(address payable weth) {
        _weth = WETH(weth);
        _weth20 = IERC20(weth);
    }

    /**
     * @notice Configures the Adapter with the coupon signer address and token to mint.
     * @param dao the dao to configure
     * @param signerAddress is the DAO instance to be configured
     * @param chunkSize how many wei per chunk
     * @param unitsPerChunk how many units do we get per chunk
     * @param maximumChunks maximum number of chunks allowed
     * @param maxUnits how many internal tokens can be minted
     * @param maxMembers maximum number of members allowed to join
     * @param canTopUp whether only new members can join or if existing members can onboard more units
     * @param fundTargetAddress multisig address to transfer the money from, set it to address(0) if you dont want to use a multisig
     * @param tokenAddr the token in which the onboarding can take place
     * @param internalTokensToMint the token that will be minted when the member joins the DAO
     */
    function configureDao(
        DaoRegistry dao,
        address signerAddress,
        uint256 chunkSize,
        uint256 unitsPerChunk,
        uint256 maximumChunks,
        uint256 maxUnits,
        uint256 maxMembers,
        uint256 canTopUp,
        address fundTargetAddress,
        address tokenAddr,
        address internalTokensToMint
    ) external onlyAdapter(dao) {
        require(
            chunkSize > 0 && chunkSize < type(uint88).max,
            "chunkSize::invalid"
        );
        require(
            maxMembers > 0 && maxMembers < type(uint88).max,
            "maxMembers::invalid"
        );
        require(
            maximumChunks > 0 && maximumChunks < type(uint88).max,
            "maximumChunks::invalid"
        );
        require(
            maxUnits > 0 && maxUnits < type(uint88).max,
            "maxUnits::invalid"
        );
        require(
            unitsPerChunk > 0 && unitsPerChunk < type(uint88).max,
            "unitsPerChunk::invalid"
        );
        require(
            maximumChunks * unitsPerChunk < type(uint88).max,
            "potential overflow"
        );

        require(isNotZeroAddress(signerAddress), "signer address is nil!");

        require(
            isNotZeroAddress(internalTokensToMint),
            "null internal token address"
        );

        dao.setAddressConfiguration(
            _configKey(tokenAddr, SignerAddressConfig),
            signerAddress
        );
        dao.setAddressConfiguration(
            _configKey(tokenAddr, FundTargetAddress),
            fundTargetAddress
        );
        dao.setConfiguration(_configKey(tokenAddr, ChunkSize), chunkSize);
        dao.setConfiguration(
            _configKey(tokenAddr, UnitsPerChunk),
            unitsPerChunk
        );
        dao.setConfiguration(
            _configKey(tokenAddr, MaximumChunks),
            maximumChunks
        );
        dao.setConfiguration(_configKey(tokenAddr, MaximumUnits), maxUnits);
        dao.setConfiguration(_configKey(tokenAddr, MaxMembers), maxMembers);
        dao.setAddressConfiguration(
            _configKey(tokenAddr, TokensToMint),
            internalTokensToMint
        );
        dao.setConfiguration(_configKey(tokenAddr, CanTopUp), canTopUp);

        BankExtension bank = BankExtension(dao.getExtensionAddress(BANK));
        require(bank.dao() == dao, "invalid dao");
        
        bank.registerPotentialNewInternalToken(UNITS);
        bank.registerPotentialNewToken(tokenAddr);
    }

    function getConfig(
        DaoRegistry dao,
        address tokenAddr,
        bytes32 key
    ) external view returns (uint256) {
        return dao.getConfiguration(_configKey(tokenAddr, key));
    }

    function getAddressConfig(
        DaoRegistry dao,
        address tokenAddr,
        bytes32 key
    ) external view returns (address) {
        return dao.getAddressConfiguration(_configKey(tokenAddr, key));
    }

    /**
     * @notice Hashes the provided coupon as an ERC712 hash.
     * @param dao is the DAO instance to be configured
     * @param coupon is the coupon to hash
     */
    function hashCouponMessage(DaoRegistry dao, Coupon memory coupon)
        public
        view
        returns (bytes32)
    {
        bytes32 message =
            keccak256(
                abi.encode(
                    COUPON_MESSAGE_TYPEHASH,
                    coupon.kycedMember,
                    coupon.memberNonce
                )
            );

        return hashMessage(dao, block.chainid, address(this), message);
    }

    /**
     * @notice Starts the onboarding propocess of a kyc member that is using ETH to join the DAO.
     * @param kycedMember The address of the kyced member that wants to join the DAO.
     * @param memberNonce The kycedMember's coupon nonce for the specified DAO.
     * @param signature The signature that will be verified to redeem the coupon.
     */
    function onboardEth(
        DaoRegistry dao,
        address kycedMember,
        uint256 memberNonce,
        bytes memory signature
    ) external payable {
        _onboard(
            dao,
            kycedMember,
            ETH_TOKEN,
            msg.value,
            memberNonce,
            signature
        );
    }

    /**
     * @notice Starts the onboarding propocess of a kyc member that is any ERC20 token to join the DAO.
     * @param kycedMember The address of the kyced member that wants to join the DAO.
     * @param tokenAddr The address of the ERC20 token that contains that funds of the kycedMember.
     * @param amount The amount in ERC20 that will be contributed to the DAO in exchange for the DAO units.
     * @param memberNonce The kycedMember's coupon nonce for the specified DAO.
     * @param signature The signature that will be verified to redeem the coupon.
     */
    function onboard(
        DaoRegistry dao,
        address kycedMember,
        address tokenAddr,
        uint256 amount,
        uint256 memberNonce,
        bytes memory signature
    ) external {
        _onboard(dao, kycedMember, tokenAddr, amount, memberNonce, signature);
    }

    /**
     * @notice Redeems a coupon to add a new member
     * @param dao is the DAO instance to be configured
     * @param kycedMember is the address that this coupon authorized to become a new member
     * @param tokenAddr is the address the ETH address(0) or an ERC20 Token address
     * @param memberNonce The kycedMember's coupon nonce for the specified DAO
     * @param signature is message signature for verification
     */
    // The function is protected against reentrancy with the reentrancyGuard(dao)
    // so it is fine to change some state after the reentrancyGuard(dao) external call
    // because it calls the dao contract to lock the session/transaction flow.
    // slither-disable-next-line reentrancy-benign,reentrancy-events
    function _onboard(
        DaoRegistry dao,
        address kycedMember,
        address tokenAddr,
        uint256 amount,
        uint256 memberNonce,
        bytes memory signature
    ) internal {
        require(
            !isActiveMember(dao, dao.getCurrentDelegateKey(kycedMember)) ||
                _daoCanTopUp(dao, tokenAddr),
            "already member"
        );
        require(memberNonce > memberNonces[kycedMember], "already redeemed");
        memberNonces[kycedMember] = memberNonce;

        uint256 maxMembers =
            dao.getConfiguration(_configKey(tokenAddr, MaxMembers));
        require(maxMembers > 0, "token not configured");
        require(dao.getNbMembers() < maxMembers, "the DAO is full");

        bytes32 couponHash =
            hashCouponMessage(dao, Coupon(kycedMember, memberNonce));
        _checkKycCoupon(dao, tokenAddr, couponHash, signature);

        OnboardingDetails memory details = _checkData(dao, tokenAddr, amount);
        totalUnits[dao][tokenAddr] += details.unitsRequested;

        BankExtension bank = BankExtension(dao.getExtensionAddress(BANK));
        require(bank.dao() == dao, "invalid dao");

        potentialNewMember(kycedMember, dao, bank);

        address multisigAddress =
            address(
                dao.getAddressConfiguration(
                    _configKey(tokenAddr, FundTargetAddress)
                )
            );
        if (multisigAddress == address(0x0)) {
            if (tokenAddr == ETH_TOKEN) {
                // The bank address is loaded from the DAO registry,
                // hence even if we change that, it belongs to the DAO,
                // so it is fine to send eth to it.
                // slither-disable-next-line arbitrary-send
                bank.addToBalance{value: details.amount}(
                    GUILD,
                    ETH_TOKEN,
                    details.amount
                );
            } else {
                bank.addToBalance(GUILD, tokenAddr, details.amount);
                IERC20 erc20 = IERC20(tokenAddr);
                erc20.safeTransferFrom(
                    msg.sender,
                    address(bank),
                    details.amount
                );
            }
        } else {
            if (tokenAddr == ETH_TOKEN) {
                // The _weth address is defined during the deployment of the contract
                // There is no way to change it once it has been deployed,
                // so it is fine to send eth to it.
                // slither-disable-next-line arbitrary-send
                _weth.deposit{value: details.amount}();
                _weth20.safeTransferFrom(
                    address(this),
                    multisigAddress,
                    details.amount
                );
            } else {
                IERC20 erc20 = IERC20(tokenAddr);
                erc20.safeTransferFrom(
                    msg.sender,
                    multisigAddress,
                    details.amount
                );
            }
        }

        bank.addToBalance(kycedMember, UNITS, details.unitsRequested);

        if (amount > details.amount && tokenAddr == ETH_TOKEN) {
            payable(msg.sender).sendValue(msg.value - details.amount);
        }

        emit Onboarded(dao, kycedMember, details.unitsRequested);
    }

    /**
     * @notice Verifies if the given amount is enough to join the DAO
     */
    function _checkData(
        DaoRegistry dao,
        address tokenAddr,
        uint256 amount
    ) internal view returns (OnboardingDetails memory details) {
        details.chunkSize = uint88(
            dao.getConfiguration(_configKey(tokenAddr, ChunkSize))
        );
        require(details.chunkSize > 0, "config chunkSize missing");
        details.numberOfChunks = uint88(amount / details.chunkSize);
        require(details.numberOfChunks > 0, "insufficient funds");
        require(
            details.numberOfChunks <=
                dao.getConfiguration(_configKey(tokenAddr, MaximumChunks)),
            "too much funds"
        );

        details.unitsPerChunk = uint88(
            dao.getConfiguration(_configKey(tokenAddr, UnitsPerChunk))
        );

        require(details.unitsPerChunk > 0, "config unitsPerChunk missing");
        details.amount = details.numberOfChunks * details.chunkSize;
        details.unitsRequested = details.numberOfChunks * details.unitsPerChunk;
        details.maximumTotalUnits = uint88(
            dao.getConfiguration(_configKey(tokenAddr, MaximumUnits))
        );

        require(
            details.unitsRequested + totalUnits[dao][tokenAddr] <=
                details.maximumTotalUnits,
            "over max total units"
        );
    }

    /**
     * @notice Checks if the given signature is valid or not.
     * @notice Reverts if the signature is invalid.
     * @param tokenAddr is the address the ETH address(0) or an ERC20 Token address.
     * @param couponHash is the hash generated by the hashCouponMessage function call.
     * @param signature is message signature for verification.
     */
    function _checkKycCoupon(
        DaoRegistry dao,
        address tokenAddr,
        bytes32 couponHash,
        bytes memory signature
    ) internal view {
        require(
            ECDSA.recover(couponHash, signature) ==
                dao.getAddressConfiguration(
                    _configKey(tokenAddr, SignerAddressConfig)
                ),
            "invalid sig"
        );
    }

    /**
     * @notice Builds the configuration key by encoding an address with a string key.
     * @param tokenAddrToMint The address to encode.
     * @param key The key to encode.
     */
    function _configKey(address tokenAddrToMint, bytes32 key)
        internal
        pure
        returns (bytes32)
    {
        return keccak256(abi.encode(tokenAddrToMint, key));
    }

    /**
     * @notice Returns if a dao allows kyc top ups.
     */
    function _daoCanTopUp(DaoRegistry dao, address tokenAddr)
        internal
        view
        returns (bool)
    {
        return dao.getConfiguration(_configKey(tokenAddr, CanTopUp)) > 0;
    }
}

File 2 of 18 : Signatures.sol
pragma solidity ^0.8.0;
pragma experimental ABIEncoderV2;

// SPDX-License-Identifier: MIT

import "../core/DaoRegistry.sol";
import "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";

/**
MIT License

Copyright (c) 2020 Openlaw

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
 */

abstract contract Signatures {
    string public constant EIP712_DOMAIN =
        "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract,address actionId)";

    bytes32 public constant EIP712_DOMAIN_TYPEHASH =
        keccak256(abi.encodePacked(EIP712_DOMAIN));

    function hashMessage(
        DaoRegistry dao,
        uint256 chainId,
        address actionId,
        bytes32 message
    ) public pure returns (bytes32) {
        return
            keccak256(
                abi.encodePacked(
                    "\x19\x01",
                    domainSeparator(dao, chainId, actionId),
                    message
                )
            );
    }

    function domainSeparator(
        DaoRegistry dao,
        uint256 chainId,
        address actionId
    ) public pure returns (bytes32) {
        return
            keccak256(
                abi.encode(
                    EIP712_DOMAIN_TYPEHASH,
                    keccak256("Snapshot Message"), // string name
                    keccak256("4"), // string version
                    chainId, // uint256 chainId
                    address(dao), // address verifyingContract,
                    actionId
                )
            );
    }

    function recover(bytes32 hash, bytes memory sig)
        public
        pure
        returns (address)
    {
        return ECDSA.recover(hash, sig);
    }

    function isValidSignature(
        address signer,
        bytes32 hash,
        bytes memory sig
    ) external view returns (bool) {
        return SignatureChecker.isValidSignatureNow(signer, hash, sig);
    }
}

File 3 of 18 : PotentialNewMember.sol
pragma solidity ^0.8.0;
import "../extensions/bank/Bank.sol";

// SPDX-License-Identifier: MIT

/**
MIT License

Copyright (c) 2020 Openlaw

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
 */

abstract contract PotentialNewMember {
    address internal constant _MEMBER_COUNT = address(0xDECAFBAD);

    function potentialNewMember(
        address memberAddress,
        DaoRegistry dao,
        BankExtension bank
    ) internal {
        dao.potentialNewMember(memberAddress);
        require(memberAddress != address(0x0), "invalid member address");
        if (address(bank) != address(0x0)) {
            if (bank.balanceOf(memberAddress, _MEMBER_COUNT) == 0) {
                bank.addToBalance(memberAddress, _MEMBER_COUNT, 1);
            }
        }
    }
}

File 4 of 18 : WETH.sol
//WETH-03.24.2020.sol
//deployed March 24,2020 Rinkeby - 0x8DD25714CCEce48767BaF266EC4F220B60f84D52
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract WETH {
    string public name = "Wrapped Ether";
    string public symbol = "WETH";
    uint8 public decimals = 18;

    event Approval(address indexed src, address indexed guy, uint256 wad);
    event Transfer(address indexed src, address indexed dst, uint256 wad);
    event Deposit(address indexed dst, uint256 wad);
    event Withdrawal(address indexed src, uint256 wad);

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

    receive() external payable {
        deposit();
    }

    function deposit() public payable {
        balanceOf[msg.sender] += msg.value;
        emit Deposit(msg.sender, msg.value);
    }

    function withdraw(uint256 wad) public {
        require(balanceOf[msg.sender] >= wad, "not enough WETH to withdraw");
        require(address(this).balance >= wad, "not enough ETH in the contract");
        balanceOf[msg.sender] -= wad;
        payable(msg.sender).transfer(wad);
        emit Withdrawal(msg.sender, wad);
    }

    function totalSupply() public view returns (uint256) {
        return address(this).balance;
    }

    function approve(address guy, uint256 wad) public returns (bool) {
        allowance[msg.sender][guy] = wad;
        emit Approval(msg.sender, guy, wad);
        return true;
    }

    function transfer(address dst, uint256 wad) public returns (bool) {
        return transferFrom(msg.sender, dst, wad);
    }

    function transferFrom(
        address src,
        address dst,
        uint256 wad
    ) public returns (bool) {
        require(balanceOf[src] >= wad, "insufficient fund");

        if (
            src != msg.sender && allowance[src][msg.sender] != type(uint256).max
        ) {
            require(
                allowance[src][msg.sender] >= wad,
                "not allowed to transfer from"
            );
            allowance[src][msg.sender] -= wad;
        }

        balanceOf[src] -= wad;
        balanceOf[dst] += wad;

        emit Transfer(src, dst, wad);

        return true;
    }
}

File 5 of 18 : MemberGuard.sol
pragma solidity ^0.8.0;

// SPDX-License-Identifier: MIT

import "../core/DaoRegistry.sol";
import "../core/DaoConstants.sol";
import "../extensions/bank/Bank.sol";

/**
MIT License

Copyright (c) 2020 Openlaw

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
 */
abstract contract MemberGuard is DaoConstants {
    /**
     * @dev Only members of the DAO are allowed to execute the function call.
     */
    modifier onlyMember(DaoRegistry dao) {
        _onlyMember(dao, msg.sender);
        _;
    }

    modifier onlyMember2(DaoRegistry dao, address _addr) {
        _onlyMember(dao, _addr);
        _;
    }

    function _onlyMember(DaoRegistry dao, address _addr) internal view {
        require(isActiveMember(dao, _addr), "onlyMember");
    }

    function isActiveMember(DaoRegistry dao, address _addr)
        public
        view
        returns (bool)
    {
        address bankAddress = dao.extensions(BANK);
        if (bankAddress != address(0x0)) {
            address memberAddr = dao.getAddressIfDelegated(_addr);
            return BankExtension(bankAddress).balanceOf(memberAddr, UNITS) > 0;
        }

        return dao.isMember(_addr);
    }
}

File 6 of 18 : AdapterGuard.sol
pragma solidity ^0.8.0;

// SPDX-License-Identifier: MIT

import "../core/DaoRegistry.sol";
import "../extensions/IExtension.sol";

/**
MIT License

Copyright (c) 2020 Openlaw

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
 */
abstract contract AdapterGuard {
    /**
     * @dev Only registered adapters are allowed to execute the function call.
     */
    modifier onlyAdapter(DaoRegistry dao) {
        require(
            (dao.state() == DaoRegistry.DaoState.CREATION &&
                creationModeCheck(dao)) || dao.isAdapter(msg.sender),
            "onlyAdapter"
        );
        _;
    }

    modifier reentrancyGuard(DaoRegistry dao) {
        require(dao.lockedAt() != block.number, "reentrancy guard");
        dao.lockSession();
        _;
        dao.unlockSession();
    }

    modifier hasAccess(DaoRegistry dao, DaoRegistry.AclFlag flag) {
        require(
            (dao.state() == DaoRegistry.DaoState.CREATION &&
                creationModeCheck(dao)) ||
                dao.hasAdapterAccess(msg.sender, flag),
            "accessDenied"
        );
        _;
    }

    function creationModeCheck(DaoRegistry dao) internal view returns (bool) {
        return
            dao.getNbMembers() == 0 ||
            dao.isMember(msg.sender) ||
            dao.isAdapter(msg.sender);
    }
}

File 7 of 18 : Bank.sol
pragma solidity ^0.8.0;

// SPDX-License-Identifier: MIT

import "../../core/DaoConstants.sol";
import "../../core/DaoRegistry.sol";
import "../IExtension.sol";
import "../../guards/AdapterGuard.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

/**
MIT License

Copyright (c) 2020 Openlaw

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
 */

contract BankExtension is DaoConstants, AdapterGuard, IExtension {
    using Address for address payable;
    using SafeERC20 for IERC20;

    uint8 public maxExternalTokens; // the maximum number of external tokens that can be stored in the bank

    bool public initialized = false; // internally tracks deployment under eip-1167 proxy pattern
    DaoRegistry public dao;

    enum AclFlag {
        ADD_TO_BALANCE,
        SUB_FROM_BALANCE,
        INTERNAL_TRANSFER,
        WITHDRAW,
        EXECUTE,
        REGISTER_NEW_TOKEN,
        REGISTER_NEW_INTERNAL_TOKEN,
        UPDATE_TOKEN
    }

    modifier noProposal {
        require(dao.lockedAt() < block.number, "proposal lock");
        _;
    }

    /// @dev - Events for Bank
    event NewBalance(address member, address tokenAddr, uint160 amount);

    event Withdraw(address account, address tokenAddr, uint160 amount);

    /*
     * STRUCTURES
     */

    struct Checkpoint {
        // A checkpoint for marking number of votes from a given block
        uint96 fromBlock;
        uint160 amount;
    }

    address[] public tokens;
    address[] public internalTokens;
    // tokenAddress => availability
    mapping(address => bool) public availableTokens;
    mapping(address => bool) public availableInternalTokens;
    // tokenAddress => memberAddress => checkpointNum => Checkpoint
    mapping(address => mapping(address => mapping(uint32 => Checkpoint)))
        public checkpoints;
    // tokenAddress => memberAddress => numCheckpoints
    mapping(address => mapping(address => uint32)) public numCheckpoints;

    /// @notice Clonable contract must have an empty constructor
    // constructor() {
    // }

    modifier hasExtensionAccess(AclFlag flag) {
        require(
            address(this) == msg.sender ||
                address(dao) == msg.sender ||
                dao.state() == DaoRegistry.DaoState.CREATION ||
                dao.hasAdapterAccessToExtension(
                    msg.sender,
                    address(this),
                    uint8(flag)
                ),
            "bank::accessDenied"
        );
        _;
    }

    /**
     * @notice Initialises the DAO
     * @dev Involves initialising available tokens, checkpoints, and membership of creator
     * @dev Can only be called once
     * @param creator The DAO's creator, who will be an initial member
     */
    function initialize(DaoRegistry _dao, address creator) external override {
        require(!initialized, "bank already initialized");
        require(_dao.isMember(creator), "bank::not member");
        dao = _dao;
        initialized = true;

        availableInternalTokens[UNITS] = true;
        internalTokens.push(UNITS);

        availableInternalTokens[MEMBER_COUNT] = true;
        internalTokens.push(MEMBER_COUNT);
        uint256 nbMembers = _dao.getNbMembers();
        for (uint256 i = 0; i < nbMembers; i++) {
            addToBalance(_dao.getMemberAddress(i), MEMBER_COUNT, 1);
        }

        _createNewAmountCheckpoint(creator, UNITS, 1);
        _createNewAmountCheckpoint(TOTAL, UNITS, 1);
    }

    function withdraw(
        address payable member,
        address tokenAddr,
        uint256 amount
    ) external hasExtensionAccess(AclFlag.WITHDRAW) {
        require(
            balanceOf(member, tokenAddr) >= amount,
            "bank::withdraw::not enough funds"
        );
        subtractFromBalance(member, tokenAddr, amount);
        if (tokenAddr == ETH_TOKEN) {
            member.sendValue(amount);
        } else {
            IERC20 erc20 = IERC20(tokenAddr);
            erc20.safeTransfer(member, amount);
        }

        emit Withdraw(member, tokenAddr, uint160(amount));
    }

    /**
     * @return Whether or not the given token is an available internal token in the bank
     * @param token The address of the token to look up
     */
    function isInternalToken(address token) external view returns (bool) {
        return availableInternalTokens[token];
    }

    /**
     * @return Whether or not the given token is an available token in the bank
     * @param token The address of the token to look up
     */
    function isTokenAllowed(address token) public view returns (bool) {
        return availableTokens[token];
    }

    /**
     * @notice Sets the maximum amount of external tokens allowed in the bank
     * @param maxTokens The maximum amount of token allowed
     */
    function setMaxExternalTokens(uint8 maxTokens) external {
        require(!initialized, "bank already initialized");
        require(
            maxTokens > 0 && maxTokens <= MAX_TOKENS_GUILD_BANK,
            "max number of external tokens should be (0,200)"
        );
        maxExternalTokens = maxTokens;
    }

    /*
     * BANK
     */

    /**
     * @notice Registers a potential new token in the bank
     * @dev Can not be a reserved token or an available internal token
     * @param token The address of the token
     */
    function registerPotentialNewToken(address token)
        external
        hasExtensionAccess(AclFlag.REGISTER_NEW_TOKEN)
    {
        require(isNotReservedAddress(token), "reservedToken");
        require(!availableInternalTokens[token], "internalToken");
        require(
            tokens.length <= maxExternalTokens,
            "exceeds the maximum tokens allowed"
        );

        if (!availableTokens[token]) {
            availableTokens[token] = true;
            tokens.push(token);
        }
    }

    /**
     * @notice Registers a potential new internal token in the bank
     * @dev Can not be a reserved token or an available token
     * @param token The address of the token
     */
    function registerPotentialNewInternalToken(address token)
        external
        hasExtensionAccess(AclFlag.REGISTER_NEW_INTERNAL_TOKEN)
    {
        require(isNotReservedAddress(token), "reservedToken");
        require(!availableTokens[token], "availableToken");

        if (!availableInternalTokens[token]) {
            availableInternalTokens[token] = true;
            internalTokens.push(token);
        }
    }

    function updateToken(address tokenAddr)
        external
        hasExtensionAccess(AclFlag.UPDATE_TOKEN)
    {
        require(isTokenAllowed(tokenAddr), "token not allowed");
        uint256 totalBalance = balanceOf(TOTAL, tokenAddr);

        uint256 realBalance;

        if (tokenAddr == ETH_TOKEN) {
            realBalance = address(this).balance;
        } else {
            IERC20 erc20 = IERC20(tokenAddr);
            realBalance = erc20.balanceOf(address(this));
        }

        if (totalBalance < realBalance) {
            addToBalance(GUILD, tokenAddr, realBalance - totalBalance);
        } else if (totalBalance > realBalance) {
            uint256 tokensToRemove = totalBalance - realBalance;
            uint256 guildBalance = balanceOf(GUILD, tokenAddr);
            if (guildBalance > tokensToRemove) {
                subtractFromBalance(GUILD, tokenAddr, tokensToRemove);
            } else {
                subtractFromBalance(GUILD, tokenAddr, guildBalance);
            }
        }
    }

    /**
     * Public read-only functions
     */

    /**
     * Internal bookkeeping
     */

    /**
     * @return The token from the bank of a given index
     * @param index The index to look up in the bank's tokens
     */
    function getToken(uint256 index) external view returns (address) {
        return tokens[index];
    }

    /**
     * @return The amount of token addresses in the bank
     */
    function nbTokens() external view returns (uint256) {
        return tokens.length;
    }

    /**
     * @return All the tokens registered in the bank.
     */
    function getTokens() external view returns (address[] memory) {
        return tokens;
    }

    /**
     * @return The internal token at a given index
     * @param index The index to look up in the bank's array of internal tokens
     */
    function getInternalToken(uint256 index) external view returns (address) {
        return internalTokens[index];
    }

    /**
     * @return The amount of internal token addresses in the bank
     */
    function nbInternalTokens() external view returns (uint256) {
        return internalTokens.length;
    }

    /**
     * @notice Adds to a member's balance of a given token
     * @param member The member whose balance will be updated
     * @param token The token to update
     * @param amount The new balance
     */
    function addToBalance(
        address member,
        address token,
        uint256 amount
    ) public payable hasExtensionAccess(AclFlag.ADD_TO_BALANCE) {
        require(
            availableTokens[token] || availableInternalTokens[token],
            "unknown token address"
        );
        uint256 newAmount = balanceOf(member, token) + amount;
        uint256 newTotalAmount = balanceOf(TOTAL, token) + amount;

        _createNewAmountCheckpoint(member, token, newAmount);
        _createNewAmountCheckpoint(TOTAL, token, newTotalAmount);
    }

    /**
     * @notice Remove from a member's balance of a given token
     * @param member The member whose balance will be updated
     * @param token The token to update
     * @param amount The new balance
     */
    function subtractFromBalance(
        address member,
        address token,
        uint256 amount
    ) public hasExtensionAccess(AclFlag.SUB_FROM_BALANCE) {
        uint256 newAmount = balanceOf(member, token) - amount;
        uint256 newTotalAmount = balanceOf(TOTAL, token) - amount;

        _createNewAmountCheckpoint(member, token, newAmount);
        _createNewAmountCheckpoint(TOTAL, token, newTotalAmount);
    }

    /**
     * @notice Make an internal token transfer
     * @param from The member who is sending tokens
     * @param to The member who is receiving tokens
     * @param amount The new amount to transfer
     */
    function internalTransfer(
        address from,
        address to,
        address token,
        uint256 amount
    ) public hasExtensionAccess(AclFlag.INTERNAL_TRANSFER) {
        uint256 newAmount = balanceOf(from, token) - amount;
        uint256 newAmount2 = balanceOf(to, token) + amount;

        _createNewAmountCheckpoint(from, token, newAmount);
        _createNewAmountCheckpoint(to, token, newAmount2);
    }

    /**
     * @notice Returns an member's balance of a given token
     * @param member The address to look up
     * @param tokenAddr The token where the member's balance of which will be returned
     * @return The amount in account's tokenAddr balance
     */
    function balanceOf(address member, address tokenAddr)
        public
        view
        returns (uint160)
    {
        uint32 nCheckpoints = numCheckpoints[tokenAddr][member];
        return
            nCheckpoints > 0
                ? checkpoints[tokenAddr][member][nCheckpoints - 1].amount
                : 0;
    }

    /**
     * @notice Determine the prior number of votes for an account as of a block number
     * @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
     * @param account The address of the account to check
     * @param blockNumber The block number to get the vote balance at
     * @return The number of votes the account had as of the given block
     */
    function getPriorAmount(
        address account,
        address tokenAddr,
        uint256 blockNumber
    ) external view returns (uint256) {
        require(
            blockNumber < block.number,
            "Uni::getPriorAmount: not yet determined"
        );

        uint32 nCheckpoints = numCheckpoints[tokenAddr][account];
        if (nCheckpoints == 0) {
            return 0;
        }

        // First check most recent balance
        if (
            checkpoints[tokenAddr][account][nCheckpoints - 1].fromBlock <=
            blockNumber
        ) {
            return checkpoints[tokenAddr][account][nCheckpoints - 1].amount;
        }

        // Next check implicit zero balance
        if (checkpoints[tokenAddr][account][0].fromBlock > blockNumber) {
            return 0;
        }

        uint32 lower = 0;
        uint32 upper = nCheckpoints - 1;
        while (upper > lower) {
            uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
            Checkpoint memory cp = checkpoints[tokenAddr][account][center];
            if (cp.fromBlock == blockNumber) {
                return cp.amount;
            } else if (cp.fromBlock < blockNumber) {
                lower = center;
            } else {
                upper = center - 1;
            }
        }
        return checkpoints[tokenAddr][account][lower].amount;
    }

    /**
     * @notice Creates a new amount checkpoint for a token of a certain member
     * @dev Reverts if the amount is greater than 2**64-1
     * @param member The member whose checkpoints will be added to
     * @param token The token of which the balance will be changed
     * @param amount The amount to be written into the new checkpoint
     */
    function _createNewAmountCheckpoint(
        address member,
        address token,
        uint256 amount
    ) internal {
        bool isValidToken = false;
        if (availableInternalTokens[token]) {
            require(
                amount < type(uint88).max,
                "token amount exceeds the maximum limit for internal tokens"
            );
            isValidToken = true;
        } else if (availableTokens[token]) {
            require(
                amount < type(uint160).max,
                "token amount exceeds the maximum limit for external tokens"
            );
            isValidToken = true;
        }
        uint160 newAmount = uint160(amount);

        require(isValidToken, "token not registered");

        uint32 nCheckpoints = numCheckpoints[token][member];
        if (
            nCheckpoints > 0 &&
            checkpoints[token][member][nCheckpoints - 1].fromBlock ==
            block.number
        ) {
            checkpoints[token][member][nCheckpoints - 1].amount = newAmount;
        } else {
            checkpoints[token][member][nCheckpoints] = Checkpoint(
                uint96(block.number),
                newAmount
            );
            numCheckpoints[token][member] = nCheckpoints + 1;
        }
        emit NewBalance(member, token, newAmount);
    }
}

File 8 of 18 : IExtension.sol
pragma solidity ^0.8.0;
import "../core/DaoRegistry.sol";

// SPDX-License-Identifier: MIT

/**
MIT License

Copyright (c) 2020 Openlaw

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
 */

interface IExtension {
    function initialize(DaoRegistry dao, address creator) external;
}

File 9 of 18 : DaoRegistry.sol
pragma solidity ^0.8.0;

// SPDX-License-Identifier: MIT

import "./DaoConstants.sol";
import "../guards/AdapterGuard.sol";
import "../guards/MemberGuard.sol";
import "../extensions/IExtension.sol";

/**
MIT License

Copyright (c) 2020 Openlaw

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
 */

contract DaoRegistry is MemberGuard, AdapterGuard {
    bool public initialized = false; // internally tracks deployment under eip-1167 proxy pattern

    enum DaoState {CREATION, READY}

    /*
     * EVENTS
     */
    /// @dev - Events for Proposals
    event SubmittedProposal(bytes32 proposalId, uint256 flags);
    event SponsoredProposal(
        bytes32 proposalId,
        uint256 flags,
        address votingAdapter
    );
    event ProcessedProposal(bytes32 proposalId, uint256 flags);
    event AdapterAdded(
        bytes32 adapterId,
        address adapterAddress,
        uint256 flags
    );
    event AdapterRemoved(bytes32 adapterId);

    event ExtensionAdded(bytes32 extensionId, address extensionAddress);
    event ExtensionRemoved(bytes32 extensionId);

    /// @dev - Events for Members
    event UpdateDelegateKey(address memberAddress, address newDelegateKey);
    event ConfigurationUpdated(bytes32 key, uint256 value);
    event AddressConfigurationUpdated(bytes32 key, address value);

    enum MemberFlag {EXISTS}

    enum ProposalFlag {EXISTS, SPONSORED, PROCESSED}

    enum AclFlag {
        REPLACE_ADAPTER,
        SUBMIT_PROPOSAL,
        UPDATE_DELEGATE_KEY,
        SET_CONFIGURATION,
        ADD_EXTENSION,
        REMOVE_EXTENSION,
        NEW_MEMBER
    }

    /*
     * STRUCTURES
     */
    struct Proposal {
        // the structure to track all the proposals in the DAO
        address adapterAddress; // the adapter address that called the functions to change the DAO state
        uint256 flags; // flags to track the state of the proposal: exist, sponsored, processed, canceled, etc.
    }

    struct Member {
        // the structure to track all the members in the DAO
        uint256 flags; // flags to track the state of the member: exists, etc
    }

    struct Checkpoint {
        // A checkpoint for marking number of votes from a given block
        uint96 fromBlock;
        uint160 amount;
    }

    struct DelegateCheckpoint {
        // A checkpoint for marking number of votes from a given block
        uint96 fromBlock;
        address delegateKey;
    }

    struct AdapterEntry {
        bytes32 id;
        uint256 acl;
    }

    struct ExtensionEntry {
        bytes32 id;
        mapping(address => uint256) acl;
    }

    /*
     * PUBLIC VARIABLES
     */
    mapping(address => Member) public members; // the map to track all members of the DAO
    address[] private _members;

    // delegate key => member address mapping
    mapping(address => address) public memberAddressesByDelegatedKey;

    // memberAddress => checkpointNum => DelegateCheckpoint
    mapping(address => mapping(uint32 => DelegateCheckpoint)) checkpoints;
    // memberAddress => numDelegateCheckpoints
    mapping(address => uint32) numCheckpoints;

    DaoState public state;

    /// @notice The map that keeps track of all proposasls submitted to the DAO
    mapping(bytes32 => Proposal) public proposals;
    /// @notice The map that tracks the voting adapter address per proposalId
    mapping(bytes32 => address) public votingAdapter;
    /// @notice The map that keeps track of all adapters registered in the DAO
    mapping(bytes32 => address) public adapters;
    /// @notice The inverse map to get the adapter id based on its address
    mapping(address => AdapterEntry) public inverseAdapters;
    /// @notice The map that keeps track of all extensions registered in the DAO
    mapping(bytes32 => address) public extensions;
    /// @notice The inverse map to get the extension id based on its address
    mapping(address => ExtensionEntry) public inverseExtensions;
    /// @notice The map that keeps track of configuration parameters for the DAO and adapters
    mapping(bytes32 => uint256) public mainConfiguration;
    mapping(bytes32 => address) public addressConfiguration;

    uint256 public lockedAt;

    /// @notice Clonable contract must have an empty constructor
    // constructor() {
    // }

    /**
     * @notice Initialises the DAO
     * @dev Involves initialising available tokens, checkpoints, and membership of creator
     * @dev Can only be called once
     * @param creator The DAO's creator, who will be an initial member
     * @param payer The account which paid for the transaction to create the DAO, who will be an initial member
     */
    function initialize(address creator, address payer) external {
        require(!initialized, "dao already initialized");
        potentialNewMember(msg.sender);
        potentialNewMember(payer);
        potentialNewMember(creator);

        initialized = true;
    }

    /**
     * @notice default fallback function to prevent from sending ether to the contract
     */
    receive() external payable {
        revert("you cannot send money back directly");
    }

    /**
     * @dev Sets the state of the dao to READY
     */
    function finalizeDao() external {
        state = DaoState.READY;
    }

    function lockSession() external {
        if (isAdapter(msg.sender) || isExtension(msg.sender)) {
            lockedAt = block.number;
        }
    }

    function unlockSession() external {
        if (isAdapter(msg.sender) || isExtension(msg.sender)) {
            lockedAt = 0;
        }
    }

    /**
     * @notice Sets a configuration value
     * @dev Changes the value of a key in the configuration mapping
     * @param key The configuration key for which the value will be set
     * @param value The value to set the key
     */
    function setConfiguration(bytes32 key, uint256 value)
        external
        hasAccess(this, AclFlag.SET_CONFIGURATION)
    {
        mainConfiguration[key] = value;

        emit ConfigurationUpdated(key, value);
    }

    function potentialNewMember(address memberAddress)
        public
        hasAccess(this, AclFlag.NEW_MEMBER)
    {
        require(memberAddress != address(0x0), "invalid member address");

        Member storage member = members[memberAddress];
        if (!getFlag(member.flags, uint8(MemberFlag.EXISTS))) {
            require(
                memberAddressesByDelegatedKey[memberAddress] == address(0x0),
                "member address already taken as delegated key"
            );
            member.flags = setFlag(
                member.flags,
                uint8(MemberFlag.EXISTS),
                true
            );
            memberAddressesByDelegatedKey[memberAddress] = memberAddress;
            _members.push(memberAddress);
        }

        address bankAddress = extensions[BANK];
        if (bankAddress != address(0x0)) {
            BankExtension bank = BankExtension(bankAddress);
            if (bank.balanceOf(memberAddress, MEMBER_COUNT) == 0) {
                bank.addToBalance(memberAddress, MEMBER_COUNT, 1);
            }
        }
    }

    /**
     * @notice Sets an configuration value
     * @dev Changes the value of a key in the configuration mapping
     * @param key The configuration key for which the value will be set
     * @param value The value to set the key
     */
    function setAddressConfiguration(bytes32 key, address value)
        external
        hasAccess(this, AclFlag.SET_CONFIGURATION)
    {
        addressConfiguration[key] = value;

        emit AddressConfigurationUpdated(key, value);
    }

    /**
     * @return The configuration value of a particular key
     * @param key The key to look up in the configuration mapping
     */
    function getConfiguration(bytes32 key) external view returns (uint256) {
        return mainConfiguration[key];
    }

    /**
     * @return The configuration value of a particular key
     * @param key The key to look up in the configuration mapping
     */
    function getAddressConfiguration(bytes32 key)
        external
        view
        returns (address)
    {
        return addressConfiguration[key];
    }

    /**
     * @notice Adds a new extension to the registry
     * @param extensionId The unique identifier of the new extension
     * @param extension The address of the extension
     * @param creator The DAO's creator, who will be an initial member
     */
    function addExtension(
        bytes32 extensionId,
        IExtension extension,
        address creator
    ) external hasAccess(this, AclFlag.ADD_EXTENSION) {
        require(extensionId != bytes32(0), "extension id must not be empty");
        require(
            extensions[extensionId] == address(0x0),
            "extension Id already in use"
        );
        extensions[extensionId] = address(extension);
        inverseExtensions[address(extension)].id = extensionId;
        extension.initialize(this, creator);
        emit ExtensionAdded(extensionId, address(extension));
    }

    function setAclToExtensionForAdapter(
        address extensionAddress,
        address adapterAddress,
        uint256 acl
    ) external hasAccess(this, AclFlag.ADD_EXTENSION) {
        require(isAdapter(adapterAddress), "not an adapter");
        require(isExtension(extensionAddress), "not an extension");
        inverseExtensions[extensionAddress].acl[adapterAddress] = acl;
    }

    /**
     * @notice Replaces an adapter in the registry in a single step.
     * @notice It handles addition and removal of adapters as special cases.
     * @dev It removes the current adapter if the adapterId maps to an existing adapter address.
     * @dev It adds an adapter if the adapterAddress parameter is not zeroed.
     * @param adapterId The unique identifier of the adapter
     * @param adapterAddress The address of the new adapter or zero if it is a removal operation
     * @param acl The flags indicating the access control layer or permissions of the new adapter
     * @param keys The keys indicating the adapter configuration names.
     * @param values The values indicating the adapter configuration values.
     */
    function replaceAdapter(
        bytes32 adapterId,
        address adapterAddress,
        uint128 acl,
        bytes32[] calldata keys,
        uint256[] calldata values
    ) external hasAccess(this, AclFlag.REPLACE_ADAPTER) {
        require(adapterId != bytes32(0), "adapterId must not be empty");

        address currentAdapterAddr = adapters[adapterId];
        if (currentAdapterAddr != address(0x0)) {
            delete inverseAdapters[currentAdapterAddr];
            delete adapters[adapterId];
            emit AdapterRemoved(adapterId);
        }

        for (uint256 i = 0; i < keys.length; i++) {
            bytes32 key = keys[i];
            uint256 value = values[i];
            mainConfiguration[key] = value;
            emit ConfigurationUpdated(key, value);
        }

        if (adapterAddress != address(0x0)) {
            require(
                inverseAdapters[adapterAddress].id == bytes32(0),
                "adapterAddress already in use"
            );
            adapters[adapterId] = adapterAddress;
            inverseAdapters[adapterAddress].id = adapterId;
            inverseAdapters[adapterAddress].acl = acl;
            emit AdapterAdded(adapterId, adapterAddress, acl);
        }
    }

    /**
     * @notice Removes an adapter from the registry
     * @param extensionId The unique identifier of the extension
     */
    function removeExtension(bytes32 extensionId)
        external
        hasAccess(this, AclFlag.REMOVE_EXTENSION)
    {
        require(extensionId != bytes32(0), "extensionId must not be empty");
        require(
            extensions[extensionId] != address(0x0),
            "extensionId not registered"
        );
        delete inverseExtensions[extensions[extensionId]];
        delete extensions[extensionId];
        emit ExtensionRemoved(extensionId);
    }

    /**
     * @notice Looks up if there is an extension of a given address
     * @return Whether or not the address is an extension
     * @param extensionAddr The address to look up
     */
    function isExtension(address extensionAddr) public view returns (bool) {
        return inverseExtensions[extensionAddr].id != bytes32(0);
    }

    /**
     * @notice Looks up if there is an adapter of a given address
     * @return Whether or not the address is an adapter
     * @param adapterAddress The address to look up
     */
    function isAdapter(address adapterAddress) public view returns (bool) {
        return inverseAdapters[adapterAddress].id != bytes32(0);
    }

    /**
     * @notice Checks if an adapter has a given ACL flag
     * @return Whether or not the given adapter has the given flag set
     * @param adapterAddress The address to look up
     * @param flag The ACL flag to check against the given address
     */
    function hasAdapterAccess(address adapterAddress, AclFlag flag)
        public
        view
        returns (bool)
    {
        return getFlag(inverseAdapters[adapterAddress].acl, uint8(flag));
    }

    /**
     * @notice Checks if an adapter has a given ACL flag
     * @return Whether or not the given adapter has the given flag set
     * @param adapterAddress The address to look up
     * @param flag The ACL flag to check against the given address
     */
    function hasAdapterAccessToExtension(
        address adapterAddress,
        address extensionAddress,
        uint8 flag
    ) public view returns (bool) {
        return
            isAdapter(adapterAddress) &&
            getFlag(
                inverseExtensions[extensionAddress].acl[adapterAddress],
                uint8(flag)
            );
    }

    /**
     * @return The address of a given adapter ID
     * @param adapterId The ID to look up
     */
    function getAdapterAddress(bytes32 adapterId)
        external
        view
        returns (address)
    {
        require(adapters[adapterId] != address(0), "adapter not found");
        return adapters[adapterId];
    }

    /**
     * @return The address of a given extension Id
     * @param extensionId The ID to look up
     */
    function getExtensionAddress(bytes32 extensionId)
        external
        view
        returns (address)
    {
        require(extensions[extensionId] != address(0), "extension not found");
        return extensions[extensionId];
    }

    /**
     * PROPOSALS
     */
    /**
     * @notice Submit proposals to the DAO registry
     */
    function submitProposal(bytes32 proposalId)
        public
        hasAccess(this, AclFlag.SUBMIT_PROPOSAL)
    {
        require(proposalId != bytes32(0), "invalid proposalId");
        require(
            !getProposalFlag(proposalId, ProposalFlag.EXISTS),
            "proposalId must be unique"
        );
        proposals[proposalId] = Proposal(msg.sender, 1); // 1 means that only the first flag is being set i.e. EXISTS
        emit SubmittedProposal(proposalId, 1);
    }

    /**
     * @notice Sponsor proposals that were submitted to the DAO registry
     * @dev adds SPONSORED to the proposal flag
     * @param proposalId The ID of the proposal to sponsor
     * @param sponsoringMember The member who is sponsoring the proposal
     */
    function sponsorProposal(
        bytes32 proposalId,
        address sponsoringMember,
        address votingAdapterAddr
    ) external onlyMember2(this, sponsoringMember) {
        // also checks if the flag was already set
        Proposal storage proposal =
            _setProposalFlag(proposalId, ProposalFlag.SPONSORED);

        uint256 flags = proposal.flags;

        require(
            proposal.adapterAddress == msg.sender,
            "only the adapter that submitted the proposal can process it"
        );

        require(
            !getFlag(flags, uint8(ProposalFlag.PROCESSED)),
            "proposal already processed"
        );
        votingAdapter[proposalId] = votingAdapterAddr;
        emit SponsoredProposal(proposalId, flags, votingAdapterAddr);
    }

    /**
     * @notice Mark a proposal as processed in the DAO registry
     * @param proposalId The ID of the proposal that is being processed
     */
    function processProposal(bytes32 proposalId) external {
        Proposal storage proposal =
            _setProposalFlag(proposalId, ProposalFlag.PROCESSED);

        require(proposal.adapterAddress == msg.sender, "err::adapter mismatch");
        uint256 flags = proposal.flags;

        emit ProcessedProposal(proposalId, flags);
    }

    /**
     * @notice Sets a flag of a proposal
     * @dev Reverts if the proposal is already processed
     * @param proposalId The ID of the proposal to be changed
     * @param flag The flag that will be set on the proposal
     */
    function _setProposalFlag(bytes32 proposalId, ProposalFlag flag)
        internal
        returns (Proposal storage)
    {
        Proposal storage proposal = proposals[proposalId];

        uint256 flags = proposal.flags;
        require(
            getFlag(flags, uint8(ProposalFlag.EXISTS)),
            "proposal does not exist for this dao"
        );

        require(
            proposal.adapterAddress == msg.sender,
            "only the adapter that submitted the proposal can set its flag"
        );

        require(!getFlag(flags, uint8(flag)), "flag already set");

        flags = setFlag(flags, uint8(flag), true);
        proposals[proposalId].flags = flags;

        return proposals[proposalId];
    }

    /*
     * MEMBERS
     */

    /**
     * @return Whether or not a given address is a member of the DAO.
     * @dev it will resolve by delegate key, not member address.
     * @param addr The address to look up
     */
    function isMember(address addr) public view returns (bool) {
        address memberAddress = memberAddressesByDelegatedKey[addr];
        return getMemberFlag(memberAddress, MemberFlag.EXISTS);
    }

    /**
     * @return Whether or not a flag is set for a given proposal
     * @param proposalId The proposal to check against flag
     * @param flag The flag to check in the proposal
     */
    function getProposalFlag(bytes32 proposalId, ProposalFlag flag)
        public
        view
        returns (bool)
    {
        return getFlag(proposals[proposalId].flags, uint8(flag));
    }

    /**
     * @return Whether or not a flag is set for a given member
     * @param memberAddress The member to check against flag
     * @param flag The flag to check in the member
     */
    function getMemberFlag(address memberAddress, MemberFlag flag)
        public
        view
        returns (bool)
    {
        return getFlag(members[memberAddress].flags, uint8(flag));
    }

    function getNbMembers() public view returns (uint256) {
        return _members.length;
    }

    function getMemberAddress(uint256 index) public view returns (address) {
        return _members[index];
    }

    /**
     * @notice Updates the delegate key of a member
     * @param memberAddr The member doing the delegation
     * @param newDelegateKey The member who is being delegated to
     */
    function updateDelegateKey(address memberAddr, address newDelegateKey)
        external
        hasAccess(this, AclFlag.UPDATE_DELEGATE_KEY)
    {
        require(newDelegateKey != address(0x0), "newDelegateKey cannot be 0");

        // skip checks if member is setting the delegate key to their member address
        if (newDelegateKey != memberAddr) {
            require(
                // newDelegate must not be delegated to
                memberAddressesByDelegatedKey[newDelegateKey] == address(0x0),
                "cannot overwrite existing delegated keys"
            );
        } else {
            require(
                memberAddressesByDelegatedKey[memberAddr] == address(0x0),
                "address already taken as delegated key"
            );
        }

        Member storage member = members[memberAddr];
        require(
            getFlag(member.flags, uint8(MemberFlag.EXISTS)),
            "member does not exist"
        );

        // Reset the delegation of the previous delegate
        memberAddressesByDelegatedKey[
            getCurrentDelegateKey(memberAddr)
        ] = address(0x0);

        memberAddressesByDelegatedKey[newDelegateKey] = memberAddr;

        _createNewDelegateCheckpoint(memberAddr, newDelegateKey);
        emit UpdateDelegateKey(memberAddr, newDelegateKey);
    }

    /**
     * Public read-only functions
     */

    /**
     * @param checkAddr The address to check for a delegate
     * @return the delegated address or the checked address if it is not a delegate
     */
    function getAddressIfDelegated(address checkAddr)
        public
        view
        returns (address)
    {
        address delegatedKey = memberAddressesByDelegatedKey[checkAddr];
        return delegatedKey == address(0x0) ? checkAddr : delegatedKey;
    }

    /**
     * @param memberAddr The member whose delegate will be returned
     * @return the delegate key at the current time for a member
     */
    function getCurrentDelegateKey(address memberAddr)
        public
        view
        returns (address)
    {
        uint32 nCheckpoints = numCheckpoints[memberAddr];
        return
            nCheckpoints > 0
                ? checkpoints[memberAddr][nCheckpoints - 1].delegateKey
                : memberAddr;
    }

    /**
     * @param memberAddr The member address to look up
     * @return The delegate key address for memberAddr at the second last checkpoint number
     */
    function getPreviousDelegateKey(address memberAddr)
        public
        view
        returns (address)
    {
        uint32 nCheckpoints = numCheckpoints[memberAddr];
        return
            nCheckpoints > 1
                ? checkpoints[memberAddr][nCheckpoints - 2].delegateKey
                : memberAddr;
    }

    /**
     * @notice Determine the prior number of votes for an account as of a block number
     * @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
     * @param memberAddr The address of the account to check
     * @param blockNumber The block number to get the vote balance at
     * @return The number of votes the account had as of the given block
     */
    function getPriorDelegateKey(address memberAddr, uint256 blockNumber)
        external
        view
        returns (address)
    {
        require(
            blockNumber < block.number,
            "Uni::getPriorDelegateKey: not yet determined"
        );

        uint32 nCheckpoints = numCheckpoints[memberAddr];
        if (nCheckpoints == 0) {
            return memberAddr;
        }

        // First check most recent balance
        if (
            checkpoints[memberAddr][nCheckpoints - 1].fromBlock <= blockNumber
        ) {
            return checkpoints[memberAddr][nCheckpoints - 1].delegateKey;
        }

        // Next check implicit zero balance
        if (checkpoints[memberAddr][0].fromBlock > blockNumber) {
            return memberAddr;
        }

        uint32 lower = 0;
        uint32 upper = nCheckpoints - 1;
        while (upper > lower) {
            uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
            DelegateCheckpoint memory cp = checkpoints[memberAddr][center];
            if (cp.fromBlock == blockNumber) {
                return cp.delegateKey;
            } else if (cp.fromBlock < blockNumber) {
                lower = center;
            } else {
                upper = center - 1;
            }
        }
        return checkpoints[memberAddr][lower].delegateKey;
    }

    /**
     * @notice Creates a new delegate checkpoint of a certain member
     * @param member The member whose delegate checkpoints will be added to
     * @param newDelegateKey The delegate key that will be written into the new checkpoint
     */
    function _createNewDelegateCheckpoint(
        address member,
        address newDelegateKey
    ) internal {
        uint32 nCheckpoints = numCheckpoints[member];
        if (
            nCheckpoints > 0 &&
            checkpoints[member][nCheckpoints - 1].fromBlock == block.number
        ) {
            checkpoints[member][nCheckpoints - 1].delegateKey = newDelegateKey;
        } else {
            checkpoints[member][nCheckpoints] = DelegateCheckpoint(
                uint96(block.number),
                newDelegateKey
            );
            numCheckpoints[member] = nCheckpoints + 1;
        }
    }
}

File 10 of 18 : DaoConstants.sol
pragma solidity ^0.8.0;

// SPDX-License-Identifier: MIT

/**
MIT License

Copyright (c) 2020 Openlaw

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
 */

abstract contract DaoConstants {
    // Adapters
    bytes32 internal constant VOTING = keccak256("voting");
    bytes32 internal constant ONBOARDING = keccak256("onboarding");
    bytes32 internal constant NONVOTING_ONBOARDING =
        keccak256("nonvoting-onboarding");
    bytes32 internal constant TRIBUTE = keccak256("tribute");
    bytes32 internal constant FINANCING = keccak256("financing");
    bytes32 internal constant MANAGING = keccak256("managing");
    bytes32 internal constant RAGEQUIT = keccak256("ragequit");
    bytes32 internal constant GUILDKICK = keccak256("guildkick");
    bytes32 internal constant EXECUTION = keccak256("execution");
    bytes32 internal constant CONFIGURATION = keccak256("configuration");
    bytes32 internal constant DISTRIBUTE = keccak256("distribute");
    bytes32 internal constant TRIBUTE_NFT = keccak256("tribute-nft");

    // Extensions
    bytes32 internal constant BANK = keccak256("bank");
    bytes32 internal constant NFT = keccak256("nft");
    bytes32 internal constant ERC20_EXT = keccak256("erc20-ext");

    // Reserved Addresses
    address internal constant GUILD = address(0xdead);
    address internal constant TOTAL = address(0xbabe);
    address internal constant ESCROW = address(0x4bec);
    address internal constant UNITS = address(0xFF1CE);
    address internal constant LOOT = address(0xB105F00D);
    address internal constant ETH_TOKEN = address(0x0);
    address internal constant MEMBER_COUNT = address(0xDECAFBAD);

    uint8 internal constant MAX_TOKENS_GUILD_BANK = 200;

    //helper
    function getFlag(uint256 flags, uint256 flag) public pure returns (bool) {
        return (flags >> uint8(flag)) % 2 == 1;
    }

    function setFlag(
        uint256 flags,
        uint256 flag,
        bool value
    ) public pure returns (uint256) {
        if (getFlag(flags, flag) != value) {
            if (value) {
                return flags + 2**flag;
            } else {
                return flags - 2**flag;
            }
        } else {
            return flags;
        }
    }

    /**
     * @notice Checks if a given address is reserved.
     */
    function isNotReservedAddress(address addr) public pure returns (bool) {
        return addr != GUILD && addr != TOTAL && addr != ESCROW;
    }

    /**
     * @notice Checks if a given address is zeroed.
     */
    function isNotZeroAddress(address addr) public pure returns (bool) {
        return addr != address(0x0);
    }
}

File 11 of 18 : SignatureChecker.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.1) (utils/cryptography/SignatureChecker.sol)

pragma solidity ^0.8.0;

import "./ECDSA.sol";
import "../Address.sol";
import "../../interfaces/IERC1271.sol";

/**
 * @dev Signature verification helper that can be used instead of `ECDSA.recover` to seamlessly support both ECDSA
 * signatures from externally owned accounts (EOAs) as well as ERC1271 signatures from smart contract wallets like
 * Argent and Gnosis Safe.
 *
 * _Available since v4.1._
 */
library SignatureChecker {
    /**
     * @dev Checks if a signature is valid for a given signer and data hash. If the signer is a smart contract, the
     * signature is validated against that smart contract using ERC1271, otherwise it's validated using `ECDSA.recover`.
     *
     * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus
     * change through time. It could return true at block N and false at block N+1 (or the opposite).
     */
    function isValidSignatureNow(
        address signer,
        bytes32 hash,
        bytes memory signature
    ) internal view returns (bool) {
        (address recovered, ECDSA.RecoverError error) = ECDSA.tryRecover(hash, signature);
        if (error == ECDSA.RecoverError.NoError && recovered == signer) {
            return true;
        }

        (bool success, bytes memory result) = signer.staticcall(
            abi.encodeWithSelector(IERC1271.isValidSignature.selector, hash, signature)
        );
        return (success &&
            result.length == 32 &&
            abi.decode(result, (bytes32)) == bytes32(IERC1271.isValidSignature.selector));
    }
}

File 12 of 18 : ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

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

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

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

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

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

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

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

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

        return (signer, RecoverError.NoError);
    }

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

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

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

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    }
}

File 13 of 18 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_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) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @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] = _HEX_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);
    }
}

File 14 of 18 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(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) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

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

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

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason 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 {
            // 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);
            }
        }
    }
}

File 15 of 18 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

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

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

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

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

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

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

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

File 16 of 18 : draft-IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

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

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

File 17 of 18 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

Settings
{
  "remappings": [],
  "optimizer": {
    "enabled": true,
    "runs": 10000
  },
  "evmVersion": "london",
  "libraries": {},
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address payable","name":"weth","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract DaoRegistry","name":"dao","type":"address"},{"indexed":false,"internalType":"address","name":"member","type":"address"},{"indexed":false,"internalType":"uint256","name":"units","type":"uint256"}],"name":"Onboarded","type":"event"},{"inputs":[],"name":"COUPON_MESSAGE_TYPE","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"COUPON_MESSAGE_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"EIP712_DOMAIN","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"EIP712_DOMAIN_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract DaoRegistry","name":"dao","type":"address"},{"internalType":"address","name":"signerAddress","type":"address"},{"internalType":"uint256","name":"chunkSize","type":"uint256"},{"internalType":"uint256","name":"unitsPerChunk","type":"uint256"},{"internalType":"uint256","name":"maximumChunks","type":"uint256"},{"internalType":"uint256","name":"maxUnits","type":"uint256"},{"internalType":"uint256","name":"maxMembers","type":"uint256"},{"internalType":"uint256","name":"canTopUp","type":"uint256"},{"internalType":"address","name":"fundTargetAddress","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"address","name":"internalTokensToMint","type":"address"}],"name":"configureDao","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract DaoRegistry","name":"dao","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"actionId","type":"address"}],"name":"domainSeparator","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"contract DaoRegistry","name":"dao","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"bytes32","name":"key","type":"bytes32"}],"name":"getAddressConfig","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract DaoRegistry","name":"dao","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"bytes32","name":"key","type":"bytes32"}],"name":"getConfig","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"flags","type":"uint256"},{"internalType":"uint256","name":"flag","type":"uint256"}],"name":"getFlag","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"contract DaoRegistry","name":"dao","type":"address"},{"components":[{"internalType":"address","name":"kycedMember","type":"address"},{"internalType":"uint256","name":"memberNonce","type":"uint256"}],"internalType":"struct KycOnboardingContract.Coupon","name":"coupon","type":"tuple"}],"name":"hashCouponMessage","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract DaoRegistry","name":"dao","type":"address"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"actionId","type":"address"},{"internalType":"bytes32","name":"message","type":"bytes32"}],"name":"hashMessage","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"contract DaoRegistry","name":"dao","type":"address"},{"internalType":"address","name":"_addr","type":"address"}],"name":"isActiveMember","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"isNotReservedAddress","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"isNotZeroAddress","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"signer","type":"address"},{"internalType":"bytes32","name":"hash","type":"bytes32"},{"internalType":"bytes","name":"sig","type":"bytes"}],"name":"isValidSignature","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"memberNonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract DaoRegistry","name":"dao","type":"address"},{"internalType":"address","name":"kycedMember","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"memberNonce","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"onboard","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract DaoRegistry","name":"dao","type":"address"},{"internalType":"address","name":"kycedMember","type":"address"},{"internalType":"uint256","name":"memberNonce","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"onboardEth","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"hash","type":"bytes32"},{"internalType":"bytes","name":"sig","type":"bytes"}],"name":"recover","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"flags","type":"uint256"},{"internalType":"uint256","name":"flag","type":"uint256"},{"internalType":"bool","name":"value","type":"bool"}],"name":"setFlag","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"contract DaoRegistry","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"totalUnits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

60806040523480156200001157600080fd5b506040516200426938038062004269833981016040819052620000349162000064565b600080546001600160a01b039092166001600160a01b031992831681179091556001805490921617905562000096565b6000602082840312156200007757600080fd5b81516001600160a01b03811681146200008f57600080fd5b9392505050565b6141c380620000a66000396000f3fe60806040526004361061016a5760003560e01c8063b244a41d116100cb578063d4e183441161007f578063ed53a96311610059578063ed53a963146103f9578063ef6a24991461040e578063fc2580311461042e57600080fd5b8063d4e18344146103a4578063e1b11da4146103c4578063e868a6bd146103d957600080fd5b8063ca0f4633116100b0578063ca0f46331461033b578063ccb3813a14610364578063d2c4de211461038457600080fd5b8063b244a41d14610306578063c7977be71461032657600080fd5b80635322d58c1161012257806384b732201161010757806384b73220146102b15780638ecf7720146102c65780639cf2fa27146102e657600080fd5b80635322d58c1461026f57806363a9fed71461028f57600080fd5b8063238a4d1e11610153578063238a4d1e146101da5780633d1f1e511461020a57806340e2dfcf1461024257600080fd5b806319045a251461016f5780631a25c910146101ac575b600080fd5b34801561017b57600080fd5b5061018f61018a366004613914565b61044e565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156101b857600080fd5b506101cc6101c7366004613970565b610463565b6040519081526020016101a3565b3480156101e657600080fd5b506101fa6101f53660046139b8565b6104cb565b60405190151581526020016101a3565b34801561021657600080fd5b506101cc610225366004613a11565b600260209081526000928352604080842090915290825290205481565b34801561024e57600080fd5b506101cc61025d366004613a4a565b60036020526000908152604090205481565b34801561027b57600080fd5b506101cc61028a366004613a67565b6104e2565b34801561029b57600080fd5b506102a4610577565b6040516101a39190613b3c565b6102c46102bf366004613b4f565b610593565b005b3480156102d257600080fd5b506101fa6102e1366004613a11565b6105a8565b3480156102f257600080fd5b506101cc610301366004613bbb565b61084a565b34801561031257600080fd5b506101cc610321366004613c0b565b61091c565b34801561033257600080fd5b506101cc610970565b34801561034757600080fd5b506101fa610356366004613a4a565b6001600160a01b0316151590565b34801561037057600080fd5b5061018f61037f366004613c39565b6109b2565b34801561039057600080fd5b506102c461039f366004613c7a565b610a73565b3480156103b057600080fd5b506102c46103bf366004613d28565b611891565b3480156103d057600080fd5b506102a46118a7565b3480156103e557600080fd5b506101cc6103f4366004613c39565b6118c3565b34801561040557600080fd5b506101cc611984565b34801561041a57600080fd5b506101fa610429366004613a4a565b6119ad565b34801561043a57600080fd5b506101fa610449366004613daf565b6119f1565b600061045a8383611a0e565b90505b92915050565b600061047085858561084a565b6040517f19010000000000000000000000000000000000000000000000000000000000006020820152602281019190915260428101839052606201604051602081830303815290604052805190602001209050949350505050565b60006104d8848484611a32565b90505b9392505050565b60008060405180606001604052806030815260200161415e6030913960405160200161050e9190613dd1565b60408051601f198184030181528282528051602091820120865187830151928501919091526001600160a01b031691830191909152606082015260800160405160208183030381529060405280519060200120905061056f84463084610463565b949350505050565b60405180606001604052806030815260200161415e6030913981565b6105a284846000348686611bba565b50505050565b6040517ffefbd8750000000000000000000000000000000000000000000000000000000081527fea0ca03c7adbe41dc655fec28a9209dc8e6e042f3d991a67765ba285b9cf73a0600482015260009081906001600160a01b0385169063fefbd8759060240160206040518083038186803b15801561062557600080fd5b505afa158015610639573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061065d9190613ded565b90506001600160a01b038116156107b8576040517fc89bb8ba0000000000000000000000000000000000000000000000000000000081526001600160a01b0384811660048301526000919086169063c89bb8ba9060240160206040518083038186803b1580156106cc57600080fd5b505afa1580156106e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107049190613ded565b6040517ff7888aec0000000000000000000000000000000000000000000000000000000081526001600160a01b038083166004830152620ff1ce602483015291925060009184169063f7888aec9060440160206040518083038186803b15801561076d57600080fd5b505afa158015610781573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107a59190613ded565b6001600160a01b0316119250505061045d565b6040517fa230c5240000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015285169063a230c5249060240160206040518083038186803b15801561081257600080fd5b505afa158015610826573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061056f9190613e0a565b60006040518060a00160405280606381526020016140fb606391396040516020016108759190613dd1565b60408051601f198184030181528282528051602091820120908301527fe2ffb2e2c8bf0b9b360ecefb7de0735865e605d6ba933b6c7e12cee0e178c8bf908201527f13600b294191fc92924bb3ce4b969c1e7e2bab8f4c93c3fc6d0a51733df3c0606060820152608081018490526001600160a01b0380861660a0830152831660c082015260e0016040516020818303038152906040528051906020012090509392505050565b600081151561092b85856119f1565b15151461096957811561095457610943836002613f76565b61094d9085613f82565b90506104db565b61095f836002613f76565b61094d9085613f9a565b50826104db565b6040518060a00160405280606381526020016140fb606391396040516020016109999190613dd1565b6040516020818303038152906040528051906020012081565b6000836001600160a01b031663fd310d29610a058585604080516001600160a01b038416602082015290810182905260009060600160405160208183030381529060405280519060200120905092915050565b6040518263ffffffff1660e01b8152600401610a2391815260200190565b60206040518083038186803b158015610a3b57600080fd5b505afa158015610a4f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104d89190613ded565b8a6000816001600160a01b031663c19d93fb6040518163ffffffff1660e01b815260040160206040518083038186803b158015610aaf57600080fd5b505afa158015610ac3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ae79190613fe0565b6001811115610af857610af8613fb1565b148015610b095750610b098161259d565b80610b9f57506040517f68c18beb0000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b038216906368c18beb9060240160206040518083038186803b158015610b6757600080fd5b505afa158015610b7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b9f9190613e0a565b610bf05760405162461bcd60e51b815260206004820152600b60248201527f6f6e6c794164617074657200000000000000000000000000000000000000000060448201526064015b60405180910390fd5b60008a118015610c0a57506affffffffffffffffffffff8a105b610c565760405162461bcd60e51b815260206004820152601260248201527f6368756e6b53697a653a3a696e76616c696400000000000000000000000000006044820152606401610be7565b600086118015610c7057506affffffffffffffffffffff86105b610cbc5760405162461bcd60e51b815260206004820152601360248201527f6d61784d656d626572733a3a696e76616c6964000000000000000000000000006044820152606401610be7565b600088118015610cd657506affffffffffffffffffffff88105b610d225760405162461bcd60e51b815260206004820152601660248201527f6d6178696d756d4368756e6b733a3a696e76616c6964000000000000000000006044820152606401610be7565b600087118015610d3c57506affffffffffffffffffffff87105b610d885760405162461bcd60e51b815260206004820152601160248201527f6d6178556e6974733a3a696e76616c69640000000000000000000000000000006044820152606401610be7565b600089118015610da257506affffffffffffffffffffff89105b610dee5760405162461bcd60e51b815260206004820152601660248201527f756e6974735065724368756e6b3a3a696e76616c6964000000000000000000006044820152606401610be7565b6affffffffffffffffffffff610e048a8a614001565b10610e515760405162461bcd60e51b815260206004820152601260248201527f706f74656e7469616c206f766572666c6f7700000000000000000000000000006044820152606401610be7565b6001600160a01b038b16610ea75760405162461bcd60e51b815260206004820152601660248201527f7369676e65722061646472657373206973206e696c21000000000000000000006044820152606401610be7565b6001600160a01b038216610efd5760405162461bcd60e51b815260206004820152601b60248201527f6e756c6c20696e7465726e616c20746f6b656e206164647265737300000000006044820152606401610be7565b604080516001600160a01b038581166020808401919091527f62fc88784e0c19cc8b8b751f1752ac9b0faec53f227474e9c143736b1b053bd28385015283518084038501815260608401808652815191909201207f3b4f921a0000000000000000000000000000000000000000000000000000000090915260648301528d811660848301529151918e1691633b4f921a9160a48082019260009290919082900301818387803b158015610faf57600080fd5b505af1158015610fc3573d6000803e3d6000fd5b5050604080516001600160a01b038781166020808401919091527fac22e216410db4a745e4c58279e55c551b17605a4393bcf3b64fa9262d9979dd83850152835180840385018152606090930190935281519190920120908f169250633b4f921a91506040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b16815260048101919091526001600160a01b0387166024820152604401600060405180830381600087803b15801561108657600080fd5b505af115801561109a573d6000803e3d6000fd5b5050604080516001600160a01b038781166020808401919091527fb024dc66daa5f76b3a0f3ca4879dc87b33f90cea509e863f3e0955b6222a3a1e83850152835180840385018152606084019485905280519101207fda0f6c70000000000000000000000000000000000000000000000000000000009093526064820192909252608481018e9052908f16925063da0f6c70915060a401600060405180830381600087803b15801561114b57600080fd5b505af115801561115f573d6000803e3d6000fd5b5050604080516001600160a01b038781166020808401919091527fe731ae3a43606ed081c5398551cfc363c835a134e5bde100a63ae178b3e8417583850152835180840385018152606084019485905280519101207fda0f6c70000000000000000000000000000000000000000000000000000000009093526064820192909252608481018d9052908f16925063da0f6c70915060a401600060405180830381600087803b15801561121057600080fd5b505af1158015611224573d6000803e3d6000fd5b5050604080516001600160a01b038781166020808401919091527f30671f20b402b0209c539f216c8370ad5c14d6756f759a0bb3e1c2b4869e9f2f83850152835180840385018152606084019485905280519101207fda0f6c70000000000000000000000000000000000000000000000000000000009093526064820192909252608481018c9052908f16925063da0f6c70915060a401600060405180830381600087803b1580156112d557600080fd5b505af11580156112e9573d6000803e3d6000fd5b5050604080516001600160a01b038781166020808401919091527ffdf6c9ba9b500ecb9379c7c8a8798f57b5727856cdf3b739640e2d178eaaa89483850152835180840385018152606084019485905280519101207fda0f6c70000000000000000000000000000000000000000000000000000000009093526064820192909252608481018b9052908f16925063da0f6c70915060a401600060405180830381600087803b15801561139a57600080fd5b505af11580156113ae573d6000803e3d6000fd5b5050604080516001600160a01b038781166020808401919091527f8f2f3c9bc35994511794a3bbcf840c067fce8d0a24cd068e9b0d4ce1f4b13ef083850152835180840385018152606084019485905280519101207fda0f6c70000000000000000000000000000000000000000000000000000000009093526064820192909252608481018a9052908f16925063da0f6c70915060a401600060405180830381600087803b15801561145f57600080fd5b505af1158015611473573d6000803e3d6000fd5b5050604080516001600160a01b038781166020808401919091527f1563be206c04f4a19d217b21c8dfa32bcc7747bde5e98f7760f02fa4bd4612ca83850152835180840385018152606090930190935281519190920120908f169250633b4f921a91506040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b16815260048101919091526001600160a01b0385166024820152604401600060405180830381600087803b15801561153657600080fd5b505af115801561154a573d6000803e3d6000fd5b5050604080516001600160a01b038781166020808401919091527f88da9ccc582665efc10ceaf87771d8f475c8be6b374a49034d994e91a1ea58b083850152835180840385018152606084019485905280519101207fda0f6c7000000000000000000000000000000000000000000000000000000000909352606482019290925260848101899052908f16925063da0f6c70915060a401600060405180830381600087803b1580156115fb57600080fd5b505af115801561160f573d6000803e3d6000fd5b50506040517f593e96b60000000000000000000000000000000000000000000000000000000081527fea0ca03c7adbe41dc655fec28a9209dc8e6e042f3d991a67765ba285b9cf73a06004820152600092506001600160a01b038f16915063593e96b69060240160206040518083038186803b15801561168e57600080fd5b505afa1580156116a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116c69190613ded565b90508c6001600160a01b0316816001600160a01b0316634162169f6040518163ffffffff1660e01b815260040160206040518083038186803b15801561170b57600080fd5b505afa15801561171f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117439190613ded565b6001600160a01b0316146117995760405162461bcd60e51b815260206004820152600b60248201527f696e76616c69642064616f0000000000000000000000000000000000000000006044820152606401610be7565b6040517ff7e15acf000000000000000000000000000000000000000000000000000000008152620ff1ce60048201526001600160a01b0382169063f7e15acf90602401600060405180830381600087803b1580156117f657600080fd5b505af115801561180a573d6000803e3d6000fd5b50506040517f69af242f0000000000000000000000000000000000000000000000000000000081526001600160a01b038781166004830152841692506369af242f9150602401600060405180830381600087803b15801561186a57600080fd5b505af115801561187e573d6000803e3d6000fd5b5050505050505050505050505050505050565b61189f868686868686611bba565b505050505050565b6040518060a00160405280606381526020016140fb6063913981565b6000836001600160a01b0316639283ae3a6119168585604080516001600160a01b038416602082015290810182905260009060600160405160208183030381529060405280519060200120905092915050565b6040518263ffffffff1660e01b815260040161193491815260200190565b60206040518083038186803b15801561194c57600080fd5b505afa158015611960573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104d8919061403e565b60405180606001604052806030815260200161415e603091396040516020016109999190613dd1565b60006001600160a01b03821661dead148015906119d557506001600160a01b03821661babe14155b801561045d57506001600160a01b038216614bec141592915050565b6000611a04600260ff841685901c614086565b6001149392505050565b6000806000611a1d858561273d565b91509150611a2a81612783565b509392505050565b6000806000611a41858561273d565b90925090506000816004811115611a5a57611a5a613fb1565b148015611a785750856001600160a01b0316826001600160a01b0316145b15611a88576001925050506104db565b600080876001600160a01b0316631626ba7e60e01b8888604051602401611ab092919061409a565b60408051601f198184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909416939093179092529051611b1b9190613dd1565b600060405180830381855afa9150503d8060008114611b56576040519150601f19603f3d011682016040523d82523d6000602084013e611b5b565b606091505b5091509150818015611b6e575080516020145b8015611bae575080517f1626ba7e0000000000000000000000000000000000000000000000000000000090611bac908301602090810190840161403e565b145b98975050505050505050565b6040517f397a69470000000000000000000000000000000000000000000000000000000081526001600160a01b038681166004830152611c5291889182169063397a69479060240160206040518083038186803b158015611c1a57600080fd5b505afa158015611c2e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102e19190613ded565b1580611c635750611c638685612977565b611caf5760405162461bcd60e51b815260206004820152600e60248201527f616c7265616479206d656d6265720000000000000000000000000000000000006044820152606401610be7565b6001600160a01b0385166000908152600360205260409020548211611d165760405162461bcd60e51b815260206004820152601060248201527f616c72656164792072656465656d6564000000000000000000000000000000006044820152606401610be7565b6001600160a01b0385811660009081526003602090815260408083208690558051888516818401527f8f2f3c9bc35994511794a3bbcf840c067fce8d0a24cd068e9b0d4ce1f4b13ef081830152815180820383018152606082019283905280519301929092207f9283ae3a0000000000000000000000000000000000000000000000000000000090915260648201529091881690639283ae3a9060840160206040518083038186803b158015611dcb57600080fd5b505afa158015611ddf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e03919061403e565b905060008111611e555760405162461bcd60e51b815260206004820152601460248201527f746f6b656e206e6f7420636f6e666967757265640000000000000000000000006044820152606401610be7565b80876001600160a01b031663c67143666040518163ffffffff1660e01b815260040160206040518083038186803b158015611e8f57600080fd5b505afa158015611ea3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ec7919061403e565b10611f145760405162461bcd60e51b815260206004820152600f60248201527f7468652044414f2069732066756c6c00000000000000000000000000000000006044820152606401610be7565b6000611f3d8860405180604001604052808a6001600160a01b03168152602001878152506104e2565b9050611f4b88878386612a61565b6000611f58898888612ba6565b60608101516001600160a01b03808c166000908152600260209081526040808320938d16835292905290812080549394506affffffffffffffffffffff90921692611fa4908490613f82565b90915550506040517f593e96b60000000000000000000000000000000000000000000000000000000081527fea0ca03c7adbe41dc655fec28a9209dc8e6e042f3d991a67765ba285b9cf73a060048201526000906001600160a01b038b169063593e96b69060240160206040518083038186803b15801561202457600080fd5b505afa158015612038573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061205c9190613ded565b9050896001600160a01b0316816001600160a01b0316634162169f6040518163ffffffff1660e01b815260040160206040518083038186803b1580156120a157600080fd5b505afa1580156120b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120d99190613ded565b6001600160a01b03161461212f5760405162461bcd60e51b815260206004820152600b60248201527f696e76616c69642064616f0000000000000000000000000000000000000000006044820152606401610be7565b61213a898b836131c4565b604080516001600160a01b038a81166020808401919091527fac22e216410db4a745e4c58279e55c551b17605a4393bcf3b64fa9262d9979dd83850152835180840385018152606084019485905280519101207ffd310d290000000000000000000000000000000000000000000000000000000090935260648201929092526000918c169063fd310d299060840160206040518083038186803b1580156121e057600080fd5b505afa1580156121f4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122189190613ded565b90506001600160a01b038116612377576001600160a01b0389166122c65760a08301516040517fc57d5fe900000000000000000000000000000000000000000000000000000000815261dead6004820152600060248201526001600160a01b03918216604482018190529184169163c57d5fe9916064016000604051808303818588803b1580156122a857600080fd5b505af11580156122bc573d6000803e3d6000fd5b5050505050612443565b60a08301516040517fc57d5fe900000000000000000000000000000000000000000000000000000000815261dead60048201526001600160a01b038b8116602483015291821660448201529083169063c57d5fe990606401600060405180830381600087803b15801561233857600080fd5b505af115801561234c573d6000803e3d6000fd5b50505060a08401518a9150612371906001600160a01b038084169133918791166133d1565b50612443565b6001600160a01b0389166124205760008054906101000a90046001600160a01b03166001600160a01b031663d0e30db08460a001516001600160a01b03166040518263ffffffff1660e01b81526004016000604051808303818588803b1580156123e057600080fd5b505af11580156123f4573d6000803e3d6000fd5b50505060a085015160015461241b93506001600160a01b03908116925030918591166133d1565b612443565b60a08301518990612441906001600160a01b038084169133918691166133d1565b505b60608301516040517fc57d5fe90000000000000000000000000000000000000000000000000000000081526001600160a01b038c81166004830152620ff1ce60248301526affffffffffffffffffffff90921660448201529083169063c57d5fe990606401600060405180830381600087803b1580156124c257600080fd5b505af11580156124d6573d6000803e3d6000fd5b505050508260a001516001600160a01b0316881180156124fd57506001600160a01b038916155b15612525576125258360a001516001600160a01b03163461251e9190613f9a565b3390613459565b7fae72ee3a8d22d597e0c519e76231f6a7a76458404a08fd8299fd971da8f9915b8b8b8560600151604051612588939291906001600160a01b0393841681529190921660208201526affffffffffffffffffffff91909116604082015260600190565b60405180910390a15050505050505050505050565b6000816001600160a01b031663c67143666040518163ffffffff1660e01b815260040160206040518083038186803b1580156125d857600080fd5b505afa1580156125ec573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612610919061403e565b15806126a757506040517fa230c5240000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b0383169063a230c5249060240160206040518083038186803b15801561266f57600080fd5b505afa158015612683573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126a79190613e0a565b8061045d57506040517f68c18beb0000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b038316906368c18beb9060240160206040518083038186803b15801561270557600080fd5b505afa158015612719573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061045d9190613e0a565b6000808251604114156127745760208301516040840151606085015160001a61276887828585613572565b9450945050505061277c565b506000905060025b9250929050565b600081600481111561279757612797613fb1565b14156127a05750565b60018160048111156127b4576127b4613fb1565b14156128025760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610be7565b600281600481111561281657612816613fb1565b14156128645760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610be7565b600381600481111561287857612878613fb1565b14156128ec5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152608401610be7565b600481600481111561290057612900613fb1565b14156129745760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152608401610be7565b50565b600080836001600160a01b0316639283ae3a6129eb857f88da9ccc582665efc10ceaf87771d8f475c8be6b374a49034d994e91a1ea58b0604080516001600160a01b038416602082015290810182905260009060600160405160208183030381529060405280519060200120905092915050565b6040518263ffffffff1660e01b8152600401612a0991815260200190565b60206040518083038186803b158015612a2157600080fd5b505afa158015612a35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a59919061403e565b119392505050565b604080516001600160a01b038581166020808401919091527f62fc88784e0c19cc8b8b751f1752ac9b0faec53f227474e9c143736b1b053bd283850152835180840385018152606084019485905280519101207ffd310d290000000000000000000000000000000000000000000000000000000090935260648201929092529085169063fd310d299060840160206040518083038186803b158015612b0557600080fd5b505afa158015612b19573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b3d9190613ded565b6001600160a01b0316612b508383611a0e565b6001600160a01b0316146105a25760405162461bcd60e51b815260206004820152600b60248201527f696e76616c6964207369670000000000000000000000000000000000000000006044820152606401610be7565b6040805160c0810182526000808252602080830182905282840182905260608084018390526080840183905260a084019290925283516001600160a01b03878116828401527fb024dc66daa5f76b3a0f3ca4879dc87b33f90cea509e863f3e0955b6222a3a1e8287015285518083038701815293820195869052835193909201929092207f9283ae3a0000000000000000000000000000000000000000000000000000000090945260648201939093529091851690639283ae3a9060840160206040518083038186803b158015612c7c57600080fd5b505afa158015612c90573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cb4919061403e565b6affffffffffffffffffffff16808252612d105760405162461bcd60e51b815260206004820152601860248201527f636f6e666967206368756e6b53697a65206d697373696e6700000000000000006044820152606401610be7565b8051612d29906affffffffffffffffffffff16836140b3565b6affffffffffffffffffffff1660208201819052612d895760405162461bcd60e51b815260206004820152601260248201527f696e73756666696369656e742066756e647300000000000000000000000000006044820152606401610be7565b604080516001600160a01b038581166020808401919091527f30671f20b402b0209c539f216c8370ad5c14d6756f759a0bb3e1c2b4869e9f2f83850152835180840385018152606084019485905280519101207f9283ae3a00000000000000000000000000000000000000000000000000000000909352606482019290925290851690639283ae3a9060840160206040518083038186803b158015612e2d57600080fd5b505afa158015612e41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e65919061403e565b81602001516affffffffffffffffffffff161115612ec55760405162461bcd60e51b815260206004820152600e60248201527f746f6f206d7563682066756e64730000000000000000000000000000000000006044820152606401610be7565b604080516001600160a01b038581166020808401919091527fe731ae3a43606ed081c5398551cfc363c835a134e5bde100a63ae178b3e8417583850152835180840385018152606084019485905280519101207f9283ae3a00000000000000000000000000000000000000000000000000000000909352606482019290925290851690639283ae3a9060840160206040518083038186803b158015612f6957600080fd5b505afa158015612f7d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fa1919061403e565b6affffffffffffffffffffff16604082018190526130015760405162461bcd60e51b815260206004820152601c60248201527f636f6e66696720756e6974735065724368756e6b206d697373696e67000000006044820152606401610be7565b8051602082015161301291906140c7565b6affffffffffffffffffffff1660a08201526040810151602082015161303891906140c7565b6affffffffffffffffffffff1660608201526001600160a01b038416639283ae3a6130bb857ffdf6c9ba9b500ecb9379c7c8a8798f57b5727856cdf3b739640e2d178eaaa894604080516001600160a01b038416602082015290810182905260009060600160405160208183030381529060405280519060200120905092915050565b6040518263ffffffff1660e01b81526004016130d991815260200190565b60206040518083038186803b1580156130f157600080fd5b505afa158015613105573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613129919061403e565b6affffffffffffffffffffff908116608083018190526001600160a01b03808716600090815260026020908152604080832093891683529290522054606084015191926131769216613f82565b11156104db5760405162461bcd60e51b815260206004820152601460248201527f6f766572206d617820746f74616c20756e6974730000000000000000000000006044820152606401610be7565b6040517fdc929f4a0000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015283169063dc929f4a90602401600060405180830381600087803b15801561322057600080fd5b505af1158015613234573d6000803e3d6000fd5b505050506001600160a01b03831661328e5760405162461bcd60e51b815260206004820152601660248201527f696e76616c6964206d656d6265722061646472657373000000000000000000006044820152606401610be7565b6001600160a01b038116156133cc576040517ff7888aec0000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015263decafbad602483015282169063f7888aec9060440160206040518083038186803b15801561330157600080fd5b505afa158015613315573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133399190613ded565b6001600160a01b03166133cc576040517fc57d5fe90000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015263decafbad60248301526001604483015282169063c57d5fe990606401600060405180830381600087803b1580156133b357600080fd5b505af11580156133c7573d6000803e3d6000fd5b505050505b505050565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd000000000000000000000000000000000000000000000000000000001790526105a290859061365f565b804710156134a95760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610be7565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146134f6576040519150601f19603f3d011682016040523d82523d6000602084013e6134fb565b606091505b50509050806133cc5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610be7565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156135a95750600090506003613656565b8460ff16601b141580156135c157508460ff16601c14155b156135d25750600090506004613656565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015613626573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661364f57600060019250925050613656565b9150600090505b94509492505050565b60006136b4826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166137449092919063ffffffff16565b8051909150156133cc57808060200190518101906136d29190613e0a565b6133cc5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610be7565b60606104d88484600085856001600160a01b0385163b6137a65760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610be7565b600080866001600160a01b031685876040516137c29190613dd1565b60006040518083038185875af1925050503d80600081146137ff576040519150601f19603f3d011682016040523d82523d6000602084013e613804565b606091505b509150915061381482828661381f565b979650505050505050565b6060831561382e5750816104db565b82511561383e5782518084602001fd5b8160405162461bcd60e51b8152600401610be79190613b3c565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261389857600080fd5b813567ffffffffffffffff808211156138b3576138b3613858565b604051601f8301601f19908116603f011681019082821181831017156138db576138db613858565b816040528381528660208588010111156138f457600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806040838503121561392757600080fd5b82359150602083013567ffffffffffffffff81111561394557600080fd5b61395185828601613887565b9150509250929050565b6001600160a01b038116811461297457600080fd5b6000806000806080858703121561398657600080fd5b84356139918161395b565b93506020850135925060408501356139a88161395b565b9396929550929360600135925050565b6000806000606084860312156139cd57600080fd5b83356139d88161395b565b925060208401359150604084013567ffffffffffffffff8111156139fb57600080fd5b613a0786828701613887565b9150509250925092565b60008060408385031215613a2457600080fd5b8235613a2f8161395b565b91506020830135613a3f8161395b565b809150509250929050565b600060208284031215613a5c57600080fd5b81356104db8161395b565b6000808284036060811215613a7b57600080fd5b8335613a868161395b565b92506040601f1982011215613a9a57600080fd5b506040516040810181811067ffffffffffffffff82111715613abe57613abe613858565b6040526020840135613acf8161395b565b81526040939093013560208401525092909150565b60005b83811015613aff578181015183820152602001613ae7565b838111156105a25750506000910152565b60008151808452613b28816020860160208601613ae4565b601f01601f19169290920160200192915050565b60208152600061045a6020830184613b10565b60008060008060808587031215613b6557600080fd5b8435613b708161395b565b93506020850135613b808161395b565b925060408501359150606085013567ffffffffffffffff811115613ba357600080fd5b613baf87828801613887565b91505092959194509250565b600080600060608486031215613bd057600080fd5b8335613bdb8161395b565b9250602084013591506040840135613bf28161395b565b809150509250925092565b801515811461297457600080fd5b600080600060608486031215613c2057600080fd5b83359250602084013591506040840135613bf281613bfd565b600080600060608486031215613c4e57600080fd5b8335613c598161395b565b92506020840135613c698161395b565b929592945050506040919091013590565b60008060008060008060008060008060006101608c8e031215613c9c57600080fd5b8b35613ca78161395b565b9a5060208c0135613cb78161395b565b995060408c0135985060608c0135975060808c0135965060a08c0135955060c08c0135945060e08c013593506101008c0135613cf28161395b565b92506101208c0135613d038161395b565b91506101408c0135613d148161395b565b809150509295989b509295989b9093969950565b60008060008060008060c08789031215613d4157600080fd5b8635613d4c8161395b565b95506020870135613d5c8161395b565b94506040870135613d6c8161395b565b9350606087013592506080870135915060a087013567ffffffffffffffff811115613d9657600080fd5b613da289828a01613887565b9150509295509295509295565b60008060408385031215613dc257600080fd5b50508035926020909101359150565b60008251613de3818460208701613ae4565b9190910192915050565b600060208284031215613dff57600080fd5b81516104db8161395b565b600060208284031215613e1c57600080fd5b81516104db81613bfd565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600181815b80851115613eaf57817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115613e9557613e95613e27565b80851615613ea257918102915b93841c9390800290613e5b565b509250929050565b600082613ec65750600161045d565b81613ed35750600061045d565b8160018114613ee95760028114613ef357613f0f565b600191505061045d565b60ff841115613f0457613f04613e27565b50506001821b61045d565b5060208310610133831016604e8410600b8410161715613f32575081810a61045d565b613f3c8383613e56565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115613f6e57613f6e613e27565b029392505050565b600061045a8383613eb7565b60008219821115613f9557613f95613e27565b500190565b600082821015613fac57613fac613e27565b500390565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b600060208284031215613ff257600080fd5b8151600281106104db57600080fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561403957614039613e27565b500290565b60006020828403121561405057600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60008261409557614095614057565b500690565b8281526040602082015260006104d86040830184613b10565b6000826140c2576140c2614057565b500490565b60006affffffffffffffffffffff808316818516818304811182151516156140f1576140f1613e27565b0294935050505056fe454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e74726163742c6164647265737320616374696f6e4964294d6573736167652861646472657373206b796365644d656d6265722c75696e74323536206d656d6265724e6f6e636529a26469706673582212208eb1d2dba1bc3c46f2670cd5b3ea366c10274b4fe6ad31ec713d710ce6a4999864736f6c63430008090033000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2

Deployed Bytecode

0x60806040526004361061016a5760003560e01c8063b244a41d116100cb578063d4e183441161007f578063ed53a96311610059578063ed53a963146103f9578063ef6a24991461040e578063fc2580311461042e57600080fd5b8063d4e18344146103a4578063e1b11da4146103c4578063e868a6bd146103d957600080fd5b8063ca0f4633116100b0578063ca0f46331461033b578063ccb3813a14610364578063d2c4de211461038457600080fd5b8063b244a41d14610306578063c7977be71461032657600080fd5b80635322d58c1161012257806384b732201161010757806384b73220146102b15780638ecf7720146102c65780639cf2fa27146102e657600080fd5b80635322d58c1461026f57806363a9fed71461028f57600080fd5b8063238a4d1e11610153578063238a4d1e146101da5780633d1f1e511461020a57806340e2dfcf1461024257600080fd5b806319045a251461016f5780631a25c910146101ac575b600080fd5b34801561017b57600080fd5b5061018f61018a366004613914565b61044e565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156101b857600080fd5b506101cc6101c7366004613970565b610463565b6040519081526020016101a3565b3480156101e657600080fd5b506101fa6101f53660046139b8565b6104cb565b60405190151581526020016101a3565b34801561021657600080fd5b506101cc610225366004613a11565b600260209081526000928352604080842090915290825290205481565b34801561024e57600080fd5b506101cc61025d366004613a4a565b60036020526000908152604090205481565b34801561027b57600080fd5b506101cc61028a366004613a67565b6104e2565b34801561029b57600080fd5b506102a4610577565b6040516101a39190613b3c565b6102c46102bf366004613b4f565b610593565b005b3480156102d257600080fd5b506101fa6102e1366004613a11565b6105a8565b3480156102f257600080fd5b506101cc610301366004613bbb565b61084a565b34801561031257600080fd5b506101cc610321366004613c0b565b61091c565b34801561033257600080fd5b506101cc610970565b34801561034757600080fd5b506101fa610356366004613a4a565b6001600160a01b0316151590565b34801561037057600080fd5b5061018f61037f366004613c39565b6109b2565b34801561039057600080fd5b506102c461039f366004613c7a565b610a73565b3480156103b057600080fd5b506102c46103bf366004613d28565b611891565b3480156103d057600080fd5b506102a46118a7565b3480156103e557600080fd5b506101cc6103f4366004613c39565b6118c3565b34801561040557600080fd5b506101cc611984565b34801561041a57600080fd5b506101fa610429366004613a4a565b6119ad565b34801561043a57600080fd5b506101fa610449366004613daf565b6119f1565b600061045a8383611a0e565b90505b92915050565b600061047085858561084a565b6040517f19010000000000000000000000000000000000000000000000000000000000006020820152602281019190915260428101839052606201604051602081830303815290604052805190602001209050949350505050565b60006104d8848484611a32565b90505b9392505050565b60008060405180606001604052806030815260200161415e6030913960405160200161050e9190613dd1565b60408051601f198184030181528282528051602091820120865187830151928501919091526001600160a01b031691830191909152606082015260800160405160208183030381529060405280519060200120905061056f84463084610463565b949350505050565b60405180606001604052806030815260200161415e6030913981565b6105a284846000348686611bba565b50505050565b6040517ffefbd8750000000000000000000000000000000000000000000000000000000081527fea0ca03c7adbe41dc655fec28a9209dc8e6e042f3d991a67765ba285b9cf73a0600482015260009081906001600160a01b0385169063fefbd8759060240160206040518083038186803b15801561062557600080fd5b505afa158015610639573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061065d9190613ded565b90506001600160a01b038116156107b8576040517fc89bb8ba0000000000000000000000000000000000000000000000000000000081526001600160a01b0384811660048301526000919086169063c89bb8ba9060240160206040518083038186803b1580156106cc57600080fd5b505afa1580156106e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107049190613ded565b6040517ff7888aec0000000000000000000000000000000000000000000000000000000081526001600160a01b038083166004830152620ff1ce602483015291925060009184169063f7888aec9060440160206040518083038186803b15801561076d57600080fd5b505afa158015610781573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107a59190613ded565b6001600160a01b0316119250505061045d565b6040517fa230c5240000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015285169063a230c5249060240160206040518083038186803b15801561081257600080fd5b505afa158015610826573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061056f9190613e0a565b60006040518060a00160405280606381526020016140fb606391396040516020016108759190613dd1565b60408051601f198184030181528282528051602091820120908301527fe2ffb2e2c8bf0b9b360ecefb7de0735865e605d6ba933b6c7e12cee0e178c8bf908201527f13600b294191fc92924bb3ce4b969c1e7e2bab8f4c93c3fc6d0a51733df3c0606060820152608081018490526001600160a01b0380861660a0830152831660c082015260e0016040516020818303038152906040528051906020012090509392505050565b600081151561092b85856119f1565b15151461096957811561095457610943836002613f76565b61094d9085613f82565b90506104db565b61095f836002613f76565b61094d9085613f9a565b50826104db565b6040518060a00160405280606381526020016140fb606391396040516020016109999190613dd1565b6040516020818303038152906040528051906020012081565b6000836001600160a01b031663fd310d29610a058585604080516001600160a01b038416602082015290810182905260009060600160405160208183030381529060405280519060200120905092915050565b6040518263ffffffff1660e01b8152600401610a2391815260200190565b60206040518083038186803b158015610a3b57600080fd5b505afa158015610a4f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104d89190613ded565b8a6000816001600160a01b031663c19d93fb6040518163ffffffff1660e01b815260040160206040518083038186803b158015610aaf57600080fd5b505afa158015610ac3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ae79190613fe0565b6001811115610af857610af8613fb1565b148015610b095750610b098161259d565b80610b9f57506040517f68c18beb0000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b038216906368c18beb9060240160206040518083038186803b158015610b6757600080fd5b505afa158015610b7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b9f9190613e0a565b610bf05760405162461bcd60e51b815260206004820152600b60248201527f6f6e6c794164617074657200000000000000000000000000000000000000000060448201526064015b60405180910390fd5b60008a118015610c0a57506affffffffffffffffffffff8a105b610c565760405162461bcd60e51b815260206004820152601260248201527f6368756e6b53697a653a3a696e76616c696400000000000000000000000000006044820152606401610be7565b600086118015610c7057506affffffffffffffffffffff86105b610cbc5760405162461bcd60e51b815260206004820152601360248201527f6d61784d656d626572733a3a696e76616c6964000000000000000000000000006044820152606401610be7565b600088118015610cd657506affffffffffffffffffffff88105b610d225760405162461bcd60e51b815260206004820152601660248201527f6d6178696d756d4368756e6b733a3a696e76616c6964000000000000000000006044820152606401610be7565b600087118015610d3c57506affffffffffffffffffffff87105b610d885760405162461bcd60e51b815260206004820152601160248201527f6d6178556e6974733a3a696e76616c69640000000000000000000000000000006044820152606401610be7565b600089118015610da257506affffffffffffffffffffff89105b610dee5760405162461bcd60e51b815260206004820152601660248201527f756e6974735065724368756e6b3a3a696e76616c6964000000000000000000006044820152606401610be7565b6affffffffffffffffffffff610e048a8a614001565b10610e515760405162461bcd60e51b815260206004820152601260248201527f706f74656e7469616c206f766572666c6f7700000000000000000000000000006044820152606401610be7565b6001600160a01b038b16610ea75760405162461bcd60e51b815260206004820152601660248201527f7369676e65722061646472657373206973206e696c21000000000000000000006044820152606401610be7565b6001600160a01b038216610efd5760405162461bcd60e51b815260206004820152601b60248201527f6e756c6c20696e7465726e616c20746f6b656e206164647265737300000000006044820152606401610be7565b604080516001600160a01b038581166020808401919091527f62fc88784e0c19cc8b8b751f1752ac9b0faec53f227474e9c143736b1b053bd28385015283518084038501815260608401808652815191909201207f3b4f921a0000000000000000000000000000000000000000000000000000000090915260648301528d811660848301529151918e1691633b4f921a9160a48082019260009290919082900301818387803b158015610faf57600080fd5b505af1158015610fc3573d6000803e3d6000fd5b5050604080516001600160a01b038781166020808401919091527fac22e216410db4a745e4c58279e55c551b17605a4393bcf3b64fa9262d9979dd83850152835180840385018152606090930190935281519190920120908f169250633b4f921a91506040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b16815260048101919091526001600160a01b0387166024820152604401600060405180830381600087803b15801561108657600080fd5b505af115801561109a573d6000803e3d6000fd5b5050604080516001600160a01b038781166020808401919091527fb024dc66daa5f76b3a0f3ca4879dc87b33f90cea509e863f3e0955b6222a3a1e83850152835180840385018152606084019485905280519101207fda0f6c70000000000000000000000000000000000000000000000000000000009093526064820192909252608481018e9052908f16925063da0f6c70915060a401600060405180830381600087803b15801561114b57600080fd5b505af115801561115f573d6000803e3d6000fd5b5050604080516001600160a01b038781166020808401919091527fe731ae3a43606ed081c5398551cfc363c835a134e5bde100a63ae178b3e8417583850152835180840385018152606084019485905280519101207fda0f6c70000000000000000000000000000000000000000000000000000000009093526064820192909252608481018d9052908f16925063da0f6c70915060a401600060405180830381600087803b15801561121057600080fd5b505af1158015611224573d6000803e3d6000fd5b5050604080516001600160a01b038781166020808401919091527f30671f20b402b0209c539f216c8370ad5c14d6756f759a0bb3e1c2b4869e9f2f83850152835180840385018152606084019485905280519101207fda0f6c70000000000000000000000000000000000000000000000000000000009093526064820192909252608481018c9052908f16925063da0f6c70915060a401600060405180830381600087803b1580156112d557600080fd5b505af11580156112e9573d6000803e3d6000fd5b5050604080516001600160a01b038781166020808401919091527ffdf6c9ba9b500ecb9379c7c8a8798f57b5727856cdf3b739640e2d178eaaa89483850152835180840385018152606084019485905280519101207fda0f6c70000000000000000000000000000000000000000000000000000000009093526064820192909252608481018b9052908f16925063da0f6c70915060a401600060405180830381600087803b15801561139a57600080fd5b505af11580156113ae573d6000803e3d6000fd5b5050604080516001600160a01b038781166020808401919091527f8f2f3c9bc35994511794a3bbcf840c067fce8d0a24cd068e9b0d4ce1f4b13ef083850152835180840385018152606084019485905280519101207fda0f6c70000000000000000000000000000000000000000000000000000000009093526064820192909252608481018a9052908f16925063da0f6c70915060a401600060405180830381600087803b15801561145f57600080fd5b505af1158015611473573d6000803e3d6000fd5b5050604080516001600160a01b038781166020808401919091527f1563be206c04f4a19d217b21c8dfa32bcc7747bde5e98f7760f02fa4bd4612ca83850152835180840385018152606090930190935281519190920120908f169250633b4f921a91506040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b16815260048101919091526001600160a01b0385166024820152604401600060405180830381600087803b15801561153657600080fd5b505af115801561154a573d6000803e3d6000fd5b5050604080516001600160a01b038781166020808401919091527f88da9ccc582665efc10ceaf87771d8f475c8be6b374a49034d994e91a1ea58b083850152835180840385018152606084019485905280519101207fda0f6c7000000000000000000000000000000000000000000000000000000000909352606482019290925260848101899052908f16925063da0f6c70915060a401600060405180830381600087803b1580156115fb57600080fd5b505af115801561160f573d6000803e3d6000fd5b50506040517f593e96b60000000000000000000000000000000000000000000000000000000081527fea0ca03c7adbe41dc655fec28a9209dc8e6e042f3d991a67765ba285b9cf73a06004820152600092506001600160a01b038f16915063593e96b69060240160206040518083038186803b15801561168e57600080fd5b505afa1580156116a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116c69190613ded565b90508c6001600160a01b0316816001600160a01b0316634162169f6040518163ffffffff1660e01b815260040160206040518083038186803b15801561170b57600080fd5b505afa15801561171f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117439190613ded565b6001600160a01b0316146117995760405162461bcd60e51b815260206004820152600b60248201527f696e76616c69642064616f0000000000000000000000000000000000000000006044820152606401610be7565b6040517ff7e15acf000000000000000000000000000000000000000000000000000000008152620ff1ce60048201526001600160a01b0382169063f7e15acf90602401600060405180830381600087803b1580156117f657600080fd5b505af115801561180a573d6000803e3d6000fd5b50506040517f69af242f0000000000000000000000000000000000000000000000000000000081526001600160a01b038781166004830152841692506369af242f9150602401600060405180830381600087803b15801561186a57600080fd5b505af115801561187e573d6000803e3d6000fd5b5050505050505050505050505050505050565b61189f868686868686611bba565b505050505050565b6040518060a00160405280606381526020016140fb6063913981565b6000836001600160a01b0316639283ae3a6119168585604080516001600160a01b038416602082015290810182905260009060600160405160208183030381529060405280519060200120905092915050565b6040518263ffffffff1660e01b815260040161193491815260200190565b60206040518083038186803b15801561194c57600080fd5b505afa158015611960573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104d8919061403e565b60405180606001604052806030815260200161415e603091396040516020016109999190613dd1565b60006001600160a01b03821661dead148015906119d557506001600160a01b03821661babe14155b801561045d57506001600160a01b038216614bec141592915050565b6000611a04600260ff841685901c614086565b6001149392505050565b6000806000611a1d858561273d565b91509150611a2a81612783565b509392505050565b6000806000611a41858561273d565b90925090506000816004811115611a5a57611a5a613fb1565b148015611a785750856001600160a01b0316826001600160a01b0316145b15611a88576001925050506104db565b600080876001600160a01b0316631626ba7e60e01b8888604051602401611ab092919061409a565b60408051601f198184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909416939093179092529051611b1b9190613dd1565b600060405180830381855afa9150503d8060008114611b56576040519150601f19603f3d011682016040523d82523d6000602084013e611b5b565b606091505b5091509150818015611b6e575080516020145b8015611bae575080517f1626ba7e0000000000000000000000000000000000000000000000000000000090611bac908301602090810190840161403e565b145b98975050505050505050565b6040517f397a69470000000000000000000000000000000000000000000000000000000081526001600160a01b038681166004830152611c5291889182169063397a69479060240160206040518083038186803b158015611c1a57600080fd5b505afa158015611c2e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102e19190613ded565b1580611c635750611c638685612977565b611caf5760405162461bcd60e51b815260206004820152600e60248201527f616c7265616479206d656d6265720000000000000000000000000000000000006044820152606401610be7565b6001600160a01b0385166000908152600360205260409020548211611d165760405162461bcd60e51b815260206004820152601060248201527f616c72656164792072656465656d6564000000000000000000000000000000006044820152606401610be7565b6001600160a01b0385811660009081526003602090815260408083208690558051888516818401527f8f2f3c9bc35994511794a3bbcf840c067fce8d0a24cd068e9b0d4ce1f4b13ef081830152815180820383018152606082019283905280519301929092207f9283ae3a0000000000000000000000000000000000000000000000000000000090915260648201529091881690639283ae3a9060840160206040518083038186803b158015611dcb57600080fd5b505afa158015611ddf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e03919061403e565b905060008111611e555760405162461bcd60e51b815260206004820152601460248201527f746f6b656e206e6f7420636f6e666967757265640000000000000000000000006044820152606401610be7565b80876001600160a01b031663c67143666040518163ffffffff1660e01b815260040160206040518083038186803b158015611e8f57600080fd5b505afa158015611ea3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ec7919061403e565b10611f145760405162461bcd60e51b815260206004820152600f60248201527f7468652044414f2069732066756c6c00000000000000000000000000000000006044820152606401610be7565b6000611f3d8860405180604001604052808a6001600160a01b03168152602001878152506104e2565b9050611f4b88878386612a61565b6000611f58898888612ba6565b60608101516001600160a01b03808c166000908152600260209081526040808320938d16835292905290812080549394506affffffffffffffffffffff90921692611fa4908490613f82565b90915550506040517f593e96b60000000000000000000000000000000000000000000000000000000081527fea0ca03c7adbe41dc655fec28a9209dc8e6e042f3d991a67765ba285b9cf73a060048201526000906001600160a01b038b169063593e96b69060240160206040518083038186803b15801561202457600080fd5b505afa158015612038573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061205c9190613ded565b9050896001600160a01b0316816001600160a01b0316634162169f6040518163ffffffff1660e01b815260040160206040518083038186803b1580156120a157600080fd5b505afa1580156120b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120d99190613ded565b6001600160a01b03161461212f5760405162461bcd60e51b815260206004820152600b60248201527f696e76616c69642064616f0000000000000000000000000000000000000000006044820152606401610be7565b61213a898b836131c4565b604080516001600160a01b038a81166020808401919091527fac22e216410db4a745e4c58279e55c551b17605a4393bcf3b64fa9262d9979dd83850152835180840385018152606084019485905280519101207ffd310d290000000000000000000000000000000000000000000000000000000090935260648201929092526000918c169063fd310d299060840160206040518083038186803b1580156121e057600080fd5b505afa1580156121f4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122189190613ded565b90506001600160a01b038116612377576001600160a01b0389166122c65760a08301516040517fc57d5fe900000000000000000000000000000000000000000000000000000000815261dead6004820152600060248201526001600160a01b03918216604482018190529184169163c57d5fe9916064016000604051808303818588803b1580156122a857600080fd5b505af11580156122bc573d6000803e3d6000fd5b5050505050612443565b60a08301516040517fc57d5fe900000000000000000000000000000000000000000000000000000000815261dead60048201526001600160a01b038b8116602483015291821660448201529083169063c57d5fe990606401600060405180830381600087803b15801561233857600080fd5b505af115801561234c573d6000803e3d6000fd5b50505060a08401518a9150612371906001600160a01b038084169133918791166133d1565b50612443565b6001600160a01b0389166124205760008054906101000a90046001600160a01b03166001600160a01b031663d0e30db08460a001516001600160a01b03166040518263ffffffff1660e01b81526004016000604051808303818588803b1580156123e057600080fd5b505af11580156123f4573d6000803e3d6000fd5b50505060a085015160015461241b93506001600160a01b03908116925030918591166133d1565b612443565b60a08301518990612441906001600160a01b038084169133918691166133d1565b505b60608301516040517fc57d5fe90000000000000000000000000000000000000000000000000000000081526001600160a01b038c81166004830152620ff1ce60248301526affffffffffffffffffffff90921660448201529083169063c57d5fe990606401600060405180830381600087803b1580156124c257600080fd5b505af11580156124d6573d6000803e3d6000fd5b505050508260a001516001600160a01b0316881180156124fd57506001600160a01b038916155b15612525576125258360a001516001600160a01b03163461251e9190613f9a565b3390613459565b7fae72ee3a8d22d597e0c519e76231f6a7a76458404a08fd8299fd971da8f9915b8b8b8560600151604051612588939291906001600160a01b0393841681529190921660208201526affffffffffffffffffffff91909116604082015260600190565b60405180910390a15050505050505050505050565b6000816001600160a01b031663c67143666040518163ffffffff1660e01b815260040160206040518083038186803b1580156125d857600080fd5b505afa1580156125ec573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612610919061403e565b15806126a757506040517fa230c5240000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b0383169063a230c5249060240160206040518083038186803b15801561266f57600080fd5b505afa158015612683573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126a79190613e0a565b8061045d57506040517f68c18beb0000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b038316906368c18beb9060240160206040518083038186803b15801561270557600080fd5b505afa158015612719573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061045d9190613e0a565b6000808251604114156127745760208301516040840151606085015160001a61276887828585613572565b9450945050505061277c565b506000905060025b9250929050565b600081600481111561279757612797613fb1565b14156127a05750565b60018160048111156127b4576127b4613fb1565b14156128025760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610be7565b600281600481111561281657612816613fb1565b14156128645760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610be7565b600381600481111561287857612878613fb1565b14156128ec5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152608401610be7565b600481600481111561290057612900613fb1565b14156129745760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152608401610be7565b50565b600080836001600160a01b0316639283ae3a6129eb857f88da9ccc582665efc10ceaf87771d8f475c8be6b374a49034d994e91a1ea58b0604080516001600160a01b038416602082015290810182905260009060600160405160208183030381529060405280519060200120905092915050565b6040518263ffffffff1660e01b8152600401612a0991815260200190565b60206040518083038186803b158015612a2157600080fd5b505afa158015612a35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a59919061403e565b119392505050565b604080516001600160a01b038581166020808401919091527f62fc88784e0c19cc8b8b751f1752ac9b0faec53f227474e9c143736b1b053bd283850152835180840385018152606084019485905280519101207ffd310d290000000000000000000000000000000000000000000000000000000090935260648201929092529085169063fd310d299060840160206040518083038186803b158015612b0557600080fd5b505afa158015612b19573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b3d9190613ded565b6001600160a01b0316612b508383611a0e565b6001600160a01b0316146105a25760405162461bcd60e51b815260206004820152600b60248201527f696e76616c6964207369670000000000000000000000000000000000000000006044820152606401610be7565b6040805160c0810182526000808252602080830182905282840182905260608084018390526080840183905260a084019290925283516001600160a01b03878116828401527fb024dc66daa5f76b3a0f3ca4879dc87b33f90cea509e863f3e0955b6222a3a1e8287015285518083038701815293820195869052835193909201929092207f9283ae3a0000000000000000000000000000000000000000000000000000000090945260648201939093529091851690639283ae3a9060840160206040518083038186803b158015612c7c57600080fd5b505afa158015612c90573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cb4919061403e565b6affffffffffffffffffffff16808252612d105760405162461bcd60e51b815260206004820152601860248201527f636f6e666967206368756e6b53697a65206d697373696e6700000000000000006044820152606401610be7565b8051612d29906affffffffffffffffffffff16836140b3565b6affffffffffffffffffffff1660208201819052612d895760405162461bcd60e51b815260206004820152601260248201527f696e73756666696369656e742066756e647300000000000000000000000000006044820152606401610be7565b604080516001600160a01b038581166020808401919091527f30671f20b402b0209c539f216c8370ad5c14d6756f759a0bb3e1c2b4869e9f2f83850152835180840385018152606084019485905280519101207f9283ae3a00000000000000000000000000000000000000000000000000000000909352606482019290925290851690639283ae3a9060840160206040518083038186803b158015612e2d57600080fd5b505afa158015612e41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e65919061403e565b81602001516affffffffffffffffffffff161115612ec55760405162461bcd60e51b815260206004820152600e60248201527f746f6f206d7563682066756e64730000000000000000000000000000000000006044820152606401610be7565b604080516001600160a01b038581166020808401919091527fe731ae3a43606ed081c5398551cfc363c835a134e5bde100a63ae178b3e8417583850152835180840385018152606084019485905280519101207f9283ae3a00000000000000000000000000000000000000000000000000000000909352606482019290925290851690639283ae3a9060840160206040518083038186803b158015612f6957600080fd5b505afa158015612f7d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fa1919061403e565b6affffffffffffffffffffff16604082018190526130015760405162461bcd60e51b815260206004820152601c60248201527f636f6e66696720756e6974735065724368756e6b206d697373696e67000000006044820152606401610be7565b8051602082015161301291906140c7565b6affffffffffffffffffffff1660a08201526040810151602082015161303891906140c7565b6affffffffffffffffffffff1660608201526001600160a01b038416639283ae3a6130bb857ffdf6c9ba9b500ecb9379c7c8a8798f57b5727856cdf3b739640e2d178eaaa894604080516001600160a01b038416602082015290810182905260009060600160405160208183030381529060405280519060200120905092915050565b6040518263ffffffff1660e01b81526004016130d991815260200190565b60206040518083038186803b1580156130f157600080fd5b505afa158015613105573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613129919061403e565b6affffffffffffffffffffff908116608083018190526001600160a01b03808716600090815260026020908152604080832093891683529290522054606084015191926131769216613f82565b11156104db5760405162461bcd60e51b815260206004820152601460248201527f6f766572206d617820746f74616c20756e6974730000000000000000000000006044820152606401610be7565b6040517fdc929f4a0000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015283169063dc929f4a90602401600060405180830381600087803b15801561322057600080fd5b505af1158015613234573d6000803e3d6000fd5b505050506001600160a01b03831661328e5760405162461bcd60e51b815260206004820152601660248201527f696e76616c6964206d656d6265722061646472657373000000000000000000006044820152606401610be7565b6001600160a01b038116156133cc576040517ff7888aec0000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015263decafbad602483015282169063f7888aec9060440160206040518083038186803b15801561330157600080fd5b505afa158015613315573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133399190613ded565b6001600160a01b03166133cc576040517fc57d5fe90000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015263decafbad60248301526001604483015282169063c57d5fe990606401600060405180830381600087803b1580156133b357600080fd5b505af11580156133c7573d6000803e3d6000fd5b505050505b505050565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd000000000000000000000000000000000000000000000000000000001790526105a290859061365f565b804710156134a95760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610be7565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146134f6576040519150601f19603f3d011682016040523d82523d6000602084013e6134fb565b606091505b50509050806133cc5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610be7565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156135a95750600090506003613656565b8460ff16601b141580156135c157508460ff16601c14155b156135d25750600090506004613656565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015613626573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661364f57600060019250925050613656565b9150600090505b94509492505050565b60006136b4826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166137449092919063ffffffff16565b8051909150156133cc57808060200190518101906136d29190613e0a565b6133cc5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610be7565b60606104d88484600085856001600160a01b0385163b6137a65760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610be7565b600080866001600160a01b031685876040516137c29190613dd1565b60006040518083038185875af1925050503d80600081146137ff576040519150601f19603f3d011682016040523d82523d6000602084013e613804565b606091505b509150915061381482828661381f565b979650505050505050565b6060831561382e5750816104db565b82511561383e5782518084602001fd5b8160405162461bcd60e51b8152600401610be79190613b3c565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261389857600080fd5b813567ffffffffffffffff808211156138b3576138b3613858565b604051601f8301601f19908116603f011681019082821181831017156138db576138db613858565b816040528381528660208588010111156138f457600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806040838503121561392757600080fd5b82359150602083013567ffffffffffffffff81111561394557600080fd5b61395185828601613887565b9150509250929050565b6001600160a01b038116811461297457600080fd5b6000806000806080858703121561398657600080fd5b84356139918161395b565b93506020850135925060408501356139a88161395b565b9396929550929360600135925050565b6000806000606084860312156139cd57600080fd5b83356139d88161395b565b925060208401359150604084013567ffffffffffffffff8111156139fb57600080fd5b613a0786828701613887565b9150509250925092565b60008060408385031215613a2457600080fd5b8235613a2f8161395b565b91506020830135613a3f8161395b565b809150509250929050565b600060208284031215613a5c57600080fd5b81356104db8161395b565b6000808284036060811215613a7b57600080fd5b8335613a868161395b565b92506040601f1982011215613a9a57600080fd5b506040516040810181811067ffffffffffffffff82111715613abe57613abe613858565b6040526020840135613acf8161395b565b81526040939093013560208401525092909150565b60005b83811015613aff578181015183820152602001613ae7565b838111156105a25750506000910152565b60008151808452613b28816020860160208601613ae4565b601f01601f19169290920160200192915050565b60208152600061045a6020830184613b10565b60008060008060808587031215613b6557600080fd5b8435613b708161395b565b93506020850135613b808161395b565b925060408501359150606085013567ffffffffffffffff811115613ba357600080fd5b613baf87828801613887565b91505092959194509250565b600080600060608486031215613bd057600080fd5b8335613bdb8161395b565b9250602084013591506040840135613bf28161395b565b809150509250925092565b801515811461297457600080fd5b600080600060608486031215613c2057600080fd5b83359250602084013591506040840135613bf281613bfd565b600080600060608486031215613c4e57600080fd5b8335613c598161395b565b92506020840135613c698161395b565b929592945050506040919091013590565b60008060008060008060008060008060006101608c8e031215613c9c57600080fd5b8b35613ca78161395b565b9a5060208c0135613cb78161395b565b995060408c0135985060608c0135975060808c0135965060a08c0135955060c08c0135945060e08c013593506101008c0135613cf28161395b565b92506101208c0135613d038161395b565b91506101408c0135613d148161395b565b809150509295989b509295989b9093969950565b60008060008060008060c08789031215613d4157600080fd5b8635613d4c8161395b565b95506020870135613d5c8161395b565b94506040870135613d6c8161395b565b9350606087013592506080870135915060a087013567ffffffffffffffff811115613d9657600080fd5b613da289828a01613887565b9150509295509295509295565b60008060408385031215613dc257600080fd5b50508035926020909101359150565b60008251613de3818460208701613ae4565b9190910192915050565b600060208284031215613dff57600080fd5b81516104db8161395b565b600060208284031215613e1c57600080fd5b81516104db81613bfd565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600181815b80851115613eaf57817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115613e9557613e95613e27565b80851615613ea257918102915b93841c9390800290613e5b565b509250929050565b600082613ec65750600161045d565b81613ed35750600061045d565b8160018114613ee95760028114613ef357613f0f565b600191505061045d565b60ff841115613f0457613f04613e27565b50506001821b61045d565b5060208310610133831016604e8410600b8410161715613f32575081810a61045d565b613f3c8383613e56565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115613f6e57613f6e613e27565b029392505050565b600061045a8383613eb7565b60008219821115613f9557613f95613e27565b500190565b600082821015613fac57613fac613e27565b500390565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b600060208284031215613ff257600080fd5b8151600281106104db57600080fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561403957614039613e27565b500290565b60006020828403121561405057600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60008261409557614095614057565b500690565b8281526040602082015260006104d86040830184613b10565b6000826140c2576140c2614057565b500490565b60006affffffffffffffffffffff808316818516818304811182151516156140f1576140f1613e27565b0294935050505056fe454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e74726163742c6164647265737320616374696f6e4964294d6573736167652861646472657373206b796365644d656d6265722c75696e74323536206d656d6265724e6f6e636529a26469706673582212208eb1d2dba1bc3c46f2670cd5b3ea366c10274b4fe6ad31ec713d710ce6a4999864736f6c63430008090033

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

000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2

-----Decoded View---------------
Arg [0] : weth (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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