feat: Add estimated_amount_in to Swap. Add SwapBuilder

Use SwapBuilder everywhere inside crate
Integration tests will be done later

--- don't change below this line ---
ENG-4696 Took 1 hour 56 minutes

Took 4 minutes
This commit is contained in:
Diana Carvalho
2025-08-13 18:00:46 +01:00
parent 616b588fc8
commit 5eb9973dbd
15 changed files with 647 additions and 763 deletions

View File

@@ -121,7 +121,7 @@ mod tests {
use tycho_common::models::protocol::ProtocolComponent;
use super::*;
use crate::encoding::models::Swap;
use crate::encoding::models::SwapBuilder;
fn weth() -> Bytes {
Bytes::from(hex!("c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2").to_vec())
@@ -174,18 +174,16 @@ mod tests {
#[case] expected_transfer: TransferType,
) {
// The swap token is the same as the given token, which is not the native token
let swaps = vec![Swap {
component: ProtocolComponent {
let swaps = vec![SwapBuilder::new(
ProtocolComponent {
protocol_system: "uniswap_v2".to_string(),
id: "0xA478c2975Ab1Ea89e8196811F51A7B7Ade33eB11".to_string(),
..Default::default()
},
token_in: swap_token_in.clone(),
token_out: dai(),
split: 0f64,
user_data: None,
protocol_state: None,
}];
swap_token_in.clone(),
dai(),
)
.build()];
let swap = SwapGroup {
protocol_system: protocol,
token_in: swap_token_in,
@@ -240,18 +238,16 @@ mod tests {
token_in: usdc(),
token_out: dai(),
split: 0f64,
swaps: vec![Swap {
component: ProtocolComponent {
swaps: vec![SwapBuilder::new(
ProtocolComponent {
protocol_system: protocol.unwrap().to_string(),
id: component_id().to_string(),
..Default::default()
},
token_in: usdc(),
token_out: dai(),
split: 0f64,
user_data: None,
protocol_state: None,
}],
usdc(),
dai(),
)
.build()],
})
};