Skip to main content
Version: Next

Queries

This document outlines the queries supported by the AMM module.

Params

Fetch the current value of module parameters.

// QueryParamsRequest is request type for the Query/Params RPC method.
message QueryParamsRequest {}

// QueryParamsResponse is response type for the Query/Params RPC method.
message QueryParamsResponse {
// params holds all the parameters of this module.
Params params = 1 [(gogoproto.nullable) = false];
}

PoolToken

Fetch the pool token for a specific pool ID and denomination.

// QueryGetPoolTokenRequest is request type for the Query/GetPoolToken RPC method.
message QueryGetPoolTokenRequest {
// pool_id is the ID of the pool to fetch the token for.
uint64 pool_id = 1;

// denom is the denomination of the token to fetch.
string denom = 2;
}

// QueryGetPoolTokenResponse is response type for the Query/GetPoolToken RPC method.
message QueryGetPoolTokenResponse {
// pool_token is the pool token for the given pool ID and denomination.
PoolToken pool_token = 1 [(gogoproto.nullable) = false];
}

AllPoolToken

Fetch all pool tokens.

message QueryAllPoolTokenRequest {
cosmos.base.query.v1beta1.PageRequest pagination = 1;
string pool_id = 2;
}

message QueryAllPoolTokenResponse {
repeated PoolToken pool_token = 1 [(gogoproto.nullable) = false];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

AllPoolTokenForPool

Fetch all pool tokens for a given pool ID.

message QueryAllPoolTokenForPoolRequest {
uint64 pool_id = 1;
}

message QueryAllPoolTokenForPoolResponse {
repeated PoolToken pool_token = 1 [(gogoproto.nullable) = false];
}

GetPool

Fetch a pool using its ID.

message QueryGetPoolRequest {
uint64 id = 1;
}

message QueryGetPoolResponse {
Pool pool = 1 [(gogoproto.nullable) = false];
}

AllPool

Fetch all pools.

message QueryAllPoolRequest {
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}

message QueryAllPoolResponse {
repeated Pool pool = 1 [(gogoproto.nullable) = false];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

GetWeightedToken

Fetch the weighted token for a specific pool ID and denomination.

message QueryGetWeightedTokenRequest {
uint64 pool_id = 1;
string denom = 2;
}

message QueryGetWeightedTokenResponse {
WeightedToken weighted_token = 1 [(gogoproto.nullable) = false];
}

AllWeightedToken

Fetch all weighted tokens.

message QueryAllWeightedTokenRequest {
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}

message QueryAllWeightedTokenResponse {
repeated WeightedToken weighted_token = 1 [(gogoproto.nullable) = false];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

GetWeightUpdateTiming

Fetch the weight update timing for a specific pool ID.

message QueryGetWeightUpdateTimingRequest {
uint64 pool_id = 1;
}

message QueryGetWeightUpdateTimingResponse {
WeightUpdateTiming weight_update_timing = 1 [(gogoproto.nullable) = false];
}

AllWeightUpdateTiming

Fetch all weight update timings.

message QueryAllWeightUpdateTimingRequest {
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}

message QueryAllWeightUpdateTimingResponse {
repeated WeightUpdateTiming weight_update_timing = 1 [(gogoproto.nullable) = false];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

AllTokenWeight

Fetch all token weights for a pool.

// computing normalized weights requires reading all tokens from the context
// and computing weight for all of them
// therefore, this query is not paginated
message QueryAllPoolTokenWeightRequest {
uint64 pool_id = 1;
}

// computing normalized weights requires reading all tokens from the context
// and computing weight for all of them
// therefore, this query is not paginated
message QueryAllPoolTokenWeightResponse {
repeated TokenWeight token_weight = 1 [(gogoproto.nullable) = false];
}

GetIntroducingPoolToken

Fetch the virtual balance pool token for a given pool ID and denomination. Which represent the virtual balance of an introducing token in a pool.

message QueryGetIntroducingPoolTokenRequest {
uint64 pool_id = 1;
string denom = 2;
}

message QueryGetIntroducingPoolTokenResponse {
VirtualBalancePoolToken introducing_pool_token = 1 [(gogoproto.nullable) = false];
}

AllIntroducingPoolToken

Fetch all virtual balance pool tokens.

message QueryAllIntroducingPoolTokenRequest {
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}

message QueryAllIntroducingPoolTokenResponse {
repeated VirtualBalancePoolToken introducing_pool_token = 1 [(gogoproto.nullable) = false];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

GetExpiringPoolToken

A query to fetch the virtual balance pool token for a given pool ID and denomination, which represents the virtual balance for removing tokens in a pool.

message QueryGetExpiringPoolTokenRequest {
uint64 pool_id = 1;
string denom = 2;
}

message QueryGetExpiringPoolTokenResponse {
VirtualBalancePoolToken expiring_pool_token = 1 [(gogoproto.nullable) = false];
}

AllExpiringPoolToken

A query to fetch all virtual balance pool tokens.

message QueryAllExpiringPoolTokenRequest {
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}

message QueryAllExpiringPoolTokenResponse {
repeated VirtualBalancePoolToken expiring_pool_token = 1 [(gogoproto.nullable) = false];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

LpToken

A query to fetch the liquidity provider (LP) token for a given pool ID.

message QueryLpTokenRequest {
uint64 pool_id = 1;
}

message QueryLpTokenResponse {
PoolToken lp_token = 1 [(gogoproto.nullable) = false];
}

GetYammConfiguration

A query to fetch the YAMM configuration for a given pool ID.

message QueryGetYammConfigurationRequest {
uint64 pool_id = 1;
}

message QueryGetYammConfigurationResponse {
YammConfiguration yamm_configuration = 1 [(gogoproto.nullable) = false];
}

AllYammConfiguration

A query to fetch all YAMM configurations.

message QueryAllYammConfigurationRequest {
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}

message QueryAllYammConfigurationResponse {
repeated YammConfiguration yamm_configuration = 1 [(gogoproto.nullable) = false];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

GetWhitelistedRoute

A query to fetch the whitelisted route for a given input and output token pair.

message QueryGetWhitelistedRouteRequest {
string token_in = 1;
string token_out = 2;
}

message QueryGetWhitelistedRouteResponse {
WhitelistedRoute whitelisted_route = 1 [(gogoproto.nullable) = false];
}

AllWhitelistedRoute

Fetches all whitelisted routes.

message QueryAllWhitelistedRouteRequest {
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}

message QueryAllWhitelistedRouteResponse {
repeated WhitelistedRoute whitelisted_route = 1 [(gogoproto.nullable) = false];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

GetOrder

Retrieves an order using its ID.

message QueryGetOrderRequest {
uint64 id = 1;
}

message QueryGetOrderResponse {
Order order = 1 [(gogoproto.nullable) = false];
}

AllOrder

Fetches all orders.

message QueryAllOrderRequest {
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}

message QueryAllOrderResponse {
repeated Order order = 1 [(gogoproto.nullable) = false];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

GetExecutableOrder

Fetches an executable order using its ID.

message QueryGetExecutableOrderRequest {
uint64 order_id = 1;
}

message QueryGetExecutableOrderResponse {
Order executable_order = 1 [(gogoproto.nullable) = false];
}

AllExecutableOrder

Fetches all executable orders.

message QueryAllExecutableOrderRequest {
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}

message QueryAllExecutableOrderResponse {
repeated Order executable_order = 1 [(gogoproto.nullable) = false];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

GetScheduleOrder

Fetches a scheduled order using its ID.

message QueryGetScheduleOrderRequest {
uint64 order_id = 1;
}

message QueryGetScheduleOrderResponse {
ScheduleOrder schedule_order = 1 [(gogoproto.nullable) = false];
}

AllScheduleOrder

Fetches all scheduled orders.

message QueryAllScheduleOrderRequest {
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}

message QueryAllScheduleOrderResponse {
repeated ScheduleOrder schedule_order = 1 [(gogoproto.nullable) = false];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

OrderStepBounds

Allows user to compute the min and max steps for a given order route.

message QueryOrderStepBoundsRequest {
uint64 pool_id = 1;
string token_in = 2;
string token_out = 3;
bool whitelisted_route = 4;
}

message QueryOrderStepBoundsResponse {
string min_step = 1 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];

string max_step = 2 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}

GetOraclePricePair

Fetches an oracle price pair using its asset ID.

message QueryGetOraclePricePairRequest {
string asset_id = 1;
}

message QueryGetOraclePricePairResponse {
OraclePricePair oracle_price_pair = 1 [(gogoproto.nullable) = false];
}

AllOraclePricePair

Fetches all oracle price pairs.

message QueryAllOraclePricePairRequest {
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}

message QueryAllOraclePricePairResponse {
repeated OraclePricePair oracle_price_pair = 1 [(gogoproto.nullable) = false];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

VaultPauseMode

Checks if the vault is paused.

message QueryVaultPauseModeRequest {}

message QueryVaultPauseModeResponse {
bool paused = 1;
}

GetPendingTokenIntroduction

This query retrieves a pending token introduction for a specified asset and target pool.

message QueryGetPendingTokenIntroductionRequest {
string asset_id = 1;
uint64 target_pool_id = 2;
}

message QueryGetPendingTokenIntroductionResponse {
PendingTokenIntroduction pending_token_introduction = 1 [(gogoproto.nullable) = false];
}

AllPendingTokenIntroduction

This query retrieves all pending token introductions.

message QueryAllPendingTokenIntroductionRequest {
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}

message QueryAllPendingTokenIntroductionResponse {
repeated PendingTokenIntroduction pending_token_introduction = 1 [(gogoproto.nullable) = false];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

YammPoolId

This query fetches a YAMM pool ID for a specified asset.

message QueryYammPoolIdRequest {
string asset_id = 1;
}

message QueryYammPoolIdResponse {
uint64 pool_id = 1;
}

SimulateSingleSwap

This query simulates a single swap and retrieves the resultant output and input amounts.

message QuerySimulateSingleSwapRequest {
Swap swap = 1 [(gogoproto.nullable) = false];
}

message QuerySimulateSingleSwapResponse {
cosmos.base.v1beta1.Coin amount_out = 1 [(gogoproto.nullable) = false];
cosmos.base.v1beta1.Coin amount_in = 2 [(gogoproto.nullable) = false];
// protocol fee does not contain the y_trade fee and refractor fee
// which is paid in case of a yAsset trade
cosmos.base.v1beta1.Coin protocol_fee = 3 [(gogoproto.nullable) = false];
cosmos.base.v1beta1.Coin swap_fee = 4 [(gogoproto.nullable) = false];
}

SimulateInitializePool

This query simulates a pool initialization and retrieves the resultant LPT output and input amounts.

message QuerySimulateInitializePoolRequest {
uint64 pool_id = 1;
repeated cosmos.base.v1beta1.Coin amounts_in = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

message QuerySimulateInitializePoolResponse {
cosmos.base.v1beta1.Coin lpt_out = 1 [(gogoproto.nullable) = false];
repeated cosmos.base.v1beta1.Coin amounts_in = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
repeated cosmos.base.v1beta1.Coin protocol_fee = 3 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

SimulateJoinAllTokensExactLpt

This query simulates joining all tokens in a pool for a specific LPT output and retrieves the resultant LPT output and input amounts.

message QuerySimulateJoinAllTokensExactLptRequest {
uint64 pool_id = 1;
string lpt_out = 2 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}

message QuerySimulateJoinAllTokensExactLptResponse {
cosmos.base.v1beta1.Coin lpt_out = 1 [(gogoproto.nullable) = false];
repeated cosmos.base.v1beta1.Coin amounts_in = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
repeated cosmos.base.v1beta1.Coin protocol_fee = 3 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

SimulateJoinExactTokens

Simulates joining specific tokens in a pool and retrieves the resulting LPT output and input amounts.

message QuerySimulateJoinExactTokensRequest {
uint64 pool_id = 1;
repeated cosmos.base.v1beta1.Coin amounts_in = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

message QuerySimulateJoinExactTokensResponse {
cosmos.base.v1beta1.Coin lpt_out = 1 [(gogoproto.nullable) = false];
repeated cosmos.base.v1beta1.Coin amounts_in = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
repeated cosmos.base.v1beta1.Coin protocol_fee = 3 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
repeated cosmos.base.v1beta1.Coin swap_fee = 4 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

SimulateJoinTokenExactLpt

Simulates adding a specific token to a pool for a particular LPT output and retrieves the resulting LPT output and input amounts.

message QuerySimulateJoinTokenExactLptRequest {
uint64 pool_id = 1;
string lpt_out = 2 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
string token_in = 3;
}

message QuerySimulateJoinTokenExactLptResponse {
cosmos.base.v1beta1.Coin lpt_out = 1 [(gogoproto.nullable) = false];
cosmos.base.v1beta1.Coin amount_in = 2 [(gogoproto.nullable) = false];
cosmos.base.v1beta1.Coin protocol_fee = 3 [(gogoproto.nullable) = false];
cosmos.base.v1beta1.Coin swap_fee = 4 [(gogoproto.nullable) = false];
}

SimulateExitTokenExactLpt

This query simulates the exit of a specific token from a pool with a certain LPT input, returning the resulting LPT input and output amounts.

message QuerySimulateExitTokenExactLptRequest {
uint64 pool_id = 1;
string lpt_in = 2 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
string token_out = 3;
}

message QuerySimulateExitTokenExactLptResponse {
cosmos.base.v1beta1.Coin lpt_in = 1 [(gogoproto.nullable) = false];
cosmos.base.v1beta1.Coin amount_out = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
cosmos.base.v1beta1.Coin protocol_fee = 3 [(gogoproto.nullable) = false];
cosmos.base.v1beta1.Coin swap_fee = 4 [(gogoproto.nullable) = false];
}

SimulateExitExactTokens

This query simulates the exit of specific tokens from a pool, returning the resulting LPT input and output amounts.

message QuerySimulateExitExactTokensRequest {
uint64 pool_id = 1;
repeated cosmos.base.v1beta1.Coin amounts_out = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

message QuerySimulateExitExactTokensResponse {
cosmos.base.v1beta1.Coin lpt_in = 1 [(gogoproto.nullable) = false];
repeated cosmos.base.v1beta1.Coin amounts_out = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
cosmos.base.v1beta1.Coin protocol_fee = 3 [(gogoproto.nullable) = false];
repeated cosmos.base.v1beta1.Coin swap_fee = 4 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

SimulateExitAllTokensExactLpt

This query simulates the exit of all tokens from a pool for a specific LPT input, returning the resulting LPT input and output amounts.

message QuerySimulateExitAllTokensExactLptRequest {
uint64 pool_id = 1;
string lpt_in = 2 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}

message QuerySimulateExitAllTokensExactLptResponse {
cosmos.base.v1beta1.Coin lpt_in = 1 [(gogoproto.nullable) = false];
repeated cosmos.base.v1beta1.Coin amounts_out = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
cosmos.base.v1beta1.Coin protocol_fee = 3 [(gogoproto.nullable) = false];
}

SpotPrice

This query retrieves the spot price of the token_out in terms of token_in. Note that tokens can also be LP tokens of the pool.

message QuerySpotPriceRequest {
uint64 pool_id = 1;
string token_in = 2;
string token_out = 3;
bool apply_fee = 4;
}

message QuerySpotPriceResponse {
string spot_price = 1 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}

SimulateBatchSwap

This query simulates a batch swap operation, providing the resulting input and output amounts.

message QuerySimulateBatchSwapRequest {
SwapType swap_type = 1;
repeated SwapStep steps = 2 [(gogoproto.nullable) = false];
}

message QuerySimulateBatchSwapResponse {
repeated cosmos.base.v1beta1.Coin amounts_in = 1 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
repeated cosmos.base.v1beta1.Coin amounts_out = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
// protocol fee does not contain the y_trade fee and refractor fee
// which is paid in case of a yAsset trade
repeated cosmos.base.v1beta1.Coin swap_protocol_fee = 3 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
repeated cosmos.base.v1beta1.Coin join_exit_protocol_fee = 4 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
repeated cosmos.base.v1beta1.Coin swap_fee = 5 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

SimulateZeroImpactJoinYamm

This query simulates joining a yamm pool with cASSET. The join is executed in two steps: initial refracts provide the required pASSET, then a join to the pool uses the remaining cASSET to acquire pASSETs. The user receives LP tokens and yASSETs minted from refracting.

message QuerySimulateZeroImpactJoinYammRequest {
cosmos.base.v1beta1.Coin c_amount_in = 1 [(gogoproto.nullable) = false];
}

message QuerySimulateZeroImpactJoinYammResponse {
cosmos.base.v1beta1.Coin lpt_out = 1 [(gogoproto.nullable) = false];

repeated cosmos.base.v1beta1.Coin y_out = 2 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];

cosmos.base.v1beta1.Coin refract_fee = 3 [(gogoproto.nullable) = false];

repeated cosmos.base.v1beta1.Coin join_protocol_fee = 4 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];

repeated cosmos.base.v1beta1.Coin swap_fee = 5 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

AllDisabledOrderPair

This query returns a paginated list of all disabled order pairs.

message QueryAllDisabledOrderPairRequest {
cosmos.base.query.v1beta1.PageRequest pagination = 1 [(gogoproto.nullable) = true];
}

message QueryAllDisabledOrderPairResponse {
repeated DisabledOrderPair disabled_order_pair = 1 [(gogoproto.nullable) = false];
cosmos.base.query.v1beta1.PageResponse pagination = 2 [(gogoproto.nullable) = true];
}

OrderPairDisabled

This query can be used to determine whether an order pair is disabled or not.

message QueryOrderPairDisabledRequest {
bool whitelisted_route = 1;
uint64 pool_id = 2;
string token_in = 3;
string token_out = 4;
}

message QueryOrderPairDisabledResponse {
bool disabled = 1;
}