Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tensorswap models using logs #600

Merged
merged 35 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ef5059b
udf to grab program data logs from log messages
desmond-hui Jun 3, 2024
4d70e90
output table with encoded program data in tx logs
desmond-hui Jun 3, 2024
a918526
add comments
desmond-hui Jun 3, 2024
6f414db
setup views and source
desmond-hui Jun 3, 2024
e18787b
update tag
desmond-hui Jun 3, 2024
f4825df
wip realtime view
desmond-hui Jun 3, 2024
e4e4d26
wip
desmond-hui Jun 4, 2024
54b1a6c
fix bad join
desmond-hui Jun 4, 2024
0aae9f3
wip
desmond-hui Jun 4, 2024
9195e65
decoded logs
desmond-hui Jun 4, 2024
1c849a0
wip
desmond-hui Jun 4, 2024
833370b
add event_type, index, inner_index and refactor existing
desmond-hui Jun 5, 2024
9025ec5
handle additional nested calls
desmond-hui Jun 5, 2024
80d9501
add columns, add to SO
desmond-hui Jun 5, 2024
6d998d0
use backfill macro
desmond-hui Jun 6, 2024
94af620
wip
desmond-hui Jun 6, 2024
17b906f
handle non-contiguous program log messaging
desmond-hui Jun 6, 2024
34c9243
Merge branch 'encoded-program-data-logs-table' into streamline-decode…
desmond-hui Jun 7, 2024
b2a5ea5
Merge branch 'streamline-decoded-logs-setup' into silver-decoded-logs
desmond-hui Jun 7, 2024
6c4b1d8
Merge branch 'silver-decoded-logs' into tensorswap-models-using-logs
desmond-hui Jun 7, 2024
f01d1e7
tmp upperbound
desmond-hui Jun 7, 2024
b362338
Merge branch 'main' into tensorswap-models-using-logs
desmond-hui Jun 28, 2024
da7d54b
minor changes
desmond-hui Jun 28, 2024
01f0918
reset child index when a new top level program is invoked
desmond-hui Jun 28, 2024
ebe3306
rebuild transaction logs program data
desmond-hui Jul 3, 2024
83c3f8b
Merge branch 'main' into tensorswap-models-using-logs
desmond-hui Jul 5, 2024
c90df4b
remove backfill
desmond-hui Jul 8, 2024
cfc6631
still need to use min price as backup
desmond-hui Jul 8, 2024
286a42d
add post PR TODO
desmond-hui Jul 8, 2024
7c92842
revert tmp full-refresh changes
desmond-hui Jul 8, 2024
a77e78f
add comment
desmond-hui Jul 8, 2024
636d67b
add tests
desmond-hui Jul 9, 2024
524eabf
update columns
desmond-hui Jul 9, 2024
5848a32
add docs and tests, fix col name
desmond-hui Jul 9, 2024
f2aa170
update col description
desmond-hui Jul 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions data/testing__nft_sales_tensorswap.csv
Original file line number Diff line number Diff line change
@@ -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,,2zzPrvMe843AJ15jwppiA25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gUFyy6eAb9FKXcM21FxrDUZjsmTakkVs99E3o4qGk31dpLmEeWyJ2Sw,2,,CoinTnNCSr9YmCPBje6Xts4XvNaCWUDf9rBLkpqHmaUm,69x69x4HCXW7Pdp1paEenanCfJhBwAVdzyQwCb5BBoMo,8fbiKJtjvkyffHJsjcsCB2CUv3nqVacYqkvRbV5aBnA,2.97
4yCbMAPrQ29bR33KTgEVuScBwwAuC4Qgbm72yoMDmkiQLqFWGcmz8o1bGoKKS5nLTsBVf7KKX7FbDh61QKjQfe6N,0,,A9DsyEuQP5J4fizYuWXKwgGebThNkFm9NEXFzBbeaEdr,34HibhTzBBgvwrWNrvgnRE81NA3yqKUpJJ7e4w4TKUvh,817KTxyHiKNcS1ozwDfmBKyix9EkiLHRi1awrjt99cy3,8.8
49 changes: 35 additions & 14 deletions models/silver/nfts/silver__nft_sales_tensorswap.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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',
Expand All @@ -230,6 +249,7 @@ pre_final AS (
index,
inner_index,
program_id,
event_type,
purchaser,
seller,
mint,
Expand All @@ -246,6 +266,7 @@ pre_final AS (
d.index,
d.inner_index,
d.program_id,
d.event_type,
d.purchaser,
d.seller,
d.mint,
Expand Down
16 changes: 14 additions & 2 deletions models/silver/nfts/silver__nft_sales_tensorswap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}"
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
90 changes: 90 additions & 0 deletions models/silver/nfts/silver__nft_sales_tensorswap_buysellevent.sql
Original file line number Diff line number Diff line change
@@ -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
83 changes: 83 additions & 0 deletions models/silver/nfts/silver__nft_sales_tensorswap_buysellevent.yml
Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 %}
Expand Down
Loading