Skip to content

Commit

Permalink
feat: create simple solver for tycho demo
Browse files Browse the repository at this point in the history
  • Loading branch information
tvinagre committed Oct 31, 2024
1 parent 6d3d437 commit 956b2db
Show file tree
Hide file tree
Showing 9 changed files with 893 additions and 8 deletions.
10 changes: 7 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 14 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
members = ["protosim_py"]

[dependencies]
ethabi = "13.0"
ethabi = "13.0"
ethers = "2.0.13"
serde_json = "1.0.105"
serde = { version = "1.0", features = ["rc"] }
Expand Down Expand Up @@ -35,18 +35,27 @@ foundry-evm = { git = "https://github.com/foundry-rs/foundry", rev = "2544793" }
revm-inspectors = { version = "0.5", features = ["serde"] }
mini-moka = "0.10"
lazy_static = "1.4.0"
clap = { version = "4.5.3", features = ["derive"] }
anyhow = "1.0.79"
tracing-subscriber = { version = "0.3.17", default-features = false, features = [
"env-filter",
"fmt",
] }
petgraph = "0.6.5"
indicatif = "0.17.8"

[dev-dependencies]
mockito = "1.1.1"
warp = "0.3.5"
approx = "0.5.1"
rstest = "0.18.2"
tracing-subscriber = { version = "0.3.17", default-features = false, features = [
"env-filter",
"fmt",
] }

tempfile = "3.13.0"

[[bin]]
name = "simple_searcher"
path = "src/simple_solver.rs"

[features]
default = []
network_tests = []
Expand Down
2 changes: 2 additions & 0 deletions src/data_feed/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod tick;
pub mod tycho;
38 changes: 38 additions & 0 deletions src/data_feed/tick.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//! Message structs for state updates
//!
//! A tick typically groups changes together based on the latency of the data source,
//! for example, on the Ethereum network, a tick is emitted every block and contains
//! all the changes from that block.
//!
//! It is generally a good idea to start any data processing whenever a tick has been fully
//! processed. However, this is not always possible, for example, centralized trading
//! venues do not have periods of latency. In such cases, the ticks should be
//! grouped into regular time intervals, such as 100 milliseconds.
use std::collections::HashMap;

use ethers::types::H160;

use crate::protocol::{models::ProtocolComponent, state::ProtocolSim};

#[derive(Debug)]
pub struct Tick {
pub time: u64,
pub states: HashMap<H160, Box<dyn ProtocolSim>>,
pub new_pairs: HashMap<H160, ProtocolComponent>,
pub removed_pairs: HashMap<H160, ProtocolComponent>,
}

impl Tick {
pub fn new(
time: u64,
states: HashMap<H160, Box<dyn ProtocolSim>>,
new_pairs: HashMap<H160, ProtocolComponent>,
) -> Self {
Tick { 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
}
}
Loading

0 comments on commit 956b2db

Please sign in to comment.