-
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
120 changed files
with
2,265 additions
and
3,728 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
100 changes: 8 additions & 92 deletions
100
daily_spellbook/models/chainlink/arbitrum/chainlink_arbitrum_ocr_gas_daily.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,107 +1,23 @@ | ||
{{ | ||
config( | ||
|
||
alias='ocr_gas_daily', | ||
partition_by=['date_month'], | ||
materialized='incremental', | ||
file_format='delta', | ||
incremental_strategy='merge', | ||
unique_key=['date_start', 'node_address'], | ||
post_hook='{{ expose_spells(\'["arbitrum"]\', | ||
"project", | ||
"chainlink", | ||
\'["linkpool_ryan"]\') }}' | ||
unique_key=['date_start', 'node_address'] | ||
) | ||
}} | ||
|
||
{% set truncate_by = 'day' %} | ||
|
||
WITH | ||
ocr_gas_fulfilled_daily AS ( | ||
SELECT | ||
cast(date_trunc('{{truncate_by}}', fulfilled.block_time) as date) as date_start, | ||
fulfilled.node_address, | ||
SUM(fulfilled.token_amount) as token_amount, | ||
SUM(fulfilled.token_amount * fulfilled.usd_amount) as usd_amount | ||
FROM | ||
{{ ref('chainlink_arbitrum_ocr_fulfilled_transactions') }} fulfilled | ||
{% if is_incremental() %} | ||
WHERE | ||
{{ incremental_predicate('fulfilled.block_time') }} | ||
{% endif %} | ||
GROUP BY | ||
1, 2 | ||
ORDER BY | ||
1, 2 | ||
), | ||
ocr_gas_reverted_daily AS ( | ||
SELECT | ||
cast(date_trunc('{{truncate_by}}', reverted.block_time) as date) as date_start, | ||
reverted.node_address, | ||
SUM(reverted.token_amount) as token_amount, | ||
SUM(reverted.token_amount * reverted.usd_amount) as usd_amount | ||
FROM | ||
{{ ref('chainlink_arbitrum_ocr_reverted_transactions') }} reverted | ||
{% if is_incremental() %} | ||
WHERE | ||
{{ incremental_predicate('reverted.block_time') }} | ||
{% endif %} | ||
GROUP BY | ||
1, 2 | ||
ORDER BY | ||
1, 2 | ||
), | ||
ocr_gas_daily_meta AS ( | ||
SELECT | ||
COALESCE( | ||
fulfilled.date_start, | ||
reverted.date_start | ||
) AS "date_start", | ||
COALESCE( | ||
fulfilled.node_address, | ||
reverted.node_address | ||
) AS "node_address", | ||
COALESCE(fulfilled.token_amount, 0) as fulfilled_token_amount, | ||
COALESCE(reverted.token_amount, 0) as reverted_token_amount, | ||
COALESCE(fulfilled.usd_amount, 0) as fulfilled_usd_amount, | ||
COALESCE(reverted.usd_amount, 0) as reverted_usd_amount | ||
FROM | ||
ocr_gas_fulfilled_daily fulfilled | ||
FULL OUTER JOIN ocr_gas_reverted_daily reverted ON | ||
reverted.date_start = fulfilled.date_start AND | ||
reverted.node_address = fulfilled.node_address | ||
ORDER BY | ||
1, 2 | ||
), | ||
ocr_gas_daily AS ( | ||
SELECT | ||
'arbitrum' as blockchain, | ||
date_start, | ||
cast(date_trunc('month', date_start) as date) as date_month, | ||
ocr_gas_daily_meta.node_address as node_address, | ||
operator_name, | ||
fulfilled_token_amount, | ||
fulfilled_usd_amount, | ||
reverted_token_amount, | ||
reverted_usd_amount, | ||
fulfilled_token_amount + reverted_token_amount as total_token_amount, | ||
fulfilled_usd_amount + reverted_usd_amount as total_usd_amount | ||
FROM ocr_gas_daily_meta | ||
LEFT JOIN {{ ref('chainlink_arbitrum_ocr_operator_node_meta') }} ocr_operator_node_meta ON ocr_operator_node_meta.node_address = ocr_gas_daily_meta.node_address | ||
{{ | ||
chainlink_ocr_gas_daily( | ||
blockchain = 'arbitrum' | ||
) | ||
}} | ||
) | ||
SELECT | ||
blockchain, | ||
date_start, | ||
date_month, | ||
node_address, | ||
operator_name, | ||
fulfilled_token_amount, | ||
fulfilled_usd_amount, | ||
reverted_token_amount, | ||
reverted_usd_amount, | ||
total_token_amount, | ||
total_usd_amount | ||
* | ||
FROM | ||
ocr_gas_daily | ||
ORDER BY | ||
"date_start" | ||
ocr_gas_daily |
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
daily_spellbook/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"]\', | ||
|
66 changes: 8 additions & 58 deletions
66
daily_spellbook/models/chainlink/arbitrum/chainlink_arbitrum_ocr_request_daily.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,73 +1,23 @@ | ||
{{ | ||
config( | ||
|
||
alias='ocr_request_daily', | ||
partition_by=['date_month'], | ||
materialized='incremental', | ||
file_format='delta', | ||
incremental_strategy='merge', | ||
unique_key=['date_start', 'node_address'], | ||
post_hook='{{ expose_spells(\'["arbitrum"]\', | ||
"project", | ||
"chainlink", | ||
\'["linkpool_ryan"]\') }}' | ||
unique_key=['date_start', 'node_address'] | ||
) | ||
}} | ||
|
||
{% set truncate_by = 'day' %} | ||
|
||
WITH | ||
ocr_request_daily_meta AS ( | ||
SELECT | ||
COALESCE( | ||
cast(date_trunc('{{truncate_by}}', fulfilled.block_time) as date), | ||
cast(date_trunc('{{truncate_by}}', reverted.block_time) as date) | ||
) AS "date_start", | ||
COALESCE( | ||
fulfilled.node_address, | ||
reverted.node_address | ||
) AS "node_address", | ||
COALESCE(COUNT(fulfilled.token_amount), 0) as fulfilled_requests, | ||
COALESCE(COUNT(reverted.token_amount), 0) as reverted_requests, | ||
COALESCE(COUNT(fulfilled.token_amount), 0) + COALESCE(COUNT(reverted.token_amount), 0) as total_requests | ||
FROM | ||
{{ ref('chainlink_arbitrum_ocr_fulfilled_transactions') }} fulfilled | ||
FULL OUTER JOIN {{ ref('chainlink_arbitrum_ocr_reverted_transactions') }} reverted ON | ||
reverted.block_time = fulfilled.block_time AND | ||
reverted.node_address = fulfilled.node_address | ||
{% if is_incremental() %} | ||
WHERE | ||
{{ incremental_predicate('fulfilled.block_time') }} | ||
OR {{ incremental_predicate('reverted.block_time') }} | ||
{% endif %} | ||
GROUP BY | ||
1, 2 | ||
ORDER BY | ||
1, 2 | ||
), | ||
ocr_request_daily AS ( | ||
SELECT | ||
'arbitrum' as blockchain, | ||
date_start, | ||
cast(date_trunc('month', date_start) as date) as date_month, | ||
ocr_request_daily_meta.node_address as node_address, | ||
operator_name, | ||
fulfilled_requests, | ||
reverted_requests, | ||
total_requests | ||
FROM ocr_request_daily_meta | ||
LEFT JOIN {{ ref('chainlink_arbitrum_ocr_operator_node_meta') }} ocr_operator_node_meta ON ocr_operator_node_meta.node_address = ocr_request_daily_meta.node_address | ||
{{ | ||
chainlink_ocr_request_daily( | ||
blockchain = 'arbitrum' | ||
) | ||
}} | ||
) | ||
SELECT | ||
blockchain, | ||
date_start, | ||
date_month, | ||
node_address, | ||
operator_name, | ||
fulfilled_requests, | ||
reverted_requests, | ||
total_requests | ||
* | ||
FROM | ||
ocr_request_daily | ||
ORDER BY | ||
"date_start" | ||
ocr_request_daily |
Oops, something went wrong.