POL Price: $0.654851 (+11.45%)
 

Overview

POL Balance

Polygon PoS Chain LogoPolygon PoS Chain LogoPolygon PoS Chain Logo0 POL

POL Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

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

Contract Source Code Verified (Exact Match)

Contract Name:
LimitOrdersFacet

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 2000 runs

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

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

import {LibSignatures} from "../libraries/LibSignatures.sol";
import {Modifiers} from "../libraries/LibAppStorage.sol";

/// "Call to method failed"
error OneInchCallFailed();
/// "Invalid 1nch source"
error Invalid1nchSource();
/// "Invalid 1nch limit order filled maker"
error InvalidLimitOrderFill();

address constant LIMIT_ORDER_PROTOCOL_1NCH = 0x94Bc2a1C732BcAd7343B25af48385Fe76E08734f; // 1nch Polygon LimitOrderProtocol

// address constant LIMIT_ORDER_PROTOCOL_1NCH = 0x119c71D3BbAC22029622cbaEc24854d3D32D2828; // 1nch Mainnet LimitOrderProtocol

// address constant LIMIT_ORDER_PROTOCOL_1NCH = 0x11431a89893025D2a48dCA4EddC396f8C8117187; // 1nch Optimism LimitOrderProtocol

/**
 * @title LimitOrdersFacet
 * @author PartyFinance
 * @notice Facet that interacts with 1nch Protocol to handle LimitOrders
 * [1nch LimitOrder introduction](https://docs.1inch.io/docs/limit-order-protocol/introduction)
 */
contract LimitOrdersFacet is Modifiers {
    /**
     * @notice Emitted when 1nch LimitOrderProtocol calls Party when a limit order is filled
     * @param taker Taker address that filled the order
     * @param makerAsset Maker asset address
     * @param takerAsset Taker asset address
     * @param makingAmount Making asset amount
     * @param takingAmount Taking asset amount
     */
    event LimitOrderFilled(
        address taker,
        address makerAsset,
        address takerAsset,
        uint256 makingAmount,
        uint256 takingAmount
    );

    struct LimitOrder {
        uint256 salt;
        address makerAsset;
        address takerAsset;
        address maker;
        address receiver;
        address allowedSender;
        uint256 makingAmount;
        uint256 takingAmount;
        bytes makerAssetData;
        bytes takerAssetData;
        bytes getMakerAmount;
        bytes getTakerAmount;
        bytes predicate;
        bytes permit;
        bytes interaction;
    }

    /**
     * @notice Approves 1nch LimitOrderProtocol to consume party assets
     * @param sellToken ERC-20 sell token address
     * @param sellAmount ERC-20 sell token amount
     */
    function approveLimitOrder(
        address sellToken,
        uint256 sellAmount
    ) external onlyManager {
        // Execute 1nch cancelOrder method
        IERC20(sellToken).approve(LIMIT_ORDER_PROTOCOL_1NCH, sellAmount);
    }

    /**
     * @notice Cancels a limit order on 1nch
     * @param order Limit Order
     */
    function cancelLimitOrder(LimitOrder memory order) external onlyManager {
        // Execute 1nch cancelOrder method
        (bool success, ) = LIMIT_ORDER_PROTOCOL_1NCH.call(
            abi.encodeWithSignature(
                "cancelOrder((uint256,address,address,address,address,address,uint256,uint256,bytes,bytes,bytes,bytes,bytes,bytes,bytes))",
                order
            )
        );
        if (!success) revert OneInchCallFailed();
    }

    /**
     * @notice Interaction receiver function for 1nch LimitOrderProtocol when a party's limit order is filled
     * @param taker Taker address that filled the order
     * @param makerAsset Maker asset address
     * @param takerAsset Taker asset address
     * @param makingAmount Making asset amount
     * @param takingAmount Taking asset amount
     * @param interactiveData Interactive call data
     */
    function notifyFillOrder(
        address taker,
        address makerAsset,
        address takerAsset,
        uint256 makingAmount,
        uint256 takingAmount,
        bytes calldata interactiveData
    ) external {
        if (msg.sender != LIMIT_ORDER_PROTOCOL_1NCH) revert Invalid1nchSource();
        address makerAddress;
        assembly {
            makerAddress := shr(96, calldataload(interactiveData.offset))
        }
        if (makerAddress != address(this)) revert InvalidLimitOrderFill();
        emit LimitOrderFilled(
            taker,
            makerAsset,
            takerAsset,
            makingAmount,
            takingAmount
        );
    }

    /**
     * @notice Standard Signature Validation Method for Contracts EIP-1271.
     * @dev Verifies that the signer is a Party Manager of the signing contract.
     */
    function isValidSignature(
        bytes32 _hash,
        bytes calldata _signature
    ) external view returns (bytes4) {
        if (s.managers[LibSignatures.recover(_hash, _signature)]) {
            return 0x1626ba7e;
        } else {
            return 0xffffffff;
        }
    }
}

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

import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";

library LibSignatures {
    /**
     * @notice A struct containing the recovered Signature
     */
    struct Sig {
        bytes32 r;
        bytes32 s;
        uint8 v;
    }
    /**
     * @notice A struct containing the Allocation info
     * @dev For the array members, need to have the same length.
     * @param sellTokens Array of ERC-20 token addresses to sell
     * @param sellAmounts Array of ERC-20 token amounts to sell
     * @param buyTokens Array of ERC-20 token addresses to buy
     * @param spenders Array of the spenders addresses
     * @param swapTargets Array of the targets to interact with (0x Exchange Proxy)
     * @param swapsCallDAta Array of bytes containing the calldata
     * @param partyValueDA Current value of the Party in denomination asset
     * @param partyTotalSupply Current total supply of the Party
     * @param expiresAt Block timestamp expiration date
     */
    struct Allocation {
        address[] sellTokens;
        uint256[] sellAmounts;
        address[] buyTokens;
        address[] spenders;
        address payable[] swapsTargets;
        bytes[] swapsCallData;
        uint256 partyValueDA;
        uint256 partyTotalSupply;
        uint256 expiresAt;
    }

    /**
     * @notice Returns the address that signed a hashed message with a signature
     */
    function recover(bytes32 _hash, bytes calldata _signature)
        internal
        pure
        returns (address)
    {
        return ECDSA.recover(_hash, _signature);
    }

    /**
     * @notice Returns an Ethereum Signed Message.
     * @dev Produces a hash corresponding to the one signed with the
     * [eth_sign JSON-RPC method](https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]) as part of EIP-191.
     */
    function getMessageHash(bytes memory _abiEncoded)
        internal
        pure
        returns (bytes32)
    {
        return
            keccak256(
                abi.encodePacked(
                    "\x19Ethereum Signed Message:\n32",
                    keccak256(_abiEncoded)
                )
            );
    }

    /**
     * @notice Verifies the tx signature against the PartyFi Sentinel address
     * @dev Used by the deposit, join, kick, leave and swap actions
     * @param user The user involved in the allocation
     * @param signer The PartyFi Sentinel singer address
     * @param allocation The allocation struct to verify
     * @param rsv The values for the transaction's signature
     */
    function isValidAllocation(
        address user,
        address signer,
        Allocation memory allocation,
        Sig memory rsv
    ) internal view returns (bool) {
        // 1. Checks if the allocation hasn't expire
        if (allocation.expiresAt < block.timestamp) return false;

        // 2. Hashes the allocation struct to get the allocation hash
        bytes32 allocationHash = getMessageHash(
            abi.encodePacked(
                address(this),
                user,
                allocation.sellTokens,
                allocation.sellAmounts,
                allocation.buyTokens,
                allocation.spenders,
                allocation.swapsTargets,
                allocation.partyValueDA,
                allocation.partyTotalSupply,
                allocation.expiresAt
            )
        );

        // 3. Validates if the recovered signer is the PartyFi Sentinel
        return ECDSA.recover(allocationHash, rsv.v, rsv.r, rsv.s) == signer;
    }
}

File 3 of 7 : 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 4 of 7 : 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);
}

File 5 of 7 : ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        } else if (error == RecoverError.InvalidSignatureV) {
            revert("ECDSA: invalid signature 'v' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            /// @solidity memory-safe-assembly
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address, RecoverError) {
        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
        uint8 v = uint8((uint256(vs) >> 255) + 27);
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }
        if (v != 27 && v != 28) {
            return (address(0), RecoverError.InvalidSignatureV);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from `s`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    }
}

File 6 of 7 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}

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

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

Contract Security Audit

Contract ABI

[{"inputs":[],"name":"Invalid1nchSource","type":"error"},{"inputs":[],"name":"InvalidLimitOrderFill","type":"error"},{"inputs":[],"name":"OneInchCallFailed","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"taker","type":"address"},{"indexed":false,"internalType":"address","name":"makerAsset","type":"address"},{"indexed":false,"internalType":"address","name":"takerAsset","type":"address"},{"indexed":false,"internalType":"uint256","name":"makingAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"takingAmount","type":"uint256"}],"name":"LimitOrderFilled","type":"event"},{"inputs":[{"internalType":"address","name":"sellToken","type":"address"},{"internalType":"uint256","name":"sellAmount","type":"uint256"}],"name":"approveLimitOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"address","name":"makerAsset","type":"address"},{"internalType":"address","name":"takerAsset","type":"address"},{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"allowedSender","type":"address"},{"internalType":"uint256","name":"makingAmount","type":"uint256"},{"internalType":"uint256","name":"takingAmount","type":"uint256"},{"internalType":"bytes","name":"makerAssetData","type":"bytes"},{"internalType":"bytes","name":"takerAssetData","type":"bytes"},{"internalType":"bytes","name":"getMakerAmount","type":"bytes"},{"internalType":"bytes","name":"getTakerAmount","type":"bytes"},{"internalType":"bytes","name":"predicate","type":"bytes"},{"internalType":"bytes","name":"permit","type":"bytes"},{"internalType":"bytes","name":"interaction","type":"bytes"}],"internalType":"struct LimitOrdersFacet.LimitOrder","name":"order","type":"tuple"}],"name":"cancelLimitOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_hash","type":"bytes32"},{"internalType":"bytes","name":"_signature","type":"bytes"}],"name":"isValidSignature","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"taker","type":"address"},{"internalType":"address","name":"makerAsset","type":"address"},{"internalType":"address","name":"takerAsset","type":"address"},{"internalType":"uint256","name":"makingAmount","type":"uint256"},{"internalType":"uint256","name":"takingAmount","type":"uint256"},{"internalType":"bytes","name":"interactiveData","type":"bytes"}],"name":"notifyFillOrder","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b50610f4c806100206000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80631626ba7e14610051578063288459c91461009957806350fd7af2146100ae578063cf21c775146100c1575b600080fd5b61006461005f366004610919565b6100d4565b6040517fffffffff00000000000000000000000000000000000000000000000000000000909116815260200160405180910390f35b6100ac6100a7366004610a67565b610157565b005b6100ac6100bc366004610c30565b6102e6565b6100ac6100cf366004610c5a565b6103fe565b6000600f816100e48686866104ec565b6001600160a01b0316815260208101919091526040016000205460ff161561012d57507f1626ba7e00000000000000000000000000000000000000000000000000000000610150565b507fffffffff000000000000000000000000000000000000000000000000000000005b9392505050565b600f6000610163610536565b6001600160a01b0316815260208101919091526040016000205460ff166101d15760405162461bcd60e51b815260206004820152601b60248201527f4f6e6c79205061727479204d616e616765727320616c6c6f776564000000000060448201526064015b60405180910390fd5b60007394bc2a1c732bcad7343b25af48385fe76e08734f6001600160a01b0316826040516024016102029190610d33565b60408051601f198184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fb244b45000000000000000000000000000000000000000000000000000000000179052516102659190610ea9565b6000604051808303816000865af19150503d80600081146102a2576040519150601f19603f3d011682016040523d82523d6000602084013e6102a7565b606091505b50509050806102e2576040517f95e2813c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050565b600f60006102f2610536565b6001600160a01b0316815260208101919091526040016000205460ff1661035b5760405162461bcd60e51b815260206004820152601b60248201527f4f6e6c79205061727479204d616e616765727320616c6c6f776564000000000060448201526064016101c8565b6040517f095ea7b30000000000000000000000000000000000000000000000000000000081527394bc2a1c732bcad7343b25af48385fe76e08734f6004820152602481018290526001600160a01b0383169063095ea7b3906044016020604051808303816000875af11580156103d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103f99190610ec5565b505050565b337394bc2a1c732bcad7343b25af48385fe76e08734f1461044b576040517ff4a00c2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b813560601c308114610489576040517f5bc8a18a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b604080516001600160a01b038a811682528981166020830152881681830152606081018790526080810186905290517fc03f0ec3b5d564c47bf1ef3adab8cf3a94276f82bc43fec87683f68af0df27999181900360a00190a15050505050505050565b600061052e8484848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061059292505050565b949350505050565b600030330361058c57600080368080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050503601516001600160a01b0316915061058f9050565b50335b90565b60008060006105a185856105b6565b915091506105ae816105fb565b509392505050565b60008082516041036105ec5760208301516040840151606085015160001a6105e0878285856107ea565b945094505050506105f4565b506000905060025b9250929050565b600081600481111561060f5761060f610ee7565b036106175750565b600181600481111561062b5761062b610ee7565b036106785760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e6174757265000000000000000060448201526064016101c8565b600281600481111561068c5761068c610ee7565b036106d95760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e6774680060448201526064016101c8565b60038160048111156106ed576106ed610ee7565b036107605760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f756500000000000000000000000000000000000000000000000000000000000060648201526084016101c8565b600481600481111561077457610774610ee7565b036107e75760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c60448201527f756500000000000000000000000000000000000000000000000000000000000060648201526084016101c8565b50565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561082157506000905060036108ce565b8460ff16601b1415801561083957508460ff16601c14155b1561084a57506000905060046108ce565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa15801561089e573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166108c7576000600192509250506108ce565b9150600090505b94509492505050565b60008083601f8401126108e957600080fd5b50813567ffffffffffffffff81111561090157600080fd5b6020830191508360208285010111156105f457600080fd5b60008060006040848603121561092e57600080fd5b83359250602084013567ffffffffffffffff81111561094c57600080fd5b610958868287016108d7565b9497909650939450505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516101e0810167ffffffffffffffff811182821017156109b8576109b8610965565b60405290565b80356001600160a01b03811681146109d557600080fd5b919050565b600082601f8301126109eb57600080fd5b813567ffffffffffffffff80821115610a0657610a06610965565b604051601f8301601f19908116603f01168101908282118183101715610a2e57610a2e610965565b81604052838152866020858801011115610a4757600080fd5b836020870160208301376000602085830101528094505050505092915050565b600060208284031215610a7957600080fd5b813567ffffffffffffffff80821115610a9157600080fd5b908301906101e08286031215610aa657600080fd5b610aae610994565b82358152610abe602084016109be565b6020820152610acf604084016109be565b6040820152610ae0606084016109be565b6060820152610af1608084016109be565b6080820152610b0260a084016109be565b60a082015260c083013560c082015260e083013560e08201526101008084013583811115610b2f57600080fd5b610b3b888287016109da565b8284015250506101208084013583811115610b5557600080fd5b610b61888287016109da565b8284015250506101408084013583811115610b7b57600080fd5b610b87888287016109da565b8284015250506101608084013583811115610ba157600080fd5b610bad888287016109da565b8284015250506101808084013583811115610bc757600080fd5b610bd3888287016109da565b8284015250506101a08084013583811115610bed57600080fd5b610bf9888287016109da565b8284015250506101c08084013583811115610c1357600080fd5b610c1f888287016109da565b918301919091525095945050505050565b60008060408385031215610c4357600080fd5b610c4c836109be565b946020939093013593505050565b600080600080600080600060c0888a031215610c7557600080fd5b610c7e886109be565b9650610c8c602089016109be565b9550610c9a604089016109be565b9450606088013593506080880135925060a088013567ffffffffffffffff811115610cc457600080fd5b610cd08a828b016108d7565b989b979a50959850939692959293505050565b60005b83811015610cfe578181015183820152602001610ce6565b50506000910152565b60008151808452610d1f816020860160208601610ce3565b601f01601f19169290920160200192915050565b602081528151602082015260006020830151610d5a60408401826001600160a01b03169052565b5060408301516001600160a01b03811660608401525060608301516001600160a01b03811660808401525060808301516001600160a01b03811660a08401525060a08301516001600160a01b03811660c08401525060c083015160e083015260e08301516101008181850152808501519150506101e06101208181860152610de6610200860184610d07565b9250808601519050601f19610140818786030181880152610e078584610d07565b945080880151925050610160818786030181880152610e268584610d07565b945080880151925050610180818786030181880152610e458584610d07565b9450808801519250506101a0818786030181880152610e648584610d07565b9450808801519250506101c0818786030181880152610e838584610d07565b908801518782039092018488015293509050610e9f8382610d07565b9695505050505050565b60008251610ebb818460208701610ce3565b9190910192915050565b600060208284031215610ed757600080fd5b8151801515811461015057600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fdfea2646970667358221220d058ad32cbdca2a4c0084c55df3ace53bec2e38544d31a58f96bbcbeb247df4964736f6c63430008110033

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80631626ba7e14610051578063288459c91461009957806350fd7af2146100ae578063cf21c775146100c1575b600080fd5b61006461005f366004610919565b6100d4565b6040517fffffffff00000000000000000000000000000000000000000000000000000000909116815260200160405180910390f35b6100ac6100a7366004610a67565b610157565b005b6100ac6100bc366004610c30565b6102e6565b6100ac6100cf366004610c5a565b6103fe565b6000600f816100e48686866104ec565b6001600160a01b0316815260208101919091526040016000205460ff161561012d57507f1626ba7e00000000000000000000000000000000000000000000000000000000610150565b507fffffffff000000000000000000000000000000000000000000000000000000005b9392505050565b600f6000610163610536565b6001600160a01b0316815260208101919091526040016000205460ff166101d15760405162461bcd60e51b815260206004820152601b60248201527f4f6e6c79205061727479204d616e616765727320616c6c6f776564000000000060448201526064015b60405180910390fd5b60007394bc2a1c732bcad7343b25af48385fe76e08734f6001600160a01b0316826040516024016102029190610d33565b60408051601f198184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fb244b45000000000000000000000000000000000000000000000000000000000179052516102659190610ea9565b6000604051808303816000865af19150503d80600081146102a2576040519150601f19603f3d011682016040523d82523d6000602084013e6102a7565b606091505b50509050806102e2576040517f95e2813c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050565b600f60006102f2610536565b6001600160a01b0316815260208101919091526040016000205460ff1661035b5760405162461bcd60e51b815260206004820152601b60248201527f4f6e6c79205061727479204d616e616765727320616c6c6f776564000000000060448201526064016101c8565b6040517f095ea7b30000000000000000000000000000000000000000000000000000000081527394bc2a1c732bcad7343b25af48385fe76e08734f6004820152602481018290526001600160a01b0383169063095ea7b3906044016020604051808303816000875af11580156103d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103f99190610ec5565b505050565b337394bc2a1c732bcad7343b25af48385fe76e08734f1461044b576040517ff4a00c2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b813560601c308114610489576040517f5bc8a18a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b604080516001600160a01b038a811682528981166020830152881681830152606081018790526080810186905290517fc03f0ec3b5d564c47bf1ef3adab8cf3a94276f82bc43fec87683f68af0df27999181900360a00190a15050505050505050565b600061052e8484848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061059292505050565b949350505050565b600030330361058c57600080368080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050503601516001600160a01b0316915061058f9050565b50335b90565b60008060006105a185856105b6565b915091506105ae816105fb565b509392505050565b60008082516041036105ec5760208301516040840151606085015160001a6105e0878285856107ea565b945094505050506105f4565b506000905060025b9250929050565b600081600481111561060f5761060f610ee7565b036106175750565b600181600481111561062b5761062b610ee7565b036106785760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e6174757265000000000000000060448201526064016101c8565b600281600481111561068c5761068c610ee7565b036106d95760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e6774680060448201526064016101c8565b60038160048111156106ed576106ed610ee7565b036107605760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f756500000000000000000000000000000000000000000000000000000000000060648201526084016101c8565b600481600481111561077457610774610ee7565b036107e75760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c60448201527f756500000000000000000000000000000000000000000000000000000000000060648201526084016101c8565b50565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561082157506000905060036108ce565b8460ff16601b1415801561083957508460ff16601c14155b1561084a57506000905060046108ce565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa15801561089e573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166108c7576000600192509250506108ce565b9150600090505b94509492505050565b60008083601f8401126108e957600080fd5b50813567ffffffffffffffff81111561090157600080fd5b6020830191508360208285010111156105f457600080fd5b60008060006040848603121561092e57600080fd5b83359250602084013567ffffffffffffffff81111561094c57600080fd5b610958868287016108d7565b9497909650939450505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516101e0810167ffffffffffffffff811182821017156109b8576109b8610965565b60405290565b80356001600160a01b03811681146109d557600080fd5b919050565b600082601f8301126109eb57600080fd5b813567ffffffffffffffff80821115610a0657610a06610965565b604051601f8301601f19908116603f01168101908282118183101715610a2e57610a2e610965565b81604052838152866020858801011115610a4757600080fd5b836020870160208301376000602085830101528094505050505092915050565b600060208284031215610a7957600080fd5b813567ffffffffffffffff80821115610a9157600080fd5b908301906101e08286031215610aa657600080fd5b610aae610994565b82358152610abe602084016109be565b6020820152610acf604084016109be565b6040820152610ae0606084016109be565b6060820152610af1608084016109be565b6080820152610b0260a084016109be565b60a082015260c083013560c082015260e083013560e08201526101008084013583811115610b2f57600080fd5b610b3b888287016109da565b8284015250506101208084013583811115610b5557600080fd5b610b61888287016109da565b8284015250506101408084013583811115610b7b57600080fd5b610b87888287016109da565b8284015250506101608084013583811115610ba157600080fd5b610bad888287016109da565b8284015250506101808084013583811115610bc757600080fd5b610bd3888287016109da565b8284015250506101a08084013583811115610bed57600080fd5b610bf9888287016109da565b8284015250506101c08084013583811115610c1357600080fd5b610c1f888287016109da565b918301919091525095945050505050565b60008060408385031215610c4357600080fd5b610c4c836109be565b946020939093013593505050565b600080600080600080600060c0888a031215610c7557600080fd5b610c7e886109be565b9650610c8c602089016109be565b9550610c9a604089016109be565b9450606088013593506080880135925060a088013567ffffffffffffffff811115610cc457600080fd5b610cd08a828b016108d7565b989b979a50959850939692959293505050565b60005b83811015610cfe578181015183820152602001610ce6565b50506000910152565b60008151808452610d1f816020860160208601610ce3565b601f01601f19169290920160200192915050565b602081528151602082015260006020830151610d5a60408401826001600160a01b03169052565b5060408301516001600160a01b03811660608401525060608301516001600160a01b03811660808401525060808301516001600160a01b03811660a08401525060a08301516001600160a01b03811660c08401525060c083015160e083015260e08301516101008181850152808501519150506101e06101208181860152610de6610200860184610d07565b9250808601519050601f19610140818786030181880152610e078584610d07565b945080880151925050610160818786030181880152610e268584610d07565b945080880151925050610180818786030181880152610e458584610d07565b9450808801519250506101a0818786030181880152610e648584610d07565b9450808801519250506101c0818786030181880152610e838584610d07565b908801518782039092018488015293509050610e9f8382610d07565b9695505050505050565b60008251610ebb818460208701610ce3565b9190910192915050565b600060208284031215610ed757600080fd5b8151801515811461015057600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fdfea2646970667358221220d058ad32cbdca2a4c0084c55df3ace53bec2e38544d31a58f96bbcbeb247df4964736f6c63430008110033

Block Transaction Gas Used Reward
view all blocks produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits

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.