aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-03-06 05:52:01 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-04-21 04:56:16 +0800
commited43d8d08b9a6cf6e015383a3edaba1946fcca6e (patch)
tree693b24344c34d026b3b6aef5c50b04e4caab67be
parentca786cdd1143f6e116b91769e6620bff31642fd5 (diff)
downloaddexon-0x-contracts-ed43d8d08b9a6cf6e015383a3edaba1946fcca6e.tar.gz
dexon-0x-contracts-ed43d8d08b9a6cf6e015383a3edaba1946fcca6e.tar.zst
dexon-0x-contracts-ed43d8d08b9a6cf6e015383a3edaba1946fcca6e.zip
Change order field names
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/LibOrder.sol41
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol56
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/MixinSettlementProxy.sol42
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/MixinWrapperFunctions.sol4
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/mixins/MSettlement.sol4
5 files changed, 73 insertions, 74 deletions
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/LibOrder.sol b/packages/contracts/src/contracts/current/protocol/Exchange/LibOrder.sol
index f0cd8f4fa..3cb76741a 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/LibOrder.sol
+++ b/packages/contracts/src/contracts/current/protocol/Exchange/LibOrder.sol
@@ -22,7 +22,7 @@ pragma experimental ABIEncoderV2;
contract LibOrder {
bytes32 constant orderSchemaHash = keccak256(
- "address exchange",
+ "address exchangeAddress",
"address makerAddress",
"address takerAddress",
"address makerTokenAddress",
@@ -32,30 +32,29 @@ contract LibOrder {
"uint256 takerTokenAmount",
"uint256 makerFeeAmount",
"uint256 takerFeeAmount",
- "uint256 expirationTimestamp",
+ "uint256 expirationTimeSeconds",
"uint256 salt"
);
// TODO: Append `Address` to all address fields and `Amount` to all value fields?
struct Order {
- address exchange; // TODO: Does this need to be a part of the Order struct?
- address maker;
- address taker;
- address makerToken;
- address takerToken;
- address feeRecipient;
+ address makerAddress;
+ address takerAddress;
+ address makerTokenAddress;
+ address takerTokenAddress;
+ address feeRecipientAddress;
uint256 makerTokenAmount;
uint256 takerTokenAmount;
- uint256 makerFee;
- uint256 takerFee;
- uint256 expirationTimestampInSec;
+ uint256 makerFeeAmount;
+ uint256 takerFeeAmount;
+ uint256 expirationTimeSeconds;
uint256 salt;
}
/// @dev Calculates Keccak-256 hash of the order.
/// @param order The order structure.
/// @return Keccak-256 EIP712 hash of the order.
- function getOrderHash(Order memory order)
+ function getOrderHash(Order order)
public view
returns (bytes32 orderHash)
{
@@ -63,17 +62,17 @@ contract LibOrder {
orderHash = keccak256(
orderSchemaHash,
keccak256(
- order.exchange,
- order.maker,
- order.taker,
- order.makerToken,
- order.takerToken,
- order.feeRecipient,
+ address(this),
+ order.makerAddress,
+ order.takerAddress,
+ order.makerTokenAddress,
+ order.takerTokenAddress,
+ order.feeRecipientAddress,
order.makerTokenAmount,
order.takerTokenAmount,
- order.makerFee,
- order.takerFee,
- order.expirationTimestampInSec,
+ order.makerFeeAmount,
+ order.takerFeeAmount,
+ order.expirationTimeSeconds,
order.salt
)
);
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol b/packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol
index 8315634ab..348098b57 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol
+++ b/packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol
@@ -44,23 +44,23 @@ contract MixinExchangeCore is
mapping (bytes32 => uint256) public cancelled;
event LogFill(
- address indexed maker,
- address taker,
- address indexed feeRecipient,
- address makerToken,
- address takerToken,
+ address indexed makerAddress,
+ address takerAddress,
+ address indexed feeRecipientAddress,
+ address makerTokenAddress,
+ address takerTokenAddress,
uint256 makerTokenFilledAmount,
uint256 takerTokenFilledAmount,
- uint256 makerFeePaid,
- uint256 takerFeePaid,
+ uint256 makerFeeAmountPaid,
+ uint256 takerFeeAmountPaid,
bytes32 indexed orderHash
);
event LogCancel(
- address indexed maker,
- address indexed feeRecipient,
- address makerToken,
- address takerToken,
+ address indexed makerAddress,
+ address indexed feeRecipientAddress,
+ address makerTokenAddress,
+ address takerTokenAddress,
uint256 makerTokenCancelledAmount,
uint256 takerTokenCancelledAmount,
bytes32 indexed orderHash
@@ -90,17 +90,17 @@ contract MixinExchangeCore is
if (filled[orderHash] == 0 && cancelled[orderHash] == 0) {
require(order.makerTokenAmount > 0);
require(order.takerTokenAmount > 0);
- require(isValidSignature(orderHash, order.maker, signature));
+ require(isValidSignature(orderHash, order.makerAddress, signature));
}
// Validate taker
- if (order.taker != address(0)) {
- require(order.taker == msg.sender);
+ if (order.takerAddress != address(0)) {
+ require(order.takerAddress == msg.sender);
}
require(takerTokenFillAmount > 0);
// Validate order expiration
- if (block.timestamp >= order.expirationTimestampInSec) {
+ if (block.timestamp >= order.expirationTimeSeconds) {
LogError(uint8(Errors.ORDER_EXPIRED), orderHash);
return 0;
}
@@ -123,20 +123,20 @@ contract MixinExchangeCore is
filled[orderHash] = safeAdd(filled[orderHash], takerTokenFilledAmount);
// Settle order
- var (makerTokenFilledAmount, makerFeePaid, takerFeePaid) =
+ var (makerTokenFilledAmount, makerFeeAmountPaid, takerFeeAmountPaid) =
settleOrder(order, msg.sender, takerTokenFilledAmount);
// Log order
LogFill(
- order.maker,
+ order.makerAddress,
msg.sender,
- order.feeRecipient,
- order.makerToken,
- order.takerToken,
+ order.feeRecipientAddress,
+ order.makerTokenAddress,
+ order.takerTokenAddress,
makerTokenFilledAmount,
takerTokenFilledAmount,
- makerFeePaid,
- takerFeePaid,
+ makerFeeAmountPaid,
+ takerFeeAmountPaid,
orderHash
);
return takerTokenFilledAmount;
@@ -159,9 +159,9 @@ contract MixinExchangeCore is
require(order.makerTokenAmount > 0);
require(order.takerTokenAmount > 0);
require(takerTokenCancelAmount > 0);
- require(order.maker == msg.sender);
+ require(order.makerAddress == msg.sender);
- if (block.timestamp >= order.expirationTimestampInSec) {
+ if (block.timestamp >= order.expirationTimeSeconds) {
LogError(uint8(Errors.ORDER_EXPIRED), orderHash);
return 0;
}
@@ -176,10 +176,10 @@ contract MixinExchangeCore is
cancelled[orderHash] = safeAdd(cancelled[orderHash], takerTokenCancelledAmount);
LogCancel(
- order.maker,
- order.feeRecipient,
- order.makerToken,
- order.takerToken,
+ order.makerAddress,
+ order.feeRecipientAddress,
+ order.makerTokenAddress,
+ order.takerTokenAddress,
getPartialAmount(takerTokenCancelledAmount, order.takerTokenAmount, order.makerTokenAmount),
takerTokenCancelledAmount,
orderHash
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/MixinSettlementProxy.sol b/packages/contracts/src/contracts/current/protocol/Exchange/MixinSettlementProxy.sol
index c75d3405a..a51ef98c9 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/MixinSettlementProxy.sol
+++ b/packages/contracts/src/contracts/current/protocol/Exchange/MixinSettlementProxy.sol
@@ -59,48 +59,48 @@ contract MixinSettlementProxy is
function settleOrder(
Order order,
- address taker,
+ address takerAddress,
uint256 takerTokenFilledAmount)
internal
returns (
uint256 makerTokenFilledAmount,
- uint256 makerFeePaid,
- uint256 takerFeePaid
+ uint256 makerFeeAmountPaid,
+ uint256 takerFeeAmountPaid
)
{
makerTokenFilledAmount = getPartialAmount(takerTokenFilledAmount, order.takerTokenAmount, order.makerTokenAmount);
require(TRANSFER_PROXY.transferFrom(
- order.makerToken,
- order.maker,
- taker,
+ order.makerTokenAddress,
+ order.makerAddress,
+ takerAddress,
makerTokenFilledAmount
));
require(TRANSFER_PROXY.transferFrom(
- order.takerToken,
- taker,
- order.maker,
+ order.takerTokenAddress,
+ takerAddress,
+ order.makerAddress,
takerTokenFilledAmount
));
- if (order.feeRecipient != address(0)) {
- if (order.makerFee > 0) {
- makerFeePaid = getPartialAmount(takerTokenFilledAmount, order.takerTokenAmount, order.makerFee);
+ if (order.feeRecipientAddress != address(0)) {
+ if (order.makerFeeAmount > 0) {
+ makerFeeAmountPaid = getPartialAmount(takerTokenFilledAmount, order.takerTokenAmount, order.makerFeeAmount);
require(TRANSFER_PROXY.transferFrom(
ZRX_TOKEN,
- order.maker,
- order.feeRecipient,
- makerFeePaid
+ order.makerAddress,
+ order.feeRecipientAddress,
+ makerFeeAmountPaid
));
}
- if (order.takerFee > 0) {
- takerFeePaid = getPartialAmount(takerTokenFilledAmount, order.takerTokenAmount, order.takerFee);
+ if (order.takerFeeAmount > 0) {
+ takerFeeAmountPaid = getPartialAmount(takerTokenFilledAmount, order.takerTokenAmount, order.takerFeeAmount);
require(TRANSFER_PROXY.transferFrom(
ZRX_TOKEN,
- taker,
- order.feeRecipient,
- takerFeePaid
+ takerAddress,
+ order.feeRecipientAddress,
+ takerFeeAmountPaid
));
}
}
- return (makerTokenFilledAmount, makerFeePaid, takerFeePaid);
+ return (makerTokenFilledAmount, makerFeeAmountPaid, takerFeeAmountPaid);
}
}
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/MixinWrapperFunctions.sol b/packages/contracts/src/contracts/current/protocol/Exchange/MixinWrapperFunctions.sol
index b8fa4c8bc..232765848 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/MixinWrapperFunctions.sol
+++ b/packages/contracts/src/contracts/current/protocol/Exchange/MixinWrapperFunctions.sol
@@ -246,7 +246,7 @@ contract MixinWrapperFunctions is
returns (uint256 totalTakerTokenFilledAmount)
{
for (uint256 i = 0; i < orders.length; i++) {
- require(orders[i].takerToken == orders[0].takerToken);
+ require(orders[i].takerTokenAddress == orders[0].takerTokenAddress);
totalTakerTokenFilledAmount = safeAdd(totalTakerTokenFilledAmount, fillOrder(
orders[i],
safeSub(takerTokenFillAmount, totalTakerTokenFilledAmount),
@@ -270,7 +270,7 @@ contract MixinWrapperFunctions is
returns (uint256 totalTakerTokenFilledAmount)
{
for (uint256 i = 0; i < orders.length; i++) {
- require(orders[i].takerToken == orders[0].takerToken);
+ require(orders[i].takerTokenAddress == orders[0].takerTokenAddress);
totalTakerTokenFilledAmount = safeAdd(totalTakerTokenFilledAmount, fillOrderNoThrow(
orders[i],
safeSub(takerTokenFillAmount, totalTakerTokenFilledAmount),
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MSettlement.sol b/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MSettlement.sol
index 2fe8353d7..4440c7979 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MSettlement.sol
+++ b/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MSettlement.sol
@@ -30,8 +30,8 @@ contract MSettlement is LibOrder {
internal
returns (
uint256 makerTokenFilledAmount,
- uint256 makerFeePaid,
- uint256 takerFeePaid
+ uint256 makerFeeAmountPaid,
+ uint256 takerFeeAmountPaid
);
}