feat(adapters): Add new bytes parameter to swap

that allows arbitrary data to be passed
This commit is contained in:
PierreMkt
2024-08-02 11:55:00 -04:00
parent 75e8bdf96f
commit 034d5ac8c2
13 changed files with 85 additions and 34 deletions

View File

@@ -10,6 +10,7 @@ import "src/libraries/FractionMath.sol";
contract AdapterTest is Test, ISwapAdapterTypes {
using FractionMath for Fraction;
bytes32 mockData = bytes32(abi.encodePacked(false));
uint256 constant pricePrecision = 10e24;
string[] public stringPctgs = ["0%", "0.1%", "50%", "100%"];
@@ -99,7 +100,7 @@ contract AdapterTest is Test, ISwapAdapterTypes {
console2.log("TEST: Swapping %d of %s", amounts[j], tokenIn);
trade = adapter.swap(
poolId, tokenIn, tokenOut, OrderSide.Sell, amounts[j]
poolId, tokenIn, tokenOut, OrderSide.Sell, amounts[j], mockData
);
uint256 executedPrice =
trade.calculatedAmount * pricePrecision / amounts[j];
@@ -188,7 +189,12 @@ contract AdapterTest is Test, ISwapAdapterTypes {
);
}
try adapter.swap(
poolId, tokenIn, tokenOut, OrderSide.Sell, aboveLimitArray[0]
poolId,
tokenIn,
tokenOut,
OrderSide.Sell,
aboveLimitArray[0],
mockData
) {
revert("Pool shouldn't be able to swap above the sell limit");
} catch Error(string memory s) {
@@ -214,7 +220,12 @@ contract AdapterTest is Test, ISwapAdapterTypes {
adapter.price(poolId, tokenIn, tokenOut, aboveLimitArray);
adapter.swap(
poolId, tokenIn, tokenOut, OrderSide.Sell, aboveLimitArray[0]
poolId,
tokenIn,
tokenOut,
OrderSide.Sell,
aboveLimitArray[0],
mockData
);
}