Commit f87aa671 authored by Chi Kei Chan's avatar Chi Kei Chan Committed by GitHub

Normalize token decimals before calculating exchange rate (#129)

parent 02341f64
......@@ -258,10 +258,10 @@ class AddLiquidity extends Component {
return;
}
const { value: tokenValue } = selectors().getBalance(fromToken[token], token);
const { value: tokenValue, decimals } = selectors().getBalance(fromToken[token], token);
const { value: ethValue } = selectors().getBalance(fromToken[token], eth);
return tokenValue.dividedBy(ethValue);
return tokenValue.multipliedBy(10 ** (18 - decimals)).dividedBy(ethValue);
}
validate() {
......@@ -368,7 +368,7 @@ class AddLiquidity extends Component {
<div className="pool__summary-panel">
<div className="pool__exchange-rate-wrapper">
<span className="pool__exchange-rate">Exchange Rate</span>
<span>{`1 ETH = ${tokenValue.dividedBy(ethValue).toFixed(4)} ${label}`}</span>
<span>{`1 ETH = ${tokenValue.multipliedBy(10 ** (18 - decimals)).dividedBy(ethValue).toFixed(4)} ${label}`}</span>
</div>
<div className="pool__exchange-rate-wrapper">
<span className="swap__exchange-rate">Current Pool Size</span>
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment