Change order field names

This commit is contained in:
Amir Bandeali
2018-03-05 13:52:01 -08:00
parent ca786cdd11
commit ed43d8d08b
5 changed files with 73 additions and 74 deletions

View File

@@ -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
)
);

View File

@@ -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

View File

@@ -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);
}
}

View File

@@ -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),

View File

@@ -30,8 +30,8 @@ contract MSettlement is LibOrder {
internal
returns (
uint256 makerTokenFilledAmount,
uint256 makerFeePaid,
uint256 takerFeePaid
uint256 makerFeeAmountPaid,
uint256 takerFeeAmountPaid
);
}