Merge branch 'main' into encoding/tnl/fix-wrapping-indices

This commit is contained in:
Tamara
2025-02-04 11:47:58 -05:00
committed by GitHub
6 changed files with 70 additions and 11 deletions

View File

@@ -1,3 +1,27 @@
## [0.29.0](https://github.com/propeller-heads/tycho-execution/compare/0.28.0...0.29.0) (2025-02-04)
### Features
* add swap encoder test in balancer v2 executor ([6333072](https://github.com/propeller-heads/tycho-execution/commit/6333072178b77bdc9a7950ed0ab84f30695d1b72))
### Bug Fixes
* executor test naming ([e6310d6](https://github.com/propeller-heads/tycho-execution/commit/e6310d65d1cb1c37ef0cef55090bf4abbe1fb275))
## [0.28.0](https://github.com/propeller-heads/tycho-execution/compare/0.27.0...0.28.0) (2025-02-04)
### Features
* Tycho encoder validation ([4bc6159](https://github.com/propeller-heads/tycho-execution/commit/4bc615913ecb41a551a8b970ba5d96f0fc20ca42))
### Bug Fixes
* test_validate_fails_for_unwrap_wrong_last_swap ([0660321](https://github.com/propeller-heads/tycho-execution/commit/06603210bcd567ce50ec79344024ea2b722ebcd3))
## [0.27.0](https://github.com/propeller-heads/tycho-execution/compare/0.26.0...0.27.0) (2025-02-04)

2
Cargo.lock generated
View File

@@ -4163,7 +4163,7 @@ dependencies = [
[[package]]
name = "tycho-execution"
version = "0.27.0"
version = "0.29.0"
dependencies = [
"alloy",
"alloy-primitives",

View File

@@ -1,6 +1,6 @@
[package]
name = "tycho-execution"
version = "0.27.0"
version = "0.29.0"
edition = "2021"
[dependencies]

View File

@@ -82,4 +82,40 @@ contract BalancerV2ExecutorTest is
assertGt(balanceAfter, balanceBefore);
assertEq(balanceAfter - balanceBefore, amountOut);
}
function testDecodeIntegration() public {
// Generated by the SwapEncoder - test_encode_balancer_v2
bytes memory protocolData =
hex"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2ba100000625a3754423978a60c9317c58a424e3d5c6ee304399dbdb9c8ef030ab642b10820db8f560002000000000000000000141d96f2f6bef1202e4ce1ff6dad0c2cb002861d3e01";
(
IERC20 tokenIn,
IERC20 tokenOut,
bytes32 poolId,
address receiver,
bool needsApproval
) = balancerV2Exposed.decodeParams(protocolData);
assertEq(address(tokenIn), WETH_ADDR);
assertEq(address(tokenOut), BAL_ADDR);
assertEq(poolId, WETH_BAL_POOL_ID);
assertEq(receiver, BOB);
assertEq(needsApproval, true);
}
function testSwapIntegration() public {
// Generated by the SwapEncoder - test_encode_balancer_v2
bytes memory protocolData =
hex"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2ba100000625a3754423978a60c9317c58a424e3d5c6ee304399dbdb9c8ef030ab642b10820db8f560002000000000000000000141d96f2f6bef1202e4ce1ff6dad0c2cb002861d3e01";
uint256 amountIn = 10 ** 18;
deal(WETH_ADDR, address(balancerV2Exposed), amountIn);
uint256 balanceBefore = BAL.balanceOf(BOB);
uint256 amountOut = balancerV2Exposed.swap(amountIn, protocolData);
uint256 balanceAfter = BAL.balanceOf(BOB);
assertGt(balanceAfter, balanceBefore);
assertEq(balanceAfter - balanceBefore, amountOut);
}
}

View File

@@ -94,7 +94,7 @@ contract UniswapV2ExecutorTest is UniswapV2ExecutorExposed, Test, Constants {
assertGe(finalBalance, amountOut);
}
function testSwapExecutorEncoderData() public {
function testDecodeIntegration() public {
// Generated by the ExecutorStrategyEncoder - test_executor_strategy_encode
bytes memory protocolData =
hex"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc288e6a0c2ddd26feeb64f039a2c41296fcb3f5640000000000000000000000000000000000000000100";
@@ -108,7 +108,7 @@ contract UniswapV2ExecutorTest is UniswapV2ExecutorExposed, Test, Constants {
assertEq(zeroForOne, false);
}
function testSwapExecutorSwap() public {
function testSwapIntegration() public {
// Generated by the ExecutorStrategyEncoder - test_executor_strategy_encode
bytes memory protocolData =
hex"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2a478c2975ab1ea89e8196811f51a7b7ade33eb111d96f2f6bef1202e4ce1ff6dad0c2cb002861d3e00";

View File

@@ -168,7 +168,6 @@ impl SwapEncoder for BalancerV2SwapEncoder {
bytes_to_address(&swap.token_out)?,
component_id,
bytes_to_address(&encoding_context.receiver)?,
encoding_context.exact_out,
approval_needed,
);
Ok(args.abi_encode_packed())
@@ -285,11 +284,12 @@ mod tests {
let swap = Swap {
component: balancer_pool,
token_in: Bytes::from("0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"), // WETH
token_out: Bytes::from("0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"), // BAL
token_out: Bytes::from("0xba100000625a3754423978a60c9317c58a424e3D"), // BAL
split: 0f64,
};
let encoding_context = EncodingContext {
receiver: Bytes::from("0x0000000000000000000000000000000000000001"),
// The receiver was generated with `makeAddr("bob") using forge`
receiver: Bytes::from("0x1d96f2f6bef1202e4ce1ff6dad0c2cb002861d3e"),
exact_out: false,
router_address: Bytes::zero(20),
};
@@ -299,6 +299,7 @@ mod tests {
.encode_swap(swap, encoding_context)
.unwrap();
let hex_swap = encode(&encoded_swap);
println!("{}", hex_swap);
assert_eq!(
hex_swap,
@@ -306,13 +307,11 @@ mod tests {
// token in
"c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
// token out
"2791bca1f2de4661ed88a30c99a7a9449aa84174",
"ba100000625a3754423978a60c9317c58a424e3d",
// pool id
"5c6ee304399dbdb9c8ef030ab642b10820db8f56000200000000000000000014",
// receiver
"0000000000000000000000000000000000000001",
// exact out
"00",
"1d96f2f6bef1202e4ce1ff6dad0c2cb002861d3e",
// approval needed
"01"
))