-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
166 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
dbt_subprojects/dex/models/automated_trades/polygon/dex_polygon_automated_base_trades.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
{{ config( | ||
schema = 'dex_polygon' | ||
, alias = 'automated_base_trades' | ||
, partition_by = ['block_month'] | ||
, materialized = 'incremental' | ||
, file_format = 'delta' | ||
, incremental_strategy = 'merge' | ||
, unique_key = ['tx_hash', 'evt_index'] | ||
, incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] | ||
) | ||
}} | ||
|
||
{% set models = [ | ||
ref('uniswap_v2_polygon_automated_base_trades') | ||
, ref('uniswap_v3_polygon_automated_base_trades') | ||
] %} | ||
|
||
with base_union as ( | ||
SELECT * | ||
FROM | ||
( | ||
{% for model in models %} | ||
SELECT | ||
blockchain | ||
, project | ||
, project_status | ||
, version | ||
, factory_address | ||
, dex_type | ||
, block_month | ||
, block_date | ||
, block_time | ||
, block_number | ||
, cast(token_bought_amount_raw as uint256) as token_bought_amount_raw | ||
, cast(token_sold_amount_raw as uint256) as token_sold_amount_raw | ||
, token_bought_address | ||
, token_sold_address | ||
, taker | ||
, maker | ||
, project_contract_address | ||
, tx_hash | ||
, evt_index | ||
, tx_from | ||
, tx_to | ||
FROM | ||
{{ model }} | ||
WHERE | ||
token_sold_amount_raw >= 0 and token_bought_amount_raw >= 0 | ||
{% if is_incremental() %} | ||
AND {{ incremental_predicate('block_time') }} | ||
{% endif %} | ||
{% if not loop.last %} | ||
UNION ALL | ||
{% endif %} | ||
{% endfor %} | ||
) | ||
) | ||
|
||
{{ | ||
add_tx_columns( | ||
model_cte = 'base_union' | ||
, blockchain = 'polygon' | ||
, columns = ['from', 'to', 'index'] | ||
) | ||
}} |
20 changes: 20 additions & 0 deletions
20
...ls/automated_trades/polygon/projects/uniswap/uniswap_v2_polygon_automated_base_trades.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{{ config( | ||
schema = 'uniswap_v2_polygon', | ||
alias = 'automated_base_trades', | ||
partition_by = ['block_month'], | ||
materialized = 'incremental', | ||
file_format = 'delta', | ||
incremental_strategy = 'merge', | ||
unique_key = ['tx_hash', 'evt_index'], | ||
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] | ||
) | ||
}} | ||
|
||
{{ | ||
uniswap_v2_forks_trades( | ||
blockchain = 'polygon' | ||
, version = '2' | ||
, Pair_evt_Swap = ref('uniswap_v2_polygon_decoded_pool_evt_swap') | ||
, Factory_evt_PairCreated = ref('uniswap_v2_polygon_decoded_factory_evt') | ||
) | ||
}} |
15 changes: 15 additions & 0 deletions
15
...dels/automated_trades/polygon/projects/uniswap/uniswap_v2_polygon_decoded_factory_evt.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{{ config( | ||
schema = 'uniswap_v2_polygon', | ||
alias = 'decoded_factory_evt', | ||
partition_by = ['block_date'], | ||
materialized = 'incremental', | ||
file_format = 'delta', | ||
incremental_strategy = 'merge', | ||
unique_key = ['tx_hash', 'index'], | ||
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] | ||
) | ||
}} | ||
|
||
{{uniswap_v2_factory_event_decoding( | ||
logs = source('polygon', 'logs') | ||
)}} |
15 changes: 15 additions & 0 deletions
15
...ls/automated_trades/polygon/projects/uniswap/uniswap_v2_polygon_decoded_pool_evt_swap.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{{ config( | ||
schema = 'uniswap_v2_polygon', | ||
alias = 'decoded_pool_evt_swap', | ||
partition_by = ['block_date'], | ||
materialized = 'incremental', | ||
file_format = 'delta', | ||
incremental_strategy = 'merge', | ||
unique_key = ['tx_hash', 'index'], | ||
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] | ||
) | ||
}} | ||
|
||
{{uniswap_v2_pool_event_decoding( | ||
logs = source('polygon', 'logs') | ||
)}} |
20 changes: 20 additions & 0 deletions
20
...ls/automated_trades/polygon/projects/uniswap/uniswap_v3_polygon_automated_base_trades.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{{ config( | ||
schema = 'uniswap_v3_polygon', | ||
alias = 'automated_base_trades', | ||
partition_by = ['block_month'], | ||
materialized = 'incremental', | ||
file_format = 'delta', | ||
incremental_strategy = 'merge', | ||
unique_key = ['tx_hash', 'evt_index'], | ||
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] | ||
) | ||
}} | ||
|
||
{{ | ||
uniswap_v3_forks_trades( | ||
blockchain = 'polygon' | ||
, version = '3' | ||
, Pair_evt_Swap = ref('uniswap_v3_polygon_decoded_pool_evt_swap') | ||
, Factory_evt_PoolCreated = ref('uniswap_v3_polygon_decoded_factory_evt') | ||
) | ||
}} |
15 changes: 15 additions & 0 deletions
15
...dels/automated_trades/polygon/projects/uniswap/uniswap_v3_polygon_decoded_factory_evt.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{{ config( | ||
schema = 'uniswap_v3_polygon', | ||
alias = 'decoded_factory_evt', | ||
partition_by = ['block_date'], | ||
materialized = 'incremental', | ||
file_format = 'delta', | ||
incremental_strategy = 'merge', | ||
unique_key = ['tx_hash', 'index'], | ||
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] | ||
) | ||
}} | ||
|
||
{{uniswap_v3_factory_event_decoding( | ||
logs = source('polygon', 'logs') | ||
)}} |
15 changes: 15 additions & 0 deletions
15
...ls/automated_trades/polygon/projects/uniswap/uniswap_v3_polygon_decoded_pool_evt_swap.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{{ config( | ||
schema = 'uniswap_v3_polygon', | ||
alias = 'decoded_pool_evt_swap', | ||
partition_by = ['block_date'], | ||
materialized = 'incremental', | ||
file_format = 'delta', | ||
incremental_strategy = 'merge', | ||
unique_key = ['tx_hash', 'index'], | ||
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] | ||
) | ||
}} | ||
|
||
{{uniswap_v3_pool_event_decoding( | ||
logs = source('polygon', 'logs') | ||
)}} |