mirror of
https://github.com/FlipsideCrypto/flow-models.git
synced 2026-02-06 15:51:48 +00:00
AN-1339/nft market (#25)
* topshot sales * add tx_succeeded * core nft sales * docs blocks * del ingested at * del last line
This commit is contained in:
parent
ab821e4154
commit
a005424621
33
models/core/core__fact_nft_sales.sql
Normal file
33
models/core/core__fact_nft_sales.sql
Normal file
@ -0,0 +1,33 @@
|
||||
{{ config(
|
||||
materialized = 'view'
|
||||
) }}
|
||||
|
||||
WITH silver_nfts AS (
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
{{ ref('silver__nft_sales') }}
|
||||
WHERE
|
||||
block_timestamp >= '2022-05-09'
|
||||
),
|
||||
gold_nfts AS (
|
||||
SELECT
|
||||
tx_id,
|
||||
block_height,
|
||||
block_timestamp,
|
||||
marketplace,
|
||||
nft_collection,
|
||||
nft_id,
|
||||
buyer,
|
||||
seller,
|
||||
price,
|
||||
currency,
|
||||
tx_succeeded
|
||||
FROM
|
||||
silver_nfts
|
||||
)
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
gold_nfts
|
||||
113
models/core/core__fact_nft_sales.yml
Normal file
113
models/core/core__fact_nft_sales.yml
Normal file
@ -0,0 +1,113 @@
|
||||
|
||||
version: 2
|
||||
|
||||
models:
|
||||
- name: core__fact_nft_sales
|
||||
description: |-
|
||||
NFT market sales on the Flow blockchain.
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- tx_id
|
||||
|
||||
columns:
|
||||
- name: tx_id
|
||||
description: "{{ doc('tx_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- unique
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: block_height
|
||||
description: "{{ doc('block_height') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
|
||||
- name: block_timestamp
|
||||
description: "{{ doc('block_timestamp') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 1
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_NTZ
|
||||
|
||||
- name: marketplace
|
||||
description: "{{ doc('marketplace') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: nft_collection
|
||||
description: "{{ doc('nft_collection') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: nft_id
|
||||
description: "{{ doc('nft_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
- NUMBER
|
||||
|
||||
- name: buyer
|
||||
description: "{{ doc('buyer') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: seller
|
||||
description: "{{ doc('seller') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: price
|
||||
description: "{{ doc('price') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
|
||||
- name: currency
|
||||
description: "{{ doc('currency') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: tx_succeeded
|
||||
description: "{{ doc('tx_succeeded') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- BOOLEAN
|
||||
5
models/descriptions/buyer.md
Normal file
5
models/descriptions/buyer.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs buyer %}
|
||||
|
||||
The party in the transaction purchasing the asset, this is an account address.
|
||||
|
||||
{% enddocs %}
|
||||
5
models/descriptions/currency.md
Normal file
5
models/descriptions/currency.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs currency %}
|
||||
|
||||
The contract address refering to the currency used in the transaction. This may or may not relate to a token in the prices table, depending on the marketplace or transaction.
|
||||
|
||||
{% enddocs %}
|
||||
5
models/descriptions/marketplace.md
Normal file
5
models/descriptions/marketplace.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs marketplace %}
|
||||
|
||||
Contract address for the marketplace where the transaction occurred.
|
||||
|
||||
{% enddocs %}
|
||||
5
models/descriptions/nft_collection.md
Normal file
5
models/descriptions/nft_collection.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs nft_collection %}
|
||||
|
||||
The contract address or ID for the NFT Collection.
|
||||
|
||||
{% enddocs %}
|
||||
5
models/descriptions/nft_id.md
Normal file
5
models/descriptions/nft_id.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs nft_id %}
|
||||
|
||||
The id of the NFT, usually a number.
|
||||
|
||||
{% enddocs %}
|
||||
5
models/descriptions/price.md
Normal file
5
models/descriptions/price.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs price %}
|
||||
|
||||
The price of the asset, in the currency specified in the table.
|
||||
|
||||
{% enddocs %}
|
||||
5
models/descriptions/seller.md
Normal file
5
models/descriptions/seller.md
Normal file
@ -0,0 +1,5 @@
|
||||
{% docs seller %}
|
||||
|
||||
The party in the transaction selling the asset, this is an account address.
|
||||
|
||||
{% enddocs %}
|
||||
23
models/silver/silver__nft_sales.sql
Normal file
23
models/silver/silver__nft_sales.sql
Normal file
@ -0,0 +1,23 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
cluster_by = ['_ingested_at::DATE, block_timestamp::DATE'],
|
||||
unique_key = 'tx_id'
|
||||
) }}
|
||||
|
||||
WITH topshot AS (
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
{{ ref('silver__nft_topshot_sales') }}
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
_ingested_at :: DATE >= CURRENT_DATE - 2
|
||||
{% endif %}
|
||||
)
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
topshot
|
||||
121
models/silver/silver__nft_sales.yml
Normal file
121
models/silver/silver__nft_sales.yml
Normal file
@ -0,0 +1,121 @@
|
||||
|
||||
version: 2
|
||||
|
||||
models:
|
||||
- name: silver__nft_sales
|
||||
description: |-
|
||||
NFT market sales on the Flow blockchain.
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- tx_id
|
||||
|
||||
columns:
|
||||
- name: tx_id
|
||||
description: "{{ doc('tx_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- unique
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: block_height
|
||||
description: "{{ doc('block_height') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
|
||||
- name: block_timestamp
|
||||
description: "{{ doc('block_timestamp') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 1
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_NTZ
|
||||
|
||||
- name: marketplace
|
||||
description: "{{ doc('marketplace') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: nft_collection
|
||||
description: "{{ doc('nft_collection') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: nft_id
|
||||
description: "{{ doc('nft_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
- NUMBER
|
||||
|
||||
- name: buyer
|
||||
description: "{{ doc('buyer') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: seller
|
||||
description: "{{ doc('seller') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: price
|
||||
description: "{{ doc('price') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
|
||||
- name: currency
|
||||
description: "{{ doc('currency') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: tx_succeeded
|
||||
description: "{{ doc('tx_succeeded') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- BOOLEAN
|
||||
|
||||
- name: _ingested_at
|
||||
description: "{{ doc('_ingested_at') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_NTZ
|
||||
90
models/silver/silver__nft_topshot_sales.sql
Normal file
90
models/silver/silver__nft_topshot_sales.sql
Normal file
@ -0,0 +1,90 @@
|
||||
{{ config(
|
||||
materialized = 'incremental',
|
||||
incremental_strategy = 'delete+insert',
|
||||
cluster_by = ['_ingested_at::DATE, block_timestamp::DATE'],
|
||||
unique_key = 'tx_id'
|
||||
) }}
|
||||
|
||||
WITH silver_events AS (
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
{{ ref('silver__events_final') }}
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE
|
||||
_ingested_at :: DATE >= CURRENT_DATE - 2
|
||||
{% endif %}
|
||||
),
|
||||
moment_data AS (
|
||||
SELECT
|
||||
block_height,
|
||||
block_timestamp,
|
||||
tx_id,
|
||||
event_contract :: STRING AS marketplace,
|
||||
event_data :id :: STRING AS nft_id,
|
||||
event_data :price :: NUMBER AS price,
|
||||
event_data :seller :: STRING AS seller,
|
||||
tx_succeeded,
|
||||
_ingested_at
|
||||
FROM
|
||||
silver_events
|
||||
WHERE
|
||||
event_type = 'MomentPurchased'
|
||||
AND event_contract LIKE 'A.c1e4f4f4c4257510%' -- topshot
|
||||
),
|
||||
currency_data AS (
|
||||
SELECT
|
||||
tx_id,
|
||||
event_contract :: STRING AS currency
|
||||
FROM
|
||||
silver_events
|
||||
WHERE
|
||||
tx_id IN (
|
||||
SELECT
|
||||
tx_id
|
||||
FROM
|
||||
moment_data
|
||||
)
|
||||
AND event_index = 0
|
||||
),
|
||||
nft_data AS (
|
||||
SELECT
|
||||
tx_id,
|
||||
event_contract :: STRING AS nft_collection,
|
||||
event_data :to :: STRING AS buyer
|
||||
FROM
|
||||
silver_events
|
||||
WHERE
|
||||
tx_id IN (
|
||||
SELECT
|
||||
tx_id
|
||||
FROM
|
||||
moment_data
|
||||
)
|
||||
AND event_type = 'Deposit'
|
||||
),
|
||||
combo AS (
|
||||
SELECT
|
||||
tx_id,
|
||||
block_height,
|
||||
block_timestamp,
|
||||
marketplace,
|
||||
nft_collection,
|
||||
nft_id,
|
||||
buyer,
|
||||
seller,
|
||||
price,
|
||||
currency,
|
||||
tx_succeeded,
|
||||
_ingested_at
|
||||
FROM
|
||||
moment_data
|
||||
LEFT JOIN currency_data USING (tx_id)
|
||||
LEFT JOIN nft_data USING (tx_id)
|
||||
)
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
combo
|
||||
121
models/silver/silver__nft_topshot_sales.yml
Normal file
121
models/silver/silver__nft_topshot_sales.yml
Normal file
@ -0,0 +1,121 @@
|
||||
|
||||
version: 2
|
||||
|
||||
models:
|
||||
- name: silver__nft_topshot_sales
|
||||
description: |-
|
||||
TopShot direct market sales on the Flow blockchain.
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- tx_id
|
||||
|
||||
columns:
|
||||
- name: tx_id
|
||||
description: "{{ doc('tx_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- unique
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: block_height
|
||||
description: "{{ doc('block_height') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
- FLOAT
|
||||
|
||||
- name: block_timestamp
|
||||
description: "{{ doc('block_timestamp') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_row_values_to_have_recent_data:
|
||||
datepart: day
|
||||
interval: 1
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_NTZ
|
||||
|
||||
- name: marketplace
|
||||
description: "{{ doc('marketplace') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: nft_collection
|
||||
description: "{{ doc('nft_collection') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: nft_id
|
||||
description: "{{ doc('nft_id') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
- NUMBER
|
||||
|
||||
- name: buyer
|
||||
description: "{{ doc('buyer') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: seller
|
||||
description: "{{ doc('seller') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: price
|
||||
description: "{{ doc('price') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- NUMBER
|
||||
|
||||
- name: currency
|
||||
description: "{{ doc('currency') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- STRING
|
||||
- VARCHAR
|
||||
|
||||
- name: tx_succeeded
|
||||
description: "{{ doc('tx_succeeded') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- BOOLEAN
|
||||
|
||||
- name: _ingested_at
|
||||
description: "{{ doc('_ingested_at') }}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_in_type_list:
|
||||
column_type_list:
|
||||
- TIMESTAMP_NTZ
|
||||
Loading…
Reference in New Issue
Block a user