-
Notifications
You must be signed in to change notification settings - Fork 126
/
Copy pathLoopringProtocol.sol
139 lines (125 loc) · 5.54 KB
/
LoopringProtocol.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
Copyright 2017 Loopring Project Ltd (Loopring Foundation).
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
pragma solidity 0.4.21;
/// @title Loopring Token Exchange Protocol Contract Interface
/// @author Daniel Wang - <[email protected]>
/// @author Kongliang Zhong - <[email protected]>
/// Recognized contributing developers from the community:
/// https://github.com/Brechtpd
contract LoopringProtocol {
uint8 public constant MARGIN_SPLIT_PERCENTAGE_BASE = 100;
/// @dev Event to emit if a ring is successfully mined.
/// _orderInfoList is an array of:
/// [orderHash, owner, tokenS, fillAmountS, lrcReward/lrcFee, splitS/splitB].
event RingMined(
uint _ringIndex,
bytes32 indexed _ringHash,
address _miner,
address _feeRecipient,
bytes32[] _orderInfoList
);
event OrderCancelled(
bytes32 indexed _orderHash,
uint _amountCancelled
);
event AllOrdersCancelled(
address indexed _address,
uint _cutoff
);
event OrdersCancelled(
address indexed _address,
address _token1,
address _token2,
uint _cutoff
);
/// @dev Cancel an order. cancel amount(amountS or amountB) can be specified
/// in orderValues.
/// @param addresses owner, tokenS, tokenB, wallet, authAddr
/// @param orderValues amountS, amountB, validSince (second),
/// validUntil (second), lrcFee, and cancelAmount.
/// @param buyNoMoreThanAmountB -
/// This indicates when an order should be considered
/// as 'completely filled'.
/// @param marginSplitPercentage -
/// Percentage of margin split to share with miner.
/// @param v Order ECDSA signature parameter v.
/// @param r Order ECDSA signature parameters r.
/// @param s Order ECDSA signature parameters s.
function cancelOrder(
address[5] addresses,
uint[6] orderValues,
bool buyNoMoreThanAmountB,
uint8 marginSplitPercentage,
uint8 v,
bytes32 r,
bytes32 s
)
external;
/// @dev Set a cutoff timestamp to invalidate all orders whose timestamp
/// is smaller than or equal to the new value of the address's cutoff
/// timestamp, for a specific trading pair.
/// @param cutoff The cutoff timestamp, will default to `block.timestamp`
/// if it is 0.
function cancelAllOrdersByTradingPair(
address token1,
address token2,
uint cutoff
)
external;
/// @dev Set a cutoff timestamp to invalidate all orders whose timestamp
/// is smaller than or equal to the new value of the address's cutoff
/// timestamp.
/// @param cutoff The cutoff timestamp, will default to `block.timestamp`
/// if it is 0.
function cancelAllOrders(
uint cutoff
)
external;
/// @dev Submit an order-ring for validation and settlement.
/// @param data Packed data containing a ring header and orders
/// Ring header: 23 bytes as follows:
/// - Ring size (1 byte)
/// - FeeRecipient (20 bytes)
/// - Fee selections (2 bytes)
/// 'Ring size' orders: 395 bytes each as follows:
/// - Owner (32 bytes)
/// - TokenS (32 bytes)
/// - Wallet (32 bytes)
/// - AuthAddr (32 bytes)
/// - AmountS (32 bytes)
/// - AmountB (32 bytes)
/// - LrcFee (32 bytes)
/// - RateAmountS (32 bytes)
/// - OrderR (32 bytes)
/// - OrderS (32 bytes)
/// - RingR (32 bytes)
/// - RingS (32 bytes)
/// - ValidSince (in seconds) (4 bytes)
/// - ValidDuration (in seconds) (4 bytes)
/// - OrderV (1 byte)
/// - RingV (1 byte)
/// - BuyNoMoreThanAmountB (1 bit)
/// - MarginSplitPercentage (7 bits)
/// Note that next order's `tokenS` equals this order's `tokenB`.
/// * The following order members contain the result of a XOR with
/// the value of the previous order:
/// AuthAddr, Wallet, RingR, RingS, RingV.
/// * Fee selections: Bits to indicate fee selections.
/// `1` represents margin split and `0` represents LRC as fee.
/// * BuyNoMoreThanAmountB: This indicates when an order should
/// be considered as 'completely filled'.
function submitRing(
bytes data
)
public;
}