-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Added new PumpFun AMM buy event to stg_decoded_swaps #9428
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
Changes from all commits
f46a60f
3760bec
086b6da
e3a613f
e176085
09c8d0f
9a4420a
c36efb6
d488da2
3a9ed44
5fa8d98
952d82e
8d752e5
3aac472
5799cd4
bf18c83
8885f00
032fe5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| {{ | ||
| config( | ||
| schema = 'pumpswap_solana', | ||
| alias = 'int_all_swaps', | ||
| materialized = 'view' | ||
| ) | ||
| }} | ||
|
|
||
| SELECT | ||
| block_slot | ||
| , block_month | ||
| , block_date | ||
| , block_time | ||
| , inner_instruction_index | ||
| , swap_inner_index | ||
| , outer_instruction_index | ||
| , outer_executing_account | ||
| , tx_id | ||
| , tx_index | ||
| , pool | ||
| , user_account | ||
| , account_user_base_token_account | ||
| , account_user_quote_token_account | ||
| , account_pool_base_token_account | ||
| , account_pool_quote_token_account | ||
| , account_protocol_fee_recipient_token_account | ||
| , base_amount | ||
| , quote_amount | ||
| , is_buy | ||
| , surrogate_key | ||
| FROM {{ ref('pumpswap_solana_stg_decoded_swaps')}} | ||
|
|
||
| UNION ALL | ||
|
|
||
| SELECT | ||
| block_slot | ||
| , block_month | ||
| , block_date | ||
| , block_time | ||
| , inner_instruction_index | ||
| , swap_inner_index | ||
| , outer_instruction_index | ||
| , outer_executing_account | ||
| , tx_id | ||
| , tx_index | ||
| , pool | ||
| , user_account | ||
| , account_user_base_token_account | ||
| , account_user_quote_token_account | ||
| , account_pool_base_token_account | ||
| , account_pool_quote_token_account | ||
| , account_protocol_fee_recipient_token_account | ||
| , base_amount | ||
| , quote_amount | ||
| , is_buy | ||
| , surrogate_key | ||
| FROM {{ref('pumpswap_solana_stg_decoded_newevent')}} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,4 +42,4 @@ SELECT | |
| p.quoteMint, | ||
| p.baseMintDecimals, | ||
| p.quoteMintDecimals | ||
| FROM pool_creation p | ||
| FROM pool_creation p | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| {{ | ||
| config( | ||
| schema = 'pumpswap_solana' | ||
| , alias = 'stg_decoded_newevent' | ||
| , partition_by = ['block_month'] | ||
| , materialized = 'incremental' | ||
| , file_format = 'delta' | ||
| , incremental_strategy = 'merge' | ||
| , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')] | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| , unique_key = ['block_month', 'block_date', 'surrogate_key'] | ||
| ) | ||
| }} | ||
|
|
||
| {% set project_start_date = '2026-03-06' %} | ||
|
|
||
| -- New buy event decoded from decoded table | ||
| WITH new_buy_events_raw AS ( | ||
| SELECT | ||
| g.evt_block_time | ||
| , g.evt_block_slot | ||
| , g.evt_block_date | ||
| , g.evt_outer_instruction_index | ||
| , g.evt_inner_instruction_index | ||
| , g.evt_tx_id | ||
| , g.evt_tx_index | ||
| , g.evt_outer_executing_account | ||
| , g.pool | ||
| , g.user | ||
| , g.user_base_token_account AS account_user_base_token_account | ||
| , g.user_quote_token_account AS account_user_quote_token_account | ||
| , f.account_arguments[8] AS account_pool_base_token_account | ||
| , f.account_arguments[9] AS account_pool_quote_token_account | ||
| , g.protocol_fee_recipient_token_account AS account_protocol_fee_recipient_token_account | ||
| , g.base_amount_out AS base_amount | ||
| , g.quote_amount_in AS quote_amount | ||
| , ROW_NUMBER() OVER ( | ||
| PARTITION BY g.evt_tx_id, g.evt_outer_instruction_index, g.evt_inner_instruction_index | ||
| ORDER BY f.inner_instruction_index | ||
| ) AS rn -- To avoid potential duplicate rows rom the join | ||
| FROM {{ source('pumpdotfun_solana', 'pump_amm_evt_buyevent') }} g | ||
| INNER JOIN {{ source('solana', 'instruction_calls') }} f | ||
| ON g.evt_tx_id = f.tx_id | ||
| AND g.evt_block_date = f.block_date | ||
| AND g.evt_outer_instruction_index = f.outer_instruction_index | ||
| AND bytearray_substring(f.data, 1, 8) = 0xc62e1552b4d9e870 | ||
| AND f.executing_account = 'pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA' | ||
| AND f.tx_success = true | ||
| AND f.block_time >= TIMESTAMP '{{ project_start_date }}' | ||
| {% if is_incremental() %} | ||
| AND {{ incremental_predicate('f.block_time') }} | ||
| {% endif %} | ||
| WHERE 1=1 | ||
| {% if is_incremental() %} | ||
| AND {{ incremental_predicate('g.evt_block_time') }} | ||
| {% else %} | ||
| AND g.evt_block_time >= TIMESTAMP '{{ project_start_date }}' | ||
| {% endif %} | ||
|
|
||
|
|
||
| ) | ||
|
|
||
| SELECT | ||
| evt_block_slot AS block_slot | ||
| , CAST(date_trunc('month', evt_block_date) AS DATE) AS block_month | ||
| , evt_block_date AS block_date | ||
| , evt_block_time as block_time | ||
| , COALESCE(evt_inner_instruction_index, 0) AS inner_instruction_index | ||
| , evt_inner_instruction_index AS swap_inner_index | ||
| , evt_outer_instruction_index AS outer_instruction_index | ||
| , evt_outer_executing_account AS outer_executing_account | ||
| , evt_tx_id AS tx_id | ||
| , evt_tx_index AS tx_index | ||
| , pool | ||
| , user as user_account | ||
| , account_user_base_token_account | ||
| , account_user_quote_token_account | ||
| , account_pool_base_token_account | ||
| , account_pool_quote_token_account | ||
| , account_protocol_fee_recipient_token_account | ||
| , base_amount | ||
| , quote_amount | ||
| , 1 AS is_buy | ||
| , {{ solana_instruction_key( | ||
| 'evt_block_slot' | ||
| , 'evt_tx_index' | ||
| , 'evt_outer_instruction_index' | ||
| , 'COALESCE(evt_inner_instruction_index, 0)' | ||
| ) }} AS surrogate_key | ||
| FROM new_buy_events_raw | ||
| WHERE rn = 1 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ | |
| ) | ||
| }} | ||
|
|
||
| {% set project_start_date = '2025-02-20' %} | ||
| {% set project_start_date = '2026-03-06' %} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't narrow the legacy swaps model to March 2026. This staging model still carries the pre-new-event buy/sell history. Moving Suggested fix-{% set project_start_date = '2026-03-06' %}
+{% set project_start_date = '2025-02-20' %}🤖 Prompt for AI Agents |
||
|
|
||
| WITH swaps AS ( | ||
| SELECT | ||
|
|
@@ -31,6 +31,7 @@ WITH swaps AS ( | |
| , account_pool_quote_token_account | ||
| , account_protocol_fee_recipient_token_account | ||
| , base_amount_out AS base_amount | ||
| , CAST(NULL AS BIGINT) AS quote_amount | ||
| , 1 AS is_buy | ||
| FROM {{ source('pumpdotfun_solana', 'pump_amm_call_buy') }} | ||
| WHERE 1=1 | ||
|
|
@@ -59,6 +60,7 @@ WITH swaps AS ( | |
| , account_pool_quote_token_account | ||
| , account_protocol_fee_recipient_token_account | ||
| , base_amount_in AS base_amount | ||
| , CAST(NULL AS BIGINT) AS quote_amount | ||
| , 0 AS is_buy | ||
| FROM {{ source('pumpdotfun_solana', 'pump_amm_call_sell') }} | ||
| WHERE 1=1 | ||
|
|
@@ -70,29 +72,30 @@ WITH swaps AS ( | |
| ) | ||
|
|
||
| SELECT | ||
| sp.call_block_slot AS block_slot | ||
| , CAST(date_trunc('month', sp.call_block_date) AS DATE) AS block_month | ||
| , sp.call_block_date AS block_date | ||
| , sp.call_block_time AS block_time | ||
| , COALESCE(sp.call_inner_instruction_index, 0) AS inner_instruction_index | ||
| , sp.call_inner_instruction_index AS swap_inner_index | ||
| , sp.call_outer_instruction_index AS outer_instruction_index | ||
| , sp.call_outer_executing_account AS outer_executing_account | ||
| , sp.call_tx_id AS tx_id | ||
| , sp.call_tx_index AS tx_index | ||
| , sp.account_pool AS pool | ||
| , sp.account_user AS user_account | ||
| , sp.account_user_base_token_account | ||
| , sp.account_user_quote_token_account | ||
| , sp.account_pool_base_token_account | ||
| , sp.account_pool_quote_token_account | ||
| , sp.account_protocol_fee_recipient_token_account | ||
| , sp.base_amount | ||
| , sp.is_buy | ||
| call_block_slot AS block_slot | ||
| , CAST(date_trunc('month', call_block_date) AS DATE) AS block_month | ||
| , call_block_date AS block_date | ||
| , call_block_time AS block_time | ||
| , COALESCE(call_inner_instruction_index, 0) AS inner_instruction_index | ||
| , call_inner_instruction_index AS swap_inner_index | ||
| , call_outer_instruction_index AS outer_instruction_index | ||
| , call_outer_executing_account AS outer_executing_account | ||
| , call_tx_id AS tx_id | ||
| , call_tx_index AS tx_index | ||
| , account_pool AS pool | ||
| , account_user AS user_account | ||
| , account_user_base_token_account | ||
| , account_user_quote_token_account | ||
| , account_pool_base_token_account | ||
| , account_pool_quote_token_account | ||
| , account_protocol_fee_recipient_token_account | ||
| , base_amount | ||
| , quote_amount | ||
| , is_buy | ||
| , {{ solana_instruction_key( | ||
| 'sp.call_block_slot' | ||
| , 'sp.call_tx_index' | ||
| , 'sp.call_outer_instruction_index' | ||
| , 'COALESCE(sp.call_inner_instruction_index, 0)' | ||
| 'call_block_slot' | ||
| , 'call_tx_index' | ||
| , 'call_outer_instruction_index' | ||
| , 'COALESCE(call_inner_instruction_index, 0)' | ||
| ) }} AS surrogate_key | ||
| FROM swaps sp | ||
| FROM swaps | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep the SQL fallback
beginaligned with the model config.This no longer matches Line 11's
config(begin = '2025-02-20'). Whenmodel.batchis absent, the query now skips the first year of Pumpswap trades even though the microbatch config still says to backfill from February 20, 2025.Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents