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 d6444eae7..df0af8e9e 100644 --- a/smart-contracts/osmosis/contracts/cl-vault/src/helpers/getters.rs +++ b/smart-contracts/osmosis/contracts/cl-vault/src/helpers/getters.rs @@ -13,8 +13,8 @@ use crate::{ ContractError, }; use cosmwasm_std::{ - coin, Addr, Coin, Decimal, Decimal256, Deps, DepsMut, Env, QuerierWrapper, Storage, Timestamp, - Uint128, Uint256, + coin, Addr, Coin, Decimal, Decimal256, Deps, Env, QuerierWrapper, Storage, Timestamp, Uint128, + Uint256, }; use super::coinlist::CoinList; diff --git a/smart-contracts/osmosis/contracts/cl-vault/src/test_helpers.rs b/smart-contracts/osmosis/contracts/cl-vault/src/test_helpers.rs index 86f5653a1..42a2440d8 100644 --- a/smart-contracts/osmosis/contracts/cl-vault/src/test_helpers.rs +++ b/smart-contracts/osmosis/contracts/cl-vault/src/test_helpers.rs @@ -24,6 +24,10 @@ use crate::state::{ PoolConfig, Position, VaultConfig, POOL_CONFIG, POSITION, RANGE_ADMIN, VAULT_CONFIG, }; +pub const POOL_ID: u64 = 1; +pub const BASE_DENOM: &str = "base"; +pub const QUOTE_DENOM: &str = "quote"; + pub struct QuasarQuerier { position: FullPositionBreakdown, current_tick: i64, @@ -104,10 +108,10 @@ impl Querier for QuasarQuerier { address: "idc".to_string(), incentives_address: "not being used".to_string(), spread_rewards_address: "not being used".to_string(), - id: 1, + id: POOL_ID, current_tick_liquidity: "100".to_string(), - token0: "uosmo".to_string(), - token1: "uion".to_string(), + token0: BASE_DENOM.to_string(), + token1: QUOTE_DENOM.to_string(), current_sqrt_price: "not used".to_string(), current_tick: self.current_tick, tick_spacing: 100, @@ -170,27 +174,27 @@ pub fn mock_deps_with_querier_with_balance( position: Some(OsmoPosition { position_id: 1, address: MOCK_CONTRACT_ADDR.to_string(), - pool_id: 1, + pool_id: POOL_ID, lower_tick: 100, upper_tick: 1000, join_time: None, liquidity: "1000000.1".to_string(), }), asset0: Some(OsmoCoin { - denom: "token0".to_string(), + denom: BASE_DENOM.to_string(), amount: "1000000".to_string(), }), asset1: Some(OsmoCoin { - denom: "token1".to_string(), + denom: QUOTE_DENOM.to_string(), amount: "1000000".to_string(), }), claimable_spread_rewards: vec![ OsmoCoin { - denom: "token0".to_string(), + denom: BASE_DENOM.to_string(), amount: "100".to_string(), }, OsmoCoin { - denom: "token1".to_string(), + denom: QUOTE_DENOM.to_string(), amount: "100".to_string(), }, ], @@ -210,9 +214,9 @@ pub fn mock_deps_with_querier_with_balance( .save( storage, &PoolConfig { - pool_id: 1, - token0: "token0".to_string(), - token1: "token1".to_string(), + pool_id: POOL_ID, + token0: BASE_DENOM.to_string(), + token1: QUOTE_DENOM.to_string(), }, ) .unwrap(); @@ -256,27 +260,27 @@ pub fn mock_deps_with_querier( position: Some(OsmoPosition { position_id, address: MOCK_CONTRACT_ADDR.to_string(), - pool_id: 1, + pool_id: POOL_ID, lower_tick: 100, upper_tick: 1000, join_time: None, liquidity: "1000000.1".to_string(), }), asset0: Some(OsmoCoin { - denom: "token0".to_string(), + denom: BASE_DENOM.to_string(), amount: "1000000".to_string(), }), asset1: Some(OsmoCoin { - denom: "token1".to_string(), + denom: QUOTE_DENOM.to_string(), amount: "1000000".to_string(), }), claimable_spread_rewards: vec![ OsmoCoin { - denom: "token0".to_string(), + denom: BASE_DENOM.to_string(), amount: "100".to_string(), }, OsmoCoin { - denom: "token1".to_string(), + denom: QUOTE_DENOM.to_string(), amount: "100".to_string(), }, ], @@ -306,9 +310,9 @@ pub fn mock_deps_with_querier( .save( storage, &PoolConfig { - pool_id: 1, - token0: "token0".to_string(), - token1: "token1".to_string(), + pool_id: POOL_ID, + token0: BASE_DENOM.to_string(), + token1: QUOTE_DENOM.to_string(), }, ) .unwrap(); diff --git a/smart-contracts/osmosis/contracts/cl-vault/src/vault/deposit.rs b/smart-contracts/osmosis/contracts/cl-vault/src/vault/deposit.rs index e988407ed..6762dc69d 100644 --- a/smart-contracts/osmosis/contracts/cl-vault/src/vault/deposit.rs +++ b/smart-contracts/osmosis/contracts/cl-vault/src/vault/deposit.rs @@ -301,7 +301,7 @@ mod tests { use crate::{ helpers::msgs::refund_bank_msg, state::{Position, POSITION}, - test_helpers::mock_deps_with_querier, + test_helpers::{mock_deps_with_querier, BASE_DENOM, QUOTE_DENOM}, }; use super::*; @@ -333,7 +333,7 @@ mod tests { env, MessageInfo { sender: sender.clone(), - funds: vec![coin(100, "token0"), coin(100, "token1")], + funds: vec![coin(100, BASE_DENOM), coin(100, QUOTE_DENOM)], }, None, ) 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 a1742694e..66d235439 100644 --- a/smart-contracts/osmosis/contracts/cl-vault/src/vault/range.rs +++ b/smart-contracts/osmosis/contracts/cl-vault/src/vault/range.rs @@ -313,7 +313,9 @@ mod tests { helpers::getters::get_range_admin, math::tick::build_tick_exp_cache, state::{MODIFY_RANGE_STATE, RANGE_ADMIN}, - test_helpers::{mock_deps_with_querier, mock_deps_with_querier_with_balance}, + test_helpers::{ + mock_deps_with_querier, mock_deps_with_querier_with_balance, BASE_DENOM, QUOTE_DENOM, + }, vault::range::requires_swap, }; @@ -368,7 +370,7 @@ mod tests { &info, &[( MOCK_CONTRACT_ADDR, - &[coin(11000, "token0"), coin(11234, "token1")], + &[coin(11000, BASE_DENOM), coin(11234, QUOTE_DENOM)], )], ); @@ -399,7 +401,7 @@ mod tests { .find(|a| { a.key == "token1" }) .unwrap() .value, - "11234token1" + format!("11234{}", QUOTE_DENOM) ); // 10000 withdrawn + 1234 local balance } diff --git a/smart-contracts/osmosis/contracts/cl-vault/src/vault/withdraw.rs b/smart-contracts/osmosis/contracts/cl-vault/src/vault/withdraw.rs index 6a26f44e1..ada3a7762 100644 --- a/smart-contracts/osmosis/contracts/cl-vault/src/vault/withdraw.rs +++ b/smart-contracts/osmosis/contracts/cl-vault/src/vault/withdraw.rs @@ -159,7 +159,10 @@ fn withdraw_msg( #[cfg(test)] mod tests { - use crate::{state::PoolConfig, test_helpers::mock_deps_with_querier_with_balance}; + use crate::{ + state::PoolConfig, + test_helpers::{mock_deps_with_querier_with_balance, BASE_DENOM, QUOTE_DENOM}, + }; use cosmwasm_std::{ testing::{mock_dependencies, mock_env, mock_info, MOCK_CONTRACT_ADDR}, Addr, CosmosMsg, SubMsgResponse, @@ -174,7 +177,7 @@ mod tests { &info, &[( MOCK_CONTRACT_ADDR, - &[coin(2000, "token0"), coin(3000, "token1")], + &[coin(2000, BASE_DENOM), coin(3000, QUOTE_DENOM)], )], ); let env = mock_env();