Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0x00983e4f577Fc29Fd8257fA2E431D7F80C02f8BE
Balance 0 ETH
Nonce 1
Code Size 5144 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

5144 bytes
0x608060405234801561000f575f5ffd5b50600436106100e8575f3560e01c80636316b4531161008a578063e680be4d11610064578063e680be4d1461025e578063f3c0f4d71461028e578063f83d08ba146102ac578063fccc2813146102b6576100e8565b80636316b45314610218578063900e2b2614610236578063a69df4b514610254576100e8565b80633fbb2c01116100c65780633fbb2c011461016a5780634a4643f71461019a57806350b3ddea146101ca5780635a849419146101e8576100e8565b806309afda18146100ec57806310b201391461011c5780632293f9731461014c575b5f5ffd5b61010660048036038101906101019190611079565b6102d4565b60405161011391906110bc565b60405180910390f35b61013660048036038101906101319190611079565b6103d6565b60405161014391906110bc565b60405180910390f35b6101546103eb565b60405161016191906110bc565b60405180910390f35b610184600480360381019061017f9190611079565b6103f2565b60405161019191906110f7565b60405180910390f35b6101b460048036038101906101af9190611079565b610416565b6040516101c191906110bc565b60405180910390f35b6101d261042b565b6040516101df919061111f565b60405180910390f35b61020260048036038101906101fd9190611079565b610443565b60405161020f91906110bc565b60405180910390f35b610220610458565b60405161022d919061111f565b60405180910390f35b61023e610470565b60405161024b91906110bc565b60405180910390f35b61025c610475565b005b61027860048036038101906102739190611079565b6105dd565b60405161028591906110bc565b60405180910390f35b610296610832565b6040516102a391906110bc565b60405180910390f35b6102b4610837565b005b6102be610c41565b6040516102cb919061111f565b60405180910390f35b5f5f5f90505f60035f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054148061032b57505f610329846105dd565b115b6103cd575f61033984610c47565b90504262278d00600160ff16836103509190611165565b61035a9190611198565b60015f8773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900467ffffffffffffffff1667ffffffffffffffff166103bf9190611165565b6103c991906111d9565b9150505b80915050919050565b6004602052805f5260405f205f915090505481565b62278d0081565b6001602052805f5260405f205f915054906101000a900467ffffffffffffffff1681565b6002602052805f5260405f205f915090505481565b73f35593120a5c19d3ae3d551b5806163b367c096d81565b6003602052805f5260405f205f915090505481565b7313d074303c95a34d304f29928dc8a16dec797e9e81565b600c81565b5f61047f336105dd565b90505f81116104ba576040517f764c157f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060035f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f82825461050691906111d9565b925050819055508060045f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8282546105599190611165565b92505081905550805f5f82825461057091906111d9565b925050819055506105967313d074303c95a34d304f29928dc8a16dec797e9e3383610cd6565b803373ffffffffffffffffffffffffffffffffffffffff167f0f0bc5b519ddefdd8e5f9e6423433aa2b869738de2ae34d58ebc796fc749fa0d60405160405180910390a350565b5f5f60035f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20540361062a575f905061082d565b5f61063483610c47565b90505f6014600360025f8773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20546106839190611198565b61068d9190611239565b60045f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20546106d591906111d9565b600c6014601160025f8973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054866107249190611198565b61072e9190611198565b6107389190611239565b6107429190611239565b61074c91906111d9565b905060035f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20548111806107e15750600c8160035f8773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20546107df91906111d9565b105b156108275760035f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205490505b80925050505b919050565b5f5481565b5f60025f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054146108ad576040517f5f0ccd7c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f73f35593120a5c19d3ae3d551b5806163b367c096d73ffffffffffffffffffffffffffffffffffffffff166370a08231336040518263ffffffff1660e01b81526004016108fb919061111f565b602060405180830381865afa158015610916573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061093a9190611293565b90505f8111610975576040517f59dc379f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f54816109829190611165565b7313d074303c95a34d304f29928dc8a16dec797e9e73ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016109cf919061111f565b602060405180830381865afa1580156109ea573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a0e9190611293565b1015610a46576040517f22bbb43c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6014600383610a569190611198565b610a609190611239565b9050610a8473f35593120a5c19d3ae3d551b5806163b367c096d3361dead85610d55565b610aa37313d074303c95a34d304f29928dc8a16dec797e9e3383610cd6565b8160025f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20819055508082610af191906111d9565b60035f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20819055508060045f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20819055504260015f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055508082610be391906111d9565b5f5f828254610bf29190611165565b92505081905550813373ffffffffffffffffffffffffffffffffffffffff167f9f1ec8c880f76798e7b793325d625e9b60e4082a553c98f42b6cda368dd6000860405160405180910390a35050565b61dead81565b5f5f62278d0060015f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900467ffffffffffffffff1667ffffffffffffffff1642610cb391906111d9565b610cbd9190611239565b9050600c811115610ccd57600c90505b80915050919050565b610d50838473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb8585604051602401610d099291906112be565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610dd7565b505050565b610dd1848573ffffffffffffffffffffffffffffffffffffffff166323b872dd868686604051602401610d8a939291906112e5565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610dd7565b50505050565b5f610e01828473ffffffffffffffffffffffffffffffffffffffff16610e6c90919063ffffffff16565b90505f815114158015610e25575080806020019051810190610e23919061134f565b155b15610e6757826040517f5274afe7000000000000000000000000000000000000000000000000000000008152600401610e5e919061111f565b60405180910390fd5b505050565b6060610e7983835f610e81565b905092915050565b606081471015610ec857306040517fcd786059000000000000000000000000000000000000000000000000000000008152600401610ebf919061111f565b60405180910390fd5b5f5f8573ffffffffffffffffffffffffffffffffffffffff168486604051610ef091906113cc565b5f6040518083038185875af1925050503d805f8114610f2a576040519150601f19603f3d011682016040523d82523d5f602084013e610f2f565b606091505b5091509150610f3f868383610f4a565b925050509392505050565b606082610f5f57610f5a82610fd7565b610fcf565b5f8251148015610f8557505f8473ffffffffffffffffffffffffffffffffffffffff163b145b15610fc757836040517f9996b315000000000000000000000000000000000000000000000000000000008152600401610fbe919061111f565b60405180910390fd5b819050610fd0565b5b9392505050565b5f81511115610fe95780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6110488261101f565b9050919050565b6110588161103e565b8114611062575f5ffd5b50565b5f813590506110738161104f565b92915050565b5f6020828403121561108e5761108d61101b565b5b5f61109b84828501611065565b91505092915050565b5f819050919050565b6110b6816110a4565b82525050565b5f6020820190506110cf5f8301846110ad565b92915050565b5f67ffffffffffffffff82169050919050565b6110f1816110d5565b82525050565b5f60208201905061110a5f8301846110e8565b92915050565b6111198161103e565b82525050565b5f6020820190506111325f830184611110565b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f61116f826110a4565b915061117a836110a4565b925082820190508082111561119257611191611138565b5b92915050565b5f6111a2826110a4565b91506111ad836110a4565b92508282026111bb816110a4565b915082820484148315176111d2576111d1611138565b5b5092915050565b5f6111e3826110a4565b91506111ee836110a4565b925082820390508181111561120657611205611138565b5b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f611243826110a4565b915061124e836110a4565b92508261125e5761125d61120c565b5b828204905092915050565b611272816110a4565b811461127c575f5ffd5b50565b5f8151905061128d81611269565b92915050565b5f602082840312156112a8576112a761101b565b5b5f6112b58482850161127f565b91505092915050565b5f6040820190506112d15f830185611110565b6112de60208301846110ad565b9392505050565b5f6060820190506112f85f830186611110565b6113056020830185611110565b61131260408301846110ad565b949350505050565b5f8115159050919050565b61132e8161131a565b8114611338575f5ffd5b50565b5f8151905061134981611325565b92915050565b5f602082840312156113645761136361101b565b5b5f6113718482850161133b565b91505092915050565b5f81519050919050565b5f81905092915050565b8281835e5f83830152505050565b5f6113a68261137a565b6113b08185611384565b93506113c081856020860161138e565b80840191505092915050565b5f6113d7828461139c565b91508190509291505056fea26469706673582212201fb2fe01cb16814dbc0f8e7bd25cb0c677c9b15baf7a1f8117cc9432a6a06bef64736f6c634300081b0033

Verified Source Code Partial Match

Compiler: v0.8.27+commit.40a35a09 EVM: cancun Optimization: No
LakePresaleVault.sol 598 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: LAKE_Presale_Vault.sol


pragma solidity =0.8.27;


error AlreadyLocked();
error NotTokenOwner();
error NotEnoughTokens();
error NothingToUnlock();


contract LakePresaleVault {
    address public constant XLAKE_ADDRESS = 0xf35593120A5c19D3ae3d551b5806163B367c096D;
    address public constant LAKE_ADDRESS = 0x13d074303C95a34d304F29928dC8A16dEc797e9E;
    address public constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD;
    
    uint256 public constant TIME_1_MONTH_ADJUSTED = 30 days;        // Time for each period = 30 days
    uint256 public constant TOTAL_WITHDRAWS = 12;                   // Max number of withdraws = 5
    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);

     /*
    Allows to lock [XLAKE_ADDRESS] tokens
    */
    function lock() external {
        require(depositedAmount[msg.sender] == 0, AlreadyLocked());
        uint _balance = IERC20(XLAKE_ADDRESS).balanceOf(msg.sender);
        require(_balance > 0, NotTokenOwner());
        require(IERC20(LAKE_ADDRESS).balanceOf(address(this)) >= _balance + totalPendingToGet , NotEnoughTokens());
        uint _toSend = _balance * 3 / 20;  // 15%
        SafeERC20.safeTransferFrom(IERC20(XLAKE_ADDRESS), msg.sender, BURN_ADDRESS, _balance);
        SafeERC20.safeTransfer(IERC20(LAKE_ADDRESS), msg.sender, _toSend);
        depositedAmount[msg.sender] = _balance;
        remainingAmount[msg.sender] = _balance - _toSend;
        withdrawnAmount[msg.sender] = _toSend;
        lockingTime[msg.sender] = uint64(block.timestamp);
        totalPendingToGet += _balance - _toSend;

        emit Locked(msg.sender, _balance);
    }

    /*
    Allows to unlock all unlockable [LAKE_ADDRESS] tokens
    */
    function unlock() external {
        uint256 _amount = getUnlockableAmount(msg.sender);
        require(_amount > 0, NothingToUnlock());

        /* underflow/overflow cannot happen:
            - Max of _amount = remainingAmount
            - Max of withdrawnAmount = depositedAmount
            - Max of _amount = totalPendingToGet
        */
        
        remainingAmount[msg.sender] -= _amount;
        withdrawnAmount[msg.sender] += _amount;
        totalPendingToGet -= _amount;

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

        emit Unlocked(msg.sender, _amount);
    }

    /*
    Get the amount of unlockable tokens [LAKE_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] * 17 / 20) / TOTAL_WITHDRAWS -
            (withdrawnAmount[_wallet] - depositedAmount[_wallet] * 3 / 20);

        if (
            _toSend > remainingAmount[_wallet] || 
            remainingAmount[_wallet] - _toSend < TOTAL_WITHDRAWS // decimals check (for the last withdraw) - 0,00000000000000012
        ) {
            _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)
    {   
        uint numUnloks = (block.timestamp - lockingTime[_wallet]) /
            TIME_1_MONTH_ADJUSTED;

        if (numUnloks > TOTAL_WITHDRAWS) numUnloks = TOTAL_WITHDRAWS;

        return numUnloks;
           
    }

    /*
    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 + NUM_EXTRA_PERIODS) *
               TIME_1_MONTH_ADJUSTED -
               block.timestamp;
        }
        return _res;
    }
}

Read Contract

BURN_ADDRESS 0xfccc2813 → address
LAKE_ADDRESS 0x6316b453 → address
TIME_1_MONTH_ADJUSTED 0x2293f973 → uint256
TOTAL_WITHDRAWS 0x900e2b26 → uint256
XLAKE_ADDRESS 0x50b3ddea → address
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 0xf83d08ba
No parameters
unlock 0xa69df4b5
No parameters

Recent Transactions

No transactions found for this address