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.
- Loading branch information
1 parent
db1fe05
commit 85a0295
Showing
10 changed files
with
454 additions
and
0 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
...projects/daily_spellbook/models/_projects/lifi/LiFiDiamond_v2_evt_LiFiTransferStarted.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,65 @@ | ||
{{ | ||
config( | ||
schema = 'lifi', | ||
alias = 'transfers', | ||
materialized = 'incremental', | ||
unique_key = ['evt_block_time', 'evt_tx_hash', 'evt_index'] | ||
) | ||
}} | ||
|
||
{% set chains = [ | ||
'ethereum', | ||
'arbitrum', | ||
'avalanche', | ||
'bnb', | ||
'fantom', | ||
'gnosis', | ||
'zksync' | ||
] %} | ||
|
||
with chain_transfers as ( | ||
{% for chain in chains %} | ||
select | ||
contract_address, | ||
evt_tx_hash, | ||
evt_index, | ||
evt_block_time, | ||
evt_block_number, | ||
transactionId, | ||
bridge, | ||
integrator, | ||
referrer, | ||
sendingAssetId, | ||
receiver, | ||
minAmount, | ||
destinationChainId, | ||
source_chain, | ||
sender | ||
from {{ ref('lifi_' ~ chain ~ '_transfers') }} | ||
{% if is_incremental() %} | ||
where evt_block_time >= date_trunc('day', now() - interval '7' day) | ||
{% endif %} | ||
|
||
{% if not loop.last %} | ||
union all | ||
{% endif %} | ||
{% endfor %} | ||
) | ||
|
||
select | ||
contract_address, | ||
evt_tx_hash, | ||
evt_index, | ||
evt_block_time, | ||
evt_block_number, | ||
transactionId, | ||
bridge, | ||
integrator, | ||
referrer, | ||
sendingAssetId, | ||
receiver, | ||
minAmount, | ||
destinationChainId, | ||
source_chain, | ||
sender | ||
from chain_transfers |
38 changes: 38 additions & 0 deletions
38
dbt_subprojects/daily_spellbook/models/_projects/lifi/arbitrum/lifi_arbitrum_transfers.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,38 @@ | ||
{{ config( | ||
schema = 'lifi_arbitrum', | ||
alias = 'transfers', | ||
materialized = 'view' | ||
) | ||
}} | ||
|
||
with source_data as ( | ||
select | ||
contract_address, | ||
evt_tx_hash, | ||
evt_index, | ||
evt_block_time, | ||
evt_block_number, | ||
json_extract_scalar(bridgeData, '$.transactionId') as transactionId, | ||
json_extract_scalar(bridgeData, '$.bridge') as bridge, | ||
json_extract_scalar(bridgeData, '$.integrator') as integrator, | ||
json_extract_scalar(bridgeData, '$.referrer') as referrer, | ||
json_extract_scalar(bridgeData, '$.sendingAssetId') as sendingAssetId, | ||
json_extract_scalar(bridgeData, '$.receiver') as receiver, | ||
json_extract_scalar(bridgeData, '$.minAmount') as minAmount, | ||
json_extract_scalar(bridgeData, '$.destinationChainId') as destinationChainId, | ||
'arbitrum' as source_chain | ||
from {{ source('lifi_arbitrum', 'LiFiDiamond_v2_evt_LiFiTransferStarted') }} | ||
), | ||
transactions as ( | ||
select | ||
"from" as sender, | ||
hash as tx_hash | ||
from {{ source('arbitrum', 'transactions') }} | ||
) | ||
|
||
select | ||
s.*, | ||
t.sender | ||
from source_data s | ||
inner join transactions t | ||
on s.evt_tx_hash = t.tx_hash |
38 changes: 38 additions & 0 deletions
38
dbt_subprojects/daily_spellbook/models/_projects/lifi/avalanche/lifi_avalanche_transfers.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,38 @@ | ||
{{ config( | ||
schema = 'lifi_avalanche', | ||
alias = 'transfers', | ||
materialized = 'view' | ||
) | ||
}} | ||
|
||
with source_data as ( | ||
select | ||
contract_address, | ||
evt_tx_hash, | ||
evt_index, | ||
evt_block_time, | ||
evt_block_number, | ||
json_extract_scalar(bridgeData, '$.transactionId') as transactionId, | ||
json_extract_scalar(bridgeData, '$.bridge') as bridge, | ||
json_extract_scalar(bridgeData, '$.integrator') as integrator, | ||
json_extract_scalar(bridgeData, '$.referrer') as referrer, | ||
json_extract_scalar(bridgeData, '$.sendingAssetId') as sendingAssetId, | ||
json_extract_scalar(bridgeData, '$.receiver') as receiver, | ||
json_extract_scalar(bridgeData, '$.minAmount') as minAmount, | ||
json_extract_scalar(bridgeData, '$.destinationChainId') as destinationChainId, | ||
'avalanche' as source_chain | ||
from {{ source('lifi_avalanche', 'LiFiDiamond_v2_evt_LiFiTransferStarted') }} | ||
), | ||
transactions as ( | ||
select | ||
"from" as sender, | ||
hash as tx_hash | ||
from {{ source('avalanche_c', 'transactions') }} | ||
) | ||
|
||
select | ||
s.*, | ||
t.sender | ||
from source_data s | ||
inner join transactions t | ||
on s.evt_tx_hash = t.tx_hash |
38 changes: 38 additions & 0 deletions
38
dbt_subprojects/daily_spellbook/models/_projects/lifi/bnb/lifi_bnb_transfers.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,38 @@ | ||
{{ config( | ||
schema = 'lifi_bnb', | ||
alias = 'transfers', | ||
materialized = 'view' | ||
) | ||
}} | ||
|
||
with source_data as ( | ||
select | ||
contract_address, | ||
evt_tx_hash, | ||
evt_index, | ||
evt_block_time, | ||
evt_block_number, | ||
json_extract_scalar(bridgeData, '$.transactionId') as transactionId, | ||
json_extract_scalar(bridgeData, '$.bridge') as bridge, | ||
json_extract_scalar(bridgeData, '$.integrator') as integrator, | ||
json_extract_scalar(bridgeData, '$.referrer') as referrer, | ||
json_extract_scalar(bridgeData, '$.sendingAssetId') as sendingAssetId, | ||
json_extract_scalar(bridgeData, '$.receiver') as receiver, | ||
json_extract_scalar(bridgeData, '$.minAmount') as minAmount, | ||
json_extract_scalar(bridgeData, '$.destinationChainId') as destinationChainId, | ||
'bnb' as source_chain | ||
from {{ source('lifi_bnb', 'LiFiDiamond_v2_evt_LiFiTransferStarted') }} | ||
), | ||
transactions as ( | ||
select | ||
"from" as sender, | ||
hash as tx_hash | ||
from {{ source('bnb', 'transactions') }} | ||
) | ||
|
||
select | ||
s.*, | ||
t.sender | ||
from source_data s | ||
inner join transactions t | ||
on s.evt_tx_hash = t.tx_hash |
38 changes: 38 additions & 0 deletions
38
dbt_subprojects/daily_spellbook/models/_projects/lifi/ethereum/lifi_ethereum_transfers.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,38 @@ | ||
{{ config( | ||
schema = 'lifi_ethereum', | ||
alias = 'transfers', | ||
materialized = 'view' | ||
) | ||
}} | ||
|
||
with source_data as ( | ||
select | ||
contract_address, | ||
evt_tx_hash, | ||
evt_index, | ||
evt_block_time, | ||
evt_block_number, | ||
json_extract_scalar(bridgeData, '$.transactionId') as transactionId, | ||
json_extract_scalar(bridgeData, '$.bridge') as bridge, | ||
json_extract_scalar(bridgeData, '$.integrator') as integrator, | ||
json_extract_scalar(bridgeData, '$.referrer') as referrer, | ||
json_extract_scalar(bridgeData, '$.sendingAssetId') as sendingAssetId, | ||
json_extract_scalar(bridgeData, '$.receiver') as receiver, | ||
json_extract_scalar(bridgeData, '$.minAmount') as minAmount, | ||
json_extract_scalar(bridgeData, '$.destinationChainId') as destinationChainId, | ||
'ethereum' as source_chain | ||
from {{ source('lifi_ethereum', 'LiFiDiamond_v2_evt_LiFiTransferStarted') }} | ||
), | ||
transactions as ( | ||
select | ||
"from" as sender, | ||
hash as tx_hash | ||
from {{ source('ethereum', 'transactions') }} | ||
) | ||
|
||
select | ||
s.*, | ||
t.sender | ||
from source_data s | ||
inner join transactions t | ||
on s.evt_tx_hash = t.tx_hash |
38 changes: 38 additions & 0 deletions
38
dbt_subprojects/daily_spellbook/models/_projects/lifi/fantom/lifi_fantom_transfers.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,38 @@ | ||
{{ config( | ||
schema = 'lifi_fantom', | ||
alias = 'transfers', | ||
materialized = 'view' | ||
) | ||
}} | ||
|
||
with source_data as ( | ||
select | ||
contract_address, | ||
evt_tx_hash, | ||
evt_index, | ||
evt_block_time, | ||
evt_block_number, | ||
json_extract_scalar(bridgeData, '$.transactionId') as transactionId, | ||
json_extract_scalar(bridgeData, '$.bridge') as bridge, | ||
json_extract_scalar(bridgeData, '$.integrator') as integrator, | ||
json_extract_scalar(bridgeData, '$.referrer') as referrer, | ||
json_extract_scalar(bridgeData, '$.sendingAssetId') as sendingAssetId, | ||
json_extract_scalar(bridgeData, '$.receiver') as receiver, | ||
json_extract_scalar(bridgeData, '$.minAmount') as minAmount, | ||
json_extract_scalar(bridgeData, '$.destinationChainId') as destinationChainId, | ||
'fantom' as source_chain | ||
from {{ source('lifi_fantom', 'LiFiDiamond_v2_evt_LiFiTransferStarted') }} | ||
), | ||
transactions as ( | ||
select | ||
"from" as sender, | ||
hash as tx_hash | ||
from {{ source('fantom', 'transactions') }} | ||
) | ||
|
||
select | ||
s.*, | ||
t.sender | ||
from source_data s | ||
inner join transactions t | ||
on s.evt_tx_hash = t.tx_hash |
38 changes: 38 additions & 0 deletions
38
dbt_subprojects/daily_spellbook/models/_projects/lifi/gnosis/lifi_gnosis_transfers.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,38 @@ | ||
{{ config( | ||
schema = 'lifi_gnosis', | ||
alias = 'transfers', | ||
materialized = 'view' | ||
) | ||
}} | ||
|
||
with source_data as ( | ||
select | ||
contract_address, | ||
evt_tx_hash, | ||
evt_index, | ||
evt_block_time, | ||
evt_block_number, | ||
json_extract_scalar(bridgeData, '$.transactionId') as transactionId, | ||
json_extract_scalar(bridgeData, '$.bridge') as bridge, | ||
json_extract_scalar(bridgeData, '$.integrator') as integrator, | ||
json_extract_scalar(bridgeData, '$.referrer') as referrer, | ||
json_extract_scalar(bridgeData, '$.sendingAssetId') as sendingAssetId, | ||
json_extract_scalar(bridgeData, '$.receiver') as receiver, | ||
json_extract_scalar(bridgeData, '$.minAmount') as minAmount, | ||
json_extract_scalar(bridgeData, '$.destinationChainId') as destinationChainId, | ||
'gnosis' as source_chain | ||
from {{ source('lifi_gnosis', 'LiFiDiamond_v2_evt_LiFiTransferStarted') }} | ||
), | ||
transactions as ( | ||
select | ||
"from" as sender, | ||
hash as tx_hash | ||
from {{ source('gnosis', 'transactions') }} | ||
) | ||
|
||
select | ||
s.*, | ||
t.sender | ||
from source_data s | ||
inner join transactions t | ||
on s.evt_tx_hash = t.tx_hash |
67 changes: 67 additions & 0 deletions
67
dbt_subprojects/daily_spellbook/models/_projects/lifi/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,67 @@ | ||
version: 2 | ||
|
||
models: | ||
- name: lifi_ethereum_transfers | ||
description: "Ethereum LiFi transfer events" | ||
columns: &common_columns | ||
- name: contract_address | ||
description: "Contract address of the LiFi Diamond" | ||
- name: evt_tx_hash | ||
description: "Transaction hash" | ||
tests: | ||
- unique: | ||
where: "evt_index IS NOT NULL" | ||
- name: evt_index | ||
description: "Event index in the transaction" | ||
- name: evt_block_time | ||
description: "Block timestamp of the event" | ||
- name: evt_block_number | ||
description: "Block number of the event" | ||
- name: transactionId | ||
description: "Unique identifier for the transfer transaction" | ||
- name: bridge | ||
description: "Bridge protocol used" | ||
- name: integrator | ||
description: "Integration partner" | ||
- name: referrer | ||
description: "Referrer address" | ||
- name: sendingAssetId | ||
description: "Source token address" | ||
- name: receiver | ||
description: "Recipient address" | ||
- name: minAmount | ||
description: "Minimum amount to be received" | ||
- name: destinationChainId | ||
description: "Target chain ID for the transfer" | ||
- name: source_chain | ||
description: "Source blockchain" | ||
- name: sender | ||
description: "Address that initiated the transaction" | ||
|
||
- name: lifi_arbitrum_transfers | ||
description: "Arbitrum LiFi transfer events" | ||
columns: *common_columns | ||
|
||
- name: lifi_avalanche_transfers | ||
description: "Avalanche LiFi transfer events" | ||
columns: *common_columns | ||
|
||
- name: lifi_bnb_transfers | ||
description: "BNB Chain LiFi transfer events" | ||
columns: *common_columns | ||
|
||
- name: lifi_fantom_transfers | ||
description: "Fantom LiFi transfer events" | ||
columns: *common_columns | ||
|
||
- name: lifi_gnosis_transfers | ||
description: "Gnosis Chain LiFi transfer events" | ||
columns: *common_columns | ||
|
||
- name: lifi_zksync_transfers | ||
description: "zkSync LiFi transfer events" | ||
columns: *common_columns | ||
|
||
- name: LiFiDiamond_v2_evt_LiFiTransferStarted | ||
description: "Combined LiFi transfer events across all supported chains" | ||
columns: *common_columns |
Oops, something went wrong.