Fixing testSwapFuzzIntegral
This commit is contained in:
@@ -11,6 +11,7 @@ contract IntegralSwapAdapterTest is Test, ISwapAdapterTypes {
|
||||
using FractionMath for Fraction;
|
||||
|
||||
IntegralSwapAdapter adapter;
|
||||
ITwapRelayer relayer;
|
||||
IERC20 constant WETH = IERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
|
||||
IERC20 constant USDC = IERC20(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48);
|
||||
address constant USDC_WETH_PAIR =
|
||||
@@ -24,12 +25,28 @@ contract IntegralSwapAdapterTest is Test, ISwapAdapterTypes {
|
||||
uint256 forkBlock = 18835309;
|
||||
vm.createSelectFork(vm.rpcUrl("mainnet"), forkBlock);
|
||||
adapter = new IntegralSwapAdapter(relayerAddress);
|
||||
relayer = ITwapRelayer(relayerAddress);
|
||||
|
||||
vm.label(address(WETH), "WETH");
|
||||
vm.label(address(USDC), "USDC");
|
||||
vm.label(address(USDC_WETH_PAIR), "USDC_WETH_PAIR");
|
||||
}
|
||||
|
||||
function getMinLimits(IERC20 sellToken, IERC20 buyToken) public view returns (uint256[] memory limits) {
|
||||
(
|
||||
uint256 price_,
|
||||
uint256 fee,
|
||||
uint256 limitMin0,
|
||||
uint256 limitMax0,
|
||||
uint256 limitMin1,
|
||||
uint256 limitMax1
|
||||
) = relayer.getPoolState(address(sellToken), address(buyToken));
|
||||
|
||||
uint256[] memory limits_ = new uint256[](2);
|
||||
limits_[0] = limitMin0;
|
||||
limits_[1] = limitMin1;
|
||||
}
|
||||
|
||||
function testPriceFuzzIntegral(uint256 amount0, uint256 amount1) public {
|
||||
bytes32 pair = bytes32(bytes20(USDC_WETH_PAIR));
|
||||
uint256[] memory limits = adapter.getLimits(pair, USDC, WETH);
|
||||
@@ -58,19 +75,24 @@ contract IntegralSwapAdapterTest is Test, ISwapAdapterTypes {
|
||||
OrderSide side = isBuy ? OrderSide.Buy : OrderSide.Sell;
|
||||
|
||||
bytes32 pair = bytes32(bytes20(USDC_WETH_PAIR));
|
||||
uint256[] memory limits = new uint256[](4);
|
||||
uint256[] memory limits = new uint256[](2);
|
||||
uint256[] memory limitsMin = new uint256[](2);
|
||||
|
||||
if (side == OrderSide.Buy) {
|
||||
limits = adapter.getLimits(pair, USDC, WETH);
|
||||
vm.assume(specifiedAmount < limits[1]);
|
||||
vm.assume(specifiedAmount > limits[3]);
|
||||
|
||||
limitsMin = getMinLimits(USDC, WETH);
|
||||
vm.assume(specifiedAmount > limitsMin[1] * 115 / 100);
|
||||
|
||||
deal(address(USDC), address(this), type(uint256).max);
|
||||
USDC.approve(address(adapter), type(uint256).max);
|
||||
} else {
|
||||
limits = adapter.getLimits(pair, USDC, WETH);
|
||||
vm.assume(specifiedAmount < limits[0]);
|
||||
vm.assume(specifiedAmount > limits[2]);
|
||||
|
||||
limitsMin = getMinLimits(USDC, WETH);
|
||||
vm.assume(specifiedAmount > limitsMin[0] * 115 / 100);
|
||||
|
||||
deal(address(USDC), address(this), type(uint256).max);
|
||||
USDC.approve(address(adapter), specifiedAmount);
|
||||
@@ -167,6 +189,6 @@ contract IntegralSwapAdapterTest is Test, ISwapAdapterTypes {
|
||||
bytes32 pair = bytes32(bytes20(USDC_WETH_PAIR));
|
||||
uint256[] memory limits = adapter.getLimits(pair, USDC, WETH);
|
||||
|
||||
assertEq(limits.length, 4);
|
||||
assertEq(limits.length, 2);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user