Skip to content

Commit

Permalink
fix: use modify_range msg slippage instead of vault_config (#503)
Browse files Browse the repository at this point in the history
## 1. Overview

Changes from where slippage is passed when swapping for the second
position

## 2. Implementation details

<!-- Describe the implementation (highlights only) as well as design
rationale. -->

## 3. How to test/use

<!-- How can people test/use this? -->

## 4. Checklist

<!-- Checklist for PR author(s). -->

- [ ] Does the Readme need to be updated?

## 5. Limitations (optional)

<!-- Describe any limitation of the capabilities listed in the Overview
section. -->

## 6. Future Work (optional)

<!-- Describe follow up work, if any. -->
  • Loading branch information
0xLaurenzo authored Sep 17, 2023
1 parent 092637f commit 3866390
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions smart-contracts/contracts/cl-vault/src/vault/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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![];
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 3866390

Please sign in to comment.