Port to Solidity 0.8.21 passes 3 tests
This commit is contained in:
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"solidity.compileUsingRemoteVersion": "v0.8.21+commit.d9974bed"
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
[profile.default]
|
[profile.default]
|
||||||
solc_version = '0.7.6'
|
# solc_version = '0.7.6'
|
||||||
|
solc_version = '0.8.21'
|
||||||
libs = ['lib']
|
libs = ['lib']
|
||||||
remappings = [
|
remappings = [
|
||||||
'@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/',
|
'@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/',
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
../v3-core/contracts/
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../v3-periphery/contracts/
|
|
||||||
Submodule lib/openzeppelin-contracts updated: 04695aecbd...0a25c1940c
@@ -61,7 +61,7 @@ library FullMath {
|
|||||||
// Factor powers of two out of denominator
|
// Factor powers of two out of denominator
|
||||||
// Compute largest power of two divisor of denominator.
|
// Compute largest power of two divisor of denominator.
|
||||||
// Always >= 1.
|
// Always >= 1.
|
||||||
uint256 twos = -denominator & denominator;
|
uint256 twos = uint256(-int256(denominator)) & denominator;
|
||||||
// Divide denominator by power of two
|
// Divide denominator by power of two
|
||||||
assembly {
|
assembly {
|
||||||
denominator := div(denominator, twos)
|
denominator := div(denominator, twos)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ library TickMath {
|
|||||||
/// at the given tick
|
/// at the given tick
|
||||||
function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {
|
function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {
|
||||||
uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));
|
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;
|
uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000;
|
||||||
if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;
|
if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// SPDX-License-Identifier: UNLICENSED
|
// 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';
|
import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
pragma solidity >=0.7.5;
|
pragma solidity >=0.7.5;
|
||||||
pragma abicoder v2;
|
pragma abicoder v2;
|
||||||
|
|
||||||
import '@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol';
|
import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol';
|
||||||
import '@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol';
|
import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol';
|
||||||
|
|
||||||
import './IPoolInitializer.sol';
|
import './IPoolInitializer.sol';
|
||||||
import './IERC721Permit.sol';
|
import './IERC721Permit.sol';
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// 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';
|
import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ library PoolAddress {
|
|||||||
/// @return pool The contract address of the V3 pool
|
/// @return pool The contract address of the V3 pool
|
||||||
function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) {
|
function computeAddress(address factory, PoolKey memory key) internal pure returns (address pool) {
|
||||||
require(key.token0 < key.token1);
|
require(key.token0 < key.token1);
|
||||||
pool = address(
|
pool = address(uint160(
|
||||||
uint256(
|
uint256(
|
||||||
keccak256(
|
keccak256(
|
||||||
abi.encodePacked(
|
abi.encodePacked(
|
||||||
@@ -43,6 +43,6 @@ library PoolAddress {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// SPDX-License-Identifier: UNLICENSED
|
// 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/Script.sol";
|
||||||
import "forge-std/console2.sol";
|
import "forge-std/console2.sol";
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// SPDX-License-Identifier: UNLICENSED
|
// SPDX-License-Identifier: UNLICENSED
|
||||||
pragma solidity =0.7.6;
|
//pragma solidity =0.7.6;
|
||||||
|
pragma solidity >=0.8.0;
|
||||||
pragma abicoder v2;
|
pragma abicoder v2;
|
||||||
|
|
||||||
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol";
|
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol";
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// SPDX-License-Identifier: UNLICENSED
|
// SPDX-License-Identifier: UNLICENSED
|
||||||
pragma solidity =0.7.6;
|
// pragma solidity =0.7.6;
|
||||||
|
pragma solidity >=0.8.0;
|
||||||
import "./OrderLib.sol";
|
import "./OrderLib.sol";
|
||||||
import "./Vault.sol";
|
import "./Vault.sol";
|
||||||
pragma abicoder v2;
|
pragma abicoder v2;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// SPDX-License-Identifier: UNLICENSED
|
// SPDX-License-Identifier: UNLICENSED
|
||||||
pragma solidity =0.7.6;
|
//pragma solidity =0.7.6;
|
||||||
|
pragma solidity >=0.8.0;
|
||||||
|
|
||||||
import "./VaultDeployer.sol";
|
import "./VaultDeployer.sol";
|
||||||
pragma abicoder v2;
|
pragma abicoder v2;
|
||||||
|
|||||||
@@ -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";
|
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
||||||
|
|
||||||
|
|
||||||
contract MockERC20 is ERC20 {
|
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)
|
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 {
|
function mint(address account, uint256 amount) external {
|
||||||
_mint(account, amount);
|
_mint(account, amount);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// SPDX-License-Identifier: UNLICENSED
|
// SPDX-License-Identifier: UNLICENSED
|
||||||
pragma solidity =0.7.6;
|
// pragma solidity =0.7.6;
|
||||||
|
pragma solidity >=0.8.0;
|
||||||
pragma abicoder v2;
|
pragma abicoder v2;
|
||||||
|
|
||||||
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
|
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// SPDX-License-Identifier: UNLICENSED
|
// SPDX-License-Identifier: UNLICENSED
|
||||||
pragma solidity =0.7.6;
|
//pragma solidity =0.7.6;
|
||||||
|
pragma solidity >=0.8.0;
|
||||||
pragma abicoder v2;
|
pragma abicoder v2;
|
||||||
|
|
||||||
import "v3-core/contracts/interfaces/IUniswapV3Pool.sol";
|
import "v3-core/contracts/interfaces/IUniswapV3Pool.sol";
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// SPDX-License-Identifier: UNLICENSED
|
// SPDX-License-Identifier: UNLICENSED
|
||||||
pragma solidity =0.7.6;
|
//pragma solidity =0.7.6;
|
||||||
|
pragma solidity >=0.8.0;
|
||||||
pragma abicoder v2;
|
pragma abicoder v2;
|
||||||
|
|
||||||
import "./Constants.sol";
|
import "./Constants.sol";
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// SPDX-License-Identifier: UNLICENSED
|
// SPDX-License-Identifier: UNLICENSED
|
||||||
pragma solidity =0.7.6;
|
//pragma solidity =0.7.6;
|
||||||
|
pragma solidity >=0.8.0;
|
||||||
pragma abicoder v2;
|
pragma abicoder v2;
|
||||||
|
|
||||||
library Util {
|
library Util {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// SPDX-License-Identifier: UNLICENSED
|
// SPDX-License-Identifier: UNLICENSED
|
||||||
pragma solidity =0.7.6;
|
//pragma solidity =0.7.6;
|
||||||
|
pragma solidity >=0.8.0;
|
||||||
pragma abicoder v2;
|
pragma abicoder v2;
|
||||||
|
|
||||||
import "./Constants.sol";
|
import "./Constants.sol";
|
||||||
@@ -31,7 +32,7 @@ contract Vault {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function withdraw(uint256 amount) public {
|
function withdraw(uint256 amount) public {
|
||||||
_withdrawNative(msg.sender, amount);
|
_withdrawNative(payable(msg.sender), amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
function withdrawTo(address payable recipient, uint256 amount) public {
|
function withdrawTo(address payable recipient, uint256 amount) public {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// SPDX-License-Identifier: UNLICENSED
|
// SPDX-License-Identifier: UNLICENSED
|
||||||
pragma solidity =0.7.6;
|
//pragma solidity =0.7.6;
|
||||||
|
pragma solidity >=0.8.0;
|
||||||
pragma abicoder v2;
|
pragma abicoder v2;
|
||||||
|
|
||||||
import "./Constants.sol";
|
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)
|
// keccak-256 hash of the Vault's bytecode (not the deployed bytecode but the initialization bytecode)
|
||||||
// can paste into:
|
// can paste into:
|
||||||
// https://emn178.github.io/online-tools/keccak_256.html
|
// 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
|
// the contract being constructed must not have any constructor arguments or the determinism will be broken. instead, use a callback to
|
||||||
// get construction arguments
|
// get construction arguments
|
||||||
@@ -22,7 +23,7 @@ library VaultAddress {
|
|||||||
|
|
||||||
function computeAddress(address factory, address owner, uint8 num) internal pure returns (address vault) {
|
function computeAddress(address factory, address owner, uint8 num) internal pure returns (address vault) {
|
||||||
bytes32 salt = keccak256(abi.encodePacked(owner,num));
|
bytes32 salt = keccak256(abi.encodePacked(owner,num));
|
||||||
vault = address(
|
vault = address(uint160(
|
||||||
uint256(
|
uint256(
|
||||||
keccak256(
|
keccak256(
|
||||||
abi.encodePacked(
|
abi.encodePacked(
|
||||||
@@ -33,6 +34,6 @@ library VaultAddress {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// SPDX-License-Identifier: UNLICENSED
|
// SPDX-License-Identifier: UNLICENSED
|
||||||
pragma solidity =0.7.6;
|
//pragma solidity =0.7.6;
|
||||||
|
pragma solidity >=0.8.0;
|
||||||
|
|
||||||
import "./Vault.sol";
|
import "./Vault.sol";
|
||||||
pragma abicoder v2;
|
pragma abicoder v2;
|
||||||
@@ -32,7 +33,7 @@ contract VaultDeployer {
|
|||||||
|
|
||||||
function _deployVault(address owner, uint8 num) internal returns (address payable vault) {
|
function _deployVault(address owner, uint8 num) internal returns (address payable vault) {
|
||||||
parameters = Parameters(owner);
|
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;
|
delete parameters;
|
||||||
emit VaultCreated( owner, num );
|
emit VaultCreated( owner, num );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// SPDX-License-Identifier: UNLICENSED
|
// SPDX-License-Identifier: UNLICENSED
|
||||||
pragma solidity =0.7.6;
|
//pragma solidity =0.7.6;
|
||||||
|
pragma solidity >=0.8.0;
|
||||||
pragma abicoder v2;
|
pragma abicoder v2;
|
||||||
|
|
||||||
interface IVaultDeployer {
|
interface IVaultDeployer {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// SPDX-License-Identifier: UNLICENSED
|
// SPDX-License-Identifier: UNLICENSED
|
||||||
pragma solidity =0.7.6;
|
//pragma solidity =0.7.6;
|
||||||
|
pragma solidity >=0.8.0;
|
||||||
pragma abicoder v2;
|
pragma abicoder v2;
|
||||||
|
|
||||||
import "forge-std/console2.sol";
|
import "forge-std/console2.sol";
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// SPDX-License-Identifier: UNLICENSED
|
// SPDX-License-Identifier: UNLICENSED
|
||||||
pragma solidity =0.7.6;
|
//pragma solidity =0.7.6;
|
||||||
|
pragma solidity >=0.8.0;
|
||||||
pragma abicoder v2;
|
pragma abicoder v2;
|
||||||
|
|
||||||
import "./MockEnv.sol";
|
import "./MockEnv.sol";
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// SPDX-License-Identifier: UNLICENSED
|
// SPDX-License-Identifier: UNLICENSED
|
||||||
pragma solidity =0.7.6;
|
//pragma solidity =0.7.6;
|
||||||
|
pragma solidity >=0.8.0;
|
||||||
pragma abicoder v2;
|
pragma abicoder v2;
|
||||||
|
|
||||||
import "forge-std/console2.sol";
|
import "forge-std/console2.sol";
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// SPDX-License-Identifier: UNLICENSED
|
// 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 "forge-std/console2.sol";
|
||||||
import "../src/Factory.sol";
|
import "../src/Factory.sol";
|
||||||
|
|||||||
Reference in New Issue
Block a user