fix 0 decimals bug

This commit is contained in:
Noah Zinsmeister 2019-05-09 20:48:34 -04:00
parent 78cdf11b37
commit c27cd98b33
No known key found for this signature in database
GPG Key ID: 83022DD49188C9F2
4 changed files with 24 additions and 4 deletions

@ -86,7 +86,12 @@ function addLiquidityStateReducer(state, action) {
function getExchangeRate(inputValue, inputDecimals, outputValue, outputDecimals, invert = false) { function getExchangeRate(inputValue, inputDecimals, outputValue, outputDecimals, invert = false) {
try { try {
if (inputValue && inputDecimals && outputValue && outputDecimals) { if (
inputValue &&
(inputDecimals || inputDecimals === 0) &&
outputValue &&
(outputDecimals || outputDecimals === 0)
) {
const factor = ethers.utils.bigNumberify(10).pow(ethers.utils.bigNumberify(18)) const factor = ethers.utils.bigNumberify(10).pow(ethers.utils.bigNumberify(18))
if (invert) { if (invert) {

@ -27,7 +27,12 @@ const GAS_MARGIN = ethers.utils.bigNumberify(1000)
function getExchangeRate(inputValue, inputDecimals, outputValue, outputDecimals, invert = false) { function getExchangeRate(inputValue, inputDecimals, outputValue, outputDecimals, invert = false) {
try { try {
if (inputValue && inputDecimals && outputValue && outputDecimals) { if (
inputValue &&
(inputDecimals || inputDecimals === 0) &&
outputValue &&
(outputDecimals || outputDecimals === 0)
) {
const factor = ethers.utils.bigNumberify(10).pow(ethers.utils.bigNumberify(18)) const factor = ethers.utils.bigNumberify(10).pow(ethers.utils.bigNumberify(18))
if (invert) { if (invert) {

@ -141,7 +141,12 @@ function swapStateReducer(state, action) {
function getExchangeRate(inputValue, inputDecimals, outputValue, outputDecimals, invert = false) { function getExchangeRate(inputValue, inputDecimals, outputValue, outputDecimals, invert = false) {
try { try {
if (inputValue && inputDecimals && outputValue && outputDecimals) { if (
inputValue &&
(inputDecimals || inputDecimals === 0) &&
outputValue &&
(outputDecimals || outputDecimals === 0)
) {
const factor = ethers.utils.bigNumberify(10).pow(ethers.utils.bigNumberify(18)) const factor = ethers.utils.bigNumberify(10).pow(ethers.utils.bigNumberify(18))
if (invert) { if (invert) {

@ -139,7 +139,12 @@ function swapStateReducer(state, action) {
function getExchangeRate(inputValue, inputDecimals, outputValue, outputDecimals, invert = false) { function getExchangeRate(inputValue, inputDecimals, outputValue, outputDecimals, invert = false) {
try { try {
if (inputValue && inputDecimals && outputValue && outputDecimals) { if (
inputValue &&
(inputDecimals || inputDecimals === 0) &&
outputValue &&
(outputDecimals || outputDecimals === 0)
) {
const factor = ethers.utils.bigNumberify(10).pow(ethers.utils.bigNumberify(18)) const factor = ethers.utils.bigNumberify(10).pow(ethers.utils.bigNumberify(18))
if (invert) { if (invert) {