编译器
0.8.17+commit.8df45f5f
文件 1 的 13: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 functionCallWithValue(target, data, 0, "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");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, 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) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, 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) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
文件 2 的 13:BaseExchangeModule.sol
pragma solidity ^0.8.9;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import {BaseModule} from "../BaseModule.sol";
abstract contract BaseExchangeModule is BaseModule {
using SafeERC20 for IERC20;
struct ETHListingParams {
address fillTo;
address refundTo;
bool revertIfIncomplete;
uint256 amount;
}
struct ERC20ListingParams {
address fillTo;
address refundTo;
bool revertIfIncomplete;
IERC20 token;
uint256 amount;
}
struct OfferParams {
address fillTo;
address refundTo;
bool revertIfIncomplete;
}
struct Fee {
address recipient;
uint256 amount;
}
address public immutable router;
error UnsuccessfulFill();
constructor(address routerAddress) {
router = routerAddress;
}
modifier refundETHLeftover(address refundTo) {
_;
uint256 leftover = address(this).balance;
if (leftover > 0) {
_sendETH(refundTo, leftover);
}
}
modifier refundERC20Leftover(address refundTo, IERC20 token) {
_;
uint256 leftover = token.balanceOf(address(this));
if (leftover > 0) {
token.safeTransfer(refundTo, leftover);
}
}
modifier chargeETHFees(Fee[] calldata fees, uint256 amount) {
if (fees.length == 0) {
_;
} else {
uint256 balanceBefore = address(this).balance;
_;
uint256 length = fees.length;
if (length > 0) {
uint256 balanceAfter = address(this).balance;
uint256 actualPaid = balanceBefore - balanceAfter;
uint256 actualFee;
for (uint256 i = 0; i < length; ) {
actualFee = (fees[i].amount * actualPaid) / amount;
if (actualFee > 0) {
_sendETH(fees[i].recipient, actualFee);
}
unchecked {
++i;
}
}
}
}
}
modifier chargeERC20Fees(
Fee[] calldata fees,
IERC20 token,
uint256 amount
) {
if (fees.length == 0) {
_;
} else {
uint256 balanceBefore = token.balanceOf(address(this));
_;
uint256 length = fees.length;
if (length > 0) {
uint256 balanceAfter = token.balanceOf(address(this));
uint256 actualPaid = balanceBefore - balanceAfter;
uint256 actualFee;
for (uint256 i = 0; i < length; ) {
actualFee = (fees[i].amount * actualPaid) / amount;
if (actualFee > 0) {
token.safeTransfer(fees[i].recipient, actualFee);
}
unchecked {
++i;
}
}
}
}
}
function _sendAllETH(address to) internal {
_sendETH(to, address(this).balance);
}
function _sendAllERC20(address to, IERC20 token) internal {
uint256 balance = token.balanceOf(address(this));
if (balance > 0) {
token.safeTransfer(to, balance);
}
}
function _sendAllERC721(address to, IERC721 token, uint256 tokenId) internal {
if (token.ownerOf(tokenId) == address(this)) {
token.safeTransferFrom(address(this), to, tokenId);
}
}
function _sendAllERC1155(address to, IERC1155 token, uint256 tokenId) internal {
uint256 balance = token.balanceOf(address(this), tokenId);
if (balance > 0) {
token.safeTransferFrom(address(this), to, tokenId, balance, "");
}
}
function _approveERC20IfNeeded(IERC20 token, address spender, uint256 amount) internal {
uint256 allowance = token.allowance(address(this), spender);
if (allowance < amount) {
if (allowance > 0) {
_approveERC20(address(token), spender, 0);
}
_approveERC20(address(token), spender, amount);
}
}
function _approveERC721IfNeeded(IERC721 token, address operator) internal {
bool isApproved = token.isApprovedForAll(address(this), operator);
if (!isApproved) {
token.setApprovalForAll(operator, true);
}
}
function _approveERC1155IfNeeded(IERC1155 token, address operator) internal {
bool isApproved = token.isApprovedForAll(address(this), operator);
if (!isApproved) {
token.setApprovalForAll(operator, true);
}
}
function _approveERC20(address token, address spender, uint256 amount) internal {
(bool success, ) = token.call(
abi.encodeWithSignature("approve(address,uint256)", spender, amount)
);
if (!success) {
revert UnsuccessfulFill();
}
}
}
文件 3 的 13:BaseModule.sol
pragma solidity ^0.8.9;
import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {TwoStepOwnable} from "../../misc/TwoStepOwnable.sol";
abstract contract BaseModule is TwoStepOwnable, ReentrancyGuard {
using SafeERC20 for IERC20;
event CallExecuted(address target, bytes data, uint256 value);
error UnsuccessfulCall();
error UnsuccessfulPayment();
error WrongParams();
constructor(address owner) TwoStepOwnable(owner) {}
function makeCalls(
address[] calldata targets,
bytes[] calldata data,
uint256[] calldata values
) external payable onlyOwner nonReentrant {
uint256 length = targets.length;
for (uint256 i = 0; i < length; ) {
_makeCall(targets[i], data[i], values[i]);
emit CallExecuted(targets[i], data[i], values[i]);
unchecked {
++i;
}
}
}
function _sendETH(address to, uint256 amount) internal {
if (amount > 0) {
(bool success, ) = payable(to).call{value: amount}("");
if (!success) {
revert UnsuccessfulPayment();
}
}
}
function _sendERC20(
address to,
uint256 amount,
IERC20 token
) internal {
if (amount > 0) {
token.safeTransfer(to, amount);
}
}
function _makeCall(
address target,
bytes memory data,
uint256 value
) internal {
(bool success, ) = payable(target).call{value: value}(data);
if (!success) {
revert UnsuccessfulCall();
}
}
}
文件 4 的 13: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;
}
文件 5 的 13:IERC165.sol
pragma solidity ^0.8.0;
interface IERC165 {
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
文件 6 的 13: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);
}
文件 7 的 13:IERC20Permit.sol
pragma solidity ^0.8.0;
interface IERC20Permit {
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
function nonces(address owner) external view returns (uint256);
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
文件 8 的 13: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);
}
文件 9 的 13:IX2Y2.sol
pragma solidity ^0.8.9;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
interface IX2Y2 {
struct OrderItem {
uint256 price;
bytes data;
}
struct ERC721Pair {
IERC721 token;
uint256 tokenId;
}
struct ERC1155Pair {
IERC1155 token;
uint256 tokenId;
uint256 amount;
}
struct Order {
uint256 salt;
address user;
uint256 network;
uint256 intent;
uint256 delegateType;
uint256 deadline;
IERC20 currency;
bytes dataMask;
OrderItem[] items;
bytes32 r;
bytes32 s;
uint8 v;
uint8 signVersion;
}
struct SettleShared {
uint256 salt;
uint256 deadline;
uint256 amountToEth;
uint256 amountToWeth;
address user;
bool canFail;
}
struct Fee {
uint256 percentage;
address to;
}
enum Op {
INVALID,
COMPLETE_SELL_OFFER,
COMPLETE_BUY_OFFER,
CANCEL_OFFER,
BID,
COMPLETE_AUCTION,
REFUND_AUCTION,
REFUND_AUCTION_STUCK_ITEM
}
struct SettleDetail {
Op op;
uint256 orderIdx;
uint256 itemIdx;
uint256 price;
bytes32 itemHash;
address executionDelegate;
bytes dataReplacement;
uint256 bidIncentivePct;
uint256 aucMinIncrementPct;
uint256 aucIncDurationSecs;
Fee[] fees;
}
struct RunInput {
Order[] orders;
SettleDetail[] details;
SettleShared shared;
bytes32 r;
bytes32 s;
uint8 v;
}
function run(RunInput calldata input) external payable;
}
文件 10 的 13: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() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
_status = _ENTERED;
}
function _nonReentrantAfter() private {
_status = _NOT_ENTERED;
}
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
}
文件 11 的 13:SafeERC20.sol
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/IERC20Permit.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 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
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");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
function _callOptionalReturn(IERC20 token, bytes memory data) private {
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
(bool success, bytes memory returndata) = address(token).call(data);
return
success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
}
}
文件 12 的 13:TwoStepOwnable.sol
pragma solidity ^0.8.9;
contract TwoStepOwnable {
address public owner;
address public pendingOwner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
error InvalidParams();
error Unauthorized();
modifier onlyOwner() {
if (msg.sender != owner) {
revert Unauthorized();
}
_;
}
constructor(address initialOwner) {
owner = initialOwner;
emit OwnershipTransferred(address(0), initialOwner);
}
function transferOwnership(address newOwner) public onlyOwner {
pendingOwner = newOwner;
}
function claimOwnership() public {
address _pendingOwner = pendingOwner;
if (msg.sender != _pendingOwner) {
revert Unauthorized();
}
owner = _pendingOwner;
pendingOwner = address(0);
emit OwnershipTransferred(owner, _pendingOwner);
}
}
文件 13 的 13:X2Y2Module.sol
pragma solidity ^0.8.9;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import {BaseExchangeModule} from "./BaseExchangeModule.sol";
import {BaseModule} from "../BaseModule.sol";
import {IX2Y2} from "../../../interfaces/IX2Y2.sol";
contract X2Y2Module is BaseExchangeModule {
using SafeERC20 for IERC20;
IX2Y2 public immutable EXCHANGE;
address public immutable ERC721_DELEGATE;
address public immutable ERC1155_DELEGATE;
constructor(
address owner,
address router,
address exchange,
address erc721Delegate,
address erc1155Delegate
) BaseModule(owner) BaseExchangeModule(router) {
EXCHANGE = IX2Y2(exchange);
ERC721_DELEGATE = erc721Delegate;
ERC1155_DELEGATE = erc1155Delegate;
}
receive() external payable {}
function acceptETHListing(
IX2Y2.RunInput calldata input,
ETHListingParams calldata params,
Fee[] calldata fees
)
external
payable
nonReentrant
refundETHLeftover(params.refundTo)
chargeETHFees(fees, params.amount)
{
_buy(input, params.fillTo, params.revertIfIncomplete, params.amount);
}
function acceptETHListings(
IX2Y2.RunInput[] calldata inputs,
ETHListingParams calldata params,
Fee[] calldata fees
)
external
payable
nonReentrant
refundETHLeftover(params.refundTo)
chargeETHFees(fees, params.amount)
{
uint256 length = inputs.length;
for (uint256 i = 0; i < length; ) {
_buy(inputs[i], params.fillTo, params.revertIfIncomplete, inputs[i].details[0].price);
unchecked {
++i;
}
}
}
function acceptERC721Offer(
IX2Y2.RunInput calldata input,
OfferParams calldata params,
Fee[] calldata fees
) external nonReentrant {
if (input.details.length != 1) {
revert WrongParams();
}
IX2Y2.SettleDetail calldata detail = input.details[0];
IX2Y2.Order calldata order = input.orders[detail.orderIdx];
IX2Y2.OrderItem calldata orderItem = order.items[detail.itemIdx];
if (detail.op != IX2Y2.Op.COMPLETE_BUY_OFFER) {
revert WrongParams();
}
bytes memory data = orderItem.data;
{
if (order.dataMask.length > 0 && detail.dataReplacement.length > 0) {
_arrayReplace(data, detail.dataReplacement, order.dataMask);
}
}
IX2Y2.ERC721Pair[] memory pairs = abi.decode(data, (IX2Y2.ERC721Pair[]));
if (pairs.length != 1) {
revert WrongParams();
}
IERC721 collection = pairs[0].token;
uint256 tokenId = pairs[0].tokenId;
_approveERC721IfNeeded(collection, ERC721_DELEGATE);
try EXCHANGE.run(input) {
uint256 feesLength = fees.length;
for (uint256 i; i < feesLength; ) {
Fee memory fee = fees[i];
_sendERC20(fee.recipient, fee.amount, order.currency);
unchecked {
++i;
}
}
_sendAllERC20(params.fillTo, order.currency);
} catch {
if (params.revertIfIncomplete) {
revert UnsuccessfulFill();
}
}
_sendAllERC721(params.refundTo, collection, tokenId);
}
function acceptERC1155Offer(
IX2Y2.RunInput calldata input,
OfferParams calldata params,
Fee[] calldata fees
) external nonReentrant {
if (input.details.length != 1) {
revert WrongParams();
}
IX2Y2.SettleDetail calldata detail = input.details[0];
IX2Y2.Order calldata order = input.orders[detail.orderIdx];
IX2Y2.OrderItem calldata orderItem = order.items[detail.itemIdx];
if (detail.op != IX2Y2.Op.COMPLETE_BUY_OFFER) {
revert WrongParams();
}
bytes memory data = orderItem.data;
{
if (order.dataMask.length > 0 && detail.dataReplacement.length > 0) {
_arrayReplace(data, detail.dataReplacement, order.dataMask);
}
}
IX2Y2.ERC1155Pair[] memory pairs = abi.decode(data, (IX2Y2.ERC1155Pair[]));
if (pairs.length != 1) {
revert WrongParams();
}
IERC1155 collection = pairs[0].token;
uint256 tokenId = pairs[0].tokenId;
_approveERC1155IfNeeded(collection, ERC1155_DELEGATE);
try EXCHANGE.run(input) {
uint256 feesLength = fees.length;
for (uint256 i; i < feesLength; ) {
Fee memory fee = fees[i];
_sendERC20(fee.recipient, fee.amount, order.currency);
unchecked {
++i;
}
}
_sendAllERC20(params.fillTo, order.currency);
} catch {
if (params.revertIfIncomplete) {
revert UnsuccessfulFill();
}
}
_sendAllERC1155(params.refundTo, collection, tokenId);
}
function onERC721Received(
address,
address,
uint256,
bytes calldata data
) external returns (bytes4) {
if (data.length > 0) {
_makeCall(router, data, 0);
}
return this.onERC721Received.selector;
}
function onERC1155Received(
address,
address,
uint256,
uint256,
bytes calldata data
) external returns (bytes4) {
if (data.length > 0) {
_makeCall(router, data, 0);
}
return this.onERC1155Received.selector;
}
function _arrayReplace(
bytes memory source,
bytes memory replacement,
bytes memory mask
) internal view virtual {
uint256 sourceLength = source.length;
for (uint256 i; i < sourceLength; ) {
if (mask[i] != 0) {
source[i] = replacement[i];
}
unchecked {
++i;
}
}
}
function _buy(
IX2Y2.RunInput calldata input,
address receiver,
bool revertIfIncomplete,
uint256 value
) internal {
if (input.details.length != 1) {
revert WrongParams();
}
IX2Y2.SettleDetail calldata detail = input.details[0];
IX2Y2.Order calldata order = input.orders[detail.orderIdx];
IX2Y2.OrderItem calldata orderItem = order.items[detail.itemIdx];
if (detail.op != IX2Y2.Op.COMPLETE_SELL_OFFER) {
revert WrongParams();
}
try EXCHANGE.run{value: value}(input) {
if (order.delegateType == 1) {
IX2Y2.ERC721Pair[] memory pairs = abi.decode(orderItem.data, (IX2Y2.ERC721Pair[]));
if (pairs.length != 1) {
revert WrongParams();
}
pairs[0].token.safeTransferFrom(address(this), receiver, pairs[0].tokenId);
} else {
IX2Y2.ERC1155Pair[] memory pairs = abi.decode(orderItem.data, (IX2Y2.ERC1155Pair[]));
if (pairs.length != 1) {
revert WrongParams();
}
pairs[0].token.safeTransferFrom(
address(this),
receiver,
pairs[0].tokenId,
pairs[0].amount,
""
);
}
} catch {
if (revertIfIncomplete) {
revert UnsuccessfulFill();
}
}
}
}
{
"compilationTarget": {
"contracts/router/modules/exchanges/X2Y2Module.sol": "X2Y2Module"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [],
"viaIR": true
}
[{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"router","type":"address"},{"internalType":"address","name":"exchange","type":"address"},{"internalType":"address","name":"erc721Delegate","type":"address"},{"internalType":"address","name":"erc1155Delegate","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"InvalidParams","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"inputs":[],"name":"UnsuccessfulCall","type":"error"},{"inputs":[],"name":"UnsuccessfulFill","type":"error"},{"inputs":[],"name":"UnsuccessfulPayment","type":"error"},{"inputs":[],"name":"WrongParams","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"CallExecuted","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"},{"inputs":[],"name":"ERC1155_DELEGATE","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ERC721_DELEGATE","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"EXCHANGE","outputs":[{"internalType":"contract IX2Y2","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"network","type":"uint256"},{"internalType":"uint256","name":"intent","type":"uint256"},{"internalType":"uint256","name":"delegateType","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"contract IERC20","name":"currency","type":"address"},{"internalType":"bytes","name":"dataMask","type":"bytes"},{"components":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct IX2Y2.OrderItem[]","name":"items","type":"tuple[]"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"uint8","name":"signVersion","type":"uint8"}],"internalType":"struct IX2Y2.Order[]","name":"orders","type":"tuple[]"},{"components":[{"internalType":"enum IX2Y2.Op","name":"op","type":"uint8"},{"internalType":"uint256","name":"orderIdx","type":"uint256"},{"internalType":"uint256","name":"itemIdx","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"bytes32","name":"itemHash","type":"bytes32"},{"internalType":"address","name":"executionDelegate","type":"address"},{"internalType":"bytes","name":"dataReplacement","type":"bytes"},{"internalType":"uint256","name":"bidIncentivePct","type":"uint256"},{"internalType":"uint256","name":"aucMinIncrementPct","type":"uint256"},{"internalType":"uint256","name":"aucIncDurationSecs","type":"uint256"},{"components":[{"internalType":"uint256","name":"percentage","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"internalType":"struct IX2Y2.Fee[]","name":"fees","type":"tuple[]"}],"internalType":"struct IX2Y2.SettleDetail[]","name":"details","type":"tuple[]"},{"components":[{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"amountToEth","type":"uint256"},{"internalType":"uint256","name":"amountToWeth","type":"uint256"},{"internalType":"address","name":"user","type":"address"},{"internalType":"bool","name":"canFail","type":"bool"}],"internalType":"struct IX2Y2.SettleShared","name":"shared","type":"tuple"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint8","name":"v","type":"uint8"}],"internalType":"struct IX2Y2.RunInput","name":"input","type":"tuple"},{"components":[{"internalType":"address","name":"fillTo","type":"address"},{"internalType":"address","name":"refundTo","type":"address"},{"internalType":"bool","name":"revertIfIncomplete","type":"bool"}],"internalType":"struct BaseExchangeModule.OfferParams","name":"params","type":"tuple"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct BaseExchangeModule.Fee[]","name":"fees","type":"tuple[]"}],"name":"acceptERC1155Offer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"network","type":"uint256"},{"internalType":"uint256","name":"intent","type":"uint256"},{"internalType":"uint256","name":"delegateType","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"contract IERC20","name":"currency","type":"address"},{"internalType":"bytes","name":"dataMask","type":"bytes"},{"components":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct IX2Y2.OrderItem[]","name":"items","type":"tuple[]"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"uint8","name":"signVersion","type":"uint8"}],"internalType":"struct IX2Y2.Order[]","name":"orders","type":"tuple[]"},{"components":[{"internalType":"enum IX2Y2.Op","name":"op","type":"uint8"},{"internalType":"uint256","name":"orderIdx","type":"uint256"},{"internalType":"uint256","name":"itemIdx","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"bytes32","name":"itemHash","type":"bytes32"},{"internalType":"address","name":"executionDelegate","type":"address"},{"internalType":"bytes","name":"dataReplacement","type":"bytes"},{"internalType":"uint256","name":"bidIncentivePct","type":"uint256"},{"internalType":"uint256","name":"aucMinIncrementPct","type":"uint256"},{"internalType":"uint256","name":"aucIncDurationSecs","type":"uint256"},{"components":[{"internalType":"uint256","name":"percentage","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"internalType":"struct IX2Y2.Fee[]","name":"fees","type":"tuple[]"}],"internalType":"struct IX2Y2.SettleDetail[]","name":"details","type":"tuple[]"},{"components":[{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"amountToEth","type":"uint256"},{"internalType":"uint256","name":"amountToWeth","type":"uint256"},{"internalType":"address","name":"user","type":"address"},{"internalType":"bool","name":"canFail","type":"bool"}],"internalType":"struct IX2Y2.SettleShared","name":"shared","type":"tuple"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint8","name":"v","type":"uint8"}],"internalType":"struct IX2Y2.RunInput","name":"input","type":"tuple"},{"components":[{"internalType":"address","name":"fillTo","type":"address"},{"internalType":"address","name":"refundTo","type":"address"},{"internalType":"bool","name":"revertIfIncomplete","type":"bool"}],"internalType":"struct BaseExchangeModule.OfferParams","name":"params","type":"tuple"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct BaseExchangeModule.Fee[]","name":"fees","type":"tuple[]"}],"name":"acceptERC721Offer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"network","type":"uint256"},{"internalType":"uint256","name":"intent","type":"uint256"},{"internalType":"uint256","name":"delegateType","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"contract IERC20","name":"currency","type":"address"},{"internalType":"bytes","name":"dataMask","type":"bytes"},{"components":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct IX2Y2.OrderItem[]","name":"items","type":"tuple[]"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"uint8","name":"signVersion","type":"uint8"}],"internalType":"struct IX2Y2.Order[]","name":"orders","type":"tuple[]"},{"components":[{"internalType":"enum IX2Y2.Op","name":"op","type":"uint8"},{"internalType":"uint256","name":"orderIdx","type":"uint256"},{"internalType":"uint256","name":"itemIdx","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"bytes32","name":"itemHash","type":"bytes32"},{"internalType":"address","name":"executionDelegate","type":"address"},{"internalType":"bytes","name":"dataReplacement","type":"bytes"},{"internalType":"uint256","name":"bidIncentivePct","type":"uint256"},{"internalType":"uint256","name":"aucMinIncrementPct","type":"uint256"},{"internalType":"uint256","name":"aucIncDurationSecs","type":"uint256"},{"components":[{"internalType":"uint256","name":"percentage","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"internalType":"struct IX2Y2.Fee[]","name":"fees","type":"tuple[]"}],"internalType":"struct IX2Y2.SettleDetail[]","name":"details","type":"tuple[]"},{"components":[{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"amountToEth","type":"uint256"},{"internalType":"uint256","name":"amountToWeth","type":"uint256"},{"internalType":"address","name":"user","type":"address"},{"internalType":"bool","name":"canFail","type":"bool"}],"internalType":"struct IX2Y2.SettleShared","name":"shared","type":"tuple"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint8","name":"v","type":"uint8"}],"internalType":"struct IX2Y2.RunInput","name":"input","type":"tuple"},{"components":[{"internalType":"address","name":"fillTo","type":"address"},{"internalType":"address","name":"refundTo","type":"address"},{"internalType":"bool","name":"revertIfIncomplete","type":"bool"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct BaseExchangeModule.ETHListingParams","name":"params","type":"tuple"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct BaseExchangeModule.Fee[]","name":"fees","type":"tuple[]"}],"name":"acceptETHListing","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"network","type":"uint256"},{"internalType":"uint256","name":"intent","type":"uint256"},{"internalType":"uint256","name":"delegateType","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"contract IERC20","name":"currency","type":"address"},{"internalType":"bytes","name":"dataMask","type":"bytes"},{"components":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct IX2Y2.OrderItem[]","name":"items","type":"tuple[]"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"uint8","name":"signVersion","type":"uint8"}],"internalType":"struct IX2Y2.Order[]","name":"orders","type":"tuple[]"},{"components":[{"internalType":"enum IX2Y2.Op","name":"op","type":"uint8"},{"internalType":"uint256","name":"orderIdx","type":"uint256"},{"internalType":"uint256","name":"itemIdx","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"bytes32","name":"itemHash","type":"bytes32"},{"internalType":"address","name":"executionDelegate","type":"address"},{"internalType":"bytes","name":"dataReplacement","type":"bytes"},{"internalType":"uint256","name":"bidIncentivePct","type":"uint256"},{"internalType":"uint256","name":"aucMinIncrementPct","type":"uint256"},{"internalType":"uint256","name":"aucIncDurationSecs","type":"uint256"},{"components":[{"internalType":"uint256","name":"percentage","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"internalType":"struct IX2Y2.Fee[]","name":"fees","type":"tuple[]"}],"internalType":"struct IX2Y2.SettleDetail[]","name":"details","type":"tuple[]"},{"components":[{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"amountToEth","type":"uint256"},{"internalType":"uint256","name":"amountToWeth","type":"uint256"},{"internalType":"address","name":"user","type":"address"},{"internalType":"bool","name":"canFail","type":"bool"}],"internalType":"struct IX2Y2.SettleShared","name":"shared","type":"tuple"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint8","name":"v","type":"uint8"}],"internalType":"struct IX2Y2.RunInput[]","name":"inputs","type":"tuple[]"},{"components":[{"internalType":"address","name":"fillTo","type":"address"},{"internalType":"address","name":"refundTo","type":"address"},{"internalType":"bool","name":"revertIfIncomplete","type":"bool"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct BaseExchangeModule.ETHListingParams","name":"params","type":"tuple"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct BaseExchangeModule.Fee[]","name":"fees","type":"tuple[]"}],"name":"acceptETHListings","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"targets","type":"address[]"},{"internalType":"bytes[]","name":"data","type":"bytes[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"makeCalls","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"router","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]