-
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?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "fee_collector" | ||
version = "1.1.7" | ||
version = "1.1.8" | ||
authors = ["Kerber0x <[email protected]>"] | ||
edition.workspace = true | ||
description = "Contract to collect the fees accrued by the pools and vaults in the liquidity hub" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -231,7 +231,7 @@ pub fn aggregate_fees( | |
})?, | ||
}))?; | ||
|
||
if balance_response.balance > Uint128::zero() { | ||
if balance_response.balance > MINIMUM_AGGREGABLE_BALANCE { | ||
// if balance is greater than zero, some swap will occur | ||
// Increase the allowance for the cw20 token so the router can perform the swap | ||
aggregate_fees_messages.push(CosmosMsg::Wasm(WasmMsg::Execute { | ||
|
@@ -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)), | ||
})?, | ||
})); | ||
|
||
|
@@ -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 commentThe 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. |
||
}, | ||
}, | ||
})?, | ||
|
@@ -384,7 +385,7 @@ pub fn forward_fees( | |
factory_addr: config.pool_factory.to_string(), | ||
factory_type: FactoryType::Pool { | ||
start_after: None, | ||
limit: Some(30u32), | ||
limit: Some(60u32), | ||
}, | ||
}, | ||
})?, | ||
|
@@ -404,7 +405,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), | ||
}, | ||
}, | ||
})?, | ||
|
@@ -423,7 +424,7 @@ pub fn forward_fees( | |
factory_addr: config.pool_factory.to_string(), | ||
factory_type: FactoryType::Pool { | ||
start_after: None, | ||
limit: Some(30u32), | ||
limit: Some(60u32), | ||
}, | ||
}, | ||
})?, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "stableswap-3pool" | ||
version = "1.2.5" | ||
version = "1.2.6" | ||
authors = ["Adam J. Weigold <[email protected]>"] | ||
edition.workspace = true | ||
license.workspace = true | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -455,17 +455,12 @@ pub fn swap( | |
amount: swap_computation.return_amount, | ||
}; | ||
|
||
let fees = swap_computation | ||
.swap_fee_amount | ||
.checked_add(swap_computation.protocol_fee_amount)? | ||
.checked_add(swap_computation.burn_fee_amount)?; | ||
|
||
// 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 commentThe reason will be displayed to describe this comment to others. Learn more. fix for bug reported a while ago |
||
return_asset.amount, | ||
swap_computation.spread_amount, | ||
)?; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -411,29 +411,12 @@ pub fn swap( | |
amount: swap_computation.return_amount, | ||
}; | ||
|
||
let fees = { | ||
let base_fees = swap_computation | ||
.swap_fee_amount | ||
.checked_add(swap_computation.protocol_fee_amount)? | ||
.checked_add(swap_computation.burn_fee_amount)?; | ||
|
||
#[cfg(feature = "osmosis")] | ||
{ | ||
base_fees.checked_add(swap_computation.osmosis_fee_amount)? | ||
} | ||
|
||
#[cfg(not(feature = "osmosis"))] | ||
{ | ||
base_fees | ||
} | ||
}; | ||
|
||
// 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 commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
return_asset.amount, | ||
swap_computation.spread_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.
add new
max_spread
in simulation