Skip to content
This repository was archived by the owner on Mar 19, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contracts/helper/OrderHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ library OrderHelper {
}
}

if (brokerInterceptor != tokenOwner) {
if (brokerInterceptor != 0x0 && brokerInterceptor != tokenOwner) {
amount = IBrokerInterceptor(brokerInterceptor).getAllowance(
tokenOwner,
broker,
Expand Down
19 changes: 8 additions & 11 deletions contracts/helper/ParticipationHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,17 @@ library ParticipationHelper {
pure
returns (bool thisOrderIsSmaller)
{
Data.Order memory order = p.order;
thisOrderIsSmaller = false;

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

if (order.limitByAmountB) {
if (p.fillAmountB > order.maxAmountB) {
p.fillAmountB = order.maxAmountB;
p.fillAmountS = p.fillAmountB.mul(p.rateS) / p.rateB;
thisOrderIsSmaller = true;
}
p.lrcFee = order.lrcFee.mul(p.fillAmountB) / order.amountB;
} else {
p.lrcFee = order.lrcFee.mul(p.fillAmountS) / order.amountS;
if (p.fillAmountS > order.maxAmountS) {
p.fillAmountS = order.maxAmountS;
thisOrderIsSmaller = true;
}

p.fillAmountB = p.fillAmountS.mul(order.amountB) / order.amountS;
p.lrcFee = order.lrcFee.mul(p.fillAmountS) / order.amountS;
}

function calculateFeeAmounts(
Expand Down
19 changes: 12 additions & 7 deletions contracts/helper/RingHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ library RingHelper {
ring.hash = keccak256(
abi.encodePacked(
ring.hash,
p.order.hash,
p.marginSplitAsFee
p.order.hash
// p.marginSplitAsFee
)
);
}
Expand All @@ -58,30 +58,35 @@ library RingHelper {
Data.Participation memory p = ring.participations[i];
Data.Order memory order = p.order;
p.fillAmountS = order.maxAmountS;
p.fillAmountB = order.maxAmountB;
// p.fillAmountB = order.maxAmountB;
}

uint smallest = 0;

for (uint i = 0; i < ring.size; i++) {
smallest = calculateOrderFillAmounts(ring, i, smallest);
if (i == ring.size - 1 && smallest == 0) {
smallest = calculateOrderFillAmounts(ring, i, smallest, true);
} else {
smallest = calculateOrderFillAmounts(ring, i, smallest, false);
}
}

for (uint i = 0; i < smallest; i++) {
for (uint i = 0; i < smallest ; i++) {
calculateOrderFillAmounts(ring, i, smallest);
}

for (uint i = 0; i < ring.size; i++) {
Data.Participation memory p = ring.participations[i];
p.calculateFeeAmounts(mining);
// p.calculateFeeAmounts(mining);
p.adjustOrderState();
}
}

function calculateOrderFillAmounts(
Data.Ring ring,
uint i,
uint smallest
uint smallest,
bool last
)
internal
pure
Expand Down
13 changes: 7 additions & 6 deletions contracts/iface/IExchange.sol
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,13 @@ contract IExchange {

/// @dev Submit a order-ring for validation and settlement.
function submitRings(
uint16 miningSpec,
uint16[] orderSpecs,
uint8[][] ringSpecs,
address[] addressLists,
uint[] uintList,
bytes[] bytesList
/* uint16 miningSpec, */
/* uint16[] orderSpecs, */
/* // uint8[][] ringSpecs, */
/* address[] addressList, */
/* uint[] uintList, */
/* bytes[] bytesList */
bytes data
)
public;
}
12 changes: 6 additions & 6 deletions contracts/impl/Data.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ library Data {
// computed fields
bytes32 hash;
address interceptor;
uint spendableLRC;
/* uint spendableLRC; */ // no lrc reward, so this field is unused.
}

struct Order {
Expand Down Expand Up @@ -93,15 +93,15 @@ library Data {
struct Participation {
// required fields
Order order;
bool marginSplitAsFee;
uint rateS;
uint rateB;
/* bool marginSplitAsFee; */
/* uint rateS; */
/* uint rateB; */

// computed fields
/* // computed fields */
uint splitS;
uint splitB;
uint lrcFee;
uint lrcReward;
// uint lrcReward;
uint fillAmountS;
uint fillAmountB;
}
Expand Down
Loading