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
8649ddc1
Unverified
Commit
8649ddc1
authored
May 27, 2019
by
Noah Zinsmeister
Committed by
GitHub
May 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hot fixes for decimal and liquidity bugs (#309)
parent
eb096603
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
20 deletions
+23
-20
AddLiquidity.js
src/pages/Pool/AddLiquidity.js
+13
-10
RemoveLiquidity.js
src/pages/Pool/RemoveLiquidity.js
+10
-10
No files found.
src/pages/Pool/AddLiquidity.js
View file @
8649ddc1
...
...
@@ -340,7 +340,7 @@ export default function AddLiquidity() {
// parse input value
useEffect
(()
=>
{
if
(
isNewExchange
===
false
&&
inputValue
&&
marketRate
&&
lastEditedField
===
INPUT
)
{
if
(
isNewExchange
===
false
&&
inputValue
&&
marketRate
&&
lastEditedField
===
INPUT
&&
decimals
)
{
try
{
const
parsedValue
=
ethers
.
utils
.
parseUnits
(
inputValue
,
18
)
...
...
@@ -353,10 +353,12 @@ export default function AddLiquidity() {
const
currencyAmount
=
marketRate
.
mul
(
parsedValue
)
.
div
(
ethers
.
utils
.
bigNumberify
(
10
).
pow
(
ethers
.
utils
.
bigNumberify
(
18
)))
.
div
(
ethers
.
utils
.
bigNumberify
(
10
).
pow
(
ethers
.
utils
.
bigNumberify
(
18
-
decimals
)))
setOutputValueParsed
(
currencyAmount
)
dispatchAddLiquidityState
({
type
:
'
UPDATE_DEPENDENT_VALUE
'
,
payload
:
{
field
:
OUTPUT
,
value
:
amountFormatter
(
currencyAmount
,
18
,
4
,
false
)
}
payload
:
{
field
:
OUTPUT
,
value
:
amountFormatter
(
currencyAmount
,
decimals
,
4
,
false
)
}
})
return
()
=>
{
...
...
@@ -372,13 +374,13 @@ export default function AddLiquidity() {
setOutputError
(
t
(
'
inputNotValid
'
))
}
}
},
[
inputValue
,
isNewExchange
,
lastEditedField
,
marketRate
,
t
])
},
[
inputValue
,
isNewExchange
,
lastEditedField
,
marketRate
,
decimals
,
t
])
// parse output value
useEffect
(()
=>
{
if
(
isNewExchange
===
false
&&
outputValue
&&
marketRateInverted
&&
lastEditedField
===
OUTPUT
)
{
if
(
isNewExchange
===
false
&&
outputValue
&&
marketRateInverted
&&
lastEditedField
===
OUTPUT
&&
decimals
)
{
try
{
const
parsedValue
=
ethers
.
utils
.
parseUnits
(
outputValue
,
18
)
const
parsedValue
=
ethers
.
utils
.
parseUnits
(
outputValue
,
decimals
)
if
(
parsedValue
.
lte
(
ethers
.
constants
.
Zero
)
||
parsedValue
.
gte
(
ethers
.
constants
.
MaxUint256
))
{
throw
Error
()
...
...
@@ -388,7 +390,8 @@ export default function AddLiquidity() {
const
currencyAmount
=
marketRateInverted
.
mul
(
parsedValue
)
.
div
(
ethers
.
utils
.
bigNumberify
(
10
).
pow
(
ethers
.
utils
.
bigNumberify
(
18
)))
.
div
(
ethers
.
utils
.
bigNumberify
(
10
).
pow
(
ethers
.
utils
.
bigNumberify
(
decimals
)))
setInputValueParsed
(
currencyAmount
)
dispatchAddLiquidityState
({
type
:
'
UPDATE_DEPENDENT_VALUE
'
,
...
...
@@ -408,7 +411,7 @@ export default function AddLiquidity() {
setInputError
(
t
(
'
inputNotValid
'
))
}
}
},
[
outputValue
,
isNewExchange
,
lastEditedField
,
marketRateInverted
,
t
])
},
[
outputValue
,
isNewExchange
,
lastEditedField
,
marketRateInverted
,
decimals
,
t
])
// input validation
useEffect
(()
=>
{
...
...
@@ -420,14 +423,14 @@ export default function AddLiquidity() {
}
}
if
(
outputValue
Parsed
&&
outputBalance
)
{
if
(
outputValue
Parsed
.
gt
(
outputBalance
))
{
if
(
outputValue
Max
&&
outputBalance
)
{
if
(
outputValue
Max
.
gt
(
outputBalance
))
{
setOutputError
(
t
(
'
insufficientBalance
'
))
}
else
{
setOutputError
(
null
)
}
}
},
[
inputValueParsed
,
inputBalance
,
outputValue
Parsed
,
outputBalance
,
t
])
},
[
inputValueParsed
,
inputBalance
,
outputValue
Max
,
outputBalance
,
t
])
const
allowance
=
useAddressAllowance
(
account
,
outputCurrency
,
exchangeAddress
)
const
[
showUnlock
,
setShowUnlock
]
=
useState
(
false
)
...
...
src/pages/Pool/RemoveLiquidity.js
View file @
8649ddc1
...
...
@@ -142,13 +142,13 @@ export default function RemoveLiquidity() {
:
undefined
const
ethWithdrawn
=
ETHPer
&&
valueParsed
&&
ETHPer
.
mul
(
valueParsed
).
div
(
ethers
.
utils
.
bigNumberify
(
10
).
pow
(
ethers
.
utils
.
bigNumberify
(
18
)))
ETHPer
&&
valueParsed
?
ETHPer
.
mul
(
valueParsed
).
div
(
ethers
.
utils
.
bigNumberify
(
10
).
pow
(
ethers
.
utils
.
bigNumberify
(
18
)))
:
undefined
const
tokenWithdrawn
=
tokenPer
&&
valueParsed
&&
tokenPer
.
mul
(
valueParsed
).
div
(
ethers
.
utils
.
bigNumberify
(
10
).
pow
(
ethers
.
utils
.
bigNumberify
(
18
)))
tokenPer
&&
valueParsed
?
tokenPer
.
mul
(
valueParsed
).
div
(
ethers
.
utils
.
bigNumberify
(
10
).
pow
(
ethers
.
utils
.
bigNumberify
(
18
)))
:
undefined
const
ethWithdrawnMin
=
ethWithdrawn
?
calculateSlippageBounds
(
ethWithdrawn
).
minimum
:
undefined
const
tokenWithdrawnMin
=
tokenWithdrawn
?
calculateSlippageBounds
(
tokenWithdrawn
).
minimum
:
undefined
...
...
@@ -284,20 +284,20 @@ export default function RemoveLiquidity() {
<
/OversizedPanel
>
<
CurrencyInputPanel
title
=
{
t
(
'
output
'
)}
description
=
{
ethWithdrawn
&&
tokenWithdraw
n
?
`(
${
t
(
'
estimated
'
)}
)`
:
''
}
description
=
{
ethWithdrawn
Min
&&
tokenWithdrawnMi
n
?
`(
${
t
(
'
estimated
'
)}
)`
:
''
}
key
=
"
remove-liquidity-input
"
renderInput
=
{()
=>
ethWithdrawn
&&
tokenWithdraw
n
?
(
ethWithdrawn
Min
&&
tokenWithdrawnMi
n
?
(
<
div
className
=
"
remove-liquidity__output
"
>
<
div
className
=
"
remove-liquidity__output-text
"
>
{
`
${
amountFormatter
(
ethWithdrawn
,
ethWithdrawn
Min
,
18
,
4
,
false
)}
ETH`
}
<
/div
>
<
div
className
=
"
remove-liquidity__output-plus
"
>
+
<
/div
>
<
div
className
=
"
remove-liquidity__output-text
"
>
{
`
${
amountFormatter
(
tokenWithdrawn
,
tokenWithdrawn
Min
,
decimals
,
Math
.
min
(
4
,
decimals
)
)}
${
symbol
}
`
}
<
/div
>
...
...
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