Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ARDev097 authored Nov 15, 2023
2 parents bca546f + 1a6ac6d commit c8f3d19
Show file tree
Hide file tree
Showing 88 changed files with 3,324 additions and 1,121 deletions.
151 changes: 0 additions & 151 deletions macros/models/_project/oneinch/oneinch_ar_calls_transfers_macro.sql

This file was deleted.

84 changes: 40 additions & 44 deletions macros/models/_project/oneinch/oneinch_lop_macro.sql
Original file line number Diff line number Diff line change
Expand Up @@ -90,32 +90,7 @@ with

orders as (
{% for contract, contract_data in cfg.items() if blockchain in contract_data['blockchains'] %}
select
'{{ blockchain }}' as blockchain
, block_time
, tx_hash
, tx_from
, tx_to
, tx_success
, contract_name
, protocol_version
, method
, call_from
, call_to
, call_trace_address
, call_selector
, maker
, maker_asset
, making_amount
, taker_asset
, taking_amount
, order_hash
, call_success
, call_gas_used
, call_output
, date_trunc('minute', block_time) as minute
, date(date_trunc('month', block_time)) as block_month
from ({% for method, method_data in contract_data.methods.items() %}
select * from ({% for method, method_data in contract_data.methods.items() %}
select
call_tx_hash as tx_hash
, '{{ contract }}' as contract_name
Expand All @@ -130,6 +105,8 @@ orders as (
, {{ method_data.get("making_amount", "output_0") }} as making_amount
, {{ method_data.get("taking_amount", "output_1") }} as taking_amount
, {{ method_data.get("order_hash", "null") }} as order_hash
, call_block_number as block_number
, call_block_time as block_time
from (
select *, cast(json_parse({{ method_data.get("order", '"order"') }}) as map(varchar, varchar)) as order_map
from {{ source('oneinch_' + blockchain, contract + '_call_' + method) }}
Expand All @@ -139,21 +116,6 @@ orders as (
)
{% if not loop.last %} union all {% endif %}
{% endfor %})
join (
select
block_time
, hash as tx_hash
, "from" as tx_from
, "to" as tx_to
, success as tx_success
from {{ source(blockchain, 'transactions') }}
where
{% if is_incremental() %}
{{ incremental_predicate('block_time') }}
{% else %}
block_time >= timestamp '{{ contract_data['start'] }}'
{% endif %}
) using(tx_hash)
join (
select
tx_hash
Expand All @@ -162,6 +124,7 @@ orders as (
, substr(input, 1, 4) as call_selector
, gas_used as call_gas_used
, output as call_output
, block_number
from {{ source(blockchain, 'traces') }}
where
{% if is_incremental() %}
Expand All @@ -170,12 +133,45 @@ orders as (
block_time >= timestamp '{{ contract_data['start'] }}'
{% endif %}
and call_type = 'call'
) using(tx_hash, call_trace_address)
) using(tx_hash, call_trace_address, block_number)
{% if not loop.last %} union all {% endif %}
{% endfor %}
)

select *
from orders

select
'{{ blockchain }}' as blockchain
, block_time
, tx_hash
, tx_from
, tx_to
, tx_success
, contract_name
, protocol_version
, method
, call_from
, call_to
, call_trace_address
, call_selector
, maker
, maker_asset
, making_amount
, taker_asset
, taking_amount
, order_hash
, call_success
, call_gas_used
, call_output
, date_trunc('minute', block_time) as minute
, date(date_trunc('month', block_time)) as block_month
from (
{{
add_tx_columns(
model_cte = 'orders'
, blockchain = blockchain
, columns = ['from', 'to', 'success']
)
}}
)

{% endmacro %}
23 changes: 23 additions & 0 deletions models/_sector/dex/trades/avalanche_c/_schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: 2

models:
- name: uniswap_v3_avalanche_c_base_trades
meta:
blockchain: avalanche_c
sector: dex
project: uniswap
contributors: jeff-dude, masquot, soispoke, mtitus6
config:
tags: [ 'avalanche_c', 'dex', 'trades', 'uniswap', 'v3' ]
description: "uniswap avalanche_c v3 base trades"
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- evt_index
- check_dex_seed:
blockchain: avalanche_c
project: uniswap
version: 3

- name: dex_avalanche_c_base_trades
4 changes: 4 additions & 0 deletions models/_sector/dex/trades/avalanche_c/_sources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version: 2

sources:
- name: uniswap_v3_avalanche_c
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{{ config(
schema = 'dex_avalanche_c'
, alias = 'base_trades'
, materialized = 'view'
)
}}

{% set base_models = [
ref('uniswap_v3_avalanche_c_base_trades')
] %}

WITH base_union AS (
SELECT *
FROM (
{% for base_model in base_models %}
SELECT
blockchain
, project
, version
, block_month
, block_date
, block_time
, block_number
, token_bought_amount_raw
, token_sold_amount_raw
, token_bought_address
, token_sold_address
, taker
, maker
, project_contract_address
, tx_hash
, evt_index
FROM
{{ base_model }}
{% if not loop.last %}
UNION ALL
{% endif %}
{% endfor %}
)
)

{{
add_tx_columns(
model_cte = 'base_union'
, blockchain = 'avalanche_c'
, columns = ['from', 'to', 'index']
)
}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{ config(
schema = 'uniswap_v3_avalanche_c'
, alias = 'base_trades'
, materialized = 'incremental'
, file_format = 'delta'
, incremental_strategy = 'merge'
, unique_key = ['tx_hash', 'evt_index']
, incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')]
)
}}

{{
uniswap_compatible_v3_trades(
blockchain = 'avalanche_c'
, project = 'uniswap'
, version = '3'
, Pair_evt_Swap = source('uniswap_v3_avalanche_c', 'Pair_evt_Swap')
, Factory_evt_PoolCreated = source('uniswap_v3_avalanche_c', 'UniswapV3Factory_evt_PoolCreated')
)
}}
Loading

0 comments on commit c8f3d19

Please sign in to comment.