Skip to content

Commit

Permalink
Merge pull request #7 from darkforestry/feat/serialize
Browse files Browse the repository at this point in the history
Feat/serialize
  • Loading branch information
0xKitsune authored Mar 24, 2023
2 parents 0826b83 + c24652f commit 13a5049
Show file tree
Hide file tree
Showing 8 changed files with 299 additions and 328 deletions.
605 changes: 285 additions & 320 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "damms"
version = "0.1.0"
version = "0.1.1"
edition = "2021"


[dependencies]
ethers = { version = "2.0.0", default-features = false, features = ["abigen", "ipc", "rustls"] }
ethers = { version = "2.0.1", default-features = false, features = ["abigen", "ipc", "rustls"] }
tokio = { version = "1.21.0", features = ["full"] }
futures = "0.3.24"
indicatif = "0.17.1"
Expand Down
3 changes: 2 additions & 1 deletion src/dex/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use ethers::{
types::{BlockNumber, Filter, Log, ValueOrArray, H160, H256, U64},
};
use indicatif::ProgressBar;
use serde::{Deserialize, Serialize};

use crate::{
abi, batch_requests,
Expand All @@ -18,7 +19,7 @@ use self::{uniswap_v2::UniswapV2Dex, uniswap_v3::UniswapV3Dex};
pub mod uniswap_v2;
pub mod uniswap_v3;

#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub enum Dex {
UniswapV2(UniswapV2Dex),
UniswapV3(UniswapV3Dex),
Expand Down
3 changes: 2 additions & 1 deletion src/dex/uniswap_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use ethers::{
types::{BlockNumber, Log, H160, H256, U256},
};
use indicatif::ProgressBar;
use serde::{Deserialize, Serialize};

use crate::{
abi, batch_requests,
Expand All @@ -16,7 +17,7 @@ use crate::{

use super::DexVariant;

#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub struct UniswapV2Dex {
pub factory_address: H160,
pub creation_block: BlockNumber,
Expand Down
3 changes: 2 additions & 1 deletion src/dex/uniswap_v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use ethers::{
types::{BlockNumber, Log, ValueOrArray, H160, H256, U256},
};
use indicatif::ProgressBar;
use serde::{Deserialize, Serialize};

use crate::{
errors::CFMMError,
Expand All @@ -18,7 +19,7 @@ use crate::{

use super::DexVariant;

#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub struct UniswapV3Dex {
pub factory_address: H160,
pub creation_block: BlockNumber,
Expand Down
3 changes: 2 additions & 1 deletion src/pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use ethers::{
providers::Middleware,
types::{Log, H160, U256},
};
use serde::{Deserialize, Serialize};

use crate::{
dex::{self, DexVariant},
Expand All @@ -16,7 +17,7 @@ pub mod uniswap_v3;
pub use uniswap_v2::UniswapV2Pool;
pub use uniswap_v3::UniswapV3Pool;

#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
pub enum Pool {
UniswapV2(UniswapV2Pool),
UniswapV3(UniswapV3Pool),
Expand Down
3 changes: 2 additions & 1 deletion src/pool/uniswap_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use ethers::{
providers::Middleware,
types::{Log, H160, H256, U256},
};
use serde::{Deserialize, Serialize};

use crate::{
abi, batch_requests,
Expand All @@ -18,7 +19,7 @@ pub const SYNC_EVENT_SIGNATURE: H256 = H256([
199, 139, 229, 14, 6, 43, 3, 169, 255, 251, 186, 209,
]);

#[derive(Debug, Clone, Copy, Default)]
#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize)]
pub struct UniswapV2Pool {
pub address: H160,
pub token_a: H160,
Expand Down
3 changes: 2 additions & 1 deletion src/pool/uniswap_v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use ethers::{
types::{Log, H160, H256, I256, U256, U64},
};
use num_bigfloat::BigFloat;
use serde::{Deserialize, Serialize};

use crate::{
abi, batch_requests,
Expand All @@ -22,7 +23,7 @@ pub const SWAP_EVENT_SIGNATURE: H256 = H256([
pub const U256_TWO: U256 = U256([2, 0, 0, 0]);
pub const Q128: U256 = U256([0, 0, 1, 0]);
pub const Q224: U256 = U256([0, 0, 0, 4294967296]);
#[derive(Clone, Copy, Debug, Default)]
#[derive(Clone, Copy, Debug, Default, Serialize, Deserialize)]
pub struct UniswapV3Pool {
pub address: H160,
pub token_a: H160,
Expand Down

0 comments on commit 13a5049

Please sign in to comment.