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

fix(smart-contracts): remove balances from PairInfo & fix minor errors #321

Merged
merged 5 commits into from
Apr 8, 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
33 changes: 4 additions & 29 deletions contracts/liquidity_hub/pool-manager/schema/pool-manager.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@
"required": [
"asset_denoms",
"pair_type",
"pool_fees",
"token_factory_lp"
"pool_fees"
],
"properties": {
"asset_denoms": {
Expand All @@ -81,9 +80,6 @@
},
"pool_fees": {
"$ref": "#/definitions/PoolFee"
},
"token_factory_lp": {
"type": "boolean"
}
},
"additionalProperties": false
Expand All @@ -101,16 +97,9 @@
"provide_liquidity": {
"type": "object",
"required": [
"assets",
"pair_identifier"
],
"properties": {
"assets": {
"type": "array",
"items": {
"$ref": "#/definitions/Coin"
}
},
"pair_identifier": {
"type": "string"
},
Expand Down Expand Up @@ -201,16 +190,9 @@
"withdraw_liquidity": {
"type": "object",
"required": [
"assets",
"pair_identifier"
],
"properties": {
"assets": {
"type": "array",
"items": {
"$ref": "#/definitions/Coin"
}
},
"pair_identifier": {
"type": "string"
}
Expand Down Expand Up @@ -901,14 +883,13 @@
},
"pair": {
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "NPairInfo",
"title": "PairInfo",
"type": "object",
"required": [
"asset_decimals",
"asset_denoms",
"assets",
"balances",
"liquidity_token",
"lp_denom",
"pair_type",
"pool_fees"
],
Expand All @@ -933,13 +914,7 @@
"$ref": "#/definitions/Coin"
}
},
"balances": {
"type": "array",
"items": {
"$ref": "#/definitions/Uint128"
}
},
"liquidity_token": {
"lp_denom": {
"type": "string"
},
"pair_type": {
Expand Down
20 changes: 1 addition & 19 deletions contracts/liquidity_hub/pool-manager/schema/raw/execute.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"required": [
"asset_denoms",
"pair_type",
"pool_fees",
"token_factory_lp"
"pool_fees"
],
"properties": {
"asset_denoms": {
Expand All @@ -34,9 +33,6 @@
},
"pool_fees": {
"$ref": "#/definitions/PoolFee"
},
"token_factory_lp": {
"type": "boolean"
}
},
"additionalProperties": false
Expand All @@ -54,16 +50,9 @@
"provide_liquidity": {
"type": "object",
"required": [
"assets",
"pair_identifier"
],
"properties": {
"assets": {
"type": "array",
"items": {
"$ref": "#/definitions/Coin"
}
},
"pair_identifier": {
"type": "string"
},
Expand Down Expand Up @@ -154,16 +143,9 @@
"withdraw_liquidity": {
"type": "object",
"required": [
"assets",
"pair_identifier"
],
"properties": {
"assets": {
"type": "array",
"items": {
"$ref": "#/definitions/Coin"
}
},
"pair_identifier": {
"type": "string"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "NPairInfo",
"title": "PairInfo",
"type": "object",
"required": [
"asset_decimals",
"asset_denoms",
"assets",
"balances",
"liquidity_token",
"lp_denom",
"pair_type",
"pool_fees"
],
Expand All @@ -32,13 +31,7 @@
"$ref": "#/definitions/Coin"
}
},
"balances": {
"type": "array",
"items": {
"$ref": "#/definitions/Uint128"
}
},
"liquidity_token": {
"lp_denom": {
"type": "string"
},
"pair_type": {
Expand Down
1 change: 0 additions & 1 deletion contracts/liquidity_hub/pool-manager/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use crate::queries::{get_swap_route, get_swap_routes};
use crate::state::{Config, MANAGER_CONFIG, PAIRS, PAIR_COUNTER};
use crate::{liquidity, manager, queries, router, swap};
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
entry_point, to_json_binary, Addr, Api, Binary, Deps, DepsMut, Env, MessageInfo, Response,
};
Expand Down
26 changes: 13 additions & 13 deletions contracts/liquidity_hub/pool-manager/src/manager/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ pub const LP_SYMBOL: &str = "uLP";
/// # Example
///
/// ```rust
/// # use cosmwasm_std::{DepsMut, Decimal, Env, MessageInfo, Response, CosmosMsg, WasmMsg, to_binary};
/// # use white_whale_std::pool_network::{asset::{AssetInfo, PairType}, pair::PoolFee};
/// # use cosmwasm_std::{DepsMut, Decimal, Env, MessageInfo, Response, CosmosMsg, WasmMsg, to_json_binary};
/// # use white_whale_std::pool_network::{asset::{PairType}, pair::PoolFee};
/// # use white_whale_std::fee::Fee;
/// # use pool_manager::error::ContractError;
/// # use pool_manager::manager::commands::MAX_ASSETS_PER_POOL;
Expand All @@ -35,8 +35,8 @@ pub const LP_SYMBOL: &str = "uLP";
/// #
/// # fn example(deps: DepsMut, env: Env, info: MessageInfo) -> Result<Response, ContractError> {
/// let asset_infos = vec![
/// AssetInfo::NativeToken { denom: "uatom".into() },
/// AssetInfo::NativeToken { denom: "uscrt".into() },
/// "uatom".into(),
/// "uscrt".into(),
/// ];
/// #[cfg(not(feature = "osmosis"))]
/// let pool_fees = PoolFee {
Expand Down Expand Up @@ -69,7 +69,7 @@ pub const LP_SYMBOL: &str = "uLP";
/// let pair_type = PairType::ConstantProduct;
/// let token_factory_lp = false;
///
/// let response = create_pair(deps, env, info, asset_infos, pool_fees, pair_type, token_factory_lp, None)?;
/// let response = create_pair(deps, env, info, asset_infos, pool_fees, pair_type, None)?;
/// # Ok(response)
/// # }
/// ```
Expand Down Expand Up @@ -117,14 +117,15 @@ pub fn create_pair(
//todo pass the asset_decimals in the create_pair msg. Let the user creating the pool
// defining the decimals, they are incentivized to do it right as they are paying a fee

// query_native_decimals(
// &deps.querier,
// env.contract.address.clone(),
// asset.to_string(),
// )
let _ = query_native_decimals(
&deps.querier,
env.contract.address.clone(),
asset.to_string(),
);

0u8
})
.collect::<Result<Vec<u8>, _>>()?;
.collect::<Vec<u8>>();

// Check if the asset infos are the same
if asset_denoms
Expand Down Expand Up @@ -175,13 +176,12 @@ pub fn create_pair(
deps.storage,
&identifier,
&PairInfo {
asset_denoms: asset_denoms.clone(),
asset_denoms,
pair_type: pair_type.clone(),
lp_denom: lp_asset.clone(),
asset_decimals: asset_decimals_vec,
pool_fees,
assets,
balances: vec![Uint128::zero(); asset_denoms.len()],
},
)?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ fn deposit_and_withdraw_sanity_check() {
// creator should have 999_000 LP shares (1M - MINIMUM_LIQUIDITY_AMOUNT)
.query_all_balances(creator.to_string(), |result| {
let balances = result.unwrap();
println!("{:?}", balances);
assert!(balances.iter().any(|coin| {
coin.denom == lp_denom && coin.amount == Uint128::from(999_000u128)
}));
Expand Down
2 changes: 1 addition & 1 deletion contracts/liquidity_hub/pool-manager/src/tests/suite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl TestingSuite {
pub(crate) fn get_lp_denom(&self, pair_id: String) -> String {
// TODO: this should have
format!(
"factory/{}/u{}.vault.{}.{}",
"factory/{}/u{}.pool.{}.{}",
self.pool_manager_addr, pair_id, pair_id, LP_SYMBOL
)
}
Expand Down
2 changes: 0 additions & 2 deletions packages/white-whale-std/src/pool_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ pub struct PairInfo {
pub asset_denoms: Vec<String>,
pub lp_denom: String,
pub asset_decimals: Vec<u8>,
// TODO: balances is included in assets, might be redundant
pub balances: Vec<Uint128>,
pub assets: Vec<Coin>,
pub pair_type: PairType,
pub pool_fees: PoolFee,
Expand Down
Loading