SWIFTProtocol

Description:

Multi-signature wallet contract requiring multiple confirmations for transaction execution.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

{{
  "language": "Solidity",
  "sources": {
    "@openzeppelin/contracts/interfaces/IERC1363.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1363.sol)

pragma solidity >=0.6.2;

import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";

/**
 * @title IERC1363
 * @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
 *
 * Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
 * after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
 */
interface IERC1363 is IERC20, IERC165 {
    /*
     * Note: the ERC-165 identifier for this interface is 0xb0202a11.
     * 0xb0202a11 ===
     *   bytes4(keccak256('transferAndCall(address,uint256)')) ^
     *   bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
     */

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value) external returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @param data Additional data with no specified format, sent in call to `spender`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}
"
    },
    "@openzeppelin/contracts/interfaces/IERC165.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC165.sol)

pragma solidity >=0.4.16;

import {IERC165} from "../utils/introspection/IERC165.sol";
"
    },
    "@openzeppelin/contracts/interfaces/IERC20.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC20.sol)

pragma solidity >=0.4.16;

import {IERC20} from "../token/ERC20/IERC20.sol";
"
    },
    "@openzeppelin/contracts/token/ERC1155/IERC1155.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC1155/IERC1155.sol)

pragma solidity >=0.6.2;

import {IERC165} from "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC-1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[ERC].
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` amount of tokens of type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

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

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(
        address[] calldata accounts,
        uint256[] calldata ids
    ) external view returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the zero address.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`.
     *
     * WARNING: This function can potentially allow a reentrancy attack when transferring tokens
     * to an untrusted contract, when invoking {IERC1155Receiver-onERC1155Received} on the receiver.
     * Ensure to follow the checks-effects-interactions pattern and consider employing
     * reentrancy guards when interacting with untrusted contracts.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `value` amount.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * WARNING: This function can potentially allow a reentrancy attack when transferring tokens
     * to an untrusted contract, when invoking {IERC1155Receiver-onERC1155BatchReceived} on the receiver.
     * Ensure to follow the checks-effects-interactions pattern and consider employing
     * reentrancy guards when interacting with untrusted contracts.
     *
     * Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments.
     *
     * Requirements:
     *
     * - `ids` and `values` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external;
}
"
    },
    "@openzeppelin/contracts/token/ERC20/IERC20.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)

pragma solidity >=0.4.16;

/**
 * @dev Interface of the ERC-20 standard as defined in the ERC.
 */
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);
}
"
    },
    "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC-20 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 {
    /**
     * @dev An operation with an ERC-20 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 Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
     */
    function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
        return _callOptionalReturnBool(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
     */
    function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
        return _callOptionalReturnBool(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.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    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.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    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.
     *
     * NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
     * only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
     * set here.
     */
    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 Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            safeTransfer(token, to, value);
        } else if (!token.transferAndCall(to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
     * has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferFromAndCallRelaxed(
        IERC1363 token,
        address from,
        address to,
        uint256 value,
        bytes memory data
    ) internal {
        if (to.code.length == 0) {
            safeTransferFrom(token, from, to, value);
        } else if (!token.transferFromAndCall(from, to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
     * Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
     * once without retrying, and relies on the returned value to be true.
     *
     * Reverts if the returned value is other than `true`.
     */
    function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            forceApprove(token, to, value);
        } else if (!token.approveAndCall(to, value, data)) {
            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 {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            // bubble errors
            if iszero(success) {
                let ptr := mload(0x40)
                returndatacopy(ptr, 0, returndatasize())
                revert(ptr, returndatasize())
            }
            returnSize := returndatasize()
            returnValue := mload(0)
        }

        if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
            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 silently catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        bool success;
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            returnSize := returndatasize()
            returnValue := mload(0)
        }
        return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
    }
}
"
    },
    "@openzeppelin/contracts/token/ERC721/IERC721.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC721/IERC721.sol)

pragma solidity >=0.6.2;

import {IERC165} from "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC-721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
     *   a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC-721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or
     *   {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
     *   a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC-721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the address zero.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}
"
    },
    "@openzeppelin/contracts/utils/Context.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

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

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}
"
    },
    "@openzeppelin/contracts/utils/introspection/IERC165.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)

pragma solidity >=0.4.16;

/**
 * @dev Interface of the ERC-165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[ERC].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
"
    },
    "@openzeppelin/contracts/utils/Pausable.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/Pausable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    bool private _paused;

    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    /**
     * @dev The operation failed because the contract is paused.
     */
    error EnforcedPause();

    /**
     * @dev The operation failed because the contract is not paused.
     */
    error ExpectedPause();

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        _requirePaused();
        _;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        if (paused()) {
            revert EnforcedPause();
        }
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        if (!paused()) {
            revert ExpectedPause();
        }
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}
"
    },
    "@openzeppelin/contracts/utils/ReentrancyGuard.sol": {
      "content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)

pragma solidity ^0.8.20;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
 * consider using {ReentrancyGuardTransient} instead.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant NOT_ENTERED = 1;
    uint256 private constant ENTERED = 2;

    uint256 private _status;

    /**
     * @dev Unauthorized reentrant call.
     */
    error ReentrancyGuardReentrantCall();

    constructor() {
        _status = NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be NOT_ENTERED
        if (_status == ENTERED) {
            revert ReentrancyGuardReentrantCall();
        }

        // Any calls to nonReentrant after this point will fail
        _status = ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = NOT_ENTERED;
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == ENTERED;
    }
}
"
    },
    "contracts/SWIFT.sol": {
      "content": "// SPDX-License-Identifier: MIT\r
pragma solidity ^0.8.25;\r
\r
/*\r
 * SWIFT Protocol\r
 * Universal Batch Transfer Contract\r
 * Version: 0.0.0.1/0 (stable)\r
 * License: MIT\r
 * Author: Bogachenko Vyacheslav\r
 * Mail:\r
 *	- Non-secure channel: bogachenkove@outlook.com\r
 *	- Secure channel: \r
 *		TOR: bogachenkove@onionmail.org (bogachenkove@gtfcy37qyzor7kb6blz2buwuu5u7qjkycasjdf3yaslibkbyhsxub4yd.onion)\r
 *		I2P: bogachenkove@i2pmail.org (bogachenkove@mail.i2p)\r
 * Jabber: bogachenkove@xmpp.jp\r
 */\r
\r
/**\r
 * LIBRARY\r
 * Libraries extend functionality through reusable code components.\r
 */\r
	/**\r
	* @notice Safe ERC20\r
	* @dev Secure ERC20 token operations\r
	*/\r
	import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";\r
	using SafeERC20 for IERC20;\r
	/**\r
	* @notice ERC20 Interface\r
	* @dev ERC20 token standard interface\r
	*/\r
	import "@openzeppelin/contracts/token/ERC20/IERC20.sol";\r
	/**\r
	* @notice ERC721 Interface\r
	* @dev Non-fungible token interface\r
	*/\r
	import "@openzeppelin/contracts/token/ERC721/IERC721.sol";\r
	/**\r
	* @notice ERC1155 Interface\r
	* @dev Multi-token contract interface\r
	*/\r
	import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";\r
	/**\r
	* @notice Reentrancy Guard\r
	* @dev Reentrant call protection\r
	*/\r
	import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";\r
	/**\r
	* @notice Pausable\r
	* @dev Emergency stop functionality\r
	*/\r
	import "@openzeppelin/contracts/utils/Pausable.sol";\r
	/**\r
	* @notice ERC165 Interface\r
	* @dev Interface detection support (ERC721 and ERC1155 only, ERC20 support not implemented because legacy ERC20 tokens do not support IERC165)\r
	*/\r
	import "@openzeppelin/contracts/utils/introspection/IERC165.sol";\r
\r
/**\r
 * @notice SWIFT Protocol\r
 * @dev Main contract implementation body\r
 */\r
contract SWIFTProtocol is ReentrancyGuard, Pausable {\r
\r
/**\r
 * CONSTANT\r
 * Constants define essential configuration parameters and preserve critical contract state.\r
 */\r
	/**\r
	 * @notice Protocol Name\r
	 * @dev Contract name string\r
	 */\r
	string public name = "Swift Protocol";\r
	/**\r
	 * @notice Contract Symbol\r
	 * @dev Token symbol string\r
	 */\r
	string public symbol = "SWIFT";\r
	/**\r
	 * @notice Current Recipient Limit\r
	 * @dev Active maximum recipient count\r
	 */\r
	uint256 public currentLimitRecipient = minimalLimitRecipient;\r
	/**\r
	 * @notice Minimum Recipient Limit\r
	 * @dev Constant minimum recipient threshold\r
	 */\r
	uint256 private constant minimalLimitRecipient = 50;\r
	/**\r
	 * @notice Maximum Recipient Limit\r
	 * @dev Constant maximum recipient threshold\r
	 */\r
	uint256 private constant maximumLimitRecipient = 5000;\r
	/**\r
	 * @notice Current Fee\r
	 * @dev Active transaction fee value\r
	 */\r
	uint256 public currentFee = minimumLimitFee;\r
	/**\r
	 * @notice Minimum Fee\r
	 * @dev Constant minimum fee threshold\r
	 */\r
	uint256 private constant minimumLimitFee = 1e12;\r
	/**\r
	 * @notice Maximum Fee\r
	 * @dev Constant maximum fee threshold\r
	 */\r
	uint256 private constant maximumLimitFee = 1e17;\r
	/**\r
	 * @notice Current Rate Limit\r
	 * @dev Active rate limiting value\r
	 */\r
	uint256 public currentRateLimit = minimalRateLimit;\r
	/**\r
	 * @notice Current Block Limit\r
	 * @dev Active block rate limiting value\r
	 */\r
	uint256 public currentBlockLimit = minimalBlockLimit;\r
	/**\r
	 * @notice Minimum Rate Limit\r
	 * @dev Constant minimum rate threshold\r
	 */\r
	uint256 private constant minimalRateLimit = 30;\r
	/**\r
	 * @notice Minimum Block Limit (blocks)\r
	 * @dev Constant minimum block threshold\r
	 */\r
	uint256 private constant minimalBlockLimit = 3;\r
	/**\r
	 * @notice Maximum Rate Limit\r
	 * @dev Constant maximum rate threshold\r
	 */\r
	uint256 private constant maximumRateLimit = 600;\r
	/**\r
	 * @notice Maximum Block Limit\r
	 * @dev Constant maximum block threshold\r
	 */\r
	uint256 private constant maximumBlockLimit = 60;\r
	/**\r
	 * @notice Contract Owner\r
	 * @dev Owner address storage\r
	 */\r
	address public owner;\r
	/**\r
	 * @notice Network Chain ID\r
	 * @dev Immutable chain identifier\r
	 */\r
	uint256 private immutable networkChain;\r
	/**\r
	 * @notice Deployment Block\r
	 * @dev Immutable creation block\r
	 */\r
	uint256 private immutable deploymentBlock;\r
	/**\r
	 * @notice Deployment Timestamp\r
	 * @dev Immutable creation time\r
	 */\r
	uint256 private immutable deploymentTime;\r
	/**\r
	 * @notice Minimum Reveal Delay\r
	 * @dev Shortest reveal period\r
	 */\r
	uint256 private minimumRevealDelay = 3;\r
	/**\r
	 * @notice Maximum Reveal Entropy\r
	 * @dev Upper entropy boundary\r
	 */\r
	uint256 private maximumRevealEntropy = 8;\r
	/**\r
	 * @notice Expiration Window\r
	 * @dev Expiration period duration\r
	 */\r
	uint256 private expirationWindow = 150;\r
	/**\r
	 * @notice Royalty Amount\r
	 * @dev Fee percentage value\r
	 */\r
	uint256 public royalty;\r
\r
/**\r
 * ENUMERATION\r
 * Enumerations define named constants to improve code clarity and reduce errors.\r
 */\r
	/**\r
	 * @notice Transfer Type\r
	 * @dev Supported asset transfer categories\r
	 */\r
	enum TransferType {\r
		ETH,\r
		ERC20,\r
		ERC721,\r
		ERC1155\r
	}\r
\r
/**\r
 * STRUCTURE\r
 * Structures group related data to facilitate complex data management and operations.\r
 */\r
	/**\r
	 * @notice Multi Transfer\r
	 * @dev Bundled cross-asset transfer operation\r
	 * @param transferType Asset classification identifier\r
	 * @param token Token contract address\r
	 * @param recipient Funds destination address\r
	 * @param amount Token quantity value\r
	 * @param tokenId NFT unique identifier\r
	 * @param ids ERC1155 token identifiers\r
	 * @param amounts ERC1155 token quantities\r
	 * @param data Additional call data\r
	 * @param nonce Transaction ordering identifier\r
	 */\r
	struct MultiTransfer {\r
		TransferType transferType;\r
		address token;\r
		address recipient;\r
		uint256 amount;\r
		uint256 tokenId;\r
		uint256[] ids;\r
		uint256[] amounts;\r
		bytes data;\r
		uint256 nonce;\r
	}\r
	/**\r
	 * @notice Withdraw Transfer\r
	 * @dev Single asset withdrawal operation\r
	 * @param transferType Asset classification identifier\r
	 * @param token Token contract address\r
	 * @param recipient Funds destination address\r
	 * @param amount Token quantity value\r
	 * @param nonce Transaction ordering identifier\r
	 */\r
	struct WithdrawTransfer {\r
		TransferType transferType;\r
		address token;\r
		address recipient;\r
		uint256 amount;\r
		uint256 nonce;\r
	}\r
	/**\r
	 * @notice Commitment\r
	 * @dev Cryptographic commitment reveal scheme\r
	 * @param hash Preimage cryptographic hash\r
	 * @param saltHash Salt value hash\r
	 * @param recipientsHash Recipients hash\r
	 * @param revealBlock Block number reveal\r
	 * @param networkChain Cross-chain identifier\r
	 * @param expirationBlock Validity deadline\r
	 * @param nonce Unique operation identifier\r
	 */\r
	struct Commitment {\r
		bytes32 hash;\r
		bytes32 saltHash;\r
		bytes32 recipientsHash;\r
		uint256 revealBlock;\r
		uint256 networkChain;\r
		uint256 expirationBlock;\r
		uint256 nonce;\r
	}\r
\r
/**\r
 * MAPPING\r
 * Mappings store and retrieve data, enabling efficient access to contract state variables.\r
 */\r
	/**\r
	 * @notice Blacklist Status\r
	 * @dev Address restriction mapping\r
	 */\r
	mapping(address => bool) public blacklist;\r
	/**\r
	 * @notice Whitelist Status\r
	 * @dev Address permission mapping\r
	 */\r
	mapping(address => bool) public whitelist;\r
	/**\r
	 * @notice Address Nonces\r
	 * @dev Transaction counter mapping\r
	 */\r
	mapping(address => uint256) public nonces;\r
	/**\r
	 * @notice Address Commitments\r
	 * @dev Pending commitment mapping\r
	 */\r
	mapping(address => Commitment) public commitments;\r
	/**\r
	 * @notice Last Timestamp\r
	 * @dev Previous operation mapping\r
	 */\r
	mapping(address => uint256) public lastTimestamp;\r
	/**\r
	 * @notice Last Block\r
	 * @dev Previous operation mapping\r
	 */\r
	mapping(address => uint256) public lastBlock;\r
\r
/**\r
 * EVENT\r
 * Events record significant contract activities, providing transparency and traceability.\r
 */\r
	/**\r
	 * @notice Pause Status\r
	 * @dev Contract pause state change\r
	 * @param status Boolean flag (true = paused / false = unpaused)\r
	 */\r
	event PauseStatus(bool status);\r
	/**\r
	 * @notice Recipient Limit Set\r
	 * @dev Recipient limit update\r
	 * @param oldValue Previous limit value\r
	 * @param newValue Updated limit value\r
	 */\r
	event LimitRecipientSet(uint256 oldValue, uint256 newValue);\r
	/**\r
	 * @notice Fee Set\r
	 * @dev Transaction fee update\r
	 * @param oldValue Previous fee value\r
	 * @param newValue Updated fee value\r
	 */\r
	event FeeSet(uint256 oldValue, uint256 newValue);\r
	/**\r
	 * @notice Rate Limit Set\r
	 * @dev Rate limit update\r
	 * @param oldTimeValue Previous time value\r
	 * @param newTimeValue Updated time value\r
	 * @param oldBlockValue Previous block value\r
	 * @param newBlockValue Updated block value\r
	 */\r
	event RateLimitSet(uint256 oldTimeValue, uint256 newTimeValue, uint256 oldBlockValue, uint256 newBlockValue);\r
	/**\r
	 * @notice Blacklist Set\r
	 * @dev Address blacklist update\r
	 * @param users Target address\r
	 * @param status Boolean flag (true = added / false = removed)\r
	 */\r
	event BlacklistSet(address indexed users, bool status);\r
	/**\r
	 * @notice Whitelist Set\r
	 * @dev Address whitelist update\r
	 * @param contracts Target address\r
	 * @param status Boolean flag (true = added / false = removed)\r
	 */\r
	event WhitelistSet(address indexed contracts, bool status);\r
	/**\r
	 * @notice ETH Transfer\r
	 * @dev Native currency transfer\r
	 * @param recipient Destination address\r
	 * @param amount Transfer value\r
	 */\r
	event TransferETH(address indexed recipient, uint256 amount);\r
	/**\r
	 * @notice ERC20 Transfer\r
	 * @dev Fungible token transfer\r
	 * @param recipient Destination address\r
	 * @param token Token address\r
	 * @param amount Transfer quantity\r
	 */\r
	event TransferERC20(address indexed recipient, address indexed token, uint256 amount);\r
	/**\r
	 * @notice ERC721 Transfer\r
	 * @dev Non-fungible token transfer\r
	 * @param recipient Destination address\r
	 * @param token Token address\r
	 * @param tokenId NFT identifier\r
	 */\r
	event TransferERC721(address indexed recipient, address indexed token, uint256 tokenId);\r
	/**\r
	 * @notice ERC1155 Transfer\r
	 * @dev Multi-token transfer\r
	 * @param recipient Destination address\r
	 * @param token Token address\r
	 * @param ids Token identifiers\r
	 * @param amounts Token quantities\r
	 */\r
	event TransferERC1155(address indexed recipient, address indexed token, uint256[] ids, uint256[] amounts);\r
	/**\r
	 * @notice Commitment Set\r
	 * @dev New commitment storage\r
	 * @param sender Creator address\r
	 * @param storedHash Hash value\r
	 */\r
	event CommitmentSet(address indexed sender, bytes32 storedHash);\r
	/**\r
	 * @notice Commitment Window Set\r
	 * @dev Timing parameters update\r
	 * @param minimumRevealDelay Reveal delay blocks\r
	 * @param maximumRevealEntropy Reveal entropy value\r
	 * @param expirationWindow Expiration duration\r
	 */\r
	event CommitmentWindowSet(uint256 minimumRevealDelay, uint256 maximumRevealEntropy, uint256 expirationWindow);\r
	/**\r
	 * @notice Reveal Set\r
	 * @dev Commitment reveal\r
	 * @param sender Revealing address\r
	 */\r
	event RevealSet(address indexed sender);\r
	/**\r
	 * @notice Ownership Transfer\r
	 * @dev Contract ownership change\r
	 * @param previousOwner Previous owner\r
	 * @param newOwner New owner\r
	 */\r
	event OwnershipTransfer(address indexed previousOwner, address indexed newOwner);\r
	/**\r
	 * @notice Owner Access Control\r
	 * @dev Restricts function caller contract owner\r
	 */\r
\r
/**\r
 * MODIFIER\r
 * Modifiers enforce function conditions to enhance security and access control.\r
 */\r
	modifier onlyOwner() {\r
		require(msg.sender == owner, "not_owner");\r
		_;\r
	}\r
	/**\r
	 * @notice Blacklist Control\r
	 * @dev Restricts blacklisted address access\r
	 */\r
	modifier notBlacklisted() {\r
		require(!blacklist[msg.sender], "blacklisted");\r
		_;\r
	}\r
	/**\r
	 * @notice Whitelist Control\r
	 * @dev Restricts contract caller permissions\r
	 */\r
	modifier notWhitelisted() {\r
		if(msg.sender != tx.origin) {\r
			require(whitelist[msg.sender], "not_whitelisted");\r
		}\r
		_;\r
	}\r
	/**\r
	 * @notice Rate Limit\r
	 * @dev Enforces operation time cooldown\r
	 */\r
	modifier rateLimit() {\r
		if(lastTimestamp[msg.sender] > 0 && block.timestamp - lastTimestamp[msg.sender] > 30 days) {\r
			lastTimestamp[msg.sender] = 0;\r
			lastBlock[msg.sender] = 0;\r
		}\r
		require(block.timestamp >= lastTimestamp[msg.sender] + currentRateLimit, "cooldown_time_period");\r
		require(block.number >= lastBlock[msg.sender] + currentBlockLimit, "cooldown_block_period");\r
		_;\r
		lastTimestamp[msg.sender] = block.timestamp;\r
		lastBlock[msg.sender] = block.number;\r
	}\r
	/**\r
	 * @notice Recipient Limit\r
	 * @dev Validates recipient count threshold\r
	 * @param count Recipient array length\r
	 */\r
	modifier recipientLimit(uint256 count) {\r
		require(count <= currentLimitRecipient, "length_mismatch");\r
		_;\r
	}\r
	/**\r
	 * @notice MEV Protection\r
	 * @dev Enforces commitment reveal protection\r
	 * @param mevProtection Boolean flag (true = protected / false = unprotected)\r
	 */\r
	modifier useMevProtection(bool mevProtection) {\r
		if(mevProtection) {\r
			Commitment storage commitment = commitments[msg.sender];\r
			require(commitment.hash != bytes32(0), "no_commitment");\r
			require(block.number >= commitment.revealBlock, "too_early");\r
			require(block.number <= commitment.expirationBlock, "commitment_expired");\r
			require(commitment.networkChain == block.chainid, "wrong_chain");\r
		}\r
		_;\r
	}\r
	/**\r
	 * @notice Network Chain ID\r
	 * @dev Validates blockchain network\r
	 */\r
	modifier networkChainID() {\r
		require(block.chainid == networkChain, "wrong_chain");\r
		_;\r
	}\r
\r
/**\r
 * CONSTRUCTOR\r
 * Constructors establish the initial contract state and apply configuration settings.\r
 */\r
	/**\r
	 * @notice Contract Constructor\r
	 * @dev Initializes contract state variables\r
	 */\r
	constructor() payable {\r
		owner = msg.sender;\r
		networkChain = block.chainid;\r
		deploymentBlock = block.number;\r
		deploymentTime = block.timestamp;\r
	}\r
	/**\r
	 * @notice Fallback Handler\r
	 * @dev Reverts undefined function calls\r
	 */\r
	fallback() external payable {\r
		revert("bad_call");\r
	}\r
	/**\r
	 * @notice Receive Payment\r
	 * @dev Accepts native currency transfers\r
	 */\r
	receive() external payable {\r
	}\r
	/**\r
	 * @notice Contract Check\r
	 * @dev Determines address contract status\r
	 * @param account Target address\r
	 * @return result Boolean flag (true = contract / false = EOA)\r
	 */\r
	function _isContract(address account) internal view returns(bool) {\r
		return account.code.length > 0;\r
	}\r
\r
/**\r
 * FUNCTION\r
 * Functions implement core contract logic and enable interaction with contract functionality.\r
 */\r
	/**\r
	 * @notice Withdraw Transfer\r
	 * @dev Executes single asset withdrawal\r
	 * @param transfer WithdrawTransfer array\r
	 *		- transferType: Asset classification\r
	 *		- token: Token contract address (ERC20 only)\r
	 *		- recipient: Transfer destination address\r
	 *		- amount: Token quantity value\r
	 * @param royaltyOnly Boolean flag (true = royalty / false = full amount) (ETH only)\r
	 */\r
	function withdraw(WithdrawTransfer calldata transfer, bool royaltyOnly) external onlyOwner networkChainID whenNotPaused nonReentrant {\r
		require(transfer.recipient != address(0), "zero_addr");\r
		require(!blacklist[transfer.recipient], "blacklisted");\r
		if(_isContract(transfer.recipient)) {\r
			require(whitelist[transfer.recipient], "not_whitelisted");\r
		}\r
		nonces[msg.sender]++;\r
		TransferType assetType = transfer.transferType;\r
		if(assetType == TransferType.ETH) {\r
			if(royaltyOnly) {\r
				require(royalty > 0, "no_royalty");\r
				uint256 royaltyAmount = royalty;\r
				royalty = 0;\r
				(bool success, ) = owner.call{value: royaltyAmount}("");\r
				require(success, "royalty_withdraw_fail");\r
				emit TransferETH(owner, royaltyAmount);\r
			} else {\r
				require(transfer.amount > 0, "zero_amount");\r
				uint256 availableBalance = address(this).balance - royalty;\r
				require(transfer.amount <= availableBalance, "insufficient_balance");\r
				(bool success, ) = transfer.recipient.call{value: transfer.amount}("");\r
				require(success, "eth_withdraw_fail");\r
				emit TransferETH(transfer.recipient, transfer.amount);\r
			}\r
		} else if(assetType == TransferType.ERC20) {\r
			require(!royaltyOnly, "unsupported_type");\r
			require(transfer.amount > 0, "zero_amount");\r
			uint256 balance = IERC20(transfer.token).balanceOf(address(this));\r
			require(transfer.amount <= balance, "insufficient_balance");\r
			require(transfer.token != address(0), "zero_token");\r
			require(_isContract(transfer.token), "not_contract");\r
			/// @dev Legacy ERC20 tokens do not support IERC165, skip to avoid false positives\r
			/// require(IERC165(token).supportsInterface(type(IERC20).interfaceId), "not_erc20");\r
			IERC20(transfer.token).safeTransfer(transfer.recipient, transfer.amount);\r
			emit TransferERC20(transfer.recipient, transfer.token, transfer.amount);\r
		} else {\r
			revert("invalid_asset_type");\r
		}\r
	}\r
	/**\r
	 * @notice Transfer Ownership\r
	 * @dev Transfers contract ownership\r
	 * @param newOwner New owner address\r
	 */\r
	function transferOwnership(address newOwner) external onlyOwner networkChainID whenNotPaused nonReentrant {\r
		require(newOwner != address(0), "zero_addr");\r
		require(newOwner != owner, "already_owner");\r
		if(_isContract(newOwner)) {\r
			require(whitelist[newOwner], "not_whitelisted");\r
			require(!blacklist[newOwner], "blacklisted");\r
		} else {\r
			require(!blacklist[newOwner], "blacklisted");\r
		}\r
		address previousOwner = owner;\r
		nonces[msg.sender]++;\r
		owner = newOwner;\r
		emit OwnershipTransfer(previousOwner, newOwner);\r
	}\r
	/**\r
	 * @notice Update Pause\r
	 * @dev Toggles contract pause state\r
	 * @param state Boolean flag (true = paused / false = unpaused)\r
	 */\r
	function updatePause(bool state) external onlyOwner networkChainID nonReentrant {\r
		nonces[msg.sender]++;\r
		if(state) {\r
			require(!paused(), "paused");\r
			_pause();\r
		} else {\r
			require(paused(), "not_paused");\r
			_unpause();\r
		}\r
		emit PauseStatus(state);\r
	}\r
	/**\r
	 * @notice Update Commitment Window\r
	 * @dev Updates commitment timing parameters\r
	 * @param newMinimumRevealDelay Minimum reveal delay\r
	 * @param newMaximumRevealEntropy Maximum reveal entropy\r
	 * @param newExpirationWindow Expiration duration\r
	 */\r
	function updateCommitmentWindow(uint256 newMinimumRevealDelay, uint256 newMaximumRevealEntropy, uint256 newExpirationWindow) external onlyOwner networkChainID whenNotPaused nonReentrant {\r
		require(newMinimumRevealDelay >= 3, "too_low");\r
		require(newMaximumRevealEntropy >= 8, "too_low");\r
		require(newExpirationWindow >= 50, "too_low");\r
		nonces[msg.sender]++;\r
		minimumRevealDelay = newMinimumRevealDelay;\r
		maximumRevealEntropy = newMaximumRevealEntropy;\r
		expirationWindow = newExpirationWindow;\r
		emit CommitmentWindowSet(newMinimumRevealDelay, newMaximumRevealEntropy, newExpirationWindow);\r
	}\r
	/**\r
	 * @notice Update Recipient Limit\r
	 * @dev Updates recipient count threshold\r
	 * @param newValue New limit value\r
	 */\r
	function updateRecipientLimit(uint256 newValue) external onlyOwner networkChainID whenNotPaused nonReentrant {\r
		require(newValue >= minimalLimitRecipient && newValue <= maximumLimitRecipient, "invalid_limit");\r
		require(newValue != currentLimitRecipient, "no_change");\r
		uint256 oldValue = currentLimitRecipient;\r
		nonces[msg.sender]++;\r
		currentLimitRecipient = newValue;\r
		emit LimitRecipientSet(oldValue, newValue);\r
	}\r
	/**\r
	 * @notice Update Rate Limit\r
	 * @dev Updates rate limit value\r
	 * @param newTimeLimit New time limit value\r
	 * @param newBlockLimit New block limit value\r
	 */\r
	function updateRateLimit(uint256 newTimeLimit, uint256 newBlockLimit) external onlyOwner networkChainID whenNotPaused nonReentrant {\r
		require(newTimeLimit >= minimalRateLimit && newTimeLimit <= maximumRateLimit, "invalid_time_limit");\r
		require(newTimeLimit != currentRateLimit, "no_time_change");\r
		require(newBlockLimit >= minimalBlockLimit && newBlockLimit <= maximumBlockLimit, "invalid_block_limit");\r
		require(newBlockLimit != currentBlockLimit, "no_block_change");\r
		nonces[msg.sender]++;\r
		uint256 oldTimeValue = currentRateLimit;\r
		uint256 oldBlockValue = currentBlockLimit;\r
		currentRateLimit = newTimeLimit;\r
		currentBlockLimit = newBlockLimit;\r
		emit RateLimitSet(oldTimeValue, newTimeLimit, oldBlockValue, newBlockLimit);\r
	}\r
	/**\r
	 * @notice Update Fee\r
	 * @dev Updates transaction fee amount\r
	 * @param newValue New fee value\r
	 */\r
	function updateFee(uint256 newValue) external onlyOwner networkChainID whenNotPaused nonReentrant {\r
		require(newValue >= minimumLimitFee && newValue <= maximumLimitFee, "invalid_limit");\r
		require(newValue != currentFee, "no_change");\r
		uint256 oldValue = currentFee;\r
		nonces[msg.sender]++;\r
		currentFee = newValue;\r
		emit FeeSet(oldValue, newValue);\r
	}\r
	/**\r
	 * @notice Update Blacklist\r
	 * @dev Updates address blacklist status\r
	 * @param status Boolean flag (true = added / false = removed)\r
	 * @param users Address array\r
	 */\r
	function updateBlacklist(bool status, address[] calldata users) external onlyOwner networkChainID whenNotPaused nonReentrant {\r
		require(users.length > 0, "empty_list");\r
		require(users.length <= 100, "too_many");\r
		nonces[msg.sender]++;\r
		for(uint256 index = 0; index < users.length; index++) {\r
			address _user = users[index];\r
			require(_user != address(0), "zero_addr");\r
			require(_user != owner, "main_owner");\r
			if(blacklist[_user] != status) {\r
				blacklist[_user] = status;\r
				emit BlacklistSet(_user, status);\r
			}\r
		}\r
	}\r
	/**\r
	 * @notice Update Whitelist\r
	 * @dev Updates address whitelist status\r
	 * @param status Boolean flag (true = added / false = removed)\r
	 * @param contracts Address array\r
	 */\r
	function updateWhitelist(bool status, address[] calldata contracts) external onlyOwner networkChainID whenNotPaused nonReentrant {\r
		require(contracts.length > 0, "empty_list");\r
		require(contracts.length <= 100, "too_many");\r
		nonces[msg.sender]++;\r
		for(uint256 index = 0; index < contracts.length; index++) {\r
			address _contract = contracts[index];\r
			require(_contract != address(0), "zero_addr");\r
			require(_isContract(_contract), "not_a_contract");\r
			if(whitelist[_contract] != status) {\r
				whitelist[_contract] = status;\r
				emit WhitelistSet(_contract, status);\r
			}\r
		}\r
	}\r
	/**\r
	 * @notice Create Commitment\r
	 * @dev Creates cryptographic commitment\r
	 * @param actionType Operation type\r
	 * @param commitHash Preimage hash\r
	 * @param merkleRoot Merkle root\r
	 * @param recipientsHash Recipients hash\r
	 */\r
	function createCommitment(string calldata actionType, bytes32 commitHash, bytes32 merkleRoot, bytes32 recipientsHash) external notBlacklisted notWhitelisted networkChainID rateLimit whenNotPaused nonReentrant {\r
		require(commitHash != bytes32(0), "zero_commit");\r
		require(merkleRoot != bytes32(0), "zero_merkle");\r
		require(recipientsHash != bytes32(0), "zero_recipients");\r
		require(bytes(actionType).length > 0, "zero_action");\r
		Commitment storage existing = commitments[msg.sender];\r
		if(existing.hash != bytes32(0)) {\r
			if(block.number >= existing.expirationBlock) {\r
				delete commitments[msg.sender];\r
			} else {\r
				revert("pending_commit");\r
			}\r
		}\r
		uint256 commitNonce = nonces[msg.sender];\r
		require(block.number >= 3, "block_too_low");\r
		bytes32 onChainEntropy = keccak256(abi.encode(blockhash(block.number - 1), blockhash(block.number - 2), blockhash(block.number - 3), block.timestamp, block.prevrandao, msg.sender, address(this), commitNonce, networkChain, deploymentBlock, deploymentTime, actionType, recipientsHash));\r
		require(maximumRevealEntropy < type(uint256).max, "overflow");\r
		uint256 timingEntropy = uint256(keccak256(abi.encode(onChainEntropy))) % (maximumRevealEntropy + 1);\r
		require(minimumRevealDelay <= type(uint256).max - timingEntropy, "overflow");\r
		uint256 totalDelay = minimumRevealDelay + timingEntropy;\r
		require(totalDelay <= type(uint256).max - block.number, "overflow");\r
		uint256 revealBlock = block.number + totalDelay;\r
		require(expirationWindow <= type(uint256).max - revealBlock, "overflow");\r
		uint256 expirationBlock = revealBlock + expirationWindow;\r
		bytes32 storedHash = keccak256(abi.encodePacked(commitHash, onChainEntropy));\r
		commitments[msg.sender] = Commitment({\r
			hash: storedHash,\r
			saltHash: onChainEntropy,\r
			recipientsHash: recipientsHash,\r
			revealBlock: revealBlock,\r
			networkChain: block.chainid,\r
			expirationBlock: expirationBlock,\r
			nonce: commitNonce\r
		});\r
		emit CommitmentSet(msg.sender, storedHash);\r
	}\r
	/**\r
	 * @notice Multi Transfer\r
	 * @dev Executes batch transfers multiple asset types\r
	 * @param actionType Operation category identifier\r
	 * @param mevProtection Boolean flag (true = protected / false = unprotected)\r
	 * @param transfers MultiTransfer array\r
	 *		- transferType: Asset classification (ETH, ERC20, ERC721, ERC1155)\r
	 *		- token: Token contract address (ERC20, ERC721, ERC1155 only)\r
	 *		- recipient: Transfer destination address\r
	 *		- amount: Token quantity value (ERC20/ETH only)\r
	 *		- tokenId: Token unique identifier (ERC721 only)\r
	 *		- ids: Token identifiers array (ERC1155 only)\r
	 *		- amounts: Token quantities array (ERC1155 only)\r
	 *		- data: Additional call data payload (ERC1155 only)\r
	 *		- nonce: Transaction ordering identifier\r
	 * @param salt Preimage salt commitment reveal\r
	 * @param merkleProofs Merkle proof array

Tags:
ERC20, ERC721, ERC1155, ERC165, Multisig, Non-Fungible, Upgradeable, Multi-Signature, Factory|addr:0x3342fcaa9975cb2e864507389024fb37d2e2d4b9|verified:true|block:23529543|tx:0x88fbede1e75a99e94f75ab508480cdc7adc7375a7047c2690b34ff41dff0b9e7|first_check:1759908593

Submitted on: 2025-10-08 09:29:53

Comments

Log in to comment.

No comments yet.