-
Notifications
You must be signed in to change notification settings - Fork 1
/
ExchangeBatchTrade.sol
55 lines (50 loc) · 1.4 KB
/
ExchangeBatchTrade.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
pragma solidity >=0.4.22 <0.6.0;
pragma experimental ABIEncoderV2;
import "./Exchange.sol";
contract ExchangeBatchTrade is Exchange {
/**
* @dev Cancel an array of orders if msg.sender is the order signer.
*/
function cancelMultipleOrders(
Order[] memory orders,
bytes[] memory signatures
)
public
{
for (uint256 index = 0; index < orders.length; index++) {
cancelSingleOrder(
orders[index],
signatures[index]
);
}
}
/**
* @dev Execute multiple trades based on the input orders and signatures.
* Note: reverts of one or more trades fail.
*/
function takeAllOrRevert(
Order[] memory orders,
bytes[] memory signatures
)
public
{
for (uint256 index = 0; index < orders.length; index++) {
bool result = _trade(orders[index], signatures[index]);
require(result, "INVALID_TAKEALL");
}
}
/**
* @dev Execute multiple trades based on the input orders and signatures.
* Note: does not revert if one or more trades fail.
*/
function takeAllPossible(
Order[] memory orders,
bytes[] memory signatures
)
public
{
for (uint256 index = 0; index < orders.length; index++) {
_trade(orders[index], signatures[index]);
}
}
}