diff --git a/packages/marketplace/contracts/exchange/AssetMatcher.sol b/packages/marketplace/contracts/exchange/AssetMatcher.sol index 58e51513f1..a02c19e1c5 100644 --- a/packages/marketplace/contracts/exchange/AssetMatcher.sol +++ b/packages/marketplace/contracts/exchange/AssetMatcher.sol @@ -46,12 +46,8 @@ contract AssetMatcher is Ownable, IAssetMatcher { ) private view returns (LibAsset.AssetType memory) { bytes4 classLeft = leftAssetType.assetClass; bytes4 classRight = rightAssetType.assetClass; - if (classLeft == LibAsset.ETH_ASSET_CLASS) { - if (classRight == LibAsset.ETH_ASSET_CLASS) { - return leftAssetType; - } - return LibAsset.AssetType(0, EMPTY); - } + require(classLeft != LibAsset.ETH_ASSET_CLASS, "maker cannot transfer native token"); + require(classRight != LibAsset.ETH_ASSET_CLASS, "taker cannot transfer native token"); if (classLeft == LibAsset.ERC20_ASSET_CLASS) { if (classRight == LibAsset.ERC20_ASSET_CLASS) { return simpleMatch(leftAssetType, rightAssetType); diff --git a/packages/marketplace/contracts/exchange/Exchange.sol b/packages/marketplace/contracts/exchange/Exchange.sol index 4f36889266..df3f8b23d0 100644 --- a/packages/marketplace/contracts/exchange/Exchange.sol +++ b/packages/marketplace/contracts/exchange/Exchange.sol @@ -36,8 +36,6 @@ contract Exchange is Initializable, AccessControlUpgradeable, ExchangeCore, Tran /// @param newRoyaltiesProvider registry for the different types of royalties /// @param orderValidatorAddress new OrderValidator contract address /// @param newAssetMatcher new AssetMatcher contract address - /// @param newNativeOrder bool to indicate of the contract accepts or doesn't native tokens, i.e. ETH or Matic - /// @param newMetaNative same as =nativeOrder but for metaTransactions // solhint-disable-next-line func-name-mixedcase function __Exchange_init( address admin, @@ -47,9 +45,7 @@ contract Exchange is Initializable, AccessControlUpgradeable, ExchangeCore, Tran address newDefaultFeeReceiver, IRoyaltiesProvider newRoyaltiesProvider, IOrderValidator orderValidatorAddress, - IAssetMatcher newAssetMatcher, - bool newNativeOrder, - bool newMetaNative + IAssetMatcher newAssetMatcher ) external initializer { __ERC2771Handler_init(newTrustedForwarder); __AccessControl_init(); @@ -59,7 +55,7 @@ contract Exchange is Initializable, AccessControlUpgradeable, ExchangeCore, Tran newDefaultFeeReceiver, newRoyaltiesProvider ); - __ExchangeCoreInitialize(newNativeOrder, newMetaNative, orderValidatorAddress, newAssetMatcher); + __ExchangeCoreInitialize(orderValidatorAddress, newAssetMatcher); _grantRole(DEFAULT_ADMIN_ROLE, admin); } @@ -140,14 +136,6 @@ contract Exchange is Initializable, AccessControlUpgradeable, ExchangeCore, Tran _setOrderValidatorContract(contractAddress); } - /// @notice update permissions for native orders - /// @param newNativeOrder for orders with native token - /// @param newMetaNative for meta orders with native token - /// @dev setter for permissions for native token exchange - function updateNative(bool newNativeOrder, bool newMetaNative) external onlyRole(DEFAULT_ADMIN_ROLE) { - _updateNative(newNativeOrder, newMetaNative); - } - /// @notice Change the address of the trusted forwarder for meta-transactions /// @param newTrustedForwarder The new trustedForwarder function setTrustedForwarder(address newTrustedForwarder) external virtual onlyRole(DEFAULT_ADMIN_ROLE) { diff --git a/packages/marketplace/contracts/exchange/ExchangeCore.sol b/packages/marketplace/contracts/exchange/ExchangeCore.sol index d799ac7b28..ca9e6cb5d2 100644 --- a/packages/marketplace/contracts/exchange/ExchangeCore.sol +++ b/packages/marketplace/contracts/exchange/ExchangeCore.sol @@ -28,14 +28,6 @@ abstract contract ExchangeCore is Initializable, TransferExecutor, ITransferMana uint256 private constant UINT256_MAX = type(uint256).max; - /// @notice boolean to indicate if native tokens are accepted for meta transactions - /// @return true if native tokens are accepted for meta tx, false otherwise - bool public nativeMeta; - - /// @notice boolean to indicate if native tokens are accepted - /// @return true if native tokens are accepted, false otherwise - bool public nativeOrder; - /// @notice stores the fills for orders /// @return order fill mapping(bytes32 => uint256) public fills; @@ -64,22 +56,16 @@ abstract contract ExchangeCore is Initializable, TransferExecutor, ITransferMana ); event AssetMatcherSet(IAssetMatcher indexed contractAddress); event OrderValidatorSet(IOrderValidator indexed contractAddress); - event NativeUpdated(bool nativeOrder, bool metaNative); /// @notice initializer for ExchangeCore - /// @param newNativeOrder for orders with native token - /// @param newMetaNative for meta orders with native token /// @param newOrderValidatorAddress new OrderValidator contract address /// @param newAssetMatcher new AssetMatcher contract address /// @dev initialize permissions for native token exchange // solhint-disable-next-line func-name-mixedcase function __ExchangeCoreInitialize( - bool newNativeOrder, - bool newMetaNative, IOrderValidator newOrderValidatorAddress, IAssetMatcher newAssetMatcher ) internal { - _updateNative(newMetaNative, newNativeOrder); _setOrderValidatorContract(newOrderValidatorAddress); _setAssetMatcherContract(newAssetMatcher); } @@ -101,16 +87,6 @@ abstract contract ExchangeCore is Initializable, TransferExecutor, ITransferMana emit OrderValidatorSet(contractAddress); } - /// @notice update permissions for native orders - /// @param newNativeOrder for orders with native token - /// @param newMetaNative for meta orders with native token - /// @dev setter for permissions for native token exchange - function _updateNative(bool newNativeOrder, bool newMetaNative) internal { - nativeMeta = newMetaNative; - nativeOrder = newNativeOrder; - emit NativeUpdated(newNativeOrder, newMetaNative); - } - /// @notice cancel order /// @param order to be canceled /// @param orderHash used as a checksum to avoid mistakes in the values of order @@ -238,7 +214,7 @@ abstract contract ExchangeCore is Initializable, TransferExecutor, ITransferMana LibFill.FillResult memory newFill ) = _parseOrdersSetFillEmitMatch(from, orderLeft, orderRight); - (uint256 totalMakeValue, uint256 totalTakeValue) = doTransfers( + doTransfers( LibDeal.DealSide({ asset: LibAsset.Asset({assetType: makeMatch, value: newFill.leftValue}), payouts: leftOrderData.payouts, @@ -252,28 +228,8 @@ abstract contract ExchangeCore is Initializable, TransferExecutor, ITransferMana LibFeeSide.getFeeSide(makeMatch.assetClass, takeMatch.assetClass) ); - uint256 takeBuyAmount = newFill.rightValue; - uint256 makeBuyAmount = newFill.leftValue; - // TODO: this force me to pass from, do we want it ? - if (((from != msg.sender) && !nativeMeta) || ((from == msg.sender) && !nativeOrder)) { - require(makeMatch.assetClass != LibAsset.ETH_ASSET_CLASS, "maker cannot transfer native token"); - require(takeMatch.assetClass != LibAsset.ETH_ASSET_CLASS, "taker cannot transfer native token"); - } - if (makeMatch.assetClass == LibAsset.ETH_ASSET_CLASS) { - require(takeMatch.assetClass != LibAsset.ETH_ASSET_CLASS, "taker cannot transfer native token"); - require(makeBuyAmount >= totalMakeValue, "not enough eth"); - if (makeBuyAmount > totalMakeValue) { - // TODO: from ? - payable(msg.sender).transferEth(makeBuyAmount - totalMakeValue); - } - } else if (takeMatch.assetClass == LibAsset.ETH_ASSET_CLASS) { - require(takeBuyAmount >= totalTakeValue, "not enough eth"); - if (takeBuyAmount > totalTakeValue) { - // TODO: from ? - payable(msg.sender).transferEth(takeBuyAmount - totalTakeValue); - } - } + // answer it was cut out with native orders } /// @notice parse orders with LibOrderDataGeneric parse() to get the order data, then create a new fill with setFillEmitMatch() diff --git a/packages/marketplace/contracts/mocks/SimpleTransferManager.sol b/packages/marketplace/contracts/mocks/SimpleTransferManager.sol index 227945d680..1e46d36005 100644 --- a/packages/marketplace/contracts/mocks/SimpleTransferManager.sol +++ b/packages/marketplace/contracts/mocks/SimpleTransferManager.sol @@ -9,11 +9,9 @@ abstract contract SimpleTransferManager is ITransferManager { LibDeal.DealSide memory left, LibDeal.DealSide memory right, LibFeeSide.FeeSide /* feeSide */ - ) internal override returns (uint256 totalMakeValue, uint256 totalTakeValue) { + ) internal override { transfer(left.asset, left.from, right.from); transfer(right.asset, right.from, left.from); - totalMakeValue = left.asset.value; - totalTakeValue = right.asset.value; } uint256[50] private __gap; diff --git a/packages/marketplace/contracts/transfer-manager/TransferManager.sol b/packages/marketplace/contracts/transfer-manager/TransferManager.sol index cbcfb36d20..f742187167 100644 --- a/packages/marketplace/contracts/transfer-manager/TransferManager.sol +++ b/packages/marketplace/contracts/transfer-manager/TransferManager.sol @@ -100,20 +100,16 @@ abstract contract TransferManager is ERC165Upgradeable, ITransferManager { /// @notice executes transfers for 2 matched orders /// @param left DealSide from the left order (see LibDeal.sol) /// @param right DealSide from the right order (see LibDeal.sol) - /// @return totalLeftValue - total amount for the left order - /// @return totalRightValue - total amount for the right order function doTransfers( LibDeal.DealSide memory left, LibDeal.DealSide memory right, LibFeeSide.FeeSide feeSide - ) internal override returns (uint256 totalLeftValue, uint256 totalRightValue) { - totalLeftValue = left.asset.value; - totalRightValue = right.asset.value; + ) internal override { if (feeSide == LibFeeSide.FeeSide.LEFT) { - totalLeftValue = doTransfersWithRoyalties(left, right); + doTransfersWithRoyalties(left, right); transferPayouts(right.asset.assetType, right.asset.value, right.from, left.payouts); } else if (feeSide == LibFeeSide.FeeSide.RIGHT) { - totalRightValue = doTransfersWithRoyalties(right, left); + doTransfersWithRoyalties(right, left); transferPayouts(left.asset.assetType, left.asset.value, left.from, right.payouts); } else { transferPayouts(left.asset.assetType, left.asset.value, left.from, right.payouts); @@ -124,11 +120,7 @@ abstract contract TransferManager is ERC165Upgradeable, ITransferManager { /// @notice executes the fee-side transfers (payment + fees) /// @param paymentSide DealSide of the fee-side order /// @param nftSide DealSide of the nft-side order - /// @return totalAmount of fee-side asset - function doTransfersWithRoyalties( - LibDeal.DealSide memory paymentSide, - LibDeal.DealSide memory nftSide - ) internal returns (uint256 totalAmount) { + function doTransfersWithRoyalties(LibDeal.DealSide memory paymentSide, LibDeal.DealSide memory nftSide) internal { uint256 rest = paymentSide.asset.value; rest = transferRoyalties( diff --git a/packages/marketplace/contracts/transfer-manager/interfaces/ITransferManager.sol b/packages/marketplace/contracts/transfer-manager/interfaces/ITransferManager.sol index c7c1a2888c..5fad64c692 100644 --- a/packages/marketplace/contracts/transfer-manager/interfaces/ITransferManager.sol +++ b/packages/marketplace/contracts/transfer-manager/interfaces/ITransferManager.sol @@ -11,5 +11,5 @@ abstract contract ITransferManager is ITransferExecutor { LibDeal.DealSide memory left, LibDeal.DealSide memory right, LibFeeSide.FeeSide feeSide - ) internal virtual returns (uint256 totalMakeValue, uint256 totalTakeValue); + ) internal virtual; } diff --git a/packages/marketplace/test/exchange/ExchangeSettings.test.ts b/packages/marketplace/test/exchange/ExchangeSettings.test.ts index 998c87681c..9a9014afef 100644 --- a/packages/marketplace/test/exchange/ExchangeSettings.test.ts +++ b/packages/marketplace/test/exchange/ExchangeSettings.test.ts @@ -26,8 +26,6 @@ describe('Exchange.sol settings', function () { expect(await ExchangeContractAsAdmin.orderValidator()).to.be.equal( await OrderValidatorAsDeployer.getAddress() ); - expect(await ExchangeContractAsAdmin.nativeMeta()).to.be.equal(true); - expect(await ExchangeContractAsAdmin.nativeOrder()).to.be.equal(true); expect(await ExchangeContractAsAdmin.getTrustedForwarder()).to.be.equal( await TrustedForwarder.getAddress() ); @@ -49,25 +47,6 @@ describe('Exchange.sol settings', function () { 'setOrderValidatorContract', 'OrderValidatorSet' ); - it('should update native order', async function () { - const {ExchangeContractAsAdmin} = await loadFixture(deployFixtures); - expect(await ExchangeContractAsAdmin.nativeMeta()).to.be.equal(true); - expect(await ExchangeContractAsAdmin.nativeOrder()).to.be.equal(true); - await expect(ExchangeContractAsAdmin.updateNative(false, false)) - .to.emit(ExchangeContractAsAdmin, 'NativeUpdated') - .withArgs(false, false); - expect(await ExchangeContractAsAdmin.nativeMeta()).to.be.equal(false); - expect(await ExchangeContractAsAdmin.nativeOrder()).to.be.equal(false); - }); - it('should not update native order if caller is not owner', async function () { - const {DEFAULT_ADMIN_ROLE, ExchangeContractAsUser, user} = - await loadFixture(deployFixtures); - await expect( - ExchangeContractAsUser.updateNative(false, false) - ).to.be.revertedWith( - `AccessControl: account ${user.address.toLowerCase()} is missing role ${DEFAULT_ADMIN_ROLE}` - ); - }); it('should not set trusted forwarder if caller is not owner', async function () { const {DEFAULT_ADMIN_ROLE, ExchangeContractAsUser, user} = await loadFixture(deployFixtures); diff --git a/packages/marketplace/test/fixtures.ts b/packages/marketplace/test/fixtures.ts index 461ff33ac7..454a26661c 100644 --- a/packages/marketplace/test/fixtures.ts +++ b/packages/marketplace/test/fixtures.ts @@ -43,8 +43,6 @@ async function deploy() { await RoyaltyRegistry.getAddress(), await OrderValidatorAsDeployer.getAddress(), await assetMatcherAsDeployer.getAddress(), - true, - true, ], { initializer: '__Exchange_init',