Skip to content

Commit

Permalink
pool filter (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
drethereum authored Dec 18, 2023
1 parent 26713ba commit 3aa751c
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 80 deletions.
2 changes: 1 addition & 1 deletion models/silver/dex/balancer/silver_dex__balancer_pools.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'block_number',
unique_key = 'pool_address',
full_refresh = false,
tags = ['curated']
) }}
Expand Down
8 changes: 1 addition & 7 deletions models/silver/dex/curve/silver_dex__curve_pools.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'block_number',
unique_key = 'pool_address',
full_refresh = false,
tags = ['curated']
) }}
Expand Down Expand Up @@ -36,12 +36,6 @@ AND _inserted_timestamp >= (
FROM
{{ this }}
)
AND to_address NOT IN (
SELECT
DISTINCT pool_address
FROM
{{ this }}
)
{% endif %}
QUALIFY(ROW_NUMBER() OVER(PARTITION BY to_address ORDER BY block_timestamp ASC)) = 1
),
Expand Down
6 changes: 3 additions & 3 deletions models/silver/dex/dodo/silver_dex__dodo_v1_pools.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'block_number',
unique_key = 'pool_address',
tags = ['curated']
) }}

Expand Down Expand Up @@ -46,6 +46,6 @@ SELECT
_log_id AS _id,
_inserted_timestamp
FROM
pool_events qualify(ROW_NUMBER() over (PARTITION BY pool_address
pool_events qualify(ROW_NUMBER() OVER (PARTITION BY pool_address
ORDER BY
_inserted_timestamp ASC)) = 1
_inserted_timestamp DESC)) = 1
8 changes: 1 addition & 7 deletions models/silver/dex/dodo/silver_dex__dodo_v2_pools.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'block_number',
unique_key = 'pool_address',
tags = ['curated']
) }}

Expand Down Expand Up @@ -47,12 +47,6 @@ AND _inserted_timestamp >= (
FROM
{{ this }}
)
AND pool_address NOT IN (
SELECT
DISTINCT pool_address
FROM
{{ this }}
)
{% endif %}
)
SELECT
Expand Down
15 changes: 6 additions & 9 deletions models/silver/dex/fraxswap/silver_dex__fraxswap_pools.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'block_number',
unique_key = 'pool_address',
tags = ['curated']
) }}

Expand All @@ -26,7 +26,8 @@ WITH pool_creation AS (
{{ ref ('silver__logs') }}
WHERE
contract_address IN (
'0xc2544a32872a91f4a553b404c6950e89de901fdb', --v1 factory
'0xc2544a32872a91f4a553b404c6950e89de901fdb',
--v1 factory
'0x54f454d747e037da288db568d4121117eab34e79' --v2 factory
)
AND topics [0] :: STRING = '0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9' --pairCreated
Expand All @@ -38,12 +39,6 @@ AND _inserted_timestamp >= (
FROM
{{ this }}
)
AND pool_address NOT IN (
SELECT
DISTINCT pool_address
FROM
{{ this }}
)
{% endif %}
)
SELECT
Expand All @@ -59,4 +54,6 @@ SELECT
_log_id,
_inserted_timestamp
FROM
pool_creation
pool_creation qualify(ROW_NUMBER() over (PARTITION BY pool_address
ORDER BY
_inserted_timestamp DESC)) = 1
8 changes: 1 addition & 7 deletions models/silver/dex/hashflow/silver_dex__hashflow_pools.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'block_number',
unique_key = 'pool_address',
tags = ['curated']
) }}

Expand Down Expand Up @@ -33,12 +33,6 @@ AND _inserted_timestamp >= (
FROM
{{ this }}
)
AND to_address NOT IN (
SELECT
DISTINCT pool_address
FROM
{{ this }}
)
{% endif %}

qualify(ROW_NUMBER() over(PARTITION BY to_address
Expand Down
6 changes: 4 additions & 2 deletions models/silver/dex/hashflow/silver_dex__hashflow_v3_pools.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = "block_number",
unique_key = "pool_address",
tags = ['curated']
) }}

Expand Down Expand Up @@ -40,4 +40,6 @@ SELECT
_log_id,
_inserted_timestamp
FROM
contract_deployments
contract_deployments qualify(ROW_NUMBER() over (PARTITION BY pool_address
ORDER BY
_inserted_timestamp DESC)) = 1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'block_number',
unique_key = 'pool_address',
tags = ['curated']
) }}

Expand Down Expand Up @@ -34,19 +34,14 @@ WITH pool_creation AS (
WHERE
contract_address = LOWER('0x5F1fe642060B5B9658C15721Ea22E982643c095c') --dynamic fee factory
AND topics [0] :: STRING = '0xfc574402c445e75f2b79b67884ff9c662244dce454c5ae68935fcd0bebb7c8ff' --created pool

{% if is_incremental() %}
AND _inserted_timestamp >= (
SELECT
MAX(_inserted_timestamp) - INTERVAL '12 hours'
FROM
{{ this }}
)
AND pool_address NOT IN (
SELECT
DISTINCT pool_address
FROM
{{ this }}
)
{% endif %}
)
SELECT
Expand All @@ -63,4 +58,6 @@ SELECT
_log_id,
_inserted_timestamp
FROM
pool_creation
pool_creation qualify(ROW_NUMBER() over (PARTITION BY pool_address
ORDER BY
_inserted_timestamp DESC)) = 1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'block_number',
unique_key = 'pool_address',
tags = ['curated']
) }}

Expand Down Expand Up @@ -47,12 +47,6 @@ AND _inserted_timestamp >= (
FROM
{{ this }}
)
AND pool_address NOT IN (
SELECT
DISTINCT pool_address
FROM
{{ this }}
)
{% endif %}
)
SELECT
Expand All @@ -71,3 +65,6 @@ SELECT
_inserted_timestamp
FROM
pool_creation
qualify(ROW_NUMBER() over (PARTITION BY pool_address
ORDER BY
_inserted_timestamp DESC)) = 1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'block_number',
unique_key = 'pool_address',
tags = ['curated']
) }}

Expand Down Expand Up @@ -38,12 +38,6 @@ AND _inserted_timestamp >= (
FROM
{{ this }}
)
AND pool_address NOT IN (
SELECT
DISTINCT pool_address
FROM
{{ this }}
)
{% endif %}
)
SELECT
Expand All @@ -61,3 +55,6 @@ SELECT
_inserted_timestamp
FROM
pool_creation
qualify(ROW_NUMBER() over (PARTITION BY pool_address
ORDER BY
_inserted_timestamp DESC)) = 1
11 changes: 4 additions & 7 deletions models/silver/dex/quickswap/silver_dex__quickswap_v2_pools.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'block_number',
unique_key = 'pool_address',
tags = ['curated']
) }}

Expand Down Expand Up @@ -35,12 +35,6 @@ AND _inserted_timestamp >= (
FROM
{{ this }}
)
AND pool_address NOT IN (
SELECT
DISTINCT pool_address
FROM
{{ this }}
)
{% endif %}
)
SELECT
Expand All @@ -57,3 +51,6 @@ SELECT
_inserted_timestamp
FROM
pool_creation
qualify(ROW_NUMBER() over (PARTITION BY pool_address
ORDER BY
_inserted_timestamp DESC)) = 1
11 changes: 4 additions & 7 deletions models/silver/dex/quickswap/silver_dex__quickswap_v3_pools.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'block_number',
unique_key = 'pool_address',
cluster_by = ['_inserted_timestamp::DATE'],
tags = ['curated']
) }}
Expand Down Expand Up @@ -33,12 +33,6 @@ AND _inserted_timestamp >= (
FROM
{{ this }}
)
AND pool_address NOT IN (
SELECT
DISTINCT pool_address
FROM
{{ this }}
)
{% endif %}
)

Expand All @@ -55,3 +49,6 @@ SELECT
_inserted_timestamp
FROM
pool_creation
qualify(ROW_NUMBER() over (PARTITION BY pool_address
ORDER BY
_inserted_timestamp DESC)) = 1
11 changes: 4 additions & 7 deletions models/silver/dex/sushi/silver_dex__sushi_pools.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'block_number',
unique_key = 'pool_address',
tags = ['curated']
) }}

Expand Down Expand Up @@ -35,12 +35,6 @@ AND _inserted_timestamp >= (
FROM
{{ this }}
)
AND pool_address NOT IN (
SELECT
DISTINCT pool_address
FROM
{{ this }}
)
{% endif %}
)
SELECT
Expand All @@ -57,3 +51,6 @@ SELECT
_inserted_timestamp
FROM
pool_creation
qualify(ROW_NUMBER() over (PARTITION BY pool_address
ORDER BY
_inserted_timestamp DESC)) = 1
2 changes: 1 addition & 1 deletion models/silver/dex/uniswap/silver_dex__univ3_pools.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'created_block',
unique_key = 'pool_address',
cluster_by = ['_inserted_timestamp::DATE'],
tags = ['curated']
) }}
Expand Down

0 comments on commit 3aa751c

Please sign in to comment.