feat: Add methods to builder to set chain and strategy independently

--- don't change below this line ---
ENG-4246 Took 15 minutes
This commit is contained in:
Diana Carvalho
2025-02-19 11:15:27 +00:00
parent 4741e628b8
commit 684de4fa60
3 changed files with 54 additions and 18 deletions

View File

@@ -103,14 +103,16 @@ fn encode_swaps(
let solution: Solution = serde_json::from_str(input)?;
let chain = Chain::Ethereum;
let encoder = if use_tycho_router {
let mut builder = EVMEncoderBuilder::new().chain(chain);
builder = if use_tycho_router {
let private_key = swapper_pk.ok_or(EncodingError::FatalError(
"Swapper private key is required for tycho_router".to_string(),
))?;
EVMEncoderBuilder::tycho_router(chain, private_key, config_path)?.build()?
builder.tycho_router(private_key, config_path)?
} else {
EVMEncoderBuilder::direct_execution(chain, config_path)?.build()?
builder.direct_execution(config_path)?
};
let encoder = builder.build()?;
let transactions = encoder.encode_router_calldata(vec![solution])?;