-
Notifications
You must be signed in to change notification settings - Fork 7
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
Pool: adds a test for the bug in question, no weird behaviour allthough I used pretty similar values with what's already present in the live environment #171
Conversation
…gh I used pretty similar values with what's already present in the live environment
bug-issue-169.md In addition to the new test, we already have a couple of other tests that look correct to me and they work. I'm thinking that we might have bad initial setup for the pool somehow, but I cannot verify that. Would it make sense for us to keep the initial command that was used to initialize the pool. I know it sounds similar to what we already have in config, but the config can get updated via Also, I think swap commission is wrong only when doing simulate_swap for XLM/EURC. My suggestion is to re-deploy everything on testnet and check again. |
contracts/pool/src/tests/swap.rs
Outdated
std::mem::swap(&mut token1, &mut token2); | ||
} | ||
|
||
let swap_fees = 1_000i64; // 10% bps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you try smaller amounts, 1% and 0.3%?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got the expected results
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like those tests. Instead of creating a new, specifically named test cases let's close this withing one test_swap_fee_variants
or something; use testcase
crate and add that fee as parameter to the tests in couple variants, including those 1%, 0.3%.
https://docs.rs/test-case/latest/test_case/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good test, just some cleaning required.
contracts/pool/src/tests/swap.rs
Outdated
#[test_case(1_000i64, 10, 99102002 ; "when fee is 10%")] | ||
#[test_case(100, 1, 9910200 ; "when fee is 1%")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[test_case(1_000i64, 10, 99102002 ; "when fee is 10%")] | |
#[test_case(100, 1, 9910200 ; "when fee is 1%")] | |
#[test_case(1_000i64, 1000, 99102002 ; "when fee is 10%")] | |
#[test_case(100, 100, 9910200 ; "when fee is 1%")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
those values suggested to be changed are gone now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only using BPS
@@ -843,12 +706,12 @@ fn bug_issue_169_below_1_percent() { | |||
} | |||
); | |||
|
|||
// 991020025 is the request, so 0.3% of that should be what's on the left hand side | |||
assert_eq!(2973060, result.commission_amount); | |||
// 991020025 is the request, so 10% of that should be what's on the left hand side |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those comments aren't accurate in parametrized test.
|
||
let result = pool.simulate_reverse_swap(&token1.address, &(output_amount - fees)); | ||
let output_amount = 991020025i128; | ||
let fees = Decimal::bps(30) * output_amount; | ||
// let fees = Decimal::percent(fee_percentage) * output_amount; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some leftover?
// let fees = Decimal::percent(fee_percentage) * output_amount; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good test 👍
No description provided.