Renamed "validate" functions to "assert" in mixin match.
This commit is contained in:
@@ -39,6 +39,7 @@ contract Exchange is
|
||||
|
||||
string constant public VERSION = "2.0.1-alpha";
|
||||
|
||||
// Mixins are instantiated in the order they are inherited
|
||||
constructor (bytes memory _zrxProxyData)
|
||||
public
|
||||
MixinExchangeCore()
|
||||
|
@@ -90,7 +90,7 @@ contract MixinExchangeCore is
|
||||
address takerAddress = getCurrentContextAddress();
|
||||
|
||||
// Either our context is valid or we revert
|
||||
validateFillOrRevert(
|
||||
assertValidFill(
|
||||
order,
|
||||
orderStatus,
|
||||
orderHash,
|
||||
@@ -131,7 +131,7 @@ contract MixinExchangeCore is
|
||||
/// Throws if order is invalid or sender does not have permission to cancel.
|
||||
/// @param order Order to cancel. Order must be Status.FILLABLE.
|
||||
/// @return True if the order state changed to cancelled.
|
||||
/// False if the order was order was in a valid, but
|
||||
/// False if the order was valid, but in an
|
||||
/// unfillable state (see LibStatus.STATUS for order states)
|
||||
function cancelOrder(Order memory order)
|
||||
public
|
||||
@@ -143,7 +143,7 @@ contract MixinExchangeCore is
|
||||
(orderStatus, orderHash, ) = getOrderInfo(order);
|
||||
|
||||
// Validate context
|
||||
validateCancelOrRevert(order, orderStatus, orderHash);
|
||||
assertValidCancel(order, orderStatus, orderHash);
|
||||
|
||||
// Perform cancel
|
||||
return updateCancelledState(order, orderStatus, orderHash);
|
||||
@@ -157,7 +157,7 @@ contract MixinExchangeCore is
|
||||
/// @param takerAssetFilledAmount Amount of order already filled.
|
||||
/// @param takerAssetFillAmount Desired amount of order to fill by taker.
|
||||
/// @param signature Proof that the orders was created by its maker.
|
||||
function validateFillOrRevert(
|
||||
function assertValidFill(
|
||||
Order memory order,
|
||||
uint8 orderStatus,
|
||||
bytes32 orderHash,
|
||||
@@ -243,22 +243,22 @@ contract MixinExchangeCore is
|
||||
|
||||
// Compute takerAssetFilledAmount
|
||||
uint256 remainingTakerAssetAmount = safeSub(order.takerAssetAmount, takerAssetFilledAmount);
|
||||
fillResults.takerAssetFilledAmount = min256(takerAssetFillAmount, remainingTakerAssetAmount);
|
||||
uint256 newTakerAssetFilledAmount = min256(takerAssetFillAmount, remainingTakerAssetAmount);
|
||||
|
||||
// Validate fill order rounding
|
||||
if (isRoundingError(
|
||||
fillResults.takerAssetFilledAmount,
|
||||
newTakerAssetFilledAmount,
|
||||
order.takerAssetAmount,
|
||||
order.makerAssetAmount))
|
||||
{
|
||||
status = uint8(Status.ROUNDING_ERROR_TOO_LARGE);
|
||||
fillResults.takerAssetFilledAmount = 0;
|
||||
return;
|
||||
return (status, fillResults);
|
||||
}
|
||||
|
||||
// Compute proportional transfer amounts
|
||||
// TODO: All three are multiplied by the same fraction. This can
|
||||
// potentially be optimized.
|
||||
fillResults.takerAssetFilledAmount = newTakerAssetFilledAmount;
|
||||
fillResults.makerAssetFilledAmount = getPartialAmount(
|
||||
fillResults.takerAssetFilledAmount,
|
||||
order.takerAssetAmount,
|
||||
@@ -276,7 +276,7 @@ contract MixinExchangeCore is
|
||||
);
|
||||
|
||||
status = uint8(Status.SUCCESS);
|
||||
return;
|
||||
return (status, fillResults);
|
||||
}
|
||||
|
||||
/// @dev Updates state with results of a fill order.
|
||||
@@ -315,7 +315,7 @@ contract MixinExchangeCore is
|
||||
/// @param order that was cancelled.
|
||||
/// @param orderStatus Status of order that was cancelled.
|
||||
/// @param orderHash Hash of order that was cancelled.
|
||||
function validateCancelOrRevert(
|
||||
function assertValidCancel(
|
||||
Order memory order,
|
||||
uint8 orderStatus,
|
||||
bytes32 orderHash
|
||||
|
@@ -75,7 +75,7 @@ contract MixinMatchOrders is
|
||||
address takerAddress = getCurrentContextAddress();
|
||||
|
||||
// Either our context is valid or we revert
|
||||
validateMatchOrThrow(leftOrder, rightOrder);
|
||||
assertValidMatch(leftOrder, rightOrder);
|
||||
|
||||
// Compute proportional fill amounts
|
||||
matchedFillResults = calculateMatchedFillResults(
|
||||
@@ -88,7 +88,7 @@ contract MixinMatchOrders is
|
||||
);
|
||||
|
||||
// Validate fill contexts
|
||||
validateFillOrRevert(
|
||||
assertValidFill(
|
||||
leftOrder,
|
||||
leftOrderInfo.orderStatus,
|
||||
leftOrderInfo.orderHash,
|
||||
@@ -97,7 +97,7 @@ contract MixinMatchOrders is
|
||||
matchedFillResults.left.takerAssetFilledAmount,
|
||||
leftSignature
|
||||
);
|
||||
validateFillOrRevert(
|
||||
assertValidFill(
|
||||
rightOrder,
|
||||
rightOrderInfo.orderStatus,
|
||||
rightOrderInfo.orderHash,
|
||||
@@ -131,14 +131,13 @@ contract MixinMatchOrders is
|
||||
matchedFillResults.right
|
||||
);
|
||||
|
||||
// Return results
|
||||
return matchedFillResults;
|
||||
}
|
||||
|
||||
/// @dev Validates context for matchOrders. Succeeds or throws.
|
||||
/// @param leftOrder First order to match.
|
||||
/// @param rightOrder Second order to match.
|
||||
function validateMatchOrThrow(
|
||||
function assertValidMatch(
|
||||
Order memory leftOrder,
|
||||
Order memory rightOrder
|
||||
)
|
||||
@@ -173,7 +172,7 @@ contract MixinMatchOrders is
|
||||
|
||||
/// @dev Validates matched fill results. Succeeds or throws.
|
||||
/// @param matchedFillResults Amounts to fill and fees to pay by maker and taker of matched orders.
|
||||
function validateMatchOrThrow(MatchedFillResults memory matchedFillResults)
|
||||
function assertValidMatch(MatchedFillResults memory matchedFillResults)
|
||||
internal
|
||||
{
|
||||
// The left order must spend at least as much as we're sending to the combined
|
||||
@@ -308,7 +307,7 @@ contract MixinMatchOrders is
|
||||
);
|
||||
|
||||
// Validate the fill results
|
||||
validateMatchOrThrow(matchedFillResults);
|
||||
assertValidMatch(matchedFillResults);
|
||||
|
||||
// Return fill results
|
||||
return matchedFillResults;
|
||||
|
@@ -64,7 +64,7 @@ contract MExchangeCore is
|
||||
/// @param takerAssetFilledAmount Amount of order already filled.
|
||||
/// @param takerAssetFillAmount Desired amount of order to fill by taker.
|
||||
/// @param signature Proof that the orders was created by its maker.
|
||||
function validateFillOrRevert(
|
||||
function assertValidFill(
|
||||
LibOrder.Order memory order,
|
||||
uint8 orderStatus,
|
||||
bytes32 orderHash,
|
||||
@@ -113,7 +113,7 @@ contract MExchangeCore is
|
||||
/// @param order that was cancelled.
|
||||
/// @param orderStatus Status of order that was cancelled.
|
||||
/// @param orderHash Hash of order that was cancelled.
|
||||
function validateCancelOrRevert(
|
||||
function assertValidCancel(
|
||||
LibOrder.Order memory order,
|
||||
uint8 orderStatus,
|
||||
bytes32 orderHash
|
||||
|
@@ -38,7 +38,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 validateMatchOrThrow(
|
||||
function assertValidMatch(
|
||||
LibOrder.Order memory leftOrder,
|
||||
LibOrder.Order memory rightOrder
|
||||
)
|
||||
@@ -46,7 +46,7 @@ contract MMatchOrders is
|
||||
|
||||
/// @dev Validates matched fill results. Succeeds or throws.
|
||||
/// @param matchedFillResults Amounts to fill and fees to pay by maker and taker of matched orders.
|
||||
function validateMatchOrThrow(LibFillResults.MatchedFillResults memory matchedFillResults)
|
||||
function assertValidMatch(LibFillResults.MatchedFillResults memory matchedFillResults)
|
||||
internal;
|
||||
|
||||
/// @dev Calculates fill amounts for the matched orders.
|
||||
|
Reference in New Issue
Block a user