diff --git a/data/testing__nft_sales_tensorswap.csv b/data/testing__nft_sales_tensorswap.csv index b79611f72..10d4e8b44 100644 --- a/data/testing__nft_sales_tensorswap.csv +++ b/data/testing__nft_sales_tensorswap.csv @@ -1,19 +1,28 @@ tx_id,index,inner_index,purchaser,seller,mint,sales_amount -zzvAhzMxDpJy99zcYms6vsjimT3XhQBf76s9AYA4XcYaEgRS2EmMDHY9uHrfz7372v85726Krz3kaKfYmLgnMFz,2,,HEsoAeQ6jgwiyPCL7A9mBjMf34qVAF96KYPNdxE68iY6,2w4HeHXEEVrpqpKUTZqVSCzCR5uWKK88pNY9pfqSW59R,BBMQUm1domLQUZr4gUm9Pd6EGLnuUu9hPX7bpD5dpqMT,0.468830396 +zzvAhzMxDpJy99zcYms6vsjimT3XhQBf76s9AYA4XcYaEgRS2EmMDHY9uHrfz7372v85726Krz3kaKfYmLgnMFz,2,,HEsoAeQ6jgwiyPCL7A9mBjMf34qVAF96KYPNdxE68iY6,2w4HeHXEEVrpqpKUTZqVSCzCR5uWKK88pNY9pfqSW59R,BBMQUm1domLQUZr4gUm9Pd6EGLnuUu9hPX7bpD5dpqMT,0.49449417 4KnHxNCwtbvdnUP9xP6aUAGpEVVgZqVnGP8FzJAz3ghPhnSgUvm8DPVdwm5tE9d78ScBxFQNqzRotW5mr2bYL9P5,2,,2zzPrvMe843AJ15jwppiA25XRXXgM4ajH9ZnVLtPmvPb,8FQ73HFaXurdDEUC4UpTJw99hvpaCJUHiqaQwBGgujiD,AnBW1sLFStkdHXpyJAH49Gu2t4y4rRhDnEKcEAcps28W,0.852 2nrF2VHpLvYQKjtFWqTxoXtHNDEJEH2zi1xYeaDd2FprFYWY7wajcnbnQbPkhqwrhQkiKfYDgKc9mCDgWUzZwvrb,2,,CqA42zXaf5zXk7EW7jtCLfL2uH1efuB9GtTfjfJ2hzoq,BsBqiPgRgHPa8YgJ6wNgfP2GJsSgAsesXtaqqvVcGm79,Ek9ECbHYSW6QB9aUU6UsovP5d2Z7mfEB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J4fizYuWXKwgGebThNkFm9NEXFzBbeaEdr,34HibhTzBBgvwrWNrvgnRE81NA3yqKUpJJ7e4w4TKUvh,817KTxyHiKNcS1ozwDfmBKyix9EkiLHRi1awrjt99cy3,8.8 \ No newline at end of file diff --git a/models/silver/nfts/silver__nft_sales_tensorswap.sql b/models/silver/nfts/silver__nft_sales_tensorswap.sql index bb0d6878c..3fb7eaf9f 100644 --- a/models/silver/nfts/silver__nft_sales_tensorswap.sql +++ b/models/silver/nfts/silver__nft_sales_tensorswap.sql @@ -162,6 +162,18 @@ base_transfers AS ( WHERE {{ between_stmts }} ), +base_logs AS ( + SELECT + block_timestamp, + tx_id, + index, + inner_index, + sales_amount, + FROM + {{ ref('silver__nft_sales_tensorswap_buysellevent') }} + WHERE + {{ between_stmts }} +), buys AS ( SELECT d.block_timestamp, @@ -197,22 +209,29 @@ buys AS ( ), sells AS ( SELECT - block_timestamp, - block_id, - tx_id, - succeeded, - index, - inner_index, - program_id, - purchaser, - seller, - mint, - min_price AS sales_amount, - _inserted_timestamp + d.block_timestamp, + d.block_id, + d.tx_id, + d.succeeded, + d.index, + d.inner_index, + d.program_id, + d.event_type, + d.purchaser, + d.seller, + d.mint, + coalesce(b.sales_amount * pow(10,-9),min_price) AS sales_amount, -- some logs are truncated so we have to use min_price + d._inserted_timestamp FROM - decoded + decoded d + LEFT JOIN + base_logs b + ON d.block_timestamp::date = b.block_timestamp::date + AND d.tx_id = b.tx_id + AND d.index = b.index + AND coalesce(d.inner_index,-1) = coalesce(b.inner_index,-1) WHERE - event_type IN ( + d.event_type IN ( 'sellNftTokenPool', 'sellNftTokenPoolT22', 'sellNftTradePoolT22', @@ -230,6 +249,7 @@ pre_final AS ( index, inner_index, program_id, + event_type, purchaser, seller, mint, @@ -246,6 +266,7 @@ pre_final AS ( d.index, d.inner_index, d.program_id, + d.event_type, d.purchaser, d.seller, d.mint, diff --git a/models/silver/nfts/silver__nft_sales_tensorswap.yml b/models/silver/nfts/silver__nft_sales_tensorswap.yml index 0e80c29e5..a1263f69d 100644 --- a/models/silver/nfts/silver__nft_sales_tensorswap.yml +++ b/models/silver/nfts/silver__nft_sales_tensorswap.yml @@ -28,7 +28,15 @@ models: '5vsPBQWgtwhqeQQUHVQhuCtWDtAu5sqQak1FkMj7ZkQbMz12m8XrgTQCYtD1paFKh1KqAakpf6hQV4APd94VihLN', '2munG4m9guSktDAp8QNt3WK1uVVD3BKV5zWqYuApjKjeiLDV9br6QwemQ1UeTHnfeF5CB7axL3K2kFbKUJpCAzHr', '5PaqpRyNvDjPkRD8UeBKUC8SiwddLLtxZgPuDTngZXCZ2sZ7tDVHoXtqwDWWf9Jq4DVCytobc4o8h1mxNMD8hXzv', - '5Ndp4DwJvVxiF6cEVtHvnzW749hjqKFdwYVYS4Bn2GHtc3qPGsk9AuowBhamqDkJaXNgiC3CaSDMK4k2a2pEchzJ')" + '5Ndp4DwJvVxiF6cEVtHvnzW749hjqKFdwYVYS4Bn2GHtc3qPGsk9AuowBhamqDkJaXNgiC3CaSDMK4k2a2pEchzJ', + '5BDJaGeqsfRTHQA8kR99syrFebNWVmpWFpWNne8jRvGpdVxzXNVw9gb3HrbZJEvphTHGsGxeWdv7TDFc4A5g2zhY', + '2L9QnyDuLf3xHmt7WQ992qX5y7GhriKsEmcAWKF7b6dakRgPftgnRP1J73HcNYq7DX8L472vHMrnGo7KyZzVuwNf', + '3n8gZ42dgEPyhm5Fg67S2YV7DB594wG2kvsqmpnvrDnoFzCvyKV9dmZKJHpZQHnXbk6KGWCdpPLhdP51HpbBiYp2', + '69suHP1ToykoujDnp4kD7oBnMzx3ftTqeuR8dASjt2PcAfbKDQrSWvuwAMghy7sWGRtP3YTgsCDK2TyYwGg99bc', + 'DyLBsEEQfp26yzfZ8ESsgP93zecc9dPCACsBaZ2QYQGDsS4UBg5gR5baHqmrFE6Cp7hVR7jUXX5aWxnrDejzdbb', + '2vSRfRA82jhyMwe3GrSnzwbYVbhTsf8E8fdMtYUmZvjDJT2Wp649qtAaoqagP2FLmRjErCfFpL64R4M84tzMJGEv', + '2iSFJTzHHAEqZpZFhGWXL9EH82NpQivxmgUFyy6eAb9FKXcM21FxrDUZjsmTakkVs99E3o4qGk31dpLmEeWyJ2Sw', + '4yCbMAPrQ29bR33KTgEVuScBwwAuC4Qgbm72yoMDmkiQLqFWGcmz8o1bGoKKS5nLTsBVf7KKX7FbDh61QKjQfe6N')" columns: - name: BLOCK_TIMESTAMP description: "{{ doc('block_timestamp') }}" @@ -59,6 +67,10 @@ models: description: "{{ doc('program_id') }}" tests: - not_null + - name: EVENT_TYPE + description: "{{ doc('event_type') }}" + tests: + - not_null - name: PURCHASER description: "{{ doc('purchaser') }}" tests: @@ -73,7 +85,7 @@ models: - not_null: where: succeeded = TRUE - name: SALES_AMOUNT - description: "{{ doc('sales_amount') }}. For bid side sales the amount is an estimation using `min_price`" + description: "{{ doc('sales_amount') }}. For bid side sales the amount is an estimation using `min_price` when logs are unavailable (ex: truncated logs)" tests: - not_null - dbt_utils.expression_is_true: diff --git a/models/silver/nfts/silver__nft_sales_tensorswap_buysellevent.sql b/models/silver/nfts/silver__nft_sales_tensorswap_buysellevent.sql new file mode 100644 index 000000000..4959d9c3d --- /dev/null +++ b/models/silver/nfts/silver__nft_sales_tensorswap_buysellevent.sql @@ -0,0 +1,90 @@ +-- depends_on: {{ ref('silver__decoded_logs') }} + +{{ config( + materialized = 'incremental', + incremental_predicates = ["dynamic_range_predicate", "block_timestamp::date"], + merge_exclude_columns = ["inserted_timestamp"], + unique_key = "nft_sales_tensorswap_id", + cluster_by = ['block_timestamp::DATE','_inserted_timestamp::DATE'], + tags = ['scheduled_non_core'] +) }} + +{% if execute %} + {% set base_query %} + CREATE OR REPLACE temporary TABLE silver.nft_sales_tensorswap_buysellevent__intermediate_tmp AS + SELECT + block_timestamp, + block_id, + tx_id, + TRUE AS succeeded, + INDEX, + inner_index, + log_index, + program_id, + event_type, + decoded_log, + _inserted_timestamp + FROM + {{ ref('silver__decoded_logs') }} + WHERE + program_id = 'TSWAPaqyCSx2KABk68Shruf4rp7CxcNi8hAsbdwmHbN' + AND event_type = 'BuySellEvent' + {% if is_incremental() %} + AND _inserted_timestamp >= ( + SELECT + MAX(_inserted_timestamp) - INTERVAL '1 hour' + FROM + {{ this }} + ) + {% else %} + AND _inserted_timestamp :: DATE >= '2024-06-02' + {% endif %} +{% endset %} + +{% do run_query(base_query) %} +{% set between_stmts = fsc_utils.dynamic_range_predicate( + "silver.nft_sales_tensorswap_buysellevent__intermediate_tmp", + "block_timestamp::date" +) %} +{% endif %} + +WITH decoded AS ( + SELECT + block_timestamp, + block_id, + tx_id, + succeeded, + INDEX, + inner_index, + log_index, + program_id, + event_type, + decoded_log:args:creatorsFee::int AS creator_fee, + decoded_log:args:currentPrice::int AS current_price, + decoded_log:args:mmFee::int AS mm_fee, + decoded_log:args:tswapFee::int AS tswap_fee, + _inserted_timestamp + FROM + silver.nft_sales_tensorswap_buysellevent__intermediate_tmp +) +SELECT + block_timestamp, + block_id, + tx_id, + succeeded, + INDEX, + inner_index, + log_index, + program_id, + event_type, + creator_fee, + mm_fee, + tswap_fee, + current_price AS sales_amount, + _inserted_timestamp, + {{ dbt_utils.generate_surrogate_key(['tx_id','index','inner_index','log_index']) }} AS nft_sales_tensorswap_buysellevent_id, + SYSDATE() AS inserted_timestamp, + SYSDATE() AS modified_timestamp, + '{{ invocation_id }}' AS _invocation_id +FROM + decoded \ No newline at end of file diff --git a/models/silver/nfts/silver__nft_sales_tensorswap_buysellevent.yml b/models/silver/nfts/silver__nft_sales_tensorswap_buysellevent.yml new file mode 100644 index 000000000..64a619834 --- /dev/null +++ b/models/silver/nfts/silver__nft_sales_tensorswap_buysellevent.yml @@ -0,0 +1,83 @@ +version: 2 +models: + - name: silver__nft_sales_tensorswap_buysellevent + columns: + - name: BLOCK_TIMESTAMP + description: "{{ doc('block_timestamp') }}" + tests: + - not_null + - dbt_expectations.expect_row_values_to_have_recent_data: + datepart: day + interval: 2 + - name: BLOCK_ID + description: "{{ doc('block_id') }}" + tests: + - not_null + - name: TX_ID + description: "{{ doc('tx_id') }}" + tests: + - not_null + - name: SUCCEEDED + description: "{{ doc('tx_succeeded') }}" + tests: + - not_null + - name: INDEX + description: "{{ doc('event_index') }}" + tests: + - not_null + - name: INNER_INDEX + description: "{{ doc('inner_index') }}" + - name: LOG_INDEX + description: "{{ doc('log_index') }}" + tests: + - not_null + - name: PROGRAM_ID + description: "{{ doc('program_id') }}" + tests: + - not_null + - name: EVENT_TYPE + description: "{{ doc('event_type') }}" + tests: + - not_null + - accepted_values: + values: ["BuySellEvent"] + - name: CREATOR_FEE + description: "Part of `sales_amount` in SOL that goes to the creator" + tests: + - not_null + - name: MM_FEE + description: "Part of `sales_amount` in SOL that goes to the market maker" + tests: + - not_null + - name: TSWAP_FEE + description: "Part of `sales_amount` in SOL that goes to Tensor" + tests: + - not_null + - name: SALES_AMOUNT + description: "{{ doc('sales_amount') }}" + tests: + - not_null + - dbt_utils.expression_is_true: + expression: ">= 0" + - name: _INSERTED_TIMESTAMP + description: "{{ doc('_inserted_timestamp') }}" + tests: + - not_null + - name: NFT_SALES_TENSORSWAP_BUYSELLEVENT_ID + description: '{{ doc("pk") }}' + tests: + - unique + - name: INSERTED_TIMESTAMP + description: '{{ doc("inserted_timestamp") }}' + tests: + - not_null + - name: MODIFIED_TIMESTAMP + description: '{{ doc("modified_timestamp") }}' + tests: + - not_null + - name: _INVOCATION_ID + description: '{{ doc("_invocation_id") }}' + tests: + - not_null: + name: test_silver__not_null_nft_sales_tensorswap_buysellevent__invocation_id + \ No newline at end of file diff --git a/models/silver/program_logs/silver__transaction_logs_program_data.sql b/models/silver/program_logs/silver__transaction_logs_program_data.sql index 3bd9ebcc9..508814602 100644 --- a/models/silver/program_logs/silver__transaction_logs_program_data.sql +++ b/models/silver/program_logs/silver__transaction_logs_program_data.sql @@ -8,6 +8,31 @@ tags = ['scheduled_core'], ) }} +/* +Adjusted backfill groupings on 2-XL +2022-08-12 7885521 +2022-08-13 11137387 +2022-08-15 351101483 +2022-08-16 1427863755 + +2022-08-17 973393045 + +2022-08-18 827193734 + +2022-08-19 2346654908 + +2022-08-20 1281709341 + +2022-08-21 341131725 +2022-08-22 13564732 +2022-08-25 384899 +2022-08-30 227067618 + +2022-08-31 2545287850 + +2022-09-01 1726232252 +*/ + WITH base AS ( SELECT @@ -22,13 +47,11 @@ WITH base AS ( WHERE succeeded AND log_messages IS NOT NULL - {% if is_incremental() %} - {% if execute %} - {{ get_batch_load_logic(this, 30, '2024-06-07') }} - {% endif %} - /* UNCOMMENT WHEN BACKFILLED - AND _inserted_timestamp >= (SELECT max(_inserted_timestamp) FROM {{ this }}) */ + /*{% if execute %} + {{ get_batch_load_logic(this, 30, '2024-07-04') }} + {% endif %}*/ + AND _inserted_timestamp >= (SELECT max(_inserted_timestamp) FROM {{ this }}) {% else %} AND _inserted_timestamp::date BETWEEN '2022-08-12' AND '2022-09-01' {% endif %}