Skip to content

Commit

Permalink
Compiled and formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
Kayanski committed Jun 1, 2023
1 parent c4416a7 commit 32e2949
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 43 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/target

artifacts/*

Cargo.lock

.env
Expand Down
20 changes: 8 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,21 @@ thiserror = { version = "1.0" }
schemars = "0.8"
cw-asset = { version = "3.0" }

abstract-core = { version = "0.15.1"}
abstract-app = { version = "0.15.0"}
abstract-sdk = { version = "0.15.1"}
abstract-core = { version = "0.15.1" }
abstract-app = { version = "0.15.0" }
abstract-sdk = { version = "0.15.1" }

# Dependencies for interface
abstract-interface = { version = "0.15.1", optional = true }
cw-orch = { version = "0.12", optional = true }

moneymarket = { git = "https://github.com/CavernPerson/money-market-contracts"}
moneymarket = { git = "https://github.com/CavernPerson/money-market-contracts" }
cw20 = "1.0.1"
[dev-dependencies]
cavern-protocol-abstract-module = {path=".", features=["interface"]}
abstract-interface = { version = "0.15.1", features = [
"daemon",
] }
abstract-testing = { version = "0.15.1"}
abstract-sdk = { version = "0.15.1", features = [
"test-utils",
] }
cavern-protocol-abstract-module = { path = ".", features = ["interface"] }
abstract-interface = { version = "0.15.1", features = ["daemon"] }
abstract-testing = { version = "0.15.1" }
abstract-sdk = { version = "0.15.1", features = ["test-utils"] }
speculoos = "0.11.0"
semver = "1.0"
dotenv = "0.15.0"
Expand Down
Binary file added artifacts/cavern_protocol_abstract_module.wasm
Binary file not shown.
1 change: 1 addition & 0 deletions artifacts/checksums.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8031ec59b9a355bad4b8dfa60fa70625f07235ee80fee34d9bbc5ea05d815cb7 cavern_protocol_abstract_module.wasm
1 change: 1 addition & 0 deletions artifacts/checksums_intermediate.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d5f0479c5ee4fc1666e1d65ee76a8f91491b4db8356f38ff27cb5746fb32a8dd ./target/wasm32-unknown-unknown/release/cavern_protocol_abstract_module.wasm
40 changes: 25 additions & 15 deletions src/handlers/execute.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use cosmwasm_std::{Uint128, CosmosMsg};
use abstract_sdk::{Execution};
use abstract_sdk::features::AbstractResponse;
use cosmwasm_std::{DepsMut, Env, MessageInfo, Response, wasm_execute, Coin, to_binary};
use abstract_sdk::Execution;
use cosmwasm_std::{to_binary, wasm_execute, Coin, DepsMut, Env, MessageInfo, Response};
use cosmwasm_std::{CosmosMsg, Uint128};
use cw_asset::{Asset, AssetInfo};

use crate::handlers::query::query_market_config;
Expand All @@ -19,8 +19,8 @@ pub fn execute_handler(
msg: AppExecuteMsg,
) -> AppResult {
match msg {
AppExecuteMsg::Deposit {amount} => execute_deposit(deps, info, app, amount),
AppExecuteMsg::Withdraw {amount} => execute_withdraw(deps, info, app, amount),
AppExecuteMsg::Deposit { amount } => execute_deposit(deps, info, app, amount),
AppExecuteMsg::Withdraw { amount } => execute_withdraw(deps, info, app, amount),
AppExecuteMsg::UpdateConfig {} => update_config(deps, info, app),
}
}
Expand All @@ -36,15 +36,18 @@ fn execute_deposit(deps: DepsMut, msg_info: MessageInfo, app: App, amount: Uint1
let executor = app.executor(deps.as_ref());
let deposit_msg: CosmosMsg = wasm_execute(
config.market_contract,
&moneymarket::market::ExecuteMsg::DepositStable { },
vec![Coin{
&moneymarket::market::ExecuteMsg::DepositStable {},
vec![Coin {
denom: market_config.stable_denom,
amount
}]
)?.into();
amount,
}],
)?
.into();
let deposit_msg = executor.execute(vec![deposit_msg.into()]);

Ok(app.tag_response(Response::default(), "update_config").add_messages(deposit_msg))
Ok(app
.tag_response(Response::default(), "update_config")
.add_messages(deposit_msg))
}

/// Update the configuration of the app
Expand All @@ -57,14 +60,21 @@ fn execute_withdraw(deps: DepsMut, msg_info: MessageInfo, app: App, amount: Uint
// We call an action on the proxy directly
let executor = app.executor(deps.as_ref());

let redeem_message = Asset{
let redeem_message = Asset {
amount,
info: AssetInfo::Cw20(deps.api.addr_validate(&market_config.aterra_contract)?)
}.send_msg(config.market_contract, to_binary(&moneymarket::market::Cw20HookMsg::RedeemStable { })?)?.into();
info: AssetInfo::Cw20(deps.api.addr_validate(&market_config.aterra_contract)?),
}
.send_msg(
config.market_contract,
to_binary(&moneymarket::market::Cw20HookMsg::RedeemStable {})?,
)?
.into();

let redeem_messages = executor.execute(vec![redeem_message]);

Ok(app.tag_response(Response::default(), "update_config").add_messages(redeem_messages))
Ok(app
.tag_response(Response::default(), "update_config")
.add_messages(redeem_messages))
}

/// Update the configuration of the app
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/instantiate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn instantiate_handler(
msg: AppInstantiateMsg,
) -> AppResult {
let config: Config = Config {
market_contract: deps.api.addr_validate(&msg.market_contract)?
market_contract: deps.api.addr_validate(&msg.market_contract)?,
};

CONFIG.save(deps.storage, &config)?;
Expand Down
10 changes: 5 additions & 5 deletions 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, ConfigResponse};
use crate::state::CONFIG;
use cosmwasm_std::{to_binary, Binary, Deps, Env, StdResult, QueryRequest, WasmQuery};
use cosmwasm_std::{to_binary, Binary, Deps, Env, QueryRequest, StdResult, WasmQuery};

pub fn query_handler(deps: Deps, _env: Env, _app: &App, msg: AppQueryMsg) -> AppResult<Binary> {
match msg {
Expand All @@ -15,12 +15,12 @@ fn query_config(deps: Deps) -> StdResult<ConfigResponse> {
Ok(ConfigResponse {})
}

pub fn query_market_config(deps: Deps) -> StdResult<moneymarket::market::ConfigResponse>{
pub fn query_market_config(deps: Deps) -> StdResult<moneymarket::market::ConfigResponse> {
let config = CONFIG.load(deps.storage)?;
let config_response = deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart{
let config_response = deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: config.market_contract.to_string(),
msg: to_binary(&moneymarket::market::QueryMsg::Config { })?
msg: to_binary(&moneymarket::market::QueryMsg::Config {})?,
}))?;

Ok(config_response)
}
}
10 changes: 3 additions & 7 deletions src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl app::AppQueryMsg for AppQueryMsg {}
/// App instantiate message
#[cosmwasm_schema::cw_serde]
pub struct AppInstantiateMsg {
pub market_contract: String
pub market_contract: String,
}

/// App execute messages
Expand All @@ -26,12 +26,8 @@ pub struct AppInstantiateMsg {
#[cfg_attr(feature = "interface", impl_into(ExecuteMsg))]
pub enum AppExecuteMsg {
UpdateConfig {},
Deposit {
amount: Uint128
},
Withdraw {
amount: Uint128
},
Deposit { amount: Uint128 },
Withdraw { amount: Uint128 },
}

#[cosmwasm_schema::cw_serde]
Expand Down
2 changes: 1 addition & 1 deletion src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use cw_storage_plus::Item;

#[cosmwasm_schema::cw_serde]
pub struct Config {
pub market_contract: Addr
pub market_contract: Addr,
}

pub const CONFIG: Item<Config> = Item::new("config");

0 comments on commit 32e2949

Please sign in to comment.