Skip to content

Commit

Permalink
fix 0 decimals bug
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahZinsmeister committed May 10, 2019
1 parent 78cdf11 commit c27cd98
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/pages/Pool/AddLiquidity.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 6 additions & 1 deletion src/pages/Pool/RemoveLiquidity.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 6 additions & 1 deletion src/pages/Send/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 6 additions & 1 deletion src/pages/Swap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit c27cd98

Please sign in to comment.