Skip to content

Commit

Permalink
Merge branch 'duneanalytics:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
danielpartida authored Aug 7, 2024
2 parents 5ea0fd7 + 94c1da5 commit e3b0bd5
Show file tree
Hide file tree
Showing 37 changed files with 751 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['blockchain', 'tx_hash', 'evt_index', 'recipient'],
post_hook='{{ expose_spells(\'["ethereum", "optimism", "arbitrum", "avalanche_c", "bnb", "gnosis"]\',
post_hook='{{ expose_spells(\'["ethereum", "optimism", "arbitrum", "avalanche_c", "bnb", "gnosis", "zksync"]\',
"sector",
"airdrop",
\'["hildobby"]\') }}'
\'["hildobby", "lgingerich"]\') }}'
)
}}

Expand All @@ -20,6 +20,7 @@
, ref('airdrop_avalanche_c_claims')
, ref('airdrop_bnb_claims')
, ref('airdrop_gnosis_claims')
, ref('airdrop_zksync_claims')
] %}


Expand All @@ -43,11 +44,10 @@ FROM (
, evt_index
FROM {{ airdrop_claims_model }}
{% if is_incremental() %}
WHERE block_time >= date_trunc('day', now() - interval '7' Day)
WHERE {{incremental_predicate('block_time')}}
{% endif %}
{% if not loop.last %}
UNION ALL
{% endif %}
{% endfor %}
)

Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
tags = [ 'static'],
schema='airdrop',
alias = 'info',
post_hook='{{ expose_spells(\'["ethereum", "bnb", "avalanche_c", "gnosis", "optimism", "arbitrum"]\',
post_hook='{{ expose_spells(\'["ethereum", "bnb", "avalanche_c", "gnosis", "optimism", "arbitrum", "lgingerich"]\',
"sector",
"dex",
\'["hildobby"]\') }}')
"airdrop",
\'["hildobby", "lgingerich"]\') }}')
}}

SELECT project, name, eligible_addresses, airdropped_total, circulating_supply_on_drop, max_supply, token_issued_by_protocol, x_username, CAST(airdrop_start AS TIMESTAMP) AS airdrop_start, CAST(airdrop_end AS TIMESTAMP) AS airdrop_end
Expand Down Expand Up @@ -60,5 +60,5 @@ FROM (VALUES
, ('jupiter', 'Jupiter', 957935, 2700000000, NULL, NULL, TRUE, 'JupiterExchange', '2024-01-01 00:00', NULL)
, ('aptos', 'Aptos', 124828, 450000000, NULL, NULL, TRUE, 'Aptos', '2022-10-01 00:00', NULL)
, ('jito', 'Jito', 13133, 439000000, NULL, NULL, TRUE, 'jito_sol', '2023-12-01 00:00', NULL)

) AS temp_table (project, name, eligible_addresses, circulating_supply_on_drop, max_supply, airdropped_total, token_issued_by_protocol, x_username, airdrop_start, airdrop_end)
, ('zksync', 'ZKsync Era', 693268, 3675000000, 3675000000, 21000000000, TRUE, 'zksync', '2024-06-17 06:45', NULL)
) AS temp_table (project, name, eligible_addresses, circulating_supply_on_drop, max_supply, airdropped_total, token_issued_by_protocol, x_username, airdrop_start, airdrop_end)
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ version: 2
models:
- name: airdrop_claims
meta:
blockchain: ethereum, optimism, arbitrum, avalanche_c, bnb, gnosis
blockchain: ethereum, optimism, arbitrum, avalanche_c, bnb, gnosis, zksync
sector: airdrop
project: addresses
contributors: hildobby
contributors: hildobby, lgingerich
config:
tags: ['table', 'airdrop', 'ethereum', 'optimism', 'arbitrum', 'avalanche_c', 'bnb', 'gnosis', 'claim']
tags: ['table', 'airdrop', 'ethereum', 'optimism', 'arbitrum', 'avalanche_c', 'bnb', 'gnosis', 'zksync', 'claim']
description: "List of claim transactions for all airdrops"
tests:
- dbt_utils.unique_combination_of_columns:
Expand Down Expand Up @@ -67,11 +67,11 @@ models:

- name: airdrop_info
meta:
blockchain: ethereum, bnb, avalanche_c, gnosis, optimism, arbitrum
sector: dex
contributors: hildobby
blockchain: ethereum, bnb, avalanche_c, gnosis, optimism, arbitrum, zksync
sector: airdrop
contributors: hildobby, lgingerich
config:
tags: ['airdrop', 'ethereum', 'bnb', 'avalanche_c', 'gnosis', 'optimism', 'arbitrum', 'info']
tags: ['airdrop', 'ethereum', 'bnb', 'avalanche_c', 'gnosis', 'optimism', 'arbitrum', 'zksync', 'info']
description: >
Airdrop info
tests:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
version: 2

models:
- name: airdrop_zksync_claims
meta:
blockchain: zksync
sector: airdrop
contributors: lgingerich
config:
tags: ['airdrop', 'zksync', 'claim']
description: "List of airdrop claim transactions on ZKsync Era"
columns:
- &blockchain
name: blockchain
description: "Blockchain"
- &block_time
name: block_time
description: "Block time of transaction"
- &block_number
name: block_number
description: "Block number of transaction"
- &project
name: project
description: "Project name"
- &airdrop_number
name: airdrop_number
description: "Airdrop identifier number"
- &recipient
name: recipient
description: "Airdrop recipient"
- &contract_address
name: contract_address
description: "Contract addressed used"
- &tx_hash
name: tx_hash
description: "Transaction hash"
- &amount_raw
name: amount_raw
description: "Raw amount of tokens"
- &amount_original
name: amount_original
description: "Original amount of tokens"
- &amount_usd
name: amount_usd
description: "USD value of tokens"
- &token_address
name: token_address
description: "Token address"
- &token_symbol
name: token_symbol
description: "Token symbol"
- &evt_index
name: evt_index
description: "Event index"
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{ config(
schema = 'airdrop_zksync',
alias = 'claims'
)
}}


{% set airdrop_claims_models = [
ref('zksync_zksync_airdrop_claims')
] %}


SELECT *
FROM (
{% for airdrop_claims_model in airdrop_claims_models %}
SELECT
blockchain
, block_time
, block_number
, project
, airdrop_number
, recipient
, contract_address
, tx_hash
, amount_raw
, amount_original
, amount_usd
, token_address
, token_symbol
, evt_index
FROM {{ airdrop_claims_model }}
{% if not loop.last %}
UNION ALL
{% endif %}
{% endfor %}
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
version: 2

models:
- name: zksync_zksync_airdrop_claims
meta:
blockchain: zksync
sector: airdrop
project: zksync
contributors: lgingerich
config:
tags: ['table', 'airdrop', 'zksync', 'claim']
description: "List of claim transactions for the $ZK airdrop"
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- recipient
- evt_index
columns:
- &blockchain
name: blockchain
description: "Blockchain"
- &block_time
name: block_time
description: "Block time of transaction"
- &block_number
name: block_number
description: "Block number of transaction"
- &project
name: project
description: "Project name"
- &airdrop_number
name: airdrop_number
description: "Airdrop identifier number"
- &recipient
name: recipient
description: "Airdrop recipient"
- &contract_address
name: contract_address
description: "Contract addressed used"
- &tx_hash
name: tx_hash
description: "Transaction hash"
- &amount_raw
name: amount_raw
description: "Raw amount of tokens"
- &amount_original
name: amount_original
description: "Original amount of tokens"
- &amount_usd
name: amount_usd
description: "USD value of tokens"
- &token_address
name: token_address
description: "Token address"
- &token_symbol
name: token_symbol
description: "Token symbol"
- &evt_index
name: evt_index
description: "Event index"
- &block_month
name: block_month
description: "Block month"
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{{
config(

schema = 'zksync_zksync',
alias = 'airdrop_claims',
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['recipient', 'tx_hash', 'evt_index']
)
}}

{% set token_address = '0x5A7d6b2F92C77FAD6CCaBd7EE0624E64907Eaf3E' %} -- ZK token

WITH early_price AS (
SELECT
MIN(minute) AS minute
, MIN_BY(price, minute) AS price
FROM {{ source('prices', 'usd') }}
WHERE blockchain = 'zksync'
AND contract_address = {{token_address}}
)

SELECT
'zksync' AS blockchain
, t.evt_block_time AS block_time
, t.evt_block_number AS block_number
, 'zksync' AS project
, 1 AS airdrop_number
, t.account AS recipient
, t.contract_address
, t.evt_tx_hash AS tx_hash
, t.amount as amount_raw
, ROUND(CAST(t.amount/POWER(10, 18) AS double), 0) AS amount_original
, CASE
WHEN t.evt_block_time >= (SELECT minute FROM early_price) THEN CAST(pu.price*t.amount/POWER(10, 18) AS double)
ELSE CAST((SELECT price FROM early_price)*t.amount/POWER(10, 18) AS double)
END AS amount_usd
, {{token_address}} AS token_address
, 'ZK' AS token_symbol
, t.evt_index
FROM {{ source('zksync_era_zksync', 'ZkMerkleDistributor_evt_Claimed') }} t
LEFT JOIN {{ source('prices','usd_forward_fill') }} pu ON pu.blockchain = 'zksync'
AND pu.contract_address = {{token_address}}
AND pu.minute = date_trunc('minute', t.evt_block_time)
{% if is_incremental() %}
AND {{incremental_predicate('pu.minute')}}
WHERE {{incremental_predicate('t.evt_block_time')}}
{% endif %}
2 changes: 2 additions & 0 deletions dbt_subprojects/daily_spellbook/models/evms/evms_blocks.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
, ('zkevm', source('zkevm', 'blocks'))
, ('blast', source('blast', 'blocks'))
, ('mantle', source('mantle', 'blocks'))
, ('mode', source('mode', 'blocks'))
, ('sei', source('sei', 'blocks'))
] %}

SELECT *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
, ('zkevm', source('zkevm', 'contracts'))
, ('blast', source('blast', 'contracts'))
, ('mantle', source('mantle', 'contracts'))
, ('sei', source('sei', 'contracts'))
] %}

SELECT *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
, ('zkevm', source('zkevm', 'creation_traces'))
, ('blast', source('blast', 'creation_traces'))
, ('mantle', source('mantle', 'creation_traces'))
, ('sei', source('sei', 'creation_traces'))
] %}

SELECT *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
, ('zkevm', source('erc1155_zkevm', 'evt_ApprovalForAll'))
, ('blast', source('erc1155_blast', 'evt_ApprovalForAll'))
, ('mantle', source('erc1155_mantle', 'evt_ApprovalForAll'))
, ('sei', source('erc1155_sei', 'evt_ApprovalForAll'))
] %}

SELECT *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
, ('zkevm', source('erc1155_zkevm', 'evt_transferbatch'))
, ('blast', source('erc1155_blast', 'evt_transferbatch'))
, ('mantle', source('erc1155_mantle', 'evt_transferbatch'))
, ('sei', source('erc1155_sei', 'evt_transferbatch'))
] %}

SELECT *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
, ('zkevm', source('erc1155_zkevm', 'evt_transfersingle'))
, ('blast', source('erc1155_blast', 'evt_transfersingle'))
, ('mantle', source('erc1155_mantle', 'evt_transfersingle'))
, ('sei', source('erc1155_sei', 'evt_transfersingle'))
] %}

SELECT *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
, ('zkevm', source('erc20_zkevm', 'evt_approval'))
, ('blast', source('erc20_blast', 'evt_approval'))
, ('mantle', source('erc20_mantle', 'evt_approval'))
, ('sei', source('erc20_sei', 'evt_Approval'))
] %}

SELECT *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
, ('zkevm', source('erc20_zkevm', 'evt_transfer'))
, ('blast', source('erc20_blast', 'evt_transfer'))
, ('mantle', source('erc20_mantle', 'evt_transfer'))
, ('sei', source('erc20_sei', 'evt_transfer'))
] %}

SELECT *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
, ('zkevm', source('erc721_zkevm', 'evt_Approval'))
, ('blast', source('erc721_blast', 'evt_Approval'))
, ('mantle', source('erc721_mantle', 'evt_Approval'))
, ('sei', source('erc721_sei', 'evt_Approval'))
] %}

SELECT *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
, ('zkevm', source('erc721_zkevm', 'evt_ApprovalForAll'))
, ('blast', source('erc721_blast', 'evt_ApprovalForAll'))
, ('mantle', source('erc721_mantle', 'evt_ApprovalForAll'))
, ('sei', source('erc721_sei', 'evt_ApprovalForAll'))
] %}

SELECT *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
, ('zkevm', source('erc721_zkevm', 'evt_transfer'))
, ('blast', source('erc721_blast', 'evt_transfer'))
, ('mantle', source('erc721_mantle', 'evt_transfer'))
, ('sei', source('erc721_sei', 'evt_transfer'))
] %}

SELECT *
Expand Down
2 changes: 2 additions & 0 deletions dbt_subprojects/daily_spellbook/models/evms/evms_logs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
, ('zkevm', source('zkevm', 'logs'))
, ('blast', source('blast', 'logs'))
, ('mantle', source('mantle', 'logs'))
, ('mode', source('mode', 'logs'))
, ('sei', source('sei', 'logs'))
] %}

SELECT *
Expand Down
Loading

0 comments on commit e3b0bd5

Please sign in to comment.