testPriceFuzzIntegral

This commit is contained in:
mp-web3
2023-12-21 18:29:02 +01:00
parent 87193425a8
commit 6c3eeff329
2 changed files with 20 additions and 0 deletions

View File

@@ -1,3 +1,4 @@
/*
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.13;
@@ -569,3 +570,4 @@ interface ITwapPair is ITwapERC20, IReserves {
function getDepositAmount1In(uint256 amount1, bytes calldata data) external view returns (uint256 depositAmount1In);
}
*/

View File

@@ -29,4 +29,22 @@ 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);
vm.assume(amount0 < limits[0]);
vm.assume(amount1 < limits[1]);
uint256[] memory amounts = new uint256[](2);
amounts[0] = amount0;
amounts[1] = amount1;
Fraction[] memory prices = adapter.price(pair, WETH, USDC, amounts);
for (uint256 i = 0; i < prices.length; i++) {
assertGt(prices[i].numerator, 0);
assertGt(prices[i].denominator, 0);
}
}
}