编译器
0.8.13+commit.abaa5c0e
文件 1 的 19:Address.sol
pragma solidity ^0.8.1;
library Address {
function isContract(address account) internal view returns (bool) {
return account.code.length > 0;
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
文件 2 的 19:Context.sol
pragma solidity ^0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
文件 3 的 19:ECDSA.sol
pragma solidity ^0.8.0;
import "../Strings.sol";
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return;
} 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");
}
}
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
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 if (signature.length == 64) {
bytes32 r;
bytes32 vs;
assembly {
r := mload(add(signature, 0x20))
vs := mload(add(signature, 0x40))
}
return tryRecover(hash, r, vs);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
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);
}
function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
if (v != 27 && v != 28) {
return (address(0), RecoverError.InvalidSignatureV);
}
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
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;
}
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
}
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
}
文件 4 的 19:ExchangeCore.sol
pragma solidity ^0.8.0;
pragma abicoder v2;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "./interfaces/IFactory.sol";
abstract contract ExchangeCore is ReentrancyGuard, EIP712 {
using SafeERC20 for IERC20;
error InvalidOrder();
error InvalidTarget();
error InvalidOrderParameters();
error NonMatchableOrders();
error NotAuthorized();
error InvalidCollection();
error InvalidSender();
error AlreadyApproved();
bytes32 private immutable _ORDER_TYPEHASH;
uint256 public constant INVERSE_BASIS_POINT = 10000;
IERC20 public exchangeToken;
mapping(bytes32 => bool) public cancelledOrFinalized;
mapping(bytes32 => uint256) private _approvedOrdersByNonce;
mapping(address => uint256) public nonces;
mapping(address => bool) public allowedCollections;
address public protocolFeeRecipient;
mapping(address => address) internal mintFeeRecipient;
enum OrderSide {
Buy,
Sell
}
enum CollectionType {
ERC721,
ERC1155
}
struct Order {
address maker;
address taker;
uint256 makerProtocolFee;
uint256 takerProtocolFee;
address feeRecipient;
OrderSide side;
CollectionType collectionType;
address mintFactory;
address collection;
uint256[] tokenIds;
uint256[] amounts;
address paymentToken;
uint256 basePrice;
uint256 extra;
uint256 listingTime;
uint256 expirationTime;
uint256 salt;
}
event OrderApproved(bytes32 indexed hash, Order order, bool orderbookInclusionDesired);
event OrderCancelled(bytes32 indexed hash);
event OrdersMatched(
bytes32 buyHash,
bytes32 sellHash,
address indexed maker,
address indexed taker,
uint256 price,
bytes32 indexed metadata
);
event NonceIncremented(address indexed maker, uint256 newNonce);
constructor() {
bytes32 typeHash = keccak256(
"Order(address maker,address taker,uint256 makerProtocolFee,uint256 takerProtocolFee,address feeRecipient,uint8 side,uint8 collectionType,address mintFactory,address collection,uint256[] tokenIds,uint256[] amounts,address paymentToken,uint256 basePrice,uint256 extra,uint256 listingTime,uint256 expirationTime,uint256 salt,uint256 nonce)"
);
_ORDER_TYPEHASH = typeHash;
}
function incrementNonce() external {
uint256 newNonce = ++nonces[msg.sender];
emit NonceIncremented(msg.sender, newNonce);
}
function transferTokens(
address token,
address from,
address to,
uint256 amount
) internal {
if (amount > 0) {
IERC20(token).safeTransferFrom(from, to, amount);
}
}
function hashOrder(Order memory order, uint256 nonce) internal view returns (bytes32) {
return
keccak256(
bytes.concat(
abi.encode(_ORDER_TYPEHASH),
abi.encode(
order.maker,
order.taker,
order.makerProtocolFee,
order.takerProtocolFee,
order.feeRecipient,
order.side
),
abi.encode(order.collectionType, order.mintFactory, order.collection),
keccak256(abi.encodePacked(order.tokenIds)),
keccak256(abi.encodePacked(order.amounts)),
abi.encode(
order.paymentToken,
order.basePrice,
order.extra,
order.listingTime,
order.expirationTime,
order.salt
),
abi.encode(nonce)
)
);
}
function hashToSign(Order memory order, uint256 nonce) internal view returns (bytes32) {
return _hashTypedDataV4(hashOrder(order, nonce));
}
function requireValidOrder(
Order memory order,
bytes memory signature,
uint256 nonce
) internal view returns (bytes32) {
bytes32 hash = hashToSign(order, nonce);
if (!validateOrder(hash, order, signature)) revert InvalidOrder();
return hash;
}
function validateOrderParameters(Order memory order) internal view returns (bool) {
if (order.maker == address(0)) {
return false;
}
if (order.tokenIds.length == 0 || order.tokenIds.length != order.amounts.length) {
return false;
}
if (order.mintFactory != address(0) && !allowedCollections[order.mintFactory]) {
return false;
}
if (order.collection == address(0) || !allowedCollections[order.collection]) {
return false;
}
return true;
}
function validateOrder(
bytes32 hash,
Order memory order,
bytes memory signature
) internal view returns (bool) {
if (!validateOrderParameters(order)) {
return false;
}
if (cancelledOrFinalized[hash]) {
return false;
}
uint256 approvedOrderNoncePlusOne = _approvedOrdersByNonce[hash];
if (approvedOrderNoncePlusOne != 0) {
return approvedOrderNoncePlusOne == nonces[order.maker] + 1;
}
return SignatureChecker.isValidSignatureNow(order.maker, hash, signature);
}
function canSettleOrder(uint256 listingTime, uint256 expirationTime) internal view returns (bool) {
return (listingTime < block.timestamp) && (expirationTime == 0 || block.timestamp < expirationTime);
}
function approvedOrders(bytes32 hash) public view returns (bool approved) {
return _approvedOrdersByNonce[hash] != 0;
}
function approveOrder(Order memory order, bool orderbookInclusionDesired) internal {
if (msg.sender != order.maker) revert InvalidSender();
bytes32 hash = hashToSign(order, nonces[order.maker]);
if (_approvedOrdersByNonce[hash] != 0) revert AlreadyApproved();
_approvedOrdersByNonce[hash] = nonces[order.maker] + 1;
emit OrderApproved(hash, order, orderbookInclusionDesired);
}
function cancelOrder(
Order memory order,
bytes memory signature,
uint256 nonce
) internal {
bytes32 hash = requireValidOrder(order, signature, nonce);
if (msg.sender != order.maker) revert NotAuthorized();
cancelledOrFinalized[hash] = true;
emit OrderCancelled(hash);
}
function calculateMatchPrice(Order memory buy, Order memory sell) internal pure returns (uint256) {
uint256 sellPrice = sell.basePrice;
uint256 buyPrice = buy.basePrice;
require(buyPrice >= sellPrice);
return sell.feeRecipient != address(0) ? sellPrice : buyPrice;
}
function executeFundsTransfer(Order memory buy, Order memory sell) internal returns (uint256) {
if (sell.paymentToken != address(0)) {
require(msg.value == 0);
}
uint256 price = calculateMatchPrice(buy, sell);
address paymentRecipient = sell.mintFactory != address(0) ? getMintRecipient(sell.collection) : sell.maker;
if (price > 0 && sell.paymentToken != address(0)) {
transferTokens(sell.paymentToken, buy.maker, paymentRecipient, price);
}
uint256 receiveAmount = price;
uint256 requiredAmount = price;
uint256 makerProtocolFee;
uint256 takerProtocolFee;
if (sell.feeRecipient != address(0)) {
require(sell.takerProtocolFee <= buy.takerProtocolFee);
if (sell.makerProtocolFee > 0) {
makerProtocolFee = SafeMath.div(SafeMath.mul(sell.makerProtocolFee, price), INVERSE_BASIS_POINT);
if (sell.paymentToken == address(0)) {
receiveAmount = SafeMath.sub(receiveAmount, makerProtocolFee);
payable(protocolFeeRecipient).transfer(makerProtocolFee);
} else {
transferTokens(sell.paymentToken, sell.maker, protocolFeeRecipient, makerProtocolFee);
}
}
if (sell.takerProtocolFee > 0) {
takerProtocolFee = SafeMath.div(SafeMath.mul(sell.takerProtocolFee, price), INVERSE_BASIS_POINT);
if (sell.paymentToken == address(0)) {
requiredAmount = SafeMath.add(requiredAmount, takerProtocolFee);
payable(protocolFeeRecipient).transfer(takerProtocolFee);
} else {
transferTokens(sell.paymentToken, buy.maker, protocolFeeRecipient, takerProtocolFee);
}
}
} else {
require(sell.paymentToken != address(0));
require(buy.takerProtocolFee <= sell.takerProtocolFee);
if (buy.makerProtocolFee > 0) {
makerProtocolFee = SafeMath.div(SafeMath.mul(buy.makerProtocolFee, price), INVERSE_BASIS_POINT);
transferTokens(sell.paymentToken, buy.maker, protocolFeeRecipient, makerProtocolFee);
}
if (buy.takerProtocolFee > 0) {
takerProtocolFee = SafeMath.div(SafeMath.mul(buy.takerProtocolFee, price), INVERSE_BASIS_POINT);
transferTokens(sell.paymentToken, sell.maker, protocolFeeRecipient, takerProtocolFee);
}
}
if (sell.paymentToken == address(0)) {
require(msg.value >= requiredAmount);
payable(paymentRecipient).transfer(receiveAmount);
uint256 diff = SafeMath.sub(msg.value, requiredAmount);
if (diff > 0) {
payable(buy.maker).transfer(diff);
}
}
return price;
}
function executeTokensTransfer(Order memory buy, Order memory sell) internal {
if (sell.collectionType == CollectionType.ERC721) {
if (sell.mintFactory != address(0)) {
if (sell.tokenIds.length == 1) {
IERC721Factory(sell.mintFactory).mint(buy.maker, sell.tokenIds[0], "");
} else {
IERC721Factory(sell.mintFactory).mintBatch(buy.maker, sell.tokenIds, "");
}
} else {
for (uint256 i = 0; i < sell.tokenIds.length; i++) {
require(sell.amounts[i] == 1, "Invalid amount");
IERC721(sell.collection).safeTransferFrom(sell.maker, buy.maker, sell.tokenIds[i], "");
}
}
} else if (sell.collectionType == CollectionType.ERC1155) {
if (sell.mintFactory != address(0)) {
if (sell.tokenIds.length == 1) {
IERC1155Factory(sell.mintFactory).mint(buy.maker, sell.tokenIds[0], sell.amounts[0], "");
} else {
IERC1155Factory(sell.mintFactory).mintBatch(buy.maker, sell.tokenIds, sell.amounts, "");
}
} else {
if (sell.tokenIds.length == 1) {
IERC1155(sell.collection).safeTransferFrom(
sell.maker,
buy.maker,
sell.tokenIds[0],
sell.amounts[0],
""
);
} else {
IERC1155(sell.collection).safeBatchTransferFrom(
sell.maker,
buy.maker,
sell.tokenIds,
sell.amounts,
""
);
}
}
}
}
function uintArrayMatch(uint256[] memory a, uint256[] memory b) internal pure returns (bool) {
if (a.length != b.length) return false;
for (uint256 i = 0; i < a.length; i++) {
if (a[i] != b[i]) return false;
}
return true;
}
function ordersCanMatch(Order memory buy, Order memory sell) internal view returns (bool) {
return (
(buy.side == OrderSide.Buy && sell.side == OrderSide.Sell) &&
(buy.tokenIds.length > 0 && uintArrayMatch(buy.tokenIds, sell.tokenIds)) &&
(sell.amounts.length == 0 || uintArrayMatch(buy.amounts, sell.amounts)) &&
(buy.paymentToken == sell.paymentToken) &&
(sell.taker == address(0) || sell.taker == buy.maker) &&
(buy.taker == address(0) || buy.taker == sell.maker) &&
((sell.feeRecipient == address(0) && buy.feeRecipient != address(0)) ||
(sell.feeRecipient != address(0) && buy.feeRecipient == address(0))) &&
(buy.mintFactory == sell.mintFactory) &&
(buy.collection == sell.collection) &&
canSettleOrder(buy.listingTime, buy.expirationTime) &&
canSettleOrder(sell.listingTime, sell.expirationTime));
}
function canMint(
address minter,
address factory,
address collection
) internal view returns (bool) {
bool allowed = IFactory(factory).canMint(collection, minter);
return allowed;
}
function atomicMatch(
Order memory buy,
bytes memory buySig,
Order memory sell,
bytes memory sellSig,
bytes32 metadata
) internal nonReentrant {
bytes32 buyHash;
if (buy.maker == msg.sender) {
if (!validateOrderParameters(buy)) revert InvalidOrderParameters();
} else {
buyHash = _requireValidOrderWithNonce(buy, buySig);
}
bytes32 sellHash;
if (sell.maker == msg.sender) {
if (!validateOrderParameters(sell)) revert InvalidOrderParameters();
} else {
sellHash = _requireValidOrderWithNonce(sell, sellSig);
}
if (!ordersCanMatch(buy, sell)) revert NonMatchableOrders();
address target = sell.mintFactory;
if (target != address(0)) {
if (!canMint(sell.maker, sell.mintFactory, sell.collection)) revert NotAuthorized();
} else {
target = sell.collection;
}
if (!Address.isContract(target)) revert InvalidTarget();
if (msg.sender != buy.maker) {
cancelledOrFinalized[buyHash] = true;
}
if (msg.sender != sell.maker) {
cancelledOrFinalized[sellHash] = true;
}
uint256 price = executeFundsTransfer(buy, sell);
executeTokensTransfer(buy, sell);
emit OrdersMatched(
buyHash,
sellHash,
sell.feeRecipient != address(0) ? sell.maker : buy.maker,
sell.feeRecipient != address(0) ? buy.maker : sell.maker,
price,
metadata
);
}
function _requireValidOrderWithNonce(Order memory order, bytes memory signature) internal view returns (bytes32) {
return requireValidOrder(order, signature, nonces[order.maker]);
}
function getMintRecipient(address collection) public view returns (address) {
address recipient = mintFeeRecipient[collection];
if (recipient != address(0)) return recipient;
recipient = mintFeeRecipient[address(0)];
if (recipient != address(0)) return recipient;
return protocolFeeRecipient;
}
}
文件 5 的 19:IERC1155.sol
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
interface IERC1155 is IERC165 {
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] values
);
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
event URI(string value, uint256 indexed id);
function balanceOf(address account, uint256 id) external view returns (uint256);
function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
external
view
returns (uint256[] memory);
function setApprovalForAll(address operator, bool approved) external;
function isApprovedForAll(address account, address operator) external view returns (bool);
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes calldata data
) external;
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytes calldata data
) external;
}
文件 6 的 19:IERC1271.sol
pragma solidity ^0.8.0;
interface IERC1271 {
function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);
}
文件 7 的 19:IERC165.sol
pragma solidity ^0.8.0;
interface IERC165 {
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
文件 8 的 19:IERC20.sol
pragma solidity ^0.8.0;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
文件 9 的 19:IERC721.sol
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
interface IERC721 is IERC165 {
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
function balanceOf(address owner) external view returns (uint256 balance);
function ownerOf(uint256 tokenId) external view returns (address owner);
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
function approve(address to, uint256 tokenId) external;
function setApprovalForAll(address operator, bool _approved) external;
function getApproved(uint256 tokenId) external view returns (address operator);
function isApprovedForAll(address owner, address operator) external view returns (bool);
}
文件 10 的 19:IFactory.sol
pragma solidity ^0.8.0;
interface IFactory {
function canMint(address collection, address account) external view returns (bool);
}
interface IERC721Factory {
function mint(
address to,
uint256 id,
bytes memory data
) external;
function mintBatch(
address to,
uint256[] memory ids,
bytes memory data
) external;
}
interface IERC1155Factory {
function mint(
address to,
uint256 id,
uint256 amount,
bytes memory data
) external;
function mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) external;
}
文件 11 的 19:KompeteMarketplace.sol
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "./exchange/ExchangeCore.sol";
contract KompeteMarketplace is ExchangeCore, Ownable, Pausable {
string public constant NAME = "Kompete Marketplace";
string public constant VERSION = "1.0";
string public constant CODENAME = "Late rabbit";
event ProtocolFeeRecipientChanged(address indexed recipient);
event MintFeeRecipientChanged(address indexed collection, address indexed recipient);
event CollectionAdded(address indexed collection);
event CollectionRemoved(address indexed collection);
constructor(IERC20 tokenAddress, address protocolFeeAddress) EIP712(NAME, VERSION) {
exchangeToken = tokenAddress;
protocolFeeRecipient = protocolFeeAddress;
}
function setProtocolFeeRecipient(address recipient) external onlyOwner {
protocolFeeRecipient = recipient;
emit ProtocolFeeRecipientChanged(recipient);
}
function setMintFeeRecipient(address collection, address recipient) external onlyOwner {
mintFeeRecipient[collection] = recipient;
emit MintFeeRecipientChanged(collection, recipient);
}
function toggleCollection(address collection, bool allowed) external onlyOwner {
if (collection == address(0)) revert InvalidCollection();
if (allowedCollections[collection] != allowed) {
allowedCollections[collection] = allowed;
if (allowed) emit CollectionAdded(collection);
else emit CollectionRemoved(collection);
}
}
function hashOrder_(Order memory order) public view returns (bytes32) {
return hashOrder(order, nonces[order.maker]);
}
function hashToSign_(Order memory order) public view returns (bytes32) {
return hashToSign(order, nonces[order.maker]);
}
function validateOrderParameters_(Order memory order) public view returns (bool) {
return validateOrderParameters(order);
}
function validateOrder_(Order memory order, bytes memory signature) public view returns (bool) {
return validateOrder(hashToSign(order, nonces[order.maker]), order, signature);
}
function approveOrder_(Order memory order, bool orderbookInclusionDesired) external whenNotPaused {
return approveOrder(order, orderbookInclusionDesired);
}
function cancelOrder_(Order memory order, bytes memory signature) external whenNotPaused {
return cancelOrder(order, signature, nonces[order.maker]);
}
function cancelOrderWithNonce_(
Order memory order,
bytes memory signature,
uint256 nonce
) external {
return cancelOrder(order, signature, nonce);
}
function ordersCanMatch_(Order memory buy, Order memory sell) public view returns (bool) {
return ordersCanMatch(buy, sell);
}
function atomicMatch_(
Order memory buy,
bytes memory buySig,
Order memory sell,
bytes memory sellSig,
bytes32 metadata
) external payable whenNotPaused {
atomicMatch(buy, buySig, sell, sellSig, metadata);
}
function pause() external onlyOwner {
_pause();
}
function unpause() external onlyOwner {
_unpause();
}
}
文件 12 的 19:Ownable.sol
pragma solidity ^0.8.0;
import "../utils/Context.sol";
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
_transferOwnership(_msgSender());
}
function owner() public view virtual returns (address) {
return _owner;
}
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
文件 13 的 19:Pausable.sol
pragma solidity ^0.8.0;
import "../utils/Context.sol";
abstract contract Pausable is Context {
event Paused(address account);
event Unpaused(address account);
bool private _paused;
constructor() {
_paused = false;
}
function paused() public view virtual returns (bool) {
return _paused;
}
modifier whenNotPaused() {
require(!paused(), "Pausable: paused");
_;
}
modifier whenPaused() {
require(paused(), "Pausable: not paused");
_;
}
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
文件 14 的 19:ReentrancyGuard.sol
pragma solidity ^0.8.0;
abstract contract ReentrancyGuard {
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
modifier nonReentrant() {
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
_status = _ENTERED;
_;
_status = _NOT_ENTERED;
}
}
文件 15 的 19:SafeERC20.sol
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../../../utils/Address.sol";
library SafeERC20 {
using Address for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
function _callOptionalReturn(IERC20 token, bytes memory data) private {
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
文件 16 的 19:SafeMath.sol
pragma solidity ^0.8.0;
library SafeMath {
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
文件 17 的 19:SignatureChecker.sol
pragma solidity ^0.8.0;
import "./ECDSA.sol";
import "../Address.sol";
import "../../interfaces/IERC1271.sol";
library SignatureChecker {
function isValidSignatureNow(
address signer,
bytes32 hash,
bytes memory signature
) internal view returns (bool) {
(address recovered, ECDSA.RecoverError error) = ECDSA.tryRecover(hash, signature);
if (error == ECDSA.RecoverError.NoError && recovered == signer) {
return true;
}
(bool success, bytes memory result) = signer.staticcall(
abi.encodeWithSelector(IERC1271.isValidSignature.selector, hash, signature)
);
return (success && result.length == 32 && abi.decode(result, (bytes4)) == IERC1271.isValidSignature.selector);
}
}
文件 18 的 19:Strings.sol
pragma solidity ^0.8.0;
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
function toString(uint256 value) internal pure returns (string memory) {
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);
}
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);
}
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);
}
}
文件 19 的 19:draft-EIP712.sol
pragma solidity ^0.8.0;
import "./ECDSA.sol";
abstract contract EIP712 {
bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;
uint256 private immutable _CACHED_CHAIN_ID;
address private immutable _CACHED_THIS;
bytes32 private immutable _HASHED_NAME;
bytes32 private immutable _HASHED_VERSION;
bytes32 private immutable _TYPE_HASH;
constructor(string memory name, string memory version) {
bytes32 hashedName = keccak256(bytes(name));
bytes32 hashedVersion = keccak256(bytes(version));
bytes32 typeHash = keccak256(
"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
);
_HASHED_NAME = hashedName;
_HASHED_VERSION = hashedVersion;
_CACHED_CHAIN_ID = block.chainid;
_CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);
_CACHED_THIS = address(this);
_TYPE_HASH = typeHash;
}
function _domainSeparatorV4() internal view returns (bytes32) {
if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {
return _CACHED_DOMAIN_SEPARATOR;
} else {
return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);
}
}
function _buildDomainSeparator(
bytes32 typeHash,
bytes32 nameHash,
bytes32 versionHash
) private view returns (bytes32) {
return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));
}
function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);
}
}
{
"compilationTarget": {
"contracts/KompeteMarketplace.sol": "KompeteMarketplace"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs",
"useLiteralContent": true
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"contract IERC20","name":"tokenAddress","type":"address"},{"internalType":"address","name":"protocolFeeAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AlreadyApproved","type":"error"},{"inputs":[],"name":"InvalidCollection","type":"error"},{"inputs":[],"name":"InvalidOrder","type":"error"},{"inputs":[],"name":"InvalidOrderParameters","type":"error"},{"inputs":[],"name":"InvalidSender","type":"error"},{"inputs":[],"name":"InvalidTarget","type":"error"},{"inputs":[],"name":"NonMatchableOrders","type":"error"},{"inputs":[],"name":"NotAuthorized","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"collection","type":"address"}],"name":"CollectionAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"collection","type":"address"}],"name":"CollectionRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"collection","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"}],"name":"MintFeeRecipientChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"maker","type":"address"},{"indexed":false,"internalType":"uint256","name":"newNonce","type":"uint256"}],"name":"NonceIncremented","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"hash","type":"bytes32"},{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"makerProtocolFee","type":"uint256"},{"internalType":"uint256","name":"takerProtocolFee","type":"uint256"},{"internalType":"address","name":"feeRecipient","type":"address"},{"internalType":"enum ExchangeCore.OrderSide","name":"side","type":"uint8"},{"internalType":"enum ExchangeCore.CollectionType","name":"collectionType","type":"uint8"},{"internalType":"address","name":"mintFactory","type":"address"},{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"uint256","name":"basePrice","type":"uint256"},{"internalType":"uint256","name":"extra","type":"uint256"},{"internalType":"uint256","name":"listingTime","type":"uint256"},{"internalType":"uint256","name":"expirationTime","type":"uint256"},{"internalType":"uint256","name":"salt","type":"uint256"}],"indexed":false,"internalType":"struct ExchangeCore.Order","name":"order","type":"tuple"},{"indexed":false,"internalType":"bool","name":"orderbookInclusionDesired","type":"bool"}],"name":"OrderApproved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"hash","type":"bytes32"}],"name":"OrderCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"buyHash","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"sellHash","type":"bytes32"},{"indexed":true,"internalType":"address","name":"maker","type":"address"},{"indexed":true,"internalType":"address","name":"taker","type":"address"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":true,"internalType":"bytes32","name":"metadata","type":"bytes32"}],"name":"OrdersMatched","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"}],"name":"ProtocolFeeRecipientChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"CODENAME","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"INVERSE_BASIS_POINT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NAME","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"allowedCollections","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"makerProtocolFee","type":"uint256"},{"internalType":"uint256","name":"takerProtocolFee","type":"uint256"},{"internalType":"address","name":"feeRecipient","type":"address"},{"internalType":"enum ExchangeCore.OrderSide","name":"side","type":"uint8"},{"internalType":"enum ExchangeCore.CollectionType","name":"collectionType","type":"uint8"},{"internalType":"address","name":"mintFactory","type":"address"},{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"uint256","name":"basePrice","type":"uint256"},{"internalType":"uint256","name":"extra","type":"uint256"},{"internalType":"uint256","name":"listingTime","type":"uint256"},{"internalType":"uint256","name":"expirationTime","type":"uint256"},{"internalType":"uint256","name":"salt","type":"uint256"}],"internalType":"struct ExchangeCore.Order","name":"order","type":"tuple"},{"internalType":"bool","name":"orderbookInclusionDesired","type":"bool"}],"name":"approveOrder_","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"hash","type":"bytes32"}],"name":"approvedOrders","outputs":[{"internalType":"bool","name":"approved","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"makerProtocolFee","type":"uint256"},{"internalType":"uint256","name":"takerProtocolFee","type":"uint256"},{"internalType":"address","name":"feeRecipient","type":"address"},{"internalType":"enum ExchangeCore.OrderSide","name":"side","type":"uint8"},{"internalType":"enum ExchangeCore.CollectionType","name":"collectionType","type":"uint8"},{"internalType":"address","name":"mintFactory","type":"address"},{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"uint256","name":"basePrice","type":"uint256"},{"internalType":"uint256","name":"extra","type":"uint256"},{"internalType":"uint256","name":"listingTime","type":"uint256"},{"internalType":"uint256","name":"expirationTime","type":"uint256"},{"internalType":"uint256","name":"salt","type":"uint256"}],"internalType":"struct ExchangeCore.Order","name":"buy","type":"tuple"},{"internalType":"bytes","name":"buySig","type":"bytes"},{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"makerProtocolFee","type":"uint256"},{"internalType":"uint256","name":"takerProtocolFee","type":"uint256"},{"internalType":"address","name":"feeRecipient","type":"address"},{"internalType":"enum ExchangeCore.OrderSide","name":"side","type":"uint8"},{"internalType":"enum ExchangeCore.CollectionType","name":"collectionType","type":"uint8"},{"internalType":"address","name":"mintFactory","type":"address"},{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"uint256","name":"basePrice","type":"uint256"},{"internalType":"uint256","name":"extra","type":"uint256"},{"internalType":"uint256","name":"listingTime","type":"uint256"},{"internalType":"uint256","name":"expirationTime","type":"uint256"},{"internalType":"uint256","name":"salt","type":"uint256"}],"internalType":"struct ExchangeCore.Order","name":"sell","type":"tuple"},{"internalType":"bytes","name":"sellSig","type":"bytes"},{"internalType":"bytes32","name":"metadata","type":"bytes32"}],"name":"atomicMatch_","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"makerProtocolFee","type":"uint256"},{"internalType":"uint256","name":"takerProtocolFee","type":"uint256"},{"internalType":"address","name":"feeRecipient","type":"address"},{"internalType":"enum ExchangeCore.OrderSide","name":"side","type":"uint8"},{"internalType":"enum ExchangeCore.CollectionType","name":"collectionType","type":"uint8"},{"internalType":"address","name":"mintFactory","type":"address"},{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"uint256","name":"basePrice","type":"uint256"},{"internalType":"uint256","name":"extra","type":"uint256"},{"internalType":"uint256","name":"listingTime","type":"uint256"},{"internalType":"uint256","name":"expirationTime","type":"uint256"},{"internalType":"uint256","name":"salt","type":"uint256"}],"internalType":"struct ExchangeCore.Order","name":"order","type":"tuple"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"cancelOrderWithNonce_","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"makerProtocolFee","type":"uint256"},{"internalType":"uint256","name":"takerProtocolFee","type":"uint256"},{"internalType":"address","name":"feeRecipient","type":"address"},{"internalType":"enum ExchangeCore.OrderSide","name":"side","type":"uint8"},{"internalType":"enum ExchangeCore.CollectionType","name":"collectionType","type":"uint8"},{"internalType":"address","name":"mintFactory","type":"address"},{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"uint256","name":"basePrice","type":"uint256"},{"internalType":"uint256","name":"extra","type":"uint256"},{"internalType":"uint256","name":"listingTime","type":"uint256"},{"internalType":"uint256","name":"expirationTime","type":"uint256"},{"internalType":"uint256","name":"salt","type":"uint256"}],"internalType":"struct ExchangeCore.Order","name":"order","type":"tuple"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"cancelOrder_","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"cancelledOrFinalized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"exchangeToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"collection","type":"address"}],"name":"getMintRecipient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"makerProtocolFee","type":"uint256"},{"internalType":"uint256","name":"takerProtocolFee","type":"uint256"},{"internalType":"address","name":"feeRecipient","type":"address"},{"internalType":"enum ExchangeCore.OrderSide","name":"side","type":"uint8"},{"internalType":"enum ExchangeCore.CollectionType","name":"collectionType","type":"uint8"},{"internalType":"address","name":"mintFactory","type":"address"},{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"uint256","name":"basePrice","type":"uint256"},{"internalType":"uint256","name":"extra","type":"uint256"},{"internalType":"uint256","name":"listingTime","type":"uint256"},{"internalType":"uint256","name":"expirationTime","type":"uint256"},{"internalType":"uint256","name":"salt","type":"uint256"}],"internalType":"struct ExchangeCore.Order","name":"order","type":"tuple"}],"name":"hashOrder_","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"makerProtocolFee","type":"uint256"},{"internalType":"uint256","name":"takerProtocolFee","type":"uint256"},{"internalType":"address","name":"feeRecipient","type":"address"},{"internalType":"enum ExchangeCore.OrderSide","name":"side","type":"uint8"},{"internalType":"enum ExchangeCore.CollectionType","name":"collectionType","type":"uint8"},{"internalType":"address","name":"mintFactory","type":"address"},{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"uint256","name":"basePrice","type":"uint256"},{"internalType":"uint256","name":"extra","type":"uint256"},{"internalType":"uint256","name":"listingTime","type":"uint256"},{"internalType":"uint256","name":"expirationTime","type":"uint256"},{"internalType":"uint256","name":"salt","type":"uint256"}],"internalType":"struct ExchangeCore.Order","name":"order","type":"tuple"}],"name":"hashToSign_","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"incrementNonce","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"makerProtocolFee","type":"uint256"},{"internalType":"uint256","name":"takerProtocolFee","type":"uint256"},{"internalType":"address","name":"feeRecipient","type":"address"},{"internalType":"enum ExchangeCore.OrderSide","name":"side","type":"uint8"},{"internalType":"enum ExchangeCore.CollectionType","name":"collectionType","type":"uint8"},{"internalType":"address","name":"mintFactory","type":"address"},{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"uint256","name":"basePrice","type":"uint256"},{"internalType":"uint256","name":"extra","type":"uint256"},{"internalType":"uint256","name":"listingTime","type":"uint256"},{"internalType":"uint256","name":"expirationTime","type":"uint256"},{"internalType":"uint256","name":"salt","type":"uint256"}],"internalType":"struct ExchangeCore.Order","name":"buy","type":"tuple"},{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"makerProtocolFee","type":"uint256"},{"internalType":"uint256","name":"takerProtocolFee","type":"uint256"},{"internalType":"address","name":"feeRecipient","type":"address"},{"internalType":"enum ExchangeCore.OrderSide","name":"side","type":"uint8"},{"internalType":"enum ExchangeCore.CollectionType","name":"collectionType","type":"uint8"},{"internalType":"address","name":"mintFactory","type":"address"},{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"uint256","name":"basePrice","type":"uint256"},{"internalType":"uint256","name":"extra","type":"uint256"},{"internalType":"uint256","name":"listingTime","type":"uint256"},{"internalType":"uint256","name":"expirationTime","type":"uint256"},{"internalType":"uint256","name":"salt","type":"uint256"}],"internalType":"struct ExchangeCore.Order","name":"sell","type":"tuple"}],"name":"ordersCanMatch_","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"protocolFeeRecipient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"collection","type":"address"},{"internalType":"address","name":"recipient","type":"address"}],"name":"setMintFeeRecipient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"}],"name":"setProtocolFeeRecipient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"collection","type":"address"},{"internalType":"bool","name":"allowed","type":"bool"}],"name":"toggleCollection","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"makerProtocolFee","type":"uint256"},{"internalType":"uint256","name":"takerProtocolFee","type":"uint256"},{"internalType":"address","name":"feeRecipient","type":"address"},{"internalType":"enum ExchangeCore.OrderSide","name":"side","type":"uint8"},{"internalType":"enum ExchangeCore.CollectionType","name":"collectionType","type":"uint8"},{"internalType":"address","name":"mintFactory","type":"address"},{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"uint256","name":"basePrice","type":"uint256"},{"internalType":"uint256","name":"extra","type":"uint256"},{"internalType":"uint256","name":"listingTime","type":"uint256"},{"internalType":"uint256","name":"expirationTime","type":"uint256"},{"internalType":"uint256","name":"salt","type":"uint256"}],"internalType":"struct ExchangeCore.Order","name":"order","type":"tuple"}],"name":"validateOrderParameters_","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"maker","type":"address"},{"internalType":"address","name":"taker","type":"address"},{"internalType":"uint256","name":"makerProtocolFee","type":"uint256"},{"internalType":"uint256","name":"takerProtocolFee","type":"uint256"},{"internalType":"address","name":"feeRecipient","type":"address"},{"internalType":"enum ExchangeCore.OrderSide","name":"side","type":"uint8"},{"internalType":"enum ExchangeCore.CollectionType","name":"collectionType","type":"uint8"},{"internalType":"address","name":"mintFactory","type":"address"},{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"uint256","name":"basePrice","type":"uint256"},{"internalType":"uint256","name":"extra","type":"uint256"},{"internalType":"uint256","name":"listingTime","type":"uint256"},{"internalType":"uint256","name":"expirationTime","type":"uint256"},{"internalType":"uint256","name":"salt","type":"uint256"}],"internalType":"struct ExchangeCore.Order","name":"order","type":"tuple"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"validateOrder_","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]