-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
events-collector: events-collector-api: initialize event types
- Loading branch information
Showing
14 changed files
with
202 additions
and
23 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -10,3 +10,5 @@ target/ | |
|
||
# MSVC Windows builds of rustc generate these, which store debugging information | ||
*.pdb | ||
|
||
/.vscode |
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
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
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,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 } |
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,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
127
events-collector/events-collector-api/src/types/events.rs
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,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, | ||
} |
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,3 @@ | ||
//! API types for the events collector | ||
|
||
pub mod events; |
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
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