Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0x410b2Ce64B09b4A0a27F0A34bb57d1CFf7C75A74
Balance 0 ETH
Nonce 1
Code Size 5564 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

5564 bytes
0x608060405234801561000f575f80fd5b50600436106100e8575f3560e01c8063900e2b261161008a578063e680be4d11610064578063e680be4d14610270578063ed10e33c146102a0578063f3c0f4d7146102aa578063fccc2813146102c8576100e8565b8063900e2b2614610218578063d8d818eb14610236578063dd46706414610254576100e8565b80632293f973116100c65780632293f9731461016a5780633fbb2c01146101885780634a4643f7146101b85780635a849419146101e8576100e8565b806309afda18146100ec5780630bdf53001461011c57806310b201391461013a575b5f80fd5b61010660048036038101906101019190610fee565b6102e6565b6040516101139190611031565b60405180910390f35b6101246103d9565b6040516101319190611059565b60405180910390f35b610154600480360381019061014f9190610fee565b6103fd565b6040516101619190611031565b60405180910390f35b610172610412565b60405161017f9190611031565b60405180910390f35b6101a2600480360381019061019d9190610fee565b610419565b6040516101af9190611094565b60405180910390f35b6101d260048036038101906101cd9190610fee565b61043d565b6040516101df9190611031565b60405180910390f35b61020260048036038101906101fd9190610fee565b610452565b60405161020f9190611031565b60405180910390f35b610220610467565b60405161022d9190611031565b60405180910390f35b61023e61046c565b60405161024b9190611059565b60405180910390f35b61026e600480360381019061026991906110d7565b610490565b005b61028a60048036038101906102859190610fee565b61085b565b6040516102979190611031565b60405180910390f35b6102a8610a38565b005b6102b2610bb5565b6040516102bf9190611031565b60405180910390f35b6102d0610bba565b6040516102dd9190611059565b60405180910390f35b5f805f90505f60035f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054148061033d57505f61033b8461085b565b115b6103d0575f61034b84610bc0565b90504262278d008261035d919061112f565b60015f8773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900467ffffffffffffffff1667ffffffffffffffff166103c29190611170565b6103cc91906111a3565b9150505b80915050919050565b7f00000000000000000000000013d074303c95a34d304f29928dc8a16dec797e9e81565b6004602052805f5260405f205f915090505481565b62278d0081565b6001602052805f5260405f205f915054906101000a900467ffffffffffffffff1681565b6002602052805f5260405f205f915090505481565b6003602052805f5260405f205f915090505481565b601281565b7f000000000000000000000000f35593120a5c19d3ae3d551b5806163b367c096d81565b5f60015f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900467ffffffffffffffff1667ffffffffffffffff161461052c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161052390611230565b60405180910390fd5b5f811161056e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161056590611298565b60405180910390fd5b5f548161057b9190611170565b7f00000000000000000000000013d074303c95a34d304f29928dc8a16dec797e9e73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016105d49190611059565b602060405180830381865afa1580156105ef573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061061391906112ca565b1015610654576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161064b90611365565b60405180910390fd5b5f60128261066291906113b0565b90508160025f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f208190555080826106b291906111a3565b60035f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20819055508060045f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20819055504260015f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555080826107a491906111a3565b5f808282546107b39190611170565b925050819055506107e87f000000000000000000000000f35593120a5c19d3ae3d551b5806163b367c096d3361dead85610c4b565b6108137f00000000000000000000000013d074303c95a34d304f29928dc8a16dec797e9e3383610ccd565b813373ffffffffffffffffffffffffffffffffffffffff167f9f1ec8c880f76798e7b793325d625e9b60e4082a553c98f42b6cda368dd6000860405160405180910390a35050565b5f8060035f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054036108a8575f9050610a33565b5f6108b283610bc0565b90505f60045f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054601260025f8773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20548461093e919061112f565b61094891906113b0565b61095291906111a3565b905060035f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20548111806109e7575060128160035f8773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20546109e591906111a3565b105b15610a2d5760035f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205490505b80925050505b919050565b5f610a423361085b565b90505f8111610a86576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a7d9061142a565b60405180910390fd5b8060035f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f828254610ad291906111a3565b925050819055508060045f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f828254610b259190611170565b92505081905550805f80828254610b3c91906111a3565b92505081905550610b6e7f00000000000000000000000013d074303c95a34d304f29928dc8a16dec797e9e3383610ccd565b803373ffffffffffffffffffffffffffffffffffffffff167f0f0bc5b519ddefdd8e5f9e6423433aa2b869738de2ae34d58ebc796fc749fa0d60405160405180910390a350565b5f5481565b61dead81565b5f600160ff1662278d0060015f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900467ffffffffffffffff1667ffffffffffffffff1642610c3091906111a3565b610c3a91906113b0565b610c449190611170565b9050919050565b610cc7848573ffffffffffffffffffffffffffffffffffffffff166323b872dd868686604051602401610c8093929190611448565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610d4c565b50505050565b610d47838473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb8585604051602401610d0092919061147d565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610d4c565b505050565b5f610d76828473ffffffffffffffffffffffffffffffffffffffff16610de190919063ffffffff16565b90505f815114158015610d9a575080806020019051810190610d9891906114d9565b155b15610ddc57826040517f5274afe7000000000000000000000000000000000000000000000000000000008152600401610dd39190611059565b60405180910390fd5b505050565b6060610dee83835f610df6565b905092915050565b606081471015610e3d57306040517fcd786059000000000000000000000000000000000000000000000000000000008152600401610e349190611059565b60405180910390fd5b5f808573ffffffffffffffffffffffffffffffffffffffff168486604051610e659190611570565b5f6040518083038185875af1925050503d805f8114610e9f576040519150601f19603f3d011682016040523d82523d5f602084013e610ea4565b606091505b5091509150610eb4868383610ebf565b925050509392505050565b606082610ed457610ecf82610f4c565b610f44565b5f8251148015610efa57505f8473ffffffffffffffffffffffffffffffffffffffff163b145b15610f3c57836040517f9996b315000000000000000000000000000000000000000000000000000000008152600401610f339190611059565b60405180910390fd5b819050610f45565b5b9392505050565b5f81511115610f5e5780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610fbd82610f94565b9050919050565b610fcd81610fb3565b8114610fd7575f80fd5b50565b5f81359050610fe881610fc4565b92915050565b5f6020828403121561100357611002610f90565b5b5f61101084828501610fda565b91505092915050565b5f819050919050565b61102b81611019565b82525050565b5f6020820190506110445f830184611022565b92915050565b61105381610fb3565b82525050565b5f60208201905061106c5f83018461104a565b92915050565b5f67ffffffffffffffff82169050919050565b61108e81611072565b82525050565b5f6020820190506110a75f830184611085565b92915050565b6110b681611019565b81146110c0575f80fd5b50565b5f813590506110d1816110ad565b92915050565b5f602082840312156110ec576110eb610f90565b5b5f6110f9848285016110c3565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f61113982611019565b915061114483611019565b925082820261115281611019565b9150828204841483151761116957611168611102565b5b5092915050565b5f61117a82611019565b915061118583611019565b925082820190508082111561119d5761119c611102565b5b92915050565b5f6111ad82611019565b91506111b883611019565b92508282039050818111156111d0576111cf611102565b5b92915050565b5f82825260208201905092915050565b7f416c7265616479206c6f636b656420746f6b656e7300000000000000000000005f82015250565b5f61121a6015836111d6565b9150611225826111e6565b602082019050919050565b5f6020820190508181035f8301526112478161120e565b9050919050565b7f43616e6e6f74206465706f736974203020746f6b656e730000000000000000005f82015250565b5f6112826017836111d6565b915061128d8261124e565b602082019050919050565b5f6020820190508181035f8301526112af81611276565b9050919050565b5f815190506112c4816110ad565b92915050565b5f602082840312156112df576112de610f90565b5b5f6112ec848285016112b6565b91505092915050565b7f436f6e747261637420646f6573206e6f7420686f6c6420656e6f75676820746f5f8201527f6b656e7300000000000000000000000000000000000000000000000000000000602082015250565b5f61134f6024836111d6565b915061135a826112f5565b604082019050919050565b5f6020820190508181035f83015261137c81611343565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f6113ba82611019565b91506113c583611019565b9250826113d5576113d4611383565b5b828204905092915050565b7f4e6f7468696e6720746f20756e6c6f636b0000000000000000000000000000005f82015250565b5f6114146011836111d6565b915061141f826113e0565b602082019050919050565b5f6020820190508181035f83015261144181611408565b9050919050565b5f60608201905061145b5f83018661104a565b611468602083018561104a565b6114756040830184611022565b949350505050565b5f6040820190506114905f83018561104a565b61149d6020830184611022565b9392505050565b5f8115159050919050565b6114b8816114a4565b81146114c2575f80fd5b50565b5f815190506114d3816114af565b92915050565b5f602082840312156114ee576114ed610f90565b5b5f6114fb848285016114c5565b91505092915050565b5f81519050919050565b5f81905092915050565b5f5b8381101561153557808201518184015260208101905061151a565b5f8484015250505050565b5f61154a82611504565b611554818561150e565b9350611564818560208601611518565b80840191505092915050565b5f61157b8284611540565b91508190509291505056fea2646970667358221220a14abb4fb4b83ab3547596d43bfcf0ebd1fdb3b674b5cdba9a96f08a5d142a1164736f6c63430008140033

Verified Source Code Partial Match

Compiler: v0.8.20+commit.a1b79de6 EVM: shanghai Optimization: No
LakeVestingOTC3.sol 600 lines
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol


// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @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 value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

    /**
     * @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` 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 value) external returns (bool);
}

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


// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.20;

/**
 * @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.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
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].
     *
     * CAUTION: See Security Considerations above.
     */
    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/utils/Address.sol


// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error AddressInsufficientBalance(address account);

    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedInnerCall();

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

        (bool success, ) = recipient.call{value: amount}("");
        if (!success) {
            revert FailedInnerCall();
        }
    }

    /**
     * @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 or custom error, it is bubbled
     * up by this function (like regular Solidity function calls). However, if
     * the call reverted with no returned reason, this function reverts with a
     * {FailedInnerCall} error.
     *
     * 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.
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0);
    }

    /**
     * @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`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert AddressInsufficientBalance(address(this));
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

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

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

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
     * unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {FailedInnerCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
     */
    function _revert(bytes memory returndata) 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 FailedInnerCall();
        }
    }
}

// File: @openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol


// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;




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

    /**
     * @dev An operation with an ERC20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @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);
        if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @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).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // 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 cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
    }
}

// File: LakeVestingOTC3.sol


pragma solidity = 0.8.20;


interface Token {
    function balanceOf(address) external view returns(uint);
}

contract LakeVestingOTC3 {
    address public immutable TOKEN_ADDRESS;  // ERC20 withdraw token contract address
    address public immutable DEPOSIT_TOKEN_ADDRESS;  // ERC-20 deposit token contract address
    address public constant BURN_ADDRESS =
        0x000000000000000000000000000000000000dEaD;  // Burn address

    uint256 public constant TIME_1_MONTH_ADJUSTED = 30 days;     // Time for each period = 30 days
    uint256 public constant TOTAL_WITHDRAWS = 18;                // Num periods = Max number of withdraws = 18
    uint256 public totalPendingToGet;                            // Total amount deposited and not withdrawn
    uint8 private constant NUM_EXTRA_PERIODS = 1;                // To be used when calculating the unlockable amount

    mapping(address => uint64) public lockingTime;      // Depositing time by an address
    mapping(address => uint256) public depositedAmount; // Total deposited ERC-20 tokens by an address
    mapping(address => uint256) public remainingAmount; // Remaining locked ERC-20 tokens by an address [deposited - withdrawn]
    mapping(address => uint256) public withdrawnAmount; // Total unlocked ERC-20 tokens by an address

    event Locked(address indexed, uint256 indexed amount);
    event Unlocked(address indexed, uint256 indexed amount);

    constructor(address _lockToken, address _unlockToken) {
        require(_lockToken != address(0) && _unlockToken != address(0), "Null address");
        DEPOSIT_TOKEN_ADDRESS = _lockToken;
        TOKEN_ADDRESS = _unlockToken;
    }

    /*
    Allows to deposit tokens [DEPOSIT_TOKEN_ADDRESS] by sender
    @param _amount: Amount to deposit.
    */
    function lock(uint256 _amount) external {
        require(lockingTime[msg.sender] == 0, "Already locked tokens");
        require(_amount > 0, "Cannot deposit 0 tokens");
        /* Check the contract holds enough tokens to withdraw by doing a externall call "balanceOf()", 
        which is a view function from a trusted contract (LAK3 token contract), avoiding "checks-effects-interactions" pattern violation risks */
        require(Token(TOKEN_ADDRESS).balanceOf(address(this)) >= _amount + totalPendingToGet , "Contract does not hold enough tokens");
        
        uint toSend = _amount / TOTAL_WITHDRAWS;
        depositedAmount[msg.sender] = _amount;
        remainingAmount[msg.sender] = _amount - toSend;
        withdrawnAmount[msg.sender] = toSend;
        lockingTime[msg.sender] = uint64(block.timestamp);
        totalPendingToGet += _amount - toSend;

        SafeERC20.safeTransferFrom(IERC20(DEPOSIT_TOKEN_ADDRESS), msg.sender, BURN_ADDRESS, _amount);
        SafeERC20.safeTransfer(IERC20(TOKEN_ADDRESS), msg.sender, toSend);

        emit Locked(msg.sender, _amount);
    }

    /*
    Allows to withdraw all unlockable tokens [TOKEN_ADDRESS]
    */
    function unLock() external {
        uint256 _amount = getUnlockableAmount(msg.sender);
        require(_amount > 0, "Nothing to unlock");

        remainingAmount[msg.sender] -= _amount;
        withdrawnAmount[msg.sender] += _amount;
        totalPendingToGet -= _amount;

        SafeERC20.safeTransfer(IERC20(TOKEN_ADDRESS), msg.sender, _amount);

        emit Unlocked(msg.sender, _amount);
    }

    /*
    Get the amount of unlockable tokens [TOKEN_ADDRESS]
    @param _wallet: Address to check
    */
    function getUnlockableAmount(address _wallet)
        public
        view
        returns (uint256)
    {
        if (remainingAmount[_wallet] == 0) return 0;

        uint256 numWithdraws = getNumUnlockPeriods(_wallet);
        uint256 _toSend = (numWithdraws * depositedAmount[_wallet]) /
            TOTAL_WITHDRAWS -
            withdrawnAmount[_wallet];

        if (
            _toSend > remainingAmount[_wallet] || 
            remainingAmount[_wallet] - _toSend < TOTAL_WITHDRAWS // decimals check (for the last withdraw) - 0,000000000000000018
        ) {
            _toSend = remainingAmount[_wallet];
        }
        return _toSend;
    }

    /*
    Get the number of unlockable periods (30 days)
    @param _wallet: Address to check
    */
    function getNumUnlockPeriods(address _wallet)
        internal
        view
        returns (uint256)
    {
        return
            (block.timestamp - lockingTime[_wallet]) /
            TIME_1_MONTH_ADJUSTED +
            NUM_EXTRA_PERIODS;
    }

    /*
    Get the time (in seconds) till the next unlock
    @param _wallet: Address to check
    returns 0 if remaining tokens is 0
    returns 0 if unlockable amount is greater than 0
    */
    function getTimeUntilNextUnlock(address _wallet)
        external
        view
        returns (uint256)
    {   
        uint _res = 0;
        if (
            remainingAmount[_wallet] == 0 ||
            getUnlockableAmount(_wallet) > 0 
        ){
            // must return 0
        }else{
            uint256 numPeriods = getNumUnlockPeriods(_wallet);
            _res = lockingTime[_wallet] +
               numPeriods *
               TIME_1_MONTH_ADJUSTED -
               block.timestamp;
        }
        return _res;

    }
}

Read Contract

BURN_ADDRESS 0xfccc2813 → address
DEPOSIT_TOKEN_ADDRESS 0xd8d818eb → address
TIME_1_MONTH_ADJUSTED 0x2293f973 → uint256
TOKEN_ADDRESS 0x0bdf5300 → address
TOTAL_WITHDRAWS 0x900e2b26 → uint256
depositedAmount 0x4a4643f7 → uint256
getTimeUntilNextUnlock 0x09afda18 → uint256
getUnlockableAmount 0xe680be4d → uint256
lockingTime 0x3fbb2c01 → uint64
remainingAmount 0x5a849419 → uint256
totalPendingToGet 0xf3c0f4d7 → uint256
withdrawnAmount 0x10b20139 → uint256

Write Contract 2 functions

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

lock 0xdd467064
uint256 _amount
unLock 0xed10e33c
No parameters

Recent Transactions

No transactions found for this address