use super::akron::AkronHookState;
use super::directional_fee::DirectionalFeeHookState;
use super::exit_fee::ExitFeeHookState;
use super::stable_surge::StableSurgeHookState;
use crate::common::types::{HookStateBase, SwapKind};
use alloy_primitives::U256;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum HookState {
Akron(AkronHookState),
DirectionalFee(DirectionalFeeHookState),
ExitFee(ExitFeeHookState),
StableSurge(StableSurgeHookState),
}
impl HookState {
pub fn hook_type(&self) -> &str {
match self {
HookState::Akron(state) => state.hook_type(),
HookState::DirectionalFee(state) => state.hook_type(),
HookState::ExitFee(state) => state.hook_type(),
HookState::StableSurge(state) => state.hook_type(),
}
}
}
impl HookStateBase for HookState {
fn hook_type(&self) -> &str {
self.hook_type()
}
}
#[derive(Debug, Clone)]
pub struct AfterSwapParams {
pub kind: SwapKind,
pub token_in: String, pub token_out: String, pub amount_in_scaled_18: U256,
pub amount_out_scaled_18: U256,
pub token_in_balance_scaled_18: U256,
pub token_out_balance_scaled_18: U256,
pub amount_calculated_scaled_18: U256,
pub amount_calculated_raw: U256,
}
#[derive(Debug, Clone)]
pub struct DynamicSwapFeeResult {
pub success: bool,
pub dynamic_swap_fee: U256,
}
#[derive(Debug, Clone)]
pub struct BeforeSwapResult {
pub success: bool,
pub hook_adjusted_balances_scaled_18: Vec<U256>,
}
#[derive(Debug, Clone)]
pub struct AfterSwapResult {
pub success: bool,
pub hook_adjusted_amount_calculated_raw: U256,
}
#[derive(Debug, Clone)]
pub struct BeforeAddLiquidityResult {
pub success: bool,
pub hook_adjusted_balances_scaled_18: Vec<U256>,
}
#[derive(Debug, Clone)]
pub struct AfterAddLiquidityResult {
pub success: bool,
pub hook_adjusted_amounts_in_raw: Vec<U256>,
}
#[derive(Debug, Clone)]
pub struct BeforeRemoveLiquidityResult {
pub success: bool,
pub hook_adjusted_balances_scaled_18: Vec<U256>,
}
#[derive(Debug, Clone)]
pub struct AfterRemoveLiquidityResult {
pub success: bool,
pub hook_adjusted_amounts_out_raw: Vec<U256>,
}