Skip to content
This repository was archived by the owner on Mar 19, 2019. It is now read-only.

Commit 7018501

Browse files
Merge pull request #356 from Loopring/version2-scratch
WIP: Version2
2 parents a9375b8 + 4289adb commit 7018501

30 files changed

+4653
-4612
lines changed

contracts/helper/OrderHelper.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ library OrderHelper {
183183
}
184184
}
185185

186-
if (brokerInterceptor != tokenOwner) {
186+
if (brokerInterceptor != 0x0 && brokerInterceptor != tokenOwner) {
187187
amount = IBrokerInterceptor(brokerInterceptor).getAllowance(
188188
tokenOwner,
189189
broker,

contracts/helper/ParticipationHelper.sol

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,17 @@ library ParticipationHelper {
4949
pure
5050
returns (bool thisOrderIsSmaller)
5151
{
52-
Data.Order memory order = p.order;
52+
thisOrderIsSmaller = false;
5353

54-
p.fillAmountB = p.fillAmountS.mul(p.rateB) / p.rateS;
54+
Data.Order memory order = p.order;
5555

56-
if (order.limitByAmountB) {
57-
if (p.fillAmountB > order.maxAmountB) {
58-
p.fillAmountB = order.maxAmountB;
59-
p.fillAmountS = p.fillAmountB.mul(p.rateS) / p.rateB;
60-
thisOrderIsSmaller = true;
61-
}
62-
p.lrcFee = order.lrcFee.mul(p.fillAmountB) / order.amountB;
63-
} else {
64-
p.lrcFee = order.lrcFee.mul(p.fillAmountS) / order.amountS;
56+
if (p.fillAmountS > order.maxAmountS) {
57+
p.fillAmountS = order.maxAmountS;
58+
thisOrderIsSmaller = true;
6559
}
60+
61+
p.fillAmountB = p.fillAmountS.mul(order.amountB) / order.amountS;
62+
p.lrcFee = order.lrcFee.mul(p.fillAmountS) / order.amountS;
6663
}
6764

6865
function calculateFeeAmounts(

contracts/helper/RingHelper.sol

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ library RingHelper {
4040
ring.hash = keccak256(
4141
abi.encodePacked(
4242
ring.hash,
43-
p.order.hash,
44-
p.marginSplitAsFee
43+
p.order.hash
44+
// p.marginSplitAsFee
4545
)
4646
);
4747
}
@@ -58,30 +58,35 @@ library RingHelper {
5858
Data.Participation memory p = ring.participations[i];
5959
Data.Order memory order = p.order;
6060
p.fillAmountS = order.maxAmountS;
61-
p.fillAmountB = order.maxAmountB;
61+
// p.fillAmountB = order.maxAmountB;
6262
}
6363

6464
uint smallest = 0;
6565

6666
for (uint i = 0; i < ring.size; i++) {
67-
smallest = calculateOrderFillAmounts(ring, i, smallest);
67+
if (i == ring.size - 1 && smallest == 0) {
68+
smallest = calculateOrderFillAmounts(ring, i, smallest, true);
69+
} else {
70+
smallest = calculateOrderFillAmounts(ring, i, smallest, false);
71+
}
6872
}
6973

70-
for (uint i = 0; i < smallest; i++) {
74+
for (uint i = 0; i < smallest ; i++) {
7175
calculateOrderFillAmounts(ring, i, smallest);
7276
}
7377

7478
for (uint i = 0; i < ring.size; i++) {
7579
Data.Participation memory p = ring.participations[i];
76-
p.calculateFeeAmounts(mining);
80+
// p.calculateFeeAmounts(mining);
7781
p.adjustOrderState();
7882
}
7983
}
8084

8185
function calculateOrderFillAmounts(
8286
Data.Ring ring,
8387
uint i,
84-
uint smallest
88+
uint smallest,
89+
bool last
8590
)
8691
internal
8792
pure

contracts/iface/IExchange.sol

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,13 @@ contract IExchange {
100100

101101
/// @dev Submit a order-ring for validation and settlement.
102102
function submitRings(
103-
uint16 miningSpec,
104-
uint16[] orderSpecs,
105-
uint8[][] ringSpecs,
106-
address[] addressLists,
107-
uint[] uintList,
108-
bytes[] bytesList
103+
/* uint16 miningSpec, */
104+
/* uint16[] orderSpecs, */
105+
/* // uint8[][] ringSpecs, */
106+
/* address[] addressList, */
107+
/* uint[] uintList, */
108+
/* bytes[] bytesList */
109+
bytes data
109110
)
110111
public;
111112
}

contracts/impl/Data.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ library Data {
5757
// computed fields
5858
bytes32 hash;
5959
address interceptor;
60-
uint spendableLRC;
60+
/* uint spendableLRC; */ // no lrc reward, so this field is unused.
6161
}
6262

6363
struct Order {
@@ -93,15 +93,15 @@ library Data {
9393
struct Participation {
9494
// required fields
9595
Order order;
96-
bool marginSplitAsFee;
97-
uint rateS;
98-
uint rateB;
96+
/* bool marginSplitAsFee; */
97+
/* uint rateS; */
98+
/* uint rateB; */
9999

100-
// computed fields
100+
/* // computed fields */
101101
uint splitS;
102102
uint splitB;
103103
uint lrcFee;
104-
uint lrcReward;
104+
// uint lrcReward;
105105
uint fillAmountS;
106106
uint fillAmountB;
107107
}

0 commit comments

Comments
 (0)