From 1a6462c3d9ebd3d6282ca7534cd9698a424b66a8 Mon Sep 17 00:00:00 2001 From: Kerber0x Date: Tue, 2 Jul 2024 15:21:13 +0100 Subject: [PATCH] feat: tweak pool query on pool manager to return a list of pools if necessary --- .../schema/bonding-manager.json | 2 +- .../schema/raw/response_to_config.json | 2 +- .../bonding-manager/src/helpers.rs | 48 ++++++++------ .../pool-manager/schema/pool-manager.json | 15 ++--- .../pool-manager/schema/raw/query.json | 8 +-- .../schema/raw/response_to_pools.json | 7 +- .../pool-manager/src/contract.rs | 13 +++- .../liquidity_hub/pool-manager/src/queries.rs | 64 +++++++++++++++++-- .../src/tests/integration_tests.rs | 55 ++++++++-------- .../pool-manager/src/tests/suite.rs | 34 ++++++---- integration-tests/tests/common/suite.rs | 20 ++++-- packages/white-whale-std/src/pool_manager.rs | 23 +++++-- 12 files changed, 190 insertions(+), 101 deletions(-) diff --git a/contracts/liquidity_hub/bonding-manager/schema/bonding-manager.json b/contracts/liquidity_hub/bonding-manager/schema/bonding-manager.json index 01fed86a..d799b1d0 100644 --- a/contracts/liquidity_hub/bonding-manager/schema/bonding-manager.json +++ b/contracts/liquidity_hub/bonding-manager/schema/bonding-manager.json @@ -852,7 +852,7 @@ ] }, "unbonding_period": { - "description": "Unbonding period in nanoseconds. The time that needs to pass before an unbonded position can be withdrawn", + "description": "Unbonding period in epochs. The time (in epochs) that needs to pass before an unbonded position can be withdrawn", "type": "integer", "format": "uint64", "minimum": 0.0 diff --git a/contracts/liquidity_hub/bonding-manager/schema/raw/response_to_config.json b/contracts/liquidity_hub/bonding-manager/schema/raw/response_to_config.json index 498ca242..4f2e9575 100644 --- a/contracts/liquidity_hub/bonding-manager/schema/raw/response_to_config.json +++ b/contracts/liquidity_hub/bonding-manager/schema/raw/response_to_config.json @@ -54,7 +54,7 @@ ] }, "unbonding_period": { - "description": "Unbonding period in nanoseconds. The time that needs to pass before an unbonded position can be withdrawn", + "description": "Unbonding period in epochs. The time (in epochs) that needs to pass before an unbonded position can be withdrawn", "type": "integer", "format": "uint64", "minimum": 0.0 diff --git a/contracts/liquidity_hub/bonding-manager/src/helpers.rs b/contracts/liquidity_hub/bonding-manager/src/helpers.rs index 75a56337..f981b0ce 100644 --- a/contracts/liquidity_hub/bonding-manager/src/helpers.rs +++ b/contracts/liquidity_hub/bonding-manager/src/helpers.rs @@ -15,7 +15,7 @@ use white_whale_std::bonding_manager::{ use white_whale_std::constants::LP_SYMBOL; use white_whale_std::epoch_manager::epoch_manager::EpochResponse; use white_whale_std::pool_manager::{ - PoolInfoResponse, SimulateSwapOperationsResponse, SwapRouteResponse, + PoolsResponse, SimulateSwapOperationsResponse, SwapRouteResponse, }; use white_whale_std::pool_network::asset; use white_whale_std::pool_network::asset::aggregate_coins; @@ -128,14 +128,16 @@ pub fn handle_lp_tokens_rewards( extract_pool_identifier(&lp_token.denom).ok_or(ContractError::AssetMismatch)?; // make sure a pool with the given identifier exists - let pool: StdResult = deps.querier.query_wasm_smart( + let pools_response: StdResult = deps.querier.query_wasm_smart( config.pool_manager_addr.to_string(), - &white_whale_std::pool_manager::QueryMsg::Pool { - pool_identifier: pool_identifier.to_string(), + &white_whale_std::pool_manager::QueryMsg::Pools { + pool_identifier: Some(pool_identifier.to_string()), + start_after: None, + limit: None, }, ); - if pool.is_err() { + if pools_response.is_err() || pools_response?.pools.is_empty() { continue; } @@ -221,25 +223,33 @@ pub fn swap_coins_to_main_token( // check if the pool has any assets, if not skip the swap // Note we are only checking the first operation here. // Might be better to another loop to check all operations - let pool_query = white_whale_std::pool_manager::QueryMsg::Pool { - pool_identifier: swap_routes - .swap_route - .swap_operations - .first() - .unwrap() - .get_pool_identifer(), + let pools_query = white_whale_std::pool_manager::QueryMsg::Pools { + pool_identifier: Some( + swap_routes + .swap_route + .swap_operations + .first() + .unwrap() + .get_pool_identifer(), + ), + start_after: None, + limit: None, }; let mut skip_swap = false; // Query for the pool to check if it has any assets - let resp: PoolInfoResponse = deps + let pools_response: PoolsResponse = deps .querier - .query_wasm_smart(config.pool_manager_addr.to_string(), &pool_query)?; + .query_wasm_smart(config.pool_manager_addr.to_string(), &pools_query)?; // Check pair 'assets' and if either one has 0 amount then don't do swaps - resp.pool_info.assets.iter().for_each(|asset| { - if asset.amount.is_zero() { - skip_swap = true; - } - }); + pools_response.pools[0] + .pool_info + .assets + .iter() + .for_each(|asset| { + if asset.amount.is_zero() { + skip_swap = true; + } + }); let simulate_swap_operations_response: SimulateSwapOperationsResponse = deps.querier.query_wasm_smart( diff --git a/contracts/liquidity_hub/pool-manager/schema/pool-manager.json b/contracts/liquidity_hub/pool-manager/schema/pool-manager.json index 157b38c8..609a5646 100644 --- a/contracts/liquidity_hub/pool-manager/schema/pool-manager.json +++ b/contracts/liquidity_hub/pool-manager/schema/pool-manager.json @@ -965,7 +965,7 @@ "additionalProperties": false }, { - "description": "Retrieves the pools information.", + "description": "Retrieves the pool information for the given pool identifier.", "type": "object", "required": [ "pools" @@ -975,7 +975,7 @@ "type": "object", "properties": { "limit": { - "description": "An optional parameter specifying the maximum number of pools to return.", + "description": "The amount of pools to return. If unspecified, will default to a value specified by the contract.", "type": [ "integer", "null" @@ -984,14 +984,14 @@ "minimum": 0.0 }, "pool_identifier": { - "description": "If provided, the query will return the pool with the given identifier, otherwise, it will return all pools.", + "description": "An optional parameter specifying the pool identifier to do the query for. If not provided, it will return all pools based on the pagination parameters.", "type": [ "string", "null" ] }, "start_after": { - "description": "An optional parameter specifying what pool identifier to start searching after.", + "description": "An optional parameter specifying what pool (identifier) to start searching after.", "type": [ "string", "null" @@ -1356,7 +1356,7 @@ ], "properties": { "pools": { - "description": "The pools on the contract.", + "description": "The pools information responses.", "type": "array", "items": { "$ref": "#/definitions/PoolInfoResponse" @@ -1447,7 +1447,6 @@ "asset_decimals", "asset_denoms", "assets", - "identifier", "lp_denom", "pool_fees", "pool_type" @@ -1476,9 +1475,6 @@ "$ref": "#/definitions/Coin" } }, - "identifier": { - "type": "string" - }, "lp_denom": { "description": "The LP denom of the pool.", "type": "string" @@ -1503,7 +1499,6 @@ "additionalProperties": false }, "PoolInfoResponse": { - "description": "The response for the `Pool` query.", "type": "object", "required": [ "pool_info", diff --git a/contracts/liquidity_hub/pool-manager/schema/raw/query.json b/contracts/liquidity_hub/pool-manager/schema/raw/query.json index e750cc46..7e4990da 100644 --- a/contracts/liquidity_hub/pool-manager/schema/raw/query.json +++ b/contracts/liquidity_hub/pool-manager/schema/raw/query.json @@ -217,7 +217,7 @@ "additionalProperties": false }, { - "description": "Retrieves the pools information.", + "description": "Retrieves the pool information for the given pool identifier.", "type": "object", "required": [ "pools" @@ -227,7 +227,7 @@ "type": "object", "properties": { "limit": { - "description": "An optional parameter specifying the maximum number of pools to return.", + "description": "The amount of pools to return. If unspecified, will default to a value specified by the contract.", "type": [ "integer", "null" @@ -236,14 +236,14 @@ "minimum": 0.0 }, "pool_identifier": { - "description": "If provided, the query will return the pool with the given identifier, otherwise, it will return all pools.", + "description": "An optional parameter specifying the pool identifier to do the query for. If not provided, it will return all pools based on the pagination parameters.", "type": [ "string", "null" ] }, "start_after": { - "description": "An optional parameter specifying what pool identifier to start searching after.", + "description": "An optional parameter specifying what pool (identifier) to start searching after.", "type": [ "string", "null" diff --git a/contracts/liquidity_hub/pool-manager/schema/raw/response_to_pools.json b/contracts/liquidity_hub/pool-manager/schema/raw/response_to_pools.json index 32fdddf6..616acbf2 100644 --- a/contracts/liquidity_hub/pool-manager/schema/raw/response_to_pools.json +++ b/contracts/liquidity_hub/pool-manager/schema/raw/response_to_pools.json @@ -8,7 +8,7 @@ ], "properties": { "pools": { - "description": "The pools on the contract.", + "description": "The pools information responses.", "type": "array", "items": { "$ref": "#/definitions/PoolInfoResponse" @@ -99,7 +99,6 @@ "asset_decimals", "asset_denoms", "assets", - "identifier", "lp_denom", "pool_fees", "pool_type" @@ -128,9 +127,6 @@ "$ref": "#/definitions/Coin" } }, - "identifier": { - "type": "string" - }, "lp_denom": { "description": "The LP denom of the pool.", "type": "string" @@ -155,7 +151,6 @@ "additionalProperties": false }, "PoolInfoResponse": { - "description": "The response for the `Pool` query.", "type": "object", "required": [ "pool_info", diff --git a/contracts/liquidity_hub/pool-manager/src/contract.rs b/contracts/liquidity_hub/pool-manager/src/contract.rs index bb5e7c61..56c4fa58 100644 --- a/contracts/liquidity_hub/pool-manager/src/contract.rs +++ b/contracts/liquidity_hub/pool-manager/src/contract.rs @@ -244,9 +244,16 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> Result Ok(to_json_binary(&queries::get_swap_routes(deps)?)?), QueryMsg::Ownership {} => Ok(to_json_binary(&cw_ownable::get_ownership(deps.storage)?)?), - QueryMsg::Pool { pool_identifier } => { - Ok(to_json_binary(&queries::get_pool(deps, pool_identifier)?)?) - } + QueryMsg::Pools { + pool_identifier, + start_after, + limit, + } => Ok(to_json_binary(&queries::get_pools( + deps, + pool_identifier, + start_after, + limit, + )?)?), QueryMsg::SwapRouteCreator { offer_asset_denom, ask_asset_denom, diff --git a/contracts/liquidity_hub/pool-manager/src/queries.rs b/contracts/liquidity_hub/pool-manager/src/queries.rs index a02e4f3a..82db99f5 100644 --- a/contracts/liquidity_hub/pool-manager/src/queries.rs +++ b/contracts/liquidity_hub/pool-manager/src/queries.rs @@ -3,11 +3,12 @@ use std::cmp::Ordering; use cosmwasm_std::{ coin, ensure, Coin, Decimal256, Deps, Fraction, Order, StdResult, Uint128, Uint256, }; +use cw_storage_plus::Bound; use white_whale_std::pool_manager::{ - AssetDecimalsResponse, Config, PoolInfoResponse, PoolType, ReverseSimulationResponse, - SimulateSwapOperationsResponse, SimulationResponse, SwapOperation, SwapRoute, - SwapRouteCreatorResponse, SwapRouteResponse, SwapRoutesResponse, + AssetDecimalsResponse, Config, PoolInfoResponse, PoolType, PoolsResponse, + ReverseSimulationResponse, SimulateSwapOperationsResponse, SimulationResponse, SwapOperation, + SwapRoute, SwapRouteCreatorResponse, SwapRouteResponse, SwapRoutesResponse, }; use crate::helpers::get_asset_indexes_in_pool; @@ -287,13 +288,62 @@ pub fn get_swap_route_creator( }) } +// settings for pagination +pub(crate) const MAX_LIMIT: u32 = 100; +const DEFAULT_LIMIT: u32 = 10; + +/// Gets the pools in the contract. Returns a [PoolsResponse]. +pub fn get_pools( + deps: Deps, + pool_identifier: Option, + start_after: Option, + limit: Option, +) -> Result { + let pools = if let Some(pool_identifier) = pool_identifier { + vec![get_pool(deps, pool_identifier)?] + } else { + let limit = limit.unwrap_or(DEFAULT_LIMIT).min(MAX_LIMIT) as usize; + let start = cw_utils::calc_range_start_string(start_after).map(Bound::ExclusiveRaw); + + POOLS + .range(deps.storage, start, None, Order::Ascending) + .take(limit) + .map(|item| { + let (_, pool) = item?; + let total_share = deps.querier.query_supply(&pool.lp_denom)?; + + Ok(PoolInfoResponse { + pool_info: pool, + total_share, + }) + }) + .collect::>>()? + + // let pool_infos = POOLS + // .range(deps.storage, start, None, Order::Ascending) + // .take(limit) + // .map(|item| { + // let (_, pool) = item?; + // + // Ok(pool) + // }) + // .collect::>>()?; + // + // for pool in pool_infos.iter() { + // let total_share = deps.querier.query_supply(&pool.lp_denom)?; + // } + }; + + Ok(PoolsResponse { pools }) +} + /// Gets the pool info for a given pool identifier. Returns a [PoolInfoResponse]. -pub fn get_pool(deps: Deps, pool_identifier: String) -> Result { - let pool = POOLS.load(deps.storage, &pool_identifier)?; - let total_share = deps.querier.query_supply(pool.lp_denom)?; +fn get_pool(deps: Deps, pool_identifier: String) -> Result { + let pool_info = POOLS.load(deps.storage, &pool_identifier)?; + let total_share = deps.querier.query_supply(&pool_info.lp_denom)?; Ok(PoolInfoResponse { - pool_info: POOLS.load(deps.storage, &pool_identifier)?, + pool_info, total_share, }) } diff --git a/contracts/liquidity_hub/pool-manager/src/tests/integration_tests.rs b/contracts/liquidity_hub/pool-manager/src/tests/integration_tests.rs index 1ada98dd..cd460830 100644 --- a/contracts/liquidity_hub/pool-manager/src/tests/integration_tests.rs +++ b/contracts/liquidity_hub/pool-manager/src/tests/integration_tests.rs @@ -1918,8 +1918,11 @@ mod swapping { ); // Query pool info to ensure the query is working fine - suite.query_pool_info("whale-uluna".to_string(), |result| { - assert_eq!(result.unwrap().pool_info.asset_decimals, vec![6u8, 6u8]); + suite.query_pools(Some("whale-uluna".to_string()), None, None, |result| { + assert_eq!( + result.unwrap().pools[0].pool_info.asset_decimals, + vec![6u8, 6u8] + ); }); // Lets try to add liquidity @@ -1953,12 +1956,12 @@ mod swapping { })); }, ) - .query_pool_info("whale-uluna".to_string(), |result| { + .query_pools(Some("whale-uluna".to_string()), None, None, |result| { let response = result.unwrap(); assert_eq!( - response.total_share, + response.pools[0].total_share, Coin { - denom: response.pool_info.lp_denom, + denom: response.pools[0].pool_info.lp_denom.clone(), amount: Uint128::from(1_000_000u128), } ); @@ -3235,16 +3238,16 @@ mod provide_liquidity { // 1_000 to the contract, and 1_000_000 to the second, single-side LP assert_eq!(res.unwrap().amount, Uint128::from(2_000_000u128)); }) - .query_pool_info("whale-uluna".to_string(), |res| { + .query_pools(Some("whale-uluna".to_string()), None, None, |res| { let response = res.unwrap(); - let whale = response + let whale = response.pools[0] .pool_info .assets .iter() .find(|coin| coin.denom == "uwhale".to_string()) .unwrap(); - let luna = response + let luna = response.pools[0] .pool_info .assets .iter() @@ -4319,9 +4322,9 @@ mod multiple_pools { result.unwrap(); }, ) - .query_pool_info("whale-uluna-pool-1".to_string(), |result| { + .query_pools(Some("whale-uluna-pool-1".to_string()), None, None, |result| { let response = result.unwrap(); - let pool_info = response.pool_info; + let pool_info = response.pools[0].pool_info.clone(); // swapped 1000 uwhale // fees: @@ -4362,9 +4365,9 @@ mod multiple_pools { result.unwrap(); }, ) - .query_pool_info("whale-uluna-pool-1".to_string(), |result| { + .query_pools(Some("whale-uluna-pool-1".to_string()), None, None, |result| { let response = result.unwrap(); - let pool_info = response.pool_info; + let pool_info = response.pools[0].pool_info.clone(); // swapped 2000 uluna // fees: @@ -4415,9 +4418,9 @@ mod multiple_pools { result.unwrap(); }, ) - .query_pool_info("whale-uluna-pool-2".to_string(), |result| { + .query_pools(Some("whale-uluna-pool-2".to_string()), None, None, |result| { let response = result.unwrap(); - let pool_info = response.pool_info; + let pool_info = response.pools[0].pool_info.clone(); // swapped 1000 uwhale // fees: @@ -4451,9 +4454,9 @@ mod multiple_pools { result.unwrap(); }, ) - .query_pool_info("whale-uluna-pool-2".to_string(), |result| { + .query_pools(Some("whale-uluna-pool-2".to_string()), None, None, |result| { let response = result.unwrap(); - let pool_info = response.pool_info; + let pool_info = response.pools[0].pool_info.clone(); // swapped 2000 uluna // fees: @@ -4505,9 +4508,9 @@ mod multiple_pools { result.unwrap(); }, ) - .query_pool_info("uluna-uusd-pool-1".to_string(), |result| { + .query_pools(Some("uluna-uusd-pool-1".to_string()), None, None, |result| { let response = result.unwrap(); - let pool_info = response.pool_info; + let pool_info = response.pools[0].pool_info.clone(); // swapped 3000 uluna // fees: @@ -4546,9 +4549,9 @@ mod multiple_pools { result.unwrap(); }, ) - .query_pool_info("uluna-uusd-pool-1".to_string(), |result| { + .query_pools(Some("uluna-uusd-pool-1".to_string()), None, None, |result| { let response = result.unwrap(); - let pool_info = response.pool_info; + let pool_info = response.pools[0].pool_info.clone(); // swapped 1500 uusd // fees: @@ -4650,9 +4653,9 @@ mod multiple_pools { |result| { result.unwrap(); }, - ).query_pool_info("whale-uluna-pool-1".to_string(), |result| { + ).query_pools(Some("whale-uluna-pool-1".to_string()), None, None, |result| { let response = result.unwrap(); - let pool_info = response.pool_info; + let pool_info = response.pools[0].pool_info.clone(); // this should have not changed since last time, since we didn't touch this pool assert_eq!(pool_info, PoolInfo { @@ -4664,9 +4667,9 @@ mod multiple_pools { pool_fees: pool_fees_1.clone(), }); }) - .query_pool_info("whale-uluna-pool-2".to_string(), |result| { + .query_pools(Some("whale-uluna-pool-2".to_string()), None, None, |result| { let response = result.unwrap(); - let pool_info = response.pool_info; + let pool_info = response.pools[0].pool_info.clone(); // the swap above was: // SwapComputation { return_amount: Uint128(3988), @@ -4681,9 +4684,9 @@ mod multiple_pools { pool_type: PoolType::ConstantProduct, pool_fees: pool_fees_2.clone(), }); - }).query_pool_info("uluna-uusd-pool-1".to_string(), |result| { + }).query_pools(Some("uluna-uusd-pool-1".to_string()),None, None, |result| { let response = result.unwrap(); - let pool_info = response.pool_info; + let pool_info = response.pools[0].pool_info.clone(); // the swap above was: // SwapComputation { return_amount: Uint128(3169), diff --git a/contracts/liquidity_hub/pool-manager/src/tests/suite.rs b/contracts/liquidity_hub/pool-manager/src/tests/suite.rs index 11880bb8..54034f0a 100644 --- a/contracts/liquidity_hub/pool-manager/src/tests/suite.rs +++ b/contracts/liquidity_hub/pool-manager/src/tests/suite.rs @@ -1,7 +1,7 @@ use cosmwasm_std::testing::MockStorage; use std::cell::RefCell; use white_whale_std::pool_manager::{ - Config, FeatureToggle, PoolInfoResponse, ReverseSimulateSwapOperationsResponse, + Config, FeatureToggle, PoolsResponse, ReverseSimulateSwapOperationsResponse, ReverseSimulationResponse, SimulateSwapOperationsResponse, SimulationResponse, SwapOperation, SwapRoute, SwapRouteCreatorResponse, SwapRouteResponse, SwapRoutesResponse, }; @@ -610,17 +610,23 @@ impl TestingSuite { self } - pub(crate) fn query_pool_info( + pub(crate) fn query_pools( &self, - pool_identifier: String, - result: impl Fn(StdResult), + pool_identifier: Option, + start_after: Option, + limit: Option, + result: impl Fn(StdResult), ) -> &Self { - let pool_info_response: StdResult = self.app.wrap().query_wasm_smart( + let pools_response: StdResult = self.app.wrap().query_wasm_smart( &self.pool_manager_addr, - &white_whale_std::pool_manager::QueryMsg::Pool { pool_identifier }, + &white_whale_std::pool_manager::QueryMsg::Pools { + pool_identifier, + start_after, + limit, + }, ); - result(pool_info_response); + result(pools_response); self } @@ -715,13 +721,15 @@ impl TestingSuite { result: impl Fn(StdResult), ) -> &mut Self { // Get the LP token from Config - let lp_token_response: PoolInfoResponse = self + let lp_token_response: PoolsResponse = self .app .wrap() .query_wasm_smart( &self.pool_manager_addr, - &white_whale_std::pool_manager::QueryMsg::Pool { - pool_identifier: identifier, + &white_whale_std::pool_manager::QueryMsg::Pools { + pool_identifier: Some(identifier), + start_after: None, + limit: None, }, ) .unwrap(); @@ -731,7 +739,7 @@ impl TestingSuite { let balance: Uint128 = self .app .wrap() - .query_balance(sender, lp_token_response.pool_info.lp_denom) + .query_balance(sender, &lp_token_response.pools[0].pool_info.lp_denom) .unwrap() .amount; @@ -834,9 +842,9 @@ impl TestingSuite { ) -> &mut Self { let lp_denom = RefCell::new("".to_string()); - self.query_pool_info(identifier.clone(), |res| { + self.query_pools(Some(identifier.clone()), None, None, |res| { let response = res.unwrap(); - *lp_denom.borrow_mut() = response.pool_info.lp_denom.clone(); + *lp_denom.borrow_mut() = response.pools[0].pool_info.lp_denom.clone(); }); let supply_response = self.app.wrap().query_supply(lp_denom.into_inner()); diff --git a/integration-tests/tests/common/suite.rs b/integration-tests/tests/common/suite.rs index 0c7f88c4..e3d5388a 100644 --- a/integration-tests/tests/common/suite.rs +++ b/integration-tests/tests/common/suite.rs @@ -19,7 +19,7 @@ use white_whale_std::incentive_manager::{ PositionsResponse, }; use white_whale_std::pool_manager::{ - PoolInfoResponse, PoolType, ReverseSimulateSwapOperationsResponse, ReverseSimulationResponse, + PoolType, PoolsResponse, ReverseSimulateSwapOperationsResponse, ReverseSimulationResponse, SimulateSwapOperationsResponse, SimulationResponse, SwapOperation, SwapRoute, SwapRoutesResponse, }; @@ -1015,17 +1015,23 @@ impl TestingSuite { self } - pub(crate) fn _query_pool( + pub(crate) fn _query_pools( &self, - pool_identifier: String, - result: impl Fn(StdResult), + pool_identifier: Option, + start_after: Option, + limit: Option, + result: impl Fn(StdResult), ) -> &Self { - let pool_info_response: StdResult = self.app.wrap().query_wasm_smart( + let pools_response: StdResult = self.app.wrap().query_wasm_smart( &self.pool_manager_addr, - &white_whale_std::pool_manager::QueryMsg::Pool { pool_identifier }, + &white_whale_std::pool_manager::QueryMsg::Pools { + pool_identifier, + start_after, + limit, + }, ); - result(pool_info_response); + result(pools_response); self } diff --git a/packages/white-whale-std/src/pool_manager.rs b/packages/white-whale-std/src/pool_manager.rs index 8823750c..789260f4 100644 --- a/packages/white-whale-std/src/pool_manager.rs +++ b/packages/white-whale-std/src/pool_manager.rs @@ -333,8 +333,17 @@ pub enum QueryMsg { operations: Vec, }, /// Retrieves the pool information for the given pool identifier. - #[returns(PoolInfoResponse)] - Pool { pool_identifier: String }, + #[returns(PoolsResponse)] + Pools { + /// An optional parameter specifying the pool identifier to do the query for. If not + /// provided, it will return all pools based on the pagination parameters. + pool_identifier: Option, + /// An optional parameter specifying what pool (identifier) to start searching after. + start_after: Option, + /// The amount of pools to return. If unspecified, will default to a value specified by + /// the contract. + limit: Option, + }, /// Retrieves the creator of the swap route to get from offer to ask asset. The creator of /// the swap route can remove it. #[returns(SwapRouteCreatorResponse)] @@ -360,7 +369,13 @@ pub struct SwapRoutesResponse { pub swap_routes: Vec, } -/// The response for the `Pool` query. +/// The response for the `Pools` query. +#[cw_serde] +pub struct PoolsResponse { + /// The pools information responses. + pub pools: Vec, +} + #[cw_serde] pub struct PoolInfoResponse { /// The pool information for the given pool identifier. @@ -448,4 +463,4 @@ pub struct ReverseSimulateSwapOperationsResponse { pub struct SwapRouteCreatorResponse { /// The creator of the swap route. pub creator: String, -} \ No newline at end of file +}