-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: Make price printer an example Running the example is now very simple. * chore: Add price explorer example * chore: format --------- Co-authored-by: kayibal <[email protected]>
- Loading branch information
Showing
11 changed files
with
676 additions
and
293 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Price Printer | ||
|
||
This example allows you to list all pools over a certain tvl threshold and explore | ||
quotes from each pool. | ||
|
||
|
||
## How to run | ||
|
||
```bash | ||
export TYCHO_API_TOKEN=sampletoken | ||
RUST_LOG=info cargo run --example explorer -- --tvl 1000 | ||
``` |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
pub mod data_feed; | ||
mod ui; | ||
|
||
extern crate tycho_simulation; | ||
|
||
use clap::Parser; | ||
use data_feed::{state::BlockState, tycho}; | ||
use futures::future::select_all; | ||
use std::env; | ||
use tokio::{sync::mpsc, task::JoinHandle}; | ||
|
||
#[derive(Parser)] | ||
struct Cli { | ||
/// The tvl threshold to filter the graph by | ||
#[arg(short, long, default_value_t = 1000.0)] | ||
tvl_threshold: f64, | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
// Parse command-line arguments into a Cli struct | ||
let cli = Cli::parse(); | ||
|
||
let tycho_url = | ||
env::var("TYCHO_URL").unwrap_or_else(|_| "tycho-beta.propellerheads.xyz".to_string()); | ||
let tycho_api_key: String = | ||
env::var("TYCHO_API_KEY").unwrap_or_else(|_| "sampletoken".to_string()); | ||
|
||
// Create communication channels for inter-thread communication | ||
let (tick_tx, tick_rx) = mpsc::channel::<BlockState>(12); | ||
|
||
let tycho_message_processor: JoinHandle<anyhow::Result<()>> = tokio::spawn(async move { | ||
tycho::process_messages(tycho_url, Some(tycho_api_key), tick_tx, cli.tvl_threshold).await; | ||
anyhow::Result::Ok(()) | ||
}); | ||
|
||
let terminal = ratatui::init(); | ||
let terminal_app = tokio::spawn(async move { | ||
ui::App::new(tick_rx) | ||
.run(terminal) | ||
.await | ||
}); | ||
let tasks = [terminal_app, tycho_message_processor]; | ||
let _ = select_all(tasks).await; | ||
ratatui::restore(); | ||
} |
Oops, something went wrong.