From 639c100edf04eb253424968d35c3e35eac241743 Mon Sep 17 00:00:00 2001 From: tarikceric Date: Wed, 17 Jul 2024 11:59:53 -0700 Subject: [PATCH 01/10] wip --- .../nfts/silver__nft_sales_amm_sell.sql | 335 ++++++++++-------- 1 file changed, 190 insertions(+), 145 deletions(-) diff --git a/models/silver/nfts/silver__nft_sales_amm_sell.sql b/models/silver/nfts/silver__nft_sales_amm_sell.sql index 3de3ed9ab..df25a7513 100644 --- a/models/silver/nfts/silver__nft_sales_amm_sell.sql +++ b/models/silver/nfts/silver__nft_sales_amm_sell.sql @@ -1,153 +1,190 @@ +-- depends_on: {{ ref('silver__decoded_instructions_combined') }} {{ config( materialized = 'incremental', - unique_key = "CONCAT_WS('-', tx_id, mint)", - incremental_strategy = 'delete+insert', - cluster_by = ['block_timestamp::DATE'], + incremental_predicates = ["dynamic_range_predicate", "block_timestamp::date"], + merge_exclude_columns = ["inserted_timestamp"], + unique_key = "nft_sales_amm_sell_id", + cluster_by = ['block_timestamp::DATE','_inserted_timestamp::DATE'], tags = ['scheduled_non_core'] ) }} -WITH base_events AS ( +{% if execute %} + {% set base_query %} + CREATE OR REPLACE temporary TABLE silver.nft_sales_amm_sell__intermediate_tmp AS SELECT - * + block_timestamp, + block_id, + tx_id, + succeeded, + signers, + INDEX, + inner_index, + program_id, + event_type, + decoded_instruction, + _inserted_timestamp FROM - {{ ref('silver__events') }} + {{ ref('silver__decoded_instructions_combined') }} WHERE program_id = 'mmm3XBJg5gk8XJxEKBvdgptZz6SgK4tXvn36sodowMc' + AND event_type IN ( + 'solMip1FulfillSell', + 'solFulfillSell', + 'solFulfillBuy', + 'solMip1FulfillBuy', + 'solOcpFulfillBuy', + 'solExtFulfillBuy' + ) + AND succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( SELECT - MAX(_inserted_timestamp) + MAX(_inserted_timestamp) - INTERVAL '1 hour' FROM {{ this }} ) {% else %} - AND block_timestamp :: DATE >= '2022-10-14' + AND _inserted_timestamp :: DATE >= '2022-10-14' {% endif %} -), -base_token_balance AS ( - SELECT - * - FROM - {{ ref('silver___post_token_balances') }} - WHERE - amount = 1 +{% endset %} -{% if is_incremental() %} -AND _inserted_timestamp >= ( +{% do run_query(base_query) %} +{% set between_stmts = fsc_utils.dynamic_range_predicate( + "silver.nft_sales_amm_sell__intermediate_tmp", + "block_timestamp::date" +) %} +{% endif %} + +WITH base_decoded AS ( SELECT - MAX(_inserted_timestamp) + * FROM - {{ this }} -) -{% else %} - AND block_timestamp :: DATE >= '2022-10-14' -{% endif %} + silver.nft_sales_amm_sell__intermediate_tmp ), base_transfers AS ( SELECT * FROM - {{ ref('silver__transfers') }} + solana_dev.silver.transfers WHERE - mint = 'So11111111111111111111111111111111111111112' - -{% if is_incremental() %} -AND _inserted_timestamp >= ( - SELECT - MAX(_inserted_timestamp) - FROM - {{ this }} -) -{% else %} - AND block_timestamp :: DATE >= '2022-10-14' -{% endif %} + mint = 'So11111111111111111111111111111111111111111' + AND succeeded + AND {{ between_stmts }} ), coral_cube_sales AS( SELECT - A.*, + block_timestamp, + block_id, + tx_id, + INDEX, + inner_index, + signers, + succeeded, + program_id, + decoded_instruction, + event_type, CASE - WHEN b1.owner IS NOT NULL THEN b1.owner - WHEN b2.owner IS NOT NULL THEN b2.owner - ELSE A.instruction :accounts [1] :: STRING + WHEN event_type IN ( + 'solFulfillSell', + 'solMip1FulfillSell' + ) THEN silver.udf_get_account_pubkey_by_name( + 'payer', + decoded_instruction :accounts + ) + ELSE silver.udf_get_account_pubkey_by_name( + 'pool', + decoded_instruction :accounts + ) END AS purchaser, CASE - WHEN b1.owner IS NOT NULL THEN A.instruction :accounts [4] :: STRING - ELSE A.instruction :accounts [0] :: STRING + WHEN event_type IN ( + 'solFulfillSell', + 'solMip1FulfillSell' + ) THEN silver.udf_get_account_pubkey_by_name( + 'pool', + decoded_instruction :accounts + ) + ELSE silver.udf_get_account_pubkey_by_name( + 'payer', + decoded_instruction :accounts + ) END AS seller, CASE - WHEN b1.owner IS NOT NULL THEN 'sell' + WHEN event_type IN ( + 'solFulfillSell', + 'solMip1FulfillSell' + ) THEN 'sell' ELSE 'buy' END AS nft_sale_type, 'Coral Cube' AS marketplace, - A.instruction :accounts [8] :: STRING AS mint + silver.udf_get_account_pubkey_by_name( + 'assetMint', + decoded_instruction :accounts + ) AS mint, + _inserted_timestamp FROM - base_events A - LEFT JOIN base_token_balance b1 - ON A.tx_id = b1.tx_id - AND A.instruction :accounts [0] = b1.owner - LEFT JOIN base_token_balance b2 - ON A.tx_id = b2.tx_id - AND A.instruction :accounts [4] = b2.owner + base_decoded WHERE - A.signers [1] = '7RpRDUZBdu5hfmqWvobPazbNeVCagRk5E3Rb8Bm8qRmD' - AND A.instruction :accounts [14] <> 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s' + signers [1] = '7RpRDUZBdu5hfmqWvobPazbNeVCagRk5E3Rb8Bm8qRmD' AND purchaser <> '7RpRDUZBdu5hfmqWvobPazbNeVCagRk5E3Rb8Bm8qRmD' - AND ARRAY_SIZE( - instruction :accounts - ) >= 16 ), mev2_sales AS( - -- mev2_buys - SELECT - A.*, - instruction :accounts [1] :: STRING AS purchaser, - instruction :accounts [0] :: STRING AS seller, - 'buy' AS nft_sale_type, - 'Magic Eden' AS marketplace, - instruction :accounts [8] :: STRING AS mint - FROM - base_events A - WHERE - signers [1] = 'NTYeYJ1wr4bpM5xo6zx5En44SvJFAd35zTxxNoERYqd' - AND ARRAY_SIZE( - instruction :accounts - ) > 16 - AND ( - instruction :accounts [12] :: STRING = '11111111111111111111111111111111' - OR instruction :accounts [16] :: STRING = 'ocp4vWUzA2z2XMYJ3QhM9vWdyoyoQwAFJhRdVTbvo9E' - ) - UNION ALL - -- mev2_sells SELECT - A.*, - instruction :accounts [0] :: STRING AS purchaser, - instruction :accounts [1] :: STRING AS seller, - 'sell' AS nft_sale_type, - 'Magic Eden' AS marketplace, + block_timestamp, + block_id, + tx_id, + INDEX, + inner_index, + signers, + succeeded, + program_id, + decoded_instruction, + event_type, + CASE + WHEN event_type IN ( + 'solMip1FulfillSell', + 'solFulfillSell' + ) THEN silver.udf_get_account_pubkey_by_name( + 'payer', + decoded_instruction :accounts + ) + ELSE silver.udf_get_account_pubkey_by_name( + 'owner', + decoded_instruction :accounts + ) + END AS purchaser, CASE - WHEN ARRAY_SIZE( - instruction :accounts - ) > 19 THEN instruction :accounts [7] :: STRING - WHEN ARRAY_SIZE( - instruction :accounts + WHEN event_type IN ( + 'solMip1FulfillSell', + 'solFulfillSell' + ) THEN silver.udf_get_account_pubkey_by_name( + 'owner', + decoded_instruction :accounts ) - IN ( - 17, - 18, - 19 - ) THEN instruction :accounts [8] :: STRING - END AS mint + ELSE silver.udf_get_account_pubkey_by_name( + 'payer', + decoded_instruction :accounts + ) + END AS seller, + CASE + WHEN event_type IN ( + 'solMip1FulfillSell', + 'solFulfillSell' + ) THEN 'sell' + ELSE 'buy' + END AS nft_sale_type, + 'Magic Eden' AS marketplace, + silver.udf_get_account_pubkey_by_name( + 'assetMint', + decoded_instruction :accounts + ) AS mint, + _inserted_timestamp FROM - base_events A + base_decoded WHERE signers [1] = 'NTYeYJ1wr4bpM5xo6zx5En44SvJFAd35zTxxNoERYqd' - AND ARRAY_SIZE( - instruction :accounts - ) > 16 - AND instruction :accounts [11] :: STRING = '11111111111111111111111111111111' - AND instruction :accounts [16] :: STRING != 'ocp4vWUzA2z2XMYJ3QhM9vWdyoyoQwAFJhRdVTbvo9E' ), coral_cube_nft_sale_amount AS ( SELECT @@ -167,7 +204,10 @@ coral_cube_nft_sale_amount AS ( ) OR ( A.nft_sale_type = 'buy' - AND A.instruction :accounts [5] = b.tx_from + AND silver.udf_get_account_pubkey_by_name( + 'buysideSolEscrowAccount', + A.decoded_instruction :accounts + ) :: STRING = b.tx_from ) GROUP BY 1, @@ -187,60 +227,65 @@ mev2_nft_sale_amount AS ( WHERE ( A.nft_sale_type = 'sell' - AND A.instruction :accounts [0] = b.tx_from + AND A.purchaser = b.tx_from ) OR ( A.nft_sale_type = 'buy' - AND A.instruction :accounts [5] = b.tx_from + AND silver.udf_get_account_pubkey_by_name( + 'buysideSolEscrowAccount', + A.decoded_instruction :accounts + ) :: STRING = b.tx_from ) GROUP BY 1, 2 +), +pre_final AS ( + SELECT + A.block_timestamp, + A.block_id, + A.tx_id, + A.succeeded, + A.index, + A.inner_index, + A.program_id, + A.mint, + A.purchaser, + A.seller, + b.sales_amount, + A.marketplace, + A._inserted_timestamp + FROM + coral_cube_sales A + LEFT JOIN coral_cube_nft_sale_amount b + ON A.tx_id = b.tx_id + WHERE + b.sales_amount IS NOT NULL + UNION + SELECT + A.block_timestamp, + A.block_id, + A.tx_id, + A.succeeded, + A.index, + A.inner_index, + A.program_id, + A.mint, + A.purchaser, + A.seller, + b.sales_amount, + A.marketplace, + A._inserted_timestamp + FROM + mev2_sales A + LEFT JOIN mev2_nft_sale_amount b + ON A.tx_id = b.tx_id ) SELECT - A.block_timestamp, - A.block_id, - A.tx_id, - A.succeeded, - A.program_id, - A.mint, - A.purchaser, - A.seller, - b.sales_amount, - A.marketplace, - A._inserted_timestamp, - {{ dbt_utils.generate_surrogate_key( - ['A.tx_id','A.mint'] - ) }} AS nft_sales_amm_sell_id, - SYSDATE() AS inserted_timestamp, - SYSDATE() AS modified_timestamp, - '{{ invocation_id }}' AS _invocation_id -FROM - coral_cube_sales A - LEFT JOIN coral_cube_nft_sale_amount b - ON A.tx_id = b.tx_id -WHERE - b.sales_amount IS NOT NULL -UNION -SELECT - A.block_timestamp, - A.block_id, - A.tx_id, - A.succeeded, - A.program_id, - A.mint, - A.purchaser, - A.seller, - b.sales_amount, - A.marketplace, - A._inserted_timestamp, - {{ dbt_utils.generate_surrogate_key( - ['A.tx_id','A.mint'] - ) }} AS nft_sales_amm_sell_id, + *, + {{ dbt_utils.generate_surrogate_key(['tx_id','mint']) }} AS nft_sales_amm_sell_id, SYSDATE() AS inserted_timestamp, SYSDATE() AS modified_timestamp, '{{ invocation_id }}' AS _invocation_id FROM - mev2_sales A - LEFT JOIN mev2_nft_sale_amount b - ON A.tx_id = b.tx_id + pre_final From 37f30b42aa48d28dae93cd6a9e0f22a26bf172bc Mon Sep 17 00:00:00 2001 From: tarikceric Date: Wed, 17 Jul 2024 12:09:44 -0700 Subject: [PATCH 02/10] add relationship test --- .../parser/silver__decoded_instructions_combined.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/models/silver/parser/silver__decoded_instructions_combined.yml b/models/silver/parser/silver__decoded_instructions_combined.yml index 0b022ebca..4289632bf 100644 --- a/models/silver/parser/silver__decoded_instructions_combined.yml +++ b/models/silver/parser/silver__decoded_instructions_combined.yml @@ -166,6 +166,16 @@ models: AND succeeded and _inserted_timestamp between current_date - 7 and current_timestamp() - INTERVAL '4 HOUR' to_condition: "_inserted_timestamp >= current_date - 7" + - dbt_utils.relationships_where: + name: dbt_utils_relationships_where_silver__decoded_instructions_combined_nft_sales_amm_sell_tx_id + to: ref('silver__nft_sales_amm_sell') + field: tx_id + from_condition: > + program_id = 'mmm3XBJg5gk8XJxEKBvdgptZz6SgK4tXvn36sodowMc' + AND event_type IN ('solMip1FulfillSell','solFulfillSell','solFulfillBuy','solMip1FulfillBuy','solOcpFulfillBuy','solExtFulfillBuy') + AND succeeded + and _inserted_timestamp between current_date - 7 and current_timestamp() - INTERVAL '4 HOUR' + to_condition: "_inserted_timestamp >= current_date - 7" - name: SIGNERS description: "{{ doc('signers') }}" - name: SUCCEEDED From 8be28037bb5dfac7f1a60580f70e984c6002deb9 Mon Sep 17 00:00:00 2001 From: tarikceric Date: Thu, 18 Jul 2024 09:54:10 -0700 Subject: [PATCH 03/10] update ref --- models/silver/nfts/silver__nft_sales_amm_sell.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/silver/nfts/silver__nft_sales_amm_sell.sql b/models/silver/nfts/silver__nft_sales_amm_sell.sql index df25a7513..3a8de264b 100644 --- a/models/silver/nfts/silver__nft_sales_amm_sell.sql +++ b/models/silver/nfts/silver__nft_sales_amm_sell.sql @@ -67,7 +67,7 @@ base_transfers AS ( SELECT * FROM - solana_dev.silver.transfers + {{ ref('silver__transfers') }} WHERE mint = 'So11111111111111111111111111111111111111111' AND succeeded From e6193ed4a3d11480bc36bc7b22c0772ce6b809bb Mon Sep 17 00:00:00 2001 From: tarikceric Date: Fri, 19 Jul 2024 16:21:59 -0700 Subject: [PATCH 04/10] add tests --- data/testing__nft_sales_amm_sell.csv | 5 ++++- models/silver/nfts/silver__nft_sales_amm_sell.sql | 12 ++++++++---- models/silver/nfts/silver__nft_sales_amm_sell.yml | 5 ++++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/data/testing__nft_sales_amm_sell.csv b/data/testing__nft_sales_amm_sell.csv index d77dd6cf6..fd44a1934 100644 --- a/data/testing__nft_sales_amm_sell.csv +++ b/data/testing__nft_sales_amm_sell.csv @@ -4,4 +4,7 @@ Ep7n5yUXoBiV6J3ntzvCqaGMS92NbQ9zdqS8ZMJVEwVGhKxsomKzGfsKzyHpzrb9s7ipLH4Cn5P88rne 46c3pCDa8hAuqiRN4SV3zwhuMz7XgDU6qrtsyzhkSXyJwjmeZ1TFsbxqnA15KCnPVLN1zNVUrouWJAskTX7v5uCF,AwQqQ1Xo9VxY64fcjw2toXZQnk94o5pFkxnGRngnqb1u,66Th151qye6WCmQ6nis5SzmBUZkVJ1uogCxMuxm6YLE,YjvHKGnS6vFNCBKtUNd1Jd2dQuovhNbY1iAbYhY22pC,12.617763101 39bf1gUcYqTuHnYTLPEbCGJ5NcpNBn8bkUGeVJxkRMRLuPP3SUaggdVcmDpHFUQSPJNq3wiCPvgzBTSwGWF53we,ESBjMYBxbsSidbQxKpY77W1V5Ewht4T1JNjqn9Qw9e7y,2uRG2BSVDBdBP1PZA6Dhde5qqs6eJZfx2jbxA148yY9n,2YZWv6StSnNx8iFneaiSPBbpi1K6AhJRA52tDXFo87o4,0.1 5cVLZm21xYLbhsi8zN2YJPacuKQjsaxcguJGZ2keP4vrGDKVJvazbvECSMaHoY5qVYWovVP53QC1scGX8rdTPUT,AwQqQ1Xo9VxY64fcjw2toXZQnk94o5pFkxnGRngnqb1u,1PKTvQ2yWWP6gXTq8EP73bWWdGmoyvMQZnQ26xKzZ2G,F3cv38qusZTfLchrNC3NFFxTKmYdRTHdk5dkymXJtYCP,31.09692544 -2yDoFY813NMMrFctpef8wxV4ktEt9Nn8kogJHSA6FBDdHpbezk6X21W2rbHK5tHLHsYBj7sdjNRDpHb9au2nEZT,AwQqQ1Xo9VxY64fcjw2toXZQnk94o5pFkxnGRngnqb1u,4AX2wYzLAaYir9pewgFmotegbPmD51eH3cjaqkTFHxok,CiyGDgU8cDHtu4Pm2otLr9SK8r3jH3xFfJTDYLQVYEXE,31.457249984 \ No newline at end of file +2yDoFY813NMMrFctpef8wxV4ktEt9Nn8kogJHSA6FBDdHpbezk6X21W2rbHK5tHLHsYBj7sdjNRDpHb9au2nEZT,AwQqQ1Xo9VxY64fcjw2toXZQnk94o5pFkxnGRngnqb1u,4AX2wYzLAaYir9pewgFmotegbPmD51eH3cjaqkTFHxok,CiyGDgU8cDHtu4Pm2otLr9SK8r3jH3xFfJTDYLQVYEXE,31.457249984 +4oyZC4YBe3gkfS4T5FBesosYh5RtUzLmzu4eY9GRmmJiaD3aPGiUAGCMSefsR65rt7kH1AdZgDKp5r9FhFi9XRUs,FpPPhKwQxY1L2M12o7JuyaSooD1J2CLzaD9BP22jyF1L,D8KemM7RsJDzys44HRfS3nJH8B8yJXdqb5Naqa4kECaU,7a1JC1yyVqC7Q57JNpja4cXvobxwx8CyfrA1wxmsjTja,0.049693 +QSbUdMWMi4qWzFoeojb7GLa9MU8TuFFWaRKZZvo69ZJVgPzYUpzi3kZ1HR62ZW4wGxRnzP1HYKZSyJ457g1HFav,CdyBZ5E6wJNYbMWpmTfsBn9iS2z2tp9ch37WTBm5Gj52,BKLBXijVbwJK47fJWHmWyz2VAUnWeZETYLwYUD1ddc3k,2QufyZxx8vrd8ztiuiM4CSRgVVz7eHCqzA1bav4SbdfL,3.861127675 +5RbhAmdeFoWDtRW4bN5FUXZvin2WMjjnbgfdUVw97QVo6mbowdBozKs2ruhZ5EvpKr2pUjHoTTqJdwGeQL2E2H5F,AGFCb7sETaMhvKuq6j3iiVmRLh7WtryAJFgnDGt6LTgN,ENL47paJQUHhtoyEowYTK1Q7kiNmqV2BkrbZJXBXGQMf,7r7ZQBFTngNKGkL84fQxJt7HCTjzWZGLnDVdcu469CQ3,0.276342858 \ No newline at end of file diff --git a/models/silver/nfts/silver__nft_sales_amm_sell.sql b/models/silver/nfts/silver__nft_sales_amm_sell.sql index 3a8de264b..2b32c2e17 100644 --- a/models/silver/nfts/silver__nft_sales_amm_sell.sql +++ b/models/silver/nfts/silver__nft_sales_amm_sell.sql @@ -34,7 +34,8 @@ 'solFulfillBuy', 'solMip1FulfillBuy', 'solOcpFulfillBuy', - 'solExtFulfillBuy' + 'solExtFulfillBuy', + 'solOcpFulfillSell' ) AND succeeded @@ -88,7 +89,8 @@ coral_cube_sales AS( CASE WHEN event_type IN ( 'solFulfillSell', - 'solMip1FulfillSell' + 'solMip1FulfillSell', + 'solOcpFulfillSell' ) THEN silver.udf_get_account_pubkey_by_name( 'payer', decoded_instruction :accounts @@ -101,7 +103,8 @@ coral_cube_sales AS( CASE WHEN event_type IN ( 'solFulfillSell', - 'solMip1FulfillSell' + 'solMip1FulfillSell', + 'solOcpFulfillSell' ) THEN silver.udf_get_account_pubkey_by_name( 'pool', decoded_instruction :accounts @@ -114,7 +117,8 @@ coral_cube_sales AS( CASE WHEN event_type IN ( 'solFulfillSell', - 'solMip1FulfillSell' + 'solMip1FulfillSell', + 'solOcpFulfillSell' ) THEN 'sell' ELSE 'buy' END AS nft_sale_type, diff --git a/models/silver/nfts/silver__nft_sales_amm_sell.yml b/models/silver/nfts/silver__nft_sales_amm_sell.yml index f772227c5..71c3815f5 100644 --- a/models/silver/nfts/silver__nft_sales_amm_sell.yml +++ b/models/silver/nfts/silver__nft_sales_amm_sell.yml @@ -20,7 +20,10 @@ models: '2yDoFY813NMMrFctpef8wxV4ktEt9Nn8kogJHSA6FBDdHpbezk6X21W2rbHK5tHLHsYBj7sdjNRDpHb9au2nEZT', '5cVLZm21xYLbhsi8zN2YJPacuKQjsaxcguJGZ2keP4vrGDKVJvazbvECSMaHoY5qVYWovVP53QC1scGX8rdTPUT', '39bf1gUcYqTuHnYTLPEbCGJ5NcpNBn8bkUGeVJxkRMRLuPP3SUaggdVcmDpHFUQSPJNq3wiCPvgzBTSwGWF53we', - '46c3pCDa8hAuqiRN4SV3zwhuMz7XgDU6qrtsyzhkSXyJwjmeZ1TFsbxqnA15KCnPVLN1zNVUrouWJAskTX7v5uCF')" + '46c3pCDa8hAuqiRN4SV3zwhuMz7XgDU6qrtsyzhkSXyJwjmeZ1TFsbxqnA15KCnPVLN1zNVUrouWJAskTX7v5uCF', + '4oyZC4YBe3gkfS4T5FBesosYh5RtUzLmzu4eY9GRmmJiaD3aPGiUAGCMSefsR65rt7kH1AdZgDKp5r9FhFi9XRUs', + 'QSbUdMWMi4qWzFoeojb7GLa9MU8TuFFWaRKZZvo69ZJVgPzYUpzi3kZ1HR62ZW4wGxRnzP1HYKZSyJ457g1HFav', + '5RbhAmdeFoWDtRW4bN5FUXZvin2WMjjnbgfdUVw97QVo6mbowdBozKs2ruhZ5EvpKr2pUjHoTTqJdwGeQL2E2H5F')" columns: - name: BLOCK_TIMESTAMP description: "{{ doc('block_timestamp') }}" From 293cf259afd09e2b7eade98e4bab625aedb74a2e Mon Sep 17 00:00:00 2001 From: tarikceric Date: Mon, 22 Jul 2024 16:39:07 -0700 Subject: [PATCH 05/10] revert --- data/testing__nft_sales_amm_sell.csv | 6 +- .../nfts/silver__nft_sales_amm_sell.sql | 337 ++++++++---------- .../nfts/silver__nft_sales_amm_sell.yml | 5 +- 3 files changed, 146 insertions(+), 202 deletions(-) diff --git a/data/testing__nft_sales_amm_sell.csv b/data/testing__nft_sales_amm_sell.csv index fd44a1934..2a93c6cd9 100644 --- a/data/testing__nft_sales_amm_sell.csv +++ b/data/testing__nft_sales_amm_sell.csv @@ -3,8 +3,4 @@ Ep7n5yUXoBiV6J3ntzvCqaGMS92NbQ9zdqS8ZMJVEwVGhKxsomKzGfsKzyHpzrb9s7ipLH4Cn5P88rne 59fgrVMFqY1scM8gumej3kCq6gzhQauso41QzB9sMx72MdH5dQ76Z7ZHcPM8gWyecCB3mriwbng8uPZ5zEKgmVN1,4GJALHbWj3y1MLGzo6MJz3hJyDwQph3nSgE54f9K9dYC,EvCoDUdLCv8D5CBfQwArvxgr2C8WRBosVDg4ZhxCHEpo,3rRg9RtT64msF5nxSUSdbnVR3mC149mM5jNW9VfZjStW,3.108971958 46c3pCDa8hAuqiRN4SV3zwhuMz7XgDU6qrtsyzhkSXyJwjmeZ1TFsbxqnA15KCnPVLN1zNVUrouWJAskTX7v5uCF,AwQqQ1Xo9VxY64fcjw2toXZQnk94o5pFkxnGRngnqb1u,66Th151qye6WCmQ6nis5SzmBUZkVJ1uogCxMuxm6YLE,YjvHKGnS6vFNCBKtUNd1Jd2dQuovhNbY1iAbYhY22pC,12.617763101 39bf1gUcYqTuHnYTLPEbCGJ5NcpNBn8bkUGeVJxkRMRLuPP3SUaggdVcmDpHFUQSPJNq3wiCPvgzBTSwGWF53we,ESBjMYBxbsSidbQxKpY77W1V5Ewht4T1JNjqn9Qw9e7y,2uRG2BSVDBdBP1PZA6Dhde5qqs6eJZfx2jbxA148yY9n,2YZWv6StSnNx8iFneaiSPBbpi1K6AhJRA52tDXFo87o4,0.1 -5cVLZm21xYLbhsi8zN2YJPacuKQjsaxcguJGZ2keP4vrGDKVJvazbvECSMaHoY5qVYWovVP53QC1scGX8rdTPUT,AwQqQ1Xo9VxY64fcjw2toXZQnk94o5pFkxnGRngnqb1u,1PKTvQ2yWWP6gXTq8EP73bWWdGmoyvMQZnQ26xKzZ2G,F3cv38qusZTfLchrNC3NFFxTKmYdRTHdk5dkymXJtYCP,31.09692544 -2yDoFY813NMMrFctpef8wxV4ktEt9Nn8kogJHSA6FBDdHpbezk6X21W2rbHK5tHLHsYBj7sdjNRDpHb9au2nEZT,AwQqQ1Xo9VxY64fcjw2toXZQnk94o5pFkxnGRngnqb1u,4AX2wYzLAaYir9pewgFmotegbPmD51eH3cjaqkTFHxok,CiyGDgU8cDHtu4Pm2otLr9SK8r3jH3xFfJTDYLQVYEXE,31.457249984 -4oyZC4YBe3gkfS4T5FBesosYh5RtUzLmzu4eY9GRmmJiaD3aPGiUAGCMSefsR65rt7kH1AdZgDKp5r9FhFi9XRUs,FpPPhKwQxY1L2M12o7JuyaSooD1J2CLzaD9BP22jyF1L,D8KemM7RsJDzys44HRfS3nJH8B8yJXdqb5Naqa4kECaU,7a1JC1yyVqC7Q57JNpja4cXvobxwx8CyfrA1wxmsjTja,0.049693 -QSbUdMWMi4qWzFoeojb7GLa9MU8TuFFWaRKZZvo69ZJVgPzYUpzi3kZ1HR62ZW4wGxRnzP1HYKZSyJ457g1HFav,CdyBZ5E6wJNYbMWpmTfsBn9iS2z2tp9ch37WTBm5Gj52,BKLBXijVbwJK47fJWHmWyz2VAUnWeZETYLwYUD1ddc3k,2QufyZxx8vrd8ztiuiM4CSRgVVz7eHCqzA1bav4SbdfL,3.861127675 -5RbhAmdeFoWDtRW4bN5FUXZvin2WMjjnbgfdUVw97QVo6mbowdBozKs2ruhZ5EvpKr2pUjHoTTqJdwGeQL2E2H5F,AGFCb7sETaMhvKuq6j3iiVmRLh7WtryAJFgnDGt6LTgN,ENL47paJQUHhtoyEowYTK1Q7kiNmqV2BkrbZJXBXGQMf,7r7ZQBFTngNKGkL84fQxJt7HCTjzWZGLnDVdcu469CQ3,0.276342858 \ No newline at end of file +5cVLZm21xYLbhsi8zN2YJPacuKQjsaxcguJGZ2keP4vrGDKVJvazbvECSMaHoY5qVYWovVP53QC1scGX8rdTPUT,AwQqQ1Xo9VxY64fcjw2toXZQnk94o5pFkxnGRngnqb1u,1PKTvQ2yWWP6gXTq8EP73bWWdGmoyvMQZnQ26xKzZ2G,F3cv38qusZTfLchrNC3NFFxTKmYdRTHdk5dkymXJtYCP,31.09692544 \ No newline at end of file diff --git a/models/silver/nfts/silver__nft_sales_amm_sell.sql b/models/silver/nfts/silver__nft_sales_amm_sell.sql index 2b32c2e17..2a8329e00 100644 --- a/models/silver/nfts/silver__nft_sales_amm_sell.sql +++ b/models/silver/nfts/silver__nft_sales_amm_sell.sql @@ -1,68 +1,49 @@ --- depends_on: {{ ref('silver__decoded_instructions_combined') }} {{ config( materialized = 'incremental', - incremental_predicates = ["dynamic_range_predicate", "block_timestamp::date"], - merge_exclude_columns = ["inserted_timestamp"], - unique_key = "nft_sales_amm_sell_id", - cluster_by = ['block_timestamp::DATE','_inserted_timestamp::DATE'], + unique_key = "CONCAT_WS('-', tx_id, mint)", + incremental_strategy = 'delete+insert', + cluster_by = ['block_timestamp::DATE'], tags = ['scheduled_non_core'] ) }} -{% if execute %} - {% set base_query %} - CREATE OR REPLACE temporary TABLE silver.nft_sales_amm_sell__intermediate_tmp AS +WITH base_events AS ( SELECT - block_timestamp, - block_id, - tx_id, - succeeded, - signers, - INDEX, - inner_index, - program_id, - event_type, - decoded_instruction, - _inserted_timestamp + * FROM - {{ ref('silver__decoded_instructions_combined') }} + {{ ref('silver__events') }} WHERE program_id = 'mmm3XBJg5gk8XJxEKBvdgptZz6SgK4tXvn36sodowMc' - AND event_type IN ( - 'solMip1FulfillSell', - 'solFulfillSell', - 'solFulfillBuy', - 'solMip1FulfillBuy', - 'solOcpFulfillBuy', - 'solExtFulfillBuy', - 'solOcpFulfillSell' - ) - AND succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( SELECT - MAX(_inserted_timestamp) - INTERVAL '1 hour' + MAX(_inserted_timestamp) FROM {{ this }} ) {% else %} - AND _inserted_timestamp :: DATE >= '2022-10-14' -{% endif %} -{% endset %} - -{% do run_query(base_query) %} -{% set between_stmts = fsc_utils.dynamic_range_predicate( - "silver.nft_sales_amm_sell__intermediate_tmp", - "block_timestamp::date" -) %} + AND block_timestamp :: DATE >= '2022-10-14' {% endif %} - -WITH base_decoded AS ( +), +base_token_balance AS ( SELECT * FROM - silver.nft_sales_amm_sell__intermediate_tmp + {{ ref('silver___post_token_balances') }} + WHERE + amount = 1 + +{% if is_incremental() %} +AND _inserted_timestamp >= ( + SELECT + MAX(_inserted_timestamp) + FROM + {{ this }} +) +{% else %} + AND block_timestamp :: DATE >= '2022-10-14' +{% endif %} ), base_transfers AS ( SELECT @@ -70,125 +51,103 @@ base_transfers AS ( FROM {{ ref('silver__transfers') }} WHERE - mint = 'So11111111111111111111111111111111111111111' - AND succeeded - AND {{ between_stmts }} + mint = 'So11111111111111111111111111111111111111112' + +{% if is_incremental() %} +AND _inserted_timestamp >= ( + SELECT + MAX(_inserted_timestamp) + FROM + {{ this }} +) +{% else %} + AND block_timestamp :: DATE >= '2022-10-14' +{% endif %} ), coral_cube_sales AS( SELECT - block_timestamp, - block_id, - tx_id, - INDEX, - inner_index, - signers, - succeeded, - program_id, - decoded_instruction, - event_type, + A.*, CASE - WHEN event_type IN ( - 'solFulfillSell', - 'solMip1FulfillSell', - 'solOcpFulfillSell' - ) THEN silver.udf_get_account_pubkey_by_name( - 'payer', - decoded_instruction :accounts - ) - ELSE silver.udf_get_account_pubkey_by_name( - 'pool', - decoded_instruction :accounts - ) + WHEN b1.owner IS NOT NULL THEN b1.owner + WHEN b2.owner IS NOT NULL THEN b2.owner + ELSE A.instruction :accounts [1] :: STRING END AS purchaser, CASE - WHEN event_type IN ( - 'solFulfillSell', - 'solMip1FulfillSell', - 'solOcpFulfillSell' - ) THEN silver.udf_get_account_pubkey_by_name( - 'pool', - decoded_instruction :accounts - ) - ELSE silver.udf_get_account_pubkey_by_name( - 'payer', - decoded_instruction :accounts - ) + WHEN b1.owner IS NOT NULL THEN A.instruction :accounts [4] :: STRING + ELSE A.instruction :accounts [0] :: STRING END AS seller, CASE - WHEN event_type IN ( - 'solFulfillSell', - 'solMip1FulfillSell', - 'solOcpFulfillSell' - ) THEN 'sell' + WHEN b1.owner IS NOT NULL THEN 'sell' ELSE 'buy' END AS nft_sale_type, 'Coral Cube' AS marketplace, - silver.udf_get_account_pubkey_by_name( - 'assetMint', - decoded_instruction :accounts - ) AS mint, - _inserted_timestamp + A.instruction :accounts [8] :: STRING AS mint FROM - base_decoded + base_events A + LEFT JOIN base_token_balance b1 + ON A.tx_id = b1.tx_id + AND A.instruction :accounts [0] = b1.owner + LEFT JOIN base_token_balance b2 + ON A.tx_id = b2.tx_id + AND A.instruction :accounts [4] = b2.owner WHERE - signers [1] = '7RpRDUZBdu5hfmqWvobPazbNeVCagRk5E3Rb8Bm8qRmD' + A.signers [1] = '7RpRDUZBdu5hfmqWvobPazbNeVCagRk5E3Rb8Bm8qRmD' + AND A.instruction :accounts [14] <> 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s' AND purchaser <> '7RpRDUZBdu5hfmqWvobPazbNeVCagRk5E3Rb8Bm8qRmD' + AND ARRAY_SIZE( + instruction :accounts + ) >= 16 ), mev2_sales AS( + -- mev2_buys SELECT - block_timestamp, - block_id, - tx_id, - INDEX, - inner_index, - signers, - succeeded, - program_id, - decoded_instruction, - event_type, - CASE - WHEN event_type IN ( - 'solMip1FulfillSell', - 'solFulfillSell' - ) THEN silver.udf_get_account_pubkey_by_name( - 'payer', - decoded_instruction :accounts - ) - ELSE silver.udf_get_account_pubkey_by_name( - 'owner', - decoded_instruction :accounts - ) - END AS purchaser, + A.*, + instruction :accounts [1] :: STRING AS purchaser, + instruction :accounts [0] :: STRING AS seller, + 'buy' AS nft_sale_type, + 'Magic Eden' AS marketplace, + instruction :accounts [8] :: STRING AS mint + FROM + base_events A + WHERE + signers [1] = 'NTYeYJ1wr4bpM5xo6zx5En44SvJFAd35zTxxNoERYqd' + AND ARRAY_SIZE( + instruction :accounts + ) > 16 + AND ( + instruction :accounts [12] :: STRING = '11111111111111111111111111111111' + OR instruction :accounts [16] :: STRING = 'ocp4vWUzA2z2XMYJ3QhM9vWdyoyoQwAFJhRdVTbvo9E' + ) + UNION ALL + -- mev2_sells + SELECT + A.*, + instruction :accounts [0] :: STRING AS purchaser, + instruction :accounts [1] :: STRING AS seller, + 'sell' AS nft_sale_type, + 'Magic Eden' AS marketplace, CASE - WHEN event_type IN ( - 'solMip1FulfillSell', - 'solFulfillSell' - ) THEN silver.udf_get_account_pubkey_by_name( - 'owner', - decoded_instruction :accounts + WHEN ARRAY_SIZE( + instruction :accounts + ) > 19 THEN instruction :accounts [7] :: STRING + WHEN ARRAY_SIZE( + instruction :accounts ) - ELSE silver.udf_get_account_pubkey_by_name( - 'payer', - decoded_instruction :accounts - ) - END AS seller, - CASE - WHEN event_type IN ( - 'solMip1FulfillSell', - 'solFulfillSell' - ) THEN 'sell' - ELSE 'buy' - END AS nft_sale_type, - 'Magic Eden' AS marketplace, - silver.udf_get_account_pubkey_by_name( - 'assetMint', - decoded_instruction :accounts - ) AS mint, - _inserted_timestamp + IN ( + 17, + 18, + 19 + ) THEN instruction :accounts [8] :: STRING + END AS mint FROM - base_decoded + base_events A WHERE signers [1] = 'NTYeYJ1wr4bpM5xo6zx5En44SvJFAd35zTxxNoERYqd' + AND ARRAY_SIZE( + instruction :accounts + ) > 16 + AND instruction :accounts [11] :: STRING = '11111111111111111111111111111111' + AND instruction :accounts [16] :: STRING != 'ocp4vWUzA2z2XMYJ3QhM9vWdyoyoQwAFJhRdVTbvo9E' ), coral_cube_nft_sale_amount AS ( SELECT @@ -208,10 +167,7 @@ coral_cube_nft_sale_amount AS ( ) OR ( A.nft_sale_type = 'buy' - AND silver.udf_get_account_pubkey_by_name( - 'buysideSolEscrowAccount', - A.decoded_instruction :accounts - ) :: STRING = b.tx_from + AND A.instruction :accounts [5] = b.tx_from ) GROUP BY 1, @@ -231,65 +187,60 @@ mev2_nft_sale_amount AS ( WHERE ( A.nft_sale_type = 'sell' - AND A.purchaser = b.tx_from + AND A.instruction :accounts [0] = b.tx_from ) OR ( A.nft_sale_type = 'buy' - AND silver.udf_get_account_pubkey_by_name( - 'buysideSolEscrowAccount', - A.decoded_instruction :accounts - ) :: STRING = b.tx_from + AND A.instruction :accounts [5] = b.tx_from ) GROUP BY 1, 2 -), -pre_final AS ( - SELECT - A.block_timestamp, - A.block_id, - A.tx_id, - A.succeeded, - A.index, - A.inner_index, - A.program_id, - A.mint, - A.purchaser, - A.seller, - b.sales_amount, - A.marketplace, - A._inserted_timestamp - FROM - coral_cube_sales A - LEFT JOIN coral_cube_nft_sale_amount b - ON A.tx_id = b.tx_id - WHERE - b.sales_amount IS NOT NULL - UNION - SELECT - A.block_timestamp, - A.block_id, - A.tx_id, - A.succeeded, - A.index, - A.inner_index, - A.program_id, - A.mint, - A.purchaser, - A.seller, - b.sales_amount, - A.marketplace, - A._inserted_timestamp - FROM - mev2_sales A - LEFT JOIN mev2_nft_sale_amount b - ON A.tx_id = b.tx_id ) SELECT - *, - {{ dbt_utils.generate_surrogate_key(['tx_id','mint']) }} AS nft_sales_amm_sell_id, + A.block_timestamp, + A.block_id, + A.tx_id, + A.succeeded, + A.program_id, + A.mint, + A.purchaser, + A.seller, + b.sales_amount, + A.marketplace, + A._inserted_timestamp, + {{ dbt_utils.generate_surrogate_key( + ['A.tx_id','A.mint'] + ) }} AS nft_sales_amm_sell_id, + SYSDATE() AS inserted_timestamp, + SYSDATE() AS modified_timestamp, + '{{ invocation_id }}' AS _invocation_id +FROM + coral_cube_sales A + LEFT JOIN coral_cube_nft_sale_amount b + ON A.tx_id = b.tx_id +WHERE + b.sales_amount IS NOT NULL +UNION +SELECT + A.block_timestamp, + A.block_id, + A.tx_id, + A.succeeded, + A.program_id, + A.mint, + A.purchaser, + A.seller, + b.sales_amount, + A.marketplace, + A._inserted_timestamp, + {{ dbt_utils.generate_surrogate_key( + ['A.tx_id','A.mint'] + ) }} AS nft_sales_amm_sell_id, SYSDATE() AS inserted_timestamp, SYSDATE() AS modified_timestamp, '{{ invocation_id }}' AS _invocation_id FROM - pre_final + mev2_sales A + LEFT JOIN mev2_nft_sale_amount b + ON A.tx_id = b.tx_id \ No newline at end of file diff --git a/models/silver/nfts/silver__nft_sales_amm_sell.yml b/models/silver/nfts/silver__nft_sales_amm_sell.yml index 71c3815f5..f772227c5 100644 --- a/models/silver/nfts/silver__nft_sales_amm_sell.yml +++ b/models/silver/nfts/silver__nft_sales_amm_sell.yml @@ -20,10 +20,7 @@ models: '2yDoFY813NMMrFctpef8wxV4ktEt9Nn8kogJHSA6FBDdHpbezk6X21W2rbHK5tHLHsYBj7sdjNRDpHb9au2nEZT', '5cVLZm21xYLbhsi8zN2YJPacuKQjsaxcguJGZ2keP4vrGDKVJvazbvECSMaHoY5qVYWovVP53QC1scGX8rdTPUT', '39bf1gUcYqTuHnYTLPEbCGJ5NcpNBn8bkUGeVJxkRMRLuPP3SUaggdVcmDpHFUQSPJNq3wiCPvgzBTSwGWF53we', - '46c3pCDa8hAuqiRN4SV3zwhuMz7XgDU6qrtsyzhkSXyJwjmeZ1TFsbxqnA15KCnPVLN1zNVUrouWJAskTX7v5uCF', - '4oyZC4YBe3gkfS4T5FBesosYh5RtUzLmzu4eY9GRmmJiaD3aPGiUAGCMSefsR65rt7kH1AdZgDKp5r9FhFi9XRUs', - 'QSbUdMWMi4qWzFoeojb7GLa9MU8TuFFWaRKZZvo69ZJVgPzYUpzi3kZ1HR62ZW4wGxRnzP1HYKZSyJ457g1HFav', - '5RbhAmdeFoWDtRW4bN5FUXZvin2WMjjnbgfdUVw97QVo6mbowdBozKs2ruhZ5EvpKr2pUjHoTTqJdwGeQL2E2H5F')" + '46c3pCDa8hAuqiRN4SV3zwhuMz7XgDU6qrtsyzhkSXyJwjmeZ1TFsbxqnA15KCnPVLN1zNVUrouWJAskTX7v5uCF')" columns: - name: BLOCK_TIMESTAMP description: "{{ doc('block_timestamp') }}" From 8caefa88067105b45999c07c0cd25babd79b47a8 Mon Sep 17 00:00:00 2001 From: tarikceric Date: Mon, 22 Jul 2024 16:41:16 -0700 Subject: [PATCH 06/10] revert --- data/testing__nft_sales_amm_sell.csv | 3 ++- models/silver/nfts/silver__nft_sales_amm_sell.sql | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/data/testing__nft_sales_amm_sell.csv b/data/testing__nft_sales_amm_sell.csv index 2a93c6cd9..d77dd6cf6 100644 --- a/data/testing__nft_sales_amm_sell.csv +++ b/data/testing__nft_sales_amm_sell.csv @@ -3,4 +3,5 @@ Ep7n5yUXoBiV6J3ntzvCqaGMS92NbQ9zdqS8ZMJVEwVGhKxsomKzGfsKzyHpzrb9s7ipLH4Cn5P88rne 59fgrVMFqY1scM8gumej3kCq6gzhQauso41QzB9sMx72MdH5dQ76Z7ZHcPM8gWyecCB3mriwbng8uPZ5zEKgmVN1,4GJALHbWj3y1MLGzo6MJz3hJyDwQph3nSgE54f9K9dYC,EvCoDUdLCv8D5CBfQwArvxgr2C8WRBosVDg4ZhxCHEpo,3rRg9RtT64msF5nxSUSdbnVR3mC149mM5jNW9VfZjStW,3.108971958 46c3pCDa8hAuqiRN4SV3zwhuMz7XgDU6qrtsyzhkSXyJwjmeZ1TFsbxqnA15KCnPVLN1zNVUrouWJAskTX7v5uCF,AwQqQ1Xo9VxY64fcjw2toXZQnk94o5pFkxnGRngnqb1u,66Th151qye6WCmQ6nis5SzmBUZkVJ1uogCxMuxm6YLE,YjvHKGnS6vFNCBKtUNd1Jd2dQuovhNbY1iAbYhY22pC,12.617763101 39bf1gUcYqTuHnYTLPEbCGJ5NcpNBn8bkUGeVJxkRMRLuPP3SUaggdVcmDpHFUQSPJNq3wiCPvgzBTSwGWF53we,ESBjMYBxbsSidbQxKpY77W1V5Ewht4T1JNjqn9Qw9e7y,2uRG2BSVDBdBP1PZA6Dhde5qqs6eJZfx2jbxA148yY9n,2YZWv6StSnNx8iFneaiSPBbpi1K6AhJRA52tDXFo87o4,0.1 -5cVLZm21xYLbhsi8zN2YJPacuKQjsaxcguJGZ2keP4vrGDKVJvazbvECSMaHoY5qVYWovVP53QC1scGX8rdTPUT,AwQqQ1Xo9VxY64fcjw2toXZQnk94o5pFkxnGRngnqb1u,1PKTvQ2yWWP6gXTq8EP73bWWdGmoyvMQZnQ26xKzZ2G,F3cv38qusZTfLchrNC3NFFxTKmYdRTHdk5dkymXJtYCP,31.09692544 \ No newline at end of file +5cVLZm21xYLbhsi8zN2YJPacuKQjsaxcguJGZ2keP4vrGDKVJvazbvECSMaHoY5qVYWovVP53QC1scGX8rdTPUT,AwQqQ1Xo9VxY64fcjw2toXZQnk94o5pFkxnGRngnqb1u,1PKTvQ2yWWP6gXTq8EP73bWWdGmoyvMQZnQ26xKzZ2G,F3cv38qusZTfLchrNC3NFFxTKmYdRTHdk5dkymXJtYCP,31.09692544 +2yDoFY813NMMrFctpef8wxV4ktEt9Nn8kogJHSA6FBDdHpbezk6X21W2rbHK5tHLHsYBj7sdjNRDpHb9au2nEZT,AwQqQ1Xo9VxY64fcjw2toXZQnk94o5pFkxnGRngnqb1u,4AX2wYzLAaYir9pewgFmotegbPmD51eH3cjaqkTFHxok,CiyGDgU8cDHtu4Pm2otLr9SK8r3jH3xFfJTDYLQVYEXE,31.457249984 \ No newline at end of file diff --git a/models/silver/nfts/silver__nft_sales_amm_sell.sql b/models/silver/nfts/silver__nft_sales_amm_sell.sql index 2a8329e00..3de3ed9ab 100644 --- a/models/silver/nfts/silver__nft_sales_amm_sell.sql +++ b/models/silver/nfts/silver__nft_sales_amm_sell.sql @@ -243,4 +243,4 @@ SELECT FROM mev2_sales A LEFT JOIN mev2_nft_sale_amount b - ON A.tx_id = b.tx_id \ No newline at end of file + ON A.tx_id = b.tx_id From 42cc7be606037af6690d3bdebd1ff6d396ee835a Mon Sep 17 00:00:00 2001 From: tarikceric Date: Mon, 22 Jul 2024 18:28:57 -0700 Subject: [PATCH 07/10] new model; convert old one to view; update gold --- data/testing__nft_sales_amm_sell_decoded.csv | 9 + models/gold/nft/nft__fact_nft_sales.sql | 25 +- .../nfts/silver__nft_sales_amm_sell.sql | 3 +- .../silver__nft_sales_amm_sell_decoded.sql | 308 ++++++++++++++++++ .../silver__nft_sales_amm_sell_decoded.yml | 95 ++++++ .../nfts/silver__nft_sales_amm_sell_view.sql | 25 ++ models/sources.yml | 1 + 7 files changed, 464 insertions(+), 2 deletions(-) create mode 100644 data/testing__nft_sales_amm_sell_decoded.csv create mode 100644 models/silver/nfts/silver__nft_sales_amm_sell_decoded.sql create mode 100644 models/silver/nfts/silver__nft_sales_amm_sell_decoded.yml create mode 100644 models/silver/nfts/silver__nft_sales_amm_sell_view.sql diff --git a/data/testing__nft_sales_amm_sell_decoded.csv b/data/testing__nft_sales_amm_sell_decoded.csv new file mode 100644 index 000000000..7b83ac4e2 --- /dev/null +++ b/data/testing__nft_sales_amm_sell_decoded.csv @@ -0,0 +1,9 @@ +tx_id,purchaser,seller,mint,sales_amount +Ep7n5yUXoBiV6J3ntzvCqaGMS92NbQ9zdqS8ZMJVEwVGhKxsomKzGfsKzyHpzrb9s7ipLH4Cn5P88rneZEcm1Uy,6Y9SASCK9Vsa1T84qb6fY16HwkxmAk3mYyxbKs1UQ5cN,EVszcWthU6JidYCPgYc1y2uqoSajkJ3uepWPcK19336b,BwQKXrxKS9qDSvjmU4ZfFv8YnJM2jYXpSQA4yE6KmV6p,4.403131112 +59fgrVMFqY1scM8gumej3kCq6gzhQauso41QzB9sMx72MdH5dQ76Z7ZHcPM8gWyecCB3mriwbng8uPZ5zEKgmVN1,4GJALHbWj3y1MLGzo6MJz3hJyDwQph3nSgE54f9K9dYC,EvCoDUdLCv8D5CBfQwArvxgr2C8WRBosVDg4ZhxCHEpo,3rRg9RtT64msF5nxSUSdbnVR3mC149mM5jNW9VfZjStW,3.108971958 +46c3pCDa8hAuqiRN4SV3zwhuMz7XgDU6qrtsyzhkSXyJwjmeZ1TFsbxqnA15KCnPVLN1zNVUrouWJAskTX7v5uCF,AwQqQ1Xo9VxY64fcjw2toXZQnk94o5pFkxnGRngnqb1u,66Th151qye6WCmQ6nis5SzmBUZkVJ1uogCxMuxm6YLE,YjvHKGnS6vFNCBKtUNd1Jd2dQuovhNbY1iAbYhY22pC,12.617763101 +5cVLZm21xYLbhsi8zN2YJPacuKQjsaxcguJGZ2keP4vrGDKVJvazbvECSMaHoY5qVYWovVP53QC1scGX8rdTPUT,AwQqQ1Xo9VxY64fcjw2toXZQnk94o5pFkxnGRngnqb1u,1PKTvQ2yWWP6gXTq8EP73bWWdGmoyvMQZnQ26xKzZ2G,F3cv38qusZTfLchrNC3NFFxTKmYdRTHdk5dkymXJtYCP,31.09692544 +2yDoFY813NMMrFctpef8wxV4ktEt9Nn8kogJHSA6FBDdHpbezk6X21W2rbHK5tHLHsYBj7sdjNRDpHb9au2nEZT,AwQqQ1Xo9VxY64fcjw2toXZQnk94o5pFkxnGRngnqb1u,4AX2wYzLAaYir9pewgFmotegbPmD51eH3cjaqkTFHxok,CiyGDgU8cDHtu4Pm2otLr9SK8r3jH3xFfJTDYLQVYEXE,31.457249984 +4oyZC4YBe3gkfS4T5FBesosYh5RtUzLmzu4eY9GRmmJiaD3aPGiUAGCMSefsR65rt7kH1AdZgDKp5r9FhFi9XRUs,FpPPhKwQxY1L2M12o7JuyaSooD1J2CLzaD9BP22jyF1L,D8KemM7RsJDzys44HRfS3nJH8B8yJXdqb5Naqa4kECaU,7a1JC1yyVqC7Q57JNpja4cXvobxwx8CyfrA1wxmsjTja,0.049693 +QSbUdMWMi4qWzFoeojb7GLa9MU8TuFFWaRKZZvo69ZJVgPzYUpzi3kZ1HR62ZW4wGxRnzP1HYKZSyJ457g1HFav,CdyBZ5E6wJNYbMWpmTfsBn9iS2z2tp9ch37WTBm5Gj52,BKLBXijVbwJK47fJWHmWyz2VAUnWeZETYLwYUD1ddc3k,2QufyZxx8vrd8ztiuiM4CSRgVVz7eHCqzA1bav4SbdfL,3.861127675 +5RbhAmdeFoWDtRW4bN5FUXZvin2WMjjnbgfdUVw97QVo6mbowdBozKs2ruhZ5EvpKr2pUjHoTTqJdwGeQL2E2H5F,AGFCb7sETaMhvKuq6j3iiVmRLh7WtryAJFgnDGt6LTgN,ENL47paJQUHhtoyEowYTK1Q7kiNmqV2BkrbZJXBXGQMf,7r7ZQBFTngNKGkL84fQxJt7HCTjzWZGLnDVdcu469CQ3,0.276342858 \ No newline at end of file diff --git a/models/gold/nft/nft__fact_nft_sales.sql b/models/gold/nft/nft__fact_nft_sales.sql index 0c0512d32..e48e122ef 100644 --- a/models/gold/nft/nft__fact_nft_sales.sql +++ b/models/gold/nft/nft__fact_nft_sales.sql @@ -337,7 +337,30 @@ SELECT '2000-01-01' ) AS modified_timestamp FROM - {{ ref('silver__nft_sales_amm_sell') }} + {{ ref('silver__nft_sales_amm_sell_view') }} +WHERE + block_timestamp::date < '2022-10-30' +UNION ALL +SELECT + marketplace, + block_timestamp, + block_id, + tx_id, + succeeded, + program_id, + purchaser, + seller, + mint, + sales_amount, + NULL as tree_authority, + NULL as merkle_tree, + NULL as leaf_index, + FALSE as is_compressed, + nft_sales_amm_sell_decoded_id as fact_nft_sales_id, + inserted_timestamp, + modified_timestamp +FROM + {{ ref('silver__nft_sales_amm_sell_decoded') }} UNION ALL SELECT 'tensorswap', diff --git a/models/silver/nfts/silver__nft_sales_amm_sell.sql b/models/silver/nfts/silver__nft_sales_amm_sell.sql index 3de3ed9ab..6301284a3 100644 --- a/models/silver/nfts/silver__nft_sales_amm_sell.sql +++ b/models/silver/nfts/silver__nft_sales_amm_sell.sql @@ -3,7 +3,8 @@ unique_key = "CONCAT_WS('-', tx_id, mint)", incremental_strategy = 'delete+insert', cluster_by = ['block_timestamp::DATE'], - tags = ['scheduled_non_core'] + full_refresh = false, + enabled = false, ) }} WITH base_events AS ( diff --git a/models/silver/nfts/silver__nft_sales_amm_sell_decoded.sql b/models/silver/nfts/silver__nft_sales_amm_sell_decoded.sql new file mode 100644 index 000000000..988e7832b --- /dev/null +++ b/models/silver/nfts/silver__nft_sales_amm_sell_decoded.sql @@ -0,0 +1,308 @@ +-- depends_on: {{ ref('silver__decoded_instructions_combined') }} +{{ config( + materialized = 'incremental', + incremental_predicates = ["dynamic_range_predicate", "block_timestamp::date"], + merge_exclude_columns = ["inserted_timestamp"], + unique_key = "nft_sales_amm_sell_decoded_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_amm_sell_decoded__intermediate_tmp AS + + SELECT + block_timestamp, + block_id, + tx_id, + succeeded, + signers, + INDEX, + inner_index, + program_id, + event_type, + decoded_instruction, + _inserted_timestamp + FROM + {{ ref('silver__decoded_instructions_combined') }} + WHERE + program_id = 'mmm3XBJg5gk8XJxEKBvdgptZz6SgK4tXvn36sodowMc' + AND event_type IN ( + 'solMip1FulfillSell', + 'solFulfillSell', + 'solFulfillBuy', + 'solMip1FulfillBuy', + 'solOcpFulfillBuy', + 'solExtFulfillBuy', + 'solOcpFulfillSell' + ) + AND succeeded + +{% if is_incremental() %} +AND _inserted_timestamp >= ( + SELECT + MAX(_inserted_timestamp) - INTERVAL '1 hour' + FROM + {{ this }} +) +{% else %} + AND block_timestamp :: DATE >= '2022-10-30' -- refer to legacy model for sales before this date +{% endif %} +{% endset %} + +{% do run_query(base_query) %} +{% set between_stmts = fsc_utils.dynamic_range_predicate( + "silver.nft_sales_amm_sell_decoded__intermediate_tmp", + "block_timestamp::date" +) %} +{% endif %} + +WITH base_decoded AS ( + SELECT + * + FROM + silver.nft_sales_amm_sell_decoded__intermediate_tmp +), +base_transfers AS ( + SELECT + * + FROM + {{ ref('silver__transfers') }} + WHERE + mint = 'So11111111111111111111111111111111111111111' + AND succeeded + AND {{ between_stmts }} +), +coral_cube_sales AS( + SELECT + block_timestamp, + block_id, + tx_id, + INDEX, + inner_index, + signers, + succeeded, + program_id, + decoded_instruction, + event_type, + CASE + WHEN event_type IN ( + 'solFulfillSell', + 'solMip1FulfillSell', + 'solOcpFulfillSell' + ) THEN silver.udf_get_account_pubkey_by_name( + 'payer', + decoded_instruction :accounts + ) + ELSE silver.udf_get_account_pubkey_by_name( + 'pool', + decoded_instruction :accounts + ) + END AS purchaser, + CASE + WHEN event_type IN ( + 'solFulfillSell', + 'solMip1FulfillSell', + 'solOcpFulfillSell' + ) THEN silver.udf_get_account_pubkey_by_name( + 'pool', + decoded_instruction :accounts + ) + ELSE silver.udf_get_account_pubkey_by_name( + 'payer', + decoded_instruction :accounts + ) + END AS seller, + CASE + WHEN event_type IN ( + 'solFulfillSell', + 'solMip1FulfillSell', + 'solOcpFulfillSell' + ) THEN 'sell' + ELSE 'buy' + END AS nft_sale_type, + 'Coral Cube' AS marketplace, + silver.udf_get_account_pubkey_by_name( + 'assetMint', + decoded_instruction :accounts + ) AS mint, + _inserted_timestamp + FROM + base_decoded + WHERE + signers [1] = '7RpRDUZBdu5hfmqWvobPazbNeVCagRk5E3Rb8Bm8qRmD' + AND purchaser <> '7RpRDUZBdu5hfmqWvobPazbNeVCagRk5E3Rb8Bm8qRmD' +), +mev2_sales AS( + SELECT + block_timestamp, + block_id, + tx_id, + INDEX, + inner_index, + signers, + succeeded, + program_id, + decoded_instruction, + event_type, + CASE + WHEN event_type IN ( + 'solMip1FulfillSell', + 'solFulfillSell' + ) THEN silver.udf_get_account_pubkey_by_name( + 'payer', + decoded_instruction :accounts + ) + ELSE silver.udf_get_account_pubkey_by_name( + 'owner', + decoded_instruction :accounts + ) + END AS purchaser, + CASE + WHEN event_type IN ( + 'solMip1FulfillSell', + 'solFulfillSell' + ) THEN silver.udf_get_account_pubkey_by_name( + 'owner', + decoded_instruction :accounts + ) + ELSE silver.udf_get_account_pubkey_by_name( + 'payer', + decoded_instruction :accounts + ) + END AS seller, + CASE + WHEN event_type IN ( + 'solMip1FulfillSell', + 'solFulfillSell' + ) THEN 'sell' + ELSE 'buy' + END AS nft_sale_type, + 'Magic Eden' AS marketplace, + silver.udf_get_account_pubkey_by_name( + 'assetMint', + decoded_instruction :accounts + ) AS mint, + _inserted_timestamp + FROM + base_decoded + WHERE + signers [1] = 'NTYeYJ1wr4bpM5xo6zx5En44SvJFAd35zTxxNoERYqd' +), +coral_cube_nft_sale_amount AS ( + SELECT + A.tx_id, + b.mint, + SUM( + b.amount + ) AS sales_amount + FROM + coral_cube_sales A + LEFT OUTER JOIN base_transfers b + ON A.tx_id = b.tx_id + WHERE + ( + A.nft_sale_type = 'sell' + AND A.purchaser = b.tx_from + ) + OR ( + A.nft_sale_type = 'buy' + AND silver.udf_get_account_pubkey_by_name( + 'buysideSolEscrowAccount', + A.decoded_instruction :accounts + ) :: STRING = b.tx_from + ) + GROUP BY + 1, + 2 +), +mev2_nft_sale_amount AS ( + SELECT + A.tx_id, + b.mint, + SUM( + b.amount + ) AS sales_amount + FROM + mev2_sales A + LEFT OUTER JOIN base_transfers b + ON A.tx_id = b.tx_id + WHERE + ( + A.nft_sale_type = 'sell' + AND A.purchaser = b.tx_from + ) + OR ( + A.nft_sale_type = 'buy' + AND silver.udf_get_account_pubkey_by_name( + 'buysideSolEscrowAccount', + A.decoded_instruction :accounts + ) :: STRING = b.tx_from + ) + GROUP BY + 1, + 2 +), +pre_final AS ( + SELECT + A.block_timestamp, + A.block_id, + A.tx_id, + A.succeeded, + A.index, + A.inner_index, + A.program_id, + A.mint, + A.purchaser, + A.seller, + b.sales_amount, + A.marketplace, + A._inserted_timestamp + FROM + coral_cube_sales A + LEFT JOIN coral_cube_nft_sale_amount b + ON A.tx_id = b.tx_id + WHERE + b.sales_amount IS NOT NULL + UNION + SELECT + A.block_timestamp, + A.block_id, + A.tx_id, + A.succeeded, + A.index, + A.inner_index, + A.program_id, + A.mint, + A.purchaser, + A.seller, + b.sales_amount, + A.marketplace, + A._inserted_timestamp + FROM + mev2_sales A + LEFT JOIN mev2_nft_sale_amount b + ON A.tx_id = b.tx_id +) +SELECT + block_timestamp, + block_id, + tx_id, + succeeded, + index, + inner_index, + program_id, + mint, + purchaser, + seller, + sales_amount, + marketplace, + _inserted_timestamp, + {{ dbt_utils.generate_surrogate_key(['tx_id','mint']) }} AS nft_sales_amm_sell_decoded_id, + SYSDATE() AS inserted_timestamp, + SYSDATE() AS modified_timestamp, + '{{ invocation_id }}' AS _invocation_id +FROM + pre_final + diff --git a/models/silver/nfts/silver__nft_sales_amm_sell_decoded.yml b/models/silver/nfts/silver__nft_sales_amm_sell_decoded.yml new file mode 100644 index 000000000..fa11dc557 --- /dev/null +++ b/models/silver/nfts/silver__nft_sales_amm_sell_decoded.yml @@ -0,0 +1,95 @@ +version: 2 +models: + - name: silver__nft_sales_amm_sell_decoded + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - TX_ID + - MINT + where: block_timestamp::date > current_date - 30 + - compare_model_subset: + name: silver__nft_sales_amm_sell_decoded_business_logic_test + compare_model: ref('testing__nft_sales_amm_sell_decoded') + compare_columns: + - tx_id + - purchaser + - seller + - mint + - round(sales_amount,8) + model_condition: "where tx_id in ('Ep7n5yUXoBiV6J3ntzvCqaGMS92NbQ9zdqS8ZMJVEwVGhKxsomKzGfsKzyHpzrb9s7ipLH4Cn5P88rneZEcm1Uy', + '59fgrVMFqY1scM8gumej3kCq6gzhQauso41QzB9sMx72MdH5dQ76Z7ZHcPM8gWyecCB3mriwbng8uPZ5zEKgmVN1', + '2yDoFY813NMMrFctpef8wxV4ktEt9Nn8kogJHSA6FBDdHpbezk6X21W2rbHK5tHLHsYBj7sdjNRDpHb9au2nEZT', + '5cVLZm21xYLbhsi8zN2YJPacuKQjsaxcguJGZ2keP4vrGDKVJvazbvECSMaHoY5qVYWovVP53QC1scGX8rdTPUT', + '46c3pCDa8hAuqiRN4SV3zwhuMz7XgDU6qrtsyzhkSXyJwjmeZ1TFsbxqnA15KCnPVLN1zNVUrouWJAskTX7v5uCF', + '4oyZC4YBe3gkfS4T5FBesosYh5RtUzLmzu4eY9GRmmJiaD3aPGiUAGCMSefsR65rt7kH1AdZgDKp5r9FhFi9XRUs', + 'QSbUdMWMi4qWzFoeojb7GLa9MU8TuFFWaRKZZvo69ZJVgPzYUpzi3kZ1HR62ZW4wGxRnzP1HYKZSyJ457g1HFav', + '5RbhAmdeFoWDtRW4bN5FUXZvin2WMjjnbgfdUVw97QVo6mbowdBozKs2ruhZ5EvpKr2pUjHoTTqJdwGeQL2E2H5F')" + recent_date_filter: &recent_date_filter + config: + where: _inserted_timestamp >= current_date - 7 + 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: *recent_date_filter + - name: TX_ID + description: "{{ doc('tx_id') }}" + tests: + - not_null: *recent_date_filter + - name: SUCCEEDED + description: "{{ doc('tx_succeeded') }}" + tests: + - not_null: *recent_date_filter + - name: PROGRAM_ID + description: "{{ doc('program_id') }}" + tests: + - not_null: *recent_date_filter + - name: PURCHASER + description: "{{ doc('purchaser') }}" + tests: + - not_null: *recent_date_filter + - name: SELLER + description: "{{ doc('seller') }}" + tests: + - not_null: *recent_date_filter + - name: MINT + description: "{{ doc('mint') }}" + tests: + - not_null: *recent_date_filter + - name: SALES_AMOUNT + description: "{{ doc('sales_amount') }}" + tests: + - not_null: *recent_date_filter + - name: MARKETPLACE + description: "{{ doc('marketplace') }}" + tests: + - not_null: *recent_date_filter + - name: _INSERTED_TIMESTAMP + description: "{{ doc('_inserted_timestamp') }}" + tests: + - not_null + - name: NFT_SALES_AMM_SELL_DECODED_ID + description: '{{ doc("pk") }}' + tests: + - unique: *recent_date_filter + - name: INSERTED_TIMESTAMP + description: '{{ doc("inserted_timestamp") }}' + tests: + - not_null: *recent_date_filter + - name: MODIFIED_TIMESTAMP + description: '{{ doc("modified_timestamp") }}' + tests: + - not_null: *recent_date_filter + - name: _INVOCATION_ID + description: '{{ doc("_invocation_id") }}' + tests: + - not_null: + name: test_silver__not_null_nft_sales_amm_sell_decoded__invocation_id + <<: *recent_date_filter \ No newline at end of file diff --git a/models/silver/nfts/silver__nft_sales_amm_sell_view.sql b/models/silver/nfts/silver__nft_sales_amm_sell_view.sql new file mode 100644 index 000000000..2fe63a5d3 --- /dev/null +++ b/models/silver/nfts/silver__nft_sales_amm_sell_view.sql @@ -0,0 +1,25 @@ +{{ config( + materialized = 'view' +) }} + +SELECT + block_timestamp, + block_id, + tx_id, + succeeded, + program_id, + mint, + purchaser, + seller, + sales_amount, + marketplace, + _inserted_timestamp, + nft_sales_amm_sell_id, + inserted_timestamp, + modified_timestamp, + _invocation_id +FROM + {{ source( + 'solana_silver', + 'nft_sales_amm_sell' + ) }} diff --git a/models/sources.yml b/models/sources.yml index 4729c8487..0d12301b3 100644 --- a/models/sources.yml +++ b/models/sources.yml @@ -84,6 +84,7 @@ sources: - name: _blocks_tx_count - name: nft_sales_solsniper_v1_events - name: swaps_intermediate_jupiterv6 + - name: nft_sales_amm_sell - name: solana_streamline database: solana schema: streamline From 5c412b99954b5d2ca83cf799747b7962085cb7ba Mon Sep 17 00:00:00 2001 From: tarikceric Date: Tue, 23 Jul 2024 12:55:35 -0700 Subject: [PATCH 08/10] add events --- .../silver/nfts/silver__nft_sales_amm_sell_decoded.sql | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/models/silver/nfts/silver__nft_sales_amm_sell_decoded.sql b/models/silver/nfts/silver__nft_sales_amm_sell_decoded.sql index 988e7832b..f67eecb4d 100644 --- a/models/silver/nfts/silver__nft_sales_amm_sell_decoded.sql +++ b/models/silver/nfts/silver__nft_sales_amm_sell_decoded.sql @@ -149,7 +149,8 @@ mev2_sales AS( CASE WHEN event_type IN ( 'solMip1FulfillSell', - 'solFulfillSell' + 'solFulfillSell', + 'solOcpFulfillSell' ) THEN silver.udf_get_account_pubkey_by_name( 'payer', decoded_instruction :accounts @@ -162,7 +163,8 @@ mev2_sales AS( CASE WHEN event_type IN ( 'solMip1FulfillSell', - 'solFulfillSell' + 'solFulfillSell', + 'solOcpFulfillSell' ) THEN silver.udf_get_account_pubkey_by_name( 'owner', decoded_instruction :accounts @@ -175,7 +177,8 @@ mev2_sales AS( CASE WHEN event_type IN ( 'solMip1FulfillSell', - 'solFulfillSell' + 'solFulfillSell', + 'solOcpFulfillSell' ) THEN 'sell' ELSE 'buy' END AS nft_sale_type, From 6c7aa52ca439588af2bf24f4e88a56674f425b28 Mon Sep 17 00:00:00 2001 From: tarikceric Date: Tue, 23 Jul 2024 13:32:53 -0700 Subject: [PATCH 09/10] update ME signers filter --- models/silver/nfts/silver__nft_sales_amm_sell_decoded.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/silver/nfts/silver__nft_sales_amm_sell_decoded.sql b/models/silver/nfts/silver__nft_sales_amm_sell_decoded.sql index f67eecb4d..ee17c5a42 100644 --- a/models/silver/nfts/silver__nft_sales_amm_sell_decoded.sql +++ b/models/silver/nfts/silver__nft_sales_amm_sell_decoded.sql @@ -191,7 +191,7 @@ mev2_sales AS( FROM base_decoded WHERE - signers [1] = 'NTYeYJ1wr4bpM5xo6zx5En44SvJFAd35zTxxNoERYqd' + COALESCE(signers[1],signers[0])::STRING = 'NTYeYJ1wr4bpM5xo6zx5En44SvJFAd35zTxxNoERYqd' ), coral_cube_nft_sale_amount AS ( SELECT From e949bd8c118edb69c660c20805424391a17dded8 Mon Sep 17 00:00:00 2001 From: tarikceric Date: Tue, 23 Jul 2024 13:34:53 -0700 Subject: [PATCH 10/10] update relationship test --- .../silver/parser/silver__decoded_instructions_combined.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/silver/parser/silver__decoded_instructions_combined.yml b/models/silver/parser/silver__decoded_instructions_combined.yml index 4289632bf..13a0b7949 100644 --- a/models/silver/parser/silver__decoded_instructions_combined.yml +++ b/models/silver/parser/silver__decoded_instructions_combined.yml @@ -167,8 +167,8 @@ models: and _inserted_timestamp between current_date - 7 and current_timestamp() - INTERVAL '4 HOUR' to_condition: "_inserted_timestamp >= current_date - 7" - dbt_utils.relationships_where: - name: dbt_utils_relationships_where_silver__decoded_instructions_combined_nft_sales_amm_sell_tx_id - to: ref('silver__nft_sales_amm_sell') + name: dbt_utils_relationships_where_silver__decoded_instructions_combined_nft_sales_amm_sell_decoded_tx_id + to: ref('silver__nft_sales_amm_sell_decoded') field: tx_id from_condition: > program_id = 'mmm3XBJg5gk8XJxEKBvdgptZz6SgK4tXvn36sodowMc'