chore: move BebopOrderType to models.rs

This commit is contained in:
pedrobergamini
2025-06-08 01:01:51 -03:00
parent 71a8401670
commit 0106c5c425
6 changed files with 58 additions and 85 deletions

View File

@@ -1,5 +1,3 @@
mod builder;
pub mod swap_encoder_registry;
mod swap_encoders;
pub use swap_encoders::BebopOrderType;

View File

@@ -13,7 +13,7 @@ use crate::encoding::{
approvals::protocol_approvals_manager::ProtocolApprovalsManager,
utils::{bytes_to_address, get_static_attribute, pad_to_fixed_size},
},
models::{Chain, EncodingContext, Swap},
models::{BebopOrderType, Chain, EncodingContext, Swap},
swap_encoder::SwapEncoder,
};
@@ -617,26 +617,6 @@ impl SwapEncoder for BalancerV3SwapEncoder {
}
}
/// Bebop order types
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum BebopOrderType {
Single = 0,
Multi = 1,
Aggregate = 2,
}
impl TryFrom<u8> for BebopOrderType {
type Error = EncodingError;
fn try_from(value: u8) -> Result<Self, Self::Error> {
match value {
0 => Ok(BebopOrderType::Single),
1 => Ok(BebopOrderType::Multi),
2 => Ok(BebopOrderType::Aggregate),
_ => Err(EncodingError::InvalidInput(format!("Invalid Bebop order type: {}", value))),
}
}
}
/// Encodes a swap on Bebop (PMM RFQ) through the given executor address.
///

View File

@@ -1256,9 +1256,9 @@ mod tests {
use tycho_common::{models::protocol::ProtocolComponent, Bytes};
use super::*;
use crate::encoding::evm::{
swap_encoder::BebopOrderType,
utils::{biguint_to_u256, write_calldata_to_file},
use crate::encoding::{
evm::utils::{biguint_to_u256, write_calldata_to_file},
models::BebopOrderType,
};
/// Helper function to build Bebop user_data
@@ -2461,7 +2461,7 @@ mod tests {
.data;
let hex_calldata = encode(&calldata);
write_calldata_to_file("test_uniswapv3_bebop", hex_calldata.as_str());
write_calldata_to_file("test_uniswap_v3_bebop", hex_calldata.as_str());
}
#[test]

View File

@@ -210,6 +210,27 @@ pub enum TransferType {
None = 2,
}
/// Bebop order types
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum BebopOrderType {
Single = 0,
Multi = 1,
Aggregate = 2,
}
impl TryFrom<u8> for BebopOrderType {
type Error = EncodingError;
fn try_from(value: u8) -> Result<Self, Self::Error> {
match value {
0 => Ok(BebopOrderType::Single),
1 => Ok(BebopOrderType::Multi),
2 => Ok(BebopOrderType::Aggregate),
_ => Err(EncodingError::InvalidInput(format!("Invalid Bebop order type: {}", value))),
}
}
}
#[derive(Clone, PartialEq, Eq, Hash)]
pub struct Chain {
pub id: u64,