mirror of
https://github.com/FlipsideCrypto/base-models.git
synced 2026-02-06 15:36:47 +00:00
add dex
This commit is contained in:
parent
f72279a824
commit
cf9cf13330
@ -75,7 +75,7 @@ native_transfers AS (
|
||||
to_address = '0x25ab3efd52e6470681ce037cd546dc60726948d3'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND et._inserted_timestamp >= (
|
||||
AND _inserted_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '12 hours'
|
||||
FROM
|
||||
|
||||
@ -21,14 +21,18 @@ WITH created_pools AS(
|
||||
segmented_data [1] :: STRING
|
||||
) :: INTEGER AS pool_number,
|
||||
CONCAT('0x', SUBSTR(segmented_data [0] :: STRING, 25, 40)) AS pool_address,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp
|
||||
FROM
|
||||
{{ ref('silver__logs') }}
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
WHERE
|
||||
topics [0] = '0x2128d88d14c80cb081c1252a5acff7a264671bf199ce226b53788fb26065005e'
|
||||
AND contract_address = '0x420dd381b31aef6683db6b902084cb0ffece40da'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -21,14 +21,18 @@ WITH created_pools AS (
|
||||
topics [3] :: STRING
|
||||
) :: INTEGER AS tick_spacing,
|
||||
CONCAT('0x', SUBSTR(segmented_data [0] :: STRING, 25, 40)) AS pool_address,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp
|
||||
FROM
|
||||
{{ ref('silver__logs') }}
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
WHERE
|
||||
topics [0] = '0xab0d57f0df537bb25e80245ef7748fa62353808c54d6e528a9dd20887aed9ac2'
|
||||
AND contract_address = lower('0x5e7BB104d84c7CB9B682AaC2F3d509f5F406809A')
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND contract_address = LOWER('0x5e7BB104d84c7CB9B682AaC2F3d509f5F406809A')
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
@ -50,13 +54,17 @@ initial_info AS (
|
||||
1.0001,
|
||||
init_tick
|
||||
) AS init_price_1_0_unadj,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp
|
||||
FROM
|
||||
{{ ref('silver__logs') }}
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
WHERE
|
||||
topics [0] :: STRING = '0x98636036cb66a9c19a37435efc1e90142190214e8abeb821bdba3f2990dd4c95'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -34,17 +34,17 @@ WITH base_swaps AS (
|
||||
segmented_data [4] :: STRING
|
||||
) :: FLOAT AS tick
|
||||
FROM
|
||||
{{ ref('silver__logs') }}
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
WHERE
|
||||
topics [0] :: STRING = '0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
AND event_removed = 'false'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
AND modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(
|
||||
_inserted_timestamp
|
||||
_inserted_timestamp
|
||||
) - INTERVAL '12 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
@ -75,8 +75,12 @@ FINAL AS (
|
||||
event_index,
|
||||
token0_address,
|
||||
token1_address,
|
||||
_log_id,
|
||||
_inserted_timestamp,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
@ -92,4 +96,4 @@ SELECT
|
||||
FROM
|
||||
FINAL qualify(ROW_NUMBER() over(PARTITION BY _log_id
|
||||
ORDER BY
|
||||
_inserted_timestamp DESC)) = 1
|
||||
_inserted_timestamp DESC)) = 1
|
||||
|
||||
@ -50,15 +50,19 @@ swaps_base AS (
|
||||
CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) AS tx_to,
|
||||
token0,
|
||||
token1,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp
|
||||
FROM
|
||||
{{ ref('silver__logs') }}
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
INNER JOIN pools p
|
||||
ON p.pool_address = contract_address
|
||||
WHERE
|
||||
topics [0] :: STRING = '0xb3e2773606abfd36b5bd91394b3a54d1398336c65005baf7bf7a05efeffaf75b'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -20,14 +20,18 @@ WITH pool_creation AS (
|
||||
utils.udf_hex_to_int(
|
||||
segmented_data [1] :: STRING
|
||||
) :: INT AS pool_id,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp
|
||||
FROM
|
||||
{{ ref ('silver__logs') }}
|
||||
{{ ref ('core__fact_event_logs') }}
|
||||
WHERE
|
||||
contract_address = LOWER('0x3E84D913803b02A4a7f027165E8cA42C14C0FdE7')
|
||||
AND topics [0] :: STRING = '0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9' --PairCreated
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -50,15 +50,19 @@ swaps_base AS (
|
||||
CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) AS tx_to,
|
||||
token0,
|
||||
token1,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp
|
||||
FROM
|
||||
{{ ref('silver__logs') }}
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
INNER JOIN pools p
|
||||
ON p.pool_address = contract_address
|
||||
WHERE
|
||||
topics [0] :: STRING = '0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -19,18 +19,22 @@ WITH pools_registered AS (
|
||||
1,
|
||||
42
|
||||
) AS pool_address,
|
||||
_log_id,
|
||||
_inserted_timestamp,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp,
|
||||
ROW_NUMBER() over (
|
||||
ORDER BY
|
||||
pool_address
|
||||
) AS row_num
|
||||
FROM
|
||||
{{ ref('silver__logs') }}
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
WHERE
|
||||
topics [0] :: STRING = '0x3c13bc30b8e878c53fd2a36b679409c073afd75950be43d8858768e956fbc20e' --PoolRegistered
|
||||
AND contract_address = '0xba12222222228d8ba445958a75a0704d566bf2c8'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
@ -49,8 +53,8 @@ tokens_registered AS (
|
||||
event_index,
|
||||
tx_hash,
|
||||
contract_address,
|
||||
decoded_flat :poolId :: STRING AS pool_id,
|
||||
decoded_flat :tokens AS tokens,
|
||||
decoded_log :poolId :: STRING AS pool_id,
|
||||
decoded_log :tokens AS tokens,
|
||||
tokens [0] :: STRING AS token0,
|
||||
tokens [1] :: STRING AS token1,
|
||||
tokens [2] :: STRING AS token2,
|
||||
@ -59,11 +63,15 @@ tokens_registered AS (
|
||||
tokens [5] :: STRING AS token5,
|
||||
tokens [6] :: STRING AS token6,
|
||||
tokens [7] :: STRING AS token7,
|
||||
decoded_flat :assetManagers AS asset_managers,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
decoded_log :assetManagers AS asset_managers,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp
|
||||
FROM
|
||||
{{ ref('silver__decoded_logs') }}
|
||||
{{ ref('core__ez_decoded_event_logs') }}
|
||||
WHERE
|
||||
topics [0] :: STRING = '0xf5847d3f2197b16cdcd2098ec95d0905cd1abdaf415f07bb7cef2bba8ac5dec4' --TokensRegistered
|
||||
AND contract_address = '0xba12222222228d8ba445958a75a0704d566bf2c8'
|
||||
@ -73,7 +81,7 @@ tokens_registered AS (
|
||||
FROM
|
||||
pools_registered
|
||||
)
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
),
|
||||
function_sigs AS (
|
||||
SELECT
|
||||
|
||||
@ -23,7 +23,7 @@ swaps_base AS (
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
contract_address,
|
||||
_inserted_timestamp,
|
||||
modified_timestamp AS _inserted_timestamp,
|
||||
'Swap' AS event_name,
|
||||
event_index,
|
||||
regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data,
|
||||
@ -51,25 +51,29 @@ swaps_base AS (
|
||||
1,
|
||||
42
|
||||
) AS pool_address,
|
||||
_log_id,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
'balancer' AS platform,
|
||||
origin_from_address AS sender,
|
||||
origin_from_address AS tx_to
|
||||
FROM
|
||||
{{ ref('silver__logs') }}
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
WHERE
|
||||
topics [0] :: STRING = '0x2170c741c41531aec20e7c107c24eecfdd15e69c9bb0a8dd37b1840b9e0b207b'
|
||||
AND contract_address = '0xba12222222228d8ba445958a75a0704d566bf2c8'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
AND modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '12 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
AND modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
)
|
||||
SELECT
|
||||
|
||||
@ -20,14 +20,18 @@ WITH pool_creation AS (
|
||||
utils.udf_hex_to_int(
|
||||
segmented_data [1] :: STRING
|
||||
) :: INT AS pool_id,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp
|
||||
FROM
|
||||
{{ ref ('silver__logs') }}
|
||||
{{ ref ('core__fact_event_logs') }}
|
||||
WHERE
|
||||
contract_address = '0xfda619b6d20975be80a10332cd39b9a4b0faa8bb' --factory
|
||||
AND topics [0] :: STRING = '0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9' --PairCreated
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -50,15 +50,19 @@ swaps_base AS (
|
||||
CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) AS tx_to,
|
||||
token0,
|
||||
token1,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp
|
||||
FROM
|
||||
{{ ref('silver__logs') }}
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
INNER JOIN pools p
|
||||
ON p.pool_address = contract_address
|
||||
WHERE
|
||||
topics [0] :: STRING = '0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -40,8 +40,8 @@ WITH contract_deployments AS (
|
||||
'0x3093f9b57a428f3eb6285a589cb35bea6e78c336',
|
||||
'0x5ef72230578b3e399e6c6f4f6360edf95e83bbfd'
|
||||
)
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND trace_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
AND trace_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -65,10 +65,14 @@ curve_base AS (
|
||||
segmented_data [3] :: STRING
|
||||
)
|
||||
) AS tokens_bought,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp
|
||||
FROM
|
||||
{{ ref('silver__logs') }}
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
l
|
||||
INNER JOIN pools p
|
||||
ON p.pool_address = l.contract_address
|
||||
@ -78,7 +82,7 @@ curve_base AS (
|
||||
'0xb2e76ae99761dc136e598d4a629bb347eccb9532a5f8bbd72e18467c3c34cc98',
|
||||
'0xd013ca23e77a65003c2c659c5442c00c805371b7fc1ebd4c206c41d1536bd90b'
|
||||
)
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
@ -138,7 +142,7 @@ token_transfers AS (
|
||||
CONCAT('0x', SUBSTR(topics [1] :: STRING, 27, 40)) AS from_address,
|
||||
CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) AS to_address
|
||||
FROM
|
||||
{{ ref('silver__logs') }}
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
WHERE
|
||||
topics [0] :: STRING = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'
|
||||
AND tx_hash IN (
|
||||
@ -150,13 +154,13 @@ token_transfers AS (
|
||||
AND CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) <> '0x0000000000000000000000000000000000000000'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
AND modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '12 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
AND modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
),
|
||||
from_transfers AS (
|
||||
|
||||
@ -25,14 +25,18 @@ WITH created_pools AS (
|
||||
segmented_data [0] :: STRING
|
||||
) :: INTEGER AS tick_spacing,
|
||||
CONCAT('0x', SUBSTR(segmented_data [1] :: STRING, 25, 40)) AS pool_address,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp
|
||||
FROM
|
||||
{{ ref('silver__logs') }}
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
WHERE
|
||||
topics [0] = '0x783cca1c0412dd0d695e784568c96da2e9c22ff989357a2e8b1d9b2b4e6b7118'
|
||||
AND contract_address = '0x3d237ac6d2f425d2e890cc99198818cc1fa48870'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
@ -54,13 +58,17 @@ initial_info AS (
|
||||
1.0001,
|
||||
init_tick
|
||||
) AS init_price_1_0_unadj,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp
|
||||
FROM
|
||||
{{ ref('silver__logs') }}
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
WHERE
|
||||
topics [0] :: STRING = '0x98636036cb66a9c19a37435efc1e90142190214e8abeb821bdba3f2990dd4c95'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -34,20 +34,20 @@ WITH base_swaps AS (
|
||||
segmented_data [4] :: STRING
|
||||
) :: FLOAT AS tick
|
||||
FROM
|
||||
{{ ref('silver__logs') }}
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
WHERE
|
||||
topics [0] :: STRING = '0x19b47279256b2a23a1665c810c8d55a1758940ee09377d4f8d26497a3577dc83'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
AND event_removed = 'false'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
AND modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '12 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
AND modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
),
|
||||
pool_data AS (
|
||||
@ -77,8 +77,12 @@ FINAL AS (
|
||||
event_index,
|
||||
token0_address,
|
||||
token1_address,
|
||||
_log_id,
|
||||
_inserted_timestamp,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
|
||||
@ -43,14 +43,18 @@ WITH pools AS (
|
||||
) AS protocolFeeRatio,
|
||||
CONCAT('0x', SUBSTR(segmented_data [6] :: STRING, 25, 40)) AS tokenA,
|
||||
CONCAT('0x', SUBSTR(segmented_data [7] :: STRING, 25, 40)) AS tokenB,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp
|
||||
FROM
|
||||
{{ ref ('silver__logs') }}
|
||||
{{ ref ('core__fact_event_logs') }}
|
||||
WHERE
|
||||
contract_address = '0xb2855783a346735e4aae0c1eb894def861fa9b45'
|
||||
AND topics [0] :: STRING = '0x9b3fb3a17b4e94eb4d1217257372dcc712218fcd4bc1c28482bd8a6804a7c775'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -76,16 +76,20 @@ swaps_base AS (
|
||||
) AS activeTick,
|
||||
tokenA,
|
||||
tokenB,
|
||||
l._log_id,
|
||||
l._inserted_timestamp
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp
|
||||
FROM
|
||||
{{ ref('silver__logs') }}
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
l
|
||||
INNER JOIN pools
|
||||
ON l.contract_address = pool_address
|
||||
WHERE
|
||||
l.topics [0] :: STRING = '0x3b841dc9ab51e3104bda4f61b41e4271192d22cd19da5ee6e292dc8e2744f713' --Swap
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -25,14 +25,18 @@ WITH created_pools AS (
|
||||
segmented_data [0] :: STRING
|
||||
) :: INTEGER AS tick_spacing,
|
||||
CONCAT('0x', SUBSTR(segmented_data [1] :: STRING, 25, 40)) AS pool_address,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp
|
||||
FROM
|
||||
{{ ref('silver__logs') }}
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
WHERE
|
||||
topics [0] = '0x783cca1c0412dd0d695e784568c96da2e9c22ff989357a2e8b1d9b2b4e6b7118'
|
||||
AND contract_address = '0xc35dadb65012ec5796536bd9864ed8773abc74c4'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
@ -55,13 +59,17 @@ initial_info AS (
|
||||
1.0001,
|
||||
init_tick
|
||||
) AS init_price_1_0_unadj,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp
|
||||
FROM
|
||||
{{ ref('silver__logs') }}
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
WHERE
|
||||
topics [0] :: STRING = '0x98636036cb66a9c19a37435efc1e90142190214e8abeb821bdba3f2990dd4c95'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -34,20 +34,20 @@ WITH base_swaps AS (
|
||||
segmented_data [4] :: STRING
|
||||
) :: FLOAT AS tick
|
||||
FROM
|
||||
{{ ref('silver__logs') }}
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
WHERE
|
||||
topics [0] :: STRING = '0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
AND event_removed = 'false'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
AND modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '12 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
AND modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
),
|
||||
pool_data AS (
|
||||
@ -77,8 +77,12 @@ FINAL AS (
|
||||
event_index,
|
||||
token0_address,
|
||||
token1_address,
|
||||
_log_id,
|
||||
_inserted_timestamp,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
|
||||
@ -20,14 +20,18 @@ WITH pool_creation AS (
|
||||
utils.udf_hex_to_int(
|
||||
segmented_data [1] :: STRING
|
||||
) :: INT AS pool_id,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp
|
||||
FROM
|
||||
{{ ref ('silver__logs') }}
|
||||
{{ ref ('core__fact_event_logs') }}
|
||||
WHERE
|
||||
contract_address = '0x04c9f118d21e8b767d2e50c946f0cc9f6c367300' --factory
|
||||
AND topics [0] :: STRING = '0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9' --PairCreated
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -50,15 +50,19 @@ swaps_base AS (
|
||||
CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) AS tx_to,
|
||||
token0,
|
||||
token1,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp
|
||||
FROM
|
||||
{{ ref('silver__logs') }}
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
INNER JOIN pools p
|
||||
ON p.pool_address = contract_address
|
||||
WHERE
|
||||
topics [0] :: STRING = '0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -20,14 +20,18 @@ WITH pool_creation AS (
|
||||
utils.udf_hex_to_int(
|
||||
segmented_data [1] :: STRING
|
||||
) :: INT AS pool_id,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp
|
||||
FROM
|
||||
{{ ref ('silver__logs') }}
|
||||
{{ ref ('core__fact_event_logs') }}
|
||||
WHERE
|
||||
contract_address = LOWER('0x8909Dc15e40173Ff4699343b6eB8132c65e18eC6')
|
||||
AND topics [0] :: STRING = '0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9' --PairCreated
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -50,15 +50,19 @@ swaps_base AS (
|
||||
CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) AS tx_to,
|
||||
token0,
|
||||
token1,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp
|
||||
FROM
|
||||
{{ ref('silver__logs') }}
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
INNER JOIN pools p
|
||||
ON p.pool_address = contract_address
|
||||
WHERE
|
||||
topics [0] :: STRING = '0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -25,14 +25,18 @@ WITH created_pools AS (
|
||||
segmented_data [0] :: STRING
|
||||
) :: INTEGER AS tick_spacing,
|
||||
CONCAT('0x', SUBSTR(segmented_data [1] :: STRING, 25, 40)) AS pool_address,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp
|
||||
FROM
|
||||
{{ ref('silver__logs') }}
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
WHERE
|
||||
topics [0] = '0x783cca1c0412dd0d695e784568c96da2e9c22ff989357a2e8b1d9b2b4e6b7118'
|
||||
AND contract_address = '0x33128a8fc17869897dce68ed026d694621f6fdfd'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
@ -54,13 +58,17 @@ initial_info AS (
|
||||
1.0001,
|
||||
init_tick
|
||||
) AS init_price_1_0_unadj,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp
|
||||
FROM
|
||||
{{ ref('silver__logs') }}
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
WHERE
|
||||
topics [0] :: STRING = '0x98636036cb66a9c19a37435efc1e90142190214e8abeb821bdba3f2990dd4c95'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -34,21 +34,21 @@ WITH base_swaps AS (
|
||||
segmented_data [4] :: STRING
|
||||
) :: FLOAT AS tick
|
||||
FROM
|
||||
{{ ref('silver__logs') }}
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
WHERE
|
||||
block_timestamp :: DATE > '2021-04-01'
|
||||
AND topics [0] :: STRING = '0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67'
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
AND event_removed = 'false'
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
AND modified_timestamp >= (
|
||||
SELECT
|
||||
MAX(_inserted_timestamp) - INTERVAL '12 hours'
|
||||
FROM
|
||||
{{ this }}
|
||||
)
|
||||
AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
AND modified_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
),
|
||||
pool_data AS (
|
||||
@ -78,8 +78,12 @@ FINAL AS (
|
||||
event_index,
|
||||
token0_address,
|
||||
token1_address,
|
||||
_log_id,
|
||||
_inserted_timestamp,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
|
||||
@ -62,14 +62,18 @@ WITH swaps_base AS (
|
||||
segmented_data [6] :: STRING
|
||||
)
|
||||
) AS feeBasisPoints,
|
||||
_log_id,
|
||||
_inserted_timestamp
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp
|
||||
FROM
|
||||
{{ ref('silver__logs') }}
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
WHERE
|
||||
contract_address = '0x4f188afdc40e6d2ddddf5fd1b2df7aef7da52f50' --Vault
|
||||
AND topics [0] :: STRING = '0x0874b2d545cb271cdbda4e093020c452328b24af12382ed62c4d00f5c26709db' --Swap
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
@ -52,10 +52,14 @@ WITH router_swaps_base AS (
|
||||
40
|
||||
)
|
||||
) AS rebateTo,
|
||||
l._log_id,
|
||||
l._inserted_timestamp
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp
|
||||
FROM
|
||||
{{ ref('silver__logs') }}
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
l
|
||||
WHERE
|
||||
contract_address IN (
|
||||
@ -67,7 +71,7 @@ WITH router_swaps_base AS (
|
||||
'0x27425e9fb6a9a625e8484cfd9620851d1fa322e5'
|
||||
) --v3
|
||||
AND topics [0] :: STRING = '0x27c98e911efdd224f4002f6cd831c3ad0d2759ee176f9ee8466d95826af22a1c' --WooRouterSwap
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
@ -119,10 +123,14 @@ swaps_base AS (
|
||||
40
|
||||
)
|
||||
) AS rebateTo,
|
||||
l._log_id,
|
||||
l._inserted_timestamp
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp
|
||||
FROM
|
||||
{{ ref('silver__logs') }}
|
||||
{{ ref('core__fact_event_logs') }}
|
||||
l
|
||||
WHERE
|
||||
contract_address IN (
|
||||
@ -145,7 +153,7 @@ swaps_base AS (
|
||||
FROM
|
||||
router_swaps_base
|
||||
)
|
||||
AND tx_status = 'SUCCESS'
|
||||
AND tx_succeeded
|
||||
|
||||
{% if is_incremental() %}
|
||||
AND _inserted_timestamp >= (
|
||||
|
||||
Loading…
Reference in New Issue
Block a user