Skip to content

Commit

Permalink
add polygon
Browse files Browse the repository at this point in the history
  • Loading branch information
0xBoxer committed Jan 28, 2025
1 parent 814e5de commit 2b3af25
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
ref('dex_ethereum_automated_base_trades')
, ref('dex_arbitrum_automated_base_trades')
, ref('dex_base_automated_base_trades')
, ref('dex_polygon_automated_base_trades')
] %}

with base_union as (
Expand Down
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']
)
}}
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')
)
}}
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')
)}}
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')
)}}
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')
)
}}
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')
)}}
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')
)}}

0 comments on commit 2b3af25

Please sign in to comment.