-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feat/mnemonic-env-var
- Loading branch information
Showing
46 changed files
with
4,769 additions
and
46 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
[package] | ||
name = "mars-params" | ||
description = "Contract storing the asset params for Credit Manager and Red Bank." | ||
version = "1.0.7" | ||
authors = { workspace = true } | ||
license = { workspace = true } | ||
edition = { workspace = true } | ||
repository = { workspace = true } | ||
homepage = { workspace = true } | ||
documentation = { workspace = true } | ||
keywords = { workspace = true } | ||
|
||
[lib] | ||
crate-type = ["cdylib", "rlib"] | ||
|
||
[features] | ||
# for quicker tests, cargo test --lib | ||
# for more explicit tests, cargo test --features=backtraces | ||
backtraces = ["cosmwasm-std/backtraces"] | ||
library = [] | ||
|
||
[dependencies] | ||
cosmwasm-schema = { workspace = true } | ||
cosmwasm-std = { workspace = true } | ||
cw2 = { workspace = true } | ||
cw-storage-plus = { workspace = true } | ||
mars-owner = { workspace = true } | ||
mars-utils = { workspace = true } | ||
schemars = { workspace = true } | ||
serde = { workspace = true } | ||
thiserror = { workspace = true } | ||
|
||
[dev-dependencies] | ||
anyhow = { workspace = true } | ||
cw-multi-test = { workspace = true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Mars Params Contract | ||
|
||
The Mars Params Contract is published to [Crates.io](https://crates.io/crates/mars-params) | ||
|
||
This contract holds the following values for all the assets in Mars Protocol: | ||
|
||
- **Max Loan To Value:** Max percentage of collateral that can be borrowed | ||
- **Liquidation Threshold:** LTV at which the loan is defined as under collateralized and can be liquidated | ||
- **Liquidation Bonus:** Percentage of extra collateral the liquidator gets as a bonus | ||
- **Deposit Enabled:** Is the asset able to be deposited into the Red Bank | ||
- **Borrow Enabled:** Is the asset able to be borrowed from the Red Bank | ||
- **Deposit Cap:** Max amount that can be deposited into the Red Bank | ||
- **Asset Settings:** Credit Manager and Red Bank Permission Settings | ||
|
||
Note: Credit Manager Vaults only utilize max loan to value, liquidation threshold, and deposit cap parameters, while Red Bank Markets utilize all of the above parameters. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use cosmwasm_schema::write_api; | ||
use mars_params::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; | ||
|
||
fn main() { | ||
write_api! { | ||
instantiate: InstantiateMsg, | ||
execute: ExecuteMsg, | ||
query: QueryMsg, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#[cfg(not(feature = "library"))] | ||
use cosmwasm_std::entry_point; | ||
use cosmwasm_std::{to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response}; | ||
use cw2::set_contract_version; | ||
use mars_owner::OwnerInit::SetInitialOwner; | ||
|
||
use crate::{ | ||
emergency_powers::{disable_borrowing, disallow_coin, set_zero_deposit_cap, set_zero_max_ltv}, | ||
error::ContractResult, | ||
execute::{assert_thf, update_asset_params, update_target_health_factor, update_vault_config}, | ||
msg::{ | ||
CmEmergencyUpdate, EmergencyUpdate, ExecuteMsg, InstantiateMsg, QueryMsg, | ||
RedBankEmergencyUpdate, | ||
}, | ||
query::{query_all_asset_params, query_all_vault_configs, query_vault_config}, | ||
state::{ASSET_PARAMS, OWNER, TARGET_HEALTH_FACTOR}, | ||
}; | ||
|
||
const CONTRACT_NAME: &str = env!("CARGO_PKG_NAME"); | ||
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); | ||
|
||
#[cfg_attr(not(feature = "library"), entry_point)] | ||
pub fn instantiate( | ||
deps: DepsMut, | ||
_: Env, | ||
_: MessageInfo, | ||
msg: InstantiateMsg, | ||
) -> ContractResult<Response> { | ||
set_contract_version(deps.storage, format!("crates.io:{CONTRACT_NAME}"), CONTRACT_VERSION)?; | ||
|
||
OWNER.initialize( | ||
deps.storage, | ||
deps.api, | ||
SetInitialOwner { | ||
owner: msg.owner, | ||
}, | ||
)?; | ||
|
||
assert_thf(msg.target_health_factor)?; | ||
TARGET_HEALTH_FACTOR.save(deps.storage, &msg.target_health_factor)?; | ||
|
||
Ok(Response::default()) | ||
} | ||
|
||
#[cfg_attr(not(feature = "library"), entry_point)] | ||
pub fn execute( | ||
deps: DepsMut, | ||
_: Env, | ||
info: MessageInfo, | ||
msg: ExecuteMsg, | ||
) -> ContractResult<Response> { | ||
match msg { | ||
ExecuteMsg::UpdateOwner(update) => Ok(OWNER.update(deps, info, update)?), | ||
ExecuteMsg::UpdateAssetParams(update) => update_asset_params(deps, info, update), | ||
ExecuteMsg::UpdateTargetHealthFactor(mcf) => update_target_health_factor(deps, info, mcf), | ||
ExecuteMsg::UpdateVaultConfig(update) => update_vault_config(deps, info, update), | ||
ExecuteMsg::EmergencyUpdate(update) => match update { | ||
EmergencyUpdate::RedBank(rb_u) => match rb_u { | ||
RedBankEmergencyUpdate::DisableBorrowing(denom) => { | ||
disable_borrowing(deps, info, &denom) | ||
} | ||
}, | ||
EmergencyUpdate::CreditManager(rv_u) => match rv_u { | ||
CmEmergencyUpdate::DisallowCoin(denom) => disallow_coin(deps, info, &denom), | ||
CmEmergencyUpdate::SetZeroMaxLtvOnVault(v) => set_zero_max_ltv(deps, info, &v), | ||
CmEmergencyUpdate::SetZeroDepositCapOnVault(v) => { | ||
set_zero_deposit_cap(deps, info, &v) | ||
} | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
#[cfg_attr(not(feature = "library"), entry_point)] | ||
pub fn query(deps: Deps, _: Env, msg: QueryMsg) -> ContractResult<Binary> { | ||
let res = match msg { | ||
QueryMsg::Owner {} => to_binary(&OWNER.query(deps.storage)?), | ||
QueryMsg::AssetParams { | ||
denom, | ||
} => to_binary(&ASSET_PARAMS.load(deps.storage, &denom)?), | ||
QueryMsg::AllAssetParams { | ||
start_after, | ||
limit, | ||
} => to_binary(&query_all_asset_params(deps, start_after, limit)?), | ||
QueryMsg::VaultConfig { | ||
address, | ||
} => to_binary(&query_vault_config(deps, &address)?), | ||
QueryMsg::AllVaultConfigs { | ||
start_after, | ||
limit, | ||
} => to_binary(&query_all_vault_configs(deps, start_after, limit)?), | ||
QueryMsg::TargetHealthFactor {} => to_binary(&TARGET_HEALTH_FACTOR.load(deps.storage)?), | ||
}; | ||
res.map_err(Into::into) | ||
} |
Oops, something went wrong.