osmosis
osmosis copied to clipboard
Proposal: Support better query for pools
Background
We currently only have a single query for querying all Pools, namely osmosis/gamm/v1beta1/pools.
But with different pools existing under different circumstances, and with over 500+ pools existing in state as of right now, there are situations where a person would like to query pools with a certain filter, or a whitelist.
I would like to propose two different ways of supporting better queries for pools.
Suggested Design
- The first way of doing this can be done via creating a pool query that accepts different filter as its request, something like this
message QueryPoolWithFilterRequest {
int64 minLiquidity = 1;
string poolType = 2;
int64 minPoolAssetNum = 3;
...
}
and then whoever's requesting can use the field that they want to use as a filter, leaving other fields with null value. The response would be returned via iterating over pool state, only returning the pools that goes under the filtered request.
- The second way of doing this is a quite untraditional way of supporting queries, which is done via using
app.toml. We create a field inapp.tomlwhere the node operator can have their own list of whitelist pool ids. Then we have a query, sayQueryPoolsUnsafe, which would non-deterministically only return the state of the pools that are whitelisted in app.toml. Using theQueryPoolsUnsafequery, who ever's querying does not have to go through the process of having to query all states of pools first, and the filtering them within the client side.
Open for discussions on the pros and cons of these ways, and also if we even do need these queries!