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

[Draft] Restructure payouts #435

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft

[Draft] Restructure payouts #435

wants to merge 15 commits into from

Conversation

fhenneke
Copy link
Collaborator

This draft PR is an attempt at implementing #427. The PR does not change the values of final results (up to rounding of floats). It changes the structure of the code and intermediate representations.

As a first step, it separates the computation of different parts of the accounting into different functions.

    # compute individual components of payments
    solver_info = compute_solver_info(
        reward_target_df,
        service_fee_df,
        config,
    )
    rewards = compute_rewards(
        batch_data,
        quote_rewards_df,
        exchange_rate_native_to_cow,
        config.reward_config,
    )
    protocol_fees = compute_protocol_fees(
        batch_data,
    )
    buffer_accounting = compute_buffer_accounting(batch_data, slippage_df)

Those functions are implemented in separate files

The results of these steps are converted into data frames for solver payments and for protocol and partner fee payments.

    # combine into solver payouts and partner payouts
    solver_payouts = compute_solver_payouts(
        solver_info, rewards, protocol_fees, buffer_accounting
    )
    partner_payouts = compute_partner_fees(batch_data, config.protocol_fee_config)

Additional changes could remove data frames from intermediate results. This would make it easier to have correct types and detect and handle missing data.

The code can be tested to produce the same transfer files as the old code.
Tests have not been adapted yet and are broken due to changes to intermediate results.

harisang added a commit that referenced this pull request Dec 3, 2024
This PR changes how missing data for reward targets is identified. It
fixes a bug where missing data causes the script to crash.

The issue seems to come from a column without valid values being
misidentified as float column and the missing value is encoded as `NaN`.
This was not identified as missing data since it only checks for `None`.

With this PR, the pandas function `isna` is used to identify missing
data.

A similar approach was used in #435.

Since local tests are still running, I created this as draft PR. I will
remove the draft status once the local run is successful.

---------

Co-authored-by: Haris Angelidakis <[email protected]>
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.

1 participant