diff --git a/models/silver/ntr/silver__ntr.sql b/models/silver/ntr/silver__ntr.sql new file mode 100644 index 0000000..291c9bf --- /dev/null +++ b/models/silver/ntr/silver__ntr.sql @@ -0,0 +1,67 @@ +{{ config( + materialized = 'incremental', + unique_key = "CONCAT_WS('-', blockchain, symbol, address, xfer_date)", + incremental_strategy = 'delete+insert', + tags = ['snowflake', 'ntr', 'crosschain'] +) }} + +SELECT + ( + record_metadata :CreateTime :: INT / 1000 + ) :: timestamp_ntz AS system_created_at, + VALUE :blockchain :: STRING AS blockchain, + VALUE :symbol :: STRING AS symbol, + VALUE :address :: STRING AS address, + VALUE :date :: DATE AS xfer_date, + VALUE :reward :: FLOAT AS reward, + VALUE :hodl :: FLOAT AS hodl, + VALUE :unlabeled_transfer :: FLOAT AS unlabeled_transfer, + VALUE :stake :: FLOAT AS stake, + VALUE :cex_deposit :: FLOAT AS cex_deposit, + VALUE :nft_buy :: FLOAT AS nft_buy, + VALUE :dex_swap :: FLOAT AS dex_swap, + VALUE :bridge :: FLOAT AS bridge, + TO_BOOLEAN(LOWER(VALUE :first_is_bounty :: STRING)) AS first_is_bounty, + TO_BOOLEAN(LOWER(VALUE :did_hunt :: STRING)) AS did_hunt, + TO_BOOLEAN(LOWER(VALUE :did_new_user :: STRING)) AS did_new_user, + TO_BOOLEAN(LOWER(VALUE :did_bounty :: STRING)) AS did_bounty +FROM + ( + SELECT + * + FROM + ( + SELECT + * + FROM + {{ source( + 'bronze', + 'prod_data_science_uploads_1748940988' + ) }} + WHERE + TRIM( + record_metadata :key :: STRING, + '"' + ) LIKE 'ntr%' + ), + LATERAL FLATTEN( + input => record_content + ) AS f + ) +WHERE + xfer_date IS NOT NULL + +{% if is_incremental() %} +AND ( + record_metadata :CreateTime :: INT / 1000 +) :: timestamp_ntz :: DATE >= ( + SELECT + DATEADD('day', -1, MAX(system_created_at :: DATE)) + FROM + {{ this }} +) +{% endif %} + +qualify(ROW_NUMBER() over(PARTITION BY blockchain, symbol, address, xfer_date +ORDER BY + system_created_at DESC)) = 1 \ No newline at end of file diff --git a/models/silver/ntr/silver__ntr.yml b/models/silver/ntr/silver__ntr.yml new file mode 100644 index 0000000..e1b6a56 --- /dev/null +++ b/models/silver/ntr/silver__ntr.yml @@ -0,0 +1,52 @@ +version: 2 +models: + - name: silver__ntr + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - BLOCKCHAIN + - SYMBOL + - ADDRESS + - XFER_DATE + columns: + - name: BLOCKCHAIN + description: The name of the blockchain + tests: + - not_null + - name: SYMBOL + description: Symbol for ntr analysis + tests: + - not_null + - name: ADDRESS + description: Address on the blockchain + tests: + - not_null + - name: XFER_DATE + description: Transfer date + tests: + - not_null + - name: REWARD + description: total paid through bounty program to the address from beginning of the data through the current date + - name: HODL + description: amount (of reward) that is still held in the original address paid + - name: UNLABLED_TRANSFER + description: amount of the reward that was transferred to an unknown address + - name: STAKE + description: amount of the reward that was staked + - name: CEX_DEPOSIT + description: amount of the reward that was deposited to a centralized exchange + - name: NFT_BUY + description: amount of the reward that was used to purchase an NFT + - name: DEX_SWAP + description: amount of the reward that was swapped for another token on a decentralized exchange + - name: BRIDGE + description: amount of the reward that was deposited to a centralized exchange + - name: FIRST_IS_BOUNTY + description: indicates if the addresses' first receipt of the token was through a Flipside program + - name: DID_HUNT + description: indicates if the address participated in a scavenger hunt for this token + - name: DID_NEW_USER + description: indicates if the address participated in a new user bounty for this token + - name: DID_BOUNTY + description: indicates if the address participated in a bounty for this token (excluding new user bounties) + \ No newline at end of file diff --git a/models/sources.yml b/models/sources.yml index 2dd3f39..b3e62e1 100644 --- a/models/sources.yml +++ b/models/sources.yml @@ -184,6 +184,7 @@ sources: schema: bronze tables: - name: prod_address_label_sink_291098491 + - name: prod_data_science_uploads_1748940988 - name: Harmony_db database: HARMONY schema: SUSHI