diff --git a/.solhint.json b/.solhint.json index 744b9dad..1a8e06a7 100644 --- a/.solhint.json +++ b/.solhint.json @@ -3,6 +3,14 @@ "plugins": [], "rules": { "avoid-suicide": "error", - "avoid-sha3": "warn" + "avoid-sha3": "warn", + "var-name-mixedcase": "off", + "func-name-mixedcase": "off", + "func-visibility": [ + "warn", + { + "ignoreConstructors": true + } + ] } -} +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index b77efa25..fa43531f 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -66,7 +66,7 @@ { "label": "test", "type": "shell", - "command": "forge test -vvv", + "command": "forge test -v", "options": { "cwd": "${workspaceFolder}" }, @@ -116,4 +116,4 @@ } } ] -} +} \ No newline at end of file diff --git a/contracts/Auction.sol b/contracts/Auction.sol index 2963bab1..e5c7f67c 100644 --- a/contracts/Auction.sol +++ b/contracts/Auction.sol @@ -1,14 +1,14 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "./library/UtilLib.sol"; - -import "../contracts/interfaces/SDCollateral/IAuction.sol"; -import "../contracts/interfaces/IStaderStakePoolManager.sol"; - -import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; +import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; + +import { UtilLib } from "./library/UtilLib.sol"; +import { IAuction } from "../contracts/interfaces/SDCollateral/IAuction.sol"; +import { IStaderStakePoolManager } from "../contracts/interfaces/IStaderStakePoolManager.sol"; +import { IStaderConfig } from "./interfaces/IStaderConfig.sol"; contract Auction is IAuction, AccessControlUpgradeable, ReentrancyGuardUpgradeable { IStaderConfig public override staderConfig; diff --git a/contracts/ETHx.sol b/contracts/ETHx.sol index 8c5f9e56..bdf69f6d 100644 --- a/contracts/ETHx.sol +++ b/contracts/ETHx.sol @@ -1,12 +1,14 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "./library/UtilLib.sol"; -import "./interfaces/IStaderConfig.sol"; +import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; +import { ERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; +import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; +import { UtilLib } from "./library/UtilLib.sol"; + +import { IStaderConfig } from "./interfaces/IStaderConfig.sol"; /** * @title ETHx token Contract diff --git a/contracts/L2/ETHx.sol b/contracts/L2/ETHx.sol index 431ad29b..3323badb 100644 --- a/contracts/L2/ETHx.sol +++ b/contracts/L2/ETHx.sol @@ -1,9 +1,10 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; +import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; +import { ERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; +import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; /** * @title ETHx token Contract for L2s diff --git a/contracts/NodeELRewardVault.sol b/contracts/NodeELRewardVault.sol index 62570877..3ceef916 100644 --- a/contracts/NodeELRewardVault.sol +++ b/contracts/NodeELRewardVault.sol @@ -1,18 +1,16 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "./library/UtilLib.sol"; +import { UtilLib } from "./library/UtilLib.sol"; -import "./interfaces/IPoolUtils.sol"; -import "./interfaces/IVaultProxy.sol"; -import "./interfaces/INodeRegistry.sol"; -import "./interfaces/INodeELRewardVault.sol"; -import "./interfaces/IStaderStakePoolManager.sol"; -import "./interfaces/IOperatorRewardsCollector.sol"; +import { IStaderConfig } from "./interfaces/IStaderConfig.sol"; +import { IPoolUtils } from "./interfaces/IPoolUtils.sol"; +import { IVaultProxy } from "./interfaces/IVaultProxy.sol"; +import { INodeELRewardVault } from "./interfaces/INodeELRewardVault.sol"; +import { IStaderStakePoolManager } from "./interfaces/IStaderStakePoolManager.sol"; +import { IOperatorRewardsCollector } from "./interfaces/IOperatorRewardsCollector.sol"; contract NodeELRewardVault is INodeELRewardVault { - constructor() {} - /** * @notice Allows the contract to receive ETH * @dev execution layer rewards may be sent as plain ETH transfers diff --git a/contracts/OperatorRewardsCollector.sol b/contracts/OperatorRewardsCollector.sol index 873a224b..7a318eb2 100644 --- a/contracts/OperatorRewardsCollector.sol +++ b/contracts/OperatorRewardsCollector.sol @@ -1,20 +1,21 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "./library/UtilLib.sol"; - -import "./interfaces/INodeRegistry.sol"; -import "./interfaces/INodeELRewardVault.sol"; -import "./interfaces/IPermissionlessNodeRegistry.sol"; -import "./interfaces/IOperatorRewardsCollector.sol"; -import "./interfaces/IStaderConfig.sol"; -import "./interfaces/ISDUtilityPool.sol"; -import "./interfaces/SDCollateral/ISDCollateral.sol"; -import "./interfaces/IWETH.sol"; -import "../contracts/interfaces/IStaderOracle.sol"; - -import "@openzeppelin/contracts/utils/math/Math.sol"; -import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; +import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; + +import { UtilLib } from "./library/UtilLib.sol"; + +import { IStaderConfig } from "./interfaces/IStaderConfig.sol"; +import { INodeRegistry } from "./interfaces/INodeRegistry.sol"; +import { INodeELRewardVault } from "./interfaces/INodeELRewardVault.sol"; +import { IPermissionlessNodeRegistry } from "./interfaces/IPermissionlessNodeRegistry.sol"; +import { IOperatorRewardsCollector } from "./interfaces/IOperatorRewardsCollector.sol"; +import { IStaderConfig } from "./interfaces/IStaderConfig.sol"; +import { ISDUtilityPool, UserData, OperatorLiquidation } from "./interfaces/ISDUtilityPool.sol"; +import { ISDCollateral } from "./interfaces/SDCollateral/ISDCollateral.sol"; +import { IWETH } from "./interfaces/IWETH.sol"; +import { IStaderOracle } from "../contracts/interfaces/IStaderOracle.sol"; contract OperatorRewardsCollector is IOperatorRewardsCollector, AccessControlUpgradeable { IStaderConfig public staderConfig; @@ -46,22 +47,15 @@ contract OperatorRewardsCollector is IOperatorRewardsCollector, AccessControlUpg emit DepositedFor(msg.sender, _receiver, msg.value); } - event log_uint256(string message, uint256 value); - /** * @notice Claims payouts for an operator, repaying any outstanding liquidations and transferring any remaining balance to the operator's rewards address. * @dev This function first checks for any unpaid liquidations for the operator and repays them if necessary. Then, it transfers any remaining balance to the operator's reward address. */ function claim() external { claimLiquidation(msg.sender); - - emit log_uint256("withdrawableInEth(msg.sender)", withdrawableInEth(msg.sender)); - uint256 amount = balances[msg.sender] > withdrawableInEth(msg.sender) ? withdrawableInEth(msg.sender) : balances[msg.sender]; - - emit log_uint256("claim amount", amount); _claim(msg.sender, amount); } diff --git a/contracts/Penalty.sol b/contracts/Penalty.sol index 0a633e9c..a92f8a2f 100644 --- a/contracts/Penalty.sol +++ b/contracts/Penalty.sol @@ -1,15 +1,15 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "./library/UtilLib.sol"; +import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; -import "./interfaces/IPenalty.sol"; -import "./interfaces/IRatedV1.sol"; -import "./interfaces/IStaderOracle.sol"; -import "./interfaces/IStaderConfig.sol"; +import { UtilLib } from "./library/UtilLib.sol"; -import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; +import { IPenalty } from "./interfaces/IPenalty.sol"; +import { IStaderOracle } from "./interfaces/IStaderOracle.sol"; +import { IStaderConfig } from "./interfaces/IStaderConfig.sol"; +import { IRatedV1 } from "./interfaces/IRatedV1.sol"; contract Penalty is IPenalty, AccessControlUpgradeable, ReentrancyGuardUpgradeable { IStaderConfig public staderConfig; diff --git a/contracts/PermissionedNodeRegistry.sol b/contracts/PermissionedNodeRegistry.sol index 10e73a5d..6d82e482 100644 --- a/contracts/PermissionedNodeRegistry.sol +++ b/contracts/PermissionedNodeRegistry.sol @@ -1,22 +1,22 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "./library/UtilLib.sol"; - -import "./library/ValidatorStatus.sol"; -import "./interfaces/IStaderConfig.sol"; -import "./interfaces/IVaultFactory.sol"; -import "./interfaces/IPoolUtils.sol"; -import "./interfaces/INodeRegistry.sol"; -import "./interfaces/IPermissionedPool.sol"; -import "./interfaces/IValidatorWithdrawalVault.sol"; -import "./interfaces/SDCollateral/ISDCollateral.sol"; -import "./interfaces/IPermissionedNodeRegistry.sol"; - -import "@openzeppelin/contracts/utils/math/Math.sol"; -import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; +import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; +import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; +import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; + +import { UtilLib } from "./library/UtilLib.sol"; + +import { ValidatorStatus } from "./library/ValidatorStatus.sol"; +import { IStaderConfig } from "./interfaces/IStaderConfig.sol"; +import { IVaultFactory } from "./interfaces/IVaultFactory.sol"; +import { IPoolUtils } from "./interfaces/IPoolUtils.sol"; +import { Operator, Validator, INodeRegistry } from "./interfaces/INodeRegistry.sol"; +import { IPermissionedPool } from "./interfaces/IPermissionedPool.sol"; +import { IValidatorWithdrawalVault } from "./interfaces/IValidatorWithdrawalVault.sol"; +import { ISDCollateral } from "./interfaces/SDCollateral/ISDCollateral.sol"; +import { IPermissionedNodeRegistry } from "./interfaces/IPermissionedNodeRegistry.sol"; contract PermissionedNodeRegistry is INodeRegistry, diff --git a/contracts/PermissionedPool.sol b/contracts/PermissionedPool.sol index a287590c..51e13681 100644 --- a/contracts/PermissionedPool.sol +++ b/contracts/PermissionedPool.sol @@ -1,22 +1,20 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "./library/UtilLib.sol"; - -import "./library/ValidatorStatus.sol"; - -import "./interfaces/IStaderConfig.sol"; -import "./interfaces/IVaultFactory.sol"; -import "./interfaces/INodeRegistry.sol"; -import "./interfaces/IStaderPoolBase.sol"; -import "./interfaces/IDepositContract.sol"; -import "./interfaces/IStaderInsuranceFund.sol"; -import "./interfaces/IStaderStakePoolManager.sol"; -import "./interfaces/IPermissionedNodeRegistry.sol"; - -import "@openzeppelin/contracts/utils/math/Math.sol"; -import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; +import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; +import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; + +import { UtilLib } from "./library/UtilLib.sol"; + +import { IStaderConfig } from "./interfaces/IStaderConfig.sol"; +import { IVaultFactory } from "./interfaces/IVaultFactory.sol"; +import { INodeRegistry } from "./interfaces/INodeRegistry.sol"; +import { IStaderPoolBase } from "./interfaces/IStaderPoolBase.sol"; +import { IDepositContract } from "./interfaces/IDepositContract.sol"; +import { IStaderInsuranceFund } from "./interfaces/IStaderInsuranceFund.sol"; +import { IStaderStakePoolManager } from "./interfaces/IStaderStakePoolManager.sol"; +import { IPermissionedNodeRegistry } from "./interfaces/IPermissionedNodeRegistry.sol"; contract PermissionedPool is IStaderPoolBase, AccessControlUpgradeable, ReentrancyGuardUpgradeable { using Math for uint256; diff --git a/contracts/PermissionlessNodeRegistry.sol b/contracts/PermissionlessNodeRegistry.sol index fa6e666c..1565929e 100644 --- a/contracts/PermissionlessNodeRegistry.sol +++ b/contracts/PermissionlessNodeRegistry.sol @@ -1,25 +1,25 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "./library/UtilLib.sol"; - -import "./library/ValidatorStatus.sol"; -import "./interfaces/IStaderConfig.sol"; -import "./interfaces/IVaultFactory.sol"; -import "./interfaces/IPoolUtils.sol"; -import "./interfaces/INodeRegistry.sol"; -import "./interfaces/ISDUtilityPool.sol"; -import "./interfaces/IPermissionlessPool.sol"; -import "./interfaces/INodeELRewardVault.sol"; -import "./interfaces/IStaderInsuranceFund.sol"; -import "./interfaces/IValidatorWithdrawalVault.sol"; -import "./interfaces/SDCollateral/ISDCollateral.sol"; -import "./interfaces/IPermissionlessNodeRegistry.sol"; -import "./interfaces/IOperatorRewardsCollector.sol"; - -import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; +import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; +import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; + +import { UtilLib } from "./library/UtilLib.sol"; + +import { ValidatorStatus } from "./library/ValidatorStatus.sol"; +import { IStaderConfig } from "./interfaces/IStaderConfig.sol"; +import { IVaultFactory } from "./interfaces/IVaultFactory.sol"; +import { IPoolUtils } from "./interfaces/IPoolUtils.sol"; +import { Operator, Validator, INodeRegistry } from "./interfaces/INodeRegistry.sol"; +import { ISDUtilityPool } from "./interfaces/ISDUtilityPool.sol"; +import { IPermissionlessPool } from "./interfaces/IPermissionlessPool.sol"; +import { INodeELRewardVault } from "./interfaces/INodeELRewardVault.sol"; +import { IStaderInsuranceFund } from "./interfaces/IStaderInsuranceFund.sol"; +import { IValidatorWithdrawalVault } from "./interfaces/IValidatorWithdrawalVault.sol"; +import { ISDCollateral } from "./interfaces/SDCollateral/ISDCollateral.sol"; +import { IPermissionlessNodeRegistry } from "./interfaces/IPermissionlessNodeRegistry.sol"; +import { IOperatorRewardsCollector } from "./interfaces/IOperatorRewardsCollector.sol"; contract PermissionlessNodeRegistry is INodeRegistry, diff --git a/contracts/PermissionlessPool.sol b/contracts/PermissionlessPool.sol index e568859f..6a211e43 100644 --- a/contracts/PermissionlessPool.sol +++ b/contracts/PermissionlessPool.sol @@ -1,20 +1,18 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "./library/UtilLib.sol"; -import "./library/ValidatorStatus.sol"; - -import "./interfaces/IStaderConfig.sol"; -import "./interfaces/IVaultFactory.sol"; -import "./interfaces/INodeRegistry.sol"; -import "./interfaces/IStaderPoolBase.sol"; -import "./interfaces/IDepositContract.sol"; -import "./interfaces/IStaderStakePoolManager.sol"; -import "./interfaces/IPermissionlessNodeRegistry.sol"; - -import "@openzeppelin/contracts/utils/math/Math.sol"; -import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; +import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; +import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; + +import { UtilLib } from "./library/UtilLib.sol"; + +import { IStaderConfig } from "./interfaces/IStaderConfig.sol"; +import { IVaultFactory } from "./interfaces/IVaultFactory.sol"; +import { INodeRegistry } from "./interfaces/INodeRegistry.sol"; +import { IStaderPoolBase } from "./interfaces/IStaderPoolBase.sol"; +import { IDepositContract } from "./interfaces/IDepositContract.sol"; +import { IPermissionlessNodeRegistry } from "./interfaces/IPermissionlessNodeRegistry.sol"; contract PermissionlessPool is IStaderPoolBase, AccessControlUpgradeable, ReentrancyGuardUpgradeable { using Math for uint256; diff --git a/contracts/PoolSelector.sol b/contracts/PoolSelector.sol index 7903d803..d2054637 100644 --- a/contracts/PoolSelector.sol +++ b/contracts/PoolSelector.sol @@ -1,15 +1,15 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "./library/UtilLib.sol"; +import { UtilLib } from "./library/UtilLib.sol"; -import "./interfaces/IStaderConfig.sol"; -import "./interfaces/IPoolSelector.sol"; -import "./interfaces/IPoolUtils.sol"; +import { IStaderConfig } from "./interfaces/IStaderConfig.sol"; +import { IPoolSelector } from "./interfaces/IPoolSelector.sol"; +import { IPoolUtils } from "./interfaces/IPoolUtils.sol"; -import "@openzeppelin/contracts/utils/math/Math.sol"; -import "@openzeppelin/contracts/utils/math/SafeMath.sol"; -import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; +import { SafeMath } from "@openzeppelin/contracts/utils/math/SafeMath.sol"; +import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; contract PoolSelector is IPoolSelector, AccessControlUpgradeable { using Math for uint256; diff --git a/contracts/PoolUtils.sol b/contracts/PoolUtils.sol index 61426918..b25c8743 100644 --- a/contracts/PoolUtils.sol +++ b/contracts/PoolUtils.sol @@ -1,13 +1,14 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "./library/UtilLib.sol"; +import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; -import "./interfaces/IPoolUtils.sol"; -import "./interfaces/IStaderPoolBase.sol"; -import "./interfaces/IStaderConfig.sol"; +import { UtilLib } from "./library/UtilLib.sol"; -import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import { IPoolUtils } from "./interfaces/IPoolUtils.sol"; +import { IStaderPoolBase } from "./interfaces/IStaderPoolBase.sol"; +import { INodeRegistry } from "./interfaces/INodeRegistry.sol"; +import { IStaderConfig } from "./interfaces/IStaderConfig.sol"; contract PoolUtils is IPoolUtils, AccessControlUpgradeable { uint64 private constant PUBKEY_LENGTH = 48; diff --git a/contracts/ProxyAdmin.sol b/contracts/ProxyAdmin.sol index 0e7d7cad..4bd11305 100644 --- a/contracts/ProxyAdmin.sol +++ b/contracts/ProxyAdmin.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; -import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; +import { ProxyAdmin } from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; // Need to import ProxyAdmin within contracts folder so `hardhat compile` can find it and compile it // The artifact of ProxyAdmin needs to be built so as to be used within scripts/safe-scripts diff --git a/contracts/SDCollateral.sol b/contracts/SDCollateral.sol index 683ea26c..87868349 100644 --- a/contracts/SDCollateral.sol +++ b/contracts/SDCollateral.sol @@ -1,18 +1,20 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "./library/UtilLib.sol"; - -import "../contracts/interfaces/IPoolUtils.sol"; -import "../contracts/interfaces/SDCollateral/ISDCollateral.sol"; -import "../contracts/interfaces/SDCollateral/IAuction.sol"; -import "../contracts/interfaces/IStaderOracle.sol"; -import "./interfaces/ISDUtilityPool.sol"; - -import "@openzeppelin/contracts/utils/math/Math.sol"; -import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; -import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; +import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; +import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; + +import { UtilLib } from "./library/UtilLib.sol"; + +import { IStaderConfig } from "./interfaces/IStaderConfig.sol"; +import { INodeRegistry } from "./interfaces/INodeRegistry.sol"; +import { IPoolUtils } from "../contracts/interfaces/IPoolUtils.sol"; +import { ISDCollateral } from "../contracts/interfaces/SDCollateral/ISDCollateral.sol"; +import { IAuction } from "../contracts/interfaces/SDCollateral/IAuction.sol"; +import { IStaderOracle } from "../contracts/interfaces/IStaderOracle.sol"; +import { ISDUtilityPool } from "./interfaces/ISDUtilityPool.sol"; contract SDCollateral is ISDCollateral, AccessControlUpgradeable, ReentrancyGuardUpgradeable { IStaderConfig public override staderConfig; diff --git a/contracts/SDIncentiveController.sol b/contracts/SDIncentiveController.sol index 26751a52..cd2f0d2d 100644 --- a/contracts/SDIncentiveController.sol +++ b/contracts/SDIncentiveController.sol @@ -1,13 +1,13 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; -import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import "./library/UtilLib.sol"; -import "./interfaces/IStaderConfig.sol"; -import "./interfaces/ISDUtilityPool.sol"; -import "./interfaces/ISDIncentiveController.sol"; +import { UtilLib } from "./library/UtilLib.sol"; +import { IStaderConfig } from "./interfaces/IStaderConfig.sol"; +import { ISDUtilityPool } from "./interfaces/ISDUtilityPool.sol"; +import { ISDIncentiveController } from "./interfaces/ISDIncentiveController.sol"; /// @title SDIncentiveController /// @notice This contract handles the distribution of reward tokens for the utility pool. diff --git a/contracts/SDUtilityPool.sol b/contracts/SDUtilityPool.sol index c0610a93..a7422bff 100644 --- a/contracts/SDUtilityPool.sol +++ b/contracts/SDUtilityPool.sol @@ -1,18 +1,19 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "./library/UtilLib.sol"; -import "./interfaces/IStaderConfig.sol"; -import "./interfaces/ISDIncentiveController.sol"; -import "./interfaces/ISDUtilityPool.sol"; -import "./interfaces/SDCollateral/ISDCollateral.sol"; -import "./interfaces/IPoolUtils.sol"; -import "./interfaces/IOperatorRewardsCollector.sol"; - -import "@openzeppelin/contracts/utils/math/Math.sol"; -import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; +import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; +import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; + +import { UtilLib } from "./library/UtilLib.sol"; + +import { IStaderConfig } from "./interfaces/IStaderConfig.sol"; +import { ISDIncentiveController } from "./interfaces/ISDIncentiveController.sol"; +import { ISDUtilityPool, OperatorLiquidation, UserData } from "./interfaces/ISDUtilityPool.sol"; +import { ISDCollateral } from "./interfaces/SDCollateral/ISDCollateral.sol"; +import { IPoolUtils } from "./interfaces/IPoolUtils.sol"; +import { IOperatorRewardsCollector } from "./interfaces/IOperatorRewardsCollector.sol"; contract SDUtilityPool is ISDUtilityPool, AccessControlUpgradeable, PausableUpgradeable { using Math for uint256; diff --git a/contracts/SocializingPool.sol b/contracts/SocializingPool.sol index d5152ea7..2c919eb6 100644 --- a/contracts/SocializingPool.sol +++ b/contracts/SocializingPool.sol @@ -1,19 +1,18 @@ // SPDX-License-Identifier: GPL-3.0-or-later - pragma solidity 0.8.16; -import "./library/UtilLib.sol"; +import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; +import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; +import { MerkleProofUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/cryptography/MerkleProofUpgradeable.sol"; +import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import "./interfaces/ISocializingPool.sol"; -import "./interfaces/SDCollateral/ISDCollateral.sol"; -import "./interfaces/IStaderStakePoolManager.sol"; -import "./interfaces/IPermissionlessNodeRegistry.sol"; +import { UtilLib } from "./library/UtilLib.sol"; -import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/utils/cryptography/MerkleProofUpgradeable.sol"; -import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import { IStaderConfig } from "./interfaces/IStaderConfig.sol"; +import { ISocializingPool, RewardsData } from "./interfaces/ISocializingPool.sol"; +import { ISDCollateral } from "./interfaces/SDCollateral/ISDCollateral.sol"; +import { IStaderStakePoolManager } from "./interfaces/IStaderStakePoolManager.sol"; contract SocializingPool is ISocializingPool, diff --git a/contracts/StaderConfig.sol b/contracts/StaderConfig.sol index b4d1b367..24af1f35 100644 --- a/contracts/StaderConfig.sol +++ b/contracts/StaderConfig.sol @@ -1,11 +1,11 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "./library/UtilLib.sol"; +import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; -import "./interfaces/IStaderConfig.sol"; +import { UtilLib } from "./library/UtilLib.sol"; -import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import { IStaderConfig } from "./interfaces/IStaderConfig.sol"; contract StaderConfig is IStaderConfig, AccessControlUpgradeable { // staked ETH per node on beacon chain i.e. 32 ETH diff --git a/contracts/StaderInsuranceFund.sol b/contracts/StaderInsuranceFund.sol index 30e01549..a1fc5bf6 100644 --- a/contracts/StaderInsuranceFund.sol +++ b/contracts/StaderInsuranceFund.sol @@ -1,14 +1,14 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "./library/UtilLib.sol"; +import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; -import "./interfaces/IStaderConfig.sol"; -import "./interfaces/IPermissionedPool.sol"; -import "./interfaces/IStaderInsuranceFund.sol"; +import { UtilLib } from "./library/UtilLib.sol"; -import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; +import { IStaderConfig } from "./interfaces/IStaderConfig.sol"; +import { IPermissionedPool } from "./interfaces/IPermissionedPool.sol"; +import { IStaderInsuranceFund } from "./interfaces/IStaderInsuranceFund.sol"; contract StaderInsuranceFund is IStaderInsuranceFund, AccessControlUpgradeable, ReentrancyGuardUpgradeable { IStaderConfig public staderConfig; diff --git a/contracts/StaderOracle.sol b/contracts/StaderOracle.sol index 41f3306e..bec4b6e2 100644 --- a/contracts/StaderOracle.sol +++ b/contracts/StaderOracle.sol @@ -1,18 +1,21 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "./library/UtilLib.sol"; - -import "./interfaces/IPoolUtils.sol"; -import "./interfaces/IStaderOracle.sol"; -import "./interfaces/ISocializingPool.sol"; -import "./interfaces/INodeRegistry.sol"; -import "./interfaces/IStaderStakePoolManager.sol"; - -import "@chainlink/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol"; -import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; +import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; +import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; + +import { AggregatorV3Interface } from "@chainlink/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol"; + +import { UtilLib } from "./library/UtilLib.sol"; + +import { IStaderConfig } from "./interfaces/IStaderConfig.sol"; +import { IPoolUtils } from "./interfaces/IPoolUtils.sol"; +import { IStaderOracle } from "./interfaces/IStaderOracle.sol"; +import { ISocializingPool } from "./interfaces/ISocializingPool.sol"; +import { INodeRegistry } from "./interfaces/INodeRegistry.sol"; +import { ExchangeRate, MissedAttestationPenaltyData, SDPriceData, ValidatorStats, ValidatorVerificationDetail, WithdrawnValidators } from "./interfaces/IStaderOracle.sol"; +import { RewardsData } from "./interfaces/ISocializingPool.sol"; contract StaderOracle is IStaderOracle, AccessControlUpgradeable, PausableUpgradeable, ReentrancyGuardUpgradeable { bool public override erInspectionMode; diff --git a/contracts/StaderStakePoolsManager.sol b/contracts/StaderStakePoolsManager.sol index 7ef0af52..efb47894 100644 --- a/contracts/StaderStakePoolsManager.sol +++ b/contracts/StaderStakePoolsManager.sol @@ -1,23 +1,22 @@ // SPDX-License-Identifier: GPL-3.0-or-later - pragma solidity 0.8.16; -import "./library/UtilLib.sol"; - -import "./ETHx.sol"; -import "./interfaces/IPoolUtils.sol"; -import "./interfaces/IPoolSelector.sol"; -import "./interfaces/IStaderConfig.sol"; -import "./interfaces/IStaderOracle.sol"; -import "./interfaces/IStaderPoolBase.sol"; -import "./interfaces/IUserWithdrawalManager.sol"; -import "./interfaces/IStaderStakePoolManager.sol"; - -import "@openzeppelin/contracts/utils/math/Math.sol"; -import "@openzeppelin/contracts/utils/math/SafeMath.sol"; -import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; +import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; +import { SafeMath } from "@openzeppelin/contracts/utils/math/SafeMath.sol"; +import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; +import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; + +import { UtilLib } from "./library/UtilLib.sol"; + +import { ETHx } from "./ETHx.sol"; +import { IPoolUtils } from "./interfaces/IPoolUtils.sol"; +import { IPoolSelector } from "./interfaces/IPoolSelector.sol"; +import { IStaderConfig } from "./interfaces/IStaderConfig.sol"; +import { IStaderOracle } from "./interfaces/IStaderOracle.sol"; +import { IStaderPoolBase } from "./interfaces/IStaderPoolBase.sol"; +import { IUserWithdrawalManager } from "./interfaces/IUserWithdrawalManager.sol"; +import { IStaderStakePoolManager } from "./interfaces/IStaderStakePoolManager.sol"; /** * @title Liquid Staking Pool Implementation diff --git a/contracts/UserWithdrawalManager.sol b/contracts/UserWithdrawalManager.sol index adcd83b6..7d4ece72 100644 --- a/contracts/UserWithdrawalManager.sol +++ b/contracts/UserWithdrawalManager.sol @@ -1,19 +1,21 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "./library/UtilLib.sol"; +import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; +import { SafeERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; +import { IERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; -import "./ETHx.sol"; -import "./interfaces/IStaderConfig.sol"; -import "./interfaces/IStaderOracle.sol"; -import "./interfaces/IStaderStakePoolManager.sol"; -import "./interfaces/IUserWithdrawalManager.sol"; +import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; +import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; -import "@openzeppelin/contracts/utils/math/Math.sol"; -import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; +import { UtilLib } from "./library/UtilLib.sol"; + +import { ETHx } from "./ETHx.sol"; +import { IStaderConfig } from "./interfaces/IStaderConfig.sol"; +import { IStaderOracle } from "./interfaces/IStaderOracle.sol"; +import { IStaderStakePoolManager } from "./interfaces/IStaderStakePoolManager.sol"; +import { IUserWithdrawalManager } from "./interfaces/IUserWithdrawalManager.sol"; contract UserWithdrawalManager is IUserWithdrawalManager, @@ -140,7 +142,7 @@ contract UserWithdrawalManager is revert ProtocolNotHealthy(); } address poolManager = staderConfig.getStakePoolManager(); - uint256 DECIMALS = staderConfig.getDecimals(); + uint256 ethxDecimals = staderConfig.getDecimals(); uint256 exchangeRate = IStaderStakePoolManager(poolManager).getExchangeRate(); uint256 maxRequestIdToFinalize = Math.min(nextRequestId, nextRequestIdToFinalize + finalizationBatchLimit) - 1; uint256 lockedEthXToBurn; @@ -151,7 +153,7 @@ contract UserWithdrawalManager is UserWithdrawInfo memory userWithdrawInfo = userWithdrawRequests[requestId]; uint256 requiredEth = userWithdrawInfo.ethExpected; uint256 lockedEthX = userWithdrawInfo.ethXAmount; - uint256 minEThRequiredToFinalizeRequest = Math.min(requiredEth, (lockedEthX * exchangeRate) / DECIMALS); + uint256 minEThRequiredToFinalizeRequest = Math.min(requiredEth, (lockedEthX * exchangeRate) / ethxDecimals); if ( (ethToSendToFinalizeRequest + minEThRequiredToFinalizeRequest > pooledETH) || (userWithdrawInfo.requestBlock + staderConfig.getMinBlockDelayToFinalizeWithdrawRequest() > diff --git a/contracts/ValidatorWithdrawalVault.sol b/contracts/ValidatorWithdrawalVault.sol index 0812cb90..1a97dd8e 100644 --- a/contracts/ValidatorWithdrawalVault.sol +++ b/contracts/ValidatorWithdrawalVault.sol @@ -1,25 +1,26 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "./library/UtilLib.sol"; -import "./library/ValidatorStatus.sol"; +import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; -import "./VaultProxy.sol"; -import "./interfaces/IPenalty.sol"; -import "./interfaces/IPoolUtils.sol"; -import "./interfaces/INodeRegistry.sol"; -import "./interfaces/IStaderStakePoolManager.sol"; -import "./interfaces/IValidatorWithdrawalVault.sol"; -import "./interfaces/SDCollateral/ISDCollateral.sol"; -import "./interfaces/IOperatorRewardsCollector.sol"; +import { UtilLib } from "./library/UtilLib.sol"; -import "@openzeppelin/contracts/utils/math/Math.sol"; +import { IStaderConfig } from "./interfaces/IStaderConfig.sol"; +import { VaultProxy } from "./VaultProxy.sol"; +import { IPenalty } from "./interfaces/IPenalty.sol"; +import { IPoolUtils } from "./interfaces/IPoolUtils.sol"; +import { INodeRegistry } from "./interfaces/INodeRegistry.sol"; +import { IStaderStakePoolManager } from "./interfaces/IStaderStakePoolManager.sol"; +import { ISDCollateral } from "./interfaces/SDCollateral/ISDCollateral.sol"; +import { IOperatorRewardsCollector } from "./interfaces/IOperatorRewardsCollector.sol"; +import { IValidatorWithdrawalVault } from "./interfaces/IValidatorWithdrawalVault.sol"; contract ValidatorWithdrawalVault is IValidatorWithdrawalVault { bool internal vaultSettleStatus; using Math for uint256; /// @custom:oz-upgrades-unsafe-allow constructor + // solhint-disable-next-line no-empty-blocks constructor() {} // Allows the contract to receive ETH @@ -89,9 +90,9 @@ contract ValidatorWithdrawalVault is IValidatorWithdrawalVault { { uint8 poolId = VaultProxy(payable(address(this))).poolId(); IStaderConfig staderConfig = VaultProxy(payable(address(this))).staderConfig(); - uint256 TOTAL_STAKED_ETH = staderConfig.getStakedEthPerNode(); + uint256 totalStakedEth = staderConfig.getStakedEthPerNode(); uint256 collateralETH = getCollateralETH(poolId, staderConfig); // 0, incase of permissioned NOs - uint256 usersETH = TOTAL_STAKED_ETH - collateralETH; + uint256 usersETH = totalStakedEth - collateralETH; uint256 contractBalance = address(this).balance; uint256 totalRewards; @@ -99,12 +100,12 @@ contract ValidatorWithdrawalVault is IValidatorWithdrawalVault { if (contractBalance <= usersETH) { _userShare = contractBalance; return (_userShare, _operatorShare, _protocolShare); - } else if (contractBalance <= TOTAL_STAKED_ETH) { + } else if (contractBalance <= totalStakedEth) { _userShare = usersETH; _operatorShare = contractBalance - _userShare; return (_userShare, _operatorShare, _protocolShare); } else { - totalRewards = contractBalance - TOTAL_STAKED_ETH; + totalRewards = contractBalance - totalStakedEth; _operatorShare = collateralETH; _userShare = usersETH; } diff --git a/contracts/VaultProxy.sol b/contracts/VaultProxy.sol index b32b5ab9..1f2936e6 100644 --- a/contracts/VaultProxy.sol +++ b/contracts/VaultProxy.sol @@ -1,8 +1,9 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "./library/UtilLib.sol"; -import "./interfaces/IVaultProxy.sol"; +import { UtilLib } from "./library/UtilLib.sol"; +import { IStaderConfig } from "./interfaces/IStaderConfig.sol"; +import { IVaultProxy } from "./interfaces/IVaultProxy.sol"; //contract to delegate call to respective vault implementation based on the flag of 'isValidatorWithdrawalVault' contract VaultProxy is IVaultProxy { @@ -40,6 +41,7 @@ contract VaultProxy is IVaultProxy { address vaultImplementation = isValidatorWithdrawalVault ? staderConfig.getValidatorWithdrawalVaultImplementation() : staderConfig.getNodeELRewardVaultImplementation(); + // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory data) = vaultImplementation.delegatecall(_input); if (!success) { revert(string(data)); diff --git a/contracts/factory/VaultFactory.sol b/contracts/factory/VaultFactory.sol index a960760d..948db41d 100644 --- a/contracts/factory/VaultFactory.sol +++ b/contracts/factory/VaultFactory.sol @@ -1,13 +1,13 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "../library/UtilLib.sol"; -import "../VaultProxy.sol"; -import "../interfaces/IVaultFactory.sol"; -import "../interfaces/IStaderConfig.sol"; +import { ClonesUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/ClonesUpgradeable.sol"; +import { AccessControlUpgradeable } from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/proxy/ClonesUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; +import { UtilLib } from "../library/UtilLib.sol"; +import { VaultProxy } from "../VaultProxy.sol"; +import { IVaultFactory } from "../interfaces/IVaultFactory.sol"; +import { IStaderConfig } from "../interfaces/IStaderConfig.sol"; contract VaultFactory is IVaultFactory, AccessControlUpgradeable { IStaderConfig public staderConfig; diff --git a/contracts/interfaces/INodeELRewardVault.sol b/contracts/interfaces/INodeELRewardVault.sol index d466591d..2d5afb8e 100644 --- a/contracts/interfaces/INodeELRewardVault.sol +++ b/contracts/interfaces/INodeELRewardVault.sol @@ -1,8 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "./IStaderConfig.sol"; - interface INodeELRewardVault { // errors error NotEnoughRewardToWithdraw(); diff --git a/contracts/interfaces/INodeRegistry.sol b/contracts/interfaces/INodeRegistry.sol index 06abd451..639240ff 100644 --- a/contracts/interfaces/INodeRegistry.sol +++ b/contracts/interfaces/INodeRegistry.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "../library/ValidatorStatus.sol"; +import { ValidatorStatus } from "../library/ValidatorStatus.sol"; struct Validator { ValidatorStatus status; // status of validator diff --git a/contracts/interfaces/IPermissionedNodeRegistry.sol b/contracts/interfaces/IPermissionedNodeRegistry.sol index 48ba9195..f0f76ee9 100644 --- a/contracts/interfaces/IPermissionedNodeRegistry.sol +++ b/contracts/interfaces/IPermissionedNodeRegistry.sol @@ -1,9 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "../library/ValidatorStatus.sol"; -import "./INodeRegistry.sol"; - interface IPermissionedNodeRegistry { // Errors error NotAPermissionedNodeOperator(); diff --git a/contracts/interfaces/IPermissionlessNodeRegistry.sol b/contracts/interfaces/IPermissionlessNodeRegistry.sol index 48289cbb..89b9e3ea 100644 --- a/contracts/interfaces/IPermissionlessNodeRegistry.sol +++ b/contracts/interfaces/IPermissionlessNodeRegistry.sol @@ -1,9 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "../library/ValidatorStatus.sol"; -import "./INodeRegistry.sol"; - interface IPermissionlessNodeRegistry { // Errors error TransferFailed(); diff --git a/contracts/interfaces/IPoolUtils.sol b/contracts/interfaces/IPoolUtils.sol index 4083d06b..35d73bd1 100644 --- a/contracts/interfaces/IPoolUtils.sol +++ b/contracts/interfaces/IPoolUtils.sol @@ -1,8 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "./INodeRegistry.sol"; - // Interface for the PoolUtils contract interface IPoolUtils { // Errors diff --git a/contracts/interfaces/ISDIncentiveController.sol b/contracts/interfaces/ISDIncentiveController.sol index b2b82118..55ec631e 100644 --- a/contracts/interfaces/ISDIncentiveController.sol +++ b/contracts/interfaces/ISDIncentiveController.sol @@ -1,8 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "./IStaderConfig.sol"; - interface ISDIncentiveController { //errors error NoRewardsToClaim(); diff --git a/contracts/interfaces/ISocializingPool.sol b/contracts/interfaces/ISocializingPool.sol index 502e8156..b42b626b 100644 --- a/contracts/interfaces/ISocializingPool.sol +++ b/contracts/interfaces/ISocializingPool.sol @@ -2,7 +2,7 @@ pragma solidity 0.8.16; -import "./IStaderConfig.sol"; +import { IStaderConfig } from "./IStaderConfig.sol"; /// @title RewardsData /// @notice This struct holds rewards merkleRoot and rewards split diff --git a/contracts/interfaces/IStaderOracle.sol b/contracts/interfaces/IStaderOracle.sol index deef3768..7bfd2a45 100644 --- a/contracts/interfaces/IStaderOracle.sol +++ b/contracts/interfaces/IStaderOracle.sol @@ -1,10 +1,8 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "../library/ValidatorStatus.sol"; - -import "./ISocializingPool.sol"; -import "./IStaderConfig.sol"; +import { IStaderConfig } from "./IStaderConfig.sol"; +import { RewardsData } from "./ISocializingPool.sol"; struct SDPriceData { uint256 reportingBlockNumber; diff --git a/contracts/interfaces/IStaderPoolBase.sol b/contracts/interfaces/IStaderPoolBase.sol index e9bc5ea2..cdcfa756 100644 --- a/contracts/interfaces/IStaderPoolBase.sol +++ b/contracts/interfaces/IStaderPoolBase.sol @@ -1,8 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "./INodeRegistry.sol"; - interface IStaderPoolBase { // Errors error UnsupportedOperation(); diff --git a/contracts/interfaces/IValidatorWithdrawalVault.sol b/contracts/interfaces/IValidatorWithdrawalVault.sol index 6d0d74b9..ad1b2ac7 100644 --- a/contracts/interfaces/IValidatorWithdrawalVault.sol +++ b/contracts/interfaces/IValidatorWithdrawalVault.sol @@ -1,8 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "./IStaderConfig.sol"; - interface IValidatorWithdrawalVault { // Errors error InvalidRewardAmount(); diff --git a/contracts/interfaces/IVaultProxy.sol b/contracts/interfaces/IVaultProxy.sol index 37a12ec8..d82f82c0 100644 --- a/contracts/interfaces/IVaultProxy.sol +++ b/contracts/interfaces/IVaultProxy.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "./IStaderConfig.sol"; +import { IStaderConfig } from "./IStaderConfig.sol"; interface IVaultProxy { error CallerNotOwner(); diff --git a/contracts/interfaces/IWETH.sol b/contracts/interfaces/IWETH.sol index bc4eefbc..9edaf0e3 100644 --- a/contracts/interfaces/IWETH.sol +++ b/contracts/interfaces/IWETH.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IWETH is IERC20 { function deposit() external payable; diff --git a/contracts/interfaces/SDCollateral/IAuction.sol b/contracts/interfaces/SDCollateral/IAuction.sol index e6b63cb9..53b7aa0a 100644 --- a/contracts/interfaces/SDCollateral/IAuction.sol +++ b/contracts/interfaces/SDCollateral/IAuction.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "../IStaderConfig.sol"; +import { IStaderConfig } from "../IStaderConfig.sol"; interface IAuction { // errors diff --git a/contracts/interfaces/SDCollateral/ISDCollateral.sol b/contracts/interfaces/SDCollateral/ISDCollateral.sol index f45ef289..927be75d 100644 --- a/contracts/interfaces/SDCollateral/ISDCollateral.sol +++ b/contracts/interfaces/SDCollateral/ISDCollateral.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "../IStaderConfig.sol"; +import { IStaderConfig } from "../IStaderConfig.sol"; interface ISDCollateral { struct PoolThresholdInfo { diff --git a/contracts/library/UtilLib.sol b/contracts/library/UtilLib.sol index c0695ebe..c75fe06c 100644 --- a/contracts/library/UtilLib.sol +++ b/contracts/library/UtilLib.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity 0.8.16; -import "../interfaces/IStaderConfig.sol"; -import "../interfaces/INodeRegistry.sol"; -import "../interfaces/IPoolUtils.sol"; -import "../interfaces/IVaultProxy.sol"; +import { IStaderConfig } from "../interfaces/IStaderConfig.sol"; +import { INodeRegistry } from "../interfaces/INodeRegistry.sol"; +import { IPoolUtils } from "../interfaces/IPoolUtils.sol"; +import { IVaultProxy } from "../interfaces/IVaultProxy.sol"; library UtilLib { error ZeroAddress(); diff --git a/package-lock.json b/package-lock.json index aa169a46..918c2448 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,7 +35,7 @@ "inquirer": "8.2.6", "prettier": "3.2.5", "prettier-plugin-solidity": "1.3.1", - "solhint": "^4.5.2", + "solhint": "5.0.1", "typechain": "^8.3.2" } }, @@ -12210,7 +12210,9 @@ } }, "node_modules/solhint": { - "version": "4.5.4", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/solhint/-/solhint-5.0.1.tgz", + "integrity": "sha512-QeQLS9HGCnIiibt+xiOa/+MuP7BWz9N7C5+Mj9pLHshdkNhuo3AzCpWmjfWVZBUuwIUO3YyCRVIcYLR3YOKGfg==", "dev": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index be238b0c..fe9781d0 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "test": "forge test -v", "prettier:check": "prettier --check \"(contracts|test|script)/**/*.sol\"", "prettier:fix": "prettier --write \"(contracts|test|script)/**/*.sol\"", - "lint": "solhint 'contracts/**/*.sol' 'test/**/*.sol' 'script/**/*.sol'", + "lint": "solhint 'contracts/**/*.sol' 'script/**/*.sol'", "upgrade:arbitrum": "npx hardhat run scripts/safe-scripts/upgrade.ts --network arbitrum", "upgrade:playground:arbitrum": "npx hardhat run scripts/safe-scripts/upgradePlayground.ts --network arbitrum" }, @@ -37,7 +37,7 @@ "inquirer": "8.2.6", "prettier": "3.2.5", "prettier-plugin-solidity": "1.3.1", - "solhint": "^4.5.2", + "solhint": "5.0.1", "typechain": "^8.3.2" }, "dependencies": { diff --git a/test/foundry_tests/PermissionedNodeRegistry.t.sol b/test/foundry_tests/PermissionedNodeRegistry.t.sol index 8f086d19..c564c174 100644 --- a/test/foundry_tests/PermissionedNodeRegistry.t.sol +++ b/test/foundry_tests/PermissionedNodeRegistry.t.sol @@ -19,7 +19,7 @@ import "../mocks/OperatorRewardsCollectorMock.sol"; import "../mocks/PoolUtilsMockForDepositFlow.sol"; import "forge-std/Test.sol"; -import "@openzeppelin/contracts/utils/math/Math.sol"; +import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; diff --git a/test/foundry_tests/PermissionlessNodeRegistry.t.sol b/test/foundry_tests/PermissionlessNodeRegistry.t.sol index 526eb353..cb0aa869 100644 --- a/test/foundry_tests/PermissionlessNodeRegistry.t.sol +++ b/test/foundry_tests/PermissionlessNodeRegistry.t.sol @@ -19,7 +19,7 @@ import "../mocks/OperatorRewardsCollectorMock.sol"; import "../mocks/PoolUtilsMockForDepositFlow.sol"; import "forge-std/Test.sol"; -import "@openzeppelin/contracts/utils/math/Math.sol"; +import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; diff --git a/test/foundry_tests/SDUtilityPool.t.sol b/test/foundry_tests/SDUtilityPool.t.sol index 7882be99..29237ea3 100644 --- a/test/foundry_tests/SDUtilityPool.t.sol +++ b/test/foundry_tests/SDUtilityPool.t.sol @@ -14,7 +14,7 @@ import "../mocks/OperatorRewardsCollectorMock.sol"; import "../mocks/PoolUtilsMock.sol"; import "forge-std/Test.sol"; -import "@openzeppelin/contracts/utils/math/Math.sol"; +import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; diff --git a/test/foundry_tests/StaderStakePoolManager.t.sol b/test/foundry_tests/StaderStakePoolManager.t.sol index bc605485..21b4ef78 100644 --- a/test/foundry_tests/StaderStakePoolManager.t.sol +++ b/test/foundry_tests/StaderStakePoolManager.t.sol @@ -10,7 +10,7 @@ import "../mocks/PoolUtilsMock.sol"; import "../mocks/StaderOracleMock.sol"; import "forge-std/Test.sol"; -import "@openzeppelin/contracts/utils/math/Math.sol"; +import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";