Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0x6D4625De53124d21a82dfb10cDb9B9f2F6D47C3c
Balance 0 ETH
Nonce 1
Code Size 4413 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

4413 bytes
0x608060405234801561000f575f80fd5b506004361061009c575f3560e01c8063ca907f2b11610064578063ca907f2b14610134578063de9375f214610152578063e13b468e14610170578063e8068e441461018c578063f3fef3a3146101ab5761009c565b806313af4035146100a05780631ebaa3a1146100bc57806328f2fe0c146100da5780638da5cb5b146100f8578063a62aca1e14610116575b5f80fd5b6100ba60048036038101906100b59190610b47565b6101c7565b005b6100c4610326565b6040516100d19190610b8a565b60405180910390f35b6100e261032c565b6040516100ef9190610b8a565b60405180910390f35b610100610332565b60405161010d9190610bb2565b60405180910390f35b61011e610357565b60405161012b9190610bb2565b60405180910390f35b61013c61037c565b6040516101499190610b8a565b60405180910390f35b61015a610382565b6040516101679190610bb2565b60405180910390f35b61018a60048036038101906101859190610b47565b6103a5565b005b61019461050b565b6040516101a2929190610bcb565b60405180910390f35b6101c560048036038101906101c09190610c1c565b6107ec565b005b5f73ffffffffffffffffffffffffffffffffffffffff1660015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610256576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161024d90610cb4565b60405180910390fd5b5f8054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146102e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102da90610d1c565b60405180910390fd5b8060015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600a5481565b60095481565b60015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60085481565b5f8054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b5f73ffffffffffffffffffffffffffffffffffffffff1660025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610434576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042b90610d84565b60405180910390fd5b5f8054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146104c1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104b890610d1c565b60405180910390fd5b8060025f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055504260058190555050565b5f805f62015180600554426105209190610dcf565b61052a9190610e2f565b90505f60025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016105879190610bb2565b602060405180830381865afa1580156105a2573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105c69190610e73565b90505f600754146105d75760075490505b6009548211156105e75760095491505b5f670de0b6b3a764000090505f8190505f805f5b6009548161ffff16101561063c57600854846106179190610e9e565b9350612710846106279190610e2f565b9350808061063490610eec565b9150506105fb565b5082846106499190610dcf565b91508183866106589190610e9e565b6106629190610e2f565b90505f600a546103e86106759190610dcf565b90505f8590505f5b888161ffff1610156106bc57600854826106979190610e9e565b9150612710826106a79190610e2f565b915080806106b490610eec565b91505061067d565b505f81905081876106cd9190610dcf565b91506103e888600a546106e09190610e9e565b6106ea9190610e2f565b6103e8828486886106fb9190610e9e565b6107059190610e9e565b61070f9190610e2f565b6107199190610e2f565b6107239190610f15565b975060095489036107345760075497505b600654886107429190610dcf565b60025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161079c9190610bb2565b602060405180830381865afa1580156107b7573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107db9190610e73565b9a509a505050505050505050509091565b5f600754036108955760025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161084f9190610bb2565b602060405180830381865afa15801561086a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061088e9190610e73565b6007819055505b61089d61050b565b60035f60045f84919050558391905055505060015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461093e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161093590610f92565b60405180910390fd5b5f60035411610982576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161097990610ffa565b60405180910390fd5b6003548111156109c7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109be90611062565b60405180910390fd5b8060045f8282546109d89190610dcf565b925050819055508060035f8282546109f09190610dcf565b925050819055508060065f828254610a089190610f15565b9250508190555060025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb83836040518363ffffffff1660e01b8152600401610a6b929190611080565b6020604051808303815f875af1158015610a87573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610aab91906110dc565b507f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a94243648282604051610add929190611080565b60405180910390a15050565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610b1682610aed565b9050919050565b610b2681610b0c565b8114610b30575f80fd5b50565b5f81359050610b4181610b1d565b92915050565b5f60208284031215610b5c57610b5b610ae9565b5b5f610b6984828501610b33565b91505092915050565b5f819050919050565b610b8481610b72565b82525050565b5f602082019050610b9d5f830184610b7b565b92915050565b610bac81610b0c565b82525050565b5f602082019050610bc55f830184610ba3565b92915050565b5f604082019050610bde5f830185610b7b565b610beb6020830184610b7b565b9392505050565b610bfb81610b72565b8114610c05575f80fd5b50565b5f81359050610c1681610bf2565b92915050565b5f8060408385031215610c3257610c31610ae9565b5b5f610c3f85828601610b33565b9250506020610c5085828601610c08565b9150509250929050565b5f82825260208201905092915050565b7f6f776e65722069732073657474656421000000000000000000000000000000005f82015250565b5f610c9e601083610c5a565b9150610ca982610c6a565b602082019050919050565b5f6020820190508181035f830152610ccb81610c92565b9050919050565b7f6d73672e73656e646572206973206e6f742041757468210000000000000000005f82015250565b5f610d06601783610c5a565b9150610d1182610cd2565b602082019050919050565b5f6020820190508181035f830152610d3381610cfa565b9050919050565b7f746b6e436f6e74726163742069732073657474656421000000000000000000005f82015250565b5f610d6e601683610c5a565b9150610d7982610d3a565b602082019050919050565b5f6020820190508181035f830152610d9b81610d62565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f610dd982610b72565b9150610de483610b72565b9250828203905081811115610dfc57610dfb610da2565b5b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f610e3982610b72565b9150610e4483610b72565b925082610e5457610e53610e02565b5b828204905092915050565b5f81519050610e6d81610bf2565b92915050565b5f60208284031215610e8857610e87610ae9565b5b5f610e9584828501610e5f565b91505092915050565b5f610ea882610b72565b9150610eb383610b72565b9250828202610ec181610b72565b91508282048414831517610ed857610ed7610da2565b5b5092915050565b5f61ffff82169050919050565b5f610ef682610edf565b915061ffff8203610f0a57610f09610da2565b5b600182019050919050565b5f610f1f82610b72565b9150610f2a83610b72565b9250828201905080821115610f4257610f41610da2565b5b92915050565b7f6d73672e73656e646572206973206e6f74204f776e65722100000000000000005f82015250565b5f610f7c601883610c5a565b9150610f8782610f48565b602082019050919050565b5f6020820190508181035f830152610fa981610f70565b9050919050565b7f756e6c6f636b656442616c616e636520697320300000000000000000000000005f82015250565b5f610fe4601483610c5a565b9150610fef82610fb0565b602082019050919050565b5f6020820190508181035f83015261101181610fd8565b9050919050565b7f756e6c6f636b656442616c616e636520697320626967676572000000000000005f82015250565b5f61104c601983610c5a565b915061105782611018565b602082019050919050565b5f6020820190508181035f83015261107981611040565b9050919050565b5f6040820190506110935f830185610ba3565b6110a06020830184610b7b565b9392505050565b5f8115159050919050565b6110bb816110a7565b81146110c5575f80fd5b50565b5f815190506110d6816110b2565b92915050565b5f602082840312156110f1576110f0610ae9565b5b5f6110fe848285016110c8565b9150509291505056fea2646970667358221220fb6048561350dce4f09fc4438adeb98afad372ee92aacadaacb466e63306a1d564736f6c63430008140033

Verified Source Code Partial Match

Compiler: v0.8.20+commit.a1b79de6 EVM: shanghai Optimization: No
Vault.sol 868 lines
// File: @openzeppelin/contracts/utils/math/SafeMath.sol


// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

// File: @openzeppelin/contracts/utils/Address.sol


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

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library 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 functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

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

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

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

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

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

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

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

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

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

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

// File: @openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol


// 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: @openzeppelin/contracts/token/ERC20/IERC20.sol


// 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: @openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol


// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;




/**
 * @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: contracts/Vault.sol



pragma solidity ^0.8.11;




contract Vault {
    using SafeMath for uint256;
    using SafeERC20 for IERC20;

    address public auth;
    address public owner;
    address public tknContract;

    uint256 private unlockedBalance;
    uint256 private totalBalance;
    uint256 private startTime;

    uint256 private totalWithdraw;
    uint256 private initialTotal;

    uint256 public c_i = 9940; //decimal 4 (1 - 10000)
    uint256 public c_t = 720; // 1-1825
    uint256 public c_y0 = 4; //decimal 1 (0 - 1000)

    event Withdraw(address withdrawer, uint256 amount);

    /**
    @notice set inital parameters for this contract
    @param _c_i Concave (0 ~ 10000)
    @param _c_t Days (1 ~ 1825)
    @param _c_y0 Starting Point (0 ~ 1000) decimal
    */
    constructor(uint256 _c_i, uint256 _c_t, uint256 _c_y0) {
        auth = msg.sender;
        c_t = _c_t;
        c_i = _c_i;
        c_y0 = _c_y0;
    }

    /**
    @notice Set Token contract address
    @param _TknContract Token Contract Address
    */
    function setTkn(address _TknContract) public {
        require(tknContract == address(0), "tknContract is setted!");
        require(msg.sender == auth, "msg.sender is not Auth!");
        tknContract = _TknContract;

        startTime = block.timestamp;
    }

    /**
    @notice Set Owner
    @param _owner Owner who can withdraw tokens
    */
    function setOwner(address _owner) public {
        require(owner == address(0), "owner is setted!");
        require(msg.sender == auth, "msg.sender is not Auth!");
        owner = _owner;
    }

    /**
    @notice Get unlockedBalance and totalBalance for realtime
    */
    function getUnlocked_TotalBalance() public view returns (uint256, uint256){
        uint256 period = (block.timestamp - startTime) / 1 days;
        uint256 temp_unlock = IERC20(tknContract).balanceOf(address(this));

        if (initialTotal != 0)
            temp_unlock = initialTotal;

        if (period > c_t) period = c_t;

        uint256 b = 10 ** 18;
        uint256 a3_1 = b;
        uint256 a3_2;
        uint256 a3;
        
        for(uint16 k = 0; k < c_t; k ++){
            a3_1 *= c_i;
            a3_1 /= 10000;
        }
        a3_2 = b - a3_1;

        a3 = temp_unlock * a3_1 / a3_2;
        
        uint256 a1 = (1000 - c_y0);

        uint256 a2_1 = b;
        for (uint16 k = 0; k < period; k ++){
            a2_1 *= c_i;
            a2_1 /= 10000;
        }
        uint256 a2_2 = a2_1;
        a2_1 = b - a2_1;

        temp_unlock = a3 * a1 * a2_1 / a2_2 / 1000 + c_y0 * temp_unlock / 1000;

        if (period == c_t) temp_unlock = initialTotal;

        return (temp_unlock - totalWithdraw, IERC20(tknContract).balanceOf(address(this)));        
    }
    
    /**
    @notice withdraw token to destination address
    @param dest destination address
    @param amount amount of tokens
    */
    function withdraw(address dest, uint256 amount) public {
        if (initialTotal == 0) initialTotal = IERC20(tknContract).balanceOf(address(this));
        (unlockedBalance, totalBalance) = getUnlocked_TotalBalance();
        require(msg.sender == owner, "msg.sender is not Owner!");
        require(unlockedBalance > 0, "unlockedBalance is 0");
        require(amount <= unlockedBalance, "unlockedBalance is bigger");
        totalBalance -= amount;
        unlockedBalance -=amount;
        totalWithdraw += amount;
        IERC20(tknContract).transfer(dest, amount);
        emit Withdraw(dest, amount);
    }
}

Read Contract

auth 0xde9375f2 → address
c_i 0xca907f2b → uint256
c_t 0x28f2fe0c → uint256
c_y0 0x1ebaa3a1 → uint256
getUnlocked_TotalBalance 0xe8068e44 → uint256, uint256
owner 0x8da5cb5b → address
tknContract 0xa62aca1e → address

Write Contract 3 functions

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

setOwner 0x13af4035
address _owner
setTkn 0xe13b468e
address _TknContract
withdraw 0xf3fef3a3
address dest
uint256 amount

Recent Transactions

No transactions found for this address