Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
668a1c80
Unverified
Commit
668a1c80
authored
Jun 21, 2019
by
Noah Zinsmeister
Committed by
GitHub
Jun 21, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix various 0 decimal bugs (#342)
parent
0a924003
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
10 deletions
+22
-10
AddLiquidity.js
src/pages/Pool/AddLiquidity.js
+19
-7
RemoveLiquidity.js
src/pages/Pool/RemoveLiquidity.js
+1
-1
index.js
src/pages/Send/index.js
+2
-2
No files found.
src/pages/Pool/AddLiquidity.js
View file @
668a1c80
...
...
@@ -309,7 +309,7 @@ export default function AddLiquidity() {
<>
<
div
>
{
t
(
'
youAreAdding
'
)}
{
b
(
`
${
amountFormatter
(
inputValueParsed
,
18
,
4
)}
ETH`
)}
{
t
(
'
and
'
)}
{
'
at most
'
}{
'
'
}
{
b
(
`
${
amountFormatter
(
outputValueMax
,
decimals
,
4
)}
${
symbol
}
`
)}
{
t
(
'
intoPool
'
)}
{
b
(
`
${
amountFormatter
(
outputValueMax
,
decimals
,
Math
.
min
(
decimals
,
4
)
)}
${
symbol
}
`
)}
{
t
(
'
intoPool
'
)}
<
/div
>
<
LastSummaryText
>
{
t
(
'
youWillMint
'
)}
{
b
(
amountFormatter
(
liquidityMinted
,
18
,
4
))}
{
t
(
'
liquidityTokens
'
)}
...
...
@@ -355,9 +355,6 @@ export default function AddLiquidity() {
const
addTransaction
=
useTransactionAdder
()
const
isActive
=
active
&&
account
const
isValid
=
inputError
===
null
||
outputError
===
null
async
function
onAddLiquidity
()
{
ReactGA
.
event
({
category
:
'
Pool
'
,
...
...
@@ -409,7 +406,13 @@ export default function AddLiquidity() {
// parse input value
useEffect
(()
=>
{
if
(
isNewExchange
===
false
&&
inputValue
&&
marketRate
&&
lastEditedField
===
INPUT
&&
decimals
)
{
if
(
isNewExchange
===
false
&&
inputValue
&&
marketRate
&&
lastEditedField
===
INPUT
&&
(
decimals
||
decimals
===
0
)
)
{
try
{
const
parsedValue
=
ethers
.
utils
.
parseUnits
(
inputValue
,
18
)
...
...
@@ -427,7 +430,7 @@ export default function AddLiquidity() {
setOutputValueParsed
(
currencyAmount
)
dispatchAddLiquidityState
({
type
:
'
UPDATE_DEPENDENT_VALUE
'
,
payload
:
{
field
:
OUTPUT
,
value
:
amountFormatter
(
currencyAmount
,
decimals
,
4
,
false
)
}
payload
:
{
field
:
OUTPUT
,
value
:
amountFormatter
(
currencyAmount
,
decimals
,
Math
.
min
(
decimals
,
4
)
,
false
)
}
})
return
()
=>
{
...
...
@@ -447,7 +450,13 @@ export default function AddLiquidity() {
// parse output value
useEffect
(()
=>
{
if
(
isNewExchange
===
false
&&
outputValue
&&
marketRateInverted
&&
lastEditedField
===
OUTPUT
&&
decimals
)
{
if
(
isNewExchange
===
false
&&
outputValue
&&
marketRateInverted
&&
lastEditedField
===
OUTPUT
&&
(
decimals
||
decimals
===
0
)
)
{
try
{
const
parsedValue
=
ethers
.
utils
.
parseUnits
(
outputValue
,
decimals
)
...
...
@@ -516,6 +525,9 @@ export default function AddLiquidity() {
}
},
[
outputValueParsed
,
allowance
,
t
])
const
isActive
=
active
&&
account
const
isValid
=
(
inputError
===
null
||
outputError
===
null
)
&&
!
showUnlock
return
(
<>
{
isNewExchange
?
(
...
...
src/pages/Pool/RemoveLiquidity.js
View file @
668a1c80
...
...
@@ -380,7 +380,7 @@ export default function RemoveLiquidity() {
<
/ExchangeRateWrapper
>
<
ExchangeRateWrapper
>
<
ExchangeRate
>
{
t
(
'
currentPoolSize
'
)}
<
/ExchangeRate
>
{
exchangeETHBalance
&&
exchangeTokenBalance
&&
decimals
?
(
{
exchangeETHBalance
&&
exchangeTokenBalance
&&
(
decimals
||
decimals
===
0
)
?
(
<
span
>
{
`
${
amountFormatter
(
exchangeETHBalance
,
18
,
4
)}
ETH +
${
amountFormatter
(
exchangeTokenBalance
,
decimals
,
...
...
src/pages/Send/index.js
View file @
668a1c80
...
...
@@ -294,7 +294,7 @@ export default function Swap({ initialCurrency }) {
// declare/get parsed and formatted versions of input/output values
const
[
independentValueParsed
,
setIndependentValueParsed
]
=
useState
()
const
dependentValueFormatted
=
!!
(
dependentValue
&&
dependentDecimals
)
const
dependentValueFormatted
=
!!
(
dependentValue
&&
(
dependentDecimals
||
dependentDecimals
===
0
)
)
?
amountFormatter
(
dependentValue
,
dependentDecimals
,
Math
.
min
(
4
,
dependentDecimals
),
false
)
:
''
const
inputValueParsed
=
independentField
===
INPUT
?
independentValueParsed
:
dependentValue
...
...
@@ -305,7 +305,7 @@ export default function Swap({ initialCurrency }) {
// validate + parse independent value
const
[
independentError
,
setIndependentError
]
=
useState
()
useEffect
(()
=>
{
if
(
independentValue
&&
independentDecimals
)
{
if
(
independentValue
&&
(
independentDecimals
||
independentDecimals
===
0
)
)
{
try
{
const
parsedValue
=
ethers
.
utils
.
parseUnits
(
independentValue
,
independentDecimals
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment