Skip to content

Commit

Permalink
Merge pull request #90 from AbstractSDK/buckram/abstract-bump
Browse files Browse the repository at this point in the history
Update carrot app to 0.23 abstract
  • Loading branch information
Buckram123 authored Jul 31, 2024
2 parents 7e1e71c + a5e305b commit e4c0796
Show file tree
Hide file tree
Showing 26 changed files with 221 additions and 209 deletions.
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ resolver = "2"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[workspace.dependencies]
cw-orch = "0.20.1"
abstract-app = { version = "0.21.0" }
abstract-interface = { version = "0.21.0" }
abstract-dex-adapter = { git = "https://github.com/abstractsdk/abstract.git", tag = "v0.21.0" }
abstract-client = { version = "0.21.0" }
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-osmosis" }
abstract-client = { version = "0.23.0" }
cw-asset = { version = "3.0" }

[profile.release]
Expand Down
2 changes: 1 addition & 1 deletion bot/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "savings-bot"
version = "0.4.0"
version = "0.5.0"
edition = "2021"
publish = false

Expand Down
4 changes: 2 additions & 2 deletions bot/src/bot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ use std::{
use tonic::transport::Channel;

use abstract_app::{
abstract_core::{ans_host, version_control::ModuleFilter},
abstract_interface::VCQueryFns,
objects::module::{ModuleInfo, ModuleStatus},
std::{ans_host, version_control::ModuleFilter},
};

const VERSION_REQ: &str = ">=0.4, <0.5";
const VERSION_REQ: &str = ">=0.4, <0.6";

const AUTHORIZATION_URLS: &[&str] = &[
MsgCreatePosition::TYPE_URL,
Expand Down
16 changes: 6 additions & 10 deletions bot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use carrot_app::contract::{APP_ID, APP_VERSION};
use cw_orch::{
anyhow,
daemon::{networks::OSMOSIS_1, Daemon},
prelude::*,
tokio::runtime::Runtime,
};

Expand All @@ -21,17 +22,13 @@ use prometheus::Registry;
pub fn cron_main(bot_args: BotArgs) -> anyhow::Result<()> {
let rt = Runtime::new()?;
let registry = Registry::new();
let mut chain_info = OSMOSIS_1;
let grpc_urls = if !bot_args.grps_urls.is_empty() {
bot_args.grps_urls.iter().map(String::as_ref).collect()
} else {
chain_info.grpc_urls.to_vec()
let mut chain_info: ChainInfoOwned = OSMOSIS_1.into();
if !bot_args.grps_urls.is_empty() {
chain_info.grpc_urls = bot_args.grps_urls;
};

chain_info.grpc_urls = &grpc_urls;
let daemon = Daemon::builder()
let daemon = Daemon::builder(chain_info.clone())
.handle(rt.handle())
.chain(chain_info.clone())
.build()?;

let module_info =
Expand Down Expand Up @@ -61,9 +58,8 @@ pub fn cron_main(bot_args: BotArgs) -> anyhow::Result<()> {
std::thread::sleep(bot.autocompound_cooldown);

// Reconnect
bot.daemon = Daemon::builder()
bot.daemon = Daemon::builder(chain_info.clone())
.handle(rt.handle())
.chain(chain_info.clone())
.build()?;
}
}
22 changes: 9 additions & 13 deletions contracts/carrot-app/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "carrot-app"
version = "0.4.0"
version = "0.5.0"
authors = [
"CyberHoward <[email protected]>",
"Adair <[email protected]>",
Expand Down Expand Up @@ -29,12 +29,7 @@ export = []
# enable node-backed tests (ensure Docker is running)
# run with `cargo test --jobs 1 --features node-tests`
node-tests = ["interface"]
interface = [
"export",
"dep:cw-orch",
"abstract-app/interface-macro",
"abstract-dex-adapter/interface",
]
interface = ["export", "dep:cw-orch"]
schema = ["abstract-app/schema"]

[dependencies]
Expand All @@ -48,13 +43,14 @@ schemars = "0.8"
cw-asset = { workspace = true }

abstract-app = { workspace = true }
abstract-sdk = { version = "0.21.0", features = ["stargate"] }
# Dependencies for interface
abstract-dex-adapter = { workspace = true, features = ["osmosis"] }
cw-orch = { workspace = true, optional = true }

osmosis-std = { version = "0.21.0" }
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"] }

[dev-dependencies]
abstract-interface = { workspace = true, features = ["daemon"] }
Expand All @@ -63,12 +59,12 @@ prost = { version = "0.12.3" }
prost-types = { version = "0.12.3" }
log = { version = "0.4.20" }
carrot-app = { path = ".", features = ["interface"] }
abstract-testing = { version = "0.21.0" }
abstract-client = { version = "0.21.0" }
abstract-sdk = { version = "0.21.0", features = ["test-utils"] }
abstract-client = { workspace = true }
abstract-app = { workspace = true, features = ["test-utils"] }
speculoos = "0.11.0"
semver = "1.0"
dotenv = "0.15.0"
env_logger = "0.10.0"
cw-orch = { workspace = true, features = ["osmosis-test-tube"] }
cw-orch = { workspace = true }
cw-orch-osmosis-test-tube = "0.3.0"
clap = { version = "4.3.7", features = ["derive"] }
5 changes: 1 addition & 4 deletions contracts/carrot-app/examples/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ fn main() -> anyhow::Result<()> {
env_logger::init();
let chain = OSMOSIS_1;
let rt = Runtime::new()?;
let daemon = DaemonBuilder::default()
.chain(chain)
.handle(rt.handle())
.build()?;
let daemon = DaemonBuilder::new(chain).handle(rt.handle()).build()?;

let abstr = abstract_client::AbstractClient::new(daemon)?;

Expand Down
41 changes: 19 additions & 22 deletions contracts/carrot-app/examples/install_savings_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ use cw_orch::{
prelude::Stargate,
tokio::runtime::Runtime,
};
use cw_orch_osmosis_test_tube::osmosis_test_tube::osmosis_std::types::cosmos::authz::v1beta1::MsgGrantResponse;
use dotenv::dotenv;

use carrot_app::{
msg::{AppInstantiateMsg, CreatePositionMessage},
state::AutocompoundRewardsConfig,
};
use osmosis_std::types::cosmos::authz::v1beta1::MsgGrantResponse;

pub struct CarrotAppInitData {
pub pool_id: u64,
Expand All @@ -35,16 +35,13 @@ fn main() -> anyhow::Result<()> {
env_logger::init();
let chain = OSMOSIS_1;
let rt = Runtime::new()?;
let daemon = DaemonBuilder::default()
.chain(chain)
.handle(rt.handle())
.build()?;
let daemon = DaemonBuilder::new(chain).handle(rt.handle()).build()?;

let client = AbstractClient::new(daemon.clone())?;
let next_local_account_id = client.next_local_account_id()?;
let random_account_id = client.random_account_id()?;

let savings_app_addr = client.module_instantiate2_address::<carrot_app::AppInterface<Daemon>>(
&AccountId::local(next_local_account_id),
&AccountId::local(random_account_id),
)?;

let funds = vec![Coin {
Expand Down Expand Up @@ -175,14 +172,14 @@ mod utils {
module::{ModuleInfo, ModuleVersion},
AccountId,
};
use abstract_app::std::{account_factory, manager::ModuleInstallConfig};
use abstract_client::*;
use abstract_dex_adapter::DEX_ADAPTER_ID;
use abstract_interface::Abstract;
use abstract_sdk::core::{account_factory, manager::ModuleInstallConfig};
use carrot_app::contract::{APP_ID, APP_VERSION};
use cosmwasm_std::{to_json_binary, to_json_vec};
use cw_orch::{environment::CwEnv, prelude::*};
use osmosis_std::types::{
use cw_orch_osmosis_test_tube::osmosis_test_tube::osmosis_std::types::{
cosmos::{
authz::v1beta1::{GenericAuthorization, Grant, MsgGrant},
bank::v1beta1::SendAuthorization,
Expand Down Expand Up @@ -219,30 +216,30 @@ mod utils {
]
.map(ToOwned::to_owned);
let savings_app_addr: String = savings_app_addr.into();
let granter = chain.sender().to_string();
let granter = chain.sender_addr().to_string();
let grantee = savings_app_addr.clone();

let reward_denom = client
.name_service()
.resolve(&AssetEntry::new(REWARD_ASSET))?;

let mut dex_spend_limit = vec![
cw_orch::osmosis_test_tube::osmosis_test_tube::osmosis_std::types::cosmos::base::v1beta1::Coin {
cw_orch_osmosis_test_tube::osmosis_test_tube::osmosis_std::types::cosmos::base::v1beta1::Coin {
denom: app_data.denom0.to_string(),
amount: LOTS.to_string(),
},
cw_orch::osmosis_test_tube::osmosis_test_tube::osmosis_std::types::cosmos::base::v1beta1::Coin {
cw_orch_osmosis_test_tube::osmosis_test_tube::osmosis_std::types::cosmos::base::v1beta1::Coin {
denom: app_data.denom1.to_string(),
amount: LOTS.to_string(),
},
cw_orch::osmosis_test_tube::osmosis_test_tube::osmosis_std::types::cosmos::base::v1beta1::Coin {
cw_orch_osmosis_test_tube::osmosis_test_tube::osmosis_std::types::cosmos::base::v1beta1::Coin {
denom: reward_denom.to_string(),
amount: LOTS.to_string(),
}];
dex_spend_limit.sort_unstable_by(|a, b| a.denom.cmp(&b.denom));
let dex_fee_authorization = Any {
value: MsgGrant {
granter: chain.sender().to_string(),
granter: chain.sender_addr().to_string(),
grantee: grantee.clone(),
grant: Some(Grant {
authorization: Some(
Expand Down Expand Up @@ -285,16 +282,16 @@ mod utils {
let chain = client.environment();
let abstr = Abstract::load_from(chain.clone())?;
let account_factory_addr = abstr.account_factory.addr_str()?;
let next_local_account_id = client.next_local_account_id()?;
let random_account_id = client.random_account_id()?;

let msg = Any {
type_url: MsgExecuteContract::TYPE_URL.to_owned(),
value: MsgExecuteContract {
sender: chain.sender().to_string(),
sender: chain.sender_addr().to_string(),
contract: account_factory_addr.to_string(),
msg: to_json_vec(&account_factory::ExecuteMsg::CreateAccount {
governance: GovernanceDetails::Monarchy {
monarch: chain.sender().to_string(),
monarch: chain.sender_addr().to_string(),
},
name: "bob".to_owned(),
description: None,
Expand All @@ -319,7 +316,7 @@ mod utils {
Some(to_json_binary(&init_msg)?),
),
],
account_id: Some(AccountId::local(next_local_account_id)),
account_id: Some(AccountId::local(random_account_id)),
})?,
funds: vec![],
}
Expand All @@ -334,14 +331,14 @@ mod utils {
init_msg: AppInstantiateMsg,
) -> anyhow::Result<Any> {
let chain = client.environment();
let next_local_account_id = client.next_local_account_id()?;
let random_account_id = client.random_account_id()?;

let msg = Any {
type_url: MsgExecuteContract::TYPE_URL.to_owned(),
value: MsgExecuteContract {
sender: chain.sender().to_string(),
sender: chain.sender_addr().to_string(),
contract: account.manager()?.to_string(),
msg: to_json_vec(&abstract_sdk::core::manager::ExecuteMsg::CreateSubAccount {
msg: to_json_vec(&abstract_app::std::manager::ExecuteMsg::CreateSubAccount {
name: "deep-adventurous-afternoon".to_owned(),
description: None,
link: None,
Expand All @@ -365,7 +362,7 @@ mod utils {
Some(to_json_binary(&init_msg)?),
),
],
account_id: Some(next_local_account_id),
account_id: Some(random_account_id),
})?,
funds: vec![],
}
Expand Down
10 changes: 5 additions & 5 deletions contracts/carrot-app/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use abstract_app::abstract_core::objects::dependency::StaticDependency;
use abstract_app::std::objects::dependency::StaticDependency;
use abstract_app::AppContract;
use cosmwasm_std::Response;

Expand Down Expand Up @@ -58,16 +58,16 @@ impl<Chain: cw_orch::environment::CwEnv> abstract_app::abstract_interface::Depen
fn dependency_install_configs(
_configuration: Self::DependenciesConfig,
) -> Result<
Vec<abstract_app::abstract_core::manager::ModuleInstallConfig>,
Vec<abstract_app::std::manager::ModuleInstallConfig>,
abstract_app::abstract_interface::AbstractInterfaceError,
> {
let dex_dependency_install_configs: Vec<abstract_app::abstract_core::manager::ModuleInstallConfig> =
let dex_dependency_install_configs: Vec<abstract_app::std::manager::ModuleInstallConfig> =
<abstract_dex_adapter::interface::DexAdapter<Chain> as abstract_app::abstract_interface::DependencyCreation>::dependency_install_configs(
cosmwasm_std::Empty {},
)?;

let adapter_install_config = abstract_app::abstract_core::manager::ModuleInstallConfig::new(
abstract_app::abstract_core::objects::module::ModuleInfo::from_id(
let adapter_install_config = abstract_app::std::manager::ModuleInstallConfig::new(
abstract_app::std::objects::module::ModuleInfo::from_id(
abstract_dex_adapter::DEX_ADAPTER_ID,
abstract_dex_adapter::contract::CONTRACT_VERSION.into(),
)?,
Expand Down
4 changes: 2 additions & 2 deletions contracts/carrot-app/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use abstract_app::abstract_sdk::AbstractSdkError;
use abstract_app::sdk::AbstractSdkError;
use abstract_app::AppError as AbstractAppError;
use abstract_app::{abstract_core::AbstractError, objects::ans_host::AnsHostError};
use abstract_app::{objects::ans_host::AnsHostError, std::AbstractError};
use cosmwasm_std::{Coin, ConversionOverflowError, Decimal, StdError};
use cw_asset::{AssetError, AssetInfo};
use cw_controllers::AdminError;
Expand Down
18 changes: 11 additions & 7 deletions contracts/carrot-app/src/handlers/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ use crate::{
TEMP_WITHDRAW_TO_ASSET,
},
};
use abstract_app::abstract_sdk::AuthZInterface;
use abstract_app::{abstract_sdk::features::AbstractResponse, objects::AnsAsset};
use abstract_app::{
objects::AnsAsset,
sdk::{
features::{AbstractNameService, AbstractResponse},
AuthZ, AuthZInterface, Resolve,
},
};
use abstract_dex_adapter::DexInterface;
use abstract_sdk::{features::AbstractNameService, Resolve};
use cosmwasm_std::{
to_json_binary, Addr, Coin, CosmosMsg, Decimal, Decimal256, Deps, DepsMut, Env, MessageInfo,
SubMsg, Uint128, Uint256, Uint64, WasmMsg,
Expand Down Expand Up @@ -83,9 +87,9 @@ fn update_config(
if let Some(new_rewards_config) = autocompound_rewards_config {
// Validate rewards config first
let ans = app.name_service(deps.as_ref());
let asset_pairing_resp: Vec<abstract_sdk::core::ans_host::AssetPairingMapEntry> = ans
let asset_pairing_resp: Vec<abstract_app::std::ans_host::AssetPairingMapEntry> = ans
.pool_list(
Some(abstract_sdk::core::ans_host::AssetPairingFilter {
Some(abstract_app::std::ans_host::AssetPairingFilter {
asset_pair: Some((
new_rewards_config.gas_asset.clone(),
new_rewards_config.swap_asset.clone(),
Expand Down Expand Up @@ -340,7 +344,7 @@ fn _inner_claim_rewards(
env: &Env,
carrot_position: CarrotPosition,
user: Addr,
authz: abstract_sdk::AuthZ,
authz: AuthZ,
) -> AppResult<(Vec<CosmosMsg>, cosmwasm_std::Coins)> {
let mut rewards = cosmwasm_std::Coins::default();
let mut collect_rewards_msgs = vec![];
Expand Down Expand Up @@ -386,7 +390,7 @@ fn _inner_withdraw(
amount: Option<Uint256>,
carrot_position: CarrotPosition,
user: Addr,
authz: abstract_sdk::AuthZ,
authz: AuthZ,
) -> AppResult<(CosmosMsg, Uint256, Uint256, [Coin; 2])> {
let position_details = carrot_position.position.position.unwrap();
let total_liquidity: Decimal256 = position_details.liquidity.parse()?;
Expand Down
4 changes: 2 additions & 2 deletions contracts/carrot-app/src/handlers/instantiate.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use abstract_app::abstract_core::ans_host::{AssetPairingFilter, AssetPairingMapEntry};
use abstract_app::abstract_sdk::{features::AbstractNameService, AbstractResponse};
use abstract_app::sdk::{features::AbstractNameService, AbstractResponse};
use abstract_app::std::ans_host::{AssetPairingFilter, AssetPairingMapEntry};
use cosmwasm_std::{DepsMut, Env, MessageInfo};
use cw_asset::AssetInfo;
use osmosis_std::types::osmosis::{
Expand Down
2 changes: 1 addition & 1 deletion contracts/carrot-app/src/handlers/migrate.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use abstract_app::{abstract_sdk::AbstractResponse, objects::AssetEntry};
use abstract_app::{objects::AssetEntry, sdk::AbstractResponse};
use cosmwasm_schema::cw_serde;
use cosmwasm_std::{DepsMut, Env, Uint64};
use cw_storage_plus::Item;
Expand Down
2 changes: 1 addition & 1 deletion contracts/carrot-app/src/handlers/query.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use abstract_app::{
abstract_core::objects::AnsAsset,
std::objects::AnsAsset,
traits::{AbstractNameService, Resolve},
};
use abstract_dex_adapter::DexInterface;
Expand Down
Loading

0 comments on commit e4c0796

Please sign in to comment.