Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0xC3fB0b7a48b56aC5F2CF08Ff07ea1878d63caaD0
Balance 0 ETH
Nonce 1
Code Size 3782 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

3782 bytes
0x6080604052600436106100c55760003560e01c80638da5cb5b1161007f578063c4d66de811610059578063c4d66de814610213578063d559b08214610233578063e2605dad1461025b578063f2fde38b1461027157600080fd5b80638da5cb5b146101a5578063b9946149146101c3578063c494e3c9146101eb57600080fd5b80622531f8146100d15780633b84e209146100fc5780634f0447781461011c57806363cfdc6d14610159578063715018a61461016e57806384a602321461018557600080fd5b366100cc57005b600080fd5b3480156100dd57600080fd5b506100e9633722614081565b6040519081526020015b60405180910390f35b34801561010857600080fd5b506100e9610117366004610bbb565b610291565b34801561012857600080fd5b506065546101419061010090046001600160a01b031681565b6040516001600160a01b0390911681526020016100f3565b34801561016557600080fd5b506100e9602d81565b34801561017a57600080fd5b50610183610656565b005b34801561019157600080fd5b506101836101a0366004610c18565b61068c565b3480156101b157600080fd5b506033546001600160a01b0316610141565b3480156101cf57600080fd5b5061014173f6dd68031a22c8a3f1e7a424ce8f43a1e1a3be3e81565b3480156101f757600080fd5b5061014173b8ee07b5ed2ff9dae6c504c9dee84151f844a59181565b34801561021f57600080fd5b5061018361022e366004610b97565b6107ac565b34801561023f57600080fd5b5061014173ca00f8eef4ce1f9183e06fa25fe7872fedcf745681565b34801561026757600080fd5b506100e961092e81565b34801561027d57600080fd5b5061018361028c366004610b97565b6108df565b60655460009060ff166102eb5760405162461bcd60e51b815260206004820152601a60248201527f5772617070696e67206e6f742079657420617661696c61626c6500000000000060448201526064015b60405180910390fd5b3384156103ba576040516323b872dd60e01b81526001600160a01b038216600482015273deadbeefdeadbeefdeadbeefdeadbeefdeadbeef60248201526044810186905273f6dd68031a22c8a3f1e7a424ce8f43a1e1a3be3e906323b872dd90606401602060405180830381600087803b15801561036857600080fd5b505af115801561037c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103a09190610bf6565b506103ad61092e86610e00565b6103b79083610de8565b91505b831561048a576040516323b872dd60e01b81526001600160a01b038216600482015273deadbeefdeadbeefdeadbeefdeadbeefdeadbeef60248201526044810185905273b8ee07b5ed2ff9dae6c504c9dee84151f844a591906323b872dd90606401602060405180830381600087803b15801561043657600080fd5b505af115801561044a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061046e9190610bf6565b5061047d633722614085610e00565b6104879083610de8565b91505b8215610557576040516323b872dd60e01b81526001600160a01b038216600482015273deadbeefdeadbeefdeadbeefdeadbeefdeadbeef60248201526044810184905273ca00f8eef4ce1f9183e06fa25fe7872fedcf7456906323b872dd90606401602060405180830381600087803b15801561050657600080fd5b505af115801561051a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061053e9190610bf6565b5061054a602d84610e00565b6105549083610de8565b91505b600082116105995760405162461bcd60e51b815260206004820152600f60248201526e04e4f5448494e475f544f5f5752415608c1b60448201526064016102e2565b6001600160a01b0386166105e15760405162461bcd60e51b815260206004820152600f60248201526e4e4f5f5a45524f5f4144445245535360881b60448201526064016102e2565b60655460405163219e412d60e21b81526001600160a01b038881166004830152602482018590526101009092049091169063867904b490604401600060405180830381600087803b15801561063557600080fd5b505af1158015610649573d6000803e3d6000fd5b5050505050949350505050565b6033546001600160a01b031633146106805760405162461bcd60e51b81526004016102e290610d68565b61068a600061097a565b565b6033546001600160a01b031633146106b65760405162461bcd60e51b81526004016102e290610d68565b6001600160a01b03841661075e576000836001600160a01b03168360405160006040518083038185875af1925050503d8060008114610711576040519150601f19603f3d011682016040523d82523d6000602084013e610716565b606091505b50509050806107585760405162461bcd60e51b815260206004820152600e60248201526d1410565351539517d1905253115160921b60448201526064016102e2565b50610769565b6107698484846109cc565b7fd8b698ac671a4f14720b5e36de4daa40f05f109182b33b75e09276a122bb65328385848460405161079e9493929190610d14565b60405180910390a150505050565b600054610100900460ff166107c75760005460ff16156107cb565b303b155b61082e5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016102e2565b600054610100900460ff16158015610850576000805461ffff19166101011790555b735a16552f59ea34e44ec81e58b3817833e9fd543633146108995760405162461bcd60e51b815260206004820152600360248201526242554d60e81b60448201526064016102e2565b6108a1610b09565b6065805460ff196001600160a01b03851661010002166001600160a81b031990911617600117905580156108db576000805461ff00191690555b5050565b6033546001600160a01b031633146109095760405162461bcd60e51b81526004016102e290610d68565b6001600160a01b03811661096e5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016102e2565b6109778161097a565b50565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b604080518082018252601981527f7472616e7366657228616464726573732c75696e74323536290000000000000060209182015281516001600160a01b0385811660248301526044808301869052845180840390910181526064909201845291810180516001600160e01b031663a9059cbb60e01b17905291516000928392871691610a589190610cf8565b6000604051808303816000865af19150503d8060008114610a95576040519150601f19603f3d011682016040523d82523d6000602084013e610a9a565b606091505b5091509150818015610ac4575080511580610ac4575080806020019051810190610ac49190610bf6565b610b025760405162461bcd60e51b815260206004820152600f60248201526e1514905394d1915497d19052531151608a1b60448201526064016102e2565b5050505050565b600054610100900460ff16610b305760405162461bcd60e51b81526004016102e290610d9d565b610b38610b40565b61068a610b67565b600054610100900460ff1661068a5760405162461bcd60e51b81526004016102e290610d9d565b600054610100900460ff16610b8e5760405162461bcd60e51b81526004016102e290610d9d565b61068a3361097a565b600060208284031215610ba957600080fd5b8135610bb481610e7b565b9392505050565b60008060008060808587031215610bd157600080fd5b8435610bdc81610e7b565b966020860135965060408601359560600135945092505050565b600060208284031215610c0857600080fd5b81518015158114610bb457600080fd5b60008060008060808587031215610c2e57600080fd5b8435610c3981610e7b565b93506020850135610c4981610e7b565b925060408501359150606085013567ffffffffffffffff80821115610c6d57600080fd5b818701915087601f830112610c8157600080fd5b813581811115610c9357610c93610e65565b604051601f8201601f19908116603f01168101908382118183101715610cbb57610cbb610e65565b816040528281528a6020848701011115610cd457600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b60008251610d0a818460208701610e1f565b9190910192915050565b600060018060a01b038087168352808616602084015250836040830152608060608301528251806080840152610d518160a0850160208701610e1f565b601f01601f19169190910160a00195945050505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60008219821115610dfb57610dfb610e4f565b500190565b6000816000190483118215151615610e1a57610e1a610e4f565b500290565b60005b83811015610e3a578181015183820152602001610e22565b83811115610e49576000848401525b50505050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461097757600080fdfea26469706673582212209d91780cae58f5b84902d3a0e435b48f6058368428f68c906694efedc62a0d5d64736f6c63430008060033

Verified Source Code Partial Match

Compiler: v0.8.6+commit.11564f7e EVM: berlin Optimization: Yes (200 runs)
CoreDAOTreasury.sol 618 lines
/** 
 *  SourceUnit: /Users/macos/dev/cLend/contracts/CoreDAOTreasury.sol
*/
            
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [////IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 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 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

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}




/** 
 *  SourceUnit: /Users/macos/dev/cLend/contracts/CoreDAOTreasury.sol
*/
            
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/utils/Initializable.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the
 * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() initializer {}
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

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

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        // If the contract is initializing we ignore whether _initialized is set in order to support multiple
        // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the
        // contract may have been reentered.
        require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

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

    function _isConstructor() private view returns (bool) {
        return !AddressUpgradeable.isContract(address(this));
    }
}




/** 
 *  SourceUnit: /Users/macos/dev/cLend/contracts/CoreDAOTreasury.sol
*/
            
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

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

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

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

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
    uint256[50] private __gap;
}




/** 
 *  SourceUnit: /Users/macos/dev/cLend/contracts/CoreDAOTreasury.sol
*/
            
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @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 `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, 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 `sender` to `recipient` 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 sender,
        address recipient,
        uint256 amount
    ) external returns (bool);

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




/** 
 *  SourceUnit: /Users/macos/dev/cLend/contracts/CoreDAOTreasury.sol
*/
            
////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

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

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

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


/** 
 *  SourceUnit: /Users/macos/dev/cLend/contracts/CoreDAOTreasury.sol
*/

////// SPDX-License-Identifier-FLATTEN-SUPPRESS-WARNING: UNLICENSED

pragma solidity =0.8.6;

////import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
////import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface ICOREDAO {
    function issue(address, uint256) external;
}

/**
 * @title Protocol treasury contract
 * @author CVault Finance
 */
contract CoreDAOTreasury is OwnableUpgradeable {
    // TODO : check addresses for 100% accuracy
    IERC20 public constant LP1_VOUCHER = IERC20(0xF6Dd68031a22c8A3F1e7a424cE8F43a1e1A3be3E);
    IERC20 public constant LP2_VOUCHER = IERC20(0xb8ee07B5ED2FF9dae6C504C9dEe84151F844a591);
    IERC20 public constant LP3_VOUCHER = IERC20(0xcA00F8eef4cE1F9183E06fA25fE7872fEDcf7456);
    address private constant DEADBEEF = 0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF;

    // TODO : check numbers for accuracy and conduct number tests

    uint256 public constant DAO_TOKENS_IN_LP1 = 2350;
    uint256 public constant DAO_TOKENS_IN_LP2 = 9250e5;
    uint256 public constant DAO_TOKENS_IN_LP3 = 45;
    bool live = false;

    ICOREDAO public coreDAO;

    event Payment(address toWho, address whatToken, uint256 howMuch, string note);

    function initialize(ICOREDAO _coreDAO) public initializer {
        require(msg.sender == 0x5A16552f59ea34E44ec81E58b3817833E9fD5436,"BUM");

        __Ownable_init();
        coreDAO = _coreDAO;
        live = true;
    }
    
    // Allow contract to get ETH since we have a pay() function that lets ETH not get stuck
    receive() external payable {}

    // Governor (owner contract) pays a community member with ETH or a token inside the treasury
    // ETH can be transfered with supplying 0x0 for "token"
    function pay(
        IERC20 token,
        address payable who,
        uint256 howManyTokens,
        string memory note
    ) public onlyOwner {
        // Flag ETH transfer
        if (token == IERC20(address(0))) {
            (bool ok, ) = who.call{value: howManyTokens}("");
            require(ok, "PAYMENT_FAILED");
        // Normal token transfer
        } else {
            // we dont check any returns cause it can be recalled
            _safeTransfer(address(token), who, howManyTokens);
        }

        emit Payment(who, address(token), howManyTokens, note);
    }

    function wrapVouchers(
        address to,
        uint256 balanceLP1User,
        uint256 balanceLP2User,
        uint256 balanceLP3User
    ) external returns (uint256 mintAmount) {
        require(live, "Wrapping not yet available");
        address from = msg.sender;
        if (balanceLP1User > 0) {
            LP1_VOUCHER.transferFrom(from, DEADBEEF, balanceLP1User);
            mintAmount = mintAmount + (balanceLP1User * DAO_TOKENS_IN_LP1);
        }

        if (balanceLP2User > 0) {
            LP2_VOUCHER.transferFrom(from, DEADBEEF, balanceLP2User);
            mintAmount = mintAmount + (balanceLP2User * DAO_TOKENS_IN_LP2);
        }

        if (balanceLP3User > 0) {
            LP3_VOUCHER.transferFrom(from, DEADBEEF, balanceLP3User);
            mintAmount = mintAmount + (balanceLP3User * DAO_TOKENS_IN_LP3);
        }

        // No-0 check
        require(mintAmount > 0, "NOTHING_TO_WRAP");
        require(to != address(0), "NO_ZERO_ADDRESS");

        // Simple permissioned wrapper over the coreDAO token mint function
        coreDAO.issue(to, mintAmount);

        return mintAmount;
    }

    function _safeTransfer(
        address token,
        address to,
        uint256 value
    ) private {
        (bool success, bytes memory data) = token.call(
            abi.encodeWithSelector(bytes4(keccak256(bytes("transfer(address,uint256)"))), to, value)
        );
        require(success && (data.length == 0 || abi.decode(data, (bool))), "TRANSFER_FAILED");
    }
}

Read Contract

DAO_TOKENS_IN_LP1 0xe2605dad → uint256
DAO_TOKENS_IN_LP2 0x002531f8 → uint256
DAO_TOKENS_IN_LP3 0x63cfdc6d → uint256
LP1_VOUCHER 0xb9946149 → address
LP2_VOUCHER 0xc494e3c9 → address
LP3_VOUCHER 0xd559b082 → address
coreDAO 0x4f044778 → address
owner 0x8da5cb5b → address

Write Contract 5 functions

These functions modify contract state and require a wallet transaction to execute.

initialize 0xc4d66de8
address _coreDAO
pay 0x84a60232
address token
address who
uint256 howManyTokens
string note
renounceOwnership 0x715018a6
No parameters
transferOwnership 0xf2fde38b
address newOwner
wrapVouchers 0x3b84e209
address to
uint256 balanceLP1User
uint256 balanceLP2User
uint256 balanceLP3User
returns: uint256

Recent Transactions

No transactions found for this address