-
Notifications
You must be signed in to change notification settings - Fork 22
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
Fix/spread assertion #222
Fix/spread assertion #222
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #222 +/- ##
=======================================
Coverage 94.50% 94.50%
=======================================
Files 217 218 +1
Lines 24822 24750 -72
=======================================
- Hits 23457 23389 -68
+ Misses 1365 1361 -4
☔ View full report in Codecov by Sentry. |
61bd61e
to
b371f74
Compare
/// If `belief_price` and `max_spread` both are given, | ||
/// we compute new spread else we just use terraswap | ||
/// spread to check `max_spread` | ||
pub fn assert_max_spread( |
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.
moved to packages/white-whale/src/pool_network/swap.rs since this code is shared with the pair contract as well.
@@ -74,11 +74,13 @@ pub enum ExecuteMsg { | |||
operations: Vec<SwapOperation>, | |||
minimum_receive: Option<Uint128>, | |||
to: Option<String>, | |||
max_spread: Option<Decimal>, |
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.
Added max_spread to router messages
b371f74
to
a820252
Compare
offer_asset.clone(), | ||
return_asset.clone(), | ||
offer_asset.amount, | ||
return_asset.amount.checked_add(fees)?, |
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.
fees should be accounted for when calculating spread in the return amount, otherwise the max_spread input by the user is gonna be off
) -> Result<(), ContractError> { | ||
let (offer_amount, return_amount, spread_amount): (Uint256, Uint256, Uint256) = | ||
match offer_decimal.cmp(&return_decimal) { |
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.
remove all the decimal things as it's not needed
@@ -289,6 +289,7 @@ pub fn aggregate_fees( | |||
operations, | |||
minimum_receive: None, | |||
to: None, | |||
max_spread: Some(Decimal::percent(50u64)), |
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.
Add the max_spread possible (50%) when doing the fees aggregation to avoid max spread assertions
a820252
to
50b8c5d
Compare
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.
Changes LGTM 🚀
035bb05
to
5e57ffb
Compare
Description and Motivation
This PR fixes the spread assertion miscalculation when interacting with tokens with different decimals. This is in preparation to the upcoming injective migration.
Additionally, it adds the
max_spread
parameter to the pool router.Related Issues
Checklist:
Update index.md
)cargo fmt --all --
.cargo clippy -- -D warnings
.cargo schema
.