-
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: add max_spread param to router operations simulation #381
base: main
Are you sure you want to change the base?
Conversation
@@ -284,6 +284,7 @@ pub fn aggregate_fees( | |||
msg: to_json_binary(&router::QueryMsg::SimulateSwapOperations { | |||
offer_amount: balance, | |||
operations: operations.clone(), | |||
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 new max_spread
in simulation
@@ -365,7 +366,7 @@ pub fn forward_fees( | |||
factory_addr: config.vault_factory.to_string(), | |||
factory_type: FactoryType::Vault { | |||
start_after: None, | |||
limit: Some(30u32), | |||
limit: Some(60u32), |
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.
increased limit to 60 items, as there are over 30 pools on terra atm.
// check max spread limit if exist | ||
swap::assert_max_spread( | ||
belief_price, | ||
max_spread, | ||
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.
fix for bug reported a while ago
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #381 +/- ##
==========================================
+ Coverage 93.21% 94.84% +1.63%
==========================================
Files 219 214 -5
Lines 24868 24770 -98
==========================================
+ Hits 23180 23493 +313
+ Misses 1688 1277 -411 ☔ View full report in Codecov by Sentry. |
// check max spread limit if exist | ||
swap::assert_max_spread( | ||
belief_price, | ||
max_spread, | ||
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.
same as above
@@ -369,6 +374,16 @@ fn simulate_swap_operations( | |||
}, | |||
)?; | |||
|
|||
if max_spread.is_some() && res.return_amount > Uint128::zero() { |
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.
So if the max_spread is passed and the return_amount is above zero then we can perform the spread assertion
Description and Motivation
With the previous fix for failing fee aggregation it was introduced a simulation on the aggregation swap. However, the aggregation doesn't perform any spread assertions. This code introduces this into the pool router.
Related Issues
Checklist:
Update index.md
)cargo fmt --all --
.cargo clippy -- -D warnings
.cargo schema
.