use std::fmt::Display;
use alloy_primitives::Address;
use nautilus_core::UnixNanos;
use serde::{Deserialize, Serialize};
use crate::{
defi::{PoolIdentifier, SharedChain, SharedDex},
identifiers::InstrumentId,
};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[cfg_attr(
feature = "python",
pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.model", from_py_object)
)]
#[cfg_attr(
feature = "python",
pyo3_stub_gen::derive::gen_stub_pyclass(module = "nautilus_trader.model")
)]
pub struct PoolFeeCollect {
pub chain: SharedChain,
pub dex: SharedDex,
pub instrument_id: InstrumentId,
pub pool_identifier: PoolIdentifier,
pub block: u64,
pub transaction_hash: String,
pub transaction_index: u32,
pub log_index: u32,
pub owner: Address,
pub amount0: u128,
pub amount1: u128,
pub tick_lower: i32,
pub tick_upper: i32,
pub timestamp: Option<UnixNanos>,
pub ts_init: Option<UnixNanos>,
}
impl PoolFeeCollect {
#[must_use]
#[allow(clippy::too_many_arguments)]
pub const fn new(
chain: SharedChain,
dex: SharedDex,
instrument_id: InstrumentId,
pool_identifier: PoolIdentifier,
block: u64,
transaction_hash: String,
transaction_index: u32,
log_index: u32,
owner: Address,
amount0: u128,
amount1: u128,
tick_lower: i32,
tick_upper: i32,
timestamp: Option<UnixNanos>,
) -> Self {
Self {
chain,
dex,
instrument_id,
pool_identifier,
block,
transaction_hash,
transaction_index,
log_index,
owner,
amount0,
amount1,
tick_lower,
tick_upper,
timestamp,
ts_init: timestamp,
}
}
}
impl Display for PoolFeeCollect {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"PoolFeeCollect({} fees collected: token0={}, token1={}, owner={}, tick_range=[{}, {}], tx={}:{}:{})",
self.instrument_id,
self.amount0,
self.amount1,
self.owner,
self.tick_lower,
self.tick_upper,
self.block,
self.transaction_index,
self.log_index,
)
}
}