-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update feeds | add base | create ocr macro
- Loading branch information
Showing
50 changed files
with
938 additions
and
867 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
{% macro | ||
chainlink_ocr_gas_transmission_logs( | ||
blockchain | ||
) | ||
%} | ||
|
||
SELECT | ||
'{{blockchain}}' as blockchain, | ||
block_hash, | ||
contract_address, | ||
data, | ||
topic0, | ||
topic1, | ||
topic2, | ||
topic3, | ||
tx_hash, | ||
block_number, | ||
block_time, | ||
index, | ||
tx_index | ||
FROM | ||
{{ source(blockchain, 'logs') }} logs | ||
WHERE | ||
topic0 = 0xf6a97944f31ea060dfde0566e4167c1a1082551e64b60ecb14d599a9d023d451 | ||
|
||
|
||
{% endmacro %} | ||
|
||
# --------------------------------------------- | ||
|
||
{% macro | ||
chainlink_ocr_fulfilled_transactions( | ||
blockchain, | ||
gas_token_symbol, | ||
gas_price_column | ||
) | ||
%} | ||
|
||
{% set incremental_interval = '7' %} | ||
|
||
WITH | ||
network_usd AS ( | ||
SELECT | ||
minute as block_time, | ||
price as usd_amount | ||
FROM | ||
{{ source('prices', 'usd') }} price | ||
WHERE | ||
symbol = '{{gas_token_symbol}}' | ||
{% if is_incremental() %} | ||
AND minute >= date_trunc('day', now() - interval '{{incremental_interval}}' day) | ||
{% endif %} | ||
), | ||
ocr_fulfilled_transactions AS ( | ||
SELECT | ||
tx.hash as tx_hash, | ||
tx.index as tx_index, | ||
MAX(tx.block_time) as block_time, | ||
cast(date_trunc('month', MAX(tx.block_time)) as date) as date_month, | ||
tx."from" as "node_address", | ||
MAX( | ||
(cast((gas_used) as double) / 1e18) * tx.{{gas_price_column}} | ||
) as token_amount, | ||
MAX(network_usd.usd_amount) as usd_amount | ||
FROM | ||
{{ source(blockchain, 'transactions') }} tx | ||
RIGHT JOIN {{ ref('chainlink_' ~ blockchain ~ '_ocr_gas_transmission_logs') }} ocr_gas_transmission_logs ON ocr_gas_transmission_logs.tx_hash = tx.hash | ||
LEFT JOIN network_usd ON date_trunc('minute', tx.block_time) = network_usd.block_time | ||
{% if is_incremental() %} | ||
WHERE tx.block_time >= date_trunc('day', now() - interval '{{incremental_interval}}' day) | ||
{% endif %} | ||
GROUP BY | ||
tx.hash, | ||
tx.index, | ||
tx."from" | ||
) | ||
SELECT | ||
'{{blockchain}}' as blockchain, | ||
block_time, | ||
date_month, | ||
node_address, | ||
token_amount, | ||
usd_amount, | ||
tx_hash, | ||
tx_index | ||
FROM | ||
ocr_fulfilled_transactions | ||
|
||
{% 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
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
1 change: 0 additions & 1 deletion
1
models/chainlink/arbitrum/chainlink_arbitrum_ocr_operator_node_meta.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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
{{ | ||
config( | ||
|
||
alias='ocr_operator_node_meta', | ||
materialized = 'view', | ||
post_hook='{{ expose_spells(\'["arbitrum"]\', | ||
|
Oops, something went wrong.