Skip to content

Commit

Permalink
events-collector: events-collector-api: initialize event types
Browse files Browse the repository at this point in the history
  • Loading branch information
akirillo committed Sep 11, 2024
1 parent edcc6a6 commit 6d8bd8f
Show file tree
Hide file tree
Showing 14 changed files with 202 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ target/

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

/.vscode
15 changes: 15 additions & 0 deletions Cargo.lock

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

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
"funds-manager/funds-manager-api",
"funds-manager/funds-manager-server",
"price-reporter",
"events-collector/events-collector-api",
]

[profile.bench]
Expand Down Expand Up @@ -39,3 +40,7 @@ diesel-async = { version = "0.4" }

# === Misc Dependencies === #
tracing = "0.1"
uuid = { version = "1.8", features = ["v4"] }
serde = { version = "1", features = ["derive"] }
serde_json = { version = "1" }
tokio = { version = "1.37", features = ["full"] }
4 changes: 2 additions & 2 deletions compliance/compliance-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ version = "0.1.0"
edition = "2021"

[dependencies]
serde = { version = "1", features = ["derive"] }
serde_json = { version = "1" }
serde = { workspace = true }
serde_json = { workspace = true }
6 changes: 3 additions & 3 deletions compliance/compliance-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ renegade-util = { workspace = true }
# === Misc === #
clap = { version = "4.5", features = ["derive", "env"] }
reqwest = { version = "0.12", features = ["json"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tokio = { version = "1.37", features = ["full"] }
serde = { workspace = true }
serde_json = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
6 changes: 3 additions & 3 deletions dealer/renegade-dealer-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ ark-mpc = { git = "https://github.com/renegade-fi/ark-mpc.git" }

k256 = "0.13"

serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
uuid = "1.8"
serde = { workspace = true }
serde_json = { workspace = true }
uuid = { workspace = true }

[dev-dependencies]
rand = "0.8"
6 changes: 3 additions & 3 deletions dealer/renegade-dealer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ base64 = "0.22"
clap = { version = "4.5", features = ["derive"] }
itertools = "0.12"
rand = "0.8"
serde_json = "1.0"
tokio = { version = "1.21", features = ["full"] }
uuid = { version = "1.8", features = ["v4"] }
serde_json = { workspace = true }
tokio = { workspace = true }
uuid = { workspace = true }

[dev-dependencies]
k256 = "0.13"
18 changes: 18 additions & 0 deletions events-collector/events-collector-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "events-collector-api"
version = "0.1.0"
edition = "2021"

[dependencies]

# === Renegade === #
renegade-circuit-types = { workspace = true }
renegade-common = { workspace = true }

# === Blockchain === #
alloy-primitives = { version = "=0.7.7", features = ["serde"] }

# === Misc === #
serde = { workspace = true }
serde_json = { workspace = true }
uuid = { workspace = true }
9 changes: 9 additions & 0 deletions events-collector/events-collector-api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//! The API for the events collector

#![deny(unsafe_code)]
#![deny(missing_docs)]
#![deny(clippy::needless_pass_by_value)]
#![deny(clippy::needless_pass_by_ref_mut)]
#![deny(clippy::missing_docs_in_private_items)]

pub mod types;
127 changes: 127 additions & 0 deletions events-collector/events-collector-api/src/types/events.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
//! Event types collected by the events collector

use alloy_primitives::{Address, U256};
use renegade_circuit_types::order::OrderSide;
use renegade_common::types::exchange::Exchange;
use serde::{Deserialize, Serialize};
use uuid::Uuid;

/// Wallet creation event
#[derive(Serialize, Deserialize)]
pub struct WalletCreation {
/// The wallet ID
pub wallet_id: Uuid,
}

/// Deposit event
#[derive(Serialize, Deserialize)]
pub struct Deposit {
/// The wallet ID
pub wallet_id: Uuid,
/// The mint of the asset being deposited
pub mint: Address,
/// The amount of the deposit
pub amount: U256,
}

/// Withdrawal event
#[derive(Serialize, Deserialize)]
pub struct Withdrawal {
/// The wallet ID
pub wallet_id: Uuid,
/// The mint of the asset being withdrawn
pub mint: Address,
/// The amount of the withdrawal
pub amount: U256,
}

/// Order placement event
#[derive(Serialize, Deserialize)]
pub struct OrderPlacement {
/// The ID of the wallet placing the order
pub wallet_id: Uuid,
/// The ID of the order being placed
pub order_id: Uuid,
/// The mint of the base asset in the order
pub base_mint: Address,
/// The mint of the quote asset in the order
pub quote_mint: Address,
/// The amount of the base asset in the order
pub amount: U256,
/// The side of the order
pub side: OrderSide,
}

/// Order cancellation event
#[derive(Serialize, Deserialize)]
pub struct OrderCancellation {
/// The ID of the wallet cancelling the order.
///
/// While not strictly necessary, we include the wallet ID
/// because order IDs can get overwritten.
pub wallet_id: Uuid,
/// The ID of the order being cancelled
pub order_id: Uuid,
}

/// Match event
#[derive(Serialize, Deserialize)]
pub struct Match {
/// The ID of the first wallet in the match.
///
/// While not strictly necessary, we include the wallet ID
/// because order IDs can get overwritten.
pub wallet_id_0: Uuid,
/// The ID of the second wallet in the match.
///
/// While not strictly necessary, we include the wallet ID
/// because order IDs can get overwritten.
pub wallet_id_1: Uuid,
/// The ID of the first order in the match
pub order_id_0: Uuid,
/// The ID of the second order in the match
pub order_id_1: Uuid,
/// The mint of the base asset in the match
pub base_mint: Address,
/// The mint of the quote asset in the match
pub quote_mint: Address,
/// The amount of the base asset exchanged in the match
pub base_amount: U256,
/// The amount of the quote asset exchanged in the match
pub quote_amount: U256,
}

/// Fee payment event
#[derive(Serialize, Deserialize)]
pub struct FeePayment {
/// The ID of the wallet paying the fee
pub wallet_id: Uuid,
/// The mint of the asset being paid
pub mint: Address,
/// The amount of the fee
pub amount: U256,
}

/// Fee collection event
#[derive(Serialize, Deserialize)]
pub struct FeeCollection {
/// The ID of the wallet collecting the fee
pub wallet_id: Uuid,
/// The mint of the asset being collected
pub mint: Address,
/// The amount of the fee
pub amount: U256,
}

/// Price update event
#[derive(Serialize, Deserialize)]
pub struct PriceUpdate {
/// The ticker of the base asset
pub base_ticker: String,
/// The ticker of the quote asset
pub quote_ticker: String,
/// The price of the asset
pub price: f64,
/// The exchange the price is from
pub exchange: Exchange,
}
3 changes: 3 additions & 0 deletions events-collector/events-collector-api/src/types/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//! API types for the events collector

pub mod events;
6 changes: 3 additions & 3 deletions funds-manager/funds-manager-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ hex = "0.4.3"
hmac = "0.12.1"
http = "0.2.12"
itertools = "0.13.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde = { workspace = true }
serde_json = { workspace = true }
sha2 = "0.10.7"
uuid = "1.7.1"
uuid = { workspace = true }

[dev-dependencies]
rand = "0.8.5"
10 changes: 5 additions & 5 deletions funds-manager/funds-manager-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ clap = { version = "4.5.3", features = ["derive", "env"] }
funds-manager-api = { path = "../funds-manager-api" }
hex = "0.4.3"
http-body-util = "0.1.0"
tokio = { version = "1.10", features = ["full"] }
tokio = { workspace = true }
warp = "0.3"

# === Infra === #
Expand Down Expand Up @@ -56,7 +56,7 @@ itertools = "0.13"
num-bigint = "0.4"
rand = "0.8"
reqwest = { version = "0.12", features = ["json"] }
serde = "1.0"
serde_json = "1.0"
tracing = "0.1"
uuid = "1.8"
serde = { workspace = true }
serde_json = { workspace = true }
tracing = { workspace = true }
uuid = { workspace = true }
8 changes: 4 additions & 4 deletions price-reporter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ hyper = { version = "0.14", features = ["http1", "http2", "server", "tcp"] }
matchit = "0.7"

# === Runtime === #
tokio = "1"
tokio = { workspace = true }
async-trait = "0.1"
futures-util = "0.3"

# === Serde === #
serde = "1"
serde_json = "1"
serde = { workspace = true }
serde_json = { workspace = true }

# === Telemetry === #
tracing = "0.1"
tracing = { workspace = true }
tracing-subscriber = { version = "0.3", features = ["env-filter", "json"] }

# === Renegade === #
Expand Down

0 comments on commit 6d8bd8f

Please sign in to comment.