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
ab99cc61
Unverified
Commit
ab99cc61
authored
Apr 27, 2021
by
Noah Zinsmeister
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add current price
parent
11a4fa23
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
12 deletions
+71
-12
PositionPage.tsx
src/pages/Pool/PositionPage.tsx
+71
-12
No files found.
src/pages/Pool/PositionPage.tsx
View file @
ab99cc61
import
React
,
{
useCallback
,
useMemo
,
useState
}
from
'
react
'
import
{
Position
}
from
'
@uniswap/v3-sdk
'
import
{
Po
ol
,
Po
sition
}
from
'
@uniswap/v3-sdk
'
import
{
PoolState
,
usePool
}
from
'
hooks/usePools
'
import
{
useToken
}
from
'
hooks/Tokens
'
import
{
useV3PositionFromTokenId
}
from
'
hooks/useV3Positions
'
...
...
@@ -22,7 +22,7 @@ import { currencyId } from 'utils/currencyId'
import
{
formatTokenAmount
}
from
'
utils/formatTokenAmount
'
import
{
useV3PositionFees
}
from
'
hooks/useV3PositionFees
'
import
{
BigNumber
}
from
'
@ethersproject/bignumber
'
import
{
WETH9
}
from
'
@uniswap/sdk-core
'
import
{
WETH9
,
Currency
}
from
'
@uniswap/sdk-core
'
import
{
useActiveWeb3React
}
from
'
hooks
'
import
{
useV3NFTPositionManagerContract
}
from
'
hooks/useContract
'
import
{
UINT128MAX
}
from
'
../RemoveLiquidity/V3
'
...
...
@@ -94,6 +94,36 @@ export const DarkBadge = styled.div`
padding: 4px 6px;
`
function
CurrentPriceCard
({
inverted
,
pool
,
currencyQuote
,
currencyBase
,
}:
{
inverted
?:
boolean
pool
?:
Pool
|
null
currencyQuote
?:
Currency
currencyBase
?:
Currency
})
{
if
(
!
pool
||
!
currencyQuote
||
!
currencyBase
)
{
return
null
}
return
(
<
DarkGreyCard
width=
"32%"
>
<
AutoColumn
gap=
"sm"
justify=
"flex-start"
>
<
TYPE
.
main
>
Current
</
TYPE
.
main
>
<
RowFixed
>
<
TYPE
.
label
>
{
(
inverted
?
pool
.
token1Price
:
pool
.
token0Price
).
toSignificant
(
4
)
}
{
currencyQuote
?.
symbol
}
/ 1
{
'
'
}
{
currencyBase
?.
symbol
}
</
TYPE
.
label
>
</
RowFixed
>
</
AutoColumn
>
</
DarkGreyCard
>
)
}
export
function
PositionPage
({
match
:
{
params
:
{
tokenId
:
tokenIdFromUrl
},
...
...
@@ -134,10 +164,12 @@ export function PositionPage({
const
currencyBase
=
inverted
?
currency1
:
currency0
// check if price is within range
const
outOf
Range
:
boolean
=
const
in
Range
:
boolean
=
pool
&&
typeof
tickLower
===
'
number
'
&&
typeof
tickUpper
===
'
number
'
?
pool
.
tickCurrent
<
tickLower
||
pool
.
tickCurrent
>
tickUpper
?
pool
.
tickCurrent
>=
tickLower
&&
pool
.
tickCurrent
<
tickUpper
:
false
const
below
=
pool
&&
typeof
tickLower
===
'
number
'
?
pool
.
tickCurrent
<
tickLower
:
false
const
above
=
pool
&&
typeof
tickUpper
===
'
number
'
?
pool
.
tickCurrent
>=
tickUpper
:
false
// fees
const
[
feeValue0
,
feeValue1
]
=
useV3PositionFees
(
pool
??
undefined
,
positionDetails
)
...
...
@@ -277,17 +309,17 @@ export function PositionPage({
</
RowBetween
>
<
RowBetween
>
<
BadgeWrapper
>
{
outOfRange
?
(
{
inRange
?
(
<
Badge
variant=
{
BadgeVariant
.
DEFAULT
}
>
<
ActiveDot
/>
<
BadgeText
>
{
t
(
'
Active
'
)
}
</
BadgeText
>
</
Badge
>
)
:
(
<
Badge
variant=
{
BadgeVariant
.
WARNING
}
>
<
AlertTriangle
width=
{
14
}
height=
{
14
}
style=
{
{
marginRight
:
'
4px
'
}
}
/>
<
BadgeText
>
{
t
(
'
Out of range
'
)
}
</
BadgeText
>
</
Badge
>
)
:
(
<
Badge
variant=
{
BadgeVariant
.
DEFAULT
}
>
<
ActiveDot
/>
<
BadgeText
>
{
t
(
'
Active
'
)
}
</
BadgeText
>
</
Badge
>
)
}
</
BadgeWrapper
>
</
RowBetween
>
...
...
@@ -351,8 +383,17 @@ export function PositionPage({
</
ButtonText
>
</
TYPE
.
label
>
{
below
&&
(
<
CurrentPriceCard
inverted=
{
inverted
}
pool=
{
pool
}
currencyQuote=
{
currencyQuote
}
currencyBase=
{
currencyBase
}
/>
)
}
<
RowBetween
>
<
DarkGreyCard
width=
"
48
%"
>
<
DarkGreyCard
width=
"
32
%"
>
<
AutoColumn
gap=
"sm"
justify=
"flex-start"
>
<
TYPE
.
main
>
Lower
</
TYPE
.
main
>
<
RowFixed
>
...
...
@@ -370,7 +411,16 @@ export function PositionPage({
</
AutoColumn
>
</
DarkGreyCard
>
<
DarkGreyCard
width=
"48%"
>
{
inRange
&&
(
<
CurrentPriceCard
inverted=
{
inverted
}
pool=
{
pool
}
currencyQuote=
{
currencyQuote
}
currencyBase=
{
currencyBase
}
/>
)
}
<
DarkGreyCard
width=
"32%"
>
<
AutoColumn
gap=
"sm"
justify=
"flex-start"
>
<
TYPE
.
main
>
Upper
</
TYPE
.
main
>
<
RowFixed
>
...
...
@@ -387,6 +437,15 @@ export function PositionPage({
</
DarkBadge
>
</
AutoColumn
>
</
DarkGreyCard
>
{
above
&&
(
<
CurrentPriceCard
inverted=
{
inverted
}
pool=
{
pool
}
currencyQuote=
{
currencyQuote
}
currencyBase=
{
currencyBase
}
/>
)
}
</
RowBetween
>
</
AutoColumn
>
</
DarkCard
>
...
...
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