Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Buckram123 committed Jan 25, 2024
1 parent 81ac41c commit 47e5915
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
7 changes: 0 additions & 7 deletions contracts/savings-app/src/handlers/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,6 @@ fn swap_msg(
))
})?;

// swap(
// offer_asset.clone(),
// ask_asset.clone(),
// Some(Decimal::percent(MAX_SPREAD_PERCENT)),
// None,
// )?;

Ok(trigger_swap_msg
.messages
.into_iter()
Expand Down
18 changes: 9 additions & 9 deletions contracts/savings-app/src/handlers/query.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::contract::{App, AppResult};

use crate::msg::{AppQueryMsg, AssetsBalanceResponse, AvailableRewardsResponse};
use crate::state::{get_osmosis_position, get_position, Config, CONFIG};
use crate::msg::{AppQueryMsg, AssetsBalanceResponse, AvailableRewardsResponse, PositionResponse};
use crate::state::{get_osmosis_position, Config, CONFIG, POSITION};
use abstract_core::objects::AnsAsset;
use abstract_dex_adapter::DexInterface;
use cosmwasm_std::{to_json_binary, Binary, Coin, Decimal, Deps, Env};
Expand All @@ -12,11 +12,17 @@ pub fn query_handler(deps: Deps, _env: Env, app: &App, msg: AppQueryMsg) -> AppR
AppQueryMsg::Balance {} => to_json_binary(&query_balance(deps, app)?),
AppQueryMsg::AvailableRewards {} => to_json_binary(&query_rewards(deps, app)?),
AppQueryMsg::Config {} => to_json_binary(&query_config(deps)?),
AppQueryMsg::Position {} => to_json_binary(&get_position(deps)?),
AppQueryMsg::Position {} => to_json_binary(&query_position(deps)?),
}
.map_err(Into::into)
}

fn query_position(deps: Deps) -> AppResult<PositionResponse> {
let position = POSITION.may_load(deps.storage)?;

Ok(PositionResponse { position })
}

fn query_config(deps: Deps) -> AppResult<Config> {
Ok(CONFIG.load(deps.storage)?)
}
Expand Down Expand Up @@ -81,9 +87,3 @@ pub fn query_price(deps: Deps, funds: &[Coin], app: &App) -> AppResult<Decimal>

Ok(price)
}

#[derive(Debug)]
pub struct ContractBalances<T> {
pub token0: T,
pub token1: T,
}
13 changes: 10 additions & 3 deletions contracts/savings-app/src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use crate::{contract::App, state::Config};
use crate::{
contract::App,
state::{Config, Position},
};
use abstract_dex_adapter::msg::DexName;
use cosmwasm_schema::{cw_serde, QueryResponses};
use cosmwasm_std::{Coin, Uint128};
Expand Down Expand Up @@ -56,8 +59,7 @@ pub enum AppQueryMsg {
Balance {},
#[returns(AvailableRewardsResponse)]
AvailableRewards {},
// TODO: Should be option if we keep it after debugging
#[returns(crate::state::Position)]
#[returns(PositionResponse)]
Position {},
}

Expand All @@ -78,3 +80,8 @@ pub struct AssetsBalanceResponse {
pub balances: Vec<Coin>,
pub liquidity: String,
}

#[cw_serde]
pub struct PositionResponse {
pub position: Option<Position>,
}

0 comments on commit 47e5915

Please sign in to comment.