feat: Bring back TransferType and simplify encoding logic

Took 1 hour 53 minutes
This commit is contained in:
Diana Carvalho
2025-05-16 16:59:35 +01:00
parent 9b59b8b434
commit 38748925b3
6 changed files with 230 additions and 309 deletions

View File

@@ -106,9 +106,7 @@ pub struct Transaction {
/// solution does not require router address.
/// * `group_token_in`: Token to be used as the input for the group swap.
/// * `group_token_out`: Token to be used as the output for the group swap.
/// * `transfer_from_needed`: true if the solution requires a transfer from the user to the router
/// or pool.
/// * `transfer_needed`: true if the solution requires a transfer from the router to the pool.
/// * `transfer`: Type of transfer to be performed. See `TransferType` for more details.
#[derive(Clone, Debug)]
pub struct EncodingContext {
pub receiver: Bytes,
@@ -116,8 +114,22 @@ pub struct EncodingContext {
pub router_address: Option<Bytes>,
pub group_token_in: Bytes,
pub group_token_out: Bytes,
pub transfer_from_needed: bool,
pub transfer_needed: bool,
pub transfer: TransferType,
}
/// Represents the type of transfer to be performed into the pool.
///
/// # Fields
///
/// * `Transfer`: Transfer the token from the router into the protocol.
/// * `TransferFrom`: Transfer the token from the sender to the protocol/router.
/// * `None`: No transfer is needed. Tokens are already in the pool.
#[repr(u8)]
#[derive(Clone, Debug, PartialEq)]
pub enum TransferType {
TransferFrom = 0,
Transfer = 1,
None = 2,
}
#[derive(Clone, PartialEq, Eq, Hash)]