Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions models/ethereum/nft/ethereum__nft_events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,51 @@ with nft as (
block_timestamp >= getdate() - interval '9 months'
{% endif %}

UNION

SELECT
event_platform,
tx_id,
block_timestamp,
event_type,
contract_address,
token_id,
event_from,
event_to,
price,
platform_fee,
creator_fee,
tx_currency
FROM {{ ref('ethereum_dbt__euler_beats_mint_original') }}
WHERE
{% if is_incremental() %}
block_timestamp >= getdate() - interval '1 days'
{% else %}
block_timestamp >= getdate() - interval '9 months'
{% endif %}

UNION

SELECT
event_platform,
tx_id,
block_timestamp,
event_type,
contract_address,
token_id,
event_from,
event_to,
price,
platform_fee,
creator_fee,
tx_currency
FROM {{ ref('ethereum_dbt__euler_beats_print_minted') }}
WHERE
{% if is_incremental() %}
block_timestamp >= getdate() - interval '1 days'
{% else %}
block_timestamp >= getdate() - interval '9 months'
{% endif %}
),

price as (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{{
config(
materialized='incremental',
sort='block_timestamp',
unique_key='tx_id',
incremental_strategy='delete+insert',
tags=['snowflake', 'ethereum', 'nft']
)
}}

WITH mints AS (

SELECT
'eulerbeats' AS event_platform,
tx_id,
block_timestamp,
'mint_original' AS event_type,
contract_address,
'eulerbeats' AS project_name,
event_inputs:seed AS token_id,
'0x0000000000000000000000000000000000000000' AS event_from,
event_inputs:to AS event_to
FROM {{ ref('ethereum__events_emitted') }}

WHERE contract_address IN ('0x8754f54074400ce745a7ceddc928fb1b7e985ed6',
'0xa98771a46dcb34b34cdad5355718f8a97c8e603e')
AND event_name = 'MintOriginal'
)

SELECT
event_platform,
eue.tx_id,
eue.block_timestamp,
mints.event_type,
mints.contract_address,
project_name,
token_id,
event_from,
event_to,
amount AS price,
--price_usd added later
amount AS platform_fee,
0 AS creator_fee,
'ETH' AS tx_currency
FROM {{ ref('ethereum__udm_events') }} eue

JOIN mints
ON eue.tx_id = mints.tx_id

WHERE eue.block_timestamp >= (SELECT min(block_timestamp)
FROM mints)

AND eue.tx_id IN (SELECT tx_id
FROM mints)

AND symbol = 'ETH'
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{{
config(
materialized='incremental',
sort='block_timestamp',
unique_key='tx_id',
incremental_strategy='delete+insert',
tags=['snowflake', 'ethereum', 'nft']
)
}}

WITH mints AS (
SELECT
'eulerbeats' AS event_platform,
tx_id,
block_timestamp,
'print_minted' AS event_type,
'eulerbeats' AS project_name,
contract_address,
event_inputs:seed AS token_id,
'0x0000000000000000000000000000000000000000' AS event_from,
event_inputs:to AS event_to,
event_inputs:royaltyPaid / power(10, 18) AS creator_fee
FROM {{ ref('ethereum__events_emitted') }}

WHERE contract_address IN ('0x8754f54074400ce745a7ceddc928fb1b7e985ed6',
'0xa98771a46dcb34b34cdad5355718f8a97c8e603e')
AND event_name = 'PrintMinted'
)

SELECT
event_platform,
eue.tx_id,
eue.block_timestamp,
mints.event_type,
mints.contract_address,
project_name,
token_id,
event_from,
event_to,
amount AS price,
--price_usd added later
0 AS platform_fee,
creator_fee,
'ETH' AS tx_currency
FROM {{ ref('ethereum__udm_events') }} eue

JOIN mints
ON eue.tx_id = mints.tx_id
AND eue.from_address = mints.event_to

WHERE eue.block_timestamp >= (SELECT min(block_timestamp)
FROM mints)

AND eue.tx_id IN (SELECT tx_id
FROM mints)

AND symbol = 'ETH'
17 changes: 17 additions & 0 deletions models/ethereum/nft/opensea/ethereum_dbt__opensea_sales.sql
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,23 @@ WITH token_transfers AS (
WHERE input_method = '0xab834bab')

AND token_id IS NOT NULL

UNION

SELECT
tx_id,
contract_addr AS contract_address,
event_inputs:from AS seller,
event_inputs:to AS buyer,
event_inputs:id AS token_id
FROM {{ source('ethereum', 'ethereum_events_emitted') }}
WHERE event_name = 'TransferSingle'

AND tx_id IN (SELECT tx_hash
FROM silver.ethereum_events
WHERE input_method = '0xab834bab')

AND token_id IS NOT NULL
),

nfts_per_tx AS (
Expand Down