From c27cd98b3395b6546da136a4fafbea3d148a045d Mon Sep 17 00:00:00 2001 From: Noah Zinsmeister Date: Thu, 9 May 2019 20:48:34 -0400 Subject: [PATCH] fix 0 decimals bug --- src/pages/Pool/AddLiquidity.js | 7 ++++++- src/pages/Pool/RemoveLiquidity.js | 7 ++++++- src/pages/Send/index.js | 7 ++++++- src/pages/Swap/index.js | 7 ++++++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/pages/Pool/AddLiquidity.js b/src/pages/Pool/AddLiquidity.js index 8a67cb8a87..3c9af478ce 100644 --- a/src/pages/Pool/AddLiquidity.js +++ b/src/pages/Pool/AddLiquidity.js @@ -86,7 +86,12 @@ function addLiquidityStateReducer(state, action) { function getExchangeRate(inputValue, inputDecimals, outputValue, outputDecimals, invert = false) { 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)) if (invert) { diff --git a/src/pages/Pool/RemoveLiquidity.js b/src/pages/Pool/RemoveLiquidity.js index 244ca53137..c0e3787044 100644 --- a/src/pages/Pool/RemoveLiquidity.js +++ b/src/pages/Pool/RemoveLiquidity.js @@ -27,7 +27,12 @@ const GAS_MARGIN = ethers.utils.bigNumberify(1000) function getExchangeRate(inputValue, inputDecimals, outputValue, outputDecimals, invert = false) { 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)) if (invert) { diff --git a/src/pages/Send/index.js b/src/pages/Send/index.js index d2d9096510..412bc1367f 100644 --- a/src/pages/Send/index.js +++ b/src/pages/Send/index.js @@ -141,7 +141,12 @@ function swapStateReducer(state, action) { function getExchangeRate(inputValue, inputDecimals, outputValue, outputDecimals, invert = false) { 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)) if (invert) { diff --git a/src/pages/Swap/index.js b/src/pages/Swap/index.js index 691fde4504..d5a375bd0b 100644 --- a/src/pages/Swap/index.js +++ b/src/pages/Swap/index.js @@ -139,7 +139,12 @@ function swapStateReducer(state, action) { function getExchangeRate(inputValue, inputDecimals, outputValue, outputDecimals, invert = false) { 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)) if (invert) {