aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src/2.0.0
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-07-23 12:16:35 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-07-23 23:02:51 +0800
commite5e68de2d7bf8bfc319200b8dc9f27cf8a081b4a (patch)
tree2f658bbb54abfa22e1d32fe7ffabeab2b5c577fe /packages/contracts/src/2.0.0
parentdcc0908617b83de8f45af3e9ca6854b897be3d72 (diff)
downloaddexon-sol-tools-e5e68de2d7bf8bfc319200b8dc9f27cf8a081b4a.tar.gz
dexon-sol-tools-e5e68de2d7bf8bfc319200b8dc9f27cf8a081b4a.tar.zst
dexon-sol-tools-e5e68de2d7bf8bfc319200b8dc9f27cf8a081b4a.zip
Use != instead of > in loops, add sanity checks to market fill functions
Diffstat (limited to 'packages/contracts/src/2.0.0')
-rw-r--r--packages/contracts/src/2.0.0/forwarder/MixinExchangeWrapper.sol10
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/MixinWrapperFunctions.sol26
2 files changed, 18 insertions, 18 deletions
diff --git a/packages/contracts/src/2.0.0/forwarder/MixinExchangeWrapper.sol b/packages/contracts/src/2.0.0/forwarder/MixinExchangeWrapper.sol
index e230767b7..e150791da 100644
--- a/packages/contracts/src/2.0.0/forwarder/MixinExchangeWrapper.sol
+++ b/packages/contracts/src/2.0.0/forwarder/MixinExchangeWrapper.sol
@@ -104,7 +104,7 @@ contract MixinExchangeWrapper is
bytes memory wethAssetData = WETH_ASSET_DATA;
uint256 ordersLength = orders.length;
- for (uint256 i = 0; i < ordersLength; i++) {
+ for (uint256 i = 0; i != ordersLength; i++) {
// We assume that asset being bought by taker is the same for each order.
// We assume that asset being sold by taker is WETH for each order.
@@ -125,7 +125,7 @@ contract MixinExchangeWrapper is
addFillResults(totalFillResults, singleFillResults);
// Stop execution if the entire amount of takerAsset has been sold
- if (totalFillResults.takerAssetFilledAmount == wethSellAmount) {
+ if (totalFillResults.takerAssetFilledAmount >= wethSellAmount) {
break;
}
}
@@ -151,7 +151,7 @@ contract MixinExchangeWrapper is
bytes memory wethAssetData = WETH_ASSET_DATA;
uint256 ordersLength = orders.length;
- for (uint256 i = 0; i < ordersLength; i++) {
+ for (uint256 i = 0; i != ordersLength; i++) {
// We assume that asset being bought by taker is the same for each order.
// We assume that asset being sold by taker is WETH for each order.
@@ -180,7 +180,7 @@ contract MixinExchangeWrapper is
addFillResults(totalFillResults, singleFillResults);
// Stop execution if the entire amount of makerAsset has been bought
- if (totalFillResults.makerAssetFilledAmount == makerAssetFillAmount) {
+ if (totalFillResults.makerAssetFilledAmount >= makerAssetFillAmount) {
break;
}
}
@@ -214,7 +214,7 @@ contract MixinExchangeWrapper is
uint256 zrxPurchased = 0;
uint256 ordersLength = orders.length;
- for (uint256 i = 0; i < ordersLength; i++) {
+ for (uint256 i = 0; i != ordersLength; i++) {
// All of these are ZRX/WETH, so we can drop the respective assetData from calldata.
orders[i].makerAssetData = zrxAssetData;
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/MixinWrapperFunctions.sol b/packages/contracts/src/2.0.0/protocol/Exchange/MixinWrapperFunctions.sol
index a0882b108..86194f461 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/MixinWrapperFunctions.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/MixinWrapperFunctions.sol
@@ -120,7 +120,7 @@ contract MixinWrapperFunctions is
returns (FillResults memory totalFillResults)
{
uint256 ordersLength = orders.length;
- for (uint256 i = 0; i < ordersLength; i++) {
+ for (uint256 i = 0; i != ordersLength; i++) {
FillResults memory singleFillResults = fillOrder(
orders[i],
takerAssetFillAmounts[i],
@@ -146,7 +146,7 @@ contract MixinWrapperFunctions is
returns (FillResults memory totalFillResults)
{
uint256 ordersLength = orders.length;
- for (uint256 i = 0; i < ordersLength; i++) {
+ for (uint256 i = 0; i != ordersLength; i++) {
FillResults memory singleFillResults = fillOrKillOrder(
orders[i],
takerAssetFillAmounts[i],
@@ -173,7 +173,7 @@ contract MixinWrapperFunctions is
returns (FillResults memory totalFillResults)
{
uint256 ordersLength = orders.length;
- for (uint256 i = 0; i < ordersLength; i++) {
+ for (uint256 i = 0; i != ordersLength; i++) {
FillResults memory singleFillResults = fillOrderNoThrow(
orders[i],
takerAssetFillAmounts[i],
@@ -200,7 +200,7 @@ contract MixinWrapperFunctions is
bytes memory takerAssetData = orders[0].takerAssetData;
uint256 ordersLength = orders.length;
- for (uint256 i = 0; i < ordersLength; i++) {
+ for (uint256 i = 0; i != ordersLength; i++) {
// We assume that asset being sold by taker is the same for each order.
// Rather than passing this in as calldata, we use the takerAssetData from the first order in all later orders.
@@ -220,7 +220,7 @@ contract MixinWrapperFunctions is
addFillResults(totalFillResults, singleFillResults);
// Stop execution if the entire amount of takerAsset has been sold
- if (totalFillResults.takerAssetFilledAmount == takerAssetFillAmount) {
+ if (totalFillResults.takerAssetFilledAmount >= takerAssetFillAmount) {
break;
}
}
@@ -244,7 +244,7 @@ contract MixinWrapperFunctions is
bytes memory takerAssetData = orders[0].takerAssetData;
uint256 ordersLength = orders.length;
- for (uint256 i = 0; i < ordersLength; i++) {
+ for (uint256 i = 0; i != ordersLength; i++) {
// We assume that asset being sold by taker is the same for each order.
// Rather than passing this in as calldata, we use the takerAssetData from the first order in all later orders.
@@ -264,7 +264,7 @@ contract MixinWrapperFunctions is
addFillResults(totalFillResults, singleFillResults);
// Stop execution if the entire amount of takerAsset has been sold
- if (totalFillResults.takerAssetFilledAmount == takerAssetFillAmount) {
+ if (totalFillResults.takerAssetFilledAmount >= takerAssetFillAmount) {
break;
}
}
@@ -287,7 +287,7 @@ contract MixinWrapperFunctions is
bytes memory makerAssetData = orders[0].makerAssetData;
uint256 ordersLength = orders.length;
- for (uint256 i = 0; i < ordersLength; i++) {
+ for (uint256 i = 0; i != ordersLength; i++) {
// We assume that asset being bought by taker is the same for each order.
// Rather than passing this in as calldata, we copy the makerAssetData from the first order onto all later orders.
@@ -315,7 +315,7 @@ contract MixinWrapperFunctions is
addFillResults(totalFillResults, singleFillResults);
// Stop execution if the entire amount of makerAsset has been bought
- if (totalFillResults.makerAssetFilledAmount == makerAssetFillAmount) {
+ if (totalFillResults.makerAssetFilledAmount >= makerAssetFillAmount) {
break;
}
}
@@ -339,7 +339,7 @@ contract MixinWrapperFunctions is
bytes memory makerAssetData = orders[0].makerAssetData;
uint256 ordersLength = orders.length;
- for (uint256 i = 0; i < ordersLength; i++) {
+ for (uint256 i = 0; i != ordersLength; i++) {
// We assume that asset being bought by taker is the same for each order.
// Rather than passing this in as calldata, we copy the makerAssetData from the first order onto all later orders.
@@ -367,7 +367,7 @@ contract MixinWrapperFunctions is
addFillResults(totalFillResults, singleFillResults);
// Stop execution if the entire amount of makerAsset has been bought
- if (totalFillResults.makerAssetFilledAmount == makerAssetFillAmount) {
+ if (totalFillResults.makerAssetFilledAmount >= makerAssetFillAmount) {
break;
}
}
@@ -380,7 +380,7 @@ contract MixinWrapperFunctions is
public
{
uint256 ordersLength = orders.length;
- for (uint256 i = 0; i < ordersLength; i++) {
+ for (uint256 i = 0; i != ordersLength; i++) {
cancelOrder(orders[i]);
}
}
@@ -395,7 +395,7 @@ contract MixinWrapperFunctions is
{
uint256 ordersLength = orders.length;
LibOrder.OrderInfo[] memory ordersInfo = new LibOrder.OrderInfo[](ordersLength);
- for (uint256 i = 0; i < ordersLength; i++) {
+ for (uint256 i = 0; i != ordersLength; i++) {
ordersInfo[i] = getOrderInfo(orders[i]);
}
return ordersInfo;