Rename internal and private functions
This commit is contained in:
@@ -69,7 +69,7 @@ contract MixinAssetProxyDispatcher is
|
|||||||
/// @param from Address to transfer token from.
|
/// @param from Address to transfer token from.
|
||||||
/// @param to Address to transfer token to.
|
/// @param to Address to transfer token to.
|
||||||
/// @param amount Amount of token to transfer.
|
/// @param amount Amount of token to transfer.
|
||||||
function dispatchTransferFrom(
|
function _dispatchTransferFrom(
|
||||||
bytes memory assetData,
|
bytes memory assetData,
|
||||||
address from,
|
address from,
|
||||||
address to,
|
address to,
|
||||||
|
@@ -35,7 +35,7 @@ contract MAssetProxyDispatcher is
|
|||||||
/// @param from Address to transfer token from.
|
/// @param from Address to transfer token from.
|
||||||
/// @param to Address to transfer token to.
|
/// @param to Address to transfer token to.
|
||||||
/// @param amount Amount of token to transfer.
|
/// @param amount Amount of token to transfer.
|
||||||
function dispatchTransferFrom(
|
function _dispatchTransferFrom(
|
||||||
bytes memory assetData,
|
bytes memory assetData,
|
||||||
address from,
|
address from,
|
||||||
address to,
|
address to,
|
||||||
|
@@ -63,7 +63,7 @@ contract MixinCoordinatorApprovalVerifier is
|
|||||||
// No approval is required for non-fill methods
|
// No approval is required for non-fill methods
|
||||||
if (orders.length > 0) {
|
if (orders.length > 0) {
|
||||||
// Revert if approval is invalid for transaction orders
|
// Revert if approval is invalid for transaction orders
|
||||||
assertValidTransactionOrdersApproval(
|
_assertValidTransactionOrdersApproval(
|
||||||
transaction,
|
transaction,
|
||||||
orders,
|
orders,
|
||||||
txOrigin,
|
txOrigin,
|
||||||
@@ -132,7 +132,7 @@ contract MixinCoordinatorApprovalVerifier is
|
|||||||
/// @param transactionSignature Proof that the transaction has been signed by the signer.
|
/// @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 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.
|
/// @param approvalSignatures Array of signatures that correspond to the feeRecipients of each order.
|
||||||
function assertValidTransactionOrdersApproval(
|
function _assertValidTransactionOrdersApproval(
|
||||||
LibZeroExTransaction.ZeroExTransaction memory transaction,
|
LibZeroExTransaction.ZeroExTransaction memory transaction,
|
||||||
LibOrder.Order[] memory orders,
|
LibOrder.Order[] memory orders,
|
||||||
address txOrigin,
|
address txOrigin,
|
||||||
|
@@ -44,7 +44,7 @@ contract LibEIP712CoordinatorDomain is
|
|||||||
public
|
public
|
||||||
{
|
{
|
||||||
address verifyingContractAddress = verifyingContractAddressIfExists == address(0) ? address(this) : verifyingContractAddressIfExists;
|
address verifyingContractAddress = verifyingContractAddressIfExists == address(0) ? address(this) : verifyingContractAddressIfExists;
|
||||||
EIP712_COORDINATOR_DOMAIN_HASH = hashEIP712Domain(
|
EIP712_COORDINATOR_DOMAIN_HASH = _hashEIP712Domain(
|
||||||
EIP712_COORDINATOR_DOMAIN_NAME,
|
EIP712_COORDINATOR_DOMAIN_NAME,
|
||||||
EIP712_COORDINATOR_DOMAIN_VERSION,
|
EIP712_COORDINATOR_DOMAIN_VERSION,
|
||||||
chainId,
|
chainId,
|
||||||
@@ -61,6 +61,6 @@ contract LibEIP712CoordinatorDomain is
|
|||||||
view
|
view
|
||||||
returns (bytes32 result)
|
returns (bytes32 result)
|
||||||
{
|
{
|
||||||
return hashEIP712Message(EIP712_COORDINATOR_DOMAIN_HASH, hashStruct);
|
return _hashEIP712Message(EIP712_COORDINATOR_DOMAIN_HASH, hashStruct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -33,7 +33,7 @@ contract MCoordinatorApprovalVerifier is
|
|||||||
/// @param transactionSignature Proof that the transaction has been signed by the signer.
|
/// @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 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.
|
/// @param approvalSignatures Array of signatures that correspond to the feeRecipients of each order.
|
||||||
function assertValidTransactionOrdersApproval(
|
function _assertValidTransactionOrdersApproval(
|
||||||
LibZeroExTransaction.ZeroExTransaction memory transaction,
|
LibZeroExTransaction.ZeroExTransaction memory transaction,
|
||||||
LibOrder.Order[] memory orders,
|
LibOrder.Order[] memory orders,
|
||||||
address txOrigin,
|
address txOrigin,
|
||||||
|
@@ -88,11 +88,11 @@ contract ERC1155 is
|
|||||||
nfOwners[id] = to;
|
nfOwners[id] = to;
|
||||||
// You could keep balance of NF type in base type id like so:
|
// You could keep balance of NF type in base type id like so:
|
||||||
// uint256 baseType = getNonFungibleBaseType(_id);
|
// uint256 baseType = getNonFungibleBaseType(_id);
|
||||||
// balances[baseType][_from] = balances[baseType][_from].safeSub(_value);
|
// balances[baseType][_from] = balances[baseType][_from]._safeSub(_value);
|
||||||
// balances[baseType][_to] = balances[baseType][_to].safeAdd(_value);
|
// balances[baseType][_to] = balances[baseType][_to]._safeAdd(_value);
|
||||||
} else {
|
} else {
|
||||||
balances[id][from] = safeSub(balances[id][from], value);
|
balances[id][from] = _safeSub(balances[id][from], value);
|
||||||
balances[id][to] = safeAdd(balances[id][to], value);
|
balances[id][to] = _safeAdd(balances[id][to], value);
|
||||||
}
|
}
|
||||||
emit TransferSingle(msg.sender, from, to, id, value);
|
emit TransferSingle(msg.sender, from, to, id, value);
|
||||||
|
|
||||||
@@ -170,8 +170,8 @@ contract ERC1155 is
|
|||||||
);
|
);
|
||||||
nfOwners[id] = to;
|
nfOwners[id] = to;
|
||||||
} else {
|
} else {
|
||||||
balances[id][from] = safeSub(balances[id][from], value);
|
balances[id][from] = _safeSub(balances[id][from], value);
|
||||||
balances[id][to] = safeAdd(balances[id][to], value);
|
balances[id][to] = _safeAdd(balances[id][to], value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit TransferBatch(msg.sender, from, to, ids, values);
|
emit TransferBatch(msg.sender, from, to, ids, values);
|
||||||
|
@@ -114,7 +114,7 @@ contract ERC1155Mintable is
|
|||||||
uint256 quantity = quantities[i];
|
uint256 quantity = quantities[i];
|
||||||
|
|
||||||
// Grant the items to the caller
|
// Grant the items to the caller
|
||||||
balances[id][dst] = safeAdd(quantity, balances[id][dst]);
|
balances[id][dst] = _safeAdd(quantity, balances[id][dst]);
|
||||||
|
|
||||||
// Emit the Transfer/Mint event.
|
// Emit the Transfer/Mint event.
|
||||||
// the 0x0 source address implies a mint
|
// the 0x0 source address implies a mint
|
||||||
@@ -172,7 +172,7 @@ contract ERC1155Mintable is
|
|||||||
nfOwners[id] = dst;
|
nfOwners[id] = dst;
|
||||||
|
|
||||||
// You could use base-type id to store NF type balances if you wish.
|
// You could use base-type id to store NF type balances if you wish.
|
||||||
// balances[_type][dst] = quantity.safeAdd(balances[_type][dst]);
|
// balances[_type][dst] = quantity._safeAdd(balances[_type][dst]);
|
||||||
|
|
||||||
emit TransferSingle(msg.sender, address(0x0), dst, id, 1);
|
emit TransferSingle(msg.sender, address(0x0), dst, id, 1);
|
||||||
|
|
||||||
@@ -194,6 +194,6 @@ contract ERC1155Mintable is
|
|||||||
|
|
||||||
// record the `maxIndex` of this nft type
|
// record the `maxIndex` of this nft type
|
||||||
// this allows us to mint more nft's of this type in a subsequent call.
|
// this allows us to mint more nft's of this type in a subsequent call.
|
||||||
maxIndex[type_] = safeAdd(to.length, maxIndex[type_]);
|
maxIndex[type_] = _safeAdd(to.length, maxIndex[type_]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -32,8 +32,8 @@ contract MintableERC20Token is
|
|||||||
function _mint(address _to, uint256 _value)
|
function _mint(address _to, uint256 _value)
|
||||||
internal
|
internal
|
||||||
{
|
{
|
||||||
balances[_to] = safeAdd(_value, balances[_to]);
|
balances[_to] = _safeAdd(_value, balances[_to]);
|
||||||
_totalSupply = safeAdd(_totalSupply, _value);
|
_totalSupply = _safeAdd(_totalSupply, _value);
|
||||||
|
|
||||||
emit Transfer(
|
emit Transfer(
|
||||||
address(0),
|
address(0),
|
||||||
@@ -48,8 +48,8 @@ contract MintableERC20Token is
|
|||||||
function _burn(address _owner, uint256 _value)
|
function _burn(address _owner, uint256 _value)
|
||||||
internal
|
internal
|
||||||
{
|
{
|
||||||
balances[_owner] = safeSub(balances[_owner], _value);
|
balances[_owner] = _safeSub(balances[_owner], _value);
|
||||||
_totalSupply = safeSub(_totalSupply, _value);
|
_totalSupply = _safeSub(_totalSupply, _value);
|
||||||
|
|
||||||
emit Transfer(
|
emit Transfer(
|
||||||
_owner,
|
_owner,
|
||||||
|
@@ -55,9 +55,9 @@ contract DummyERC20Token is
|
|||||||
{
|
{
|
||||||
uint256 currBalance = balances[_target];
|
uint256 currBalance = balances[_target];
|
||||||
if (_value < currBalance) {
|
if (_value < currBalance) {
|
||||||
_totalSupply = safeSub(_totalSupply, safeSub(currBalance, _value));
|
_totalSupply = _safeSub(_totalSupply, _safeSub(currBalance, _value));
|
||||||
} else {
|
} else {
|
||||||
_totalSupply = safeAdd(_totalSupply, safeSub(_value, currBalance));
|
_totalSupply = _safeAdd(_totalSupply, _safeSub(_value, currBalance));
|
||||||
}
|
}
|
||||||
balances[_target] = _value;
|
balances[_target] = _value;
|
||||||
}
|
}
|
||||||
|
@@ -223,8 +223,8 @@ contract ERC721Token is
|
|||||||
}
|
}
|
||||||
|
|
||||||
owners[_tokenId] = _to;
|
owners[_tokenId] = _to;
|
||||||
balances[_from] = safeSub(balances[_from], 1);
|
balances[_from] = _safeSub(balances[_from], 1);
|
||||||
balances[_to] = safeAdd(balances[_to], 1);
|
balances[_to] = _safeAdd(balances[_to], 1);
|
||||||
|
|
||||||
emit Transfer(
|
emit Transfer(
|
||||||
_from,
|
_from,
|
||||||
|
@@ -43,7 +43,7 @@ contract MintableERC721Token is
|
|||||||
);
|
);
|
||||||
|
|
||||||
owners[_tokenId] = _to;
|
owners[_tokenId] = _to;
|
||||||
balances[_to] = safeAdd(balances[_to], 1);
|
balances[_to] = _safeAdd(balances[_to], 1);
|
||||||
|
|
||||||
emit Transfer(
|
emit Transfer(
|
||||||
address(0),
|
address(0),
|
||||||
@@ -71,7 +71,7 @@ contract MintableERC721Token is
|
|||||||
);
|
);
|
||||||
|
|
||||||
owners[_tokenId] = address(0);
|
owners[_tokenId] = address(0);
|
||||||
balances[_owner] = safeSub(balances[_owner], 1);
|
balances[_owner] = _safeSub(balances[_owner], 1);
|
||||||
|
|
||||||
emit Transfer(
|
emit Transfer(
|
||||||
_owner,
|
_owner,
|
||||||
|
@@ -47,13 +47,13 @@ contract MixinAssets is
|
|||||||
external
|
external
|
||||||
onlyOwner
|
onlyOwner
|
||||||
{
|
{
|
||||||
transferAssetToSender(assetData, amount);
|
_transferAssetToSender(assetData, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Transfers given amount of asset to sender.
|
/// @dev Transfers given amount of asset to sender.
|
||||||
/// @param assetData Byte array encoded for the respective asset proxy.
|
/// @param assetData Byte array encoded for the respective asset proxy.
|
||||||
/// @param amount Amount of asset to transfer to sender.
|
/// @param amount Amount of asset to transfer to sender.
|
||||||
function transferAssetToSender(
|
function _transferAssetToSender(
|
||||||
bytes memory assetData,
|
bytes memory assetData,
|
||||||
uint256 amount
|
uint256 amount
|
||||||
)
|
)
|
||||||
@@ -62,9 +62,9 @@ contract MixinAssets is
|
|||||||
bytes4 proxyId = assetData.readBytes4(0);
|
bytes4 proxyId = assetData.readBytes4(0);
|
||||||
|
|
||||||
if (proxyId == ERC20_DATA_ID) {
|
if (proxyId == ERC20_DATA_ID) {
|
||||||
transferERC20Token(assetData, amount);
|
_transferERC20Token(assetData, amount);
|
||||||
} else if (proxyId == ERC721_DATA_ID) {
|
} else if (proxyId == ERC721_DATA_ID) {
|
||||||
transferERC721Token(assetData, amount);
|
_transferERC721Token(assetData, amount);
|
||||||
} else {
|
} else {
|
||||||
revert("UNSUPPORTED_ASSET_PROXY");
|
revert("UNSUPPORTED_ASSET_PROXY");
|
||||||
}
|
}
|
||||||
@@ -73,7 +73,7 @@ contract MixinAssets is
|
|||||||
/// @dev Decodes ERC20 assetData and transfers given amount to sender.
|
/// @dev Decodes ERC20 assetData and transfers given amount to sender.
|
||||||
/// @param assetData Byte array encoded for the respective asset proxy.
|
/// @param assetData Byte array encoded for the respective asset proxy.
|
||||||
/// @param amount Amount of asset to transfer to sender.
|
/// @param amount Amount of asset to transfer to sender.
|
||||||
function transferERC20Token(
|
function _transferERC20Token(
|
||||||
bytes memory assetData,
|
bytes memory assetData,
|
||||||
uint256 amount
|
uint256 amount
|
||||||
)
|
)
|
||||||
@@ -119,7 +119,7 @@ contract MixinAssets is
|
|||||||
/// @dev Decodes ERC721 assetData and transfers given amount to sender.
|
/// @dev Decodes ERC721 assetData and transfers given amount to sender.
|
||||||
/// @param assetData Byte array encoded for the respective asset proxy.
|
/// @param assetData Byte array encoded for the respective asset proxy.
|
||||||
/// @param amount Amount of asset to transfer to sender.
|
/// @param amount Amount of asset to transfer to sender.
|
||||||
function transferERC721Token(
|
function _transferERC721Token(
|
||||||
bytes memory assetData,
|
bytes memory assetData,
|
||||||
uint256 amount
|
uint256 amount
|
||||||
)
|
)
|
||||||
|
@@ -40,7 +40,7 @@ contract MixinExchangeWrapper is
|
|||||||
/// @param takerAssetFillAmount Desired amount of takerAsset to sell.
|
/// @param takerAssetFillAmount Desired amount of takerAsset to sell.
|
||||||
/// @param signature Proof that order has been created by maker.
|
/// @param signature Proof that order has been created by maker.
|
||||||
/// @return Amounts filled and fees paid by maker and taker.
|
/// @return Amounts filled and fees paid by maker and taker.
|
||||||
function fillOrderNoThrow(
|
function _fillOrderNoThrow(
|
||||||
LibOrder.Order memory order,
|
LibOrder.Order memory order,
|
||||||
uint256 takerAssetFillAmount,
|
uint256 takerAssetFillAmount,
|
||||||
bytes memory signature
|
bytes memory signature
|
||||||
@@ -49,7 +49,7 @@ contract MixinExchangeWrapper is
|
|||||||
returns (FillResults memory fillResults)
|
returns (FillResults memory fillResults)
|
||||||
{
|
{
|
||||||
// ABI encode calldata for `fillOrder`
|
// ABI encode calldata for `fillOrder`
|
||||||
bytes memory fillOrderCalldata = abiEncodeFillOrder(
|
bytes memory fillOrderCalldata = _abiEncodeFillOrder(
|
||||||
order,
|
order,
|
||||||
takerAssetFillAmount,
|
takerAssetFillAmount,
|
||||||
signature
|
signature
|
||||||
@@ -85,7 +85,7 @@ contract MixinExchangeWrapper is
|
|||||||
/// @param wethSellAmount Desired amount of WETH to sell.
|
/// @param wethSellAmount Desired amount of WETH to sell.
|
||||||
/// @param signatures Proofs that orders have been signed by makers.
|
/// @param signatures Proofs that orders have been signed by makers.
|
||||||
/// @return Amounts filled and fees paid by makers and taker.
|
/// @return Amounts filled and fees paid by makers and taker.
|
||||||
function marketSellWeth(
|
function _marketSellWeth(
|
||||||
LibOrder.Order[] memory orders,
|
LibOrder.Order[] memory orders,
|
||||||
uint256 wethSellAmount,
|
uint256 wethSellAmount,
|
||||||
bytes[] memory signatures
|
bytes[] memory signatures
|
||||||
@@ -105,17 +105,17 @@ contract MixinExchangeWrapper is
|
|||||||
orders[i].takerAssetData = wethAssetData;
|
orders[i].takerAssetData = wethAssetData;
|
||||||
|
|
||||||
// Calculate the remaining amount of WETH to sell
|
// Calculate the remaining amount of WETH to sell
|
||||||
uint256 remainingTakerAssetFillAmount = safeSub(wethSellAmount, totalFillResults.takerAssetFilledAmount);
|
uint256 remainingTakerAssetFillAmount = _safeSub(wethSellAmount, totalFillResults.takerAssetFilledAmount);
|
||||||
|
|
||||||
// Attempt to sell the remaining amount of WETH
|
// Attempt to sell the remaining amount of WETH
|
||||||
FillResults memory singleFillResults = fillOrderNoThrow(
|
FillResults memory singleFillResults = _fillOrderNoThrow(
|
||||||
orders[i],
|
orders[i],
|
||||||
remainingTakerAssetFillAmount,
|
remainingTakerAssetFillAmount,
|
||||||
signatures[i]
|
signatures[i]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Update amounts filled and fees paid by maker and taker
|
// Update amounts filled and fees paid by maker and taker
|
||||||
addFillResults(totalFillResults, singleFillResults);
|
_addFillResults(totalFillResults, singleFillResults);
|
||||||
|
|
||||||
// Stop execution if the entire amount of takerAsset has been sold
|
// Stop execution if the entire amount of takerAsset has been sold
|
||||||
if (totalFillResults.takerAssetFilledAmount >= wethSellAmount) {
|
if (totalFillResults.takerAssetFilledAmount >= wethSellAmount) {
|
||||||
@@ -132,7 +132,7 @@ contract MixinExchangeWrapper is
|
|||||||
/// @param makerAssetFillAmount Desired amount of makerAsset to buy.
|
/// @param makerAssetFillAmount Desired amount of makerAsset to buy.
|
||||||
/// @param signatures Proofs that orders have been signed by makers.
|
/// @param signatures Proofs that orders have been signed by makers.
|
||||||
/// @return Amounts filled and fees paid by makers and taker.
|
/// @return Amounts filled and fees paid by makers and taker.
|
||||||
function marketBuyExactAmountWithWeth(
|
function _marketBuyExactAmountWithWeth(
|
||||||
LibOrder.Order[] memory orders,
|
LibOrder.Order[] memory orders,
|
||||||
uint256 makerAssetFillAmount,
|
uint256 makerAssetFillAmount,
|
||||||
bytes[] memory signatures
|
bytes[] memory signatures
|
||||||
@@ -153,27 +153,27 @@ contract MixinExchangeWrapper is
|
|||||||
orders[i].takerAssetData = wethAssetData;
|
orders[i].takerAssetData = wethAssetData;
|
||||||
|
|
||||||
// Calculate the remaining amount of makerAsset to buy
|
// Calculate the remaining amount of makerAsset to buy
|
||||||
uint256 remainingMakerAssetFillAmount = safeSub(makerAssetFillAmount, totalFillResults.makerAssetFilledAmount);
|
uint256 remainingMakerAssetFillAmount = _safeSub(makerAssetFillAmount, totalFillResults.makerAssetFilledAmount);
|
||||||
|
|
||||||
// Convert the remaining amount of makerAsset to buy into remaining amount
|
// Convert the remaining amount of makerAsset to buy into remaining amount
|
||||||
// of takerAsset to sell, assuming entire amount can be sold in the current order.
|
// of takerAsset to sell, assuming entire amount can be sold in the current order.
|
||||||
// We round up because the exchange rate computed by fillOrder rounds in favor
|
// We round up because the exchange rate computed by fillOrder rounds in favor
|
||||||
// of the Maker. In this case we want to overestimate the amount of takerAsset.
|
// of the Maker. In this case we want to overestimate the amount of takerAsset.
|
||||||
uint256 remainingTakerAssetFillAmount = getPartialAmountCeil(
|
uint256 remainingTakerAssetFillAmount = _getPartialAmountCeil(
|
||||||
orders[i].takerAssetAmount,
|
orders[i].takerAssetAmount,
|
||||||
orders[i].makerAssetAmount,
|
orders[i].makerAssetAmount,
|
||||||
remainingMakerAssetFillAmount
|
remainingMakerAssetFillAmount
|
||||||
);
|
);
|
||||||
|
|
||||||
// Attempt to sell the remaining amount of takerAsset
|
// Attempt to sell the remaining amount of takerAsset
|
||||||
FillResults memory singleFillResults = fillOrderNoThrow(
|
FillResults memory singleFillResults = _fillOrderNoThrow(
|
||||||
orders[i],
|
orders[i],
|
||||||
remainingTakerAssetFillAmount,
|
remainingTakerAssetFillAmount,
|
||||||
signatures[i]
|
signatures[i]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Update amounts filled and fees paid by maker and taker
|
// Update amounts filled and fees paid by maker and taker
|
||||||
addFillResults(totalFillResults, singleFillResults);
|
_addFillResults(totalFillResults, singleFillResults);
|
||||||
|
|
||||||
// Stop execution if the entire amount of makerAsset has been bought
|
// Stop execution if the entire amount of makerAsset has been bought
|
||||||
makerAssetFilledAmount = totalFillResults.makerAssetFilledAmount;
|
makerAssetFilledAmount = totalFillResults.makerAssetFilledAmount;
|
||||||
@@ -198,7 +198,7 @@ contract MixinExchangeWrapper is
|
|||||||
/// @param zrxBuyAmount Desired amount of ZRX to buy.
|
/// @param zrxBuyAmount Desired amount of ZRX to buy.
|
||||||
/// @param signatures Proofs that orders have been created by makers.
|
/// @param signatures Proofs that orders have been created by makers.
|
||||||
/// @return totalFillResults Amounts filled and fees paid by maker and taker.
|
/// @return totalFillResults Amounts filled and fees paid by maker and taker.
|
||||||
function marketBuyExactZrxWithWeth(
|
function _marketBuyExactZrxWithWeth(
|
||||||
LibOrder.Order[] memory orders,
|
LibOrder.Order[] memory orders,
|
||||||
uint256 zrxBuyAmount,
|
uint256 zrxBuyAmount,
|
||||||
bytes[] memory signatures
|
bytes[] memory signatures
|
||||||
@@ -223,28 +223,28 @@ contract MixinExchangeWrapper is
|
|||||||
orders[i].takerAssetData = wethAssetData;
|
orders[i].takerAssetData = wethAssetData;
|
||||||
|
|
||||||
// Calculate the remaining amount of ZRX to buy.
|
// Calculate the remaining amount of ZRX to buy.
|
||||||
uint256 remainingZrxBuyAmount = safeSub(zrxBuyAmount, zrxPurchased);
|
uint256 remainingZrxBuyAmount = _safeSub(zrxBuyAmount, zrxPurchased);
|
||||||
|
|
||||||
// Convert the remaining amount of ZRX to buy into remaining amount
|
// Convert the remaining amount of ZRX to buy into remaining amount
|
||||||
// of WETH to sell, assuming entire amount can be sold in the current order.
|
// of WETH to sell, assuming entire amount can be sold in the current order.
|
||||||
// We round up because the exchange rate computed by fillOrder rounds in favor
|
// We round up because the exchange rate computed by fillOrder rounds in favor
|
||||||
// of the Maker. In this case we want to overestimate the amount of takerAsset.
|
// of the Maker. In this case we want to overestimate the amount of takerAsset.
|
||||||
uint256 remainingWethSellAmount = getPartialAmountCeil(
|
uint256 remainingWethSellAmount = _getPartialAmountCeil(
|
||||||
orders[i].takerAssetAmount,
|
orders[i].takerAssetAmount,
|
||||||
safeSub(orders[i].makerAssetAmount, orders[i].takerFee), // our exchange rate after fees
|
_safeSub(orders[i].makerAssetAmount, orders[i].takerFee), // our exchange rate after fees
|
||||||
remainingZrxBuyAmount
|
remainingZrxBuyAmount
|
||||||
);
|
);
|
||||||
|
|
||||||
// Attempt to sell the remaining amount of WETH.
|
// Attempt to sell the remaining amount of WETH.
|
||||||
FillResults memory singleFillResult = fillOrderNoThrow(
|
FillResults memory singleFillResult = _fillOrderNoThrow(
|
||||||
orders[i],
|
orders[i],
|
||||||
remainingWethSellAmount,
|
remainingWethSellAmount,
|
||||||
signatures[i]
|
signatures[i]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Update amounts filled and fees paid by maker and taker.
|
// Update amounts filled and fees paid by maker and taker.
|
||||||
addFillResults(totalFillResults, singleFillResult);
|
_addFillResults(totalFillResults, singleFillResult);
|
||||||
zrxPurchased = safeSub(totalFillResults.makerAssetFilledAmount, totalFillResults.takerFeePaid);
|
zrxPurchased = _safeSub(totalFillResults.makerAssetFilledAmount, totalFillResults.takerFeePaid);
|
||||||
|
|
||||||
// Stop execution if the entire amount of ZRX has been bought.
|
// Stop execution if the entire amount of ZRX has been bought.
|
||||||
if (zrxPurchased >= zrxBuyAmount) {
|
if (zrxPurchased >= zrxBuyAmount) {
|
||||||
|
@@ -81,44 +81,44 @@ contract MixinForwarderCore is
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Convert ETH to WETH.
|
// Convert ETH to WETH.
|
||||||
convertEthToWeth();
|
_convertEthToWeth();
|
||||||
|
|
||||||
uint256 wethSellAmount;
|
uint256 wethSellAmount;
|
||||||
uint256 zrxBuyAmount;
|
uint256 zrxBuyAmount;
|
||||||
uint256 makerAssetAmountPurchased;
|
uint256 makerAssetAmountPurchased;
|
||||||
if (orders[0].makerAssetData.equals(ZRX_ASSET_DATA)) {
|
if (orders[0].makerAssetData.equals(ZRX_ASSET_DATA)) {
|
||||||
// Calculate amount of WETH that won't be spent on ETH fees.
|
// Calculate amount of WETH that won't be spent on ETH fees.
|
||||||
wethSellAmount = getPartialAmountFloor(
|
wethSellAmount = _getPartialAmountFloor(
|
||||||
PERCENTAGE_DENOMINATOR,
|
PERCENTAGE_DENOMINATOR,
|
||||||
safeAdd(PERCENTAGE_DENOMINATOR, feePercentage),
|
_safeAdd(PERCENTAGE_DENOMINATOR, feePercentage),
|
||||||
msg.value
|
msg.value
|
||||||
);
|
);
|
||||||
// Market sell available WETH.
|
// Market sell available WETH.
|
||||||
// ZRX fees are paid with this contract's balance.
|
// ZRX fees are paid with this contract's balance.
|
||||||
orderFillResults = marketSellWeth(
|
orderFillResults = _marketSellWeth(
|
||||||
orders,
|
orders,
|
||||||
wethSellAmount,
|
wethSellAmount,
|
||||||
signatures
|
signatures
|
||||||
);
|
);
|
||||||
// The fee amount must be deducted from the amount transfered back to sender.
|
// The fee amount must be deducted from the amount transfered back to sender.
|
||||||
makerAssetAmountPurchased = safeSub(orderFillResults.makerAssetFilledAmount, orderFillResults.takerFeePaid);
|
makerAssetAmountPurchased = _safeSub(orderFillResults.makerAssetFilledAmount, orderFillResults.takerFeePaid);
|
||||||
} else {
|
} else {
|
||||||
// 5% of WETH is reserved for filling feeOrders and paying feeRecipient.
|
// 5% of WETH is reserved for filling feeOrders and paying feeRecipient.
|
||||||
wethSellAmount = getPartialAmountFloor(
|
wethSellAmount = _getPartialAmountFloor(
|
||||||
MAX_WETH_FILL_PERCENTAGE,
|
MAX_WETH_FILL_PERCENTAGE,
|
||||||
PERCENTAGE_DENOMINATOR,
|
PERCENTAGE_DENOMINATOR,
|
||||||
msg.value
|
msg.value
|
||||||
);
|
);
|
||||||
// Market sell 95% of WETH.
|
// Market sell 95% of WETH.
|
||||||
// ZRX fees are payed with this contract's balance.
|
// ZRX fees are payed with this contract's balance.
|
||||||
orderFillResults = marketSellWeth(
|
orderFillResults = _marketSellWeth(
|
||||||
orders,
|
orders,
|
||||||
wethSellAmount,
|
wethSellAmount,
|
||||||
signatures
|
signatures
|
||||||
);
|
);
|
||||||
// Buy back all ZRX spent on fees.
|
// Buy back all ZRX spent on fees.
|
||||||
zrxBuyAmount = orderFillResults.takerFeePaid;
|
zrxBuyAmount = orderFillResults.takerFeePaid;
|
||||||
feeOrderFillResults = marketBuyExactZrxWithWeth(
|
feeOrderFillResults = _marketBuyExactZrxWithWeth(
|
||||||
feeOrders,
|
feeOrders,
|
||||||
zrxBuyAmount,
|
zrxBuyAmount,
|
||||||
feeSignatures
|
feeSignatures
|
||||||
@@ -128,7 +128,7 @@ contract MixinForwarderCore is
|
|||||||
|
|
||||||
// Transfer feePercentage of total ETH spent on primary orders to feeRecipient.
|
// Transfer feePercentage of total ETH spent on primary orders to feeRecipient.
|
||||||
// Refund remaining ETH to msg.sender.
|
// Refund remaining ETH to msg.sender.
|
||||||
transferEthFeeAndRefund(
|
_transferEthFeeAndRefund(
|
||||||
orderFillResults.takerAssetFilledAmount,
|
orderFillResults.takerAssetFilledAmount,
|
||||||
feeOrderFillResults.takerAssetFilledAmount,
|
feeOrderFillResults.takerAssetFilledAmount,
|
||||||
feePercentage,
|
feePercentage,
|
||||||
@@ -136,7 +136,7 @@ contract MixinForwarderCore is
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Transfer purchased assets to msg.sender.
|
// Transfer purchased assets to msg.sender.
|
||||||
transferAssetToSender(orders[0].makerAssetData, makerAssetAmountPurchased);
|
_transferAssetToSender(orders[0].makerAssetData, makerAssetAmountPurchased);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Attempt to purchase makerAssetFillAmount of makerAsset by selling ETH provided with transaction.
|
/// @dev Attempt to purchase makerAssetFillAmount of makerAsset by selling ETH provided with transaction.
|
||||||
@@ -167,31 +167,31 @@ contract MixinForwarderCore is
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Convert ETH to WETH.
|
// Convert ETH to WETH.
|
||||||
convertEthToWeth();
|
_convertEthToWeth();
|
||||||
|
|
||||||
uint256 zrxBuyAmount;
|
uint256 zrxBuyAmount;
|
||||||
uint256 makerAssetAmountPurchased;
|
uint256 makerAssetAmountPurchased;
|
||||||
if (orders[0].makerAssetData.equals(ZRX_ASSET_DATA)) {
|
if (orders[0].makerAssetData.equals(ZRX_ASSET_DATA)) {
|
||||||
// If the makerAsset is ZRX, it is not necessary to pay fees out of this
|
// If the makerAsset is ZRX, it is not necessary to pay fees out of this
|
||||||
// contracts's ZRX balance because fees are factored into the price of the order.
|
// contracts's ZRX balance because fees are factored into the price of the order.
|
||||||
orderFillResults = marketBuyExactZrxWithWeth(
|
orderFillResults = _marketBuyExactZrxWithWeth(
|
||||||
orders,
|
orders,
|
||||||
makerAssetFillAmount,
|
makerAssetFillAmount,
|
||||||
signatures
|
signatures
|
||||||
);
|
);
|
||||||
// The fee amount must be deducted from the amount transfered back to sender.
|
// The fee amount must be deducted from the amount transfered back to sender.
|
||||||
makerAssetAmountPurchased = safeSub(orderFillResults.makerAssetFilledAmount, orderFillResults.takerFeePaid);
|
makerAssetAmountPurchased = _safeSub(orderFillResults.makerAssetFilledAmount, orderFillResults.takerFeePaid);
|
||||||
} else {
|
} else {
|
||||||
// Attemp to purchase desired amount of makerAsset.
|
// Attemp to purchase desired amount of makerAsset.
|
||||||
// ZRX fees are payed with this contract's balance.
|
// ZRX fees are payed with this contract's balance.
|
||||||
orderFillResults = marketBuyExactAmountWithWeth(
|
orderFillResults = _marketBuyExactAmountWithWeth(
|
||||||
orders,
|
orders,
|
||||||
makerAssetFillAmount,
|
makerAssetFillAmount,
|
||||||
signatures
|
signatures
|
||||||
);
|
);
|
||||||
// Buy back all ZRX spent on fees.
|
// Buy back all ZRX spent on fees.
|
||||||
zrxBuyAmount = orderFillResults.takerFeePaid;
|
zrxBuyAmount = orderFillResults.takerFeePaid;
|
||||||
feeOrderFillResults = marketBuyExactZrxWithWeth(
|
feeOrderFillResults = _marketBuyExactZrxWithWeth(
|
||||||
feeOrders,
|
feeOrders,
|
||||||
zrxBuyAmount,
|
zrxBuyAmount,
|
||||||
feeSignatures
|
feeSignatures
|
||||||
@@ -201,7 +201,7 @@ contract MixinForwarderCore is
|
|||||||
|
|
||||||
// Transfer feePercentage of total ETH spent on primary orders to feeRecipient.
|
// Transfer feePercentage of total ETH spent on primary orders to feeRecipient.
|
||||||
// Refund remaining ETH to msg.sender.
|
// Refund remaining ETH to msg.sender.
|
||||||
transferEthFeeAndRefund(
|
_transferEthFeeAndRefund(
|
||||||
orderFillResults.takerAssetFilledAmount,
|
orderFillResults.takerAssetFilledAmount,
|
||||||
feeOrderFillResults.takerAssetFilledAmount,
|
feeOrderFillResults.takerAssetFilledAmount,
|
||||||
feePercentage,
|
feePercentage,
|
||||||
@@ -209,6 +209,6 @@ contract MixinForwarderCore is
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Transfer purchased assets to msg.sender.
|
// Transfer purchased assets to msg.sender.
|
||||||
transferAssetToSender(orders[0].makerAssetData, makerAssetAmountPurchased);
|
_transferAssetToSender(orders[0].makerAssetData, makerAssetAmountPurchased);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -40,7 +40,7 @@ contract MixinWeth is
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Converts message call's ETH value into WETH.
|
/// @dev Converts message call's ETH value into WETH.
|
||||||
function convertEthToWeth()
|
function _convertEthToWeth()
|
||||||
internal
|
internal
|
||||||
{
|
{
|
||||||
require(
|
require(
|
||||||
@@ -56,7 +56,7 @@ contract MixinWeth is
|
|||||||
/// @param wethSoldForZrx Amount of WETH sold when purchasing ZRX required for primary order fees.
|
/// @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 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.
|
/// @param feeRecipient Address that will receive ETH when orders are filled.
|
||||||
function transferEthFeeAndRefund(
|
function _transferEthFeeAndRefund(
|
||||||
uint256 wethSoldExcludingFeeOrders,
|
uint256 wethSoldExcludingFeeOrders,
|
||||||
uint256 wethSoldForZrx,
|
uint256 wethSoldForZrx,
|
||||||
uint256 feePercentage,
|
uint256 feePercentage,
|
||||||
@@ -71,17 +71,17 @@ contract MixinWeth is
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Ensure that no extra WETH owned by this contract has been sold.
|
// Ensure that no extra WETH owned by this contract has been sold.
|
||||||
uint256 wethSold = safeAdd(wethSoldExcludingFeeOrders, wethSoldForZrx);
|
uint256 wethSold = _safeAdd(wethSoldExcludingFeeOrders, wethSoldForZrx);
|
||||||
require(
|
require(
|
||||||
wethSold <= msg.value,
|
wethSold <= msg.value,
|
||||||
"OVERSOLD_WETH"
|
"OVERSOLD_WETH"
|
||||||
);
|
);
|
||||||
|
|
||||||
// Calculate amount of WETH that hasn't been sold.
|
// Calculate amount of WETH that hasn't been sold.
|
||||||
uint256 wethRemaining = safeSub(msg.value, wethSold);
|
uint256 wethRemaining = _safeSub(msg.value, wethSold);
|
||||||
|
|
||||||
// Calculate ETH fee to pay to feeRecipient.
|
// Calculate ETH fee to pay to feeRecipient.
|
||||||
uint256 ethFee = getPartialAmountFloor(
|
uint256 ethFee = _getPartialAmountFloor(
|
||||||
feePercentage,
|
feePercentage,
|
||||||
PERCENTAGE_DENOMINATOR,
|
PERCENTAGE_DENOMINATOR,
|
||||||
wethSoldExcludingFeeOrders
|
wethSoldExcludingFeeOrders
|
||||||
@@ -104,7 +104,7 @@ contract MixinWeth is
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Refund remaining ETH to msg.sender.
|
// Refund remaining ETH to msg.sender.
|
||||||
uint256 ethRefund = safeSub(wethRemaining, ethFee);
|
uint256 ethRefund = _safeSub(wethRemaining, ethFee);
|
||||||
if (ethRefund > 0) {
|
if (ethRefund > 0) {
|
||||||
msg.sender.transfer(ethRefund);
|
msg.sender.transfer(ethRefund);
|
||||||
}
|
}
|
||||||
|
@@ -27,7 +27,7 @@ contract MAssets is
|
|||||||
/// @dev Transfers given amount of asset to sender.
|
/// @dev Transfers given amount of asset to sender.
|
||||||
/// @param assetData Byte array encoded for the respective asset proxy.
|
/// @param assetData Byte array encoded for the respective asset proxy.
|
||||||
/// @param amount Amount of asset to transfer to sender.
|
/// @param amount Amount of asset to transfer to sender.
|
||||||
function transferAssetToSender(
|
function _transferAssetToSender(
|
||||||
bytes memory assetData,
|
bytes memory assetData,
|
||||||
uint256 amount
|
uint256 amount
|
||||||
)
|
)
|
||||||
@@ -36,7 +36,7 @@ contract MAssets is
|
|||||||
/// @dev Decodes ERC20 assetData and transfers given amount to sender.
|
/// @dev Decodes ERC20 assetData and transfers given amount to sender.
|
||||||
/// @param assetData Byte array encoded for the respective asset proxy.
|
/// @param assetData Byte array encoded for the respective asset proxy.
|
||||||
/// @param amount Amount of asset to transfer to sender.
|
/// @param amount Amount of asset to transfer to sender.
|
||||||
function transferERC20Token(
|
function _transferERC20Token(
|
||||||
bytes memory assetData,
|
bytes memory assetData,
|
||||||
uint256 amount
|
uint256 amount
|
||||||
)
|
)
|
||||||
@@ -45,7 +45,7 @@ contract MAssets is
|
|||||||
/// @dev Decodes ERC721 assetData and transfers given amount to sender.
|
/// @dev Decodes ERC721 assetData and transfers given amount to sender.
|
||||||
/// @param assetData Byte array encoded for the respective asset proxy.
|
/// @param assetData Byte array encoded for the respective asset proxy.
|
||||||
/// @param amount Amount of asset to transfer to sender.
|
/// @param amount Amount of asset to transfer to sender.
|
||||||
function transferERC721Token(
|
function _transferERC721Token(
|
||||||
bytes memory assetData,
|
bytes memory assetData,
|
||||||
uint256 amount
|
uint256 amount
|
||||||
)
|
)
|
||||||
|
@@ -31,7 +31,7 @@ contract MExchangeWrapper {
|
|||||||
/// @param takerAssetFillAmount Desired amount of takerAsset to sell.
|
/// @param takerAssetFillAmount Desired amount of takerAsset to sell.
|
||||||
/// @param signature Proof that order has been created by maker.
|
/// @param signature Proof that order has been created by maker.
|
||||||
/// @return Amounts filled and fees paid by maker and taker.
|
/// @return Amounts filled and fees paid by maker and taker.
|
||||||
function fillOrderNoThrow(
|
function _fillOrderNoThrow(
|
||||||
LibOrder.Order memory order,
|
LibOrder.Order memory order,
|
||||||
uint256 takerAssetFillAmount,
|
uint256 takerAssetFillAmount,
|
||||||
bytes memory signature
|
bytes memory signature
|
||||||
@@ -45,7 +45,7 @@ contract MExchangeWrapper {
|
|||||||
/// @param wethSellAmount Desired amount of WETH to sell.
|
/// @param wethSellAmount Desired amount of WETH to sell.
|
||||||
/// @param signatures Proofs that orders have been signed by makers.
|
/// @param signatures Proofs that orders have been signed by makers.
|
||||||
/// @return Amounts filled and fees paid by makers and taker.
|
/// @return Amounts filled and fees paid by makers and taker.
|
||||||
function marketSellWeth(
|
function _marketSellWeth(
|
||||||
LibOrder.Order[] memory orders,
|
LibOrder.Order[] memory orders,
|
||||||
uint256 wethSellAmount,
|
uint256 wethSellAmount,
|
||||||
bytes[] memory signatures
|
bytes[] memory signatures
|
||||||
@@ -60,7 +60,7 @@ contract MExchangeWrapper {
|
|||||||
/// @param makerAssetFillAmount Desired amount of makerAsset to buy.
|
/// @param makerAssetFillAmount Desired amount of makerAsset to buy.
|
||||||
/// @param signatures Proofs that orders have been signed by makers.
|
/// @param signatures Proofs that orders have been signed by makers.
|
||||||
/// @return Amounts filled and fees paid by makers and taker.
|
/// @return Amounts filled and fees paid by makers and taker.
|
||||||
function marketBuyExactAmountWithWeth(
|
function _marketBuyExactAmountWithWeth(
|
||||||
LibOrder.Order[] memory orders,
|
LibOrder.Order[] memory orders,
|
||||||
uint256 makerAssetFillAmount,
|
uint256 makerAssetFillAmount,
|
||||||
bytes[] memory signatures
|
bytes[] memory signatures
|
||||||
@@ -77,7 +77,7 @@ contract MExchangeWrapper {
|
|||||||
/// @param zrxBuyAmount Desired amount of ZRX to buy.
|
/// @param zrxBuyAmount Desired amount of ZRX to buy.
|
||||||
/// @param signatures Proofs that orders have been created by makers.
|
/// @param signatures Proofs that orders have been created by makers.
|
||||||
/// @return totalFillResults Amounts filled and fees paid by maker and taker.
|
/// @return totalFillResults Amounts filled and fees paid by maker and taker.
|
||||||
function marketBuyExactZrxWithWeth(
|
function _marketBuyExactZrxWithWeth(
|
||||||
LibOrder.Order[] memory orders,
|
LibOrder.Order[] memory orders,
|
||||||
uint256 zrxBuyAmount,
|
uint256 zrxBuyAmount,
|
||||||
bytes[] memory signatures
|
bytes[] memory signatures
|
||||||
|
@@ -22,7 +22,7 @@ pragma solidity ^0.5.5;
|
|||||||
contract MWeth {
|
contract MWeth {
|
||||||
|
|
||||||
/// @dev Converts message call's ETH value into WETH.
|
/// @dev Converts message call's ETH value into WETH.
|
||||||
function convertEthToWeth()
|
function _convertEthToWeth()
|
||||||
internal;
|
internal;
|
||||||
|
|
||||||
/// @dev Transfers feePercentage of WETH spent on primary orders to feeRecipient.
|
/// @dev Transfers feePercentage of WETH spent on primary orders to feeRecipient.
|
||||||
@@ -31,7 +31,7 @@ contract MWeth {
|
|||||||
/// @param wethSoldForZrx Amount of WETH sold when purchasing ZRX required for primary order fees.
|
/// @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 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.
|
/// @param feeRecipient Address that will receive ETH when orders are filled.
|
||||||
function transferEthFeeAndRefund(
|
function _transferEthFeeAndRefund(
|
||||||
uint256 wethSoldExcludingFeeOrders,
|
uint256 wethSoldExcludingFeeOrders,
|
||||||
uint256 wethSoldForZrx,
|
uint256 wethSoldForZrx,
|
||||||
uint256 feePercentage,
|
uint256 feePercentage,
|
||||||
|
@@ -25,7 +25,6 @@
|
|||||||
},
|
},
|
||||||
"contracts": [
|
"contracts": [
|
||||||
"src/LibAbiEncoder.sol",
|
"src/LibAbiEncoder.sol",
|
||||||
"src/LibAssetProxyErrors.sol",
|
|
||||||
"src/LibConstants.sol",
|
"src/LibConstants.sol",
|
||||||
"src/LibEIP712ExchangeDomain.sol",
|
"src/LibEIP712ExchangeDomain.sol",
|
||||||
"src/LibFillResults.sol",
|
"src/LibFillResults.sol",
|
||||||
|
@@ -29,7 +29,7 @@ contract LibAbiEncoder {
|
|||||||
/// @param takerAssetFillAmount Desired amount of takerAsset to sell.
|
/// @param takerAssetFillAmount Desired amount of takerAsset to sell.
|
||||||
/// @param signature Proof that order has been created by maker.
|
/// @param signature Proof that order has been created by maker.
|
||||||
/// @return ABI encoded calldata for `fillOrder`.
|
/// @return ABI encoded calldata for `fillOrder`.
|
||||||
function abiEncodeFillOrder(
|
function _abiEncodeFillOrder(
|
||||||
LibOrder.Order memory order,
|
LibOrder.Order memory order,
|
||||||
uint256 takerAssetFillAmount,
|
uint256 takerAssetFillAmount,
|
||||||
bytes memory signature
|
bytes memory signature
|
||||||
|
@@ -43,7 +43,7 @@ contract LibEIP712ExchangeDomain is
|
|||||||
public
|
public
|
||||||
{
|
{
|
||||||
address verifyingContractAddress = verifyingContractAddressIfExists == address(0) ? address(this) : verifyingContractAddressIfExists;
|
address verifyingContractAddress = verifyingContractAddressIfExists == address(0) ? address(this) : verifyingContractAddressIfExists;
|
||||||
EIP712_EXCHANGE_DOMAIN_HASH = hashEIP712Domain(
|
EIP712_EXCHANGE_DOMAIN_HASH = _hashEIP712Domain(
|
||||||
EIP712_EXCHANGE_DOMAIN_NAME,
|
EIP712_EXCHANGE_DOMAIN_NAME,
|
||||||
EIP712_EXCHANGE_DOMAIN_VERSION,
|
EIP712_EXCHANGE_DOMAIN_VERSION,
|
||||||
chainId,
|
chainId,
|
||||||
@@ -55,11 +55,11 @@ contract LibEIP712ExchangeDomain is
|
|||||||
/// of the Exchange contract.
|
/// of the Exchange contract.
|
||||||
/// @param hashStruct The EIP712 hash struct.
|
/// @param hashStruct The EIP712 hash struct.
|
||||||
/// @return EIP712 hash applied to the Exchange EIP712 Domain.
|
/// @return EIP712 hash applied to the Exchange EIP712 Domain.
|
||||||
function hashEIP712ExchangeMessage(bytes32 hashStruct)
|
function _hashEIP712ExchangeMessage(bytes32 hashStruct)
|
||||||
internal
|
internal
|
||||||
view
|
view
|
||||||
returns (bytes32 result)
|
returns (bytes32 result)
|
||||||
{
|
{
|
||||||
return hashEIP712Message(EIP712_EXCHANGE_DOMAIN_HASH, hashStruct);
|
return _hashEIP712Message(EIP712_EXCHANGE_DOMAIN_HASH, hashStruct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -58,7 +58,7 @@ contract LibExchangeErrors {
|
|||||||
/// registerAssetProxy errors ///
|
/// registerAssetProxy errors ///
|
||||||
string constant internal ASSET_PROXY_ALREADY_EXISTS = "ASSET_PROXY_ALREADY_EXISTS"; // AssetProxy with same id already exists.
|
string constant internal ASSET_PROXY_ALREADY_EXISTS = "ASSET_PROXY_ALREADY_EXISTS"; // AssetProxy with same id already exists.
|
||||||
|
|
||||||
/// dispatchTransferFrom errors ///
|
/// _dispatchTransferFrom errors ///
|
||||||
string constant internal ASSET_PROXY_DOES_NOT_EXIST = "ASSET_PROXY_DOES_NOT_EXIST"; // No assetProxy registered at given id.
|
string constant internal ASSET_PROXY_DOES_NOT_EXIST = "ASSET_PROXY_DOES_NOT_EXIST"; // No assetProxy registered at given id.
|
||||||
string constant internal TRANSFER_FAILED = "TRANSFER_FAILED"; // Asset transfer unsuccesful.
|
string constant internal TRANSFER_FAILED = "TRANSFER_FAILED"; // Asset transfer unsuccesful.
|
||||||
|
|
||||||
|
@@ -41,13 +41,13 @@ contract LibFillResults is
|
|||||||
/// Modifies the first FillResults instance specified.
|
/// Modifies the first FillResults instance specified.
|
||||||
/// @param totalFillResults Fill results instance that will be added onto.
|
/// @param totalFillResults Fill results instance that will be added onto.
|
||||||
/// @param singleFillResults Fill results instance that will be added to totalFillResults.
|
/// @param singleFillResults Fill results instance that will be added to totalFillResults.
|
||||||
function addFillResults(FillResults memory totalFillResults, FillResults memory singleFillResults)
|
function _addFillResults(FillResults memory totalFillResults, FillResults memory singleFillResults)
|
||||||
internal
|
internal
|
||||||
pure
|
pure
|
||||||
{
|
{
|
||||||
totalFillResults.makerAssetFilledAmount = safeAdd(totalFillResults.makerAssetFilledAmount, singleFillResults.makerAssetFilledAmount);
|
totalFillResults.makerAssetFilledAmount = _safeAdd(totalFillResults.makerAssetFilledAmount, singleFillResults.makerAssetFilledAmount);
|
||||||
totalFillResults.takerAssetFilledAmount = safeAdd(totalFillResults.takerAssetFilledAmount, singleFillResults.takerAssetFilledAmount);
|
totalFillResults.takerAssetFilledAmount = _safeAdd(totalFillResults.takerAssetFilledAmount, singleFillResults.takerAssetFilledAmount);
|
||||||
totalFillResults.makerFeePaid = safeAdd(totalFillResults.makerFeePaid, singleFillResults.makerFeePaid);
|
totalFillResults.makerFeePaid = _safeAdd(totalFillResults.makerFeePaid, singleFillResults.makerFeePaid);
|
||||||
totalFillResults.takerFeePaid = safeAdd(totalFillResults.takerFeePaid, singleFillResults.takerFeePaid);
|
totalFillResults.takerFeePaid = _safeAdd(totalFillResults.takerFeePaid, singleFillResults.takerFeePaid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -30,7 +30,7 @@ contract LibMath is
|
|||||||
/// @param denominator Denominator.
|
/// @param denominator Denominator.
|
||||||
/// @param target Value to calculate partial of.
|
/// @param target Value to calculate partial of.
|
||||||
/// @return Partial value of target rounded down.
|
/// @return Partial value of target rounded down.
|
||||||
function safeGetPartialAmountFloor(
|
function _safeGetPartialAmountFloor(
|
||||||
uint256 numerator,
|
uint256 numerator,
|
||||||
uint256 denominator,
|
uint256 denominator,
|
||||||
uint256 target
|
uint256 target
|
||||||
@@ -45,7 +45,7 @@ contract LibMath is
|
|||||||
);
|
);
|
||||||
|
|
||||||
require(
|
require(
|
||||||
!isRoundingErrorFloor(
|
!_isRoundingErrorFloor(
|
||||||
numerator,
|
numerator,
|
||||||
denominator,
|
denominator,
|
||||||
target
|
target
|
||||||
@@ -53,8 +53,8 @@ contract LibMath is
|
|||||||
"ROUNDING_ERROR"
|
"ROUNDING_ERROR"
|
||||||
);
|
);
|
||||||
|
|
||||||
partialAmount = safeDiv(
|
partialAmount = _safeDiv(
|
||||||
safeMul(numerator, target),
|
_safeMul(numerator, target),
|
||||||
denominator
|
denominator
|
||||||
);
|
);
|
||||||
return partialAmount;
|
return partialAmount;
|
||||||
@@ -66,7 +66,7 @@ contract LibMath is
|
|||||||
/// @param denominator Denominator.
|
/// @param denominator Denominator.
|
||||||
/// @param target Value to calculate partial of.
|
/// @param target Value to calculate partial of.
|
||||||
/// @return Partial value of target rounded up.
|
/// @return Partial value of target rounded up.
|
||||||
function safeGetPartialAmountCeil(
|
function _safeGetPartialAmountCeil(
|
||||||
uint256 numerator,
|
uint256 numerator,
|
||||||
uint256 denominator,
|
uint256 denominator,
|
||||||
uint256 target
|
uint256 target
|
||||||
@@ -81,7 +81,7 @@ contract LibMath is
|
|||||||
);
|
);
|
||||||
|
|
||||||
require(
|
require(
|
||||||
!isRoundingErrorCeil(
|
!_isRoundingErrorCeil(
|
||||||
numerator,
|
numerator,
|
||||||
denominator,
|
denominator,
|
||||||
target
|
target
|
||||||
@@ -89,13 +89,13 @@ contract LibMath is
|
|||||||
"ROUNDING_ERROR"
|
"ROUNDING_ERROR"
|
||||||
);
|
);
|
||||||
|
|
||||||
// safeDiv computes `floor(a / b)`. We use the identity (a, b integer):
|
// _safeDiv computes `floor(a / b)`. We use the identity (a, b integer):
|
||||||
// ceil(a / b) = floor((a + b - 1) / b)
|
// ceil(a / b) = floor((a + b - 1) / b)
|
||||||
// To implement `ceil(a / b)` using safeDiv.
|
// To implement `ceil(a / b)` using _safeDiv.
|
||||||
partialAmount = safeDiv(
|
partialAmount = _safeDiv(
|
||||||
safeAdd(
|
_safeAdd(
|
||||||
safeMul(numerator, target),
|
_safeMul(numerator, target),
|
||||||
safeSub(denominator, 1)
|
_safeSub(denominator, 1)
|
||||||
),
|
),
|
||||||
denominator
|
denominator
|
||||||
);
|
);
|
||||||
@@ -107,7 +107,7 @@ contract LibMath is
|
|||||||
/// @param denominator Denominator.
|
/// @param denominator Denominator.
|
||||||
/// @param target Value to calculate partial of.
|
/// @param target Value to calculate partial of.
|
||||||
/// @return Partial value of target rounded down.
|
/// @return Partial value of target rounded down.
|
||||||
function getPartialAmountFloor(
|
function _getPartialAmountFloor(
|
||||||
uint256 numerator,
|
uint256 numerator,
|
||||||
uint256 denominator,
|
uint256 denominator,
|
||||||
uint256 target
|
uint256 target
|
||||||
@@ -121,8 +121,8 @@ contract LibMath is
|
|||||||
"DIVISION_BY_ZERO"
|
"DIVISION_BY_ZERO"
|
||||||
);
|
);
|
||||||
|
|
||||||
partialAmount = safeDiv(
|
partialAmount = _safeDiv(
|
||||||
safeMul(numerator, target),
|
_safeMul(numerator, target),
|
||||||
denominator
|
denominator
|
||||||
);
|
);
|
||||||
return partialAmount;
|
return partialAmount;
|
||||||
@@ -133,7 +133,7 @@ contract LibMath is
|
|||||||
/// @param denominator Denominator.
|
/// @param denominator Denominator.
|
||||||
/// @param target Value to calculate partial of.
|
/// @param target Value to calculate partial of.
|
||||||
/// @return Partial value of target rounded up.
|
/// @return Partial value of target rounded up.
|
||||||
function getPartialAmountCeil(
|
function _getPartialAmountCeil(
|
||||||
uint256 numerator,
|
uint256 numerator,
|
||||||
uint256 denominator,
|
uint256 denominator,
|
||||||
uint256 target
|
uint256 target
|
||||||
@@ -147,13 +147,13 @@ contract LibMath is
|
|||||||
"DIVISION_BY_ZERO"
|
"DIVISION_BY_ZERO"
|
||||||
);
|
);
|
||||||
|
|
||||||
// safeDiv computes `floor(a / b)`. We use the identity (a, b integer):
|
// _safeDiv computes `floor(a / b)`. We use the identity (a, b integer):
|
||||||
// ceil(a / b) = floor((a + b - 1) / b)
|
// ceil(a / b) = floor((a + b - 1) / b)
|
||||||
// To implement `ceil(a / b)` using safeDiv.
|
// To implement `ceil(a / b)` using _safeDiv.
|
||||||
partialAmount = safeDiv(
|
partialAmount = _safeDiv(
|
||||||
safeAdd(
|
_safeAdd(
|
||||||
safeMul(numerator, target),
|
_safeMul(numerator, target),
|
||||||
safeSub(denominator, 1)
|
_safeSub(denominator, 1)
|
||||||
),
|
),
|
||||||
denominator
|
denominator
|
||||||
);
|
);
|
||||||
@@ -165,7 +165,7 @@ contract LibMath is
|
|||||||
/// @param denominator Denominator.
|
/// @param denominator Denominator.
|
||||||
/// @param target Value to multiply with numerator/denominator.
|
/// @param target Value to multiply with numerator/denominator.
|
||||||
/// @return Rounding error is present.
|
/// @return Rounding error is present.
|
||||||
function isRoundingErrorFloor(
|
function _isRoundingErrorFloor(
|
||||||
uint256 numerator,
|
uint256 numerator,
|
||||||
uint256 denominator,
|
uint256 denominator,
|
||||||
uint256 target
|
uint256 target
|
||||||
@@ -210,7 +210,7 @@ contract LibMath is
|
|||||||
numerator,
|
numerator,
|
||||||
denominator
|
denominator
|
||||||
);
|
);
|
||||||
isError = safeMul(1000, remainder) >= safeMul(numerator, target);
|
isError = _safeMul(1000, remainder) >= _safeMul(numerator, target);
|
||||||
return isError;
|
return isError;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,7 +219,7 @@ contract LibMath is
|
|||||||
/// @param denominator Denominator.
|
/// @param denominator Denominator.
|
||||||
/// @param target Value to multiply with numerator/denominator.
|
/// @param target Value to multiply with numerator/denominator.
|
||||||
/// @return Rounding error is present.
|
/// @return Rounding error is present.
|
||||||
function isRoundingErrorCeil(
|
function _isRoundingErrorCeil(
|
||||||
uint256 numerator,
|
uint256 numerator,
|
||||||
uint256 denominator,
|
uint256 denominator,
|
||||||
uint256 target
|
uint256 target
|
||||||
@@ -246,8 +246,8 @@ contract LibMath is
|
|||||||
numerator,
|
numerator,
|
||||||
denominator
|
denominator
|
||||||
);
|
);
|
||||||
remainder = safeSub(denominator, remainder) % denominator;
|
remainder = _safeSub(denominator, remainder) % denominator;
|
||||||
isError = safeMul(1000, remainder) >= safeMul(numerator, target);
|
isError = _safeMul(1000, remainder) >= _safeMul(numerator, target);
|
||||||
return isError;
|
return isError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -86,14 +86,14 @@ contract LibOrder is
|
|||||||
view
|
view
|
||||||
returns (bytes32 orderHash)
|
returns (bytes32 orderHash)
|
||||||
{
|
{
|
||||||
orderHash = hashEIP712ExchangeMessage(hashOrder(order));
|
orderHash = _hashEIP712ExchangeMessage(_hashOrder(order));
|
||||||
return orderHash;
|
return orderHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Calculates EIP712 hash of the order.
|
/// @dev Calculates EIP712 hash of the order.
|
||||||
/// @param order The order structure.
|
/// @param order The order structure.
|
||||||
/// @return EIP712 hash of the order.
|
/// @return EIP712 hash of the order.
|
||||||
function hashOrder(Order memory order)
|
function _hashOrder(Order memory order)
|
||||||
internal
|
internal
|
||||||
pure
|
pure
|
||||||
returns (bytes32 result)
|
returns (bytes32 result)
|
||||||
|
@@ -50,14 +50,14 @@ contract LibZeroExTransaction is
|
|||||||
returns (bytes32 transactionHash)
|
returns (bytes32 transactionHash)
|
||||||
{
|
{
|
||||||
// Hash the transaction with the domain separator of the Exchange contract.
|
// Hash the transaction with the domain separator of the Exchange contract.
|
||||||
transactionHash = hashEIP712ExchangeMessage(hashZeroExTransaction(transaction));
|
transactionHash = _hashEIP712ExchangeMessage(_hashZeroExTransaction(transaction));
|
||||||
return transactionHash;
|
return transactionHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Calculates EIP712 hash of the 0x transaction with no domain separator.
|
/// @dev Calculates EIP712 hash of the 0x transaction with no domain separator.
|
||||||
/// @param transaction 0x transaction containing salt, signerAddress, and data.
|
/// @param transaction 0x transaction containing salt, signerAddress, and data.
|
||||||
/// @return EIP712 hash of the transaction with no domain separator.
|
/// @return EIP712 hash of the transaction with no domain separator.
|
||||||
function hashZeroExTransaction(ZeroExTransaction memory transaction)
|
function _hashZeroExTransaction(ZeroExTransaction memory transaction)
|
||||||
internal
|
internal
|
||||||
pure
|
pure
|
||||||
returns (bytes32 result)
|
returns (bytes32 result)
|
||||||
|
@@ -39,7 +39,7 @@ contract TestLibs is
|
|||||||
LibEIP712ExchangeDomain(chainId, address(0))
|
LibEIP712ExchangeDomain(chainId, address(0))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
function publicAbiEncodeFillOrder(
|
function abiEncodeFillOrder(
|
||||||
Order memory order,
|
Order memory order,
|
||||||
uint256 takerAssetFillAmount,
|
uint256 takerAssetFillAmount,
|
||||||
bytes memory signature
|
bytes memory signature
|
||||||
@@ -48,7 +48,7 @@ contract TestLibs is
|
|||||||
pure
|
pure
|
||||||
returns (bytes memory fillOrderCalldata)
|
returns (bytes memory fillOrderCalldata)
|
||||||
{
|
{
|
||||||
fillOrderCalldata = abiEncodeFillOrder(
|
fillOrderCalldata = _abiEncodeFillOrder(
|
||||||
order,
|
order,
|
||||||
takerAssetFillAmount,
|
takerAssetFillAmount,
|
||||||
signature
|
signature
|
||||||
@@ -56,7 +56,7 @@ contract TestLibs is
|
|||||||
return fillOrderCalldata;
|
return fillOrderCalldata;
|
||||||
}
|
}
|
||||||
|
|
||||||
function publicGetPartialAmountFloor(
|
function getPartialAmountFloor(
|
||||||
uint256 numerator,
|
uint256 numerator,
|
||||||
uint256 denominator,
|
uint256 denominator,
|
||||||
uint256 target
|
uint256 target
|
||||||
@@ -65,7 +65,7 @@ contract TestLibs is
|
|||||||
pure
|
pure
|
||||||
returns (uint256 partialAmount)
|
returns (uint256 partialAmount)
|
||||||
{
|
{
|
||||||
partialAmount = getPartialAmountFloor(
|
partialAmount = _getPartialAmountFloor(
|
||||||
numerator,
|
numerator,
|
||||||
denominator,
|
denominator,
|
||||||
target
|
target
|
||||||
@@ -73,7 +73,7 @@ contract TestLibs is
|
|||||||
return partialAmount;
|
return partialAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
function publicGetPartialAmountCeil(
|
function getPartialAmountCeil(
|
||||||
uint256 numerator,
|
uint256 numerator,
|
||||||
uint256 denominator,
|
uint256 denominator,
|
||||||
uint256 target
|
uint256 target
|
||||||
@@ -82,7 +82,7 @@ contract TestLibs is
|
|||||||
pure
|
pure
|
||||||
returns (uint256 partialAmount)
|
returns (uint256 partialAmount)
|
||||||
{
|
{
|
||||||
partialAmount = getPartialAmountCeil(
|
partialAmount = _getPartialAmountCeil(
|
||||||
numerator,
|
numerator,
|
||||||
denominator,
|
denominator,
|
||||||
target
|
target
|
||||||
@@ -90,7 +90,7 @@ contract TestLibs is
|
|||||||
return partialAmount;
|
return partialAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
function publicIsRoundingErrorFloor(
|
function isRoundingErrorFloor(
|
||||||
uint256 numerator,
|
uint256 numerator,
|
||||||
uint256 denominator,
|
uint256 denominator,
|
||||||
uint256 target
|
uint256 target
|
||||||
@@ -99,7 +99,7 @@ contract TestLibs is
|
|||||||
pure
|
pure
|
||||||
returns (bool isError)
|
returns (bool isError)
|
||||||
{
|
{
|
||||||
isError = isRoundingErrorFloor(
|
isError = _isRoundingErrorFloor(
|
||||||
numerator,
|
numerator,
|
||||||
denominator,
|
denominator,
|
||||||
target
|
target
|
||||||
@@ -107,7 +107,7 @@ contract TestLibs is
|
|||||||
return isError;
|
return isError;
|
||||||
}
|
}
|
||||||
|
|
||||||
function publicIsRoundingErrorCeil(
|
function isRoundingErrorCeil(
|
||||||
uint256 numerator,
|
uint256 numerator,
|
||||||
uint256 denominator,
|
uint256 denominator,
|
||||||
uint256 target
|
uint256 target
|
||||||
@@ -116,7 +116,7 @@ contract TestLibs is
|
|||||||
pure
|
pure
|
||||||
returns (bool isError)
|
returns (bool isError)
|
||||||
{
|
{
|
||||||
isError = isRoundingErrorCeil(
|
isError = _isRoundingErrorCeil(
|
||||||
numerator,
|
numerator,
|
||||||
denominator,
|
denominator,
|
||||||
target
|
target
|
||||||
@@ -124,7 +124,7 @@ contract TestLibs is
|
|||||||
return isError;
|
return isError;
|
||||||
}
|
}
|
||||||
|
|
||||||
function publicGetOrderHash(Order memory order)
|
function getOrderHash(Order memory order)
|
||||||
public
|
public
|
||||||
view
|
view
|
||||||
returns (bytes32 orderHash)
|
returns (bytes32 orderHash)
|
||||||
@@ -157,12 +157,12 @@ contract TestLibs is
|
|||||||
return EIP712_EXCHANGE_DOMAIN_HASH;
|
return EIP712_EXCHANGE_DOMAIN_HASH;
|
||||||
}
|
}
|
||||||
|
|
||||||
function publicAddFillResults(FillResults memory totalFillResults, FillResults memory singleFillResults)
|
function addFillResults(FillResults memory totalFillResults, FillResults memory singleFillResults)
|
||||||
public
|
public
|
||||||
pure
|
pure
|
||||||
returns (FillResults memory)
|
returns (FillResults memory)
|
||||||
{
|
{
|
||||||
addFillResults(totalFillResults, singleFillResults);
|
_addFillResults(totalFillResults, singleFillResults);
|
||||||
return totalFillResults;
|
return totalFillResults;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,6 @@
|
|||||||
import { ContractArtifact } from 'ethereum-types';
|
import { ContractArtifact } from 'ethereum-types';
|
||||||
|
|
||||||
import * as LibAbiEncoder from '../generated-artifacts/LibAbiEncoder.json';
|
import * as LibAbiEncoder from '../generated-artifacts/LibAbiEncoder.json';
|
||||||
import * as LibAssetProxyErrors from '../generated-artifacts/LibAssetProxyErrors.json';
|
|
||||||
import * as LibConstants from '../generated-artifacts/LibConstants.json';
|
import * as LibConstants from '../generated-artifacts/LibConstants.json';
|
||||||
import * as LibEIP712ExchangeDomain from '../generated-artifacts/LibEIP712ExchangeDomain.json';
|
import * as LibEIP712ExchangeDomain from '../generated-artifacts/LibEIP712ExchangeDomain.json';
|
||||||
import * as LibFillResults from '../generated-artifacts/LibFillResults.json';
|
import * as LibFillResults from '../generated-artifacts/LibFillResults.json';
|
||||||
@@ -16,7 +15,6 @@ import * as LibZeroExTransaction from '../generated-artifacts/LibZeroExTransacti
|
|||||||
import * as TestLibs from '../generated-artifacts/TestLibs.json';
|
import * as TestLibs from '../generated-artifacts/TestLibs.json';
|
||||||
export const artifacts = {
|
export const artifacts = {
|
||||||
LibAbiEncoder: LibAbiEncoder as ContractArtifact,
|
LibAbiEncoder: LibAbiEncoder as ContractArtifact,
|
||||||
LibAssetProxyErrors: LibAssetProxyErrors as ContractArtifact,
|
|
||||||
LibConstants: LibConstants as ContractArtifact,
|
LibConstants: LibConstants as ContractArtifact,
|
||||||
LibFillResults: LibFillResults as ContractArtifact,
|
LibFillResults: LibFillResults as ContractArtifact,
|
||||||
LibMath: LibMath as ContractArtifact,
|
LibMath: LibMath as ContractArtifact,
|
||||||
|
@@ -4,7 +4,6 @@
|
|||||||
* -----------------------------------------------------------------------------
|
* -----------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
export * from '../generated-wrappers/lib_abi_encoder';
|
export * from '../generated-wrappers/lib_abi_encoder';
|
||||||
export * from '../generated-wrappers/lib_asset_proxy_errors';
|
|
||||||
export * from '../generated-wrappers/lib_constants';
|
export * from '../generated-wrappers/lib_constants';
|
||||||
export * from '../generated-wrappers/lib_e_i_p712_exchange_domain';
|
export * from '../generated-wrappers/lib_e_i_p712_exchange_domain';
|
||||||
export * from '../generated-wrappers/lib_fill_results';
|
export * from '../generated-wrappers/lib_fill_results';
|
||||||
|
@@ -88,7 +88,7 @@ describe('Exchange libs', () => {
|
|||||||
const denominator = new BigNumber(999);
|
const denominator = new BigNumber(999);
|
||||||
const target = new BigNumber(50);
|
const target = new BigNumber(50);
|
||||||
// rounding error = ((20*50/999) - floor(20*50/999)) / (20*50/999) = 0.1%
|
// rounding error = ((20*50/999) - floor(20*50/999)) / (20*50/999) = 0.1%
|
||||||
const isRoundingError = await libs.publicIsRoundingErrorFloor.callAsync(numerator, denominator, target);
|
const isRoundingError = await libs.isRoundingErrorFloor.callAsync(numerator, denominator, target);
|
||||||
expect(isRoundingError).to.be.true();
|
expect(isRoundingError).to.be.true();
|
||||||
});
|
});
|
||||||
it('should return false if there is a rounding of 0.09%', async () => {
|
it('should return false if there is a rounding of 0.09%', async () => {
|
||||||
@@ -96,7 +96,7 @@ describe('Exchange libs', () => {
|
|||||||
const denominator = new BigNumber(9991);
|
const denominator = new BigNumber(9991);
|
||||||
const target = new BigNumber(500);
|
const target = new BigNumber(500);
|
||||||
// rounding error = ((20*500/9991) - floor(20*500/9991)) / (20*500/9991) = 0.09%
|
// rounding error = ((20*500/9991) - floor(20*500/9991)) / (20*500/9991) = 0.09%
|
||||||
const isRoundingError = await libs.publicIsRoundingErrorFloor.callAsync(numerator, denominator, target);
|
const isRoundingError = await libs.isRoundingErrorFloor.callAsync(numerator, denominator, target);
|
||||||
expect(isRoundingError).to.be.false();
|
expect(isRoundingError).to.be.false();
|
||||||
});
|
});
|
||||||
it('should return true if there is a rounding error of 0.11%', async () => {
|
it('should return true if there is a rounding error of 0.11%', async () => {
|
||||||
@@ -104,7 +104,7 @@ describe('Exchange libs', () => {
|
|||||||
const denominator = new BigNumber(9989);
|
const denominator = new BigNumber(9989);
|
||||||
const target = new BigNumber(500);
|
const target = new BigNumber(500);
|
||||||
// rounding error = ((20*500/9989) - floor(20*500/9989)) / (20*500/9989) = 0.011%
|
// rounding error = ((20*500/9989) - floor(20*500/9989)) / (20*500/9989) = 0.011%
|
||||||
const isRoundingError = await libs.publicIsRoundingErrorFloor.callAsync(numerator, denominator, target);
|
const isRoundingError = await libs.isRoundingErrorFloor.callAsync(numerator, denominator, target);
|
||||||
expect(isRoundingError).to.be.true();
|
expect(isRoundingError).to.be.true();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -114,7 +114,7 @@ describe('Exchange libs', () => {
|
|||||||
const denominator = new BigNumber(1001);
|
const denominator = new BigNumber(1001);
|
||||||
const target = new BigNumber(50);
|
const target = new BigNumber(50);
|
||||||
// rounding error = (ceil(20*50/1001) - (20*50/1001)) / (20*50/1001) = 0.1%
|
// rounding error = (ceil(20*50/1001) - (20*50/1001)) / (20*50/1001) = 0.1%
|
||||||
const isRoundingError = await libs.publicIsRoundingErrorCeil.callAsync(numerator, denominator, target);
|
const isRoundingError = await libs.isRoundingErrorCeil.callAsync(numerator, denominator, target);
|
||||||
expect(isRoundingError).to.be.true();
|
expect(isRoundingError).to.be.true();
|
||||||
});
|
});
|
||||||
it('should return false if there is a rounding of 0.09%', async () => {
|
it('should return false if there is a rounding of 0.09%', async () => {
|
||||||
@@ -122,7 +122,7 @@ describe('Exchange libs', () => {
|
|||||||
const denominator = new BigNumber(10009);
|
const denominator = new BigNumber(10009);
|
||||||
const target = new BigNumber(500);
|
const target = new BigNumber(500);
|
||||||
// rounding error = (ceil(20*500/10009) - (20*500/10009)) / (20*500/10009) = 0.09%
|
// rounding error = (ceil(20*500/10009) - (20*500/10009)) / (20*500/10009) = 0.09%
|
||||||
const isRoundingError = await libs.publicIsRoundingErrorCeil.callAsync(numerator, denominator, target);
|
const isRoundingError = await libs.isRoundingErrorCeil.callAsync(numerator, denominator, target);
|
||||||
expect(isRoundingError).to.be.false();
|
expect(isRoundingError).to.be.false();
|
||||||
});
|
});
|
||||||
it('should return true if there is a rounding error of 0.11%', async () => {
|
it('should return true if there is a rounding error of 0.11%', async () => {
|
||||||
@@ -130,7 +130,7 @@ describe('Exchange libs', () => {
|
|||||||
const denominator = new BigNumber(10011);
|
const denominator = new BigNumber(10011);
|
||||||
const target = new BigNumber(500);
|
const target = new BigNumber(500);
|
||||||
// rounding error = (ceil(20*500/10011) - (20*500/10011)) / (20*500/10011) = 0.11%
|
// rounding error = (ceil(20*500/10011) - (20*500/10011)) / (20*500/10011) = 0.11%
|
||||||
const isRoundingError = await libs.publicIsRoundingErrorCeil.callAsync(numerator, denominator, target);
|
const isRoundingError = await libs.isRoundingErrorCeil.callAsync(numerator, denominator, target);
|
||||||
expect(isRoundingError).to.be.true();
|
expect(isRoundingError).to.be.true();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -140,13 +140,13 @@ describe('Exchange libs', () => {
|
|||||||
describe('getOrderHash', () => {
|
describe('getOrderHash', () => {
|
||||||
it('should output the correct orderHash', async () => {
|
it('should output the correct orderHash', async () => {
|
||||||
signedOrder = await orderFactory.newSignedOrderAsync();
|
signedOrder = await orderFactory.newSignedOrderAsync();
|
||||||
const orderHashHex = await libs.publicGetOrderHash.callAsync(signedOrder);
|
const orderHashHex = await libs.getOrderHash.callAsync(signedOrder);
|
||||||
expect(orderHashUtils.getOrderHashHex(signedOrder)).to.be.equal(orderHashHex);
|
expect(orderHashUtils.getOrderHashHex(signedOrder)).to.be.equal(orderHashHex);
|
||||||
});
|
});
|
||||||
it('orderHash should differ if chainId is different', async () => {
|
it('orderHash should differ if chainId is different', async () => {
|
||||||
signedOrder = await orderFactory.newSignedOrderAsync();
|
signedOrder = await orderFactory.newSignedOrderAsync();
|
||||||
const orderHashHex1 = await libsAlternateChain.publicGetOrderHash.callAsync(signedOrder);
|
const orderHashHex1 = await libsAlternateChain.getOrderHash.callAsync(signedOrder);
|
||||||
const orderHashHex2 = await libs.publicGetOrderHash.callAsync(signedOrder);
|
const orderHashHex2 = await libs.getOrderHash.callAsync(signedOrder);
|
||||||
expect(orderHashHex1).to.be.not.equal(orderHashHex2);
|
expect(orderHashHex1).to.be.not.equal(orderHashHex2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -57,7 +57,7 @@ contract Wallet is
|
|||||||
"LENGTH_65_REQUIRED"
|
"LENGTH_65_REQUIRED"
|
||||||
);
|
);
|
||||||
|
|
||||||
return validateEIP712Signature(hash, signature);
|
return _validateEIP712Signature(hash, signature);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Validates an order AND EIP712 signature.
|
/// @dev Validates an order AND EIP712 signature.
|
||||||
@@ -80,10 +80,10 @@ contract Wallet is
|
|||||||
order.makerAddress == WALLET_OWNER,
|
order.makerAddress == WALLET_OWNER,
|
||||||
"INVALID_ORDER_MAKER"
|
"INVALID_ORDER_MAKER"
|
||||||
);
|
);
|
||||||
return validateEIP712Signature(orderHash, signature);
|
return _validateEIP712Signature(orderHash, signature);
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateEIP712Signature(
|
function _validateEIP712Signature(
|
||||||
bytes32 hash,
|
bytes32 hash,
|
||||||
bytes memory signature
|
bytes memory signature
|
||||||
)
|
)
|
||||||
|
@@ -43,7 +43,7 @@ contract MixinAssetProxyDispatcher is
|
|||||||
bytes4 assetProxyId = IAssetProxy(assetProxy).getProxyId();
|
bytes4 assetProxyId = IAssetProxy(assetProxy).getProxyId();
|
||||||
address currentAssetProxy = assetProxies[assetProxyId];
|
address currentAssetProxy = assetProxies[assetProxyId];
|
||||||
if (currentAssetProxy != address(0)) {
|
if (currentAssetProxy != address(0)) {
|
||||||
rrevert(AssetProxyExistsError(currentAssetProxy));
|
_rrevert(AssetProxyExistsError(currentAssetProxy));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add asset proxy and log registration.
|
// Add asset proxy and log registration.
|
||||||
@@ -71,7 +71,7 @@ contract MixinAssetProxyDispatcher is
|
|||||||
/// @param from Address to transfer token from.
|
/// @param from Address to transfer token from.
|
||||||
/// @param to Address to transfer token to.
|
/// @param to Address to transfer token to.
|
||||||
/// @param amount Amount of token to transfer.
|
/// @param amount Amount of token to transfer.
|
||||||
function dispatchTransferFrom(
|
function _dispatchTransferFrom(
|
||||||
bytes32 orderHash,
|
bytes32 orderHash,
|
||||||
bytes memory assetData,
|
bytes memory assetData,
|
||||||
address from,
|
address from,
|
||||||
@@ -84,7 +84,7 @@ contract MixinAssetProxyDispatcher is
|
|||||||
if (amount > 0 && from != to) {
|
if (amount > 0 && from != to) {
|
||||||
// Ensure assetData length is valid
|
// Ensure assetData length is valid
|
||||||
if (assetData.length <= 3) {
|
if (assetData.length <= 3) {
|
||||||
rrevert(AssetProxyDispatchError(
|
_rrevert(AssetProxyDispatchError(
|
||||||
AssetProxyDispatchErrorCodes.INVALID_ASSET_DATA_LENGTH,
|
AssetProxyDispatchErrorCodes.INVALID_ASSET_DATA_LENGTH,
|
||||||
orderHash,
|
orderHash,
|
||||||
assetData
|
assetData
|
||||||
@@ -103,7 +103,7 @@ contract MixinAssetProxyDispatcher is
|
|||||||
|
|
||||||
// Ensure that assetProxy exists
|
// Ensure that assetProxy exists
|
||||||
if (assetProxy == address(0)) {
|
if (assetProxy == address(0)) {
|
||||||
rrevert(AssetProxyDispatchError(
|
_rrevert(AssetProxyDispatchError(
|
||||||
AssetProxyDispatchErrorCodes.UNKNOWN_ASSET_PROXY,
|
AssetProxyDispatchErrorCodes.UNKNOWN_ASSET_PROXY,
|
||||||
orderHash,
|
orderHash,
|
||||||
assetData
|
assetData
|
||||||
@@ -194,7 +194,7 @@ contract MixinAssetProxyDispatcher is
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!didSucceed) {
|
if (!didSucceed) {
|
||||||
rrevert(AssetProxyTransferError(
|
_rrevert(AssetProxyTransferError(
|
||||||
orderHash,
|
orderHash,
|
||||||
assetData,
|
assetData,
|
||||||
revertData
|
revertData
|
||||||
|
@@ -60,25 +60,25 @@ contract MixinExchangeCore is
|
|||||||
external
|
external
|
||||||
nonReentrant
|
nonReentrant
|
||||||
{
|
{
|
||||||
address makerAddress = getCurrentContextAddress();
|
address makerAddress = _getCurrentContextAddress();
|
||||||
// If this function is called via `executeTransaction`, we only update the orderEpoch for the makerAddress/msg.sender combination.
|
// If this function is called via `executeTransaction`, we only update the orderEpoch for the makerAddress/msg.sender combination.
|
||||||
// This allows external filter contracts to add rules to how orders are cancelled via this function.
|
// This allows external filter contracts to add rules to how orders are cancelled via this function.
|
||||||
address senderAddress = makerAddress == msg.sender ? address(0) : msg.sender;
|
address orderSenderAddress = makerAddress == msg.sender ? address(0) : msg.sender;
|
||||||
|
|
||||||
// orderEpoch is initialized to 0, so to cancelUpTo we need salt + 1
|
// orderEpoch is initialized to 0, so to cancelUpTo we need salt + 1
|
||||||
uint256 newOrderEpoch = targetOrderEpoch + 1;
|
uint256 newOrderEpoch = targetOrderEpoch + 1;
|
||||||
uint256 oldOrderEpoch = orderEpoch[makerAddress][senderAddress];
|
uint256 oldOrderEpoch = orderEpoch[makerAddress][orderSenderAddress];
|
||||||
|
|
||||||
// Ensure orderEpoch is monotonically increasing
|
// Ensure orderEpoch is monotonically increasing
|
||||||
if (newOrderEpoch <= oldOrderEpoch) {
|
if (newOrderEpoch <= oldOrderEpoch) {
|
||||||
rrevert(OrderEpochError(makerAddress, senderAddress, oldOrderEpoch));
|
_rrevert(OrderEpochError(makerAddress, orderSenderAddress, oldOrderEpoch));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update orderEpoch
|
// Update orderEpoch
|
||||||
orderEpoch[makerAddress][senderAddress] = newOrderEpoch;
|
orderEpoch[makerAddress][orderSenderAddress] = newOrderEpoch;
|
||||||
emit CancelUpTo(
|
emit CancelUpTo(
|
||||||
makerAddress,
|
makerAddress,
|
||||||
senderAddress,
|
orderSenderAddress,
|
||||||
newOrderEpoch
|
newOrderEpoch
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ contract MixinExchangeCore is
|
|||||||
nonReentrant
|
nonReentrant
|
||||||
returns (FillResults memory fillResults)
|
returns (FillResults memory fillResults)
|
||||||
{
|
{
|
||||||
fillResults = fillOrderInternal(
|
fillResults = _fillOrder(
|
||||||
order,
|
order,
|
||||||
takerAssetFillAmount,
|
takerAssetFillAmount,
|
||||||
signature
|
signature
|
||||||
@@ -112,7 +112,7 @@ contract MixinExchangeCore is
|
|||||||
public
|
public
|
||||||
nonReentrant
|
nonReentrant
|
||||||
{
|
{
|
||||||
cancelOrderInternal(order);
|
_cancelOrder(order);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Gets information about an order: status, hash, and amount filled.
|
/// @dev Gets information about an order: status, hash, and amount filled.
|
||||||
@@ -181,7 +181,7 @@ contract MixinExchangeCore is
|
|||||||
/// @param takerAssetFillAmount Desired amount of takerAsset to sell.
|
/// @param takerAssetFillAmount Desired amount of takerAsset to sell.
|
||||||
/// @param signature Proof that order has been created by maker.
|
/// @param signature Proof that order has been created by maker.
|
||||||
/// @return Amounts filled and fees paid by maker and taker.
|
/// @return Amounts filled and fees paid by maker and taker.
|
||||||
function fillOrderInternal(
|
function _fillOrder(
|
||||||
Order memory order,
|
Order memory order,
|
||||||
uint256 takerAssetFillAmount,
|
uint256 takerAssetFillAmount,
|
||||||
bytes memory signature
|
bytes memory signature
|
||||||
@@ -193,10 +193,10 @@ contract MixinExchangeCore is
|
|||||||
OrderInfo memory orderInfo = getOrderInfo(order);
|
OrderInfo memory orderInfo = getOrderInfo(order);
|
||||||
|
|
||||||
// Fetch taker address
|
// Fetch taker address
|
||||||
address takerAddress = getCurrentContextAddress();
|
address takerAddress = _getCurrentContextAddress();
|
||||||
|
|
||||||
// Assert that the order is fillable by taker
|
// Assert that the order is fillable by taker
|
||||||
assertFillableOrder(
|
_assertFillableOrder(
|
||||||
order,
|
order,
|
||||||
orderInfo,
|
orderInfo,
|
||||||
takerAddress,
|
takerAddress,
|
||||||
@@ -204,11 +204,11 @@ contract MixinExchangeCore is
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Get amount of takerAsset to fill
|
// Get amount of takerAsset to fill
|
||||||
uint256 remainingTakerAssetAmount = safeSub(order.takerAssetAmount, orderInfo.orderTakerAssetFilledAmount);
|
uint256 remainingTakerAssetAmount = _safeSub(order.takerAssetAmount, orderInfo.orderTakerAssetFilledAmount);
|
||||||
uint256 takerAssetFilledAmount = min256(takerAssetFillAmount, remainingTakerAssetAmount);
|
uint256 takerAssetFilledAmount = _min256(takerAssetFillAmount, remainingTakerAssetAmount);
|
||||||
|
|
||||||
// Validate context
|
// Validate context
|
||||||
assertValidFill(
|
_assertValidFill(
|
||||||
order,
|
order,
|
||||||
orderInfo,
|
orderInfo,
|
||||||
takerAssetFillAmount,
|
takerAssetFillAmount,
|
||||||
@@ -217,12 +217,12 @@ contract MixinExchangeCore is
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Compute proportional fill amounts
|
// Compute proportional fill amounts
|
||||||
fillResults = calculateFillResults(order, takerAssetFilledAmount);
|
fillResults = _calculateFillResults(order, takerAssetFilledAmount);
|
||||||
|
|
||||||
bytes32 orderHash = orderInfo.orderHash;
|
bytes32 orderHash = orderInfo.orderHash;
|
||||||
|
|
||||||
// Update exchange internal state
|
// Update exchange internal state
|
||||||
updateFilledState(
|
_updateFilledState(
|
||||||
order,
|
order,
|
||||||
takerAddress,
|
takerAddress,
|
||||||
orderHash,
|
orderHash,
|
||||||
@@ -244,24 +244,24 @@ contract MixinExchangeCore is
|
|||||||
/// @dev After calling, the order can not be filled anymore.
|
/// @dev After calling, the order can not be filled anymore.
|
||||||
/// Throws if order is invalid or sender does not have permission to cancel.
|
/// Throws if order is invalid or sender does not have permission to cancel.
|
||||||
/// @param order Order to cancel. Order must be OrderStatus.FILLABLE.
|
/// @param order Order to cancel. Order must be OrderStatus.FILLABLE.
|
||||||
function cancelOrderInternal(Order memory order)
|
function _cancelOrder(Order memory order)
|
||||||
internal
|
internal
|
||||||
{
|
{
|
||||||
// Fetch current order status
|
// Fetch current order status
|
||||||
OrderInfo memory orderInfo = getOrderInfo(order);
|
OrderInfo memory orderInfo = getOrderInfo(order);
|
||||||
|
|
||||||
// Validate context
|
// Validate context
|
||||||
assertValidCancel(order, orderInfo);
|
_assertValidCancel(order, orderInfo);
|
||||||
|
|
||||||
// Perform cancel
|
// Perform cancel
|
||||||
updateCancelledState(order, orderInfo.orderHash);
|
_updateCancelledState(order, orderInfo.orderHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Updates state with results of a fill order.
|
/// @dev Updates state with results of a fill order.
|
||||||
/// @param order that was filled.
|
/// @param order that was filled.
|
||||||
/// @param takerAddress Address of taker who filled the order.
|
/// @param takerAddress Address of taker who filled the order.
|
||||||
/// @param orderTakerAssetFilledAmount Amount of order already filled.
|
/// @param orderTakerAssetFilledAmount Amount of order already filled.
|
||||||
function updateFilledState(
|
function _updateFilledState(
|
||||||
Order memory order,
|
Order memory order,
|
||||||
address takerAddress,
|
address takerAddress,
|
||||||
bytes32 orderHash,
|
bytes32 orderHash,
|
||||||
@@ -271,7 +271,7 @@ contract MixinExchangeCore is
|
|||||||
internal
|
internal
|
||||||
{
|
{
|
||||||
// Update state
|
// Update state
|
||||||
filled[orderHash] = safeAdd(orderTakerAssetFilledAmount, fillResults.takerAssetFilledAmount);
|
filled[orderHash] = _safeAdd(orderTakerAssetFilledAmount, fillResults.takerAssetFilledAmount);
|
||||||
|
|
||||||
// Log order
|
// Log order
|
||||||
emit Fill(
|
emit Fill(
|
||||||
@@ -294,7 +294,7 @@ contract MixinExchangeCore is
|
|||||||
/// Otherwise, updating state would have no effect.
|
/// Otherwise, updating state would have no effect.
|
||||||
/// @param order that was cancelled.
|
/// @param order that was cancelled.
|
||||||
/// @param orderHash Hash of order that was cancelled.
|
/// @param orderHash Hash of order that was cancelled.
|
||||||
function updateCancelledState(
|
function _updateCancelledState(
|
||||||
Order memory order,
|
Order memory order,
|
||||||
bytes32 orderHash
|
bytes32 orderHash
|
||||||
)
|
)
|
||||||
@@ -319,7 +319,7 @@ contract MixinExchangeCore is
|
|||||||
/// @param orderInfo OrderStatus, orderHash, and amount already filled of order.
|
/// @param orderInfo OrderStatus, orderHash, and amount already filled of order.
|
||||||
/// @param takerAddress Address of order taker.
|
/// @param takerAddress Address of order taker.
|
||||||
/// @param signature Proof that the orders was created by its maker.
|
/// @param signature Proof that the orders was created by its maker.
|
||||||
function assertFillableOrder(
|
function _assertFillableOrder(
|
||||||
Order memory order,
|
Order memory order,
|
||||||
OrderInfo memory orderInfo,
|
OrderInfo memory orderInfo,
|
||||||
address takerAddress,
|
address takerAddress,
|
||||||
@@ -330,7 +330,7 @@ contract MixinExchangeCore is
|
|||||||
{
|
{
|
||||||
// An order can only be filled if its status is FILLABLE.
|
// An order can only be filled if its status is FILLABLE.
|
||||||
if (orderInfo.orderStatus != uint8(OrderStatus.FILLABLE)) {
|
if (orderInfo.orderStatus != uint8(OrderStatus.FILLABLE)) {
|
||||||
rrevert(OrderStatusError(
|
_rrevert(OrderStatusError(
|
||||||
orderInfo.orderHash,
|
orderInfo.orderHash,
|
||||||
OrderStatus(orderInfo.orderStatus)
|
OrderStatus(orderInfo.orderStatus)
|
||||||
));
|
));
|
||||||
@@ -339,26 +339,26 @@ contract MixinExchangeCore is
|
|||||||
// Validate sender is allowed to fill this order
|
// Validate sender is allowed to fill this order
|
||||||
if (order.senderAddress != address(0)) {
|
if (order.senderAddress != address(0)) {
|
||||||
if (order.senderAddress != msg.sender) {
|
if (order.senderAddress != msg.sender) {
|
||||||
rrevert(InvalidSenderError(orderInfo.orderHash, msg.sender));
|
_rrevert(InvalidSenderError(orderInfo.orderHash, msg.sender));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate taker is allowed to fill this order
|
// Validate taker is allowed to fill this order
|
||||||
if (order.takerAddress != address(0)) {
|
if (order.takerAddress != address(0)) {
|
||||||
if (order.takerAddress != takerAddress) {
|
if (order.takerAddress != takerAddress) {
|
||||||
rrevert(InvalidTakerError(orderInfo.orderHash, takerAddress));
|
_rrevert(InvalidTakerError(orderInfo.orderHash, takerAddress));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate Maker signature (check only if first time seen)
|
// Validate Maker signature (check only if first time seen)
|
||||||
if (orderInfo.orderTakerAssetFilledAmount == 0) {
|
if (orderInfo.orderTakerAssetFilledAmount == 0) {
|
||||||
address makerAddress = order.makerAddress;
|
address makerAddress = order.makerAddress;
|
||||||
if (!isValidOrderWithHashSignature(
|
if (!_isValidOrderWithHashSignature(
|
||||||
order,
|
order,
|
||||||
orderInfo.orderHash,
|
orderInfo.orderHash,
|
||||||
makerAddress,
|
makerAddress,
|
||||||
signature)) {
|
signature)) {
|
||||||
rrevert(SignatureError(
|
_rrevert(SignatureError(
|
||||||
SignatureErrorCodes.BAD_SIGNATURE,
|
SignatureErrorCodes.BAD_SIGNATURE,
|
||||||
orderInfo.orderHash,
|
orderInfo.orderHash,
|
||||||
makerAddress,
|
makerAddress,
|
||||||
@@ -374,7 +374,7 @@ contract MixinExchangeCore is
|
|||||||
/// @param takerAssetFillAmount Desired amount of order to fill by taker.
|
/// @param takerAssetFillAmount Desired amount of order to fill by taker.
|
||||||
/// @param takerAssetFilledAmount Amount of takerAsset that will be filled.
|
/// @param takerAssetFilledAmount Amount of takerAsset that will be filled.
|
||||||
/// @param makerAssetFilledAmount Amount of makerAsset that will be transfered.
|
/// @param makerAssetFilledAmount Amount of makerAsset that will be transfered.
|
||||||
function assertValidFill(
|
function _assertValidFill(
|
||||||
Order memory order,
|
Order memory order,
|
||||||
OrderInfo memory orderInfo,
|
OrderInfo memory orderInfo,
|
||||||
uint256 takerAssetFillAmount, // TODO: use FillResults
|
uint256 takerAssetFillAmount, // TODO: use FillResults
|
||||||
@@ -387,22 +387,22 @@ 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(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(FillErrorCodes.TAKER_OVERPAY, orderInfo.orderHash));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure order is not overfilled
|
// Make sure order is not overfilled
|
||||||
// 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 (safeAdd(orderInfo.orderTakerAssetFilledAmount, takerAssetFilledAmount)
|
if (_safeAdd(orderInfo.orderTakerAssetFilledAmount, takerAssetFilledAmount)
|
||||||
> order.takerAssetAmount) {
|
> order.takerAssetAmount) {
|
||||||
rrevert(FillError(FillErrorCodes.OVERFILL, orderInfo.orderHash));
|
_rrevert(FillError(FillErrorCodes.OVERFILL, orderInfo.orderHash));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure order is filled at acceptable price.
|
// Make sure order is filled at acceptable price.
|
||||||
@@ -422,16 +422,16 @@ contract MixinExchangeCore is
|
|||||||
// order.makerAssetAmount * takerAssetFilledAmount
|
// order.makerAssetAmount * takerAssetFilledAmount
|
||||||
// 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 (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(FillErrorCodes.INVALID_FILL_PRICE, orderInfo.orderHash));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Validates context for cancelOrder. Succeeds or throws.
|
/// @dev Validates context for cancelOrder. Succeeds or throws.
|
||||||
/// @param order to be cancelled.
|
/// @param order to be cancelled.
|
||||||
/// @param orderInfo OrderStatus, orderHash, and amount already filled of order.
|
/// @param orderInfo OrderStatus, orderHash, and amount already filled of order.
|
||||||
function assertValidCancel(
|
function _assertValidCancel(
|
||||||
Order memory order,
|
Order memory order,
|
||||||
OrderInfo memory orderInfo
|
OrderInfo memory orderInfo
|
||||||
)
|
)
|
||||||
@@ -441,7 +441,7 @@ contract MixinExchangeCore is
|
|||||||
// Ensure order is valid
|
// Ensure order is valid
|
||||||
// An order can only be cancelled if its status is FILLABLE.
|
// An order can only be cancelled if its status is FILLABLE.
|
||||||
if (orderInfo.orderStatus != uint8(OrderStatus.FILLABLE)) {
|
if (orderInfo.orderStatus != uint8(OrderStatus.FILLABLE)) {
|
||||||
rrevert(OrderStatusError(
|
_rrevert(OrderStatusError(
|
||||||
orderInfo.orderHash,
|
orderInfo.orderHash,
|
||||||
OrderStatus(orderInfo.orderStatus)
|
OrderStatus(orderInfo.orderStatus)
|
||||||
));
|
));
|
||||||
@@ -450,14 +450,14 @@ contract MixinExchangeCore is
|
|||||||
// Validate sender is allowed to cancel this order
|
// Validate sender is allowed to cancel this order
|
||||||
if (order.senderAddress != address(0)) {
|
if (order.senderAddress != address(0)) {
|
||||||
if (order.senderAddress != msg.sender) {
|
if (order.senderAddress != msg.sender) {
|
||||||
rrevert(InvalidSenderError(orderInfo.orderHash, msg.sender));
|
_rrevert(InvalidSenderError(orderInfo.orderHash, msg.sender));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate transaction signed by maker
|
// Validate transaction signed by maker
|
||||||
address makerAddress = getCurrentContextAddress();
|
address makerAddress = _getCurrentContextAddress();
|
||||||
if (order.makerAddress != makerAddress) {
|
if (order.makerAddress != makerAddress) {
|
||||||
rrevert(InvalidMakerError(orderInfo.orderHash, makerAddress));
|
_rrevert(InvalidMakerError(orderInfo.orderHash, makerAddress));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -465,7 +465,7 @@ contract MixinExchangeCore is
|
|||||||
/// @param order to be filled.
|
/// @param order to be filled.
|
||||||
/// @param takerAssetFilledAmount Amount of takerAsset that will be filled.
|
/// @param takerAssetFilledAmount Amount of takerAsset that will be filled.
|
||||||
/// @return fillResults Amounts filled and fees paid by maker and taker.
|
/// @return fillResults Amounts filled and fees paid by maker and taker.
|
||||||
function calculateFillResults(
|
function _calculateFillResults(
|
||||||
Order memory order,
|
Order memory order,
|
||||||
uint256 takerAssetFilledAmount
|
uint256 takerAssetFilledAmount
|
||||||
)
|
)
|
||||||
@@ -475,17 +475,17 @@ contract MixinExchangeCore is
|
|||||||
{
|
{
|
||||||
// Compute proportional transfer amounts
|
// Compute proportional transfer amounts
|
||||||
fillResults.takerAssetFilledAmount = takerAssetFilledAmount;
|
fillResults.takerAssetFilledAmount = takerAssetFilledAmount;
|
||||||
fillResults.makerAssetFilledAmount = safeGetPartialAmountFloor(
|
fillResults.makerAssetFilledAmount = _safeGetPartialAmountFloor(
|
||||||
takerAssetFilledAmount,
|
takerAssetFilledAmount,
|
||||||
order.takerAssetAmount,
|
order.takerAssetAmount,
|
||||||
order.makerAssetAmount
|
order.makerAssetAmount
|
||||||
);
|
);
|
||||||
fillResults.makerFeePaid = safeGetPartialAmountFloor(
|
fillResults.makerFeePaid = _safeGetPartialAmountFloor(
|
||||||
fillResults.makerAssetFilledAmount,
|
fillResults.makerAssetFilledAmount,
|
||||||
order.makerAssetAmount,
|
order.makerAssetAmount,
|
||||||
order.makerFee
|
order.makerFee
|
||||||
);
|
);
|
||||||
fillResults.takerFeePaid = safeGetPartialAmountFloor(
|
fillResults.takerFeePaid = _safeGetPartialAmountFloor(
|
||||||
takerAssetFilledAmount,
|
takerAssetFilledAmount,
|
||||||
order.takerAssetAmount,
|
order.takerAssetAmount,
|
||||||
order.takerFee
|
order.takerFee
|
||||||
@@ -508,28 +508,28 @@ contract MixinExchangeCore is
|
|||||||
private
|
private
|
||||||
{
|
{
|
||||||
bytes memory zrxAssetData = ZRX_ASSET_DATA;
|
bytes memory zrxAssetData = ZRX_ASSET_DATA;
|
||||||
dispatchTransferFrom(
|
_dispatchTransferFrom(
|
||||||
orderHash,
|
orderHash,
|
||||||
order.makerAssetData,
|
order.makerAssetData,
|
||||||
order.makerAddress,
|
order.makerAddress,
|
||||||
takerAddress,
|
takerAddress,
|
||||||
fillResults.makerAssetFilledAmount
|
fillResults.makerAssetFilledAmount
|
||||||
);
|
);
|
||||||
dispatchTransferFrom(
|
_dispatchTransferFrom(
|
||||||
orderHash,
|
orderHash,
|
||||||
order.takerAssetData,
|
order.takerAssetData,
|
||||||
takerAddress,
|
takerAddress,
|
||||||
order.makerAddress,
|
order.makerAddress,
|
||||||
fillResults.takerAssetFilledAmount
|
fillResults.takerAssetFilledAmount
|
||||||
);
|
);
|
||||||
dispatchTransferFrom(
|
_dispatchTransferFrom(
|
||||||
orderHash,
|
orderHash,
|
||||||
zrxAssetData,
|
zrxAssetData,
|
||||||
order.makerAddress,
|
order.makerAddress,
|
||||||
order.feeRecipientAddress,
|
order.feeRecipientAddress,
|
||||||
fillResults.makerFeePaid
|
fillResults.makerFeePaid
|
||||||
);
|
);
|
||||||
dispatchTransferFrom(
|
_dispatchTransferFrom(
|
||||||
orderHash,
|
orderHash,
|
||||||
zrxAssetData,
|
zrxAssetData,
|
||||||
takerAddress,
|
takerAddress,
|
||||||
|
@@ -31,7 +31,7 @@ contract MixinExchangeRichErrors is
|
|||||||
function SignatureError(
|
function SignatureError(
|
||||||
SignatureErrorCodes errorCode,
|
SignatureErrorCodes errorCode,
|
||||||
bytes32 hash,
|
bytes32 hash,
|
||||||
address signer,
|
address signerAddress,
|
||||||
bytes memory signature
|
bytes memory signature
|
||||||
)
|
)
|
||||||
internal
|
internal
|
||||||
@@ -42,14 +42,14 @@ contract MixinExchangeRichErrors is
|
|||||||
SIGNATURE_ERROR_SELECTOR,
|
SIGNATURE_ERROR_SELECTOR,
|
||||||
errorCode,
|
errorCode,
|
||||||
hash,
|
hash,
|
||||||
signer,
|
signerAddress,
|
||||||
signature
|
signature
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function SignatureValidatorError(
|
function SignatureValidatorError(
|
||||||
bytes32 hash,
|
bytes32 hash,
|
||||||
address signer,
|
address signerAddress,
|
||||||
bytes memory signature,
|
bytes memory signature,
|
||||||
bytes memory errorData
|
bytes memory errorData
|
||||||
)
|
)
|
||||||
@@ -60,7 +60,7 @@ contract MixinExchangeRichErrors is
|
|||||||
return abi.encodeWithSelector(
|
return abi.encodeWithSelector(
|
||||||
SIGNATURE_VALIDATOR_ERROR_SELECTOR,
|
SIGNATURE_VALIDATOR_ERROR_SELECTOR,
|
||||||
hash,
|
hash,
|
||||||
signer,
|
signerAddress,
|
||||||
signature,
|
signature,
|
||||||
errorData
|
errorData
|
||||||
);
|
);
|
||||||
@@ -68,7 +68,7 @@ contract MixinExchangeRichErrors is
|
|||||||
|
|
||||||
function SignatureWalletError(
|
function SignatureWalletError(
|
||||||
bytes32 hash,
|
bytes32 hash,
|
||||||
address signer,
|
address signerAddress,
|
||||||
bytes memory signature,
|
bytes memory signature,
|
||||||
bytes memory errorData
|
bytes memory errorData
|
||||||
)
|
)
|
||||||
@@ -79,7 +79,7 @@ contract MixinExchangeRichErrors is
|
|||||||
return abi.encodeWithSelector(
|
return abi.encodeWithSelector(
|
||||||
SIGNATURE_WALLET_ERROR_SELECTOR,
|
SIGNATURE_WALLET_ERROR_SELECTOR,
|
||||||
hash,
|
hash,
|
||||||
signer,
|
signerAddress,
|
||||||
signature,
|
signature,
|
||||||
errorData
|
errorData
|
||||||
);
|
);
|
||||||
@@ -87,7 +87,7 @@ contract MixinExchangeRichErrors is
|
|||||||
|
|
||||||
function SignatureOrderValidatorError(
|
function SignatureOrderValidatorError(
|
||||||
bytes32 orderHash,
|
bytes32 orderHash,
|
||||||
address signer,
|
address signerAddress,
|
||||||
bytes memory signature,
|
bytes memory signature,
|
||||||
bytes memory errorData
|
bytes memory errorData
|
||||||
)
|
)
|
||||||
@@ -98,7 +98,7 @@ contract MixinExchangeRichErrors is
|
|||||||
return abi.encodeWithSelector(
|
return abi.encodeWithSelector(
|
||||||
SIGNATURE_ORDER_VALIDATOR_ERROR_SELECTOR,
|
SIGNATURE_ORDER_VALIDATOR_ERROR_SELECTOR,
|
||||||
orderHash,
|
orderHash,
|
||||||
signer,
|
signerAddress,
|
||||||
signature,
|
signature,
|
||||||
errorData
|
errorData
|
||||||
);
|
);
|
||||||
@@ -140,7 +140,7 @@ contract MixinExchangeRichErrors is
|
|||||||
|
|
||||||
function InvalidSenderError(
|
function InvalidSenderError(
|
||||||
bytes32 orderHash,
|
bytes32 orderHash,
|
||||||
address sender
|
address senderAddress
|
||||||
)
|
)
|
||||||
internal
|
internal
|
||||||
pure
|
pure
|
||||||
@@ -149,13 +149,13 @@ contract MixinExchangeRichErrors is
|
|||||||
return abi.encodeWithSelector(
|
return abi.encodeWithSelector(
|
||||||
INVALID_SENDER_ERROR_SELECTOR,
|
INVALID_SENDER_ERROR_SELECTOR,
|
||||||
orderHash,
|
orderHash,
|
||||||
sender
|
senderAddress
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function InvalidMakerError(
|
function InvalidMakerError(
|
||||||
bytes32 orderHash,
|
bytes32 orderHash,
|
||||||
address maker
|
address makerAddress
|
||||||
)
|
)
|
||||||
internal
|
internal
|
||||||
pure
|
pure
|
||||||
@@ -164,7 +164,7 @@ contract MixinExchangeRichErrors is
|
|||||||
return abi.encodeWithSelector(
|
return abi.encodeWithSelector(
|
||||||
INVALID_MAKER_ERROR_SELECTOR,
|
INVALID_MAKER_ERROR_SELECTOR,
|
||||||
orderHash,
|
orderHash,
|
||||||
maker
|
makerAddress
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,7 +185,7 @@ contract MixinExchangeRichErrors is
|
|||||||
|
|
||||||
function InvalidTakerError(
|
function InvalidTakerError(
|
||||||
bytes32 orderHash,
|
bytes32 orderHash,
|
||||||
address taker
|
address takerAddress
|
||||||
)
|
)
|
||||||
internal
|
internal
|
||||||
pure
|
pure
|
||||||
@@ -194,13 +194,13 @@ contract MixinExchangeRichErrors is
|
|||||||
return abi.encodeWithSelector(
|
return abi.encodeWithSelector(
|
||||||
INVALID_TAKER_ERROR_SELECTOR,
|
INVALID_TAKER_ERROR_SELECTOR,
|
||||||
orderHash,
|
orderHash,
|
||||||
taker
|
takerAddress
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function OrderEpochError(
|
function OrderEpochError(
|
||||||
address maker,
|
address makerAddress,
|
||||||
address sender,
|
address orderSenderAddress,
|
||||||
uint256 currentEpoch
|
uint256 currentEpoch
|
||||||
)
|
)
|
||||||
internal
|
internal
|
||||||
@@ -209,8 +209,8 @@ contract MixinExchangeRichErrors is
|
|||||||
{
|
{
|
||||||
return abi.encodeWithSelector(
|
return abi.encodeWithSelector(
|
||||||
ORDER_EPOCH_ERROR_SELECTOR,
|
ORDER_EPOCH_ERROR_SELECTOR,
|
||||||
maker,
|
makerAddress,
|
||||||
sender,
|
orderSenderAddress,
|
||||||
currentEpoch
|
currentEpoch
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -294,7 +294,7 @@ contract MixinExchangeRichErrors is
|
|||||||
|
|
||||||
function TransactionSignatureError(
|
function TransactionSignatureError(
|
||||||
bytes32 transactionHash,
|
bytes32 transactionHash,
|
||||||
address signer,
|
address signerAddress,
|
||||||
bytes memory signature
|
bytes memory signature
|
||||||
)
|
)
|
||||||
internal
|
internal
|
||||||
@@ -304,7 +304,7 @@ contract MixinExchangeRichErrors is
|
|||||||
return abi.encodeWithSelector(
|
return abi.encodeWithSelector(
|
||||||
TRANSACTION_SIGNATURE_ERROR_SELECTOR,
|
TRANSACTION_SIGNATURE_ERROR_SELECTOR,
|
||||||
transactionHash,
|
transactionHash,
|
||||||
signer,
|
signerAddress,
|
||||||
signature
|
signature
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -66,25 +66,25 @@ contract MixinMatchOrders is
|
|||||||
LibOrder.OrderInfo memory rightOrderInfo = getOrderInfo(rightOrder);
|
LibOrder.OrderInfo memory rightOrderInfo = getOrderInfo(rightOrder);
|
||||||
|
|
||||||
// Fetch taker address
|
// Fetch taker address
|
||||||
address takerAddress = getCurrentContextAddress();
|
address takerAddress = _getCurrentContextAddress();
|
||||||
|
|
||||||
// Either our context is valid or we revert
|
// Either our context is valid or we revert
|
||||||
assertFillableOrder(
|
_assertFillableOrder(
|
||||||
leftOrder,
|
leftOrder,
|
||||||
leftOrderInfo,
|
leftOrderInfo,
|
||||||
takerAddress,
|
takerAddress,
|
||||||
leftSignature
|
leftSignature
|
||||||
);
|
);
|
||||||
assertFillableOrder(
|
_assertFillableOrder(
|
||||||
rightOrder,
|
rightOrder,
|
||||||
rightOrderInfo,
|
rightOrderInfo,
|
||||||
takerAddress,
|
takerAddress,
|
||||||
rightSignature
|
rightSignature
|
||||||
);
|
);
|
||||||
assertValidMatch(leftOrder, rightOrder);
|
_assertValidMatch(leftOrder, rightOrder);
|
||||||
|
|
||||||
// Compute proportional fill amounts
|
// Compute proportional fill amounts
|
||||||
matchedFillResults = calculateMatchedFillResults(
|
matchedFillResults = _calculateMatchedFillResults(
|
||||||
leftOrder,
|
leftOrder,
|
||||||
rightOrder,
|
rightOrder,
|
||||||
leftOrderInfo.orderTakerAssetFilledAmount,
|
leftOrderInfo.orderTakerAssetFilledAmount,
|
||||||
@@ -92,14 +92,14 @@ contract MixinMatchOrders is
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Validate fill contexts
|
// Validate fill contexts
|
||||||
assertValidFill(
|
_assertValidFill(
|
||||||
leftOrder,
|
leftOrder,
|
||||||
leftOrderInfo,
|
leftOrderInfo,
|
||||||
matchedFillResults.left.takerAssetFilledAmount,
|
matchedFillResults.left.takerAssetFilledAmount,
|
||||||
matchedFillResults.left.takerAssetFilledAmount,
|
matchedFillResults.left.takerAssetFilledAmount,
|
||||||
matchedFillResults.left.makerAssetFilledAmount
|
matchedFillResults.left.makerAssetFilledAmount
|
||||||
);
|
);
|
||||||
assertValidFill(
|
_assertValidFill(
|
||||||
rightOrder,
|
rightOrder,
|
||||||
rightOrderInfo,
|
rightOrderInfo,
|
||||||
matchedFillResults.right.takerAssetFilledAmount,
|
matchedFillResults.right.takerAssetFilledAmount,
|
||||||
@@ -108,14 +108,14 @@ contract MixinMatchOrders is
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Update exchange state
|
// Update exchange state
|
||||||
updateFilledState(
|
_updateFilledState(
|
||||||
leftOrder,
|
leftOrder,
|
||||||
takerAddress,
|
takerAddress,
|
||||||
leftOrderInfo.orderHash,
|
leftOrderInfo.orderHash,
|
||||||
leftOrderInfo.orderTakerAssetFilledAmount,
|
leftOrderInfo.orderTakerAssetFilledAmount,
|
||||||
matchedFillResults.left
|
matchedFillResults.left
|
||||||
);
|
);
|
||||||
updateFilledState(
|
_updateFilledState(
|
||||||
rightOrder,
|
rightOrder,
|
||||||
takerAddress,
|
takerAddress,
|
||||||
rightOrderInfo.orderHash,
|
rightOrderInfo.orderHash,
|
||||||
@@ -139,7 +139,7 @@ contract MixinMatchOrders is
|
|||||||
/// @dev Validates context for matchOrders. Succeeds or throws.
|
/// @dev Validates context for matchOrders. Succeeds or throws.
|
||||||
/// @param leftOrder First order to match.
|
/// @param leftOrder First order to match.
|
||||||
/// @param rightOrder Second order to match.
|
/// @param rightOrder Second order to match.
|
||||||
function assertValidMatch(
|
function _assertValidMatch(
|
||||||
LibOrder.Order memory leftOrder,
|
LibOrder.Order memory leftOrder,
|
||||||
LibOrder.Order memory rightOrder
|
LibOrder.Order memory rightOrder
|
||||||
)
|
)
|
||||||
@@ -154,9 +154,9 @@ contract MixinMatchOrders is
|
|||||||
// AND
|
// AND
|
||||||
// <rightOrder.makerAssetAmount> / <rightOrder.takerAssetAmount> >= <leftOrder.takerAssetAmount> / <leftOrder.makerAssetAmount>
|
// <rightOrder.makerAssetAmount> / <rightOrder.takerAssetAmount> >= <leftOrder.takerAssetAmount> / <leftOrder.makerAssetAmount>
|
||||||
// These equations can be combined to get the following:
|
// These equations can be combined to get the following:
|
||||||
if (safeMul(leftOrder.makerAssetAmount, rightOrder.makerAssetAmount) <
|
if (_safeMul(leftOrder.makerAssetAmount, rightOrder.makerAssetAmount) <
|
||||||
safeMul(leftOrder.takerAssetAmount, rightOrder.takerAssetAmount)) {
|
_safeMul(leftOrder.takerAssetAmount, rightOrder.takerAssetAmount)) {
|
||||||
rrevert(NegativeSpreadError(
|
_rrevert(NegativeSpreadError(
|
||||||
getOrderHash(leftOrder),
|
getOrderHash(leftOrder),
|
||||||
getOrderHash(rightOrder)
|
getOrderHash(rightOrder)
|
||||||
));
|
));
|
||||||
@@ -172,7 +172,7 @@ contract MixinMatchOrders is
|
|||||||
/// @param leftOrderTakerAssetFilledAmount Amount of left order already filled.
|
/// @param leftOrderTakerAssetFilledAmount Amount of left order already filled.
|
||||||
/// @param rightOrderTakerAssetFilledAmount Amount of right 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.
|
/// @param matchedFillResults Amounts to fill and fees to pay by maker and taker of matched orders.
|
||||||
function calculateMatchedFillResults(
|
function _calculateMatchedFillResults(
|
||||||
LibOrder.Order memory leftOrder,
|
LibOrder.Order memory leftOrder,
|
||||||
LibOrder.Order memory rightOrder,
|
LibOrder.Order memory rightOrder,
|
||||||
uint256 leftOrderTakerAssetFilledAmount,
|
uint256 leftOrderTakerAssetFilledAmount,
|
||||||
@@ -183,14 +183,14 @@ contract MixinMatchOrders is
|
|||||||
returns (LibFillResults.MatchedFillResults memory matchedFillResults)
|
returns (LibFillResults.MatchedFillResults memory matchedFillResults)
|
||||||
{
|
{
|
||||||
// Derive maker asset amounts for left & right orders, given store taker assert amounts
|
// Derive maker asset amounts for left & right orders, given store taker assert amounts
|
||||||
uint256 leftTakerAssetAmountRemaining = safeSub(leftOrder.takerAssetAmount, leftOrderTakerAssetFilledAmount);
|
uint256 leftTakerAssetAmountRemaining = _safeSub(leftOrder.takerAssetAmount, leftOrderTakerAssetFilledAmount);
|
||||||
uint256 leftMakerAssetAmountRemaining = safeGetPartialAmountFloor(
|
uint256 leftMakerAssetAmountRemaining = _safeGetPartialAmountFloor(
|
||||||
leftOrder.makerAssetAmount,
|
leftOrder.makerAssetAmount,
|
||||||
leftOrder.takerAssetAmount,
|
leftOrder.takerAssetAmount,
|
||||||
leftTakerAssetAmountRemaining
|
leftTakerAssetAmountRemaining
|
||||||
);
|
);
|
||||||
uint256 rightTakerAssetAmountRemaining = safeSub(rightOrder.takerAssetAmount, rightOrderTakerAssetFilledAmount);
|
uint256 rightTakerAssetAmountRemaining = _safeSub(rightOrder.takerAssetAmount, rightOrderTakerAssetFilledAmount);
|
||||||
uint256 rightMakerAssetAmountRemaining = safeGetPartialAmountFloor(
|
uint256 rightMakerAssetAmountRemaining = _safeGetPartialAmountFloor(
|
||||||
rightOrder.makerAssetAmount,
|
rightOrder.makerAssetAmount,
|
||||||
rightOrder.takerAssetAmount,
|
rightOrder.takerAssetAmount,
|
||||||
rightTakerAssetAmountRemaining
|
rightTakerAssetAmountRemaining
|
||||||
@@ -212,7 +212,7 @@ contract MixinMatchOrders is
|
|||||||
matchedFillResults.left.takerAssetFilledAmount = matchedFillResults.right.makerAssetFilledAmount;
|
matchedFillResults.left.takerAssetFilledAmount = matchedFillResults.right.makerAssetFilledAmount;
|
||||||
// Round down to ensure the maker's exchange rate does not exceed the price specified by the order.
|
// Round down to ensure the maker's exchange rate does not exceed the price specified by the order.
|
||||||
// We favor the maker when the exchange rate must be rounded.
|
// We favor the maker when the exchange rate must be rounded.
|
||||||
matchedFillResults.left.makerAssetFilledAmount = safeGetPartialAmountFloor(
|
matchedFillResults.left.makerAssetFilledAmount = _safeGetPartialAmountFloor(
|
||||||
leftOrder.makerAssetAmount,
|
leftOrder.makerAssetAmount,
|
||||||
leftOrder.takerAssetAmount,
|
leftOrder.takerAssetAmount,
|
||||||
matchedFillResults.left.takerAssetFilledAmount
|
matchedFillResults.left.takerAssetFilledAmount
|
||||||
@@ -224,7 +224,7 @@ contract MixinMatchOrders is
|
|||||||
matchedFillResults.right.makerAssetFilledAmount = matchedFillResults.left.takerAssetFilledAmount;
|
matchedFillResults.right.makerAssetFilledAmount = matchedFillResults.left.takerAssetFilledAmount;
|
||||||
// Round up to ensure the maker's exchange rate does not exceed the price specified by the order.
|
// Round up to ensure the maker's exchange rate does not exceed the price specified by the order.
|
||||||
// We favor the maker when the exchange rate must be rounded.
|
// We favor the maker when the exchange rate must be rounded.
|
||||||
matchedFillResults.right.takerAssetFilledAmount = safeGetPartialAmountCeil(
|
matchedFillResults.right.takerAssetFilledAmount = _safeGetPartialAmountCeil(
|
||||||
rightOrder.takerAssetAmount,
|
rightOrder.takerAssetAmount,
|
||||||
rightOrder.makerAssetAmount,
|
rightOrder.makerAssetAmount,
|
||||||
matchedFillResults.right.makerAssetFilledAmount
|
matchedFillResults.right.makerAssetFilledAmount
|
||||||
@@ -232,30 +232,30 @@ contract MixinMatchOrders is
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calculate amount given to taker
|
// Calculate amount given to taker
|
||||||
matchedFillResults.leftMakerAssetSpreadAmount = safeSub(
|
matchedFillResults.leftMakerAssetSpreadAmount = _safeSub(
|
||||||
matchedFillResults.left.makerAssetFilledAmount,
|
matchedFillResults.left.makerAssetFilledAmount,
|
||||||
matchedFillResults.right.takerAssetFilledAmount
|
matchedFillResults.right.takerAssetFilledAmount
|
||||||
);
|
);
|
||||||
|
|
||||||
// Compute fees for left order
|
// Compute fees for left order
|
||||||
matchedFillResults.left.makerFeePaid = safeGetPartialAmountFloor(
|
matchedFillResults.left.makerFeePaid = _safeGetPartialAmountFloor(
|
||||||
matchedFillResults.left.makerAssetFilledAmount,
|
matchedFillResults.left.makerAssetFilledAmount,
|
||||||
leftOrder.makerAssetAmount,
|
leftOrder.makerAssetAmount,
|
||||||
leftOrder.makerFee
|
leftOrder.makerFee
|
||||||
);
|
);
|
||||||
matchedFillResults.left.takerFeePaid = safeGetPartialAmountFloor(
|
matchedFillResults.left.takerFeePaid = _safeGetPartialAmountFloor(
|
||||||
matchedFillResults.left.takerAssetFilledAmount,
|
matchedFillResults.left.takerAssetFilledAmount,
|
||||||
leftOrder.takerAssetAmount,
|
leftOrder.takerAssetAmount,
|
||||||
leftOrder.takerFee
|
leftOrder.takerFee
|
||||||
);
|
);
|
||||||
|
|
||||||
// Compute fees for right order
|
// Compute fees for right order
|
||||||
matchedFillResults.right.makerFeePaid = safeGetPartialAmountFloor(
|
matchedFillResults.right.makerFeePaid = _safeGetPartialAmountFloor(
|
||||||
matchedFillResults.right.makerAssetFilledAmount,
|
matchedFillResults.right.makerAssetFilledAmount,
|
||||||
rightOrder.makerAssetAmount,
|
rightOrder.makerAssetAmount,
|
||||||
rightOrder.makerFee
|
rightOrder.makerFee
|
||||||
);
|
);
|
||||||
matchedFillResults.right.takerFeePaid = safeGetPartialAmountFloor(
|
matchedFillResults.right.takerFeePaid = _safeGetPartialAmountFloor(
|
||||||
matchedFillResults.right.takerAssetFilledAmount,
|
matchedFillResults.right.takerAssetFilledAmount,
|
||||||
rightOrder.takerAssetAmount,
|
rightOrder.takerAssetAmount,
|
||||||
rightOrder.takerFee
|
rightOrder.takerFee
|
||||||
@@ -284,21 +284,21 @@ contract MixinMatchOrders is
|
|||||||
{
|
{
|
||||||
bytes memory zrxAssetData = ZRX_ASSET_DATA;
|
bytes memory zrxAssetData = ZRX_ASSET_DATA;
|
||||||
// Order makers and taker
|
// Order makers and taker
|
||||||
dispatchTransferFrom(
|
_dispatchTransferFrom(
|
||||||
leftOrderHash,
|
leftOrderHash,
|
||||||
leftOrder.makerAssetData,
|
leftOrder.makerAssetData,
|
||||||
leftOrder.makerAddress,
|
leftOrder.makerAddress,
|
||||||
rightOrder.makerAddress,
|
rightOrder.makerAddress,
|
||||||
matchedFillResults.right.takerAssetFilledAmount
|
matchedFillResults.right.takerAssetFilledAmount
|
||||||
);
|
);
|
||||||
dispatchTransferFrom(
|
_dispatchTransferFrom(
|
||||||
rightOrderHash,
|
rightOrderHash,
|
||||||
rightOrder.makerAssetData,
|
rightOrder.makerAssetData,
|
||||||
rightOrder.makerAddress,
|
rightOrder.makerAddress,
|
||||||
leftOrder.makerAddress,
|
leftOrder.makerAddress,
|
||||||
matchedFillResults.left.takerAssetFilledAmount
|
matchedFillResults.left.takerAssetFilledAmount
|
||||||
);
|
);
|
||||||
dispatchTransferFrom(
|
_dispatchTransferFrom(
|
||||||
leftOrderHash,
|
leftOrderHash,
|
||||||
leftOrder.makerAssetData,
|
leftOrder.makerAssetData,
|
||||||
leftOrder.makerAddress,
|
leftOrder.makerAddress,
|
||||||
@@ -307,14 +307,14 @@ contract MixinMatchOrders is
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Maker fees
|
// Maker fees
|
||||||
dispatchTransferFrom(
|
_dispatchTransferFrom(
|
||||||
leftOrderHash,
|
leftOrderHash,
|
||||||
zrxAssetData,
|
zrxAssetData,
|
||||||
leftOrder.makerAddress,
|
leftOrder.makerAddress,
|
||||||
leftOrder.feeRecipientAddress,
|
leftOrder.feeRecipientAddress,
|
||||||
matchedFillResults.left.makerFeePaid
|
matchedFillResults.left.makerFeePaid
|
||||||
);
|
);
|
||||||
dispatchTransferFrom(
|
_dispatchTransferFrom(
|
||||||
rightOrderHash,
|
rightOrderHash,
|
||||||
zrxAssetData,
|
zrxAssetData,
|
||||||
rightOrder.makerAddress,
|
rightOrder.makerAddress,
|
||||||
@@ -324,25 +324,25 @@ contract MixinMatchOrders is
|
|||||||
|
|
||||||
// Taker fees
|
// Taker fees
|
||||||
if (leftOrder.feeRecipientAddress == rightOrder.feeRecipientAddress) {
|
if (leftOrder.feeRecipientAddress == rightOrder.feeRecipientAddress) {
|
||||||
dispatchTransferFrom(
|
_dispatchTransferFrom(
|
||||||
leftOrderHash,
|
leftOrderHash,
|
||||||
zrxAssetData,
|
zrxAssetData,
|
||||||
takerAddress,
|
takerAddress,
|
||||||
leftOrder.feeRecipientAddress,
|
leftOrder.feeRecipientAddress,
|
||||||
safeAdd(
|
_safeAdd(
|
||||||
matchedFillResults.left.takerFeePaid,
|
matchedFillResults.left.takerFeePaid,
|
||||||
matchedFillResults.right.takerFeePaid
|
matchedFillResults.right.takerFeePaid
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
dispatchTransferFrom(
|
_dispatchTransferFrom(
|
||||||
leftOrderHash,
|
leftOrderHash,
|
||||||
zrxAssetData,
|
zrxAssetData,
|
||||||
takerAddress,
|
takerAddress,
|
||||||
leftOrder.feeRecipientAddress,
|
leftOrder.feeRecipientAddress,
|
||||||
matchedFillResults.left.takerFeePaid
|
matchedFillResults.left.takerFeePaid
|
||||||
);
|
);
|
||||||
dispatchTransferFrom(
|
_dispatchTransferFrom(
|
||||||
rightOrderHash,
|
rightOrderHash,
|
||||||
zrxAssetData,
|
zrxAssetData,
|
||||||
takerAddress,
|
takerAddress,
|
||||||
|
@@ -55,7 +55,7 @@ contract MixinSignatureValidator is
|
|||||||
external
|
external
|
||||||
nonReentrant
|
nonReentrant
|
||||||
{
|
{
|
||||||
address signerAddress = getCurrentContextAddress();
|
address signerAddress = _getCurrentContextAddress();
|
||||||
preSigned[hash][signerAddress] = true;
|
preSigned[hash][signerAddress] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ contract MixinSignatureValidator is
|
|||||||
external
|
external
|
||||||
nonReentrant
|
nonReentrant
|
||||||
{
|
{
|
||||||
address signerAddress = getCurrentContextAddress();
|
address signerAddress = _getCurrentContextAddress();
|
||||||
allowedValidators[signerAddress][validatorAddress] = approval;
|
allowedValidators[signerAddress][validatorAddress] = approval;
|
||||||
emit SignatureValidatorApproval(
|
emit SignatureValidatorApproval(
|
||||||
signerAddress,
|
signerAddress,
|
||||||
@@ -90,7 +90,7 @@ contract MixinSignatureValidator is
|
|||||||
external
|
external
|
||||||
nonReentrant
|
nonReentrant
|
||||||
{
|
{
|
||||||
address signerAddress = getCurrentContextAddress();
|
address signerAddress = _getCurrentContextAddress();
|
||||||
allowedOrderValidators[signerAddress][validatorAddress] = approval;
|
allowedOrderValidators[signerAddress][validatorAddress] = approval;
|
||||||
emit SignatureValidatorApproval(
|
emit SignatureValidatorApproval(
|
||||||
signerAddress,
|
signerAddress,
|
||||||
@@ -114,7 +114,7 @@ contract MixinSignatureValidator is
|
|||||||
returns (bool isValid)
|
returns (bool isValid)
|
||||||
{
|
{
|
||||||
bytes32 orderHash = getOrderHash(order);
|
bytes32 orderHash = getOrderHash(order);
|
||||||
return isValidOrderWithHashSignature(
|
return _isValidOrderWithHashSignature(
|
||||||
order,
|
order,
|
||||||
orderHash,
|
orderHash,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
@@ -145,7 +145,7 @@ contract MixinSignatureValidator is
|
|||||||
// function.
|
// function.
|
||||||
if (signatureType == SignatureType.OrderValidator ||
|
if (signatureType == SignatureType.OrderValidator ||
|
||||||
signatureType == SignatureType.WalletOrderValidator) {
|
signatureType == SignatureType.WalletOrderValidator) {
|
||||||
rrevert(SignatureError(
|
_rrevert(SignatureError(
|
||||||
SignatureErrorCodes.INAPPROPRIATE_SIGNATURE_TYPE,
|
SignatureErrorCodes.INAPPROPRIATE_SIGNATURE_TYPE,
|
||||||
hash,
|
hash,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
@@ -167,7 +167,7 @@ contract MixinSignatureValidator is
|
|||||||
/// @param signerAddress Address that should have signed the.Signat given hash.
|
/// @param signerAddress Address that should have signed the.Signat given hash.
|
||||||
/// @param signature Proof that the hash has been signed by signer.
|
/// @param signature Proof that the hash has been signed by signer.
|
||||||
/// @return True if the signature is valid for the given hash and signer.
|
/// @return True if the signature is valid for the given hash and signer.
|
||||||
function isValidOrderWithHashSignature(
|
function _isValidOrderWithHashSignature(
|
||||||
Order memory order,
|
Order memory order,
|
||||||
bytes32 orderHash,
|
bytes32 orderHash,
|
||||||
address signerAddress,
|
address signerAddress,
|
||||||
@@ -221,7 +221,7 @@ contract MixinSignatureValidator is
|
|||||||
returns (SignatureType signatureType)
|
returns (SignatureType signatureType)
|
||||||
{
|
{
|
||||||
if (signature.length == 0) {
|
if (signature.length == 0) {
|
||||||
rrevert(SignatureError(
|
_rrevert(SignatureError(
|
||||||
SignatureErrorCodes.INVALID_LENGTH,
|
SignatureErrorCodes.INVALID_LENGTH,
|
||||||
hash,
|
hash,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
@@ -234,7 +234,7 @@ contract MixinSignatureValidator is
|
|||||||
|
|
||||||
// Ensure signature is supported
|
// Ensure signature is supported
|
||||||
if (signatureTypeRaw >= uint8(SignatureType.NSignatureTypes)) {
|
if (signatureTypeRaw >= uint8(SignatureType.NSignatureTypes)) {
|
||||||
rrevert(SignatureError(
|
_rrevert(SignatureError(
|
||||||
SignatureErrorCodes.UNSUPPORTED,
|
SignatureErrorCodes.UNSUPPORTED,
|
||||||
hash,
|
hash,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
@@ -248,7 +248,7 @@ contract MixinSignatureValidator is
|
|||||||
// it an explicit option. This aids testing and analysis. It is
|
// it an explicit option. This aids testing and analysis. It is
|
||||||
// also the initialization value for the enum type.
|
// also the initialization value for the enum type.
|
||||||
if (SignatureType(signatureTypeRaw) == SignatureType.Illegal) {
|
if (SignatureType(signatureTypeRaw) == SignatureType.Illegal) {
|
||||||
rrevert(SignatureError(
|
_rrevert(SignatureError(
|
||||||
SignatureErrorCodes.ILLEGAL,
|
SignatureErrorCodes.ILLEGAL,
|
||||||
hash,
|
hash,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
@@ -296,7 +296,7 @@ contract MixinSignatureValidator is
|
|||||||
return returnData.readUint256(0) == 1;
|
return returnData.readUint256(0) == 1;
|
||||||
}
|
}
|
||||||
// Static call to verifier failed.
|
// Static call to verifier failed.
|
||||||
rrevert(SignatureWalletError(
|
_rrevert(SignatureWalletError(
|
||||||
hash,
|
hash,
|
||||||
walletAddress,
|
walletAddress,
|
||||||
signature,
|
signature,
|
||||||
@@ -355,7 +355,7 @@ contract MixinSignatureValidator is
|
|||||||
return returnData.readUint256(0) == 1;
|
return returnData.readUint256(0) == 1;
|
||||||
}
|
}
|
||||||
// Static call to verifier failed.
|
// Static call to verifier failed.
|
||||||
rrevert(SignatureValidatorError(
|
_rrevert(SignatureValidatorError(
|
||||||
hash,
|
hash,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
signature,
|
signature,
|
||||||
@@ -403,7 +403,7 @@ contract MixinSignatureValidator is
|
|||||||
return returnData.readUint256(0) == 1;
|
return returnData.readUint256(0) == 1;
|
||||||
}
|
}
|
||||||
// Static call to verifier failed.
|
// Static call to verifier failed.
|
||||||
rrevert(SignatureWalletOrderValidatorError(
|
_rrevert(SignatureWalletOrderValidatorError(
|
||||||
orderHash,
|
orderHash,
|
||||||
walletAddress,
|
walletAddress,
|
||||||
signature,
|
signature,
|
||||||
@@ -463,7 +463,7 @@ contract MixinSignatureValidator is
|
|||||||
return returnData.readUint256(0) == 1;
|
return returnData.readUint256(0) == 1;
|
||||||
}
|
}
|
||||||
// Static call to verifier failed.
|
// Static call to verifier failed.
|
||||||
rrevert(SignatureOrderValidatorError(
|
_rrevert(SignatureOrderValidatorError(
|
||||||
orderHash,
|
orderHash,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
signature,
|
signature,
|
||||||
@@ -489,7 +489,7 @@ contract MixinSignatureValidator is
|
|||||||
// a correctly formatted but incorrect signature.
|
// a correctly formatted but incorrect signature.
|
||||||
if (signatureType == SignatureType.Invalid) {
|
if (signatureType == SignatureType.Invalid) {
|
||||||
if (signature.length != 1) {
|
if (signature.length != 1) {
|
||||||
rrevert(SignatureError(
|
_rrevert(SignatureError(
|
||||||
SignatureErrorCodes.INVALID_LENGTH,
|
SignatureErrorCodes.INVALID_LENGTH,
|
||||||
hash,
|
hash,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
@@ -502,7 +502,7 @@ contract MixinSignatureValidator is
|
|||||||
// Signature using EIP712
|
// Signature using EIP712
|
||||||
} else if (signatureType == SignatureType.EIP712) {
|
} else if (signatureType == SignatureType.EIP712) {
|
||||||
if (signature.length != 66) {
|
if (signature.length != 66) {
|
||||||
rrevert(SignatureError(
|
_rrevert(SignatureError(
|
||||||
SignatureErrorCodes.INVALID_LENGTH,
|
SignatureErrorCodes.INVALID_LENGTH,
|
||||||
hash,
|
hash,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
@@ -524,7 +524,7 @@ contract MixinSignatureValidator is
|
|||||||
// Signed using web3.eth_sign
|
// Signed using web3.eth_sign
|
||||||
} else if (signatureType == SignatureType.EthSign) {
|
} else if (signatureType == SignatureType.EthSign) {
|
||||||
if (signature.length != 66) {
|
if (signature.length != 66) {
|
||||||
rrevert(SignatureError(
|
_rrevert(SignatureError(
|
||||||
SignatureErrorCodes.INVALID_LENGTH,
|
SignatureErrorCodes.INVALID_LENGTH,
|
||||||
hash,
|
hash,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
|
@@ -87,7 +87,7 @@ contract MixinTransactions is
|
|||||||
|
|
||||||
// Prevent reentrancy
|
// Prevent reentrancy
|
||||||
if (currentContextAddress != address(0)) {
|
if (currentContextAddress != address(0)) {
|
||||||
rrevert(TransactionError(
|
_rrevert(TransactionError(
|
||||||
TransactionErrorCodes.NO_REENTRANCY,
|
TransactionErrorCodes.NO_REENTRANCY,
|
||||||
transactionHash
|
transactionHash
|
||||||
));
|
));
|
||||||
@@ -95,7 +95,7 @@ contract MixinTransactions is
|
|||||||
|
|
||||||
// Validate transaction has not been executed
|
// Validate transaction has not been executed
|
||||||
if (transactions[transactionHash]) {
|
if (transactions[transactionHash]) {
|
||||||
rrevert(TransactionError(
|
_rrevert(TransactionError(
|
||||||
TransactionErrorCodes.ALREADY_EXECUTED,
|
TransactionErrorCodes.ALREADY_EXECUTED,
|
||||||
transactionHash
|
transactionHash
|
||||||
));
|
));
|
||||||
@@ -109,7 +109,7 @@ contract MixinTransactions is
|
|||||||
transactionHash,
|
transactionHash,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
signature)) {
|
signature)) {
|
||||||
rrevert(TransactionSignatureError(
|
_rrevert(TransactionSignatureError(
|
||||||
transactionHash,
|
transactionHash,
|
||||||
signerAddress,
|
signerAddress,
|
||||||
signature
|
signature
|
||||||
@@ -124,7 +124,7 @@ contract MixinTransactions is
|
|||||||
transactions[transactionHash] = true;
|
transactions[transactionHash] = true;
|
||||||
(bool didSucceed, bytes memory returnData) = address(this).delegatecall(transaction.data);
|
(bool didSucceed, bytes memory returnData) = address(this).delegatecall(transaction.data);
|
||||||
if (!didSucceed) {
|
if (!didSucceed) {
|
||||||
rrevert(TransactionExecutionError(
|
_rrevert(TransactionExecutionError(
|
||||||
transactionHash,
|
transactionHash,
|
||||||
returnData
|
returnData
|
||||||
));
|
));
|
||||||
@@ -143,7 +143,7 @@ contract MixinTransactions is
|
|||||||
/// If calling a cancel function, this address will represent the maker.
|
/// If calling a cancel function, this address will represent the maker.
|
||||||
/// @return Signer of 0x transaction if entry point is `executeTransaction`.
|
/// @return Signer of 0x transaction if entry point is `executeTransaction`.
|
||||||
/// `msg.sender` if entry point is any other function.
|
/// `msg.sender` if entry point is any other function.
|
||||||
function getCurrentContextAddress()
|
function _getCurrentContextAddress()
|
||||||
internal
|
internal
|
||||||
view
|
view
|
||||||
returns (address)
|
returns (address)
|
||||||
|
@@ -51,7 +51,7 @@ contract MixinWrapperFunctions is
|
|||||||
nonReentrant
|
nonReentrant
|
||||||
returns (FillResults memory fillResults)
|
returns (FillResults memory fillResults)
|
||||||
{
|
{
|
||||||
fillResults = fillOrKillOrderInternal(
|
fillResults = _fillOrKillOrder(
|
||||||
order,
|
order,
|
||||||
takerAssetFillAmount,
|
takerAssetFillAmount,
|
||||||
signature
|
signature
|
||||||
@@ -74,7 +74,7 @@ contract MixinWrapperFunctions is
|
|||||||
returns (FillResults memory fillResults)
|
returns (FillResults memory fillResults)
|
||||||
{
|
{
|
||||||
// ABI encode calldata for `fillOrder`
|
// ABI encode calldata for `fillOrder`
|
||||||
bytes memory fillOrderCalldata = abiEncodeFillOrder(
|
bytes memory fillOrderCalldata = _abiEncodeFillOrder(
|
||||||
order,
|
order,
|
||||||
takerAssetFillAmount,
|
takerAssetFillAmount,
|
||||||
signature
|
signature
|
||||||
@@ -118,12 +118,12 @@ contract MixinWrapperFunctions is
|
|||||||
{
|
{
|
||||||
uint256 ordersLength = orders.length;
|
uint256 ordersLength = orders.length;
|
||||||
for (uint256 i = 0; i != ordersLength; i++) {
|
for (uint256 i = 0; i != ordersLength; i++) {
|
||||||
FillResults memory singleFillResults = fillOrderInternal(
|
FillResults memory singleFillResults = _fillOrder(
|
||||||
orders[i],
|
orders[i],
|
||||||
takerAssetFillAmounts[i],
|
takerAssetFillAmounts[i],
|
||||||
signatures[i]
|
signatures[i]
|
||||||
);
|
);
|
||||||
addFillResults(totalFillResults, singleFillResults);
|
_addFillResults(totalFillResults, singleFillResults);
|
||||||
}
|
}
|
||||||
return totalFillResults;
|
return totalFillResults;
|
||||||
}
|
}
|
||||||
@@ -145,12 +145,12 @@ contract MixinWrapperFunctions is
|
|||||||
{
|
{
|
||||||
uint256 ordersLength = orders.length;
|
uint256 ordersLength = orders.length;
|
||||||
for (uint256 i = 0; i != ordersLength; i++) {
|
for (uint256 i = 0; i != ordersLength; i++) {
|
||||||
FillResults memory singleFillResults = fillOrKillOrderInternal(
|
FillResults memory singleFillResults = _fillOrKillOrder(
|
||||||
orders[i],
|
orders[i],
|
||||||
takerAssetFillAmounts[i],
|
takerAssetFillAmounts[i],
|
||||||
signatures[i]
|
signatures[i]
|
||||||
);
|
);
|
||||||
addFillResults(totalFillResults, singleFillResults);
|
_addFillResults(totalFillResults, singleFillResults);
|
||||||
}
|
}
|
||||||
return totalFillResults;
|
return totalFillResults;
|
||||||
}
|
}
|
||||||
@@ -177,7 +177,7 @@ contract MixinWrapperFunctions is
|
|||||||
takerAssetFillAmounts[i],
|
takerAssetFillAmounts[i],
|
||||||
signatures[i]
|
signatures[i]
|
||||||
);
|
);
|
||||||
addFillResults(totalFillResults, singleFillResults);
|
_addFillResults(totalFillResults, singleFillResults);
|
||||||
}
|
}
|
||||||
return totalFillResults;
|
return totalFillResults;
|
||||||
}
|
}
|
||||||
@@ -206,17 +206,17 @@ contract MixinWrapperFunctions is
|
|||||||
orders[i].takerAssetData = takerAssetData;
|
orders[i].takerAssetData = takerAssetData;
|
||||||
|
|
||||||
// Calculate the remaining amount of takerAsset to sell
|
// Calculate the remaining amount of takerAsset to sell
|
||||||
uint256 remainingTakerAssetFillAmount = safeSub(takerAssetFillAmount, totalFillResults.takerAssetFilledAmount);
|
uint256 remainingTakerAssetFillAmount = _safeSub(takerAssetFillAmount, totalFillResults.takerAssetFilledAmount);
|
||||||
|
|
||||||
// Attempt to sell the remaining amount of takerAsset
|
// Attempt to sell the remaining amount of takerAsset
|
||||||
FillResults memory singleFillResults = fillOrderInternal(
|
FillResults memory singleFillResults = _fillOrder(
|
||||||
orders[i],
|
orders[i],
|
||||||
remainingTakerAssetFillAmount,
|
remainingTakerAssetFillAmount,
|
||||||
signatures[i]
|
signatures[i]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Update amounts filled and fees paid by maker and taker
|
// Update amounts filled and fees paid by maker and taker
|
||||||
addFillResults(totalFillResults, singleFillResults);
|
_addFillResults(totalFillResults, singleFillResults);
|
||||||
|
|
||||||
// Stop execution if the entire amount of takerAsset has been sold
|
// Stop execution if the entire amount of takerAsset has been sold
|
||||||
if (totalFillResults.takerAssetFilledAmount >= takerAssetFillAmount) {
|
if (totalFillResults.takerAssetFilledAmount >= takerAssetFillAmount) {
|
||||||
@@ -250,7 +250,7 @@ contract MixinWrapperFunctions is
|
|||||||
orders[i].takerAssetData = takerAssetData;
|
orders[i].takerAssetData = takerAssetData;
|
||||||
|
|
||||||
// Calculate the remaining amount of takerAsset to sell
|
// Calculate the remaining amount of takerAsset to sell
|
||||||
uint256 remainingTakerAssetFillAmount = safeSub(takerAssetFillAmount, totalFillResults.takerAssetFilledAmount);
|
uint256 remainingTakerAssetFillAmount = _safeSub(takerAssetFillAmount, totalFillResults.takerAssetFilledAmount);
|
||||||
|
|
||||||
// Attempt to sell the remaining amount of takerAsset
|
// Attempt to sell the remaining amount of takerAsset
|
||||||
FillResults memory singleFillResults = fillOrderNoThrow(
|
FillResults memory singleFillResults = fillOrderNoThrow(
|
||||||
@@ -260,7 +260,7 @@ contract MixinWrapperFunctions is
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Update amounts filled and fees paid by maker and taker
|
// Update amounts filled and fees paid by maker and taker
|
||||||
addFillResults(totalFillResults, singleFillResults);
|
_addFillResults(totalFillResults, singleFillResults);
|
||||||
|
|
||||||
// Stop execution if the entire amount of takerAsset has been sold
|
// Stop execution if the entire amount of takerAsset has been sold
|
||||||
if (totalFillResults.takerAssetFilledAmount >= takerAssetFillAmount) {
|
if (totalFillResults.takerAssetFilledAmount >= takerAssetFillAmount) {
|
||||||
@@ -294,25 +294,25 @@ contract MixinWrapperFunctions is
|
|||||||
orders[i].makerAssetData = makerAssetData;
|
orders[i].makerAssetData = makerAssetData;
|
||||||
|
|
||||||
// Calculate the remaining amount of makerAsset to buy
|
// Calculate the remaining amount of makerAsset to buy
|
||||||
uint256 remainingMakerAssetFillAmount = safeSub(makerAssetFillAmount, totalFillResults.makerAssetFilledAmount);
|
uint256 remainingMakerAssetFillAmount = _safeSub(makerAssetFillAmount, totalFillResults.makerAssetFilledAmount);
|
||||||
|
|
||||||
// Convert the remaining amount of makerAsset to buy into remaining amount
|
// Convert the remaining amount of makerAsset to buy into remaining amount
|
||||||
// of takerAsset to sell, assuming entire amount can be sold in the current order
|
// of takerAsset to sell, assuming entire amount can be sold in the current order
|
||||||
uint256 remainingTakerAssetFillAmount = getPartialAmountFloor(
|
uint256 remainingTakerAssetFillAmount = _getPartialAmountFloor(
|
||||||
orders[i].takerAssetAmount,
|
orders[i].takerAssetAmount,
|
||||||
orders[i].makerAssetAmount,
|
orders[i].makerAssetAmount,
|
||||||
remainingMakerAssetFillAmount
|
remainingMakerAssetFillAmount
|
||||||
);
|
);
|
||||||
|
|
||||||
// Attempt to sell the remaining amount of takerAsset
|
// Attempt to sell the remaining amount of takerAsset
|
||||||
FillResults memory singleFillResults = fillOrderInternal(
|
FillResults memory singleFillResults = _fillOrder(
|
||||||
orders[i],
|
orders[i],
|
||||||
remainingTakerAssetFillAmount,
|
remainingTakerAssetFillAmount,
|
||||||
signatures[i]
|
signatures[i]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Update amounts filled and fees paid by maker and taker
|
// Update amounts filled and fees paid by maker and taker
|
||||||
addFillResults(totalFillResults, singleFillResults);
|
_addFillResults(totalFillResults, singleFillResults);
|
||||||
|
|
||||||
// Stop execution if the entire amount of makerAsset has been bought
|
// Stop execution if the entire amount of makerAsset has been bought
|
||||||
if (totalFillResults.makerAssetFilledAmount >= makerAssetFillAmount) {
|
if (totalFillResults.makerAssetFilledAmount >= makerAssetFillAmount) {
|
||||||
@@ -346,11 +346,11 @@ contract MixinWrapperFunctions is
|
|||||||
orders[i].makerAssetData = makerAssetData;
|
orders[i].makerAssetData = makerAssetData;
|
||||||
|
|
||||||
// Calculate the remaining amount of makerAsset to buy
|
// Calculate the remaining amount of makerAsset to buy
|
||||||
uint256 remainingMakerAssetFillAmount = safeSub(makerAssetFillAmount, totalFillResults.makerAssetFilledAmount);
|
uint256 remainingMakerAssetFillAmount = _safeSub(makerAssetFillAmount, totalFillResults.makerAssetFilledAmount);
|
||||||
|
|
||||||
// Convert the remaining amount of makerAsset to buy into remaining amount
|
// Convert the remaining amount of makerAsset to buy into remaining amount
|
||||||
// of takerAsset to sell, assuming entire amount can be sold in the current order
|
// of takerAsset to sell, assuming entire amount can be sold in the current order
|
||||||
uint256 remainingTakerAssetFillAmount = getPartialAmountFloor(
|
uint256 remainingTakerAssetFillAmount = _getPartialAmountFloor(
|
||||||
orders[i].takerAssetAmount,
|
orders[i].takerAssetAmount,
|
||||||
orders[i].makerAssetAmount,
|
orders[i].makerAssetAmount,
|
||||||
remainingMakerAssetFillAmount
|
remainingMakerAssetFillAmount
|
||||||
@@ -364,7 +364,7 @@ contract MixinWrapperFunctions is
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Update amounts filled and fees paid by maker and taker
|
// Update amounts filled and fees paid by maker and taker
|
||||||
addFillResults(totalFillResults, singleFillResults);
|
_addFillResults(totalFillResults, singleFillResults);
|
||||||
|
|
||||||
// Stop execution if the entire amount of makerAsset has been bought
|
// Stop execution if the entire amount of makerAsset has been bought
|
||||||
if (totalFillResults.makerAssetFilledAmount >= makerAssetFillAmount) {
|
if (totalFillResults.makerAssetFilledAmount >= makerAssetFillAmount) {
|
||||||
@@ -382,7 +382,7 @@ contract MixinWrapperFunctions is
|
|||||||
{
|
{
|
||||||
uint256 ordersLength = orders.length;
|
uint256 ordersLength = orders.length;
|
||||||
for (uint256 i = 0; i != ordersLength; i++) {
|
for (uint256 i = 0; i != ordersLength; i++) {
|
||||||
cancelOrderInternal(orders[i]);
|
_cancelOrder(orders[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -406,7 +406,7 @@ contract MixinWrapperFunctions is
|
|||||||
/// @param order Order struct containing order specifications.
|
/// @param order Order struct containing order specifications.
|
||||||
/// @param takerAssetFillAmount Desired amount of takerAsset to sell.
|
/// @param takerAssetFillAmount Desired amount of takerAsset to sell.
|
||||||
/// @param signature Proof that order has been created by maker.
|
/// @param signature Proof that order has been created by maker.
|
||||||
function fillOrKillOrderInternal(
|
function _fillOrKillOrder(
|
||||||
LibOrder.Order memory order,
|
LibOrder.Order memory order,
|
||||||
uint256 takerAssetFillAmount,
|
uint256 takerAssetFillAmount,
|
||||||
bytes memory signature
|
bytes memory signature
|
||||||
@@ -414,13 +414,13 @@ contract MixinWrapperFunctions is
|
|||||||
internal
|
internal
|
||||||
returns (FillResults memory fillResults)
|
returns (FillResults memory fillResults)
|
||||||
{
|
{
|
||||||
fillResults = fillOrderInternal(
|
fillResults = _fillOrder(
|
||||||
order,
|
order,
|
||||||
takerAssetFillAmount,
|
takerAssetFillAmount,
|
||||||
signature
|
signature
|
||||||
);
|
);
|
||||||
if (fillResults.takerAssetFilledAmount != takerAssetFillAmount) {
|
if (fillResults.takerAssetFilledAmount != takerAssetFillAmount) {
|
||||||
rrevert(IncompleteFillError(getOrderInfo(order).orderHash));
|
_rrevert(IncompleteFillError(getOrderInfo(order).orderHash));
|
||||||
}
|
}
|
||||||
return fillResults;
|
return fillResults;
|
||||||
}
|
}
|
||||||
|
@@ -28,7 +28,7 @@ contract LibExchangeRichErrorDecoder is
|
|||||||
/// @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.
|
||||||
/// @return signer The expected signer of the hash.
|
/// @return signerAddress The expected signerAddress of the hash.
|
||||||
/// @return signature The full signature.
|
/// @return signature The full signature.
|
||||||
function decodeSignatureError(bytes memory encoded)
|
function decodeSignatureError(bytes memory encoded)
|
||||||
public
|
public
|
||||||
@@ -36,20 +36,20 @@ contract LibExchangeRichErrorDecoder is
|
|||||||
returns (
|
returns (
|
||||||
SignatureErrorCodes errorCode,
|
SignatureErrorCodes errorCode,
|
||||||
bytes32 hash,
|
bytes32 hash,
|
||||||
address signer,
|
address signerAddress,
|
||||||
bytes memory signature
|
bytes memory signature
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_assertSelectorBytes(encoded, SIGNATURE_ERROR_SELECTOR);
|
_assertSelectorBytes(encoded, SIGNATURE_ERROR_SELECTOR);
|
||||||
errorCode = SignatureErrorCodes(_readErrorParameterAsUint256(encoded, 0));
|
errorCode = SignatureErrorCodes(_readErrorParameterAsUint256(encoded, 0));
|
||||||
hash = _readErrorParameterAsBytes32(encoded, 1);
|
hash = _readErrorParameterAsBytes32(encoded, 1);
|
||||||
signer = _readErrorParameterAsAddress(encoded, 2);
|
signerAddress = _readErrorParameterAsAddress(encoded, 2);
|
||||||
signature = _readErrorParameterAsBytes(encoded, 3);
|
signature = _readErrorParameterAsBytes(encoded, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Decompose an ABI-encoded SignatureValidatorError.
|
/// @dev Decompose an ABI-encoded SignatureValidatorError.
|
||||||
/// @param encoded ABI-encoded revert error.
|
/// @param encoded ABI-encoded revert error.
|
||||||
/// @return signer The expected signer of the hash.
|
/// @return signerAddress The expected signerAddress of the hash.
|
||||||
/// @return signature The full signature bytes.
|
/// @return signature The full signature bytes.
|
||||||
/// @return errorData The revert data thrown by the validator contract.
|
/// @return errorData The revert data thrown by the validator contract.
|
||||||
function decodeSignatureValidatorError(bytes memory encoded)
|
function decodeSignatureValidatorError(bytes memory encoded)
|
||||||
@@ -57,14 +57,14 @@ contract LibExchangeRichErrorDecoder is
|
|||||||
pure
|
pure
|
||||||
returns (
|
returns (
|
||||||
bytes32 hash,
|
bytes32 hash,
|
||||||
address signer,
|
address signerAddress,
|
||||||
bytes memory signature,
|
bytes memory signature,
|
||||||
bytes memory errorData
|
bytes memory errorData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_assertSelectorBytes(encoded, SIGNATURE_VALIDATOR_ERROR_SELECTOR);
|
_assertSelectorBytes(encoded, SIGNATURE_VALIDATOR_ERROR_SELECTOR);
|
||||||
hash = _readErrorParameterAsBytes32(encoded, 0);
|
hash = _readErrorParameterAsBytes32(encoded, 0);
|
||||||
signer = _readErrorParameterAsAddress(encoded, 1);
|
signerAddress = _readErrorParameterAsAddress(encoded, 1);
|
||||||
signature = _readErrorParameterAsBytes(encoded, 2);
|
signature = _readErrorParameterAsBytes(encoded, 2);
|
||||||
errorData = _readErrorParameterAsBytes(encoded, 3);
|
errorData = _readErrorParameterAsBytes(encoded, 3);
|
||||||
}
|
}
|
||||||
@@ -72,7 +72,7 @@ contract LibExchangeRichErrorDecoder is
|
|||||||
/// @dev Decompose an ABI-encoded SignatureWalletError.
|
/// @dev Decompose an ABI-encoded SignatureWalletError.
|
||||||
/// @param encoded ABI-encoded revert error.
|
/// @param encoded ABI-encoded revert error.
|
||||||
/// @return errorCode The error code.
|
/// @return errorCode The error code.
|
||||||
/// @return signer The expected signer of the hash.
|
/// @return signerAddress The expected signerAddress of the hash.
|
||||||
/// @return signature The full signature bytes.
|
/// @return signature The full signature bytes.
|
||||||
/// @return errorData The revert data thrown by the validator contract.
|
/// @return errorData The revert data thrown by the validator contract.
|
||||||
function decodeSignatureWalletError(bytes memory encoded)
|
function decodeSignatureWalletError(bytes memory encoded)
|
||||||
@@ -80,14 +80,14 @@ contract LibExchangeRichErrorDecoder is
|
|||||||
pure
|
pure
|
||||||
returns (
|
returns (
|
||||||
bytes32 hash,
|
bytes32 hash,
|
||||||
address signer,
|
address signerAddress,
|
||||||
bytes memory signature,
|
bytes memory signature,
|
||||||
bytes memory errorData
|
bytes memory errorData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_assertSelectorBytes(encoded, SIGNATURE_WALLET_ERROR_SELECTOR);
|
_assertSelectorBytes(encoded, SIGNATURE_WALLET_ERROR_SELECTOR);
|
||||||
hash = _readErrorParameterAsBytes32(encoded, 0);
|
hash = _readErrorParameterAsBytes32(encoded, 0);
|
||||||
signer = _readErrorParameterAsAddress(encoded, 1);
|
signerAddress = _readErrorParameterAsAddress(encoded, 1);
|
||||||
signature = _readErrorParameterAsBytes(encoded, 2);
|
signature = _readErrorParameterAsBytes(encoded, 2);
|
||||||
errorData = _readErrorParameterAsBytes(encoded, 3);
|
errorData = _readErrorParameterAsBytes(encoded, 3);
|
||||||
}
|
}
|
||||||
@@ -95,7 +95,7 @@ contract LibExchangeRichErrorDecoder is
|
|||||||
/// @dev Decompose an ABI-encoded SignatureOrderValidatorError.
|
/// @dev Decompose an ABI-encoded SignatureOrderValidatorError.
|
||||||
/// @param encoded ABI-encoded revert error.
|
/// @param encoded ABI-encoded revert error.
|
||||||
/// @return errorCode The error code.
|
/// @return errorCode The error code.
|
||||||
/// @return signer The expected signer of the hash.
|
/// @return signerAddress The expected signerAddress of the hash.
|
||||||
/// @return signature The full signature bytes.
|
/// @return signature The full signature bytes.
|
||||||
/// @return errorData The revert data thrown by the validator contract.
|
/// @return errorData The revert data thrown by the validator contract.
|
||||||
function decodeSignatureOrderValidatorError(bytes memory encoded)
|
function decodeSignatureOrderValidatorError(bytes memory encoded)
|
||||||
@@ -103,14 +103,14 @@ contract LibExchangeRichErrorDecoder is
|
|||||||
pure
|
pure
|
||||||
returns (
|
returns (
|
||||||
bytes32 hash,
|
bytes32 hash,
|
||||||
address signer,
|
address signerAddress,
|
||||||
bytes memory signature,
|
bytes memory signature,
|
||||||
bytes memory errorData
|
bytes memory errorData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_assertSelectorBytes(encoded, SIGNATURE_ORDER_VALIDATOR_ERROR_SELECTOR);
|
_assertSelectorBytes(encoded, SIGNATURE_ORDER_VALIDATOR_ERROR_SELECTOR);
|
||||||
hash = _readErrorParameterAsBytes32(encoded, 0);
|
hash = _readErrorParameterAsBytes32(encoded, 0);
|
||||||
signer = _readErrorParameterAsAddress(encoded, 1);
|
signerAddress = _readErrorParameterAsAddress(encoded, 1);
|
||||||
signature = _readErrorParameterAsBytes(encoded, 2);
|
signature = _readErrorParameterAsBytes(encoded, 2);
|
||||||
errorData = _readErrorParameterAsBytes(encoded, 3);
|
errorData = _readErrorParameterAsBytes(encoded, 3);
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,7 @@ contract LibExchangeRichErrorDecoder is
|
|||||||
/// @dev Decompose an ABI-encoded SignatureWalletOrderValidatorError.
|
/// @dev Decompose an ABI-encoded SignatureWalletOrderValidatorError.
|
||||||
/// @param encoded ABI-encoded revert error.
|
/// @param encoded ABI-encoded revert error.
|
||||||
/// @return errorCode The error code.
|
/// @return errorCode The error code.
|
||||||
/// @return signer The expected signer of the hash.
|
/// @return signerAddress The expected signerAddress of the hash.
|
||||||
/// @return signature The full signature bytes.
|
/// @return signature The full signature bytes.
|
||||||
/// @return errorData The revert data thrown by the validator contract.
|
/// @return errorData The revert data thrown by the validator contract.
|
||||||
function decodeSignatureWalletOrderValidatorError(bytes memory encoded)
|
function decodeSignatureWalletOrderValidatorError(bytes memory encoded)
|
||||||
@@ -126,14 +126,14 @@ contract LibExchangeRichErrorDecoder is
|
|||||||
pure
|
pure
|
||||||
returns (
|
returns (
|
||||||
bytes32 hash,
|
bytes32 hash,
|
||||||
address signer,
|
address signerAddress,
|
||||||
bytes memory signature,
|
bytes memory signature,
|
||||||
bytes memory errorData
|
bytes memory errorData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_assertSelectorBytes(encoded, SIGNATURE_WALLET_ORDER_VALIDATOR_ERROR_SELECTOR);
|
_assertSelectorBytes(encoded, SIGNATURE_WALLET_ORDER_VALIDATOR_ERROR_SELECTOR);
|
||||||
hash = _readErrorParameterAsBytes32(encoded, 0);
|
hash = _readErrorParameterAsBytes32(encoded, 0);
|
||||||
signer = _readErrorParameterAsAddress(encoded, 1);
|
signerAddress = _readErrorParameterAsAddress(encoded, 1);
|
||||||
signature = _readErrorParameterAsBytes(encoded, 2);
|
signature = _readErrorParameterAsBytes(encoded, 2);
|
||||||
errorData = _readErrorParameterAsBytes(encoded, 3);
|
errorData = _readErrorParameterAsBytes(encoded, 3);
|
||||||
}
|
}
|
||||||
@@ -158,52 +158,52 @@ contract LibExchangeRichErrorDecoder is
|
|||||||
/// @dev Decompose an ABI-encoded InvalidSenderError.
|
/// @dev Decompose an ABI-encoded InvalidSenderError.
|
||||||
/// @param encoded ABI-encoded revert error.
|
/// @param encoded ABI-encoded revert error.
|
||||||
/// @return orderHash The order hash.
|
/// @return orderHash The order hash.
|
||||||
/// @return sender The sender.
|
/// @return senderAddress The senderAddress.
|
||||||
function decodeInvalidSenderError(bytes memory encoded)
|
function decodeInvalidSenderError(bytes memory encoded)
|
||||||
public
|
public
|
||||||
pure
|
pure
|
||||||
returns (
|
returns (
|
||||||
bytes32 orderHash,
|
bytes32 orderHash,
|
||||||
address sender
|
address senderAddress
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_assertSelectorBytes(encoded, INVALID_SENDER_ERROR_SELECTOR);
|
_assertSelectorBytes(encoded, INVALID_SENDER_ERROR_SELECTOR);
|
||||||
orderHash = _readErrorParameterAsBytes32(encoded, 0);
|
orderHash = _readErrorParameterAsBytes32(encoded, 0);
|
||||||
sender = _readErrorParameterAsAddress(encoded, 1);
|
senderAddress = _readErrorParameterAsAddress(encoded, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Decompose an ABI-encoded InvalidMakerError.
|
/// @dev Decompose an ABI-encoded InvalidMakerError.
|
||||||
/// @param encoded ABI-encoded revert error.
|
/// @param encoded ABI-encoded revert error.
|
||||||
/// @return orderHash The order hash.
|
/// @return orderHash The order hash.
|
||||||
/// @return maker The maker of the order.
|
/// @return makerAddress The makerAddress of the order.
|
||||||
function decodeInvalidMakerError(bytes memory encoded)
|
function decodeInvalidMakerError(bytes memory encoded)
|
||||||
public
|
public
|
||||||
pure
|
pure
|
||||||
returns (
|
returns (
|
||||||
bytes32 orderHash,
|
bytes32 orderHash,
|
||||||
address maker
|
address makerAddress
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_assertSelectorBytes(encoded, INVALID_MAKER_ERROR_SELECTOR);
|
_assertSelectorBytes(encoded, INVALID_MAKER_ERROR_SELECTOR);
|
||||||
orderHash = _readErrorParameterAsBytes32(encoded, 0);
|
orderHash = _readErrorParameterAsBytes32(encoded, 0);
|
||||||
maker = _readErrorParameterAsAddress(encoded, 1);
|
makerAddress = _readErrorParameterAsAddress(encoded, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Decompose an ABI-encoded InvalidTaker.
|
/// @dev Decompose an ABI-encoded InvalidTaker.
|
||||||
/// @param encoded ABI-encoded revert error.
|
/// @param encoded ABI-encoded revert error.
|
||||||
/// @return orderHash The order hash.
|
/// @return orderHash The order hash.
|
||||||
/// @return taker The taker of the order.
|
/// @return takerAddress The takerAddress of the order.
|
||||||
function decodeInvalidTakerError(bytes memory encoded)
|
function decodeInvalidTakerError(bytes memory encoded)
|
||||||
public
|
public
|
||||||
pure
|
pure
|
||||||
returns (
|
returns (
|
||||||
bytes32 orderHash,
|
bytes32 orderHash,
|
||||||
address taker
|
address takerAddress
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_assertSelectorBytes(encoded, INVALID_TAKER_ERROR_SELECTOR);
|
_assertSelectorBytes(encoded, INVALID_TAKER_ERROR_SELECTOR);
|
||||||
orderHash = _readErrorParameterAsBytes32(encoded, 0);
|
orderHash = _readErrorParameterAsBytes32(encoded, 0);
|
||||||
taker = _readErrorParameterAsAddress(encoded, 1);
|
takerAddress = _readErrorParameterAsAddress(encoded, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Decompose an ABI-encoded FillError.
|
/// @dev Decompose an ABI-encoded FillError.
|
||||||
@@ -225,21 +225,21 @@ contract LibExchangeRichErrorDecoder is
|
|||||||
|
|
||||||
/// @dev Decompose an ABI-encoded OrderEpochError.
|
/// @dev Decompose an ABI-encoded OrderEpochError.
|
||||||
/// @param encoded ABI-encoded revert error.
|
/// @param encoded ABI-encoded revert error.
|
||||||
/// @return maker The order maker.
|
/// @return makerAddress The order makerAddress.
|
||||||
/// @return sender The sender.
|
/// @return orderSenderAddress The senderAddress.
|
||||||
/// @return currentEpoch The current epoch for the maker.
|
/// @return currentEpoch The current epoch for the makerAddress.
|
||||||
function decodeOrderEpochError(bytes memory encoded)
|
function decodeOrderEpochError(bytes memory encoded)
|
||||||
public
|
public
|
||||||
pure
|
pure
|
||||||
returns (
|
returns (
|
||||||
address maker,
|
address makerAddress,
|
||||||
address sender,
|
address orderSenderAddress,
|
||||||
uint256 currentEpoch
|
uint256 currentEpoch
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_assertSelectorBytes(encoded, ORDER_EPOCH_ERROR_SELECTOR);
|
_assertSelectorBytes(encoded, ORDER_EPOCH_ERROR_SELECTOR);
|
||||||
maker = _readErrorParameterAsAddress(encoded, 0);
|
makerAddress = _readErrorParameterAsAddress(encoded, 0);
|
||||||
sender = _readErrorParameterAsAddress(encoded, 1);
|
orderSenderAddress = _readErrorParameterAsAddress(encoded, 1);
|
||||||
currentEpoch = _readErrorParameterAsUint256(encoded, 2);
|
currentEpoch = _readErrorParameterAsUint256(encoded, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,20 +332,20 @@ contract LibExchangeRichErrorDecoder is
|
|||||||
/// @dev Decompose an ABI-encoded TransactionSignatureError.
|
/// @dev Decompose an ABI-encoded TransactionSignatureError.
|
||||||
/// @param encoded ABI-encoded revert error.
|
/// @param encoded ABI-encoded revert error.
|
||||||
/// @return transactionHash Hash of the transaction.
|
/// @return transactionHash Hash of the transaction.
|
||||||
/// @return signer Signer of the transaction.
|
/// @return signerAddress Signer of the transaction.
|
||||||
/// @return signature Full signature for the transaction.
|
/// @return signature Full signature for the transaction.
|
||||||
function decodeTransactionSignatureError(bytes memory encoded)
|
function decodeTransactionSignatureError(bytes memory encoded)
|
||||||
public
|
public
|
||||||
pure
|
pure
|
||||||
returns (
|
returns (
|
||||||
bytes32 transactionHash,
|
bytes32 transactionHash,
|
||||||
address signer,
|
address signerAddress,
|
||||||
bytes memory signature
|
bytes memory signature
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_assertSelectorBytes(encoded, TRANSACTION_SIGNATURE_ERROR_SELECTOR);
|
_assertSelectorBytes(encoded, TRANSACTION_SIGNATURE_ERROR_SELECTOR);
|
||||||
transactionHash = _readErrorParameterAsBytes32(encoded, 0);
|
transactionHash = _readErrorParameterAsBytes32(encoded, 0);
|
||||||
signer = _readErrorParameterAsAddress(encoded, 1);
|
signerAddress = _readErrorParameterAsAddress(encoded, 1);
|
||||||
signature = _readErrorParameterAsBytes(encoded, 2);
|
signature = _readErrorParameterAsBytes(encoded, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -36,7 +36,7 @@ contract MAssetProxyDispatcher is
|
|||||||
/// @param from Address to transfer token from.
|
/// @param from Address to transfer token from.
|
||||||
/// @param to Address to transfer token to.
|
/// @param to Address to transfer token to.
|
||||||
/// @param amount Amount of token to transfer.
|
/// @param amount Amount of token to transfer.
|
||||||
function dispatchTransferFrom(
|
function _dispatchTransferFrom(
|
||||||
bytes32 orderHash,
|
bytes32 orderHash,
|
||||||
bytes memory assetData,
|
bytes memory assetData,
|
||||||
address from,
|
address from,
|
||||||
|
@@ -55,7 +55,7 @@ contract MExchangeCore is
|
|||||||
// CancelUpTo event is emitted whenever `cancelOrdersUpTo` is executed succesfully.
|
// CancelUpTo event is emitted whenever `cancelOrdersUpTo` is executed succesfully.
|
||||||
event CancelUpTo(
|
event CancelUpTo(
|
||||||
address indexed makerAddress, // Orders cancelled must have been created by this address.
|
address indexed makerAddress, // Orders cancelled must have been created by this address.
|
||||||
address indexed senderAddress, // Orders cancelled must have a `senderAddress` equal to 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.
|
uint256 orderEpoch // Orders with specified makerAddress and senderAddress with a salt less than this value are considered cancelled.
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ contract MExchangeCore is
|
|||||||
/// @param takerAssetFillAmount Desired amount of takerAsset to sell.
|
/// @param takerAssetFillAmount Desired amount of takerAsset to sell.
|
||||||
/// @param signature Proof that order has been created by maker.
|
/// @param signature Proof that order has been created by maker.
|
||||||
/// @return Amounts filled and fees paid by maker and taker.
|
/// @return Amounts filled and fees paid by maker and taker.
|
||||||
function fillOrderInternal(
|
function _fillOrder(
|
||||||
LibOrder.Order memory order,
|
LibOrder.Order memory order,
|
||||||
uint256 takerAssetFillAmount,
|
uint256 takerAssetFillAmount,
|
||||||
bytes memory signature
|
bytes memory signature
|
||||||
@@ -74,7 +74,7 @@ contract MExchangeCore is
|
|||||||
|
|
||||||
/// @dev After calling, the order can not be filled anymore.
|
/// @dev After calling, the order can not be filled anymore.
|
||||||
/// @param order Order struct containing order specifications.
|
/// @param order Order struct containing order specifications.
|
||||||
function cancelOrderInternal(LibOrder.Order memory order)
|
function _cancelOrder(LibOrder.Order memory order)
|
||||||
internal;
|
internal;
|
||||||
|
|
||||||
/// @dev Updates state with results of a fill order.
|
/// @dev Updates state with results of a fill order.
|
||||||
@@ -82,7 +82,7 @@ contract MExchangeCore is
|
|||||||
/// @param takerAddress Address of taker who filled the order.
|
/// @param takerAddress Address of taker who filled the order.
|
||||||
/// @param orderTakerAssetFilledAmount Amount of order already filled.
|
/// @param orderTakerAssetFilledAmount Amount of order already filled.
|
||||||
/// @return fillResults Amounts filled and fees paid by maker and taker.
|
/// @return fillResults Amounts filled and fees paid by maker and taker.
|
||||||
function updateFilledState(
|
function _updateFilledState(
|
||||||
LibOrder.Order memory order,
|
LibOrder.Order memory order,
|
||||||
address takerAddress,
|
address takerAddress,
|
||||||
bytes32 orderHash,
|
bytes32 orderHash,
|
||||||
@@ -96,7 +96,7 @@ contract MExchangeCore is
|
|||||||
/// Otherwise, updating state would have no effect.
|
/// Otherwise, updating state would have no effect.
|
||||||
/// @param order that was cancelled.
|
/// @param order that was cancelled.
|
||||||
/// @param orderHash Hash of order that was cancelled.
|
/// @param orderHash Hash of order that was cancelled.
|
||||||
function updateCancelledState(
|
function _updateCancelledState(
|
||||||
LibOrder.Order memory order,
|
LibOrder.Order memory order,
|
||||||
bytes32 orderHash
|
bytes32 orderHash
|
||||||
)
|
)
|
||||||
@@ -107,7 +107,7 @@ contract MExchangeCore is
|
|||||||
/// @param orderInfo OrderStatus, orderHash, and amount already filled of order.
|
/// @param orderInfo OrderStatus, orderHash, and amount already filled of order.
|
||||||
/// @param takerAddress Address of order taker.
|
/// @param takerAddress Address of order taker.
|
||||||
/// @param signature Proof that the orders was created by its maker.
|
/// @param signature Proof that the orders was created by its maker.
|
||||||
function assertFillableOrder(
|
function _assertFillableOrder(
|
||||||
LibOrder.Order memory order,
|
LibOrder.Order memory order,
|
||||||
LibOrder.OrderInfo memory orderInfo,
|
LibOrder.OrderInfo memory orderInfo,
|
||||||
address takerAddress,
|
address takerAddress,
|
||||||
@@ -122,7 +122,7 @@ contract MExchangeCore is
|
|||||||
/// @param takerAssetFillAmount Desired amount of order to fill by taker.
|
/// @param takerAssetFillAmount Desired amount of order to fill by taker.
|
||||||
/// @param takerAssetFilledAmount Amount of takerAsset that will be filled.
|
/// @param takerAssetFilledAmount Amount of takerAsset that will be filled.
|
||||||
/// @param makerAssetFilledAmount Amount of makerAsset that will be transfered.
|
/// @param makerAssetFilledAmount Amount of makerAsset that will be transfered.
|
||||||
function assertValidFill(
|
function _assertValidFill(
|
||||||
LibOrder.Order memory order,
|
LibOrder.Order memory order,
|
||||||
LibOrder.OrderInfo memory orderInfo,
|
LibOrder.OrderInfo memory orderInfo,
|
||||||
uint256 takerAssetFillAmount,
|
uint256 takerAssetFillAmount,
|
||||||
@@ -135,7 +135,7 @@ contract MExchangeCore is
|
|||||||
/// @dev Validates context for cancelOrder. Succeeds or throws.
|
/// @dev Validates context for cancelOrder. Succeeds or throws.
|
||||||
/// @param order to be cancelled.
|
/// @param order to be cancelled.
|
||||||
/// @param orderInfo OrderStatus, orderHash, and amount already filled of order.
|
/// @param orderInfo OrderStatus, orderHash, and amount already filled of order.
|
||||||
function assertValidCancel(
|
function _assertValidCancel(
|
||||||
LibOrder.Order memory order,
|
LibOrder.Order memory order,
|
||||||
LibOrder.OrderInfo memory orderInfo
|
LibOrder.OrderInfo memory orderInfo
|
||||||
)
|
)
|
||||||
@@ -146,7 +146,7 @@ contract MExchangeCore is
|
|||||||
/// @param order to be filled.
|
/// @param order to be filled.
|
||||||
/// @param takerAssetFilledAmount Amount of takerAsset that will be filled.
|
/// @param takerAssetFilledAmount Amount of takerAsset that will be filled.
|
||||||
/// @return fillResults Amounts filled and fees paid by maker and taker.
|
/// @return fillResults Amounts filled and fees paid by maker and taker.
|
||||||
function calculateFillResults(
|
function _calculateFillResults(
|
||||||
LibOrder.Order memory order,
|
LibOrder.Order memory order,
|
||||||
uint256 takerAssetFilledAmount
|
uint256 takerAssetFilledAmount
|
||||||
)
|
)
|
||||||
|
@@ -31,7 +31,7 @@ contract MExchangeRichErrors is
|
|||||||
function SignatureError(
|
function SignatureError(
|
||||||
SignatureErrorCodes errorCode,
|
SignatureErrorCodes errorCode,
|
||||||
bytes32 hash,
|
bytes32 hash,
|
||||||
address signer,
|
address signerAddress,
|
||||||
bytes memory signature
|
bytes memory signature
|
||||||
)
|
)
|
||||||
internal
|
internal
|
||||||
@@ -40,7 +40,7 @@ contract MExchangeRichErrors is
|
|||||||
|
|
||||||
function SignatureValidatorError(
|
function SignatureValidatorError(
|
||||||
bytes32 hash,
|
bytes32 hash,
|
||||||
address signer,
|
address signerAddress,
|
||||||
bytes memory signature,
|
bytes memory signature,
|
||||||
bytes memory errorData
|
bytes memory errorData
|
||||||
)
|
)
|
||||||
@@ -50,7 +50,7 @@ contract MExchangeRichErrors is
|
|||||||
|
|
||||||
function SignatureWalletError(
|
function SignatureWalletError(
|
||||||
bytes32 hash,
|
bytes32 hash,
|
||||||
address signer,
|
address signerAddress,
|
||||||
bytes memory signature,
|
bytes memory signature,
|
||||||
bytes memory errorData
|
bytes memory errorData
|
||||||
)
|
)
|
||||||
@@ -60,7 +60,7 @@ contract MExchangeRichErrors is
|
|||||||
|
|
||||||
function SignatureOrderValidatorError(
|
function SignatureOrderValidatorError(
|
||||||
bytes32 orderHash,
|
bytes32 orderHash,
|
||||||
address signer,
|
address signerAddress,
|
||||||
bytes memory signature,
|
bytes memory signature,
|
||||||
bytes memory errorData
|
bytes memory errorData
|
||||||
)
|
)
|
||||||
@@ -88,7 +88,7 @@ contract MExchangeRichErrors is
|
|||||||
|
|
||||||
function InvalidSenderError(
|
function InvalidSenderError(
|
||||||
bytes32 orderHash,
|
bytes32 orderHash,
|
||||||
address sender
|
address senderAddress
|
||||||
)
|
)
|
||||||
internal
|
internal
|
||||||
pure
|
pure
|
||||||
@@ -96,7 +96,7 @@ contract MExchangeRichErrors is
|
|||||||
|
|
||||||
function InvalidMakerError(
|
function InvalidMakerError(
|
||||||
bytes32 orderHash,
|
bytes32 orderHash,
|
||||||
address maker
|
address makerAddress
|
||||||
)
|
)
|
||||||
internal
|
internal
|
||||||
pure
|
pure
|
||||||
@@ -112,15 +112,15 @@ contract MExchangeRichErrors is
|
|||||||
|
|
||||||
function InvalidTakerError(
|
function InvalidTakerError(
|
||||||
bytes32 orderHash,
|
bytes32 orderHash,
|
||||||
address taker
|
address takerAddress
|
||||||
)
|
)
|
||||||
internal
|
internal
|
||||||
pure
|
pure
|
||||||
returns (bytes memory);
|
returns (bytes memory);
|
||||||
|
|
||||||
function OrderEpochError(
|
function OrderEpochError(
|
||||||
address maker,
|
address makerAddress,
|
||||||
address sender,
|
address senderAddress,
|
||||||
uint256 currentEpoch
|
uint256 currentEpoch
|
||||||
)
|
)
|
||||||
internal
|
internal
|
||||||
@@ -170,7 +170,7 @@ contract MExchangeRichErrors is
|
|||||||
|
|
||||||
function TransactionSignatureError(
|
function TransactionSignatureError(
|
||||||
bytes32 transactionHash,
|
bytes32 transactionHash,
|
||||||
address signer,
|
address signerAddress,
|
||||||
bytes memory signature
|
bytes memory signature
|
||||||
)
|
)
|
||||||
internal
|
internal
|
||||||
|
@@ -30,7 +30,7 @@ contract MMatchOrders is
|
|||||||
/// @dev Validates context for matchOrders. Succeeds or throws.
|
/// @dev Validates context for matchOrders. Succeeds or throws.
|
||||||
/// @param leftOrder First order to match.
|
/// @param leftOrder First order to match.
|
||||||
/// @param rightOrder Second order to match.
|
/// @param rightOrder Second order to match.
|
||||||
function assertValidMatch(
|
function _assertValidMatch(
|
||||||
LibOrder.Order memory leftOrder,
|
LibOrder.Order memory leftOrder,
|
||||||
LibOrder.Order memory rightOrder
|
LibOrder.Order memory rightOrder
|
||||||
)
|
)
|
||||||
@@ -46,7 +46,7 @@ contract MMatchOrders is
|
|||||||
/// @param leftOrderTakerAssetFilledAmount Amount of left order already filled.
|
/// @param leftOrderTakerAssetFilledAmount Amount of left order already filled.
|
||||||
/// @param rightOrderTakerAssetFilledAmount Amount of right 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.
|
/// @param matchedFillResults Amounts to fill and fees to pay by maker and taker of matched orders.
|
||||||
function calculateMatchedFillResults(
|
function _calculateMatchedFillResults(
|
||||||
LibOrder.Order memory leftOrder,
|
LibOrder.Order memory leftOrder,
|
||||||
LibOrder.Order memory rightOrder,
|
LibOrder.Order memory rightOrder,
|
||||||
uint256 leftOrderTakerAssetFilledAmount,
|
uint256 leftOrderTakerAssetFilledAmount,
|
||||||
|
@@ -53,7 +53,7 @@ contract MSignatureValidator is
|
|||||||
/// @param signerAddress Address that should have signed the.Signat given hash.
|
/// @param signerAddress Address that should have signed the.Signat given hash.
|
||||||
/// @param signature Proof that the hash has been signed by signer.
|
/// @param signature Proof that the hash has been signed by signer.
|
||||||
/// @return True if the signature is valid for the given hash and signer.
|
/// @return True if the signature is valid for the given hash and signer.
|
||||||
function isValidOrderWithHashSignature(
|
function _isValidOrderWithHashSignature(
|
||||||
LibOrder.Order memory order,
|
LibOrder.Order memory order,
|
||||||
bytes32 orderHash,
|
bytes32 orderHash,
|
||||||
address signerAddress,
|
address signerAddress,
|
||||||
|
@@ -42,7 +42,7 @@ contract MTransactions is
|
|||||||
/// If calling a cancel function, this address will represent the maker.
|
/// If calling a cancel function, this address will represent the maker.
|
||||||
/// @return Signer of 0x transaction if entry point is `executeTransaction`.
|
/// @return Signer of 0x transaction if entry point is `executeTransaction`.
|
||||||
/// `msg.sender` if entry point is any other function.
|
/// `msg.sender` if entry point is any other function.
|
||||||
function getCurrentContextAddress()
|
function _getCurrentContextAddress()
|
||||||
internal
|
internal
|
||||||
view
|
view
|
||||||
returns (address);
|
returns (address);
|
||||||
|
@@ -31,7 +31,7 @@ contract MWrapperFunctions is
|
|||||||
/// @param order LibOrder.Order struct containing order specifications.
|
/// @param order LibOrder.Order struct containing order specifications.
|
||||||
/// @param takerAssetFillAmount Desired amount of takerAsset to sell.
|
/// @param takerAssetFillAmount Desired amount of takerAsset to sell.
|
||||||
/// @param signature Proof that order has been created by maker.
|
/// @param signature Proof that order has been created by maker.
|
||||||
function fillOrKillOrderInternal(
|
function _fillOrKillOrder(
|
||||||
LibOrder.Order memory order,
|
LibOrder.Order memory order,
|
||||||
uint256 takerAssetFillAmount,
|
uint256 takerAssetFillAmount,
|
||||||
bytes memory signature
|
bytes memory signature
|
||||||
|
@@ -91,56 +91,56 @@ contract ReentrantERC20Token is
|
|||||||
bytes memory callData;
|
bytes memory callData;
|
||||||
// Create callData for function that corresponds to currentFunctionId
|
// Create callData for function that corresponds to currentFunctionId
|
||||||
if (currentFunctionId == uint8(ExchangeFunction.FILL_ORDER)) {
|
if (currentFunctionId == uint8(ExchangeFunction.FILL_ORDER)) {
|
||||||
LibOrder.Order memory order = createOrders(1)[0];
|
LibOrder.Order memory order = _createOrders(1)[0];
|
||||||
callData = abi.encodeWithSelector(
|
callData = abi.encodeWithSelector(
|
||||||
exchange.fillOrder.selector,
|
exchange.fillOrder.selector,
|
||||||
order,
|
order,
|
||||||
order.takerAssetAmount,
|
order.takerAssetAmount,
|
||||||
createWalletSignatures(1)[0]
|
_createWalletSignatures(1)[0]
|
||||||
);
|
);
|
||||||
} else if (currentFunctionId == uint8(ExchangeFunction.FILL_OR_KILL_ORDER)) {
|
} else if (currentFunctionId == uint8(ExchangeFunction.FILL_OR_KILL_ORDER)) {
|
||||||
LibOrder.Order memory order = createOrders(1)[0];
|
LibOrder.Order memory order = _createOrders(1)[0];
|
||||||
callData = abi.encodeWithSelector(
|
callData = abi.encodeWithSelector(
|
||||||
exchange.fillOrKillOrder.selector,
|
exchange.fillOrKillOrder.selector,
|
||||||
order,
|
order,
|
||||||
order.takerAssetAmount,
|
order.takerAssetAmount,
|
||||||
createWalletSignatures(1)[0]
|
_createWalletSignatures(1)[0]
|
||||||
);
|
);
|
||||||
} else if (currentFunctionId == uint8(ExchangeFunction.BATCH_FILL_ORDERS)) {
|
} else if (currentFunctionId == uint8(ExchangeFunction.BATCH_FILL_ORDERS)) {
|
||||||
LibOrder.Order[] memory orders = createOrders(BATCH_SIZE);
|
LibOrder.Order[] memory orders = _createOrders(BATCH_SIZE);
|
||||||
callData = abi.encodeWithSelector(
|
callData = abi.encodeWithSelector(
|
||||||
exchange.batchFillOrders.selector,
|
exchange.batchFillOrders.selector,
|
||||||
orders,
|
orders,
|
||||||
getTakerFillAmounts(orders),
|
getTakerFillAmounts(orders),
|
||||||
createWalletSignatures(BATCH_SIZE)
|
_createWalletSignatures(BATCH_SIZE)
|
||||||
);
|
);
|
||||||
} else if (currentFunctionId == uint8(ExchangeFunction.BATCH_FILL_OR_KILL_ORDERS)) {
|
} else if (currentFunctionId == uint8(ExchangeFunction.BATCH_FILL_OR_KILL_ORDERS)) {
|
||||||
LibOrder.Order[] memory orders = createOrders(BATCH_SIZE);
|
LibOrder.Order[] memory orders = _createOrders(BATCH_SIZE);
|
||||||
callData = abi.encodeWithSelector(
|
callData = abi.encodeWithSelector(
|
||||||
exchange.batchFillOrKillOrders.selector,
|
exchange.batchFillOrKillOrders.selector,
|
||||||
orders,
|
orders,
|
||||||
getTakerFillAmounts(orders),
|
getTakerFillAmounts(orders),
|
||||||
createWalletSignatures(BATCH_SIZE)
|
_createWalletSignatures(BATCH_SIZE)
|
||||||
);
|
);
|
||||||
} else if (currentFunctionId == uint8(ExchangeFunction.MARKET_BUY_ORDERS)) {
|
} else if (currentFunctionId == uint8(ExchangeFunction.MARKET_BUY_ORDERS)) {
|
||||||
LibOrder.Order[] memory orders = createOrders(BATCH_SIZE);
|
LibOrder.Order[] memory orders = _createOrders(BATCH_SIZE);
|
||||||
callData = abi.encodeWithSelector(
|
callData = abi.encodeWithSelector(
|
||||||
exchange.marketBuyOrders.selector,
|
exchange.marketBuyOrders.selector,
|
||||||
orders,
|
orders,
|
||||||
sumTakerFillAmounts(orders),
|
_sumTakerFillAmounts(orders),
|
||||||
createWalletSignatures(BATCH_SIZE)
|
_createWalletSignatures(BATCH_SIZE)
|
||||||
);
|
);
|
||||||
} else if (currentFunctionId == uint8(ExchangeFunction.MARKET_SELL_ORDERS)) {
|
} else if (currentFunctionId == uint8(ExchangeFunction.MARKET_SELL_ORDERS)) {
|
||||||
LibOrder.Order[] memory orders = createOrders(BATCH_SIZE);
|
LibOrder.Order[] memory orders = _createOrders(BATCH_SIZE);
|
||||||
callData = abi.encodeWithSelector(
|
callData = abi.encodeWithSelector(
|
||||||
exchange.marketSellOrders.selector,
|
exchange.marketSellOrders.selector,
|
||||||
orders,
|
orders,
|
||||||
sumTakerFillAmounts(orders),
|
_sumTakerFillAmounts(orders),
|
||||||
createWalletSignatures(BATCH_SIZE)
|
_createWalletSignatures(BATCH_SIZE)
|
||||||
);
|
);
|
||||||
} else if (currentFunctionId == uint8(ExchangeFunction.MATCH_ORDERS)) {
|
} else if (currentFunctionId == uint8(ExchangeFunction.MATCH_ORDERS)) {
|
||||||
LibOrder.Order[2] memory orders = createMatchedOrders();
|
LibOrder.Order[2] memory orders = createMatchedOrders();
|
||||||
bytes[] memory signatures = createWalletSignatures(2);
|
bytes[] memory signatures = _createWalletSignatures(2);
|
||||||
callData = abi.encodeWithSelector(
|
callData = abi.encodeWithSelector(
|
||||||
exchange.matchOrders.selector,
|
exchange.matchOrders.selector,
|
||||||
orders[0],
|
orders[0],
|
||||||
@@ -151,12 +151,12 @@ contract ReentrantERC20Token is
|
|||||||
} else if (currentFunctionId == uint8(ExchangeFunction.CANCEL_ORDER)) {
|
} else if (currentFunctionId == uint8(ExchangeFunction.CANCEL_ORDER)) {
|
||||||
callData = abi.encodeWithSelector(
|
callData = abi.encodeWithSelector(
|
||||||
exchange.cancelOrder.selector,
|
exchange.cancelOrder.selector,
|
||||||
createOrders(1)[0]
|
_createOrders(1)[0]
|
||||||
);
|
);
|
||||||
} else if (currentFunctionId == uint8(ExchangeFunction.BATCH_CANCEL_ORDERS)) {
|
} else if (currentFunctionId == uint8(ExchangeFunction.BATCH_CANCEL_ORDERS)) {
|
||||||
callData = abi.encodeWithSelector(
|
callData = abi.encodeWithSelector(
|
||||||
exchange.batchCancelOrders.selector,
|
exchange.batchCancelOrders.selector,
|
||||||
createOrders(BATCH_SIZE)
|
_createOrders(BATCH_SIZE)
|
||||||
);
|
);
|
||||||
} else if (currentFunctionId == uint8(ExchangeFunction.CANCEL_ORDERS_UP_TO)) {
|
} else if (currentFunctionId == uint8(ExchangeFunction.CANCEL_ORDERS_UP_TO)) {
|
||||||
callData = abi.encodeWithSelector(
|
callData = abi.encodeWithSelector(
|
||||||
@@ -166,18 +166,18 @@ contract ReentrantERC20Token is
|
|||||||
} else if (currentFunctionId == uint8(ExchangeFunction.PRE_SIGN)) {
|
} else if (currentFunctionId == uint8(ExchangeFunction.PRE_SIGN)) {
|
||||||
callData = abi.encodeWithSelector(
|
callData = abi.encodeWithSelector(
|
||||||
exchange.preSign.selector,
|
exchange.preSign.selector,
|
||||||
uint256(getRandomAddress())
|
uint256(_getRandomAddress())
|
||||||
);
|
);
|
||||||
} else if (currentFunctionId == uint8(ExchangeFunction.SET_SIGNATURE_VALIDATOR_APPROVAL)) {
|
} else if (currentFunctionId == uint8(ExchangeFunction.SET_SIGNATURE_VALIDATOR_APPROVAL)) {
|
||||||
callData = abi.encodeWithSelector(
|
callData = abi.encodeWithSelector(
|
||||||
exchange.setSignatureValidatorApproval.selector,
|
exchange.setSignatureValidatorApproval.selector,
|
||||||
getRandomAddress(),
|
_getRandomAddress(),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
} else if (currentFunctionId == uint8(ExchangeFunction.SET_ORDER_VALIDATOR_APPROVAL)) {
|
} else if (currentFunctionId == uint8(ExchangeFunction.SET_ORDER_VALIDATOR_APPROVAL)) {
|
||||||
callData = abi.encodeWithSelector(
|
callData = abi.encodeWithSelector(
|
||||||
exchange.setOrderValidatorApproval.selector,
|
exchange.setOrderValidatorApproval.selector,
|
||||||
getRandomAddress(),
|
_getRandomAddress(),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -207,7 +207,7 @@ contract ReentrantERC20Token is
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Create valid test orders where the maker is set to this contract.
|
/// @dev Create valid test orders where the maker is set to this contract.
|
||||||
function createOrders(
|
function _createOrders(
|
||||||
uint8 count
|
uint8 count
|
||||||
)
|
)
|
||||||
internal
|
internal
|
||||||
@@ -218,7 +218,7 @@ contract ReentrantERC20Token is
|
|||||||
for (uint8 i = 0; i != count; i++) {
|
for (uint8 i = 0; i != count; i++) {
|
||||||
orders[i].makerAddress = address(this);
|
orders[i].makerAddress = address(this);
|
||||||
orders[i].takerAddress = address(0x0);
|
orders[i].takerAddress = address(0x0);
|
||||||
orders[i].feeRecipientAddress = getRandomAddress();
|
orders[i].feeRecipientAddress = _getRandomAddress();
|
||||||
orders[i].senderAddress = address(0x0);
|
orders[i].senderAddress = address(0x0);
|
||||||
orders[i].makerAssetAmount = 1 ether;
|
orders[i].makerAssetAmount = 1 ether;
|
||||||
orders[i].takerAssetAmount = 2 ether;
|
orders[i].takerAssetAmount = 2 ether;
|
||||||
@@ -226,8 +226,8 @@ contract ReentrantERC20Token is
|
|||||||
orders[i].takerFee = 0;
|
orders[i].takerFee = 0;
|
||||||
orders[i].expirationTimeSeconds = now + 60 * 60 * 24;
|
orders[i].expirationTimeSeconds = now + 60 * 60 * 24;
|
||||||
orders[i].salt = now + i;
|
orders[i].salt = now + i;
|
||||||
orders[i].makerAssetData = createAssetData();
|
orders[i].makerAssetData = _createAssetData();
|
||||||
orders[i].takerAssetData = createAssetData();
|
orders[i].takerAssetData = _createAssetData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,7 +238,7 @@ contract ReentrantERC20Token is
|
|||||||
returns (LibOrder.Order[2] memory orders)
|
returns (LibOrder.Order[2] memory orders)
|
||||||
{
|
{
|
||||||
|
|
||||||
LibOrder.Order[] memory _orders = createOrders(2);
|
LibOrder.Order[] memory _orders = _createOrders(2);
|
||||||
orders[0] = _orders[0];
|
orders[0] = _orders[0];
|
||||||
orders[1] = _orders[1];
|
orders[1] = _orders[1];
|
||||||
orders[1].takerAssetAmount = orders[1].makerAssetAmount;
|
orders[1].takerAssetAmount = orders[1].makerAssetAmount;
|
||||||
@@ -259,7 +259,7 @@ contract ReentrantERC20Token is
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sumTakerFillAmounts(
|
function _sumTakerFillAmounts(
|
||||||
LibOrder.Order[] memory orders
|
LibOrder.Order[] memory orders
|
||||||
)
|
)
|
||||||
internal
|
internal
|
||||||
@@ -274,7 +274,7 @@ contract ReentrantERC20Token is
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Generate a random address.
|
/// @dev Generate a random address.
|
||||||
function getRandomAddress()
|
function _getRandomAddress()
|
||||||
internal
|
internal
|
||||||
view
|
view
|
||||||
returns (address)
|
returns (address)
|
||||||
@@ -290,7 +290,7 @@ contract ReentrantERC20Token is
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Create empty wallet-verified signatures.
|
/// @dev Create empty wallet-verified signatures.
|
||||||
function createWalletSignatures(
|
function _createWalletSignatures(
|
||||||
uint8 count
|
uint8 count
|
||||||
)
|
)
|
||||||
internal
|
internal
|
||||||
@@ -304,7 +304,7 @@ contract ReentrantERC20Token is
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Create asset data that points to this ERC20 contract.
|
/// @dev Create asset data that points to this ERC20 contract.
|
||||||
function createAssetData()
|
function _createAssetData()
|
||||||
internal
|
internal
|
||||||
view
|
view
|
||||||
returns (bytes memory assetData)
|
returns (bytes memory assetData)
|
||||||
|
@@ -26,7 +26,7 @@ contract TestAssetProxyDispatcher is
|
|||||||
MixinAssetProxyDispatcher,
|
MixinAssetProxyDispatcher,
|
||||||
MixinExchangeRichErrors
|
MixinExchangeRichErrors
|
||||||
{
|
{
|
||||||
function publicDispatchTransferFrom(
|
function dispatchTransferFrom(
|
||||||
bytes32 orderHash,
|
bytes32 orderHash,
|
||||||
bytes memory assetData,
|
bytes memory assetData,
|
||||||
address from,
|
address from,
|
||||||
@@ -35,6 +35,6 @@ contract TestAssetProxyDispatcher is
|
|||||||
)
|
)
|
||||||
public
|
public
|
||||||
{
|
{
|
||||||
dispatchTransferFrom(orderHash, assetData, from, to, amount);
|
_dispatchTransferFrom(orderHash, assetData, from, to, amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -38,12 +38,12 @@ contract TestExchangeInternals is
|
|||||||
/// @param totalFillResults Fill results instance that will be added onto.
|
/// @param totalFillResults Fill results instance that will be added onto.
|
||||||
/// @param singleFillResults Fill results instance that will be added to totalFillResults.
|
/// @param singleFillResults Fill results instance that will be added to totalFillResults.
|
||||||
/// @return newTotalFillResults The result of adding singleFillResults to totalFilResults.
|
/// @return newTotalFillResults The result of adding singleFillResults to totalFilResults.
|
||||||
function publicAddFillResults(FillResults memory totalFillResults, FillResults memory singleFillResults)
|
function addFillResults(FillResults memory totalFillResults, FillResults memory singleFillResults)
|
||||||
public
|
public
|
||||||
pure
|
pure
|
||||||
returns (FillResults memory)
|
returns (FillResults memory)
|
||||||
{
|
{
|
||||||
addFillResults(totalFillResults, singleFillResults);
|
_addFillResults(totalFillResults, singleFillResults);
|
||||||
return totalFillResults;
|
return totalFillResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ contract TestExchangeInternals is
|
|||||||
/// @param order to be filled.
|
/// @param order to be filled.
|
||||||
/// @param takerAssetFilledAmount Amount of takerAsset that will be filled.
|
/// @param takerAssetFilledAmount Amount of takerAsset that will be filled.
|
||||||
/// @return fillResults Amounts filled and fees paid by maker and taker.
|
/// @return fillResults Amounts filled and fees paid by maker and taker.
|
||||||
function publicCalculateFillResults(
|
function calculateFillResults(
|
||||||
Order memory order,
|
Order memory order,
|
||||||
uint256 takerAssetFilledAmount
|
uint256 takerAssetFilledAmount
|
||||||
)
|
)
|
||||||
@@ -59,7 +59,7 @@ contract TestExchangeInternals is
|
|||||||
pure
|
pure
|
||||||
returns (FillResults memory fillResults)
|
returns (FillResults memory fillResults)
|
||||||
{
|
{
|
||||||
return calculateFillResults(order, takerAssetFilledAmount);
|
return _calculateFillResults(order, takerAssetFilledAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Calculates partial value given a numerator and denominator.
|
/// @dev Calculates partial value given a numerator and denominator.
|
||||||
@@ -68,7 +68,7 @@ contract TestExchangeInternals is
|
|||||||
/// @param denominator Denominator.
|
/// @param denominator Denominator.
|
||||||
/// @param target Value to calculate partial of.
|
/// @param target Value to calculate partial of.
|
||||||
/// @return Partial value of target.
|
/// @return Partial value of target.
|
||||||
function publicSafeGetPartialAmountFloor(
|
function safeGetPartialAmountFloor(
|
||||||
uint256 numerator,
|
uint256 numerator,
|
||||||
uint256 denominator,
|
uint256 denominator,
|
||||||
uint256 target
|
uint256 target
|
||||||
@@ -77,7 +77,7 @@ contract TestExchangeInternals is
|
|||||||
pure
|
pure
|
||||||
returns (uint256 partialAmount)
|
returns (uint256 partialAmount)
|
||||||
{
|
{
|
||||||
return safeGetPartialAmountFloor(numerator, denominator, target);
|
return _safeGetPartialAmountFloor(numerator, denominator, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Calculates partial value given a numerator and denominator.
|
/// @dev Calculates partial value given a numerator and denominator.
|
||||||
@@ -86,7 +86,7 @@ contract TestExchangeInternals is
|
|||||||
/// @param denominator Denominator.
|
/// @param denominator Denominator.
|
||||||
/// @param target Value to calculate partial of.
|
/// @param target Value to calculate partial of.
|
||||||
/// @return Partial value of target.
|
/// @return Partial value of target.
|
||||||
function publicSafeGetPartialAmountCeil(
|
function safeGetPartialAmountCeil(
|
||||||
uint256 numerator,
|
uint256 numerator,
|
||||||
uint256 denominator,
|
uint256 denominator,
|
||||||
uint256 target
|
uint256 target
|
||||||
@@ -95,7 +95,7 @@ contract TestExchangeInternals is
|
|||||||
pure
|
pure
|
||||||
returns (uint256 partialAmount)
|
returns (uint256 partialAmount)
|
||||||
{
|
{
|
||||||
return safeGetPartialAmountCeil(numerator, denominator, target);
|
return _safeGetPartialAmountCeil(numerator, denominator, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Calculates partial value given a numerator and denominator.
|
/// @dev Calculates partial value given a numerator and denominator.
|
||||||
@@ -103,7 +103,7 @@ contract TestExchangeInternals is
|
|||||||
/// @param denominator Denominator.
|
/// @param denominator Denominator.
|
||||||
/// @param target Value to calculate partial of.
|
/// @param target Value to calculate partial of.
|
||||||
/// @return Partial value of target.
|
/// @return Partial value of target.
|
||||||
function publicGetPartialAmountFloor(
|
function getPartialAmountFloor(
|
||||||
uint256 numerator,
|
uint256 numerator,
|
||||||
uint256 denominator,
|
uint256 denominator,
|
||||||
uint256 target
|
uint256 target
|
||||||
@@ -112,7 +112,7 @@ contract TestExchangeInternals is
|
|||||||
pure
|
pure
|
||||||
returns (uint256 partialAmount)
|
returns (uint256 partialAmount)
|
||||||
{
|
{
|
||||||
return getPartialAmountFloor(numerator, denominator, target);
|
return _getPartialAmountFloor(numerator, denominator, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Calculates partial value given a numerator and denominator.
|
/// @dev Calculates partial value given a numerator and denominator.
|
||||||
@@ -120,7 +120,7 @@ contract TestExchangeInternals is
|
|||||||
/// @param denominator Denominator.
|
/// @param denominator Denominator.
|
||||||
/// @param target Value to calculate partial of.
|
/// @param target Value to calculate partial of.
|
||||||
/// @return Partial value of target.
|
/// @return Partial value of target.
|
||||||
function publicGetPartialAmountCeil(
|
function getPartialAmountCeil(
|
||||||
uint256 numerator,
|
uint256 numerator,
|
||||||
uint256 denominator,
|
uint256 denominator,
|
||||||
uint256 target
|
uint256 target
|
||||||
@@ -129,7 +129,7 @@ contract TestExchangeInternals is
|
|||||||
pure
|
pure
|
||||||
returns (uint256 partialAmount)
|
returns (uint256 partialAmount)
|
||||||
{
|
{
|
||||||
return getPartialAmountCeil(numerator, denominator, target);
|
return _getPartialAmountCeil(numerator, denominator, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Checks if rounding error >= 0.1%.
|
/// @dev Checks if rounding error >= 0.1%.
|
||||||
@@ -137,7 +137,7 @@ contract TestExchangeInternals is
|
|||||||
/// @param denominator Denominator.
|
/// @param denominator Denominator.
|
||||||
/// @param target Value to multiply with numerator/denominator.
|
/// @param target Value to multiply with numerator/denominator.
|
||||||
/// @return Rounding error is present.
|
/// @return Rounding error is present.
|
||||||
function publicIsRoundingErrorFloor(
|
function isRoundingErrorFloor(
|
||||||
uint256 numerator,
|
uint256 numerator,
|
||||||
uint256 denominator,
|
uint256 denominator,
|
||||||
uint256 target
|
uint256 target
|
||||||
@@ -146,7 +146,7 @@ contract TestExchangeInternals is
|
|||||||
pure
|
pure
|
||||||
returns (bool isError)
|
returns (bool isError)
|
||||||
{
|
{
|
||||||
return isRoundingErrorFloor(numerator, denominator, target);
|
return _isRoundingErrorFloor(numerator, denominator, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Checks if rounding error >= 0.1%.
|
/// @dev Checks if rounding error >= 0.1%.
|
||||||
@@ -154,7 +154,7 @@ contract TestExchangeInternals is
|
|||||||
/// @param denominator Denominator.
|
/// @param denominator Denominator.
|
||||||
/// @param target Value to multiply with numerator/denominator.
|
/// @param target Value to multiply with numerator/denominator.
|
||||||
/// @return Rounding error is present.
|
/// @return Rounding error is present.
|
||||||
function publicIsRoundingErrorCeil(
|
function isRoundingErrorCeil(
|
||||||
uint256 numerator,
|
uint256 numerator,
|
||||||
uint256 denominator,
|
uint256 denominator,
|
||||||
uint256 target
|
uint256 target
|
||||||
@@ -163,7 +163,7 @@ contract TestExchangeInternals is
|
|||||||
pure
|
pure
|
||||||
returns (bool isError)
|
returns (bool isError)
|
||||||
{
|
{
|
||||||
return isRoundingErrorCeil(numerator, denominator, target);
|
return _isRoundingErrorCeil(numerator, denominator, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Updates state with results of a fill order.
|
/// @dev Updates state with results of a fill order.
|
||||||
@@ -171,7 +171,7 @@ contract TestExchangeInternals is
|
|||||||
/// @param takerAddress Address of taker who filled the order.
|
/// @param takerAddress Address of taker who filled the order.
|
||||||
/// @param orderTakerAssetFilledAmount Amount of order already filled.
|
/// @param orderTakerAssetFilledAmount Amount of order already filled.
|
||||||
/// @return fillResults Amounts filled and fees paid by maker and taker.
|
/// @return fillResults Amounts filled and fees paid by maker and taker.
|
||||||
function publicUpdateFilledState(
|
function updateFilledState(
|
||||||
Order memory order,
|
Order memory order,
|
||||||
address takerAddress,
|
address takerAddress,
|
||||||
bytes32 orderHash,
|
bytes32 orderHash,
|
||||||
@@ -180,7 +180,7 @@ contract TestExchangeInternals is
|
|||||||
)
|
)
|
||||||
public
|
public
|
||||||
{
|
{
|
||||||
updateFilledState(
|
_updateFilledState(
|
||||||
order,
|
order,
|
||||||
takerAddress,
|
takerAddress,
|
||||||
orderHash,
|
orderHash,
|
||||||
|
@@ -41,7 +41,7 @@ contract TestStaticCallReceiver {
|
|||||||
external
|
external
|
||||||
returns (bool isValid)
|
returns (bool isValid)
|
||||||
{
|
{
|
||||||
updateState();
|
_updateState();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ contract TestStaticCallReceiver {
|
|||||||
external
|
external
|
||||||
returns (bool isValid)
|
returns (bool isValid)
|
||||||
{
|
{
|
||||||
updateState();
|
_updateState();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ contract TestStaticCallReceiver {
|
|||||||
external
|
external
|
||||||
returns (bool isValid)
|
returns (bool isValid)
|
||||||
{
|
{
|
||||||
updateState();
|
_updateState();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ contract TestStaticCallReceiver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Increments state variable.
|
/// @dev Increments state variable.
|
||||||
function updateState()
|
function _updateState()
|
||||||
internal
|
internal
|
||||||
{
|
{
|
||||||
state++;
|
state++;
|
||||||
|
@@ -192,7 +192,7 @@ describe('AssetProxyDispatcher', () => {
|
|||||||
const erc20Balances = await erc20Wrapper.getBalancesAsync();
|
const erc20Balances = await erc20Wrapper.getBalancesAsync();
|
||||||
const amount = new BigNumber(10);
|
const amount = new BigNumber(10);
|
||||||
await web3Wrapper.awaitTransactionSuccessAsync(
|
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
await assetProxyDispatcher.publicDispatchTransferFrom.sendTransactionAsync(
|
await assetProxyDispatcher.dispatchTransferFrom.sendTransactionAsync(
|
||||||
orderHash,
|
orderHash,
|
||||||
encodedAssetData,
|
encodedAssetData,
|
||||||
makerAddress,
|
makerAddress,
|
||||||
@@ -225,7 +225,7 @@ describe('AssetProxyDispatcher', () => {
|
|||||||
const erc20Balances = await erc20Wrapper.getBalancesAsync();
|
const erc20Balances = await erc20Wrapper.getBalancesAsync();
|
||||||
const amount = constants.ZERO_AMOUNT;
|
const amount = constants.ZERO_AMOUNT;
|
||||||
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(
|
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
await assetProxyDispatcher.publicDispatchTransferFrom.sendTransactionAsync(
|
await assetProxyDispatcher.dispatchTransferFrom.sendTransactionAsync(
|
||||||
orderHash,
|
orderHash,
|
||||||
encodedAssetData,
|
encodedAssetData,
|
||||||
makerAddress,
|
makerAddress,
|
||||||
@@ -253,7 +253,7 @@ describe('AssetProxyDispatcher', () => {
|
|||||||
const erc20Balances = await erc20Wrapper.getBalancesAsync();
|
const erc20Balances = await erc20Wrapper.getBalancesAsync();
|
||||||
const amount = new BigNumber(10);
|
const amount = new BigNumber(10);
|
||||||
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(
|
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
await assetProxyDispatcher.publicDispatchTransferFrom.sendTransactionAsync(
|
await assetProxyDispatcher.dispatchTransferFrom.sendTransactionAsync(
|
||||||
orderHash,
|
orderHash,
|
||||||
encodedAssetData,
|
encodedAssetData,
|
||||||
makerAddress,
|
makerAddress,
|
||||||
@@ -278,7 +278,7 @@ describe('AssetProxyDispatcher', () => {
|
|||||||
orderHash,
|
orderHash,
|
||||||
encodedAssetData,
|
encodedAssetData,
|
||||||
);
|
);
|
||||||
const tx = assetProxyDispatcher.publicDispatchTransferFrom.sendTransactionAsync(
|
const tx = assetProxyDispatcher.dispatchTransferFrom.sendTransactionAsync(
|
||||||
orderHash,
|
orderHash,
|
||||||
encodedAssetData,
|
encodedAssetData,
|
||||||
makerAddress,
|
makerAddress,
|
||||||
|
@@ -196,7 +196,7 @@ describe('Exchange core internal functions', () => {
|
|||||||
async function testAddFillResultsAsync(totalValue: BigNumber, singleValue: BigNumber): Promise<FillResults> {
|
async function testAddFillResultsAsync(totalValue: BigNumber, singleValue: BigNumber): Promise<FillResults> {
|
||||||
const totalFillResults = makeFillResults(totalValue);
|
const totalFillResults = makeFillResults(totalValue);
|
||||||
const singleFillResults = makeFillResults(singleValue);
|
const singleFillResults = makeFillResults(singleValue);
|
||||||
return testExchange.publicAddFillResults.callAsync(totalFillResults, singleFillResults);
|
return testExchange.addFillResults.callAsync(totalFillResults, singleFillResults);
|
||||||
}
|
}
|
||||||
await testCombinatoriallyWithReferenceFuncAsync(
|
await testCombinatoriallyWithReferenceFuncAsync(
|
||||||
'addFillResults',
|
'addFillResults',
|
||||||
@@ -260,7 +260,7 @@ describe('Exchange core internal functions', () => {
|
|||||||
otherAmount: BigNumber,
|
otherAmount: BigNumber,
|
||||||
): Promise<FillResults> {
|
): Promise<FillResults> {
|
||||||
const order = makeOrder(otherAmount, orderTakerAssetAmount, otherAmount, otherAmount);
|
const order = makeOrder(otherAmount, orderTakerAssetAmount, otherAmount, otherAmount);
|
||||||
return testExchange.publicCalculateFillResults.callAsync(order, takerAssetFilledAmount);
|
return testExchange.calculateFillResults.callAsync(order, takerAssetFilledAmount);
|
||||||
}
|
}
|
||||||
await testCombinatoriallyWithReferenceFuncAsync(
|
await testCombinatoriallyWithReferenceFuncAsync(
|
||||||
'calculateFillResults',
|
'calculateFillResults',
|
||||||
@@ -290,7 +290,7 @@ describe('Exchange core internal functions', () => {
|
|||||||
denominator: BigNumber,
|
denominator: BigNumber,
|
||||||
target: BigNumber,
|
target: BigNumber,
|
||||||
): Promise<BigNumber> {
|
): Promise<BigNumber> {
|
||||||
return testExchange.publicGetPartialAmountFloor.callAsync(numerator, denominator, target);
|
return testExchange.getPartialAmountFloor.callAsync(numerator, denominator, target);
|
||||||
}
|
}
|
||||||
await testCombinatoriallyWithReferenceFuncAsync(
|
await testCombinatoriallyWithReferenceFuncAsync(
|
||||||
'getPartialAmountFloor',
|
'getPartialAmountFloor',
|
||||||
@@ -327,7 +327,7 @@ describe('Exchange core internal functions', () => {
|
|||||||
denominator: BigNumber,
|
denominator: BigNumber,
|
||||||
target: BigNumber,
|
target: BigNumber,
|
||||||
): Promise<BigNumber> {
|
): Promise<BigNumber> {
|
||||||
return testExchange.publicGetPartialAmountCeil.callAsync(numerator, denominator, target);
|
return testExchange.getPartialAmountCeil.callAsync(numerator, denominator, target);
|
||||||
}
|
}
|
||||||
await testCombinatoriallyWithReferenceFuncAsync(
|
await testCombinatoriallyWithReferenceFuncAsync(
|
||||||
'getPartialAmountCeil',
|
'getPartialAmountCeil',
|
||||||
@@ -343,7 +343,7 @@ describe('Exchange core internal functions', () => {
|
|||||||
denominator: BigNumber,
|
denominator: BigNumber,
|
||||||
target: BigNumber,
|
target: BigNumber,
|
||||||
): Promise<BigNumber> {
|
): Promise<BigNumber> {
|
||||||
return testExchange.publicSafeGetPartialAmountFloor.callAsync(numerator, denominator, target);
|
return testExchange.safeGetPartialAmountFloor.callAsync(numerator, denominator, target);
|
||||||
}
|
}
|
||||||
await testCombinatoriallyWithReferenceFuncAsync(
|
await testCombinatoriallyWithReferenceFuncAsync(
|
||||||
'safeGetPartialAmountFloor',
|
'safeGetPartialAmountFloor',
|
||||||
@@ -384,7 +384,7 @@ describe('Exchange core internal functions', () => {
|
|||||||
denominator: BigNumber,
|
denominator: BigNumber,
|
||||||
target: BigNumber,
|
target: BigNumber,
|
||||||
): Promise<BigNumber> {
|
): Promise<BigNumber> {
|
||||||
return testExchange.publicSafeGetPartialAmountCeil.callAsync(numerator, denominator, target);
|
return testExchange.safeGetPartialAmountCeil.callAsync(numerator, denominator, target);
|
||||||
}
|
}
|
||||||
await testCombinatoriallyWithReferenceFuncAsync(
|
await testCombinatoriallyWithReferenceFuncAsync(
|
||||||
'safeGetPartialAmountCeil',
|
'safeGetPartialAmountCeil',
|
||||||
@@ -400,7 +400,7 @@ describe('Exchange core internal functions', () => {
|
|||||||
denominator: BigNumber,
|
denominator: BigNumber,
|
||||||
target: BigNumber,
|
target: BigNumber,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
return testExchange.publicIsRoundingErrorFloor.callAsync(numerator, denominator, target);
|
return testExchange.isRoundingErrorFloor.callAsync(numerator, denominator, target);
|
||||||
}
|
}
|
||||||
await testCombinatoriallyWithReferenceFuncAsync(
|
await testCombinatoriallyWithReferenceFuncAsync(
|
||||||
'isRoundingErrorFloor',
|
'isRoundingErrorFloor',
|
||||||
@@ -416,7 +416,7 @@ describe('Exchange core internal functions', () => {
|
|||||||
denominator: BigNumber,
|
denominator: BigNumber,
|
||||||
target: BigNumber,
|
target: BigNumber,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
return testExchange.publicIsRoundingErrorCeil.callAsync(numerator, denominator, target);
|
return testExchange.isRoundingErrorCeil.callAsync(numerator, denominator, target);
|
||||||
}
|
}
|
||||||
await testCombinatoriallyWithReferenceFuncAsync(
|
await testCombinatoriallyWithReferenceFuncAsync(
|
||||||
'isRoundingErrorCeil',
|
'isRoundingErrorCeil',
|
||||||
@@ -459,7 +459,7 @@ describe('Exchange core internal functions', () => {
|
|||||||
takerFeePaid: new BigNumber(0),
|
takerFeePaid: new BigNumber(0),
|
||||||
};
|
};
|
||||||
await web3Wrapper.awaitTransactionSuccessAsync(
|
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||||
await testExchange.publicUpdateFilledState.sendTransactionAsync(
|
await testExchange.updateFilledState.sendTransactionAsync(
|
||||||
emptySignedOrder,
|
emptySignedOrder,
|
||||||
constants.NULL_ADDRESS,
|
constants.NULL_ADDRESS,
|
||||||
orderHash,
|
orderHash,
|
||||||
|
@@ -220,13 +220,13 @@ describe('matchOrders', () => {
|
|||||||
const numerator = signedOrderLeft.makerAssetAmount;
|
const numerator = signedOrderLeft.makerAssetAmount;
|
||||||
const denominator = signedOrderLeft.takerAssetAmount;
|
const denominator = signedOrderLeft.takerAssetAmount;
|
||||||
const target = signedOrderRight.makerAssetAmount;
|
const target = signedOrderRight.makerAssetAmount;
|
||||||
const isRoundingErrorCeil = await testExchange.publicIsRoundingErrorCeil.callAsync(
|
const isRoundingErrorCeil = await testExchange.isRoundingErrorCeil.callAsync(
|
||||||
numerator,
|
numerator,
|
||||||
denominator,
|
denominator,
|
||||||
target,
|
target,
|
||||||
);
|
);
|
||||||
expect(isRoundingErrorCeil).to.be.true();
|
expect(isRoundingErrorCeil).to.be.true();
|
||||||
const isRoundingErrorFloor = await testExchange.publicIsRoundingErrorFloor.callAsync(
|
const isRoundingErrorFloor = await testExchange.isRoundingErrorFloor.callAsync(
|
||||||
numerator,
|
numerator,
|
||||||
denominator,
|
denominator,
|
||||||
target,
|
target,
|
||||||
@@ -284,13 +284,13 @@ describe('matchOrders', () => {
|
|||||||
const numerator = signedOrderRight.takerAssetAmount;
|
const numerator = signedOrderRight.takerAssetAmount;
|
||||||
const denominator = signedOrderRight.makerAssetAmount;
|
const denominator = signedOrderRight.makerAssetAmount;
|
||||||
const target = signedOrderLeft.takerAssetAmount;
|
const target = signedOrderLeft.takerAssetAmount;
|
||||||
const isRoundingErrorFloor = await testExchange.publicIsRoundingErrorFloor.callAsync(
|
const isRoundingErrorFloor = await testExchange.isRoundingErrorFloor.callAsync(
|
||||||
numerator,
|
numerator,
|
||||||
denominator,
|
denominator,
|
||||||
target,
|
target,
|
||||||
);
|
);
|
||||||
expect(isRoundingErrorFloor).to.be.true();
|
expect(isRoundingErrorFloor).to.be.true();
|
||||||
const isRoundingErrorCeil = await testExchange.publicIsRoundingErrorCeil.callAsync(
|
const isRoundingErrorCeil = await testExchange.isRoundingErrorCeil.callAsync(
|
||||||
numerator,
|
numerator,
|
||||||
denominator,
|
denominator,
|
||||||
target,
|
target,
|
||||||
|
@@ -614,7 +614,7 @@ export class FillOrderCombinatorialUtils {
|
|||||||
takerAssetFillAmount: BigNumber,
|
takerAssetFillAmount: BigNumber,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const params = orderUtils.createFill(signedOrder, takerAssetFillAmount);
|
const params = orderUtils.createFill(signedOrder, takerAssetFillAmount);
|
||||||
const abiDataEncodedByContract = await this.testLibsContract.publicAbiEncodeFillOrder.callAsync(
|
const abiDataEncodedByContract = await this.testLibsContract.abiEncodeFillOrder.callAsync(
|
||||||
params.order,
|
params.order,
|
||||||
params.takerAssetFillAmount,
|
params.takerAssetFillAmount,
|
||||||
params.signature,
|
params.signature,
|
||||||
|
@@ -120,8 +120,8 @@ contract DutchAuction is
|
|||||||
address token = assetData.readAddress(16);
|
address token = assetData.readAddress(16);
|
||||||
// Calculate the excess from the buy order. This can occur if the buyer sends in a higher
|
// Calculate the excess from the buy order. This can occur if the buyer sends in a higher
|
||||||
// amount than the calculated current amount
|
// amount than the calculated current amount
|
||||||
uint256 buyerExcessAmount = safeSub(buyOrder.makerAssetAmount, auctionDetails.currentAmount);
|
uint256 buyerExcessAmount = _safeSub(buyOrder.makerAssetAmount, auctionDetails.currentAmount);
|
||||||
uint256 sellerExcessAmount = safeSub(leftMakerAssetSpreadAmount, buyerExcessAmount);
|
uint256 sellerExcessAmount = _safeSub(leftMakerAssetSpreadAmount, buyerExcessAmount);
|
||||||
// Return the difference between auctionDetails.currentAmount and sellOrder.takerAssetAmount
|
// Return the difference between auctionDetails.currentAmount and sellOrder.takerAssetAmount
|
||||||
// to the seller
|
// to the seller
|
||||||
if (sellerExcessAmount > 0) {
|
if (sellerExcessAmount > 0) {
|
||||||
@@ -190,10 +190,10 @@ contract DutchAuction is
|
|||||||
// Auction end time is guaranteed by 0x Exchange due to the order expiration
|
// Auction end time is guaranteed by 0x Exchange due to the order expiration
|
||||||
auctionDetails.currentAmount = minAmount;
|
auctionDetails.currentAmount = minAmount;
|
||||||
} else {
|
} else {
|
||||||
auctionDetails.currentAmount = safeAdd(
|
auctionDetails.currentAmount = _safeAdd(
|
||||||
minAmount,
|
minAmount,
|
||||||
safeDiv(
|
_safeDiv(
|
||||||
safeMul(remainingDurationSeconds, amountDelta),
|
_safeMul(remainingDurationSeconds, amountDelta),
|
||||||
auctionDurationSeconds
|
auctionDurationSeconds
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@@ -45,7 +45,7 @@ contract MixinAssets is
|
|||||||
external
|
external
|
||||||
onlyOwner
|
onlyOwner
|
||||||
{
|
{
|
||||||
transferAssetToSender(assetData, amount);
|
_transferAssetToSender(assetData, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @dev Approves or disapproves an AssetProxy to spend asset.
|
/// @dev Approves or disapproves an AssetProxy to spend asset.
|
||||||
@@ -72,7 +72,7 @@ contract MixinAssets is
|
|||||||
/// @dev Transfers given amount of asset to sender.
|
/// @dev Transfers given amount of asset to sender.
|
||||||
/// @param assetData Byte array encoded for the respective asset proxy.
|
/// @param assetData Byte array encoded for the respective asset proxy.
|
||||||
/// @param amount Amount of asset to transfer to sender.
|
/// @param amount Amount of asset to transfer to sender.
|
||||||
function transferAssetToSender(
|
function _transferAssetToSender(
|
||||||
bytes memory assetData,
|
bytes memory assetData,
|
||||||
uint256 amount
|
uint256 amount
|
||||||
)
|
)
|
||||||
@@ -81,9 +81,9 @@ contract MixinAssets is
|
|||||||
bytes4 proxyId = assetData.readBytes4(0);
|
bytes4 proxyId = assetData.readBytes4(0);
|
||||||
|
|
||||||
if (proxyId == ERC20_DATA_ID) {
|
if (proxyId == ERC20_DATA_ID) {
|
||||||
transferERC20Token(assetData, amount);
|
_transferERC20Token(assetData, amount);
|
||||||
} else if (proxyId == ERC721_DATA_ID) {
|
} else if (proxyId == ERC721_DATA_ID) {
|
||||||
transferERC721Token(assetData, amount);
|
_transferERC721Token(assetData, amount);
|
||||||
} else {
|
} else {
|
||||||
revert("UNSUPPORTED_ASSET_PROXY");
|
revert("UNSUPPORTED_ASSET_PROXY");
|
||||||
}
|
}
|
||||||
@@ -92,7 +92,7 @@ contract MixinAssets is
|
|||||||
/// @dev Decodes ERC20 assetData and transfers given amount to sender.
|
/// @dev Decodes ERC20 assetData and transfers given amount to sender.
|
||||||
/// @param assetData Byte array encoded for the respective asset proxy.
|
/// @param assetData Byte array encoded for the respective asset proxy.
|
||||||
/// @param amount Amount of asset to transfer to sender.
|
/// @param amount Amount of asset to transfer to sender.
|
||||||
function transferERC20Token(
|
function _transferERC20Token(
|
||||||
bytes memory assetData,
|
bytes memory assetData,
|
||||||
uint256 amount
|
uint256 amount
|
||||||
)
|
)
|
||||||
@@ -139,7 +139,7 @@ contract MixinAssets is
|
|||||||
/// @dev Decodes ERC721 assetData and transfers given amount to sender.
|
/// @dev Decodes ERC721 assetData and transfers given amount to sender.
|
||||||
/// @param assetData Byte array encoded for the respective asset proxy.
|
/// @param assetData Byte array encoded for the respective asset proxy.
|
||||||
/// @param amount Amount of asset to transfer to sender.
|
/// @param amount Amount of asset to transfer to sender.
|
||||||
function transferERC721Token(
|
function _transferERC721Token(
|
||||||
bytes memory assetData,
|
bytes memory assetData,
|
||||||
uint256 amount
|
uint256 amount
|
||||||
)
|
)
|
||||||
|
@@ -27,7 +27,7 @@ contract MAssets is
|
|||||||
/// @dev Transfers given amount of asset to sender.
|
/// @dev Transfers given amount of asset to sender.
|
||||||
/// @param assetData Byte array encoded for the respective asset proxy.
|
/// @param assetData Byte array encoded for the respective asset proxy.
|
||||||
/// @param amount Amount of asset to transfer to sender.
|
/// @param amount Amount of asset to transfer to sender.
|
||||||
function transferAssetToSender(
|
function _transferAssetToSender(
|
||||||
bytes memory assetData,
|
bytes memory assetData,
|
||||||
uint256 amount
|
uint256 amount
|
||||||
)
|
)
|
||||||
@@ -36,7 +36,7 @@ contract MAssets is
|
|||||||
/// @dev Decodes ERC20 assetData and transfers given amount to sender.
|
/// @dev Decodes ERC20 assetData and transfers given amount to sender.
|
||||||
/// @param assetData Byte array encoded for the respective asset proxy.
|
/// @param assetData Byte array encoded for the respective asset proxy.
|
||||||
/// @param amount Amount of asset to transfer to sender.
|
/// @param amount Amount of asset to transfer to sender.
|
||||||
function transferERC20Token(
|
function _transferERC20Token(
|
||||||
bytes memory assetData,
|
bytes memory assetData,
|
||||||
uint256 amount
|
uint256 amount
|
||||||
)
|
)
|
||||||
@@ -45,7 +45,7 @@ contract MAssets is
|
|||||||
/// @dev Decodes ERC721 assetData and transfers given amount to sender.
|
/// @dev Decodes ERC721 assetData and transfers given amount to sender.
|
||||||
/// @param assetData Byte array encoded for the respective asset proxy.
|
/// @param assetData Byte array encoded for the respective asset proxy.
|
||||||
/// @param amount Amount of asset to transfer to sender.
|
/// @param amount Amount of asset to transfer to sender.
|
||||||
function transferERC721Token(
|
function _transferERC721Token(
|
||||||
bytes memory assetData,
|
bytes memory assetData,
|
||||||
uint256 amount
|
uint256 amount
|
||||||
)
|
)
|
||||||
|
@@ -36,7 +36,7 @@ contract LibEIP712 {
|
|||||||
/// @param version The EIP712 domain version.
|
/// @param version The EIP712 domain version.
|
||||||
/// @param verifyingContractAddress The EIP712 verifying contract.
|
/// @param verifyingContractAddress The EIP712 verifying contract.
|
||||||
/// @return EIP712 domain separator.
|
/// @return EIP712 domain separator.
|
||||||
function hashEIP712Domain(
|
function _hashEIP712Domain(
|
||||||
string memory name,
|
string memory name,
|
||||||
string memory version,
|
string memory version,
|
||||||
uint256 chainId,
|
uint256 chainId,
|
||||||
@@ -60,7 +60,7 @@ contract LibEIP712 {
|
|||||||
/// with getDomainHash().
|
/// with getDomainHash().
|
||||||
/// @param hashStruct The EIP712 hash struct.
|
/// @param hashStruct The EIP712 hash struct.
|
||||||
/// @return EIP712 hash applied to the given EIP712 Domain.
|
/// @return EIP712 hash applied to the given EIP712 Domain.
|
||||||
function hashEIP712Message(bytes32 eip712DomainHash, bytes32 hashStruct)
|
function _hashEIP712Message(bytes32 eip712DomainHash, bytes32 hashStruct)
|
||||||
internal
|
internal
|
||||||
pure
|
pure
|
||||||
returns (bytes32 result)
|
returns (bytes32 result)
|
||||||
|
@@ -46,7 +46,7 @@ contract RichErrors is
|
|||||||
|
|
||||||
/// @dev Reverts an encoded rich revert reason `errorData`.
|
/// @dev Reverts an encoded rich revert reason `errorData`.
|
||||||
/// @param errorData ABI encoded error data.
|
/// @param errorData ABI encoded error data.
|
||||||
function rrevert(bytes memory errorData)
|
function _rrevert(bytes memory errorData)
|
||||||
internal
|
internal
|
||||||
pure
|
pure
|
||||||
{
|
{
|
||||||
|
@@ -40,7 +40,7 @@ contract MRichErrors is
|
|||||||
|
|
||||||
/// @dev Reverts an encoded rich revert reason `errorData`.
|
/// @dev Reverts an encoded rich revert reason `errorData`.
|
||||||
/// @param errorData ABI encoded error data.
|
/// @param errorData ABI encoded error data.
|
||||||
function rrevert(bytes memory errorData)
|
function _rrevert(bytes memory errorData)
|
||||||
internal
|
internal
|
||||||
pure;
|
pure;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user