From 07ca52b2ff6cae221790b68cd4474ec95c672ad6 Mon Sep 17 00:00:00 2001 From: PierreMkt Date: Mon, 5 Aug 2024 13:56:28 -0400 Subject: [PATCH] chore(adapters): Address PR review keep mock data as empty bytes --- evm/src/integral/IntegralSwapAdapter.sol | 2 +- evm/test/AdapterTest.sol | 2 +- evm/test/AngleAdapter.t.sol | 7 ++++--- evm/test/BalancerV2SwapAdapter.t.sol | 15 +++++++++++---- evm/test/EtherfiAdapter.t.sol | 7 ++++--- evm/test/IntegralSwapAdapter.t.sol | 11 +++++++---- evm/test/UniswapV2SwapAdapter.t.sol | 11 +++++++---- 7 files changed, 35 insertions(+), 20 deletions(-) diff --git a/evm/src/integral/IntegralSwapAdapter.sol b/evm/src/integral/IntegralSwapAdapter.sol index c3ff1d0..d74ff0d 100644 --- a/evm/src/integral/IntegralSwapAdapter.sol +++ b/evm/src/integral/IntegralSwapAdapter.sol @@ -60,7 +60,7 @@ contract IntegralSwapAdapter is ISwapAdapter { address buyToken, OrderSide side, uint256 specifiedAmount, - bytes32 data + bytes32 ) external override returns (Trade memory trade) { if (specifiedAmount == 0) { return trade; diff --git a/evm/test/AdapterTest.sol b/evm/test/AdapterTest.sol index 8ef36d4..cdb2c58 100644 --- a/evm/test/AdapterTest.sol +++ b/evm/test/AdapterTest.sol @@ -10,7 +10,7 @@ import "src/libraries/FractionMath.sol"; contract AdapterTest is Test, ISwapAdapterTypes { using FractionMath for Fraction; - bytes32 mockData = bytes32(abi.encodePacked(false)); + bytes32 mockData; uint256 constant pricePrecision = 10e24; string[] public stringPctgs = ["0%", "0.1%", "50%", "100%"]; diff --git a/evm/test/AngleAdapter.t.sol b/evm/test/AngleAdapter.t.sol index 8df15de..082a475 100644 --- a/evm/test/AngleAdapter.t.sol +++ b/evm/test/AngleAdapter.t.sol @@ -18,7 +18,7 @@ contract AngleAdapterTest is Test, ISwapAdapterTypes { ITransmuter(0x00253582b2a3FE112feEC532221d9708c64cEFAb); uint256 constant TEST_ITERATIONS = 100; - bytes32 mockData = bytes32(abi.encodePacked(false)); + bytes32 mockData; function setUp() public { uint256 forkBlock = 18921770; @@ -179,19 +179,20 @@ contract AngleAdapterTest is Test, ISwapAdapterTypes { function testGetCapabilitiesAngle(bytes32 pair, address t0, address t1) public + view { Capability[] memory res = adapter.getCapabilities(pair, t0, t1); assertEq(res.length, 2); } - function testGetTokensAngle() public { + function testGetTokensAngle() public view { address[] memory tokens = adapter.getTokens(bytes32(0)); assertGe(tokens.length, 2); } - function testGetLimitsAngle() public { + function testGetLimitsAngle() public view { bytes32 pair = bytes32(0); uint256[] memory limits = adapter.getLimits(pair, address(agEUR), address(EURC)); diff --git a/evm/test/BalancerV2SwapAdapter.t.sol b/evm/test/BalancerV2SwapAdapter.t.sol index 7cb610c..c1053ec 100644 --- a/evm/test/BalancerV2SwapAdapter.t.sol +++ b/evm/test/BalancerV2SwapAdapter.t.sol @@ -12,6 +12,7 @@ import {FractionMath} from "src/libraries/FractionMath.sol"; contract BalancerV2SwapAdapterTest is AdapterTest { using FractionMath for Fraction; + bytes32 mockBoolData = bytes32(abi.encode(false)); IVault constant balancerV2Vault = IVault(payable(0xBA12222222228d8Ba445958a75a0704d566BF2C8)); BalancerV2SwapAdapter adapter; @@ -111,7 +112,12 @@ contract BalancerV2SwapAdapterTest is AdapterTest { uint256 weth_balance = IERC20(WETH).balanceOf(address(this)); Trade memory trade = adapter.swap( - B_80BAL_20WETH_POOL_ID, BAL, WETH, side, specifiedAmount, mockData + B_80BAL_20WETH_POOL_ID, + BAL, + WETH, + side, + specifiedAmount, + mockBoolData ); if (trade.calculatedAmount > 0) { @@ -154,7 +160,7 @@ contract BalancerV2SwapAdapterTest is AdapterTest { WETH, OrderSide.Sell, amounts[i], - mockData + mockBoolData ); vm.revertTo(beforeSwap); @@ -190,7 +196,7 @@ contract BalancerV2SwapAdapterTest is AdapterTest { WETH, OrderSide.Buy, amounts[i], - mockData + mockBoolData ); vm.revertTo(beforeSwap); @@ -214,6 +220,7 @@ contract BalancerV2SwapAdapterTest is AdapterTest { function testGetCapabilitiesFuzz(bytes32 pool, address t0, address t1) public + view { Capability[] memory res = adapter.getCapabilities(pool, t0, t1); @@ -224,7 +231,7 @@ contract BalancerV2SwapAdapterTest is AdapterTest { assertEq(uint256(res[3]), uint256(Capability.HardLimits)); } - function testGetTokens() public { + function testGetTokens() public view { address[] memory tokens = adapter.getTokens(B_80BAL_20WETH_POOL_ID); assertEq(tokens[0], BAL); diff --git a/evm/test/EtherfiAdapter.t.sol b/evm/test/EtherfiAdapter.t.sol index c98d74a..9f60173 100644 --- a/evm/test/EtherfiAdapter.t.sol +++ b/evm/test/EtherfiAdapter.t.sol @@ -15,7 +15,7 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes { IeEth eEth; uint256 constant TEST_ITERATIONS = 100; - bytes32 mockData = bytes32(abi.encodePacked(false)); + bytes32 mockData; function setUp() public { uint256 forkBlock = 19218495; @@ -404,6 +404,7 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes { function testGetCapabilitiesEtherfi(bytes32 pair, address t0, address t1) public + view { Capability[] memory res = adapter.getCapabilities(pair, address(t0), address(t1)); @@ -411,14 +412,14 @@ contract EtherfiAdapterTest is Test, ISwapAdapterTypes { assertEq(res.length, 3); } - function testGetTokensEtherfi() public { + function testGetTokensEtherfi() public view { bytes32 pair = bytes32(0); address[] memory tokens = adapter.getTokens(pair); assertEq(tokens.length, 3); } - function testGetLimitsEtherfi() public { + function testGetLimitsEtherfi() public view { bytes32 pair = bytes32(0); uint256[] memory limits = adapter.getLimits(pair, address(eEth), address(weEth)); diff --git a/evm/test/IntegralSwapAdapter.t.sol b/evm/test/IntegralSwapAdapter.t.sol index abfa8bc..18dde5c 100644 --- a/evm/test/IntegralSwapAdapter.t.sol +++ b/evm/test/IntegralSwapAdapter.t.sol @@ -16,7 +16,7 @@ contract IntegralSwapAdapterTest is Test, ISwapAdapterTypes { address constant USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48; address constant USDC_WETH_PAIR = 0x2fe16Dd18bba26e457B7dD2080d5674312b026a2; address constant relayerAddress = 0xd17b3c9784510E33cD5B87b490E79253BcD81e2E; - bytes32 mockData = bytes32(abi.encodePacked(false)); + bytes32 mockData; uint256 constant TEST_ITERATIONS = 100; @@ -31,7 +31,10 @@ contract IntegralSwapAdapterTest is Test, ISwapAdapterTypes { vm.label(address(USDC_WETH_PAIR), "USDC_WETH_PAIR"); } - function testPriceFuzzIntegral(uint256 amount0, uint256 amount1) public { + function testPriceFuzzIntegral(uint256 amount0, uint256 amount1) + public + view + { bytes32 pair = bytes32(bytes20(USDC_WETH_PAIR)); uint256[] memory limits = adapter.getLimits(pair, USDC, WETH); vm.assume(amount0 < limits[0]); @@ -159,14 +162,14 @@ contract IntegralSwapAdapterTest is Test, ISwapAdapterTypes { assertEq(res.length, 4); } - function testGetTokensIntegral() public { + function testGetTokensIntegral() public view { bytes32 pair = bytes32(bytes20(USDC_WETH_PAIR)); address[] memory tokens = adapter.getTokens(pair); assertEq(tokens.length, 2); } - function testGetLimitsIntegral() public { + function testGetLimitsIntegral() public view { bytes32 pair = bytes32(bytes20(USDC_WETH_PAIR)); uint256[] memory limits = adapter.getLimits(pair, USDC, WETH); diff --git a/evm/test/UniswapV2SwapAdapter.t.sol b/evm/test/UniswapV2SwapAdapter.t.sol index f2a3a1c..7be622d 100644 --- a/evm/test/UniswapV2SwapAdapter.t.sol +++ b/evm/test/UniswapV2SwapAdapter.t.sol @@ -29,7 +29,7 @@ contract UniswapV2PairFunctionTest is AdapterTest { vm.label(USDC_WETH_PAIR, "USDC_WETH_PAIR"); } - function testPriceFuzz(uint256 amount0, uint256 amount1) public { + function testPriceFuzz(uint256 amount0, uint256 amount1) public view { bytes32 pair = bytes32(bytes20(USDC_WETH_PAIR)); uint256[] memory limits = adapter.getLimits(pair, USDC, WETH); vm.assume(amount0 < limits[0]); @@ -47,7 +47,7 @@ contract UniswapV2PairFunctionTest is AdapterTest { } } - function testPriceDecreasing() public { + function testPriceDecreasing() public view { bytes32 pair = bytes32(bytes20(USDC_WETH_PAIR)); uint256[] memory amounts = new uint256[](TEST_ITERATIONS); @@ -149,13 +149,16 @@ contract UniswapV2PairFunctionTest is AdapterTest { executeIncreasingSwaps(OrderSide.Buy); } - function testGetCapabilities(bytes32 pair, address t0, address t1) public { + function testGetCapabilities(bytes32 pair, address t0, address t1) + public + view + { Capability[] memory res = adapter.getCapabilities(pair, t0, t1); assertEq(res.length, 4); } - function testGetLimits() public { + function testGetLimits() public view { bytes32 pair = bytes32(bytes20(USDC_WETH_PAIR)); uint256[] memory limits = adapter.getLimits(pair, USDC, WETH);