Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perf/solidity version to 0.8.24 #55

Merged
merged 10 commits into from
Mar 20, 2024
3 changes: 1 addition & 2 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"extends": "solhint:recommended",

"rules": {
"compiler-version": ["error", "0.8.16"],
"compiler-version": ["error", "0.8.24"],
"ordering": "error",
"avoid-throw": "off",
"avoid-suicide": "error",
Expand Down
6 changes: 3 additions & 3 deletions contracts/Farm.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.24;

// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //
// @@@@@@@@@@@@@@@@@@***@@@@@@@@@@@@@@@@@@@@@@@@ //
Expand All @@ -26,7 +26,7 @@ pragma solidity 0.8.16;

import {SafeERC20, IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";
import {Multicall} from "@openzeppelin/contracts/utils/Multicall.sol";
import {FarmStorage} from "./FarmStorage.sol";
Expand Down Expand Up @@ -81,7 +81,7 @@ abstract contract Farm is FarmStorage, Ownable, ReentrancyGuard, Initializable,
error InvalidCooldownPeriod();

// Disallow initialization of a implementation contract.
constructor() {
constructor() Ownable(msg.sender) {
_disableInitializers();
}

Expand Down
7 changes: 4 additions & 3 deletions contracts/FarmDeployer.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.24;

// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //
// @@@@@@@@@@@@@@@@@@***@@@@@@@@@@@@@@@@@@@@@@@@ //
Expand All @@ -26,12 +26,13 @@ pragma solidity 0.8.16;

import {SafeERC20, IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
parv3213 marked this conversation as resolved.
Show resolved Hide resolved
import {IFarmRegistry} from "./interfaces/IFarmRegistry.sol";

/// @title FarmDeployer contract of Demeter Protocol
/// @notice Exposes base functionalities which will be useful in every deployer
/// @author Sperax Foundation
abstract contract FarmDeployer is Ownable {
abstract contract FarmDeployer is Ownable, ReentrancyGuard {
using SafeERC20 for IERC20;

address public immutable FARM_REGISTRY;
Expand All @@ -51,7 +52,7 @@ abstract contract FarmDeployer is Ownable {
/// @notice Constructor.
/// @param _farmRegistry Address of the Demeter Farm Registry.
/// @param _farmId Id of the farm.
constructor(address _farmRegistry, string memory _farmId) {
constructor(address _farmRegistry, string memory _farmId) Ownable(msg.sender) {
_validateNonZeroAddr(_farmRegistry);
FARM_REGISTRY = _farmRegistry;
farmId = _farmId;
Expand Down
4 changes: 2 additions & 2 deletions contracts/FarmRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.24;

// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //
// @@@@@@@@@@@@@@@@@@***@@@@@@@@@@@@@@@@@@@@@@@@ //
Expand Down Expand Up @@ -67,7 +67,7 @@ contract FarmRegistry is OwnableUpgradeable {
external
initializer
{
OwnableUpgradeable.__Ownable_init();
OwnableUpgradeable.__Ownable_init(msg.sender);
updateFeeParams(_feeReceiver, _feeToken, _feeAmount, _extensionFeePerDay);
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/FarmStorage.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.24;

// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //
// @@@@@@@@@@@@@@@@@@***@@@@@@@@@@@@@@@@@@@@@@@@ //
Expand Down
3 changes: 1 addition & 2 deletions contracts/e20-farms/E20Farm.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.24;

// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //
// @@@@@@@@@@@@@@@@@@***@@@@@@@@@@@@@@@@@@@@@@@@ //
Expand Down Expand Up @@ -27,7 +27,6 @@ pragma solidity 0.8.16;
import {SafeERC20, IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {RewardTokenData} from "../Farm.sol";
import {ExpirableFarm} from "../features/ExpirableFarm.sol";
import {Deposit} from "../interfaces/DataTypes.sol";
import {OperableDeposit} from "../features/OperableDeposit.sol";

abstract contract E20Farm is ExpirableFarm, OperableDeposit {
Expand Down
2 changes: 1 addition & 1 deletion contracts/e20-farms/balancerV2/BalancerV2Farm.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.24;

// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //
// @@@@@@@@@@@@@@@@@@***@@@@@@@@@@@@@@@@@@@@@@@@ //
Expand Down
5 changes: 2 additions & 3 deletions contracts/e20-farms/balancerV2/BalancerV2FarmDeployer.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.24;

// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //
// @@@@@@@@@@@@@@@@@@***@@@@@@@@@@@@@@@@@@@@@@@@ //
Expand Down Expand Up @@ -27,15 +27,14 @@ pragma solidity 0.8.16;
import {FarmDeployer, SafeERC20, IERC20, IFarmRegistry} from "../../FarmDeployer.sol";
import {IBalancerV2Vault} from "./interfaces/IBalancerV2Vault.sol";
import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import {RewardTokenData} from "../E20Farm.sol";
import {BalancerV2Farm} from "./BalancerV2Farm.sol";

/// @title Deployer for Balancer farm
/// @author Sperax Foundation
/// @notice This contract allows anyone to calculate fees and create farms
/// @dev It consults Balancer's vault to validate the pool
contract BalancerV2FarmDeployer is FarmDeployer, ReentrancyGuard {
contract BalancerV2FarmDeployer is FarmDeployer {
using SafeERC20 for IERC20;

// farmAdmin - Address to which ownership of farm is transferred to post deployment
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.24;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/e20-farms/uniswapV2/UniV2Farm.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.24;

// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //
// @@@@@@@@@@@@@@@@@@***@@@@@@@@@@@@@@@@@@@@@@@@ //
Expand Down
5 changes: 2 additions & 3 deletions contracts/e20-farms/uniswapV2/UniV2FarmDeployer.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.24;

// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //
// @@@@@@@@@@@@@@@@@@***@@@@@@@@@@@@@@@@@@@@@@@@ //
Expand Down Expand Up @@ -27,11 +27,10 @@ pragma solidity 0.8.16;
import {FarmDeployer, SafeERC20, IERC20, IFarmRegistry} from "../../FarmDeployer.sol";
import {IUniswapV2Factory} from "./interfaces/IUniswapV2Factory.sol";
import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import {RewardTokenData} from "../E20Farm.sol";
import {UniV2Farm} from "./UniV2Farm.sol";

contract UniV2FarmDeployer is FarmDeployer, ReentrancyGuard {
contract UniV2FarmDeployer is FarmDeployer {
using SafeERC20 for IERC20;

// @dev the token Order is not important
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.8.16;
pragma solidity 0.8.24;

interface IUniswapV2Factory {
function getPair(address _tokenA, address _tokenB) external view returns (address);
Expand Down
2 changes: 1 addition & 1 deletion contracts/e721-farms/E721Farm.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.24;

// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //
// @@@@@@@@@@@@@@@@@@***@@@@@@@@@@@@@@@@@@@@@@@@ //
Expand Down
3 changes: 1 addition & 2 deletions contracts/e721-farms/camelotV2/CamelotV2Farm.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.24;

// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //
// @@@@@@@@@@@@@@@@@@***@@@@@@@@@@@@@@@@@@@@@@@@ //
Expand Down Expand Up @@ -29,7 +29,6 @@ import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol
import {INFTPoolFactory, INFTPool, INFTHandler, IPair, IRouter} from "./interfaces/ICamelotV2.sol";
import {RewardTokenData} from "../../Farm.sol";
import {Farm, E721Farm} from "../E721Farm.sol";
import {Deposit} from "../../interfaces/DataTypes.sol";
import {OperableDeposit} from "../../features/OperableDeposit.sol";
import {ExpirableFarm} from "../../features/ExpirableFarm.sol";
import {TokenUtils} from "../../utils/TokenUtils.sol";
Expand Down
5 changes: 2 additions & 3 deletions contracts/e721-farms/camelotV2/CamelotV2FarmDeployer.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.24;

// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //
// @@@@@@@@@@@@@@@@@@***@@@@@@@@@@@@@@@@@@@@@@@@ //
Expand Down Expand Up @@ -27,10 +27,9 @@ pragma solidity 0.8.16;
import {FarmDeployer, IFarmRegistry} from "../../FarmDeployer.sol";
import {CamelotV2Farm, RewardTokenData} from "./CamelotV2Farm.sol";
import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import {ICamelotV2Factory} from "./interfaces/ICamelotV2.sol";

contract CamelotV2FarmDeployer is FarmDeployer, ReentrancyGuard {
contract CamelotV2FarmDeployer is FarmDeployer {
// @dev the token Order is not important
struct CamelotPoolData {
address tokenA;
Expand Down
2 changes: 1 addition & 1 deletion contracts/e721-farms/camelotV2/interfaces/ICamelotV2.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT Line
pragma solidity 0.8.16;
pragma solidity 0.8.24;

import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";

Expand Down
14 changes: 8 additions & 6 deletions contracts/e721-farms/camelotV3/CamelotV3Farm.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.24;

// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //
// @@@@@@@@@@@@@@@@@@***@@@@@@@@@@@@@@@@@@@@@@@@ //
Expand Down Expand Up @@ -30,9 +30,7 @@ import {ExpirableFarm} from "../../features/ExpirableFarm.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {INFPM, ICamelotV3Factory, ICamelotV3TickSpacing} from "./interfaces/ICamelotV3.sol";
import {ICamelotV3Utils} from "./interfaces/ICamelotV3Utils.sol";
import {ICamelotV3NFPMUtils, Position} from "./interfaces/ICamelotV3NonfungiblePositionManagerUtils.sol";
import {Deposit} from "../../interfaces/DataTypes.sol";
import {OperableDeposit} from "../../features/OperableDeposit.sol";
import {TokenUtils} from "../../utils/TokenUtils.sol";

Expand Down Expand Up @@ -229,9 +227,13 @@ contract CamelotV3Farm is E721Farm, ExpirableFarm, OperableDeposit {

/// @notice A function to be called by Demeter Rewarder to get tokens and amounts associated with the farm's liquidity.
function getTokenAmounts() external view override returns (address[] memory, uint256[] memory) {
return TokenUtils.getCamelotV3TokenAmounts(
camelotPool, camelotUtils, tickLowerAllowed, tickUpperAllowed, rewardFunds[COMMON_FUND_ID].totalLiquidity
);
return TokenUtils.getCamelotV3TokenAmounts({
_camelotPool: camelotPool,
_camelotUtils: camelotUtils,
_tickLower: tickLowerAllowed,
_tickUpper: tickUpperAllowed,
_liquidity: rewardFunds[COMMON_FUND_ID].totalLiquidity
});
}

// --------------------- Public and overriding Functions ---------------------
Expand Down
5 changes: 2 additions & 3 deletions contracts/e721-farms/camelotV3/CamelotV3FarmDeployer.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.24;

// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //
// @@@@@@@@@@@@@@@@@@***@@@@@@@@@@@@@@@@@@@@@@@@ //
Expand Down Expand Up @@ -27,9 +27,8 @@ pragma solidity 0.8.16;
import {FarmDeployer, IFarmRegistry} from "../../FarmDeployer.sol";
import {CamelotV3Farm, RewardTokenData, CamelotPoolData, InitializeInput} from "./CamelotV3Farm.sol";
import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";

contract CamelotV3FarmDeployer is FarmDeployer, ReentrancyGuard {
contract CamelotV3FarmDeployer is FarmDeployer {
// farmAdmin - Address to which ownership of farm is transferred to post deployment
// farmStartTime - Time after which the rewards start accruing for the deposits in the farm.
// cooldownPeriod - cooldown period for locked deposits (in days)
Expand Down
2 changes: 1 addition & 1 deletion contracts/e721-farms/camelotV3/interfaces/ICamelotV3.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.16;
pragma solidity 0.8.24;

import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.24;

struct Position {
uint96 nonce;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.24;

interface ICamelotV3Utils {
function getAmountsForLiquidity(uint160 sqrtRatioX96, int24 _tickLower, int24 _tickUpper, uint128 _liquidity)
Expand Down
34 changes: 17 additions & 17 deletions contracts/e721-farms/uniswapV3/UniV3ActiveLiquidityDeployer.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.24;

// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //
// @@@@@@@@@@@@@@@@@@***@@@@@@@@@@@@@@@@@@@@@@@@ //
Expand All @@ -25,12 +25,11 @@ pragma solidity 0.8.16;
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //

import {FarmDeployer, IFarmRegistry} from "../../FarmDeployer.sol";
import {RewardTokenData, UniswapPoolData} from "./UniV3Farm.sol";
import {RewardTokenData, UniswapPoolData, InitializeInput} from "./UniV3Farm.sol";
import {UniV3ActiveLiquidityFarm} from "./UniV3ActiveLiquidityFarm.sol";
import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";

contract UniV3ActiveLiquidityDeployer is FarmDeployer, ReentrancyGuard {
contract UniV3ActiveLiquidityDeployer is FarmDeployer {
// farmAdmin - Address to which ownership of farm is transferred to post deployment
// farmStartTime - Time after which the rewards start accruing for the deposits in the farm.
// cooldownPeriod - cooldown period for locked deposits (in days)
Expand Down Expand Up @@ -82,20 +81,21 @@ contract UniV3ActiveLiquidityDeployer is FarmDeployer, ReentrancyGuard {
/// @param _data data for deployment.
function createFarm(FarmData memory _data) external nonReentrant returns (address) {
_validateNonZeroAddr(_data.farmAdmin);

UniV3ActiveLiquidityFarm farmInstance = UniV3ActiveLiquidityFarm(Clones.clone(farmImplementation));
farmInstance.initialize({
_farmId: farmId,
_farmStartTime: _data.farmStartTime,
_cooldownPeriod: _data.cooldownPeriod,
_farmRegistry: FARM_REGISTRY,
_uniswapPoolData: _data.uniswapPoolData,
_rwdTokenData: _data.rewardData,
_uniV3Factory: UNI_V3_FACTORY,
_nftContract: NFPM,
_uniswapUtils: UNISWAP_UTILS,
_nfpmUtils: NFPM_UTILS
});
farmInstance.initialize(
InitializeInput({
farmId: farmId,
farmStartTime: _data.farmStartTime,
cooldownPeriod: _data.cooldownPeriod,
farmRegistry: FARM_REGISTRY,
uniswapPoolData: _data.uniswapPoolData,
rwdTokenData: _data.rewardData,
uniV3Factory: UNI_V3_FACTORY,
nftContract: NFPM,
uniswapUtils: UNISWAP_UTILS,
nfpmUtils: NFPM_UTILS
})
);
farmInstance.transferOwnership(_data.farmAdmin);
address farm = address(farmInstance);
// Calculate and collect fee if required
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;
pragma solidity 0.8.24;

// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //
// @@@@@@@@@@@@@@@@@@***@@@@@@@@@@@@@@@@@@@@@@@@ //
Expand Down
Loading
Loading