In @0x/contracts-exchange
: fix contract bugs introduced by changes
This commit is contained in:
committed by
Amir Bandeali
parent
e00ac37cb2
commit
3a6664282c
@@ -230,6 +230,7 @@ contract MixinExchangeCore is
|
||||
|
||||
// Settle order
|
||||
settleOrder(
|
||||
orderInfo.orderHash,
|
||||
order,
|
||||
takerAddress,
|
||||
fillResults
|
||||
@@ -486,10 +487,12 @@ contract MixinExchangeCore is
|
||||
}
|
||||
|
||||
/// @dev Settles an order by transferring assets between counterparties.
|
||||
/// @param orderHash The order hash.
|
||||
/// @param order Order struct containing order specifications.
|
||||
/// @param takerAddress Address selling takerAsset and buying makerAsset.
|
||||
/// @param fillResults Amounts to be filled and fees paid by maker and taker.
|
||||
function settleOrder(
|
||||
bytes32 orderHash,
|
||||
LibOrder.Order memory order,
|
||||
address takerAddress,
|
||||
LibFillResults.FillResults memory fillResults
|
||||
@@ -498,24 +501,28 @@ contract MixinExchangeCore is
|
||||
{
|
||||
bytes memory zrxAssetData = ZRX_ASSET_DATA;
|
||||
dispatchTransferFrom(
|
||||
orderHash,
|
||||
order.makerAssetData,
|
||||
order.makerAddress,
|
||||
takerAddress,
|
||||
fillResults.makerAssetFilledAmount
|
||||
);
|
||||
dispatchTransferFrom(
|
||||
orderHash,
|
||||
order.takerAssetData,
|
||||
takerAddress,
|
||||
order.makerAddress,
|
||||
fillResults.takerAssetFilledAmount
|
||||
);
|
||||
dispatchTransferFrom(
|
||||
orderHash,
|
||||
zrxAssetData,
|
||||
order.makerAddress,
|
||||
order.feeRecipientAddress,
|
||||
fillResults.makerFeePaid
|
||||
);
|
||||
dispatchTransferFrom(
|
||||
orderHash,
|
||||
zrxAssetData,
|
||||
takerAddress,
|
||||
order.feeRecipientAddress,
|
||||
|
@@ -19,6 +19,7 @@
|
||||
pragma solidity ^0.5.5;
|
||||
|
||||
import "@0x/contracts-utils/contracts/src/RichErrors.sol";
|
||||
import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol";
|
||||
import "./mixins/MExchangeRichErrors.sol";
|
||||
|
||||
|
||||
|
@@ -125,6 +125,8 @@ contract MixinMatchOrders is
|
||||
|
||||
// Settle matched orders. Succeeds or throws.
|
||||
settleMatchedOrders(
|
||||
leftOrderInfo.orderHash,
|
||||
rightOrderInfo.orderHash,
|
||||
leftOrder,
|
||||
rightOrder,
|
||||
takerAddress,
|
||||
@@ -264,11 +266,15 @@ contract MixinMatchOrders is
|
||||
}
|
||||
|
||||
/// @dev Settles matched order by transferring appropriate funds between order makers, taker, and fee recipient.
|
||||
/// @param leftOrderHash First matched order hash.
|
||||
/// @param rightOrderHash Second matched order hash.
|
||||
/// @param leftOrder First matched order.
|
||||
/// @param rightOrder Second matched order.
|
||||
/// @param takerAddress Address that matched the orders. The taker receives the spread between orders as profit.
|
||||
/// @param matchedFillResults Struct holding amounts to transfer between makers, taker, and fee recipients.
|
||||
function settleMatchedOrders(
|
||||
bytes32 leftOrderHash,
|
||||
bytes32 rightOrderHash,
|
||||
LibOrder.Order memory leftOrder,
|
||||
LibOrder.Order memory rightOrder,
|
||||
address takerAddress,
|
||||
@@ -279,18 +285,21 @@ contract MixinMatchOrders is
|
||||
bytes memory zrxAssetData = ZRX_ASSET_DATA;
|
||||
// Order makers and taker
|
||||
dispatchTransferFrom(
|
||||
leftOrderHash,
|
||||
leftOrder.makerAssetData,
|
||||
leftOrder.makerAddress,
|
||||
rightOrder.makerAddress,
|
||||
matchedFillResults.right.takerAssetFilledAmount
|
||||
);
|
||||
dispatchTransferFrom(
|
||||
rightOrderHash,
|
||||
rightOrder.makerAssetData,
|
||||
rightOrder.makerAddress,
|
||||
leftOrder.makerAddress,
|
||||
matchedFillResults.left.takerAssetFilledAmount
|
||||
);
|
||||
dispatchTransferFrom(
|
||||
leftOrderHash,
|
||||
leftOrder.makerAssetData,
|
||||
leftOrder.makerAddress,
|
||||
takerAddress,
|
||||
@@ -299,12 +308,14 @@ contract MixinMatchOrders is
|
||||
|
||||
// Maker fees
|
||||
dispatchTransferFrom(
|
||||
leftOrderHash,
|
||||
zrxAssetData,
|
||||
leftOrder.makerAddress,
|
||||
leftOrder.feeRecipientAddress,
|
||||
matchedFillResults.left.makerFeePaid
|
||||
);
|
||||
dispatchTransferFrom(
|
||||
rightOrderHash,
|
||||
zrxAssetData,
|
||||
rightOrder.makerAddress,
|
||||
rightOrder.feeRecipientAddress,
|
||||
@@ -314,6 +325,7 @@ contract MixinMatchOrders is
|
||||
// Taker fees
|
||||
if (leftOrder.feeRecipientAddress == rightOrder.feeRecipientAddress) {
|
||||
dispatchTransferFrom(
|
||||
leftOrderHash,
|
||||
zrxAssetData,
|
||||
takerAddress,
|
||||
leftOrder.feeRecipientAddress,
|
||||
@@ -324,12 +336,14 @@ contract MixinMatchOrders is
|
||||
);
|
||||
} else {
|
||||
dispatchTransferFrom(
|
||||
leftOrderHash,
|
||||
zrxAssetData,
|
||||
takerAddress,
|
||||
leftOrder.feeRecipientAddress,
|
||||
matchedFillResults.left.takerFeePaid
|
||||
);
|
||||
dispatchTransferFrom(
|
||||
rightOrderHash,
|
||||
zrxAssetData,
|
||||
takerAddress,
|
||||
rightOrder.feeRecipientAddress,
|
||||
|
@@ -23,9 +23,9 @@ import "@0x/contracts-utils/contracts/src/LibBytes.sol";
|
||||
import "@0x/contracts-utils/contracts/src/ReentrancyGuard.sol";
|
||||
import "./mixins/MSignatureValidator.sol";
|
||||
import "./mixins/MTransactions.sol";
|
||||
import "./mixins/MExchangeRichErrors.sol";
|
||||
import "./interfaces/IWallet.sol";
|
||||
import "./interfaces/IValidator.sol";
|
||||
import "./mixins/MExchangeRichErrors.sol";
|
||||
|
||||
|
||||
contract MixinSignatureValidator is
|
||||
|
@@ -31,11 +31,13 @@ contract MAssetProxyDispatcher is
|
||||
);
|
||||
|
||||
/// @dev Forwards arguments to assetProxy and calls `transferFrom`. Either succeeds or throws.
|
||||
/// @param orderHash Hash of the order associated with this transfer.
|
||||
/// @param assetData Byte array encoded for the asset.
|
||||
/// @param from Address to transfer token from.
|
||||
/// @param to Address to transfer token to.
|
||||
/// @param amount Amount of token to transfer.
|
||||
function dispatchTransferFrom(
|
||||
bytes32 orderHash,
|
||||
bytes memory assetData,
|
||||
address from,
|
||||
address to,
|
||||
|
@@ -21,10 +21,11 @@ pragma solidity ^0.5.5;
|
||||
import "../src/MixinAssetProxyDispatcher.sol";
|
||||
|
||||
|
||||
contract TestAssetProxyDispatcher is
|
||||
contract TestAssetProxyDispatcher is
|
||||
MixinAssetProxyDispatcher
|
||||
{
|
||||
function publicDispatchTransferFrom(
|
||||
bytes32 orderHash,
|
||||
bytes memory assetData,
|
||||
address from,
|
||||
address to,
|
||||
@@ -32,6 +33,6 @@ contract TestAssetProxyDispatcher is
|
||||
)
|
||||
public
|
||||
{
|
||||
dispatchTransferFrom(assetData, from, to, amount);
|
||||
dispatchTransferFrom(orderHash, assetData, from, to, amount);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user