Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v4.0.3 #420

Merged
merged 6 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 23 additions & 34 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion contracts/pair_concentrated_inj/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ tiny-keccak = { version = "2.0.2", features = ["keccak"] }
hex = "0.4.3"

[dev-dependencies]
cw20-base = "1.1
cw20-base = "1.1"
astroport-mocks = { path = "../../packages/astroport_mocks" }
astroport-factory = { path = "../factory" }
proptest = "1.0"
Expand Down
5 changes: 4 additions & 1 deletion contracts/periphery/liquidity_manager/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "astroport-liquidity-manager"
version = "1.1.0"
version = "1.2.0"
edition = "2021"
description = "Astroport Liquidity Manager contract"
license = "GPL-3.0-only"
Expand All @@ -19,10 +19,13 @@ cosmwasm-schema.workspace = true
cw-storage-plus.workspace = true
cw20 = "1.1"
thiserror.workspace = true
itertools.workspace = true
astroport = { path = "../../../packages/astroport", version = "4" }
cw20-base = { version = "1.1", features = ["library"] }
astroport-pair = { path = "../../pair", features = ["library"], version = "1.5" }
astroport-pair-stable = { path = "../../pair_stable", features = ["library"], version = "3" }
astroport-pair-concentrated = { path = "../../pair_concentrated", features = ["library"], version = "3" }
astroport-pcl-common = { path = "../../../packages/astroport_pcl_common", version = "2" }
astroport-factory = { path = "../../factory", features = ["library"], version = "1" }

[dev-dependencies]
Expand Down
59 changes: 56 additions & 3 deletions contracts/periphery/liquidity_manager/src/query.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::collections::HashMap;

#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{to_json_binary, Binary, Deps, Env, StdError, StdResult, Uint128};
Expand All @@ -8,9 +10,13 @@ use astroport::liquidity_manager::QueryMsg;
use astroport::pair::{ExecuteMsg as PairExecuteMsg, QueryMsg as PairQueryMsg};
use astroport::querier::query_supply;
use astroport_pair::contract::get_share_in_assets;
use astroport_pcl_common::state::Precisions;

use crate::error::ContractError;
use crate::utils::{convert_config, stableswap_provide_simulation, xyk_provide_simulation};
use crate::utils::{
convert_pcl_config, convert_stable_config, pcl_provide_simulation,
stableswap_provide_simulation, xyk_provide_simulation,
};

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
Expand Down Expand Up @@ -102,7 +108,7 @@ fn simulate_provide(
.querier
.query_wasm_raw(pair_addr, b"config")?
.ok_or_else(|| StdError::generic_err("pair stable config not found"))?;
let pair_config = convert_config(deps.querier, pair_config_data)?;
let pair_config = convert_stable_config(deps.querier, pair_config_data)?;
to_json_binary(
&stableswap_provide_simulation(
deps.querier,
Expand All @@ -114,7 +120,54 @@ fn simulate_provide(
.map_err(|err| StdError::generic_err(format!("{err}")))?,
)
}
PairType::Custom(..) => unimplemented!("not implemented yet"),
PairType::Custom(typ) if typ == "concentrated" => {
let balances = pair_info.query_pools(&deps.querier, &pair_addr)?;
let pcl_config_raw = deps
.querier
.query_wasm_raw(&pair_addr, b"config")?
.ok_or_else(|| StdError::generic_err("PCL config not found"))?;
let pcl_config = convert_pcl_config(pcl_config_raw)?;
let precisions = balances
.iter()
.map(|asset| {
let prec = Precisions::PRECISIONS
.query(&deps.querier, pair_addr.clone(), asset.info.to_string())?
.or_else(|| {
asset
.info
.decimals(&deps.querier, &pcl_config.factory_addr)
.ok()
})
.ok_or_else(|| {
StdError::generic_err(format!(
"Asset {} precision not found",
&asset.info
))
})?;
Ok((asset.info.to_string(), prec))
})
.collect::<StdResult<HashMap<_, _>>>()?;
let dec_balances = balances
.into_iter()
.map(|asset| {
asset
.to_decimal_asset(*precisions.get(&asset.info.to_string()).unwrap())
.map_err(Into::into)
})
.collect::<StdResult<Vec<_>>>()?;
let total_share = query_supply(&deps.querier, &pair_info.liquidity_token)?;
pcl_provide_simulation(
env,
dec_balances,
assets,
total_share,
pcl_config,
precisions,
)
.map_err(|err| StdError::generic_err(err.to_string()))
.and_then(|res| to_json_binary(&res))
}
PairType::Custom(_) => unimplemented!("not implemented yet"),
}
}
_ => Err(StdError::generic_err("Invalid simulate message")),
Expand Down
Loading
Loading