diff --git a/smart-contracts/osmosis/contracts/cl-vault/src/helpers/getters.rs b/smart-contracts/osmosis/contracts/cl-vault/src/helpers/getters.rs index 3e7f32a89..8f5a530a3 100644 --- a/smart-contracts/osmosis/contracts/cl-vault/src/helpers/getters.rs +++ b/smart-contracts/osmosis/contracts/cl-vault/src/helpers/getters.rs @@ -202,20 +202,30 @@ pub fn get_single_sided_deposit_1_to_0_swap_amount( Ok(swap_amount) } -pub fn get_unused_balances(querier: &QuerierWrapper, env: &Env) -> Result { +pub fn get_unused_balances( + querier: &QuerierWrapper, + addr: &Addr, +) -> Result { Ok(CoinList::from_coins( - querier.query_all_balances(env.contract.address.to_string())?, + querier.query_all_balances(addr.to_string())?, )) } +pub fn get_unused_pair( + deps: &Deps, + addr: &Addr, + pool_config: &PoolConfig, +) -> Result, ContractError> { + let unused_balances = get_unused_balances(&deps.querier, addr)?; + Ok(get_vault_funds_or_zero(&unused_balances, pool_config)) +} + pub fn get_unused_pair_balances( - deps: &DepsMut, + deps: &Deps, env: &Env, pool_config: &PoolConfig, ) -> Result, ContractError> { - let unused_balances = get_unused_balances(&deps.querier, env)?; - let vault_funds = get_vault_funds_or_zero(&unused_balances, pool_config); - + let vault_funds = get_unused_pair(deps, &env.contract.address, pool_config)?; Ok(vec![vault_funds.base, vault_funds.quote]) } diff --git a/smart-contracts/osmosis/contracts/cl-vault/src/instantiate.rs b/smart-contracts/osmosis/contracts/cl-vault/src/instantiate.rs index 8da71b281..023ebe70f 100644 --- a/smart-contracts/osmosis/contracts/cl-vault/src/instantiate.rs +++ b/smart-contracts/osmosis/contracts/cl-vault/src/instantiate.rs @@ -77,7 +77,7 @@ pub fn handle_instantiate( } .into(); - let vault_funds = get_unused_pair_balances(&deps, &env, &pool_config)?; + let vault_funds = get_unused_pair_balances(&deps.as_ref(), &env, &pool_config)?; let create_position_msg = create_position( deps, diff --git a/smart-contracts/osmosis/contracts/cl-vault/src/query.rs b/smart-contracts/osmosis/contracts/cl-vault/src/query.rs index 9da35e720..c0f17a5b3 100644 --- a/smart-contracts/osmosis/contracts/cl-vault/src/query.rs +++ b/smart-contracts/osmosis/contracts/cl-vault/src/query.rs @@ -177,7 +177,7 @@ pub fn query_user_balance( pub fn query_total_assets(deps: Deps, env: Env) -> Result { let position = get_position(deps.storage, &deps.querier)?; let pool = POOL_CONFIG.load(deps.storage)?; - let unused_balance = get_unused_balances(&deps.querier, &env)?; + let unused_balance = get_unused_balances(&deps.querier, &env.contract.address)?; // add token0 unused balance to what's in the position let mut token0 = position 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 56764670a..d587fb6ea 100644 --- a/smart-contracts/osmosis/contracts/cl-vault/src/vault/autocompound.rs +++ b/smart-contracts/osmosis/contracts/cl-vault/src/vault/autocompound.rs @@ -33,7 +33,7 @@ pub fn execute_autocompound( .ok_or(ContractError::PositionNotFound)?; let pool = POOL_CONFIG.load(deps.storage)?; - let balance = get_unused_pair_balances(&deps, env, &pool)?; + let balance = get_unused_pair_balances(&deps.as_ref(), env, &pool)?; let token0 = balance[0].clone(); let token1 = balance[1].clone(); 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 891e872cd..a1742694e 100644 --- a/smart-contracts/osmosis/contracts/cl-vault/src/vault/range.rs +++ b/smart-contracts/osmosis/contracts/cl-vault/src/vault/range.rs @@ -116,7 +116,7 @@ pub fn handle_withdraw_position_reply(deps: DepsMut, env: Env) -> Result Result