forked from duneanalytics/spellbook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'duneanalytics:main' into main
- Loading branch information
Showing
37 changed files
with
751 additions
and
60 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
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
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
54 changes: 54 additions & 0 deletions
54
dbt_subprojects/daily_spellbook/models/_sector/airdrops/zksync/_schema.yml
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,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" |
36 changes: 36 additions & 0 deletions
36
dbt_subprojects/daily_spellbook/models/_sector/airdrops/zksync/airdrop_zksync_claims.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,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 %} | ||
) |
64 changes: 64 additions & 0 deletions
64
dbt_subprojects/daily_spellbook/models/_sector/airdrops/zksync/projects/_schema.yml
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,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" |
49 changes: 49 additions & 0 deletions
49
.../daily_spellbook/models/_sector/airdrops/zksync/projects/zksync_zksync_airdrop_claims.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,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 %} |
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
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
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.