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
1b798889
Unverified
Commit
1b798889
authored
May 05, 2021
by
Ian Lapham
Committed by
GitHub
May 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add default increment behavior (#157)
Co-authored-by:
Noah Zinsmeister
<
noahwz@gmail.com
>
parent
1e54b976
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
6 deletions
+29
-6
index.tsx
src/pages/AddLiquidity/index.tsx
+3
-1
hooks.ts
src/state/mint/v3/hooks.ts
+26
-5
No files found.
src/pages/AddLiquidity/index.tsx
View file @
1b798889
...
...
@@ -106,6 +106,7 @@ export default function AddLiquidity({
const
{
independentField
,
typedValue
,
startPriceTypedValue
}
=
useV3MintState
()
const
{
pool
,
ticks
,
dependentField
,
price
,
...
...
@@ -348,7 +349,8 @@ export default function AddLiquidity({
quoteCurrency
??
undefined
,
feeAmount
,
tickLower
,
tickUpper
tickUpper
,
pool
)
return
(
...
...
src/state/mint/v3/hooks.ts
View file @
1b798889
...
...
@@ -420,7 +420,8 @@ export function useRangeHopCallbacks(
quoteCurrency
:
Currency
|
undefined
,
feeAmount
:
FeeAmount
|
undefined
,
tickLower
:
number
|
undefined
,
tickUpper
:
number
|
undefined
tickUpper
:
number
|
undefined
,
pool
?:
Pool
|
undefined
|
null
)
{
const
{
chainId
}
=
useActiveWeb3React
()
const
baseToken
=
useMemo
(()
=>
wrappedCurrency
(
baseCurrency
,
chainId
),
[
baseCurrency
,
chainId
])
...
...
@@ -431,32 +432,52 @@ export function useRangeHopCallbacks(
const
newPrice
=
tickToPrice
(
baseToken
,
quoteToken
,
tickLower
-
TICK_SPACINGS
[
feeAmount
])
return
newPrice
.
toSignificant
(
5
,
undefined
,
Rounding
.
ROUND_UP
)
}
// use pool current tick as starting tick if we have pool but no tick input
if
(
!
(
typeof
tickLower
===
'
number
'
)
&&
baseToken
&&
quoteToken
&&
feeAmount
&&
pool
)
{
const
newPrice
=
tickToPrice
(
baseToken
,
quoteToken
,
pool
.
tickCurrent
-
TICK_SPACINGS
[
feeAmount
])
return
newPrice
.
toSignificant
(
5
,
undefined
,
Rounding
.
ROUND_UP
)
}
return
''
},
[
baseToken
,
quoteToken
,
tickLower
,
feeAmount
])
},
[
baseToken
,
quoteToken
,
tickLower
,
feeAmount
,
pool
])
const
getIncrementLower
=
useCallback
(()
=>
{
if
(
baseToken
&&
quoteToken
&&
typeof
tickLower
===
'
number
'
&&
feeAmount
)
{
const
newPrice
=
tickToPrice
(
baseToken
,
quoteToken
,
tickLower
+
TICK_SPACINGS
[
feeAmount
])
return
newPrice
.
toSignificant
(
5
,
undefined
,
Rounding
.
ROUND_UP
)
}
// use pool current tick as starting tick if we have pool but no tick input
if
(
!
(
typeof
tickLower
===
'
number
'
)
&&
baseToken
&&
quoteToken
&&
feeAmount
&&
pool
)
{
const
newPrice
=
tickToPrice
(
baseToken
,
quoteToken
,
pool
.
tickCurrent
+
TICK_SPACINGS
[
feeAmount
])
return
newPrice
.
toSignificant
(
5
,
undefined
,
Rounding
.
ROUND_UP
)
}
return
''
},
[
baseToken
,
quoteToken
,
tickLower
,
feeAmount
])
},
[
baseToken
,
quoteToken
,
tickLower
,
feeAmount
,
pool
])
const
getDecrementUpper
=
useCallback
(()
=>
{
if
(
baseToken
&&
quoteToken
&&
typeof
tickUpper
===
'
number
'
&&
feeAmount
)
{
const
newPrice
=
tickToPrice
(
baseToken
,
quoteToken
,
tickUpper
-
TICK_SPACINGS
[
feeAmount
])
return
newPrice
.
toSignificant
(
5
,
undefined
,
Rounding
.
ROUND_UP
)
}
// use pool current tick as starting tick if we have pool but no tick input
if
(
!
(
typeof
tickUpper
===
'
number
'
)
&&
baseToken
&&
quoteToken
&&
feeAmount
&&
pool
)
{
const
newPrice
=
tickToPrice
(
baseToken
,
quoteToken
,
pool
.
tickCurrent
-
TICK_SPACINGS
[
feeAmount
])
return
newPrice
.
toSignificant
(
5
,
undefined
,
Rounding
.
ROUND_UP
)
}
return
''
},
[
baseToken
,
quoteToken
,
tickUpper
,
feeAmount
])
},
[
baseToken
,
quoteToken
,
tickUpper
,
feeAmount
,
pool
])
const
getIncrementUpper
=
useCallback
(()
=>
{
if
(
baseToken
&&
quoteToken
&&
typeof
tickUpper
===
'
number
'
&&
feeAmount
)
{
const
newPrice
=
tickToPrice
(
baseToken
,
quoteToken
,
tickUpper
+
TICK_SPACINGS
[
feeAmount
])
return
newPrice
.
toSignificant
(
5
,
undefined
,
Rounding
.
ROUND_UP
)
}
// use pool current tick as starting tick if we have pool but no tick input
if
(
!
(
typeof
tickUpper
===
'
number
'
)
&&
baseToken
&&
quoteToken
&&
feeAmount
&&
pool
)
{
const
newPrice
=
tickToPrice
(
baseToken
,
quoteToken
,
pool
.
tickCurrent
+
TICK_SPACINGS
[
feeAmount
])
return
newPrice
.
toSignificant
(
5
,
undefined
,
Rounding
.
ROUND_UP
)
}
return
''
},
[
baseToken
,
quoteToken
,
tickUpper
,
feeAmount
])
},
[
baseToken
,
quoteToken
,
tickUpper
,
feeAmount
,
pool
])
return
{
getDecrementLower
,
getIncrementLower
,
getDecrementUpper
,
getIncrementUpper
}
}
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