Skip to content

Conversation

@kerber0x
Copy link
Contributor

@kerber0x kerber0x commented Sep 3, 2024

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:

  • I have read Migaloo's contribution guidelines.
  • My pull request has a sound title and description (not something vague like Update index.md)
  • All existing and new tests are passing.
  • I updated/added relevant documentation.
  • The code is formatted properly cargo fmt --all --.
  • Clippy doesn't report any issues cargo clippy -- -D warnings.
  • I have regenerated the schemas if needed cargo schema.

msg: to_json_binary(&router::QueryMsg::SimulateSwapOperations {
offer_amount: balance,
operations: operations.clone(),
max_spread: Some(Decimal::percent(50u64)),
Copy link
Contributor Author

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

factory_type: FactoryType::Vault {
start_after: None,
limit: Some(30u32),
limit: Some(60u32),
Copy link
Contributor Author

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.

belief_price,
max_spread,
offer_asset.amount,
return_asset.amount.checked_add(fees)?,
Copy link
Contributor Author

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
Copy link

codecov bot commented Sep 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.84%. Comparing base (a96fecb) to head (3eb627d).

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.
📢 Have feedback on the report? Share it here.

belief_price,
max_spread,
offer_asset.amount,
return_asset.amount.checked_add(fees)?,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

same as above

},
)?;

if max_spread.is_some() && res.return_amount > Uint128::zero() {
Copy link
Contributor Author

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

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