Removed all mixins/ directories from the repository
This commit is contained in:
parent
f2f81b0f7b
commit
9ef55023f2
@ -19,14 +19,20 @@
|
|||||||
pragma solidity ^0.5.9;
|
pragma solidity ^0.5.9;
|
||||||
|
|
||||||
import "@0x/contracts-utils/contracts/src/Ownable.sol";
|
import "@0x/contracts-utils/contracts/src/Ownable.sol";
|
||||||
import "./mixins/MAssetProxyDispatcher.sol";
|
|
||||||
import "./interfaces/IAssetProxy.sol";
|
import "./interfaces/IAssetProxy.sol";
|
||||||
|
import "./interfaces/IAssetProxyDispatcher.sol";
|
||||||
|
|
||||||
|
|
||||||
contract MixinAssetProxyDispatcher is
|
contract MixinAssetProxyDispatcher is
|
||||||
Ownable,
|
Ownable,
|
||||||
MAssetProxyDispatcher
|
IAssetProxyDispatcher
|
||||||
{
|
{
|
||||||
|
// Logs registration of new asset proxy
|
||||||
|
event AssetProxyRegistered(
|
||||||
|
bytes4 id, // Id of new registered AssetProxy.
|
||||||
|
address assetProxy // Address of new registered AssetProxy.
|
||||||
|
);
|
||||||
|
|
||||||
// Mapping from Asset Proxy Id's to their respective Asset Proxy
|
// Mapping from Asset Proxy Id's to their respective Asset Proxy
|
||||||
mapping (bytes4 => address) public assetProxies;
|
mapping (bytes4 => address) public assetProxies;
|
||||||
|
|
||||||
|
@ -19,13 +19,25 @@
|
|||||||
pragma solidity ^0.5.9;
|
pragma solidity ^0.5.9;
|
||||||
|
|
||||||
import "@0x/contracts-utils/contracts/src/Ownable.sol";
|
import "@0x/contracts-utils/contracts/src/Ownable.sol";
|
||||||
import "./mixins/MAuthorizable.sol";
|
import "./interfaces/IAuthorizable.sol";
|
||||||
|
|
||||||
|
|
||||||
contract MixinAuthorizable is
|
contract MixinAuthorizable is
|
||||||
Ownable,
|
Ownable,
|
||||||
MAuthorizable
|
IAuthorizable
|
||||||
{
|
{
|
||||||
|
// Event logged when a new address is authorized.
|
||||||
|
event AuthorizedAddressAdded(
|
||||||
|
address indexed target,
|
||||||
|
address indexed caller
|
||||||
|
);
|
||||||
|
|
||||||
|
// Event logged when a currently authorized address is unauthorized.
|
||||||
|
event AuthorizedAddressRemoved(
|
||||||
|
address indexed target,
|
||||||
|
address indexed caller
|
||||||
|
);
|
||||||
|
|
||||||
/// @dev Only authorized addresses can invoke functions with this modifier.
|
/// @dev Only authorized addresses can invoke functions with this modifier.
|
||||||
modifier onlyAuthorized {
|
modifier onlyAuthorized {
|
||||||
require(
|
require(
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2018 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
import "../interfaces/IAssetProxyDispatcher.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract MAssetProxyDispatcher is
|
|
||||||
IAssetProxyDispatcher
|
|
||||||
{
|
|
||||||
// Logs registration of new asset proxy
|
|
||||||
event AssetProxyRegistered(
|
|
||||||
bytes4 id, // Id of new registered AssetProxy.
|
|
||||||
address assetProxy // Address of new registered AssetProxy.
|
|
||||||
);
|
|
||||||
|
|
||||||
/// @dev Forwards arguments to assetProxy and calls `transferFrom`. Either succeeds or throws.
|
|
||||||
/// @param assetData Byte array encoded for the asset.
|
|
||||||
/// @param from Address to transfer token from.
|
|
||||||
/// @param to Address to transfer token to.
|
|
||||||
/// @param amount Amount of token to transfer.
|
|
||||||
function _dispatchTransferFrom(
|
|
||||||
bytes memory assetData,
|
|
||||||
address from,
|
|
||||||
address to,
|
|
||||||
uint256 amount
|
|
||||||
)
|
|
||||||
internal;
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2018 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
import "../interfaces/IAuthorizable.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract MAuthorizable is
|
|
||||||
IAuthorizable
|
|
||||||
{
|
|
||||||
// Event logged when a new address is authorized.
|
|
||||||
event AuthorizedAddressAdded(
|
|
||||||
address indexed target,
|
|
||||||
address indexed caller
|
|
||||||
);
|
|
||||||
|
|
||||||
// Event logged when a currently authorized address is unauthorized.
|
|
||||||
event AuthorizedAddressRemoved(
|
|
||||||
address indexed target,
|
|
||||||
address indexed caller
|
|
||||||
);
|
|
||||||
|
|
||||||
/// @dev Only authorized addresses can invoke functions with this modifier.
|
|
||||||
modifier onlyAuthorized { revert(); _; }
|
|
||||||
}
|
|
@ -25,8 +25,8 @@ import "@0x/contracts-exchange-libs/contracts/src/LibZeroExTransaction.sol";
|
|||||||
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
||||||
import "@0x/contracts-utils/contracts/src/LibAddressArray.sol";
|
import "@0x/contracts-utils/contracts/src/LibAddressArray.sol";
|
||||||
import "./libs/LibCoordinatorApproval.sol";
|
import "./libs/LibCoordinatorApproval.sol";
|
||||||
import "./mixins/MSignatureValidator.sol";
|
import "./interfaces/ISignatureValidator.sol";
|
||||||
import "./mixins/MCoordinatorApprovalVerifier.sol";
|
import "./interfaces/ICoordinatorApprovalVerifier.sol";
|
||||||
|
|
||||||
|
|
||||||
// solhint-disable avoid-tx-origin
|
// solhint-disable avoid-tx-origin
|
||||||
@ -34,8 +34,8 @@ contract MixinCoordinatorApprovalVerifier is
|
|||||||
LibExchangeSelectors,
|
LibExchangeSelectors,
|
||||||
LibCoordinatorApproval,
|
LibCoordinatorApproval,
|
||||||
LibZeroExTransaction,
|
LibZeroExTransaction,
|
||||||
MSignatureValidator,
|
ISignatureValidator,
|
||||||
MCoordinatorApprovalVerifier
|
ICoordinatorApprovalVerifier
|
||||||
{
|
{
|
||||||
using LibBytes for bytes;
|
using LibBytes for bytes;
|
||||||
using LibAddressArray for address[];
|
using LibAddressArray for address[];
|
||||||
|
@ -21,13 +21,13 @@ pragma experimental ABIEncoderV2;
|
|||||||
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibZeroExTransaction.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibZeroExTransaction.sol";
|
||||||
import "./libs/LibConstants.sol";
|
import "./libs/LibConstants.sol";
|
||||||
import "./mixins/MCoordinatorApprovalVerifier.sol";
|
|
||||||
import "./interfaces/ICoordinatorCore.sol";
|
import "./interfaces/ICoordinatorCore.sol";
|
||||||
|
import "./interfaces/ICoordinatorApprovalVerifier.sol";
|
||||||
|
|
||||||
|
|
||||||
contract MixinCoordinatorCore is
|
contract MixinCoordinatorCore is
|
||||||
LibConstants,
|
LibConstants,
|
||||||
MCoordinatorApprovalVerifier,
|
ICoordinatorApprovalVerifier,
|
||||||
ICoordinatorCore
|
ICoordinatorCore
|
||||||
{
|
{
|
||||||
/// @dev Executes a 0x transaction that has been signed by the feeRecipients that correspond to each order in the transaction's Exchange calldata.
|
/// @dev Executes a 0x transaction that has been signed by the feeRecipients that correspond to each order in the transaction's Exchange calldata.
|
||||||
|
@ -19,14 +19,28 @@
|
|||||||
pragma solidity ^0.5.9;
|
pragma solidity ^0.5.9;
|
||||||
|
|
||||||
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
||||||
import "./mixins/MSignatureValidator.sol";
|
import "./interfaces/ISignatureValidator.sol";
|
||||||
|
|
||||||
|
|
||||||
contract MixinSignatureValidator is
|
contract MixinSignatureValidator is
|
||||||
MSignatureValidator
|
ISignatureValidator
|
||||||
{
|
{
|
||||||
using LibBytes for bytes;
|
using LibBytes for bytes;
|
||||||
|
|
||||||
|
// Allowed signature types.
|
||||||
|
enum SignatureType {
|
||||||
|
Illegal, // 0x00, default value
|
||||||
|
Invalid, // 0x01
|
||||||
|
EIP712, // 0x02
|
||||||
|
EthSign, // 0x03
|
||||||
|
Wallet, // 0x04
|
||||||
|
Validator, // 0x05
|
||||||
|
PreSigned, // 0x06
|
||||||
|
OrderValidator, // 0x07
|
||||||
|
WalletOrderValidator, // 0x08
|
||||||
|
NSignatureTypes // 0x09, number of signature types. Always leave at end.
|
||||||
|
}
|
||||||
|
|
||||||
/// @dev Recovers the address of a signer given a hash and signature.
|
/// @dev Recovers the address of a signer given a hash and signature.
|
||||||
/// @param hash Any 32 byte hash.
|
/// @param hash Any 32 byte hash.
|
||||||
/// @param signature Proof that the hash has been signed by signer.
|
/// @param signature Proof that the hash has been signed by signer.
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2018 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
pragma experimental ABIEncoderV2;
|
|
||||||
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
|
||||||
import "../interfaces/ICoordinatorApprovalVerifier.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract MCoordinatorApprovalVerifier is
|
|
||||||
ICoordinatorApprovalVerifier
|
|
||||||
{
|
|
||||||
/// @dev Validates that the feeRecipients of a batch of order have approved a 0x transaction.
|
|
||||||
/// @param transaction 0x transaction containing salt, signerAddress, and data.
|
|
||||||
/// @param orders Array of order structs containing order specifications.
|
|
||||||
/// @param txOrigin Required signer of Ethereum transaction calling this function.
|
|
||||||
/// @param transactionSignature Proof that the transaction has been signed by the signer.
|
|
||||||
/// @param approvalExpirationTimeSeconds Array of expiration times in seconds for which each corresponding approval signature expires.
|
|
||||||
/// @param approvalSignatures Array of signatures that correspond to the feeRecipients of each order.
|
|
||||||
function _assertValidTransactionOrdersApproval(
|
|
||||||
LibZeroExTransaction.ZeroExTransaction memory transaction,
|
|
||||||
LibOrder.Order[] memory orders,
|
|
||||||
address txOrigin,
|
|
||||||
bytes memory transactionSignature,
|
|
||||||
uint256[] memory approvalExpirationTimeSeconds,
|
|
||||||
bytes[] memory approvalSignatures
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
view;
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2018 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
import "../interfaces/ISignatureValidator.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract MSignatureValidator is
|
|
||||||
ISignatureValidator
|
|
||||||
{
|
|
||||||
// Allowed signature types.
|
|
||||||
enum SignatureType {
|
|
||||||
Illegal, // 0x00, default value
|
|
||||||
Invalid, // 0x01
|
|
||||||
EIP712, // 0x02
|
|
||||||
EthSign, // 0x03
|
|
||||||
NSignatureTypes // 0x04, number of signature types. Always leave at end.
|
|
||||||
}
|
|
||||||
}
|
|
@ -30,7 +30,6 @@
|
|||||||
"src/interfaces/IERC1155.sol",
|
"src/interfaces/IERC1155.sol",
|
||||||
"src/interfaces/IERC1155Mintable.sol",
|
"src/interfaces/IERC1155Mintable.sol",
|
||||||
"src/interfaces/IERC1155Receiver.sol",
|
"src/interfaces/IERC1155Receiver.sol",
|
||||||
"src/mixins/MNonFungibleToken.sol",
|
|
||||||
"test/DummyERC1155Receiver.sol"
|
"test/DummyERC1155Receiver.sol"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -18,12 +18,8 @@
|
|||||||
|
|
||||||
pragma solidity ^0.5.9;
|
pragma solidity ^0.5.9;
|
||||||
|
|
||||||
import "./mixins/MNonFungibleToken.sol";
|
|
||||||
|
|
||||||
|
contract MixinNonFungibleToken {
|
||||||
contract MixinNonFungibleToken is
|
|
||||||
MNonFungibleToken
|
|
||||||
{
|
|
||||||
/// Use a split bit implementation.
|
/// Use a split bit implementation.
|
||||||
/// Store the type in the upper 128 bits..
|
/// Store the type in the upper 128 bits..
|
||||||
uint256 constant internal TYPE_MASK = uint256(uint128(~0)) << 128;
|
uint256 constant internal TYPE_MASK = uint256(uint128(~0)) << 128;
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2018 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
|
|
||||||
contract MNonFungibleToken {
|
|
||||||
|
|
||||||
/// @dev Returns true if token is non-fungible
|
|
||||||
function isNonFungible(uint256 id) public pure returns(bool);
|
|
||||||
|
|
||||||
/// @dev Returns true if token is fungible
|
|
||||||
function isFungible(uint256 _d) public pure returns(bool);
|
|
||||||
|
|
||||||
/// @dev Returns index of non-fungible token
|
|
||||||
function getNonFungibleIndex(uint256 id) public pure returns(uint256);
|
|
||||||
|
|
||||||
/// @dev Returns base type of non-fungible token
|
|
||||||
function getNonFungibleBaseType(uint256 id) public pure returns(uint256);
|
|
||||||
|
|
||||||
/// @dev Returns true if input is base-type of a non-fungible token
|
|
||||||
function isNonFungibleBaseType(uint256 id) public pure returns(bool);
|
|
||||||
|
|
||||||
/// @dev Returns true if input is a non-fungible token
|
|
||||||
function isNonFungibleItem(uint256 id) public pure returns(bool);
|
|
||||||
|
|
||||||
/// @dev returns owner of a non-fungible token
|
|
||||||
function ownerOf(uint256 id) public view returns (address);
|
|
||||||
}
|
|
@ -34,7 +34,7 @@
|
|||||||
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol"
|
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"abis": "generated-artifacts/@(DummyERC1155Receiver|ERC1155|ERC1155Mintable|IERC1155|IERC1155Mintable|IERC1155Receiver|MNonFungibleToken|MixinNonFungibleToken).json",
|
"abis": "./generated-artifacts/@(DummyERC1155Receiver|ERC1155|ERC1155Mintable|IERC1155|IERC1155Mintable|IERC1155Receiver|MixinNonFungibleToken).json",
|
||||||
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually."
|
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually."
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -12,14 +12,12 @@ import * as IERC1155 from '../generated-artifacts/IERC1155.json';
|
|||||||
import * as IERC1155Mintable from '../generated-artifacts/IERC1155Mintable.json';
|
import * as IERC1155Mintable from '../generated-artifacts/IERC1155Mintable.json';
|
||||||
import * as IERC1155Receiver from '../generated-artifacts/IERC1155Receiver.json';
|
import * as IERC1155Receiver from '../generated-artifacts/IERC1155Receiver.json';
|
||||||
import * as MixinNonFungibleToken from '../generated-artifacts/MixinNonFungibleToken.json';
|
import * as MixinNonFungibleToken from '../generated-artifacts/MixinNonFungibleToken.json';
|
||||||
import * as MNonFungibleToken from '../generated-artifacts/MNonFungibleToken.json';
|
|
||||||
export const artifacts = {
|
export const artifacts = {
|
||||||
DummyERC1155Receiver: DummyERC1155Receiver as ContractArtifact,
|
|
||||||
ERC1155: ERC1155 as ContractArtifact,
|
ERC1155: ERC1155 as ContractArtifact,
|
||||||
MNonFungibleToken: MNonFungibleToken as ContractArtifact,
|
|
||||||
ERC1155Mintable: ERC1155Mintable as ContractArtifact,
|
ERC1155Mintable: ERC1155Mintable as ContractArtifact,
|
||||||
MixinNonFungibleToken: MixinNonFungibleToken as ContractArtifact,
|
MixinNonFungibleToken: MixinNonFungibleToken as ContractArtifact,
|
||||||
|
IERC1155: IERC1155 as ContractArtifact,
|
||||||
IERC1155Mintable: IERC1155Mintable as ContractArtifact,
|
IERC1155Mintable: IERC1155Mintable as ContractArtifact,
|
||||||
IERC1155Receiver: IERC1155Receiver as ContractArtifact,
|
IERC1155Receiver: IERC1155Receiver as ContractArtifact,
|
||||||
IERC1155: IERC1155 as ContractArtifact,
|
DummyERC1155Receiver: DummyERC1155Receiver as ContractArtifact,
|
||||||
};
|
};
|
||||||
|
@ -9,5 +9,4 @@ export * from '../generated-wrappers/erc1155_mintable';
|
|||||||
export * from '../generated-wrappers/i_erc1155_mintable';
|
export * from '../generated-wrappers/i_erc1155_mintable';
|
||||||
export * from '../generated-wrappers/i_erc1155_receiver';
|
export * from '../generated-wrappers/i_erc1155_receiver';
|
||||||
export * from '../generated-wrappers/ierc1155';
|
export * from '../generated-wrappers/ierc1155';
|
||||||
export * from '../generated-wrappers/m_non_fungible_token';
|
|
||||||
export * from '../generated-wrappers/mixin_non_fungible_token';
|
export * from '../generated-wrappers/mixin_non_fungible_token';
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
"generated-artifacts/IERC1155.json",
|
"generated-artifacts/IERC1155.json",
|
||||||
"generated-artifacts/IERC1155Mintable.json",
|
"generated-artifacts/IERC1155Mintable.json",
|
||||||
"generated-artifacts/IERC1155Receiver.json",
|
"generated-artifacts/IERC1155Receiver.json",
|
||||||
"generated-artifacts/MNonFungibleToken.json",
|
|
||||||
"generated-artifacts/MixinNonFungibleToken.json"
|
"generated-artifacts/MixinNonFungibleToken.json"
|
||||||
],
|
],
|
||||||
"exclude": ["./deploy/solc/solc_bin"]
|
"exclude": ["./deploy/solc/solc_bin"]
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol"
|
"lint-contracts": "solhint -c ../.solhint.json contracts/**/**/**/**/*.sol"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"abis": "./generated-artifacts/@(DummyERC20Token|DummyMultipleReturnERC20Token|DummyNoReturnERC20Token|ERC20Token|IERC20Token|IEtherToken|MintableERC20Token|UnlimitedAllowanceERC20Token|WETH9|ZRXToken).json",
|
"abis": "./generated-artifacts/@(DummyERC20Token|DummyMultipleReturnERC20Token|DummyNoReturnERC20Token|ERC20Token|IERC20Token|IEtherToken|MintableERC20Token|UnlimitedAllowanceERC20Token|UntransferrableDummyERC20Token|WETH9|ZRXToken).json",
|
||||||
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually."
|
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually."
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -13,6 +13,7 @@ import * as IERC20Token from '../generated-artifacts/IERC20Token.json';
|
|||||||
import * as IEtherToken from '../generated-artifacts/IEtherToken.json';
|
import * as IEtherToken from '../generated-artifacts/IEtherToken.json';
|
||||||
import * as MintableERC20Token from '../generated-artifacts/MintableERC20Token.json';
|
import * as MintableERC20Token from '../generated-artifacts/MintableERC20Token.json';
|
||||||
import * as UnlimitedAllowanceERC20Token from '../generated-artifacts/UnlimitedAllowanceERC20Token.json';
|
import * as UnlimitedAllowanceERC20Token from '../generated-artifacts/UnlimitedAllowanceERC20Token.json';
|
||||||
|
import * as UntransferrableDummyERC20Token from '../generated-artifacts/UntransferrableDummyERC20Token.json';
|
||||||
import * as WETH9 from '../generated-artifacts/WETH9.json';
|
import * as WETH9 from '../generated-artifacts/WETH9.json';
|
||||||
import * as ZRXToken from '../generated-artifacts/ZRXToken.json';
|
import * as ZRXToken from '../generated-artifacts/ZRXToken.json';
|
||||||
export const artifacts = {
|
export const artifacts = {
|
||||||
@ -26,4 +27,5 @@ export const artifacts = {
|
|||||||
DummyERC20Token: DummyERC20Token as ContractArtifact,
|
DummyERC20Token: DummyERC20Token as ContractArtifact,
|
||||||
DummyMultipleReturnERC20Token: DummyMultipleReturnERC20Token as ContractArtifact,
|
DummyMultipleReturnERC20Token: DummyMultipleReturnERC20Token as ContractArtifact,
|
||||||
DummyNoReturnERC20Token: DummyNoReturnERC20Token as ContractArtifact,
|
DummyNoReturnERC20Token: DummyNoReturnERC20Token as ContractArtifact,
|
||||||
|
UntransferrableDummyERC20Token: UntransferrableDummyERC20Token as ContractArtifact,
|
||||||
};
|
};
|
||||||
|
@ -11,5 +11,6 @@ export * from '../generated-wrappers/i_erc20_token';
|
|||||||
export * from '../generated-wrappers/i_ether_token';
|
export * from '../generated-wrappers/i_ether_token';
|
||||||
export * from '../generated-wrappers/mintable_erc20_token';
|
export * from '../generated-wrappers/mintable_erc20_token';
|
||||||
export * from '../generated-wrappers/unlimited_allowance_erc20_token';
|
export * from '../generated-wrappers/unlimited_allowance_erc20_token';
|
||||||
|
export * from '../generated-wrappers/untransferrable_dummy_erc20_token';
|
||||||
export * from '../generated-wrappers/weth9';
|
export * from '../generated-wrappers/weth9';
|
||||||
export * from '../generated-wrappers/zrx_token';
|
export * from '../generated-wrappers/zrx_token';
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
"generated-artifacts/IEtherToken.json",
|
"generated-artifacts/IEtherToken.json",
|
||||||
"generated-artifacts/MintableERC20Token.json",
|
"generated-artifacts/MintableERC20Token.json",
|
||||||
"generated-artifacts/UnlimitedAllowanceERC20Token.json",
|
"generated-artifacts/UnlimitedAllowanceERC20Token.json",
|
||||||
|
"generated-artifacts/UntransferrableDummyERC20Token.json",
|
||||||
"generated-artifacts/WETH9.json",
|
"generated-artifacts/WETH9.json",
|
||||||
"generated-artifacts/ZRXToken.json"
|
"generated-artifacts/ZRXToken.json"
|
||||||
],
|
],
|
||||||
|
@ -23,13 +23,13 @@ import "@0x/contracts-utils/contracts/src/Ownable.sol";
|
|||||||
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
|
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
|
||||||
import "@0x/contracts-erc721/contracts/src/interfaces/IERC721Token.sol";
|
import "@0x/contracts-erc721/contracts/src/interfaces/IERC721Token.sol";
|
||||||
import "./libs/LibConstants.sol";
|
import "./libs/LibConstants.sol";
|
||||||
import "./mixins/MAssets.sol";
|
import "./interfaces/IAssets.sol";
|
||||||
|
|
||||||
|
|
||||||
contract MixinAssets is
|
contract MixinAssets is
|
||||||
Ownable,
|
Ownable,
|
||||||
LibConstants,
|
LibConstants
|
||||||
MAssets
|
IAssets,
|
||||||
{
|
{
|
||||||
using LibBytes for bytes;
|
using LibBytes for bytes;
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ pragma solidity ^0.5.9;
|
|||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import "./libs/LibConstants.sol";
|
import "./libs/LibConstants.sol";
|
||||||
import "./mixins/MExchangeWrapper.sol";
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol";
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibMath.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibMath.sol";
|
||||||
@ -31,8 +30,7 @@ contract MixinExchangeWrapper is
|
|||||||
LibFillResults,
|
LibFillResults,
|
||||||
LibMath,
|
LibMath,
|
||||||
LibConstants,
|
LibConstants,
|
||||||
LibExchangeSelectors,
|
LibExchangeSelectors
|
||||||
MExchangeWrapper
|
|
||||||
{
|
{
|
||||||
/// @dev Fills the input order.
|
/// @dev Fills the input order.
|
||||||
/// Returns false if the transaction would otherwise revert.
|
/// Returns false if the transaction would otherwise revert.
|
||||||
|
@ -20,9 +20,7 @@ pragma solidity ^0.5.9;
|
|||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import "./libs/LibConstants.sol";
|
import "./libs/LibConstants.sol";
|
||||||
import "./mixins/MWeth.sol";
|
import "./interfaces/IAsserts.sol";
|
||||||
import "./mixins/MAssets.sol";
|
|
||||||
import "./mixins/MExchangeWrapper.sol";
|
|
||||||
import "./interfaces/IForwarderCore.sol";
|
import "./interfaces/IForwarderCore.sol";
|
||||||
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
||||||
@ -34,9 +32,7 @@ contract MixinForwarderCore is
|
|||||||
LibFillResults,
|
LibFillResults,
|
||||||
LibMath,
|
LibMath,
|
||||||
LibConstants,
|
LibConstants,
|
||||||
MWeth,
|
IAsserts,
|
||||||
MAssets,
|
|
||||||
MExchangeWrapper,
|
|
||||||
IForwarderCore
|
IForwarderCore
|
||||||
{
|
{
|
||||||
using LibBytes for bytes;
|
using LibBytes for bytes;
|
||||||
|
@ -20,13 +20,11 @@ pragma solidity ^0.5.9;
|
|||||||
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibMath.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibMath.sol";
|
||||||
import "./libs/LibConstants.sol";
|
import "./libs/LibConstants.sol";
|
||||||
import "./mixins/MWeth.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract MixinWeth is
|
contract MixinWeth is
|
||||||
LibMath,
|
LibMath,
|
||||||
LibConstants,
|
LibConstants,
|
||||||
MWeth
|
|
||||||
{
|
{
|
||||||
/// @dev Default payabale function, this allows us to withdraw WETH
|
/// @dev Default payabale function, this allows us to withdraw WETH
|
||||||
function ()
|
function ()
|
||||||
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2018 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
import "../interfaces/IAssets.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract MAssets is
|
|
||||||
IAssets
|
|
||||||
{
|
|
||||||
/// @dev Transfers given amount of asset to sender.
|
|
||||||
/// @param assetData Byte array encoded for the respective asset proxy.
|
|
||||||
/// @param amount Amount of asset to transfer to sender.
|
|
||||||
function _transferAssetToSender(
|
|
||||||
bytes memory assetData,
|
|
||||||
uint256 amount
|
|
||||||
)
|
|
||||||
internal;
|
|
||||||
|
|
||||||
/// @dev Decodes ERC20 assetData and transfers given amount to sender.
|
|
||||||
/// @param assetData Byte array encoded for the respective asset proxy.
|
|
||||||
/// @param amount Amount of asset to transfer to sender.
|
|
||||||
function _transferERC20Token(
|
|
||||||
bytes memory assetData,
|
|
||||||
uint256 amount
|
|
||||||
)
|
|
||||||
internal;
|
|
||||||
|
|
||||||
/// @dev Decodes ERC721 assetData and transfers given amount to sender.
|
|
||||||
/// @param assetData Byte array encoded for the respective asset proxy.
|
|
||||||
/// @param amount Amount of asset to transfer to sender.
|
|
||||||
function _transferERC721Token(
|
|
||||||
bytes memory assetData,
|
|
||||||
uint256 amount
|
|
||||||
)
|
|
||||||
internal;
|
|
||||||
}
|
|
@ -1,87 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2018 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
pragma experimental ABIEncoderV2;
|
|
||||||
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract MExchangeWrapper {
|
|
||||||
|
|
||||||
/// @dev Fills the input order.
|
|
||||||
/// Returns false if the transaction would otherwise revert.
|
|
||||||
/// @param order Order struct containing order specifications.
|
|
||||||
/// @param takerAssetFillAmount Desired amount of takerAsset to sell.
|
|
||||||
/// @param signature Proof that order has been created by maker.
|
|
||||||
/// @return Amounts filled and fees paid by maker and taker.
|
|
||||||
function _fillOrderNoThrow(
|
|
||||||
LibOrder.Order memory order,
|
|
||||||
uint256 takerAssetFillAmount,
|
|
||||||
bytes memory signature
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
returns (LibFillResults.FillResults memory fillResults);
|
|
||||||
|
|
||||||
/// @dev Synchronously executes multiple calls of fillOrder until total amount of WETH has been sold by taker.
|
|
||||||
/// Returns false if the transaction would otherwise revert.
|
|
||||||
/// @param orders Array of order specifications.
|
|
||||||
/// @param wethSellAmount Desired amount of WETH to sell.
|
|
||||||
/// @param signatures Proofs that orders have been signed by makers.
|
|
||||||
/// @return Amounts filled and fees paid by makers and taker.
|
|
||||||
function _marketSellWeth(
|
|
||||||
LibOrder.Order[] memory orders,
|
|
||||||
uint256 wethSellAmount,
|
|
||||||
bytes[] memory signatures
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
returns (LibFillResults.FillResults memory totalFillResults);
|
|
||||||
|
|
||||||
/// @dev Synchronously executes multiple fill orders in a single transaction until total amount is bought by taker.
|
|
||||||
/// Returns false if the transaction would otherwise revert.
|
|
||||||
/// The asset being sold by taker must always be WETH.
|
|
||||||
/// @param orders Array of order specifications.
|
|
||||||
/// @param makerAssetFillAmount Desired amount of makerAsset to buy.
|
|
||||||
/// @param signatures Proofs that orders have been signed by makers.
|
|
||||||
/// @return Amounts filled and fees paid by makers and taker.
|
|
||||||
function _marketBuyExactAmountWithWeth(
|
|
||||||
LibOrder.Order[] memory orders,
|
|
||||||
uint256 makerAssetFillAmount,
|
|
||||||
bytes[] memory signatures
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
returns (LibFillResults.FillResults memory totalFillResults);
|
|
||||||
|
|
||||||
/// @dev Buys zrxBuyAmount of ZRX fee tokens, taking into account ZRX fees for each order. This will guarantee
|
|
||||||
/// that at least zrxBuyAmount of ZRX is purchased (sometimes slightly over due to rounding issues).
|
|
||||||
/// It is possible that a request to buy 200 ZRX will require purchasing 202 ZRX
|
|
||||||
/// as 2 ZRX is required to purchase the 200 ZRX fee tokens. This guarantees at least 200 ZRX for future purchases.
|
|
||||||
/// The asset being sold by taker must always be WETH.
|
|
||||||
/// @param orders Array of order specifications containing ZRX as makerAsset and WETH as takerAsset.
|
|
||||||
/// @param zrxBuyAmount Desired amount of ZRX to buy.
|
|
||||||
/// @param signatures Proofs that orders have been created by makers.
|
|
||||||
/// @return totalFillResults Amounts filled and fees paid by maker and taker.
|
|
||||||
function _marketBuyExactZrxWithWeth(
|
|
||||||
LibOrder.Order[] memory orders,
|
|
||||||
uint256 zrxBuyAmount,
|
|
||||||
bytes[] memory signatures
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
returns (LibFillResults.FillResults memory totalFillResults);
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2018 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
|
|
||||||
contract MWeth {
|
|
||||||
|
|
||||||
/// @dev Converts message call's ETH value into WETH.
|
|
||||||
function _convertEthToWeth()
|
|
||||||
internal;
|
|
||||||
|
|
||||||
/// @dev Transfers feePercentage of WETH spent on primary orders to feeRecipient.
|
|
||||||
/// Refunds any excess ETH to msg.sender.
|
|
||||||
/// @param wethSoldExcludingFeeOrders Amount of WETH sold when filling primary orders.
|
|
||||||
/// @param wethSoldForZrx Amount of WETH sold when purchasing ZRX required for primary order fees.
|
|
||||||
/// @param feePercentage Percentage of WETH sold that will payed as fee to forwarding contract feeRecipient.
|
|
||||||
/// @param feeRecipient Address that will receive ETH when orders are filled.
|
|
||||||
function _transferEthFeeAndRefund(
|
|
||||||
uint256 wethSoldExcludingFeeOrders,
|
|
||||||
uint256 wethSoldForZrx,
|
|
||||||
uint256 feePercentage,
|
|
||||||
address payable feeRecipient
|
|
||||||
)
|
|
||||||
internal;
|
|
||||||
}
|
|
@ -30,13 +30,12 @@ import "./MixinExchangeRichErrors.sol";
|
|||||||
|
|
||||||
// solhint-disable no-empty-blocks
|
// solhint-disable no-empty-blocks
|
||||||
contract Exchange is
|
contract Exchange is
|
||||||
MixinExchangeCore,
|
|
||||||
MixinMatchOrders,
|
MixinMatchOrders,
|
||||||
MixinSignatureValidator,
|
|
||||||
MixinTransactions,
|
|
||||||
MixinAssetProxyDispatcher,
|
|
||||||
MixinWrapperFunctions,
|
MixinWrapperFunctions,
|
||||||
MixinExchangeRichErrors
|
MixinExchangeCore,
|
||||||
|
MixinSignatureValidator,
|
||||||
|
MixinAssetProxyDispatcher,
|
||||||
|
MixinTransactions
|
||||||
{
|
{
|
||||||
string constant public VERSION = "3.0.0";
|
string constant public VERSION = "3.0.0";
|
||||||
|
|
||||||
|
@ -19,16 +19,23 @@
|
|||||||
pragma solidity ^0.5.9;
|
pragma solidity ^0.5.9;
|
||||||
|
|
||||||
import "@0x/contracts-utils/contracts/src/Ownable.sol";
|
import "@0x/contracts-utils/contracts/src/Ownable.sol";
|
||||||
import "./mixins/MAssetProxyDispatcher.sol";
|
import "@0x/contracts-utils/contracts/src/RichErrors.sol";
|
||||||
import "./mixins/MExchangeRichErrors.sol";
|
|
||||||
import "./interfaces/IAssetProxy.sol";
|
import "./interfaces/IAssetProxy.sol";
|
||||||
|
import "./interfaces/IAssetProxyDispatcher.sol";
|
||||||
|
import "./MixinExchangeRichErrors.sol";
|
||||||
|
|
||||||
|
|
||||||
contract MixinAssetProxyDispatcher is
|
contract MixinAssetProxyDispatcher is
|
||||||
|
MixinExchangeRichErrors,
|
||||||
Ownable,
|
Ownable,
|
||||||
MAssetProxyDispatcher,
|
IAssetProxyDispatcher
|
||||||
MExchangeRichErrors
|
|
||||||
{
|
{
|
||||||
|
// Logs registration of new asset proxy
|
||||||
|
event AssetProxyRegistered(
|
||||||
|
bytes4 id, // Id of new registered AssetProxy.
|
||||||
|
address assetProxy // Address of new registered AssetProxy.
|
||||||
|
);
|
||||||
|
|
||||||
// Mapping from Asset Proxy Id's to their respective Asset Proxy
|
// Mapping from Asset Proxy Id's to their respective Asset Proxy
|
||||||
mapping (bytes4 => address) public assetProxies;
|
mapping (bytes4 => address) public assetProxies;
|
||||||
|
|
||||||
|
@ -25,27 +25,63 @@ import "@0x/contracts-exchange-libs/contracts/src/LibExchangeSelectors.sol";
|
|||||||
import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol";
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibMath.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibMath.sol";
|
||||||
import "./mixins/MExchangeCore.sol";
|
import "./interfaces/IAssetProxyDispatcher.sol";
|
||||||
import "./mixins/MSignatureValidator.sol";
|
import "./interfaces/IExchangeCore.sol";
|
||||||
import "./mixins/MTransactions.sol";
|
import "./interfaces/ISignatureValidator.sol";
|
||||||
import "./mixins/MAssetProxyDispatcher.sol";
|
import "./interfaces/ITransactions.sol";
|
||||||
import "./mixins/MExchangeRichErrors.sol";
|
import "./MixinAssetProxyDispatcher.sol";
|
||||||
|
import "./MixinExchangeRichErrors.sol";
|
||||||
|
import "./MixinSignatureValidator.sol";
|
||||||
|
|
||||||
|
|
||||||
contract MixinExchangeCore is
|
contract MixinExchangeCore is
|
||||||
|
MixinExchangeRichErrors,
|
||||||
ReentrancyGuard,
|
ReentrancyGuard,
|
||||||
LibExchangeSelectors,
|
LibExchangeSelectors,
|
||||||
LibMath,
|
LibMath,
|
||||||
LibOrder,
|
LibOrder,
|
||||||
LibFillResults,
|
LibFillResults,
|
||||||
MAssetProxyDispatcher,
|
IAssetProxyDispatcher,
|
||||||
MExchangeCore,
|
IExchangeCore,
|
||||||
MSignatureValidator,
|
ISignatureValidator,
|
||||||
MTransactions,
|
ITransactions
|
||||||
MExchangeRichErrors
|
|
||||||
{
|
{
|
||||||
using LibBytes for bytes;
|
using LibBytes for bytes;
|
||||||
|
|
||||||
|
// Fill event is emitted whenever an order is filled.
|
||||||
|
event Fill(
|
||||||
|
address indexed makerAddress, // Address that created the order.
|
||||||
|
address indexed feeRecipientAddress, // Address that received fees.
|
||||||
|
bytes makerAssetData, // Encoded data specific to makerAsset.
|
||||||
|
bytes takerAssetData, // Encoded data specific to takerAsset.
|
||||||
|
bytes makerFeeAssetData, // Encoded data specific to makerFeeAsset.
|
||||||
|
bytes takerFeeAssetData, // Encoded data specific to takerFeeAsset.
|
||||||
|
uint256 makerAssetFilledAmount, // Amount of makerAsset sold by maker and bought by taker.
|
||||||
|
uint256 takerAssetFilledAmount, // Amount of takerAsset sold by taker and bought by maker.
|
||||||
|
uint256 makerFeePaid, // Amount of makerFeeAssetData paid to feeRecipient by maker.
|
||||||
|
uint256 takerFeePaid, // Amount of takerFeeAssetData paid to feeRecipient by taker.
|
||||||
|
address takerAddress, // Address that filled the order.
|
||||||
|
address senderAddress, // Address that called the Exchange contract (msg.sender).
|
||||||
|
bytes32 indexed orderHash // EIP712 hash of order (see LibOrder.getOrderHash).
|
||||||
|
);
|
||||||
|
|
||||||
|
// Cancel event is emitted whenever an individual order is cancelled.
|
||||||
|
event Cancel(
|
||||||
|
address indexed makerAddress, // Address that created the order.
|
||||||
|
address indexed feeRecipientAddress, // Address that would have recieved fees if order was filled.
|
||||||
|
address senderAddress, // Address that called the Exchange contract (msg.sender).
|
||||||
|
bytes32 indexed orderHash, // EIP712 hash of order (see LibOrder.getOrderHash).
|
||||||
|
bytes makerAssetData, // Encoded data specific to makerAsset.
|
||||||
|
bytes takerAssetData // Encoded data specific to takerAsset.
|
||||||
|
);
|
||||||
|
|
||||||
|
// CancelUpTo event is emitted whenever `cancelOrdersUpTo` is executed succesfully.
|
||||||
|
event CancelUpTo(
|
||||||
|
address indexed makerAddress, // Orders cancelled must have been created by this address.
|
||||||
|
address indexed orderSenderAddress, // Orders cancelled must have a `senderAddress` equal to this address.
|
||||||
|
uint256 orderEpoch // Orders with specified makerAddress and senderAddress with a salt less than this value are considered cancelled.
|
||||||
|
);
|
||||||
|
|
||||||
// Mapping of orderHash => amount of takerAsset already bought by maker
|
// Mapping of orderHash => amount of takerAsset already bought by maker
|
||||||
mapping (bytes32 => uint256) public filled;
|
mapping (bytes32 => uint256) public filled;
|
||||||
|
|
||||||
@ -393,14 +429,14 @@ contract MixinExchangeCore is
|
|||||||
// Revert if fill amount is invalid
|
// Revert if fill amount is invalid
|
||||||
// TODO: reconsider necessity for v2.1
|
// TODO: reconsider necessity for v2.1
|
||||||
if (takerAssetFillAmount == 0) {
|
if (takerAssetFillAmount == 0) {
|
||||||
_rrevert(FillError(FillErrorCodes.INVALID_TAKER_AMOUNT, orderInfo.orderHash));
|
_rrevert(FillError(MixinExchangeRichErrors.FillErrorCodes.INVALID_TAKER_AMOUNT, orderInfo.orderHash));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure taker does not pay more than desired amount
|
// Make sure taker does not pay more than desired amount
|
||||||
// NOTE: This assertion should never fail, it is here
|
// NOTE: This assertion should never fail, it is here
|
||||||
// as an extra defence against potential bugs.
|
// as an extra defence against potential bugs.
|
||||||
if (takerAssetFilledAmount > takerAssetFillAmount) {
|
if (takerAssetFilledAmount > takerAssetFillAmount) {
|
||||||
_rrevert(FillError(FillErrorCodes.TAKER_OVERPAY, orderInfo.orderHash));
|
_rrevert(FillError(MixinExchangeRichErrors.FillErrorCodes.TAKER_OVERPAY, orderInfo.orderHash));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure order is not overfilled
|
// Make sure order is not overfilled
|
||||||
@ -408,7 +444,7 @@ contract MixinExchangeCore is
|
|||||||
// as an extra defence against potential bugs.
|
// as an extra defence against potential bugs.
|
||||||
if (_safeAdd(orderInfo.orderTakerAssetFilledAmount, takerAssetFilledAmount)
|
if (_safeAdd(orderInfo.orderTakerAssetFilledAmount, takerAssetFilledAmount)
|
||||||
> order.takerAssetAmount) {
|
> order.takerAssetAmount) {
|
||||||
_rrevert(FillError(FillErrorCodes.OVERFILL, orderInfo.orderHash));
|
_rrevert(FillError(MixinExchangeRichErrors.FillErrorCodes.OVERFILL, orderInfo.orderHash));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure order is filled at acceptable price.
|
// Make sure order is filled at acceptable price.
|
||||||
@ -430,7 +466,7 @@ contract MixinExchangeCore is
|
|||||||
// as an extra defence against potential bugs.
|
// as an extra defence against potential bugs.
|
||||||
if (_safeMul(makerAssetFilledAmount, order.takerAssetAmount)
|
if (_safeMul(makerAssetFilledAmount, order.takerAssetAmount)
|
||||||
> _safeMul(order.makerAssetAmount, takerAssetFilledAmount)) {
|
> _safeMul(order.makerAssetAmount, takerAssetFilledAmount)) {
|
||||||
_rrevert(FillError(FillErrorCodes.INVALID_FILL_PRICE, orderInfo.orderHash));
|
_rrevert(FillError(MixinExchangeRichErrors.FillErrorCodes.INVALID_FILL_PRICE, orderInfo.orderHash));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,6 +536,30 @@ contract MixinExchangeCore is
|
|||||||
return fillResults;
|
return fillResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _isValidOrderWithHashSignature(
|
||||||
|
Order memory order,
|
||||||
|
bytes32 orderHash,
|
||||||
|
address signerAddress,
|
||||||
|
bytes memory signature
|
||||||
|
)
|
||||||
|
internal
|
||||||
|
view
|
||||||
|
returns (bool isValid);
|
||||||
|
|
||||||
|
function _getCurrentContextAddress()
|
||||||
|
internal
|
||||||
|
view
|
||||||
|
returns (address);
|
||||||
|
|
||||||
|
function _dispatchTransferFrom(
|
||||||
|
bytes32 orderHash,
|
||||||
|
bytes memory assetData,
|
||||||
|
address from,
|
||||||
|
address to,
|
||||||
|
uint256 amount
|
||||||
|
)
|
||||||
|
internal;
|
||||||
|
|
||||||
/// @dev Settles an order by transferring assets between counterparties.
|
/// @dev Settles an order by transferring assets between counterparties.
|
||||||
/// @param orderHash The order hash.
|
/// @param orderHash The order hash.
|
||||||
/// @param order Order struct containing order specifications.
|
/// @param order Order struct containing order specifications.
|
||||||
|
@ -20,13 +20,113 @@ pragma solidity ^0.5.9;
|
|||||||
|
|
||||||
import "@0x/contracts-utils/contracts/src/RichErrors.sol";
|
import "@0x/contracts-utils/contracts/src/RichErrors.sol";
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
||||||
import "./mixins/MExchangeRichErrors.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract MixinExchangeRichErrors is
|
contract MixinExchangeRichErrors is
|
||||||
RichErrors,
|
RichErrors
|
||||||
MExchangeRichErrors
|
|
||||||
{
|
{
|
||||||
|
enum AssetProxyDispatchErrorCodes {
|
||||||
|
INVALID_ASSET_DATA_LENGTH,
|
||||||
|
UNKNOWN_ASSET_PROXY
|
||||||
|
}
|
||||||
|
|
||||||
|
enum FillErrorCodes {
|
||||||
|
INVALID_TAKER_AMOUNT,
|
||||||
|
TAKER_OVERPAY,
|
||||||
|
OVERFILL,
|
||||||
|
INVALID_FILL_PRICE
|
||||||
|
}
|
||||||
|
|
||||||
|
enum SignatureErrorCodes {
|
||||||
|
BAD_SIGNATURE,
|
||||||
|
INVALID_LENGTH,
|
||||||
|
UNSUPPORTED,
|
||||||
|
ILLEGAL,
|
||||||
|
INAPPROPRIATE_SIGNATURE_TYPE
|
||||||
|
}
|
||||||
|
|
||||||
|
enum TransactionErrorCodes {
|
||||||
|
NO_REENTRANCY,
|
||||||
|
ALREADY_EXECUTED,
|
||||||
|
EXPIRED
|
||||||
|
}
|
||||||
|
|
||||||
|
// bytes4(keccak256("SignatureError(uint8,bytes32,address,bytes)"))
|
||||||
|
bytes4 internal constant SIGNATURE_ERROR_SELECTOR =
|
||||||
|
0x7e5a2318;
|
||||||
|
|
||||||
|
// bytes4(keccak256("SignatureValidatorError(bytes32,address,bytes,bytes)"))
|
||||||
|
bytes4 internal constant SIGNATURE_VALIDATOR_ERROR_SELECTOR =
|
||||||
|
0x169fad8c;
|
||||||
|
|
||||||
|
// bytes4(keccak256("SignatureWalletError(bytes32,address,bytes,bytes)"))
|
||||||
|
bytes4 internal constant SIGNATURE_WALLET_ERROR_SELECTOR =
|
||||||
|
0x1b8388f7;
|
||||||
|
|
||||||
|
// bytes4(keccak256("SignatureOrderValidatorError(bytes32,address,bytes,bytes)"))
|
||||||
|
bytes4 internal constant SIGNATURE_ORDER_VALIDATOR_ERROR_SELECTOR =
|
||||||
|
0xfabf4577;
|
||||||
|
|
||||||
|
// bytes4(keccak256("SignatureWalletOrderValidatorError(bytes32,address,bytes,bytes)"))
|
||||||
|
bytes4 internal constant SIGNATURE_WALLET_ORDER_VALIDATOR_ERROR_SELECTOR =
|
||||||
|
0xa85f3360;
|
||||||
|
|
||||||
|
// bytes4(keccak256("OrderStatusError(bytes32,uint8)"))
|
||||||
|
bytes4 internal constant ORDER_STATUS_ERROR_SELECTOR =
|
||||||
|
0xfdb6ca8d;
|
||||||
|
|
||||||
|
// bytes4(keccak256("InvalidSenderError(bytes32,address)"))
|
||||||
|
bytes4 internal constant INVALID_SENDER_ERROR_SELECTOR =
|
||||||
|
0x95b59997;
|
||||||
|
|
||||||
|
// bytes4(keccak256("InvalidMakerError(bytes32,address)"))
|
||||||
|
bytes4 internal constant INVALID_MAKER_ERROR_SELECTOR =
|
||||||
|
0x26bf55d9;
|
||||||
|
|
||||||
|
// bytes4(keccak256("FillError(uint8,bytes32)"))
|
||||||
|
bytes4 internal constant FILL_ERROR_SELECTOR =
|
||||||
|
0xe94a7ed0;
|
||||||
|
|
||||||
|
// bytes4(keccak256("InvalidTakerError(bytes32,address)"))
|
||||||
|
bytes4 internal constant INVALID_TAKER_ERROR_SELECTOR =
|
||||||
|
0xfdb328be;
|
||||||
|
|
||||||
|
// bytes4(keccak256("OrderEpochError(address,address,uint256)"))
|
||||||
|
bytes4 internal constant ORDER_EPOCH_ERROR_SELECTOR =
|
||||||
|
0x4ad31275;
|
||||||
|
|
||||||
|
// bytes4(keccak256("AssetProxyExistsError(address)"))
|
||||||
|
bytes4 internal constant ASSET_PROXY_EXISTS_ERROR_SELECTOR =
|
||||||
|
0xcc8b3b53;
|
||||||
|
|
||||||
|
// bytes4(keccak256("AssetProxyDispatchError(uint8,bytes32,bytes)"))
|
||||||
|
bytes4 internal constant ASSET_PROXY_DISPATCH_ERROR_SELECTOR =
|
||||||
|
0x488219a6;
|
||||||
|
|
||||||
|
// bytes4(keccak256("AssetProxyTransferError(bytes32,bytes,bytes)"))
|
||||||
|
bytes4 internal constant ASSET_PROXY_TRANSFER_ERROR_SELECTOR =
|
||||||
|
0x4678472b;
|
||||||
|
|
||||||
|
// bytes4(keccak256("NegativeSpreadError(bytes32,bytes32)"))
|
||||||
|
bytes4 internal constant NEGATIVE_SPREAD_ERROR_SELECTOR =
|
||||||
|
0xb6555d6f;
|
||||||
|
|
||||||
|
// bytes4(keccak256("TransactionError(uint8,bytes32)"))
|
||||||
|
bytes4 internal constant TRANSACTION_ERROR_SELECTOR =
|
||||||
|
0xf5985184;
|
||||||
|
|
||||||
|
// bytes4(keccak256("TransactionSignatureError(bytes32,address,bytes)"))
|
||||||
|
bytes4 internal constant TRANSACTION_SIGNATURE_ERROR_SELECTOR =
|
||||||
|
0xbfd56ef6;
|
||||||
|
|
||||||
|
// bytes4(keccak256("TransactionExecutionError(bytes32,bytes)"))
|
||||||
|
bytes4 internal constant TRANSACTION_EXECUTION_ERROR_SELECTOR =
|
||||||
|
0x20d11f61;
|
||||||
|
|
||||||
|
// bytes4(keccak256("IncompleteFillError(bytes32)"))
|
||||||
|
bytes4 internal constant INCOMPLETE_FILL_ERROR_SELECTOR =
|
||||||
|
0x152aa60e;
|
||||||
|
|
||||||
// solhint-disable func-name-mixedcase
|
// solhint-disable func-name-mixedcase
|
||||||
function SignatureError(
|
function SignatureError(
|
||||||
SignatureErrorCodes errorCode,
|
SignatureErrorCodes errorCode,
|
||||||
|
@ -15,26 +15,27 @@ pragma solidity ^0.5.9;
|
|||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import "@0x/contracts-utils/contracts/src/ReentrancyGuard.sol";
|
import "@0x/contracts-utils/contracts/src/ReentrancyGuard.sol";
|
||||||
|
import "@0x/contracts-utils/contracts/src/RichErrors.sol";
|
||||||
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibMath.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibMath.sol";
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol";
|
||||||
import "./mixins/MExchangeCore.sol";
|
import "./interfaces/IAssetProxyDispatcher.sol";
|
||||||
import "./mixins/MMatchOrders.sol";
|
import "./interfaces/IExchangeCore.sol";
|
||||||
import "./mixins/MTransactions.sol";
|
import "./interfaces/IMatchOrders.sol";
|
||||||
import "./mixins/MAssetProxyDispatcher.sol";
|
import "./interfaces/ITransactions.sol";
|
||||||
import "./mixins/MExchangeRichErrors.sol";
|
import "./MixinExchangeRichErrors.sol";
|
||||||
|
|
||||||
|
|
||||||
contract MixinMatchOrders is
|
contract MixinMatchOrders is
|
||||||
|
MixinExchangeRichErrors,
|
||||||
ReentrancyGuard,
|
ReentrancyGuard,
|
||||||
LibMath,
|
LibMath,
|
||||||
LibOrder,
|
LibOrder,
|
||||||
MAssetProxyDispatcher,
|
IAssetProxyDispatcher,
|
||||||
MExchangeCore,
|
IExchangeCore,
|
||||||
MMatchOrders,
|
IMatchOrders,
|
||||||
MTransactions,
|
ITransactions
|
||||||
MExchangeRichErrors
|
|
||||||
{
|
{
|
||||||
using LibBytes for bytes;
|
using LibBytes for bytes;
|
||||||
|
|
||||||
@ -267,6 +268,48 @@ contract MixinMatchOrders is
|
|||||||
return matchedFillResults;
|
return matchedFillResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _dispatchTransferFrom(
|
||||||
|
bytes32 orderHash,
|
||||||
|
bytes memory assetData,
|
||||||
|
address from,
|
||||||
|
address to,
|
||||||
|
uint256 amount
|
||||||
|
)
|
||||||
|
internal;
|
||||||
|
|
||||||
|
function _getCurrentContextAddress()
|
||||||
|
internal
|
||||||
|
view
|
||||||
|
returns (address);
|
||||||
|
|
||||||
|
function _assertFillableOrder(
|
||||||
|
Order memory order,
|
||||||
|
OrderInfo memory orderInfo,
|
||||||
|
address takerAddress,
|
||||||
|
bytes memory signature
|
||||||
|
)
|
||||||
|
internal
|
||||||
|
view;
|
||||||
|
|
||||||
|
function _updateFilledState(
|
||||||
|
Order memory order,
|
||||||
|
address takerAddress,
|
||||||
|
bytes32 orderHash,
|
||||||
|
uint256 orderTakerAssetFilledAmount,
|
||||||
|
LibFillResults.FillResults memory fillResults
|
||||||
|
)
|
||||||
|
internal;
|
||||||
|
|
||||||
|
function _assertValidFill(
|
||||||
|
Order memory order,
|
||||||
|
OrderInfo memory orderInfo,
|
||||||
|
uint256 takerAssetFillAmount, // TODO: use FillResults
|
||||||
|
uint256 takerAssetFilledAmount,
|
||||||
|
uint256 makerAssetFilledAmount
|
||||||
|
)
|
||||||
|
internal
|
||||||
|
view;
|
||||||
|
|
||||||
/// @dev Settles matched order by transferring appropriate funds between order makers, taker, and fee recipient.
|
/// @dev Settles matched order by transferring appropriate funds between order makers, taker, and fee recipient.
|
||||||
/// @param leftOrderHash First matched order hash.
|
/// @param leftOrderHash First matched order hash.
|
||||||
/// @param rightOrderHash Second matched order hash.
|
/// @param rightOrderHash Second matched order hash.
|
||||||
|
@ -21,24 +21,45 @@ pragma experimental ABIEncoderV2;
|
|||||||
|
|
||||||
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
||||||
import "@0x/contracts-utils/contracts/src/ReentrancyGuard.sol";
|
import "@0x/contracts-utils/contracts/src/ReentrancyGuard.sol";
|
||||||
|
import "@0x/contracts-utils/contracts/src/RichErrors.sol";
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
||||||
import "./mixins/MSignatureValidator.sol";
|
|
||||||
import "./mixins/MTransactions.sol";
|
|
||||||
import "./mixins/MExchangeRichErrors.sol";
|
|
||||||
import "./interfaces/IWallet.sol";
|
import "./interfaces/IWallet.sol";
|
||||||
import "./interfaces/IValidator.sol";
|
import "./interfaces/IValidator.sol";
|
||||||
import "./interfaces/IOrderValidator.sol";
|
import "./interfaces/IOrderValidator.sol";
|
||||||
|
import "./interfaces/ISignatureValidator.sol";
|
||||||
|
import "./interfaces/ITransactions.sol";
|
||||||
|
import "./MixinExchangeRichErrors.sol";
|
||||||
|
|
||||||
|
|
||||||
contract MixinSignatureValidator is
|
contract MixinSignatureValidator is
|
||||||
|
MixinExchangeRichErrors,
|
||||||
ReentrancyGuard,
|
ReentrancyGuard,
|
||||||
LibOrder,
|
LibOrder,
|
||||||
MSignatureValidator,
|
ISignatureValidator,
|
||||||
MTransactions,
|
ITransactions
|
||||||
MExchangeRichErrors
|
|
||||||
{
|
{
|
||||||
using LibBytes for bytes;
|
using LibBytes for bytes;
|
||||||
|
|
||||||
|
// Allowed signature types.
|
||||||
|
enum SignatureType {
|
||||||
|
Illegal, // 0x00, default value
|
||||||
|
Invalid, // 0x01
|
||||||
|
EIP712, // 0x02
|
||||||
|
EthSign, // 0x03
|
||||||
|
Wallet, // 0x04
|
||||||
|
Validator, // 0x05
|
||||||
|
PreSigned, // 0x06
|
||||||
|
OrderValidator, // 0x07
|
||||||
|
WalletOrderValidator, // 0x08
|
||||||
|
NSignatureTypes // 0x09, number of signature types. Always leave at end.
|
||||||
|
}
|
||||||
|
|
||||||
|
event SignatureValidatorApproval(
|
||||||
|
address indexed signerAddress, // Address that approves or disapproves a contract to verify signatures.
|
||||||
|
address indexed validatorAddress, // Address of signature validator contract.
|
||||||
|
bool approved // Approval or disapproval of validator contract.
|
||||||
|
);
|
||||||
|
|
||||||
// Mapping of hash => signer => signed
|
// Mapping of hash => signer => signed
|
||||||
mapping (bytes32 => mapping (address => bool)) public preSigned;
|
mapping (bytes32 => mapping (address => bool)) public preSigned;
|
||||||
|
|
||||||
@ -210,6 +231,11 @@ contract MixinSignatureValidator is
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _getCurrentContextAddress()
|
||||||
|
internal
|
||||||
|
view
|
||||||
|
returns (address);
|
||||||
|
|
||||||
/// Reads the `SignatureType` from the end of a signature and validates it.
|
/// Reads the `SignatureType` from the end of a signature and validates it.
|
||||||
function _readValidSignatureType(
|
function _readValidSignatureType(
|
||||||
bytes32 hash,
|
bytes32 hash,
|
||||||
|
@ -20,17 +20,19 @@ pragma solidity ^0.5.9;
|
|||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibZeroExTransaction.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibZeroExTransaction.sol";
|
||||||
import "./mixins/MSignatureValidator.sol";
|
import "./interfaces/ISignatureValidator.sol";
|
||||||
import "./mixins/MTransactions.sol";
|
import "./interfaces/ITransactions.sol";
|
||||||
import "./mixins/MExchangeRichErrors.sol";
|
import "./MixinExchangeRichErrors.sol";
|
||||||
|
|
||||||
|
|
||||||
contract MixinTransactions is
|
contract MixinTransactions is
|
||||||
|
MixinExchangeRichErrors,
|
||||||
LibZeroExTransaction,
|
LibZeroExTransaction,
|
||||||
MSignatureValidator,
|
ISignatureValidator,
|
||||||
MTransactions,
|
ITransactions
|
||||||
MExchangeRichErrors
|
|
||||||
{
|
{
|
||||||
|
// TransactionExecution event is emitted when a ZeroExTransaction is executed.
|
||||||
|
event TransactionExecution(bytes32 indexed transactionHash);
|
||||||
|
|
||||||
// Mapping of transaction hash => executed
|
// Mapping of transaction hash => executed
|
||||||
// This prevents transactions from being executed more than once.
|
// This prevents transactions from being executed more than once.
|
||||||
|
@ -20,23 +20,24 @@ pragma solidity ^0.5.9;
|
|||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import "@0x/contracts-utils/contracts/src/ReentrancyGuard.sol";
|
import "@0x/contracts-utils/contracts/src/ReentrancyGuard.sol";
|
||||||
|
import "@0x/contracts-utils/contracts/src/RichErrors.sol";
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibExchangeSelectors.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibExchangeSelectors.sol";
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibMath.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibMath.sol";
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol";
|
||||||
import "./mixins/MExchangeCore.sol";
|
import "./interfaces/IExchangeCore.sol";
|
||||||
import "./mixins/MWrapperFunctions.sol";
|
import "./interfaces/IWrapperFunctions.sol";
|
||||||
import "./mixins/MExchangeRichErrors.sol";
|
import "./MixinExchangeRichErrors.sol";
|
||||||
|
|
||||||
|
|
||||||
contract MixinWrapperFunctions is
|
contract MixinWrapperFunctions is
|
||||||
|
MixinExchangeRichErrors,
|
||||||
ReentrancyGuard,
|
ReentrancyGuard,
|
||||||
LibExchangeSelectors,
|
LibExchangeSelectors,
|
||||||
LibMath,
|
LibMath,
|
||||||
LibFillResults,
|
LibFillResults,
|
||||||
MExchangeCore,
|
IExchangeCore,
|
||||||
MWrapperFunctions,
|
IWrapperFunctions
|
||||||
MExchangeRichErrors
|
|
||||||
{
|
{
|
||||||
/// @dev Fills the input order. Reverts if exact takerAssetFillAmount not filled.
|
/// @dev Fills the input order. Reverts if exact takerAssetFillAmount not filled.
|
||||||
/// @param order Order struct containing order specifications.
|
/// @param order Order struct containing order specifications.
|
||||||
@ -451,4 +452,17 @@ contract MixinWrapperFunctions is
|
|||||||
}
|
}
|
||||||
return fillResults;
|
return fillResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _fillOrder(
|
||||||
|
LibOrder.Order memory order,
|
||||||
|
uint256 takerAssetFillAmount,
|
||||||
|
bytes memory signature
|
||||||
|
)
|
||||||
|
internal
|
||||||
|
returns (FillResults memory fillResults);
|
||||||
|
|
||||||
|
/// @dev After calling, the order can not be filled anymore.
|
||||||
|
/// @param order Order struct containing order specifications.
|
||||||
|
function _cancelOrder(LibOrder.Order memory order)
|
||||||
|
internal;
|
||||||
}
|
}
|
||||||
|
@ -18,13 +18,91 @@
|
|||||||
|
|
||||||
pragma solidity ^0.5.9;
|
pragma solidity ^0.5.9;
|
||||||
|
|
||||||
|
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
||||||
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
||||||
import "../mixins/MExchangeRichErrorTypes.sol";
|
import "../MixinAssetProxyDispatcher.sol";
|
||||||
|
import "../MixinExchangeRichErrors.sol";
|
||||||
|
import "../MixinSignatureValidator.sol";
|
||||||
|
import "../MixinTransactions.sol";
|
||||||
|
|
||||||
|
|
||||||
contract LibExchangeRichErrorDecoder is
|
contract LibExchangeRichErrorDecoder {
|
||||||
MExchangeRichErrorTypes
|
// bytes4(keccak256("SignatureError(uint8,bytes32,address,bytes)"))
|
||||||
{
|
bytes4 internal constant SIGNATURE_ERROR_SELECTOR =
|
||||||
|
0x7e5a2318;
|
||||||
|
|
||||||
|
// bytes4(keccak256("SignatureValidatorError(bytes32,address,bytes,bytes)"))
|
||||||
|
bytes4 internal constant SIGNATURE_VALIDATOR_ERROR_SELECTOR =
|
||||||
|
0x169fad8c;
|
||||||
|
|
||||||
|
// bytes4(keccak256("SignatureWalletError(bytes32,address,bytes,bytes)"))
|
||||||
|
bytes4 internal constant SIGNATURE_WALLET_ERROR_SELECTOR =
|
||||||
|
0x1b8388f7;
|
||||||
|
|
||||||
|
// bytes4(keccak256("SignatureOrderValidatorError(bytes32,address,bytes,bytes)"))
|
||||||
|
bytes4 internal constant SIGNATURE_ORDER_VALIDATOR_ERROR_SELECTOR =
|
||||||
|
0xfabf4577;
|
||||||
|
|
||||||
|
// bytes4(keccak256("SignatureWalletOrderValidatorError(bytes32,address,bytes,bytes)"))
|
||||||
|
bytes4 internal constant SIGNATURE_WALLET_ORDER_VALIDATOR_ERROR_SELECTOR =
|
||||||
|
0xa85f3360;
|
||||||
|
|
||||||
|
// bytes4(keccak256("OrderStatusError(bytes32,uint8)"))
|
||||||
|
bytes4 internal constant ORDER_STATUS_ERROR_SELECTOR =
|
||||||
|
0xfdb6ca8d;
|
||||||
|
|
||||||
|
// bytes4(keccak256("InvalidSenderError(bytes32,address)"))
|
||||||
|
bytes4 internal constant INVALID_SENDER_ERROR_SELECTOR =
|
||||||
|
0x95b59997;
|
||||||
|
|
||||||
|
// bytes4(keccak256("InvalidMakerError(bytes32,address)"))
|
||||||
|
bytes4 internal constant INVALID_MAKER_ERROR_SELECTOR =
|
||||||
|
0x26bf55d9;
|
||||||
|
|
||||||
|
// bytes4(keccak256("FillError(uint8,bytes32)"))
|
||||||
|
bytes4 internal constant FILL_ERROR_SELECTOR =
|
||||||
|
0xe94a7ed0;
|
||||||
|
|
||||||
|
// bytes4(keccak256("InvalidTakerError(bytes32,address)"))
|
||||||
|
bytes4 internal constant INVALID_TAKER_ERROR_SELECTOR =
|
||||||
|
0xfdb328be;
|
||||||
|
|
||||||
|
// bytes4(keccak256("OrderEpochError(address,address,uint256)"))
|
||||||
|
bytes4 internal constant ORDER_EPOCH_ERROR_SELECTOR =
|
||||||
|
0x4ad31275;
|
||||||
|
|
||||||
|
// bytes4(keccak256("AssetProxyExistsError(address)"))
|
||||||
|
bytes4 internal constant ASSET_PROXY_EXISTS_ERROR_SELECTOR =
|
||||||
|
0xcc8b3b53;
|
||||||
|
|
||||||
|
// bytes4(keccak256("AssetProxyDispatchError(uint8,bytes32,bytes)"))
|
||||||
|
bytes4 internal constant ASSET_PROXY_DISPATCH_ERROR_SELECTOR =
|
||||||
|
0x488219a6;
|
||||||
|
|
||||||
|
// bytes4(keccak256("AssetProxyTransferError(bytes32,bytes,bytes)"))
|
||||||
|
bytes4 internal constant ASSET_PROXY_TRANSFER_ERROR_SELECTOR =
|
||||||
|
0x4678472b;
|
||||||
|
|
||||||
|
// bytes4(keccak256("NegativeSpreadError(bytes32,bytes32)"))
|
||||||
|
bytes4 internal constant NEGATIVE_SPREAD_ERROR_SELECTOR =
|
||||||
|
0xb6555d6f;
|
||||||
|
|
||||||
|
// bytes4(keccak256("TransactionError(uint8,bytes32)"))
|
||||||
|
bytes4 internal constant TRANSACTION_ERROR_SELECTOR =
|
||||||
|
0xf5985184;
|
||||||
|
|
||||||
|
// bytes4(keccak256("TransactionSignatureError(bytes32,address,bytes)"))
|
||||||
|
bytes4 internal constant TRANSACTION_SIGNATURE_ERROR_SELECTOR =
|
||||||
|
0xbfd56ef6;
|
||||||
|
|
||||||
|
// bytes4(keccak256("TransactionExecutionError(bytes32,bytes)"))
|
||||||
|
bytes4 internal constant TRANSACTION_EXECUTION_ERROR_SELECTOR =
|
||||||
|
0x20d11f61;
|
||||||
|
|
||||||
|
// bytes4(keccak256("IncompleteFillError(bytes32)"))
|
||||||
|
bytes4 internal constant INCOMPLETE_FILL_ERROR_SELECTOR =
|
||||||
|
0x152aa60e;
|
||||||
|
|
||||||
/// @dev Decompose an ABI-encoded SignatureError.
|
/// @dev Decompose an ABI-encoded SignatureError.
|
||||||
/// @param encoded ABI-encoded revert error.
|
/// @param encoded ABI-encoded revert error.
|
||||||
/// @return errorCode The error code.
|
/// @return errorCode The error code.
|
||||||
@ -34,14 +112,14 @@ contract LibExchangeRichErrorDecoder is
|
|||||||
public
|
public
|
||||||
pure
|
pure
|
||||||
returns (
|
returns (
|
||||||
SignatureErrorCodes errorCode,
|
MixinExchangeRichErrors.SignatureErrorCodes errorCode,
|
||||||
bytes32 hash,
|
bytes32 hash,
|
||||||
address signerAddress,
|
address signerAddress,
|
||||||
bytes memory signature
|
bytes memory signature
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_assertSelectorBytes(encoded, SIGNATURE_ERROR_SELECTOR);
|
_assertSelectorBytes(encoded, SIGNATURE_ERROR_SELECTOR);
|
||||||
errorCode = SignatureErrorCodes(_readErrorParameterAsUint256(encoded, 0));
|
errorCode = MixinExchangeRichErrors.SignatureErrorCodes(_readErrorParameterAsUint256(encoded, 0));
|
||||||
hash = _readErrorParameterAsBytes32(encoded, 1);
|
hash = _readErrorParameterAsBytes32(encoded, 1);
|
||||||
signerAddress = _readErrorParameterAsAddress(encoded, 2);
|
signerAddress = _readErrorParameterAsAddress(encoded, 2);
|
||||||
signature = _readErrorParameterAsBytes(encoded, 3);
|
signature = _readErrorParameterAsBytes(encoded, 3);
|
||||||
@ -214,12 +292,12 @@ contract LibExchangeRichErrorDecoder is
|
|||||||
public
|
public
|
||||||
pure
|
pure
|
||||||
returns (
|
returns (
|
||||||
FillErrorCodes errorCode,
|
MixinExchangeRichErrors.FillErrorCodes errorCode,
|
||||||
bytes32 orderHash
|
bytes32 orderHash
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_assertSelectorBytes(encoded, FILL_ERROR_SELECTOR);
|
_assertSelectorBytes(encoded, FILL_ERROR_SELECTOR);
|
||||||
errorCode = FillErrorCodes(_readErrorParameterAsUint256(encoded, 0));
|
errorCode = MixinExchangeRichErrors.FillErrorCodes(_readErrorParameterAsUint256(encoded, 0));
|
||||||
orderHash = _readErrorParameterAsBytes32(encoded, 1);
|
orderHash = _readErrorParameterAsBytes32(encoded, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,13 +342,13 @@ contract LibExchangeRichErrorDecoder is
|
|||||||
public
|
public
|
||||||
pure
|
pure
|
||||||
returns (
|
returns (
|
||||||
AssetProxyDispatchErrorCodes errorCode,
|
MixinExchangeRichErrors.AssetProxyDispatchErrorCodes errorCode,
|
||||||
bytes32 orderHash,
|
bytes32 orderHash,
|
||||||
bytes memory assetData
|
bytes memory assetData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_assertSelectorBytes(encoded, ASSET_PROXY_DISPATCH_ERROR_SELECTOR);
|
_assertSelectorBytes(encoded, ASSET_PROXY_DISPATCH_ERROR_SELECTOR);
|
||||||
errorCode = AssetProxyDispatchErrorCodes(_readErrorParameterAsUint256(encoded, 0));
|
errorCode = MixinExchangeRichErrors.AssetProxyDispatchErrorCodes(_readErrorParameterAsUint256(encoded, 0));
|
||||||
orderHash = _readErrorParameterAsBytes32(encoded, 1);
|
orderHash = _readErrorParameterAsBytes32(encoded, 1);
|
||||||
assetData = _readErrorParameterAsBytes(encoded, 2);
|
assetData = _readErrorParameterAsBytes(encoded, 2);
|
||||||
}
|
}
|
||||||
@ -320,12 +398,12 @@ contract LibExchangeRichErrorDecoder is
|
|||||||
public
|
public
|
||||||
pure
|
pure
|
||||||
returns (
|
returns (
|
||||||
TransactionErrorCodes errorCode,
|
MixinExchangeRichErrors.TransactionErrorCodes errorCode,
|
||||||
bytes32 transactionHash
|
bytes32 transactionHash
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_assertSelectorBytes(encoded, TRANSACTION_ERROR_SELECTOR);
|
_assertSelectorBytes(encoded, TRANSACTION_ERROR_SELECTOR);
|
||||||
errorCode = TransactionErrorCodes(_readErrorParameterAsUint256(encoded, 0));
|
errorCode = MixinExchangeRichErrors.TransactionErrorCodes(_readErrorParameterAsUint256(encoded, 0));
|
||||||
transactionHash = _readErrorParameterAsBytes32(encoded, 1);
|
transactionHash = _readErrorParameterAsBytes32(encoded, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2018 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
import "../interfaces/IAssetProxyDispatcher.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract MAssetProxyDispatcher is
|
|
||||||
IAssetProxyDispatcher
|
|
||||||
{
|
|
||||||
// Logs registration of new asset proxy
|
|
||||||
event AssetProxyRegistered(
|
|
||||||
bytes4 id, // Id of new registered AssetProxy.
|
|
||||||
address assetProxy // Address of new registered AssetProxy.
|
|
||||||
);
|
|
||||||
|
|
||||||
/// @dev Forwards arguments to assetProxy and calls `transferFrom`. Either succeeds or throws.
|
|
||||||
/// @param orderHash Hash of the order associated with this transfer.
|
|
||||||
/// @param assetData Byte array encoded for the asset.
|
|
||||||
/// @param from Address to transfer token from.
|
|
||||||
/// @param to Address to transfer token to.
|
|
||||||
/// @param amount Amount of token to transfer.
|
|
||||||
function _dispatchTransferFrom(
|
|
||||||
bytes32 orderHash,
|
|
||||||
bytes memory assetData,
|
|
||||||
address from,
|
|
||||||
address to,
|
|
||||||
uint256 amount
|
|
||||||
)
|
|
||||||
internal;
|
|
||||||
}
|
|
@ -1,159 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2018 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
pragma experimental ABIEncoderV2;
|
|
||||||
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol";
|
|
||||||
import "../interfaces/IExchangeCore.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract MExchangeCore is
|
|
||||||
IExchangeCore
|
|
||||||
{
|
|
||||||
// Fill event is emitted whenever an order is filled.
|
|
||||||
event Fill(
|
|
||||||
address indexed makerAddress, // Address that created the order.
|
|
||||||
address indexed feeRecipientAddress, // Address that received fees.
|
|
||||||
bytes makerAssetData, // Encoded data specific to makerAsset.
|
|
||||||
bytes takerAssetData, // Encoded data specific to takerAsset.
|
|
||||||
bytes makerFeeAssetData, // Encoded data specific to makerFeeAsset.
|
|
||||||
bytes takerFeeAssetData, // Encoded data specific to takerFeeAsset.
|
|
||||||
uint256 makerAssetFilledAmount, // Amount of makerAsset sold by maker and bought by taker.
|
|
||||||
uint256 takerAssetFilledAmount, // Amount of takerAsset sold by taker and bought by maker.
|
|
||||||
uint256 makerFeePaid, // Amount of makerFeeAssetData paid to feeRecipient by maker.
|
|
||||||
uint256 takerFeePaid, // Amount of takerFeeAssetData paid to feeRecipient by taker.
|
|
||||||
address takerAddress, // Address that filled the order.
|
|
||||||
address senderAddress, // Address that called the Exchange contract (msg.sender).
|
|
||||||
bytes32 indexed orderHash // EIP712 hash of order (see LibOrder.getOrderHash).
|
|
||||||
);
|
|
||||||
|
|
||||||
// Cancel event is emitted whenever an individual order is cancelled.
|
|
||||||
event Cancel(
|
|
||||||
address indexed makerAddress, // Address that created the order.
|
|
||||||
address indexed feeRecipientAddress, // Address that would have recieved fees if order was filled.
|
|
||||||
address senderAddress, // Address that called the Exchange contract (msg.sender).
|
|
||||||
bytes32 indexed orderHash, // EIP712 hash of order (see LibOrder.getOrderHash).
|
|
||||||
bytes makerAssetData, // Encoded data specific to makerAsset.
|
|
||||||
bytes takerAssetData // Encoded data specific to takerAsset.
|
|
||||||
);
|
|
||||||
|
|
||||||
// CancelUpTo event is emitted whenever `cancelOrdersUpTo` is executed succesfully.
|
|
||||||
event CancelUpTo(
|
|
||||||
address indexed makerAddress, // Orders cancelled must have been created by this address.
|
|
||||||
address indexed orderSenderAddress, // Orders cancelled must have a `senderAddress` equal to this address.
|
|
||||||
uint256 orderEpoch // Orders with specified makerAddress and senderAddress with a salt less than this value are considered cancelled.
|
|
||||||
);
|
|
||||||
|
|
||||||
/// @dev Fills the input order.
|
|
||||||
/// @param order Order struct containing order specifications.
|
|
||||||
/// @param takerAssetFillAmount Desired amount of takerAsset to sell.
|
|
||||||
/// @param signature Proof that order has been created by maker.
|
|
||||||
/// @return Amounts filled and fees paid by maker and taker.
|
|
||||||
function _fillOrder(
|
|
||||||
LibOrder.Order memory order,
|
|
||||||
uint256 takerAssetFillAmount,
|
|
||||||
bytes memory signature
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
returns (LibFillResults.FillResults memory fillResults);
|
|
||||||
|
|
||||||
/// @dev After calling, the order can not be filled anymore.
|
|
||||||
/// @param order Order struct containing order specifications.
|
|
||||||
function _cancelOrder(LibOrder.Order memory order)
|
|
||||||
internal;
|
|
||||||
|
|
||||||
/// @dev Updates state with results of a fill order.
|
|
||||||
/// @param order that was filled.
|
|
||||||
/// @param takerAddress Address of taker who filled the order.
|
|
||||||
/// @param orderTakerAssetFilledAmount Amount of order already filled.
|
|
||||||
/// @return fillResults Amounts filled and fees paid by maker and taker.
|
|
||||||
function _updateFilledState(
|
|
||||||
LibOrder.Order memory order,
|
|
||||||
address takerAddress,
|
|
||||||
bytes32 orderHash,
|
|
||||||
uint256 orderTakerAssetFilledAmount,
|
|
||||||
LibFillResults.FillResults memory fillResults
|
|
||||||
)
|
|
||||||
internal;
|
|
||||||
|
|
||||||
/// @dev Updates state with results of cancelling an order.
|
|
||||||
/// State is only updated if the order is currently fillable.
|
|
||||||
/// Otherwise, updating state would have no effect.
|
|
||||||
/// @param order that was cancelled.
|
|
||||||
/// @param orderHash Hash of order that was cancelled.
|
|
||||||
function _updateCancelledState(
|
|
||||||
LibOrder.Order memory order,
|
|
||||||
bytes32 orderHash
|
|
||||||
)
|
|
||||||
internal;
|
|
||||||
|
|
||||||
/// @dev Validates context for fillOrder. Succeeds or throws.
|
|
||||||
/// @param order to be filled.
|
|
||||||
/// @param orderInfo OrderStatus, orderHash, and amount already filled of order.
|
|
||||||
/// @param takerAddress Address of order taker.
|
|
||||||
/// @param signature Proof that the orders was created by its maker.
|
|
||||||
function _assertFillableOrder(
|
|
||||||
LibOrder.Order memory order,
|
|
||||||
LibOrder.OrderInfo memory orderInfo,
|
|
||||||
address takerAddress,
|
|
||||||
bytes memory signature
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
view;
|
|
||||||
|
|
||||||
/// @dev Validates context for fillOrder. Succeeds or throws.
|
|
||||||
/// @param order to be filled.
|
|
||||||
/// @param orderInfo Status, orderHash, and amount already filled of order.
|
|
||||||
/// @param takerAssetFillAmount Desired amount of order to fill by taker.
|
|
||||||
/// @param takerAssetFilledAmount Amount of takerAsset that will be filled.
|
|
||||||
/// @param makerAssetFilledAmount Amount of makerAsset that will be transfered.
|
|
||||||
function _assertValidFill(
|
|
||||||
LibOrder.Order memory order,
|
|
||||||
LibOrder.OrderInfo memory orderInfo,
|
|
||||||
uint256 takerAssetFillAmount,
|
|
||||||
uint256 takerAssetFilledAmount,
|
|
||||||
uint256 makerAssetFilledAmount
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
view;
|
|
||||||
|
|
||||||
/// @dev Validates context for cancelOrder. Succeeds or throws.
|
|
||||||
/// @param order to be cancelled.
|
|
||||||
/// @param orderInfo OrderStatus, orderHash, and amount already filled of order.
|
|
||||||
function _assertValidCancel(
|
|
||||||
LibOrder.Order memory order,
|
|
||||||
LibOrder.OrderInfo memory orderInfo
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
view;
|
|
||||||
|
|
||||||
/// @dev Calculates amounts filled and fees paid by maker and taker.
|
|
||||||
/// @param order to be filled.
|
|
||||||
/// @param takerAssetFilledAmount Amount of takerAsset that will be filled.
|
|
||||||
/// @return fillResults Amounts filled and fees paid by maker and taker.
|
|
||||||
function _calculateFillResults(
|
|
||||||
LibOrder.Order memory order,
|
|
||||||
uint256 takerAssetFilledAmount
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (LibFillResults.FillResults memory fillResults);
|
|
||||||
|
|
||||||
}
|
|
@ -1,130 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2018 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
import "@0x/contracts-utils/contracts/src/mixins/MRichErrorTypes.sol";
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract MExchangeRichErrorTypes is
|
|
||||||
MRichErrorTypes
|
|
||||||
{
|
|
||||||
enum FillErrorCodes {
|
|
||||||
INVALID_TAKER_AMOUNT,
|
|
||||||
TAKER_OVERPAY,
|
|
||||||
OVERFILL,
|
|
||||||
INVALID_FILL_PRICE
|
|
||||||
}
|
|
||||||
|
|
||||||
enum SignatureErrorCodes {
|
|
||||||
BAD_SIGNATURE,
|
|
||||||
INVALID_LENGTH,
|
|
||||||
UNSUPPORTED,
|
|
||||||
ILLEGAL,
|
|
||||||
INAPPROPRIATE_SIGNATURE_TYPE
|
|
||||||
}
|
|
||||||
|
|
||||||
enum AssetProxyDispatchErrorCodes {
|
|
||||||
INVALID_ASSET_DATA_LENGTH,
|
|
||||||
UNKNOWN_ASSET_PROXY
|
|
||||||
}
|
|
||||||
|
|
||||||
enum TransactionErrorCodes {
|
|
||||||
NO_REENTRANCY,
|
|
||||||
ALREADY_EXECUTED,
|
|
||||||
EXPIRED
|
|
||||||
}
|
|
||||||
|
|
||||||
// bytes4(keccak256("SignatureError(uint8,bytes32,address,bytes)"))
|
|
||||||
bytes4 internal constant SIGNATURE_ERROR_SELECTOR =
|
|
||||||
0x7e5a2318;
|
|
||||||
|
|
||||||
// bytes4(keccak256("SignatureValidatorError(bytes32,address,bytes,bytes)"))
|
|
||||||
bytes4 internal constant SIGNATURE_VALIDATOR_ERROR_SELECTOR =
|
|
||||||
0x169fad8c;
|
|
||||||
|
|
||||||
// bytes4(keccak256("SignatureWalletError(bytes32,address,bytes,bytes)"))
|
|
||||||
bytes4 internal constant SIGNATURE_WALLET_ERROR_SELECTOR =
|
|
||||||
0x1b8388f7;
|
|
||||||
|
|
||||||
// bytes4(keccak256("SignatureOrderValidatorError(bytes32,address,bytes,bytes)"))
|
|
||||||
bytes4 internal constant SIGNATURE_ORDER_VALIDATOR_ERROR_SELECTOR =
|
|
||||||
0xfabf4577;
|
|
||||||
|
|
||||||
// bytes4(keccak256("SignatureWalletOrderValidatorError(bytes32,address,bytes,bytes)"))
|
|
||||||
bytes4 internal constant SIGNATURE_WALLET_ORDER_VALIDATOR_ERROR_SELECTOR =
|
|
||||||
0xa85f3360;
|
|
||||||
|
|
||||||
// bytes4(keccak256("OrderStatusError(bytes32,uint8)"))
|
|
||||||
bytes4 internal constant ORDER_STATUS_ERROR_SELECTOR =
|
|
||||||
0xfdb6ca8d;
|
|
||||||
|
|
||||||
// bytes4(keccak256("InvalidSenderError(bytes32,address)"))
|
|
||||||
bytes4 internal constant INVALID_SENDER_ERROR_SELECTOR =
|
|
||||||
0x95b59997;
|
|
||||||
|
|
||||||
// bytes4(keccak256("InvalidMakerError(bytes32,address)"))
|
|
||||||
bytes4 internal constant INVALID_MAKER_ERROR_SELECTOR =
|
|
||||||
0x26bf55d9;
|
|
||||||
|
|
||||||
// bytes4(keccak256("FillError(uint8,bytes32)"))
|
|
||||||
bytes4 internal constant FILL_ERROR_SELECTOR =
|
|
||||||
0xe94a7ed0;
|
|
||||||
|
|
||||||
// bytes4(keccak256("InvalidTakerError(bytes32,address)"))
|
|
||||||
bytes4 internal constant INVALID_TAKER_ERROR_SELECTOR =
|
|
||||||
0xfdb328be;
|
|
||||||
|
|
||||||
// bytes4(keccak256("OrderEpochError(address,address,uint256)"))
|
|
||||||
bytes4 internal constant ORDER_EPOCH_ERROR_SELECTOR =
|
|
||||||
0x4ad31275;
|
|
||||||
|
|
||||||
// bytes4(keccak256("AssetProxyExistsError(address)"))
|
|
||||||
bytes4 internal constant ASSET_PROXY_EXISTS_ERROR_SELECTOR =
|
|
||||||
0xcc8b3b53;
|
|
||||||
|
|
||||||
// bytes4(keccak256("AssetProxyDispatchError(uint8,bytes32,bytes)"))
|
|
||||||
bytes4 internal constant ASSET_PROXY_DISPATCH_ERROR_SELECTOR =
|
|
||||||
0x488219a6;
|
|
||||||
|
|
||||||
// bytes4(keccak256("AssetProxyTransferError(bytes32,bytes,bytes)"))
|
|
||||||
bytes4 internal constant ASSET_PROXY_TRANSFER_ERROR_SELECTOR =
|
|
||||||
0x4678472b;
|
|
||||||
|
|
||||||
// bytes4(keccak256("NegativeSpreadError(bytes32,bytes32)"))
|
|
||||||
bytes4 internal constant NEGATIVE_SPREAD_ERROR_SELECTOR =
|
|
||||||
0xb6555d6f;
|
|
||||||
|
|
||||||
// bytes4(keccak256("TransactionError(uint8,bytes32)"))
|
|
||||||
bytes4 internal constant TRANSACTION_ERROR_SELECTOR =
|
|
||||||
0xf5985184;
|
|
||||||
|
|
||||||
// bytes4(keccak256("TransactionSignatureError(bytes32,address,bytes)"))
|
|
||||||
bytes4 internal constant TRANSACTION_SIGNATURE_ERROR_SELECTOR =
|
|
||||||
0xbfd56ef6;
|
|
||||||
|
|
||||||
// bytes4(keccak256("TransactionExecutionError(bytes32,bytes)"))
|
|
||||||
bytes4 internal constant TRANSACTION_EXECUTION_ERROR_SELECTOR =
|
|
||||||
0x20d11f61;
|
|
||||||
|
|
||||||
// bytes4(keccak256("IncompleteFillError(bytes32)"))
|
|
||||||
bytes4 internal constant INCOMPLETE_FILL_ERROR_SELECTOR =
|
|
||||||
0x152aa60e;
|
|
||||||
|
|
||||||
}
|
|
@ -1,194 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2018 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
import "@0x/contracts-utils/contracts/src/mixins/MRichErrors.sol";
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
|
||||||
import "./MExchangeRichErrorTypes.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract MExchangeRichErrors is
|
|
||||||
MExchangeRichErrorTypes,
|
|
||||||
MRichErrors
|
|
||||||
{
|
|
||||||
// solhint-disable func-name-mixedcase
|
|
||||||
function SignatureError(
|
|
||||||
SignatureErrorCodes errorCode,
|
|
||||||
bytes32 hash,
|
|
||||||
address signerAddress,
|
|
||||||
bytes memory signature
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (bytes memory);
|
|
||||||
|
|
||||||
function SignatureValidatorError(
|
|
||||||
bytes32 hash,
|
|
||||||
address signerAddress,
|
|
||||||
bytes memory signature,
|
|
||||||
bytes memory errorData
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (bytes memory);
|
|
||||||
|
|
||||||
function SignatureWalletError(
|
|
||||||
bytes32 hash,
|
|
||||||
address signerAddress,
|
|
||||||
bytes memory signature,
|
|
||||||
bytes memory errorData
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (bytes memory);
|
|
||||||
|
|
||||||
function SignatureOrderValidatorError(
|
|
||||||
bytes32 orderHash,
|
|
||||||
address signerAddress,
|
|
||||||
bytes memory signature,
|
|
||||||
bytes memory errorData
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (bytes memory);
|
|
||||||
|
|
||||||
function SignatureWalletOrderValidatorError(
|
|
||||||
bytes32 orderHash,
|
|
||||||
address wallet,
|
|
||||||
bytes memory signature,
|
|
||||||
bytes memory errorData
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (bytes memory);
|
|
||||||
|
|
||||||
function OrderStatusError(
|
|
||||||
bytes32 orderHash,
|
|
||||||
LibOrder.OrderStatus orderStatus
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (bytes memory);
|
|
||||||
|
|
||||||
function InvalidSenderError(
|
|
||||||
bytes32 orderHash,
|
|
||||||
address senderAddress
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (bytes memory);
|
|
||||||
|
|
||||||
function InvalidMakerError(
|
|
||||||
bytes32 orderHash,
|
|
||||||
address makerAddress
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (bytes memory);
|
|
||||||
|
|
||||||
function FillError(
|
|
||||||
FillErrorCodes errorCode,
|
|
||||||
bytes32 orderHash
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (bytes memory);
|
|
||||||
|
|
||||||
function InvalidTakerError(
|
|
||||||
bytes32 orderHash,
|
|
||||||
address takerAddress
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (bytes memory);
|
|
||||||
|
|
||||||
function OrderEpochError(
|
|
||||||
address makerAddress,
|
|
||||||
address senderAddress,
|
|
||||||
uint256 currentEpoch
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (bytes memory);
|
|
||||||
|
|
||||||
function AssetProxyExistsError(
|
|
||||||
address proxyAddress
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (bytes memory);
|
|
||||||
|
|
||||||
function AssetProxyDispatchError(
|
|
||||||
AssetProxyDispatchErrorCodes errorCode,
|
|
||||||
bytes32 orderHash,
|
|
||||||
bytes memory assetData
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (bytes memory);
|
|
||||||
|
|
||||||
function AssetProxyTransferError(
|
|
||||||
bytes32 orderHash,
|
|
||||||
bytes memory assetData,
|
|
||||||
bytes memory errorData
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (bytes memory);
|
|
||||||
|
|
||||||
function NegativeSpreadError(
|
|
||||||
bytes32 leftOrderHash,
|
|
||||||
bytes32 rightOrderHash
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (bytes memory);
|
|
||||||
|
|
||||||
function TransactionError(
|
|
||||||
TransactionErrorCodes errorCode,
|
|
||||||
bytes32 transactionHash
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (bytes memory);
|
|
||||||
|
|
||||||
function TransactionSignatureError(
|
|
||||||
bytes32 transactionHash,
|
|
||||||
address signerAddress,
|
|
||||||
bytes memory signature
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (bytes memory);
|
|
||||||
|
|
||||||
function TransactionExecutionError(
|
|
||||||
bytes32 transactionHash,
|
|
||||||
bytes memory errorData
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (bytes memory);
|
|
||||||
|
|
||||||
function IncompleteFillError(
|
|
||||||
bytes32 orderHash
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (bytes memory);
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2018 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
pragma experimental ABIEncoderV2;
|
|
||||||
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol";
|
|
||||||
import "../interfaces/IMatchOrders.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract MMatchOrders is
|
|
||||||
IMatchOrders
|
|
||||||
{
|
|
||||||
/// @dev Validates context for matchOrders. Succeeds or throws.
|
|
||||||
/// @param leftOrder First order to match.
|
|
||||||
/// @param rightOrder Second order to match.
|
|
||||||
function _assertValidMatch(
|
|
||||||
LibOrder.Order memory leftOrder,
|
|
||||||
LibOrder.Order memory rightOrder
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
view;
|
|
||||||
|
|
||||||
/// @dev Calculates fill amounts for the matched orders.
|
|
||||||
/// Each order is filled at their respective price point. However, the calculations are
|
|
||||||
/// carried out as though the orders are both being filled at the right order's price point.
|
|
||||||
/// The profit made by the leftOrder order goes to the taker (who matched the two orders).
|
|
||||||
/// @param leftOrder First order to match.
|
|
||||||
/// @param rightOrder Second order to match.
|
|
||||||
/// @param leftOrderTakerAssetFilledAmount Amount of left order already filled.
|
|
||||||
/// @param rightOrderTakerAssetFilledAmount Amount of right order already filled.
|
|
||||||
/// @param matchedFillResults Amounts to fill and fees to pay by maker and taker of matched orders.
|
|
||||||
function _calculateMatchedFillResults(
|
|
||||||
LibOrder.Order memory leftOrder,
|
|
||||||
LibOrder.Order memory rightOrder,
|
|
||||||
uint256 leftOrderTakerAssetFilledAmount,
|
|
||||||
uint256 rightOrderTakerAssetFilledAmount
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (LibFillResults.MatchedFillResults memory matchedFillResults);
|
|
||||||
|
|
||||||
}
|
|
@ -1,65 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2018 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
pragma experimental ABIEncoderV2;
|
|
||||||
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
|
||||||
import "../interfaces/ISignatureValidator.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract MSignatureValidator is
|
|
||||||
ISignatureValidator
|
|
||||||
{
|
|
||||||
event SignatureValidatorApproval(
|
|
||||||
address indexed signerAddress, // Address that approves or disapproves a contract to verify signatures.
|
|
||||||
address indexed validatorAddress, // Address of signature validator contract.
|
|
||||||
bool approved // Approval or disapproval of validator contract.
|
|
||||||
);
|
|
||||||
|
|
||||||
// Allowed signature types.
|
|
||||||
enum SignatureType {
|
|
||||||
Illegal, // 0x00, default value
|
|
||||||
Invalid, // 0x01
|
|
||||||
EIP712, // 0x02
|
|
||||||
EthSign, // 0x03
|
|
||||||
Wallet, // 0x04
|
|
||||||
Validator, // 0x05
|
|
||||||
PreSigned, // 0x06
|
|
||||||
OrderValidator, // 0x07
|
|
||||||
WalletOrderValidator, // 0x08
|
|
||||||
NSignatureTypes // 0x09, number of signature types. Always leave at end.
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @dev Verifies that an order, with provided order hash, has been signed
|
|
||||||
/// by the given signer.
|
|
||||||
/// @param order The order.
|
|
||||||
/// @param orderHash The hash of the order.
|
|
||||||
/// @param signerAddress Address that should have signed the.Signat given hash.
|
|
||||||
/// @param signature Proof that the hash has been signed by signer.
|
|
||||||
/// @return True if the signature is valid for the given hash and signer.
|
|
||||||
function _isValidOrderWithHashSignature(
|
|
||||||
LibOrder.Order memory order,
|
|
||||||
bytes32 orderHash,
|
|
||||||
address signerAddress,
|
|
||||||
bytes memory signature
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
view
|
|
||||||
returns (bool isValid);
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2018 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
pragma experimental ABIEncoderV2;
|
|
||||||
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibZeroExTransaction.sol";
|
|
||||||
import "../interfaces/ITransactions.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract MTransactions is
|
|
||||||
ITransactions
|
|
||||||
{
|
|
||||||
// TransactionExecution event is emitted when a ZeroExTransaction is executed.
|
|
||||||
event TransactionExecution(bytes32 indexed transactionHash);
|
|
||||||
|
|
||||||
/// @dev Executes an Exchange method call in the context of signer.
|
|
||||||
/// @param transaction 0x transaction containing salt, signerAddress, and data.
|
|
||||||
/// @param signature Proof that transaction has been signed by signer.
|
|
||||||
/// @return ABI encoded return data of the underlying Exchange function call.
|
|
||||||
function _executeTransaction(
|
|
||||||
LibZeroExTransaction.ZeroExTransaction memory transaction,
|
|
||||||
bytes memory signature
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
returns (bytes memory);
|
|
||||||
|
|
||||||
/// @dev The current function will be called in the context of this address (either 0x transaction signer or `msg.sender`).
|
|
||||||
/// If calling a fill function, this address will represent the taker.
|
|
||||||
/// If calling a cancel function, this address will represent the maker.
|
|
||||||
/// @return Signer of 0x transaction if entry point is `executeTransaction`.
|
|
||||||
/// `msg.sender` if entry point is any other function.
|
|
||||||
function _getCurrentContextAddress()
|
|
||||||
internal
|
|
||||||
view
|
|
||||||
returns (address);
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2018 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
pragma experimental ABIEncoderV2;
|
|
||||||
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibFillResults.sol";
|
|
||||||
import "../interfaces/IWrapperFunctions.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract MWrapperFunctions is
|
|
||||||
IWrapperFunctions
|
|
||||||
{
|
|
||||||
/// @dev Fills the input order. Reverts if exact takerAssetFillAmount not filled.
|
|
||||||
/// @param order LibOrder.Order struct containing order specifications.
|
|
||||||
/// @param takerAssetFillAmount Desired amount of takerAsset to sell.
|
|
||||||
/// @param signature Proof that order has been created by maker.
|
|
||||||
function _fillOrKillOrder(
|
|
||||||
LibOrder.Order memory order,
|
|
||||||
uint256 takerAssetFillAmount,
|
|
||||||
bytes memory signature
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
returns (LibFillResults.FillResults memory fillResults);
|
|
||||||
}
|
|
@ -19,12 +19,10 @@
|
|||||||
pragma solidity ^0.5.5;
|
pragma solidity ^0.5.5;
|
||||||
|
|
||||||
import "../src/MixinAssetProxyDispatcher.sol";
|
import "../src/MixinAssetProxyDispatcher.sol";
|
||||||
import "../src/MixinExchangeRichErrors.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract TestAssetProxyDispatcher is
|
contract TestAssetProxyDispatcher is
|
||||||
MixinAssetProxyDispatcher,
|
MixinAssetProxyDispatcher
|
||||||
MixinExchangeRichErrors
|
|
||||||
{
|
{
|
||||||
function dispatchTransferFrom(
|
function dispatchTransferFrom(
|
||||||
bytes32 orderHash,
|
bytes32 orderHash,
|
||||||
|
@ -22,14 +22,12 @@ pragma experimental ABIEncoderV2;
|
|||||||
import "@0x/contracts-exchange-libs/contracts/src/LibEIP712ExchangeDomain.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibEIP712ExchangeDomain.sol";
|
||||||
import "../src/MixinSignatureValidator.sol";
|
import "../src/MixinSignatureValidator.sol";
|
||||||
import "../src/MixinTransactions.sol";
|
import "../src/MixinTransactions.sol";
|
||||||
import "../src/MixinExchangeRichErrors.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract TestSignatureValidator is
|
contract TestSignatureValidator is
|
||||||
LibEIP712ExchangeDomain,
|
LibEIP712ExchangeDomain,
|
||||||
MixinSignatureValidator,
|
MixinSignatureValidator,
|
||||||
MixinTransactions,
|
MixinTransactions
|
||||||
MixinExchangeRichErrors
|
|
||||||
{
|
{
|
||||||
|
|
||||||
// solhint-disable no-empty-blocks
|
// solhint-disable no-empty-blocks
|
||||||
|
@ -21,12 +21,12 @@ pragma experimental ABIEncoderV2;
|
|||||||
|
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibExchangeSelectors.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibExchangeSelectors.sol";
|
||||||
import "@0x/contracts-exchange-libs/contracts/src/LibZeroExTransaction.sol";
|
import "@0x/contracts-exchange-libs/contracts/src/LibZeroExTransaction.sol";
|
||||||
import "./mixins/MBalanceThresholdFilterCore.sol";
|
|
||||||
import "./MixinExchangeCalldata.sol";
|
import "./MixinExchangeCalldata.sol";
|
||||||
|
import "./interfaces/IBalanceThresholdFilterCore.sol";
|
||||||
|
|
||||||
|
|
||||||
contract MixinBalanceThresholdFilterCore is
|
contract MixinBalanceThresholdFilterCore is
|
||||||
MBalanceThresholdFilterCore,
|
IBalanceThresholdFilterCore,
|
||||||
MixinExchangeCalldata,
|
MixinExchangeCalldata,
|
||||||
LibExchangeSelectors
|
LibExchangeSelectors
|
||||||
{
|
{
|
||||||
|
@ -19,13 +19,10 @@
|
|||||||
|
|
||||||
pragma solidity ^0.5.9;
|
pragma solidity ^0.5.9;
|
||||||
|
|
||||||
import "./mixins/MExchangeCalldata.sol";
|
|
||||||
import "@0x/contracts-utils/contracts/src/LibAddressArray.sol";
|
import "@0x/contracts-utils/contracts/src/LibAddressArray.sol";
|
||||||
|
|
||||||
|
|
||||||
contract MixinExchangeCalldata is
|
contract MixinExchangeCalldata {
|
||||||
MExchangeCalldata
|
|
||||||
{
|
|
||||||
|
|
||||||
using LibAddressArray for address[];
|
using LibAddressArray for address[];
|
||||||
|
|
||||||
|
@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2018 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
import "@0x/contracts-exchange/contracts/src/interfaces/IExchange.sol";
|
|
||||||
import "../interfaces/IThresholdAsset.sol";
|
|
||||||
import "../interfaces/IBalanceThresholdFilterCore.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract MBalanceThresholdFilterCore is
|
|
||||||
IBalanceThresholdFilterCore
|
|
||||||
{
|
|
||||||
|
|
||||||
// Points to 0x exchange contract
|
|
||||||
// solhint-disable var-name-mixedcase
|
|
||||||
IExchange internal EXCHANGE;
|
|
||||||
|
|
||||||
// The asset that must be held by makers/takers
|
|
||||||
IThresholdAsset internal THRESHOLD_ASSET;
|
|
||||||
|
|
||||||
// The minimum balance of `THRESHOLD_ASSET` that must be held by makers/takers
|
|
||||||
uint256 internal BALANCE_THRESHOLD;
|
|
||||||
// solhint-enable var-name-mixedcase
|
|
||||||
|
|
||||||
// Addresses that hold at least `BALANCE_THRESHOLD` of `THRESHOLD_ASSET`
|
|
||||||
event ValidatedAddresses (
|
|
||||||
address[] addresses
|
|
||||||
);
|
|
||||||
|
|
||||||
/// @dev Constructs an array of addresses to be validated.
|
|
||||||
/// Addresses depend on which Exchange function is to be called
|
|
||||||
/// (defined by `signedExchangeTransaction` above).
|
|
||||||
/// @param signerAddress Address of transaction signer.
|
|
||||||
/// @return addressesToValidate Array of addresses to validate.
|
|
||||||
function _getAddressesToValidate(address signerAddress)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (address[] memory addressesToValidate);
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Copyright 2018 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
|
|
||||||
contract MExchangeCalldata {
|
|
||||||
|
|
||||||
/// @dev Emulates the `calldataload` opcode on the embedded Exchange calldata,
|
|
||||||
/// which is accessed through `signedExchangeTransaction`.
|
|
||||||
/// @param offset Offset into the Exchange calldata.
|
|
||||||
/// @return value Corresponding 32 byte value stored at `offset`.
|
|
||||||
function _exchangeCalldataload(uint256 offset)
|
|
||||||
internal pure
|
|
||||||
returns (bytes32 value);
|
|
||||||
|
|
||||||
/// @dev Convenience function that skips the 4 byte selector when loading
|
|
||||||
/// from the embedded Exchange calldata.
|
|
||||||
/// @param offset Offset into the Exchange calldata (minus the 4 byte selector)
|
|
||||||
/// @return value Corresponding 32 byte value stored at `offset` + 4.
|
|
||||||
function _loadExchangeData(uint256 offset)
|
|
||||||
internal pure
|
|
||||||
returns (bytes32 value);
|
|
||||||
|
|
||||||
/// @dev Extracts the maker address from an order stored in the Exchange calldata
|
|
||||||
/// (which is embedded in `signedExchangeTransaction`).
|
|
||||||
/// @param orderParamIndex Index of the order in the Exchange function's signature.
|
|
||||||
/// @return makerAddress The extracted maker address.
|
|
||||||
function _loadMakerAddressFromOrder(uint256 orderParamIndex)
|
|
||||||
internal pure
|
|
||||||
returns (address makerAddress);
|
|
||||||
|
|
||||||
/// @dev Extracts the maker addresses from an array of orders stored in the Exchange calldata
|
|
||||||
/// (which is embedded in `signedExchangeTransaction`).
|
|
||||||
/// @param orderArrayParamIndex Index of the order array in the Exchange function's signature
|
|
||||||
/// @return makerAddresses The extracted maker addresses.
|
|
||||||
function _loadMakerAddressesFromOrderArray(uint256 orderArrayParamIndex)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (address[] memory makerAddresses);
|
|
||||||
}
|
|
@ -22,12 +22,12 @@ import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
|||||||
import "@0x/contracts-utils/contracts/src/Ownable.sol";
|
import "@0x/contracts-utils/contracts/src/Ownable.sol";
|
||||||
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
|
import "@0x/contracts-erc20/contracts/src/interfaces/IERC20Token.sol";
|
||||||
import "@0x/contracts-erc721/contracts/src/interfaces/IERC721Token.sol";
|
import "@0x/contracts-erc721/contracts/src/interfaces/IERC721Token.sol";
|
||||||
import "./mixins/MAssets.sol";
|
|
||||||
import "./libs/LibConstants.sol";
|
import "./libs/LibConstants.sol";
|
||||||
|
import "./interfaces/IAssets.sol";
|
||||||
|
|
||||||
|
|
||||||
contract MixinAssets is
|
contract MixinAssets is
|
||||||
MAssets,
|
IAssets,
|
||||||
Ownable,
|
Ownable,
|
||||||
LibConstants
|
LibConstants
|
||||||
{
|
{
|
||||||
|
@ -1,71 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2018 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
import "../interfaces/IAssets.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract MAssets is
|
|
||||||
IAssets
|
|
||||||
{
|
|
||||||
/// @dev Transfers given amount of asset to sender.
|
|
||||||
/// @param assetData Byte array encoded for the respective asset proxy.
|
|
||||||
/// @param amount Amount of asset to transfer to sender.
|
|
||||||
function _transferAssetToSender(
|
|
||||||
bytes memory assetData,
|
|
||||||
uint256 amount
|
|
||||||
)
|
|
||||||
internal;
|
|
||||||
|
|
||||||
/// @dev Decodes ERC20 assetData and transfers given amount to sender.
|
|
||||||
/// @param assetData Byte array encoded for the respective asset proxy.
|
|
||||||
/// @param amount Amount of asset to transfer to sender.
|
|
||||||
function _transferERC20Token(
|
|
||||||
bytes memory assetData,
|
|
||||||
uint256 amount
|
|
||||||
)
|
|
||||||
internal;
|
|
||||||
|
|
||||||
/// @dev Decodes ERC721 assetData and transfers given amount to sender.
|
|
||||||
/// @param assetData Byte array encoded for the respective asset proxy.
|
|
||||||
/// @param amount Amount of asset to transfer to sender.
|
|
||||||
function _transferERC721Token(
|
|
||||||
bytes memory assetData,
|
|
||||||
uint256 amount
|
|
||||||
)
|
|
||||||
internal;
|
|
||||||
|
|
||||||
/// @dev Sets approval for ERC20 AssetProxy.
|
|
||||||
/// @param assetData Byte array encoded for the respective asset proxy.
|
|
||||||
/// @param amount Amount of asset to approve for respective proxy.
|
|
||||||
function _approveERC20Token(
|
|
||||||
bytes memory assetData,
|
|
||||||
uint256 amount
|
|
||||||
)
|
|
||||||
internal;
|
|
||||||
|
|
||||||
/// @dev Sets approval for ERC721 AssetProxy.
|
|
||||||
/// @param assetData Byte array encoded for the respective asset proxy.
|
|
||||||
/// @param amount Amount of asset to approve for respective proxy.
|
|
||||||
function _approveERC721Token(
|
|
||||||
bytes memory assetData,
|
|
||||||
uint256 amount
|
|
||||||
)
|
|
||||||
internal;
|
|
||||||
}
|
|
@ -18,12 +18,12 @@
|
|||||||
|
|
||||||
pragma solidity ^0.5.9;
|
pragma solidity ^0.5.9;
|
||||||
|
|
||||||
import "./mixins/MRichErrors.sol";
|
|
||||||
|
|
||||||
|
contract RichErrors {
|
||||||
|
// bytes4(keccak256("Error(string)"))
|
||||||
|
bytes4 internal constant STANDARD_ERROR_SELECTOR =
|
||||||
|
0x08c379a0;
|
||||||
|
|
||||||
contract RichErrors is
|
|
||||||
MRichErrors
|
|
||||||
{
|
|
||||||
// solhint-disable func-name-mixedcase
|
// solhint-disable func-name-mixedcase
|
||||||
/// @dev ABI encode a standard, string revert error payload.
|
/// @dev ABI encode a standard, string revert error payload.
|
||||||
/// This is the same payload that would be included by a `revert(string)`
|
/// This is the same payload that would be included by a `revert(string)`
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
|
|
||||||
contract MRichErrorTypes {
|
|
||||||
// bytes4(keccak256("Error(string)"))
|
|
||||||
bytes4 internal constant STANDARD_ERROR_SELECTOR =
|
|
||||||
0x08c379a0;
|
|
||||||
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
|
|
||||||
Copyright 2019 ZeroEx Intl.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
pragma solidity ^0.5.9;
|
|
||||||
|
|
||||||
import "./MRichErrorTypes.sol";
|
|
||||||
|
|
||||||
|
|
||||||
contract MRichErrors is
|
|
||||||
MRichErrorTypes
|
|
||||||
{
|
|
||||||
// solhint-disable func-name-mixedcase
|
|
||||||
|
|
||||||
/// @dev ABI encode a standard, string revert error payload.
|
|
||||||
/// This is the same payload that would be included by a `revert(string)`
|
|
||||||
/// solidity statement. It has the function signature `Error(string)`.
|
|
||||||
/// @param message The error string.
|
|
||||||
/// @return The ABI encoded error.
|
|
||||||
function StandardError(
|
|
||||||
string memory message
|
|
||||||
)
|
|
||||||
internal
|
|
||||||
pure
|
|
||||||
returns (bytes memory);
|
|
||||||
|
|
||||||
/// @dev Reverts an encoded rich revert reason `errorData`.
|
|
||||||
/// @param errorData ABI encoded error data.
|
|
||||||
function _rrevert(bytes memory errorData)
|
|
||||||
internal
|
|
||||||
pure;
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user