Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mainnet solver rewards dashboard and update with service fee #8

Closed
wants to merge 1 commit into from

Conversation

harisang
Copy link
Contributor

@harisang harisang commented Sep 2, 2024

This PR adds the following to the repo:

  • Query 2510345, which is the main query showing in the solver rewards dashboard.
  • Query 4017925, which computes whether a solver needs to pay the CoW DAO bonding pool service fee or not.

Note that query 2510345 has some proposed changes, regarding the implementation of the service fee and the reduction in the rewards being transferred to solvers. The changes are between lines 746-811.

So the plan is to get the PR approved, and before merging actually edit query 2510345 to ensure its code is identical to the code in this PR.

Copy link
Contributor

@fhenneke fhenneke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good opportunity to clean up this query (and the respective solver-rewards query).

As a minimum, the external queries referenced in this query should be called instead of their code being copied.

There is much room for other improvements, but some of that (e.g. using the actual solver-rewards query for the dashboard or using query 4021306 from coincidence of want for slippage) could be addressed later.

@@ -0,0 +1,842 @@
with
-- BEGIN VOUCH REGISTRY: https://dune.com/queries/2283344
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That whole block should be replaced with something like

named_result as (
    select * from query_2283344(bonding_pool_data='{{bonding_pool_data}}',end_time='{{end_time}}')
)

and query 2283344 should be added to the repo as well. Note that all query parameters should be lower case for this to work. So this query and the underlying query need to change parameter names.

The resulting table could also be renamed to something like valid_vouches_with_names or something shorter.

),
-- END VOUCH_REGISTRY

-- BEGIN SLIPPAGE: https://dune.com/queries/3427730
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block should be replaced by something like

solver_slippage as (
    select * from query_3427730(start_time='{{start_time}}',end_time='{{end_time}}')
)

and query 3427730 should be added to the repo.

on w.evt_tx_hash= bm.tx_hash
where owner = 0x9008d19f58aabd9ed0d60971565aa8510560ab41
)
,pre_batch_transfers as (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This table is really close to what query 4021306 does (see coincidence of wants query). With a bit of renaming, we could use

filtered_batches as (
    select
        ...
    from cow_protocol_ethereum.batches
    where ...
),
pre_batch_transfers as (
    select
        ...
    from query_4021306(start_time='{{start_time}}',end_time='{{end_time}}')
    where not transfer_type in ('slippage_in', 'slippage_out')
),
batch_transfers as (
    select
        ...
    from pre_batch_transfers
    join filtered_batches
)

and blockchain = 'ethereum'
)
-- -- V3 PoC Query For Token List: https://dune.com/queries/2259926
,token_list as (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This table and the parameter TokenList should be removed. They are not used anywhere. (The parameter also needs to be removed from the query in solver-rewards.)

SELECT from_hex(address_str) as address
FROM ( VALUES {{TokenList}} ) as _ (address_str)
)
,internalized_imbalances as (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Internalized imbalances are not user anymore, so this part of the query should be removed as well.

select
solver,
service_fee
from query_4038102
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the query used in solver-rewards and should be changed to 4017925.

The query also needs a time parameter and should be passed the start time of the accounting period.

 service_fee_data as (
    select
        solver,
        service_fee
    from query_4017925(cutoff_time='{{start_time}}')

jd.pool_name,
jd.pool,
jd.joined_on,
date_diff('day', date(jd.joined_on), date(NOW())) AS days_in_pool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOW() should probably be changed to a cutoff_time parameter which would chosen as start_time.

WHERE time > CAST('2024-08-20 00:00:00' AS timestamp) -- CIP-48 starts bonding pool timer at midnight UTC on 20/08/24
),

initial_vouches AS (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The part on vouches might just reuse the vouches query.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That query does not look much simpler that just hard-coding all solver addresses, their starting date, and their status (e.g. exempt for 6 month, 9 month, indefinitely).

The query might help finding those dates.

@@ -0,0 +1,175 @@
WITH
bonding_pools (pool, name, initial_funder) AS (
SELECT from_hex(pool), name, from_hex(funder) FROM (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(this query uses a different style (keywords in all caps) than the other query)

@harisang
Copy link
Contributor Author

Closing as a lot of changes have happened in between so will reopen a PR with just the main dashboard there.

@harisang harisang closed this Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants