aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-04-10 01:32:51 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-04-21 04:56:17 +0800
commit5d05a2da7416d37da81d004d489c69d7326d9cce (patch)
treea0192957146eabb83e96bfb4266fbe2af5e81156 /packages
parent2f639b77bbcad9884b25536787e1d35a2eee2e34 (diff)
downloaddexon-sol-tools-5d05a2da7416d37da81d004d489c69d7326d9cce.tar
dexon-sol-tools-5d05a2da7416d37da81d004d489c69d7326d9cce.tar.gz
dexon-sol-tools-5d05a2da7416d37da81d004d489c69d7326d9cce.tar.bz2
dexon-sol-tools-5d05a2da7416d37da81d004d489c69d7326d9cce.tar.lz
dexon-sol-tools-5d05a2da7416d37da81d004d489c69d7326d9cce.tar.xz
dexon-sol-tools-5d05a2da7416d37da81d004d489c69d7326d9cce.tar.zst
dexon-sol-tools-5d05a2da7416d37da81d004d489c69d7326d9cce.zip
Revert variable naming
Diffstat (limited to 'packages')
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/LibOrder.sol12
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol26
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/MixinSettlementProxy.sol16
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/MixinWrapperFunctions.sol108
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/mixins/MExchangeCore.sol6
-rw-r--r--packages/contracts/src/contracts/current/protocol/Exchange/mixins/MSettlement.sol4
-rw-r--r--packages/contracts/src/utils/exchange_wrapper.ts62
-rw-r--r--packages/contracts/src/utils/formatters.ts16
-rw-r--r--packages/contracts/src/utils/order_utils.ts18
-rw-r--r--packages/contracts/src/utils/types.ts14
-rw-r--r--packages/contracts/test/exchange/core.ts254
-rw-r--r--packages/contracts/test/exchange/helpers.ts4
-rw-r--r--packages/contracts/test/exchange/wrapper.ts358
13 files changed, 454 insertions, 444 deletions
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/LibOrder.sol b/packages/contracts/src/contracts/current/protocol/Exchange/LibOrder.sol
index 4394e26c8..5562e692e 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/LibOrder.sol
+++ b/packages/contracts/src/contracts/current/protocol/Exchange/LibOrder.sol
@@ -28,8 +28,8 @@ contract LibOrder {
"address makerTokenAddress",
"address takerTokenAddress",
"address feeRecipientAddress",
- "uint256 makerSellAmount",
- "uint256 makerBuyAmount",
+ "uint256 makerTokenAmount",
+ "uint256 takerTokenAmount",
"uint256 makerFee",
"uint256 takerFee",
"uint256 expirationTimeSeconds",
@@ -42,8 +42,8 @@ contract LibOrder {
address makerTokenAddress;
address takerTokenAddress;
address feeRecipientAddress;
- uint256 makerSellAmount;
- uint256 makerBuyAmount;
+ uint256 makerTokenAmount;
+ uint256 takerTokenAmount;
uint256 makerFee;
uint256 takerFee;
uint256 expirationTimeSeconds;
@@ -68,8 +68,8 @@ contract LibOrder {
order.makerTokenAddress,
order.takerTokenAddress,
order.feeRecipientAddress,
- order.makerSellAmount,
- order.makerBuyAmount,
+ order.makerTokenAmount,
+ order.takerTokenAmount,
order.makerFee,
order.takerFee,
order.expirationTimeSeconds,
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol b/packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol
index ea1cf507b..e93b7a3eb 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol
+++ b/packages/contracts/src/contracts/current/protocol/Exchange/MixinExchangeCore.sol
@@ -55,8 +55,8 @@ contract MixinExchangeCore is
address indexed feeRecipientAddress,
address makerTokenAddress,
address takerTokenAddress,
- uint256 makerAmountSold,
- uint256 takerAmountSold,
+ uint256 makerTokenFilledAmount,
+ uint256 takerTokenFilledAmount,
uint256 makerFeePaid,
uint256 takerFeePaid,
bytes32 indexed orderHash
@@ -81,12 +81,12 @@ contract MixinExchangeCore is
/// @dev Fills the input order.
/// @param order Order struct containing order specifications.
- /// @param takerSellAmount Desired amount of takerToken to sell.
+ /// @param takerTokenFillAmount Desired amount of takerToken to sell.
/// @param signature Proof that order has been created by maker.
/// @return Amounts filled and fees paid by maker and taker.
function fillOrder(
Order memory order,
- uint256 takerSellAmount,
+ uint256 takerTokenFillAmount,
bytes memory signature)
public
returns (FillResults memory fillResults)
@@ -124,26 +124,26 @@ contract MixinExchangeCore is
}
// Validate order availability
- uint256 remainingMakerBuyAmount = safeSub(order.makerBuyAmount, filled[orderHash]);
+ uint256 remainingMakerBuyAmount = safeSub(order.takerTokenAmount, filled[orderHash]);
if (remainingMakerBuyAmount == 0) {
emit ExchangeError(uint8(Errors.ORDER_FULLY_FILLED), orderHash);
return fillResults;
}
// Validate fill order rounding
- fillResults.takerAmountSold = min256(takerSellAmount, remainingMakerBuyAmount);
- if (isRoundingError(fillResults.takerAmountSold, order.makerBuyAmount, order.makerSellAmount)) {
+ fillResults.takerTokenFilledAmount = min256(takerTokenFillAmount, remainingMakerBuyAmount);
+ if (isRoundingError(fillResults.takerTokenFilledAmount, order.takerTokenAmount, order.makerTokenAmount)) {
emit ExchangeError(uint8(Errors.ROUNDING_ERROR_TOO_LARGE), orderHash);
- fillResults.takerAmountSold = 0;
+ fillResults.takerTokenFilledAmount = 0;
return fillResults;
}
// Update state
- filled[orderHash] = safeAdd(filled[orderHash], fillResults.takerAmountSold);
+ filled[orderHash] = safeAdd(filled[orderHash], fillResults.takerTokenFilledAmount);
// Settle order
- (fillResults.makerAmountSold, fillResults.makerFeePaid, fillResults.takerFeePaid) =
- settleOrder(order, msg.sender, fillResults.takerAmountSold);
+ (fillResults.makerTokenFilledAmount, fillResults.makerFeePaid, fillResults.takerFeePaid) =
+ settleOrder(order, msg.sender, fillResults.takerTokenFilledAmount);
// Log order
emit Fill(
@@ -152,8 +152,8 @@ contract MixinExchangeCore is
order.feeRecipientAddress,
order.makerTokenAddress,
order.takerTokenAddress,
- fillResults.makerAmountSold,
- fillResults.takerAmountSold,
+ fillResults.makerTokenFilledAmount,
+ fillResults.takerTokenFilledAmount,
fillResults.makerFeePaid,
fillResults.takerFeePaid,
orderHash
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/MixinSettlementProxy.sol b/packages/contracts/src/contracts/current/protocol/Exchange/MixinSettlementProxy.sol
index 772ea3d9f..2d7e98184 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/MixinSettlementProxy.sol
+++ b/packages/contracts/src/contracts/current/protocol/Exchange/MixinSettlementProxy.sol
@@ -59,21 +59,21 @@ contract MixinSettlementProxy is
function settleOrder(
Order memory order,
address takerAddress,
- uint256 takerAmountSold)
+ uint256 takerTokenFilledAmount)
internal
returns (
- uint256 makerAmountSold,
+ uint256 makerTokenFilledAmount,
uint256 makerFeePaid,
uint256 takerFeePaid
)
{
- makerAmountSold = getPartialAmount(takerAmountSold, order.makerBuyAmount, order.makerSellAmount);
+ makerTokenFilledAmount = getPartialAmount(takerTokenFilledAmount, order.takerTokenAmount, order.makerTokenAmount);
require(
TRANSFER_PROXY.transferFrom(
order.makerTokenAddress,
order.makerAddress,
takerAddress,
- makerAmountSold
+ makerTokenFilledAmount
)
);
require(
@@ -81,12 +81,12 @@ contract MixinSettlementProxy is
order.takerTokenAddress,
takerAddress,
order.makerAddress,
- takerAmountSold
+ takerTokenFilledAmount
)
);
if (order.feeRecipientAddress != address(0)) {
if (order.makerFee > 0) {
- makerFeePaid = getPartialAmount(takerAmountSold, order.makerBuyAmount, order.makerFee);
+ makerFeePaid = getPartialAmount(takerTokenFilledAmount, order.takerTokenAmount, order.makerFee);
require(
TRANSFER_PROXY.transferFrom(
ZRX_TOKEN,
@@ -97,7 +97,7 @@ contract MixinSettlementProxy is
);
}
if (order.takerFee > 0) {
- takerFeePaid = getPartialAmount(takerAmountSold, order.makerBuyAmount, order.takerFee);
+ takerFeePaid = getPartialAmount(takerTokenFilledAmount, order.takerTokenAmount, order.takerFee);
require(
TRANSFER_PROXY.transferFrom(
ZRX_TOKEN,
@@ -108,6 +108,6 @@ contract MixinSettlementProxy is
);
}
}
- return (makerAmountSold, makerFeePaid, takerFeePaid);
+ return (makerTokenFilledAmount, makerFeePaid, takerFeePaid);
}
}
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/MixinWrapperFunctions.sol b/packages/contracts/src/contracts/current/protocol/Exchange/MixinWrapperFunctions.sol
index 88505ef0e..3674ea318 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/MixinWrapperFunctions.sol
+++ b/packages/contracts/src/contracts/current/protocol/Exchange/MixinWrapperFunctions.sol
@@ -29,35 +29,35 @@ contract MixinWrapperFunctions is
SafeMath,
LibPartialAmount
{
- /// @dev Fills the input order. Reverts if exact takerSellAmount not filled.
+ /// @dev Fills the input order. Reverts if exact takerTokenFillAmount not filled.
/// @param order Order struct containing order specifications.
- /// @param takerSellAmount Desired amount of takerToken to sell.
+ /// @param takerTokenFillAmount Desired amount of takerToken to sell.
/// @param signature Proof that order has been created by maker.
function fillOrKillOrder(
Order memory order,
- uint256 takerSellAmount,
+ uint256 takerTokenFillAmount,
bytes memory signature)
public
returns (FillResults memory fillResults)
{
fillResults = fillOrder(
order,
- takerSellAmount,
+ takerTokenFillAmount,
signature
);
- require(fillResults.takerAmountSold == takerSellAmount);
+ require(fillResults.takerTokenFilledAmount == takerTokenFillAmount);
return fillResults;
}
/// @dev Fills an order with specified parameters and ECDSA signature.
/// Returns false if the transaction would otherwise revert.
/// @param order Order struct containing order specifications.
- /// @param takerSellAmount Desired amount of takerToken to sell.
+ /// @param takerTokenFillAmount Desired amount of takerToken to sell.
/// @param signature Proof that order has been created by maker.
/// @return Amounts filled and fees paid by maker and taker.
function fillOrderNoThrow(
Order memory order,
- uint256 takerSellAmount,
+ uint256 takerTokenFillAmount,
bytes memory signature)
public
returns (FillResults memory fillResults)
@@ -106,8 +106,8 @@ contract MixinWrapperFunctions is
mstore(add(start, 292), mload(add(order, 288))) // expirationTimeSeconds
mstore(add(start, 324), mload(add(order, 320))) // salt
- // Write takerSellAmount
- mstore(add(start, 356), takerSellAmount)
+ // Write takerTokenFillAmount
+ mstore(add(start, 356), takerTokenFillAmount)
// Write signature offset
mstore(add(start, 388), 416)
@@ -156,18 +156,18 @@ contract MixinWrapperFunctions is
/// @dev Synchronously executes multiple calls of fillOrder.
/// @param orders Array of order specifications.
- /// @param takerSellAmounts Array of desired amounts of takerToken to sell in orders.
+ /// @param takerTokenFillAmounts Array of desired amounts of takerToken to sell in orders.
/// @param signatures Proofs that orders have been created by makers.
function batchFillOrders(
Order[] memory orders,
- uint256[] memory takerSellAmounts,
+ uint256[] memory takerTokenFillAmounts,
bytes[] memory signatures)
public
{
for (uint256 i = 0; i < orders.length; i++) {
fillOrder(
orders[i],
- takerSellAmounts[i],
+ takerTokenFillAmounts[i],
signatures[i]
);
}
@@ -175,18 +175,18 @@ contract MixinWrapperFunctions is
/// @dev Synchronously executes multiple calls of fillOrKill.
/// @param orders Array of order specifications.
- /// @param takerSellAmounts Array of desired amounts of takerToken to sell in orders.
+ /// @param takerTokenFillAmounts Array of desired amounts of takerToken to sell in orders.
/// @param signatures Proofs that orders have been created by makers.
function batchFillOrKillOrders(
Order[] memory orders,
- uint256[] memory takerSellAmounts,
+ uint256[] memory takerTokenFillAmounts,
bytes[] memory signatures)
public
{
for (uint256 i = 0; i < orders.length; i++) {
fillOrKillOrder(
orders[i],
- takerSellAmounts[i],
+ takerTokenFillAmounts[i],
signatures[i]
);
}
@@ -195,18 +195,18 @@ contract MixinWrapperFunctions is
/// @dev Fills an order with specified parameters and ECDSA signature.
/// Returns false if the transaction would otherwise revert.
/// @param orders Array of order specifications.
- /// @param takerSellAmounts Array of desired amounts of takerToken to sell in orders.
+ /// @param takerTokenFillAmounts Array of desired amounts of takerToken to sell in orders.
/// @param signatures Proofs that orders have been created by makers.
function batchFillOrdersNoThrow(
Order[] memory orders,
- uint256[] memory takerSellAmounts,
+ uint256[] memory takerTokenFillAmounts,
bytes[] memory signatures)
public
{
for (uint256 i = 0; i < orders.length; i++) {
fillOrderNoThrow(
orders[i],
- takerSellAmounts[i],
+ takerTokenFillAmounts[i],
signatures[i]
);
}
@@ -214,29 +214,29 @@ contract MixinWrapperFunctions is
/// @dev Synchronously executes multiple calls of fillOrder until total amount of takerToken is sold by taker.
/// @param orders Array of order specifications.
- /// @param takerSellAmount Desired amount of takerToken to sell.
+ /// @param takerTokenFillAmount Desired amount of takerToken to sell.
/// @param signatures Proofs that orders have been created by makers.
/// @return Amounts filled and fees paid by makers and taker.
function marketSellOrders(
Order[] memory orders,
- uint256 takerSellAmount,
+ uint256 takerTokenFillAmount,
bytes[] memory signatures)
public
returns (FillResults memory fillResults)
{
for (uint256 i = 0; i < orders.length; i++) {
require(orders[i].takerTokenAddress == orders[0].takerTokenAddress);
- uint256 remainingTakerSellAmount = safeSub(takerSellAmount, fillResults.takerAmountSold);
+ uint256 remainingTakerTokenFillAmount = safeSub(takerTokenFillAmount, fillResults.takerTokenFilledAmount);
FillResults memory currentFillResults = fillOrder(
orders[i],
- remainingTakerSellAmount,
+ remainingTakerTokenFillAmount,
signatures[i]
);
- fillResults.makerAmountSold = safeAdd(fillResults.makerAmountSold, currentFillResults.makerAmountSold);
- fillResults.takerAmountSold = safeAdd(fillResults.takerAmountSold, currentFillResults.takerAmountSold);
+ fillResults.makerTokenFilledAmount = safeAdd(fillResults.makerTokenFilledAmount, currentFillResults.makerTokenFilledAmount);
+ fillResults.takerTokenFilledAmount = safeAdd(fillResults.takerTokenFilledAmount, currentFillResults.takerTokenFilledAmount);
fillResults.makerFeePaid = safeAdd(fillResults.makerFeePaid, currentFillResults.makerFeePaid);
fillResults.takerFeePaid = safeAdd(fillResults.takerFeePaid, currentFillResults.takerFeePaid);
- if (fillResults.takerAmountSold == takerSellAmount) {
+ if (fillResults.takerTokenFilledAmount == takerTokenFillAmount) {
break;
}
}
@@ -246,29 +246,29 @@ contract MixinWrapperFunctions is
/// @dev Synchronously executes multiple calls of fillOrder until total amount of takerToken is sold by taker.
/// Returns false if the transaction would otherwise revert.
/// @param orders Array of order specifications.
- /// @param takerSellAmount Desired amount of takerToken to sell.
+ /// @param takerTokenFillAmount Desired amount of takerToken to sell.
/// @param signatures Proofs that orders have been signed by makers.
/// @return Amounts filled and fees paid by makers and taker.
function marketSellOrdersNoThrow(
Order[] memory orders,
- uint256 takerSellAmount,
+ uint256 takerTokenFillAmount,
bytes[] memory signatures)
public
returns (FillResults memory fillResults)
{
for (uint256 i = 0; i < orders.length; i++) {
require(orders[i].takerTokenAddress == orders[0].takerTokenAddress);
- uint256 remainingTakerSellAmount = safeSub(takerSellAmount, fillResults.takerAmountSold);
+ uint256 remainingTakerTokenFillAmount = safeSub(takerTokenFillAmount, fillResults.takerTokenFilledAmount);
FillResults memory currentFillResults = fillOrderNoThrow(
orders[i],
- remainingTakerSellAmount,
+ remainingTakerTokenFillAmount,
signatures[i]
);
- fillResults.makerAmountSold = safeAdd(fillResults.makerAmountSold, currentFillResults.makerAmountSold);
- fillResults.takerAmountSold = safeAdd(fillResults.takerAmountSold, currentFillResults.takerAmountSold);
+ fillResults.makerTokenFilledAmount = safeAdd(fillResults.makerTokenFilledAmount, currentFillResults.makerTokenFilledAmount);
+ fillResults.takerTokenFilledAmount = safeAdd(fillResults.takerTokenFilledAmount, currentFillResults.takerTokenFilledAmount);
fillResults.makerFeePaid = safeAdd(fillResults.makerFeePaid, currentFillResults.makerFeePaid);
fillResults.takerFeePaid = safeAdd(fillResults.takerFeePaid, currentFillResults.takerFeePaid);
- if (fillResults.takerAmountSold == takerSellAmount) {
+ if (fillResults.takerTokenFilledAmount == takerTokenFillAmount) {
break;
}
}
@@ -277,34 +277,34 @@ contract MixinWrapperFunctions is
/// @dev Synchronously executes multiple calls of fillOrder until total amount of makerToken is bought by taker.
/// @param orders Array of order specifications.
- /// @param takerBuyAmount Desired amount of makerToken to buy.
+ /// @param makerTokenFillAmount Desired amount of makerToken to buy.
/// @param signatures Proofs that orders have been signed by makers.
/// @return Amounts filled and fees paid by makers and taker.
function marketBuyOrders(
Order[] memory orders,
- uint256 takerBuyAmount,
+ uint256 makerTokenFillAmount,
bytes[] memory signatures)
public
returns (FillResults memory fillResults)
{
for (uint256 i = 0; i < orders.length; i++) {
require(orders[i].makerTokenAddress == orders[0].makerTokenAddress);
- uint256 remainingTakerBuyAmount = safeSub(takerBuyAmount, fillResults.makerAmountSold);
- uint256 remainingTakerSellAmount = getPartialAmount(
- orders[i].makerBuyAmount,
- orders[i].makerSellAmount,
- remainingTakerBuyAmount
+ uint256 remainingMakerTokenFillAmount = safeSub(makerTokenFillAmount, fillResults.makerTokenFilledAmount);
+ uint256 remainingTakerTokenFillAmount = getPartialAmount(
+ orders[i].takerTokenAmount,
+ orders[i].makerTokenAmount,
+ remainingMakerTokenFillAmount
);
FillResults memory currentFillResults = fillOrder(
orders[i],
- remainingTakerSellAmount,
+ remainingTakerTokenFillAmount,
signatures[i]
);
- fillResults.makerAmountSold = safeAdd(fillResults.makerAmountSold, currentFillResults.makerAmountSold);
- fillResults.takerAmountSold = safeAdd(fillResults.takerAmountSold, currentFillResults.takerAmountSold);
+ fillResults.makerTokenFilledAmount = safeAdd(fillResults.makerTokenFilledAmount, currentFillResults.makerTokenFilledAmount);
+ fillResults.takerTokenFilledAmount = safeAdd(fillResults.takerTokenFilledAmount, currentFillResults.takerTokenFilledAmount);
fillResults.makerFeePaid = safeAdd(fillResults.makerFeePaid, currentFillResults.makerFeePaid);
fillResults.takerFeePaid = safeAdd(fillResults.takerFeePaid, currentFillResults.takerFeePaid);
- if (fillResults.makerAmountSold == takerBuyAmount) {
+ if (fillResults.makerTokenFilledAmount == makerTokenFillAmount) {
break;
}
}
@@ -314,34 +314,34 @@ contract MixinWrapperFunctions is
/// @dev Synchronously executes multiple fill orders in a single transaction until total amount is bought by taker.
/// Returns false if the transaction would otherwise revert.
/// @param orders Array of order specifications.
- /// @param takerBuyAmount Desired amount of makerToken to buy.
+ /// @param makerTokenFillAmount Desired amount of makerToken to buy.
/// @param signatures Proofs that orders have been signed by makers.
/// @return Amounts filled and fees paid by makers and taker.
function marketBuyOrdersNoThrow(
Order[] memory orders,
- uint256 takerBuyAmount,
+ uint256 makerTokenFillAmount,
bytes[] memory signatures)
public
returns (FillResults memory fillResults)
{
for (uint256 i = 0; i < orders.length; i++) {
require(orders[i].makerTokenAddress == orders[0].makerTokenAddress);
- uint256 remainingTakerBuyAmount = safeSub(takerBuyAmount, fillResults.makerAmountSold);
- uint256 remainingTakerSellAmount = getPartialAmount(
- orders[i].makerBuyAmount,
- orders[i].makerSellAmount,
- remainingTakerBuyAmount
+ uint256 remainingMakerTokenFillAmount = safeSub(makerTokenFillAmount, fillResults.makerTokenFilledAmount);
+ uint256 remainingTakerTokenFillAmount = getPartialAmount(
+ orders[i].takerTokenAmount,
+ orders[i].makerTokenAmount,
+ remainingMakerTokenFillAmount
);
FillResults memory currentFillResults = fillOrderNoThrow(
orders[i],
- remainingTakerSellAmount,
+ remainingTakerTokenFillAmount,
signatures[i]
);
- fillResults.makerAmountSold = safeAdd(fillResults.makerAmountSold, currentFillResults.makerAmountSold);
- fillResults.takerAmountSold = safeAdd(fillResults.takerAmountSold, currentFillResults.takerAmountSold);
+ fillResults.makerTokenFilledAmount = safeAdd(fillResults.makerTokenFilledAmount, currentFillResults.makerTokenFilledAmount);
+ fillResults.takerTokenFilledAmount = safeAdd(fillResults.takerTokenFilledAmount, currentFillResults.takerTokenFilledAmount);
fillResults.makerFeePaid = safeAdd(fillResults.makerFeePaid, currentFillResults.makerFeePaid);
fillResults.takerFeePaid = safeAdd(fillResults.takerFeePaid, currentFillResults.takerFeePaid);
- if (fillResults.makerAmountSold == takerBuyAmount) {
+ if (fillResults.makerTokenFilledAmount == makerTokenFillAmount) {
break;
}
}
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MExchangeCore.sol b/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MExchangeCore.sol
index 968fec195..d2ec4da04 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MExchangeCore.sol
+++ b/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MExchangeCore.sol
@@ -24,15 +24,15 @@ import "../LibOrder.sol";
contract MExchangeCore is LibOrder {
struct FillResults {
- uint256 makerAmountSold;
- uint256 takerAmountSold;
+ uint256 makerTokenFilledAmount;
+ uint256 takerTokenFilledAmount;
uint256 makerFeePaid;
uint256 takerFeePaid;
}
function fillOrder(
Order memory order,
- uint256 takerSellAmount,
+ uint256 takerTokenFillAmount,
bytes memory signature)
public
returns (FillResults memory fillResults);
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 c3e332a87..a9911c8ce 100644
--- a/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MSettlement.sol
+++ b/packages/contracts/src/contracts/current/protocol/Exchange/mixins/MSettlement.sol
@@ -26,10 +26,10 @@ contract MSettlement is LibOrder {
function settleOrder(
Order memory order,
address takerAddress,
- uint256 takerAmountSold)
+ uint256 takerTokenFilledAmount)
internal
returns (
- uint256 makerAmountSold,
+ uint256 makerTokenFilledAmount,
uint256 makerFeePaid,
uint256 takerFeePaid
);
diff --git a/packages/contracts/src/utils/exchange_wrapper.ts b/packages/contracts/src/utils/exchange_wrapper.ts
index 743a9c496..cda012aa9 100644
--- a/packages/contracts/src/utils/exchange_wrapper.ts
+++ b/packages/contracts/src/utils/exchange_wrapper.ts
@@ -22,12 +22,12 @@ export class ExchangeWrapper {
public async fillOrderAsync(
signedOrder: SignedOrder,
from: string,
- opts: { takerSellAmount?: BigNumber } = {},
+ opts: { takerTokenFillAmount?: BigNumber } = {},
): Promise<TransactionReceiptWithDecodedLogs> {
- const params = orderUtils.createFill(signedOrder, opts.takerSellAmount);
+ const params = orderUtils.createFill(signedOrder, opts.takerTokenFillAmount);
const txHash = await this._exchange.fillOrder.sendTransactionAsync(
params.order,
- params.takerSellAmount,
+ params.takerTokenFillAmount,
params.signature,
{ from },
);
@@ -43,12 +43,12 @@ export class ExchangeWrapper {
public async fillOrKillOrderAsync(
signedOrder: SignedOrder,
from: string,
- opts: { takerSellAmount?: BigNumber } = {},
+ opts: { takerTokenFillAmount?: BigNumber } = {},
): Promise<TransactionReceiptWithDecodedLogs> {
- const params = orderUtils.createFill(signedOrder, opts.takerSellAmount);
+ const params = orderUtils.createFill(signedOrder, opts.takerTokenFillAmount);
const txHash = await this._exchange.fillOrKillOrder.sendTransactionAsync(
params.order,
- params.takerSellAmount,
+ params.takerTokenFillAmount,
params.signature,
{ from },
);
@@ -58,12 +58,12 @@ export class ExchangeWrapper {
public async fillOrderNoThrowAsync(
signedOrder: SignedOrder,
from: string,
- opts: { takerSellAmount?: BigNumber } = {},
+ opts: { takerTokenFillAmount?: BigNumber } = {},
): Promise<TransactionReceiptWithDecodedLogs> {
- const params = orderUtils.createFill(signedOrder, opts.takerSellAmount);
+ const params = orderUtils.createFill(signedOrder, opts.takerTokenFillAmount);
const txHash = await this._exchange.fillOrderNoThrow.sendTransactionAsync(
params.order,
- params.takerSellAmount,
+ params.takerTokenFillAmount,
params.signature,
{ from },
);
@@ -73,12 +73,12 @@ export class ExchangeWrapper {
public async batchFillOrdersAsync(
orders: SignedOrder[],
from: string,
- opts: { takerSellAmounts?: BigNumber[] } = {},
+ opts: { takerTokenFillAmounts?: BigNumber[] } = {},
): Promise<TransactionReceiptWithDecodedLogs> {
- const params = formatters.createBatchFill(orders, opts.takerSellAmounts);
+ const params = formatters.createBatchFill(orders, opts.takerTokenFillAmounts);
const txHash = await this._exchange.batchFillOrders.sendTransactionAsync(
params.orders,
- params.takerSellAmounts,
+ params.takerTokenFillAmounts,
params.signatures,
{ from },
);
@@ -88,12 +88,12 @@ export class ExchangeWrapper {
public async batchFillOrKillOrdersAsync(
orders: SignedOrder[],
from: string,
- opts: { takerSellAmounts?: BigNumber[] } = {},
+ opts: { takerTokenFillAmounts?: BigNumber[] } = {},
): Promise<TransactionReceiptWithDecodedLogs> {
- const params = formatters.createBatchFill(orders, opts.takerSellAmounts);
+ const params = formatters.createBatchFill(orders, opts.takerTokenFillAmounts);
const txHash = await this._exchange.batchFillOrKillOrders.sendTransactionAsync(
params.orders,
- params.takerSellAmounts,
+ params.takerTokenFillAmounts,
params.signatures,
{ from },
);
@@ -103,12 +103,12 @@ export class ExchangeWrapper {
public async batchFillOrdersNoThrowAsync(
orders: SignedOrder[],
from: string,
- opts: { takerSellAmounts?: BigNumber[] } = {},
+ opts: { takerTokenFillAmounts?: BigNumber[] } = {},
): Promise<TransactionReceiptWithDecodedLogs> {
- const params = formatters.createBatchFill(orders, opts.takerSellAmounts);
+ const params = formatters.createBatchFill(orders, opts.takerTokenFillAmounts);
const txHash = await this._exchange.batchFillOrdersNoThrow.sendTransactionAsync(
params.orders,
- params.takerSellAmounts,
+ params.takerTokenFillAmounts,
params.signatures,
{ from },
);
@@ -118,12 +118,12 @@ export class ExchangeWrapper {
public async marketSellOrdersAsync(
orders: SignedOrder[],
from: string,
- opts: { takerSellAmount: BigNumber },
+ opts: { takerTokenFillAmount: BigNumber },
): Promise<TransactionReceiptWithDecodedLogs> {
- const params = formatters.createMarketSellOrders(orders, opts.takerSellAmount);
+ const params = formatters.createMarketSellOrders(orders, opts.takerTokenFillAmount);
const txHash = await this._exchange.marketSellOrders.sendTransactionAsync(
params.orders,
- params.takerSellAmount,
+ params.takerTokenFillAmount,
params.signatures,
{ from },
);
@@ -133,12 +133,12 @@ export class ExchangeWrapper {
public async marketSellOrdersNoThrowAsync(
orders: SignedOrder[],
from: string,
- opts: { takerSellAmount: BigNumber },
+ opts: { takerTokenFillAmount: BigNumber },
): Promise<TransactionReceiptWithDecodedLogs> {
- const params = formatters.createMarketSellOrders(orders, opts.takerSellAmount);
+ const params = formatters.createMarketSellOrders(orders, opts.takerTokenFillAmount);
const txHash = await this._exchange.marketSellOrdersNoThrow.sendTransactionAsync(
params.orders,
- params.takerSellAmount,
+ params.takerTokenFillAmount,
params.signatures,
{ from },
);
@@ -148,12 +148,12 @@ export class ExchangeWrapper {
public async marketBuyOrdersAsync(
orders: SignedOrder[],
from: string,
- opts: { takerBuyAmount: BigNumber },
+ opts: { makerTokenFillAmount: BigNumber },
): Promise<TransactionReceiptWithDecodedLogs> {
- const params = formatters.createMarketBuyOrders(orders, opts.takerBuyAmount);
+ const params = formatters.createMarketBuyOrders(orders, opts.makerTokenFillAmount);
const txHash = await this._exchange.marketBuyOrders.sendTransactionAsync(
params.orders,
- params.takerBuyAmount,
+ params.makerTokenFillAmount,
params.signatures,
{ from },
);
@@ -163,12 +163,12 @@ export class ExchangeWrapper {
public async marketBuyOrdersNoThrowAsync(
orders: SignedOrder[],
from: string,
- opts: { takerBuyAmount: BigNumber },
+ opts: { makerTokenFillAmount: BigNumber },
): Promise<TransactionReceiptWithDecodedLogs> {
- const params = formatters.createMarketBuyOrders(orders, opts.takerBuyAmount);
+ const params = formatters.createMarketBuyOrders(orders, opts.makerTokenFillAmount);
const txHash = await this._exchange.marketBuyOrdersNoThrow.sendTransactionAsync(
params.orders,
- params.takerBuyAmount,
+ params.makerTokenFillAmount,
params.signatures,
{ from },
);
@@ -221,7 +221,7 @@ export class ExchangeWrapper {
);
return partialAmount;
}
- public async getMakerAmountBoughtAsync(orderHashHex: string): Promise<BigNumber> {
+ public async getTakerTokenFilledAmount(orderHashHex: string): Promise<BigNumber> {
const filledAmount = new BigNumber(await this._exchange.filled.callAsync(orderHashHex));
return filledAmount;
}
diff --git a/packages/contracts/src/utils/formatters.ts b/packages/contracts/src/utils/formatters.ts
index d70c03cb8..fce10c448 100644
--- a/packages/contracts/src/utils/formatters.ts
+++ b/packages/contracts/src/utils/formatters.ts
@@ -5,27 +5,27 @@ import { orderUtils } from './order_utils';
import { BatchCancelOrders, BatchFillOrders, MarketBuyOrders, MarketSellOrders, SignedOrder } from './types';
export const formatters = {
- createBatchFill(signedOrders: SignedOrder[], takerSellAmounts: BigNumber[] = []) {
+ createBatchFill(signedOrders: SignedOrder[], takerTokenFillAmounts: BigNumber[] = []) {
const batchFill: BatchFillOrders = {
orders: [],
signatures: [],
- takerSellAmounts,
+ takerTokenFillAmounts,
};
_.forEach(signedOrders, signedOrder => {
const orderStruct = orderUtils.getOrderStruct(signedOrder);
batchFill.orders.push(orderStruct);
batchFill.signatures.push(signedOrder.signature);
- if (takerSellAmounts.length < signedOrders.length) {
- batchFill.takerSellAmounts.push(signedOrder.makerBuyAmount);
+ if (takerTokenFillAmounts.length < signedOrders.length) {
+ batchFill.takerTokenFillAmounts.push(signedOrder.takerTokenAmount);
}
});
return batchFill;
},
- createMarketSellOrders(signedOrders: SignedOrder[], takerSellAmount: BigNumber) {
+ createMarketSellOrders(signedOrders: SignedOrder[], takerTokenFillAmount: BigNumber) {
const marketSellOrders: MarketSellOrders = {
orders: [],
signatures: [],
- takerSellAmount,
+ takerTokenFillAmount,
};
_.forEach(signedOrders, signedOrder => {
const orderStruct = orderUtils.getOrderStruct(signedOrder);
@@ -34,11 +34,11 @@ export const formatters = {
});
return marketSellOrders;
},
- createMarketBuyOrders(signedOrders: SignedOrder[], takerBuyAmount: BigNumber) {
+ createMarketBuyOrders(signedOrders: SignedOrder[], makerTokenFillAmount: BigNumber) {
const marketBuyOrders: MarketBuyOrders = {
orders: [],
signatures: [],
- takerBuyAmount,
+ makerTokenFillAmount,
};
_.forEach(signedOrders, signedOrder => {
const orderStruct = orderUtils.getOrderStruct(signedOrder);
diff --git a/packages/contracts/src/utils/order_utils.ts b/packages/contracts/src/utils/order_utils.ts
index 1f808024a..26336c81d 100644
--- a/packages/contracts/src/utils/order_utils.ts
+++ b/packages/contracts/src/utils/order_utils.ts
@@ -7,10 +7,10 @@ import { crypto } from './crypto';
import { OrderStruct, SignatureType, SignedOrder, UnsignedOrder } from './types';
export const orderUtils = {
- createFill: (signedOrder: SignedOrder, takerSellAmount?: BigNumber) => {
+ createFill: (signedOrder: SignedOrder, takerTokenFillAmount?: BigNumber) => {
const fill = {
order: orderUtils.getOrderStruct(signedOrder),
- takerSellAmount: takerSellAmount || signedOrder.makerBuyAmount,
+ takerTokenFillAmount: takerTokenFillAmount || signedOrder.takerTokenAmount,
signature: signedOrder.signature,
};
return fill;
@@ -18,7 +18,7 @@ export const orderUtils = {
createCancel(signedOrder: SignedOrder, takerTokenCancelAmount?: BigNumber) {
const cancel = {
order: orderUtils.getOrderStruct(signedOrder),
- takerTokenCancelAmount: takerTokenCancelAmount || signedOrder.makerBuyAmount,
+ takerTokenCancelAmount: takerTokenCancelAmount || signedOrder.takerTokenAmount,
};
return cancel;
},
@@ -29,8 +29,8 @@ export const orderUtils = {
makerTokenAddress: signedOrder.makerTokenAddress,
takerTokenAddress: signedOrder.takerTokenAddress,
feeRecipientAddress: signedOrder.feeRecipientAddress,
- makerSellAmount: signedOrder.makerSellAmount,
- makerBuyAmount: signedOrder.makerBuyAmount,
+ makerTokenAmount: signedOrder.makerTokenAmount,
+ takerTokenAmount: signedOrder.takerTokenAmount,
makerFee: signedOrder.makerFee,
takerFee: signedOrder.takerFee,
expirationTimeSeconds: signedOrder.expirationTimeSeconds,
@@ -46,8 +46,8 @@ export const orderUtils = {
'address makerTokenAddress',
'address takerTokenAddress',
'address feeRecipientAddress',
- 'uint256 makerSellAmount',
- 'uint256 makerBuyAmount',
+ 'uint256 makerTokenAmount',
+ 'uint256 takerTokenAmount',
'uint256 makerFee',
'uint256 takerFee',
'uint256 expirationTimeSeconds',
@@ -60,8 +60,8 @@ export const orderUtils = {
order.makerTokenAddress,
order.takerTokenAddress,
order.feeRecipientAddress,
- order.makerSellAmount,
- order.makerBuyAmount,
+ order.makerTokenAmount,
+ order.takerTokenAmount,
order.makerFee,
order.takerFee,
order.expirationTimeSeconds,
diff --git a/packages/contracts/src/utils/types.ts b/packages/contracts/src/utils/types.ts
index 570f664e0..ed0ebeee9 100644
--- a/packages/contracts/src/utils/types.ts
+++ b/packages/contracts/src/utils/types.ts
@@ -14,19 +14,19 @@ export interface SubmissionContractEventArgs {
export interface BatchFillOrders {
orders: OrderStruct[];
signatures: string[];
- takerSellAmounts: BigNumber[];
+ takerTokenFillAmounts: BigNumber[];
}
export interface MarketSellOrders {
orders: OrderStruct[];
signatures: string[];
- takerSellAmount: BigNumber;
+ takerTokenFillAmount: BigNumber;
}
export interface MarketBuyOrders {
orders: OrderStruct[];
signatures: string[];
- takerBuyAmount: BigNumber;
+ makerTokenFillAmount: BigNumber;
}
export interface BatchCancelOrders {
@@ -43,8 +43,8 @@ export interface DefaultOrderParams {
feeRecipientAddress: string;
makerTokenAddress: string;
takerTokenAddress: string;
- makerSellAmount: BigNumber;
- makerBuyAmount: BigNumber;
+ makerTokenAmount: BigNumber;
+ takerTokenAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
}
@@ -128,8 +128,8 @@ export interface OrderStruct {
makerTokenAddress: string;
takerTokenAddress: string;
feeRecipientAddress: string;
- makerSellAmount: BigNumber;
- makerBuyAmount: BigNumber;
+ makerTokenAmount: BigNumber;
+ takerTokenAmount: BigNumber;
makerFee: BigNumber;
takerFee: BigNumber;
expirationTimeSeconds: BigNumber;
diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts
index 406a96fa0..df4915403 100644
--- a/packages/contracts/test/exchange/core.ts
+++ b/packages/contracts/test/exchange/core.ts
@@ -88,8 +88,8 @@ describe('Exchange', () => {
feeRecipientAddress,
makerTokenAddress: rep.address,
takerTokenAddress: dgd.address,
- makerSellAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
- makerBuyAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
+ makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
+ takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
makerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
takerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
};
@@ -143,80 +143,80 @@ describe('Exchange', () => {
it('should create an unfillable order', async () => {
signedOrder = orderFactory.newSignedOrder({
- makerSellAmount: new BigNumber(1001),
- makerBuyAmount: new BigNumber(3),
+ makerTokenAmount: new BigNumber(1001),
+ takerTokenAmount: new BigNumber(3),
});
- const makerAmountBoughtBefore = await exWrapper.getMakerAmountBoughtAsync(
+ const takerTokenFilledAmountBefore = await exWrapper.getTakerTokenFilledAmount(
orderUtils.getOrderHashHex(signedOrder),
);
- expect(makerAmountBoughtBefore).to.be.bignumber.equal(0);
+ expect(takerTokenFilledAmountBefore).to.be.bignumber.equal(0);
const fillTakerTokenAmount1 = new BigNumber(2);
await exWrapper.fillOrderAsync(signedOrder, takerAddress, {
- takerSellAmount: fillTakerTokenAmount1,
+ takerTokenFillAmount: fillTakerTokenAmount1,
});
- const filledTakerTokenAmountAfter1 = await exWrapper.getMakerAmountBoughtAsync(
+ const takerTokenFilledAmountAfter1 = await exWrapper.getTakerTokenFilledAmount(
orderUtils.getOrderHashHex(signedOrder),
);
- expect(filledTakerTokenAmountAfter1).to.be.bignumber.equal(fillTakerTokenAmount1);
+ expect(takerTokenFilledAmountAfter1).to.be.bignumber.equal(fillTakerTokenAmount1);
const fillTakerTokenAmount2 = new BigNumber(1);
await exWrapper.fillOrderAsync(signedOrder, takerAddress, {
- takerSellAmount: fillTakerTokenAmount2,
+ takerTokenFillAmount: fillTakerTokenAmount2,
});
- const filledTakerTokenAmountAfter2 = await exWrapper.getMakerAmountBoughtAsync(
+ const takerTokenFilledAmountAfter2 = await exWrapper.getTakerTokenFilledAmount(
orderUtils.getOrderHashHex(signedOrder),
);
- expect(filledTakerTokenAmountAfter2).to.be.bignumber.equal(filledTakerTokenAmountAfter1);
+ expect(takerTokenFilledAmountAfter2).to.be.bignumber.equal(takerTokenFilledAmountAfter1);
});
- it('should transfer the correct amounts when makerSellAmount === makerBuyAmount', async () => {
+ it('should transfer the correct amounts when makerTokenAmount === takerTokenAmount', async () => {
signedOrder = orderFactory.newSignedOrder({
- makerSellAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
- makerBuyAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
+ makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
+ takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
});
- const makerAmountBoughtBefore = await exWrapper.getMakerAmountBoughtAsync(
+ const takerTokenFilledAmountBefore = await exWrapper.getTakerTokenFilledAmount(
orderUtils.getOrderHashHex(signedOrder),
);
- expect(makerAmountBoughtBefore).to.be.bignumber.equal(0);
+ expect(takerTokenFilledAmountBefore).to.be.bignumber.equal(0);
- const takerSellAmount = signedOrder.makerBuyAmount.div(2);
- await exWrapper.fillOrderAsync(signedOrder, takerAddress, { takerSellAmount });
+ const takerTokenFillAmount = signedOrder.takerTokenAmount.div(2);
+ await exWrapper.fillOrderAsync(signedOrder, takerAddress, { takerTokenFillAmount });
- const makerAmountBoughtAfter = await exWrapper.getMakerAmountBoughtAsync(
+ const makerAmountBoughtAfter = await exWrapper.getTakerTokenFilledAmount(
orderUtils.getOrderHashHex(signedOrder),
);
- expect(makerAmountBoughtAfter).to.be.bignumber.equal(takerSellAmount);
+ expect(makerAmountBoughtAfter).to.be.bignumber.equal(takerTokenFillAmount);
const newBalances = await dmyBalances.getAsync();
- const makerAmountSold = takerSellAmount
- .times(signedOrder.makerSellAmount)
- .dividedToIntegerBy(signedOrder.makerBuyAmount);
+ const makerTokenFilledAmount = takerTokenFillAmount
+ .times(signedOrder.makerTokenAmount)
+ .dividedToIntegerBy(signedOrder.takerTokenAmount);
const makerFeePaid = signedOrder.makerFee
- .times(makerAmountSold)
- .dividedToIntegerBy(signedOrder.makerSellAmount);
+ .times(makerTokenFilledAmount)
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
const takerFeePaid = signedOrder.takerFee
- .times(makerAmountSold)
- .dividedToIntegerBy(signedOrder.makerSellAmount);
+ .times(makerTokenFilledAmount)
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
expect(newBalances[makerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.makerTokenAddress].minus(makerAmountSold),
+ balances[makerAddress][signedOrder.makerTokenAddress].minus(makerTokenFilledAmount),
);
expect(newBalances[makerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.takerTokenAddress].add(takerSellAmount),
+ balances[makerAddress][signedOrder.takerTokenAddress].add(takerTokenFillAmount),
);
expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
balances[makerAddress][zrx.address].minus(makerFeePaid),
);
expect(newBalances[takerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.takerTokenAddress].minus(takerSellAmount),
+ balances[takerAddress][signedOrder.takerTokenAddress].minus(takerTokenFillAmount),
);
expect(newBalances[takerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.makerTokenAddress].add(makerAmountSold),
+ balances[takerAddress][signedOrder.makerTokenAddress].add(makerTokenFilledAmount),
);
expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
balances[takerAddress][zrx.address].minus(takerFeePaid),
@@ -226,50 +226,50 @@ describe('Exchange', () => {
);
});
- it('should transfer the correct amounts when makerSellAmount > makerBuyAmount', async () => {
+ it('should transfer the correct amounts when makerTokenAmount > takerTokenAmount', async () => {
signedOrder = orderFactory.newSignedOrder({
- makerSellAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
- makerBuyAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
+ makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
+ takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
});
- const makerAmountBoughtBefore = await exWrapper.getMakerAmountBoughtAsync(
+ const takerTokenFilledAmountBefore = await exWrapper.getTakerTokenFilledAmount(
orderUtils.getOrderHashHex(signedOrder),
);
- expect(makerAmountBoughtBefore).to.be.bignumber.equal(0);
+ expect(takerTokenFilledAmountBefore).to.be.bignumber.equal(0);
- const takerSellAmount = signedOrder.makerBuyAmount.div(2);
- await exWrapper.fillOrderAsync(signedOrder, takerAddress, { takerSellAmount });
+ const takerTokenFillAmount = signedOrder.takerTokenAmount.div(2);
+ await exWrapper.fillOrderAsync(signedOrder, takerAddress, { takerTokenFillAmount });
- const makerAmountBoughtAfter = await exWrapper.getMakerAmountBoughtAsync(
+ const makerAmountBoughtAfter = await exWrapper.getTakerTokenFilledAmount(
orderUtils.getOrderHashHex(signedOrder),
);
- expect(makerAmountBoughtAfter).to.be.bignumber.equal(takerSellAmount);
+ expect(makerAmountBoughtAfter).to.be.bignumber.equal(takerTokenFillAmount);
const newBalances = await dmyBalances.getAsync();
- const makerAmountSold = takerSellAmount
- .times(signedOrder.makerSellAmount)
- .dividedToIntegerBy(signedOrder.makerBuyAmount);
+ const makerTokenFilledAmount = takerTokenFillAmount
+ .times(signedOrder.makerTokenAmount)
+ .dividedToIntegerBy(signedOrder.takerTokenAmount);
const makerFeePaid = signedOrder.makerFee
- .times(makerAmountSold)
- .dividedToIntegerBy(signedOrder.makerSellAmount);
+ .times(makerTokenFilledAmount)
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
const takerFeePaid = signedOrder.takerFee
- .times(makerAmountSold)
- .dividedToIntegerBy(signedOrder.makerSellAmount);
+ .times(makerTokenFilledAmount)
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
expect(newBalances[makerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.makerTokenAddress].minus(makerAmountSold),
+ balances[makerAddress][signedOrder.makerTokenAddress].minus(makerTokenFilledAmount),
);
expect(newBalances[makerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.takerTokenAddress].add(takerSellAmount),
+ balances[makerAddress][signedOrder.takerTokenAddress].add(takerTokenFillAmount),
);
expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
balances[makerAddress][zrx.address].minus(makerFeePaid),
);
expect(newBalances[takerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.takerTokenAddress].minus(takerSellAmount),
+ balances[takerAddress][signedOrder.takerTokenAddress].minus(takerTokenFillAmount),
);
expect(newBalances[takerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.makerTokenAddress].add(makerAmountSold),
+ balances[takerAddress][signedOrder.makerTokenAddress].add(makerTokenFilledAmount),
);
expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
balances[takerAddress][zrx.address].minus(takerFeePaid),
@@ -279,50 +279,50 @@ describe('Exchange', () => {
);
});
- it('should transfer the correct amounts when makerSellAmount < makerBuyAmount', async () => {
+ it('should transfer the correct amounts when makerTokenAmount < takerTokenAmount', async () => {
signedOrder = orderFactory.newSignedOrder({
- makerSellAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
- makerBuyAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
+ makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
+ takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
});
- const makerAmountBoughtBefore = await exWrapper.getMakerAmountBoughtAsync(
+ const takerTokenFilledAmountBefore = await exWrapper.getTakerTokenFilledAmount(
orderUtils.getOrderHashHex(signedOrder),
);
- expect(makerAmountBoughtBefore).to.be.bignumber.equal(0);
+ expect(takerTokenFilledAmountBefore).to.be.bignumber.equal(0);
- const takerSellAmount = signedOrder.makerBuyAmount.div(2);
- await exWrapper.fillOrderAsync(signedOrder, takerAddress, { takerSellAmount });
+ const takerTokenFillAmount = signedOrder.takerTokenAmount.div(2);
+ await exWrapper.fillOrderAsync(signedOrder, takerAddress, { takerTokenFillAmount });
- const makerAmountBoughtAfter = await exWrapper.getMakerAmountBoughtAsync(
+ const makerAmountBoughtAfter = await exWrapper.getTakerTokenFilledAmount(
orderUtils.getOrderHashHex(signedOrder),
);
- expect(makerAmountBoughtAfter).to.be.bignumber.equal(takerSellAmount);
+ expect(makerAmountBoughtAfter).to.be.bignumber.equal(takerTokenFillAmount);
const newBalances = await dmyBalances.getAsync();
- const makerAmountSold = takerSellAmount
- .times(signedOrder.makerSellAmount)
- .dividedToIntegerBy(signedOrder.makerBuyAmount);
+ const makerTokenFilledAmount = takerTokenFillAmount
+ .times(signedOrder.makerTokenAmount)
+ .dividedToIntegerBy(signedOrder.takerTokenAmount);
const makerFeePaid = signedOrder.makerFee
- .times(makerAmountSold)
- .dividedToIntegerBy(signedOrder.makerSellAmount);
+ .times(makerTokenFilledAmount)
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
const takerFeePaid = signedOrder.takerFee
- .times(makerAmountSold)
- .dividedToIntegerBy(signedOrder.makerSellAmount);
+ .times(makerTokenFilledAmount)
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
expect(newBalances[makerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.makerTokenAddress].minus(makerAmountSold),
+ balances[makerAddress][signedOrder.makerTokenAddress].minus(makerTokenFilledAmount),
);
expect(newBalances[makerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.takerTokenAddress].add(takerSellAmount),
+ balances[makerAddress][signedOrder.takerTokenAddress].add(takerTokenFillAmount),
);
expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
balances[makerAddress][zrx.address].minus(makerFeePaid),
);
expect(newBalances[takerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.takerTokenAddress].minus(takerSellAmount),
+ balances[takerAddress][signedOrder.takerTokenAddress].minus(takerTokenFillAmount),
);
expect(newBalances[takerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.makerTokenAddress].add(makerAmountSold),
+ balances[takerAddress][signedOrder.makerTokenAddress].add(makerTokenFilledAmount),
);
expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
balances[takerAddress][zrx.address].minus(takerFeePaid),
@@ -335,49 +335,49 @@ describe('Exchange', () => {
it('should transfer the correct amounts when taker is specified and order is claimed by taker', async () => {
signedOrder = orderFactory.newSignedOrder({
takerAddress,
- makerSellAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
- makerBuyAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
+ makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
+ takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
});
- const makerAmountBoughtBefore = await exWrapper.getMakerAmountBoughtAsync(
+ const takerTokenFilledAmountBefore = await exWrapper.getTakerTokenFilledAmount(
orderUtils.getOrderHashHex(signedOrder),
);
- expect(makerAmountBoughtBefore).to.be.bignumber.equal(0);
+ expect(takerTokenFilledAmountBefore).to.be.bignumber.equal(0);
- const takerSellAmount = signedOrder.makerBuyAmount.div(2);
- await exWrapper.fillOrderAsync(signedOrder, takerAddress, { takerSellAmount });
+ const takerTokenFillAmount = signedOrder.takerTokenAmount.div(2);
+ await exWrapper.fillOrderAsync(signedOrder, takerAddress, { takerTokenFillAmount });
- const makerAmountBoughtAfter = await exWrapper.getMakerAmountBoughtAsync(
+ const makerAmountBoughtAfter = await exWrapper.getTakerTokenFilledAmount(
orderUtils.getOrderHashHex(signedOrder),
);
- const expectedMakerAmountBoughtAfter = takerSellAmount.add(makerAmountBoughtBefore);
+ const expectedMakerAmountBoughtAfter = takerTokenFillAmount.add(takerTokenFilledAmountBefore);
expect(makerAmountBoughtAfter).to.be.bignumber.equal(expectedMakerAmountBoughtAfter);
const newBalances = await dmyBalances.getAsync();
- const makerAmountSold = takerSellAmount
- .times(signedOrder.makerSellAmount)
- .dividedToIntegerBy(signedOrder.makerBuyAmount);
+ const makerTokenFilledAmount = takerTokenFillAmount
+ .times(signedOrder.makerTokenAmount)
+ .dividedToIntegerBy(signedOrder.takerTokenAmount);
const makerFeePaid = signedOrder.makerFee
- .times(makerAmountSold)
- .dividedToIntegerBy(signedOrder.makerSellAmount);
+ .times(makerTokenFilledAmount)
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
const takerFeePaid = signedOrder.takerFee
- .times(makerAmountSold)
- .dividedToIntegerBy(signedOrder.makerSellAmount);
+ .times(makerTokenFilledAmount)
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
expect(newBalances[makerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.makerTokenAddress].minus(makerAmountSold),
+ balances[makerAddress][signedOrder.makerTokenAddress].minus(makerTokenFilledAmount),
);
expect(newBalances[makerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.takerTokenAddress].add(takerSellAmount),
+ balances[makerAddress][signedOrder.takerTokenAddress].add(takerTokenFillAmount),
);
expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
balances[makerAddress][zrx.address].minus(makerFeePaid),
);
expect(newBalances[takerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.takerTokenAddress].minus(takerSellAmount),
+ balances[takerAddress][signedOrder.takerTokenAddress].minus(takerTokenFillAmount),
);
expect(newBalances[takerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.makerTokenAddress].add(makerAmountSold),
+ balances[takerAddress][signedOrder.makerTokenAddress].add(makerTokenFilledAmount),
);
expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
balances[takerAddress][zrx.address].minus(takerFeePaid),
@@ -387,31 +387,33 @@ describe('Exchange', () => {
);
});
- it('should fill remaining value if takerSellAmount > remaining makerBuyAmount', async () => {
- const takerSellAmount = signedOrder.makerBuyAmount.div(2);
- await exWrapper.fillOrderAsync(signedOrder, takerAddress, { takerSellAmount });
+ it('should fill remaining value if takerTokenFillAmount > remaining takerTokenAmount', async () => {
+ const takerTokenFillAmount = signedOrder.takerTokenAmount.div(2);
+ await exWrapper.fillOrderAsync(signedOrder, takerAddress, { takerTokenFillAmount });
const res = await exWrapper.fillOrderAsync(signedOrder, takerAddress, {
- takerSellAmount: signedOrder.makerBuyAmount,
+ takerTokenFillAmount: signedOrder.takerTokenAmount,
});
const log = res.logs[0] as LogWithDecodedArgs<FillContractEventArgs>;
- expect(log.args.takerAmountSold).to.be.bignumber.equal(signedOrder.makerBuyAmount.minus(takerSellAmount));
+ expect(log.args.takerTokenFilledAmount).to.be.bignumber.equal(
+ signedOrder.takerTokenAmount.minus(takerTokenFillAmount),
+ );
const newBalances = await dmyBalances.getAsync();
expect(newBalances[makerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.makerTokenAddress].minus(signedOrder.makerSellAmount),
+ balances[makerAddress][signedOrder.makerTokenAddress].minus(signedOrder.makerTokenAmount),
);
expect(newBalances[makerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.takerTokenAddress].add(signedOrder.makerBuyAmount),
+ balances[makerAddress][signedOrder.takerTokenAddress].add(signedOrder.takerTokenAmount),
);
expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
balances[makerAddress][zrx.address].minus(signedOrder.makerFee),
);
expect(newBalances[takerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.takerTokenAddress].minus(signedOrder.makerBuyAmount),
+ balances[takerAddress][signedOrder.takerTokenAddress].minus(signedOrder.takerTokenAmount),
);
expect(newBalances[takerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.makerTokenAddress].add(signedOrder.makerSellAmount),
+ balances[takerAddress][signedOrder.makerTokenAddress].add(signedOrder.makerTokenAmount),
);
expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
balances[takerAddress][zrx.address].minus(signedOrder.takerFee),
@@ -424,14 +426,14 @@ describe('Exchange', () => {
it('should log 1 event with the correct arguments when order has a feeRecipient', async () => {
const divisor = 2;
const res = await exWrapper.fillOrderAsync(signedOrder, takerAddress, {
- takerSellAmount: signedOrder.makerBuyAmount.div(divisor),
+ takerTokenFillAmount: signedOrder.takerTokenAmount.div(divisor),
});
expect(res.logs).to.have.length(1);
const log = res.logs[0] as LogWithDecodedArgs<FillContractEventArgs>;
const logArgs = log.args;
- const expectedFilledMakerTokenAmount = signedOrder.makerSellAmount.div(divisor);
- const expectedFilledTakerTokenAmount = signedOrder.makerBuyAmount.div(divisor);
+ const expectedFilledMakerTokenAmount = signedOrder.makerTokenAmount.div(divisor);
+ const expectedFilledTakerTokenAmount = signedOrder.takerTokenAmount.div(divisor);
const expectedFeeMPaid = signedOrder.makerFee.div(divisor);
const expectedFeeTPaid = signedOrder.takerFee.div(divisor);
@@ -440,8 +442,8 @@ describe('Exchange', () => {
expect(signedOrder.feeRecipientAddress).to.be.equal(logArgs.feeRecipientAddress);
expect(signedOrder.makerTokenAddress).to.be.equal(logArgs.makerTokenAddress);
expect(signedOrder.takerTokenAddress).to.be.equal(logArgs.takerTokenAddress);
- expect(expectedFilledMakerTokenAmount).to.be.bignumber.equal(logArgs.makerAmountSold);
- expect(expectedFilledTakerTokenAmount).to.be.bignumber.equal(logArgs.takerAmountSold);
+ expect(expectedFilledMakerTokenAmount).to.be.bignumber.equal(logArgs.makerTokenFilledAmount);
+ expect(expectedFilledTakerTokenAmount).to.be.bignumber.equal(logArgs.takerTokenFilledAmount);
expect(expectedFeeMPaid).to.be.bignumber.equal(logArgs.makerFeePaid);
expect(expectedFeeTPaid).to.be.bignumber.equal(logArgs.takerFeePaid);
expect(orderUtils.getOrderHashHex(signedOrder)).to.be.equal(logArgs.orderHash);
@@ -453,14 +455,14 @@ describe('Exchange', () => {
});
const divisor = 2;
const res = await exWrapper.fillOrderAsync(signedOrder, takerAddress, {
- takerSellAmount: signedOrder.makerBuyAmount.div(divisor),
+ takerTokenFillAmount: signedOrder.takerTokenAmount.div(divisor),
});
expect(res.logs).to.have.length(1);
const log = res.logs[0] as LogWithDecodedArgs<FillContractEventArgs>;
const logArgs = log.args;
- const expectedFilledMakerTokenAmount = signedOrder.makerSellAmount.div(divisor);
- const expectedFilledTakerTokenAmount = signedOrder.makerBuyAmount.div(divisor);
+ const expectedFilledMakerTokenAmount = signedOrder.makerTokenAmount.div(divisor);
+ const expectedFilledTakerTokenAmount = signedOrder.takerTokenAmount.div(divisor);
const expectedFeeMPaid = new BigNumber(0);
const expectedFeeTPaid = new BigNumber(0);
@@ -469,8 +471,8 @@ describe('Exchange', () => {
expect(signedOrder.feeRecipientAddress).to.be.equal(logArgs.feeRecipientAddress);
expect(signedOrder.makerTokenAddress).to.be.equal(logArgs.makerTokenAddress);
expect(signedOrder.takerTokenAddress).to.be.equal(logArgs.takerTokenAddress);
- expect(expectedFilledMakerTokenAmount).to.be.bignumber.equal(logArgs.makerAmountSold);
- expect(expectedFilledTakerTokenAmount).to.be.bignumber.equal(logArgs.takerAmountSold);
+ expect(expectedFilledMakerTokenAmount).to.be.bignumber.equal(logArgs.makerTokenFilledAmount);
+ expect(expectedFilledTakerTokenAmount).to.be.bignumber.equal(logArgs.takerTokenFilledAmount);
expect(expectedFeeMPaid).to.be.bignumber.equal(logArgs.makerFeePaid);
expect(expectedFeeTPaid).to.be.bignumber.equal(logArgs.takerFeePaid);
expect(orderUtils.getOrderHashHex(signedOrder)).to.be.equal(logArgs.orderHash);
@@ -479,15 +481,15 @@ describe('Exchange', () => {
it('should throw when taker is specified and order is claimed by other', async () => {
signedOrder = orderFactory.newSignedOrder({
takerAddress: feeRecipientAddress,
- makerSellAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
- makerBuyAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
+ makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
+ takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
});
return expect(exWrapper.fillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(constants.REVERT);
});
it('should throw if signature is invalid', async () => {
signedOrder = orderFactory.newSignedOrder({
- makerSellAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
+ makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(10), 18),
});
const invalidR = ethUtil.sha3('invalidR');
@@ -501,7 +503,7 @@ describe('Exchange', () => {
it('should throw if maker balances are too low to fill order', async () => {
signedOrder = orderFactory.newSignedOrder({
- makerSellAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
+ makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
});
return expect(exWrapper.fillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(constants.REVERT);
@@ -509,7 +511,7 @@ describe('Exchange', () => {
it('should throw if taker balances are too low to fill order', async () => {
signedOrder = orderFactory.newSignedOrder({
- makerBuyAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
+ takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
});
return expect(exWrapper.fillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(constants.REVERT);
@@ -582,7 +584,7 @@ describe('Exchange', () => {
it('should be able to cancel a full order', async () => {
await exWrapper.cancelOrderAsync(signedOrder, makerAddress);
await exWrapper.fillOrderAsync(signedOrder, takerAddress, {
- takerSellAmount: signedOrder.makerBuyAmount.div(2),
+ takerTokenFillAmount: signedOrder.takerTokenAmount.div(2),
});
const newBalances = await dmyBalances.getAsync();
@@ -655,31 +657,31 @@ describe('Exchange', () => {
balances = await dmyBalances.getAsync();
const signedOrders = await Promise.all([
orderFactory.newSignedOrder({
- makerSellAmount: ZeroEx.toBaseUnitAmount(new BigNumber(9), 18),
- makerBuyAmount: ZeroEx.toBaseUnitAmount(new BigNumber(9), 18),
+ makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(9), 18),
+ takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(9), 18),
salt: new BigNumber(0),
}),
orderFactory.newSignedOrder({
- makerSellAmount: ZeroEx.toBaseUnitAmount(new BigNumber(79), 18),
- makerBuyAmount: ZeroEx.toBaseUnitAmount(new BigNumber(79), 18),
+ makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(79), 18),
+ takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(79), 18),
salt: new BigNumber(1),
}),
orderFactory.newSignedOrder({
- makerSellAmount: ZeroEx.toBaseUnitAmount(new BigNumber(979), 18),
- makerBuyAmount: ZeroEx.toBaseUnitAmount(new BigNumber(979), 18),
+ makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(979), 18),
+ takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(979), 18),
salt: new BigNumber(2),
}),
orderFactory.newSignedOrder({
- makerSellAmount: ZeroEx.toBaseUnitAmount(new BigNumber(7979), 18),
- makerBuyAmount: ZeroEx.toBaseUnitAmount(new BigNumber(7979), 18),
+ makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(7979), 18),
+ takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(7979), 18),
salt: new BigNumber(3),
}),
]);
await exWrapper.batchFillOrdersNoThrowAsync(signedOrders, takerAddress);
const newBalances = await dmyBalances.getAsync();
- const fillMakerTokenAmount = signedOrders[2].makerSellAmount.add(signedOrders[3].makerSellAmount);
- const fillTakerTokenAmount = signedOrders[2].makerBuyAmount.add(signedOrders[3].makerBuyAmount);
+ const fillMakerTokenAmount = signedOrders[2].makerTokenAmount.add(signedOrders[3].makerTokenAmount);
+ const fillTakerTokenAmount = signedOrders[2].takerTokenAmount.add(signedOrders[3].takerTokenAmount);
const makerFee = signedOrders[2].makerFee.add(signedOrders[3].makerFee);
const takerFee = signedOrders[2].takerFee.add(signedOrders[3].takerFee);
expect(newBalances[makerAddress][signedOrders[3].makerTokenAddress]).to.be.bignumber.equal(
diff --git a/packages/contracts/test/exchange/helpers.ts b/packages/contracts/test/exchange/helpers.ts
index 76a64d567..4fa55efa1 100644
--- a/packages/contracts/test/exchange/helpers.ts
+++ b/packages/contracts/test/exchange/helpers.ts
@@ -52,8 +52,8 @@ describe('Exchange', () => {
feeRecipientAddress,
makerTokenAddress: rep.address,
takerTokenAddress: dgd.address,
- makerSellAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
- makerBuyAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
+ makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
+ takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
makerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
takerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
};
diff --git a/packages/contracts/test/exchange/wrapper.ts b/packages/contracts/test/exchange/wrapper.ts
index 145d9ad55..0ba74e1e9 100644
--- a/packages/contracts/test/exchange/wrapper.ts
+++ b/packages/contracts/test/exchange/wrapper.ts
@@ -80,8 +80,8 @@ describe('Exchange', () => {
feeRecipientAddress,
makerTokenAddress: rep.address,
takerTokenAddress: dgd.address,
- makerSellAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
- makerBuyAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
+ makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
+ takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
makerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
takerFee: ZeroEx.toBaseUnitAmount(new BigNumber(1), 18),
};
@@ -114,39 +114,39 @@ describe('Exchange', () => {
describe('fillOrKillOrder', () => {
it('should transfer the correct amounts', async () => {
const signedOrder = orderFactory.newSignedOrder({
- makerSellAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
- makerBuyAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
+ makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
+ takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
});
- const takerSellAmount = signedOrder.makerBuyAmount.div(2);
+ const takerTokenFillAmount = signedOrder.takerTokenAmount.div(2);
await exWrapper.fillOrKillOrderAsync(signedOrder, takerAddress, {
- takerSellAmount,
+ takerTokenFillAmount,
});
const newBalances = await dmyBalances.getAsync();
- const makerAmountSold = takerSellAmount
- .times(signedOrder.makerSellAmount)
- .dividedToIntegerBy(signedOrder.makerBuyAmount);
+ const makerTokenFilledAmount = takerTokenFillAmount
+ .times(signedOrder.makerTokenAmount)
+ .dividedToIntegerBy(signedOrder.takerTokenAmount);
const makerFee = signedOrder.makerFee
- .times(makerAmountSold)
- .dividedToIntegerBy(signedOrder.makerSellAmount);
+ .times(makerTokenFilledAmount)
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
const takerFee = signedOrder.takerFee
- .times(makerAmountSold)
- .dividedToIntegerBy(signedOrder.makerSellAmount);
+ .times(makerTokenFilledAmount)
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
expect(newBalances[makerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.makerTokenAddress].minus(makerAmountSold),
+ balances[makerAddress][signedOrder.makerTokenAddress].minus(makerTokenFilledAmount),
);
expect(newBalances[makerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.takerTokenAddress].add(takerSellAmount),
+ balances[makerAddress][signedOrder.takerTokenAddress].add(takerTokenFillAmount),
);
expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
balances[makerAddress][zrx.address].minus(makerFee),
);
expect(newBalances[takerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.takerTokenAddress].minus(takerSellAmount),
+ balances[takerAddress][signedOrder.takerTokenAddress].minus(takerTokenFillAmount),
);
expect(newBalances[takerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.makerTokenAddress].add(makerAmountSold),
+ balances[takerAddress][signedOrder.makerTokenAddress].add(makerTokenFilledAmount),
);
expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
balances[takerAddress][zrx.address].minus(takerFee),
@@ -166,11 +166,11 @@ describe('Exchange', () => {
);
});
- it('should throw if entire takerSellAmount not filled', async () => {
+ it('should throw if entire takerTokenFillAmount not filled', async () => {
const signedOrder = orderFactory.newSignedOrder();
await exWrapper.fillOrderAsync(signedOrder, takerAddress, {
- takerSellAmount: signedOrder.makerBuyAmount.div(2),
+ takerTokenFillAmount: signedOrder.takerTokenAmount.div(2),
});
return expect(exWrapper.fillOrKillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(
@@ -182,39 +182,39 @@ describe('Exchange', () => {
describe('fillOrderNoThrow', () => {
it('should transfer the correct amounts', async () => {
const signedOrder = orderFactory.newSignedOrder({
- makerSellAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
- makerBuyAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
+ makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
+ takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(200), 18),
});
- const takerSellAmount = signedOrder.makerBuyAmount.div(2);
+ const takerTokenFillAmount = signedOrder.takerTokenAmount.div(2);
await exWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress, {
- takerSellAmount,
+ takerTokenFillAmount,
});
const newBalances = await dmyBalances.getAsync();
- const makerAmountSold = takerSellAmount
- .times(signedOrder.makerSellAmount)
- .dividedToIntegerBy(signedOrder.makerBuyAmount);
+ const makerTokenFilledAmount = takerTokenFillAmount
+ .times(signedOrder.makerTokenAmount)
+ .dividedToIntegerBy(signedOrder.takerTokenAmount);
const makerFee = signedOrder.makerFee
- .times(makerAmountSold)
- .dividedToIntegerBy(signedOrder.makerSellAmount);
+ .times(makerTokenFilledAmount)
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
const takerFee = signedOrder.takerFee
- .times(makerAmountSold)
- .dividedToIntegerBy(signedOrder.makerSellAmount);
+ .times(makerTokenFilledAmount)
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
expect(newBalances[makerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.makerTokenAddress].minus(makerAmountSold),
+ balances[makerAddress][signedOrder.makerTokenAddress].minus(makerTokenFilledAmount),
);
expect(newBalances[makerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrder.takerTokenAddress].add(takerSellAmount),
+ balances[makerAddress][signedOrder.takerTokenAddress].add(takerTokenFillAmount),
);
expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
balances[makerAddress][zrx.address].minus(makerFee),
);
expect(newBalances[takerAddress][signedOrder.takerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.takerTokenAddress].minus(takerSellAmount),
+ balances[takerAddress][signedOrder.takerTokenAddress].minus(takerTokenFillAmount),
);
expect(newBalances[takerAddress][signedOrder.makerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrder.makerTokenAddress].add(makerAmountSold),
+ balances[takerAddress][signedOrder.makerTokenAddress].add(makerTokenFilledAmount),
);
expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
balances[takerAddress][zrx.address].minus(takerFee),
@@ -226,7 +226,7 @@ describe('Exchange', () => {
it('should not change balances if maker balances are too low to fill order', async () => {
const signedOrder = orderFactory.newSignedOrder({
- makerSellAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
+ makerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
});
await exWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress);
@@ -236,7 +236,7 @@ describe('Exchange', () => {
it('should not change balances if taker balances are too low to fill order', async () => {
const signedOrder = orderFactory.newSignedOrder({
- makerBuyAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
+ takerTokenAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18),
});
await exWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress);
@@ -272,11 +272,11 @@ describe('Exchange', () => {
expect(newBalances).to.be.deep.equal(balances);
});
- it('should not change balances if makerTokenAddress is ZRX, makerSellAmount + makerFee > maker balance', async () => {
+ it('should not change balances if makerTokenAddress is ZRX, makerTokenAmount + makerFee > maker balance', async () => {
const makerZRXBalance = new BigNumber(balances[makerAddress][zrx.address]);
const signedOrder = orderFactory.newSignedOrder({
makerTokenAddress: zrx.address,
- makerSellAmount: makerZRXBalance,
+ makerTokenAmount: makerZRXBalance,
makerFee: new BigNumber(1),
});
await exWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress);
@@ -284,11 +284,11 @@ describe('Exchange', () => {
expect(newBalances).to.be.deep.equal(balances);
});
- it('should not change balances if makerTokenAddress is ZRX, makerSellAmount + makerFee > maker allowance', async () => {
+ it('should not change balances if makerTokenAddress is ZRX, makerTokenAmount + makerFee > maker allowance', async () => {
const makerZRXAllowance = await zrx.allowance.callAsync(makerAddress, tokenTransferProxy.address);
const signedOrder = orderFactory.newSignedOrder({
makerTokenAddress: zrx.address,
- makerSellAmount: new BigNumber(makerZRXAllowance),
+ makerTokenAmount: new BigNumber(makerZRXAllowance),
makerFee: new BigNumber(1),
});
await exWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress);
@@ -296,11 +296,11 @@ describe('Exchange', () => {
expect(newBalances).to.be.deep.equal(balances);
});
- it('should not change balances if takerTokenAddress is ZRX, makerBuyAmount + takerFee > taker balance', async () => {
+ it('should not change balances if takerTokenAddress is ZRX, takerTokenAmount + takerFee > taker balance', async () => {
const takerZRXBalance = new BigNumber(balances[takerAddress][zrx.address]);
const signedOrder = orderFactory.newSignedOrder({
takerTokenAddress: zrx.address,
- makerBuyAmount: takerZRXBalance,
+ takerTokenAmount: takerZRXBalance,
takerFee: new BigNumber(1),
});
await exWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress);
@@ -308,11 +308,11 @@ describe('Exchange', () => {
expect(newBalances).to.be.deep.equal(balances);
});
- it('should not change balances if takerTokenAddress is ZRX, makerBuyAmount + takerFee > taker allowance', async () => {
+ it('should not change balances if takerTokenAddress is ZRX, takerTokenAmount + takerFee > taker allowance', async () => {
const takerZRXAllowance = await zrx.allowance.callAsync(takerAddress, tokenTransferProxy.address);
const signedOrder = orderFactory.newSignedOrder({
takerTokenAddress: zrx.address,
- makerBuyAmount: new BigNumber(takerZRXAllowance),
+ takerTokenAmount: new BigNumber(takerZRXAllowance),
takerFee: new BigNumber(1),
});
await exWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress);
@@ -333,33 +333,33 @@ describe('Exchange', () => {
describe('batchFillOrders', () => {
it('should transfer the correct amounts', async () => {
- const takerSellAmounts: BigNumber[] = [];
+ const takerTokenFillAmounts: BigNumber[] = [];
const makerTokenAddress = rep.address;
const takerTokenAddress = dgd.address;
_.forEach(signedOrders, signedOrder => {
- const takerSellAmount = signedOrder.makerBuyAmount.div(2);
- const makerAmountSold = takerSellAmount
- .times(signedOrder.makerSellAmount)
- .dividedToIntegerBy(signedOrder.makerBuyAmount);
+ const takerTokenFillAmount = signedOrder.takerTokenAmount.div(2);
+ const makerTokenFilledAmount = takerTokenFillAmount
+ .times(signedOrder.makerTokenAmount)
+ .dividedToIntegerBy(signedOrder.takerTokenAmount);
const makerFee = signedOrder.makerFee
- .times(makerAmountSold)
- .dividedToIntegerBy(signedOrder.makerSellAmount);
+ .times(makerTokenFilledAmount)
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
const takerFee = signedOrder.takerFee
- .times(makerAmountSold)
- .dividedToIntegerBy(signedOrder.makerSellAmount);
- takerSellAmounts.push(takerSellAmount);
+ .times(makerTokenFilledAmount)
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
+ takerTokenFillAmounts.push(takerTokenFillAmount);
balances[makerAddress][makerTokenAddress] = balances[makerAddress][makerTokenAddress].minus(
- makerAmountSold,
+ makerTokenFilledAmount,
);
balances[makerAddress][takerTokenAddress] = balances[makerAddress][takerTokenAddress].add(
- takerSellAmount,
+ takerTokenFillAmount,
);
balances[makerAddress][zrx.address] = balances[makerAddress][zrx.address].minus(makerFee);
balances[takerAddress][makerTokenAddress] = balances[takerAddress][makerTokenAddress].add(
- makerAmountSold,
+ makerTokenFilledAmount,
);
balances[takerAddress][takerTokenAddress] = balances[takerAddress][takerTokenAddress].minus(
- takerSellAmount,
+ takerTokenFillAmount,
);
balances[takerAddress][zrx.address] = balances[takerAddress][zrx.address].minus(takerFee);
balances[feeRecipientAddress][zrx.address] = balances[feeRecipientAddress][zrx.address].add(
@@ -368,7 +368,7 @@ describe('Exchange', () => {
});
await exWrapper.batchFillOrdersAsync(signedOrders, takerAddress, {
- takerSellAmounts,
+ takerTokenFillAmounts,
});
const newBalances = await dmyBalances.getAsync();
@@ -378,33 +378,33 @@ describe('Exchange', () => {
describe('batchFillOrKillOrders', () => {
it('should transfer the correct amounts', async () => {
- const takerSellAmounts: BigNumber[] = [];
+ const takerTokenFillAmounts: BigNumber[] = [];
const makerTokenAddress = rep.address;
const takerTokenAddress = dgd.address;
_.forEach(signedOrders, signedOrder => {
- const takerSellAmount = signedOrder.makerBuyAmount.div(2);
- const makerAmountSold = takerSellAmount
- .times(signedOrder.makerSellAmount)
- .dividedToIntegerBy(signedOrder.makerBuyAmount);
+ const takerTokenFillAmount = signedOrder.takerTokenAmount.div(2);
+ const makerTokenFilledAmount = takerTokenFillAmount
+ .times(signedOrder.makerTokenAmount)
+ .dividedToIntegerBy(signedOrder.takerTokenAmount);
const makerFee = signedOrder.makerFee
- .times(makerAmountSold)
- .dividedToIntegerBy(signedOrder.makerSellAmount);
+ .times(makerTokenFilledAmount)
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
const takerFee = signedOrder.takerFee
- .times(makerAmountSold)
- .dividedToIntegerBy(signedOrder.makerSellAmount);
- takerSellAmounts.push(takerSellAmount);
+ .times(makerTokenFilledAmount)
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
+ takerTokenFillAmounts.push(takerTokenFillAmount);
balances[makerAddress][makerTokenAddress] = balances[makerAddress][makerTokenAddress].minus(
- makerAmountSold,
+ makerTokenFilledAmount,
);
balances[makerAddress][takerTokenAddress] = balances[makerAddress][takerTokenAddress].add(
- takerSellAmount,
+ takerTokenFillAmount,
);
balances[makerAddress][zrx.address] = balances[makerAddress][zrx.address].minus(makerFee);
balances[takerAddress][makerTokenAddress] = balances[takerAddress][makerTokenAddress].add(
- makerAmountSold,
+ makerTokenFilledAmount,
);
balances[takerAddress][takerTokenAddress] = balances[takerAddress][takerTokenAddress].minus(
- takerSellAmount,
+ takerTokenFillAmount,
);
balances[takerAddress][zrx.address] = balances[takerAddress][zrx.address].minus(takerFee);
balances[feeRecipientAddress][zrx.address] = balances[feeRecipientAddress][zrx.address].add(
@@ -413,7 +413,7 @@ describe('Exchange', () => {
});
await exWrapper.batchFillOrKillOrdersAsync(signedOrders, takerAddress, {
- takerSellAmounts,
+ takerTokenFillAmounts,
});
const newBalances = await dmyBalances.getAsync();
@@ -421,17 +421,17 @@ describe('Exchange', () => {
});
it('should throw if a single signedOrder does not fill the expected amount', async () => {
- const takerSellAmounts: BigNumber[] = [];
+ const takerTokenFillAmounts: BigNumber[] = [];
_.forEach(signedOrders, signedOrder => {
- const takerSellAmount = signedOrder.makerBuyAmount.div(2);
- takerSellAmounts.push(takerSellAmount);
+ const takerTokenFillAmount = signedOrder.takerTokenAmount.div(2);
+ takerTokenFillAmounts.push(takerTokenFillAmount);
});
await exWrapper.fillOrKillOrderAsync(signedOrders[0], takerAddress);
return expect(
exWrapper.batchFillOrKillOrdersAsync(signedOrders, takerAddress, {
- takerSellAmounts,
+ takerTokenFillAmounts,
}),
).to.be.rejectedWith(constants.REVERT);
});
@@ -439,33 +439,33 @@ describe('Exchange', () => {
describe('batchFillOrdersNoThrow', async () => {
it('should transfer the correct amounts', async () => {
- const takerSellAmounts: BigNumber[] = [];
+ const takerTokenFillAmounts: BigNumber[] = [];
const makerTokenAddress = rep.address;
const takerTokenAddress = dgd.address;
_.forEach(signedOrders, signedOrder => {
- const takerSellAmount = signedOrder.makerBuyAmount.div(2);
- const makerAmountSold = takerSellAmount
- .times(signedOrder.makerSellAmount)
- .dividedToIntegerBy(signedOrder.makerBuyAmount);
+ const takerTokenFillAmount = signedOrder.takerTokenAmount.div(2);
+ const makerTokenFilledAmount = takerTokenFillAmount
+ .times(signedOrder.makerTokenAmount)
+ .dividedToIntegerBy(signedOrder.takerTokenAmount);
const makerFee = signedOrder.makerFee
- .times(makerAmountSold)
- .dividedToIntegerBy(signedOrder.makerSellAmount);
+ .times(makerTokenFilledAmount)
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
const takerFee = signedOrder.takerFee
- .times(makerAmountSold)
- .dividedToIntegerBy(signedOrder.makerSellAmount);
- takerSellAmounts.push(takerSellAmount);
+ .times(makerTokenFilledAmount)
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
+ takerTokenFillAmounts.push(takerTokenFillAmount);
balances[makerAddress][makerTokenAddress] = balances[makerAddress][makerTokenAddress].minus(
- makerAmountSold,
+ makerTokenFilledAmount,
);
balances[makerAddress][takerTokenAddress] = balances[makerAddress][takerTokenAddress].add(
- takerSellAmount,
+ takerTokenFillAmount,
);
balances[makerAddress][zrx.address] = balances[makerAddress][zrx.address].minus(makerFee);
balances[takerAddress][makerTokenAddress] = balances[takerAddress][makerTokenAddress].add(
- makerAmountSold,
+ makerTokenFilledAmount,
);
balances[takerAddress][takerTokenAddress] = balances[takerAddress][takerTokenAddress].minus(
- takerSellAmount,
+ takerTokenFillAmount,
);
balances[takerAddress][zrx.address] = balances[takerAddress][zrx.address].minus(takerFee);
balances[feeRecipientAddress][zrx.address] = balances[feeRecipientAddress][zrx.address].add(
@@ -474,7 +474,7 @@ describe('Exchange', () => {
});
await exWrapper.batchFillOrdersNoThrowAsync(signedOrders, takerAddress, {
- takerSellAmounts,
+ takerTokenFillAmounts,
});
const newBalances = await dmyBalances.getAsync();
@@ -482,7 +482,7 @@ describe('Exchange', () => {
});
it('should not throw if an order is invalid and fill the remaining orders', async () => {
- const takerSellAmounts: BigNumber[] = [];
+ const takerTokenFillAmounts: BigNumber[] = [];
const makerTokenAddress = rep.address;
const takerTokenAddress = dgd.address;
@@ -492,31 +492,31 @@ describe('Exchange', () => {
};
const validOrders = signedOrders.slice(1);
- takerSellAmounts.push(invalidOrder.makerBuyAmount.div(2));
+ takerTokenFillAmounts.push(invalidOrder.takerTokenAmount.div(2));
_.forEach(validOrders, signedOrder => {
- const takerSellAmount = signedOrder.makerBuyAmount.div(2);
- const makerAmountSold = takerSellAmount
- .times(signedOrder.makerSellAmount)
- .dividedToIntegerBy(signedOrder.makerBuyAmount);
+ const takerTokenFillAmount = signedOrder.takerTokenAmount.div(2);
+ const makerTokenFilledAmount = takerTokenFillAmount
+ .times(signedOrder.makerTokenAmount)
+ .dividedToIntegerBy(signedOrder.takerTokenAmount);
const makerFee = signedOrder.makerFee
- .times(makerAmountSold)
- .dividedToIntegerBy(signedOrder.makerSellAmount);
+ .times(makerTokenFilledAmount)
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
const takerFee = signedOrder.takerFee
- .times(makerAmountSold)
- .dividedToIntegerBy(signedOrder.makerSellAmount);
- takerSellAmounts.push(takerSellAmount);
+ .times(makerTokenFilledAmount)
+ .dividedToIntegerBy(signedOrder.makerTokenAmount);
+ takerTokenFillAmounts.push(takerTokenFillAmount);
balances[makerAddress][makerTokenAddress] = balances[makerAddress][makerTokenAddress].minus(
- makerAmountSold,
+ makerTokenFilledAmount,
);
balances[makerAddress][takerTokenAddress] = balances[makerAddress][takerTokenAddress].add(
- takerSellAmount,
+ takerTokenFillAmount,
);
balances[makerAddress][zrx.address] = balances[makerAddress][zrx.address].minus(makerFee);
balances[takerAddress][makerTokenAddress] = balances[takerAddress][makerTokenAddress].add(
- makerAmountSold,
+ makerTokenFilledAmount,
);
balances[takerAddress][takerTokenAddress] = balances[takerAddress][takerTokenAddress].minus(
- takerSellAmount,
+ takerTokenFillAmount,
);
balances[takerAddress][zrx.address] = balances[takerAddress][zrx.address].minus(takerFee);
balances[feeRecipientAddress][zrx.address] = balances[feeRecipientAddress][zrx.address].add(
@@ -526,7 +526,7 @@ describe('Exchange', () => {
const newOrders = [invalidOrder, ...validOrders];
await exWrapper.batchFillOrdersNoThrowAsync(newOrders, takerAddress, {
- takerSellAmounts,
+ takerTokenFillAmounts,
});
const newBalances = await dmyBalances.getAsync();
@@ -535,33 +535,35 @@ describe('Exchange', () => {
});
describe('marketSellOrders', () => {
- it('should stop when the entire takerSellAmount is filled', async () => {
- const takerSellAmount = signedOrders[0].makerBuyAmount.plus(signedOrders[1].makerBuyAmount.div(2));
+ it('should stop when the entire takerTokenFillAmount is filled', async () => {
+ const takerTokenFillAmount = signedOrders[0].takerTokenAmount.plus(
+ signedOrders[1].takerTokenAmount.div(2),
+ );
await exWrapper.marketSellOrdersAsync(signedOrders, takerAddress, {
- takerSellAmount,
+ takerTokenFillAmount,
});
const newBalances = await dmyBalances.getAsync();
- const makerAmountSold = signedOrders[0].makerSellAmount.add(
- signedOrders[1].makerSellAmount.dividedToIntegerBy(2),
+ const makerTokenFilledAmount = signedOrders[0].makerTokenAmount.add(
+ signedOrders[1].makerTokenAmount.dividedToIntegerBy(2),
);
const makerFee = signedOrders[0].makerFee.add(signedOrders[1].makerFee.dividedToIntegerBy(2));
const takerFee = signedOrders[0].takerFee.add(signedOrders[1].takerFee.dividedToIntegerBy(2));
expect(newBalances[makerAddress][signedOrders[0].makerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrders[0].makerTokenAddress].minus(makerAmountSold),
+ balances[makerAddress][signedOrders[0].makerTokenAddress].minus(makerTokenFilledAmount),
);
expect(newBalances[makerAddress][signedOrders[0].takerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrders[0].takerTokenAddress].add(takerSellAmount),
+ balances[makerAddress][signedOrders[0].takerTokenAddress].add(takerTokenFillAmount),
);
expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
balances[makerAddress][zrx.address].minus(makerFee),
);
expect(newBalances[takerAddress][signedOrders[0].takerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrders[0].takerTokenAddress].minus(takerSellAmount),
+ balances[takerAddress][signedOrders[0].takerTokenAddress].minus(takerTokenFillAmount),
);
expect(newBalances[takerAddress][signedOrders[0].makerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrders[0].makerTokenAddress].add(makerAmountSold),
+ balances[takerAddress][signedOrders[0].makerTokenAddress].add(makerTokenFilledAmount),
);
expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
balances[takerAddress][zrx.address].minus(takerFee),
@@ -571,24 +573,24 @@ describe('Exchange', () => {
);
});
- it('should fill all signedOrders if cannot fill entire takerSellAmount', async () => {
- const takerSellAmount = ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18);
+ it('should fill all signedOrders if cannot fill entire takerTokenFillAmount', async () => {
+ const takerTokenFillAmount = ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18);
_.forEach(signedOrders, signedOrder => {
balances[makerAddress][signedOrder.makerTokenAddress] = balances[makerAddress][
signedOrder.makerTokenAddress
- ].minus(signedOrder.makerSellAmount);
+ ].minus(signedOrder.makerTokenAmount);
balances[makerAddress][signedOrder.takerTokenAddress] = balances[makerAddress][
signedOrder.takerTokenAddress
- ].add(signedOrder.makerBuyAmount);
+ ].add(signedOrder.takerTokenAmount);
balances[makerAddress][zrx.address] = balances[makerAddress][zrx.address].minus(
signedOrder.makerFee,
);
balances[takerAddress][signedOrder.makerTokenAddress] = balances[takerAddress][
signedOrder.makerTokenAddress
- ].add(signedOrder.makerSellAmount);
+ ].add(signedOrder.makerTokenAmount);
balances[takerAddress][signedOrder.takerTokenAddress] = balances[takerAddress][
signedOrder.takerTokenAddress
- ].minus(signedOrder.makerBuyAmount);
+ ].minus(signedOrder.takerTokenAmount);
balances[takerAddress][zrx.address] = balances[takerAddress][zrx.address].minus(
signedOrder.takerFee,
);
@@ -597,7 +599,7 @@ describe('Exchange', () => {
);
});
await exWrapper.marketSellOrdersAsync(signedOrders, takerAddress, {
- takerSellAmount,
+ takerTokenFillAmount,
});
const newBalances = await dmyBalances.getAsync();
@@ -613,40 +615,42 @@ describe('Exchange', () => {
return expect(
exWrapper.marketSellOrdersAsync(signedOrders, takerAddress, {
- takerSellAmount: ZeroEx.toBaseUnitAmount(new BigNumber(1000), 18),
+ takerTokenFillAmount: ZeroEx.toBaseUnitAmount(new BigNumber(1000), 18),
}),
).to.be.rejectedWith(constants.REVERT);
});
});
describe('marketSellOrdersNoThrow', () => {
- it('should stop when the entire takerSellAmount is filled', async () => {
- const takerSellAmount = signedOrders[0].makerBuyAmount.plus(signedOrders[1].makerBuyAmount.div(2));
+ it('should stop when the entire takerTokenFillAmount is filled', async () => {
+ const takerTokenFillAmount = signedOrders[0].takerTokenAmount.plus(
+ signedOrders[1].takerTokenAmount.div(2),
+ );
await exWrapper.marketSellOrdersNoThrowAsync(signedOrders, takerAddress, {
- takerSellAmount,
+ takerTokenFillAmount,
});
const newBalances = await dmyBalances.getAsync();
- const makerAmountSold = signedOrders[0].makerSellAmount.add(
- signedOrders[1].makerSellAmount.dividedToIntegerBy(2),
+ const makerTokenFilledAmount = signedOrders[0].makerTokenAmount.add(
+ signedOrders[1].makerTokenAmount.dividedToIntegerBy(2),
);
const makerFee = signedOrders[0].makerFee.add(signedOrders[1].makerFee.dividedToIntegerBy(2));
const takerFee = signedOrders[0].takerFee.add(signedOrders[1].takerFee.dividedToIntegerBy(2));
expect(newBalances[makerAddress][signedOrders[0].makerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrders[0].makerTokenAddress].minus(makerAmountSold),
+ balances[makerAddress][signedOrders[0].makerTokenAddress].minus(makerTokenFilledAmount),
);
expect(newBalances[makerAddress][signedOrders[0].takerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrders[0].takerTokenAddress].add(takerSellAmount),
+ balances[makerAddress][signedOrders[0].takerTokenAddress].add(takerTokenFillAmount),
);
expect(newBalances[makerAddress][zrx.address]).to.be.bignumber.equal(
balances[makerAddress][zrx.address].minus(makerFee),
);
expect(newBalances[takerAddress][signedOrders[0].takerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrders[0].takerTokenAddress].minus(takerSellAmount),
+ balances[takerAddress][signedOrders[0].takerTokenAddress].minus(takerTokenFillAmount),
);
expect(newBalances[takerAddress][signedOrders[0].makerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrders[0].makerTokenAddress].add(makerAmountSold),
+ balances[takerAddress][signedOrders[0].makerTokenAddress].add(makerTokenFilledAmount),
);
expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
balances[takerAddress][zrx.address].minus(takerFee),
@@ -656,24 +660,24 @@ describe('Exchange', () => {
);
});
- it('should fill all signedOrders if cannot fill entire takerSellAmount', async () => {
- const takerSellAmount = ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18);
+ it('should fill all signedOrders if cannot fill entire takerTokenFillAmount', async () => {
+ const takerTokenFillAmount = ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18);
_.forEach(signedOrders, signedOrder => {
balances[makerAddress][signedOrder.makerTokenAddress] = balances[makerAddress][
signedOrder.makerTokenAddress
- ].minus(signedOrder.makerSellAmount);
+ ].minus(signedOrder.makerTokenAmount);
balances[makerAddress][signedOrder.takerTokenAddress] = balances[makerAddress][
signedOrder.takerTokenAddress
- ].add(signedOrder.makerBuyAmount);
+ ].add(signedOrder.takerTokenAmount);
balances[makerAddress][zrx.address] = balances[makerAddress][zrx.address].minus(
signedOrder.makerFee,
);
balances[takerAddress][signedOrder.makerTokenAddress] = balances[takerAddress][
signedOrder.makerTokenAddress
- ].add(signedOrder.makerSellAmount);
+ ].add(signedOrder.makerTokenAmount);
balances[takerAddress][signedOrder.takerTokenAddress] = balances[takerAddress][
signedOrder.takerTokenAddress
- ].minus(signedOrder.makerBuyAmount);
+ ].minus(signedOrder.takerTokenAmount);
balances[takerAddress][zrx.address] = balances[takerAddress][zrx.address].minus(
signedOrder.takerFee,
);
@@ -682,7 +686,7 @@ describe('Exchange', () => {
);
});
await exWrapper.marketSellOrdersNoThrowAsync(signedOrders, takerAddress, {
- takerSellAmount,
+ takerTokenFillAmount,
});
const newBalances = await dmyBalances.getAsync();
@@ -698,28 +702,30 @@ describe('Exchange', () => {
return expect(
exWrapper.marketSellOrdersNoThrowAsync(signedOrders, takerAddress, {
- takerSellAmount: ZeroEx.toBaseUnitAmount(new BigNumber(1000), 18),
+ takerTokenFillAmount: ZeroEx.toBaseUnitAmount(new BigNumber(1000), 18),
}),
).to.be.rejectedWith(constants.REVERT);
});
});
describe('marketBuyOrders', () => {
- it('should stop when the entire takerBuyAmount is filled', async () => {
- const takerBuyAmount = signedOrders[0].makerSellAmount.plus(signedOrders[1].makerSellAmount.div(2));
+ it('should stop when the entire makerTokenFillAmount is filled', async () => {
+ const makerTokenFillAmount = signedOrders[0].makerTokenAmount.plus(
+ signedOrders[1].makerTokenAmount.div(2),
+ );
await exWrapper.marketBuyOrdersAsync(signedOrders, takerAddress, {
- takerBuyAmount,
+ makerTokenFillAmount,
});
const newBalances = await dmyBalances.getAsync();
- const makerAmountBought = signedOrders[0].makerBuyAmount.add(
- signedOrders[1].makerBuyAmount.dividedToIntegerBy(2),
+ const makerAmountBought = signedOrders[0].takerTokenAmount.add(
+ signedOrders[1].takerTokenAmount.dividedToIntegerBy(2),
);
const makerFee = signedOrders[0].makerFee.add(signedOrders[1].makerFee.dividedToIntegerBy(2));
const takerFee = signedOrders[0].takerFee.add(signedOrders[1].takerFee.dividedToIntegerBy(2));
expect(newBalances[makerAddress][signedOrders[0].makerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrders[0].makerTokenAddress].minus(takerBuyAmount),
+ balances[makerAddress][signedOrders[0].makerTokenAddress].minus(makerTokenFillAmount),
);
expect(newBalances[makerAddress][signedOrders[0].takerTokenAddress]).to.be.bignumber.equal(
balances[makerAddress][signedOrders[0].takerTokenAddress].add(makerAmountBought),
@@ -731,7 +737,7 @@ describe('Exchange', () => {
balances[takerAddress][signedOrders[0].takerTokenAddress].minus(makerAmountBought),
);
expect(newBalances[takerAddress][signedOrders[0].makerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrders[0].makerTokenAddress].add(takerBuyAmount),
+ balances[takerAddress][signedOrders[0].makerTokenAddress].add(makerTokenFillAmount),
);
expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
balances[takerAddress][zrx.address].minus(takerFee),
@@ -741,24 +747,24 @@ describe('Exchange', () => {
);
});
- it('should fill all signedOrders if cannot fill entire takerBuyAmount', async () => {
- const takerBuyAmount = ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18);
+ it('should fill all signedOrders if cannot fill entire makerTokenFillAmount', async () => {
+ const makerTokenFillAmount = ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18);
_.forEach(signedOrders, signedOrder => {
balances[makerAddress][signedOrder.makerTokenAddress] = balances[makerAddress][
signedOrder.makerTokenAddress
- ].minus(signedOrder.makerSellAmount);
+ ].minus(signedOrder.makerTokenAmount);
balances[makerAddress][signedOrder.takerTokenAddress] = balances[makerAddress][
signedOrder.takerTokenAddress
- ].add(signedOrder.makerBuyAmount);
+ ].add(signedOrder.takerTokenAmount);
balances[makerAddress][zrx.address] = balances[makerAddress][zrx.address].minus(
signedOrder.makerFee,
);
balances[takerAddress][signedOrder.makerTokenAddress] = balances[takerAddress][
signedOrder.makerTokenAddress
- ].add(signedOrder.makerSellAmount);
+ ].add(signedOrder.makerTokenAmount);
balances[takerAddress][signedOrder.takerTokenAddress] = balances[takerAddress][
signedOrder.takerTokenAddress
- ].minus(signedOrder.makerBuyAmount);
+ ].minus(signedOrder.takerTokenAmount);
balances[takerAddress][zrx.address] = balances[takerAddress][zrx.address].minus(
signedOrder.takerFee,
);
@@ -767,7 +773,7 @@ describe('Exchange', () => {
);
});
await exWrapper.marketBuyOrdersAsync(signedOrders, takerAddress, {
- takerBuyAmount,
+ makerTokenFillAmount,
});
const newBalances = await dmyBalances.getAsync();
@@ -783,28 +789,30 @@ describe('Exchange', () => {
return expect(
exWrapper.marketBuyOrdersAsync(signedOrders, takerAddress, {
- takerBuyAmount: ZeroEx.toBaseUnitAmount(new BigNumber(1000), 18),
+ makerTokenFillAmount: ZeroEx.toBaseUnitAmount(new BigNumber(1000), 18),
}),
).to.be.rejectedWith(constants.REVERT);
});
});
describe('marketBuyOrdersNoThrow', () => {
- it('should stop when the entire takerBuyAmount is filled', async () => {
- const takerBuyAmount = signedOrders[0].makerSellAmount.plus(signedOrders[1].makerSellAmount.div(2));
+ it('should stop when the entire makerTokenFillAmount is filled', async () => {
+ const makerTokenFillAmount = signedOrders[0].makerTokenAmount.plus(
+ signedOrders[1].makerTokenAmount.div(2),
+ );
await exWrapper.marketBuyOrdersNoThrowAsync(signedOrders, takerAddress, {
- takerBuyAmount,
+ makerTokenFillAmount,
});
const newBalances = await dmyBalances.getAsync();
- const makerAmountBought = signedOrders[0].makerBuyAmount.add(
- signedOrders[1].makerBuyAmount.dividedToIntegerBy(2),
+ const makerAmountBought = signedOrders[0].takerTokenAmount.add(
+ signedOrders[1].takerTokenAmount.dividedToIntegerBy(2),
);
const makerFee = signedOrders[0].makerFee.add(signedOrders[1].makerFee.dividedToIntegerBy(2));
const takerFee = signedOrders[0].takerFee.add(signedOrders[1].takerFee.dividedToIntegerBy(2));
expect(newBalances[makerAddress][signedOrders[0].makerTokenAddress]).to.be.bignumber.equal(
- balances[makerAddress][signedOrders[0].makerTokenAddress].minus(takerBuyAmount),
+ balances[makerAddress][signedOrders[0].makerTokenAddress].minus(makerTokenFillAmount),
);
expect(newBalances[makerAddress][signedOrders[0].takerTokenAddress]).to.be.bignumber.equal(
balances[makerAddress][signedOrders[0].takerTokenAddress].add(makerAmountBought),
@@ -816,7 +824,7 @@ describe('Exchange', () => {
balances[takerAddress][signedOrders[0].takerTokenAddress].minus(makerAmountBought),
);
expect(newBalances[takerAddress][signedOrders[0].makerTokenAddress]).to.be.bignumber.equal(
- balances[takerAddress][signedOrders[0].makerTokenAddress].add(takerBuyAmount),
+ balances[takerAddress][signedOrders[0].makerTokenAddress].add(makerTokenFillAmount),
);
expect(newBalances[takerAddress][zrx.address]).to.be.bignumber.equal(
balances[takerAddress][zrx.address].minus(takerFee),
@@ -826,24 +834,24 @@ describe('Exchange', () => {
);
});
- it('should fill all signedOrders if cannot fill entire takerSellAmount', async () => {
- const takerSellAmount = ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18);
+ it('should fill all signedOrders if cannot fill entire takerTokenFillAmount', async () => {
+ const takerTokenFillAmount = ZeroEx.toBaseUnitAmount(new BigNumber(100000), 18);
_.forEach(signedOrders, signedOrder => {
balances[makerAddress][signedOrder.makerTokenAddress] = balances[makerAddress][
signedOrder.makerTokenAddress
- ].minus(signedOrder.makerSellAmount);
+ ].minus(signedOrder.makerTokenAmount);
balances[makerAddress][signedOrder.takerTokenAddress] = balances[makerAddress][
signedOrder.takerTokenAddress
- ].add(signedOrder.makerBuyAmount);
+ ].add(signedOrder.takerTokenAmount);
balances[makerAddress][zrx.address] = balances[makerAddress][zrx.address].minus(
signedOrder.makerFee,
);
balances[takerAddress][signedOrder.makerTokenAddress] = balances[takerAddress][
signedOrder.makerTokenAddress
- ].add(signedOrder.makerSellAmount);
+ ].add(signedOrder.makerTokenAmount);
balances[takerAddress][signedOrder.takerTokenAddress] = balances[takerAddress][
signedOrder.takerTokenAddress
- ].minus(signedOrder.makerBuyAmount);
+ ].minus(signedOrder.takerTokenAmount);
balances[takerAddress][zrx.address] = balances[takerAddress][zrx.address].minus(
signedOrder.takerFee,
);
@@ -852,7 +860,7 @@ describe('Exchange', () => {
);
});
await exWrapper.marketSellOrdersNoThrowAsync(signedOrders, takerAddress, {
- takerSellAmount,
+ takerTokenFillAmount,
});
const newBalances = await dmyBalances.getAsync();
@@ -868,7 +876,7 @@ describe('Exchange', () => {
return expect(
exWrapper.marketBuyOrdersNoThrowAsync(signedOrders, takerAddress, {
- takerBuyAmount: ZeroEx.toBaseUnitAmount(new BigNumber(1000), 18),
+ makerTokenFillAmount: ZeroEx.toBaseUnitAmount(new BigNumber(1000), 18),
}),
).to.be.rejectedWith(constants.REVERT);
});
@@ -876,11 +884,11 @@ describe('Exchange', () => {
describe('batchCancelOrders', () => {
it('should be able to cancel multiple signedOrders', async () => {
- const takerTokenCancelAmounts = _.map(signedOrders, signedOrder => signedOrder.makerBuyAmount);
+ const takerTokenCancelAmounts = _.map(signedOrders, signedOrder => signedOrder.takerTokenAmount);
await exWrapper.batchCancelOrdersAsync(signedOrders, makerAddress);
await exWrapper.batchFillOrdersAsync(signedOrders, takerAddress, {
- takerSellAmounts: takerTokenCancelAmounts,
+ takerTokenFillAmounts: takerTokenCancelAmounts,
});
const newBalances = await dmyBalances.getAsync();
expect(balances).to.be.deep.equal(newBalances);