Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
Modified the matchOrders tests to test matchOrdersWithMaximalFill
Browse files Browse the repository at this point in the history
  • Loading branch information
jalextowle committed Jul 1, 2019
1 parent 7a90b9d commit 1e2d43c
Show file tree
Hide file tree
Showing 5 changed files with 395 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ contract MixinAssetProxyDispatcher is
// at `cdStart`.
// The first 32 bytes are the length of the data.
mstore(cdStart, revertDataSize)
// Copy the revert data immediately after the length.
// Copy the revert data immediately after the length.
returndatacopy(add(cdStart, 32), 0, revertDataSize)
// We need to move the free memory pointer because we
// still have solidity logic that executes after this assembly.
Expand Down
25 changes: 17 additions & 8 deletions contracts/exchange/contracts/src/MixinMatchOrders.sol
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,13 @@ contract MixinMatchOrders is
}
}

// FIXME
function _batchMatchOrders(
LibOrder.Order[] memory leftOrders,
LibOrder.Order[] memory rightOrders,
bytes[] memory leftSignatures,
bytes[] memory rightSignatures,
bool isWithMaximalFill
bool withMaximalFill
)
internal
returns (LibFillResults.BatchMatchedFillResults memory batchMatchedFillResults)
Expand Down Expand Up @@ -184,7 +185,7 @@ contract MixinMatchOrders is
LibFillResults.MatchedFillResults memory matchResults;
// Match the two orders that are pointed to by the left and right indices. If specified, use the
// matchOrdersWithMaximalFill function.
if (isWithMaximalFill) {
if (withMaximalFill) {
// Match the two orders that are pointed to by the left and right indices
matchResults = matchOrdersWithMaximalFill(
leftOrder,
Expand Down Expand Up @@ -297,14 +298,14 @@ 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.
/// @param maximalFill A boolean indicating whether or not this calculation should use the maximal
/// @param withMaximalFill A boolean indicating whether or not this calculation should use the maximal
/// fill strategy for order matching.
function _calculateMatchedFillResults(
LibOrder.Order memory leftOrder,
LibOrder.Order memory rightOrder,
uint256 leftOrderTakerAssetFilledAmount,
uint256 rightOrderTakerAssetFilledAmount,
bool maximalFill
bool withMaximalFill
)
internal
pure
Expand All @@ -324,7 +325,7 @@ contract MixinMatchOrders is
rightTakerAssetAmountRemaining
);

if (maximalFill) {
if (withMaximalFill) {
bool leftSpread;
bool rightSpread;
// FIXME -- Add good comments
Expand All @@ -349,15 +350,15 @@ contract MixinMatchOrders is
);
matchedFillResults.right.takerAssetFilledAmount = leftMakerAssetAmountRemaining;
matchedFillResults.left.makerAssetFilledAmount = leftMakerAssetAmountRemaining;
matchedFillResults.left.makerAssetFilledAmount = leftTakerAssetAmountRemaining;
matchedFillResults.left.takerAssetFilledAmount = leftTakerAssetAmountRemaining;
// FIXME(Add comment?)
rightSpread = true;
} else {
// Case 3: The right and left orders are fully filled
matchedFillResults.left.makerAssetFilledAmount = leftMakerAssetAmountRemaining;
matchedFillResults.left.takerAssetFilledAmount = leftTakerAssetAmountRemaining;
matchedFillResults.right.makerAssetFilledAmount = rightMakerAssetAmountRemaining;
matchedFillResults.right.takerAssetFilledAmount = rightTakerAssetAmountRemaining;
matchedFillResults.left.makerAssetFilledAmount = leftMakerAssetAmountRemaining;
matchedFillResults.left.takerAssetFilledAmount = leftTakerAssetAmountRemaining;
// FIXME(Add comment?)
leftSpread = true;
rightSpread = true;
Expand Down Expand Up @@ -659,6 +660,14 @@ contract MixinMatchOrders is
matchedFillResults.leftMakerAssetSpreadAmount
);

_dispatchTransferFrom(
rightOrderHash,
rightOrder.makerAssetData,
rightOrder.makerAddress,
takerAddress,
matchedFillResults.rightMakerAssetSpreadAmount
);

// Settle taker fees.
if (
leftFeeRecipientAddress == rightFeeRecipientAddress &&
Expand Down
Loading

0 comments on commit 1e2d43c

Please sign in to comment.