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

Commit 3321f92

Browse files
committed
fix rate
1 parent 89aff41 commit 3321f92

File tree

6 files changed

+11
-5
lines changed

6 files changed

+11
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ coverage
1919

2020
# nyc test coverage
2121
.nyc_output
22+
test/
2223

2324
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
2425
.grunt

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "loopring.js",
3-
"version": "2.0.12",
3+
"version": "2.0.13",
44
"description": "Loopring javascript library",
55
"scripts": {
66
"lint": "eslint . --fix",

src/common/formatter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import BN from 'bn.js';
44

55
BigNumber.config({
66
EXPONENTIAL_AT: 20,
7-
RANGE: [-20, 10000000],
7+
RANGE: [-100000, 10000000],
88
ROUNDING_MODE: 1
99
});
1010
/**

src/ethereum/contracts/Contracts.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,16 @@ const encodeSubmitRing = (orders, feeRecipient, feeSelections) =>
3737
feeSelections = orders.map(item => 0);
3838
}
3939
const ringHash = getRingHash(orders, feeRecipient, feeSelections);
40-
const amounts = orders.map(order => toBig(order.amountS).div(toBig(order.amountB)));
41-
const tem = amounts.reduce((total, amount) =>
40+
41+
let amounts = toBig(1);
42+
let amountb = toBig(1);
43+
44+
orders.forEach(order =>
4245
{
43-
return total.times(amount);
46+
amounts = amounts.times(toBig(order.amountS));
47+
amountb = amountb.times(toBig(order.amountB));
4448
});
49+
const tem = amounts.div(amountb);
4550
const rate = Math.pow(toNumber(tem), 1 / orders.length);
4651
if (rate < 1)
4752
{

test/encodeRing.js

Whitespace-only changes.

test/order.js

Whitespace-only changes.

0 commit comments

Comments
 (0)