File size: 24,867 Bytes
f998fcd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
{
  "language": "Solidity",
  "sources": {
    "src/JPGAuctionProxy.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport \"./IAuctionHouse.sol\";\nimport \"./ISplitMain.sol\";\nimport \"solmate/tokens/ERC20.sol\";\nimport \"solmate/utils/SafeTransferLib.sol\";\n\n/// @dev Pass this contract as the curator of an auction\ncontract JPGAuctionProxy {\n    /// @dev Eth mainnet deployment of Zora's auction house\n    IAuctionHouse constant auctionHouse =\n        IAuctionHouse(0xE468cE99444174Bd3bBBEd09209577d25D1ad673);\n\n    address immutable splitter;\n\n    address public owner;\n\n    error NotOwner();\n\n    modifier onlyOwner() {\n        if (msg.sender != owner) {\n            revert NotOwner();\n        }\n        _;\n    }\n\n    /// @dev Splitter is the already deployed split contract for\n    /// the two parties that are splitting the commission\n    constructor(address _splitter) {\n        splitter = _splitter;\n\n        owner = msg.sender;\n    }\n\n    /// @dev Allows the owner to start an auction of which this contract is the curator\n    function setAuctionApproval(uint256 auctionId, bool approved)\n        public\n        onlyOwner\n    {\n        auctionHouse.setAuctionApproval(auctionId, approved);\n    }\n\n    /// @dev Forwards ETH directly to the splitter contract. The Zora contract will unwrap the eth for us and send\n    /// it here. If for whatever reason that failed, we will have WETH in this contract (unfailable), so we add\n    /// an emergency function to deal with that.\n    receive() external payable {\n        SafeTransferLib.safeTransferETH(splitter, address(this).balance);\n    }\n\n    /// @dev If zora's `endAuction` failed to send ETH here (or the splits contract rejected it and we failed to forward it), it winds up\n    /// as WETH in this contract. If this happened, let the owner transfer it at their will. As well as if for whatever reason this contract\n    /// received other ERC20 tokens.\n    function emergencyERC20Withdraw(address token, address recipient)\n        public\n        onlyOwner\n    {\n        SafeTransferLib.safeTransfer(\n            ERC20(token), recipient, ERC20(token).balanceOf(address(this))\n        );\n    }\n}\n"
    },
    "src/IAuctionHouse.sol": {
      "content": "pragma solidity ^0.8.13;\n\ninterface IAuctionHouse {\n    struct Auction {\n        // ID for the ERC721 token\n        uint256 tokenId;\n        // Address for the ERC721 contract\n        address tokenContract;\n        // Whether or not the auction curator has approved the auction to start\n        bool approved;\n        // The current highest bid amount\n        uint256 amount;\n        // The length of time to run the auction for, after the first bid was made\n        uint256 duration;\n        // The time of the first bid\n        uint256 firstBidTime;\n        // The minimum price of the first bid\n        uint256 reservePrice;\n        // The sale percentage to send to the curator\n        uint8 curatorFeePercentage;\n        // The address that should receive the funds once the NFT is sold.\n        address tokenOwner;\n        // The address of the current highest bid\n        address payable bidder;\n        // The address of the auction's curator.\n        // The curator can reject or approve an auction\n        address payable curator;\n        // The address of the ERC-20 currency to run the auction with.\n        // If set to 0x0, the auction will be run in ETH\n        address auctionCurrency;\n    }\n\n    event AuctionCreated(\n        uint256 indexed auctionId,\n        uint256 indexed tokenId,\n        address indexed tokenContract,\n        uint256 duration,\n        uint256 reservePrice,\n        address tokenOwner,\n        address curator,\n        uint8 curatorFeePercentage,\n        address auctionCurrency\n    );\n\n    event AuctionApprovalUpdated(\n        uint256 indexed auctionId,\n        uint256 indexed tokenId,\n        address indexed tokenContract,\n        bool approved\n    );\n\n    event AuctionReservePriceUpdated(\n        uint256 indexed auctionId,\n        uint256 indexed tokenId,\n        address indexed tokenContract,\n        uint256 reservePrice\n    );\n\n    event AuctionBid(\n        uint256 indexed auctionId,\n        uint256 indexed tokenId,\n        address indexed tokenContract,\n        address sender,\n        uint256 value,\n        bool firstBid,\n        bool extended\n    );\n\n    event AuctionDurationExtended(\n        uint256 indexed auctionId,\n        uint256 indexed tokenId,\n        address indexed tokenContract,\n        uint256 duration\n    );\n\n    event AuctionEnded(\n        uint256 indexed auctionId,\n        uint256 indexed tokenId,\n        address indexed tokenContract,\n        address tokenOwner,\n        address curator,\n        address winner,\n        uint256 amount,\n        uint256 curatorFee,\n        address auctionCurrency\n    );\n\n    event AuctionCanceled(\n        uint256 indexed auctionId,\n        uint256 indexed tokenId,\n        address indexed tokenContract,\n        address tokenOwner\n    );\n\n    function createAuction(\n        uint256 tokenId,\n        address tokenContract,\n        uint256 duration,\n        uint256 reservePrice,\n        address payable curator,\n        uint8 curatorFeePercentages,\n        address auctionCurrency\n    )\n        external\n        returns (uint256);\n\n    function setAuctionApproval(uint256 auctionId, bool approved) external;\n\n    function setAuctionReservePrice(uint256 auctionId, uint256 reservePrice)\n        external;\n\n    function createBid(uint256 auctionId, uint256 amount) external payable;\n\n    function endAuction(uint256 auctionId) external;\n\n    function cancelAuction(uint256 auctionId) external;\n\n    function auctions(uint256 auctionId)\n        external\n        view\n        returns (IAuctionHouse.Auction memory);\n}\n"
    },
    "src/ISplitMain.sol": {
      "content": "pragma solidity ^0.8.13;\n\nimport {ERC20} from \"solmate/tokens/ERC20.sol\";\n\n/**\n * @title ISplitMain\n * @author 0xSplits <will@0xSplits.xyz>\n */\ninterface ISplitMain {\n    /**\n     * FUNCTIONS\n     */\n\n    function walletImplementation() external returns (address);\n\n    function createSplit(\n        address[] calldata accounts,\n        uint32[] calldata percentAllocations,\n        uint32 distributorFee,\n        address controller\n    )\n        external\n        returns (address);\n\n    function predictImmutableSplitAddress(\n        address[] calldata accounts,\n        uint32[] calldata percentAllocations,\n        uint32 distributorFee\n    )\n        external\n        view\n        returns (address);\n\n    function updateSplit(\n        address split,\n        address[] calldata accounts,\n        uint32[] calldata percentAllocations,\n        uint32 distributorFee\n    )\n        external;\n\n    function transferControl(address split, address newController) external;\n\n    function cancelControlTransfer(address split) external;\n\n    function acceptControl(address split) external;\n\n    function makeSplitImmutable(address split) external;\n\n    function distributeETH(\n        address split,\n        address[] calldata accounts,\n        uint32[] calldata percentAllocations,\n        uint32 distributorFee,\n        address distributorAddress\n    )\n        external;\n\n    function updateAndDistributeETH(\n        address split,\n        address[] calldata accounts,\n        uint32[] calldata percentAllocations,\n        uint32 distributorFee,\n        address distributorAddress\n    )\n        external;\n\n    function distributeERC20(\n        address split,\n        ERC20 token,\n        address[] calldata accounts,\n        uint32[] calldata percentAllocations,\n        uint32 distributorFee,\n        address distributorAddress\n    )\n        external;\n\n    function updateAndDistributeERC20(\n        address split,\n        ERC20 token,\n        address[] calldata accounts,\n        uint32[] calldata percentAllocations,\n        uint32 distributorFee,\n        address distributorAddress\n    )\n        external;\n\n    function withdraw(\n        address account,\n        uint256 withdrawETH,\n        ERC20[] calldata tokens\n    )\n        external;\n\n    /**\n     * EVENTS\n     */\n\n    /**\n     * @notice emitted after each successful split creation\n     * @param split Address of the created split\n     */\n    event CreateSplit(address indexed split);\n\n    /**\n     * @notice emitted after each successful split update\n     * @param split Address of the updated split\n     */\n    event UpdateSplit(address indexed split);\n\n    /**\n     * @notice emitted after each initiated split control transfer\n     * @param split Address of the split control transfer was initiated for\n     * @param newPotentialController Address of the split's new potential controller\n     */\n    event InitiateControlTransfer(\n        address indexed split, address indexed newPotentialController\n    );\n\n    /**\n     * @notice emitted after each canceled split control transfer\n     * @param split Address of the split control transfer was canceled for\n     */\n    event CancelControlTransfer(address indexed split);\n\n    /**\n     * @notice emitted after each successful split control transfer\n     * @param split Address of the split control was transferred for\n     * @param previousController Address of the split's previous controller\n     * @param newController Address of the split's new controller\n     */\n    event ControlTransfer(\n        address indexed split,\n        address indexed previousController,\n        address indexed newController\n    );\n\n    /**\n     * @notice emitted after each successful ETH balance split\n     * @param split Address of the split that distributed its balance\n     * @param amount Amount of ETH distributed\n     * @param distributorAddress Address to credit distributor fee to\n     */\n    event DistributeETH(\n        address indexed split,\n        uint256 amount,\n        address indexed distributorAddress\n    );\n\n    /**\n     * @notice emitted after each successful ERC20 balance split\n     * @param split Address of the split that distributed its balance\n     * @param token Address of ERC20 distributed\n     * @param amount Amount of ERC20 distributed\n     * @param distributorAddress Address to credit distributor fee to\n     */\n    event DistributeERC20(\n        address indexed split,\n        ERC20 indexed token,\n        uint256 amount,\n        address indexed distributorAddress\n    );\n\n    /**\n     * @notice emitted after each successful withdrawal\n     * @param account Address that funds were withdrawn to\n     * @param ethAmount Amount of ETH withdrawn\n     * @param tokens Addresses of ERC20s withdrawn\n     * @param tokenAmounts Amounts of corresponding ERC20s withdrawn\n     */\n    event Withdrawal(\n        address indexed account,\n        uint256 ethAmount,\n        ERC20[] tokens,\n        uint256[] tokenAmounts\n    );\n}\n"
    },
    "lib/solmate/src/tokens/ERC20.sol": {
      "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\nabstract contract ERC20 {\n    /*//////////////////////////////////////////////////////////////\n                                 EVENTS\n    //////////////////////////////////////////////////////////////*/\n\n    event Transfer(address indexed from, address indexed to, uint256 amount);\n\n    event Approval(address indexed owner, address indexed spender, uint256 amount);\n\n    /*//////////////////////////////////////////////////////////////\n                            METADATA STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    string public name;\n\n    string public symbol;\n\n    uint8 public immutable decimals;\n\n    /*//////////////////////////////////////////////////////////////\n                              ERC20 STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    uint256 public totalSupply;\n\n    mapping(address => uint256) public balanceOf;\n\n    mapping(address => mapping(address => uint256)) public allowance;\n\n    /*//////////////////////////////////////////////////////////////\n                            EIP-2612 STORAGE\n    //////////////////////////////////////////////////////////////*/\n\n    uint256 internal immutable INITIAL_CHAIN_ID;\n\n    bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\n\n    mapping(address => uint256) public nonces;\n\n    /*//////////////////////////////////////////////////////////////\n                               CONSTRUCTOR\n    //////////////////////////////////////////////////////////////*/\n\n    constructor(\n        string memory _name,\n        string memory _symbol,\n        uint8 _decimals\n    ) {\n        name = _name;\n        symbol = _symbol;\n        decimals = _decimals;\n\n        INITIAL_CHAIN_ID = block.chainid;\n        INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                               ERC20 LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    function approve(address spender, uint256 amount) public virtual returns (bool) {\n        allowance[msg.sender][spender] = amount;\n\n        emit Approval(msg.sender, spender, amount);\n\n        return true;\n    }\n\n    function transfer(address to, uint256 amount) public virtual returns (bool) {\n        balanceOf[msg.sender] -= amount;\n\n        // Cannot overflow because the sum of all user\n        // balances can't exceed the max uint256 value.\n        unchecked {\n            balanceOf[to] += amount;\n        }\n\n        emit Transfer(msg.sender, to, amount);\n\n        return true;\n    }\n\n    function transferFrom(\n        address from,\n        address to,\n        uint256 amount\n    ) public virtual returns (bool) {\n        uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\n\n        if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\n\n        balanceOf[from] -= amount;\n\n        // Cannot overflow because the sum of all user\n        // balances can't exceed the max uint256 value.\n        unchecked {\n            balanceOf[to] += amount;\n        }\n\n        emit Transfer(from, to, amount);\n\n        return true;\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                             EIP-2612 LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    function permit(\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) public virtual {\n        require(deadline >= block.timestamp, \"PERMIT_DEADLINE_EXPIRED\");\n\n        // Unchecked because the only math done is incrementing\n        // the owner's nonce which cannot realistically overflow.\n        unchecked {\n            address recoveredAddress = ecrecover(\n                keccak256(\n                    abi.encodePacked(\n                        \"\\x19\\x01\",\n                        DOMAIN_SEPARATOR(),\n                        keccak256(\n                            abi.encode(\n                                keccak256(\n                                    \"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\"\n                                ),\n                                owner,\n                                spender,\n                                value,\n                                nonces[owner]++,\n                                deadline\n                            )\n                        )\n                    )\n                ),\n                v,\n                r,\n                s\n            );\n\n            require(recoveredAddress != address(0) && recoveredAddress == owner, \"INVALID_SIGNER\");\n\n            allowance[recoveredAddress][spender] = value;\n        }\n\n        emit Approval(owner, spender, value);\n    }\n\n    function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\n        return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\n    }\n\n    function computeDomainSeparator() internal view virtual returns (bytes32) {\n        return\n            keccak256(\n                abi.encode(\n                    keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"),\n                    keccak256(bytes(name)),\n                    keccak256(\"1\"),\n                    block.chainid,\n                    address(this)\n                )\n            );\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                        INTERNAL MINT/BURN LOGIC\n    //////////////////////////////////////////////////////////////*/\n\n    function _mint(address to, uint256 amount) internal virtual {\n        totalSupply += amount;\n\n        // Cannot overflow because the sum of all user\n        // balances can't exceed the max uint256 value.\n        unchecked {\n            balanceOf[to] += amount;\n        }\n\n        emit Transfer(address(0), to, amount);\n    }\n\n    function _burn(address from, uint256 amount) internal virtual {\n        balanceOf[from] -= amount;\n\n        // Cannot underflow because a user's balance\n        // will never be larger than the total supply.\n        unchecked {\n            totalSupply -= amount;\n        }\n\n        emit Transfer(from, address(0), amount);\n    }\n}\n"
    },
    "lib/solmate/src/utils/SafeTransferLib.sol": {
      "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport {ERC20} from \"../tokens/ERC20.sol\";\n\n/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)\n/// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.\n/// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller.\nlibrary SafeTransferLib {\n    /*//////////////////////////////////////////////////////////////\n                             ETH OPERATIONS\n    //////////////////////////////////////////////////////////////*/\n\n    function safeTransferETH(address to, uint256 amount) internal {\n        bool success;\n\n        assembly {\n            // Transfer the ETH and store if it succeeded or not.\n            success := call(gas(), to, amount, 0, 0, 0, 0)\n        }\n\n        require(success, \"ETH_TRANSFER_FAILED\");\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                            ERC20 OPERATIONS\n    //////////////////////////////////////////////////////////////*/\n\n    function safeTransferFrom(\n        ERC20 token,\n        address from,\n        address to,\n        uint256 amount\n    ) internal {\n        bool success;\n\n        assembly {\n            // Get a pointer to some free memory.\n            let freeMemoryPointer := mload(0x40)\n\n            // Write the abi-encoded calldata into memory, beginning with the function selector.\n            mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000)\n            mstore(add(freeMemoryPointer, 4), from) // Append the \"from\" argument.\n            mstore(add(freeMemoryPointer, 36), to) // Append the \"to\" argument.\n            mstore(add(freeMemoryPointer, 68), amount) // Append the \"amount\" argument.\n\n            success := and(\n                // Set success to whether the call reverted, if not we check it either\n                // returned exactly 1 (can't just be non-zero data), or had no return data.\n                or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n                // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3.\n                // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n                // Counterintuitively, this call must be positioned second to the or() call in the\n                // surrounding and() call or else returndatasize() will be zero during the computation.\n                call(gas(), token, 0, freeMemoryPointer, 100, 0, 32)\n            )\n        }\n\n        require(success, \"TRANSFER_FROM_FAILED\");\n    }\n\n    function safeTransfer(\n        ERC20 token,\n        address to,\n        uint256 amount\n    ) internal {\n        bool success;\n\n        assembly {\n            // Get a pointer to some free memory.\n            let freeMemoryPointer := mload(0x40)\n\n            // Write the abi-encoded calldata into memory, beginning with the function selector.\n            mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)\n            mstore(add(freeMemoryPointer, 4), to) // Append the \"to\" argument.\n            mstore(add(freeMemoryPointer, 36), amount) // Append the \"amount\" argument.\n\n            success := and(\n                // Set success to whether the call reverted, if not we check it either\n                // returned exactly 1 (can't just be non-zero data), or had no return data.\n                or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n                // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\n                // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n                // Counterintuitively, this call must be positioned second to the or() call in the\n                // surrounding and() call or else returndatasize() will be zero during the computation.\n                call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\n            )\n        }\n\n        require(success, \"TRANSFER_FAILED\");\n    }\n\n    function safeApprove(\n        ERC20 token,\n        address to,\n        uint256 amount\n    ) internal {\n        bool success;\n\n        assembly {\n            // Get a pointer to some free memory.\n            let freeMemoryPointer := mload(0x40)\n\n            // Write the abi-encoded calldata into memory, beginning with the function selector.\n            mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000)\n            mstore(add(freeMemoryPointer, 4), to) // Append the \"to\" argument.\n            mstore(add(freeMemoryPointer, 36), amount) // Append the \"amount\" argument.\n\n            success := and(\n                // Set success to whether the call reverted, if not we check it either\n                // returned exactly 1 (can't just be non-zero data), or had no return data.\n                or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n                // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\n                // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n                // Counterintuitively, this call must be positioned second to the or() call in the\n                // surrounding and() call or else returndatasize() will be zero during the computation.\n                call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\n            )\n        }\n\n        require(success, \"APPROVE_FAILED\");\n    }\n}\n"
    }
  },
  "settings": {
    "remappings": [
      "ds-test/=lib/solmate/lib/ds-test/src/",
      "forge-std/=lib/forge-std/src/",
      "solmate/=lib/solmate/src/"
    ],
    "optimizer": {
      "enabled": true,
      "runs": 200
    },
    "metadata": {
      "bytecodeHash": "ipfs"
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "evmVersion": "london",
    "libraries": {}
  }
}