Port to Solidity 0.8.21 passes 3 tests

This commit is contained in:
7400
2023-10-25 08:14:19 -07:00
parent 72cbdbc2fd
commit 499782828a
28 changed files with 63 additions and 36 deletions

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"solidity.compileUsingRemoteVersion": "v0.8.21+commit.d9974bed"
}

View File

@@ -1,5 +1,6 @@
[profile.default]
solc_version = '0.7.6'
# solc_version = '0.7.6'
solc_version = '0.8.21'
libs = ['lib']
remappings = [
'@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/',

View File

@@ -1 +0,0 @@
../v3-core/contracts/

View File

@@ -1 +0,0 @@
../v3-periphery/contracts/

View File

@@ -61,7 +61,7 @@ library FullMath {
// Factor powers of two out of denominator
// Compute largest power of two divisor of denominator.
// Always >= 1.
uint256 twos = -denominator & denominator;
uint256 twos = uint256(-int256(denominator)) & denominator;
// Divide denominator by power of two
assembly {
denominator := div(denominator, twos)

View File

@@ -22,7 +22,7 @@ library TickMath {
/// at the given tick
function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {
uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));
require(absTick <= uint256(MAX_TICK), 'T');
require(absTick <= uint256(int256(MAX_TICK)), 'T');
uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000;
if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;

View File

@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.0;
pragma solidity >=0.8.0;
//pragma solidity ^0.7.0;
import '@openzeppelin/contracts/token/ERC20/IERC20.sol';

View File

@@ -2,8 +2,8 @@
pragma solidity >=0.7.5;
pragma abicoder v2;
import '@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol';
import '@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol';
import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol';
import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol';
import './IPoolInitializer.sol';
import './IERC721Permit.sol';

View File

@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity =0.7.6;
// pragma solidity =0.7.6;
pragma solidity >=0.8.0;
import '@openzeppelin/contracts/token/ERC20/IERC20.sol';

View File

@@ -32,7 +32,7 @@ library PoolAddress {
/// @return pool The contract address of the V3 pool
function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) {
require(key.token0 < key.token1);
pool = address(
pool = address(uint160(
uint256(
keccak256(
abi.encodePacked(
@@ -43,6 +43,6 @@ library PoolAddress {
)
)
)
);
));
}
}

View File

@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.7.6;
// pragma solidity =0.7.6;
pragma solidity >=0.8.0;
import "forge-std/Script.sol";
import "forge-std/console2.sol";

View File

@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.7.6;
//pragma solidity =0.7.6;
pragma solidity >=0.8.0;
pragma abicoder v2;
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol";

View File

@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.7.6;
// pragma solidity =0.7.6;
pragma solidity >=0.8.0;
import "./OrderLib.sol";
import "./Vault.sol";
pragma abicoder v2;

View File

@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.7.6;
//pragma solidity =0.7.6;
pragma solidity >=0.8.0;
import "./VaultDeployer.sol";
pragma abicoder v2;

View File

@@ -1,15 +1,22 @@
pragma solidity =0.7.6;
//pragma solidity =0.7.6;
pragma solidity >=0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract MockERC20 is ERC20 {
constructor(string memory name, string memory symbol, uint8 decimals)
uint8 private _decimals;
constructor(string memory name, string memory symbol, uint8 decimals_)
ERC20(name, symbol)
{
_setupDecimals(decimals);
// _setupDecimals(decimals);
_decimals = decimals_;
}
function decimals() public view override returns (uint8) {
return _decimals;
}
function mint(address account, uint256 amount) external {
_mint(account, amount);

View File

@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.7.6;
// pragma solidity =0.7.6;
pragma solidity >=0.8.0;
pragma abicoder v2;
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";

View File

@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.7.6;
//pragma solidity =0.7.6;
pragma solidity >=0.8.0;
pragma abicoder v2;
import "v3-core/contracts/interfaces/IUniswapV3Pool.sol";

View File

@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.7.6;
//pragma solidity =0.7.6;
pragma solidity >=0.8.0;
pragma abicoder v2;
import "./Constants.sol";

View File

@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.7.6;
//pragma solidity =0.7.6;
pragma solidity >=0.8.0;
pragma abicoder v2;
library Util {

View File

@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.7.6;
//pragma solidity =0.7.6;
pragma solidity >=0.8.0;
pragma abicoder v2;
import "./Constants.sol";
@@ -31,7 +32,7 @@ contract Vault {
}
function withdraw(uint256 amount) public {
_withdrawNative(msg.sender, amount);
_withdrawNative(payable(msg.sender), amount);
}
function withdrawTo(address payable recipient, uint256 amount) public {

View File

@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.7.6;
//pragma solidity =0.7.6;
pragma solidity >=0.8.0;
pragma abicoder v2;
import "./Constants.sol";
@@ -10,7 +11,7 @@ library VaultAddress {
// keccak-256 hash of the Vault's bytecode (not the deployed bytecode but the initialization bytecode)
// can paste into:
// https://emn178.github.io/online-tools/keccak_256.html
bytes32 internal constant VAULT_INIT_CODE_HASH = 0xbc5f4b6509a7bbf6d9bcbd2b24c599e63143e9ba77aebe3d9486f1cbfcbda9ea;
bytes32 internal constant VAULT_INIT_CODE_HASH = 0x060e1878e07cde3b1fe03b6a8929c62c502510ed5dda30b278951f11dfc03490;
// the contract being constructed must not have any constructor arguments or the determinism will be broken. instead, use a callback to
// get construction arguments
@@ -22,7 +23,7 @@ library VaultAddress {
function computeAddress(address factory, address owner, uint8 num) internal pure returns (address vault) {
bytes32 salt = keccak256(abi.encodePacked(owner,num));
vault = address(
vault = address(uint160(
uint256(
keccak256(
abi.encodePacked(
@@ -33,6 +34,6 @@ library VaultAddress {
)
)
)
);
));
}
}

View File

@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.7.6;
//pragma solidity =0.7.6;
pragma solidity >=0.8.0;
import "./Vault.sol";
pragma abicoder v2;
@@ -32,7 +33,7 @@ contract VaultDeployer {
function _deployVault(address owner, uint8 num) internal returns (address payable vault) {
parameters = Parameters(owner);
vault = address(new Vault{salt: keccak256(abi.encodePacked(owner,num))}());
vault = payable(address(new Vault{salt: keccak256(abi.encodePacked(owner,num))}()));
delete parameters;
emit VaultCreated( owner, num );
}

View File

@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.7.6;
//pragma solidity =0.7.6;
pragma solidity >=0.8.0;
pragma abicoder v2;
interface IVaultDeployer {

View File

@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.7.6;
//pragma solidity =0.7.6;
pragma solidity >=0.8.0;
pragma abicoder v2;
import "forge-std/console2.sol";

View File

@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.7.6;
//pragma solidity =0.7.6;
pragma solidity >=0.8.0;
pragma abicoder v2;
import "./MockEnv.sol";

View File

@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.7.6;
//pragma solidity =0.7.6;
pragma solidity >=0.8.0;
pragma abicoder v2;
import "forge-std/console2.sol";

View File

@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity =0.7.6;
pragma solidity >=0.8.0;
//pragma solidity =0.7.6;
import "forge-std/console2.sol";
import "../src/Factory.sol";