chore: renamings for clarity

- Also added a check for length in the Curve executor.
This commit is contained in:
TAMARA LIPOWSKI
2025-04-15 12:44:03 -04:00
committed by Diana Carvalho
parent 3a73fef933
commit 30dc3f7682
13 changed files with 82 additions and 80 deletions

View File

@@ -33,21 +33,21 @@ pub trait TransferOptimization {
} else if is_first_swap && send_funds_to_pool {
if permit2 {
// Transfer from swapper to pool using permit2.
TransferType::Permit2Transfer
TransferType::TransferPermit2ToProtocol
} else {
// Transfer from swapper to pool.
TransferType::TransferFrom
TransferType::TransferFromToProtocol
}
} else if is_first_swap && funds_expected_in_router {
if permit2 {
// Transfer from swapper to router using permit2.
TransferType::Permit2TransferToRouter
TransferType::TransferPermit2ToRouter
} else {
// Transfer from swapper to router.
TransferType::TransferToRouter
TransferType::TransferFromToRouter
}
} else {
TransferType::Transfer
TransferType::TransferToProtocol
}
}
}
@@ -93,7 +93,7 @@ mod tests {
let strategy = MockStrategy {};
let transfer_method =
strategy.get_transfer_type(swap.clone(), weth(), eth(), weth(), true, false);
assert_eq!(transfer_method, TransferType::Permit2Transfer);
assert_eq!(transfer_method, TransferType::TransferPermit2ToProtocol);
}
#[test]
@@ -111,7 +111,7 @@ mod tests {
let strategy = MockStrategy {};
let transfer_method =
strategy.get_transfer_type(swap.clone(), weth(), eth(), weth(), false, false);
assert_eq!(transfer_method, TransferType::TransferFrom);
assert_eq!(transfer_method, TransferType::TransferFromToProtocol);
}
#[test]
@@ -149,7 +149,7 @@ mod tests {
let strategy = MockStrategy {};
let transfer_method =
strategy.get_transfer_type(swap.clone(), eth(), eth(), weth(), false, true);
assert_eq!(transfer_method, TransferType::TransferFrom);
assert_eq!(transfer_method, TransferType::TransferFromToProtocol);
}
#[test]
@@ -168,6 +168,6 @@ mod tests {
let strategy = MockStrategy {};
let transfer_method =
strategy.get_transfer_type(swap.clone(), weth(), eth(), weth(), false, false);
assert_eq!(transfer_method, TransferType::Transfer);
assert_eq!(transfer_method, TransferType::TransferToProtocol);
}
}

View File

@@ -595,7 +595,7 @@ mod tests {
router_address: Some(Bytes::zero(20)),
group_token_in: token_in.clone(),
group_token_out: token_out.clone(),
transfer_type: TransferType::Transfer,
transfer_type: TransferType::TransferToProtocol,
};
let encoder = UniswapV2SwapEncoder::new(
String::from("0x543778987b293C7E8Cf0722BB2e935ba6f4068D4"),
@@ -649,7 +649,7 @@ mod tests {
router_address: Some(Bytes::zero(20)),
group_token_in: token_in.clone(),
group_token_out: token_out.clone(),
transfer_type: TransferType::Transfer,
transfer_type: TransferType::TransferToProtocol,
};
let encoder = UniswapV3SwapEncoder::new(
String::from("0x543778987b293C7E8Cf0722BB2e935ba6f4068D4"),
@@ -773,7 +773,7 @@ mod tests {
group_token_in: token_in.clone(),
group_token_out: token_out.clone(),
transfer_type: TransferType::Transfer,
transfer_type: TransferType::TransferToProtocol,
};
let encoder = UniswapV4SwapEncoder::new(
String::from("0xF62849F9A0B5Bf2913b396098F7c7019b51A820a"),
@@ -842,7 +842,7 @@ mod tests {
group_token_in: group_token_in.clone(),
// Token out is the same as the group token out
group_token_out: token_out.clone(),
transfer_type: TransferType::Transfer,
transfer_type: TransferType::TransferToProtocol,
};
let encoder = UniswapV4SwapEncoder::new(
@@ -885,7 +885,7 @@ mod tests {
router_address: Some(router_address.clone()),
group_token_in: usde_address.clone(),
group_token_out: wbtc_address.clone(),
transfer_type: TransferType::Transfer,
transfer_type: TransferType::TransferToProtocol,
};
// Setup - First sequence: USDE -> USDT
@@ -1017,7 +1017,7 @@ mod tests {
group_token_out: token_out.clone(),
exact_out: false,
router_address: Some(Bytes::default()),
transfer_type: TransferType::Transfer,
transfer_type: TransferType::TransferToProtocol,
};
let encoder =
@@ -1060,7 +1060,7 @@ mod tests {
group_token_out: group_token_out.clone(),
exact_out: false,
router_address: Some(Bytes::default()),
transfer_type: TransferType::Transfer,
transfer_type: TransferType::TransferToProtocol,
};
let first_swap = Swap {

View File

@@ -260,7 +260,7 @@ impl TychoExecutorEncoder {
router_address: None,
group_token_in: grouped_swap.input_token.clone(),
group_token_out: grouped_swap.output_token.clone(),
transfer_type: TransferType::Transfer,
transfer_type: TransferType::TransferToProtocol,
};
let protocol_data = swap_encoder.encode_swap(swap.clone(), encoding_context.clone())?;
grouped_protocol_data.extend(protocol_data);