use osmosis_std_derive::CosmwasmExt;
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(
Clone,
PartialEq,
Eq,
::prost::Message,
::serde::Serialize,
::serde::Deserialize,
::schemars::JsonSchema,
CosmwasmExt,
)]
#[proto_message(type_url = "/osmosis.twap.v1beta1.TwapRecord")]
pub struct TwapRecord {
#[prost(uint64, tag = "1")]
#[serde(alias = "poolID")]
#[serde(
serialize_with = "crate::serde::as_str::serialize",
deserialize_with = "crate::serde::as_str::deserialize"
)]
pub pool_id: u64,
#[prost(string, tag = "2")]
pub asset0_denom: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub asset1_denom: ::prost::alloc::string::String,
#[prost(int64, tag = "4")]
#[serde(
serialize_with = "crate::serde::as_str::serialize",
deserialize_with = "crate::serde::as_str::deserialize"
)]
pub height: i64,
#[prost(message, optional, tag = "5")]
pub time: ::core::option::Option<crate::shim::Timestamp>,
#[prost(string, tag = "6")]
pub p0_last_spot_price: ::prost::alloc::string::String,
#[prost(string, tag = "7")]
pub p1_last_spot_price: ::prost::alloc::string::String,
#[prost(string, tag = "8")]
pub p0_arithmetic_twap_accumulator: ::prost::alloc::string::String,
#[prost(string, tag = "9")]
pub p1_arithmetic_twap_accumulator: ::prost::alloc::string::String,
#[prost(string, tag = "10")]
pub geometric_twap_accumulator: ::prost::alloc::string::String,
#[prost(message, optional, tag = "11")]
pub last_error_time: ::core::option::Option<crate::shim::Timestamp>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(
Clone,
PartialEq,
Eq,
::prost::Message,
::serde::Serialize,
::serde::Deserialize,
::schemars::JsonSchema,
CosmwasmExt,
)]
#[proto_message(type_url = "/osmosis.twap.v1beta1.Params")]
pub struct Params {
#[prost(string, tag = "1")]
#[serde(alias = "prune_epochIDentifier")]
pub prune_epoch_identifier: ::prost::alloc::string::String,
#[prost(message, optional, tag = "2")]
pub record_history_keep_period: ::core::option::Option<crate::shim::Duration>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(
Clone,
PartialEq,
Eq,
::prost::Message,
::serde::Serialize,
::serde::Deserialize,
::schemars::JsonSchema,
CosmwasmExt,
)]
#[proto_message(type_url = "/osmosis.twap.v1beta1.GenesisState")]
pub struct GenesisState {
#[prost(message, repeated, tag = "1")]
pub twaps: ::prost::alloc::vec::Vec<TwapRecord>,
#[prost(message, optional, tag = "2")]
pub params: ::core::option::Option<Params>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(
Clone,
PartialEq,
Eq,
::prost::Message,
::serde::Serialize,
::serde::Deserialize,
::schemars::JsonSchema,
CosmwasmExt,
)]
#[proto_message(type_url = "/osmosis.twap.v1beta1.ArithmeticTwapRequest")]
#[proto_query(
path = "/osmosis.twap.v1beta1.Query/ArithmeticTwap",
response_type = ArithmeticTwapResponse
)]
pub struct ArithmeticTwapRequest {
#[prost(uint64, tag = "1")]
#[serde(alias = "poolID")]
#[serde(
serialize_with = "crate::serde::as_str::serialize",
deserialize_with = "crate::serde::as_str::deserialize"
)]
pub pool_id: u64,
#[prost(string, tag = "2")]
pub base_asset: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub quote_asset: ::prost::alloc::string::String,
#[prost(message, optional, tag = "4")]
pub start_time: ::core::option::Option<crate::shim::Timestamp>,
#[prost(message, optional, tag = "5")]
pub end_time: ::core::option::Option<crate::shim::Timestamp>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(
Clone,
PartialEq,
Eq,
::prost::Message,
::serde::Serialize,
::serde::Deserialize,
::schemars::JsonSchema,
CosmwasmExt,
)]
#[proto_message(type_url = "/osmosis.twap.v1beta1.ArithmeticTwapResponse")]
pub struct ArithmeticTwapResponse {
#[prost(string, tag = "1")]
pub arithmetic_twap: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(
Clone,
PartialEq,
Eq,
::prost::Message,
::serde::Serialize,
::serde::Deserialize,
::schemars::JsonSchema,
CosmwasmExt,
)]
#[proto_message(type_url = "/osmosis.twap.v1beta1.ArithmeticTwapToNowRequest")]
#[proto_query(
path = "/osmosis.twap.v1beta1.Query/ArithmeticTwapToNow",
response_type = ArithmeticTwapToNowResponse
)]
pub struct ArithmeticTwapToNowRequest {
#[prost(uint64, tag = "1")]
#[serde(alias = "poolID")]
#[serde(
serialize_with = "crate::serde::as_str::serialize",
deserialize_with = "crate::serde::as_str::deserialize"
)]
pub pool_id: u64,
#[prost(string, tag = "2")]
pub base_asset: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub quote_asset: ::prost::alloc::string::String,
#[prost(message, optional, tag = "4")]
pub start_time: ::core::option::Option<crate::shim::Timestamp>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(
Clone,
PartialEq,
Eq,
::prost::Message,
::serde::Serialize,
::serde::Deserialize,
::schemars::JsonSchema,
CosmwasmExt,
)]
#[proto_message(type_url = "/osmosis.twap.v1beta1.ArithmeticTwapToNowResponse")]
pub struct ArithmeticTwapToNowResponse {
#[prost(string, tag = "1")]
pub arithmetic_twap: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(
Clone,
PartialEq,
Eq,
::prost::Message,
::serde::Serialize,
::serde::Deserialize,
::schemars::JsonSchema,
CosmwasmExt,
)]
#[proto_message(type_url = "/osmosis.twap.v1beta1.GeometricTwapRequest")]
#[proto_query(
path = "/osmosis.twap.v1beta1.Query/GeometricTwap",
response_type = GeometricTwapResponse
)]
pub struct GeometricTwapRequest {
#[prost(uint64, tag = "1")]
#[serde(alias = "poolID")]
#[serde(
serialize_with = "crate::serde::as_str::serialize",
deserialize_with = "crate::serde::as_str::deserialize"
)]
pub pool_id: u64,
#[prost(string, tag = "2")]
pub base_asset: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub quote_asset: ::prost::alloc::string::String,
#[prost(message, optional, tag = "4")]
pub start_time: ::core::option::Option<crate::shim::Timestamp>,
#[prost(message, optional, tag = "5")]
pub end_time: ::core::option::Option<crate::shim::Timestamp>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(
Clone,
PartialEq,
Eq,
::prost::Message,
::serde::Serialize,
::serde::Deserialize,
::schemars::JsonSchema,
CosmwasmExt,
)]
#[proto_message(type_url = "/osmosis.twap.v1beta1.GeometricTwapResponse")]
pub struct GeometricTwapResponse {
#[prost(string, tag = "1")]
pub geometric_twap: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(
Clone,
PartialEq,
Eq,
::prost::Message,
::serde::Serialize,
::serde::Deserialize,
::schemars::JsonSchema,
CosmwasmExt,
)]
#[proto_message(type_url = "/osmosis.twap.v1beta1.GeometricTwapToNowRequest")]
#[proto_query(
path = "/osmosis.twap.v1beta1.Query/GeometricTwapToNow",
response_type = GeometricTwapToNowResponse
)]
pub struct GeometricTwapToNowRequest {
#[prost(uint64, tag = "1")]
#[serde(alias = "poolID")]
#[serde(
serialize_with = "crate::serde::as_str::serialize",
deserialize_with = "crate::serde::as_str::deserialize"
)]
pub pool_id: u64,
#[prost(string, tag = "2")]
pub base_asset: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub quote_asset: ::prost::alloc::string::String,
#[prost(message, optional, tag = "4")]
pub start_time: ::core::option::Option<crate::shim::Timestamp>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(
Clone,
PartialEq,
Eq,
::prost::Message,
::serde::Serialize,
::serde::Deserialize,
::schemars::JsonSchema,
CosmwasmExt,
)]
#[proto_message(type_url = "/osmosis.twap.v1beta1.GeometricTwapToNowResponse")]
pub struct GeometricTwapToNowResponse {
#[prost(string, tag = "1")]
pub geometric_twap: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(
Clone,
PartialEq,
Eq,
::prost::Message,
::serde::Serialize,
::serde::Deserialize,
::schemars::JsonSchema,
CosmwasmExt,
)]
#[proto_message(type_url = "/osmosis.twap.v1beta1.ParamsRequest")]
#[proto_query(
path = "/osmosis.twap.v1beta1.Query/Params",
response_type = ParamsResponse
)]
pub struct ParamsRequest {}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(
Clone,
PartialEq,
Eq,
::prost::Message,
::serde::Serialize,
::serde::Deserialize,
::schemars::JsonSchema,
CosmwasmExt,
)]
#[proto_message(type_url = "/osmosis.twap.v1beta1.ParamsResponse")]
pub struct ParamsResponse {
#[prost(message, optional, tag = "1")]
pub params: ::core::option::Option<Params>,
}
pub struct TwapQuerier<'a, Q: cosmwasm_std::CustomQuery> {
querier: &'a cosmwasm_std::QuerierWrapper<'a, Q>,
}
impl<'a, Q: cosmwasm_std::CustomQuery> TwapQuerier<'a, Q> {
pub fn new(querier: &'a cosmwasm_std::QuerierWrapper<'a, Q>) -> Self {
Self { querier }
}
pub fn params(&self) -> Result<ParamsResponse, cosmwasm_std::StdError> {
ParamsRequest {}.query(self.querier)
}
pub fn arithmetic_twap(
&self,
pool_id: u64,
base_asset: ::prost::alloc::string::String,
quote_asset: ::prost::alloc::string::String,
start_time: ::core::option::Option<crate::shim::Timestamp>,
end_time: ::core::option::Option<crate::shim::Timestamp>,
) -> Result<ArithmeticTwapResponse, cosmwasm_std::StdError> {
ArithmeticTwapRequest {
pool_id,
base_asset,
quote_asset,
start_time,
end_time,
}
.query(self.querier)
}
pub fn arithmetic_twap_to_now(
&self,
pool_id: u64,
base_asset: ::prost::alloc::string::String,
quote_asset: ::prost::alloc::string::String,
start_time: ::core::option::Option<crate::shim::Timestamp>,
) -> Result<ArithmeticTwapToNowResponse, cosmwasm_std::StdError> {
ArithmeticTwapToNowRequest {
pool_id,
base_asset,
quote_asset,
start_time,
}
.query(self.querier)
}
pub fn geometric_twap(
&self,
pool_id: u64,
base_asset: ::prost::alloc::string::String,
quote_asset: ::prost::alloc::string::String,
start_time: ::core::option::Option<crate::shim::Timestamp>,
end_time: ::core::option::Option<crate::shim::Timestamp>,
) -> Result<GeometricTwapResponse, cosmwasm_std::StdError> {
GeometricTwapRequest {
pool_id,
base_asset,
quote_asset,
start_time,
end_time,
}
.query(self.querier)
}
pub fn geometric_twap_to_now(
&self,
pool_id: u64,
base_asset: ::prost::alloc::string::String,
quote_asset: ::prost::alloc::string::String,
start_time: ::core::option::Option<crate::shim::Timestamp>,
) -> Result<GeometricTwapToNowResponse, cosmwasm_std::StdError> {
GeometricTwapToNowRequest {
pool_id,
base_asset,
quote_asset,
start_time,
}
.query(self.querier)
}
}