feat: Add transfer out for Uniswap V4

Add transfer in Executor and pass receiver address in encoding
This is done by using the TAKE action instead of TAKE_ALL

--- don't change below this line ---
ENG-4315 Took 1 hour 36 minutes

Took 2 minutes
This commit is contained in:
Diana Carvalho
2025-04-15 16:21:23 +01:00
parent 328a281a44
commit ec87969aa6
7 changed files with 43 additions and 27 deletions

View File

@@ -207,6 +207,7 @@ impl SwapEncoder for UniswapV4SwapEncoder {
group_token_out_address,
zero_to_one,
(encoding_context.transfer_type as u8).to_be_bytes(),
bytes_to_address(&encoding_context.receiver)?,
pool_params,
);
@@ -766,9 +767,8 @@ mod tests {
split: 0f64,
};
let encoding_context = EncodingContext {
// The receiver address was taken from `address(uniswapV4Exposed)` in the
// UniswapV4Executor.t.sol
receiver: Bytes::from("0x5615deb798bb3e4dfa0139dfa1b3d433cc23b72f"),
// The receiver is ALICE to match the solidity tests
receiver: Bytes::from("0xcd09f75E2BF2A4d11F3AB23f1389FcC1621c0cc2"),
exact_out: false,
// Same as the executor address
router_address: Some(Bytes::from("0x5615deb798bb3e4dfa0139dfa1b3d433cc23b72f")),
@@ -800,6 +800,8 @@ mod tests {
"01",
// transfer type
"00",
// receiver
"cd09f75e2bf2a4d11f3ab23f1389fcc1621c0cc2",
// pool params:
// - intermediary token
"dac17f958d2ee523a2206206994597c13d831ec7",
@@ -878,11 +880,11 @@ mod tests {
let usdt_address = Bytes::from("0xdAC17F958D2ee523a2206206994597C13D831ec7");
let wbtc_address = Bytes::from("0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599");
let router_address = Bytes::from("0x5615deb798bb3e4dfa0139dfa1b3d433cc23b72f");
let receiver_address = router_address.clone();
// The context is the same for both swaps, since the group token in and out are the same
let context = EncodingContext {
receiver: receiver_address.clone(),
// The receiver is ALICE to match the solidity tests
receiver: Bytes::from("0xcd09f75E2BF2A4d11F3AB23f1389FcC1621c0cc2"),
exact_out: false,
router_address: Some(router_address.clone()),
group_token_in: usde_address.clone(),
@@ -968,6 +970,8 @@ mod tests {
"01",
// transfer type
"00",
// receiver
"cd09f75e2bf2a4d11f3ab23f1389fcc1621c0cc2",
// pool params:
// - intermediary token USDT
"dac17f958d2ee523a2206206994597c13d831ec7",
@@ -983,6 +987,7 @@ mod tests {
"00003c"
))
);
println!("{}", combined_hex)
}
mod ekubo {