creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "src/Disperse.sol": {
        "content": "// SPDX-License-Identifier: None\n// Unvest Contracts (last updated v3.0.0) (Disperse.sol)\npragma solidity ^0.8.24;\n\nimport { Ownable } from \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/// @title Disperse\n/// @notice Gas optimized bulk transfers of ERC20 and ETH that collects any given amount of fee in ETH.\n/// @dev Disclaimer: This is a forked and modified contract from PopPunkLLC/gaslite-core in order to collect fees.\n/// Original contract without fees can be found on:\n/// https://github.com/PopPunkLLC/gaslite-core/blob/d62de3c70fb53d5a315e2e33bfd61587abdd7212/src/GasliteDrop.sol\ncontract Disperse is Ownable {\n    address public collector;\n\n    /// @notice Initializes the contract with a collector address\n    /// @param _collector The address of the fee collector\n    constructor(address _collector) Ownable(msg.sender) {\n        collector = _collector;\n    }\n\n    /// @notice Sets the collector address\n    /// @dev Only the contract owner can call this function\n    /// @param _collector The address of the fee collector\n    function setCollector(address _collector) external onlyOwner {\n        collector = _collector;\n    }\n\n    /// @notice Airdrop ERC20 tokens to a list of addresses\n    /// @param _token The address of the ERC20 contract\n    /// @param _addresses The addresses to airdrop to\n    /// @param _amounts The amounts to airdrop\n    /// @param _totalAmount The total amount to airdrop\n    function airdropERC20(\n        address _token,\n        address[] calldata _addresses,\n        uint256[] calldata _amounts,\n        uint256 _totalAmount\n    )\n        external\n        payable\n    {\n        assembly {\n            // Check that the number of addresses matches the number of amounts\n            if iszero(eq(_amounts.length, _addresses.length)) { revert(0, 0) }\n\n            // transferFrom(address from, address to, uint256 amount)\n            mstore(0x00, hex\"23b872dd\")\n            // from address\n            mstore(0x04, caller())\n            // to address (this contract)\n            mstore(0x24, address())\n            // total amount\n            mstore(0x44, _totalAmount)\n\n            // transfer total amount to this contract\n            if iszero(call(gas(), _token, 0, 0x00, 0x64, 0, 0)) { revert(0, 0) }\n\n            // transfer(address to, uint256 value)\n            mstore(0x00, hex\"a9059cbb\")\n\n            // end of array\n            let end := add(_addresses.offset, shl(5, _addresses.length))\n            // diff = _addresses.offset - _amounts.offset\n            let diff := sub(_addresses.offset, _amounts.offset)\n\n            // Loop through the addresses\n            for { let addressOffset := _addresses.offset } 1 { } {\n                // to address\n                mstore(0x04, calldataload(addressOffset))\n                // amount\n                mstore(0x24, calldataload(sub(addressOffset, diff)))\n                // transfer the tokens\n                if iszero(call(gas(), _token, 0, 0x00, 0x64, 0, 0)) { revert(0, 0) }\n                // increment the address offset\n                addressOffset := add(addressOffset, 0x20)\n                // if addressOffset >= end, break\n                if iszero(lt(addressOffset, end)) { break }\n            }\n        }\n\n        collectFees();\n    }\n\n    /// @notice Airdrop ETH to a list of addresses\n    /// @param _addresses The addresses to airdrop to\n    /// @param _amounts The amounts to airdrop\n    function airdropETH(address[] calldata _addresses, uint256[] calldata _amounts) external payable {\n        assembly {\n            // Check that the number of addresses matches the number of amounts\n            if iszero(eq(_amounts.length, _addresses.length)) { revert(0, 0) }\n\n            // iterator\n            let i := _addresses.offset\n            // end of array\n            let end := add(i, shl(5, _addresses.length))\n            // diff = _addresses.offset - _amounts.offset\n            let diff := sub(_amounts.offset, _addresses.offset)\n\n            // Loop through the addresses\n            for { } 1 { } {\n                // transfer the ETH\n                if iszero(call(gas(), calldataload(i), calldataload(add(i, diff)), 0x00, 0x00, 0x00, 0x00)) {\n                    revert(0x00, 0x00)\n                }\n                // increment the iterator\n                i := add(i, 0x20)\n                // if i >= end, break\n                if eq(end, i) { break }\n            }\n        }\n\n        collectFees();\n    }\n\n    /// @notice Sends any received Ether to the collector address.\n    function collectFees() public {\n        assembly {\n            // Load the collector address from the first storage slot\n            let collectorAddress := sload(collector.slot)\n\n            // Retrieve the contract's balance\n            let contractBalance := selfbalance()\n\n            if gt(contractBalance, 0) {\n                // Call the transfer function to send Ether\n                let success := call(gas(), collectorAddress, contractBalance, 0, 0, 0, 0)\n\n                // Check if the call was successful\n                if eq(success, 0) { revert(0, 0) }\n            }\n        }\n    }\n\n    /// @notice Allows the contract to receive Ether directly with a call to this function.\n    /// @dev Any Ether received is stored in the contract's balance.\n    receive() external payable { }\n}\n"
      },
      "node_modules/@openzeppelin/contracts/access/Ownable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\npragma solidity ^0.8.20;\n\nimport {Context} from \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n    address private _owner;\n\n    /**\n     * @dev The caller account is not authorized to perform an operation.\n     */\n    error OwnableUnauthorizedAccount(address account);\n\n    /**\n     * @dev The owner is not a valid owner account. (eg. `address(0)`)\n     */\n    error OwnableInvalidOwner(address owner);\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n     */\n    constructor(address initialOwner) {\n        if (initialOwner == address(0)) {\n            revert OwnableInvalidOwner(address(0));\n        }\n        _transferOwnership(initialOwner);\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        _checkOwner();\n        _;\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        if (owner() != _msgSender()) {\n            revert OwnableUnauthorizedAccount(_msgSender());\n        }\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby disabling any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        if (newOwner == address(0)) {\n            revert OwnableInvalidOwner(address(0));\n        }\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n}\n"
      },
      "node_modules/@openzeppelin/contracts/utils/Context.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n\n    function _contextSuffixLength() internal view virtual returns (uint256) {\n        return 0;\n    }\n}\n"
      }
    },
    "settings": {
      "remappings": [
        "@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/",
        "@openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/",
        "@prb/test/=node_modules/@prb/test/",
        "forge-std/=node_modules/forge-std/"
      ],
      "optimizer": {
        "enabled": true,
        "runs": 10000
      },
      "metadata": {
        "useLiteralContent": false,
        "bytecodeHash": "none",
        "appendCBOR": true
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "evmVersion": "paris",
      "viaIR": false,
      "libraries": {}
    }
  }}