Skip to content

Commit

Permalink
CLIENT-530: fix infinity in create order
Browse files Browse the repository at this point in the history
  • Loading branch information
tsigel committed Feb 19, 2018
1 parent 5475731 commit a2fa20c
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/modules/dex/directives/createOrder/CreateOrder.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,18 @@

setMaxPrice() {
if (this.priceBalance.asset.id === this.fee.asset.id) {
const amount = this.amountBalance.cloneWithTokens(this.priceBalance.sub(this.fee)
.getTokens()
.div(this.price.getTokens())
.round(this.amountBalance.asset.precision, BigNumber.ROUND_FLOOR));
if (amount.getTokens().lt(0)) {
this.amount = amount.cloneWithTokens('0');
if (this.price.getTokens().eq(0)) {
this.amount = this.amountBalance.cloneWithTokens('0');
} else {
this.amount = amount;
const amount = this.amountBalance.cloneWithTokens(this.priceBalance.sub(this.fee)
.getTokens()
.div(this.price.getTokens())
.round(this.amountBalance.asset.precision, BigNumber.ROUND_FLOOR));
if (amount.getTokens().lt(0)) {
this.amount = amount.cloneWithTokens('0');
} else {
this.amount = amount;
}
}
} else {
this.amount = this.amountBalance.cloneWithTokens(this.priceBalance.getTokens()
Expand Down Expand Up @@ -288,7 +292,7 @@
const sell = Number(this.bid.price);
const buy = Number(this.ask.price);

this.spreadPercent = (((buy - sell) * 100 / buy) || 0).toFixed(2);
this.spreadPercent = buy ? (((buy - sell) * 100 / buy) || 0).toFixed(2) : '0.00';
}

/**
Expand Down

0 comments on commit a2fa20c

Please sign in to comment.