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
1a7b86d1
Unverified
Commit
1a7b86d1
authored
Aug 17, 2022
by
Vignesh Mohankumar
Committed by
GitHub
Aug 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: remove unused exports (#4380)
parent
f66f8c4d
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
4 additions
and
239 deletions
+4
-239
styleds.tsx
src/components/swap/styleds.tsx
+0
-12
misc.ts
src/constants/misc.ts
+0
-7
useDebounce.ts
src/hooks/useDebounce.ts
+1
-32
useImperativeDisableScroll.ts
src/hooks/useImperativeDisableScroll.ts
+0
-17
useTimeout.ts
src/hooks/useTimeout.ts
+0
-27
useIsValidBlock.ts
src/lib/hooks/useIsValidBlock.ts
+1
-15
styled.tsx
src/pages/styled.tsx
+0
-12
hooks.ts
src/state/application/hooks.ts
+0
-4
hooks.ts
src/state/connection/hooks.ts
+1
-26
hooks.tsx
src/state/stake/hooks.tsx
+0
-16
hooks.tsx
src/state/user/hooks.tsx
+0
-22
chains.tsx
src/utils/chains.tsx
+1
-6
index.ts
src/utils/index.ts
+0
-5
isTradeBetter.ts
src/utils/isTradeBetter.ts
+0
-32
prices.ts
src/utils/prices.ts
+0
-6
No files found.
src/components/swap/styleds.tsx
View file @
1a7b86d1
import
{
loadingOpacityMixin
}
from
'
components/Loader/styled
'
import
{
TooltipContainer
}
from
'
components/Tooltip
'
import
{
transparentize
}
from
'
polished
'
import
{
ReactNode
}
from
'
react
'
...
...
@@ -6,9 +5,7 @@ import { AlertTriangle } from 'react-feather'
import
{
Text
}
from
'
rebass
'
import
styled
,
{
css
}
from
'
styled-components/macro
'
import
{
ThemedText
}
from
'
../../theme
'
import
{
AutoColumn
}
from
'
../Column
'
import
TradePrice
from
'
./TradePrice
'
export
const
Wrapper
=
styled
.
div
`
position: relative;
...
...
@@ -135,11 +132,6 @@ export const SwapShowAcceptChanges = styled(AutoColumn)`
margin-top: 8px;
`
export
const
TransactionDetailsLabel
=
styled
(
ThemedText
.
DeprecatedBlack
)
`
border-bottom: 1px solid
${({
theme
})
=>
theme
.
deprecated_bg2
}
;
padding-bottom: 0.5rem;
`
export
const
ResponsiveTooltipContainer
=
styled
(
TooltipContainer
)
<
{
origin
?:
string
;
width
?:
string
}
>
`
background-color:
${({
theme
})
=>
theme
.
deprecated_bg0
}
;
border: 1px solid
${({
theme
})
=>
theme
.
deprecated_bg2
}
;
...
...
@@ -151,7 +143,3 @@ export const ResponsiveTooltipContainer = styled(TooltipContainer)<{ origin?: st
transform-origin:
${
origin
??
'
top left
'
};
`}
`
export
const
StyledTradePrice
=
styled
(
TradePrice
)
<
{
$loading
:
boolean
}
>
`
${
loadingOpacityMixin
}
`
src/constants/misc.ts
View file @
1a7b86d1
...
...
@@ -3,10 +3,6 @@ import JSBI from 'jsbi'
export
const
ZERO_ADDRESS
=
'
0x0000000000000000000000000000000000000000
'
export
const
NetworkContextName
=
'
NETWORK
'
export
const
IS_IN_IFRAME
=
window
.
parent
!==
window
// 30 minutes, denominated in seconds
export
const
DEFAULT_DEADLINE_FROM_NOW
=
60
*
30
export
const
L2_DEADLINE_FROM_NOW
=
60
*
5
...
...
@@ -33,8 +29,5 @@ export const PRICE_IMPACT_WITHOUT_FEE_CONFIRM_MIN: Percent = new Percent(JSBI.Bi
// for non expert mode disable swaps above this
export
const
BLOCKED_PRICE_IMPACT_NON_EXPERT
:
Percent
=
new
Percent
(
JSBI
.
BigInt
(
1500
),
BIPS_BASE
)
// 15%
export
const
BETTER_TRADE_LESS_HOPS_THRESHOLD
=
new
Percent
(
JSBI
.
BigInt
(
50
),
BIPS_BASE
)
export
const
ZERO_PERCENT
=
new
Percent
(
'
0
'
)
export
const
TWO_PERCENT
=
new
Percent
(
JSBI
.
BigInt
(
200
),
BIPS_BASE
)
export
const
ONE_HUNDRED_PERCENT
=
new
Percent
(
'
1
'
)
src/hooks/useDebounce.ts
View file @
1a7b86d1
import
{
useEffect
,
use
Ref
,
use
State
}
from
'
react
'
import
{
useEffect
,
useState
}
from
'
react
'
/**
* Debounces updates to a value.
...
...
@@ -24,34 +24,3 @@ export default function useDebounce<T>(value: T, delay: number): T {
return
debouncedValue
}
export
function
useDebouncedCallback
<
A
extends
unknown
[]
>
(
callback
:
(...
args
:
A
)
=>
void
,
wait
:
number
)
{
// track args & timeout handle between calls
const
argsRef
=
useRef
<
A
>
()
const
timeout
=
useRef
<
ReturnType
<
typeof
setTimeout
>>
()
function
cleanup
()
{
if
(
timeout
.
current
)
{
clearTimeout
(
timeout
.
current
)
}
}
// make sure our timeout gets cleared if
// our consuming component gets unmounted
useEffect
(()
=>
cleanup
,
[])
return
function
debouncedCallback
(...
args
:
A
)
{
// capture latest args
argsRef
.
current
=
args
// clear debounce timer
cleanup
()
// start waiting again
timeout
.
current
=
setTimeout
(()
=>
{
if
(
argsRef
.
current
)
{
callback
(...
argsRef
.
current
)
}
},
wait
)
}
}
src/hooks/useImperativeDisableScroll.ts
deleted
100644 → 0
View file @
f66f8c4d
import
{
useEffect
}
from
'
react
'
/**
* Disable scroll of an element based on condition
*/
export
function
useImperativeDisableScroll
({
element
,
disabled
}:
{
element
?:
HTMLElement
;
disabled
?:
boolean
})
{
useEffect
(()
=>
{
if
(
!
element
)
return
element
.
style
.
overflowY
=
disabled
?
'
hidden
'
:
'
auto
'
return
()
=>
{
element
.
style
.
overflowY
=
'
auto
'
}
// eslint-disable-next-line react-hooks/exhaustive-deps
},
[
disabled
])
}
src/hooks/useTimeout.ts
deleted
100644 → 0
View file @
f66f8c4d
import
{
useEffect
,
useState
}
from
'
react
'
const
getReturnValues
=
(
countDown
:
number
):
[
number
,
number
,
number
,
number
]
=>
{
// calculate time left
const
days
=
Math
.
floor
(
countDown
/
(
1000
*
60
*
60
*
24
))
const
hours
=
Math
.
floor
((
countDown
%
(
1000
*
60
*
60
*
24
))
/
(
1000
*
60
*
60
))
const
minutes
=
Math
.
floor
((
countDown
%
(
1000
*
60
*
60
))
/
(
1000
*
60
))
const
seconds
=
Math
.
floor
((
countDown
%
(
1000
*
60
))
/
1000
)
return
[
days
,
hours
,
minutes
,
seconds
]
}
export
const
useTimeout
=
(
targetDate
:
Date
)
=>
{
const
countDownDate
=
new
Date
(
targetDate
).
getTime
()
const
[
countDown
,
setCountDown
]
=
useState
<
number
>
(
countDownDate
-
new
Date
().
getTime
())
useEffect
(()
=>
{
const
interval
=
setInterval
(()
=>
{
setCountDown
(
countDownDate
-
new
Date
().
getTime
())
},
1000
)
return
()
=>
clearInterval
(
interval
)
},
[
countDownDate
])
return
getReturnValues
(
countDown
)
}
src/lib/hooks/useIsValidBlock.ts
View file @
1a7b86d1
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
atomWithImmer
}
from
'
jotai/immer
'
import
{
useAtomValue
,
useUpdateAtom
}
from
'
jotai/utils
'
import
{
useAtomValue
}
from
'
jotai/utils
'
import
{
useCallback
}
from
'
react
'
import
useBlockNumber
from
'
./useBlockNumber
'
...
...
@@ -10,20 +10,6 @@ const oldestBlockMapAtom = atomWithImmer<{ [chainId: number]: number }>({})
const
DEFAULT_MAX_BLOCK_AGE
=
10
export
function
useSetOldestValidBlock
():
(
block
:
number
)
=>
void
{
const
{
chainId
}
=
useWeb3React
()
const
updateValidBlock
=
useUpdateAtom
(
oldestBlockMapAtom
)
return
useCallback
(
(
block
:
number
)
=>
{
if
(
!
chainId
)
return
updateValidBlock
((
oldestBlockMap
)
=>
{
oldestBlockMap
[
chainId
]
=
Math
.
max
(
block
,
oldestBlockMap
[
chainId
]
||
0
)
})
},
[
chainId
,
updateValidBlock
]
)
}
export
function
useGetIsValidBlock
(
maxBlockAge
=
DEFAULT_MAX_BLOCK_AGE
):
(
block
:
number
)
=>
boolean
{
const
{
chainId
}
=
useWeb3React
()
const
currentBlock
=
useBlockNumber
()
...
...
src/pages/styled.tsx
deleted
100644 → 0
View file @
f66f8c4d
import
styled
from
'
styled-components/macro
'
export
const
IframeBodyWrapper
=
styled
.
div
`
display: flex;
flex-direction: column;
width: 100%;
margin-top: 3rem;
padding: 1rem;
align-items: center;
flex: 1;
z-index: 1;
`
src/state/application/hooks.ts
View file @
1a7b86d1
...
...
@@ -66,10 +66,6 @@ export function useTogglePrivacyPolicy(): () => void {
return
useToggleModal
(
ApplicationModal
.
PRIVACY_POLICY
)
}
export
function
useToggleTimeSelector
():
()
=>
void
{
return
useToggleModal
(
ApplicationModal
.
TIME_SELECTOR
)
}
export
function
useToggleFeatureFlags
():
()
=>
void
{
return
useToggleModal
(
ApplicationModal
.
FEATURE_FLAGS
)
}
...
...
src/state/connection/hooks.ts
View file @
1a7b86d1
import
{
CurrencyAmount
,
Token
}
from
'
@uniswap/sdk-core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
JSBI
from
'
jsbi
'
import
{
useTokenBalance
,
useTokenBalancesWithLoadingIndicator
}
from
'
lib/hooks/useCurrencyBalance
'
import
{
useTokenBalancesWithLoadingIndicator
}
from
'
lib/hooks/useCurrencyBalance
'
import
{
useMemo
}
from
'
react
'
import
{
UNI
}
from
'
../../constants/tokens
'
import
{
useAllTokens
}
from
'
../../hooks/Tokens
'
import
{
useUserUnclaimedAmount
}
from
'
../claim/hooks
'
import
{
useTotalUniEarned
}
from
'
../stake/hooks
'
export
{
default
as
useCurrencyBalance
,
...
...
@@ -27,24 +23,3 @@ export function useAllTokenBalances(): [{ [tokenAddress: string]: CurrencyAmount
const
[
balances
,
balancesIsLoading
]
=
useTokenBalancesWithLoadingIndicator
(
account
??
undefined
,
allTokensArray
)
return
[
balances
??
{},
balancesIsLoading
]
}
// get the total owned, unclaimed, and unharvested UNI for account
export
function
useAggregateUniBalance
():
CurrencyAmount
<
Token
>
|
undefined
{
const
{
account
,
chainId
}
=
useWeb3React
()
const
uni
=
chainId
?
UNI
[
chainId
]
:
undefined
const
uniBalance
:
CurrencyAmount
<
Token
>
|
undefined
=
useTokenBalance
(
account
??
undefined
,
uni
)
const
uniUnclaimed
:
CurrencyAmount
<
Token
>
|
undefined
=
useUserUnclaimedAmount
(
account
)
const
uniUnHarvested
:
CurrencyAmount
<
Token
>
|
undefined
=
useTotalUniEarned
()
if
(
!
uni
)
return
undefined
return
CurrencyAmount
.
fromRawAmount
(
uni
,
JSBI
.
add
(
JSBI
.
add
(
uniBalance
?.
quotient
??
JSBI
.
BigInt
(
0
),
uniUnclaimed
?.
quotient
??
JSBI
.
BigInt
(
0
)),
uniUnHarvested
?.
quotient
??
JSBI
.
BigInt
(
0
)
)
)
}
src/state/stake/hooks.tsx
View file @
1a7b86d1
...
...
@@ -228,22 +228,6 @@ export function useStakingInfo(pairToFilterBy?: Pair | null): StakingInfo[] {
])
}
export
function
useTotalUniEarned
():
CurrencyAmount
<
Token
>
|
undefined
{
const
{
chainId
}
=
useWeb3React
()
const
uni
=
chainId
?
UNI
[
chainId
]
:
undefined
const
stakingInfos
=
useStakingInfo
()
return
useMemo
(()
=>
{
if
(
!
uni
)
return
undefined
return
(
stakingInfos
?.
reduce
(
(
accumulator
,
stakingInfo
)
=>
accumulator
.
add
(
stakingInfo
.
earnedAmount
),
CurrencyAmount
.
fromRawAmount
(
uni
,
'
0
'
)
)
??
CurrencyAmount
.
fromRawAmount
(
uni
,
'
0
'
)
)
},
[
stakingInfos
,
uni
])
}
// based on typed value
export
function
useDerivedStakeInfo
(
typedValue
:
string
,
...
...
src/state/user/hooks.tsx
View file @
1a7b86d1
...
...
@@ -4,7 +4,6 @@ import { useWeb3React } from '@web3-react/core'
import
{
L2_CHAIN_IDS
}
from
'
constants/chains
'
import
{
SupportedLocale
}
from
'
constants/locales
'
import
{
L2_DEADLINE_FROM_NOW
}
from
'
constants/misc
'
import
useCurrentBlockTimestamp
from
'
hooks/useCurrentBlockTimestamp
'
import
JSBI
from
'
jsbi
'
import
{
useCallback
,
useMemo
}
from
'
react
'
import
{
shallowEqual
}
from
'
react-redux
'
...
...
@@ -19,7 +18,6 @@ import {
addSerializedToken
,
removeSerializedToken
,
updateHideClosedPositions
,
updateShowDonationLink
,
updateShowSurveyPopup
,
updateUserClientSideRouter
,
updateUserDarkMode
,
...
...
@@ -118,26 +116,6 @@ export function useShowSurveyPopup(): [boolean | undefined, (showPopup: boolean)
return
[
showSurveyPopup
,
toggleShowSurveyPopup
]
}
const
DONATION_END_TIMESTAMP
=
1646864954
// Jan 15th
export
function
useShowDonationLink
():
[
boolean
|
undefined
,
(
showDonationLink
:
boolean
)
=>
void
]
{
const
dispatch
=
useAppDispatch
()
const
showDonationLink
=
useAppSelector
((
state
)
=>
state
.
user
.
showDonationLink
)
const
toggleShowDonationLink
=
useCallback
(
(
showPopup
:
boolean
)
=>
{
dispatch
(
updateShowDonationLink
({
showDonationLink
:
showPopup
}))
},
[
dispatch
]
)
const
timestamp
=
useCurrentBlockTimestamp
()
const
durationOver
=
timestamp
?
timestamp
.
toNumber
()
>
DONATION_END_TIMESTAMP
:
false
const
donationVisible
=
showDonationLink
!==
false
&&
!
durationOver
return
[
donationVisible
,
toggleShowDonationLink
]
}
export
function
useClientSideRouter
():
[
boolean
,
(
userClientSideRouter
:
boolean
)
=>
void
]
{
const
dispatch
=
useAppDispatch
()
...
...
src/utils/chains.tsx
View file @
1a7b86d1
import
{
getChainInfo
,
NetworkType
}
from
'
constants/chainInfo
'
import
{
SupportedL1ChainId
,
SupportedL2ChainId
}
from
'
constants/chains
'
export
function
isL1ChainId
(
chainId
:
number
|
undefined
):
chainId
is
SupportedL1ChainId
{
const
chainInfo
=
getChainInfo
(
chainId
)
return
chainInfo
?.
networkType
===
NetworkType
.
L1
}
import
{
SupportedL2ChainId
}
from
'
constants/chains
'
export
function
isL2ChainId
(
chainId
:
number
|
undefined
):
chainId
is
SupportedL2ChainId
{
const
chainInfo
=
getChainInfo
(
chainId
)
...
...
src/utils/index.ts
View file @
1a7b86d1
...
...
@@ -3,7 +3,6 @@ import { AddressZero } from '@ethersproject/constants'
import
{
Contract
}
from
'
@ethersproject/contracts
'
import
{
JsonRpcProvider
,
JsonRpcSigner
}
from
'
@ethersproject/providers
'
import
{
Token
}
from
'
@uniswap/sdk-core
'
import
{
FeeAmount
}
from
'
@uniswap/v3-sdk
'
import
{
ChainTokenMap
}
from
'
lib/hooks/useTokenList/utils
'
// returns the checksummed address if the address is valid, otherwise returns false
...
...
@@ -50,7 +49,3 @@ export function escapeRegExp(string: string): string {
export
function
isTokenOnList
(
chainTokenMap
:
ChainTokenMap
,
token
?:
Token
):
boolean
{
return
Boolean
(
token
?.
isToken
&&
chainTokenMap
[
token
.
chainId
]?.[
token
.
address
])
}
export
function
formattedFeeAmount
(
feeAmount
:
FeeAmount
):
number
{
return
feeAmount
/
10000
}
src/utils/isTradeBetter.ts
deleted
100644 → 0
View file @
f66f8c4d
import
{
Currency
,
Percent
,
TradeType
}
from
'
@uniswap/sdk-core
'
import
{
Trade
as
V2Trade
}
from
'
@uniswap/v2-sdk
'
import
{
ONE_HUNDRED_PERCENT
,
ZERO_PERCENT
}
from
'
../constants/misc
'
// returns whether tradeB is better than tradeA by at least a threshold percentage amount
// only used by v2 hooks
export
function
isTradeBetter
(
tradeA
:
V2Trade
<
Currency
,
Currency
,
TradeType
>
|
undefined
|
null
,
tradeB
:
V2Trade
<
Currency
,
Currency
,
TradeType
>
|
undefined
|
null
,
minimumDelta
:
Percent
=
ZERO_PERCENT
):
boolean
|
undefined
{
if
(
tradeA
&&
!
tradeB
)
return
false
if
(
tradeB
&&
!
tradeA
)
return
true
if
(
!
tradeA
||
!
tradeB
)
return
undefined
if
(
tradeA
.
tradeType
!==
tradeB
.
tradeType
||
!
tradeA
.
inputAmount
.
currency
.
equals
(
tradeB
.
inputAmount
.
currency
)
||
!
tradeA
.
outputAmount
.
currency
.
equals
(
tradeB
.
outputAmount
.
currency
)
)
{
throw
new
Error
(
'
Comparing incomparable trades
'
)
}
if
(
minimumDelta
.
equalTo
(
ZERO_PERCENT
))
{
return
tradeA
.
executionPrice
.
lessThan
(
tradeB
.
executionPrice
)
}
else
{
return
tradeA
.
executionPrice
.
asFraction
.
multiply
(
minimumDelta
.
add
(
ONE_HUNDRED_PERCENT
))
.
lessThan
(
tradeB
.
executionPrice
)
}
}
src/utils/prices.ts
View file @
1a7b86d1
...
...
@@ -21,12 +21,6 @@ export function computeRealizedPriceImpact(trade: Trade<Currency, Currency, Trad
return
trade
.
priceImpact
.
subtract
(
realizedLpFeePercent
)
}
export
function
getPriceImpactWarning
(
priceImpact
?:
Percent
):
'
warning
'
|
'
error
'
|
undefined
{
if
(
priceImpact
?.
greaterThan
(
ALLOWED_PRICE_IMPACT_HIGH
))
return
'
error
'
if
(
priceImpact
?.
greaterThan
(
ALLOWED_PRICE_IMPACT_MEDIUM
))
return
'
warning
'
return
}
// computes realized lp fee as a percent
export
function
computeRealizedLPFeePercent
(
trade
:
Trade
<
Currency
,
Currency
,
TradeType
>
):
Percent
{
let
percent
:
Percent
...
...
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