-
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.
Merge pull request #28 from propeller-heads/tl/create-tycho-demo
feat: create simple solver for tycho demo
- Loading branch information
Showing
8 changed files
with
566 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,19 @@ | ||
[package] | ||
name = "tutorial" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[[bin]] | ||
name = "tutorial" | ||
path = "src/main.rs" | ||
|
||
[dependencies] | ||
protosim = { path = ".." } | ||
tokio = { version = "1", features = ["full"] } | ||
tracing = "0.1" | ||
tracing-subscriber = "0.3" | ||
ethers = "2.0.13" | ||
clap = { version = "4.5.3", features = ["derive"] } | ||
anyhow = "1.0.79" | ||
tycho-core = { git = "ssh://github.com/propeller-heads/tycho-indexer.git", package = "tycho-core", tag = "0.41.0" } | ||
tycho-client = { git = "ssh://github.com/propeller-heads/tycho-indexer.git", package = "tycho-client", tag = "0.41.0" } |
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,2 @@ | ||
pub mod state; | ||
pub mod tycho; |
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,36 @@ | ||
//! Message structs for state updates | ||
//! | ||
//! A BlockState typically groups changes together based on the latency of the data source, | ||
//! for example, on the Ethereum network, a BlockState is emitted every block and contains | ||
//! all the changes from that block. | ||
use std::collections::HashMap; | ||
|
||
use ethers::types::H160; | ||
|
||
use protosim::protocol::{models::ProtocolComponent, state::ProtocolSim}; | ||
|
||
#[derive(Debug)] | ||
pub struct BlockState { | ||
pub time: u64, | ||
/// The current state of all pools | ||
pub states: HashMap<H160, Box<dyn ProtocolSim>>, | ||
/// The new pairs that were added in this block | ||
pub new_pairs: HashMap<H160, ProtocolComponent>, | ||
/// The pairs that were removed in this block | ||
pub removed_pairs: HashMap<H160, ProtocolComponent>, | ||
} | ||
|
||
impl BlockState { | ||
pub fn new( | ||
time: u64, | ||
states: HashMap<H160, Box<dyn ProtocolSim>>, | ||
new_pairs: HashMap<H160, ProtocolComponent>, | ||
) -> Self { | ||
BlockState { time, states, new_pairs, removed_pairs: HashMap::new() } | ||
} | ||
|
||
pub fn set_removed_pairs(mut self, pairs: HashMap<H160, ProtocolComponent>) -> Self { | ||
self.removed_pairs = pairs; | ||
self | ||
} | ||
} |
Oops, something went wrong.