feat: Transfer Optimizations in MaverickV2
- Also added integration test to test the optimizations, where we can see the in and out transfers being optimized if we enable verbose foundry testing - Fixed typo in swap encoder builder initialization
This commit is contained in:
@@ -2318,6 +2318,56 @@ mod tests {
|
||||
write_calldata_to_file("test_single_encoding_strategy_ekubo", hex_calldata.as_str());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_single_encoding_strategy_maverick() {
|
||||
// GHO -> (maverick) -> USDC
|
||||
let maverick_pool = ProtocolComponent {
|
||||
id: String::from("0x14Cf6D2Fe3E1B326114b07d22A6F6bb59e346c67"),
|
||||
protocol_system: String::from("vm:maverick_v2"),
|
||||
..Default::default()
|
||||
};
|
||||
let token_in = Bytes::from("0x40D16FC0246aD3160Ccc09B8D0D3A2cD28aE6C2f");
|
||||
let token_out = Bytes::from("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48");
|
||||
let swap = Swap {
|
||||
component: maverick_pool,
|
||||
token_in: token_in.clone(),
|
||||
token_out: token_out.clone(),
|
||||
split: 0f64,
|
||||
};
|
||||
|
||||
let swap_encoder_registry = get_swap_encoder_registry();
|
||||
let encoder = SingleSwapStrategyEncoder::new(
|
||||
eth_chain(),
|
||||
swap_encoder_registry,
|
||||
None,
|
||||
Bytes::from_str("0xA4AD4f68d0b91CFD19687c881e50f3A00242828c").unwrap(),
|
||||
false,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let solution = Solution {
|
||||
exact_out: false,
|
||||
given_token: token_in,
|
||||
given_amount: BigUint::from_str("1_000000000000000000").unwrap(),
|
||||
checked_token: token_out,
|
||||
expected_amount: None,
|
||||
checked_amount: Some(BigUint::from_str("1000").unwrap()),
|
||||
slippage: None,
|
||||
// Alice
|
||||
sender: Bytes::from_str("0xcd09f75E2BF2A4d11F3AB23f1389FcC1621c0cc2").unwrap(),
|
||||
receiver: Bytes::from_str("0xcd09f75E2BF2A4d11F3AB23f1389FcC1621c0cc2").unwrap(),
|
||||
swaps: vec![swap],
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let (calldata, _) = encoder
|
||||
.encode_strategy(solution)
|
||||
.unwrap();
|
||||
|
||||
let hex_calldata = encode(&calldata);
|
||||
write_calldata_to_file("test_single_encoding_strategy_maverick", hex_calldata.as_str());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_single_encoding_strategy_usv4_eth_in() {
|
||||
// Performs a single swap from ETH to PEPE using a USV4 pool
|
||||
|
||||
Reference in New Issue
Block a user