From 3866390f44aa79e7b28b58ac370deb3e06503336 Mon Sep 17 00:00:00 2001 From: LaurensKubat <32776056+LaurensKubat@users.noreply.github.com> Date: Mon, 18 Sep 2023 01:06:54 +0200 Subject: [PATCH] fix: use modify_range msg slippage instead of vault_config (#503) ## 1. Overview Changes from where slippage is passed when swapping for the second position ## 2. Implementation details ## 3. How to test/use ## 4. Checklist - [ ] Does the Readme need to be updated? ## 5. Limitations (optional) ## 6. Future Work (optional) --- smart-contracts/contracts/cl-vault/src/vault/range.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/smart-contracts/contracts/cl-vault/src/vault/range.rs b/smart-contracts/contracts/cl-vault/src/vault/range.rs index 82d5a829c..f3f9f3e09 100644 --- a/smart-contracts/contracts/cl-vault/src/vault/range.rs +++ b/smart-contracts/contracts/cl-vault/src/vault/range.rs @@ -22,7 +22,7 @@ use crate::{ reply::Replies, state::{ ModifyRangeState, Position, SwapDepositMergeState, MODIFY_RANGE_STATE, POOL_CONFIG, - POSITION, RANGE_ADMIN, SWAP_DEPOSIT_MERGE_STATE, VAULT_CONFIG, + POSITION, RANGE_ADMIN, SWAP_DEPOSIT_MERGE_STATE, }, vault::concentrated_liquidity::get_position, vault::merge::MergeResponse, @@ -256,7 +256,6 @@ pub fn do_swap_deposit_merge( let (balance0, balance1) = refunded_amounts; let pool_config = POOL_CONFIG.load(deps.storage)?; - let vault_config = VAULT_CONFIG.load(deps.storage)?; let pool_details = get_cl_pool_info(&deps.querier, pool_config.pool_id)?; let mut target_range_position_ids = vec![]; @@ -341,10 +340,9 @@ pub fn do_swap_deposit_merge( CURRENT_SWAP.save(deps.storage, &(swap_direction, left_over_amount))?; - let token_out_min_amount = token_out_ideal_amount?.checked_multiply_ratio( - vault_config.swap_max_slippage.numerator(), - vault_config.swap_max_slippage.denominator(), - )?; + let mrs = MODIFY_RANGE_STATE.load(deps.storage)?.unwrap(); + let token_out_min_amount = token_out_ideal_amount? + .checked_multiply_ratio(mrs.max_slippage.numerator(), mrs.max_slippage.denominator())?; let swap_msg = swap( deps,