MATIC Price: $0.725663 (+0.74%)
Gas: 64 GWei
 

Overview

MATIC Balance

Polygon PoS Chain LogoPolygon PoS Chain LogoPolygon PoS Chain Logo0 MATIC

MATIC Value

$0.00

Sponsored

Transaction Hash
Method
Block
From
To
Value
0x60806040392879722023-02-14 16:11:20464 days ago1676391080IN
 Create: PartyInit
0 MATIC0.37474033498.48731669

Parent Transaction Hash Block From To Value
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
PartyInit

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 2000 runs

Other Settings:
default evmVersion
File 1 of 11 : PartyInit.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";

import {LibERC20} from "../libraries/LibERC20.sol";
import {AppStorage, PartyInfo} from "../libraries/LibAppStorage.sol";
import {LibDiamond} from "../libraries/LibDiamond.sol";

import {IDiamondLoupe} from "../interfaces/IDiamondLoupe.sol";
import {IDiamondCut} from "../interfaces/IDiamondCut.sol";
import {IERC165} from "../interfaces/IERC165.sol";
import {IERC20} from "../interfaces/IERC20.sol";

/**
 * @notice A struct containing the initialization arguments structs
 * @member partyCreator The user that created the Party
 * @member partyInfo PartyInfo struct
 * @member tokenSymbol Party ERC-20 symbol metadata
 * @member initialDeposit Initial deposit in denomination asset made by the party creator
 * @member platformFeeCollector Fee collector address
 * @member platformFee Fee amount in bps
 * @member platformSentinel Sentinel address
 */
struct InitArgs {
    address partyCreator;
    PartyInfo partyInfo;
    string tokenSymbol;
    uint256 initialDeposit;
    address denominationAsset;
    address platformFeeCollector;
    uint256 platformFee;
    address platformSentinel;
}

contract PartyInit {
    AppStorage internal s;

    /**
     * @notice Emitted exactly once by a party when #initialize is first called
     * @param partyCreator Address of the user that created the party
     * @param partyName Name of the party
     * @param isPublic Visibility of the party
     * @param dAsset Address of the denomination asset for the party
     * @param minDeposit Minimum deposit of the party
     * @param maxDeposit Maximum deposit of the party
     * @param mintedPT Minted party tokens for creating the party
     * @param bio Bio of the party
     * @param img Img url of the party
     * @param model Model of party created
     * @param purpose Purpose of party created
     */
    event PartyCreated(
        address partyCreator,
        string partyName,
        bool isPublic,
        address dAsset,
        uint256 minDeposit,
        uint256 maxDeposit,
        uint256 mintedPT,
        string bio,
        string img,
        string model,
        string purpose
    );

    /**
     * @notice Initialization method for created Parties
     * @dev Must be called by the PartyFactory during the Party creation
     * @param _args Initialization arguments struct
     */
    function init(InitArgs memory _args) external {
        // Main platform addresses
        s.platformFee = _args.platformFee;
        s.platformFeeCollector = _args.platformFeeCollector;
        s.platformSentinel = _args.platformSentinel;
        s.platformFactory = msg.sender;

        // Party data
        s.denominationAsset = _args.denominationAsset;
        s.partyInfo = _args.partyInfo;
        s.tokens.push(_args.denominationAsset);
        s.managers[_args.partyCreator] = true;
        s.members[_args.partyCreator] = true;
        s.creator = _args.partyCreator;

        // Set PartyToken Metadata
        s.name = _args.partyInfo.name;
        s.symbol = _args.tokenSymbol;

        // Mint the initial PartyTokens to the deployer
        uint256 mintedPT = _args.initialDeposit *
            10 ** (18 - IERC20Metadata(_args.denominationAsset).decimals());
        LibERC20._mint(_args.partyCreator, mintedPT);

        // Adding ERC165 data
        LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();
        ds.supportedInterfaces[type(IERC165).interfaceId] = true;
        ds.supportedInterfaces[type(IDiamondCut).interfaceId] = true;
        ds.supportedInterfaces[type(IDiamondLoupe).interfaceId] = true;
        ds.supportedInterfaces[type(IERC20).interfaceId] = true;

        // Emit PartyCreated event
        emit PartyCreated(
            _args.partyCreator,
            _args.partyInfo.name,
            _args.partyInfo.isPublic,
            _args.denominationAsset,
            _args.partyInfo.minDeposit,
            _args.partyInfo.maxDeposit,
            mintedPT,
            _args.partyInfo.bio,
            _args.partyInfo.img,
            _args.partyInfo.model,
            _args.partyInfo.purpose
        );
    }
}

File 2 of 11 : LibERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import {LibAppStorage, AppStorage} from "./LibAppStorage.sol";

library LibERC20 {
    event Transfer(address indexed from, address indexed to, uint256 amount);

    /**
     * @notice Mint tokens for a given account
     * @param account Address recipient
     * @param amount Amount of tokens to be minted
     */
    function _mint(address account, uint256 amount) internal {
        require(account != address(0), "ERC20: mint to the zero address");

        AppStorage storage s = LibAppStorage.diamondStorage();
        s.totalSupply += amount;
        s.balances[account] += amount;

        emit Transfer(address(0), account, amount);
    }

    /**
     * @notice Burn tokens held by given account
     * @param account Address of burned tokens
     * @param amount Amount of tokens to be burnt
     */
    function _burn(address account, uint256 amount) internal {
        require(account != address(0), "ERC20: burn from the zero address");

        AppStorage storage s = LibAppStorage.diamondStorage();
        uint256 balance = s.balances[account];
        require(balance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            s.balances[account] = balance - amount;
        }
        s.totalSupply -= amount;

        emit Transfer(account, address(0), amount);
    }
}

File 2 of 11 : IDiamondLoupe.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

/******************************************************************************\
* Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen)
* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535
/******************************************************************************/

// A loupe is a small magnifying glass used to look at diamonds.
// These functions look at diamonds
interface IDiamondLoupe {
    /// These functions are expected to be called frequently
    /// by tools.

    struct Facet {
        address facetAddress;
        bytes4[] functionSelectors;
    }

    /// @notice Gets all facet addresses and their four byte function selectors.
    /// @return facets_ Facet
    function facets() external view returns (Facet[] memory facets_);

    /// @notice Gets all the function selectors supported by a specific facet.
    /// @param _facet The facet address.
    /// @return facetFunctionSelectors_
    function facetFunctionSelectors(address _facet)
        external
        view
        returns (bytes4[] memory facetFunctionSelectors_);

    /// @notice Get all the facet addresses used by a diamond.
    /// @return facetAddresses_
    function facetAddresses()
        external
        view
        returns (address[] memory facetAddresses_);

    /// @notice Gets the facet that supports the given selector.
    /// @dev If facet is not found return address(0).
    /// @param _functionSelector The function selector.
    /// @return facetAddress_ The facet address.
    function facetAddress(bytes4 _functionSelector)
        external
        view
        returns (address facetAddress_);
}

File 2 of 11 : IERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

interface IERC20 {
    /**
     * @notice Queries the Party ERC-20 token name
     * @return Token name metadata
     */
    function name() external view returns (string memory);

    /**
     * @notice Queries the Party ERC-20 token symbol
     * @return Token symbol metadata
     */
    function symbol() external view returns (string memory);

    /**
     * @notice Queries the Party ERC-20 token decimals
     * @return Token decimals metadata
     */
    function decimals() external pure returns (uint8);

    /**
     * @notice Queries the Party ERC-20 total minted supply
     * @return Token total supply
     */
    function totalSupply() external view returns (uint256);

    /**
     * @notice Queries the Party ERC-20 balance of a given account
     * @param account Address
     * @return Token balance of a given ccount
     */
    function balanceOf(address account) external view returns (uint256);
}

File 2 of 11 : LibAppStorage.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import {LibMeta} from "./LibMeta.sol";

/**
 * @notice A struct containing the Party info tracked in storage.
 * @param name Name of the Party
 * @param bio Description of the Party
 * @param img Image URL of the Party (path to storage without protocol/domain)
 * @param model Model of the Party: "Democracy", "Monarchy", "WeightedDemocracy", "Republic"
 * @param purpose Purpose of the Party: "Trading", "YieldFarming", "LiquidityProviding", "NFT"
 * @param isPublic Visibility of the Party. (Private parties requires an accepted join request)
 * @param minDeposit Minimum deposit allowed in denomination asset
 * @param maxDeposit Maximum deposit allowed in denomination asset
 */
struct PartyInfo {
    string name;
    string bio;
    string img;
    string model;
    string purpose;
    bool isPublic;
    uint256 minDeposit;
    uint256 maxDeposit;
}

/**
 * @notice A struct containing the Announcement info tracked in storage.
 * @param title Title of the Announcement
 * @param bio Content of the Announcement
 * @param img Any external URL to include in the Announcement
 * @param model Model of the Party: "Democracy", "Monarchy", "WeightedDemocracy", "Republic"
 * @param created Block timestamp date of the Announcement creation
 * @param updated Block timestamp date of any Announcement edition
 */
struct Announcement {
    string title;
    string content;
    string url;
    string img;
    uint256 created;
    uint256 updated;
}

/**
 * @notice A struct containing the TokenGate info tracked in storage.
 * @param token Address of the asset
 * @param amount Required amount to hold
 */
struct TokenGate {
    address token;
    uint256 amount;
}

struct AppStorage {
    //
    // Party vault token
    //
    string name;
    string symbol;
    uint256 totalSupply;
    mapping(address => uint256) balances;
    mapping(address => mapping(address => uint256)) allowances;
    //
    // Denomination token asset for deposit/withdraws
    //
    address denominationAsset;
    //
    // Party info
    //
    PartyInfo partyInfo;
    bool closed; // Party life status
    //
    // Party access
    //
    mapping(address => bool) managers; // Maping to get if address is a manager
    mapping(address => bool) members; // Maping to get if address is a member
    //
    // Party ERC-20 holdings
    //
    address[] tokens; // Array of current party tokens holdings
    //
    // Party Announcements
    //
    Announcement[] announcements;
    //
    // Party Join Requests
    //
    address[] joinRequests; // Array of users that requested to join the party
    mapping(address => bool) acceptedRequests; // Mapping of requests accepted by a manager
    //
    // PLATFORM
    //
    uint256 platformFee; // Platform fee (in bps, 50 bps -> 0.5%)
    address platformFeeCollector; // Platform fee collector
    address platformSentinel; // Platform sentinel
    address platformFactory; // Platform factory
    //
    // Extended Party access
    //
    address creator; // Creator of the Party
    //
    // Token gating
    //
    TokenGate[] tokenGates;
}

library LibAppStorage {
    function diamondStorage() internal pure returns (AppStorage storage ds) {
        assembly {
            ds.slot := 0
        }
    }
}

contract Modifiers {
    AppStorage internal s;

    modifier onlyCreator() {
        require(s.creator == LibMeta.msgSender(), "Only Party Creator allowed");
        _;
    }

    modifier onlyManager() {
        require(s.managers[LibMeta.msgSender()], "Only Party Managers allowed");
        _;
    }

    modifier onlyMember() {
        require(s.members[LibMeta.msgSender()], "Only Party Members allowed");
        _;
    }

    modifier notMember() {
        require(
            !s.members[LibMeta.msgSender()],
            "Only non Party Members allowed"
        );
        _;
    }

    modifier onlyFactory() {
        require(
            LibMeta.msgSender() == s.platformFactory,
            "Only Factory allowed"
        );
        _;
    }

    modifier isAlive() {
        require(!s.closed, "Party is closed");
        _;
    }
}

File 2 of 11 : LibDiamond.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

/******************************************************************************\
* Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen)
* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535
/******************************************************************************/
import {IDiamondCut} from "../interfaces/IDiamondCut.sol";

library LibDiamond {
    bytes32 constant DIAMOND_STORAGE_POSITION =
        keccak256("diamond.standard.diamond.storage");

    struct DiamondStorage {
        // maps function selectors to the facets that execute the functions.
        // and maps the selectors to their position in the selectorSlots array.
        // func selector => address facet, selector position
        mapping(bytes4 => bytes32) facets;
        // array of slots of function selectors.
        // each slot holds 8 function selectors.
        mapping(uint256 => bytes32) selectorSlots;
        // The number of function selectors in selectorSlots
        uint16 selectorCount;
        // Used to query if a contract implements an interface.
        // Used to implement ERC-165.
        mapping(bytes4 => bool) supportedInterfaces;
        // owner of the contract
        address contractOwner;
    }

    function diamondStorage()
        internal
        pure
        returns (DiamondStorage storage ds)
    {
        bytes32 position = DIAMOND_STORAGE_POSITION;
        assembly {
            ds.slot := position
        }
    }

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

    function setContractOwner(address _newOwner) internal {
        DiamondStorage storage ds = diamondStorage();
        address previousOwner = ds.contractOwner;
        ds.contractOwner = _newOwner;
        emit OwnershipTransferred(previousOwner, _newOwner);
    }

    function contractOwner() internal view returns (address contractOwner_) {
        contractOwner_ = diamondStorage().contractOwner;
    }

    function enforceIsContractOwner() internal view {
        require(
            msg.sender == diamondStorage().contractOwner,
            "LibDiamond: Must be contract owner"
        );
    }

    event DiamondCut(
        IDiamondCut.FacetCut[] _diamondCut,
        address _init,
        bytes _calldata
    );

    bytes32 constant CLEAR_ADDRESS_MASK =
        bytes32(uint256(0xffffffffffffffffffffffff));
    bytes32 constant CLEAR_SELECTOR_MASK = bytes32(uint256(0xffffffff << 224));

    // Internal function version of diamondCut
    // This code is almost the same as the external diamondCut,
    // except it is using 'Facet[] memory _diamondCut' instead of
    // 'Facet[] calldata _diamondCut'.
    // The code is duplicated to prevent copying calldata to memory which
    // causes an error for a two dimensional array.
    function diamondCut(
        IDiamondCut.FacetCut[] memory _diamondCut,
        address _init,
        bytes memory _calldata
    ) internal {
        DiamondStorage storage ds = diamondStorage();
        uint256 originalSelectorCount = ds.selectorCount;
        uint256 selectorCount = originalSelectorCount;
        bytes32 selectorSlot;
        // Check if last selector slot is not full
        // "selectorCount & 7" is a gas efficient modulo by eight "selectorCount % 8"
        if (selectorCount & 7 > 0) {
            // get last selectorSlot
            // "selectorSlot >> 3" is a gas efficient division by 8 "selectorSlot / 8"
            selectorSlot = ds.selectorSlots[selectorCount >> 3];
        }
        // loop through diamond cut
        for (
            uint256 facetIndex;
            facetIndex < _diamondCut.length;
            facetIndex++
        ) {
            (selectorCount, selectorSlot) = addReplaceRemoveFacetSelectors(
                selectorCount,
                selectorSlot,
                _diamondCut[facetIndex].facetAddress,
                _diamondCut[facetIndex].action,
                _diamondCut[facetIndex].functionSelectors
            );
        }
        if (selectorCount != originalSelectorCount) {
            ds.selectorCount = uint16(selectorCount);
        }
        // If last selector slot is not full
        // "selectorCount & 7" is a gas efficient modulo by eight "selectorCount % 8"
        if (selectorCount & 7 > 0) {
            // "selectorSlot >> 3" is a gas efficient division by 8 "selectorSlot / 8"
            ds.selectorSlots[selectorCount >> 3] = selectorSlot;
        }
        emit DiamondCut(_diamondCut, _init, _calldata);
        initializeDiamondCut(_init, _calldata);
    }

    function addReplaceRemoveFacetSelectors(
        uint256 _selectorCount,
        bytes32 _selectorSlot,
        address _newFacetAddress,
        IDiamondCut.FacetCutAction _action,
        bytes4[] memory _selectors
    ) internal returns (uint256, bytes32) {
        DiamondStorage storage ds = diamondStorage();
        require(
            _selectors.length > 0,
            "LibDiamondCut: No selectors in facet to cut"
        );
        if (_action == IDiamondCut.FacetCutAction.Add) {
            enforceHasContractCode(
                _newFacetAddress,
                "LibDiamondCut: Add facet has no code"
            );
            for (
                uint256 selectorIndex;
                selectorIndex < _selectors.length;
                selectorIndex++
            ) {
                bytes4 selector = _selectors[selectorIndex];
                bytes32 oldFacet = ds.facets[selector];
                require(
                    address(bytes20(oldFacet)) == address(0),
                    "LibDiamondCut: Can't add function that already exists"
                );
                // add facet for selector
                ds.facets[selector] =
                    bytes20(_newFacetAddress) |
                    bytes32(_selectorCount);
                // "_selectorCount & 7" is a gas efficient modulo by eight "_selectorCount % 8"
                // " << 5 is the same as multiplying by 32 ( * 32)
                uint256 selectorInSlotPosition = (_selectorCount & 7) << 5;
                // clear selector position in slot and add selector
                _selectorSlot =
                    (_selectorSlot &
                        ~(CLEAR_SELECTOR_MASK >> selectorInSlotPosition)) |
                    (bytes32(selector) >> selectorInSlotPosition);
                // if slot is full then write it to storage
                if (selectorInSlotPosition == 224) {
                    // "_selectorSlot >> 3" is a gas efficient division by 8 "_selectorSlot / 8"
                    ds.selectorSlots[_selectorCount >> 3] = _selectorSlot;
                    _selectorSlot = 0;
                }
                _selectorCount++;
            }
        } else if (_action == IDiamondCut.FacetCutAction.Replace) {
            enforceHasContractCode(
                _newFacetAddress,
                "LibDiamondCut: Replace facet has no code"
            );
            for (
                uint256 selectorIndex;
                selectorIndex < _selectors.length;
                selectorIndex++
            ) {
                bytes4 selector = _selectors[selectorIndex];
                bytes32 oldFacet = ds.facets[selector];
                address oldFacetAddress = address(bytes20(oldFacet));
                // only useful if immutable functions exist
                require(
                    oldFacetAddress != address(this),
                    "LibDiamondCut: Can't replace immutable function"
                );
                require(
                    oldFacetAddress != _newFacetAddress,
                    "LibDiamondCut: Can't replace function with same function"
                );
                require(
                    oldFacetAddress != address(0),
                    "LibDiamondCut: Can't replace function that doesn't exist"
                );
                // replace old facet address
                ds.facets[selector] =
                    (oldFacet & CLEAR_ADDRESS_MASK) |
                    bytes20(_newFacetAddress);
            }
        } else if (_action == IDiamondCut.FacetCutAction.Remove) {
            require(
                _newFacetAddress == address(0),
                "LibDiamondCut: Remove facet address must be address(0)"
            );
            // "_selectorCount >> 3" is a gas efficient division by 8 "_selectorCount / 8"
            uint256 selectorSlotCount = _selectorCount >> 3;
            // "_selectorCount & 7" is a gas efficient modulo by eight "_selectorCount % 8"
            uint256 selectorInSlotIndex = _selectorCount & 7;
            for (
                uint256 selectorIndex;
                selectorIndex < _selectors.length;
                selectorIndex++
            ) {
                if (_selectorSlot == 0) {
                    // get last selectorSlot
                    selectorSlotCount--;
                    _selectorSlot = ds.selectorSlots[selectorSlotCount];
                    selectorInSlotIndex = 7;
                } else {
                    selectorInSlotIndex--;
                }
                bytes4 lastSelector;
                uint256 oldSelectorsSlotCount;
                uint256 oldSelectorInSlotPosition;
                // adding a block here prevents stack too deep error
                {
                    bytes4 selector = _selectors[selectorIndex];
                    bytes32 oldFacet = ds.facets[selector];
                    require(
                        address(bytes20(oldFacet)) != address(0),
                        "LibDiamondCut: Can't remove function that doesn't exist"
                    );
                    // only useful if immutable functions exist
                    require(
                        address(bytes20(oldFacet)) != address(this),
                        "LibDiamondCut: Can't remove immutable function"
                    );
                    // replace selector with last selector in ds.facets
                    // gets the last selector
                    // " << 5 is the same as multiplying by 32 ( * 32)
                    lastSelector = bytes4(
                        _selectorSlot << (selectorInSlotIndex << 5)
                    );
                    if (lastSelector != selector) {
                        // update last selector slot position info
                        ds.facets[lastSelector] =
                            (oldFacet & CLEAR_ADDRESS_MASK) |
                            bytes20(ds.facets[lastSelector]);
                    }
                    delete ds.facets[selector];
                    uint256 oldSelectorCount = uint16(uint256(oldFacet));
                    // "oldSelectorCount >> 3" is a gas efficient division by 8 "oldSelectorCount / 8"
                    oldSelectorsSlotCount = oldSelectorCount >> 3;
                    // "oldSelectorCount & 7" is a gas efficient modulo by eight "oldSelectorCount % 8"
                    // " << 5 is the same as multiplying by 32 ( * 32)
                    oldSelectorInSlotPosition = (oldSelectorCount & 7) << 5;
                }
                if (oldSelectorsSlotCount != selectorSlotCount) {
                    bytes32 oldSelectorSlot = ds.selectorSlots[
                        oldSelectorsSlotCount
                    ];
                    // clears the selector we are deleting and puts the last selector in its place.
                    oldSelectorSlot =
                        (oldSelectorSlot &
                            ~(CLEAR_SELECTOR_MASK >>
                                oldSelectorInSlotPosition)) |
                        (bytes32(lastSelector) >> oldSelectorInSlotPosition);
                    // update storage with the modified slot
                    ds.selectorSlots[oldSelectorsSlotCount] = oldSelectorSlot;
                } else {
                    // clears the selector we are deleting and puts the last selector in its place.
                    _selectorSlot =
                        (_selectorSlot &
                            ~(CLEAR_SELECTOR_MASK >>
                                oldSelectorInSlotPosition)) |
                        (bytes32(lastSelector) >> oldSelectorInSlotPosition);
                }
                if (selectorInSlotIndex == 0) {
                    delete ds.selectorSlots[selectorSlotCount];
                    _selectorSlot = 0;
                }
            }
            _selectorCount = selectorSlotCount * 8 + selectorInSlotIndex;
        } else {
            revert("LibDiamondCut: Incorrect FacetCutAction");
        }
        return (_selectorCount, _selectorSlot);
    }

    function initializeDiamondCut(address _init, bytes memory _calldata)
        internal
    {
        if (_init == address(0)) {
            require(
                _calldata.length == 0,
                "LibDiamondCut: _init is address(0) but_calldata is not empty"
            );
        } else {
            require(
                _calldata.length > 0,
                "LibDiamondCut: _calldata is empty but _init is not address(0)"
            );
            if (_init != address(this)) {
                enforceHasContractCode(
                    _init,
                    "LibDiamondCut: _init address has no code"
                );
            }
            (bool success, bytes memory error) = _init.delegatecall(_calldata);
            if (!success) {
                if (error.length > 0) {
                    // bubble up the error
                    revert(string(error));
                } else {
                    revert("LibDiamondCut: _init function reverted");
                }
            }
        }
    }

    function enforceHasContractCode(
        address _contract,
        string memory _errorMessage
    ) internal view {
        uint256 contractSize;
        assembly {
            contractSize := extcodesize(_contract)
        }
        require(contractSize > 0, _errorMessage);
    }
}

File 2 of 11 : IDiamondCut.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

/******************************************************************************\
* Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen)
* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535
/******************************************************************************/

interface IDiamondCut {
    enum FacetCutAction {
        Add,
        Replace,
        Remove
    }
    // Add=0, Replace=1, Remove=2

    struct FacetCut {
        address facetAddress;
        FacetCutAction action;
        bytes4[] functionSelectors;
    }

    /// @notice Add/replace/remove any number of functions and optionally execute
    ///         a function with delegatecall
    /// @param _diamondCut Contains the facet addresses and function selectors
    /// @param _init The address of the contract or facet to execute _calldata
    /// @param _calldata A function call, including function selector and arguments
    ///                  _calldata is executed with delegatecall on _init
    function diamondCut(
        FacetCut[] calldata _diamondCut,
        address _init,
        bytes calldata _calldata
    ) external;

    event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata);
}

File 2 of 11 : IERC165.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

interface IERC165 {
    /// @notice Query if a contract implements an interface
    /// @param interfaceId The interface identifier, as specified in ERC-165
    /// @dev Interface identification is specified in ERC-165. This function
    ///  uses less than 30,000 gas.
    /// @return `true` if the contract implements `interfaceID` and
    ///  `interfaceID` is not 0xffffffff, `false` otherwise
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 2 of 11 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

File 2 of 11 : LibMeta.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

library LibMeta {
    function getChainID() internal view returns (uint256 id) {
        assembly {
            id := chainid()
        }
    }

    function msgSender() internal view returns (address sender_) {
        if (msg.sender == address(this)) {
            bytes memory array = msg.data;
            uint256 index = msg.data.length;
            assembly {
                // Load the 32 bytes word from memory with the address on the lower 20 bytes, and mask those.
                sender_ := and(
                    mload(add(array, index)),
                    0xffffffffffffffffffffffffffffffffffffffff
                )
            }
        } else {
            sender_ = msg.sender;
        }
    }
}

File 2 of 11 : 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);
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 2000
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "metadata": {
    "useLiteralContent": true
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"partyCreator","type":"address"},{"indexed":false,"internalType":"string","name":"partyName","type":"string"},{"indexed":false,"internalType":"bool","name":"isPublic","type":"bool"},{"indexed":false,"internalType":"address","name":"dAsset","type":"address"},{"indexed":false,"internalType":"uint256","name":"minDeposit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxDeposit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"mintedPT","type":"uint256"},{"indexed":false,"internalType":"string","name":"bio","type":"string"},{"indexed":false,"internalType":"string","name":"img","type":"string"},{"indexed":false,"internalType":"string","name":"model","type":"string"},{"indexed":false,"internalType":"string","name":"purpose","type":"string"}],"name":"PartyCreated","type":"event"},{"inputs":[{"components":[{"internalType":"address","name":"partyCreator","type":"address"},{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"bio","type":"string"},{"internalType":"string","name":"img","type":"string"},{"internalType":"string","name":"model","type":"string"},{"internalType":"string","name":"purpose","type":"string"},{"internalType":"bool","name":"isPublic","type":"bool"},{"internalType":"uint256","name":"minDeposit","type":"uint256"},{"internalType":"uint256","name":"maxDeposit","type":"uint256"}],"internalType":"struct PartyInfo","name":"partyInfo","type":"tuple"},{"internalType":"string","name":"tokenSymbol","type":"string"},{"internalType":"uint256","name":"initialDeposit","type":"uint256"},{"internalType":"address","name":"denominationAsset","type":"address"},{"internalType":"address","name":"platformFeeCollector","type":"address"},{"internalType":"uint256","name":"platformFee","type":"uint256"},{"internalType":"address","name":"platformSentinel","type":"address"}],"internalType":"struct InitArgs","name":"_args","type":"tuple"}],"name":"init","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b50610ca7806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80639981e6ba14610030575b600080fd5b61004361003e3660046107b1565b610045565b005b60c081015160155560a08101516016805473ffffffffffffffffffffffffffffffffffffffff9283167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915560e083015160178054918416918316919091179055601880548216331790556080830151600580549190931691161790556020810151805160069081906100dd9082610924565b50602082015160018201906100f29082610924565b50604082015160028201906101079082610924565b506060820151600382019061011c9082610924565b50608082015160048201906101319082610924565b5060a082015160058201805491151560ff1992831617905560c0830151600683015560e0909201516007909101556080820151601180546001818101835560009283527f31ecc21a745e3968a04e9570e4425bc18fa8019c68028196b546d1669c200c68909101805473ffffffffffffffffffffffffffffffffffffffff9485167fffffffffffffffffffffffff000000000000000000000000000000000000000091821617909155855184168352600f602090815260408085208054881685179055875186168552601082528420805490961690921790945584516019805491909416941693909317909155908201515161022d9082610924565b5060408101516001906102409082610924565b506000816080015173ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610292573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102b691906109e4565b6102c1906012610a24565b6102cc90600a610b27565b82606001516102db9190610b36565b90506102eb82600001518261047c565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131f60209081527f699d9daa71b280d05a152715774afa0a81a312594b2d731d6b0b2552b7d6f69f8054600160ff1991821681179092557ff97e938d8af42f52387bb74b8b526fda8f184cc2aa534340a8d75a88fbecc77580548216831790557f65d510a5d8f7ef134ec444f7f34ee808c8eeb5177cdfd16be0c40fe1ab43369580548216831790557fcaaf2fc9000000000000000000000000000000000000000000000000000000006000527fc948b980938d663840437c45b013ee10a15dfcd888579f4279a30d47920ad0ca80549091169091179055825183820151805160a082015160808088015160c085015160e0860151978601516040808801516060890151959098015190517fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c9a7f6961163ce2d23c05c84cca730988be314ddc2c745c6ff4cca1cd7a5c4fabb6179a61046f9a9099989791948e949093919291610b93565b60405180910390a1505050565b73ffffffffffffffffffffffffffffffffffffffff82166104fd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640160405180910390fd5b6000818160020160008282546105139190610c5e565b909155505073ffffffffffffffffffffffffffffffffffffffff831660009081526003820160205260408120805484929061054f908490610c5e565b909155505060405182815273ffffffffffffffffffffffffffffffffffffffff8416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3505050565b634e487b7160e01b600052604160045260246000fd5b604051610100810167ffffffffffffffff811182821017156105e1576105e16105a7565b60405290565b803573ffffffffffffffffffffffffffffffffffffffff8116811461060b57600080fd5b919050565b600082601f83011261062157600080fd5b813567ffffffffffffffff8082111561063c5761063c6105a7565b604051601f8301601f19908116603f01168101908282118183101715610664576106646105a7565b8160405283815286602085880101111561067d57600080fd5b836020870160208301376000602085830101528094505050505092915050565b8035801515811461060b57600080fd5b600061010082840312156106c057600080fd5b6106c86105bd565b9050813567ffffffffffffffff808211156106e257600080fd5b6106ee85838601610610565b8352602084013591508082111561070457600080fd5b61071085838601610610565b6020840152604084013591508082111561072957600080fd5b61073585838601610610565b6040840152606084013591508082111561074e57600080fd5b61075a85838601610610565b6060840152608084013591508082111561077357600080fd5b5061078084828501610610565b60808301525061079260a0830161069d565b60a082015260c082013560c082015260e082013560e082015292915050565b6000602082840312156107c357600080fd5b813567ffffffffffffffff808211156107db57600080fd5b9083019061010082860312156107f057600080fd5b6107f86105bd565b610801836105e7565b815260208301358281111561081557600080fd5b610821878286016106ad565b60208301525060408301358281111561083957600080fd5b61084587828601610610565b60408301525060608301356060820152610861608084016105e7565b608082015261087260a084016105e7565b60a082015260c083013560c082015261088d60e084016105e7565b60e082015295945050505050565b600181811c908216806108af57607f821691505b6020821081036108cf57634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111561091f57600081815260208120601f850160051c810160208610156108fc5750805b601f850160051c820191505b8181101561091b57828155600101610908565b5050505b505050565b815167ffffffffffffffff81111561093e5761093e6105a7565b6109528161094c845461089b565b846108d5565b602080601f831160018114610987576000841561096f5750858301515b600019600386901b1c1916600185901b17855561091b565b600085815260208120601f198616915b828110156109b657888601518255948401946001909101908401610997565b50858210156109d45787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6000602082840312156109f657600080fd5b815160ff81168114610a0757600080fd5b9392505050565b634e487b7160e01b600052601160045260246000fd5b60ff8281168282160390811115610a3d57610a3d610a0e565b92915050565b600181815b80851115610a7e578160001904821115610a6457610a64610a0e565b80851615610a7157918102915b93841c9390800290610a48565b509250929050565b600082610a9557506001610a3d565b81610aa257506000610a3d565b8160018114610ab85760028114610ac257610ade565b6001915050610a3d565b60ff841115610ad357610ad3610a0e565b50506001821b610a3d565b5060208310610133831016604e8410600b8410161715610b01575081810a610a3d565b610b0b8383610a43565b8060001904821115610b1f57610b1f610a0e565b029392505050565b6000610a0760ff841683610a86565b8082028115828204841417610a3d57610a3d610a0e565b6000815180845260005b81811015610b7357602081850181015186830182015201610b57565b506000602082860101526020601f19601f83011685010191505092915050565b600061016073ffffffffffffffffffffffffffffffffffffffff8e168352806020840152610bc38184018e610b4d565b8c1515604085015273ffffffffffffffffffffffffffffffffffffffff8c16606085015290508960808401528860a08401528760c084015282810360e0840152610c0d8188610b4d565b9050828103610100840152610c228187610b4d565b9050828103610120840152610c378186610b4d565b9050828103610140840152610c4c8185610b4d565b9e9d5050505050505050505050505050565b80820180821115610a3d57610a3d610a0e56fea26469706673582212203786ea1ac5a364eb4557d06d8f26b04a17f8cdd80544d440719887800ebedcde64736f6c63430008110033

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061002b5760003560e01c80639981e6ba14610030575b600080fd5b61004361003e3660046107b1565b610045565b005b60c081015160155560a08101516016805473ffffffffffffffffffffffffffffffffffffffff9283167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915560e083015160178054918416918316919091179055601880548216331790556080830151600580549190931691161790556020810151805160069081906100dd9082610924565b50602082015160018201906100f29082610924565b50604082015160028201906101079082610924565b506060820151600382019061011c9082610924565b50608082015160048201906101319082610924565b5060a082015160058201805491151560ff1992831617905560c0830151600683015560e0909201516007909101556080820151601180546001818101835560009283527f31ecc21a745e3968a04e9570e4425bc18fa8019c68028196b546d1669c200c68909101805473ffffffffffffffffffffffffffffffffffffffff9485167fffffffffffffffffffffffff000000000000000000000000000000000000000091821617909155855184168352600f602090815260408085208054881685179055875186168552601082528420805490961690921790945584516019805491909416941693909317909155908201515161022d9082610924565b5060408101516001906102409082610924565b506000816080015173ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610292573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102b691906109e4565b6102c1906012610a24565b6102cc90600a610b27565b82606001516102db9190610b36565b90506102eb82600001518261047c565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131f60209081527f699d9daa71b280d05a152715774afa0a81a312594b2d731d6b0b2552b7d6f69f8054600160ff1991821681179092557ff97e938d8af42f52387bb74b8b526fda8f184cc2aa534340a8d75a88fbecc77580548216831790557f65d510a5d8f7ef134ec444f7f34ee808c8eeb5177cdfd16be0c40fe1ab43369580548216831790557fcaaf2fc9000000000000000000000000000000000000000000000000000000006000527fc948b980938d663840437c45b013ee10a15dfcd888579f4279a30d47920ad0ca80549091169091179055825183820151805160a082015160808088015160c085015160e0860151978601516040808801516060890151959098015190517fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c9a7f6961163ce2d23c05c84cca730988be314ddc2c745c6ff4cca1cd7a5c4fabb6179a61046f9a9099989791948e949093919291610b93565b60405180910390a1505050565b73ffffffffffffffffffffffffffffffffffffffff82166104fd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640160405180910390fd5b6000818160020160008282546105139190610c5e565b909155505073ffffffffffffffffffffffffffffffffffffffff831660009081526003820160205260408120805484929061054f908490610c5e565b909155505060405182815273ffffffffffffffffffffffffffffffffffffffff8416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3505050565b634e487b7160e01b600052604160045260246000fd5b604051610100810167ffffffffffffffff811182821017156105e1576105e16105a7565b60405290565b803573ffffffffffffffffffffffffffffffffffffffff8116811461060b57600080fd5b919050565b600082601f83011261062157600080fd5b813567ffffffffffffffff8082111561063c5761063c6105a7565b604051601f8301601f19908116603f01168101908282118183101715610664576106646105a7565b8160405283815286602085880101111561067d57600080fd5b836020870160208301376000602085830101528094505050505092915050565b8035801515811461060b57600080fd5b600061010082840312156106c057600080fd5b6106c86105bd565b9050813567ffffffffffffffff808211156106e257600080fd5b6106ee85838601610610565b8352602084013591508082111561070457600080fd5b61071085838601610610565b6020840152604084013591508082111561072957600080fd5b61073585838601610610565b6040840152606084013591508082111561074e57600080fd5b61075a85838601610610565b6060840152608084013591508082111561077357600080fd5b5061078084828501610610565b60808301525061079260a0830161069d565b60a082015260c082013560c082015260e082013560e082015292915050565b6000602082840312156107c357600080fd5b813567ffffffffffffffff808211156107db57600080fd5b9083019061010082860312156107f057600080fd5b6107f86105bd565b610801836105e7565b815260208301358281111561081557600080fd5b610821878286016106ad565b60208301525060408301358281111561083957600080fd5b61084587828601610610565b60408301525060608301356060820152610861608084016105e7565b608082015261087260a084016105e7565b60a082015260c083013560c082015261088d60e084016105e7565b60e082015295945050505050565b600181811c908216806108af57607f821691505b6020821081036108cf57634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111561091f57600081815260208120601f850160051c810160208610156108fc5750805b601f850160051c820191505b8181101561091b57828155600101610908565b5050505b505050565b815167ffffffffffffffff81111561093e5761093e6105a7565b6109528161094c845461089b565b846108d5565b602080601f831160018114610987576000841561096f5750858301515b600019600386901b1c1916600185901b17855561091b565b600085815260208120601f198616915b828110156109b657888601518255948401946001909101908401610997565b50858210156109d45787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6000602082840312156109f657600080fd5b815160ff81168114610a0757600080fd5b9392505050565b634e487b7160e01b600052601160045260246000fd5b60ff8281168282160390811115610a3d57610a3d610a0e565b92915050565b600181815b80851115610a7e578160001904821115610a6457610a64610a0e565b80851615610a7157918102915b93841c9390800290610a48565b509250929050565b600082610a9557506001610a3d565b81610aa257506000610a3d565b8160018114610ab85760028114610ac257610ade565b6001915050610a3d565b60ff841115610ad357610ad3610a0e565b50506001821b610a3d565b5060208310610133831016604e8410600b8410161715610b01575081810a610a3d565b610b0b8383610a43565b8060001904821115610b1f57610b1f610a0e565b029392505050565b6000610a0760ff841683610a86565b8082028115828204841417610a3d57610a3d610a0e565b6000815180845260005b81811015610b7357602081850181015186830182015201610b57565b506000602082860101526020601f19601f83011685010191505092915050565b600061016073ffffffffffffffffffffffffffffffffffffffff8e168352806020840152610bc38184018e610b4d565b8c1515604085015273ffffffffffffffffffffffffffffffffffffffff8c16606085015290508960808401528860a08401528760c084015282810360e0840152610c0d8188610b4d565b9050828103610100840152610c228187610b4d565b9050828103610120840152610c378186610b4d565b9050828103610140840152610c4c8185610b4d565b9e9d5050505050505050505050505050565b80820180821115610a3d57610a3d610a0e56fea26469706673582212203786ea1ac5a364eb4557d06d8f26b04a17f8cdd80544d440719887800ebedcde64736f6c63430008110033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.