Skip to content

Commit

Permalink
Switched to quasar app
Browse files Browse the repository at this point in the history
  • Loading branch information
Kayanski committed Jan 17, 2024
1 parent 7b4412b commit c5098fd
Show file tree
Hide file tree
Showing 23 changed files with 33 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,17 @@ abstract-dex-adapter = { git = "https://github.com/abstractsdk/abstract", branch

abstract-interface = { git = "https://github.com/abstractsdk/abstract", branch = "cw-orch-authz/patch", optional = true }
cw-orch = { version = "0.19.1", optional = true }
# cl-vault = { git = "https://github.com/abstractsdk/quasar", version = "0.1.0", features = [
# "library",
# ] }
cl-vault = { path = "../../../quasar/smart-contracts/contracts/cl-vault", features = [
"library",
] }

cw-vault-multi-standard = { git = "https://github.com/quasar-finance/cw-vault-standard", features = [
"lockup",
"force-unlock",
] }
[dev-dependencies]
app = { path = ".", features = ["interface"] }
abstract-interface = { git = "https://github.com/abstractsdk/abstract", branch = "cw-orch-authz/patch", features = [
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
use std::collections::HashSet;

use crate::cl_vault::{
self, BalancesQuery, TotalAssetsResponse, UserSharesBalanceResponse, VaultMessage, VaultQuery,
};
use crate::contract::{App, AppResult};
use crate::error::AppError;
use crate::msg::{AppExecuteMsg, ExecuteMsg};
Expand All @@ -19,6 +16,11 @@ use cosmwasm_std::{
};
use cw_asset::AssetList;

use crate::cl_vault::msg::ExtensionExecuteMsg;
use crate::cl_vault::msg::ExtensionQueryMsg;
use crate::cl_vault::query::{TotalAssetsResponse, UserSharesBalanceResponse};
use crate::cl_vault::{self, msg::UserBalanceQueryMsg};

use super::query::{query_balances, ContractBalances};
const MAX_SPREAD_PERCENT: u64 = 20;

Expand Down Expand Up @@ -90,8 +92,8 @@ fn autocompound(deps: DepsMut, env: Env, info: MessageInfo, app: App) -> AppResu

let msg_claim = CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: config.quasar_pool.to_string(),
msg: to_json_binary(&cl_vault::ExecuteMsg::VaultExtension(
VaultMessage::ClaimRewards {},
msg: to_json_binary(&cl_vault::msg::ExecuteMsg::VaultExtension(
ExtensionExecuteMsg::ClaimRewards {},
))?,
funds: vec![],
});
Expand Down Expand Up @@ -125,7 +127,7 @@ fn internal_deposit_all(deps: Deps, env: Env, info: MessageInfo, app: App) -> Ap
let all_quasar_assets: TotalAssetsResponse =
deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: config.quasar_pool.to_string(),
msg: to_json_binary(&crate::cl_vault::QueryMsg::TotalAssets {})?,
msg: to_json_binary(&crate::cl_vault::msg::QueryMsg::TotalAssets {})?,
}))?;

// After the swap we can deposit the exact amount of tokens inside the quasar pool
Expand All @@ -138,7 +140,7 @@ fn internal_deposit_all(deps: Deps, env: Env, info: MessageInfo, app: App) -> Ap

let msg = CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: config.quasar_pool.to_string(),
msg: to_json_binary(&crate::cl_vault::ExecuteMsg::ExactDeposit { recipient: None })?,
msg: to_json_binary(&crate::cl_vault::msg::ExecuteMsg::ExactDeposit { recipient: None })?,
funds: vec![
Coin {
denom: all_quasar_assets.token0.denom,
Expand All @@ -165,7 +167,7 @@ fn internal_swap_correct_amount(deps: DepsMut, env: Env, info: MessageInfo, app:
let all_quasar_assets: TotalAssetsResponse =
deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: config.quasar_pool.to_string(),
msg: to_json_binary(&crate::cl_vault::QueryMsg::TotalAssets {})?,
msg: to_json_binary(&crate::cl_vault::msg::QueryMsg::TotalAssets {})?,
}))?;

let token0 = all_quasar_assets.token0;
Expand Down Expand Up @@ -244,8 +246,8 @@ fn _inner_withdraw(
} else {
let user_shares: UserSharesBalanceResponse = deps.querier.query_wasm_smart(
config.quasar_pool.to_string(),
&cl_vault::QueryMsg::VaultExtension(VaultQuery::Balances(
BalancesQuery::UserSharesBalance {
&cl_vault::msg::QueryMsg::VaultExtension(ExtensionQueryMsg::Balances(
UserBalanceQueryMsg::UserSharesBalance {
user: env.contract.address.to_string(),
},
)),
Expand All @@ -256,7 +258,7 @@ fn _inner_withdraw(

let msg = CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: config.quasar_pool.to_string(),
msg: to_json_binary(&cl_vault::ExecuteMsg::Redeem {
msg: to_json_binary(&cl_vault::msg::ExecuteMsg::Redeem {
recipient: Some(app.account_base(deps.as_ref())?.proxy.to_string()),
amount: liquidity_amount,
})?,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::cl_vault::{self, BalancesQuery, UserRewardsResponse};
use crate::cl_vault::{self};
use crate::contract::{App, AppResult};
use crate::msg::{AppQueryMsg, AssetsBalanceResponse, AvailableRewardsResponse, StateResponse};
use crate::state::CONFIG;
use cl_vault::msg::{ExtensionQueryMsg, QueryMsg, UserBalanceQueryMsg};
use cl_vault::query::UserRewardsResponse;
use cosmwasm_std::{to_json_binary, Binary, Deps, Env, StdResult, Uint128};

pub fn query_handler(deps: Deps, env: Env, _app: &App, msg: AppQueryMsg) -> AppResult<Binary> {
Expand All @@ -27,8 +29,8 @@ fn query_balance(deps: Deps, env: Env) -> StdResult<AssetsBalanceResponse> {

deps.querier.query_wasm_smart(
config.quasar_pool.to_string(),
&cl_vault::QueryMsg::VaultExtension(cl_vault::VaultQuery::Balances(
BalancesQuery::UserAssetsBalance {
&QueryMsg::VaultExtension(ExtensionQueryMsg::Balances(
UserBalanceQueryMsg::UserAssetsBalance {
user: env.contract.address.to_string(),
},
)),
Expand All @@ -39,8 +41,8 @@ fn query_rewards(deps: Deps, env: Env) -> StdResult<AvailableRewardsResponse> {

let response: UserRewardsResponse = deps.querier.query_wasm_smart(
config.quasar_pool.to_string(),
&cl_vault::QueryMsg::VaultExtension(cl_vault::VaultQuery::Balances(
BalancesQuery::UserRewards {
&QueryMsg::VaultExtension(ExtensionQueryMsg::Balances(
UserBalanceQueryMsg::UserRewards {
user: env.contract.address.to_string(),
},
)),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod cl_vault;
// pub mod cl_vault;
pub use cl_vault;
pub mod contract;
pub mod error;
mod handlers;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
64 changes: 0 additions & 64 deletions contracts/savings-app/src/cl_vault.rs

This file was deleted.

2 changes: 1 addition & 1 deletion savings-bot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ dotenv = "0.15.0"
env_logger = "0.10.0"
log = "0.4.20"
tonic = "0.10.0"
app = { path = "../contracts/savings-app" }
app = { path = "../contracts/savings-app-quasar" }

0 comments on commit c5098fd

Please sign in to comment.