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
04296750
Unverified
Commit
04296750
authored
May 04, 2021
by
Ian Lapham
Committed by
GitHub
May 04, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
recreate bug fixes (#109)
parent
eedba979
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
91 additions
and
19 deletions
+91
-19
index.tsx
src/components/PositionPreview/index.tsx
+19
-2
Review.tsx
src/pages/AddLiquidity/Review.tsx
+5
-12
index.tsx
src/pages/AddLiquidity/index.tsx
+4
-2
PositionPage.tsx
src/pages/Pool/PositionPage.tsx
+63
-3
No files found.
src/components/PositionPreview/index.tsx
View file @
04296750
...
@@ -8,16 +8,33 @@ import CurrencyLogo from 'components/CurrencyLogo'
...
@@ -8,16 +8,33 @@ import CurrencyLogo from 'components/CurrencyLogo'
import
{
unwrappedToken
}
from
'
utils/wrappedCurrency
'
import
{
unwrappedToken
}
from
'
utils/wrappedCurrency
'
import
{
Break
}
from
'
components/earn/styled
'
import
{
Break
}
from
'
components/earn/styled
'
import
{
useTranslation
}
from
'
react-i18next
'
import
{
useTranslation
}
from
'
react-i18next
'
import
{
Currency
}
from
'
@uniswap/sdk-core
'
import
RateToggle
from
'
components/RateToggle
'
import
RateToggle
from
'
components/RateToggle
'
export
const
PositionPreview
=
({
position
,
title
}:
{
position
:
Position
;
title
?:
string
})
=>
{
export
const
PositionPreview
=
({
position
,
title
,
baseCurrencyDefault
,
}:
{
position
:
Position
title
?:
string
baseCurrencyDefault
?:
Currency
|
undefined
})
=>
{
const
{
t
}
=
useTranslation
()
const
{
t
}
=
useTranslation
()
const
currency0
=
unwrappedToken
(
position
.
pool
.
token0
)
const
currency0
=
unwrappedToken
(
position
.
pool
.
token0
)
const
currency1
=
unwrappedToken
(
position
.
pool
.
token1
)
const
currency1
=
unwrappedToken
(
position
.
pool
.
token1
)
// track which currency should be base
// track which currency should be base
const
[
baseCurrency
,
setBaseCurrency
]
=
useState
(
currency0
)
const
[
baseCurrency
,
setBaseCurrency
]
=
useState
(
baseCurrencyDefault
?
baseCurrencyDefault
===
currency0
?
currency0
:
baseCurrencyDefault
===
currency1
?
currency1
:
currency0
:
currency0
)
const
sorted
=
baseCurrency
===
currency0
const
sorted
=
baseCurrency
===
currency0
const
quoteCurrency
=
sorted
?
currency1
:
currency0
const
quoteCurrency
=
sorted
?
currency1
:
currency0
...
...
src/pages/AddLiquidity/Review.tsx
View file @
04296750
...
@@ -28,6 +28,7 @@ export function Review({
...
@@ -28,6 +28,7 @@ export function Review({
position
,
position
,
currencies
,
currencies
,
outOfRange
,
outOfRange
,
baseCurrency
,
}:
{
}:
{
position
?:
Position
position
?:
Position
existingPosition
?:
Position
existingPosition
?:
Position
...
@@ -36,6 +37,7 @@ export function Review({
...
@@ -36,6 +37,7 @@ export function Review({
priceLower
?:
Price
priceLower
?:
Price
priceUpper
?:
Price
priceUpper
?:
Price
outOfRange
:
boolean
outOfRange
:
boolean
baseCurrency
?:
Currency
})
{
})
{
const
currencyA
:
Currency
|
undefined
=
currencies
[
Field
.
CURRENCY_A
]
const
currencyA
:
Currency
|
undefined
=
currencies
[
Field
.
CURRENCY_A
]
const
currencyB
:
Currency
|
undefined
=
currencies
[
Field
.
CURRENCY_B
]
const
currencyB
:
Currency
|
undefined
=
currencies
[
Field
.
CURRENCY_B
]
...
@@ -52,18 +54,9 @@ export function Review({
...
@@ -52,18 +54,9 @@ export function Review({
</
RowFixed
>
</
RowFixed
>
<
RangeBadge
inRange=
{
!
outOfRange
}
>
{
outOfRange
?
'
Out of range
'
:
'
In Range
'
}
</
RangeBadge
>
<
RangeBadge
inRange=
{
!
outOfRange
}
>
{
outOfRange
?
'
Out of range
'
:
'
In Range
'
}
</
RangeBadge
>
</
RowBetween
>
</
RowBetween
>
{
position
?
<
PositionPreview
position=
{
position
}
title=
{
'
Tokens To Add
'
}
/>
:
null
}
{
position
?
(
{
/* <YellowCard>
<
PositionPreview
position=
{
position
}
title=
{
'
Tokens To Add
'
}
baseCurrencyDefault=
{
baseCurrency
}
/>
<AutoColumn gap="md">
)
:
null
}
<RowBetween>
<TYPE.label color={theme.text2}>Efficiency Comparison</TYPE.label>
<AlertCircle stroke={theme.text2} />
</RowBetween>
<TYPE.label fontWeight={400} color={theme.text2}>
This liquidity position has an increased capital efficiency relative to an unbounded price limit.
</TYPE.label>
</AutoColumn>
</YellowCard> */
}
</
AutoColumn
>
</
AutoColumn
>
</
Wrapper
>
</
Wrapper
>
)
)
...
...
src/pages/AddLiquidity/index.tsx
View file @
04296750
...
@@ -293,9 +293,10 @@ export default function AddLiquidity({
...
@@ -293,9 +293,10 @@ export default function AddLiquidity({
// if there was a tx hash, we want to clear the input
// if there was a tx hash, we want to clear the input
if
(
txHash
)
{
if
(
txHash
)
{
onFieldAInput
(
''
)
onFieldAInput
(
''
)
history
.
push
(
'
/pool
'
)
}
}
setTxHash
(
''
)
setTxHash
(
''
)
},
[
onFieldAInput
,
txHash
])
},
[
history
,
onFieldAInput
,
txHash
])
const
addIsUnsupported
=
useIsSwapUnsupported
(
currencies
?.
CURRENCY_A
,
currencies
?.
CURRENCY_B
)
const
addIsUnsupported
=
useIsSwapUnsupported
(
currencies
?.
CURRENCY_A
,
currencies
?.
CURRENCY_B
)
...
@@ -304,7 +305,7 @@ export default function AddLiquidity({
...
@@ -304,7 +305,7 @@ export default function AddLiquidity({
onFieldBInput
(
''
)
onFieldBInput
(
''
)
onLeftRangeInput
(
''
)
onLeftRangeInput
(
''
)
onRightRangeInput
(
''
)
onRightRangeInput
(
''
)
history
.
push
(
`/add
/
`
)
history
.
push
(
`/add`
)
},
[
history
,
onFieldAInput
,
onFieldBInput
,
onLeftRangeInput
,
onRightRangeInput
])
},
[
history
,
onFieldAInput
,
onFieldBInput
,
onLeftRangeInput
,
onRightRangeInput
])
// get value and prices at ticks
// get value and prices at ticks
...
@@ -339,6 +340,7 @@ export default function AddLiquidity({
...
@@ -339,6 +340,7 @@ export default function AddLiquidity({
priceLower=
{
priceLower
}
priceLower=
{
priceLower
}
priceUpper=
{
priceUpper
}
priceUpper=
{
priceUpper
}
outOfRange=
{
outOfRange
}
outOfRange=
{
outOfRange
}
baseCurrency=
{
baseCurrency
??
undefined
}
/>
/>
)
}
)
}
bottomContent=
{
()
=>
(
bottomContent=
{
()
=>
(
...
...
src/pages/Pool/PositionPage.tsx
View file @
04296750
...
@@ -28,6 +28,7 @@ import { useActiveWeb3React } from 'hooks'
...
@@ -28,6 +28,7 @@ import { useActiveWeb3React } from 'hooks'
import
{
useV3NFTPositionManagerContract
}
from
'
hooks/useContract
'
import
{
useV3NFTPositionManagerContract
}
from
'
hooks/useContract
'
import
{
useIsTransactionPending
,
useTransactionAdder
}
from
'
state/transactions/hooks
'
import
{
useIsTransactionPending
,
useTransactionAdder
}
from
'
state/transactions/hooks
'
import
ReactGA
from
'
react-ga
'
import
ReactGA
from
'
react-ga
'
import
TransactionConfirmationModal
,
{
ConfirmationModalContent
}
from
'
components/TransactionConfirmationModal
'
import
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
{
TransactionResponse
}
from
'
@ethersproject/providers
'
import
{
Dots
}
from
'
components/swap/styleds
'
import
{
Dots
}
from
'
components/swap/styleds
'
import
{
getPriceOrderingFromPositionForUI
}
from
'
../../components/PositionListItem
'
import
{
getPriceOrderingFromPositionForUI
}
from
'
../../components/PositionListItem
'
...
@@ -230,14 +231,15 @@ export function PositionPage({
...
@@ -230,14 +231,15 @@ export function PositionPage({
// const below = pool && typeof tickLower === 'number' ? pool.tickCurrent < tickLower : false
// const below = pool && typeof tickLower === 'number' ? pool.tickCurrent < tickLower : false
// const above = pool && typeof tickUpper === 'number' ? pool.tickCurrent >= tickUpper : false
// const above = pool && typeof tickUpper === 'number' ? pool.tickCurrent >= tickUpper : false
const
ratio
=
const
ratio
=
useMemo
(()
=>
{
priceLower
&&
pool
&&
priceUpper
return
priceLower
&&
pool
&&
priceUpper
?
getRatio
(
?
getRatio
(
inverted
?
priceUpper
.
invert
()
:
priceLower
,
inverted
?
priceUpper
.
invert
()
:
priceLower
,
pool
.
token0Price
,
pool
.
token0Price
,
inverted
?
priceLower
.
invert
()
:
priceUpper
inverted
?
priceLower
.
invert
()
:
priceUpper
)
)
:
undefined
:
undefined
},
[
inverted
,
pool
,
priceLower
,
priceUpper
])
// fees
// fees
const
[
feeValue0
,
feeValue1
]
=
useV3PositionFees
(
pool
??
undefined
,
positionDetails
)
const
[
feeValue0
,
feeValue1
]
=
useV3PositionFees
(
pool
??
undefined
,
positionDetails
)
...
@@ -245,6 +247,7 @@ export function PositionPage({
...
@@ -245,6 +247,7 @@ export function PositionPage({
const
[
collecting
,
setCollecting
]
=
useState
<
boolean
>
(
false
)
const
[
collecting
,
setCollecting
]
=
useState
<
boolean
>
(
false
)
const
[
collectMigrationHash
,
setCollectMigrationHash
]
=
useState
<
string
|
null
>
(
null
)
const
[
collectMigrationHash
,
setCollectMigrationHash
]
=
useState
<
string
|
null
>
(
null
)
const
isCollectPending
=
useIsTransactionPending
(
collectMigrationHash
??
undefined
)
const
isCollectPending
=
useIsTransactionPending
(
collectMigrationHash
??
undefined
)
const
[
showConfirm
,
setShowConfirm
]
=
useState
(
false
)
const
addTransaction
=
useTransactionAdder
()
const
addTransaction
=
useTransactionAdder
()
const
positionManager
=
useV3NFTPositionManagerContract
()
const
positionManager
=
useV3NFTPositionManagerContract
()
...
@@ -319,6 +322,49 @@ export function PositionPage({
...
@@ -319,6 +322,49 @@ export function PositionPage({
return
amount0
.
add
(
amount1
)
return
amount0
.
add
(
amount1
)
},
[
price0
,
price1
,
position
])
},
[
price0
,
price1
,
position
])
function
modalHeader
()
{
return
(
<
AutoColumn
gap=
{
'
md
'
}
style=
{
{
marginTop
:
'
20px
'
}
}
>
<
LightCard
padding=
"12px 16px"
>
<
AutoColumn
gap=
"md"
>
<
RowBetween
>
<
RowFixed
>
<
CurrencyLogo
currency=
{
currencyQuote
}
size=
{
'
20px
'
}
style=
{
{
marginRight
:
'
0.5rem
'
}
}
/>
<
TYPE
.
main
>
{
inverted
?
feeValue0
?
formatTokenAmount
(
feeValue0
,
4
)
:
'
-
'
:
feeValue1
?
formatTokenAmount
(
feeValue1
,
4
)
:
'
-
'
}
</
TYPE
.
main
>
</
RowFixed
>
<
TYPE
.
main
>
{
currencyQuote
?.
symbol
}
</
TYPE
.
main
>
</
RowBetween
>
<
RowBetween
>
<
RowFixed
>
<
CurrencyLogo
currency=
{
currencyBase
}
size=
{
'
20px
'
}
style=
{
{
marginRight
:
'
0.5rem
'
}
}
/>
<
TYPE
.
main
>
{
inverted
?
feeValue0
?
formatTokenAmount
(
feeValue1
,
4
)
:
'
-
'
:
feeValue1
?
formatTokenAmount
(
feeValue0
,
4
)
:
'
-
'
}
</
TYPE
.
main
>
</
RowFixed
>
<
TYPE
.
main
>
{
currencyBase
?.
symbol
}
</
TYPE
.
main
>
</
RowBetween
>
</
AutoColumn
>
</
LightCard
>
<
TYPE
.
italic
>
Collecting fees will withdraw currently available fees for you.
</
TYPE
.
italic
>
<
ButtonPrimary
onClick=
{
collect
}
>
Collect
</
ButtonPrimary
>
</
AutoColumn
>
)
}
return
loading
||
poolState
===
PoolState
.
LOADING
||
!
feeAmount
?
(
return
loading
||
poolState
===
PoolState
.
LOADING
||
!
feeAmount
?
(
<
LoadingRows
>
<
LoadingRows
>
<
div
/>
<
div
/>
...
@@ -336,6 +382,20 @@ export function PositionPage({
...
@@ -336,6 +382,20 @@ export function PositionPage({
</
LoadingRows
>
</
LoadingRows
>
)
:
(
)
:
(
<
PageWrapper
>
<
PageWrapper
>
<
TransactionConfirmationModal
isOpen=
{
showConfirm
}
onDismiss=
{
()
=>
setShowConfirm
(
false
)
}
attemptingTxn=
{
collecting
}
hash=
{
collectMigrationHash
??
''
}
content=
{
()
=>
(
<
ConfirmationModalContent
title=
{
'
Collect fees
'
}
onDismiss=
{
()
=>
setShowConfirm
(
false
)
}
topContent=
{
modalHeader
}
/>
)
}
pendingText=
{
'
Collecting fees
'
}
/>
<
AutoColumn
gap=
"md"
>
<
AutoColumn
gap=
"md"
>
<
AutoColumn
gap=
"sm"
>
<
AutoColumn
gap=
"sm"
>
<
Link
style=
{
{
textDecoration
:
'
none
'
,
width
:
'
fit-content
'
,
marginBottom
:
'
0.5rem
'
}
}
to=
"/pool"
>
<
Link
style=
{
{
textDecoration
:
'
none
'
,
width
:
'
fit-content
'
,
marginBottom
:
'
0.5rem
'
}
}
to=
"/pool"
>
...
@@ -466,7 +526,7 @@ export function PositionPage({
...
@@ -466,7 +526,7 @@ export function PositionPage({
width=
"fit-content"
width=
"fit-content"
style=
{
{
borderRadius
:
'
12px
'
}
}
style=
{
{
borderRadius
:
'
12px
'
}
}
padding=
"4px 8px"
padding=
"4px 8px"
onClick=
{
collect
}
onClick=
{
()
=>
setShowConfirm
(
true
)
}
>
>
{
!!
collectMigrationHash
&&
!
isCollectPending
?
(
{
!!
collectMigrationHash
&&
!
isCollectPending
?
(
<
TYPE
.
main
color=
{
theme
.
text1
}
>
Collected
</
TYPE
.
main
>
<
TYPE
.
main
color=
{
theme
.
text1
}
>
Collected
</
TYPE
.
main
>
...
...
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