refactor: use SwapBuilder in integration tests

This commit is contained in:
adrian
2025-10-09 10:30:22 +02:00
committed by Adrian Benavides
parent 52e9f4da89
commit 3e92b1be66
6 changed files with 243 additions and 386 deletions

View File

@@ -7,7 +7,7 @@ use num_bigint::BigUint;
use tycho_common::{models::protocol::ProtocolComponent, Bytes};
use tycho_execution::encoding::{
evm::utils::{biguint_to_u256, write_calldata_to_file},
models::{NativeAction, Solution, Swap, UserTransferType},
models::{NativeAction, Solution, SwapBuilder, UserTransferType},
};
use crate::common::{
@@ -23,19 +23,16 @@ fn test_single_swap_strategy_encoder() {
let weth = weth();
let dai = dai();
let swap = Swap {
component: ProtocolComponent {
let swap = SwapBuilder::new(
ProtocolComponent {
id: "0xA478c2975Ab1Ea89e8196811F51A7B7Ade33eB11".to_string(),
protocol_system: "uniswap_v2".to_string(),
..Default::default()
},
token_in: weth.clone(),
token_out: dai.clone(),
split: 0f64,
user_data: None,
protocol_state: None,
estimated_amount_in: None,
};
weth.clone(),
dai.clone(),
)
.build();
let encoder = get_tycho_router_encoder(UserTransferType::TransferFromPermit2);
@@ -111,19 +108,16 @@ fn test_single_swap_strategy_encoder_no_permit2() {
let checked_amount = BigUint::from_str("1_640_000000000000000000").unwrap();
let expected_min_amount = U256::from_str("1_640_000000000000000000").unwrap();
let swap = Swap {
component: ProtocolComponent {
let swap = SwapBuilder::new(
ProtocolComponent {
id: "0xA478c2975Ab1Ea89e8196811F51A7B7Ade33eB11".to_string(),
protocol_system: "uniswap_v2".to_string(),
..Default::default()
},
token_in: weth.clone(),
token_out: dai.clone(),
split: 0f64,
user_data: None,
protocol_state: None,
estimated_amount_in: None,
};
weth.clone(),
dai.clone(),
)
.build();
let encoder = get_tycho_router_encoder(UserTransferType::TransferFrom);
let solution = Solution {
@@ -195,19 +189,16 @@ fn test_single_swap_strategy_encoder_no_transfer_in() {
let checked_amount = BigUint::from_str("1_640_000000000000000000").unwrap();
let expected_min_amount = U256::from_str("1_640_000000000000000000").unwrap();
let swap = Swap {
component: ProtocolComponent {
let swap = SwapBuilder::new(
ProtocolComponent {
id: "0xA478c2975Ab1Ea89e8196811F51A7B7Ade33eB11".to_string(),
protocol_system: "uniswap_v2".to_string(),
..Default::default()
},
token_in: weth.clone(),
token_out: dai.clone(),
split: 0f64,
user_data: None,
protocol_state: None,
estimated_amount_in: None,
};
weth.clone(),
dai.clone(),
)
.build();
let encoder = get_tycho_router_encoder(UserTransferType::None);
let solution = Solution {
@@ -280,19 +271,16 @@ fn test_single_swap_strategy_encoder_wrap() {
let dai = dai();
let swap = Swap {
component: ProtocolComponent {
let swap = SwapBuilder::new(
ProtocolComponent {
id: "0xA478c2975Ab1Ea89e8196811F51A7B7Ade33eB11".to_string(),
protocol_system: "uniswap_v2".to_string(),
..Default::default()
},
token_in: weth(),
token_out: dai.clone(),
split: 0f64,
user_data: None,
protocol_state: None,
estimated_amount_in: None,
};
weth(),
dai.clone(),
)
.build();
let encoder = get_tycho_router_encoder(UserTransferType::TransferFromPermit2);
let solution = Solution {
@@ -334,19 +322,16 @@ fn test_single_swap_strategy_encoder_unwrap() {
let dai = dai();
let swap = Swap {
component: ProtocolComponent {
let swap = SwapBuilder::new(
ProtocolComponent {
id: "0xA478c2975Ab1Ea89e8196811F51A7B7Ade33eB11".to_string(),
protocol_system: "uniswap_v2".to_string(),
..Default::default()
},
token_in: dai.clone(),
token_out: weth(),
split: 0f64,
user_data: None,
protocol_state: None,
estimated_amount_in: None,
};
dai.clone(),
weth(),
)
.build();
let encoder = get_tycho_router_encoder(UserTransferType::TransferFromPermit2);
let solution = Solution {