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
b14da284
Unverified
Commit
b14da284
authored
May 19, 2021
by
Moody Salem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: remove all tick lens stuff that is not used
parent
d3c04b72
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1 addition
and
122 deletions
+1
-122
addresses.ts
src/constants/addresses.ts
+0
-1
useAllV3Ticks.ts
src/hooks/useAllV3Ticks.ts
+0
-113
useContract.ts
src/hooks/useContract.ts
+1
-7
useV2Trade.ts
src/hooks/useV2Trade.ts
+0
-1
No files found.
src/constants/addresses.ts
View file @
b14da284
...
...
@@ -15,7 +15,6 @@ export const ARGENT_WALLET_DETECTOR_ADDRESS: { [chainId in ChainId]?: string } =
}
export
const
V3_CORE_FACTORY_ADDRESSES
=
constructSameAddressMap
(
V3_FACTORY_ADDRESS
)
export
const
QUOTER_ADDRESSES
=
constructSameAddressMap
(
'
0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6
'
)
export
const
TICK_LENS_ADDRESSES
=
constructSameAddressMap
(
'
0xbfd8137f7d1516D3ea5cA83523914859ec47F573
'
)
export
const
NONFUNGIBLE_POSITION_MANAGER_ADDRESSES
=
constructSameAddressMap
(
'
0xC36442b4a4522E871399CD717aBDD847Ab11FE88
'
)
...
...
src/hooks/useAllV3Ticks.ts
deleted
100644 → 0
View file @
d3c04b72
import
{
Token
}
from
'
@uniswap/sdk-core
'
import
{
FeeAmount
,
TICK_SPACINGS
}
from
'
@uniswap/v3-sdk
'
import
{
nearestUsableTick
,
TickMath
}
from
'
@uniswap/v3-sdk/dist/
'
import
{
ZERO_ADDRESS
}
from
'
../constants/misc
'
import
{
useEffect
,
useMemo
,
useState
}
from
'
react
'
import
{
Result
,
useSingleCallResult
,
useSingleContractMultipleData
}
from
'
state/multicall/hooks
'
import
{
useTickLens
,
useV3Factory
}
from
'
./useContract
'
function
bitmapIndex
(
tick
:
number
,
tickSpacing
:
number
)
{
return
Math
.
floor
(
tick
/
tickSpacing
/
256
)
}
const
REFRESH_FREQUENCY
=
{
blocksPerFetch
:
2
}
interface
TickData
{
tick
:
number
liquidityNet
:
number
liquidityGross
:
number
}
// for now, reconsider using this function, it consumes a lot of data and cpu to fetch all the ticks.
export
function
useAllV3Ticks
(
token0
:
Token
|
undefined
,
token1
:
Token
|
undefined
,
feeAmount
:
FeeAmount
|
undefined
):
{
loading
:
boolean
syncing
:
boolean
error
:
boolean
valid
:
boolean
tickData
:
TickData
[]
}
{
const
tickSpacing
=
feeAmount
&&
TICK_SPACINGS
[
feeAmount
]
const
minIndex
=
useMemo
(
()
=>
(
tickSpacing
?
bitmapIndex
(
nearestUsableTick
(
TickMath
.
MIN_TICK
,
tickSpacing
),
tickSpacing
)
:
undefined
),
[
tickSpacing
]
)
const
maxIndex
=
useMemo
(
()
=>
(
tickSpacing
?
bitmapIndex
(
nearestUsableTick
(
TickMath
.
MAX_TICK
,
tickSpacing
),
tickSpacing
)
:
undefined
),
[
tickSpacing
]
)
const
[
tickDataLatestSynced
,
setTickDataLatestSynced
]
=
useState
<
TickData
[]
>
([])
// fetch the pool address
const
factoryContract
=
useV3Factory
()
const
poolAddress
=
useSingleCallResult
(
factoryContract
,
'
getPool
'
,
[
token0
?.
address
,
token1
?.
address
,
feeAmount
])
.
result
?.[
0
]
const
tickLensArgs
:
[
string
,
number
][]
=
useMemo
(
()
=>
maxIndex
&&
minIndex
&&
poolAddress
&&
poolAddress
!==
ZERO_ADDRESS
?
new
Array
(
maxIndex
-
minIndex
+
1
)
.
fill
(
0
)
.
map
((
_
,
i
)
=>
i
+
minIndex
)
.
map
((
wordIndex
)
=>
[
poolAddress
,
wordIndex
])
:
[],
[
minIndex
,
maxIndex
,
poolAddress
]
)
const
tickLens
=
useTickLens
()
const
callStates
=
useSingleContractMultipleData
(
tickLensArgs
.
length
>
0
?
tickLens
:
undefined
,
'
getPopulatedTicksInWord
'
,
tickLensArgs
,
REFRESH_FREQUENCY
,
3
_000_000
)
const
error
=
useMemo
(()
=>
callStates
.
some
(({
error
})
=>
error
),
[
callStates
])
const
loading
=
useMemo
(()
=>
callStates
.
some
(({
loading
})
=>
loading
),
[
callStates
])
const
syncing
=
useMemo
(()
=>
callStates
.
some
(({
syncing
})
=>
syncing
),
[
callStates
])
const
valid
=
useMemo
(()
=>
callStates
.
some
(({
valid
})
=>
valid
),
[
callStates
])
const
tickData
=
useMemo
(
()
=>
callStates
.
map
(({
result
})
=>
(
result
as
Result
)?.
populatedTicks
)
.
reduce
(
(
accumulator
,
current
)
=>
[
...
accumulator
,
...(
current
?.
map
((
tickData
:
TickData
)
=>
{
return
{
tick
:
tickData
.
tick
,
liquidityNet
:
tickData
.
liquidityNet
,
liquidityGross
:
tickData
.
liquidityGross
,
}
})
??
[]),
],
[]
),
[
callStates
]
)
// return the latest synced tickdata even if we are still loading the newest data
useEffect
(()
=>
{
if
(
!
syncing
&&
!
loading
&&
!
error
&&
valid
)
{
setTickDataLatestSynced
(
tickData
)
}
},
[
error
,
loading
,
syncing
,
tickData
,
valid
])
return
useMemo
(
()
=>
({
loading
,
syncing
,
error
,
valid
,
tickData
:
tickDataLatestSynced
,
}),
[
loading
,
syncing
,
error
,
valid
,
tickDataLatestSynced
]
)
}
src/hooks/useContract.ts
View file @
b14da284
...
...
@@ -9,7 +9,6 @@ import { abi as V3FactoryABI } from '@uniswap/v3-core/artifacts/contracts/Uniswa
import
{
abi
as
V3PoolABI
}
from
'
@uniswap/v3-core/artifacts/contracts/UniswapV3Pool.sol/UniswapV3Pool.json
'
import
{
abi
as
QuoterABI
}
from
'
@uniswap/v3-periphery/artifacts/contracts/lens/Quoter.sol/Quoter.json
'
import
{
abi
as
V2MigratorABI
}
from
'
@uniswap/v3-periphery/artifacts/contracts/V3Migrator.sol/V3Migrator.json
'
import
{
abi
as
TickLensABI
}
from
'
@uniswap/v3-periphery/artifacts/contracts/lens/TickLens.sol/TickLens.json
'
import
{
abi
as
IUniswapV2Router02ABI
}
from
'
@uniswap/v2-periphery/build/IUniswapV2Router02.json
'
import
ARGENT_WALLET_DETECTOR_ABI
from
'
abis/argent-wallet-detector.json
'
...
...
@@ -26,7 +25,6 @@ import EIP_2612 from 'abis/eip_2612.json'
import
{
NONFUNGIBLE_POSITION_MANAGER_ADDRESSES
,
QUOTER_ADDRESSES
,
TICK_LENS_ADDRESSES
,
V3_CORE_FACTORY_ADDRESSES
,
V3_MIGRATOR_ADDRESSES
,
ARGENT_WALLET_DETECTOR_ADDRESS
,
...
...
@@ -39,7 +37,7 @@ import {
}
from
'
constants/addresses
'
import
{
abi
as
NFTPositionManagerABI
}
from
'
@uniswap/v3-periphery/artifacts/contracts/NonfungiblePositionManager.sol/NonfungiblePositionManager.json
'
import
{
useMemo
}
from
'
react
'
import
{
Quoter
,
TickLens
,
UniswapV3Factory
,
UniswapV3Pool
}
from
'
types/v3
'
import
{
Quoter
,
UniswapV3Factory
,
UniswapV3Pool
}
from
'
types/v3
'
import
{
NonfungiblePositionManager
}
from
'
types/v3/NonfungiblePositionManager
'
import
{
V3Migrator
}
from
'
types/v3/V3Migrator
'
import
{
getContract
}
from
'
utils
'
...
...
@@ -155,7 +153,3 @@ export function useV3Pool(address: string | undefined) {
export
function
useV3Quoter
()
{
return
useContract
<
Quoter
>
(
QUOTER_ADDRESSES
,
QuoterABI
)
}
export
function
useTickLens
():
TickLens
|
null
{
return
useContract
<
TickLens
>
(
TICK_LENS_ADDRESSES
,
TickLensABI
)
}
src/hooks/useV2Trade.ts
View file @
b14da284
import
{
Currency
,
CurrencyAmount
,
TradeType
}
from
'
@uniswap/sdk-core
'
import
{
Pair
,
Trade
}
from
'
@uniswap/v2-sdk
'
import
{
useMemo
}
from
'
react
'
import
{
useUserSingleHopOnly
}
from
'
state/user/hooks
'
import
{
isTradeBetter
}
from
'
utils/isTradeBetter
'
import
{
BETTER_TRADE_LESS_HOPS_THRESHOLD
}
from
'
../constants/misc
'
import
{
useAllCurrencyCombinations
}
from
'
./useAllCurrencyCombinations
'
...
...
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