Skip to content

Commit

Permalink
Lend-market v2: execute enter market
Browse files Browse the repository at this point in the history
  • Loading branch information
ueco-jb committed Nov 21, 2023
1 parent 3f02759 commit 28514e0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
15 changes: 15 additions & 0 deletions contracts/lending/market_v2/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ mod execute {

use crate::{
interest::{calculate_interest, epochs_passed, query_ctoken_multiplier, InterestUpdate},
msg::CreditAgencyExecuteMsg,
state::debt,
};

Expand Down Expand Up @@ -337,6 +338,20 @@ mod execute {
}
}

// Register the account into Credit Agency as a depositor.
fn enter_market<T>(cfg: &Config, account: &Addr) -> StdResult<SubMsg<T>> {
let msg = to_binary(&CreditAgencyExecuteMsg::EnterMarket {
account: account.to_string(),
})?;

Ok(SubMsg::new(WasmMsg::Execute {
contract_addr: cfg.credit_agency.address.to_string(),
msg,
funds: vec![],
code_hash: cfg.credit_agency.code_hash.clone(),
}))
}

/// Handler for `ExecuteMsg::Withdraw`
pub fn withdraw(
mut deps: DepsMut,
Expand Down
14 changes: 7 additions & 7 deletions contracts/lending/market_v2/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ pub enum ExecuteMsg {
Withdraw { amount: Uint128 },
}

#[cw_serde]
pub enum CreditAgencyExecuteMsg {
/// Ensures a given account has entered a market. Meant to be called by a specific
/// market contract - so the sender of the msg would be the market
EnterMarket { account: String },
}

#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {}
Expand Down Expand Up @@ -100,13 +107,6 @@ pub struct ReserveResponse {
pub reserve: Uint128,
}

#[cw_serde]
pub enum CreditAgencyExecuteMsg {
/// Ensures a given account has entered a market. Meant to be called by a specific
/// market contract - so the sender of the msg would be the market
EnterMarket { account: String },
}

#[cw_serde]
pub struct ApyResponse {
/// How much % interest will a borrower have to pay
Expand Down

0 comments on commit 28514e0

Please sign in to comment.