Skip to content

Commit

Permalink
chore(ecplore): handle cache
Browse files Browse the repository at this point in the history
  • Loading branch information
yannamsellem committed May 17, 2024
1 parent 0e430f2 commit 520f80c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ export function useTopPoolsFromTokenQuery(token: string, skip = false) {
offset: '0',
},
skip,
context: {
headers: {
'Cache-control': 'max-age=1800',
'X-Agnostic-Cache-Refresh-Trigger': '0.9',
},
},
})

const offsetRef = useRef(20)
Expand Down
10 changes: 9 additions & 1 deletion apps/web/src/graphql/agnostic/pools/useTopPools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,15 @@ function transform(data?: AgnosticTopPoolResult): TopV3PoolsQuery | undefined {

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function useTopV3PoolsQuery(_: any) {
const { data, error, loading } = useQuery<AgnosticTopPoolResult>(TOP_POOLS_QUERY, { client })
const { data, error, loading } = useQuery<AgnosticTopPoolResult>(TOP_POOLS_QUERY, {
client,
context: {
headers: {
'Cache-control': 'max-age=1800',
'X-Agnostic-Cache-Refresh-Trigger': '0.9',
},
},
})

return {
data: useMemo(() => transform(data), [data]),
Expand Down
7 changes: 6 additions & 1 deletion apps/web/src/graphql/agnostic/useDailyProtocolTVL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ type AgnosticHistoricalProtocolTVLResult = {
explore_daily_protocol_tvl_v3?: { timestamp: string; tvl_usd: string }[]
}

// eslint-disable-next-line import/no-unused-modules
export function useDailyProtocolTvlQuery({ variables }: { variables: { chain: Chain } }) {
const { data, loading } = useQuery<AgnosticHistoricalProtocolTVLResult>(HISTORICAL_PROTOCOL_TVL_QUERY, {
client,
skip: variables.chain !== Chain.Ethereum,
context: {
headers: {
'Cache-control': 'max-age=86400',
'X-Agnostic-Cache-Refresh-Trigger': '0.9',
},
},
})

return {
Expand Down
7 changes: 6 additions & 1 deletion apps/web/src/graphql/agnostic/useHistoricalProtocolVolume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ type AgnosticHistoricalProtocolVolumeVariables = {
all_time?: boolean
}

// eslint-disable-next-line import/no-unused-modules
export function useHistoricalProtocolVolumeQuery({
variables,
}: {
Expand All @@ -45,6 +44,12 @@ export function useHistoricalProtocolVolumeQuery({
all_time: variables.duration === HistoryDuration.Max,
},
skip: shouldSkip(variables.chain, variables.duration),
context: {
headers: {
'Cache-control': 'max-age=86400',
'X-Agnostic-Cache-Refresh-Trigger': '0.9',
},
},
}
)

Expand Down

0 comments on commit 520f80c

Please sign in to comment.