mirror of
https://github.com/FlipsideCrypto/optimism-models.git
synced 2026-02-06 11:01:44 +00:00
clean final tables
This commit is contained in:
parent
7bd255206c
commit
6c0745de7d
@ -75,31 +75,25 @@ AND _inserted_timestamp >= (
|
||||
)
|
||||
AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day'
|
||||
{% endif %}
|
||||
),
|
||||
FINAL AS (
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
p.contract_address,
|
||||
token0_address,
|
||||
token1_address,
|
||||
tick_spacing,
|
||||
pool_address,
|
||||
COALESCE(
|
||||
init_tick,
|
||||
0
|
||||
) AS init_tick,
|
||||
p._log_id AS _id,
|
||||
p._inserted_timestamp
|
||||
FROM
|
||||
created_pools p
|
||||
LEFT JOIN initial_info i
|
||||
ON p.pool_address = i.contract_address
|
||||
)
|
||||
SELECT
|
||||
*
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
p.contract_address,
|
||||
token0_address,
|
||||
token1_address,
|
||||
tick_spacing,
|
||||
pool_address,
|
||||
COALESCE(
|
||||
init_tick,
|
||||
0
|
||||
) AS init_tick,
|
||||
p._log_id AS _id,
|
||||
p._inserted_timestamp
|
||||
FROM
|
||||
FINAL qualify(ROW_NUMBER() over(PARTITION BY pool_address
|
||||
created_pools p
|
||||
LEFT JOIN initial_info i
|
||||
ON p.pool_address = i.contract_address qualify(ROW_NUMBER() over(PARTITION BY p.pool_address
|
||||
ORDER BY
|
||||
_inserted_timestamp DESC)) = 1
|
||||
p._inserted_timestamp DESC)) = 1
|
||||
|
||||
@ -59,43 +59,37 @@ pool_data AS (
|
||||
pool_address
|
||||
FROM
|
||||
{{ ref('silver_dex__velodrome_v3_pools') }}
|
||||
),
|
||||
FINAL AS (
|
||||
SELECT
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
contract_address AS pool_address,
|
||||
contract_address,
|
||||
recipient,
|
||||
sender,
|
||||
tick,
|
||||
tick_spacing,
|
||||
liquidity,
|
||||
event_index,
|
||||
token0_address,
|
||||
token1_address,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
amount0_unadj,
|
||||
amount1_unadj,
|
||||
'Swap' AS event_name,
|
||||
'velodrome-v3' AS platform
|
||||
FROM
|
||||
base_swaps
|
||||
INNER JOIN pool_data
|
||||
ON pool_data.pool_address = base_swaps.contract_address
|
||||
)
|
||||
SELECT
|
||||
*
|
||||
block_number,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
contract_address AS pool_address,
|
||||
contract_address,
|
||||
recipient,
|
||||
sender,
|
||||
tick,
|
||||
tick_spacing,
|
||||
liquidity,
|
||||
event_index,
|
||||
token0_address,
|
||||
token1_address,
|
||||
CONCAT(
|
||||
tx_hash :: STRING,
|
||||
'-',
|
||||
event_index :: STRING
|
||||
) AS _log_id,
|
||||
modified_timestamp AS _inserted_timestamp,
|
||||
origin_function_signature,
|
||||
origin_from_address,
|
||||
origin_to_address,
|
||||
amount0_unadj,
|
||||
amount1_unadj,
|
||||
'Swap' AS event_name,
|
||||
'velodrome-v3' AS platform
|
||||
FROM
|
||||
FINAL qualify(ROW_NUMBER() over(PARTITION BY _log_id
|
||||
base_swaps
|
||||
INNER JOIN pool_data
|
||||
ON pool_data.pool_address = base_swaps.contract_address qualify(ROW_NUMBER() over(PARTITION BY _log_id
|
||||
ORDER BY
|
||||
_inserted_timestamp DESC)) = 1
|
||||
_inserted_timestamp DESC)) = 1
|
||||
|
||||
Loading…
Reference in New Issue
Block a user