import { PageRequest, PageResponse } from "../../../cosmos/base/query/v1beta1/pagination"; import { SwapAmountInRoute, SwapAmountOutRoute } from "./tx"; import { Any } from "../../../google/protobuf/any"; import { Coin } from "../../../cosmos/base/v1beta1/coin"; import * as _m0 from "protobufjs/minimal"; import { Long, isSet, DeepPartial } from "@osmonauts/helpers"; /** =============================== Pool */ export interface QueryPoolRequest { poolId: Long; } export interface QueryPoolResponse { pool: Any; } /** =============================== Pools */ export interface QueryPoolsRequest { /** pagination defines an optional pagination for the request. */ pagination?: PageRequest; } export interface QueryPoolsResponse { pools: Any[]; /** pagination defines the pagination in the response. */ pagination?: PageResponse; } /** =============================== NumPools */ export interface QueryNumPoolsRequest {} export interface QueryNumPoolsResponse { numPools: Long; } /** =============================== PoolParams */ export interface QueryPoolParamsRequest { poolId: Long; } export interface QueryPoolParamsResponse { params: Any; } /** =============================== PoolLiquidity */ export interface QueryTotalPoolLiquidityRequest { poolId: Long; } export interface QueryTotalPoolLiquidityResponse { liquidity: Coin[]; } /** =============================== TotalShares */ export interface QueryTotalSharesRequest { poolId: Long; } export interface QueryTotalSharesResponse { totalShares: Coin; } /** * QuerySpotPriceRequest defines the gRPC request structure for a SpotPrice * query. */ export interface QuerySpotPriceRequest { poolId: Long; base_asset_denom: string; quote_asset_denom: string; } /** * QuerySpotPriceResponse defines the gRPC response structure for a SpotPrice * query. */ export interface QuerySpotPriceResponse { /** String of the Dec. Ex) 10.203uatom */ spotPrice: string; } /** =============================== EstimateSwapExactAmountIn */ export interface QuerySwapExactAmountInRequest { sender: string; poolId: Long; tokenIn: string; routes: SwapAmountInRoute[]; } export interface QuerySwapExactAmountInResponse { tokenOutAmount: string; } /** =============================== EstimateSwapExactAmountOut */ export interface QuerySwapExactAmountOutRequest { sender: string; poolId: Long; routes: SwapAmountOutRoute[]; tokenOut: string; } export interface QuerySwapExactAmountOutResponse { tokenInAmount: string; } export interface QueryTotalLiquidityRequest {} export interface QueryTotalLiquidityResponse { liquidity: Coin[]; } function createBaseQueryPoolRequest(): QueryPoolRequest { return { poolId: Long.UZERO }; } export const QueryPoolRequest = { encode(message: QueryPoolRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (!message.poolId.isZero()) { writer.uint32(8).uint64(message.poolId); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): QueryPoolRequest { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryPoolRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.poolId = (reader.uint64() as Long); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): QueryPoolRequest { return { poolId: isSet(object.poolId) ? Long.fromString(object.poolId) : Long.UZERO }; }, toJSON(message: QueryPoolRequest): unknown { const obj: any = {}; message.poolId !== undefined && (obj.poolId = (message.poolId || Long.UZERO).toString()); return obj; }, fromPartial(object: DeepPartial): QueryPoolRequest { const message = createBaseQueryPoolRequest(); message.poolId = object.poolId !== undefined && object.poolId !== null ? Long.fromValue(object.poolId) : Long.UZERO; return message; } }; function createBaseQueryPoolResponse(): QueryPoolResponse { return { pool: undefined }; } export const QueryPoolResponse = { encode(message: QueryPoolResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.pool !== undefined) { Any.encode(message.pool, writer.uint32(10).fork()).ldelim(); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): QueryPoolResponse { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryPoolResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.pool = Any.decode(reader, reader.uint32()); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): QueryPoolResponse { return { pool: isSet(object.pool) ? Any.fromJSON(object.pool) : undefined }; }, toJSON(message: QueryPoolResponse): unknown { const obj: any = {}; message.pool !== undefined && (obj.pool = message.pool ? Any.toJSON(message.pool) : undefined); return obj; }, fromPartial(object: DeepPartial): QueryPoolResponse { const message = createBaseQueryPoolResponse(); message.pool = object.pool !== undefined && object.pool !== null ? Any.fromPartial(object.pool) : undefined; return message; } }; function createBaseQueryPoolsRequest(): QueryPoolsRequest { return { pagination: undefined }; } export const QueryPoolsRequest = { encode(message: QueryPoolsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.pagination !== undefined) { PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): QueryPoolsRequest { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryPoolsRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 2: message.pagination = PageRequest.decode(reader, reader.uint32()); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): QueryPoolsRequest { return { pagination: isSet(object.pagination) ? PageRequest.fromJSON(object.pagination) : undefined }; }, toJSON(message: QueryPoolsRequest): unknown { const obj: any = {}; message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) : undefined); return obj; }, fromPartial(object: DeepPartial): QueryPoolsRequest { const message = createBaseQueryPoolsRequest(); message.pagination = object.pagination !== undefined && object.pagination !== null ? PageRequest.fromPartial(object.pagination) : undefined; return message; } }; function createBaseQueryPoolsResponse(): QueryPoolsResponse { return { pools: [], pagination: undefined }; } export const QueryPoolsResponse = { encode(message: QueryPoolsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { for (const v of message.pools) { Any.encode(v!, writer.uint32(10).fork()).ldelim(); } if (message.pagination !== undefined) { PageResponse.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): QueryPoolsResponse { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryPoolsResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.pools.push(Any.decode(reader, reader.uint32())); break; case 2: message.pagination = PageResponse.decode(reader, reader.uint32()); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): QueryPoolsResponse { return { pools: Array.isArray(object?.pools) ? object.pools.map((e: any) => Any.fromJSON(e)) : [], pagination: isSet(object.pagination) ? PageResponse.fromJSON(object.pagination) : undefined }; }, toJSON(message: QueryPoolsResponse): unknown { const obj: any = {}; if (message.pools) { obj.pools = message.pools.map(e => e ? Any.toJSON(e) : undefined); } else { obj.pools = []; } message.pagination !== undefined && (obj.pagination = message.pagination ? PageResponse.toJSON(message.pagination) : undefined); return obj; }, fromPartial(object: DeepPartial): QueryPoolsResponse { const message = createBaseQueryPoolsResponse(); message.pools = object.pools?.map(e => Any.fromPartial(e)) || []; message.pagination = object.pagination !== undefined && object.pagination !== null ? PageResponse.fromPartial(object.pagination) : undefined; return message; } }; function createBaseQueryNumPoolsRequest(): QueryNumPoolsRequest { return {}; } export const QueryNumPoolsRequest = { encode(_: QueryNumPoolsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): QueryNumPoolsRequest { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryNumPoolsRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(_: any): QueryNumPoolsRequest { return {}; }, toJSON(_: QueryNumPoolsRequest): unknown { const obj: any = {}; return obj; }, fromPartial(_: DeepPartial): QueryNumPoolsRequest { const message = createBaseQueryNumPoolsRequest(); return message; } }; function createBaseQueryNumPoolsResponse(): QueryNumPoolsResponse { return { numPools: Long.UZERO }; } export const QueryNumPoolsResponse = { encode(message: QueryNumPoolsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (!message.numPools.isZero()) { writer.uint32(8).uint64(message.numPools); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): QueryNumPoolsResponse { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryNumPoolsResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.numPools = (reader.uint64() as Long); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): QueryNumPoolsResponse { return { numPools: isSet(object.numPools) ? Long.fromString(object.numPools) : Long.UZERO }; }, toJSON(message: QueryNumPoolsResponse): unknown { const obj: any = {}; message.numPools !== undefined && (obj.numPools = (message.numPools || Long.UZERO).toString()); return obj; }, fromPartial(object: DeepPartial): QueryNumPoolsResponse { const message = createBaseQueryNumPoolsResponse(); message.numPools = object.numPools !== undefined && object.numPools !== null ? Long.fromValue(object.numPools) : Long.UZERO; return message; } }; function createBaseQueryPoolParamsRequest(): QueryPoolParamsRequest { return { poolId: Long.UZERO }; } export const QueryPoolParamsRequest = { encode(message: QueryPoolParamsRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (!message.poolId.isZero()) { writer.uint32(8).uint64(message.poolId); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): QueryPoolParamsRequest { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryPoolParamsRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.poolId = (reader.uint64() as Long); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): QueryPoolParamsRequest { return { poolId: isSet(object.poolId) ? Long.fromString(object.poolId) : Long.UZERO }; }, toJSON(message: QueryPoolParamsRequest): unknown { const obj: any = {}; message.poolId !== undefined && (obj.poolId = (message.poolId || Long.UZERO).toString()); return obj; }, fromPartial(object: DeepPartial): QueryPoolParamsRequest { const message = createBaseQueryPoolParamsRequest(); message.poolId = object.poolId !== undefined && object.poolId !== null ? Long.fromValue(object.poolId) : Long.UZERO; return message; } }; function createBaseQueryPoolParamsResponse(): QueryPoolParamsResponse { return { params: undefined }; } export const QueryPoolParamsResponse = { encode(message: QueryPoolParamsResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.params !== undefined) { Any.encode(message.params, writer.uint32(10).fork()).ldelim(); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): QueryPoolParamsResponse { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryPoolParamsResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.params = Any.decode(reader, reader.uint32()); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): QueryPoolParamsResponse { return { params: isSet(object.params) ? Any.fromJSON(object.params) : undefined }; }, toJSON(message: QueryPoolParamsResponse): unknown { const obj: any = {}; message.params !== undefined && (obj.params = message.params ? Any.toJSON(message.params) : undefined); return obj; }, fromPartial(object: DeepPartial): QueryPoolParamsResponse { const message = createBaseQueryPoolParamsResponse(); message.params = object.params !== undefined && object.params !== null ? Any.fromPartial(object.params) : undefined; return message; } }; function createBaseQueryTotalPoolLiquidityRequest(): QueryTotalPoolLiquidityRequest { return { poolId: Long.UZERO }; } export const QueryTotalPoolLiquidityRequest = { encode(message: QueryTotalPoolLiquidityRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (!message.poolId.isZero()) { writer.uint32(8).uint64(message.poolId); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): QueryTotalPoolLiquidityRequest { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryTotalPoolLiquidityRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.poolId = (reader.uint64() as Long); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): QueryTotalPoolLiquidityRequest { return { poolId: isSet(object.poolId) ? Long.fromString(object.poolId) : Long.UZERO }; }, toJSON(message: QueryTotalPoolLiquidityRequest): unknown { const obj: any = {}; message.poolId !== undefined && (obj.poolId = (message.poolId || Long.UZERO).toString()); return obj; }, fromPartial(object: DeepPartial): QueryTotalPoolLiquidityRequest { const message = createBaseQueryTotalPoolLiquidityRequest(); message.poolId = object.poolId !== undefined && object.poolId !== null ? Long.fromValue(object.poolId) : Long.UZERO; return message; } }; function createBaseQueryTotalPoolLiquidityResponse(): QueryTotalPoolLiquidityResponse { return { liquidity: [] }; } export const QueryTotalPoolLiquidityResponse = { encode(message: QueryTotalPoolLiquidityResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { for (const v of message.liquidity) { Coin.encode(v!, writer.uint32(10).fork()).ldelim(); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): QueryTotalPoolLiquidityResponse { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryTotalPoolLiquidityResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.liquidity.push(Coin.decode(reader, reader.uint32())); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): QueryTotalPoolLiquidityResponse { return { liquidity: Array.isArray(object?.liquidity) ? object.liquidity.map((e: any) => Coin.fromJSON(e)) : [] }; }, toJSON(message: QueryTotalPoolLiquidityResponse): unknown { const obj: any = {}; if (message.liquidity) { obj.liquidity = message.liquidity.map(e => e ? Coin.toJSON(e) : undefined); } else { obj.liquidity = []; } return obj; }, fromPartial(object: DeepPartial): QueryTotalPoolLiquidityResponse { const message = createBaseQueryTotalPoolLiquidityResponse(); message.liquidity = object.liquidity?.map(e => Coin.fromPartial(e)) || []; return message; } }; function createBaseQueryTotalSharesRequest(): QueryTotalSharesRequest { return { poolId: Long.UZERO }; } export const QueryTotalSharesRequest = { encode(message: QueryTotalSharesRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (!message.poolId.isZero()) { writer.uint32(8).uint64(message.poolId); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): QueryTotalSharesRequest { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryTotalSharesRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.poolId = (reader.uint64() as Long); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): QueryTotalSharesRequest { return { poolId: isSet(object.poolId) ? Long.fromString(object.poolId) : Long.UZERO }; }, toJSON(message: QueryTotalSharesRequest): unknown { const obj: any = {}; message.poolId !== undefined && (obj.poolId = (message.poolId || Long.UZERO).toString()); return obj; }, fromPartial(object: DeepPartial): QueryTotalSharesRequest { const message = createBaseQueryTotalSharesRequest(); message.poolId = object.poolId !== undefined && object.poolId !== null ? Long.fromValue(object.poolId) : Long.UZERO; return message; } }; function createBaseQueryTotalSharesResponse(): QueryTotalSharesResponse { return { totalShares: undefined }; } export const QueryTotalSharesResponse = { encode(message: QueryTotalSharesResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.totalShares !== undefined) { Coin.encode(message.totalShares, writer.uint32(10).fork()).ldelim(); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): QueryTotalSharesResponse { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryTotalSharesResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.totalShares = Coin.decode(reader, reader.uint32()); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): QueryTotalSharesResponse { return { totalShares: isSet(object.totalShares) ? Coin.fromJSON(object.totalShares) : undefined }; }, toJSON(message: QueryTotalSharesResponse): unknown { const obj: any = {}; message.totalShares !== undefined && (obj.totalShares = message.totalShares ? Coin.toJSON(message.totalShares) : undefined); return obj; }, fromPartial(object: DeepPartial): QueryTotalSharesResponse { const message = createBaseQueryTotalSharesResponse(); message.totalShares = object.totalShares !== undefined && object.totalShares !== null ? Coin.fromPartial(object.totalShares) : undefined; return message; } }; function createBaseQuerySpotPriceRequest(): QuerySpotPriceRequest { return { poolId: Long.UZERO, base_asset_denom: "", quote_asset_denom: "" }; } export const QuerySpotPriceRequest = { encode(message: QuerySpotPriceRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (!message.poolId.isZero()) { writer.uint32(8).uint64(message.poolId); } if (message.base_asset_denom !== "") { writer.uint32(18).string(message.base_asset_denom); } if (message.quote_asset_denom !== "") { writer.uint32(26).string(message.quote_asset_denom); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): QuerySpotPriceRequest { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQuerySpotPriceRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.poolId = (reader.uint64() as Long); break; case 2: message.base_asset_denom = reader.string(); break; case 3: message.quote_asset_denom = reader.string(); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): QuerySpotPriceRequest { return { poolId: isSet(object.poolId) ? Long.fromString(object.poolId) : Long.UZERO, base_asset_denom: isSet(object.base_asset_denom) ? String(object.base_asset_denom) : "", quote_asset_denom: isSet(object.quote_asset_denom) ? String(object.quote_asset_denom) : "" }; }, toJSON(message: QuerySpotPriceRequest): unknown { const obj: any = {}; message.poolId !== undefined && (obj.poolId = (message.poolId || Long.UZERO).toString()); message.base_asset_denom !== undefined && (obj.base_asset_denom = message.base_asset_denom); message.quote_asset_denom !== undefined && (obj.quote_asset_denom = message.quote_asset_denom); return obj; }, fromPartial(object: DeepPartial): QuerySpotPriceRequest { const message = createBaseQuerySpotPriceRequest(); message.poolId = object.poolId !== undefined && object.poolId !== null ? Long.fromValue(object.poolId) : Long.UZERO; message.base_asset_denom = object.base_asset_denom ?? ""; message.quote_asset_denom = object.quote_asset_denom ?? ""; return message; } }; function createBaseQuerySpotPriceResponse(): QuerySpotPriceResponse { return { spotPrice: "" }; } export const QuerySpotPriceResponse = { encode(message: QuerySpotPriceResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.spotPrice !== "") { writer.uint32(10).string(message.spotPrice); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): QuerySpotPriceResponse { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQuerySpotPriceResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.spotPrice = reader.string(); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): QuerySpotPriceResponse { return { spotPrice: isSet(object.spotPrice) ? String(object.spotPrice) : "" }; }, toJSON(message: QuerySpotPriceResponse): unknown { const obj: any = {}; message.spotPrice !== undefined && (obj.spotPrice = message.spotPrice); return obj; }, fromPartial(object: DeepPartial): QuerySpotPriceResponse { const message = createBaseQuerySpotPriceResponse(); message.spotPrice = object.spotPrice ?? ""; return message; } }; function createBaseQuerySwapExactAmountInRequest(): QuerySwapExactAmountInRequest { return { sender: "", poolId: Long.UZERO, tokenIn: "", routes: [] }; } export const QuerySwapExactAmountInRequest = { encode(message: QuerySwapExactAmountInRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.sender !== "") { writer.uint32(10).string(message.sender); } if (!message.poolId.isZero()) { writer.uint32(16).uint64(message.poolId); } if (message.tokenIn !== "") { writer.uint32(26).string(message.tokenIn); } for (const v of message.routes) { SwapAmountInRoute.encode(v!, writer.uint32(34).fork()).ldelim(); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): QuerySwapExactAmountInRequest { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQuerySwapExactAmountInRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.sender = reader.string(); break; case 2: message.poolId = (reader.uint64() as Long); break; case 3: message.tokenIn = reader.string(); break; case 4: message.routes.push(SwapAmountInRoute.decode(reader, reader.uint32())); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): QuerySwapExactAmountInRequest { return { sender: isSet(object.sender) ? String(object.sender) : "", poolId: isSet(object.poolId) ? Long.fromString(object.poolId) : Long.UZERO, tokenIn: isSet(object.tokenIn) ? String(object.tokenIn) : "", routes: Array.isArray(object?.routes) ? object.routes.map((e: any) => SwapAmountInRoute.fromJSON(e)) : [] }; }, toJSON(message: QuerySwapExactAmountInRequest): unknown { const obj: any = {}; message.sender !== undefined && (obj.sender = message.sender); message.poolId !== undefined && (obj.poolId = (message.poolId || Long.UZERO).toString()); message.tokenIn !== undefined && (obj.tokenIn = message.tokenIn); if (message.routes) { obj.routes = message.routes.map(e => e ? SwapAmountInRoute.toJSON(e) : undefined); } else { obj.routes = []; } return obj; }, fromPartial(object: DeepPartial): QuerySwapExactAmountInRequest { const message = createBaseQuerySwapExactAmountInRequest(); message.sender = object.sender ?? ""; message.poolId = object.poolId !== undefined && object.poolId !== null ? Long.fromValue(object.poolId) : Long.UZERO; message.tokenIn = object.tokenIn ?? ""; message.routes = object.routes?.map(e => SwapAmountInRoute.fromPartial(e)) || []; return message; } }; function createBaseQuerySwapExactAmountInResponse(): QuerySwapExactAmountInResponse { return { tokenOutAmount: "" }; } export const QuerySwapExactAmountInResponse = { encode(message: QuerySwapExactAmountInResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.tokenOutAmount !== "") { writer.uint32(10).string(message.tokenOutAmount); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): QuerySwapExactAmountInResponse { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQuerySwapExactAmountInResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.tokenOutAmount = reader.string(); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): QuerySwapExactAmountInResponse { return { tokenOutAmount: isSet(object.tokenOutAmount) ? String(object.tokenOutAmount) : "" }; }, toJSON(message: QuerySwapExactAmountInResponse): unknown { const obj: any = {}; message.tokenOutAmount !== undefined && (obj.tokenOutAmount = message.tokenOutAmount); return obj; }, fromPartial(object: DeepPartial): QuerySwapExactAmountInResponse { const message = createBaseQuerySwapExactAmountInResponse(); message.tokenOutAmount = object.tokenOutAmount ?? ""; return message; } }; function createBaseQuerySwapExactAmountOutRequest(): QuerySwapExactAmountOutRequest { return { sender: "", poolId: Long.UZERO, routes: [], tokenOut: "" }; } export const QuerySwapExactAmountOutRequest = { encode(message: QuerySwapExactAmountOutRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.sender !== "") { writer.uint32(10).string(message.sender); } if (!message.poolId.isZero()) { writer.uint32(16).uint64(message.poolId); } for (const v of message.routes) { SwapAmountOutRoute.encode(v!, writer.uint32(26).fork()).ldelim(); } if (message.tokenOut !== "") { writer.uint32(34).string(message.tokenOut); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): QuerySwapExactAmountOutRequest { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQuerySwapExactAmountOutRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.sender = reader.string(); break; case 2: message.poolId = (reader.uint64() as Long); break; case 3: message.routes.push(SwapAmountOutRoute.decode(reader, reader.uint32())); break; case 4: message.tokenOut = reader.string(); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): QuerySwapExactAmountOutRequest { return { sender: isSet(object.sender) ? String(object.sender) : "", poolId: isSet(object.poolId) ? Long.fromString(object.poolId) : Long.UZERO, routes: Array.isArray(object?.routes) ? object.routes.map((e: any) => SwapAmountOutRoute.fromJSON(e)) : [], tokenOut: isSet(object.tokenOut) ? String(object.tokenOut) : "" }; }, toJSON(message: QuerySwapExactAmountOutRequest): unknown { const obj: any = {}; message.sender !== undefined && (obj.sender = message.sender); message.poolId !== undefined && (obj.poolId = (message.poolId || Long.UZERO).toString()); if (message.routes) { obj.routes = message.routes.map(e => e ? SwapAmountOutRoute.toJSON(e) : undefined); } else { obj.routes = []; } message.tokenOut !== undefined && (obj.tokenOut = message.tokenOut); return obj; }, fromPartial(object: DeepPartial): QuerySwapExactAmountOutRequest { const message = createBaseQuerySwapExactAmountOutRequest(); message.sender = object.sender ?? ""; message.poolId = object.poolId !== undefined && object.poolId !== null ? Long.fromValue(object.poolId) : Long.UZERO; message.routes = object.routes?.map(e => SwapAmountOutRoute.fromPartial(e)) || []; message.tokenOut = object.tokenOut ?? ""; return message; } }; function createBaseQuerySwapExactAmountOutResponse(): QuerySwapExactAmountOutResponse { return { tokenInAmount: "" }; } export const QuerySwapExactAmountOutResponse = { encode(message: QuerySwapExactAmountOutResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.tokenInAmount !== "") { writer.uint32(10).string(message.tokenInAmount); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): QuerySwapExactAmountOutResponse { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQuerySwapExactAmountOutResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.tokenInAmount = reader.string(); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): QuerySwapExactAmountOutResponse { return { tokenInAmount: isSet(object.tokenInAmount) ? String(object.tokenInAmount) : "" }; }, toJSON(message: QuerySwapExactAmountOutResponse): unknown { const obj: any = {}; message.tokenInAmount !== undefined && (obj.tokenInAmount = message.tokenInAmount); return obj; }, fromPartial(object: DeepPartial): QuerySwapExactAmountOutResponse { const message = createBaseQuerySwapExactAmountOutResponse(); message.tokenInAmount = object.tokenInAmount ?? ""; return message; } }; function createBaseQueryTotalLiquidityRequest(): QueryTotalLiquidityRequest { return {}; } export const QueryTotalLiquidityRequest = { encode(_: QueryTotalLiquidityRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): QueryTotalLiquidityRequest { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryTotalLiquidityRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(_: any): QueryTotalLiquidityRequest { return {}; }, toJSON(_: QueryTotalLiquidityRequest): unknown { const obj: any = {}; return obj; }, fromPartial(_: DeepPartial): QueryTotalLiquidityRequest { const message = createBaseQueryTotalLiquidityRequest(); return message; } }; function createBaseQueryTotalLiquidityResponse(): QueryTotalLiquidityResponse { return { liquidity: [] }; } export const QueryTotalLiquidityResponse = { encode(message: QueryTotalLiquidityResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { for (const v of message.liquidity) { Coin.encode(v!, writer.uint32(10).fork()).ldelim(); } return writer; }, decode(input: _m0.Reader | Uint8Array, length?: number): QueryTotalLiquidityResponse { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryTotalLiquidityResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.liquidity.push(Coin.decode(reader, reader.uint32())); break; default: reader.skipType(tag & 7); break; } } return message; }, fromJSON(object: any): QueryTotalLiquidityResponse { return { liquidity: Array.isArray(object?.liquidity) ? object.liquidity.map((e: any) => Coin.fromJSON(e)) : [] }; }, toJSON(message: QueryTotalLiquidityResponse): unknown { const obj: any = {}; if (message.liquidity) { obj.liquidity = message.liquidity.map(e => e ? Coin.toJSON(e) : undefined); } else { obj.liquidity = []; } return obj; }, fromPartial(object: DeepPartial): QueryTotalLiquidityResponse { const message = createBaseQueryTotalLiquidityResponse(); message.liquidity = object.liquidity?.map(e => Coin.fromPartial(e)) || []; return message; } };