diff --git a/Cargo.toml b/Cargo.toml index cd7a1bd..9219524 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,12 +4,15 @@ resolver = "2" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [workspace.dependencies] -cw-orch = "0.24.0" -abstract-app = { version = "0.23.0" } -abstract-interface = { version = "0.23.0" } -abstract-dex-adapter = { git = "https://github.com/abstractsdk/abstract.git", tag = "v0.23.0-dex-adapter" } -abstract-client = { version = "0.23.0" } -cw-asset = { version = "3.0" } +cw-orch = { version = "0.27.0" } +abstract-app = { version = "0.24.1" } +abstract-adapter = { version = "0.24.1" } +abstract-interface = { version = "0.24.1" } +abstract-dex-adapter = { git = "https://github.com/abstractsdk/abstract.git", branch = "main", default-features = false } +abstract-osmosis-adapter = { git = "https://github.com/abstractsdk/abstract.git", branch = "main" } +abstract-client = { version = "0.24.1" } +cw-asset = { version = "4.0" } +cw-orch-osmosis-test-tube = { version = "0.4.0" } [profile.release] rpath = false @@ -21,3 +24,15 @@ debug-assertions = false codegen-units = 1 panic = 'abort' incremental = false + +[patch.crates-io] +abstract-app = { git = "https://github.com/abstractsdk/abstract.git", branch = "artifacts/0.24.x" } +abstract-adapter = { git = "https://github.com/abstractsdk/abstract.git", branch = "artifacts/0.24.x" } +abstract-interface = { git = "https://github.com/abstractsdk/abstract.git", branch = "artifacts/0.24.x" } +abstract-client = { git = "https://github.com/abstractsdk/abstract.git", branch = "artifacts/0.24.x" } +abstract-dex-standard = { git = "https://github.com/abstractsdk/abstract.git", branch = "artifacts/0.24.x" } +abstract-std = { git = "https://github.com/abstractsdk/abstract.git", branch = "artifacts/0.24.x" } +abstract-sdk = { git = "https://github.com/abstractsdk/abstract.git", branch = "artifacts/0.24.x" } +abstract-adapter-utils = { git = "https://github.com/abstractsdk/abstract.git", branch = "artifacts/0.24.x" } +# abstract-osmosis-adapter = { git = "https://github.com/abstractsdk/abstract.git", branch = "artifacts/0.24.x" } +# abstract-dex-adapter = { git = "https://github.com/abstractsdk/abstract.git", branch = "artifacts/0.24.x" } # Replace to tag tag = "v0.25.0" } diff --git a/bot/Cargo.toml b/bot/Cargo.toml index c5d1eb0..4875683 100644 --- a/bot/Cargo.toml +++ b/bot/Cargo.toml @@ -12,13 +12,13 @@ path = "src/bin/local.rs" cw-orch = { workspace = true, features = ["daemon"] } abstract-app = { workspace = true } abstract-client = { workspace = true } -cosmwasm-std = { version = "1.2" } -osmosis-std = { version = "0.21.0" } -cosmos-sdk-proto = { version = "0.20.0" } +cosmwasm-std = { version = "2.0" } +osmosis-std = { version = "0.26.0" } +cosmos-sdk-proto = { version = "0.24.0", features = ["cosmwasm"] } dotenv = "0.15.0" env_logger = "0.11.2" log = "0.4.20" -tonic = "0.10.0" +tonic = "0.12.3" carrot-app = { path = "../contracts/carrot-app", features = ["interface"] } clap = { version = "4", features = ["derive"] } humantime = "2.1.0" diff --git a/bot/src/bot.rs b/bot/src/bot.rs index ba23366..12ae333 100644 --- a/bot/src/bot.rs +++ b/bot/src/bot.rs @@ -43,9 +43,9 @@ use std::{ use tonic::transport::Channel; use abstract_app::{ - abstract_interface::VCQueryFns, + abstract_interface::RegistryQueryFns, objects::module::{ModuleInfo, ModuleStatus}, - std::{ans_host, version_control::ModuleFilter}, + std::{ans_host, registry::ModuleFilter}, }; const LAST_INCOMPATIBLE_VERSION: &str = "0.3.1"; @@ -330,7 +330,7 @@ fn autocompound_instance( } mod utils { - use abstract_app::std::version_control::ModulesListResponse; + use abstract_app::std::registry::ModulesListResponse; use cosmos_sdk_proto::{ cosmos::base::query::v1beta1::{PageRequest, PageResponse}, cosmwasm::wasm::v1::QueryContractsByCodeResponse, @@ -395,7 +395,7 @@ mod utils { ) -> anyhow::Result { let daemon = abstr.environment(); - let account = abstr.account_from(AccountSource::App(Addr::unchecked(contract_addr)))?; + let account = abstr.fetch_account(AccountSource::App(Addr::unchecked(contract_addr)))?; let granter = account.owner()?; // Check if authz is indeed given @@ -407,8 +407,8 @@ mod utils { .block_on(async { authz_querier ._grants( - granter.to_string(), - authz_grantee.clone(), + &granter, + &Addr::unchecked(authz_grantee), // Get every authorization "".to_owned(), None, @@ -496,7 +496,7 @@ mod utils { }); let mut module_list = ModulesListResponse { modules: vec![] }; loop { - let saving_modules = abstr.version_control().module_list( + let saving_modules = abstr.registry().module_list( Some(ModuleFilter { namespace: Some(module_info.namespace.to_string()), name: Some(module_info.name.clone()), diff --git a/contracts/carrot-app/Cargo.toml b/contracts/carrot-app/Cargo.toml index d4f557d..e798d95 100644 --- a/contracts/carrot-app/Cargo.toml +++ b/contracts/carrot-app/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "carrot-app" -version = "0.5.1" +version = "0.6.0" authors = [ "CyberHoward ", "Adair ", @@ -33,38 +33,35 @@ interface = ["export", "dep:cw-orch"] schema = ["abstract-app/schema"] [dependencies] -cw-utils = { version = "1.0.3" } -cosmwasm-std = { version = "1.2" } -cosmwasm-schema = { version = "1.2" } -cw-controllers = { version = "1.0.1" } -cw-storage-plus = "1.2.0" +cw-utils = { version = "2.0.0" } +cosmwasm-std = { version = "2.0" } +cosmwasm-schema = { version = "2.0" } +cw-controllers = { version = "2.0.0" } +cw-storage-plus = { version = "2.0.0" } thiserror = { version = "1.0.50" } schemars = "0.8" cw-asset = { workspace = true } -abstract-app = { workspace = true } +abstract-app = { workspace = true, features = ["stargate"] } # Dependencies for interface -abstract-dex-adapter = { workspace = true, features = ["osmosis"] } +abstract-dex-adapter = { workspace = true, features = [ +], default-features = false } cw-orch = { workspace = true, optional = true } -osmosis-std = { version = "0.25.0" } -prost = { version = "0.12.3" } -# TODO: just to enable "stargate" on abstract-app remove, see ABS-480 -abstract-sdk = { version = "0.23.0", features = ["stargate"] } +osmosis-std = { version = "0.26.0" } +prost = { version = "0.13.1" } [dev-dependencies] abstract-interface = { workspace = true, features = ["daemon"] } -prost = { version = "0.12.3" } -prost-types = { version = "0.12.3" } +prost-types = { version = "0.13.1" } log = { version = "0.4.20" } carrot-app = { path = ".", features = ["interface"] } abstract-client = { workspace = true } -abstract-app = { workspace = true, features = ["test-utils"] } -speculoos = "0.11.0" +abstract-app = { workspace = true, features = ["test-utils", "stargate"] } semver = "1.0" dotenv = "0.15.0" env_logger = "0.10.0" -cw-orch = { workspace = true } -cw-orch-osmosis-test-tube = "0.3.0" +cw-orch = { workspace = true, features = ["daemon"] } +cw-orch-osmosis-test-tube = { workspace = true } clap = { version = "4.3.7", features = ["derive"] } diff --git a/contracts/carrot-app/examples/deploy.rs b/contracts/carrot-app/examples/deploy.rs index 12340fb..e7fb745 100644 --- a/contracts/carrot-app/examples/deploy.rs +++ b/contracts/carrot-app/examples/deploy.rs @@ -19,10 +19,12 @@ fn main() -> anyhow::Result<()> { let abstr = abstract_client::AbstractClient::new(daemon)?; let publisher = abstr - .publisher_builder(Namespace::new(ABSTRACT_NAMESPACE)?) - .build()?; + .fetch_or_build_account(Namespace::new(ABSTRACT_NAMESPACE)?, |builder| { + builder.namespace(Namespace::new(ABSTRACT_NAMESPACE).unwrap()) + })? + .publisher()?; publisher.publish_app::>()?; - abstr.version_control().approve_any_abstract_modules()?; + abstr.registry().approve_any_abstract_modules()?; Ok(()) } diff --git a/contracts/carrot-app/examples/install_savings_app.rs b/contracts/carrot-app/examples/install_savings_app.rs index 661783d..440344a 100644 --- a/contracts/carrot-app/examples/install_savings_app.rs +++ b/contracts/carrot-app/examples/install_savings_app.rs @@ -6,7 +6,6 @@ use cw_orch::{ anyhow, daemon::{networks::OSMOSIS_1, Daemon, DaemonBuilder}, prelude::Stargate, - tokio::runtime::Runtime, }; use cw_orch_osmosis_test_tube::osmosis_test_tube::osmosis_std::types::cosmos::authz::v1beta1::MsgGrantResponse; use dotenv::dotenv; @@ -34,8 +33,7 @@ fn main() -> anyhow::Result<()> { dotenv().ok(); env_logger::init(); let chain = OSMOSIS_1; - let rt = Runtime::new()?; - let daemon = DaemonBuilder::new(chain).handle(rt.handle()).build()?; + let daemon = DaemonBuilder::new(chain).build()?; let client = AbstractClient::new(daemon.clone())?; let random_account_id = client.random_account_id()?; @@ -78,7 +76,7 @@ fn main() -> anyhow::Result<()> { let create_sub_account_message = utils::create_account_message(&client, init_msg)?; msgs.push(create_sub_account_message); - let _ = daemon.commit_any::(msgs, None)?; + let _ = daemon.commit_any(msgs, None)?; Ok(()) } @@ -168,11 +166,14 @@ mod utils { pub const LOTS: u128 = 100_000_000_000_000; pub const REWARD_ASSET: &str = "osmosis>osmo"; - use abstract_app::objects::{ - module::{ModuleInfo, ModuleVersion}, - AccountId, + use abstract_app::std::account::ModuleInstallConfig; + use abstract_app::{ + objects::{ + module::{ModuleInfo, ModuleVersion}, + salt, AccountId, + }, + std::account, }; - use abstract_app::std::{account_factory, manager::ModuleInstallConfig}; use abstract_client::*; use abstract_dex_adapter::DEX_ADAPTER_ID; use abstract_interface::Abstract; @@ -184,7 +185,7 @@ mod utils { authz::v1beta1::{GenericAuthorization, Grant, MsgGrant}, bank::v1beta1::SendAuthorization, }, - cosmwasm::wasm::v1::MsgExecuteContract, + cosmwasm::wasm::v1::{MsgExecuteContract, MsgInstantiateContract2}, osmosis::{ concentratedliquidity::v1beta1::{ MsgAddToPosition, MsgCollectIncentives, MsgCollectSpreadRewards, MsgCreatePosition, @@ -202,8 +203,8 @@ mod utils { savings_app_addr: impl Into, app_data: &CarrotAppInitData, ) -> Result, anyhow::Error> { - let dex_fee_account = client.account_from(AccountId::local(0))?; - let dex_fee_addr = dex_fee_account.proxy()?.to_string(); + let dex_fee_account = client.fetch_account(AccountId::local(0))?; + let dex_fee_addr = dex_fee_account.address()?.to_string(); let chain = client.environment().clone(); let authorization_urls = [ @@ -281,22 +282,32 @@ mod utils { ) -> anyhow::Result { let chain = client.environment(); let abstr = Abstract::load_from(chain.clone())?; - let account_factory_addr = abstr.account_factory.addr_str()?; let random_account_id = client.random_account_id()?; + let salt = salt::generate_instantiate_salt(&AccountId::local(random_account_id)); + let code_id = abstr.account_code_id()?; + let creator = chain.sender_addr().to_string(); + + let account_address = chain.wasm_querier().instantiate2_addr( + code_id, + &Addr::unchecked(creator.clone()), + salt.clone(), + )?; let msg = Any { - type_url: MsgExecuteContract::TYPE_URL.to_owned(), - value: MsgExecuteContract { - sender: chain.sender_addr().to_string(), - contract: account_factory_addr.to_string(), - msg: to_json_vec(&account_factory::ExecuteMsg::CreateAccount { - governance: GovernanceDetails::Monarchy { + type_url: MsgInstantiateContract2::TYPE_URL.to_owned(), + value: MsgInstantiateContract2 { + sender: creator, + admin: account_address, + code_id, + label: "Abstract Account".to_owned(), + msg: to_json_vec(&account::InstantiateMsg:: { + code_id, + owner: GovernanceDetails::Monarchy { monarch: chain.sender_addr().to_string(), }, - name: "bob".to_owned(), + name: Some("bob".to_owned()), description: None, link: None, - base_asset: None, namespace: None, install_modules: vec![ ModuleInstallConfig::new( @@ -317,8 +328,11 @@ mod utils { ), ], account_id: Some(AccountId::local(random_account_id)), + authenticator: None, })?, funds: vec![], + salt: salt.to_vec(), + fix_msg: false, } .to_proto_bytes(), }; @@ -337,33 +351,34 @@ mod utils { type_url: MsgExecuteContract::TYPE_URL.to_owned(), value: MsgExecuteContract { sender: chain.sender_addr().to_string(), - contract: account.manager()?.to_string(), - msg: to_json_vec(&abstract_app::std::manager::ExecuteMsg::CreateSubAccount { - name: "deep-adventurous-afternoon".to_owned(), - description: None, - link: None, - base_asset: None, - namespace: None, - install_modules: vec![ - ModuleInstallConfig::new( - ModuleInfo::from_id( - DEX_ADAPTER_ID, - ModuleVersion::Version( - abstract_dex_adapter::contract::CONTRACT_VERSION.to_owned(), - ), - )?, - None, - ), - ModuleInstallConfig::new( - ModuleInfo::from_id( - APP_ID, - ModuleVersion::Version(APP_VERSION.to_owned()), - )?, - Some(to_json_binary(&init_msg)?), - ), - ], - account_id: Some(random_account_id), - })?, + contract: account.address()?.to_string(), + msg: to_json_vec( + &abstract_app::std::account::ExecuteMsg::::CreateSubAccount { + name: Some("deep-adventurous-afternoon".to_owned()), + description: None, + link: None, + namespace: None, + install_modules: vec![ + ModuleInstallConfig::new( + ModuleInfo::from_id( + DEX_ADAPTER_ID, + ModuleVersion::Version( + abstract_dex_adapter::contract::CONTRACT_VERSION.to_owned(), + ), + )?, + None, + ), + ModuleInstallConfig::new( + ModuleInfo::from_id( + APP_ID, + ModuleVersion::Version(APP_VERSION.to_owned()), + )?, + Some(to_json_binary(&init_msg)?), + ), + ], + account_id: Some(random_account_id), + }, + )?, funds: vec![], } .to_proto_bytes(), diff --git a/contracts/carrot-app/src/contract.rs b/contracts/carrot-app/src/contract.rs index 8186b1c..763824e 100644 --- a/contracts/carrot-app/src/contract.rs +++ b/contracts/carrot-app/src/contract.rs @@ -58,15 +58,15 @@ impl abstract_app::abstract_interface::Depen fn dependency_install_configs( _configuration: Self::DependenciesConfig, ) -> Result< - Vec, + Vec, abstract_app::abstract_interface::AbstractInterfaceError, > { - let dex_dependency_install_configs: Vec = + let dex_dependency_install_configs: Vec = as abstract_app::abstract_interface::DependencyCreation>::dependency_install_configs( cosmwasm_std::Empty {}, )?; - let adapter_install_config = abstract_app::std::manager::ModuleInstallConfig::new( + let adapter_install_config = abstract_app::std::account::ModuleInstallConfig::new( abstract_app::std::objects::module::ModuleInfo::from_id( abstract_dex_adapter::DEX_ADAPTER_ID, abstract_dex_adapter::contract::CONTRACT_VERSION.into(), diff --git a/contracts/carrot-app/src/handlers/execute.rs b/contracts/carrot-app/src/handlers/execute.rs index 82be0d4..8ee3fab 100644 --- a/contracts/carrot-app/src/handlers/execute.rs +++ b/contracts/carrot-app/src/handlers/execute.rs @@ -128,7 +128,7 @@ fn create_position( app: App, create_position_msg: CreatePositionMessage, ) -> AppResult { - app.admin.assert_admin(deps.as_ref(), &info.sender)?; + app.admin.assert_admin(deps.as_ref(), &env, &info.sender)?; // Check if there is already saved position if CarrotPosition::may_load(deps.as_ref())?.is_some() { return Err(AppError::PositionExists {}); @@ -156,7 +156,7 @@ fn deposit( ) -> AppResult { // Only the admin (manager contracts or account owner) + the smart contract can deposit app.admin - .assert_admin(deps.as_ref(), &info.sender) + .assert_admin(deps.as_ref(), &env, &info.sender) .or(assert_contract(&info, &env))?; let carrot_position = CarrotPosition::load(deps.as_ref())?; @@ -208,7 +208,7 @@ fn withdraw( app: App, ) -> AppResult { // Only the authorized addresses (admin ?) can withdraw - app.admin.assert_admin(deps.as_ref(), &info.sender)?; + app.admin.assert_admin(deps.as_ref(), &env, &info.sender)?; let carrot_position = CarrotPosition::load(deps.as_ref())?; // Get app's user and set up authz. @@ -324,7 +324,7 @@ fn autocompound(deps: DepsMut, env: Env, info: MessageInfo, app: App) -> AppResu .add_message(msg_deposit); // If called by non-admin and reward cooldown has ended, send rewards to the contract caller. - if !app.admin.is_admin(deps.as_ref(), &info.sender)? && compound_status.is_ready() { + if !app.admin.is_admin(deps.as_ref(), &env, &info.sender)? && compound_status.is_ready() { let executor_reward_messages = autocompound_executor_rewards( deps.as_ref(), &env, @@ -533,7 +533,7 @@ pub fn autocompound_executor_rewards( // If not enough gas coins - swap for some amount if user_gas_balance < rewards_config.min_gas_balance { // Get asset entries - let dex = app.ans_dex(deps, OSMOSIS.to_string()); + let dex = app.ans_dex(deps, env, OSMOSIS.to_string()); // Do reverse swap to find approximate amount we need to swap let need_gas_coins = rewards_config.max_gas_balance - user_gas_balance; diff --git a/contracts/carrot-app/src/handlers/query.rs b/contracts/carrot-app/src/handlers/query.rs index ef242e4..96d4485 100644 --- a/contracts/carrot-app/src/handlers/query.rs +++ b/contracts/carrot-app/src/handlers/query.rs @@ -59,7 +59,7 @@ fn query_compound_status(deps: Deps, env: Env, app: &App) -> AppResult AppResult { pub fn query_price( deps: Deps, + env: &Env, funds: &[Coin], app: &App, max_spread: Option, @@ -154,7 +155,7 @@ pub fn query_price( // We take the biggest amount and simulate a swap for the corresponding asset let price = if amount0 > amount1 { - let simulation_result = app.ans_dex(deps, OSMOSIS.to_string()).simulate_swap( + let simulation_result = app.ans_dex(deps, env, OSMOSIS.to_string()).simulate_swap( AnsAsset::new(config.pool_config.asset0, amount0), config.pool_config.asset1, )?; @@ -168,7 +169,7 @@ pub fn query_price( } price } else { - let simulation_result = app.ans_dex(deps, OSMOSIS.to_string()).simulate_swap( + let simulation_result = app.ans_dex(deps, env, OSMOSIS.to_string()).simulate_swap( AnsAsset::new(config.pool_config.asset1, amount1), config.pool_config.asset0, )?; diff --git a/contracts/carrot-app/src/handlers/swap_helpers.rs b/contracts/carrot-app/src/handlers/swap_helpers.rs index 312e4c5..3281cc6 100644 --- a/contracts/carrot-app/src/handlers/swap_helpers.rs +++ b/contracts/carrot-app/src/handlers/swap_helpers.rs @@ -45,7 +45,7 @@ pub(crate) fn swap_msg( } let sender = get_user(deps, app)?; - let dex = app.ans_dex(deps, OSMOSIS.to_string()); + let dex = app.ans_dex(deps, env, OSMOSIS.to_string()); let max_spread = Some(max_spread.unwrap_or(DEFAULT_MAX_SPREAD)); let trigger_swap_msg: GenerateMessagesResponse = dex.generate_swap_messages(offer_asset, ask_asset, max_spread, None, sender.clone())?; @@ -106,7 +106,7 @@ pub(crate) fn tokens_to_swap( let (offer_asset, ask_asset, assets_for_position) = if x0_a1 < x1_a0 { let numerator = x1_a0 - x0_a1; - let denominator = asset0.amount + price * asset1.amount; + let denominator = asset0.amount + asset1.amount.mul_floor(price); let y1 = numerator / denominator; ( @@ -114,7 +114,7 @@ pub(crate) fn tokens_to_swap( config.pool_config.asset0, AssetsForPosition { asset0: Coin { - amount: x0.amount + price * y1, + amount: x0.amount + y1.mul_floor(price), denom: x0.denom, }, asset1: Coin { @@ -125,8 +125,8 @@ pub(crate) fn tokens_to_swap( ) } else { let numerator = x0_a1 - x1_a0; - let denominator = - asset1.amount + Decimal::from_ratio(asset0.amount, 1u128) / price * Uint128::one(); + let denominator = asset1.amount + + Uint128::one().mul_floor(Decimal::from_ratio(asset0.amount, 1u128) / price); let y0 = numerator / denominator; ( @@ -138,7 +138,8 @@ pub(crate) fn tokens_to_swap( denom: x0.denom, }, asset1: Coin { - amount: x1.amount + Decimal::from_ratio(y0, 1u128) / price * Uint128::one(), + amount: x1.amount + + Uint128::one().mul_floor(Decimal::from_ratio(y0, 1u128) / price), denom: x1.denom, }, }, @@ -160,7 +161,15 @@ pub fn swap_to_enter_position( belief_price0: Option, belief_price1: Option, ) -> AppResult<(Vec, AssetsForPosition)> { - let price = query_price(deps, &funds, app, max_spread, belief_price0, belief_price1)?; + let price = query_price( + deps, + env, + &funds, + app, + max_spread, + belief_price0, + belief_price1, + )?; let (offer_asset, ask_asset, assets_for_position) = tokens_to_swap(deps, funds, asset0, asset1, price)?; @@ -322,7 +331,8 @@ mod tests { 5_000 - 5_000 * amount1 / (amount1 - + (Decimal::from_ratio(amount0, 1u128) / price * Uint128::one()).u128()), + + (Uint128::one().mul_floor(Decimal::from_ratio(amount0, 1u128) / price)) + .u128()), ); assert_eq!(swap.name, AssetEntry::new(TOKEN1)); assert_eq!(ask_asset, AssetEntry::new(TOKEN0)); @@ -348,7 +358,9 @@ mod tests { assert_eq!(ask_asset, AssetEntry::new(TOKEN1)); assert_eq!( 10_000 - swap.amount.u128(), - 4_000 + (Decimal::from_ratio(swap.amount, 1u128) / price * Uint128::one()).u128() + 4_000 + + (Uint128::one().mul_floor(Decimal::from_ratio(swap.amount, 1u128) / price)) + .u128() ); } } diff --git a/contracts/carrot-app/src/replies/add_to_position.rs b/contracts/carrot-app/src/replies/add_to_position.rs index 11fa9df..8463f4e 100644 --- a/contracts/carrot-app/src/replies/add_to_position.rs +++ b/contracts/carrot-app/src/replies/add_to_position.rs @@ -9,7 +9,9 @@ use crate::{ }; pub fn add_to_position_reply(deps: DepsMut, env: Env, app: App, reply: Reply) -> AppResult { - let SubMsgResult::Ok(SubMsgResponse { data: Some(b), .. }) = reply.result else { + #[allow(deprecated)] + let SubMsgResult::Ok(SubMsgResponse { data: Some(b), .. }) = reply.result + else { return Err(AppError::Std(StdError::generic_err( "Failed to create position", ))); diff --git a/contracts/carrot-app/src/replies/create_position.rs b/contracts/carrot-app/src/replies/create_position.rs index eeda843..8182ec6 100644 --- a/contracts/carrot-app/src/replies/create_position.rs +++ b/contracts/carrot-app/src/replies/create_position.rs @@ -9,7 +9,9 @@ use crate::{ }; pub fn create_position_reply(deps: DepsMut, env: Env, app: App, reply: Reply) -> AppResult { - let SubMsgResult::Ok(SubMsgResponse { data: Some(b), .. }) = reply.result else { + #[allow(deprecated)] + let SubMsgResult::Ok(SubMsgResponse { data: Some(b), .. }) = reply.result + else { return Err(AppError::Std(StdError::generic_err( "Failed to create position", ))); diff --git a/contracts/carrot-app/src/replies/withdraw_to_asset.rs b/contracts/carrot-app/src/replies/withdraw_to_asset.rs index fa968d2..6c80a57 100644 --- a/contracts/carrot-app/src/replies/withdraw_to_asset.rs +++ b/contracts/carrot-app/src/replies/withdraw_to_asset.rs @@ -10,7 +10,9 @@ use crate::{ }; pub fn withdraw_to_asset_reply(deps: DepsMut, env: Env, app: App, reply: Reply) -> AppResult { - let SubMsgResult::Ok(SubMsgResponse { data: Some(b), .. }) = reply.result else { + #[allow(deprecated)] + let SubMsgResult::Ok(SubMsgResponse { data: Some(b), .. }) = reply.result + else { return Err(AppError::Std(StdError::generic_err( "Failed to withdraw to asset", ))); diff --git a/contracts/carrot-app/tests/autocompound.rs b/contracts/carrot-app/tests/autocompound.rs index 9a1b8b9..77d58be 100644 --- a/contracts/carrot-app/tests/autocompound.rs +++ b/contracts/carrot-app/tests/autocompound.rs @@ -5,7 +5,7 @@ use crate::common::{ create_position, setup_test_tube, DEX_NAME, GAS_DENOM, LOTS, REWARD_DENOM, USDC, USDC_DENOM, USDT, USDT_DENOM, }; -use abstract_app::abstract_interface::{Abstract, AbstractAccount}; +use abstract_app::abstract_interface::{Abstract, AccountI}; use carrot_app::msg::{ AppExecuteMsgFns, AppQueryMsgFns, AssetsBalanceResponse, CompoundStatus, CompoundStatusResponse, }; @@ -33,7 +33,7 @@ fn check_autocompound() -> anyhow::Result<()> { let mut chain = carrot_app.environment().clone(); chain.add_balance( - chain.sender_addr(), + &chain.sender_addr(), coins(5_000_000, format!("gamm/pool/{pool_id}")), )?; @@ -81,9 +81,9 @@ fn check_autocompound() -> anyhow::Result<()> { let dex: abstract_dex_adapter::interface::DexAdapter<_> = carrot_app.module()?; let abs = Abstract::load_from(chain.clone())?; let account_id = carrot_app.account().id()?; - let account = AbstractAccount::new(&abs, account_id); + let account = AccountI::load_from(&abs, account_id)?; chain.bank_send( - account.proxy.addr_str()?, + account.addr_str()?, vec![ coin(200_000, USDC_DENOM.to_owned()), coin(200_000, USDT_DENOM.to_owned()), @@ -119,12 +119,12 @@ fn check_autocompound() -> anyhow::Result<()> { let balance_before_autocompound: AssetsBalanceResponse = carrot_app.balance()?; let balance_usdc_before_autocompound = chain .bank_querier() - .balance(chain.sender_addr(), Some(USDC_DENOM.to_owned()))? + .balance(&chain.sender_addr(), Some(USDC_DENOM.to_owned()))? .pop() .unwrap(); let balance_usdt_before_autocompound = chain .bank_querier() - .balance(chain.sender_addr(), Some(USDT_DENOM.to_owned()))? + .balance(&chain.sender_addr(), Some(USDT_DENOM.to_owned()))? .pop() .unwrap(); @@ -136,12 +136,12 @@ fn check_autocompound() -> anyhow::Result<()> { let balance_after_autocompound: AssetsBalanceResponse = carrot_app.balance().unwrap(); let balance_usdc_after_autocompound = chain .bank_querier() - .balance(chain.sender_addr(), Some(USDC_DENOM.to_owned()))? + .balance(&chain.sender_addr(), Some(USDC_DENOM.to_owned()))? .pop() .unwrap(); let balance_usdt_after_autocompound = chain .bank_querier() - .balance(chain.sender_addr(), Some(USDT_DENOM.to_owned()))? + .balance(&chain.sender_addr(), Some(USDT_DENOM.to_owned()))? .pop() .unwrap(); @@ -164,7 +164,7 @@ fn stranger_autocompound() -> anyhow::Result<()> { let mut chain = carrot_app.environment().clone(); chain.add_balance( - chain.sender_addr(), + &chain.sender_addr(), coins(5_000_000, format!("gamm/pool/{pool_id}")), )?; let stranger = chain.init_account(coins(LOTS, GAS_DENOM))?; @@ -212,9 +212,9 @@ fn stranger_autocompound() -> anyhow::Result<()> { let dex: abstract_dex_adapter::interface::DexAdapter<_> = carrot_app.module()?; let abs = Abstract::load_from(chain.clone())?; let account_id = carrot_app.account().id()?; - let account = AbstractAccount::new(&abs, account_id); + let account = AccountI::load_from(&abs, account_id)?; chain.bank_send( - account.proxy.addr_str()?, + account.addr_str()?, vec![ coin(200_000, USDC_DENOM.to_owned()), coin(200_000, USDT_DENOM.to_owned()), @@ -277,7 +277,8 @@ fn stranger_autocompound() -> anyhow::Result<()> { assert!(status.spread_rewards.is_empty()); // Check stranger gets rewarded - let stranger_reward_balance = chain.query_balance(stranger.address().as_str(), REWARD_DENOM)?; + let stranger_reward_balance = + chain.query_balance(&Addr::unchecked(stranger.address()), REWARD_DENOM)?; assert_eq!(stranger_reward_balance, Uint128::new(1000)); Ok(()) } diff --git a/contracts/carrot-app/tests/common.rs b/contracts/carrot-app/tests/common.rs index 04c3a55..1d25f73 100644 --- a/contracts/carrot-app/tests/common.rs +++ b/contracts/carrot-app/tests/common.rs @@ -1,8 +1,9 @@ use std::iter; use abstract_app::objects::module::ModuleInfo; +use abstract_app::objects::namespace::ABSTRACT_NAMESPACE; use abstract_app::std::{ - manager::{self, ModuleInstallConfig}, + account::{self, ModuleInstallConfig}, objects::{pool_id::PoolAddressBase, AccountId, AssetEntry, PoolMetadata, PoolType}, }; use abstract_client::{AbstractClient, Application, Environment, Namespace}; @@ -25,7 +26,7 @@ use cw_orch_osmosis_test_tube::osmosis_test_tube::osmosis_std::types::{ use cw_orch_osmosis_test_tube::osmosis_test_tube::{ osmosis_std::types::{ cosmos::{ - authz::v1beta1::{GenericAuthorization, Grant, MsgGrant, MsgGrantResponse}, + authz::v1beta1::{GenericAuthorization, Grant, MsgGrant}, base::v1beta1, }, osmosis::{ @@ -103,8 +104,10 @@ pub fn deploy( // We deploy the carrot_app let publisher = client - .publisher_builder(Namespace::new("abstract")?) - .build()?; + .fetch_or_build_account(Namespace::new(ABSTRACT_NAMESPACE)?, |builder| { + builder.namespace(Namespace::new(ABSTRACT_NAMESPACE).unwrap()) + })? + .publisher()?; // The dex adapter let dex_adapter = publisher .publish_adapter::<_, abstract_dex_adapter::interface::DexAdapter>( @@ -145,12 +148,11 @@ pub fn deploy( type_url: MsgExecuteContract::TYPE_URL.to_owned(), value: MsgExecuteContract { sender: chain.sender_addr().to_string(), - contract: publisher.account().manager()?.to_string(), - msg: to_json_vec(&manager::ExecuteMsg::CreateSubAccount { - name: "bob".to_owned(), + contract: publisher.account().address()?.to_string(), + msg: to_json_vec(&account::ExecuteMsg::::CreateSubAccount { + name: Some("bob".to_owned()), description: None, link: None, - base_asset: None, namespace: None, install_modules: vec![ ModuleInstallConfig::new(ModuleInfo::from_id_latest(DEX_ADAPTER_ID)?, None), @@ -166,7 +168,7 @@ pub fn deploy( .to_proto_bytes(), }; msgs.push(create_sub_account_message); - let _ = chain.commit_any::(msgs, None)?; + let _ = chain.commit_any(msgs, None)?; // Now get Application struct let account = client.account_from(AccountId::local(random_account_id))?; @@ -186,13 +188,13 @@ pub fn deploy( // We update authorized addresses on the adapter for the app dex_adapter.execute( &abstract_dex_adapter::msg::ExecuteMsg::Base(abstract_app::std::adapter::BaseExecuteMsg { - proxy_address: Some(carrot_app.account().proxy()?.to_string()), + account_address: Some(carrot_app.account().address()?.to_string()), msg: abstract_app::std::adapter::AdapterBaseMsg::UpdateAuthorizedAddresses { to_add: vec![carrot_app.addr_str()?], to_remove: vec![], }, }), - None, + &[], )?; Ok(carrot_app) @@ -216,14 +218,14 @@ pub fn create_position( belief_price1: None, }) .into(), - None, + &[], ) .map_err(Into::into) } pub fn create_pool(mut chain: OsmosisTestTube) -> anyhow::Result<(u64, u64)> { - chain.add_balance(chain.sender_addr(), coins(LOTS, USDC_DENOM))?; - chain.add_balance(chain.sender_addr(), coins(LOTS, USDT_DENOM))?; + chain.add_balance(&chain.sender_addr(), coins(LOTS, USDC_DENOM))?; + chain.add_balance(&chain.sender_addr(), coins(LOTS, USDT_DENOM))?; let asset0 = USDT_DENOM.to_owned(); let asset1 = USDC_DENOM.to_owned(); @@ -249,11 +251,13 @@ pub fn create_pool(mut chain: OsmosisTestTube) -> anyhow::Result<(u64, u64)> { title: "Create concentrated uosmo:usdc pool".to_string(), description: "Create concentrated uosmo:usdc pool, so that we can trade it" .to_string(), + #[allow(deprecated)] pool_records: vec![PoolRecord { denom0: USDT_DENOM.to_owned(), denom1: USDC_DENOM.to_owned(), tick_spacing: TICK_SPACING, spread_factor: Decimal::percent(SPREAD_FACTOR).atomics().to_string(), + exponent_at_price_one: String::default(), }], }, chain.sender_addr().to_string(), @@ -292,15 +296,15 @@ pub fn create_pool(mut chain: OsmosisTestTube) -> anyhow::Result<(u64, u64)> { let gamm = Gamm::new(&*test_tube); let rewards_pool_provider = test_tube.init_account(&[ - Coin::new(1_000_000_000, asset1.clone()), - Coin::new(2_000_000_000, REWARD_DENOM), + Coin::new(1_000_000_000_u128, asset1.clone()), + Coin::new(2_000_000_000_u128, REWARD_DENOM), Coin::new(LOTS, GAS_DENOM), ])?; let gas_pool_response = gamm.create_basic_pool( &[ - Coin::new(1_000_000_000, asset1), - Coin::new(2_000_000_000, REWARD_DENOM), + Coin::new(1_000_000_000_u128, asset1), + Coin::new(2_000_000_000_u128, REWARD_DENOM), ], &rewards_pool_provider, )?; @@ -315,7 +319,7 @@ pub fn setup_test_tube( Application>, )> { let _ = env_logger::builder().is_test(true).try_init(); - let chain = OsmosisTestTube::new(vec![coin(LOTS, GAS_DENOM)]); + let chain = OsmosisTestTube::new(coins(LOTS, GAS_DENOM)); // We create a usdt-usdc pool let (pool_id, gas_pool_id) = create_pool(chain.clone())?; @@ -340,12 +344,12 @@ pub fn setup_test_tube( Ok((pool_id, carrot_app)) } -pub fn give_authorizations_msgs( +pub fn give_authorizations_msgs( client: &AbstractClient, savings_app_addr: impl Into, ) -> Result, anyhow::Error> { - let dex_fee_account = client.account_from(AccountId::local(0))?; - let dex_fee_addr = dex_fee_account.proxy()?.to_string(); + let dex_fee_account = client.fetch_account(AccountId::local(0))?; + let dex_fee_addr = dex_fee_account.address()?.to_string(); let chain = client.environment().clone(); let authorization_urls = [ @@ -417,9 +421,7 @@ pub fn give_authorizations( savings_app_addr: impl Into, ) -> Result<(), anyhow::Error> { let msgs = give_authorizations_msgs(client, savings_app_addr)?; - client - .environment() - .commit_any::(msgs, None)?; + client.environment().commit_any(msgs, None)?; Ok(()) } diff --git a/contracts/carrot-app/tests/deposit_withdraw.rs b/contracts/carrot-app/tests/deposit_withdraw.rs index a7da378..0c636aa 100644 --- a/contracts/carrot-app/tests/deposit_withdraw.rs +++ b/contracts/carrot-app/tests/deposit_withdraw.rs @@ -4,7 +4,7 @@ use std::str::FromStr; use crate::common::{create_position, setup_test_tube, USDC, USDC_DENOM, USDT, USDT_DENOM}; use abstract_app::objects::AssetEntry; -use abstract_interface::{Abstract, AbstractAccount}; +use abstract_interface::{Abstract, AccountI}; use carrot_app::msg::{ AppExecuteMsg, AppExecuteMsgFns, AppQueryMsgFns, AssetsBalanceResponse, CompoundStatus, CreatePositionMessage, PositionResponse, SwapToAsset, @@ -90,12 +90,12 @@ fn withdraw_position() -> anyhow::Result<()> { let balance: AssetsBalanceResponse = carrot_app.balance()?; let balance_usdc_before_withdraw = chain .bank_querier() - .balance(chain.sender_addr(), Some(USDT_DENOM.to_owned()))? + .balance(&chain.sender_addr(), Some(USDT_DENOM.to_owned()))? .pop() .unwrap(); let balance_usdt_before_withdraw = chain .bank_querier() - .balance(chain.sender_addr(), Some(USDC_DENOM.to_owned()))? + .balance(&chain.sender_addr(), Some(USDC_DENOM.to_owned()))? .pop() .unwrap(); @@ -106,12 +106,12 @@ fn withdraw_position() -> anyhow::Result<()> { let balance_usdc_after_half_withdraw = chain .bank_querier() - .balance(chain.sender_addr(), Some(USDT_DENOM.to_owned()))? + .balance(&chain.sender_addr(), Some(USDT_DENOM.to_owned()))? .pop() .unwrap(); let balance_usdt_after_half_withdraw = chain .bank_querier() - .balance(chain.sender_addr(), Some(USDC_DENOM.to_owned()))? + .balance(&chain.sender_addr(), Some(USDC_DENOM.to_owned()))? .pop() .unwrap(); @@ -122,12 +122,12 @@ fn withdraw_position() -> anyhow::Result<()> { carrot_app.withdraw(None, None)?; let balance_usdc_after_full_withdraw = chain .bank_querier() - .balance(chain.sender_addr(), Some(USDT_DENOM.to_owned()))? + .balance(&chain.sender_addr(), Some(USDT_DENOM.to_owned()))? .pop() .unwrap(); let balance_usdt_after_full_withdraw = chain .bank_querier() - .balance(chain.sender_addr(), Some(USDC_DENOM.to_owned()))? + .balance(&chain.sender_addr(), Some(USDC_DENOM.to_owned()))? .pop() .unwrap(); @@ -292,9 +292,9 @@ fn partial_withdraw_position_autoclaims() -> anyhow::Result<()> { let dex: abstract_dex_adapter::interface::DexAdapter<_> = carrot_app.module()?; let abs = Abstract::load_from(chain.clone())?; let account_id = carrot_app.account().id()?; - let account = AbstractAccount::new(&abs, account_id); + let account = AccountI::load_from(&abs, account_id)?; chain.bank_send( - account.proxy.addr_str()?, + account.addr_str()?, vec![ coin(200_000, USDC_DENOM.to_owned()), coin(200_000, USDT_DENOM.to_owned()), @@ -352,9 +352,9 @@ fn manual_partial_withdraw_position_doesnt_autoclaim() -> anyhow::Result<()> { let dex: abstract_dex_adapter::interface::DexAdapter<_> = carrot_app.module()?; let abs = Abstract::load_from(chain.clone())?; let account_id = carrot_app.account().id()?; - let account = AbstractAccount::new(&abs, account_id); + let account = AccountI::load_from(&abs, account_id)?; chain.bank_send( - account.proxy.addr_str()?, + account.addr_str()?, vec![ coin(200_000, USDC_DENOM.to_owned()), coin(200_000, USDT_DENOM.to_owned()), @@ -471,7 +471,7 @@ fn error_on_provided_funds() -> anyhow::Result<()> { belief_price1: None, }) .into(), - Some(&[coin(10, GAS_DENOM)]), + &[coin(10, GAS_DENOM)], ) .expect_err("Should error when funds provided"); Ok(()) @@ -500,10 +500,10 @@ fn withdraw_to_asset() -> anyhow::Result<()> { { let asset0_balance_before = chain .bank_querier() - .balance(chain.sender_addr(), Some(USDT_DENOM.to_owned()))?; + .balance(&chain.sender_addr(), Some(USDT_DENOM.to_owned()))?; let asset1_balance_before = chain .bank_querier() - .balance(chain.sender_addr(), Some(USDC_DENOM.to_owned()))?; + .balance(&chain.sender_addr(), Some(USDC_DENOM.to_owned()))?; carrot_app.withdraw( Some(withdraw_liquidity_amount), @@ -515,10 +515,10 @@ fn withdraw_to_asset() -> anyhow::Result<()> { let asset0_balance_after = chain .bank_querier() - .balance(chain.sender_addr(), Some(USDT_DENOM.to_owned()))?; + .balance(&chain.sender_addr(), Some(USDT_DENOM.to_owned()))?; let asset1_balance_after = chain .bank_querier() - .balance(chain.sender_addr(), Some(USDC_DENOM.to_owned()))?; + .balance(&chain.sender_addr(), Some(USDC_DENOM.to_owned()))?; assert_eq!(asset0_balance_before, asset0_balance_after); assert!( @@ -531,10 +531,10 @@ fn withdraw_to_asset() -> anyhow::Result<()> { { let asset0_balance_before = chain .bank_querier() - .balance(chain.sender_addr(), Some(USDT_DENOM.to_owned()))?; + .balance(&chain.sender_addr(), Some(USDT_DENOM.to_owned()))?; let asset1_balance_before = chain .bank_querier() - .balance(chain.sender_addr(), Some(USDC_DENOM.to_owned()))?; + .balance(&chain.sender_addr(), Some(USDC_DENOM.to_owned()))?; carrot_app.withdraw( Some(withdraw_liquidity_amount), @@ -546,10 +546,10 @@ fn withdraw_to_asset() -> anyhow::Result<()> { let asset0_balance_after = chain .bank_querier() - .balance(chain.sender_addr(), Some(USDT_DENOM.to_owned()))?; + .balance(&chain.sender_addr(), Some(USDT_DENOM.to_owned()))?; let asset1_balance_after = chain .bank_querier() - .balance(chain.sender_addr(), Some(USDC_DENOM.to_owned()))?; + .balance(&chain.sender_addr(), Some(USDC_DENOM.to_owned()))?; assert_eq!(asset1_balance_before, asset1_balance_after); assert!( diff --git a/contracts/carrot-app/tests/recreate_position.rs b/contracts/carrot-app/tests/recreate_position.rs index d6cd3f4..d2deb97 100644 --- a/contracts/carrot-app/tests/recreate_position.rs +++ b/contracts/carrot-app/tests/recreate_position.rs @@ -192,7 +192,7 @@ fn install_on_sub_account() -> anyhow::Result<()> { .install_app_with_dependencies::>( &init_msg, Empty {}, - )? + ) .build()?; let carrot_app = account.application::>()?; @@ -254,7 +254,7 @@ fn install_on_sub_account_create_position_on_install() -> anyhow::Result<()> { .install_app_with_dependencies::>( &init_msg, Empty {}, - )? + ) .build()?; let carrot_app = account.application::>()?;