Skip to content

Commit

Permalink
use signed integer bound
Browse files Browse the repository at this point in the history
  • Loading branch information
gretzke committed May 16, 2024
1 parent dbfdf96 commit 35aadb3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/test/Fuzzers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,11 @@ contract Fuzzers is StdUtils {
return (tickLower, tickUpper);
}

function createRandomSqrtPriceX96(PoolKey memory key, uint256 seed) internal pure returns (uint160) {
function createRandomSqrtPriceX96(PoolKey memory key, int256 seed) internal pure returns (uint160) {
int24 tickSpacing = key.tickSpacing;
int256 min = int256(TickMath.minUsableTick(tickSpacing));
int256 max = int256(TickMath.maxUsableTick(tickSpacing));
uint256 range = uint256(max - min);
int256 randomTick = int256(bound(seed, 0, range)) + min;
int256 randomTick = bound(seed, min, max);
return TickMath.getSqrtPriceAtTick(int24(randomTick));
}

Expand Down
4 changes: 2 additions & 2 deletions test/PoolManager.swap.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ abstract contract V3Fuzzer is V3Helper, Deployers, Fuzzers, IUniswapV3MintCallba

function addLiquidity(
FeeTiers fee,
uint256 sqrtPriceX96seed,
int256 sqrtPriceX96seed,
int24 lowerTick,
int24 upperTick,
int128 liquidityDelta
Expand Down Expand Up @@ -102,7 +102,7 @@ abstract contract V3Fuzzer is V3Helper, Deployers, Fuzzers, IUniswapV3MintCallba
}

contract V3SwapTests is V3Fuzzer {
function test_shouldSwapEqual(int24 lowerTick, int24 upperTick, int128 liquidityDelta, uint256 sqrtPriceX96seed)
function test_shouldSwapEqual(int24 lowerTick, int24 upperTick, int128 liquidityDelta, int256 sqrtPriceX96seed)
public
{
(IUniswapV3Pool pool, PoolKey memory key_) =
Expand Down

0 comments on commit 35aadb3

Please sign in to comment.