sygmaprotocol / sygma-widget

Transfer widget for the sygmaprotocol
5 stars 2 forks source link

fix: max button rounds value #137

Closed Lykhoyda closed 3 months ago

Lykhoyda commented 3 months ago

Closes #124 #123

wainola commented 3 months ago

@mpetrunic @Lykhoyda how many decimals do we want to display if user clicks on max? currently we display 4. Do we want to adjust that?

Lykhoyda commented 3 months ago

Way too complicated. Can you redo PR by using following code:

Math.floor(Number.parseFloat(utils.formatUnits(BigNumber.from("28999999998000000000"), 18))*10000) / 10000

I agree it's more complicated, but it will work with bigger numbers. Might be overkill for this scenario as we have max 18 decimals. So I replace the code with yours

Lykhoyda commented 3 months ago

@mpetrunic @wainola the code didn't work with values with 16 decimals, so I had to change the method tokenBalanceToNumber to do the operations with the BigNumbers.