-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for the new Rewards V2
- Loading branch information
Showing
86 changed files
with
4,073 additions
and
110 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
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 +1 @@ | ||
e94b8e364dfddd0743746f089f89a3d570751f03 | ||
da8f00be49d1447f22934629d9d6819e3d763af9 |
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
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
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
67 changes: 67 additions & 0 deletions
67
...ts/testdata/operatorAvsRegistrationSnapshots/preprodRewardsV2_generateExpectedResults.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,67 @@ | ||
COPY ( | ||
with filtered as ( | ||
select * from dbt_preprod_holesky_rewards.operator_avs_status | ||
where block_time < '2024-12-11' | ||
), | ||
marked_statuses AS ( | ||
SELECT | ||
operator, | ||
avs, | ||
registered, | ||
block_time, | ||
block_date, | ||
LEAD(block_time) OVER (PARTITION BY operator, avs ORDER BY block_time ASC, log_index ASC) AS next_block_time, | ||
LEAD(registered) OVER (PARTITION BY operator, avs ORDER BY block_time ASC, log_index ASC) AS next_registration_status, | ||
LEAD(block_date) OVER (PARTITION BY operator, avs ORDER BY block_time ASC, log_index ASC) AS next_block_date, | ||
LAG(registered) OVER (PARTITION BY operator, avs ORDER BY block_time ASC, log_index ASC) AS prev_registered, | ||
LAG(block_date) OVER (PARTITION BY operator, avs ORDER BY block_time ASC, log_index ASC) AS prev_block_date | ||
FROM filtered | ||
), | ||
removed_same_day_deregistrations AS ( | ||
SELECT * from marked_statuses | ||
WHERE NOT ( | ||
(registered = TRUE AND | ||
COALESCE(next_registration_status = FALSE, false) AND | ||
COALESCE(block_date = next_block_date, false)) OR | ||
(registered = FALSE AND | ||
COALESCE(prev_registered = TRUE, false) and | ||
COALESCE(block_date = prev_block_date, false) | ||
) | ||
) | ||
), | ||
registration_periods AS ( | ||
SELECT | ||
operator, | ||
avs, | ||
block_time AS start_time, | ||
COALESCE(next_block_time, TIMESTAMP '2024-12-11') AS end_time, | ||
registered | ||
FROM removed_same_day_deregistrations | ||
WHERE registered = TRUE | ||
), | ||
registration_windows_extra as ( | ||
SELECT | ||
operator, | ||
avs, | ||
date_trunc('day', start_time) + interval '1' day as start_time, | ||
date_trunc('day', end_time) as end_time | ||
FROM registration_periods | ||
), | ||
operator_avs_registration_windows as ( | ||
SELECT * from registration_windows_extra | ||
WHERE start_time != end_time | ||
), | ||
cleaned_records AS ( | ||
SELECT * FROM operator_avs_registration_windows | ||
WHERE start_time < end_time | ||
), | ||
final_results as ( | ||
SELECT | ||
operator, | ||
avs, | ||
to_char(d, 'YYYY-MM-DD') AS snapshot | ||
FROM cleaned_records | ||
CROSS JOIN generate_series(DATE(start_time), DATE(end_time) - interval '1' day, interval '1' day) AS d | ||
) | ||
select * from final_results | ||
) TO STDOUT WITH DELIMITER ',' CSV HEADER; |
18 changes: 18 additions & 0 deletions
18
internal/tests/testdata/operatorAvsSplitSnapshots/README.md
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 @@ | ||
## preprod rewardsv2 | ||
|
||
```sql | ||
select | ||
lower(arguments #>> '{1, Value}') as operator, | ||
lower(arguments #>> '{2, Value}') as avs, | ||
to_timestamp((output_data ->> 'activatedAt')::integer)::timestamp(6) as activated_at, | ||
output_data ->> 'oldOperatorAVSSplitBips' as old_operator_avs_split_bips, | ||
output_data ->> 'newOperatorAVSSplitBips' as new_operator_avs_split_bips, | ||
block_number, | ||
transaction_hash, | ||
log_index | ||
from transaction_logs | ||
where | ||
address = '0xb22ef643e1e067c994019a4c19e403253c05c2b0' | ||
and event_name = 'OperatorAVSSplitBipsSet' | ||
order by block_number desc | ||
``` |
57 changes: 57 additions & 0 deletions
57
internal/tests/testdata/operatorDirectedRewardSubmissions/README.md
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,57 @@ | ||
## preprod rewards-v2 | ||
|
||
```sql | ||
WITH strategies AS ( | ||
SELECT | ||
tl.*, | ||
lower(arguments #>> '{2, Value}') as reward_hash, | ||
output_data->'operatorDirectedRewardsSubmission'->>'token' as token, | ||
output_data->'operatorDirectedRewardsSubmission'->>'duration' as duration, | ||
output_data->'operatorDirectedRewardsSubmission'->>'startTimestamp' as start_timestamp, | ||
strategy_data, | ||
strategy_idx - 1 as strategy_idx -- Subtract 1 for 0-based indexing | ||
FROM transaction_logs as tl, | ||
jsonb_array_elements(output_data->'operatorDirectedRewardsSubmission'->'strategiesAndMultipliers') | ||
WITH ORDINALITY AS t(strategy_data, strategy_idx) | ||
where | ||
address = '0xb22ef643e1e067c994019a4c19e403253c05c2b0' | ||
and event_name = 'OperatorDirectedAVSRewardsSubmissionCreated' | ||
), | ||
operators AS ( | ||
SELECT | ||
lower(arguments #>> '{2, Value}') as reward_hash, | ||
operator_data, | ||
operator_data->>'operator' as operator, | ||
output_data->'operatorDirectedRewardsSubmission' as rewards_submission, | ||
operator_idx - 1 as operator_idx -- Subtract 1 to make it 0-based indexing | ||
FROM transaction_logs, | ||
jsonb_array_elements(output_data->'operatorDirectedRewardsSubmission'->'operatorRewards') | ||
WITH ORDINALITY AS t(operator_data, operator_idx) | ||
where | ||
address = '0xb22ef643e1e067c994019a4c19e403253c05c2b0' | ||
and event_name = 'OperatorDirectedAVSRewardsSubmissionCreated' | ||
), | ||
joined_data as ( | ||
SELECT | ||
lower(arguments #>> '{1, Value}') as avs, | ||
lower(arguments #>> '{2, Value}') as reward_hash, | ||
strategies.token, | ||
operator_data->>'operator' as operator, | ||
operator_idx as operator_index, | ||
operator_data->>'amount' as amount, | ||
strategy_data->>'strategy' as strategy, | ||
strategy_idx as strategy_index, | ||
strategy_data->>'multiplier' as multiplier, | ||
(to_timestamp((rewards_submission->>'startTimestamp')::int))::timestamp(6) as start_timestamp, | ||
(rewards_submission->>'duration')::int as duration, | ||
to_timestamp((rewards_submission->>'startTimestamp')::int + (rewards_submission->>'duration')::int)::timestamp(6) as end_timestamp, | ||
block_number, | ||
transaction_hash, | ||
log_index | ||
FROM strategies | ||
inner join operators on( | ||
strategies.reward_hash = operators.reward_hash | ||
) | ||
) | ||
select * from joined_data | ||
``` |
Oops, something went wrong.