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