-
Notifications
You must be signed in to change notification settings - Fork 9
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
0b9aaf8
commit c5daf18
Showing
6 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
models/staging/chainlink/fact_chainlink_ethereum_vrf_request_fulfilled.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,32 @@ | ||
{{ | ||
config( | ||
materialized="table", | ||
snowflake_warehouse="CHAINLINK", | ||
database="chainlink", | ||
schema="raw", | ||
alias="fact_ethereum_vrf_request_fulfilled", | ||
) | ||
}} | ||
|
||
|
||
SELECT | ||
'ethereum' as blockchain, | ||
MAX(CAST(v1_request.fee AS double))/1e18 AS token_value, | ||
MAX(v1_fulfilled.block_timestamp) as evt_block_time | ||
FROM | ||
{{ ref('fact_chainlink_ethereum_vrf_v1_random_request_logs') }} v1_request | ||
INNER JOIN {{ ref('fact_chainlink_ethereum_vrf_v1_random_fulfilled_logs') }} v1_fulfilled | ||
ON v1_fulfilled.request_id = v1_request.request_id | ||
GROUP BY | ||
v1_request.tx_hash | ||
UNION | ||
|
||
SELECT | ||
'ethereum' as blockchain, | ||
MAX(CAST(v2_fulfilled.payment as double))/1e18 AS token_value, | ||
MAX(v2_fulfilled.block_timestamp) as evt_block_time | ||
FROM | ||
{{ ref('fact_chainlink_ethereum_vrf_v2_random_fulfilled_logs') }} v2_fulfilled | ||
GROUP BY | ||
v2_fulfilled.tx_hash, | ||
v2_fulfilled.event_index |
21 changes: 21 additions & 0 deletions
21
models/staging/chainlink/fact_chainlink_ethereum_vrf_request_fulfilled_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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{{ | ||
config( | ||
materialized="table", | ||
snowflake_warehouse="CHAINLINK", | ||
database="chainlink", | ||
schema="raw", | ||
alias="fact_ethereum_vrf_request_fulfilled_daily", | ||
) | ||
}} | ||
|
||
|
||
SELECT | ||
'ethereum' as blockchain, | ||
cast(date_trunc('day', evt_block_time) AS date) AS date_start, | ||
SUM(token_value) as token_amount | ||
FROM | ||
{{ref('fact_chainlink_ethereum_vrf_request_fulfilled')}} vrf_request_fulfilled | ||
GROUP BY | ||
2 | ||
ORDER BY | ||
2 |
33 changes: 33 additions & 0 deletions
33
models/staging/chainlink/fact_chainlink_ethereum_vrf_rewards_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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{{ | ||
config( | ||
materialized="table", | ||
snowflake_warehouse="CHAINLINK", | ||
database="chainlink", | ||
schema="raw", | ||
alias="fact_ethereum_vrf_rewards_daily", | ||
) | ||
}} | ||
|
||
WITH | ||
link_usd_daily AS ( | ||
{{get_coingecko_price_with_latest("chainlink")}} | ||
), | ||
vrf_reward_daily AS ( | ||
SELECT | ||
vrf_daily.date_start, | ||
COALESCE(vrf_daily.token_amount, 0) as token_amount, | ||
COALESCE(vrf_daily.token_amount * lud.price, 0) as usd_amount | ||
FROM | ||
{{ref('fact_chainlink_ethereum_vrf_request_fulfilled_daily')}} vrf_daily | ||
LEFT JOIN link_usd_daily lud ON lud.date = vrf_daily.date_start | ||
ORDER BY date_start | ||
) | ||
SELECT | ||
'ethereum' as blockchain, | ||
date_start as date, | ||
token_amount, | ||
usd_amount | ||
FROM | ||
vrf_reward_daily | ||
ORDER BY | ||
2 |
17 changes: 17 additions & 0 deletions
17
models/staging/chainlink/fact_chainlink_ethereum_vrf_v1_random_fulfilled_logs.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,17 @@ | ||
{{ | ||
config( | ||
materialized="table", | ||
snowflake_warehouse="CHAINLINK", | ||
database="chainlink", | ||
schema="raw", | ||
alias="fact_ethereum_vrf_v1_random_fulfilled_logs", | ||
) | ||
}} | ||
|
||
select | ||
block_timestamp, | ||
tx_hash, | ||
GET_PATH(decoded_log, 'requestId') as request_id | ||
from ethereum_flipside.core.ez_decoded_event_logs | ||
where event_name = 'RandomnessRequestFulfilled' | ||
and contract_address = '0xf0d54349addcf704f77ae15b96510dea15cb7952' |
19 changes: 19 additions & 0 deletions
19
models/staging/chainlink/fact_chainlink_ethereum_vrf_v1_random_request_logs.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,19 @@ | ||
{{ | ||
config( | ||
materialized="table", | ||
snowflake_warehouse="CHAINLINK", | ||
database="chainlink", | ||
schema="raw", | ||
alias="fact_ethereum_vrf_v1_random_request_logs", | ||
) | ||
}} | ||
|
||
select | ||
block_timestamp, | ||
tx_hash, | ||
origin_from_address as tx_from, | ||
CAST(GET_PATH(decoded_log,'fee') as double) as fee, | ||
GET_PATH(decoded_log, 'requestID') as request_id | ||
from ethereum_flipside.core.ez_decoded_event_logs | ||
where event_name = 'RandomnessRequest' | ||
and contract_address = '0xf0d54349addcf704f77ae15b96510dea15cb7952' |
18 changes: 18 additions & 0 deletions
18
models/staging/chainlink/fact_chainlink_ethereum_vrf_v2_random_fulfilled_logs.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,18 @@ | ||
{{ | ||
config( | ||
materialized="table", | ||
snowflake_warehouse="CHAINLINK", | ||
database="chainlink", | ||
schema="raw", | ||
alias="fact_ethereum_vrf_v2_random_fulfilled_logs", | ||
) | ||
}} | ||
|
||
select | ||
block_timestamp, | ||
tx_hash, | ||
event_index, | ||
GET_PATH(decoded_log, 'payment') as payment | ||
from ethereum_flipside.core.ez_decoded_event_logs | ||
where event_name = 'RandomWordsFulfilled' | ||
and contract_address = '0x271682deb8c4e0901d1a1550ad2e64d568e69909' |