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

Fee tests #2510

Merged
merged 22 commits into from
Mar 12, 2024
Merged

Fee tests #2510

merged 22 commits into from
Mar 12, 2024

Conversation

fleupold
Copy link
Contributor

@fleupold fleupold commented Mar 10, 2024

Description

Proposal on how to improve the readability of #2467

It only implements two surplus and one price improvement test case as an example, the others still need to be converted.

Changes

  • Decouple quoted_order amounts from execution amounts. This makes it so that a test case can specify a concrete limit price (QuotedOrders currently always use the AMM to compute their buy amounts).
  • Implement in_given_out on pool to correctly compute the executed amounts for buy orders.
  • Remove unnecessary executed method (will likely need this one for partial fill tests)
  • Comment on why we expect the values we expect
  • Small naming improvements so that the TestCase is easier to read

How to test

Driver tests

Fixes #2479

@squadgazzz squadgazzz marked this pull request as ready for review March 11, 2024 14:29
@squadgazzz squadgazzz requested a review from a team as a code owner March 11, 2024 14:29
Copy link
Contributor Author

@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 good overall (but I'm biased) but I think there could be a bit more consistency and some more small cleanups.

"factor": factor
}
}),
pub mod fee {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this one needs a bit of clean up. Either revert or move this module into its own file please.

Copy link
Contributor

Choose a reason for hiding this comment

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

Done

async fn price_improvement_fee_sell_out_of_market_order() {
let fee_policy = Policy::PriceImprovement {
factor: 0.5,
max_volume_factor: 1.0,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we have any tests checking the max volume factor for this policy?

Copy link
Contributor

Choose a reason for hiding this comment

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

Added

squadgazzz and others added 3 commits March 11, 2024 16:10
Co-authored-by: Felix Leupold <felixleupold90@gmail.com>
Co-authored-by: Felix Leupold <felixleupold90@gmail.com>
Copy link
Contributor

@sunce86 sunce86 left a comment

Choose a reason for hiding this comment

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

Lg. Tests are pretty readable.

What's missing to have a complete suite of tests are capped versions for price improvement and maybe versions with partially fillable orders (but that might be out of the scope of this PR)

@squadgazzz squadgazzz enabled auto-merge (squash) March 12, 2024 09:43
@squadgazzz squadgazzz merged commit e970e8e into main Mar 12, 2024
9 checks passed
@squadgazzz squadgazzz deleted the fee_tests branch March 12, 2024 09:48
@github-actions github-actions bot locked and limited conversation to collaborators Mar 12, 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.

Implement Price Improvement integration tests
3 participants