Skip to content

Commit

Permalink
pool filter (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
drethereum authored Dec 19, 2023
1 parent 213d3c9 commit 3b7cd20
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 73 deletions.
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
9 changes: 2 additions & 7 deletions models/silver/defi/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 @@ -35,12 +35,7 @@ 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
14 changes: 1 addition & 13 deletions models/silver/defi/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 @@ -33,12 +33,6 @@ AND _inserted_timestamp >= (
FROM
{{ this }}
)
AND to_address NOT IN (
SELECT
DISTINCT pool_address
FROM
{{ this }}
)
{% endif %}
),
pool_evt AS (
Expand Down Expand Up @@ -80,12 +74,6 @@ AND _inserted_timestamp >= (
FROM
{{ this }}
)
AND pool_address NOT IN (
SELECT
DISTINCT pool_address
FROM
{{ this }}
)
{% endif %}
),
FINAL AS (
Expand Down
12 changes: 4 additions & 8 deletions models/silver/defi/dex/frax/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 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 @@ -56,4 +50,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
12 changes: 3 additions & 9 deletions models/silver/defi/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 @@ -32,19 +32,12 @@ 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
)

SELECT
tx_hash,
block_number,
Expand All @@ -53,4 +46,5 @@ SELECT
contract_address AS pool_address,
_call_id,
_inserted_timestamp
FROM contract_deployments
FROM
contract_deployments
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 @@ -47,12 +47,6 @@ AND _inserted_timestamp >= (
FROM
{{ this }}
)
AND pool_address NOT IN (
SELECT
DISTINCT pool_address
FROM
{{ this }}
)
{% endif %}
)
SELECT
Expand All @@ -70,4 +64,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 @@ -38,12 +38,6 @@ AND _inserted_timestamp >= (
FROM
{{ this }}
)
AND pool_address NOT IN (
SELECT
DISTINCT pool_address
FROM
{{ this }}
)
{% endif %}
)
SELECT
Expand All @@ -60,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
17 changes: 8 additions & 9 deletions models/silver/defi/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 All @@ -22,7 +22,10 @@ WITH pool_creation AS (
FROM
{{ ref ('silver__logs') }}
WHERE
contract_address IN ('0xcaabdd9cf4b61813d4a52f980d6bc1b713fe66f5','0x1b02da8cb0d097eb8d57a175b88c7d8b47997506')
contract_address IN (
'0xcaabdd9cf4b61813d4a52f980d6bc1b713fe66f5',
'0x1b02da8cb0d097eb8d57a175b88c7d8b47997506'
)
AND topics [0] :: STRING = '0xe469f9471ac1d98222517eb2cdff1ef4df5f7880269173bb782bb78e499d9de3' --DeployPool

{% if is_incremental() %}
Expand All @@ -32,12 +35,6 @@ AND _inserted_timestamp >= (
FROM
{{ this }}
)
AND pool_address NOT IN (
SELECT
DISTINCT pool_address
FROM
{{ this }}
)
{% endif %}
)
SELECT
Expand All @@ -52,4 +49,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
2 changes: 1 addition & 1 deletion models/silver/defi/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 = 'block_number',
unique_key = 'pool_address',
cluster_by = ['block_timestamp::DATE'],
tags = ['curated']
) }}
Expand Down
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 = ['block_timestamp::DATE'],
tags = ['curated']
) }}
Expand Down Expand Up @@ -42,3 +42,7 @@ AND _inserted_timestamp >= (
{{ this }}
)
{% endif %}

qualify(ROW_NUMBER() over (PARTITION BY pool_address
ORDER BY
_inserted_timestamp DESC)) = 1
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ WITH pool_creation AS (
AND contract_address = '0x25cbddb98b35ab1ff77413456b31ec81a6b6b746' --velo deployer

{% if is_incremental() %}
AND pool_address NOT IN (
SELECT
DISTINCT pool_address
FROM
{{ this }}
)

{% endif %}
),
function_sigs AS (
Expand Down

0 comments on commit 3b7cd20

Please sign in to comment.