-
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.
feat: operator-directed rewards calculation
- Loading branch information
1 parent
92e934d
commit 930ae7b
Showing
50 changed files
with
1,948 additions
and
123 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 | ||
d67ef5d895bdc0ccd6a006a1683ac3e58f820ad0 |
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
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 | ||
``` |
49 changes: 49 additions & 0 deletions
49
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,49 @@ | ||
## preprod rewards-v2 | ||
|
||
```sql | ||
WITH strategies AS ( | ||
SELECT | ||
tl.*, | ||
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 | ||
operator_data, | ||
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' | ||
) | ||
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 | ||
CROSS JOIN operators; | ||
``` |
17 changes: 17 additions & 0 deletions
17
internal/tests/testdata/operatorPISplitSnapshots/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,17 @@ | ||
|
||
## preprod rewardsV2 | ||
```sql | ||
select | ||
lower(arguments #>> '{1, Value}') as operator, | ||
to_timestamp((output_data ->> 'activatedAt')::integer)::timestamp(6) as activated_at, | ||
output_data ->> 'oldOperatorPISplitBips' as old_operator_pi_split_bips, | ||
output_data ->> 'newOperatorPISplitBips' as new_operator_pi_split_bips, | ||
block_number, | ||
transaction_hash, | ||
log_index | ||
from transaction_logs | ||
where | ||
address = '0xb22ef643e1e067c994019a4c19e403253c05c2b0' | ||
and event_name = 'OperatorPISplitBipsSet' | ||
order by block_number desc | ||
``` |
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
5 changes: 5 additions & 0 deletions
5
internal/tests/testdata/operatorShareSnapshots/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,5 @@ | ||
COPY ( | ||
select * | ||
FROM dbt_preprod_holesky_rewards.operator_share_snapshots | ||
where snapshot < '2024-12-10' | ||
) TO STDOUT WITH DELIMITER ',' CSV HEADER |
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
22 changes: 22 additions & 0 deletions
22
internal/tests/testdata/operatorShares/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,22 @@ | ||
COPY ( | ||
SELECT | ||
operator, | ||
strategy, | ||
SUM(shares) OVER (PARTITION BY operator, strategy ORDER BY block_time, log_index) AS shares, | ||
transaction_hash, | ||
log_index, | ||
block_time, | ||
block_date, | ||
block_number | ||
FROM ( | ||
SELECT operator, strategy, shares, transaction_hash, log_index, block_time, block_date, block_number | ||
FROM dbt_preprod_holesky_rewards.operator_share_increases | ||
where block_date < '2024-12-11' | ||
|
||
UNION ALL | ||
|
||
SELECT operator, strategy, shares * -1 AS shares, transaction_hash, log_index, block_time, block_date, block_number | ||
FROM dbt_preprod_holesky_rewards.operator_share_decreases | ||
where block_date < '2024-12-11' | ||
) combined_shares | ||
) TO STDOUT WITH DELIMITER ',' CSV HEADER |
Oops, something went wrong.