Skip to content

Commit

Permalink
Bump astroport and cw-asset dependencies to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
larry0x committed Mar 12, 2022
1 parent c2be90d commit 0212e69
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 59 deletions.
30 changes: 7 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions contracts/martian-field/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ crate-type = ["cdylib", "rlib"]
backtraces = ["cosmwasm-std/backtraces"]

[dependencies]
cosmwasm-std = "^0.16"
cw-asset = { version = "0.3.2", features = ["legacy"] }
cw-storage-plus = "^0.9"
cosmwasm-std = "0.16"
cw-asset = { version = "1.0", features = ["legacy"] }
cw-storage-plus = "0.9"
fields-of-mars = { path = "../../packages/fields-of-mars" }
schemars = "0.8.1"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion contracts/martian-field/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub fn update_position(
&env.contract.address,
&info.sender,
&mut received_coins,
&asset.check(api)?,
&asset.check(api, None)?,
&mut msgs,
&mut attrs,
)?,
Expand Down
2 changes: 1 addition & 1 deletion contracts/martian-field/src/execute_replies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub fn after_swap(deps: DepsMut, response: SubMsgExecutionResponse) -> StdResult

// parse Astroport's event log to find out how much asset was returned from the swap
let returned_asset_unchecked = Pair::parse_swap_events(&response.events)?;
let returned_asset = returned_asset_unchecked.check(deps.api)?;
let returned_asset = returned_asset_unchecked.check(deps.api, None)?;
assets.add(&returned_asset)?;

// save the updated state/position
Expand Down
10 changes: 5 additions & 5 deletions contracts/mock-astro-generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ crate-type = ["cdylib", "rlib"]
backtraces = ["cosmwasm-std/backtraces"]

[dependencies]
astroport = "0.3.1"
astroport = "1.0"
fields-of-mars = { path = "../../packages/fields-of-mars" }
cosmwasm-std = "^0.16"
cw20 = "0.8.0" # Astroport uses cw-plus 0.8, while Mars uses 0.9, which are not compatible in some cases
cw-asset = { version = "0.3.2", features = ["legacy"] }
cw-storage-plus = "^0.9"
cosmwasm-std = "0.16"
cw20 = "0.8" # Astroport uses cw-plus 0.8, while Mars uses 0.9, which are not compatible in some cases
cw-asset = { version = "1.0", features = ["legacy"] }
cw-storage-plus = "0.9"
schemars = "0.8.1"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
12 changes: 6 additions & 6 deletions contracts/mock-oracle/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "mock-oracle"
version = "1.0.0"
authors = ["larry_0x <larry@delphidigital.io>"]
authors = ["larry <larry@delphidigital.io>"]
edition = "2018"
license = "GPL-3.0-or-later"
repository = "https://github.com/mars-protocol/field-of-mars"
Expand All @@ -13,11 +13,11 @@ crate-type = ["cdylib", "rlib"]
backtraces = ["cosmwasm-std/backtraces"]

[dependencies]
astroport = "0.3.1"
astroport = "1.0"
fields-of-mars = { path = "../../packages/fields-of-mars" }
cosmwasm-std = "^0.16"
cw-asset = { version = "0.3.2", features = ["legacy"] }
cw-storage-plus = "^0.9"
mars-core = "1.0.0"
cosmwasm-std = "0.16"
cw-asset = { version = "1.0", features = ["legacy"] }
cw-storage-plus = "0.9"
mars-core = "1.0"
schemars = "0.8.1"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
12 changes: 6 additions & 6 deletions contracts/mock-red-bank/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "mock-red-bank"
version = "1.0.0"
authors = ["larry_0x <larry@delphidigital.io>"]
authors = ["larry <larry@delphidigital.io>"]
edition = "2018"
license = "GPL-3.0-or-later"
repository = "https://github.com/mars-protocol/field-of-mars"
Expand All @@ -13,11 +13,11 @@ crate-type = ["cdylib", "rlib"]
backtraces = ["cosmwasm-std/backtraces"]

[dependencies]
cosmwasm-std = "^0.16"
cw20 = "^0.9"
cw-asset = { version = "0.3.2", features = ["legacy"] }
cw-storage-plus = "^0.9"
cosmwasm-std = "0.16"
cw20 = "0.9"
cw-asset = { version = "1.0", features = ["legacy"] }
cw-storage-plus = "0.9"
fields-of-mars = { path = "../../packages/fields-of-mars" }
mars-core = "1.0.0"
mars-core = "1.0"
schemars = "0.8.1"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
15 changes: 7 additions & 8 deletions packages/fields-of-mars/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
[package]
name = "fields-of-mars"
version = "1.0.0"
authors = ["larry_0x <larry@delphidigital.io>"]
authors = ["larry <larry@delphidigital.io>"]
description = "Leveraged yield farming strategy utilizing contract-to-contract (C2C) lending from Mars Protocol"
edition = "2018"
license = "GPL-3.0-or-later"
repository = "https://github.com/mars-protocol/field-of-mars"

[dependencies]
astroport = "0.3.1"
cosmwasm-std = "^0.16"
cw20 = "^0.9"
cw-asset = { version = "0.3.2", features = ["legacy"] }
mars-core = "1.0.0"
astroport = "1.0"
cosmwasm-std = "0.16"
cw20 = "0.9"
cw-asset = { version = "1.0", features = ["legacy"] }
mars-core = "1.0"
schemars = "0.8.1"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
terra-cosmwasm = "2.2.0"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
11 changes: 9 additions & 2 deletions packages/fields-of-mars/src/adapters/astro_pair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,14 @@ impl Pair {
.split(", ")
.collect();

let primary_asset_label = primary_asset_info.to_string();
let primary_asset_label = get_asset_label(primary_asset_info);
let primary_withdrawn_amount_str = asset_strs
.iter()
.find(|asset_str| asset_str.contains(&primary_asset_label))
.map(|asset_str| asset_str.replace(&primary_asset_label, ""))
.ok_or_else(|| StdError::generic_err("failed to parse primary withdrawn amount"))?;

let secondary_asset_label = secondary_asset_info.to_string();
let secondary_asset_label = get_asset_label(secondary_asset_info);
let secondary_withdrawn_amount_str = asset_strs
.iter()
.find(|asset_str| asset_str.contains(&secondary_asset_label))
Expand All @@ -314,3 +314,10 @@ impl Pair {
fn event_contains_attr(event: &Event, key: &str, value: &str) -> bool {
event.attributes.iter().any(|attr| attr.key == key && attr.value == value)
}

fn get_asset_label(asset_info: &AssetInfo) -> String {
match asset_info {
AssetInfo::Cw20(contract_addr) => contract_addr.into(),
AssetInfo::Native(denom) => denom.clone(),
}
}
9 changes: 8 additions & 1 deletion packages/fields-of-mars/src/adapters/oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,16 @@ impl Oracle {
let response: MarsDecimal = querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: self.contract_addr.to_string(),
msg: to_binary(&QueryMsg::AssetPriceByReference {
asset_reference: asset_info.to_string().as_bytes().to_vec(),
asset_reference: get_asset_reference(asset_info),
})?,
}))?;
Ok(response.to_std_decimal()) // cast mars_core::math::decimal::Decimal to cosmwasm_std::Decimal
}
}

fn get_asset_reference(asset_info: &AssetInfo) -> Vec<u8> {
match asset_info {
AssetInfo::Cw20(contract_addr) => contract_addr.as_bytes().to_vec(),
AssetInfo::Native(denom) => denom.as_bytes().to_vec(),
}
}
6 changes: 3 additions & 3 deletions packages/fields-of-mars/src/martian_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ impl From<Config> for ConfigUnchecked {
impl ConfigUnchecked {
pub fn check(&self, api: &dyn Api) -> StdResult<Config> {
Ok(Config {
primary_asset_info: self.primary_asset_info.check(api)?,
secondary_asset_info: self.secondary_asset_info.check(api)?,
astro_token_info: self.astro_token_info.check(api)?,
primary_asset_info: self.primary_asset_info.check(api, None)?,
secondary_asset_info: self.secondary_asset_info.check(api, None)?,
astro_token_info: self.astro_token_info.check(api, None)?,
primary_pair: self.primary_pair.check(api)?,
astro_pair: self.astro_pair.check(api)?,
astro_generator: self.astro_generator.check(api)?,
Expand Down

0 comments on commit 0212e69

Please sign in to comment.