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
d4c5d3e8
Unverified
Commit
d4c5d3e8
authored
May 20, 2021
by
Moody Salem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: run eslint
parent
a6e46623
Changes
31
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
143 additions
and
153 deletions
+143
-153
ListUpdatePopup.tsx
src/components/Popups/ListUpdatePopup.tsx
+5
-1
index.tsx
src/components/PositionListItem/index.tsx
+1
-3
useAddTokenToMetamask.ts
src/hooks/useAddTokenToMetamask.ts
+1
-3
useDerivedPositionInfo.ts
src/hooks/useDerivedPositionInfo.ts
+1
-3
useENS.ts
src/hooks/useENS.ts
+1
-3
useERC20Permit.ts
src/hooks/useERC20Permit.ts
+4
-4
usePositionTokenURI.ts
src/hooks/usePositionTokenURI.ts
+4
-3
useTokenAllowance.ts
src/hooks/useTokenAllowance.ts
+4
-4
useV2Pairs.ts
src/hooks/useV2Pairs.ts
+4
-3
index.tsx
src/pages/AddLiquidity/index.tsx
+2
-7
Countdown.tsx
src/pages/Earn/Countdown.tsx
+6
-5
MigrateV2Pair.tsx
src/pages/MigrateV2/MigrateV2Pair.tsx
+4
-6
PositionPage.tsx
src/pages/Pool/PositionPage.tsx
+9
-2
v2.tsx
src/pages/Pool/v2.tsx
+4
-3
index.tsx
src/pages/RemoveLiquidity/index.tsx
+12
-9
index.tsx
src/pages/Swap/index.tsx
+14
-12
actions.ts
src/state/application/actions.ts
+2
-3
hooks.ts
src/state/claim/hooks.ts
+1
-3
hooks.ts
src/state/governance/hooks.ts
+4
-3
hooks.ts
src/state/lists/hooks.ts
+4
-4
actions.ts
src/state/mint/v3/actions.ts
+2
-3
hooks.ts
src/state/mint/v3/hooks.ts
+7
-15
updater.test.ts
src/state/multicall/updater.test.ts
+3
-3
updater.tsx
src/state/multicall/updater.tsx
+4
-3
actions.ts
src/state/swap/actions.ts
+8
-7
hooks.ts
src/state/swap/hooks.ts
+3
-6
actions.ts
src/state/transactions/actions.ts
+9
-8
hooks.tsx
src/state/transactions/hooks.tsx
+1
-3
actions.ts
src/state/user/actions.ts
+2
-3
hooks.tsx
src/state/user/hooks.tsx
+12
-12
hooks.ts
src/state/wallet/hooks.ts
+5
-6
No files found.
src/components/Popups/ListUpdatePopup.tsx
View file @
d4c5d3e8
...
...
@@ -46,7 +46,11 @@ export default function ListUpdatePopup({
removeThisPopup
()
},
[
auto
,
dispatch
,
listUrl
,
removeThisPopup
])
const
{
added
:
tokensAdded
,
changed
:
tokensChanged
,
removed
:
tokensRemoved
}
=
useMemo
(()
=>
{
const
{
added
:
tokensAdded
,
changed
:
tokensChanged
,
removed
:
tokensRemoved
,
}
=
useMemo
(()
=>
{
return
diffTokenLists
(
oldList
.
tokens
,
newList
.
tokens
)
},
[
newList
.
tokens
,
oldList
.
tokens
])
const
numTokensChanged
=
useMemo
(
...
...
src/components/PositionListItem/index.tsx
View file @
d4c5d3e8
...
...
@@ -118,9 +118,7 @@ export interface PositionListItemProps {
positionDetails
:
PositionDetails
}
export
function
getPriceOrderingFromPositionForUI
(
position
?:
Position
):
{
export
function
getPriceOrderingFromPositionForUI
(
position
?:
Position
):
{
priceLower
?:
Price
<
Token
,
Token
>
priceUpper
?:
Price
<
Token
,
Token
>
quote
?:
Token
...
...
src/hooks/useAddTokenToMetamask.ts
View file @
d4c5d3e8
...
...
@@ -3,9 +3,7 @@ import { Currency, Token } from '@uniswap/sdk-core'
import
{
useCallback
,
useState
}
from
'
react
'
import
{
useActiveWeb3React
}
from
'
hooks/web3
'
export
default
function
useAddTokenToMetamask
(
currencyToAdd
:
Currency
|
undefined
):
{
export
default
function
useAddTokenToMetamask
(
currencyToAdd
:
Currency
|
undefined
):
{
addToken
:
()
=>
void
success
:
boolean
|
undefined
}
{
...
...
src/hooks/useDerivedPositionInfo.ts
View file @
d4c5d3e8
...
...
@@ -3,9 +3,7 @@ import { usePool } from 'hooks/usePools'
import
{
PositionDetails
}
from
'
types/position
'
import
{
useCurrency
}
from
'
./Tokens
'
export
function
useDerivedPositionInfo
(
positionDetails
:
PositionDetails
|
undefined
):
{
export
function
useDerivedPositionInfo
(
positionDetails
:
PositionDetails
|
undefined
):
{
position
:
Position
|
undefined
pool
:
Pool
|
undefined
}
{
...
...
src/hooks/useENS.ts
View file @
d4c5d3e8
...
...
@@ -6,9 +6,7 @@ import useENSName from './useENSName'
* Given a name or address, does a lookup to resolve to an address and name
* @param nameOrAddress ENS name or address
*/
export
default
function
useENS
(
nameOrAddress
?:
string
|
null
):
{
export
default
function
useENS
(
nameOrAddress
?:
string
|
null
):
{
loading
:
boolean
address
:
string
|
null
name
:
string
|
null
...
...
src/hooks/useERC20Permit.ts
View file @
d4c5d3e8
...
...
@@ -276,10 +276,10 @@ export function useERC20PermitFromTrade(
)
{
const
{
chainId
}
=
useActiveWeb3React
()
const
swapRouterAddress
=
chainId
?
SWAP_ROUTER_ADDRESSES
[
chainId
]
:
undefined
const
amountToApprove
=
useMemo
(
()
=>
(
trade
?
trade
.
maximumAmountIn
(
allowedSlippage
)
:
undefined
),
[
trade
,
allowedSlippage
,
]
)
const
amountToApprove
=
useMemo
(
()
=>
(
trade
?
trade
.
maximumAmountIn
(
allowedSlippage
)
:
undefined
)
,
[
trade
,
allowedSlippage
]
)
return
useERC20Permit
(
amountToApprove
,
...
...
src/hooks/usePositionTokenURI.ts
View file @
d4c5d3e8
...
...
@@ -29,9 +29,10 @@ type UsePositionTokenURIResult =
export
function
usePositionTokenURI
(
tokenId
:
TokenId
|
undefined
):
UsePositionTokenURIResult
{
const
contract
=
useV3NFTPositionManagerContract
()
const
inputs
=
useMemo
(()
=>
[
tokenId
instanceof
BigNumber
?
tokenId
.
toHexString
()
:
tokenId
?.
toString
(
16
)],
[
tokenId
,
])
const
inputs
=
useMemo
(
()
=>
[
tokenId
instanceof
BigNumber
?
tokenId
.
toHexString
()
:
tokenId
?.
toString
(
16
)],
[
tokenId
]
)
const
{
result
,
error
,
loading
,
valid
}
=
useSingleCallResult
(
contract
,
'
tokenURI
'
,
inputs
,
NEVER_RELOAD
,
1
_600_000
)
return
useMemo
(()
=>
{
...
...
src/hooks/useTokenAllowance.ts
View file @
d4c5d3e8
...
...
@@ -9,8 +9,8 @@ export function useTokenAllowance(token?: Token, owner?: string, spender?: strin
const
inputs
=
useMemo
(()
=>
[
owner
,
spender
],
[
owner
,
spender
])
const
allowance
=
useSingleCallResult
(
contract
,
'
allowance
'
,
inputs
).
result
return
useMemo
(
()
=>
(
token
&&
allowance
?
CurrencyAmount
.
fromRawAmount
(
token
,
allowance
.
toString
())
:
undefined
),
[
token
,
allowance
,
]
)
return
useMemo
(
()
=>
(
token
&&
allowance
?
CurrencyAmount
.
fromRawAmount
(
token
,
allowance
.
toString
())
:
undefined
)
,
[
token
,
allowance
]
)
}
src/hooks/useV2Pairs.ts
View file @
d4c5d3e8
...
...
@@ -15,9 +15,10 @@ export enum PairState {
}
export
function
useV2Pairs
(
currencies
:
[
Currency
|
undefined
,
Currency
|
undefined
][]):
[
PairState
,
Pair
|
null
][]
{
const
tokens
=
useMemo
(()
=>
currencies
.
map
(([
currencyA
,
currencyB
])
=>
[
currencyA
?.
wrapped
,
currencyB
?.
wrapped
]),
[
currencies
,
])
const
tokens
=
useMemo
(
()
=>
currencies
.
map
(([
currencyA
,
currencyB
])
=>
[
currencyA
?.
wrapped
,
currencyB
?.
wrapped
]),
[
currencies
]
)
const
pairAddresses
=
useMemo
(
()
=>
...
...
src/pages/AddLiquidity/index.tsx
View file @
d4c5d3e8
...
...
@@ -124,13 +124,8 @@ export default function AddLiquidity({
existingPosition
)
const
{
onFieldAInput
,
onFieldBInput
,
onLeftRangeInput
,
onRightRangeInput
,
onStartPriceInput
,
}
=
useV3MintActionHandlers
(
noLiquidity
)
const
{
onFieldAInput
,
onFieldBInput
,
onLeftRangeInput
,
onRightRangeInput
,
onStartPriceInput
}
=
useV3MintActionHandlers
(
noLiquidity
)
const
isValid
=
!
errorMessage
&&
!
invalidRange
...
...
src/pages/Earn/Countdown.tsx
View file @
d4c5d3e8
...
...
@@ -9,9 +9,10 @@ const REWARDS_DURATION = DAY * REWARDS_DURATION_DAYS
export
function
Countdown
({
exactEnd
}:
{
exactEnd
?:
Date
})
{
// get end/beginning times
const
end
=
useMemo
(()
=>
(
exactEnd
?
Math
.
floor
(
exactEnd
.
getTime
()
/
1000
)
:
STAKING_GENESIS
+
REWARDS_DURATION
),
[
exactEnd
,
])
const
end
=
useMemo
(
()
=>
(
exactEnd
?
Math
.
floor
(
exactEnd
.
getTime
()
/
1000
)
:
STAKING_GENESIS
+
REWARDS_DURATION
),
[
exactEnd
]
)
const
begin
=
useMemo
(()
=>
end
-
REWARDS_DURATION
,
[
end
])
// get current time
...
...
@@ -58,9 +59,9 @@ export function Countdown({ exactEnd }: { exactEnd?: Date }) {
{
message
}{
'
'
}
{
Number
.
isFinite
(
timeRemaining
)
&&
(
<
code
>
{
`${days}:${hours.toString().padStart(2, '0')}:${minutes
{
`${days}:${hours.toString().padStart(2, '0')}:${minutes
.toString().padStart(2, '0')}:${seconds
.toString()
.padStart(2, '0')}
:${seconds.toString().padStart(2, '0')}
`
}
.padStart(2, '0')}`
}
</
code
>
)
}
</
TYPE
.
black
>
...
...
src/pages/MigrateV2/MigrateV2Pair.tsx
View file @
d4c5d3e8
...
...
@@ -159,12 +159,10 @@ function V2PairMigration({
const
noLiquidity
=
poolState
===
PoolState
.
NOT_EXISTS
// get spot prices + price difference
const
v2SpotPrice
=
useMemo
(()
=>
new
Price
(
token0
,
token1
,
reserve0
.
quotient
,
reserve1
.
quotient
),
[
token0
,
token1
,
reserve0
,
reserve1
,
])
const
v2SpotPrice
=
useMemo
(
()
=>
new
Price
(
token0
,
token1
,
reserve0
.
quotient
,
reserve1
.
quotient
),
[
token0
,
token1
,
reserve0
,
reserve1
]
)
const
v3SpotPrice
=
poolState
===
PoolState
.
EXISTS
?
pool
?.
token0Price
:
undefined
let
priceDifferenceFraction
:
Fraction
|
undefined
=
...
...
src/pages/Pool/PositionPage.tsx
View file @
d4c5d3e8
...
...
@@ -295,8 +295,15 @@ export function PositionPage({
const
parsedTokenId
=
tokenIdFromUrl
?
BigNumber
.
from
(
tokenIdFromUrl
)
:
undefined
const
{
loading
,
position
:
positionDetails
}
=
useV3PositionFromTokenId
(
parsedTokenId
)
const
{
token0
:
token0Address
,
token1
:
token1Address
,
fee
:
feeAmount
,
liquidity
,
tickLower
,
tickUpper
,
tokenId
}
=
positionDetails
||
{}
const
{
token0
:
token0Address
,
token1
:
token1Address
,
fee
:
feeAmount
,
liquidity
,
tickLower
,
tickUpper
,
tokenId
,
}
=
positionDetails
||
{}
const
removed
=
liquidity
?.
eq
(
0
)
...
...
src/pages/Pool/v2.tsx
View file @
d4c5d3e8
...
...
@@ -85,9 +85,10 @@ export default function Pool() {
()
=>
trackedTokenPairs
.
map
((
tokens
)
=>
({
liquidityToken
:
toV2LiquidityToken
(
tokens
),
tokens
})),
[
trackedTokenPairs
]
)
const
liquidityTokens
=
useMemo
(()
=>
tokenPairsWithLiquidityTokens
.
map
((
tpwlt
)
=>
tpwlt
.
liquidityToken
),
[
tokenPairsWithLiquidityTokens
,
])
const
liquidityTokens
=
useMemo
(
()
=>
tokenPairsWithLiquidityTokens
.
map
((
tpwlt
)
=>
tpwlt
.
liquidityToken
),
[
tokenPairsWithLiquidityTokens
]
)
const
[
v2PairsBalances
,
fetchingV2PairBalances
]
=
useTokenBalancesWithLoadingIndicator
(
account
??
undefined
,
liquidityTokens
...
...
src/pages/RemoveLiquidity/index.tsx
View file @
d4c5d3e8
...
...
@@ -130,15 +130,18 @@ export default function RemoveLiquidity({
[
_onUserInput
]
)
const
onLiquidityInput
=
useCallback
((
typedValue
:
string
):
void
=>
onUserInput
(
Field
.
LIQUIDITY
,
typedValue
),
[
onUserInput
,
])
const
onCurrencyAInput
=
useCallback
((
typedValue
:
string
):
void
=>
onUserInput
(
Field
.
CURRENCY_A
,
typedValue
),
[
onUserInput
,
])
const
onCurrencyBInput
=
useCallback
((
typedValue
:
string
):
void
=>
onUserInput
(
Field
.
CURRENCY_B
,
typedValue
),
[
onUserInput
,
])
const
onLiquidityInput
=
useCallback
(
(
typedValue
:
string
):
void
=>
onUserInput
(
Field
.
LIQUIDITY
,
typedValue
),
[
onUserInput
]
)
const
onCurrencyAInput
=
useCallback
(
(
typedValue
:
string
):
void
=>
onUserInput
(
Field
.
CURRENCY_A
,
typedValue
),
[
onUserInput
]
)
const
onCurrencyBInput
=
useCallback
(
(
typedValue
:
string
):
void
=>
onUserInput
(
Field
.
CURRENCY_B
,
typedValue
),
[
onUserInput
]
)
// tx sending
const
addTransaction
=
useTransactionAdder
()
...
...
src/pages/Swap/index.tsx
View file @
d4c5d3e8
...
...
@@ -115,11 +115,11 @@ export default function Swap({ history }: RouteComponentProps) {
inputError
:
swapInputError
,
}
=
useDerivedSwapInfo
(
toggledVersion
)
const
{
wrapType
,
execute
:
onWrap
,
inputError
:
wrapInputError
}
=
useWrapCallback
(
currencies
[
Field
.
INPUT
]
,
currencies
[
Field
.
OUTPUT
]
,
typedValue
)
const
{
wrapType
,
execute
:
onWrap
,
inputError
:
wrapInputError
,
}
=
useWrapCallback
(
currencies
[
Field
.
INPUT
],
currencies
[
Field
.
OUTPUT
],
typedValue
)
const
showWrap
:
boolean
=
wrapType
!==
WrapType
.
NOT_APPLICABLE
const
{
address
:
recipientAddress
}
=
useENSAddress
(
recipient
)
...
...
@@ -194,10 +194,11 @@ export default function Swap({ history }: RouteComponentProps) {
// check whether the user has approved the router on the input token
const
[
approvalState
,
approveCallback
]
=
useApproveCallbackFromTrade
(
trade
,
allowedSlippage
)
const
{
state
:
signatureState
,
signatureData
,
gatherPermitSignature
}
=
useERC20PermitFromTrade
(
trade
,
allowedSlippage
)
const
{
state
:
signatureState
,
signatureData
,
gatherPermitSignature
,
}
=
useERC20PermitFromTrade
(
trade
,
allowedSlippage
)
const
handleApprove
=
useCallback
(
async
()
=>
{
if
(
signatureState
===
UseERC20PermitState
.
NOT_SIGNED
&&
gatherPermitSignature
)
{
...
...
@@ -334,9 +335,10 @@ export default function Swap({ history }: RouteComponentProps) {
maxInputAmount
&&
onUserInput
(
Field
.
INPUT
,
maxInputAmount
.
toExact
())
},
[
maxInputAmount
,
onUserInput
])
const
handleOutputSelect
=
useCallback
((
outputCurrency
)
=>
onCurrencySelection
(
Field
.
OUTPUT
,
outputCurrency
),
[
onCurrencySelection
,
])
const
handleOutputSelect
=
useCallback
(
(
outputCurrency
)
=>
onCurrencySelection
(
Field
.
OUTPUT
,
outputCurrency
),
[
onCurrencySelection
]
)
const
swapIsUnsupported
=
useIsSwapUnsupported
(
currencies
?.
INPUT
,
currencies
?.
OUTPUT
)
...
...
src/state/application/actions.ts
View file @
d4c5d3e8
...
...
@@ -32,7 +32,6 @@ export enum ApplicationModal {
export
const
updateBlockNumber
=
createAction
<
{
chainId
:
number
;
blockNumber
:
number
}
>
(
'
application/updateBlockNumber
'
)
export
const
setOpenModal
=
createAction
<
ApplicationModal
|
null
>
(
'
application/setOpenModal
'
)
export
const
addPopup
=
createAction
<
{
key
?:
string
;
removeAfterMs
?:
number
|
null
;
content
:
PopupContent
}
>
(
'
application/addPopup
'
)
export
const
addPopup
=
createAction
<
{
key
?:
string
;
removeAfterMs
?:
number
|
null
;
content
:
PopupContent
}
>
(
'
application/addPopup
'
)
export
const
removePopup
=
createAction
<
{
key
:
string
}
>
(
'
application/removePopup
'
)
src/state/claim/hooks.ts
View file @
d4c5d3e8
...
...
@@ -88,9 +88,7 @@ export function useUserUnclaimedAmount(account: string | null | undefined): Curr
return
CurrencyAmount
.
fromRawAmount
(
uni
,
JSBI
.
BigInt
(
userClaimData
.
amount
))
}
export
function
useClaimCallback
(
account
:
string
|
null
|
undefined
):
{
export
function
useClaimCallback
(
account
:
string
|
null
|
undefined
):
{
claimCallback
:
()
=>
Promise
<
string
>
}
{
// get claim data for this account
...
...
src/state/governance/hooks.ts
View file @
d4c5d3e8
...
...
@@ -64,9 +64,10 @@ export function useDataFromEventLogs() {
const
govContract
=
useGovernanceContract
()
// create filter for these specific events
const
filter
=
useMemo
(()
=>
({
...
govContract
?.
filters
?.[
'
ProposalCreated
'
](),
fromBlock
:
0
,
toBlock
:
'
latest
'
}),
[
govContract
,
])
const
filter
=
useMemo
(
()
=>
({
...
govContract
?.
filters
?.[
'
ProposalCreated
'
](),
fromBlock
:
0
,
toBlock
:
'
latest
'
}),
[
govContract
]
)
useEffect
(()
=>
{
async
function
fetchData
()
{
...
...
src/state/lists/hooks.ts
View file @
d4c5d3e8
...
...
@@ -109,10 +109,10 @@ export function useUnsupportedTokenList(): TokenAddressMap {
const
loadedUnsupportedListMap
=
useCombinedTokenMapFromUrls
(
UNSUPPORTED_LIST_URLS
)
// format into one token address map
return
useMemo
(
()
=>
combineMaps
(
localUnsupportedListMap
,
loadedUnsupportedListMap
),
[
localUnsupportedListMap
,
loadedUnsupportedListMap
,
]
)
return
useMemo
(
()
=>
combineMaps
(
localUnsupportedListMap
,
loadedUnsupportedListMap
)
,
[
localUnsupportedListMap
,
loadedUnsupportedListMap
]
)
}
export
function
useIsListActive
(
url
:
string
):
boolean
{
...
...
src/state/mint/v3/actions.ts
View file @
d4c5d3e8
...
...
@@ -10,9 +10,8 @@ export enum Bound {
UPPER
=
'
UPPER
'
,
}
export
const
typeInput
=
createAction
<
{
field
:
Field
;
typedValue
:
string
;
noLiquidity
:
boolean
}
>
(
'
mintV3/typeInputMint
'
)
export
const
typeInput
=
createAction
<
{
field
:
Field
;
typedValue
:
string
;
noLiquidity
:
boolean
}
>
(
'
mintV3/typeInputMint
'
)
export
const
typeStartPriceInput
=
createAction
<
{
typedValue
:
string
}
>
(
'
mintV3/typeStartPriceInput
'
)
export
const
typeLeftRangeInput
=
createAction
<
{
typedValue
:
string
}
>
(
'
mintV3/typeLeftRangeInput
'
)
export
const
typeRightRangeInput
=
createAction
<
{
typedValue
:
string
}
>
(
'
mintV3/typeRightRangeInput
'
)
...
...
src/state/mint/v3/hooks.ts
View file @
d4c5d3e8
...
...
@@ -27,9 +27,7 @@ export function useV3MintState(): AppState['mintV3'] {
return
useSelector
<
AppState
,
AppState
[
'
mintV3
'
]
>
((
state
)
=>
state
.
mintV3
)
}
export
function
useV3MintActionHandlers
(
noLiquidity
:
boolean
|
undefined
):
{
export
function
useV3MintActionHandlers
(
noLiquidity
:
boolean
|
undefined
):
{
onFieldAInput
:
(
typedValue
:
string
)
=>
void
onFieldBInput
:
(
typedValue
:
string
)
=>
void
onLeftRangeInput
:
(
typedValue
:
string
)
=>
void
...
...
@@ -113,13 +111,8 @@ export function useV3DerivedMintInfo(
}
{
const
{
account
}
=
useActiveWeb3React
()
const
{
independentField
,
typedValue
,
leftRangeTypedValue
,
rightRangeTypedValue
,
startPriceTypedValue
,
}
=
useV3MintState
()
const
{
independentField
,
typedValue
,
leftRangeTypedValue
,
rightRangeTypedValue
,
startPriceTypedValue
}
=
useV3MintState
()
const
dependentField
=
independentField
===
Field
.
CURRENCY_A
?
Field
.
CURRENCY_B
:
Field
.
CURRENCY_A
...
...
@@ -133,11 +126,10 @@ export function useV3DerivedMintInfo(
)
// formatted with tokens
const
[
tokenA
,
tokenB
,
baseToken
]
=
useMemo
(()
=>
[
currencyA
?.
wrapped
,
currencyB
?.
wrapped
,
baseCurrency
?.
wrapped
],
[
currencyA
,
currencyB
,
baseCurrency
,
])
const
[
tokenA
,
tokenB
,
baseToken
]
=
useMemo
(
()
=>
[
currencyA
?.
wrapped
,
currencyB
?.
wrapped
,
baseCurrency
?.
wrapped
],
[
currencyA
,
currencyB
,
baseCurrency
]
)
const
[
token0
,
token1
]
=
useMemo
(
()
=>
...
...
src/state/multicall/updater.test.ts
View file @
d4c5d3e8
...
...
@@ -128,9 +128,9 @@ describe('multicall updater', () => {
expect
(
outdatedListeningKeys
({},
{
abc
:
2
,
def
:
3
},
1
,
1
)).
toEqual
([
'
abc
'
,
'
def
'
])
})
it
(
'
returns only outdated keys
'
,
()
=>
{
expect
(
outdatedListeningKeys
({
[
1
]:
{
abc
:
{
data
:
'
0x
'
,
blockNumber
:
2
}
}
},
{
abc
:
1
,
def
:
1
},
1
,
2
)
)
.
toEqual
([
'
def
'
])
expect
(
outdatedListeningKeys
({
[
1
]:
{
abc
:
{
data
:
'
0x
'
,
blockNumber
:
2
}
}
},
{
abc
:
1
,
def
:
1
},
1
,
2
)).
toEqual
(
[
'
def
'
]
)
})
it
(
'
returns only keys not being fetched
'
,
()
=>
{
expect
(
...
...
src/state/multicall/updater.tsx
View file @
d4c5d3e8
...
...
@@ -134,9 +134,10 @@ export default function Updater(): null {
return
outdatedListeningKeys
(
state
.
callResults
,
listeningKeys
,
chainId
,
latestBlockNumber
)
},
[
chainId
,
state
.
callResults
,
listeningKeys
,
latestBlockNumber
])
const
serializedOutdatedCallKeys
=
useMemo
(()
=>
JSON
.
stringify
(
unserializedOutdatedCallKeys
.
sort
()),
[
unserializedOutdatedCallKeys
,
])
const
serializedOutdatedCallKeys
=
useMemo
(
()
=>
JSON
.
stringify
(
unserializedOutdatedCallKeys
.
sort
()),
[
unserializedOutdatedCallKeys
]
)
useEffect
(()
=>
{
if
(
!
latestBlockNumber
||
!
chainId
||
!
multicall2Contract
)
return
...
...
src/state/swap/actions.ts
View file @
d4c5d3e8
...
...
@@ -8,11 +8,12 @@ export enum Field {
export
const
selectCurrency
=
createAction
<
{
field
:
Field
;
currencyId
:
string
}
>
(
'
swap/selectCurrency
'
)
export
const
switchCurrencies
=
createAction
<
void
>
(
'
swap/switchCurrencies
'
)
export
const
typeInput
=
createAction
<
{
field
:
Field
;
typedValue
:
string
}
>
(
'
swap/typeInput
'
)
export
const
replaceSwapState
=
createAction
<
{
field
:
Field
typedValue
:
string
inputCurrencyId
?:
string
outputCurrencyId
?:
string
recipient
:
string
|
null
}
>
(
'
swap/replaceSwapState
'
)
export
const
replaceSwapState
=
createAction
<
{
field
:
Field
typedValue
:
string
inputCurrencyId
?:
string
outputCurrencyId
?:
string
recipient
:
string
|
null
}
>
(
'
swap/replaceSwapState
'
)
export
const
setRecipient
=
createAction
<
{
recipient
:
string
|
null
}
>
(
'
swap/setRecipient
'
)
src/state/swap/hooks.ts
View file @
d4c5d3e8
...
...
@@ -113,9 +113,7 @@ function involvesAddress(
}
// from the current swap inputs, compute the best trade and return it.
export
function
useDerivedSwapInfo
(
toggledVersion
:
Version
):
{
export
function
useDerivedSwapInfo
(
toggledVersion
:
Version
):
{
currencies
:
{
[
field
in
Field
]?:
Currency
}
currencyBalances
:
{
[
field
in
Field
]?:
CurrencyAmount
<
Currency
>
}
parsedAmount
:
CurrencyAmount
<
Currency
>
|
undefined
...
...
@@ -282,9 +280,8 @@ export function useDefaultsFromURLSearch():
const
{
chainId
}
=
useActiveWeb3React
()
const
dispatch
=
useDispatch
<
AppDispatch
>
()
const
parsedQs
=
useParsedQueryString
()
const
[
result
,
setResult
]
=
useState
<
{
inputCurrencyId
:
string
|
undefined
;
outputCurrencyId
:
string
|
undefined
}
|
undefined
>
()
const
[
result
,
setResult
]
=
useState
<
{
inputCurrencyId
:
string
|
undefined
;
outputCurrencyId
:
string
|
undefined
}
|
undefined
>
()
useEffect
(()
=>
{
if
(
!
chainId
)
return
...
...
src/state/transactions/actions.ts
View file @
d4c5d3e8
...
...
@@ -11,14 +11,15 @@ export interface SerializableTransactionReceipt {
status
?:
number
}
export
const
addTransaction
=
createAction
<
{
chainId
:
number
hash
:
string
from
:
string
approval
?:
{
tokenAddress
:
string
;
spender
:
string
}
claim
?:
{
recipient
:
string
}
summary
?:
string
}
>
(
'
transactions/addTransaction
'
)
export
const
addTransaction
=
createAction
<
{
chainId
:
number
hash
:
string
from
:
string
approval
?:
{
tokenAddress
:
string
;
spender
:
string
}
claim
?:
{
recipient
:
string
}
summary
?:
string
}
>
(
'
transactions/addTransaction
'
)
export
const
clearAllTransactions
=
createAction
<
{
chainId
:
number
}
>
(
'
transactions/clearAllTransactions
'
)
export
const
finalizeTransaction
=
createAction
<
{
chainId
:
number
...
...
src/state/transactions/hooks.tsx
View file @
d4c5d3e8
...
...
@@ -86,9 +86,7 @@ export function useHasPendingApproval(tokenAddress: string | undefined, spender:
// watch for submissions to claim
// return null if not done loading, return undefined if not found
export
function
useUserHasSubmittedClaim
(
account
?:
string
):
{
export
function
useUserHasSubmittedClaim
(
account
?:
string
):
{
claimSubmitted
:
boolean
claimTxn
:
TransactionDetails
|
undefined
}
{
...
...
src/state/user/actions.ts
View file @
d4c5d3e8
...
...
@@ -24,7 +24,6 @@ export const updateUserDeadline = createAction<{ userDeadline: number }>('user/u
export
const
addSerializedToken
=
createAction
<
{
serializedToken
:
SerializedToken
}
>
(
'
user/addSerializedToken
'
)
export
const
removeSerializedToken
=
createAction
<
{
chainId
:
number
;
address
:
string
}
>
(
'
user/removeSerializedToken
'
)
export
const
addSerializedPair
=
createAction
<
{
serializedPair
:
SerializedPair
}
>
(
'
user/addSerializedPair
'
)
export
const
removeSerializedPair
=
createAction
<
{
chainId
:
number
;
tokenAAddress
:
string
;
tokenBAddress
:
string
}
>
(
'
user/removeSerializedPair
'
)
export
const
removeSerializedPair
=
createAction
<
{
chainId
:
number
;
tokenAAddress
:
string
;
tokenBAddress
:
string
}
>
(
'
user/removeSerializedPair
'
)
export
const
toggleURLWarning
=
createAction
<
void
>
(
'
app/toggleURLWarning
'
)
src/state/user/hooks.tsx
View file @
d4c5d3e8
...
...
@@ -131,9 +131,10 @@ export function useUserSlippageTolerance(): Percent | 'auto' {
return
state
.
user
.
userSlippageTolerance
})
return
useMemo
(()
=>
(
userSlippageTolerance
===
'
auto
'
?
'
auto
'
:
new
Percent
(
userSlippageTolerance
,
10
_000
)),
[
userSlippageTolerance
,
])
return
useMemo
(
()
=>
(
userSlippageTolerance
===
'
auto
'
?
'
auto
'
:
new
Percent
(
userSlippageTolerance
,
10
_000
)),
[
userSlippageTolerance
]
)
}
/**
...
...
@@ -142,10 +143,10 @@ export function useUserSlippageTolerance(): Percent | 'auto' {
*/
export
function
useUserSlippageToleranceWithDefault
(
defaultSlippageTolerance
:
Percent
):
Percent
{
const
allowedSlippage
=
useUserSlippageTolerance
()
return
useMemo
(
()
=>
(
allowedSlippage
===
'
auto
'
?
defaultSlippageTolerance
:
allowedSlippage
),
[
allowedSlippage
,
defaultSlippageTolerance
,
]
)
return
useMemo
(
()
=>
(
allowedSlippage
===
'
auto
'
?
defaultSlippageTolerance
:
allowedSlippage
)
,
[
allowedSlippage
,
defaultSlippageTolerance
]
)
}
export
function
useUserTransactionTTL
():
[
number
,
(
slippage
:
number
)
=>
void
]
{
...
...
@@ -278,11 +279,10 @@ export function useTrackedTokenPairs(): [Token, Token][] {
})
},
[
savedSerializedPairs
,
chainId
])
const
combinedList
=
useMemo
(()
=>
userPairs
.
concat
(
generatedPairs
).
concat
(
pinnedPairs
),
[
generatedPairs
,
pinnedPairs
,
userPairs
,
])
const
combinedList
=
useMemo
(
()
=>
userPairs
.
concat
(
generatedPairs
).
concat
(
pinnedPairs
),
[
generatedPairs
,
pinnedPairs
,
userPairs
]
)
return
useMemo
(()
=>
{
// dedupes pairs of tokens in the combined list
...
...
src/state/wallet/hooks.ts
View file @
d4c5d3e8
...
...
@@ -15,9 +15,7 @@ import { Erc20Interface } from 'abis/types/Erc20'
/**
* Returns a map of the given addresses to their eventually consistent ETH balances.
*/
export
function
useETHBalances
(
uncheckedAddresses
?:
(
string
|
undefined
)[]
):
{
export
function
useETHBalances
(
uncheckedAddresses
?:
(
string
|
undefined
)[]):
{
[
address
:
string
]:
CurrencyAmount
<
Currency
>
|
undefined
}
{
const
{
chainId
}
=
useActiveWeb3React
()
...
...
@@ -113,9 +111,10 @@ export function useCurrencyBalances(
account
?:
string
,
currencies
?:
(
Currency
|
undefined
)[]
):
(
CurrencyAmount
<
Currency
>
|
undefined
)[]
{
const
tokens
=
useMemo
(()
=>
currencies
?.
filter
((
currency
):
currency
is
Token
=>
currency
?.
isToken
??
false
)
??
[],
[
currencies
,
])
const
tokens
=
useMemo
(
()
=>
currencies
?.
filter
((
currency
):
currency
is
Token
=>
currency
?.
isToken
??
false
)
??
[],
[
currencies
]
)
const
tokenBalances
=
useTokenBalances
(
account
,
tokens
)
const
containsETH
:
boolean
=
useMemo
(()
=>
currencies
?.
some
((
currency
)
=>
currency
?.
isNative
)
??
false
,
[
currencies
])
...
...
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