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
cdbf440e
Unverified
Commit
cdbf440e
authored
May 05, 2020
by
Ian Lapham
Committed by
GitHub
May 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add slider, big fixes (#715)
parent
5426e488
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
7 deletions
+34
-7
index.tsx
src/components/ExchangePage/index.tsx
+3
-1
index.js
src/components/Slider/index.js
+5
-5
index.js
src/components/WalletModal/index.js
+9
-0
AddLiquidity.tsx
src/pages/Supply/AddLiquidity.tsx
+1
-1
RemoveLiquidity.tsx
src/pages/Supply/RemoveLiquidity.tsx
+16
-0
No files found.
src/components/ExchangePage/index.tsx
View file @
cdbf440e
...
@@ -1426,7 +1426,9 @@ function ExchangePage({ sendingInput = false, history, params }) {
...
@@ -1426,7 +1426,9 @@ function ExchangePage({ sendingInput = false, history, params }) {
error={!!warningHigh}
error={!!warningHigh}
>
>
<Text fontSize={20} fontWeight={500}>
<Text fontSize={20} fontWeight={500}>
{generalError
{!account
? 'Connect Wallet'
: generalError
? generalError
? generalError
: inputError
: inputError
? inputError
? inputError
...
...
src/components/Slider/index.js
View file @
cdbf440e
...
@@ -24,7 +24,7 @@ import { useDebounce } from '../../hooks'
...
@@ -24,7 +24,7 @@ import { useDebounce } from '../../hooks'
const
StyledSlider
=
withStyles
({
const
StyledSlider
=
withStyles
({
root
:
{
root
:
{
width
:
'
95%
'
,
width
:
'
95%
'
,
color
:
'
#
3880ff
'
,
color
:
'
#
ff007a
'
,
height
:
4
,
height
:
4
,
marginLeft
:
'
15px
'
,
marginLeft
:
'
15px
'
,
padding
:
'
15px 0
'
padding
:
'
15px 0
'
...
@@ -32,7 +32,7 @@ const StyledSlider = withStyles({
...
@@ -32,7 +32,7 @@ const StyledSlider = withStyles({
thumb
:
{
thumb
:
{
height
:
28
,
height
:
28
,
width
:
28
,
width
:
28
,
backgroundColor
:
'
#
2172E5
'
,
backgroundColor
:
'
#
ff007a
'
,
marginTop
:
-
14
,
marginTop
:
-
14
,
marginLeft
:
-
14
,
marginLeft
:
-
14
,
'
&:focus,&:hover,&$active
'
:
{
'
&:focus,&:hover,&$active
'
:
{
...
@@ -78,17 +78,17 @@ export default function InputSlider({ value, onChange, override }) {
...
@@ -78,17 +78,17 @@ export default function InputSlider({ value, onChange, override }) {
}
}
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
override
&&
value
!==
internalVal
)
{
if
(
override
)
{
setInternalVal
(
value
)
setInternalVal
(
value
)
}
}
},
[
internalVal
,
override
,
value
])
},
[
override
,
value
])
return
(
return
(
<
StyledSlider
<
StyledSlider
value
=
{
typeof
internalVal
===
'
number
'
?
internalVal
:
0
}
value
=
{
typeof
internalVal
===
'
number
'
?
internalVal
:
0
}
onChange
=
{
handleChange
}
onChange
=
{
handleChange
}
aria
-
labelledby
=
"
input-slider
"
aria
-
labelledby
=
"
input-slider
"
// marks={marks
}
step
=
{
1
}
/
>
/
>
)
)
}
}
src/components/WalletModal/index.js
View file @
cdbf440e
...
@@ -127,6 +127,15 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions
...
@@ -127,6 +127,15 @@ export default function WalletModal({ pendingTransactions, confirmedTransactions
const
walletModalOpen
=
useWalletModalOpen
()
const
walletModalOpen
=
useWalletModalOpen
()
const
toggleWalletModal
=
useWalletModalToggle
()
const
toggleWalletModal
=
useWalletModalToggle
()
const
previousAccount
=
usePrevious
(
account
)
// close on connection, when logged out before
useEffect
(()
=>
{
if
(
account
&&
!
previousAccount
&&
walletModalOpen
)
{
toggleWalletModal
()
}
},
[
account
,
previousAccount
,
toggleWalletModal
,
walletModalOpen
])
// always reset to account view
// always reset to account view
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
walletModalOpen
)
{
if
(
walletModalOpen
)
{
...
...
src/pages/Supply/AddLiquidity.tsx
View file @
cdbf440e
...
@@ -677,7 +677,7 @@ function AddLiquidity({ token0, token1, step = false }) {
...
@@ -677,7 +677,7 @@ function AddLiquidity({ token0, token1, step = false }) {
value={formattedAmounts[Field.OUTPUT]}
value={formattedAmounts[Field.OUTPUT]}
onUserInput={onUserInput}
onUserInput={onUserInput}
onMax={() => {
onMax={() => {
onMax(maxAmountOutput?.toExact(), Field.OUTPUT)
maxAmountOutput &&
onMax(maxAmountOutput?.toExact(), Field.OUTPUT)
}}
}}
atMax={atMaxAmountOutput}
atMax={atMaxAmountOutput}
token={tokens[Field.OUTPUT]}
token={tokens[Field.OUTPUT]}
...
...
src/pages/Supply/RemoveLiquidity.tsx
View file @
cdbf440e
...
@@ -4,6 +4,7 @@ import { ethers } from 'ethers'
...
@@ -4,6 +4,7 @@ import { ethers } from 'ethers'
import
{
parseUnits
}
from
'
@ethersproject/units
'
import
{
parseUnits
}
from
'
@ethersproject/units
'
import
{
TokenAmount
,
JSBI
,
Route
,
WETH
,
Percent
,
Token
,
Pair
}
from
'
@uniswap/sdk
'
import
{
TokenAmount
,
JSBI
,
Route
,
WETH
,
Percent
,
Token
,
Pair
}
from
'
@uniswap/sdk
'
import
Slider
from
'
../../components/Slider
'
import
TokenLogo
from
'
../../components/TokenLogo
'
import
TokenLogo
from
'
../../components/TokenLogo
'
import
DoubleLogo
from
'
../../components/DoubleLogo
'
import
DoubleLogo
from
'
../../components/DoubleLogo
'
import
PositionCard
from
'
../../components/PositionCard
'
import
PositionCard
from
'
../../components/PositionCard
'
...
@@ -271,7 +272,19 @@ export default function RemoveLiquidity({ token0, token1 }) {
...
@@ -271,7 +272,19 @@ export default function RemoveLiquidity({ token0, token1 }) {
parsedAmounts
[
Field
.
LIQUIDITY
]
&&
parsedAmounts
[
Field
.
LIQUIDITY
]
&&
new
Percent
(
parsedAmounts
[
Field
.
LIQUIDITY
]?.
raw
,
userLiquidity
.
raw
).
toFixed
(
0
)
new
Percent
(
parsedAmounts
[
Field
.
LIQUIDITY
]?.
raw
,
userLiquidity
.
raw
).
toFixed
(
0
)
const
[
override
,
setSliderOverride
]
=
useState
(
false
)
// override slider internal value
const
handlePresetPercentage
=
newPercent
=>
{
const
handlePresetPercentage
=
newPercent
=>
{
setSliderOverride
(
true
)
onUserInput
(
Field
.
LIQUIDITY
,
new
TokenAmount
(
pair
?.
liquidityToken
,
JSBI
.
divide
(
JSBI
.
multiply
(
userLiquidity
.
raw
,
JSBI
.
BigInt
(
newPercent
)),
JSBI
.
BigInt
(
100
))
).
toExact
()
)
}
const
handleSliderChange
=
(
event
,
newPercent
)
=>
{
onUserInput
(
onUserInput
(
Field
.
LIQUIDITY
,
Field
.
LIQUIDITY
,
new
TokenAmount
(
new
TokenAmount
(
...
@@ -627,6 +640,9 @@ export default function RemoveLiquidity({ token0, token1 }) {
...
@@ -627,6 +640,9 @@ export default function RemoveLiquidity({ token0, token1 }) {
{derivedPerecent ? (parseInt(derivedPerecent) < 1 ? '<1' : derivedPerecent) : '0'}%
{derivedPerecent ? (parseInt(derivedPerecent) < 1 ? '<1' : derivedPerecent) : '0'}%
</Text>
</Text>
</Row>
</Row>
{!showAdvanced && (
<Slider value={parseFloat(derivedPerecent)} onChange={handleSliderChange} override={override} />
)}
{!showAdvanced && (
{!showAdvanced && (
<RowBetween>
<RowBetween>
<MaxButton onClick={e => handlePresetPercentage(25)} width="20%">
<MaxButton onClick={e => handlePresetPercentage(25)} width="20%">
...
...
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