diff --git a/.gitignore b/.gitignore index 8f43da1..b265040 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,5 @@ /target -artifacts/* - Cargo.lock .env diff --git a/Cargo.toml b/Cargo.toml index e20aba1..d900b47 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/artifacts/cavern_protocol_abstract_module.wasm b/artifacts/cavern_protocol_abstract_module.wasm new file mode 100644 index 0000000..388d990 Binary files /dev/null and b/artifacts/cavern_protocol_abstract_module.wasm differ diff --git a/artifacts/checksums.txt b/artifacts/checksums.txt new file mode 100644 index 0000000..8f7e264 --- /dev/null +++ b/artifacts/checksums.txt @@ -0,0 +1 @@ +8031ec59b9a355bad4b8dfa60fa70625f07235ee80fee34d9bbc5ea05d815cb7 cavern_protocol_abstract_module.wasm diff --git a/artifacts/checksums_intermediate.txt b/artifacts/checksums_intermediate.txt new file mode 100644 index 0000000..f3cb3c1 --- /dev/null +++ b/artifacts/checksums_intermediate.txt @@ -0,0 +1 @@ +d5f0479c5ee4fc1666e1d65ee76a8f91491b4db8356f38ff27cb5746fb32a8dd ./target/wasm32-unknown-unknown/release/cavern_protocol_abstract_module.wasm diff --git a/src/handlers/execute.rs b/src/handlers/execute.rs index 57585fc..3826e74 100644 --- a/src/handlers/execute.rs +++ b/src/handlers/execute.rs @@ -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; @@ -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), } } @@ -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 @@ -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 diff --git a/src/handlers/instantiate.rs b/src/handlers/instantiate.rs index 5d4e3dc..dee3874 100644 --- a/src/handlers/instantiate.rs +++ b/src/handlers/instantiate.rs @@ -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)?; diff --git a/src/handlers/query.rs b/src/handlers/query.rs index d046760..3cf20c5 100644 --- a/src/handlers/query.rs +++ b/src/handlers/query.rs @@ -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 { match msg { @@ -15,12 +15,12 @@ fn query_config(deps: Deps) -> StdResult { Ok(ConfigResponse {}) } -pub fn query_market_config(deps: Deps) -> StdResult{ +pub fn query_market_config(deps: Deps) -> StdResult { 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) -} \ No newline at end of file +} diff --git a/src/msg.rs b/src/msg.rs index c5b9fb1..4cb50dc 100644 --- a/src/msg.rs +++ b/src/msg.rs @@ -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 @@ -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] diff --git a/src/state.rs b/src/state.rs index d46d07f..492d85a 100644 --- a/src/state.rs +++ b/src/state.rs @@ -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 = Item::new("config");