From d736631d521629d132af68a8cfe66b0805464370 Mon Sep 17 00:00:00 2001 From: mp-web3 Date: Thu, 21 Dec 2023 18:32:10 +0100 Subject: [PATCH] testPriceDecreasing failing --- evm/test/IntegralSwapAdapter.t.sol | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/evm/test/IntegralSwapAdapter.t.sol b/evm/test/IntegralSwapAdapter.t.sol index e13cbc4..a677ec7 100644 --- a/evm/test/IntegralSwapAdapter.t.sol +++ b/evm/test/IntegralSwapAdapter.t.sol @@ -29,6 +29,7 @@ contract IntegralSwapAdapterTest is Test, ISwapAdapterTypes { } + function testPriceFuzzIntegral(uint256 amount0, uint256 amount1) public { bytes32 pair = bytes32(bytes20(USDC_WETH_PAIR)); uint256[] memory limits = adapter.getLimits(pair, USDC, WETH); @@ -47,4 +48,22 @@ contract IntegralSwapAdapterTest is Test, ISwapAdapterTypes { } } + + function testPriceDecreasingIntegral() public { + bytes32 pair = bytes32(bytes20(USDC_WETH_PAIR)); + uint256[] memory amounts = new uint256[](TEST_ITERATIONS); + + for (uint256 i = 0; i < TEST_ITERATIONS; i++) { + amounts[i] = 1000 * i * 10 ** 6; + } + + Fraction[] memory prices = adapter.price(pair, USDC, WETH, amounts); + + for (uint256 i = 0; i < TEST_ITERATIONS - 1; i++) { + assertEq(prices[i].compareFractions(prices[i + 1]), 1); + assertGt(prices[i].denominator, 0); + assertGt(prices[i + 1].denominator, 0); + } + } + }