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

Commit

Permalink
fix rate
Browse files Browse the repository at this point in the history
  • Loading branch information
lyddream committed Nov 28, 2018
1 parent 89aff41 commit 3321f92
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ coverage

# nyc test coverage
.nyc_output
test/

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "loopring.js",
"version": "2.0.12",
"version": "2.0.13",
"description": "Loopring javascript library",
"scripts": {
"lint": "eslint . --fix",
Expand Down
2 changes: 1 addition & 1 deletion src/common/formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import BN from 'bn.js';

BigNumber.config({
EXPONENTIAL_AT: 20,
RANGE: [-20, 10000000],
RANGE: [-100000, 10000000],
ROUNDING_MODE: 1
});
/**
Expand Down
11 changes: 8 additions & 3 deletions src/ethereum/contracts/Contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,16 @@ const encodeSubmitRing = (orders, feeRecipient, feeSelections) =>
feeSelections = orders.map(item => 0);
}
const ringHash = getRingHash(orders, feeRecipient, feeSelections);
const amounts = orders.map(order => toBig(order.amountS).div(toBig(order.amountB)));
const tem = amounts.reduce((total, amount) =>

let amounts = toBig(1);
let amountb = toBig(1);

orders.forEach(order =>
{
return total.times(amount);
amounts = amounts.times(toBig(order.amountS));
amountb = amountb.times(toBig(order.amountB));
});
const tem = amounts.div(amountb);
const rate = Math.pow(toNumber(tem), 1 / orders.length);
if (rate < 1)
{
Expand Down
Empty file added test/encodeRing.js
Empty file.
Empty file added test/order.js
Empty file.

0 comments on commit 3321f92

Please sign in to comment.