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
2de43a8c
Unverified
Commit
2de43a8c
authored
May 02, 2022
by
David Mihal
Committed by
GitHub
May 02, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: take tick range from URL (#3208)
* Take tick range from URL * Keep minPrice/maxPrice in the URL
parent
5383436c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
3 deletions
+29
-3
index.tsx
src/pages/AddLiquidity/index.tsx
+22
-1
hooks.tsx
src/state/mint/v3/hooks.tsx
+7
-2
No files found.
src/pages/AddLiquidity/index.tsx
View file @
2de43a8c
...
@@ -5,6 +5,7 @@ import { Currency, CurrencyAmount, Percent } from '@uniswap/sdk-core'
...
@@ -5,6 +5,7 @@ import { Currency, CurrencyAmount, Percent } from '@uniswap/sdk-core'
import
{
FeeAmount
,
NonfungiblePositionManager
}
from
'
@uniswap/v3-sdk
'
import
{
FeeAmount
,
NonfungiblePositionManager
}
from
'
@uniswap/v3-sdk
'
import
UnsupportedCurrencyFooter
from
'
components/swap/UnsupportedCurrencyFooter
'
import
UnsupportedCurrencyFooter
from
'
components/swap/UnsupportedCurrencyFooter
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
useActiveWeb3React
from
'
hooks/useActiveWeb3React
'
import
useParsedQueryString
from
'
hooks/useParsedQueryString
'
import
{
useCallback
,
useContext
,
useEffect
,
useState
}
from
'
react
'
import
{
useCallback
,
useContext
,
useEffect
,
useState
}
from
'
react
'
import
{
AlertTriangle
}
from
'
react-feather
'
import
{
AlertTriangle
}
from
'
react-feather
'
import
ReactGA
from
'
react-ga4
'
import
ReactGA
from
'
react-ga4
'
...
@@ -86,6 +87,7 @@ export default function AddLiquidity({
...
@@ -86,6 +87,7 @@ export default function AddLiquidity({
const
expertMode
=
useIsExpertMode
()
const
expertMode
=
useIsExpertMode
()
const
addTransaction
=
useTransactionAdder
()
const
addTransaction
=
useTransactionAdder
()
const
positionManager
=
useV3NFTPositionManagerContract
()
const
positionManager
=
useV3NFTPositionManagerContract
()
const
parsedQs
=
useParsedQueryString
()
// check for existing position if tokenId in url
// check for existing position if tokenId in url
const
{
position
:
existingPositionDetails
,
loading
:
positionLoading
}
=
useV3PositionFromTokenId
(
const
{
position
:
existingPositionDetails
,
loading
:
positionLoading
}
=
useV3PositionFromTokenId
(
...
@@ -107,7 +109,8 @@ export default function AddLiquidity({
...
@@ -107,7 +109,8 @@ export default function AddLiquidity({
baseCurrency
&&
currencyB
&&
baseCurrency
.
wrapped
.
equals
(
currencyB
.
wrapped
)
?
undefined
:
currencyB
baseCurrency
&&
currencyB
&&
baseCurrency
.
wrapped
.
equals
(
currencyB
.
wrapped
)
?
undefined
:
currencyB
// mint state
// mint state
const
{
independentField
,
typedValue
,
startPriceTypedValue
}
=
useV3MintState
()
const
{
independentField
,
typedValue
,
startPriceTypedValue
,
rightRangeTypedValue
,
leftRangeTypedValue
}
=
useV3MintState
()
const
{
const
{
pool
,
pool
,
...
@@ -150,6 +153,24 @@ export default function AddLiquidity({
...
@@ -150,6 +153,24 @@ export default function AddLiquidity({
useEffect
(()
=>
setShowCapitalEfficiencyWarning
(
false
),
[
baseCurrency
,
quoteCurrency
,
feeAmount
])
useEffect
(()
=>
setShowCapitalEfficiencyWarning
(
false
),
[
baseCurrency
,
quoteCurrency
,
feeAmount
])
useEffect
(()
=>
{
if
(
typeof
parsedQs
.
minPrice
===
'
string
'
&&
parsedQs
.
minPrice
!==
leftRangeTypedValue
&&
!
isNaN
(
parsedQs
.
minPrice
as
any
)
)
{
onLeftRangeInput
(
parsedQs
.
minPrice
)
}
if
(
typeof
parsedQs
.
maxPrice
===
'
string
'
&&
parsedQs
.
maxPrice
!==
rightRangeTypedValue
&&
!
isNaN
(
parsedQs
.
maxPrice
as
any
)
)
{
onRightRangeInput
(
parsedQs
.
maxPrice
)
}
},
[
parsedQs
,
rightRangeTypedValue
,
leftRangeTypedValue
,
onRightRangeInput
,
onLeftRangeInput
])
// txn values
// txn values
const
deadline
=
useTransactionDeadline
()
// custom from users settings
const
deadline
=
useTransactionDeadline
()
// custom from users settings
...
...
src/state/mint/v3/hooks.tsx
View file @
2de43a8c
...
@@ -16,8 +16,10 @@ import { usePool } from 'hooks/usePools'
...
@@ -16,8 +16,10 @@ import { usePool } from 'hooks/usePools'
import
JSBI
from
'
jsbi
'
import
JSBI
from
'
jsbi
'
import
tryParseCurrencyAmount
from
'
lib/utils/tryParseCurrencyAmount
'
import
tryParseCurrencyAmount
from
'
lib/utils/tryParseCurrencyAmount
'
import
{
ReactNode
,
useCallback
,
useMemo
}
from
'
react
'
import
{
ReactNode
,
useCallback
,
useMemo
}
from
'
react
'
import
{
useHistory
}
from
'
react-router-dom
'
import
{
useAppDispatch
,
useAppSelector
}
from
'
state/hooks
'
import
{
useAppDispatch
,
useAppSelector
}
from
'
state/hooks
'
import
{
getTickToPrice
}
from
'
utils/getTickToPrice
'
import
{
getTickToPrice
}
from
'
utils/getTickToPrice
'
import
{
replaceURLParam
}
from
'
utils/routes
'
import
{
BIG_INT_ZERO
}
from
'
../../../constants/misc
'
import
{
BIG_INT_ZERO
}
from
'
../../../constants/misc
'
import
{
PoolState
}
from
'
../../../hooks/usePools
'
import
{
PoolState
}
from
'
../../../hooks/usePools
'
...
@@ -46,6 +48,7 @@ export function useV3MintActionHandlers(noLiquidity: boolean | undefined): {
...
@@ -46,6 +48,7 @@ export function useV3MintActionHandlers(noLiquidity: boolean | undefined): {
onStartPriceInput
:
(
typedValue
:
string
)
=>
void
onStartPriceInput
:
(
typedValue
:
string
)
=>
void
}
{
}
{
const
dispatch
=
useAppDispatch
()
const
dispatch
=
useAppDispatch
()
const
history
=
useHistory
()
const
onFieldAInput
=
useCallback
(
const
onFieldAInput
=
useCallback
(
(
typedValue
:
string
)
=>
{
(
typedValue
:
string
)
=>
{
...
@@ -64,15 +67,17 @@ export function useV3MintActionHandlers(noLiquidity: boolean | undefined): {
...
@@ -64,15 +67,17 @@ export function useV3MintActionHandlers(noLiquidity: boolean | undefined): {
const
onLeftRangeInput
=
useCallback
(
const
onLeftRangeInput
=
useCallback
(
(
typedValue
:
string
)
=>
{
(
typedValue
:
string
)
=>
{
dispatch
(
typeLeftRangeInput
({
typedValue
}))
dispatch
(
typeLeftRangeInput
({
typedValue
}))
history
.
replace
({
search
:
replaceURLParam
(
history
.
location
.
search
,
'
minPrice
'
,
typedValue
)
})
},
},
[
dispatch
]
[
dispatch
,
history
]
)
)
const
onRightRangeInput
=
useCallback
(
const
onRightRangeInput
=
useCallback
(
(
typedValue
:
string
)
=>
{
(
typedValue
:
string
)
=>
{
dispatch
(
typeRightRangeInput
({
typedValue
}))
dispatch
(
typeRightRangeInput
({
typedValue
}))
history
.
replace
({
search
:
replaceURLParam
(
history
.
location
.
search
,
'
maxPrice
'
,
typedValue
)
})
},
},
[
dispatch
]
[
dispatch
,
history
]
)
)
const
onStartPriceInput
=
useCallback
(
const
onStartPriceInput
=
useCallback
(
...
...
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