diff --git a/crates/bin/pindexer/src/dex_ex/mod.rs b/crates/bin/pindexer/src/dex_ex/mod.rs index d430ef7150..3d264947f1 100644 --- a/crates/bin/pindexer/src/dex_ex/mod.rs +++ b/crates/bin/pindexer/src/dex_ex/mod.rs @@ -435,8 +435,8 @@ mod summary { now AS ( SELECT price, liquidity FROM snapshots - WHERE time >= $3 - ORDER BY time ASC + WHERE time <= $3 + ORDER BY time DESC LIMIT 1 ), sums AS ( diff --git a/crates/bin/pindexer/src/indexer_ext.rs b/crates/bin/pindexer/src/indexer_ext.rs index 9ff68994f3..9c3e1e6351 100644 --- a/crates/bin/pindexer/src/indexer_ext.rs +++ b/crates/bin/pindexer/src/indexer_ext.rs @@ -1,11 +1,9 @@ -use std::str::FromStr; - pub trait IndexerExt: Sized { - fn with_default_penumbra_app_views(self) -> Self; + fn with_default_penumbra_app_views(self, options: &crate::Options) -> Self; } impl IndexerExt for cometindex::Indexer { - fn with_default_penumbra_app_views(self) -> Self { + fn with_default_penumbra_app_views(self, options: &crate::Options) -> Self { self.with_index(Box::new(crate::block::Block {})) .with_index(Box::new(crate::stake::ValidatorSet {})) .with_index(Box::new(crate::stake::Slashings {})) @@ -13,21 +11,13 @@ impl IndexerExt for cometindex::Indexer { .with_index(Box::new(crate::stake::UndelegationTxs {})) .with_index(Box::new(crate::governance::GovernanceProposals {})) .with_index(Box::new(crate::dex_ex::Component::new( - penumbra_asset::asset::Id::from_str( - // USDC - "passet1w6e7fvgxsy6ccy3m8q0eqcuyw6mh3yzqu3uq9h58nu8m8mku359spvulf6", - ) - .expect("should be able to parse passet"), - 100.0 * 1000_0000.0, + options.indexing_denom, + options.dex_ex_min_liquidity as f64, ))) .with_index(Box::new(crate::supply::Component::new())) .with_index(Box::new(crate::ibc::Component::new())) - .with_index(Box::new(crate::insights::Component::new( - penumbra_asset::asset::Id::from_str( - // USDC - "passet1w6e7fvgxsy6ccy3m8q0eqcuyw6mh3yzqu3uq9h58nu8m8mku359spvulf6", - ) - .ok(), - ))) + .with_index(Box::new(crate::insights::Component::new(Some( + options.indexing_denom, + )))) } } diff --git a/crates/bin/pindexer/src/lib.rs b/crates/bin/pindexer/src/lib.rs index 529b56102f..c8296746b7 100644 --- a/crates/bin/pindexer/src/lib.rs +++ b/crates/bin/pindexer/src/lib.rs @@ -1,7 +1,8 @@ -pub use cometindex::{opt::Options, AppView, ContextualizedEvent, Indexer, PgPool, PgTransaction}; +pub use cometindex::{AppView, ContextualizedEvent, Indexer, PgPool, PgTransaction}; mod indexer_ext; pub use indexer_ext::IndexerExt; +use penumbra_asset::asset; pub mod block; pub mod dex_ex; pub mod ibc; @@ -11,3 +12,18 @@ pub mod stake; pub mod supply; pub mod governance; + +#[derive(clap::Parser, Clone, Debug)] +pub struct Options { + #[clap(flatten)] + pub cometindex: cometindex::opt::Options, + /// The denom to use for indexing related components, of the form passet1... + #[clap( + long, + default_value = "passet1w6e7fvgxsy6ccy3m8q0eqcuyw6mh3yzqu3uq9h58nu8m8mku359spvulf6" + )] + pub indexing_denom: asset::Id, + /// The minimum liquidity for the indexing denom in the dex explorer app view. + #[clap(long, default_value = "100000000")] + pub dex_ex_min_liquidity: u128, +} diff --git a/crates/bin/pindexer/src/main.rs b/crates/bin/pindexer/src/main.rs index fee7ab0f90..4dae1164f3 100644 --- a/crates/bin/pindexer/src/main.rs +++ b/crates/bin/pindexer/src/main.rs @@ -4,9 +4,10 @@ use pindexer::{Indexer, IndexerExt as _, Options}; #[tokio::main] async fn main() -> Result<()> { - Indexer::new(Options::parse()) + let opts = Options::parse(); + Indexer::new(opts.cometindex.clone()) .with_default_tracing() - .with_default_penumbra_app_views() + .with_default_penumbra_app_views(&opts) .run() .await?;