mirror of
https://github.com/FlipsideCrypto/solana-models.git
synced 2026-02-06 15:26:47 +00:00
Jup gold views (#596)
* wip * add gold schemas for jup swaps * add version 2 of jupv6 summary model * disable jupv6 version 1 model * match col names of existing gold swap tables * change recent date filter to take advantage of partitions, modify _log_id for jupv6
This commit is contained in:
parent
fd968bb6a3
commit
7674f10792
@ -37,6 +37,7 @@ FROM
|
||||
LEFT OUTER JOIN {{ ref('core__dim_labels') }}
|
||||
l
|
||||
ON s.program_id = l.address
|
||||
/* TODO: DEPRECATE - remove jupiter swaps from this table, we will only cover individual dexes moving forward. Aggregator(s) get their own model(s) */
|
||||
UNION ALL
|
||||
SELECT
|
||||
block_timestamp,
|
||||
@ -50,16 +51,43 @@ SELECT
|
||||
to_mint AS swap_to_mint,
|
||||
program_id,
|
||||
l.address_name AS swap_program,
|
||||
concat_ws('-',tx_id,swap_index) as _log_id,
|
||||
concat_ws('-',tx_id,swap_index,swap_program) as _log_id,
|
||||
swaps_intermediate_jupiterv6_id as fact_swaps_id,
|
||||
s.inserted_timestamp,
|
||||
s.modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver__swaps_intermediate_jupiterv6') }}
|
||||
{{ ref('silver__swaps_intermediate_jupiterv6_view') }}
|
||||
s
|
||||
LEFT OUTER JOIN {{ ref('core__dim_labels') }}
|
||||
l
|
||||
ON s.program_id = l.address
|
||||
WHERE
|
||||
block_timestamp::date < '2023-08-03'
|
||||
UNION ALL
|
||||
SELECT
|
||||
block_timestamp,
|
||||
block_id,
|
||||
tx_id,
|
||||
succeeded,
|
||||
swapper,
|
||||
from_amount AS swap_from_amount,
|
||||
from_mint AS swap_from_mint,
|
||||
to_amount AS swap_to_amount,
|
||||
to_mint AS swap_to_mint,
|
||||
program_id,
|
||||
l.address_name AS swap_program,
|
||||
concat_ws('-',tx_id,swap_index,swap_program) as _log_id,
|
||||
swaps_intermediate_jupiterv6_id as fact_swaps_id,
|
||||
s.inserted_timestamp,
|
||||
s.modified_timestamp
|
||||
FROM
|
||||
{{ ref('silver__swaps_intermediate_jupiterv6_2') }}
|
||||
s
|
||||
LEFT OUTER JOIN {{ ref('core__dim_labels') }}
|
||||
l
|
||||
ON s.program_id = l.address
|
||||
WHERE
|
||||
block_timestamp::date >= '2023-08-03'
|
||||
UNION ALL
|
||||
SELECT
|
||||
block_timestamp,
|
||||
|
||||
@ -4,7 +4,7 @@ models:
|
||||
description: This table contains swaps performed on Jupiter, Orca, Raydium, Saber, Bonkswap, Dooar, Phoenix and Meteora swap programs. Intermediate swaps are aggregated over the DEX programs, so the values showcase the final mint/amount swap values. Ie. a swap on Jupiter that swaps SOL->USDC->mSOL->ETH would show the initial amount in and the final amount out of SOL->ETH. For Phoenix, we are not capturing swaps where there are separate transactions for placing the order and filling the order.
|
||||
recent_date_filter: &recent_date_filter
|
||||
config:
|
||||
where: inserted_timestamp >= current_date - 7
|
||||
where: block_timestamp >= current_date - 7
|
||||
columns:
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: "{{ doc('block_timestamp') }}"
|
||||
|
||||
26
models/gold/defi/defi__fact_swaps_jupiter_inner.sql
Normal file
26
models/gold/defi/defi__fact_swaps_jupiter_inner.sql
Normal file
@ -0,0 +1,26 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
meta ={ 'database_tags':{ 'table':{ 'PURPOSE': 'SWAPS' }}},
|
||||
tags = ['scheduled_non_core']
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
block_timestamp,
|
||||
block_id,
|
||||
tx_id,
|
||||
index,
|
||||
inner_index,
|
||||
swap_index,
|
||||
succeeded,
|
||||
swapper,
|
||||
from_mint AS swap_from_mint,
|
||||
from_amount AS swap_from_amount,
|
||||
to_mint AS swap_to_mint,
|
||||
to_amount AS swap_to_amount,
|
||||
swap_program_id,
|
||||
aggregator_program_id,
|
||||
swaps_inner_intermediate_jupiterv6_id AS fact_swaps_jupiter_inner_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp,
|
||||
FROM
|
||||
{{ ref('silver__swaps_inner_intermediate_jupiterv6') }}
|
||||
70
models/gold/defi/defi__fact_swaps_jupiter_inner.yml
Normal file
70
models/gold/defi/defi__fact_swaps_jupiter_inner.yml
Normal file
@ -0,0 +1,70 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: defi__fact_swaps_jupiter_inner
|
||||
columns:
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: "{{ doc('block_timestamp') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: BLOCK_ID
|
||||
description: "{{ doc('block_id') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: TX_ID
|
||||
description: "{{ doc('tx_id') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: INDEX
|
||||
description: "{{ doc('event_index') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: INNER_INDEX
|
||||
description: "{{ doc('inner_index') }}. This is the inner index of the log event listing the inner swap"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: SWAP_INDEX
|
||||
description: "{{ doc('swaps_swap_index') }} as it relates to the top level Jupiter V6 swap instruction"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: SUCCEEDED
|
||||
description: "{{ doc('tx_succeeded') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: SWAP_PROGRAM_ID
|
||||
description: "{{ doc('program_id') }}. This is the AMM performing the swap."
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: AGGREGATOR_PROGRAM_ID
|
||||
description: "{{ doc('program_id') }}. This is the aggregator calling the different AMMs."
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: SWAPPER
|
||||
description: "{{ doc('swaps_swapper') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: SWAP_FROM_AMOUNT
|
||||
description: "{{ doc('swaps_from_amt') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: SWAP_FROM_MINT
|
||||
description: "{{ doc('swaps_from_mint') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: SWAP_TO_AMOUNT
|
||||
description: "{{ doc('swaps_to_amt') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: SWAP_TO_MINT
|
||||
description: "{{ doc('swaps_to_mint') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: FACT_SWAPS_JUPITER_INNER_ID
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: INSERTED_TIMESTAMP
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
49
models/gold/defi/defi__fact_swaps_jupiter_summary.sql
Normal file
49
models/gold/defi/defi__fact_swaps_jupiter_summary.sql
Normal file
@ -0,0 +1,49 @@
|
||||
{{ config(
|
||||
materialized = 'view',
|
||||
meta ={ 'database_tags':{ 'table':{ 'PURPOSE': 'SWAPS' }}},
|
||||
tags = ['scheduled_non_core']
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
block_timestamp,
|
||||
block_id,
|
||||
tx_id,
|
||||
swap_index AS index,
|
||||
NULL AS inner_index,
|
||||
swap_index,
|
||||
succeeded,
|
||||
swapper,
|
||||
from_mint AS swap_from_mint,
|
||||
from_amt AS swap_from_amount,
|
||||
to_mint AS swap_to_mint,
|
||||
to_amt AS swap_to_amount,
|
||||
program_id,
|
||||
swaps_intermediate_jupiterv6_id AS fact_swaps_jupiter_summary_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp,
|
||||
FROM
|
||||
{{ ref('silver__swaps_intermediate_jupiterv6_view') }}
|
||||
WHERE
|
||||
block_timestamp::date < '2023-08-03'
|
||||
UNION ALL
|
||||
SELECT
|
||||
block_timestamp,
|
||||
block_id,
|
||||
tx_id,
|
||||
index,
|
||||
inner_index,
|
||||
swap_index,
|
||||
succeeded,
|
||||
swapper,
|
||||
from_mint AS swap_from_mint,
|
||||
from_amount AS swap_from_amount,
|
||||
to_mint AS swap_to_mint,
|
||||
to_amount AS swap_to_amount,
|
||||
program_id,
|
||||
swaps_intermediate_jupiterv6_id AS fact_swaps_jupiter_summary_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp,
|
||||
FROM
|
||||
{{ ref('silver__swaps_intermediate_jupiterv6_2') }}
|
||||
WHERE
|
||||
block_timestamp::date >= '2023-08-03'
|
||||
66
models/gold/defi/defi__fact_swaps_jupiter_summary.yml
Normal file
66
models/gold/defi/defi__fact_swaps_jupiter_summary.yml
Normal file
@ -0,0 +1,66 @@
|
||||
version: 2
|
||||
models:
|
||||
- name: defi__fact_swaps_jupiter_summary
|
||||
columns:
|
||||
- name: BLOCK_TIMESTAMP
|
||||
description: "{{ doc('block_timestamp') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: BLOCK_ID
|
||||
description: "{{ doc('block_id') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: TX_ID
|
||||
description: "{{ doc('tx_id') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: INDEX
|
||||
description: "{{ doc('event_index') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: INNER_INDEX
|
||||
description: "{{ doc('inner_index') }}. This is the inner index of the log event listing the inner swap"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: SWAP_INDEX
|
||||
description: "{{ doc('swaps_swap_index') }} as it relates to the top level Jupiter V6 swap instruction"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: SUCCEEDED
|
||||
description: "{{ doc('tx_succeeded') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: PROGRAM_ID
|
||||
description: "{{ doc('program_id') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: SWAPPER
|
||||
description: "{{ doc('swaps_swapper') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: SWAP_FROM_AMOUNT
|
||||
description: "{{ doc('swaps_from_amt') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: SWAP_FROM_MINT
|
||||
description: "{{ doc('swaps_from_mint') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: SWAP_TO_AMOUNT
|
||||
description: "{{ doc('swaps_to_amt') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: SWAP_TO_MINT
|
||||
description: "{{ doc('swaps_to_mint') }}"
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: FACT_SWAPS_JUPITER_SUMMARY_ID
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: INSERTED_TIMESTAMP
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
- name: MODIFIED_TIMESTAMP
|
||||
description: '{{ doc("modified_timestamp") }}'
|
||||
tests:
|
||||
- dbt_expectations.expect_column_to_exist
|
||||
@ -12,6 +12,7 @@
|
||||
'{{this.identifier}}',
|
||||
'ON EQUALITY(tx_id, swapper, from_mint, to_mint)'
|
||||
),
|
||||
enabled=false,
|
||||
) }}
|
||||
|
||||
{% if execute %}
|
||||
|
||||
@ -0,0 +1,23 @@
|
||||
{{ config(
|
||||
materialized = 'view'
|
||||
) }}
|
||||
|
||||
SELECT
|
||||
block_id,
|
||||
block_timestamp,
|
||||
tx_id,
|
||||
swap_index,
|
||||
program_id,
|
||||
succeeded,
|
||||
swapper,
|
||||
from_amt,
|
||||
from_mint,
|
||||
to_amt,
|
||||
to_mint,
|
||||
_inserted_timestamp,
|
||||
swaps_intermediate_jupiterv6_id,
|
||||
inserted_timestamp,
|
||||
modified_timestamp,
|
||||
invocation_id
|
||||
FROM
|
||||
{{ source('solana_silver', 'swaps_intermediate_jupiterv6') }}
|
||||
@ -88,6 +88,7 @@ sources:
|
||||
- name: stake_pool_actions_socean
|
||||
- name: _blocks_tx_count
|
||||
- name: nft_sales_solsniper_v1_events
|
||||
- name: swaps_intermediate_jupiterv6
|
||||
- name: solana_streamline
|
||||
database: solana
|
||||
schema: streamline
|
||||
|
||||
Loading…
Reference in New Issue
Block a user