diff --git a/smart-contracts/osmosis/contracts/cl-vault/src/contract.rs b/smart-contracts/osmosis/contracts/cl-vault/src/contract.rs index dfabfd1cf..682a78ce2 100644 --- a/smart-contracts/osmosis/contracts/cl-vault/src/contract.rs +++ b/smart-contracts/osmosis/contracts/cl-vault/src/contract.rs @@ -13,27 +13,27 @@ use crate::query::{ use crate::reply::Replies; #[allow(deprecated)] use crate::state::{MigrationStatus, MIGRATION_STATUS}; -use crate::vault::admin::execute_admin; -use crate::vault::autocompound::{ - execute_autocompound, execute_migration_step, handle_autocompound_reply, +use crate::vault::{ + admin::execute_admin, + autocompound::{ + execute_autocompound, execute_migration_step, handle_autocompound_reply, handle_merge_reply, + }, + deposit::{execute_any_deposit, execute_exact_deposit, handle_any_deposit_swap_reply}, + distribution::{ + execute_collect_rewards, handle_collect_incentives_reply, + handle_collect_spread_rewards_reply, + }, + merge::{ + execute_merge_position, handle_merge_create_position_reply, + handle_merge_withdraw_position_reply, + }, + range::{ + execute_update_range, handle_initial_create_position_reply, + handle_iteration_create_position_reply, handle_swap_reply, handle_withdraw_position_reply, + }, + swap::execute_swap_non_vault_funds, + withdraw::{execute_withdraw, handle_withdraw_user_reply}, }; -use crate::vault::deposit::{ - execute_any_deposit, execute_exact_deposit, handle_any_deposit_swap_reply, -}; -use crate::vault::distribution::{ - execute_collect_rewards, handle_collect_incentives_reply, handle_collect_spread_rewards_reply, -}; -use crate::vault::merge::{ - execute_merge_position, handle_merge_create_position_reply, - handle_merge_withdraw_position_reply, -}; -use crate::vault::range::{ - execute_update_range, handle_initial_create_position_reply, - handle_iteration_create_position_reply, handle_merge_reply, handle_swap_reply, - handle_withdraw_position_reply, -}; -use crate::vault::swap::execute_swap_non_vault_funds; -use crate::vault::withdraw::{execute_withdraw, handle_withdraw_user_reply}; #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Reply, Response}; diff --git a/smart-contracts/osmosis/contracts/cl-vault/src/vault/autocompound.rs b/smart-contracts/osmosis/contracts/cl-vault/src/vault/autocompound.rs index 96310bbb9..86b6ff33e 100644 --- a/smart-contracts/osmosis/contracts/cl-vault/src/vault/autocompound.rs +++ b/smart-contracts/osmosis/contracts/cl-vault/src/vault/autocompound.rs @@ -14,8 +14,8 @@ use crate::msg::{ExecuteMsg, MergePositionMsg}; use crate::reply::Replies; #[allow(deprecated)] use crate::state::USER_REWARDS; -use crate::state::{MigrationStatus, MIGRATION_STATUS, POOL_CONFIG, POSITION}; -use crate::vault::concentrated_liquidity::create_position; +use crate::state::{MigrationStatus, Position, MIGRATION_STATUS, POOL_CONFIG, POSITION}; +use crate::vault::{concentrated_liquidity::create_position, merge::MergeResponse}; use crate::ContractError; pub fn execute_autocompound( @@ -109,6 +109,30 @@ pub fn handle_autocompound_reply( )) } +pub fn handle_merge_reply( + deps: DepsMut, + env: Env, + data: SubMsgResult, +) -> Result { + let merge_response: MergeResponse = data.try_into()?; + + let position = POSITION.load(deps.storage)?; + POSITION.save( + deps.storage, + &Position { + position_id: merge_response.new_position_id, + join_time: env.block.time.seconds(), + claim_after: position.claim_after, + }, + )?; + + Ok(Response::new() + .add_attribute("method", "reply") + .add_attribute("action", "handle_merge_reply") + .add_attribute("swap_deposit_merge_status", "success") + .add_attribute("status", "success")) +} + // Migration is a to-depreacate entrypoint useful to migrate from Distribute to Accumulate after Autocompound implementation pub fn execute_migration_step( deps: DepsMut, diff --git a/smart-contracts/osmosis/contracts/cl-vault/src/vault/range.rs b/smart-contracts/osmosis/contracts/cl-vault/src/vault/range.rs index d4e545313..843df79b6 100644 --- a/smart-contracts/osmosis/contracts/cl-vault/src/vault/range.rs +++ b/smart-contracts/osmosis/contracts/cl-vault/src/vault/range.rs @@ -13,7 +13,6 @@ use crate::{ }, vault::{ concentrated_liquidity::{create_position, get_cl_pool_info, get_position}, - merge::MergeResponse, swap::{estimate_swap_min_out_amount, swap_msg}, }, ContractError, @@ -391,33 +390,6 @@ pub fn handle_iteration_create_position_reply( )) } -// store new position id and exit -pub fn handle_merge_reply( - deps: DepsMut, - env: Env, - data: SubMsgResult, -) -> Result { - let merge_response: MergeResponse = data.try_into()?; - - // Load the current Position to extract join_time and claim_after which is unchangeable in this context - let position = POSITION.load(deps.storage)?; - - POSITION.save( - deps.storage, - &Position { - position_id: merge_response.new_position_id, - join_time: env.block.time.seconds(), - claim_after: position.claim_after, - }, - )?; - - Ok(Response::new() - .add_attribute("method", "reply") - .add_attribute("action", "handle_merge_reply") - .add_attribute("swap_deposit_merge_status", "success") - .add_attribute("status", "success")) -} - #[cfg(test)] mod tests { use std::str::FromStr;