Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2 #38

Draft
wants to merge 43 commits into
base: mainv2
Choose a base branch
from
Draft

V2 #38

Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
839cc6e
Started running tests
Kayanski Mar 22, 2024
3f28a97
Restored
Kayanski Mar 22, 2024
023f3f0
Handle multiple osmosis pool positions
Kayanski Mar 26, 2024
fb12617
Add autocompound'
Kayanski Mar 26, 2024
d1cfce1
Rationalized exchange rate
Kayanski Mar 26, 2024
3b8b374
nits
Kayanski Mar 26, 2024
9c8d8f2
Added params to help deposit
Kayanski Mar 26, 2024
467433d
nits
CyberHoward Mar 27, 2024
ac021d9
rename expected_tokens to asset_distribution
CyberHoward Mar 27, 2024
458cca4
Added current status
Kayanski Mar 27, 2024
37f8772
Incorporated money market
Kayanski Mar 27, 2024
fa554c7
optimize strategy query
CyberHoward Mar 28, 2024
fb38a09
Added internal messages, and better strategy checks
Kayanski Mar 28, 2024
39477b8
Merge
Kayanski Mar 28, 2024
97e65bc
Check
Kayanski Mar 28, 2024
8ff3e5e
Deposit refactor
Kayanski Mar 28, 2024
54a0cb6
Fix auto-compounding and test checks
Kayanski Mar 28, 2024
619e8c1
Added smart deposit
Kayanski Mar 28, 2024
e5ff15b
More structure
Kayanski Mar 29, 2024
a266725
Added inbalance test
Kayanski Mar 29, 2024
904e0c4
Added rebalance and tests
Kayanski Apr 3, 2024
615842e
Added checked and unchecked features
Kayanski Apr 4, 2024
1babe2f
Checks on config
Kayanski Apr 4, 2024
a142f88
Moved checks
Kayanski Apr 5, 2024
656ad28
Added deposit preview
Kayanski Apr 5, 2024
7fe855f
Added release profile
Kayanski Apr 8, 2024
7f1f75b
Nots
Kayanski Apr 8, 2024
eb326a3
error rename
Kayanski Apr 8, 2024
2085369
Migrate Msg to struct
Kayanski Apr 8, 2024
6903c1a
Fixed instantiate and dependencies
Kayanski Apr 11, 2024
2414e21
Added localnet tests
Kayanski Apr 11, 2024
3de860b
Gas optimizations
Kayanski Apr 11, 2024
2499025
Simplify further yield source impls
Kayanski Apr 11, 2024
2f716d2
Rename yield type
Kayanski Apr 11, 2024
b21d38e
Extend gas tests
Kayanski Apr 15, 2024
1c3a970
UPdated estimates
Kayanski Apr 15, 2024
b9b508c
Added withdraw preview and removed useless deposit operation
Kayanski Apr 15, 2024
13c1c76
Added update strategy preview
Kayanski Apr 15, 2024
adca153
Removed usless import
Kayanski Apr 15, 2024
6e75065
Corrected tests
Kayanski Apr 17, 2024
ea38f9c
Updated autocompound process
Kayanski Apr 19, 2024
c300a49
Fix autocompound test
Kayanski Apr 19, 2024
923d49a
Changed autocompound strartegy on bot
Kayanski Apr 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,28 @@ resolver = "2"

[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-money-market-adapter = { git = "https://github.com/abstractsdk/abstract.git" }
abstract-money-market-standard = { git = "https://github.com/abstractsdk/abstract.git" }
abstract-client = { version = "0.21.0" }
abstract-testing = { version = "0.21.0" }
abstract-sdk = { version = "0.21.0", features = ["stargate"] }


[patch.crates-io]
# This is included to avoid recompinling too much
osmosis-test-tube = { path = "../test-tube/packages/osmosis-test-tube" }


# This was added to account for the fix data forwaring in the proxy contract + moneymarket adapter
abstract-app = { git = "https://github.com/abstractsdk/abstract.git" }
abstract-adapter = { git = "https://github.com/abstractsdk/abstract.git" }
abstract-adapter-utils = { git = "https://github.com/abstractsdk/abstract.git" }
abstract-interface = { git = "https://github.com/abstractsdk/abstract.git" }
abstract-client = { git = "https://github.com/abstractsdk/abstract.git" }
abstract-testing = { git = "https://github.com/abstractsdk/abstract.git" }
abstract-core = { git = "https://github.com/abstractsdk/abstract.git" }
abstract-sdk = { git = "https://github.com/abstractsdk/abstract.git" }
2 changes: 1 addition & 1 deletion bot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ abstract-client = { workspace = true }
osmosis-std = { version = "0.21.0" }
cosmos-sdk-proto = { version = "0.20.0" }
dotenv = "0.15.0"
env_logger = "0.11.2"
env_logger = { version = "0.11.3", default-features = false }
log = "0.4.20"
tonic = "0.10.0"
carrot-app = { path = "../contracts/carrot-app", features = ["interface"] }
Expand Down
17 changes: 12 additions & 5 deletions contracts/carrot-app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ interface = [
"dep:cw-orch",
"abstract-app/interface-macro",
"abstract-dex-adapter/interface",
"abstract-money-market-adapter/interface",
]
schema = ["abstract-app/schema"]

Expand All @@ -48,10 +49,13 @@ schemars = "0.8"
cw-asset = { version = "3.0" }

abstract-app = { workspace = true }
abstract-sdk = { version = "0.21.0", features = ["stargate"] }
abstract-sdk = { workspace = true }

# Dependencies for interface
abstract-dex-adapter = { workspace = true, features = ["osmosis"] }
abstract-money-market-adapter = { workspace = true, features = ["mars"] }
cw-orch = { workspace = true, optional = true }
abstract-money-market-standard = { workspace = true }

osmosis-std = { version = "0.21.0" }
prost = { version = "0.12.3" }
Expand All @@ -63,12 +67,15 @@ 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-testing = { workspace = true }
abstract-client = { workspace = true }
abstract-sdk = { workspace = true, features = ["test-utils"] }

# For cw-optimizoor
env_logger = { version = "0.11.3", default-features = false }

speculoos = "0.11.0"
semver = "1.0"
dotenv = "0.15.0"
env_logger = "0.10.0"
cw-orch = { workspace = true, features = ["osmosis-test-tube"] }
clap = { version = "4.3.7", features = ["derive"] }
127 changes: 25 additions & 102 deletions contracts/carrot-app/examples/install_savings_app.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(unused)]
use abstract_app::objects::{AccountId, AssetEntry};
use abstract_client::AbstractClient;
use cosmwasm_std::{Coin, Uint128, Uint256, Uint64};
use cosmwasm_std::{coins, Coin, Uint128, Uint256, Uint64};
use cw_orch::{
anyhow,
daemon::{networks::OSMOSIS_1, Daemon, DaemonBuilder},
Expand All @@ -11,8 +11,14 @@ use cw_orch::{
use dotenv::dotenv;

use carrot_app::{
msg::{AppInstantiateMsg, CreatePositionMessage},
state::AutocompoundRewardsConfig,
autocompound::{
AutocompoundConfig, AutocompoundConfigBase, AutocompoundRewardsConfig,
AutocompoundRewardsConfigBase,
},
contract::OSMOSIS,
msg::AppInstantiateMsg,
state::ConfigBase,
yield_sources::{BalanceStrategy, BalanceStrategyBase},
};
use osmosis_std::types::cosmos::authz::v1beta1::MsgGrantResponse;

Expand Down Expand Up @@ -54,29 +60,24 @@ fn main() -> anyhow::Result<()> {

let app_data = usdc_usdc_ax::app_data(funds, 100_000_000_000_000, 100_000_000_000_000);

// Give all authzs and create subaccount with app in single tx
let mut msgs = utils::give_authorizations_msgs(&client, savings_app_addr, &app_data)?;

let mut msgs = vec![];
let init_msg = AppInstantiateMsg {
pool_id: app_data.pool_id,
autocompound_cooldown_seconds: Uint64::new(AUTOCOMPOUND_COOLDOWN_SECONDS),
autocompound_rewards_config: AutocompoundRewardsConfig {
gas_asset: AssetEntry::new(utils::REWARD_ASSET),
swap_asset: app_data.swap_asset,
reward: Uint128::new(50_000),
min_gas_balance: Uint128::new(1000000),
max_gas_balance: Uint128::new(3000000),
config: ConfigBase {
autocompound_config: AutocompoundConfigBase {
cooldown_seconds: Uint64::new(AUTOCOMPOUND_COOLDOWN_SECONDS),
rewards: AutocompoundRewardsConfigBase {
gas_asset: AssetEntry::new(utils::REWARD_ASSET),
swap_asset: app_data.swap_asset,
reward: Uint128::new(50_000),
min_gas_balance: Uint128::new(1000000),
max_gas_balance: Uint128::new(3000000),
_phantom: std::marker::PhantomData,
},
},
balance_strategy: BalanceStrategyBase(vec![]),
dex: OSMOSIS.to_string(),
},
create_position: Some(CreatePositionMessage {
lower_tick: app_data.lower_tick,
upper_tick: app_data.upper_tick,
funds: app_data.funds,
asset0: app_data.asset0,
asset1: app_data.asset1,
max_spread: None,
belief_price0: None,
belief_price1: None,
}),
deposit: Some(coins(100, "usdc")),
};
let create_sub_account_message = utils::create_account_message(&client, init_msg)?;

Expand Down Expand Up @@ -200,84 +201,6 @@ mod utils {
use prost_types::Any;
use std::iter;

pub fn give_authorizations_msgs<Chain: CwEnv + Stargate>(
client: &AbstractClient<Chain>,
savings_app_addr: impl Into<String>,
app_data: &CarrotAppInitData,
) -> Result<Vec<Any>, anyhow::Error> {
let dex_fee_account = client.account_from(AccountId::local(0))?;
let dex_fee_addr = dex_fee_account.proxy()?.to_string();
let chain = client.environment().clone();

let authorization_urls = [
MsgCreatePosition::TYPE_URL,
MsgSwapExactAmountIn::TYPE_URL,
MsgAddToPosition::TYPE_URL,
MsgWithdrawPosition::TYPE_URL,
MsgCollectIncentives::TYPE_URL,
MsgCollectSpreadRewards::TYPE_URL,
]
.map(ToOwned::to_owned);
let savings_app_addr: String = savings_app_addr.into();
let granter = chain.sender().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 {
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 {
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 {
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(),
grantee: grantee.clone(),
grant: Some(Grant {
authorization: Some(
SendAuthorization {
spend_limit: dex_spend_limit,
allow_list: vec![dex_fee_addr, savings_app_addr],
}
.to_any(),
),
expiration: None,
}),
}
.encode_to_vec(),
type_url: MsgGrant::TYPE_URL.to_owned(),
};

let msgs: Vec<Any> = authorization_urls
.into_iter()
.map(|msg| Any {
value: MsgGrant {
granter: granter.clone(),
grantee: grantee.clone(),
grant: Some(Grant {
authorization: Some(GenericAuthorization { msg }.to_any()),
expiration: None,
}),
}
.encode_to_vec(),
type_url: MsgGrant::TYPE_URL.to_owned(),
})
.chain(iter::once(dex_fee_authorization))
.collect();
Ok(msgs)
}

pub fn create_account_message<Chain: CwEnv>(
client: &AbstractClient<Chain>,
init_msg: AppInstantiateMsg,
Expand Down
Loading
Loading