mirror of
https://github.com/FlipsideCrypto/polygon-models.git
synced 2026-02-06 16:11:59 +00:00
removed incremental logic on price cte
This commit is contained in:
parent
4e8526d8f8
commit
102b646fea
@ -1,7 +1,7 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'block_number',
|
||||
unique_key = ['block_number','platform_name','platform_exchange_version'],
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['non_realtime']
|
||||
) }}
|
||||
@ -43,7 +43,7 @@ WHERE
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '24 hours'
|
||||
) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -84,7 +84,7 @@ WHERE
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '24 hours'
|
||||
) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -125,7 +125,7 @@ WHERE
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '24 hours'
|
||||
) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -153,15 +153,6 @@ prices_raw AS (
|
||||
FROM
|
||||
nft_base_models
|
||||
)
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND HOUR >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '48 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
all_prices AS (
|
||||
SELECT
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'block_number',
|
||||
unique_key = ['block_number','platform','version'],
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['non_realtime']
|
||||
) }}
|
||||
@ -27,6 +27,7 @@ SELECT
|
||||
pool_address,
|
||||
pool_name,
|
||||
'balancer' AS platform,
|
||||
'v1' AS version,
|
||||
_log_id AS _id,
|
||||
_inserted_timestamp,
|
||||
token0,
|
||||
@ -60,6 +61,7 @@ SELECT
|
||||
pool_address,
|
||||
pool_name,
|
||||
'curve' AS platform,
|
||||
'v1' AS version,
|
||||
_call_id AS _id,
|
||||
_inserted_timestamp,
|
||||
MAX(CASE WHEN token_num = 1 THEN token_address END) AS token0,
|
||||
@ -96,6 +98,7 @@ SELECT
|
||||
base_token AS token0,
|
||||
quote_token AS token1,
|
||||
'dodo-v1' AS platform,
|
||||
'v1' AS version,
|
||||
_id,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
@ -123,6 +126,7 @@ SELECT
|
||||
base_token AS token0,
|
||||
quote_token AS token1,
|
||||
'dodo-v2' AS platform,
|
||||
'v2' AS version,
|
||||
_log_id AS _id,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
@ -151,6 +155,7 @@ SELECT
|
||||
token0,
|
||||
token1,
|
||||
'fraxswap' AS platform,
|
||||
'v1' AS version,
|
||||
_log_id AS _id,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
@ -178,6 +183,7 @@ SELECT
|
||||
token0,
|
||||
token1,
|
||||
'kyberswap-v1' AS platform,
|
||||
'v1-dynamic' AS version,
|
||||
_log_id AS _id,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
@ -205,6 +211,7 @@ SELECT
|
||||
token0,
|
||||
token1,
|
||||
'kyberswap-v1' AS platform,
|
||||
'v1-static' AS version,
|
||||
_log_id AS _id,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
@ -233,6 +240,7 @@ SELECT
|
||||
token0,
|
||||
token1,
|
||||
'kyberswap-v2' AS platform,
|
||||
'v2' AS version,
|
||||
_log_id AS _id,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
@ -260,6 +268,7 @@ SELECT
|
||||
token0,
|
||||
token1,
|
||||
'quickswap-v2' AS platform,
|
||||
'v2' AS version,
|
||||
_log_id AS _id,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
@ -287,6 +296,7 @@ SELECT
|
||||
token0_address AS token0,
|
||||
token1_address AS token1,
|
||||
'quickswap-v3' AS platform,
|
||||
'v3' AS version,
|
||||
_log_id AS _id,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
@ -314,6 +324,7 @@ SELECT
|
||||
token0,
|
||||
token1,
|
||||
'sushiswap' AS platform,
|
||||
'v1' AS version,
|
||||
_log_id AS _id,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
@ -342,6 +353,7 @@ SELECT
|
||||
token0_address AS token0,
|
||||
token1_address AS token1,
|
||||
'uniswap-v3' AS platform,
|
||||
'v3' AS version,
|
||||
_log_id AS _id,
|
||||
_inserted_timestamp
|
||||
FROM
|
||||
@ -419,6 +431,7 @@ FINAL AS (
|
||||
OBJECT_CONSTRUCT('token0',c0.symbol,'token1',c1.symbol) AS symbols,
|
||||
OBJECT_CONSTRUCT('token0',c0.decimals,'token1',c1.decimals) AS decimals,
|
||||
platform,
|
||||
version,
|
||||
_id,
|
||||
p._inserted_timestamp
|
||||
FROM all_pools_standard p
|
||||
@ -443,6 +456,7 @@ FINAL AS (
|
||||
OBJECT_CONSTRUCT('token0',c0.symbol,'token1',c1.symbol) AS symbols,
|
||||
OBJECT_CONSTRUCT('token0',c0.decimals,'token1',c1.decimals) AS decimals,
|
||||
platform,
|
||||
version,
|
||||
_id,
|
||||
p._inserted_timestamp
|
||||
FROM all_pools_v3 p
|
||||
@ -475,6 +489,7 @@ FINAL AS (
|
||||
OBJECT_CONSTRUCT('token0', c0.symbol, 'token1', c1.symbol, 'token2', c2.symbol, 'token3', c3.symbol, 'token4', c4.symbol, 'token5', c5.symbol, 'token6', c6.symbol, 'token7', c7.symbol) AS symbols,
|
||||
OBJECT_CONSTRUCT('token0', c0.decimals, 'token1', c1.decimals, 'token2', c2.decimals, 'token3', c3.decimals, 'token4', c4.decimals, 'token5', c5.decimals, 'token6', c6.decimals, 'token7', c7.decimals) AS decimals,
|
||||
platform,
|
||||
version,
|
||||
_id,
|
||||
p._inserted_timestamp
|
||||
FROM all_pools_other p
|
||||
@ -501,6 +516,7 @@ SELECT
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
platform,
|
||||
version,
|
||||
contract_address,
|
||||
pool_address,
|
||||
pool_name,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
unique_key = 'block_number',
|
||||
unique_key = ['block_number','platform','version'],
|
||||
cluster_by = ['block_timestamp::DATE'],
|
||||
tags = ['non_realtime']
|
||||
) }}
|
||||
@ -30,15 +30,6 @@ prices AS (
|
||||
FROM
|
||||
contracts
|
||||
)
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND HOUR >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '48 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
{% endif %}
|
||||
),
|
||||
univ3_swaps AS (
|
||||
SELECT
|
||||
@ -93,6 +84,7 @@ univ3_swaps AS (
|
||||
recipient AS tx_to,
|
||||
event_index,
|
||||
'uniswap-v3' AS platform,
|
||||
'v3' AS version,
|
||||
CASE
|
||||
WHEN amount0_unadj > 0 THEN token0_address
|
||||
ELSE token1_address
|
||||
@ -135,7 +127,7 @@ univ3_swaps AS (
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '12 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -169,6 +161,7 @@ woofi_swaps AS (
|
||||
tx_to,
|
||||
event_index,
|
||||
platform,
|
||||
'v1' AS version,
|
||||
token_in,
|
||||
token_out,
|
||||
CONCAT(
|
||||
@ -208,7 +201,7 @@ woofi_swaps AS (
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '12 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -242,6 +235,7 @@ kyberswap_v1_dynamic AS (
|
||||
tx_to,
|
||||
event_index,
|
||||
platform,
|
||||
'v1-dynamic' AS version,
|
||||
token_in,
|
||||
token_out,
|
||||
NULL AS pool_name,
|
||||
@ -259,7 +253,7 @@ kyberswap_v1_dynamic AS (
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '12 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -293,6 +287,7 @@ kyberswap_v1_static AS (
|
||||
tx_to,
|
||||
event_index,
|
||||
platform,
|
||||
'v1-static' AS version,
|
||||
token_in,
|
||||
token_out,
|
||||
NULL AS pool_name,
|
||||
@ -310,7 +305,7 @@ kyberswap_v1_static AS (
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '12 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -344,6 +339,7 @@ kyberswap_v2_elastic AS (
|
||||
tx_to,
|
||||
event_index,
|
||||
platform,
|
||||
'v2' AS version,
|
||||
token_in,
|
||||
token_out,
|
||||
NULL AS pool_name,
|
||||
@ -361,7 +357,7 @@ kyberswap_v2_elastic AS (
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '12 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -395,6 +391,7 @@ fraxswap_swaps AS (
|
||||
tx_to,
|
||||
event_index,
|
||||
platform,
|
||||
'v1' AS version,
|
||||
token_in,
|
||||
token_out,
|
||||
NULL AS pool_name,
|
||||
@ -412,7 +409,7 @@ fraxswap_swaps AS (
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '12 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -446,6 +443,7 @@ sushi_swaps AS (
|
||||
tx_to,
|
||||
event_index,
|
||||
platform,
|
||||
'v1' AS version,
|
||||
token_in,
|
||||
token_out,
|
||||
NULL AS pool_name,
|
||||
@ -463,7 +461,7 @@ sushi_swaps AS (
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '12 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -486,6 +484,7 @@ curve_swaps AS (
|
||||
tx_to,
|
||||
event_index,
|
||||
platform,
|
||||
'v1' AS version,
|
||||
token_in,
|
||||
token_out,
|
||||
COALESCE(
|
||||
@ -531,7 +530,7 @@ curve_swaps AS (
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '12 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -566,6 +565,7 @@ balancer_swaps AS (
|
||||
tx_to,
|
||||
event_index,
|
||||
platform,
|
||||
'v1' AS version,
|
||||
token_in,
|
||||
token_out,
|
||||
_log_id,
|
||||
@ -582,7 +582,7 @@ balancer_swaps AS (
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '12 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -640,6 +640,7 @@ quickswap_v3_swaps AS (
|
||||
recipient AS tx_to,
|
||||
event_index,
|
||||
'quickswap-v3' AS platform,
|
||||
'v3' AS version,
|
||||
CASE
|
||||
WHEN amount0_unadj > 0 THEN token0_address
|
||||
ELSE token1_address
|
||||
@ -684,7 +685,7 @@ quickswap_v3_swaps AS (
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '12 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -718,6 +719,7 @@ quickswap_v2_swaps AS (
|
||||
tx_to,
|
||||
event_index,
|
||||
platform,
|
||||
'v2' AS version,
|
||||
token_in,
|
||||
token_out,
|
||||
NULL AS pool_name,
|
||||
@ -735,7 +737,7 @@ quickswap_v2_swaps AS (
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '12 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -769,6 +771,7 @@ dodo_v1_swaps AS (
|
||||
tx_to,
|
||||
event_index,
|
||||
platform,
|
||||
'v1' AS version,
|
||||
token_in,
|
||||
token_out,
|
||||
NULL AS pool_name,
|
||||
@ -786,7 +789,7 @@ dodo_v1_swaps AS (
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '12 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -820,6 +823,7 @@ dodo_v2_swaps AS (
|
||||
tx_to,
|
||||
event_index,
|
||||
platform,
|
||||
'v2' AS version,
|
||||
token_in,
|
||||
token_out,
|
||||
NULL AS pool_name,
|
||||
@ -837,7 +841,7 @@ dodo_v2_swaps AS (
|
||||
WHERE
|
||||
_inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '12 hours'
|
||||
MAX(_inserted_timestamp) - INTERVAL '36 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
@ -863,6 +867,7 @@ all_dex_standard AS (
|
||||
tx_to,
|
||||
event_index,
|
||||
platform,
|
||||
version,
|
||||
token_in,
|
||||
token_out,
|
||||
symbol_in,
|
||||
@ -892,6 +897,7 @@ all_dex_standard AS (
|
||||
tx_to,
|
||||
event_index,
|
||||
platform,
|
||||
version,
|
||||
token_in,
|
||||
token_out,
|
||||
symbol_in,
|
||||
@ -921,6 +927,7 @@ all_dex_standard AS (
|
||||
tx_to,
|
||||
event_index,
|
||||
platform,
|
||||
version,
|
||||
token_in,
|
||||
token_out,
|
||||
token_symbol_in AS symbol_in,
|
||||
@ -950,6 +957,7 @@ all_dex_standard AS (
|
||||
tx_to,
|
||||
event_index,
|
||||
platform,
|
||||
version,
|
||||
token_in,
|
||||
token_out,
|
||||
symbol_in,
|
||||
@ -979,6 +987,7 @@ all_dex_standard AS (
|
||||
tx_to,
|
||||
event_index,
|
||||
platform,
|
||||
version,
|
||||
token_in,
|
||||
token_out,
|
||||
symbol_in,
|
||||
@ -1008,6 +1017,7 @@ all_dex_standard AS (
|
||||
tx_to,
|
||||
event_index,
|
||||
platform,
|
||||
version,
|
||||
token_in,
|
||||
token_out,
|
||||
symbol_in,
|
||||
@ -1037,6 +1047,7 @@ all_dex_standard AS (
|
||||
tx_to,
|
||||
event_index,
|
||||
platform,
|
||||
version,
|
||||
token_in,
|
||||
token_out,
|
||||
symbol_in,
|
||||
@ -1066,6 +1077,7 @@ all_dex_standard AS (
|
||||
tx_to,
|
||||
event_index,
|
||||
platform,
|
||||
version,
|
||||
token_in,
|
||||
token_out,
|
||||
symbol_in,
|
||||
@ -1095,6 +1107,7 @@ all_dex_standard AS (
|
||||
tx_to,
|
||||
event_index,
|
||||
platform,
|
||||
version,
|
||||
token_in,
|
||||
token_out,
|
||||
symbol_in,
|
||||
@ -1124,6 +1137,7 @@ all_dex_standard AS (
|
||||
tx_to,
|
||||
event_index,
|
||||
platform,
|
||||
version,
|
||||
token_in,
|
||||
token_out,
|
||||
symbol_in,
|
||||
@ -1153,6 +1167,7 @@ all_dex_standard AS (
|
||||
tx_to,
|
||||
event_index,
|
||||
platform,
|
||||
version,
|
||||
token_in,
|
||||
token_out,
|
||||
symbol_in,
|
||||
@ -1186,6 +1201,7 @@ all_dex_custom AS (
|
||||
tx_to,
|
||||
event_index,
|
||||
platform,
|
||||
version,
|
||||
token_in,
|
||||
token_out,
|
||||
symbol_in,
|
||||
@ -1215,6 +1231,7 @@ all_dex_custom AS (
|
||||
tx_to,
|
||||
event_index,
|
||||
platform,
|
||||
version,
|
||||
token_in,
|
||||
token_out,
|
||||
symbol_in,
|
||||
@ -1257,6 +1274,7 @@ FINAL AS (
|
||||
tx_to,
|
||||
event_index,
|
||||
platform,
|
||||
version,
|
||||
token_in,
|
||||
token_out,
|
||||
symbol_in,
|
||||
@ -1304,6 +1322,7 @@ FINAL AS (
|
||||
tx_to,
|
||||
event_index,
|
||||
platform,
|
||||
version,
|
||||
token_in,
|
||||
token_out,
|
||||
symbol_in,
|
||||
@ -1346,6 +1365,7 @@ SELECT
|
||||
tx_to,
|
||||
event_index,
|
||||
f.platform,
|
||||
f.version,
|
||||
token_in,
|
||||
token_out,
|
||||
symbol_in,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user