use alloy::primitives::{Address, U256};
use nautilus_core::UnixNanos;
use nautilus_model::{
defi::{PoolLiquidityUpdate, PoolLiquidityUpdateType, SharedChain, SharedDex},
identifiers::InstrumentId,
};
#[derive(Debug, Clone)]
pub struct BurnEvent {
pub dex: SharedDex,
pub pool_address: Address,
pub block_number: u64,
pub transaction_hash: String,
pub transaction_index: u32,
pub log_index: u32,
pub owner: Address,
pub tick_lower: i32,
pub tick_upper: i32,
pub amount: u128,
pub amount0: U256,
pub amount1: U256,
}
impl BurnEvent {
#[must_use]
#[allow(clippy::too_many_arguments)]
pub const fn new(
dex: SharedDex,
pool_address: Address,
block_number: u64,
transaction_hash: String,
transaction_index: u32,
log_index: u32,
owner: Address,
tick_lower: i32,
tick_upper: i32,
amount: u128,
amount0: U256,
amount1: U256,
) -> Self {
Self {
dex,
pool_address,
block_number,
transaction_hash,
transaction_index,
log_index,
owner,
tick_lower,
tick_upper,
amount,
amount0,
amount1,
}
}
#[allow(clippy::too_many_arguments)]
#[must_use]
pub fn to_pool_liquidity_update(
&self,
chain: SharedChain,
dex: SharedDex,
instrument_id: InstrumentId,
pool_address: Address,
timestamp: Option<UnixNanos>,
) -> PoolLiquidityUpdate {
PoolLiquidityUpdate::new(
chain,
dex,
instrument_id,
pool_address,
PoolLiquidityUpdateType::Burn,
self.block_number,
self.transaction_hash.clone(),
self.transaction_index,
self.log_index,
None,
self.owner,
self.amount,
self.amount0,
self.amount1,
self.tick_lower,
self.tick_upper,
timestamp,
)
}
}