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

Move executed_surplus_fee #2103

Merged
merged 7 commits into from
Jan 6, 2024
Merged

Move executed_surplus_fee #2103

merged 7 commits into from
Jan 6, 2024

Conversation

sunce86
Copy link
Contributor

@sunce86 sunce86 commented Nov 30, 2023

Description

OrderClass::Limit variant contained executed_surplus_fee field just for the needs of the API so the fee could be displayed to the users.

I moved the executed_surplus_fee to parent struct since there is no good reason to keep it as part of the OrderClass, on the contrary, we have a lot of places where we use the order class but omit the value of executed_surplus_fee as irrelevant.

@sunce86 sunce86 requested a review from a team as a code owner November 30, 2023 15:50
Copy link
Contributor

@fleupold fleupold left a comment

Choose a reason for hiding this comment

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

How does this change affect existing orders in the database?

In order to make coordination with the frontend changes easier, I wonder if a migration plan could be:

  1. Populate executed_fee_amount for all order types (while keeping executed_surplus_fee for limit orders)
  2. Change frontend to read executed_fee_amount for all orders
  3. Drop executed_surplus_fee from the model

crates/shared/src/db_order_conversions.rs Show resolved Hide resolved
@sunce86
Copy link
Contributor Author

sunce86 commented Dec 1, 2023

How does this change affect existing orders in the database?

In order to make coordination with the frontend changes easier, I wonder if a migration plan could be:

  1. Populate executed_fee_amount for all order types (while keeping executed_surplus_fee for limit orders)
  2. Change frontend to read executed_fee_amount for all orders
  3. Drop executed_surplus_fee from the model

Yes, that would be the way to go. Will prepare the PR for (1).

Copy link
Contributor

@MartinquaXD MartinquaXD left a comment

Choose a reason for hiding this comment

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

The change makes sense to me when executed in coordination with the frontend.

@sunce86 sunce86 changed the title Remove executed_surplus_fee [ON HOLD] Remove executed_surplus_fee Dec 16, 2023
@sunce86 sunce86 changed the title [ON HOLD] Remove executed_surplus_fee Move executed_surplus_fee Dec 29, 2023
@sunce86
Copy link
Contributor Author

sunce86 commented Dec 29, 2023

Updated the PR description and the code. Now the change is just to move the executed_surplus_fee to the parent struct.

@sunce86 sunce86 requested a review from fleupold December 29, 2023 21:15
Copy link
Contributor

@fleupold fleupold left a comment

Choose a reason for hiding this comment

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

Looks alright to me. However, if we introduce a new field this change needs to be tightly coordinated with the frontend team, doesn't it? Otherwise displaying the fee in the fronted will break. My understanding was that we would start exposing surplus fee as part of executed fee amount (the two values are already summed up iirc)

Can you test that change locally and show how a limit order fee would look like in the explorer?

Comment on lines +743 to +744
#[serde_as(as = "HexOrDecimalU256")]
pub executed_surplus_fee: U256,
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is only used for the UI, can we not add it to the existing executed_fee_amount ?

@sunce86
Copy link
Contributor Author

sunce86 commented Dec 30, 2023

if we introduce a new field this change needs to be tightly coordinated with the frontend team

This PR does not include new field, it just moves the filed from one struct to it's parent struct, but the serialization for the API is the same (as the unit test deserialization_and_back proves).

If this is only used for the UI, can we not add it to the existing executed_fee_amount

I don't know. I've asked the frontend team this several times, but never got a clear yes/no answer, so I dropped the idea for now and decided to just refactor the backend side without changing the API.

@sunce86 sunce86 merged commit 35ca75b into main Jan 6, 2024
8 checks passed
@sunce86 sunce86 deleted the class-limit branch January 6, 2024 11:05
@github-actions github-actions bot locked and limited conversation to collaborators Jan 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants