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

auth-server: add output net of fees #93

Merged
merged 1 commit into from
Jan 21, 2025
Merged

auth-server: add output net of fees #93

merged 1 commit into from
Jan 21, 2025

Conversation

sehyunc
Copy link
Contributor

@sehyunc sehyunc commented Jan 21, 2025

Purpose

This PR takes into account fees when recording quote comparison metrics. We do so by calculating the fee take amount and storing it in the QuoteResponse struct.

Testing

  • Tested locally
  • Test in testnet

@sehyunc sehyunc force-pushed the sehyun/fee-costs branch 4 times, most recently from f46c721 to a15636c Compare January 21, 2025 02:10
@sehyunc sehyunc requested a review from joeykraut January 21, 2025 02:10
Comment on lines 59 to 63
let diff_ratio = (our_output_value_net_of_fee - source_output_value_net_of_fee)
/ source_output_value_net_of_fee;
let bps_diff = diff_ratio * DECIMAL_TO_BPS;

bps_diff as i32
Copy link
Member

Choose a reason for hiding this comment

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

we should probably do this as an f64 calculation, rather than using an integral type. precision matters for these metrics and rounding down to the nearest basis point is not a precision loss I feel good about.

Same with the gas diff metric


/// Internal helper that calculates the net output value with configurable
/// deductions.
fn calculate_net_output(
Copy link
Member

Choose a reason for hiding this comment

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

This helper doesn't seem very valuable, in general I'm against helpers that are just a bunch of boolean switches -- they become dumping grounds for one-off behaviors and they don't capture anything general.

Maybe what we can do is refactor the common behavior into a helper get_receive_amount_mint and then each of the callers of this method can call the respective deduction helpers or just inline the logic

@sehyunc sehyunc merged commit ca1468a into main Jan 21, 2025
4 checks passed
@sehyunc sehyunc deleted the sehyun/fee-costs branch January 21, 2025 19:04
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