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
a4a954c8
Unverified
Commit
a4a954c8
authored
Feb 15, 2023
by
Jordan Frankfurt
Committed by
GitHub
Feb 15, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: update subgraph query to actually fetch all tick data (#5982)
parent
82dcdcec
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
9 deletions
+34
-9
types-and-hooks.ts
src/graphql/data/__generated__/types-and-hooks.ts
+5
-1
AllV3TicksQuery.ts
src/graphql/thegraph/AllV3TicksQuery.ts
+1
-1
usePoolTickData.ts
src/hooks/usePoolTickData.ts
+28
-7
No files found.
src/graphql/data/__generated__/types-and-hooks.ts
View file @
a4a954c8
...
@@ -83,7 +83,8 @@ export enum Chain {
...
@@ -83,7 +83,8 @@ export enum Chain {
Ethereum
=
'
ETHEREUM
'
,
Ethereum
=
'
ETHEREUM
'
,
EthereumGoerli
=
'
ETHEREUM_GOERLI
'
,
EthereumGoerli
=
'
ETHEREUM_GOERLI
'
,
Optimism
=
'
OPTIMISM
'
,
Optimism
=
'
OPTIMISM
'
,
Polygon
=
'
POLYGON
'
Polygon
=
'
POLYGON
'
,
UnknownChain
=
'
UNKNOWN_CHAIN
'
}
}
export
type
ContractInput
=
{
export
type
ContractInput
=
{
...
@@ -632,9 +633,12 @@ export type QueryNftBalancesArgs = {
...
@@ -632,9 +633,12 @@ export type QueryNftBalancesArgs = {
after
?:
InputMaybe
<
Scalars
[
'
String
'
]
>
;
after
?:
InputMaybe
<
Scalars
[
'
String
'
]
>
;
before
?:
InputMaybe
<
Scalars
[
'
String
'
]
>
;
before
?:
InputMaybe
<
Scalars
[
'
String
'
]
>
;
chain
?:
InputMaybe
<
Chain
>
;
chain
?:
InputMaybe
<
Chain
>
;
cursor
?:
InputMaybe
<
Scalars
[
'
String
'
]
>
;
datasource
?:
InputMaybe
<
DatasourceProvider
>
;
filter
?:
InputMaybe
<
NftBalancesFilterInput
>
;
filter
?:
InputMaybe
<
NftBalancesFilterInput
>
;
first
?:
InputMaybe
<
Scalars
[
'
Int
'
]
>
;
first
?:
InputMaybe
<
Scalars
[
'
Int
'
]
>
;
last
?:
InputMaybe
<
Scalars
[
'
Int
'
]
>
;
last
?:
InputMaybe
<
Scalars
[
'
Int
'
]
>
;
limit
?:
InputMaybe
<
Scalars
[
'
Int
'
]
>
;
ownerAddress
:
Scalars
[
'
String
'
];
ownerAddress
:
Scalars
[
'
String
'
];
};
};
...
...
src/graphql/thegraph/AllV3TicksQuery.ts
View file @
a4a954c8
...
@@ -24,7 +24,7 @@ export default function useAllV3TicksQuery(poolAddress: string | undefined, skip
...
@@ -24,7 +24,7 @@ export default function useAllV3TicksQuery(poolAddress: string | undefined, skip
data
,
data
,
loading
:
isLoading
,
loading
:
isLoading
,
error
,
error
,
}
=
useQuery
(
query
,
{
}
=
useQuery
<
Record
<
'
ticks
'
,
Ticks
>>
(
query
,
{
variables
:
{
variables
:
{
poolAddress
:
poolAddress
?.
toLowerCase
(),
poolAddress
:
poolAddress
?.
toLowerCase
(),
skip
,
skip
,
...
...
src/hooks/usePoolTickData.ts
View file @
a4a954c8
...
@@ -3,7 +3,7 @@ import { FeeAmount, nearestUsableTick, Pool, TICK_SPACINGS, tickToPrice } from '
...
@@ -3,7 +3,7 @@ import { FeeAmount, nearestUsableTick, Pool, TICK_SPACINGS, tickToPrice } from '
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
SupportedChainId
}
from
'
constants/chains
'
import
{
SupportedChainId
}
from
'
constants/chains
'
import
{
ZERO_ADDRESS
}
from
'
constants/misc
'
import
{
ZERO_ADDRESS
}
from
'
constants/misc
'
import
useAllV3TicksQuery
,
{
TickData
}
from
'
graphql/thegraph/AllV3TicksQuery
'
import
useAllV3TicksQuery
,
{
TickData
,
Ticks
}
from
'
graphql/thegraph/AllV3TicksQuery
'
import
JSBI
from
'
jsbi
'
import
JSBI
from
'
jsbi
'
import
{
useSingleContractMultipleData
}
from
'
lib/hooks/multicall
'
import
{
useSingleContractMultipleData
}
from
'
lib/hooks/multicall
'
import
ms
from
'
ms.macro
'
import
ms
from
'
ms.macro
'
...
@@ -140,7 +140,8 @@ function useTicksFromTickLens(
...
@@ -140,7 +140,8 @@ function useTicksFromTickLens(
function
useTicksFromSubgraph
(
function
useTicksFromSubgraph
(
currencyA
:
Currency
|
undefined
,
currencyA
:
Currency
|
undefined
,
currencyB
:
Currency
|
undefined
,
currencyB
:
Currency
|
undefined
,
feeAmount
:
FeeAmount
|
undefined
feeAmount
:
FeeAmount
|
undefined
,
skip
=
0
)
{
)
{
const
{
chainId
}
=
useWeb3React
()
const
{
chainId
}
=
useWeb3React
()
const
poolAddress
=
const
poolAddress
=
...
@@ -154,9 +155,10 @@ function useTicksFromSubgraph(
...
@@ -154,9 +155,10 @@ function useTicksFromSubgraph(
)
)
:
undefined
:
undefined
return
useAllV3TicksQuery
(
poolAddress
,
0
,
ms
`30s`
)
return
useAllV3TicksQuery
(
poolAddress
,
skip
,
ms
`30s`
)
}
}
const
MAX_THE_GRAPH_TICK_FETCH_VALUE
=
1000
// Fetches all ticks for a given pool
// Fetches all ticks for a given pool
function
useAllV3Ticks
(
function
useAllV3Ticks
(
currencyA
:
Currency
|
undefined
,
currencyA
:
Currency
|
undefined
,
...
@@ -170,12 +172,31 @@ function useAllV3Ticks(
...
@@ -170,12 +172,31 @@ function useAllV3Ticks(
const
useSubgraph
=
currencyA
?
!
CHAIN_IDS_MISSING_SUBGRAPH_DATA
.
includes
(
currencyA
.
chainId
)
:
true
const
useSubgraph
=
currencyA
?
!
CHAIN_IDS_MISSING_SUBGRAPH_DATA
.
includes
(
currencyA
.
chainId
)
:
true
const
tickLensTickData
=
useTicksFromTickLens
(
!
useSubgraph
?
currencyA
:
undefined
,
currencyB
,
feeAmount
)
const
tickLensTickData
=
useTicksFromTickLens
(
!
useSubgraph
?
currencyA
:
undefined
,
currencyB
,
feeAmount
)
const
subgraphTickData
=
useTicksFromSubgraph
(
useSubgraph
?
currencyA
:
undefined
,
currencyB
,
feeAmount
)
const
[
skipNumber
,
setSkipNumber
]
=
useState
(
0
)
const
[
subgraphTickData
,
setSubgraphTickData
]
=
useState
<
Ticks
>
([])
const
{
data
,
error
,
isLoading
}
=
useTicksFromSubgraph
(
useSubgraph
?
currencyA
:
undefined
,
currencyB
,
feeAmount
,
skipNumber
)
useEffect
(()
=>
{
if
(
data
?.
ticks
.
length
)
{
setSubgraphTickData
((
tickData
)
=>
[...
tickData
,
...
data
.
ticks
])
if
(
data
.
ticks
.
length
===
MAX_THE_GRAPH_TICK_FETCH_VALUE
)
{
setSkipNumber
((
skipNumber
)
=>
skipNumber
+
MAX_THE_GRAPH_TICK_FETCH_VALUE
)
}
}
},
[
data
?.
ticks
])
return
{
return
{
isLoading
:
useSubgraph
?
subgraphTickData
.
isLoading
:
tickLensTickData
.
isLoading
,
isLoading
:
useSubgraph
error
:
useSubgraph
?
subgraphTickData
.
error
:
tickLensTickData
.
isError
,
?
isLoading
||
data
?.
ticks
.
length
===
MAX_THE_GRAPH_TICK_FETCH_VALUE
ticks
:
useSubgraph
?
subgraphTickData
.
data
?.
ticks
:
tickLensTickData
.
tickData
,
:
tickLensTickData
.
isLoading
,
error
:
useSubgraph
?
error
:
tickLensTickData
.
isError
,
ticks
:
useSubgraph
?
subgraphTickData
:
tickLensTickData
.
tickData
,
}
}
}
}
...
...
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