false
false
0
The new Blockscout UI is now open source! Learn how to deploy it here

Contract Address Details

0xe18036D7E3377801a19d5Db3f9b236617979674E

Contract Name
TippingZK
Creator
0xc62d01–dfded6 at 0x70d73d–8120a9
Balance
4.007117562863400142 ETH
Tokens
Fetching tokens...
Transactions
477,468 Transactions
Transfers
4 Transfers
Gas Used
21,535,751,969
Last Balance Update
4889060
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
Contract name:
TippingZK




Optimization enabled
true
Compiler version
v0.8.17+commit.8df45f5f




Optimization runs
200
Verified at
2023-06-01T22:41:10.733762Z

src/contracts/TippingZK.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";

import { ITipping } from "./interfaces/ITipping.sol";
import { MultiAssetSender } from "./libs/MultiAssetSender.sol";
import { FeeCalculator } from "./libs/FeeCalculatorZK.sol";
import { Batchable } from "./libs/Batchable.sol";

import { AssetType, FeeType } from "./enums/IDrissEnums.sol";

error tipping__withdraw__OnlyAdminCanWithdraw();

/**
 * @title Tipping
 * @author Lennard (lennardevertz)
 * @custom:contributor Rafał Kalinowski <deliriusz.eth@gmail.com>
 * @notice Tipping is a helper smart contract used for IDriss social media tipping functionality
 * @notice This contract was modified by @lennardevertz for usage in ETHGlobal Lisbon 2023
 */
contract TippingZK is Ownable, ITipping, MultiAssetSender, FeeCalculator, Batchable, IERC165 {
    address public contractOwner;
    mapping(address => uint256) public balanceOf;
    mapping(address => bool) public admins;

    event TipMessage(
        address indexed recipientAddress,
        string message,
        address indexed sender,
        address indexed tokenAddress
    );

    constructor() {
        admins[msg.sender] = true;

        FEE_TYPE_MAPPING[AssetType.Coin] = FeeType.Percentage;
        FEE_TYPE_MAPPING[AssetType.Token] = FeeType.Percentage;
        FEE_TYPE_MAPPING[AssetType.NFT] = FeeType.Constant;
        FEE_TYPE_MAPPING[AssetType.ERC1155] = FeeType.Constant;
    }

    /**
     * @notice Send native currency tip, charging a small fee
     */
    function sendTo(
        address _recipient,
        uint256, // amount is used only for multicall
        string memory _message
    ) external payable override {
        uint256 msgValue = _MSG_VALUE > 0 ? _MSG_VALUE : msg.value;
        (, uint256 paymentValue) = _splitPayment(msgValue, AssetType.Coin);
        _sendCoin(_recipient, paymentValue);

        emit TipMessage(_recipient, _message, msg.sender, address(0));
    }

    /**
     * @notice Send a tip in ERC20 token, charging a small fee
     */
    function sendTokenTo(
        address _recipient,
        uint256 _amount,
        address _tokenContractAddr,
        string memory _message
    ) external payable override {
        (, uint256 paymentValue) = _splitPayment(_amount, AssetType.Token);

        _sendTokenAssetFrom(_amount, msg.sender, address(this), _tokenContractAddr);
        _sendTokenAsset(paymentValue, _recipient, _tokenContractAddr);

        emit TipMessage(_recipient, _message, msg.sender, _tokenContractAddr);
    }

    /**
     * @notice Send a tip in ERC721 token, charging a small $ fee
     */
    function sendERC721To(
        address _recipient,
        uint256 _tokenId,
        address _nftContractAddress,
        string memory _message
    ) external payable override {
        // we use it just to revert when value is too small
        uint256 msgValue = _MSG_VALUE > 0 ? _MSG_VALUE : msg.value;
        _splitPayment(msgValue, AssetType.NFT);

        _sendNFTAsset(_tokenId, msg.sender, _recipient, _nftContractAddress);

        emit TipMessage(_recipient, _message, msg.sender, _nftContractAddress);
    }

    /**
     * @notice Send a tip in ERC721 token, charging a small $ fee
     */
    function sendERC1155To(
        address _recipient,
        uint256 _assetId,
        uint256 _amount,
        address _assetContractAddress,
        string memory _message
    ) external payable override {
        // we use it just to revert when value is too small
        uint256 msgValue = _MSG_VALUE > 0 ? _MSG_VALUE : msg.value;
        _splitPayment(msgValue, AssetType.ERC1155);

        _sendERC1155Asset(_assetId, _amount, msg.sender, _recipient, _assetContractAddress);

        emit TipMessage(_recipient, _message, msg.sender, _assetContractAddress);
    }

    /**
     * @notice Withdraw native currency transfer fees
     */
    function withdraw() external override onlyAdminCanWithdraw {
        (bool success, ) = msg.sender.call{value: address(this).balance}("");
        require(success, "Failed to withdraw.");
    }

    modifier onlyAdminCanWithdraw() {
        if (admins[msg.sender] != true) {
            revert tipping__withdraw__OnlyAdminCanWithdraw();
        }
        _;
    }

    /**
     * @notice Withdraw ERC20 transfer fees
     */
    function withdrawToken(address _tokenContract)
        external
        override
        onlyAdminCanWithdraw
    {
        IERC20 withdrawTC = IERC20(_tokenContract);
        withdrawTC.transfer(msg.sender, withdrawTC.balanceOf(address(this)));
    }

    /**
     * @notice Add admin with priviledged access
     */
    function addAdmin(address _adminAddress)
        external
        override
        onlyOwner
    {
        admins[_adminAddress] = true;
    }

    /**
     * @notice Remove admin
     */
    function deleteAdmin(address _adminAddress)
        external
        override
        onlyOwner
    {
        admins[_adminAddress] = false;
    }

    /**
    * @notice This is a function that allows for multicall
    * @param _calls An array of inputs for each call.
    * @dev calls Batchable::callBatch
    */
    function batch(bytes[] calldata _calls) external payable {
        batchCall(_calls);
    }

    function isMsgValueOverride(bytes4 _selector) override pure internal returns (bool) {
        return
            _selector == this.sendTo.selector ||
            _selector == this.sendTokenTo.selector ||
            _selector == this.sendERC721To.selector ||
            _selector == this.sendERC1155To.selector
        ;
    }

    function calculateMsgValueForACall(bytes4 _selector, bytes memory _calldata) override view internal returns (uint256) {
        uint256 currentCallPriceAmount;

        if (_selector == this.sendTo.selector) {
            assembly {
                currentCallPriceAmount := mload(add(_calldata, 68))
            }
        } else if (_selector == this.sendTokenTo.selector) {
            currentCallPriceAmount = getPaymentFee(0, AssetType.Token);
        } else if (_selector == this.sendTokenTo.selector) {
            currentCallPriceAmount = getPaymentFee(0, AssetType.NFT);
        } else {
            currentCallPriceAmount = getPaymentFee(0, AssetType.ERC1155);
        }

        return currentCallPriceAmount;
    }

    /*
    * @notice Always reverts. By default Ownable supports renouncing ownership, that is setting owner to address 0.
    *         However in this case it would disallow receiving payment fees by anyone.
    */
    function renounceOwnership() public override view onlyOwner {
        revert("Operation not supported");
    }

    /**
     * @notice ERC165 interface function implementation, listing all supported interfaces
     */
    function supportsInterface (bytes4 interfaceId) public pure override returns (bool) {
        return interfaceId == type(IERC165).interfaceId
         || interfaceId == type(ITipping).interfaceId;
    }
}
        

@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface AggregatorV3Interface {
  function decimals() external view returns (uint8);

  function description() external view returns (string memory);

  function version() external view returns (uint256);

  function getRoundData(uint80 _roundId)
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );

  function latestRoundData()
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );
}
          

@openzeppelin/contracts/utils/introspection/IERC165.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * 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[EIP 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/access/Ownable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

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

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

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

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

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

@openzeppelin/contracts/token/ERC1155/IERC1155.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` tokens of token 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 amount of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    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 caller.
     */
    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 `amount` tokens of token type `id` from `from` to `to`.
     *
     * 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 `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 amount,
        bytes calldata data
    ) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` 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 amounts,
        bytes calldata data
    ) external;
}
          

@openzeppelin/contracts/token/ERC20/IERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) external returns (bool);
}
          

@openzeppelin/contracts/token/ERC721/IERC721.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 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 ERC721 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 ERC721
     * 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 caller.
     *
     * 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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

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

src/contracts/enums/IDrissEnums.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

enum AssetType {
    Coin,
    Token,
    NFT,
    ERC1155
}

/**
* Percentage - constant percentage, e.g. 1% of the msg.value
* PercentageOrConstantMaximum - get msg.value percentage, or constant dollar value, depending on what is bigger
* Constant - constant dollar value, e.g. $1 - uses price Oracle
*/
enum FeeType {
    Percentage,
    PercentageOrConstantMaximum,
    Constant
}
          

src/contracts/interfaces/ITipping.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import { AssetType } from "../enums/IDrissEnums.sol";

interface ITipping {
    function sendTo(
        address _recipient,
        uint256 _amount,
        string memory _message
    ) external payable;

    function sendTokenTo(
        address _recipient,
        uint256 _amount,
        address _tokenContractAddr,
        string memory _message
    ) external payable;

    function sendERC721To(
        address _recipient,
        uint256 _assetId,
        address _nftContractAddress,
        string memory _message
    ) external payable;

    function sendERC1155To(
        address _recipient,
        uint256 _assetId,
        uint256 _amount,
        address _nftContractAddress,
        string memory _message
    ) external payable;

    function withdraw() external;

    function withdrawToken(address _tokenContract) external;

    function addAdmin(address _adminAddress) external;

    function deleteAdmin(address _adminAddress) external;
}
          

src/contracts/libs/Batchable.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

/**
 * @title Batchable
 * @author Rafał Kalinowski <deliriusz.eth@gmail.com>
 * @dev This is BoringBatchable based function with a small twist: because delgatecall passes msg.value
 *      on each call, it may introduce double spending issue. To avoid that, we handle cases when msg.value matters separately.
 *      Please note that you'll have to pass msg.value in amount field for native currency per each call
 *      Additionally, please keep in mind that currently you cannot put payable and nonpayable calls in the same batch -
 *      - nonpayable functions will revert when receiving money
 */
abstract contract Batchable {
    uint256 internal _MSG_VALUE;
    uint256 internal constant _BATCH_NOT_ENTERED = 1;
    uint256 internal constant _BATCH_ENTERED = 2;
    uint256 internal _batchStatus;

    error BatchError(bytes innerError);

    constructor() {
        _batchStatus = _BATCH_NOT_ENTERED;
    }

    /**
    * @notice This function allows batched call to self (this contract).
    * @param _calls An array of inputs for each call.
    * @dev - it sets _MSG_VALUE variable for a call, if function is payable
     *       check if the function is payable is done in your implementation of function `isMsgValueOverride()`
     *       and _MSG_VALUE is set based on your `calculateMsgValueForACall()` implementation
    */
    // F1: External is ok here because this is the batch function, adding it to a batch makes no sense
    // F2: Calls in the batch may be payable, delegatecall operates in the same context, so each call in the batch has access to msg.value
    // C3: The length of the loop is fully under user control, so can't be exploited
    // C7: Delegatecall is used on the same contract, and there is reentrancy guard in place
    function batchCall(bytes[] calldata _calls) internal {
        // bacause we already have reentrancy guard for functions, we set second kind of reentrancy guard
        require(_batchStatus != _BATCH_ENTERED, "ReentrancyGuard: reentrant call");
        uint256 msgValueSentAcc;

        _batchStatus = _BATCH_ENTERED;

        for (uint256 i = 0; i < _calls.length; i++) {
            bool success;
            bytes memory result;
            bytes memory data = _calls[i];
            bytes4 sig;

            assembly {
                sig := mload(add(data, add(0x20, 0)))
            }

            // set proper msg.value for payable function, as delegatecall can introduce double spending
            if (isMsgValueOverride(sig)) {
                uint256 currentCallPriceAmount = calculateMsgValueForACall(sig, data);

                _MSG_VALUE = currentCallPriceAmount;
                msgValueSentAcc += currentCallPriceAmount;

                require (msgValueSentAcc <= msg.value, "Can't send more than msg.value");

                (success, result) = address(this).delegatecall(data);

                _MSG_VALUE = 0;
            } else {
                (success, result) = address(this).delegatecall(data);
            }

            if (!success) {
                _getRevertMsg(result);
            }
        }

        _batchStatus = _BATCH_NOT_ENTERED;
    }

    /**
    * @notice This is part of BoringBatchable contract
    *         https://github.com/boringcrypto/BoringSolidity/blob/master/contracts/BoringBatchable.sol
    * @dev Helper function to extract a useful revert message from a failed call.
    * If the returned data is malformed or not correctly abi encoded then this call can fail itself.
    */
    function _getRevertMsg(bytes memory _returnData) internal pure {
        // If the _res length is less than 68, then
        // the transaction failed with custom error or silently (without a revert message)
        if (_returnData.length < 68) revert BatchError(_returnData);

        assembly {
        // Slice the sighash.
            _returnData := add(_returnData, 0x04)
        }
        revert(abi.decode(_returnData, (string))); // All that remains is the revert string
    }

    /**
    * @notice Checks if a function is payable, i.e. should _MSG_VALUE be set
    * @param _selector function selector
    * @dev Write your logic checking if a function is payable, e.g. this.<function-name>.selector == _selector
    *      WARNING - if you, or someone else if able to construct the same selector for a malicious function (which is not that hard),
    *      the logic may break and the msg.value may be exploited
    */
    function isMsgValueOverride(bytes4 _selector) virtual pure internal returns (bool);

    /**
    * @notice Calculates msg.value that should be sent with a call
    * @param _selector function selector
    * @param _calldata single call encoded data
    * @dev You should probably decode function parameters and check what value should be passed
    */
    function calculateMsgValueForACall(bytes4 _selector, bytes memory _calldata) virtual view internal returns (uint256);
}
          

src/contracts/libs/FeeCalculatorZK.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

import { AssetType, FeeType } from "../enums/IDrissEnums.sol";

/**
 * @title FeeCalculator
 * @author Rafał Kalinowski <deliriusz.eth@gmail.com>
 * @notice This is an utility contract for calculating a fee
 */
contract FeeCalculator is Ownable {
    uint256 public constant PAYMENT_FEE_SLIPPAGE_PERCENT = 5;
    uint256 public PAYMENT_FEE_PERCENTAGE = 10;
    uint256 public PAYMENT_FEE_PERCENTAGE_DENOMINATOR = 1000;
    uint256 public MINIMAL_PAYMENT_FEE = 500000000000000;
    // you have to pass your desired fee types in a constructor deriving this contract
    mapping (AssetType => FeeType) FEE_TYPE_MAPPING;

    constructor() {
    }


    /**
     * @notice Calculates payment fee
     * @param _value - payment value
     * @param _assetType - asset type, required as ERC20 & ERC721 only take minimal fee
     * @return fee - processing fee, few percent of slippage is allowed
     */
    function getPaymentFee(uint256 _value, AssetType _assetType) public view returns (uint256) {
        uint256 minimumPaymentFee = _getMinimumFee();
        uint256 percentageFee = _getPercentageFee(_value);
        FeeType feeType = FEE_TYPE_MAPPING[_assetType];
        if (feeType == FeeType.Constant) {
            return minimumPaymentFee;
        } else if (feeType == FeeType.Percentage) {
            return percentageFee;
        }

        // default case - PercentageOrConstantMaximum
        if (percentageFee > minimumPaymentFee) return percentageFee; else return minimumPaymentFee;
    }

    function _getMinimumFee() internal view returns (uint256) {
        return MINIMAL_PAYMENT_FEE;
    }

    function _getPercentageFee(uint256 _value) internal view returns (uint256) {
        return (_value * PAYMENT_FEE_PERCENTAGE) / PAYMENT_FEE_PERCENTAGE_DENOMINATOR;
    }

    /**
     * @notice Calculates value of a fee from sent msg.value
     * @param _valueToSplit - payment value, taken from msg.value
     * @param _assetType - asset type, as there may be different calculation logic for each type
     * @return fee - processing fee, few percent of slippage is allowed
     * @return value - payment value after substracting fee
     */
    function _splitPayment(uint256 _valueToSplit, AssetType _assetType) internal view returns (uint256 fee, uint256 value) {
        uint256 minimalPaymentFee = _getMinimumFee();
        uint256 paymentFee = getPaymentFee(_valueToSplit, _assetType);

        // we accept slippage of matic price if fee type is not percentage - it this case we always get % no matter dollar price
        if (FEE_TYPE_MAPPING[_assetType] != FeeType.Percentage
            && _valueToSplit >= minimalPaymentFee * (100 - PAYMENT_FEE_SLIPPAGE_PERCENT) / 100
            && _valueToSplit <= minimalPaymentFee) {
            fee = _valueToSplit;
        } else {
            fee = paymentFee;
        }

        require (_valueToSplit >= fee, "Value sent is smaller than minimal fee.");

        value = _valueToSplit - fee;
    }


    /**
    * @notice adjust payment fee percentage for big native currenct transfers
    * @dev Solidity is not good when it comes to handling floats. We use denominator then,
    *      e.g. to set payment fee to 1.5% , just pass paymentFee = 15 & denominator = 1000 => 15 / 1000 = 0.015 = 1.5%
    */
    function changePaymentFeePercentage (uint256 _paymentFeePercentage, uint256 _paymentFeeDenominator) external onlyOwner {
        require(_paymentFeePercentage > 0, "Payment fee has to be bigger than 0");
        require(_paymentFeeDenominator > 0, "Payment fee denominator has to be bigger than 0");

        PAYMENT_FEE_PERCENTAGE = _paymentFeePercentage;
        PAYMENT_FEE_PERCENTAGE_DENOMINATOR = _paymentFeeDenominator;
    }

    /**
    * @notice adjust minimal payment fee for all asset transfers
    * @dev Solidity is not good when it comes to handling floats. We use denominator then,
    *      e.g. to set minimal payment fee to 2.2$ , just pass paymentFee = 22 & denominator = 10 => 22 / 10 = 2.2
    */
    function changeMinimalPaymentFee (uint256 _minimalPaymentFee) external onlyOwner {
        require(_minimalPaymentFee > 0, "Payment fee has to be bigger than 0");

        MINIMAL_PAYMENT_FEE = _minimalPaymentFee;
    }
}
          

src/contracts/libs/MultiAssetSender.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";

/**
 * @title MultiAssetSender
 * @author Rafał Kalinowski <deliriusz.eth@gmail.com>
 * @notice This is an utility contract for sending different kind of assets
 * @dev Please note that you should make reentrancy check yourself
 */
contract MultiAssetSender {

    constructor() { }

    /**
    * @notice Wrapper for sending native Coin via call function
    * @dev When using this function please make sure to not send it to anyone, verify the
    *      address in IDriss registry
    */
    function _sendCoin (address _to, uint256 _amount) internal {
        (bool sent, ) = payable(_to).call{value: _amount}("");
        require(sent, "Failed to send");
    }

    /**
     * @notice Wrapper for sending single ERC1155 asset 
     * @dev due to how approval in ERC1155 standard is handled, the smart contract has to ask for permissions to manage
     *      ALL tokens "for simplicity"... Hence, it has to be done before calling function that transfers the token
     *      to smart contract, and revoked afterwards
     */
    function _sendERC1155AssetBatch (
        uint256[] memory _assetIds,
        uint256[] memory _amounts,
        address _from,
        address _to,
        address _contractAddress
    ) internal {
        IERC1155 nft = IERC1155(_contractAddress);
        nft.safeBatchTransferFrom(_from, _to, _assetIds, _amounts, "");
    }

    /**
     * @notice Wrapper for sending multiple ERC1155 assets
     * @dev due to how approval in ERC1155 standard is handled, the smart contract has to ask for permissions to manage
     *      ALL tokens "for simplicity"... Hence, it has to be done before calling function that transfers the token
     *      to smart contract, and revoked afterwards
     */
    function _sendERC1155Asset (
        uint256 _assetId,
        uint256 _amount,
        address _from,
        address _to,
        address _contractAddress
    ) internal {
        IERC1155 nft = IERC1155(_contractAddress);
        nft.safeTransferFrom(_from, _to, _assetId, _amount, "");
    }

    /**
     * @notice Wrapper for sending NFT asset
     */
    function _sendNFTAsset (
        uint256 _assetIds,
        address _from,
        address _to,
        address _contractAddress
    ) internal {
        IERC721 nft = IERC721(_contractAddress);
        nft.safeTransferFrom(_from, _to, _assetIds, "");
    }

    /**
     * @notice Wrapper for sending NFT asset with additional checks and iteraton over an array
     */
    function _sendNFTAssetBatch (
        uint256[] memory _assetIds,
        address _from,
        address _to,
        address _contractAddress
    ) internal {
        require(_assetIds.length > 0, "Nothing to send");

        IERC721 nft = IERC721(_contractAddress);
        for (uint256 i = 0; i < _assetIds.length; ++i) {
            nft.safeTransferFrom(_from, _to, _assetIds[i], "");
        }
    }

    /**
     * @notice Wrapper for sending ERC20 Token asset with additional checks
     */
    function _sendTokenAsset (
        uint256 _amount,
        address _to,
        address _contractAddress
    ) internal {
        IERC20 token = IERC20(_contractAddress);

        bool sent = token.transfer(_to, _amount);
        require(sent, "Failed to transfer token");
    }

    /**
     * @notice Wrapper for sending ERC20 token from specific account with additional checks and iteraton over an array
     */
    function _sendTokenAssetFrom (
        uint256 _amount,
        address _from,
        address _to,
        address _contractAddress
    ) internal {
        IERC20 token = IERC20(_contractAddress);

        bool sent = token.transferFrom(_from, _to, _amount);
        require(sent, "Failed to transfer token");
    }
}
          

Compiler Settings

{"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers","metadata"],"":["ast"]}},"optimizer":{"runs":200,"enabled":true},"libraries":{}}
              

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[]},{"type":"error","name":"BatchError","inputs":[{"type":"bytes","name":"innerError","internalType":"bytes"}]},{"type":"error","name":"tipping__withdraw__OnlyAdminCanWithdraw","inputs":[]},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"TipMessage","inputs":[{"type":"address","name":"recipientAddress","internalType":"address","indexed":true},{"type":"string","name":"message","internalType":"string","indexed":false},{"type":"address","name":"sender","internalType":"address","indexed":true},{"type":"address","name":"tokenAddress","internalType":"address","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"MINIMAL_PAYMENT_FEE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"PAYMENT_FEE_PERCENTAGE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"PAYMENT_FEE_PERCENTAGE_DENOMINATOR","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"PAYMENT_FEE_SLIPPAGE_PERCENT","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addAdmin","inputs":[{"type":"address","name":"_adminAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"admins","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balanceOf","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"batch","inputs":[{"type":"bytes[]","name":"_calls","internalType":"bytes[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"changeMinimalPaymentFee","inputs":[{"type":"uint256","name":"_minimalPaymentFee","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"changePaymentFeePercentage","inputs":[{"type":"uint256","name":"_paymentFeePercentage","internalType":"uint256"},{"type":"uint256","name":"_paymentFeeDenominator","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"contractOwner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"deleteAdmin","inputs":[{"type":"address","name":"_adminAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getPaymentFee","inputs":[{"type":"uint256","name":"_value","internalType":"uint256"},{"type":"uint8","name":"_assetType","internalType":"enum AssetType"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"payable","outputs":[],"name":"sendERC1155To","inputs":[{"type":"address","name":"_recipient","internalType":"address"},{"type":"uint256","name":"_assetId","internalType":"uint256"},{"type":"uint256","name":"_amount","internalType":"uint256"},{"type":"address","name":"_assetContractAddress","internalType":"address"},{"type":"string","name":"_message","internalType":"string"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"sendERC721To","inputs":[{"type":"address","name":"_recipient","internalType":"address"},{"type":"uint256","name":"_tokenId","internalType":"uint256"},{"type":"address","name":"_nftContractAddress","internalType":"address"},{"type":"string","name":"_message","internalType":"string"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"sendTo","inputs":[{"type":"address","name":"_recipient","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"string","name":"_message","internalType":"string"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"sendTokenTo","inputs":[{"type":"address","name":"_recipient","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"},{"type":"address","name":"_tokenContractAddr","internalType":"address"},{"type":"string","name":"_message","internalType":"string"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"interfaceId","internalType":"bytes4"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdraw","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdrawToken","inputs":[{"type":"address","name":"_tokenContract","internalType":"address"}]}]
              

Contract Creation Code

0x6080604052600a6001556103e86002556601c6bf5263400060035534801561002657600080fd5b5061003033610107565b600160068190553360009081526009602090815260408220805460ff199081169094179055600490527f17ef568e3e12ab5b9c7254a8d58478811de00f9e6eb34345acd53bf8fd09d3ec8054831690557fabd6e7cb50984ff9c2f3e18a2660c3353dadf4e3291deeb275dae2cd1e44fe058054831690557f91da3fd0782e51c6b3986e9e672fd566868e71f3dbc2d6c2cd6fbb3e361af2a780548316600290811790915560039091527f2e174c10e159ea99b867ce3205125c24a42d128804e4070ed6fcc8cc98166aa08054909216179055610157565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b611925806101666000396000f3fe6080604052600436106101405760003560e01c80635c73f163116100b6578063894760691161006f57806389476069146103345780638d157db8146103545780638da5cb5b146103675780639cd6aa4c14610399578063ce606ee0146103b9578063f2fde38b146103d957600080fd5b80635c73f1631461029457806370480275146102aa57806370a08231146102ca5780637129607a146102f7578063715018a61461030a57806383a4c7e11461031f57600080fd5b80631e897afb116101085780631e897afb146101e957806327e1f7df146101fc57806330ae06e01461021c5780633ccfd60b1461023c57806341dfeca514610251578063429b62e51461026457600080fd5b806301ffc9a71461014557806303f613dc1461017a5780630728c7d21461019e5780630f7f630a146101c057806316e49145146101d6575b600080fd5b34801561015157600080fd5b50610165610160366004611338565b6103f9565b60405190151581526020015b60405180910390f35b34801561018657600080fd5b5061019060025481565b604051908152602001610171565b3480156101aa57600080fd5b506101be6101b9366004611362565b610430565b005b3480156101cc57600080fd5b5061019060035481565b6101be6101e4366004611465565b6104d4565b6101be6101f73660046114bc565b610562565b34801561020857600080fd5b506101be610217366004611531565b610570565b34801561022857600080fd5b506101be61023736600461154c565b610599565b34801561024857600080fd5b506101be6105c6565b6101be61025f366004611565565b61068c565b34801561027057600080fd5b5061016561027f366004611531565b60096020526000908152604090205460ff1681565b3480156102a057600080fd5b5061019060015481565b3480156102b657600080fd5b506101be6102c5366004611531565b610700565b3480156102d657600080fd5b506101906102e5366004611531565b60086020526000908152604090205481565b6101be6103053660046115cd565b61072c565b34801561031657600080fd5b506101be6107ba565b34801561032b57600080fd5b50610190600581565b34801561034057600080fd5b506101be61034f366004611531565b61080a565b6101be610362366004611565565b610927565b34801561037357600080fd5b506000546001600160a01b03165b6040516001600160a01b039091168152602001610171565b3480156103a557600080fd5b506101906103b436600461163f565b610957565b3480156103c557600080fd5b50600754610381906001600160a01b031681565b3480156103e557600080fd5b506101be6103f4366004611531565b610a14565b60006001600160e01b031982166301ffc9a760e01b148061042a57506001600160e01b0319821663249311f560e11b145b92915050565b610438610a8a565b600082116104615760405162461bcd60e51b815260040161045890611673565b60405180910390fd5b600081116104c95760405162461bcd60e51b815260206004820152602f60248201527f5061796d656e74206665652064656e6f6d696e61746f722068617320746f206260448201526e06520626967676572207468616e203608c1b6064820152608401610458565b600191909155600255565b600080600554116104e557346104e9565b6005545b905060006104f8826000610ae6565b9150506105058582610c12565b60006001600160a01b0316336001600160a01b0316866001600160a01b03167f7f2664f4cc0d5e1cd88924a43d93d73ee92ccc1c4e0f1cb15c54c83131481a77866040516105539190611706565b60405180910390a45050505050565b61056c8282610ca6565b5050565b610578610a8a565b6001600160a01b03166000908152600960205260409020805460ff19169055565b6105a1610a8a565b600081116105c15760405162461bcd60e51b815260040161045890611673565b600355565b3360009081526009602052604090205460ff1615156001146105fb57604051631eda59c960e11b815260040160405180910390fd5b604051600090339047908381818185875af1925050503d806000811461063d576040519150601f19603f3d011682016040523d82523d6000602084013e610642565b606091505b50509050806106895760405162461bcd60e51b81526020600482015260136024820152722330b4b632b2103a37903bb4ba34323930bb9760691b6044820152606401610458565b50565b6000610699846001610ae6565b9150506106a884333086610ed5565b6106b3818685610fa7565b826001600160a01b0316336001600160a01b0316866001600160a01b03167f7f2664f4cc0d5e1cd88924a43d93d73ee92ccc1c4e0f1cb15c54c83131481a77856040516105539190611706565b610708610a8a565b6001600160a01b03166000908152600960205260409020805460ff19166001179055565b6000806005541161073d5734610741565b6005545b905061074e816003610ae6565b505061075d8585338987611070565b826001600160a01b0316336001600160a01b0316876001600160a01b03167f7f2664f4cc0d5e1cd88924a43d93d73ee92ccc1c4e0f1cb15c54c83131481a77856040516107aa9190611706565b60405180910390a4505050505050565b6107c2610a8a565b60405162461bcd60e51b815260206004820152601760248201527f4f7065726174696f6e206e6f7420737570706f727465640000000000000000006044820152606401610458565b3360009081526009602052604090205460ff16151560011461083f57604051631eda59c960e11b815260040160405180910390fd5b6040516370a0823160e01b815230600482015281906001600160a01b0382169063a9059cbb90339083906370a0823190602401602060405180830381865afa15801561088f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108b39190611719565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303816000875af11580156108fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109229190611732565b505050565b60008060055411610938573461093c565b6005545b9050610949816002610ae6565b50506106b3843387866110fa565b60008061096360035490565b905060006109708561117c565b905060006004600086600381111561098a5761098a611754565b600381111561099b5761099b611754565b815260208101919091526040016000205460ff16905060028160028111156109c5576109c5611754565b036109d55782935050505061042a565b60008160028111156109e9576109e9611754565b036109f85750915061042a9050565b82821115610a0a5750915061042a9050565b5090949350505050565b610a1c610a8a565b6001600160a01b038116610a815760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610458565b61068981611199565b6000546001600160a01b03163314610ae45760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610458565b565b6000806000610af460035490565b90506000610b028686610957565b9050600060046000876003811115610b1c57610b1c611754565b6003811115610b2d57610b2d611754565b815260208101919091526040016000205460ff166002811115610b5257610b52611754565b14158015610b8057506064610b68600582611780565b610b729084611793565b610b7c91906117aa565b8610155b8015610b8c5750818611155b15610b9957859350610b9d565b8093505b83861015610bfd5760405162461bcd60e51b815260206004820152602760248201527f56616c75652073656e7420697320736d616c6c6572207468616e206d696e696d60448201526630b6103332b29760c91b6064820152608401610458565b610c078487611780565b925050509250929050565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114610c5f576040519150601f19603f3d011682016040523d82523d6000602084013e610c64565b606091505b50509050806109225760405162461bcd60e51b815260206004820152600e60248201526d11985a5b1959081d1bc81cd95b9960921b6044820152606401610458565b600260065403610cf85760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610458565b60026006556000805b82811015610eca57600060606000868685818110610d2157610d216117cc565b9050602002810190610d3391906117e2565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050506020810151909150610d78816111e9565b15610e4e576000610d898284611255565b60058190559050610d9a8188611830565b965034871115610dec5760405162461bcd60e51b815260206004820152601e60248201527f43616e27742073656e64206d6f7265207468616e206d73672e76616c756500006044820152606401610458565b6040513090610dfc908590611843565b600060405180830381855af49150503d8060008114610e37576040519150601f19603f3d011682016040523d82523d6000602084013e610e3c565b606091505b5060006005559095509350610ea59050565b6040513090610e5e908490611843565b600060405180830381855af49150503d8060008114610e99576040519150601f19603f3d011682016040523d82523d6000602084013e610e9e565b606091505b5090945092505b83610eb357610eb3836112e0565b505050508080610ec29061185f565b915050610d01565b505060016006555050565b6040516323b872dd60e01b81526001600160a01b03848116600483015283811660248301526044820186905282916000918316906323b872dd906064016020604051808303816000875af1158015610f31573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f559190611732565b905080610f9f5760405162461bcd60e51b81526020600482015260186024820152772330b4b632b2103a37903a3930b739b332b9103a37b5b2b760411b6044820152606401610458565b505050505050565b60405163a9059cbb60e01b81526001600160a01b03838116600483015260248201859052829160009183169063a9059cbb906044016020604051808303816000875af1158015610ffb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061101f9190611732565b9050806110695760405162461bcd60e51b81526020600482015260186024820152772330b4b632b2103a37903a3930b739b332b9103a37b5b2b760411b6044820152606401610458565b5050505050565b604051637921219560e11b81526001600160a01b0384811660048301528381166024830152604482018790526064820186905260a06084830152600060a483015282919082169063f242432a9060c401600060405180830381600087803b1580156110da57600080fd5b505af11580156110ee573d6000803e3d6000fd5b50505050505050505050565b604051635c46a7ef60e11b81526001600160a01b038481166004830152838116602483015260448201869052608060648301526000608483015282919082169063b88d4fde9060a401600060405180830381600087803b15801561115d57600080fd5b505af1158015611171573d6000803e3d6000fd5b505050505050505050565b60006002546001548361118f9190611793565b61042a91906117aa565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006001600160e01b031982166316e4914560e01b148061121a57506001600160e01b031982166341dfeca560e01b145b8061123557506001600160e01b031982166311a2afb760e31b145b8061042a57506001600160e01b03198216633894b03d60e11b1492915050565b60008063e91b6ebb60e01b6001600160e01b031985160161127b575060448201516112d9565b63be20135b60e01b6001600160e01b03198516016112a65761129f60006001610957565b90506112d9565b63be20135b60e01b6001600160e01b03198516016112ca5761129f60006002610957565b6112d660006003610957565b90505b9392505050565b604481511015611305578060405163d935448560e01b81526004016104589190611706565b6004810190508080602001905181019061131f9190611878565b60405162461bcd60e51b81526004016104589190611706565b60006020828403121561134a57600080fd5b81356001600160e01b0319811681146112d957600080fd5b6000806040838503121561137557600080fd5b50508035926020909101359150565b80356001600160a01b038116811461139b57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156113df576113df6113a0565b604052919050565b600067ffffffffffffffff821115611401576114016113a0565b50601f01601f191660200190565b600082601f83011261142057600080fd5b813561143361142e826113e7565b6113b6565b81815284602083860101111561144857600080fd5b816020850160208301376000918101602001919091529392505050565b60008060006060848603121561147a57600080fd5b61148384611384565b925060208401359150604084013567ffffffffffffffff8111156114a657600080fd5b6114b28682870161140f565b9150509250925092565b600080602083850312156114cf57600080fd5b823567ffffffffffffffff808211156114e757600080fd5b818501915085601f8301126114fb57600080fd5b81358181111561150a57600080fd5b8660208260051b850101111561151f57600080fd5b60209290920196919550909350505050565b60006020828403121561154357600080fd5b6112d982611384565b60006020828403121561155e57600080fd5b5035919050565b6000806000806080858703121561157b57600080fd5b61158485611384565b93506020850135925061159960408601611384565b9150606085013567ffffffffffffffff8111156115b557600080fd5b6115c18782880161140f565b91505092959194509250565b600080600080600060a086880312156115e557600080fd5b6115ee86611384565b9450602086013593506040860135925061160a60608701611384565b9150608086013567ffffffffffffffff81111561162657600080fd5b6116328882890161140f565b9150509295509295909350565b6000806040838503121561165257600080fd5b8235915060208301356004811061166857600080fd5b809150509250929050565b60208082526023908201527f5061796d656e74206665652068617320746f206265206269676765722074686160408201526206e20360ec1b606082015260800190565b60005b838110156116d15781810151838201526020016116b9565b50506000910152565b600081518084526116f28160208601602086016116b6565b601f01601f19169290920160200192915050565b6020815260006112d960208301846116da565b60006020828403121561172b57600080fd5b5051919050565b60006020828403121561174457600080fd5b815180151581146112d957600080fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b8181038181111561042a5761042a61176a565b808202811582820484141761042a5761042a61176a565b6000826117c757634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052603260045260246000fd5b6000808335601e198436030181126117f957600080fd5b83018035915067ffffffffffffffff82111561181457600080fd5b60200191503681900382131561182957600080fd5b9250929050565b8082018082111561042a5761042a61176a565b600082516118558184602087016116b6565b9190910192915050565b6000600182016118715761187161176a565b5060010190565b60006020828403121561188a57600080fd5b815167ffffffffffffffff8111156118a157600080fd5b8201601f810184136118b257600080fd5b80516118c061142e826113e7565b8181528560208385010111156118d557600080fd5b6118e68260208301602086016116b6565b9594505050505056fea264697066735822122063106177cce7332c4c2ab71484e684d7d2a2ff6d657441f845a568de40763d0664736f6c63430008110033

Deployed ByteCode

0x6080604052600436106101405760003560e01c80635c73f163116100b6578063894760691161006f57806389476069146103345780638d157db8146103545780638da5cb5b146103675780639cd6aa4c14610399578063ce606ee0146103b9578063f2fde38b146103d957600080fd5b80635c73f1631461029457806370480275146102aa57806370a08231146102ca5780637129607a146102f7578063715018a61461030a57806383a4c7e11461031f57600080fd5b80631e897afb116101085780631e897afb146101e957806327e1f7df146101fc57806330ae06e01461021c5780633ccfd60b1461023c57806341dfeca514610251578063429b62e51461026457600080fd5b806301ffc9a71461014557806303f613dc1461017a5780630728c7d21461019e5780630f7f630a146101c057806316e49145146101d6575b600080fd5b34801561015157600080fd5b50610165610160366004611338565b6103f9565b60405190151581526020015b60405180910390f35b34801561018657600080fd5b5061019060025481565b604051908152602001610171565b3480156101aa57600080fd5b506101be6101b9366004611362565b610430565b005b3480156101cc57600080fd5b5061019060035481565b6101be6101e4366004611465565b6104d4565b6101be6101f73660046114bc565b610562565b34801561020857600080fd5b506101be610217366004611531565b610570565b34801561022857600080fd5b506101be61023736600461154c565b610599565b34801561024857600080fd5b506101be6105c6565b6101be61025f366004611565565b61068c565b34801561027057600080fd5b5061016561027f366004611531565b60096020526000908152604090205460ff1681565b3480156102a057600080fd5b5061019060015481565b3480156102b657600080fd5b506101be6102c5366004611531565b610700565b3480156102d657600080fd5b506101906102e5366004611531565b60086020526000908152604090205481565b6101be6103053660046115cd565b61072c565b34801561031657600080fd5b506101be6107ba565b34801561032b57600080fd5b50610190600581565b34801561034057600080fd5b506101be61034f366004611531565b61080a565b6101be610362366004611565565b610927565b34801561037357600080fd5b506000546001600160a01b03165b6040516001600160a01b039091168152602001610171565b3480156103a557600080fd5b506101906103b436600461163f565b610957565b3480156103c557600080fd5b50600754610381906001600160a01b031681565b3480156103e557600080fd5b506101be6103f4366004611531565b610a14565b60006001600160e01b031982166301ffc9a760e01b148061042a57506001600160e01b0319821663249311f560e11b145b92915050565b610438610a8a565b600082116104615760405162461bcd60e51b815260040161045890611673565b60405180910390fd5b600081116104c95760405162461bcd60e51b815260206004820152602f60248201527f5061796d656e74206665652064656e6f6d696e61746f722068617320746f206260448201526e06520626967676572207468616e203608c1b6064820152608401610458565b600191909155600255565b600080600554116104e557346104e9565b6005545b905060006104f8826000610ae6565b9150506105058582610c12565b60006001600160a01b0316336001600160a01b0316866001600160a01b03167f7f2664f4cc0d5e1cd88924a43d93d73ee92ccc1c4e0f1cb15c54c83131481a77866040516105539190611706565b60405180910390a45050505050565b61056c8282610ca6565b5050565b610578610a8a565b6001600160a01b03166000908152600960205260409020805460ff19169055565b6105a1610a8a565b600081116105c15760405162461bcd60e51b815260040161045890611673565b600355565b3360009081526009602052604090205460ff1615156001146105fb57604051631eda59c960e11b815260040160405180910390fd5b604051600090339047908381818185875af1925050503d806000811461063d576040519150601f19603f3d011682016040523d82523d6000602084013e610642565b606091505b50509050806106895760405162461bcd60e51b81526020600482015260136024820152722330b4b632b2103a37903bb4ba34323930bb9760691b6044820152606401610458565b50565b6000610699846001610ae6565b9150506106a884333086610ed5565b6106b3818685610fa7565b826001600160a01b0316336001600160a01b0316866001600160a01b03167f7f2664f4cc0d5e1cd88924a43d93d73ee92ccc1c4e0f1cb15c54c83131481a77856040516105539190611706565b610708610a8a565b6001600160a01b03166000908152600960205260409020805460ff19166001179055565b6000806005541161073d5734610741565b6005545b905061074e816003610ae6565b505061075d8585338987611070565b826001600160a01b0316336001600160a01b0316876001600160a01b03167f7f2664f4cc0d5e1cd88924a43d93d73ee92ccc1c4e0f1cb15c54c83131481a77856040516107aa9190611706565b60405180910390a4505050505050565b6107c2610a8a565b60405162461bcd60e51b815260206004820152601760248201527f4f7065726174696f6e206e6f7420737570706f727465640000000000000000006044820152606401610458565b3360009081526009602052604090205460ff16151560011461083f57604051631eda59c960e11b815260040160405180910390fd5b6040516370a0823160e01b815230600482015281906001600160a01b0382169063a9059cbb90339083906370a0823190602401602060405180830381865afa15801561088f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108b39190611719565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303816000875af11580156108fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109229190611732565b505050565b60008060055411610938573461093c565b6005545b9050610949816002610ae6565b50506106b3843387866110fa565b60008061096360035490565b905060006109708561117c565b905060006004600086600381111561098a5761098a611754565b600381111561099b5761099b611754565b815260208101919091526040016000205460ff16905060028160028111156109c5576109c5611754565b036109d55782935050505061042a565b60008160028111156109e9576109e9611754565b036109f85750915061042a9050565b82821115610a0a5750915061042a9050565b5090949350505050565b610a1c610a8a565b6001600160a01b038116610a815760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610458565b61068981611199565b6000546001600160a01b03163314610ae45760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610458565b565b6000806000610af460035490565b90506000610b028686610957565b9050600060046000876003811115610b1c57610b1c611754565b6003811115610b2d57610b2d611754565b815260208101919091526040016000205460ff166002811115610b5257610b52611754565b14158015610b8057506064610b68600582611780565b610b729084611793565b610b7c91906117aa565b8610155b8015610b8c5750818611155b15610b9957859350610b9d565b8093505b83861015610bfd5760405162461bcd60e51b815260206004820152602760248201527f56616c75652073656e7420697320736d616c6c6572207468616e206d696e696d60448201526630b6103332b29760c91b6064820152608401610458565b610c078487611780565b925050509250929050565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114610c5f576040519150601f19603f3d011682016040523d82523d6000602084013e610c64565b606091505b50509050806109225760405162461bcd60e51b815260206004820152600e60248201526d11985a5b1959081d1bc81cd95b9960921b6044820152606401610458565b600260065403610cf85760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610458565b60026006556000805b82811015610eca57600060606000868685818110610d2157610d216117cc565b9050602002810190610d3391906117e2565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050506020810151909150610d78816111e9565b15610e4e576000610d898284611255565b60058190559050610d9a8188611830565b965034871115610dec5760405162461bcd60e51b815260206004820152601e60248201527f43616e27742073656e64206d6f7265207468616e206d73672e76616c756500006044820152606401610458565b6040513090610dfc908590611843565b600060405180830381855af49150503d8060008114610e37576040519150601f19603f3d011682016040523d82523d6000602084013e610e3c565b606091505b5060006005559095509350610ea59050565b6040513090610e5e908490611843565b600060405180830381855af49150503d8060008114610e99576040519150601f19603f3d011682016040523d82523d6000602084013e610e9e565b606091505b5090945092505b83610eb357610eb3836112e0565b505050508080610ec29061185f565b915050610d01565b505060016006555050565b6040516323b872dd60e01b81526001600160a01b03848116600483015283811660248301526044820186905282916000918316906323b872dd906064016020604051808303816000875af1158015610f31573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f559190611732565b905080610f9f5760405162461bcd60e51b81526020600482015260186024820152772330b4b632b2103a37903a3930b739b332b9103a37b5b2b760411b6044820152606401610458565b505050505050565b60405163a9059cbb60e01b81526001600160a01b03838116600483015260248201859052829160009183169063a9059cbb906044016020604051808303816000875af1158015610ffb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061101f9190611732565b9050806110695760405162461bcd60e51b81526020600482015260186024820152772330b4b632b2103a37903a3930b739b332b9103a37b5b2b760411b6044820152606401610458565b5050505050565b604051637921219560e11b81526001600160a01b0384811660048301528381166024830152604482018790526064820186905260a06084830152600060a483015282919082169063f242432a9060c401600060405180830381600087803b1580156110da57600080fd5b505af11580156110ee573d6000803e3d6000fd5b50505050505050505050565b604051635c46a7ef60e11b81526001600160a01b038481166004830152838116602483015260448201869052608060648301526000608483015282919082169063b88d4fde9060a401600060405180830381600087803b15801561115d57600080fd5b505af1158015611171573d6000803e3d6000fd5b505050505050505050565b60006002546001548361118f9190611793565b61042a91906117aa565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006001600160e01b031982166316e4914560e01b148061121a57506001600160e01b031982166341dfeca560e01b145b8061123557506001600160e01b031982166311a2afb760e31b145b8061042a57506001600160e01b03198216633894b03d60e11b1492915050565b60008063e91b6ebb60e01b6001600160e01b031985160161127b575060448201516112d9565b63be20135b60e01b6001600160e01b03198516016112a65761129f60006001610957565b90506112d9565b63be20135b60e01b6001600160e01b03198516016112ca5761129f60006002610957565b6112d660006003610957565b90505b9392505050565b604481511015611305578060405163d935448560e01b81526004016104589190611706565b6004810190508080602001905181019061131f9190611878565b60405162461bcd60e51b81526004016104589190611706565b60006020828403121561134a57600080fd5b81356001600160e01b0319811681146112d957600080fd5b6000806040838503121561137557600080fd5b50508035926020909101359150565b80356001600160a01b038116811461139b57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156113df576113df6113a0565b604052919050565b600067ffffffffffffffff821115611401576114016113a0565b50601f01601f191660200190565b600082601f83011261142057600080fd5b813561143361142e826113e7565b6113b6565b81815284602083860101111561144857600080fd5b816020850160208301376000918101602001919091529392505050565b60008060006060848603121561147a57600080fd5b61148384611384565b925060208401359150604084013567ffffffffffffffff8111156114a657600080fd5b6114b28682870161140f565b9150509250925092565b600080602083850312156114cf57600080fd5b823567ffffffffffffffff808211156114e757600080fd5b818501915085601f8301126114fb57600080fd5b81358181111561150a57600080fd5b8660208260051b850101111561151f57600080fd5b60209290920196919550909350505050565b60006020828403121561154357600080fd5b6112d982611384565b60006020828403121561155e57600080fd5b5035919050565b6000806000806080858703121561157b57600080fd5b61158485611384565b93506020850135925061159960408601611384565b9150606085013567ffffffffffffffff8111156115b557600080fd5b6115c18782880161140f565b91505092959194509250565b600080600080600060a086880312156115e557600080fd5b6115ee86611384565b9450602086013593506040860135925061160a60608701611384565b9150608086013567ffffffffffffffff81111561162657600080fd5b6116328882890161140f565b9150509295509295909350565b6000806040838503121561165257600080fd5b8235915060208301356004811061166857600080fd5b809150509250929050565b60208082526023908201527f5061796d656e74206665652068617320746f206265206269676765722074686160408201526206e20360ec1b606082015260800190565b60005b838110156116d15781810151838201526020016116b9565b50506000910152565b600081518084526116f28160208601602086016116b6565b601f01601f19169290920160200192915050565b6020815260006112d960208301846116da565b60006020828403121561172b57600080fd5b5051919050565b60006020828403121561174457600080fd5b815180151581146112d957600080fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b8181038181111561042a5761042a61176a565b808202811582820484141761042a5761042a61176a565b6000826117c757634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052603260045260246000fd5b6000808335601e198436030181126117f957600080fd5b83018035915067ffffffffffffffff82111561181457600080fd5b60200191503681900382131561182957600080fd5b9250929050565b8082018082111561042a5761042a61176a565b600082516118558184602087016116b6565b9190910192915050565b6000600182016118715761187161176a565b5060010190565b60006020828403121561188a57600080fd5b815167ffffffffffffffff8111156118a157600080fd5b8201601f810184136118b257600080fd5b80516118c061142e826113e7565b8181528560208385010111156118d557600080fd5b6118e68260208301602086016116b6565b9594505050505056fea264697066735822122063106177cce7332c4c2ab71484e684d7d2a2ff6d657441f845a568de40763d0664736f6c63430008110033