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
ed801deb
Unverified
Commit
ed801deb
authored
May 03, 2021
by
Noah Zinsmeister
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add fiat value of liquidity + fees
parent
c3472764
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
7 deletions
+29
-7
PositionPage.tsx
src/pages/Pool/PositionPage.tsx
+29
-7
No files found.
src/pages/Pool/PositionPage.tsx
View file @
ed801deb
...
...
@@ -23,7 +23,7 @@ import { currencyId } from 'utils/currencyId'
import
{
formatTokenAmount
}
from
'
utils/formatTokenAmount
'
import
{
useV3PositionFees
}
from
'
hooks/useV3PositionFees
'
import
{
BigNumber
}
from
'
@ethersproject/bignumber
'
import
{
WETH9
,
Currency
,
CurrencyAmount
,
Percent
}
from
'
@uniswap/sdk-core
'
import
{
WETH9
,
Currency
,
CurrencyAmount
,
Percent
,
Fraction
}
from
'
@uniswap/sdk-core
'
import
{
useActiveWeb3React
}
from
'
hooks
'
import
{
useV3NFTPositionManagerContract
}
from
'
hooks/useContract
'
import
{
useIsTransactionPending
,
useTransactionAdder
}
from
'
state/transactions/hooks
'
...
...
@@ -39,6 +39,7 @@ import RateToggle from '../../components/RateToggle'
import
{
useSingleCallResult
}
from
'
state/multicall/hooks
'
import
RangeBadge
from
'
../../components/Badge/RangeBadge
'
import
useUSDCPrice
from
'
hooks/useUSDCPrice
'
const
PageWrapper
=
styled
.
div
`
min-width: 800px;
...
...
@@ -241,6 +242,23 @@ export function PositionPage({
const
owner
=
useSingleCallResult
(
!!
tokenId
?
positionManager
:
null
,
'
ownerOf
'
,
[
tokenId
]).
result
?.[
0
]
const
ownsNFT
=
owner
===
account
||
positionDetails
?.
operator
===
account
const
price0
=
useUSDCPrice
(
token0
??
undefined
)
const
price1
=
useUSDCPrice
(
token1
??
undefined
)
const
fiatValueOfFees
:
CurrencyAmount
|
null
=
useMemo
(()
=>
{
if
(
!
price0
||
!
price1
||
!
feeValue0
||
!
feeValue1
)
return
null
const
amount0
=
price0
.
quote
(
feeValue0
)
const
amount1
=
price1
.
quote
(
feeValue1
)
return
amount0
.
add
(
amount1
)
},
[
price0
,
price1
,
feeValue0
,
feeValue1
])
const
fiatValueOfLiquidity
:
CurrencyAmount
|
null
=
useMemo
(()
=>
{
if
(
!
price0
||
!
price1
||
!
position
)
return
null
const
amount0
=
price0
.
quote
(
position
.
amount0
)
const
amount1
=
price1
.
quote
(
position
.
amount1
)
return
amount0
.
add
(
amount1
)
},
[
price0
,
price1
,
position
])
return
loading
||
poolState
===
PoolState
.
LOADING
||
!
feeAmount
?
(
<
LoadingRows
>
<
div
/>
...
...
@@ -330,9 +348,11 @@ export function PositionPage({
<
AutoColumn
gap=
"lg"
style=
{
{
width
:
'
100%
'
}
}
>
<
AutoColumn
gap=
"md"
>
<
Label
>
Position liquidity
</
Label
>
{
fiatValueOfLiquidity
?.
greaterThan
(
new
Fraction
(
1
,
100
))
&&
(
<
TYPE
.
largeHeader
fontSize=
"36px"
fontWeight=
{
500
}
>
$1222.22
$
{
fiatValueOfLiquidity
.
toFixed
(
2
)
}
</
TYPE
.
largeHeader
>
)
}
</
AutoColumn
>
<
LightCard
padding=
"12px 16px"
>
...
...
@@ -366,9 +386,11 @@ export function PositionPage({
<
RowBetween
style=
{
{
alignItems
:
'
flex-start
'
}
}
>
<
AutoColumn
gap=
"md"
>
<
Label
>
Fees Earned
</
Label
>
{
fiatValueOfFees
?.
greaterThan
(
new
Fraction
(
1
,
100
))
&&
(
<
TYPE
.
largeHeader
color=
{
theme
.
green1
}
fontSize=
"36px"
fontWeight=
{
500
}
>
$2.22
$
{
fiatValueOfFees
.
toFixed
(
2
)
}
</
TYPE
.
largeHeader
>
)
}
</
AutoColumn
>
{
feeValue0
?.
greaterThan
(
0
)
||
feeValue1
?.
greaterThan
(
0
)
||
!!
collectMigrationHash
?
(
<
ButtonConfirmed
...
...
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