Skip to content

Commit 21d567c

Browse files
committed
Lend-market v2: There will be no oracle after all
1 parent 2616b3a commit 21d567c

File tree

2 files changed

+25
-20
lines changed

2 files changed

+25
-20
lines changed

contracts/lending/market_v2/src/contract.rs

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ pub fn instantiate(
6464
credit_agency: Contract::new(&info.sender.clone(), &msg.credit_agency_code_hash).into(),
6565
reserve_factor: msg.reserve_factor,
6666
borrow_limit_ratio: msg.borrow_limit_ratio,
67+
oracle: msg.oracle.into()
6768
};
6869
CONFIG.save(deps.storage, &cfg)?;
6970
VIEWING_KEY.save(deps.storage, &msg.viewing_key)?;
@@ -262,6 +263,7 @@ mod query {
262263
use shade_protocol::{
263264
c_std::{ContractInfo, Decimal, Deps, Uint128},
264265
utils::asset::Contract,
266+
contract_interfaces::oracles,
265267
};
266268

267269
use lend_token::msg::{BalanceResponse, QueryMsg as TokenQueryMsg, TokenInfoResponse};
@@ -433,26 +435,27 @@ mod query {
433435
pub fn price_market_local_per_common(deps: Deps) -> Result<PriceRate, ContractError> {
434436
todo!();
435437

436-
// let config = CONFIG.load(deps.storage)?;
437-
// // If tokens are the same, just return 1:1.
438-
// if config.common_token == config.market_token {
439-
// Ok(PriceRate {
440-
// sell_denom: config.market_token.clone(),
441-
// buy_denom: config.common_token,
442-
// rate_sell_per_buy: Decimal::one(),
443-
// })
444-
// } else {
445-
// let price_response: TwapResponse = OracleQueryMsg::Twap {
446-
// offer: config.market_token.clone().into(),
447-
// ask: config.common_token.clone().into(),
448-
// }
449-
// .query(&deps.querier, config.price_oracle.clone())?;
450-
// Ok(PriceRate {
451-
// sell_denom: config.market_token,
452-
// buy_denom: config.common_token,
453-
// rate_sell_per_buy: price_response.a_per_b,
454-
// })
455-
// }
438+
let config = CONFIG.load(deps.storage)?;
439+
// If tokens are the same, just return 1:1.
440+
if config.common_token == config.market_token {
441+
Ok(PriceRate {
442+
sell_denom: config.market_token.clone(),
443+
buy_denom: config.common_token,
444+
rate_sell_per_buy: Decimal::one(),
445+
})
446+
} else {
447+
todo!();
448+
// let price_response: TwapResponse = OracleQueryMsg::Twap {
449+
// offer: config.market_token.clone().into(),
450+
// ask: config.common_token.clone().into(),
451+
// }
452+
// .query(&deps.querier, config.price_oracle.clone())?;
453+
Ok(PriceRate {
454+
sell_denom: config.market_token,
455+
buy_denom: config.common_token,
456+
rate_sell_per_buy: Decimal::one() /*price_response.a_per_b,*/
457+
})
458+
}
456459
}
457460

458461
// /// Handler for `QueryMsg::CreditLine`

contracts/lending/market_v2/src/state.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ pub struct Config {
3939
pub price_oracle: String,
4040
/// Address of Credit Agency
4141
pub credit_agency: ContractInfo,
42+
/// Address of oracle
43+
pub oracle: ContractInfo,
4244
pub reserve_factor: Decimal,
4345
}
4446

0 commit comments

Comments
 (0)