arbitrum-models/models/silver/defi/dex/hashflow/silver_dex__hashflow_pools.sql
drethereum 288b86157a
AN-5990/arb-migration (#321)
* models - streamline - core , decoder

* delete bronze subfolders

* models - docs, gh

* silver - observablity, core, abis, prices, stats, nft transfers

* gold - stats, price, core, nft transfers

* sources

* tests, dbt project, packages, makefile, python folder, slack notify yml

* macros, and empty folders

* remove base

* update for fsc-evm changes - package, makefile, sources, dbt_project, workflows, docs

* gold tags

* silver bridge tags

* dex tags

* lending tags

* nft tags

* protocol tags

* temp package

* docs

* wh

* 48

---------

Co-authored-by: sam <sam@flipsidecrypto.com>
2025-05-08 10:03:03 -06:00

68 lines
1.5 KiB
SQL

{{ config(
materialized = 'incremental',
incremental_strategy = 'delete+insert',
unique_key = 'pool_address',
tags = ['silver_dex','defi','dex','curated']
) }}
WITH contract_deployments AS (
SELECT
tx_hash,
block_number,
block_timestamp,
from_address AS deployer_address,
to_address AS contract_address,
concat_ws(
'-',
block_number,
tx_position,
CONCAT(
TYPE,
'_',
trace_address
)
) AS _call_id,
modified_timestamp AS _inserted_timestamp
FROM
{{ ref('core__fact_traces') }}
WHERE
from_address IN (
'0xe43632337d3f9a52ffd098fe71a57cc5961c041f',
'0x63ae536fec0b57bdeb1fd6a893191b4239f61bff',
'0x75fb2ab4d5b0de8b1a1acdc9124887d35d459084'
)
AND TYPE ILIKE 'create%'
AND tx_succeeded
AND trace_succeeded
{% if is_incremental() %}
AND _inserted_timestamp >= (
SELECT
MAX(_inserted_timestamp) - INTERVAL '12 hours'
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,
block_timestamp,
deployer_address,
contract_address AS pool_address,
_call_id,
_inserted_timestamp
FROM
contract_deployments