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
Showing
97 changed files
with
5,074 additions
and
117 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
dbt_subprojects/daily_spellbook/macros/project/lifi/lifi_extract_bridge_data_macro.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,37 @@ | ||
{% macro lifi_extract_bridge_data(blockchain) %} | ||
|
||
{% set bridge_data_fields = [ | ||
'transactionId', | ||
'bridge', | ||
'integrator', | ||
'referrer', | ||
'sendingAssetId', | ||
'receiver', | ||
'minAmount', | ||
'destinationChainId' | ||
] %} | ||
|
||
select | ||
contract_address, | ||
evt_tx_hash as tx_hash, | ||
evt_index, | ||
evt_block_time as block_time, | ||
evt_block_number as block_number, | ||
cast(date_trunc('day', evt_block_time) as date) as block_date, | ||
{% for field in bridge_data_fields %} | ||
{% if field in ['transactionId', 'referrer', 'sendingAssetId', 'receiver'] %} | ||
from_hex(json_extract_scalar(bridgedata, '$.{{ field }}')) as {{ field }}, | ||
{% elif field == 'minAmount' %} | ||
cast(json_extract_scalar(bridgedata, '$.{{ field }}') as double) as {{ field }}, | ||
{% else %} | ||
json_extract_scalar(bridgedata, '$.{{ field }}') as {{ field }}, | ||
{% endif %} | ||
{% endfor %} | ||
'{{ blockchain }}' as source_chain, | ||
{{ dbt_utils.generate_surrogate_key(['evt_tx_hash', 'evt_index']) }} as transfer_id | ||
from {{ source('lifi_' ~ blockchain, 'LiFiDiamond_v2_evt_LiFiTransferStarted') }} | ||
{% if is_incremental() %} | ||
where {{ incremental_predicate('evt_block_time') }} | ||
{% endif %} | ||
|
||
{% endmacro %} |
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.