mirror of
https://github.com/FlipsideCrypto/near-models.git
synced 2026-02-06 11:26:52 +00:00
upd gold and complete nft sales
This commit is contained in:
parent
bc94aa57dc
commit
d00cd22ec1
@ -5,7 +5,6 @@
|
||||
) }}
|
||||
|
||||
WITH nft_sales AS (
|
||||
|
||||
SELECT
|
||||
receipt_id,
|
||||
block_id,
|
||||
@ -29,8 +28,8 @@ WITH nft_sales AS (
|
||||
platform_fee,
|
||||
platform_fee_usd,
|
||||
nft_sales_id AS ez_nft_sales_id,
|
||||
COALESCE(inserted_timestamp, _inserted_timestamp, '2000-01-01' :: TIMESTAMP_NTZ) AS inserted_timestamp,
|
||||
COALESCE(modified_timestamp, _inserted_timestamp, '2000-01-01' :: TIMESTAMP_NTZ) AS modified_timestamp
|
||||
inserted_timestamp,
|
||||
modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver__nft_complete_nft_sales') }}
|
||||
)
|
||||
|
||||
@ -3,7 +3,10 @@ version: 2
|
||||
models:
|
||||
- name: nft__ez_nft_sales
|
||||
description: |-
|
||||
This table records all the NFT sales actions of the main Near marketplaces.
|
||||
This view provides a standardized interface for all NFT sales across NEAR marketplaces.
|
||||
It includes sales from Mintbase, Paras, and other marketplaces (Apollo42, TradePort, UniqArt, L2E, FewAndFar, Mitte).
|
||||
The view handles price conversions to USD and includes platform fees, royalties, and affiliate information where available.
|
||||
|
||||
columns:
|
||||
- name: RECEIPT_ID
|
||||
description: "{{ doc('receipt_id')}}"
|
||||
@ -12,12 +15,15 @@ models:
|
||||
|
||||
- name: BLOCK_ID
|
||||
description: "{{ doc('block_id')}}"
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: "{{ doc('block_timestamp')}}"
|
||||
tests:
|
||||
- not_null:
|
||||
where: inserted_timestamp <= current_timestamp - interval '10 hour'
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_of_type:
|
||||
column_type: TIMESTAMP_NTZ
|
||||
|
||||
- name: TX_HASH
|
||||
description: "{{ doc('tx_hash')}}"
|
||||
@ -33,26 +39,36 @@ models:
|
||||
description: "{{ doc('from_address')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: .*\.near$
|
||||
|
||||
- name: BUYER_ADDRESS
|
||||
description: "{{ doc('to_address')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: .*\.near$
|
||||
|
||||
- name: PLATFORM_ADDRESS
|
||||
description: "Platform Address"
|
||||
description: "The contract address of the NFT marketplace where the sale occurred"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: .*\.near$
|
||||
|
||||
- name: PLATFORM_NAME
|
||||
description: "Platform Name"
|
||||
description: "The name of the NFT marketplace (e.g., Mintbase, Paras, Apollo42, etc.)"
|
||||
tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values: ['Mintbase', 'Paras', 'Apollo42', 'TradePort', 'UniqArt', 'L2E', 'FewAndFar', 'Mitte']
|
||||
|
||||
- name: NFT_ADDRESS
|
||||
description: "NFT Address"
|
||||
description: "The contract address of the NFT collection"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: .*\.near$
|
||||
|
||||
- name: TOKEN_ID
|
||||
description: "{{ doc('token_id')}}"
|
||||
@ -63,9 +79,18 @@ models:
|
||||
description: "{{ doc('raw_price')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_of_type:
|
||||
column_type: FLOAT
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
|
||||
- name: PRICE_USD
|
||||
description: "{{ doc('price_usd')}}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_of_type:
|
||||
column_type: FLOAT
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
|
||||
- name: METHOD_NAME
|
||||
description: "{{ doc('method_name')}}"
|
||||
@ -77,26 +102,46 @@ models:
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: LOGS_INDEX
|
||||
description: "ROW NUMBER"
|
||||
|
||||
- name: AFFILIATE_ID
|
||||
description: "{{ doc('affiliate_id')}}"
|
||||
|
||||
- name: AFFILIATE_AMOUNT
|
||||
description: "{{ doc('affiliate_amount')}}"
|
||||
|
||||
- name: AFFILIATE_AMOUNT_USD
|
||||
description: "The USD value of the affiliate amount at the time of the sale"
|
||||
|
||||
- name: ROYALTIES
|
||||
description: "{{ doc('royalties')}}"
|
||||
|
||||
- name: PLATFORM_FEE
|
||||
description: "{{ doc('platform_fee')}}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
|
||||
- name: NFT_SALES_ID
|
||||
- name: PLATFORM_FEE_USD
|
||||
description: "The USD value of the platform fee at the time of the sale"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
|
||||
- name: EZ_NFT_SALES_ID
|
||||
description: "{{doc('id')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- unique
|
||||
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: "{{doc('inserted_timestamp')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_of_type:
|
||||
column_type: TIMESTAMP_NTZ
|
||||
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: "{{doc('modified_timestamp')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_of_type:
|
||||
column_type: TIMESTAMP_NTZ
|
||||
|
||||
@ -9,9 +9,9 @@
|
||||
) }}
|
||||
|
||||
WITH mintbase_nft_sales AS (
|
||||
|
||||
SELECT
|
||||
action_id,
|
||||
receipt_id,
|
||||
action_index,
|
||||
block_id,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
@ -25,12 +25,11 @@ WITH mintbase_nft_sales AS (
|
||||
method_name,
|
||||
LOG,
|
||||
price,
|
||||
logs_index,
|
||||
log_index AS logs_index,
|
||||
affiliate_id,
|
||||
affiliate_amount,
|
||||
royalties,
|
||||
platform_fee,
|
||||
_inserted_timestamp,
|
||||
_partition_by_block_number
|
||||
FROM
|
||||
{{ ref('silver__nft_mintbase_sales') }}
|
||||
@ -49,7 +48,8 @@ WITH mintbase_nft_sales AS (
|
||||
),
|
||||
paras_nft_sales AS (
|
||||
SELECT
|
||||
action_id,
|
||||
receipt_id,
|
||||
action_index,
|
||||
block_id,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
@ -63,12 +63,11 @@ paras_nft_sales AS (
|
||||
method_name,
|
||||
LOG,
|
||||
price,
|
||||
logs_index,
|
||||
0 AS logs_index,
|
||||
affiliate_id,
|
||||
affiliate_amount,
|
||||
royalties,
|
||||
platform_fee,
|
||||
_inserted_timestamp,
|
||||
_partition_by_block_number
|
||||
FROM
|
||||
{{ ref('silver__nft_paras_sales') }}
|
||||
@ -87,7 +86,8 @@ paras_nft_sales AS (
|
||||
),
|
||||
other_nft_sales AS (
|
||||
SELECT
|
||||
action_id,
|
||||
receipt_id,
|
||||
action_index,
|
||||
block_id,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
@ -101,12 +101,11 @@ other_nft_sales AS (
|
||||
method_name,
|
||||
LOG,
|
||||
price,
|
||||
logs_index,
|
||||
affiliate_id,
|
||||
affiliate_amount,
|
||||
royalties,
|
||||
platform_fee,
|
||||
_inserted_timestamp,
|
||||
0 AS logs_index,
|
||||
NULL AS affiliate_id,
|
||||
NULL AS affiliate_amount,
|
||||
NULL AS royalties,
|
||||
NULL AS platform_fee,
|
||||
_partition_by_block_number
|
||||
FROM
|
||||
{{ ref('silver__nft_other_sales') }}
|
||||
@ -132,7 +131,6 @@ prices AS (
|
||||
) AS block_timestamp_hour,
|
||||
price as price_usd
|
||||
FROM
|
||||
|
||||
{{ ref('silver__complete_token_prices') }}
|
||||
WHERE
|
||||
token_address = 'wrap.near' qualify ROW_NUMBER() over (
|
||||
@ -157,11 +155,10 @@ sales_union AS (
|
||||
*
|
||||
FROM
|
||||
other_nft_sales
|
||||
|
||||
),
|
||||
FINAL AS (
|
||||
SELECT
|
||||
split_part(action_id, '-', 1) AS receipt_id,
|
||||
receipt_id,
|
||||
block_id,
|
||||
block_timestamp,
|
||||
tx_hash,
|
||||
@ -183,7 +180,6 @@ FINAL AS (
|
||||
royalties,
|
||||
platform_fee AS platform_fee,
|
||||
platform_fee * p.price_usd AS platform_fee_usd,
|
||||
_inserted_timestamp,
|
||||
_partition_by_block_number
|
||||
FROM
|
||||
sales_union s
|
||||
|
||||
@ -3,56 +3,108 @@ version: 2
|
||||
models:
|
||||
- name: silver__nft_complete_nft_sales
|
||||
description: |-
|
||||
This table records all the NFT sales actions of the mainy Near marketplaces..
|
||||
This table records all NFT sales actions across the main NEAR marketplaces, including Mintbase, Paras, and other marketplaces like Apollo42, TradePort, and Mitte.
|
||||
The model combines data from marketplace-specific models and standardizes the output format.
|
||||
|
||||
columns:
|
||||
- name: RECEIPT_ID
|
||||
description: "{{ doc('receipt_id')}}"
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: BLOCK_ID
|
||||
description: "{{ doc('block_id')}}"
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: "{{ doc('block_timestamp')}}"
|
||||
tests:
|
||||
- not_null:
|
||||
where: _inserted_timestamp <= current_timestamp - interval '10 hour'
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_of_type:
|
||||
column_type: TIMESTAMP_NTZ
|
||||
|
||||
- name: TX_HASH
|
||||
description: "{{ doc('tx_hash')}}"
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: GAS_BURNED
|
||||
description: "{{ doc('attached_gas')}}"
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: SELLER_ADDRESS
|
||||
description: "{{ doc('from_address')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: .*\.near$
|
||||
|
||||
- name: BUYER_ADDRESS
|
||||
description: "{{ doc('to_address')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: .*\.near$
|
||||
|
||||
- name: PLATFORM_ADDRESS
|
||||
description: "{{ doc('tx_signer')}}"
|
||||
description: "The contract address of the NFT marketplace where the sale occurred"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: .*\.near$
|
||||
|
||||
- name: PLATFORM_NAME
|
||||
description: "Platform Name"
|
||||
description: "The name of the NFT marketplace (e.g., Mintbase, Paras, Apollo42, etc.)"
|
||||
tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values: ['Mintbase', 'Paras', 'Apollo42', 'TradePort', 'UniqArt', 'L2E', 'FewAndFar', 'Mitte']
|
||||
|
||||
- name: NFT_ADDRESS
|
||||
description: "NFT Address"
|
||||
description: "The contract address of the NFT collection"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_match_regex:
|
||||
regex: .*\.near$
|
||||
|
||||
- name: TOKEN_ID
|
||||
description: "{{ doc('token_id')}}"
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: PRICE
|
||||
description: "{{ doc('raw_price')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_of_type:
|
||||
column_type: FLOAT
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
|
||||
- name: PRICE_USD
|
||||
description: "{{ doc('price_usd')}}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_of_type:
|
||||
column_type: FLOAT
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
|
||||
- name: METHOD_NAME
|
||||
description: "{{ doc('method_name')}}"
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: LOGS
|
||||
- name: LOG
|
||||
description: "{{ doc('logs')}}"
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: LOGS_INDEX
|
||||
description: "The index of the log entry for this sale, used to maintain order and uniqueness"
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: AFFILIATE_ID
|
||||
description: "{{ doc('affiliate_id')}}"
|
||||
@ -60,14 +112,25 @@ models:
|
||||
- name: AFFILIATE_AMOUNT
|
||||
description: "{{ doc('affiliate_amount')}}"
|
||||
|
||||
- name: AFFILIATE_AMOUNT_USD
|
||||
description: "The USD value of the affiliate amount at the time of the sale"
|
||||
|
||||
- name: ROYALTIES
|
||||
description: "{{ doc('royalties')}}"
|
||||
|
||||
- name: PLATFORM_FEE
|
||||
description: "{{ doc('platform_fee')}}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
include_null: true
|
||||
|
||||
- name: _INSERTED_TIMESTAMP
|
||||
description: "{{ doc('_inserted_timestamp')}}"
|
||||
- name: PLATFORM_FEE_USD
|
||||
description: "The USD value of the platform fee at the time of the sale"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
include_null: true
|
||||
|
||||
- name: _PARTITION_BY_BLOCK_NUMBER
|
||||
description: "{{ doc('_partition_by_block_number')}}"
|
||||
@ -80,9 +143,19 @@ models:
|
||||
|
||||
- name: INSERTED_TIMESTAMP
|
||||
description: "{{doc('inserted_timestamp')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_of_type:
|
||||
column_type: TIMESTAMP_NTZ
|
||||
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: "{{doc('modified_timestamp')}}"
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_expectations.expect_column_values_to_be_of_type:
|
||||
column_type: TIMESTAMP_NTZ
|
||||
|
||||
- name: _INVOCATION_ID
|
||||
description: "{{doc('invocation_id')}}"
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
Loading…
Reference in New Issue
Block a user