Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 46 additions & 16 deletions lib/cron/cache-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ import {
ZORA_POST_HOOK_ON_BASE_v2_2,
ZORA_POST_HOOK_ON_BASE_v2_2_1,
ZORA_POST_HOOK_ON_BASE_v2_3_0,
CLANKER_DYNAMIC_FEE_HOOKS_ADDRESS_ON_BASE,
CLANKER_STATIC_FEE_HOOKS_ADDRESS_ON_BASE,
CLANKER_DYNAMIC_FEE_HOOKS_ADDRESS_ON_BASE_v2,
CLANKER_STATIC_FEE_HOOKS_ADDRESS_ON_BASE_v2,
CLANKER_DYNAMIC_FEE_HOOKS_ADDRESS_ON_ARBITRUM,
CLANKER_STATIC_FEE_HOOKS_ADDRESS_ON_ARBITRUM,
CLANKER_DYNAMIC_FEE_HOOKS_ADDRESS_ON_UNICHAIN,
CLANKER_STATIC_FEE_HOOKS_ADDRESS_ON_UNICHAIN,
CLANKER_STATIC_FEE_HOOKS_ADDRESS_ON_MAINNET,
CLANKER_STATIC_FEE_HOOKS_ADDRESS_ON_MONAD,
} from '../util/hooksAddressesAllowlist'

// during local cdk stack update, the env vars are not populated
Expand Down Expand Up @@ -100,6 +110,26 @@ export const ZORA_HOOKS_FOR_V4_SUBGRAPH_FILTERING = new Set([
ZORA_POST_HOOK_ON_BASE_v2_3_0,
])

// Clanker hooks addresses for V4 filtering - MUST be lowercase
export const CLANKER_HOOKS_FOR_V4_SUBGRAPH_FILTERING = new Set([
CLANKER_DYNAMIC_FEE_HOOKS_ADDRESS_ON_BASE,
CLANKER_STATIC_FEE_HOOKS_ADDRESS_ON_BASE,
CLANKER_DYNAMIC_FEE_HOOKS_ADDRESS_ON_BASE_v2,
CLANKER_STATIC_FEE_HOOKS_ADDRESS_ON_BASE_v2,
CLANKER_DYNAMIC_FEE_HOOKS_ADDRESS_ON_ARBITRUM,
CLANKER_STATIC_FEE_HOOKS_ADDRESS_ON_ARBITRUM,
CLANKER_DYNAMIC_FEE_HOOKS_ADDRESS_ON_UNICHAIN,
CLANKER_STATIC_FEE_HOOKS_ADDRESS_ON_UNICHAIN,
CLANKER_STATIC_FEE_HOOKS_ADDRESS_ON_MAINNET,
CLANKER_STATIC_FEE_HOOKS_ADDRESS_ON_MONAD,
])

// Combined hooks set for V4SubgraphProvider low-TVL filtering (uses trackedZoraEthThreshold = 0.001)
export const HOOKS_FOR_V4_SUBGRAPH_LOW_TVL_FILTERING = new Set([
...ZORA_HOOKS_FOR_V4_SUBGRAPH_FILTERING,
...CLANKER_HOOKS_FOR_V4_SUBGRAPH_FILTERING,
])

export const v4SubgraphUrlOverride = (chainId: ChainId) => {
switch (chainId) {
case ChainId.SEPOLIA:
Expand Down Expand Up @@ -215,7 +245,7 @@ export const v2SubgraphUrlOverride = (chainId: ChainId) => {

const v4TrackedEthThreshold = 0.01 // Pools need at least 0.01 of trackedEth to be selected
const v4BaseTrackedEthThreshold = 0.1 // Pools on Base need at least 0.1 of trackedEth to be selected
const v4BaseZoraTrackedEthThreshold = 0.001 // Pools on Zora need at least 0.1 of trackedEth to be selected
const v4BaseZoraTrackedEthThreshold = 0.001 // Pools on Zora/Clanker need at least 0.001 of trackedEth to be selected
const v4UntrackedUsdThreshold = 0 // v4 subgraph totalValueLockedUSDUntracked returns 0, even with the pools that have appropriate liqudities and correct pool pricing

export const v3TrackedEthThreshold = 0.01 // Pools need at least 0.01 of trackedEth to be selected
Expand Down Expand Up @@ -674,7 +704,7 @@ export const chainProtocols = [
true,
v4TrackedEthThreshold,
v4BaseZoraTrackedEthThreshold,
ZORA_HOOKS_FOR_V4_SUBGRAPH_FILTERING,
HOOKS_FOR_V4_SUBGRAPH_LOW_TVL_FILTERING,
v4UntrackedUsdThreshold,
v4SubgraphUrlOverride(ChainId.SEPOLIA)
),
Expand All @@ -690,7 +720,7 @@ export const chainProtocols = [
true,
v4TrackedEthThreshold,
v4BaseZoraTrackedEthThreshold,
ZORA_HOOKS_FOR_V4_SUBGRAPH_FILTERING,
HOOKS_FOR_V4_SUBGRAPH_LOW_TVL_FILTERING,
v4UntrackedUsdThreshold,
v4SubgraphUrlOverride(ChainId.ARBITRUM_ONE)
),
Expand All @@ -706,7 +736,7 @@ export const chainProtocols = [
true,
v4BaseTrackedEthThreshold,
v4BaseZoraTrackedEthThreshold,
ZORA_HOOKS_FOR_V4_SUBGRAPH_FILTERING,
HOOKS_FOR_V4_SUBGRAPH_LOW_TVL_FILTERING,
v4UntrackedUsdThreshold,
v4SubgraphUrlOverride(ChainId.BASE),
process.env.GRAPH_BEARER_TOKEN
Expand All @@ -723,7 +753,7 @@ export const chainProtocols = [
true,
v4TrackedEthThreshold,
v4BaseZoraTrackedEthThreshold,
ZORA_HOOKS_FOR_V4_SUBGRAPH_FILTERING,
HOOKS_FOR_V4_SUBGRAPH_LOW_TVL_FILTERING,
v4UntrackedUsdThreshold,
v4SubgraphUrlOverride(ChainId.POLYGON)
),
Expand All @@ -739,7 +769,7 @@ export const chainProtocols = [
true,
v4TrackedEthThreshold,
v4BaseZoraTrackedEthThreshold,
ZORA_HOOKS_FOR_V4_SUBGRAPH_FILTERING,
HOOKS_FOR_V4_SUBGRAPH_LOW_TVL_FILTERING,
v4UntrackedUsdThreshold,
v4SubgraphUrlOverride(ChainId.WORLDCHAIN)
),
Expand All @@ -755,7 +785,7 @@ export const chainProtocols = [
true,
v4TrackedEthThreshold,
v4BaseZoraTrackedEthThreshold,
ZORA_HOOKS_FOR_V4_SUBGRAPH_FILTERING,
HOOKS_FOR_V4_SUBGRAPH_LOW_TVL_FILTERING,
v4UntrackedUsdThreshold,
v4SubgraphUrlOverride(ChainId.ZORA)
),
Expand All @@ -771,7 +801,7 @@ export const chainProtocols = [
true,
v4TrackedEthThreshold,
v4BaseZoraTrackedEthThreshold,
ZORA_HOOKS_FOR_V4_SUBGRAPH_FILTERING,
HOOKS_FOR_V4_SUBGRAPH_LOW_TVL_FILTERING,
v4UntrackedUsdThreshold,
v4SubgraphUrlOverride(ChainId.UNICHAIN)
),
Expand All @@ -794,7 +824,7 @@ export const chainProtocols = [
true,
v4TrackedEthThreshold,
v4BaseZoraTrackedEthThreshold,
ZORA_HOOKS_FOR_V4_SUBGRAPH_FILTERING,
HOOKS_FOR_V4_SUBGRAPH_LOW_TVL_FILTERING,
v4UntrackedUsdThreshold,
v4SubgraphUrlOverride(ChainId.BLAST)
),
Expand All @@ -810,7 +840,7 @@ export const chainProtocols = [
true,
v4TrackedEthThreshold,
v4BaseZoraTrackedEthThreshold,
ZORA_HOOKS_FOR_V4_SUBGRAPH_FILTERING,
HOOKS_FOR_V4_SUBGRAPH_LOW_TVL_FILTERING,
v4UntrackedUsdThreshold,
v4SubgraphUrlOverride(ChainId.MAINNET)
),
Expand All @@ -833,7 +863,7 @@ export const chainProtocols = [
true,
v4TrackedEthThreshold,
v4BaseZoraTrackedEthThreshold,
ZORA_HOOKS_FOR_V4_SUBGRAPH_FILTERING,
HOOKS_FOR_V4_SUBGRAPH_LOW_TVL_FILTERING,
v4UntrackedUsdThreshold,
v4SubgraphUrlOverride(ChainId.SONEIUM)
),
Expand All @@ -849,7 +879,7 @@ export const chainProtocols = [
true,
v4TrackedEthThreshold,
v4BaseZoraTrackedEthThreshold,
ZORA_HOOKS_FOR_V4_SUBGRAPH_FILTERING,
HOOKS_FOR_V4_SUBGRAPH_LOW_TVL_FILTERING,
v4UntrackedUsdThreshold,
v4SubgraphUrlOverride(ChainId.OPTIMISM)
),
Expand All @@ -865,7 +895,7 @@ export const chainProtocols = [
true,
v4TrackedEthThreshold,
v4BaseZoraTrackedEthThreshold,
ZORA_HOOKS_FOR_V4_SUBGRAPH_FILTERING,
HOOKS_FOR_V4_SUBGRAPH_LOW_TVL_FILTERING,
v4UntrackedUsdThreshold,
v4SubgraphUrlOverride(ChainId.BNB)
),
Expand All @@ -881,7 +911,7 @@ export const chainProtocols = [
true,
v4TrackedEthThreshold,
v4BaseZoraTrackedEthThreshold,
ZORA_HOOKS_FOR_V4_SUBGRAPH_FILTERING,
HOOKS_FOR_V4_SUBGRAPH_LOW_TVL_FILTERING,
v4UntrackedUsdThreshold,
v4SubgraphUrlOverride(ChainId.MONAD),
process.env.GOLD_SKY_BEARER_TOKEN
Expand All @@ -898,7 +928,7 @@ export const chainProtocols = [
true,
v4TrackedEthThreshold,
v4BaseZoraTrackedEthThreshold,
ZORA_HOOKS_FOR_V4_SUBGRAPH_FILTERING,
HOOKS_FOR_V4_SUBGRAPH_LOW_TVL_FILTERING,
v4UntrackedUsdThreshold,
v4SubgraphUrlOverride(ChainId.XLAYER),
process.env.GRAPH_BEARER_TOKEN
Expand All @@ -915,7 +945,7 @@ export const chainProtocols = [
true,
v4TrackedEthThreshold,
v4BaseZoraTrackedEthThreshold,
ZORA_HOOKS_FOR_V4_SUBGRAPH_FILTERING,
HOOKS_FOR_V4_SUBGRAPH_LOW_TVL_FILTERING,
v4UntrackedUsdThreshold,
v4SubgraphUrlOverride(ChainId.AVALANCHE)
),
Expand Down
30 changes: 30 additions & 0 deletions lib/util/v4HooksPoolsFiltering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,34 @@ import {
ZORA_POST_HOOK_ON_BASE_v2_2_1,
ZORA_POST_HOOK_ON_BASE_v2_3_0,
ZORA_POST_HOOK_ON_BASE_v2_4_0,
CLANKER_DYNAMIC_FEE_HOOKS_ADDRESS_ON_BASE,
CLANKER_STATIC_FEE_HOOKS_ADDRESS_ON_BASE,
CLANKER_DYNAMIC_FEE_HOOKS_ADDRESS_ON_BASE_v2,
CLANKER_STATIC_FEE_HOOKS_ADDRESS_ON_BASE_v2,
CLANKER_DYNAMIC_FEE_HOOKS_ADDRESS_ON_ARBITRUM,
CLANKER_STATIC_FEE_HOOKS_ADDRESS_ON_ARBITRUM,
CLANKER_DYNAMIC_FEE_HOOKS_ADDRESS_ON_UNICHAIN,
CLANKER_STATIC_FEE_HOOKS_ADDRESS_ON_UNICHAIN,
CLANKER_STATIC_FEE_HOOKS_ADDRESS_ON_MAINNET,
CLANKER_STATIC_FEE_HOOKS_ADDRESS_ON_MONAD,
} from './hooksAddressesAllowlist'
import { ChainId, Currency, Token } from '@uniswap/sdk-core'
import { PriorityQueue } from '@datastructures-js/priority-queue'
import { ADDRESS_ZERO } from '@uniswap/router-sdk'

const CLANKER_HOOKS = new Set([
CLANKER_DYNAMIC_FEE_HOOKS_ADDRESS_ON_BASE,
CLANKER_STATIC_FEE_HOOKS_ADDRESS_ON_BASE,
CLANKER_DYNAMIC_FEE_HOOKS_ADDRESS_ON_BASE_v2,
CLANKER_STATIC_FEE_HOOKS_ADDRESS_ON_BASE_v2,
CLANKER_DYNAMIC_FEE_HOOKS_ADDRESS_ON_ARBITRUM,
CLANKER_STATIC_FEE_HOOKS_ADDRESS_ON_ARBITRUM,
CLANKER_DYNAMIC_FEE_HOOKS_ADDRESS_ON_UNICHAIN,
CLANKER_STATIC_FEE_HOOKS_ADDRESS_ON_UNICHAIN,
CLANKER_STATIC_FEE_HOOKS_ADDRESS_ON_MAINNET,
CLANKER_STATIC_FEE_HOOKS_ADDRESS_ON_MONAD,
])

type V4PoolGroupingKey = string
const TOP_GROUPED_V4_POOLS = 10

Expand Down Expand Up @@ -198,6 +221,13 @@ export function v4HooksPoolsFiltering(chainId: ChainId, pools: Array<V4SubgraphP
}
}

const isClankerPool = CLANKER_HOOKS.has(pool.hooks.toLowerCase())
if (isClankerPool) {
if (pool.tvlETH <= 0.001) {
shouldNotAddV4Pool = true
}
}

if (!shouldNotAddV4Pool) {
v4Pools.push(pool)
}
Expand Down
Loading