Skip to content

Commit

Permalink
Merge branch '1inch-updates-26' of https://github.com/max-morrow/spel…
Browse files Browse the repository at this point in the history
…lbook into 1inch-updates-26
  • Loading branch information
max-morrow committed Jun 18, 2024
2 parents 4a30a79 + f8a4f6b commit 2acb2e1
Show file tree
Hide file tree
Showing 127 changed files with 2,075 additions and 1,002 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{{ config(
schema = 'addresses_events_blast'
, alias = 'first_activity'
, materialized = 'incremental'
, file_format = 'delta'
, incremental_strategy = 'append'
, unique_key = ['address']
)
}}

SELECT 'blast' AS blockchain
, et."from" AS address
, MIN_BY(et."to", et.block_number) AS first_activity_to
, MIN(et.block_time) AS first_block_time
, MIN(et.block_number) AS first_block_number
, MIN_BY(et.hash, et.block_number) AS first_tx_hash
, MIN_BY(COALESCE(sig.function, CAST((bytearray_substring(et.data, 1, 4)) as VARCHAR)), et.block_number) as first_function
, MIN_BY(et.value/1e18, et.block_number) as first_{{native_symbol}}_transferred
FROM
{{ source('blast', 'transactions') }} et
LEFT JOIN (
SELECT
DISTINCT id,
split_part(signature,'(',1) as function
FROM
{{ source('abi', 'signatures') }}
where type = 'function_call'
AND id NOT IN (0x09779838, 0x00000000) -- for some weird reason these have duplicates functions
) sig
ON sig.id = bytearray_substring(et.data, 1, 4)
{% if is_incremental() %}
LEFT JOIN {{this}} ffb ON et."from" = ffb.address
WHERE ffb.address IS NULL
AND et.block_time >= date_trunc('day', now() - interval '7' day)
{% endif %}

GROUP BY et."from"
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{ config(
schema = 'addresses_events_blast'
, alias = 'first_funded_by'
, materialized = 'incremental'
, file_format = 'delta'
, incremental_strategy = 'append'
, unique_key = ['address']
)
}}


{{addresses_events_first_funded_by(
blockchain='blast'
)}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
version: 2

models:
- name: addresses_events_blast_first_funded_by
meta:
blockchain: blast
sector: addresses_events
project: addresses
contributors: hildobby, lgingerich
config:
tags: ['table', 'funded', 'addresses_events', 'blast']
description: "Table showing who first funded each blast address in ETH"
tests:
- check_seed:
seed_file: ref('first_funded_by_seed')
filter:
blockchain: blast
match_columns:
- blockchain
- address
check_columns:
- first_funded_by
- block_number
- tx_hash
columns:
- name: blockchain
description: "Blockchain"
- name: address
description: "Concerned blast address"
tests:
- unique
- name: first_funded_by
description: "Which blast address first funded the address with ETH"
- name: block_time
description: "The block time on which the address was first funded with ETH"
- name: block_number
description: "The block number on which the address was first funded with ETH"
- name: tx_hash
description: "The transaction hash on which the address was first funded with ETH"

- name: addresses_events_blast_first_activity
meta:
blockchain: blast
sector: addresses_events
project: addresses
contributors: hildobby
config:
tags: ['table', 'activity', 'addresses_events', 'blast']
description: "Table showing first activity of each blast Mainnet address"
tests:
- check_seed:
seed_file: ref('first_activity_seed')
filter:
blockchain: blast
match_columns:
- address
check_columns:
- first_activity_to
- first_block_number
- first_tx_hash
columns:
- name: blockchain
description: "Blockchain"
- name: address
description: "Concerned blast Mainnet address"
tests:
- unique
- name: first_activity_to
description: "First transaction activity to address"
- name: first_block_time
description: "The block time on which the address made it's first activity"
- name: first_block_number
description: "The block number on which the address made it's first activity"
- name: first_tx_hash
description: "The transaction hash on which the address made it's first activity"
- name: first_function
description: "first function called by address"
- name: first_eth_transferred
description: "ETH transferred in transaction"
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{{ config(
schema = 'addresses_events_mantle'
, alias = 'first_activity'
, materialized = 'incremental'
, file_format = 'delta'
, incremental_strategy = 'append'
, unique_key = ['address']
)
}}

SELECT 'mantle' AS blockchain
, et."from" AS address
, MIN_BY(et."to", et.block_number) AS first_activity_to
, MIN(et.block_time) AS first_block_time
, MIN(et.block_number) AS first_block_number
, MIN_BY(et.hash, et.block_number) AS first_tx_hash
, MIN_BY(COALESCE(sig.function, CAST((bytearray_substring(et.data, 1, 4)) as VARCHAR)), et.block_number) as first_function
, MIN_BY(et.value/1e18, et.block_number) as first_{{native_symbol}}_transferred
FROM
{{ source('mantle', 'transactions') }} et
LEFT JOIN (
SELECT
DISTINCT id,
split_part(signature,'(',1) as function
FROM
{{ source('abi', 'signatures') }}
where type = 'function_call'
AND id NOT IN (0x09779838, 0x00000000) -- for some weird reason these have duplicates functions
) sig
ON sig.id = bytearray_substring(et.data, 1, 4)
{% if is_incremental() %}
LEFT JOIN {{this}} ffb ON et."from" = ffb.address
WHERE ffb.address IS NULL
AND et.block_time >= date_trunc('day', now() - interval '7' day)
{% endif %}

GROUP BY et."from"
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{ config(
schema = 'addresses_events_mantle'
, alias = 'first_funded_by'
, materialized = 'incremental'
, file_format = 'delta'
, incremental_strategy = 'append'
, unique_key = ['address']
)
}}


{{addresses_events_first_funded_by(
blockchain='mantle'
)}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
version: 2

models:
- name: addresses_events_mantle_first_funded_by
meta:
blockchain: mantle
sector: addresses_events
project: addresses
contributors: hildobby
config:
tags: ['table', 'funded', 'addresses_events', 'mantle']
description: "Table showing who first funded each Linea address in ETH"
tests:
- check_seed:
seed_file: ref('first_funded_by_seed')
filter:
blockchain: mantle
match_columns:
- blockchain
- address
check_columns:
- first_funded_by
- block_number
- tx_hash
columns:
- name: blockchain
description: "Blockchain"
- name: address
description: "Concerned mantle address"
tests:
- unique
- name: first_funded_by
description: "Which mantle address first funded the address with ETH"
- name: block_time
description: "The block time on which the address was first funded with ETH"
- name: block_number
description: "The block number on which the address was first funded with ETH"
- name: tx_hash
description: "The transaction hash on which the address was first funded with ETH"

- name: addresses_events_mantle_first_activity
meta:
blockchain: mantle
sector: addresses_events
project: addresses
contributors: hildobby
config:
tags: ['table', 'activity', 'addresses_events', 'mantle']
description: "Table showing first activity of each mantle Mainnet address"
tests:
- check_seed:
seed_file: ref('first_activity_seed')
filter:
blockchain: mantle
match_columns:
- address
check_columns:
- first_activity_to
- first_block_number
- first_tx_hash
columns:
- name: blockchain
description: "Blockchain"
- name: address
description: "Concerned mantle Mainnet address"
tests:
- unique
- name: first_activity_to
description: "First transaction activity to address"
- name: first_block_time
description: "The block time on which the address made it's first activity"
- name: first_block_number
description: "The block number on which the address made it's first activity"
- name: first_tx_hash
description: "The transaction hash on which the address made it's first activity"
- name: first_function
description: "first function called by address"
- name: first_eth_transferred
description: "ETH transferred in transaction"
4 changes: 2 additions & 2 deletions dex/models/trades/_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
models:
- name: dex_trades
meta:
blockchain: arbitrum, avalanche_c, base, bnb, celo, ethereum, fantom, gnosis, optimism, polygon, scroll, zksync, linea
blockchain: arbitrum, avalanche_c, base, bnb, celo, ethereum, fantom, gnosis, optimism, polygon, scroll, zksync, linea, blast
sector: dex
contributors: 0xRob, hosuke, jeff-dude, tomfutago
config:
Expand Down Expand Up @@ -99,7 +99,7 @@ models:

- name: dex_base_trades
meta:
blockchain: arbitrum, avalanche_c, base, bnb, celo, ethereum, fantom, gnosis, optimism, polygon, scroll, zksync, linea
blockchain: arbitrum, avalanche_c, base, bnb, celo, ethereum, fantom, gnosis, optimism, polygon, scroll, zksync, linea, blast
sector: dex
contributors: 0xRob, hosuke, jeff-dude, tomfutago
config:
Expand Down
38 changes: 38 additions & 0 deletions dex/models/trades/arbitrum/_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -698,3 +698,41 @@ models:
- check_dex_base_trades_seed:
seed_file: ref('solidly_v3_arbitrum_base_trades_seed')

- name: dackieswap_v3_arbitrum_base_trades
meta:
blockchain: arbitrum
sector: dex
project: dackieswap
contributors: blanchemaria6
config:
tags: [ 'arbitrum', 'dex', 'trades', 'dackieswap' ]
description: "dackieswap v3 arbitrum base trades"
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- evt_index
- check_dex_base_trades_seed:
seed_file: ref('dackieswap_v3_arbitrum_base_trades_seed')
filter:
version: 3

- name: dackieswap_v2_arbitrum_base_trades
meta:
blockchain: arbitrum
sector: dex
project: dackieswap
contributors: blanchemaria6
config:
tags: [ 'arbitrum', 'dex', 'trades', 'dackieswap' ]
description: "dackieswap v2 arbitrum base trades"
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- evt_index
- check_dex_base_trades_seed:
seed_file: ref('dackieswap_v2_arbitrum_base_trades_seed')
filter:
version: 2

2 changes: 2 additions & 0 deletions dex/models/trades/arbitrum/dex_arbitrum_base_trades.sql
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
, ref('auragi_arbitrum_base_trades')
, ref('wombat_exchange_arbitrum_base_trades')
, ref('solidly_v3_arbitrum_base_trades')
, ref('dackieswap_v3_arbitrum_base_trades')
, ref('dackieswap_v2_arbitrum_base_trades')
] %}

WITH base_union AS (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{
config(
schema = 'dackieswap_v2_arbitrum',
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_v2_trades(
blockchain = 'arbitrum',
project = 'dackieswap',
version = '2',
Pair_evt_Swap = source('dackieswap_v2_arbitrum', 'DackiePair_evt_Swap'),
Factory_evt_PairCreated = source('dackieswap_v2_arbitrum', 'DackieFactory_evt_PairCreated')
)
}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{
config(
schema = 'dackieswap_v3_arbitrum',
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 = 'arbitrum',
project = 'dackieswap',
version = '3',
Pair_evt_Swap = source('dackieswap_v3_arbitrum', 'PancakeV3Pool_evt_Swap'),
Factory_evt_PoolCreated = source('dackieswap_v3_arbitrum', 'PancakeV3Factory_evt_PoolCreated')
)
}}
2 changes: 1 addition & 1 deletion dex/models/trades/base/_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ models:
blockchain: base
sector: dex
project: aerodrome
contributors: msilb7, tomfutago
contributors: msilb7, tomfutago, Henrystats
config:
tags: [ 'base', 'dex', 'trades', 'aerodrome' ]
description: aerodrome base trades
Expand Down
Loading

0 comments on commit 2acb2e1

Please sign in to comment.