diff --git a/Cargo.lock b/Cargo.lock index 2a9ef6c5..a3ffbfba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1515,7 +1515,7 @@ dependencies = [ [[package]] name = "stableswap-3pool" -version = "1.2.2" +version = "1.2.3" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -1607,7 +1607,7 @@ dependencies = [ [[package]] name = "terraswap-pair" -version = "1.3.3" +version = "1.3.4" dependencies = [ "anybuf", "cosmwasm-schema", diff --git a/contracts/liquidity_hub/pool-network/stableswap_3pool/Cargo.toml b/contracts/liquidity_hub/pool-network/stableswap_3pool/Cargo.toml index e34a3d56..ff1b9f75 100644 --- a/contracts/liquidity_hub/pool-network/stableswap_3pool/Cargo.toml +++ b/contracts/liquidity_hub/pool-network/stableswap_3pool/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "stableswap-3pool" -version = "1.2.2" +version = "1.2.3" authors = ["Adam J. Weigold "] edition.workspace = true license.workspace = true diff --git a/contracts/liquidity_hub/pool-network/stableswap_3pool/src/commands.rs b/contracts/liquidity_hub/pool-network/stableswap_3pool/src/commands.rs index 60d5ee91..d7bc43a4 100644 --- a/contracts/liquidity_hub/pool-network/stableswap_3pool/src/commands.rs +++ b/contracts/liquidity_hub/pool-network/stableswap_3pool/src/commands.rs @@ -31,7 +31,7 @@ use white_whale_std::pool_network::trio::{Config, Cw20HookMsg, FeatureToggle, Po use crate::error::ContractError; use crate::helpers; -use crate::helpers::{get_protocol_fee_for_asset, get_total_share, has_factory_token}; +use crate::helpers::{get_protocol_fee_for_asset, get_total_share}; use crate::stableswap_math::curve::StableSwap; use crate::state::{ store_fee, ALL_TIME_BURNED_FEES, ALL_TIME_COLLECTED_PROTOCOL_FEES, COLLECTED_PROTOCOL_FEES, @@ -567,20 +567,6 @@ pub fn update_config( if let Some(pool_fees) = pool_fees { pool_fees.is_valid()?; - - let trio_info_raw: TrioInfoRaw = TRIO_INFO.load(deps.storage)?; - - if has_factory_token( - &trio_info_raw - .asset_infos - .into_iter() - .map(|raw| raw.to_normal(deps.api).unwrap()) - .collect::>(), - ) && pool_fees.burn_fee.share > Decimal::zero() - { - return Err(ContractError::TokenFactoryAssetBurnDisabled {}); - } - config.pool_fees = pool_fees; } diff --git a/contracts/liquidity_hub/pool-network/stableswap_3pool/src/contract.rs b/contracts/liquidity_hub/pool-network/stableswap_3pool/src/contract.rs index 0fbe7930..ae632ced 100644 --- a/contracts/liquidity_hub/pool-network/stableswap_3pool/src/contract.rs +++ b/contracts/liquidity_hub/pool-network/stableswap_3pool/src/contract.rs @@ -1,8 +1,7 @@ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - to_json_binary, Binary, Decimal, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdError, - StdResult, + to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdError, StdResult, }; use cw2::{get_contract_version, set_contract_version}; use protobuf::Message; @@ -15,7 +14,6 @@ use white_whale_std::pool_network::trio::{ use crate::error::ContractError; use crate::error::ContractError::MigrateInvalidVersion; -use crate::helpers::has_factory_token; use crate::response::MsgInstantiateContractResponse; use crate::state::{ ALL_TIME_BURNED_FEES, ALL_TIME_COLLECTED_PROTOCOL_FEES, COLLECTED_PROTOCOL_FEES, CONFIG, @@ -47,10 +45,6 @@ pub fn instantiate( ) -> Result { set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - if has_factory_token(&msg.asset_infos) && msg.pool_fees.burn_fee.share > Decimal::zero() { - return Err(ContractError::TokenFactoryAssetBurnDisabled {}); - } - let trio_info: &TrioInfoRaw = &TrioInfoRaw { contract_addr: deps.api.addr_canonicalize(env.contract.address.as_str())?, liquidity_token: AssetInfoRaw::NativeToken { diff --git a/contracts/liquidity_hub/pool-network/stableswap_3pool/src/error.rs b/contracts/liquidity_hub/pool-network/stableswap_3pool/src/error.rs index 7a93ab0e..c3b3375a 100644 --- a/contracts/liquidity_hub/pool-network/stableswap_3pool/src/error.rs +++ b/contracts/liquidity_hub/pool-network/stableswap_3pool/src/error.rs @@ -43,9 +43,6 @@ pub enum ContractError { #[error("Failed to compute the LP share with the given deposit")] LiquidityShareComputation {}, - #[error("Burn fee is not allowed when using factory tokens")] - TokenFactoryAssetBurnDisabled {}, - #[error("The token factory feature is not enabled")] TokenFactoryNotEnabled {}, } diff --git a/contracts/liquidity_hub/pool-network/stableswap_3pool/src/helpers.rs b/contracts/liquidity_hub/pool-network/stableswap_3pool/src/helpers.rs index 7e1455d4..35ec7614 100644 --- a/contracts/liquidity_hub/pool-network/stableswap_3pool/src/helpers.rs +++ b/contracts/liquidity_hub/pool-network/stableswap_3pool/src/helpers.rs @@ -12,7 +12,13 @@ use cw_storage_plus::Item; feature = "injective" ))] use cosmwasm_std::CosmosMsg; -use white_whale_std::pool_network::asset::{is_factory_token, Asset, AssetInfo, AssetInfoRaw}; +#[cfg(any( + feature = "token_factory", + feature = "osmosis_token_factory", + feature = "injective" +))] +use white_whale_std::pool_network::asset::is_factory_token; +use white_whale_std::pool_network::asset::{Asset, AssetInfo, AssetInfoRaw}; #[cfg(feature = "token_factory")] use white_whale_std::pool_network::denom::MsgCreateDenom; #[cfg(feature = "injective")] @@ -300,15 +306,6 @@ pub fn get_total_share(deps: &Deps, liquidity_token: String) -> StdResult bool { - assets.iter().any(|asset| match asset { - AssetInfo::Token { .. } => false, - AssetInfo::NativeToken { denom } => is_factory_token(denom), - }) -} - /// Creates a new LP token for this pool pub fn create_lp_token( deps: DepsMut, diff --git a/contracts/liquidity_hub/pool-network/stableswap_3pool/src/tests/testing.rs b/contracts/liquidity_hub/pool-network/stableswap_3pool/src/tests/testing.rs index 9e2f66f1..c96dc98a 100644 --- a/contracts/liquidity_hub/pool-network/stableswap_3pool/src/tests/testing.rs +++ b/contracts/liquidity_hub/pool-network/stableswap_3pool/src/tests/testing.rs @@ -204,134 +204,6 @@ fn proper_initialization_tokenfactory_lp() { ); } -#[cfg(feature = "token_factory")] -#[test] -fn intialize_with_burnable_token_factory_asset() { - let mut deps = mock_dependencies(&[]); - - deps.querier.with_token_balances(&[ - ( - &"asset0000".to_string(), - &[(&MOCK_CONTRACT_ADDR.to_string(), &Uint128::from(123u128))], - ), - ( - &"asset0001".to_string(), - &[(&MOCK_CONTRACT_ADDR.to_string(), &Uint128::from(456u128))], - ), - ]); - - let msg = InstantiateMsg { - asset_infos: [ - AssetInfo::NativeToken { - denom: "factory/migaloo1436kxs0w2es6xlqpp9rd35e3d0cjnw4sv8j3a7483sgks29jqwgshqdky4/ampWHALE".to_string(), - }, - AssetInfo::Token { - contract_addr: "asset0000".to_string(), - }, - AssetInfo::Token { - contract_addr: "asset0001".to_string(), - }, - ], - token_code_id: 10u64, - asset_decimals: [6u8, 8u8, 10u8], - pool_fees: PoolFee { - protocol_fee: Fee { - share: Decimal::percent(1u64), - }, - swap_fee: Fee { - share: Decimal::percent(1u64), - }, - burn_fee: Fee { - share: Decimal::zero(), - }, - }, - fee_collector_addr: "collector".to_string(), - amp_factor: 1000, - token_factory_lp: true, - }; - - // we can just call .unwrap() to assert this was a success - let env = mock_env(); - let info = mock_info("addr0000", &[]); - let res = instantiate(deps.as_mut(), env.clone(), info.clone(), msg).unwrap(); - - let expected = >::into(MsgCreateDenom { - sender: MOCK_CONTRACT_ADDR.to_string(), - subdenom: LP_SYMBOL.to_string(), - }); - - assert_eq!(res.messages[0].msg, expected); - - // let's try to increase the burn fee. It should fail - let update_config_message = UpdateConfig { - owner: None, - fee_collector_addr: None, - pool_fees: Some(PoolFee { - protocol_fee: Fee { - share: Decimal::percent(1u64), - }, - swap_fee: Fee { - share: Decimal::percent(1u64), - }, - burn_fee: Fee { - share: Decimal::percent(1u64), - }, - }), - feature_toggle: None, - amp_factor: None, - }; - - let res = execute( - deps.as_mut(), - env.clone(), - info.clone(), - update_config_message, - ); - match res { - Ok(_) => panic!("Expected error, ContractError::TokenFactoryAssetBurnDisabled"), - Err(ContractError::TokenFactoryAssetBurnDisabled {}) => (), - _ => panic!("Expected error, ContractError::TokenFactoryAssetBurnDisabled"), - } - - // now let's try instantiating the contract with burning fees, it should fail - let msg = InstantiateMsg { - asset_infos: [ - AssetInfo::NativeToken { - denom: "factory/migaloo1436kxs0w2es6xlqpp9rd35e3d0cjnw4sv8j3a7483sgks29jqwgshqdky4/ampWHALE".to_string(), - }, - AssetInfo::Token { - contract_addr: "asset0000".to_string(), - }, - AssetInfo::Token { - contract_addr: "asset0001".to_string(), - }, - ], - token_code_id: 10u64, - asset_decimals: [6u8, 8u8, 10u8], - pool_fees: PoolFee { - protocol_fee: Fee { - share: Decimal::percent(1u64), - }, - swap_fee: Fee { - share: Decimal::percent(1u64), - }, - burn_fee: Fee { - share: Decimal::percent(1u64), - }, - }, - fee_collector_addr: "collector".to_string(), - amp_factor: 1000, - token_factory_lp: true, - }; - - let res = instantiate(deps.as_mut(), env, info, msg); - match res { - Ok(_) => panic!("Expected error, ContractError::TokenFactoryAssetBurnDisabled"), - Err(ContractError::TokenFactoryAssetBurnDisabled {}) => (), - _ => panic!("Expected error, ContractError::TokenFactoryAssetBurnDisabled"), - } -} - #[cfg(not(feature = "osmosis"))] #[test] fn test_initialization_invalid_fees() { diff --git a/contracts/liquidity_hub/pool-network/terraswap_pair/Cargo.toml b/contracts/liquidity_hub/pool-network/terraswap_pair/Cargo.toml index 79e7ecf9..ac22fbb7 100644 --- a/contracts/liquidity_hub/pool-network/terraswap_pair/Cargo.toml +++ b/contracts/liquidity_hub/pool-network/terraswap_pair/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "terraswap-pair" -version = "1.3.3" +version = "1.3.4" authors = [ "Terraform Labs, PTE.", "DELIGHT LABS", diff --git a/contracts/liquidity_hub/pool-network/terraswap_pair/src/commands.rs b/contracts/liquidity_hub/pool-network/terraswap_pair/src/commands.rs index ea441663..0c781848 100644 --- a/contracts/liquidity_hub/pool-network/terraswap_pair/src/commands.rs +++ b/contracts/liquidity_hub/pool-network/terraswap_pair/src/commands.rs @@ -19,8 +19,7 @@ use cw20::{Cw20ExecuteMsg, Cw20ReceiveMsg}; ))] use white_whale_std::pool_network::asset::is_factory_token; use white_whale_std::pool_network::asset::{ - get_total_share, has_factory_token, Asset, AssetInfo, AssetInfoRaw, PairInfoRaw, - MINIMUM_LIQUIDITY_AMOUNT, + get_total_share, Asset, AssetInfo, AssetInfoRaw, PairInfoRaw, MINIMUM_LIQUIDITY_AMOUNT, }; #[cfg(feature = "token_factory")] use white_whale_std::pool_network::denom::{Coin, MsgBurn, MsgMint}; @@ -565,20 +564,6 @@ pub fn update_config( if let Some(pool_fees) = pool_fees { pool_fees.is_valid()?; - - let pair_info_raw = PAIR_INFO.load(deps.storage)?; - - if has_factory_token( - &pair_info_raw - .asset_infos - .into_iter() - .map(|raw| raw.to_normal(deps.api).unwrap()) - .collect::>(), - ) && pool_fees.burn_fee.share > Decimal::zero() - { - return Err(ContractError::TokenFactoryAssetBurnDisabled {}); - } - config.pool_fees = pool_fees; } diff --git a/contracts/liquidity_hub/pool-network/terraswap_pair/src/contract.rs b/contracts/liquidity_hub/pool-network/terraswap_pair/src/contract.rs index 865437bd..d4cdcbe1 100644 --- a/contracts/liquidity_hub/pool-network/terraswap_pair/src/contract.rs +++ b/contracts/liquidity_hub/pool-network/terraswap_pair/src/contract.rs @@ -1,14 +1,13 @@ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - to_json_binary, Binary, Decimal, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdError, - StdResult, + to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdError, StdResult, }; use cw2::{get_contract_version, set_contract_version}; use protobuf::Message; use semver::Version; -use white_whale_std::pool_network::asset::{has_factory_token, AssetInfoRaw, PairInfoRaw}; +use white_whale_std::pool_network::asset::{AssetInfoRaw, PairInfoRaw}; use white_whale_std::pool_network::pair::{ Config, ExecuteMsg, FeatureToggle, InstantiateMsg, MigrateMsg, QueryMsg, }; @@ -36,10 +35,6 @@ pub fn instantiate( ) -> Result { set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - if has_factory_token(&msg.asset_infos) && msg.pool_fees.burn_fee.share > Decimal::zero() { - return Err(ContractError::TokenFactoryAssetBurnDisabled {}); - } - let pair_info: &PairInfoRaw = &PairInfoRaw { contract_addr: deps.api.addr_canonicalize(env.contract.address.as_str())?, liquidity_token: AssetInfoRaw::NativeToken { diff --git a/contracts/liquidity_hub/pool-network/terraswap_pair/src/error.rs b/contracts/liquidity_hub/pool-network/terraswap_pair/src/error.rs index 22a97034..6a28fd9d 100644 --- a/contracts/liquidity_hub/pool-network/terraswap_pair/src/error.rs +++ b/contracts/liquidity_hub/pool-network/terraswap_pair/src/error.rs @@ -67,9 +67,6 @@ pub enum ContractError { #[error("An overflow occurred when attempting to construct a decimal")] DecimalOverflow {}, - #[error("Burn fee is not allowed when using factory tokens")] - TokenFactoryAssetBurnDisabled {}, - #[error("The token factory feature is not enabled")] TokenFactoryNotEnabled {}, } diff --git a/contracts/liquidity_hub/pool-network/terraswap_pair/src/tests/testing.rs b/contracts/liquidity_hub/pool-network/terraswap_pair/src/tests/testing.rs index 68a3d7c3..1f5735ba 100644 --- a/contracts/liquidity_hub/pool-network/terraswap_pair/src/tests/testing.rs +++ b/contracts/liquidity_hub/pool-network/terraswap_pair/src/tests/testing.rs @@ -186,121 +186,6 @@ fn proper_initialization_token_factory_lp() { ); } -#[cfg(feature = "token_factory")] -#[test] -fn intialize_with_burnable_token_factory_asset() { - let mut deps = mock_dependencies(&[]); - - deps.querier.with_token_balances(&[( - &"asset0000".to_string(), - &[(&MOCK_CONTRACT_ADDR.to_string(), &Uint128::from(123u128))], - )]); - - let msg = InstantiateMsg { - asset_infos: [ - AssetInfo::NativeToken { - denom: "factory/migaloo1436kxs0w2es6xlqpp9rd35e3d0cjnw4sv8j3a7483sgks29jqwgshqdky4/ampWHALE".to_string(), - }, - AssetInfo::Token { - contract_addr: "asset0000".to_string(), - }, - ], - token_code_id: 10u64, - asset_decimals: [6u8, 8u8], - pool_fees: PoolFee { - protocol_fee: Fee { - share: Decimal::percent(1u64), - }, - swap_fee: Fee { - share: Decimal::percent(1u64), - }, - burn_fee: Fee { - share: Decimal::zero(), - }, - }, - fee_collector_addr: "collector".to_string(), - pair_type: PairType::ConstantProduct, - token_factory_lp: true, - }; - - // we can just call .unwrap() to assert this was a success - let env = mock_env(); - let info = mock_info("addr0000", &[]); - let res = instantiate(deps.as_mut(), env.clone(), info.clone(), msg).unwrap(); - - let expected = >::into(MsgCreateDenom { - sender: MOCK_CONTRACT_ADDR.to_string(), - subdenom: LP_SYMBOL.to_string(), - }); - - assert_eq!(res.messages[0].msg, expected); - - // let's try to increase the burn fee. It should fail - let update_config_message = UpdateConfig { - owner: None, - fee_collector_addr: None, - pool_fees: Some(PoolFee { - protocol_fee: Fee { - share: Decimal::percent(1u64), - }, - swap_fee: Fee { - share: Decimal::percent(1u64), - }, - burn_fee: Fee { - share: Decimal::percent(1u64), - }, - }), - feature_toggle: None, - }; - - let res = execute( - deps.as_mut(), - env.clone(), - info.clone(), - update_config_message, - ); - match res { - Ok(_) => panic!("Expected error, ContractError::TokenFactoryAssetBurnDisabled"), - Err(ContractError::TokenFactoryAssetBurnDisabled {}) => (), - _ => panic!("Expected error, ContractError::TokenFactoryAssetBurnDisabled"), - } - - // now let's try instantiating the contract with burning fees, it should fail - let msg = InstantiateMsg { - asset_infos: [ - AssetInfo::NativeToken { - denom: "factory/migaloo1436kxs0w2es6xlqpp9rd35e3d0cjnw4sv8j3a7483sgks29jqwgshqdky4/ampWHALE".to_string(), - }, - AssetInfo::Token { - contract_addr: "asset0000".to_string(), - }, - ], - token_code_id: 10u64, - asset_decimals: [6u8, 8u8], - pool_fees: PoolFee { - protocol_fee: Fee { - share: Decimal::percent(1u64), - }, - swap_fee: Fee { - share: Decimal::percent(1u64), - }, - burn_fee: Fee { - share: Decimal::percent(1u64), - }, - }, - fee_collector_addr: "collector".to_string(), - pair_type: PairType::ConstantProduct, - token_factory_lp: true, - }; - - let res = instantiate(deps.as_mut(), env, info, msg); - match res { - Ok(_) => panic!("Expected error, ContractError::TokenFactoryAssetBurnDisabled"), - Err(ContractError::TokenFactoryAssetBurnDisabled {}) => (), - _ => panic!("Expected error, ContractError::TokenFactoryAssetBurnDisabled"), - } -} - #[cfg(not(feature = "osmosis"))] #[test] fn test_initialization_invalid_fees() {