From a38a60f620c827fec327ee53cbab01a51ebc2985 Mon Sep 17 00:00:00 2001 From: Dima Lekhovitsky Date: Tue, 20 Aug 2024 15:05:50 +0300 Subject: [PATCH 1/3] feat: reorganize interfaces, introduce `contractType` getter --- contracts/core/AccountFactoryV3.sol | 3 +++ contracts/core/BotListV3.sol | 3 +++ contracts/core/GearStakingV3.sol | 3 +++ contracts/core/PriceOracleV3.sol | 3 +++ contracts/credit/CreditAccountV3.sol | 5 ++++- contracts/credit/CreditConfiguratorV3.sol | 3 +++ contracts/credit/CreditFacadeV3.sol | 5 ++++- contracts/credit/CreditManagerV3.sol | 5 +++++ contracts/credit/CreditManagerV3_USDT.sol | 3 +++ .../interfaces/ICreditConfiguratorV3.sol | 3 ++- contracts/interfaces/ICreditFacadeV3.sol | 3 ++- contracts/interfaces/IGaugeV3.sol | 3 ++- contracts/interfaces/IPoolQuotaKeeperV3.sol | 4 +++- contracts/interfaces/IPoolV3.sol | 4 +++- contracts/interfaces/IPriceOracleV3.sol | 3 ++- contracts/interfaces/ITumblerV3.sol | 3 ++- contracts/interfaces/{ => base}/IACL.sol | 1 - contracts/interfaces/base/IACLTrait.sol | 8 +++++++ contracts/interfaces/base/IAdapter.sol | 11 ++-------- .../{ => base}/IContractsRegister.sol | 0 .../base/IContractsRegisterTrait.sol | 8 +++++++ .../interfaces/base/IControlledTrait.sol | 14 +++++++++++++ contracts/interfaces/{ => base}/IDegenNFT.sol | 0 contracts/interfaces/base/IPriceFeed.sol | 4 ---- contracts/interfaces/base/IVersion.sol | 5 ++++- contracts/pool/GaugeV3.sol | 3 +++ contracts/pool/LinearInterestRateModelV3.sol | 3 +++ contracts/pool/PoolQuotaKeeperV3.sol | 3 +++ contracts/pool/PoolV3.sol | 5 +++++ contracts/pool/PoolV3_USDT.sol | 3 +++ contracts/pool/TumblerV3.sol | 3 +++ .../test/helpers/IntegrationTestHelper.sol | 7 ++++--- .../credit/OpenCreditAccount.int.t.sol | 2 +- .../test/mocks/core/AccountFactoryMock.sol | 2 ++ contracts/test/mocks/core/AdapterMock.sol | 5 ++--- .../test/mocks/credit/CreditAccountMock.sol | 4 +++- .../test/mocks/governance/GearStakingMock.sol | 2 ++ .../test/mocks/oracles/PriceFeedMock.sol | 8 ++----- .../test/mocks/pool/PoolQuotaKeeperMock.sol | 21 ++++++++++--------- contracts/test/mocks/token/DegenNFTMock.sol | 2 +- contracts/traits/ACLTrait.sol | 7 ++++--- contracts/traits/ContractsRegisterTrait.sol | 7 ++++--- contracts/traits/ControlledTrait.sol | 10 ++++----- 43 files changed, 143 insertions(+), 61 deletions(-) rename contracts/interfaces/{ => base}/IACL.sol (87%) create mode 100644 contracts/interfaces/base/IACLTrait.sol rename contracts/interfaces/{ => base}/IContractsRegister.sol (100%) create mode 100644 contracts/interfaces/base/IContractsRegisterTrait.sol create mode 100644 contracts/interfaces/base/IControlledTrait.sol rename contracts/interfaces/{ => base}/IDegenNFT.sol (100%) diff --git a/contracts/core/AccountFactoryV3.sol b/contracts/core/AccountFactoryV3.sol index 45b24e33..037d0a53 100644 --- a/contracts/core/AccountFactoryV3.sol +++ b/contracts/core/AccountFactoryV3.sol @@ -44,6 +44,9 @@ contract AccountFactoryV3 is IAccountFactoryV3, Ownable { /// @notice Contract version uint256 public constant override version = 3_10; + /// @notice Contract type + bytes32 public constant override contractType = "AF"; + /// @notice Delay after which returned credit accounts can be reused uint40 public constant override delay = 3 days; diff --git a/contracts/core/BotListV3.sol b/contracts/core/BotListV3.sol index 9adb7870..b93900fb 100644 --- a/contracts/core/BotListV3.sol +++ b/contracts/core/BotListV3.sol @@ -27,6 +27,9 @@ contract BotListV3 is IBotListV3, SanityCheckTrait, Ownable { /// @notice Contract version uint256 public constant override version = 3_10; + /// @notice Contract type + bytes32 public constant override contractType = "BL"; + /// @notice Credit manager's approved status mapping(address => bool) public override approvedCreditManager; diff --git a/contracts/core/GearStakingV3.sol b/contracts/core/GearStakingV3.sol index f51256b2..0342a59b 100644 --- a/contracts/core/GearStakingV3.sol +++ b/contracts/core/GearStakingV3.sol @@ -32,6 +32,9 @@ contract GearStakingV3 is IGearStakingV3, Ownable, ReentrancyGuardTrait, SanityC /// @notice Contract version uint256 public constant override version = 3_10; + /// @notice Contract type + bytes32 public constant override contractType = "GS"; + /// @notice Address of the GEAR token address public immutable override gear; diff --git a/contracts/core/PriceOracleV3.sol b/contracts/core/PriceOracleV3.sol index 409af580..7e8a6d77 100644 --- a/contracts/core/PriceOracleV3.sol +++ b/contracts/core/PriceOracleV3.sol @@ -40,6 +40,9 @@ contract PriceOracleV3 is ControlledTrait, PriceFeedValidationTrait, SanityCheck /// @notice Contract version uint256 public constant override version = 3_10; + /// @notice Contract type + bytes32 public constant override contractType = "PO"; + /// @dev Mapping from token address to price feed params mapping(address => PriceFeedParams) internal _priceFeedsParams; diff --git a/contracts/credit/CreditAccountV3.sol b/contracts/credit/CreditAccountV3.sol index 5f337e49..6eafdf94 100644 --- a/contracts/credit/CreditAccountV3.sol +++ b/contracts/credit/CreditAccountV3.sol @@ -17,7 +17,10 @@ contract CreditAccountV3 is ICreditAccountV3 { using Address for address; /// @notice Contract version - uint256 public constant override version = 3_00; + uint256 public constant override version = 3_10; + + /// @notice Contract type + bytes32 public constant override contractType = "CA"; /// @notice Account factory this account was deployed with address public immutable override factory; diff --git a/contracts/credit/CreditConfiguratorV3.sol b/contracts/credit/CreditConfiguratorV3.sol index aa900a44..40771641 100644 --- a/contracts/credit/CreditConfiguratorV3.sol +++ b/contracts/credit/CreditConfiguratorV3.sol @@ -41,6 +41,9 @@ contract CreditConfiguratorV3 is ICreditConfiguratorV3, ControlledTrait, SanityC /// @notice Contract version uint256 public constant override version = 3_10; + /// @notice Contract type + bytes32 public constant override contractType = "CC"; + /// @notice Credit manager address address public immutable override creditManager; diff --git a/contracts/credit/CreditFacadeV3.sol b/contracts/credit/CreditFacadeV3.sol index 1e44af81..616812fd 100644 --- a/contracts/credit/CreditFacadeV3.sol +++ b/contracts/credit/CreditFacadeV3.sol @@ -29,7 +29,7 @@ import { ICreditManagerV3, ManageDebtAction } from "../interfaces/ICreditManagerV3.sol"; -import {IDegenNFT} from "../interfaces/IDegenNFT.sol"; +import {IDegenNFT} from "../interfaces/base/IDegenNFT.sol"; import "../interfaces/IExceptions.sol"; import {IPoolV3} from "../interfaces/IPoolV3.sol"; import {IPriceOracleV3, PriceUpdate} from "../interfaces/IPriceOracleV3.sol"; @@ -74,6 +74,9 @@ contract CreditFacadeV3 is ICreditFacadeV3, Pausable, ACLTrait, ReentrancyGuardT /// @notice Contract version uint256 public constant override version = 3_10; + /// @notice Contract type + bytes32 public constant override contractType = "CF"; + /// @notice Maximum quota size, as a multiple of `maxDebt` uint256 public constant override maxQuotaMultiplier = 2; diff --git a/contracts/credit/CreditManagerV3.sol b/contracts/credit/CreditManagerV3.sol index 376e0b0d..5090c631 100644 --- a/contracts/credit/CreditManagerV3.sol +++ b/contracts/credit/CreditManagerV3.sol @@ -182,6 +182,11 @@ contract CreditManagerV3 is ICreditManagerV3, SanityCheckTrait, ReentrancyGuardT creditConfigurator = msg.sender; // U:[CM-1] } + /// @notice Contract type + function contractType() external view virtual override returns (bytes32) { + return "CM"; + } + // ------------------ // // ACCOUNT MANAGEMENT // // ------------------ // diff --git a/contracts/credit/CreditManagerV3_USDT.sol b/contracts/credit/CreditManagerV3_USDT.sol index f2c27376..231fc938 100644 --- a/contracts/credit/CreditManagerV3_USDT.sol +++ b/contracts/credit/CreditManagerV3_USDT.sol @@ -10,6 +10,9 @@ import {IPoolV3} from "../interfaces/IPoolV3.sol"; /// @title Credit manager V3 USDT /// @notice Credit manager variation for USDT underlying with enabled transfer fees contract CreditManagerV3_USDT is CreditManagerV3, USDT_Transfer { + /// @notice Contract type + bytes32 public constant override contractType = "CM_USDT"; + constructor( address _pool, address _accountFactory, diff --git a/contracts/interfaces/ICreditConfiguratorV3.sol b/contracts/interfaces/ICreditConfiguratorV3.sol index a4b75190..45c5e9d1 100644 --- a/contracts/interfaces/ICreditConfiguratorV3.sol +++ b/contracts/interfaces/ICreditConfiguratorV3.sol @@ -4,6 +4,7 @@ pragma solidity ^0.8.17; import {IVersion} from "./base/IVersion.sol"; +import {IControlledTrait} from "./base/IControlledTrait.sol"; enum AllowanceAction { FORBID, @@ -95,7 +96,7 @@ interface ICreditConfiguratorV3Events { } /// @title Credit configurator V3 interface -interface ICreditConfiguratorV3 is IVersion, ICreditConfiguratorV3Events { +interface ICreditConfiguratorV3 is IVersion, IControlledTrait, ICreditConfiguratorV3Events { function creditManager() external view returns (address); function creditFacade() external view returns (address); diff --git a/contracts/interfaces/ICreditFacadeV3.sol b/contracts/interfaces/ICreditFacadeV3.sol index 02664a3d..43a93dbd 100644 --- a/contracts/interfaces/ICreditFacadeV3.sol +++ b/contracts/interfaces/ICreditFacadeV3.sol @@ -6,6 +6,7 @@ pragma solidity ^0.8.17; import {AllowanceAction} from "./ICreditConfiguratorV3.sol"; import "./ICreditFacadeV3Multicall.sol"; import {PriceUpdate} from "./IPriceOracleV3.sol"; +import {IACLTrait} from "./base/IACLTrait.sol"; import {IVersion} from "./base/IVersion.sol"; /// @notice Multicall element @@ -82,7 +83,7 @@ interface ICreditFacadeV3Events { } /// @title Credit facade V3 interface -interface ICreditFacadeV3 is IVersion, ICreditFacadeV3Events { +interface ICreditFacadeV3 is IVersion, IACLTrait, ICreditFacadeV3Events { function creditManager() external view returns (address); function underlying() external view returns (address); diff --git a/contracts/interfaces/IGaugeV3.sol b/contracts/interfaces/IGaugeV3.sol index 6398d116..972c6cde 100644 --- a/contracts/interfaces/IGaugeV3.sol +++ b/contracts/interfaces/IGaugeV3.sol @@ -3,6 +3,7 @@ // (c) Gearbox Foundation, 2024. pragma solidity ^0.8.17; +import {IControlledTrait} from "./base/IControlledTrait.sol"; import {IRateKeeper} from "./base/IRateKeeper.sol"; import {IVotingContract} from "./base/IVotingContract.sol"; @@ -39,7 +40,7 @@ interface IGaugeV3Events { } /// @title Gauge V3 interface -interface IGaugeV3 is IVotingContract, IRateKeeper, IGaugeV3Events { +interface IGaugeV3 is IVotingContract, IRateKeeper, IControlledTrait, IGaugeV3Events { function voter() external view returns (address); function updateEpoch() external; diff --git a/contracts/interfaces/IPoolQuotaKeeperV3.sol b/contracts/interfaces/IPoolQuotaKeeperV3.sol index 4d180604..8a6f7cf9 100644 --- a/contracts/interfaces/IPoolQuotaKeeperV3.sol +++ b/contracts/interfaces/IPoolQuotaKeeperV3.sol @@ -3,6 +3,8 @@ // (c) Gearbox Foundation, 2024. pragma solidity ^0.8.17; +import {IControlledTrait} from "./base/IControlledTrait.sol"; +import {IContractsRegisterTrait} from "./base/IContractsRegisterTrait.sol"; import {IVersion} from "./base/IVersion.sol"; struct TokenQuotaParams { @@ -42,7 +44,7 @@ interface IPoolQuotaKeeperV3Events { } /// @title Pool quota keeper V3 interface -interface IPoolQuotaKeeperV3 is IPoolQuotaKeeperV3Events, IVersion { +interface IPoolQuotaKeeperV3 is IPoolQuotaKeeperV3Events, IVersion, IControlledTrait, IContractsRegisterTrait { function pool() external view returns (address); function underlying() external view returns (address); diff --git a/contracts/interfaces/IPoolV3.sol b/contracts/interfaces/IPoolV3.sol index d055b272..3f523c7d 100644 --- a/contracts/interfaces/IPoolV3.sol +++ b/contracts/interfaces/IPoolV3.sol @@ -7,6 +7,8 @@ pragma abicoder v1; import {IERC4626} from "@openzeppelin/contracts/interfaces/IERC4626.sol"; import {IERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol"; import {IVersion} from "./base/IVersion.sol"; +import {IControlledTrait} from "./base/IControlledTrait.sol"; +import {IContractsRegisterTrait} from "./base/IContractsRegisterTrait.sol"; interface IPoolV3Events { /// @notice Emitted when depositing liquidity with referral code @@ -41,7 +43,7 @@ interface IPoolV3Events { } /// @title Pool V3 interface -interface IPoolV3 is IVersion, IPoolV3Events, IERC4626, IERC20Permit { +interface IPoolV3 is IVersion, IControlledTrait, IContractsRegisterTrait, IPoolV3Events, IERC4626, IERC20Permit { function underlyingToken() external view returns (address); function treasury() external view returns (address); diff --git a/contracts/interfaces/IPriceOracleV3.sol b/contracts/interfaces/IPriceOracleV3.sol index 5f586590..e6b89985 100644 --- a/contracts/interfaces/IPriceOracleV3.sol +++ b/contracts/interfaces/IPriceOracleV3.sol @@ -4,6 +4,7 @@ pragma solidity ^0.8.17; import {IVersion} from "./base/IVersion.sol"; +import {IControlledTrait} from "./base/IControlledTrait.sol"; /// @notice Price feed params /// @param priceFeed Price feed address @@ -37,7 +38,7 @@ interface IPriceOracleV3Events { } /// @title Price oracle V3 interface -interface IPriceOracleV3 is IVersion, IPriceOracleV3Events { +interface IPriceOracleV3 is IVersion, IControlledTrait, IPriceOracleV3Events { function getTokens() external view returns (address[] memory); function priceFeeds(address token) external view returns (address priceFeed); diff --git a/contracts/interfaces/ITumblerV3.sol b/contracts/interfaces/ITumblerV3.sol index 7060bb36..809b106f 100644 --- a/contracts/interfaces/ITumblerV3.sol +++ b/contracts/interfaces/ITumblerV3.sol @@ -4,6 +4,7 @@ pragma solidity ^0.8.17; import {IRateKeeper} from "./base/IRateKeeper.sol"; +import {IControlledTrait} from "./base/IControlledTrait.sol"; interface ITumblerV3Events { /// @notice Emitted when new token is added @@ -14,7 +15,7 @@ interface ITumblerV3Events { } /// @title Tumbler V3 interface -interface ITumblerV3 is IRateKeeper, ITumblerV3Events { +interface ITumblerV3 is IRateKeeper, IControlledTrait, ITumblerV3Events { function underlying() external view returns (address); function poolQuotaKeeper() external view returns (address); diff --git a/contracts/interfaces/IACL.sol b/contracts/interfaces/base/IACL.sol similarity index 87% rename from contracts/interfaces/IACL.sol rename to contracts/interfaces/base/IACL.sol index 2c1b142c..d1b3ee25 100644 --- a/contracts/interfaces/IACL.sol +++ b/contracts/interfaces/base/IACL.sol @@ -4,7 +4,6 @@ pragma solidity ^0.8.17; interface IACL { - function owner() external view returns (address); function isConfigurator(address account) external view returns (bool); function isPausableAdmin(address addr) external view returns (bool); function isUnpausableAdmin(address addr) external view returns (bool); diff --git a/contracts/interfaces/base/IACLTrait.sol b/contracts/interfaces/base/IACLTrait.sol new file mode 100644 index 00000000..b57f1d42 --- /dev/null +++ b/contracts/interfaces/base/IACLTrait.sol @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: MIT +// Gearbox Protocol. Generalized leverage for DeFi protocols +// (c) Gearbox Foundation, 2024. +pragma solidity ^0.8.17; + +interface IACLTrait { + function acl() external view returns (address); +} diff --git a/contracts/interfaces/base/IAdapter.sol b/contracts/interfaces/base/IAdapter.sol index 055a5b1c..725ac63d 100644 --- a/contracts/interfaces/base/IAdapter.sol +++ b/contracts/interfaces/base/IAdapter.sol @@ -3,19 +3,12 @@ // (c) Gearbox Foundation, 2024. pragma solidity ^0.8.17; -import {AdapterType} from "@gearbox-protocol/sdk-gov/contracts/AdapterType.sol"; +import {IVersion} from "./IVersion.sol"; /// @title Adapter interface /// @notice Generic interface for an adapter that can be used to interact with external protocols. /// Adapters can be assumed to be non-malicious since they are developed by Gearbox DAO. -interface IAdapter { - /// @notice Adapter type - function _gearboxAdapterType() external view returns (AdapterType); - - /// @notice Adapter version - /// @dev Doesn't follow `IVersion` for historic reasons - function _gearboxAdapterVersion() external view returns (uint16); - +interface IAdapter is IVersion { /// @notice Credit manager this adapter is connected to /// @dev Assumed to be an immutable state variable function creditManager() external view returns (address); diff --git a/contracts/interfaces/IContractsRegister.sol b/contracts/interfaces/base/IContractsRegister.sol similarity index 100% rename from contracts/interfaces/IContractsRegister.sol rename to contracts/interfaces/base/IContractsRegister.sol diff --git a/contracts/interfaces/base/IContractsRegisterTrait.sol b/contracts/interfaces/base/IContractsRegisterTrait.sol new file mode 100644 index 00000000..488fdc6e --- /dev/null +++ b/contracts/interfaces/base/IContractsRegisterTrait.sol @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: MIT +// Gearbox Protocol. Generalized leverage for DeFi protocols +// (c) Gearbox Foundation, 2024. +pragma solidity ^0.8.17; + +interface IContractsRegisterTrait { + function contractsRegister() external view returns (address); +} diff --git a/contracts/interfaces/base/IControlledTrait.sol b/contracts/interfaces/base/IControlledTrait.sol new file mode 100644 index 00000000..c8235105 --- /dev/null +++ b/contracts/interfaces/base/IControlledTrait.sol @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: MIT +// Gearbox Protocol. Generalized leverage for DeFi protocols +// (c) Gearbox Foundation, 2024. +pragma solidity ^0.8.17; + +import {IACLTrait} from "./IACLTrait.sol"; + +interface IControlledTrait is IACLTrait { + /// @notice Emitted when new external controller is set + event NewController(address indexed newController); + + function controller() external view returns (address); + function setController(address) external; +} diff --git a/contracts/interfaces/IDegenNFT.sol b/contracts/interfaces/base/IDegenNFT.sol similarity index 100% rename from contracts/interfaces/IDegenNFT.sol rename to contracts/interfaces/base/IDegenNFT.sol diff --git a/contracts/interfaces/base/IPriceFeed.sol b/contracts/interfaces/base/IPriceFeed.sol index c7d51248..529da972 100644 --- a/contracts/interfaces/base/IPriceFeed.sol +++ b/contracts/interfaces/base/IPriceFeed.sol @@ -3,15 +3,11 @@ // (c) Gearbox Foundation, 2024. pragma solidity ^0.8.17; -import {PriceFeedType} from "@gearbox-protocol/sdk-gov/contracts/PriceFeedType.sol"; import {IVersion} from "./IVersion.sol"; /// @title Price feed interface /// @notice Interface for Chainlink-like price feeds that can be plugged into Gearbox's price oracle interface IPriceFeed is IVersion { - /// @notice Price feed type - function priceFeedType() external view returns (PriceFeedType); - /// @notice Whether price feed implements its own staleness and sanity checks function skipPriceCheck() external view returns (bool); diff --git a/contracts/interfaces/base/IVersion.sol b/contracts/interfaces/base/IVersion.sol index 2ceac95c..2b40bb64 100644 --- a/contracts/interfaces/base/IVersion.sol +++ b/contracts/interfaces/base/IVersion.sol @@ -4,8 +4,11 @@ pragma solidity ^0.8.17; /// @title Version interface -/// @notice Defines contract version +/// @notice Defines contract version and type interface IVersion { /// @notice Contract version function version() external view returns (uint256); + + /// @notice Contract type + function contractType() external view returns (bytes32); } diff --git a/contracts/pool/GaugeV3.sol b/contracts/pool/GaugeV3.sol index e0352856..fbbf13b3 100644 --- a/contracts/pool/GaugeV3.sol +++ b/contracts/pool/GaugeV3.sol @@ -34,6 +34,9 @@ contract GaugeV3 is IGaugeV3, ControlledTrait, SanityCheckTrait { /// @notice Contract version uint256 public constant override version = 3_10; + /// @notice Contract type + bytes32 public constant override contractType = "RK_GAUGE"; + /// @notice Address of the pool this gauge is connected to address public immutable override pool; diff --git a/contracts/pool/LinearInterestRateModelV3.sol b/contracts/pool/LinearInterestRateModelV3.sol index 63134d08..d163b6d6 100644 --- a/contracts/pool/LinearInterestRateModelV3.sol +++ b/contracts/pool/LinearInterestRateModelV3.sol @@ -20,6 +20,9 @@ contract LinearInterestRateModelV3 is ILinearInterestRateModelV3 { /// @notice Contract version uint256 public constant override version = 3_10; + /// @notice Contract type + bytes32 public constant override contractType = "IRM_LINEAR"; + /// @notice Whether to prevent borrowing over `U_2` utilization bool public immutable override isBorrowingMoreU2Forbidden; diff --git a/contracts/pool/PoolQuotaKeeperV3.sol b/contracts/pool/PoolQuotaKeeperV3.sol index 940d7fe6..9915e3d0 100644 --- a/contracts/pool/PoolQuotaKeeperV3.sol +++ b/contracts/pool/PoolQuotaKeeperV3.sol @@ -37,6 +37,9 @@ contract PoolQuotaKeeperV3 is IPoolQuotaKeeperV3, ControlledTrait, ContractsRegi /// @notice Contract version uint256 public constant override version = 3_10; + /// @notice Contract type + bytes32 public constant override contractType = "QK"; + /// @notice Address of the underlying token address public immutable override underlying; diff --git a/contracts/pool/PoolV3.sol b/contracts/pool/PoolV3.sol index 37c0b276..436362f5 100644 --- a/contracts/pool/PoolV3.sol +++ b/contracts/pool/PoolV3.sol @@ -153,6 +153,11 @@ contract PoolV3 is _setTotalDebtLimit(totalDebtLimit_); // U:[LP-1B] } + /// @notice Contract type + function contractType() external view virtual override returns (bytes32) { + return "LP"; + } + /// @notice Pool shares decimals, matches underlying token decimals function decimals() public view override(ERC20, ERC4626, IERC20Metadata) returns (uint8) { return ERC4626.decimals(); diff --git a/contracts/pool/PoolV3_USDT.sol b/contracts/pool/PoolV3_USDT.sol index 9ba25b3c..a1c86a32 100644 --- a/contracts/pool/PoolV3_USDT.sol +++ b/contracts/pool/PoolV3_USDT.sol @@ -9,6 +9,9 @@ import {USDT_Transfer} from "../traits/USDT_Transfer.sol"; /// @title Pool V3 USDT /// @notice Pool variation for USDT underlying with enabled transfer fees contract PoolV3_USDT is PoolV3, USDT_Transfer { + /// @notice Contract type + bytes32 public constant override contractType = "LP_USDT"; + constructor( address acl_, address contractsRegister_, diff --git a/contracts/pool/TumblerV3.sol b/contracts/pool/TumblerV3.sol index f7783604..ada02dad 100644 --- a/contracts/pool/TumblerV3.sol +++ b/contracts/pool/TumblerV3.sol @@ -26,6 +26,9 @@ contract TumblerV3 is ITumblerV3, ControlledTrait, SanityCheckTrait { /// @notice Contract version uint256 public constant override version = 3_10; + /// @notice Contract type + bytes32 public constant override contractType = "RK_TUMBLER"; + /// @notice Pool whose quota rates are set by this contract address public immutable override pool; diff --git a/contracts/test/helpers/IntegrationTestHelper.sol b/contracts/test/helpers/IntegrationTestHelper.sol index c98f3919..8a7080fd 100644 --- a/contracts/test/helpers/IntegrationTestHelper.sol +++ b/contracts/test/helpers/IntegrationTestHelper.sol @@ -6,9 +6,10 @@ pragma solidity ^0.8.17; import "../interfaces/IAddressProviderV3.sol"; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol"; +import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {AccountFactoryV3} from "../../core/AccountFactoryV3.sol"; -import {IACL} from "../../interfaces/IACL.sol"; -import {IContractsRegister} from "../../interfaces/IContractsRegister.sol"; +import {IACL} from "../../interfaces//base/IACL.sol"; +import {IContractsRegister} from "../../interfaces/base/IContractsRegister.sol"; import {IWETH} from "../../interfaces/external/IWETH.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; @@ -312,7 +313,7 @@ contract IntegrationTestHelper is TestHelper, BalanceHelper, ConfigManager { vm.prank(INITIAL_LP); pool.deposit(depositAmount, INITIAL_LP); - address configurator = IACL(addressProvider.getAddressOrRevert(AP_ACL, NO_VERSION_CONTROL)).owner(); + address configurator = Ownable(addressProvider.getAddressOrRevert(AP_ACL, NO_VERSION_CONTROL)).owner(); uint256 currentLimit = pool.creditManagerDebtLimit(address(creditManager)); vm.prank(configurator); pool.setCreditManagerDebtLimit(address(creditManager), currentLimit + depositAmount); diff --git a/contracts/test/integration/credit/OpenCreditAccount.int.t.sol b/contracts/test/integration/credit/OpenCreditAccount.int.t.sol index 460756d3..08cce1b8 100644 --- a/contracts/test/integration/credit/OpenCreditAccount.int.t.sol +++ b/contracts/test/integration/credit/OpenCreditAccount.int.t.sol @@ -5,7 +5,7 @@ pragma solidity ^0.8.17; import "../../interfaces/IAddressProviderV3.sol"; -import {IDegenNFT} from "../../../interfaces/IDegenNFT.sol"; +import {IDegenNFT} from "../../../interfaces/base/IDegenNFT.sol"; import {IAccountFactoryV3} from "../../../interfaces/IAccountFactoryV3.sol"; import {ICreditAccountV3} from "../../../interfaces/ICreditAccountV3.sol"; import { diff --git a/contracts/test/mocks/core/AccountFactoryMock.sol b/contracts/test/mocks/core/AccountFactoryMock.sol index 1c8f3396..a75a92c3 100644 --- a/contracts/test/mocks/core/AccountFactoryMock.sol +++ b/contracts/test/mocks/core/AccountFactoryMock.sol @@ -16,6 +16,8 @@ contract AccountFactoryMock is Test, IAccountFactoryV3 { /// @dev Contract version uint256 public version; + bytes32 public constant override contractType = "AF_MOCK"; + address public usedAccount; address public returnedAccount; diff --git a/contracts/test/mocks/core/AdapterMock.sol b/contracts/test/mocks/core/AdapterMock.sol index fdcb5bc2..07b498bb 100644 --- a/contracts/test/mocks/core/AdapterMock.sol +++ b/contracts/test/mocks/core/AdapterMock.sol @@ -3,14 +3,13 @@ // (c) Gearbox Foundation, 2023. pragma solidity ^0.8.17; -import {AdapterType} from "@gearbox-protocol/sdk-gov/contracts/AdapterType.sol"; import {ICreditManagerV3} from "../../../interfaces/ICreditManagerV3.sol"; import {IAdapter} from "../../../interfaces/base/IAdapter.sol"; /// @title Adapter Mock contract AdapterMock is IAdapter { - AdapterType public constant override _gearboxAdapterType = AdapterType.ABSTRACT; - uint16 public constant override _gearboxAdapterVersion = 1; + uint256 public constant override version = 3_10; + bytes32 public constant override contractType = "AD_MOCK"; address public immutable override creditManager; address public immutable override targetContract; diff --git a/contracts/test/mocks/credit/CreditAccountMock.sol b/contracts/test/mocks/credit/CreditAccountMock.sol index ed74c818..90482eae 100644 --- a/contracts/test/mocks/credit/CreditAccountMock.sol +++ b/contracts/test/mocks/credit/CreditAccountMock.sol @@ -20,7 +20,9 @@ contract CreditAccountMock is ICreditAccountV3, CreditAccountMockEvents { address public creditManager; // Contract version - uint256 public constant version = 3_00; + uint256 public constant version = 3_10; + + bytes32 public constant contractType = "CA_MOCK"; bytes public return_executeResult; diff --git a/contracts/test/mocks/governance/GearStakingMock.sol b/contracts/test/mocks/governance/GearStakingMock.sol index 740cb54d..699740d5 100644 --- a/contracts/test/mocks/governance/GearStakingMock.sol +++ b/contracts/test/mocks/governance/GearStakingMock.sol @@ -9,6 +9,8 @@ import {EPOCHS_TO_WITHDRAW} from "../../../libraries/Constants.sol"; contract GearStakingMock is IGearStakingV3 { uint256 public constant version = 3_10; + bytes32 public constant override contractType = "GS_MOCK"; + uint16 public getCurrentEpoch; function setCurrentEpoch(uint16 epoch) external { diff --git a/contracts/test/mocks/oracles/PriceFeedMock.sol b/contracts/test/mocks/oracles/PriceFeedMock.sol index bcc1f2b4..0182ec6d 100644 --- a/contracts/test/mocks/oracles/PriceFeedMock.sol +++ b/contracts/test/mocks/oracles/PriceFeedMock.sol @@ -3,7 +3,6 @@ // (c) Gearbox Foundation, 2023. pragma solidity ^0.8.10; -import {PriceFeedType} from "@gearbox-protocol/sdk-gov/contracts/PriceFeedType.sol"; import {IPriceFeed} from "../../../interfaces/base/IPriceFeed.sol"; enum FlagState { @@ -15,7 +14,8 @@ enum FlagState { /// @title Price feed mock /// @notice Used for test purposes only contract PriceFeedMock is IPriceFeed { - PriceFeedType public constant override priceFeedType = PriceFeedType.CHAINLINK_ORACLE; + uint256 public constant override version = 3_10; + bytes32 public constant override contractType = "PF_MOCK"; int256 private price; uint8 public immutable override decimals; @@ -52,10 +52,6 @@ contract PriceFeedMock is IPriceFeed { return "price oracle"; } - function version() external pure override returns (uint256) { - return 1; - } - function setPrice(int256 newPrice) external { price = newPrice; } diff --git a/contracts/test/mocks/pool/PoolQuotaKeeperMock.sol b/contracts/test/mocks/pool/PoolQuotaKeeperMock.sol index bb953de1..8e52b29c 100644 --- a/contracts/test/mocks/pool/PoolQuotaKeeperMock.sol +++ b/contracts/test/mocks/pool/PoolQuotaKeeperMock.sol @@ -3,16 +3,18 @@ // (c) Gearbox Foundation, 2023. pragma solidity ^0.8.17; -import {IPoolQuotaKeeperV3, TokenQuotaParams, AccountQuota} from "../../../interfaces/IPoolQuotaKeeperV3.sol"; +import {TokenQuotaParams, AccountQuota} from "../../../interfaces/IPoolQuotaKeeperV3.sol"; -contract PoolQuotaKeeperMock is IPoolQuotaKeeperV3 { - uint256 public constant override version = 3_10; +contract PoolQuotaKeeperMock { + uint256 public constant version = 3_10; + + bytes32 public constant contractType = "QK_MOCK"; /// @dev Address provider address public immutable underlying; /// @dev Address of the protocol treasury - address public immutable override pool; + address public immutable pool; /// @dev Mapping from token address to its respective quota parameters TokenQuotaParams public totalQuotaParam; @@ -98,7 +100,6 @@ contract PoolQuotaKeeperMock is IPoolQuotaKeeperV3 { function getQuotaAndOutstandingInterest(address, address token) external view - override returns (uint96 quoted, uint128 interest) { quoted = _quoted[token]; @@ -106,22 +107,22 @@ contract PoolQuotaKeeperMock is IPoolQuotaKeeperV3 { } /// @dev Returns cumulative index in RAY for a quoted token. Returns 0 for non-quoted tokens. - function cumulativeIndex(address token) public view override returns (uint192) { + function cumulativeIndex(address token) public view returns (uint192) { // return totalQuotaParams[token].cumulativeIndexSince(lastQuotaRateUpdate); } /// @dev Returns quota rate in PERCENTAGE FORMAT - function getQuotaRate(address) external view override returns (uint16) { + function getQuotaRate(address) external view returns (uint16) { return totalQuotaParam.rate; } /// @dev Returns an array of all quoted tokens - function quotedTokens() external view override returns (address[] memory) { + function quotedTokens() external view returns (address[] memory) { // return quotaTokensSet.values(); } /// @dev Returns whether a token is quoted - function isQuotedToken(address) external view override returns (bool) { + function isQuotedToken(address) external view returns (bool) { return return_isQuotedToken; } @@ -140,7 +141,7 @@ contract PoolQuotaKeeperMock is IPoolQuotaKeeperV3 { } /// @notice Returns the current annual quota revenue to the pool - function poolQuotaRevenue() external view virtual override returns (uint256 quotaRevenue) { + function poolQuotaRevenue() external view virtual returns (uint256 quotaRevenue) { return 0; } diff --git a/contracts/test/mocks/token/DegenNFTMock.sol b/contracts/test/mocks/token/DegenNFTMock.sol index 6d642788..717be115 100644 --- a/contracts/test/mocks/token/DegenNFTMock.sol +++ b/contracts/test/mocks/token/DegenNFTMock.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.17; import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol"; -import {IDegenNFT} from "../../../interfaces/IDegenNFT.sol"; +import {IDegenNFT} from "../../../interfaces/base/IDegenNFT.sol"; import {InsufficientBalanceException} from "../../../interfaces/IExceptions.sol"; contract DegenNFTMock is ERC721, IDegenNFT { diff --git a/contracts/traits/ACLTrait.sol b/contracts/traits/ACLTrait.sol index a30d9d81..c295eae3 100644 --- a/contracts/traits/ACLTrait.sol +++ b/contracts/traits/ACLTrait.sol @@ -3,7 +3,8 @@ // (c) Gearbox Foundation, 2024. pragma solidity ^0.8.17; -import {IACL} from "../interfaces/IACL.sol"; +import {IACL} from "../interfaces/base/IACL.sol"; +import {IACLTrait} from "../interfaces/base/IACLTrait.sol"; import { AddressIsNotContractException, CallerNotConfiguratorException, @@ -14,9 +15,9 @@ import { /// @title ACL trait /// @notice Utility class for ACL (access-control list) consumers -abstract contract ACLTrait { +abstract contract ACLTrait is IACLTrait { /// @notice ACL contract address - address public immutable acl; + address public immutable override acl; /// @dev Ensures that function caller has configurator role modifier configuratorOnly() { diff --git a/contracts/traits/ContractsRegisterTrait.sol b/contracts/traits/ContractsRegisterTrait.sol index 63424cee..0ad4835a 100644 --- a/contracts/traits/ContractsRegisterTrait.sol +++ b/contracts/traits/ContractsRegisterTrait.sol @@ -3,7 +3,8 @@ // (c) Gearbox Foundation, 2024. pragma solidity ^0.8.17; -import {IContractsRegister} from "../interfaces/IContractsRegister.sol"; +import {IContractsRegister} from "../interfaces/base/IContractsRegister.sol"; +import {IContractsRegisterTrait} from "../interfaces/base/IContractsRegisterTrait.sol"; import { AddressIsNotContractException, RegisteredCreditManagerOnlyException, @@ -13,9 +14,9 @@ import { /// @title Contracts register trait /// @notice Trait that simplifies validation of pools and credit managers -abstract contract ContractsRegisterTrait { +abstract contract ContractsRegisterTrait is IContractsRegisterTrait { /// @notice Contracts register contract address - address public immutable contractsRegister; + address public immutable override contractsRegister; /// @dev Ensures that given address is a registered pool modifier registeredPoolOnly(address addr) { diff --git a/contracts/traits/ControlledTrait.sol b/contracts/traits/ControlledTrait.sol index 831667f2..d7fcad94 100644 --- a/contracts/traits/ControlledTrait.sol +++ b/contracts/traits/ControlledTrait.sol @@ -3,6 +3,7 @@ // (c) Gearbox Foundation, 2024. pragma solidity ^0.8.17; +import {IControlledTrait} from "../interfaces/base/IControlledTrait.sol"; import { AddressIsNotContractException, CallerNotControllerOrConfiguratorException } from "../interfaces/IExceptions.sol"; @@ -11,12 +12,9 @@ import {ACLTrait} from "./ACLTrait.sol"; /// @title Controlled trait /// @notice Extended version of the ACL trait that introduces external controller role -abstract contract ControlledTrait is ACLTrait { - /// @notice Emitted when new external controller is set - event NewController(address indexed newController); - +abstract contract ControlledTrait is ACLTrait, IControlledTrait { /// @notice External controller address - address public controller; + address public override controller; /// @dev Ensures that function caller is external controller or configurator modifier controllerOrConfiguratorOnly() { @@ -29,7 +27,7 @@ abstract contract ControlledTrait is ACLTrait { constructor(address acl) ACLTrait(acl) {} /// @notice Sets new external controller contract, can only be called by configurator - function setController(address newController) external configuratorOnly { + function setController(address newController) external override configuratorOnly { if (controller == newController) return; if (newController.code.length == 0) revert AddressIsNotContractException(newController); controller = newController; From ac56079752bb9aa7c8bc2cfcc1d07ca188042d93 Mon Sep 17 00:00:00 2001 From: Dima Lekhovitsky Date: Tue, 20 Aug 2024 15:10:37 +0300 Subject: [PATCH 2/3] fix: silence compiler warnings --- contracts/credit/CreditConfiguratorV3.sol | 2 +- contracts/test/gas/credit/CreditFacade.gas.t.sol | 2 -- contracts/test/helpers/IntegrationTestHelper.sol | 2 +- .../integration/credit/CreditConfigurator.int.t.sol | 2 +- contracts/test/lib/helper.sol | 9 ++++++--- contracts/test/suites/CreditManagerFactory.sol | 1 - contracts/test/unit/core/PriceOracleV3.unit.t.sol | 2 +- contracts/test/unit/libraries/BitMask.unit.t.sol | 8 ++++---- contracts/test/unit/libraries/CreditLogic.unit.t.sol | 12 ++++++------ .../unit/pool/LinearInterestRateModelV3.unit.t.sol | 2 +- .../test/unit/pool/PoolQuotaKeeperV3.unit.t.sol | 2 +- contracts/test/unit/pool/TumblerV3.unit.t.sol | 2 +- 12 files changed, 23 insertions(+), 23 deletions(-) diff --git a/contracts/credit/CreditConfiguratorV3.sol b/contracts/credit/CreditConfiguratorV3.sol index 40771641..09bb4164 100644 --- a/contracts/credit/CreditConfiguratorV3.sol +++ b/contracts/credit/CreditConfiguratorV3.sol @@ -287,7 +287,7 @@ contract CreditConfiguratorV3 is ICreditConfiguratorV3, ControlledTrait, SanityC } address cf = creditFacade(); - if (targetContract == creditFacade() || adapter == creditFacade()) { + if (targetContract == cf || adapter == cf) { revert TargetContractNotAllowedException(); // I:[CC-10C] } diff --git a/contracts/test/gas/credit/CreditFacade.gas.t.sol b/contracts/test/gas/credit/CreditFacade.gas.t.sol index 32b950f0..eedac9d7 100644 --- a/contracts/test/gas/credit/CreditFacade.gas.t.sol +++ b/contracts/test/gas/credit/CreditFacade.gas.t.sol @@ -659,8 +659,6 @@ contract CreditFacadeGasTest is IntegrationTestHelper { vm.roll(block.number + 1); - address linkToken = tokenTestSuite.addressOf(Tokens.LINK); - calls = MultiCallBuilder.build( MultiCall({target: address(adapterMock), callData: abi.encodeCall(AdapterMock.dumbCall, ())}), MultiCall({ diff --git a/contracts/test/helpers/IntegrationTestHelper.sol b/contracts/test/helpers/IntegrationTestHelper.sol index 8a7080fd..078d8aa3 100644 --- a/contracts/test/helpers/IntegrationTestHelper.sol +++ b/contracts/test/helpers/IntegrationTestHelper.sol @@ -582,7 +582,7 @@ contract IntegrationTestHelper is TestHelper, BalanceHelper, ConfigManager { vm.roll(block.number + 1); } - function expectSafeAllowance(address creditAccount, address target) internal { + function expectSafeAllowance(address creditAccount, address target) internal view { uint256 len = creditManager.collateralTokensCount(); for (uint256 i = 0; i < len; i++) { (address token,) = creditManager.collateralTokenByMask(1 << i); diff --git a/contracts/test/integration/credit/CreditConfigurator.int.t.sol b/contracts/test/integration/credit/CreditConfigurator.int.t.sol index 3c8fe00b..222d51e2 100644 --- a/contracts/test/integration/credit/CreditConfigurator.int.t.sol +++ b/contracts/test/integration/credit/CreditConfigurator.int.t.sol @@ -62,7 +62,7 @@ contract CreditConfiguratorIntegrationTest is IntegrationTestHelper, ICreditConf uint16 liquidationDiscount, uint16 feeLiquidationExpired, uint16 liquidationDiscountExpired - ) internal { + ) internal view { ( , uint16 feeLiquidation2, diff --git a/contracts/test/lib/helper.sol b/contracts/test/lib/helper.sol index 9f8bf1bc..6c932a51 100644 --- a/contracts/test/lib/helper.sol +++ b/contracts/test/lib/helper.sol @@ -134,17 +134,20 @@ contract TestHelper is Test { array[3] = v4; } - function assertEq(uint16[] memory a1, uint16[] memory a2, string memory reason) internal { + function assertEq(uint16[] memory a1, uint16[] memory a2, string memory reason) internal pure { assertEq(a1.length, a2.length, string.concat(reason, "Arrays has different length")); assertEq(_copyU16toU256(a1), _copyU16toU256(a2), reason); } - function assertEq(CollateralDebtData memory cdd1, CollateralDebtData memory cdd2) internal { + function assertEq(CollateralDebtData memory cdd1, CollateralDebtData memory cdd2) internal pure { assertEq(cdd1, cdd2, ""); } - function assertEq(CollateralDebtData memory cdd1, CollateralDebtData memory cdd2, string memory reason) internal { + function assertEq(CollateralDebtData memory cdd1, CollateralDebtData memory cdd2, string memory reason) + internal + pure + { assertEq(cdd1.debt, cdd2.debt, string.concat(reason, "\nIncorrect debt")); assertEq( cdd1.cumulativeIndexNow, cdd2.cumulativeIndexNow, string.concat(reason, "\nIncorrect cumulativeIndexNow") diff --git a/contracts/test/suites/CreditManagerFactory.sol b/contracts/test/suites/CreditManagerFactory.sol index ed32c12a..6fd64fe7 100644 --- a/contracts/test/suites/CreditManagerFactory.sol +++ b/contracts/test/suites/CreditManagerFactory.sol @@ -30,7 +30,6 @@ contract CreditManagerFactory { uint16 feeInterest, string memory name ) { - address acl = IAddressProviderV3(addressProvider).getAddressOrRevert(AP_ACL, NO_VERSION_CONTROL); address weth = IAddressProviderV3(addressProvider).getAddressOrRevert(AP_WETH_TOKEN, NO_VERSION_CONTROL); address accountFactory = IAddressProviderV3(addressProvider).getAddressOrRevert(AP_ACCOUNT_FACTORY, 3_10); address priceOracle = IAddressProviderV3(addressProvider).getAddressOrRevert(AP_PRICE_ORACLE, 3_10); diff --git a/contracts/test/unit/core/PriceOracleV3.unit.t.sol b/contracts/test/unit/core/PriceOracleV3.unit.t.sol index 2da6e13c..6fb94dcd 100644 --- a/contracts/test/unit/core/PriceOracleV3.unit.t.sol +++ b/contracts/test/unit/core/PriceOracleV3.unit.t.sol @@ -256,7 +256,7 @@ contract PriceOracleV3UnitTest is Test, IPriceOracleV3Events { // ------------------ // /// @notice U:[PO-6]: `_getTokenReserveKey` works as expected - function test_U_PO_06_getTokenReserveKey_works_as_expected(address token) public { + function test_U_PO_06_getTokenReserveKey_works_as_expected(address token) public view { address expectedKey = address(uint160(uint256(keccak256(abi.encodePacked("RESERVE", token))))); assertEq(priceOracle.exposed_getTokenReserveKey(token), expectedKey); } diff --git a/contracts/test/unit/libraries/BitMask.unit.t.sol b/contracts/test/unit/libraries/BitMask.unit.t.sol index f4de86e3..f829de1c 100644 --- a/contracts/test/unit/libraries/BitMask.unit.t.sol +++ b/contracts/test/unit/libraries/BitMask.unit.t.sol @@ -14,7 +14,7 @@ contract BitMaskUnitTest is TestHelper { using BitMask for uint256; /// @notice U:[BM-3]: `calcEnabledTokens` works correctly - function test_U_BM_03_calcEnabledTokens_works_correctly(uint8 bitsToEnable, uint256 randomValue) public { + function test_U_BM_03_calcEnabledTokens_works_correctly(uint8 bitsToEnable, uint256 randomValue) public pure { uint256 bitMask; for (uint256 i; i < bitsToEnable;) { @@ -30,7 +30,7 @@ contract BitMaskUnitTest is TestHelper { } /// @notice U:[BM-4]: `enable` & `disable` works correctly - function test_U_BM_04_enable_and_disable_works_correctly(uint8 bit) public { + function test_U_BM_04_enable_and_disable_works_correctly(uint8 bit) public pure { uint256 mask; mask = mask.enable(1 << bit); assertEq(mask, 1 << bit, "Enable doesn't work"); @@ -40,7 +40,7 @@ contract BitMaskUnitTest is TestHelper { } /// @notice U:[BM-5]: `enableDisable` works correctly - function test_U_BM_05_enableDisable_works_correctly(uint8 bit) public { + function test_U_BM_05_enableDisable_works_correctly(uint8 bit) public pure { uint256 mask; mask = mask.enableDisable(1 << bit, 0); @@ -51,7 +51,7 @@ contract BitMaskUnitTest is TestHelper { } /// @notice U:[BM-6]: `lsbMask` works correctly - function test_U_BM_06_lsbMask_works_correctly(uint256 mask) public { + function test_U_BM_06_lsbMask_works_correctly(uint256 mask) public pure { uint256 lsbMask = mask.lsbMask(); if (lsbMask == 0) { assertEq(mask, 0, "Zero LSB for non-zero mask"); diff --git a/contracts/test/unit/libraries/CreditLogic.unit.t.sol b/contracts/test/unit/libraries/CreditLogic.unit.t.sol index 23d94f8e..27633a37 100644 --- a/contracts/test/unit/libraries/CreditLogic.unit.t.sol +++ b/contracts/test/unit/libraries/CreditLogic.unit.t.sol @@ -114,7 +114,7 @@ contract CreditLogicUnitTest is TestHelper { uint128 quotaInterest, uint128 quotaFees, uint16 feeInterest - ) internal { + ) internal pure { (uint256 newDebt, uint256 newIndex,, uint128 newQuotaInterest, uint128 newQuotaFees) = CreditLogic.calcDecrease(amount, debt, indexNow, indexLastUpdate, quotaInterest, quotaFees, feeInterest); @@ -138,7 +138,7 @@ contract CreditLogicUnitTest is TestHelper { uint128 quotaInterest, uint128 quotaFees, uint16 feeInterest - ) internal { + ) internal pure { (uint256 newDebt,, uint256 profit,,) = CreditLogic.calcDecrease(amount, debt, indexNow, indexLastUpdate, quotaInterest, quotaFees, feeInterest); @@ -160,7 +160,7 @@ contract CreditLogicUnitTest is TestHelper { uint128 quotaInterest, uint128 quotaFees, uint16 feeInterest - ) internal { + ) internal pure { (uint256 newDebt, uint256 newIndex,,,) = CreditLogic.calcDecrease(amount, debt, indexNow, indexLastUpdate, quotaInterest, quotaFees, feeInterest); @@ -184,7 +184,7 @@ contract CreditLogicUnitTest is TestHelper { uint128 quotaInterest, uint128 quotaFees, uint16 feeInterest - ) internal { + ) internal pure { (uint256 newDebt,,, uint128 newQuotaInterest, uint128 newQuotaFees) = CreditLogic.calcDecrease(amount, debt, indexNow, indexLastUpdate, quotaInterest, quotaFees, feeInterest); @@ -217,7 +217,7 @@ contract CreditLogicUnitTest is TestHelper { } /// @notice U:[CL-4]: `calcLiquidationPayments` gives expected outputs - function test_U_CL_04_calcLiquidationPayments_case_test() public { + function test_U_CL_04_calcLiquidationPayments_case_test() public view { /// FEE INTEREST: 50% /// NORMAL LIQUIDATION PREMIUM: 4% /// NORMAL LIQUIDATION FEE: 1.5% @@ -390,7 +390,7 @@ contract CreditLogicUnitTest is TestHelper { } /// @notice U:[CL-5]: `getLiquidationThreshold` gives expected outputs - function test_U_CL_05_getLiquidationThreshold_case_test() public { + function test_U_CL_05_getLiquidationThreshold_case_test() public view { LiquidationThresholdTestCase[6] memory cases = [ LiquidationThresholdTestCase({ name: "LIQUIDATION THRESHOLD RAMP IN THE FUTURE", diff --git a/contracts/test/unit/pool/LinearInterestRateModelV3.unit.t.sol b/contracts/test/unit/pool/LinearInterestRateModelV3.unit.t.sol index ad5b65be..02851545 100644 --- a/contracts/test/unit/pool/LinearInterestRateModelV3.unit.t.sol +++ b/contracts/test/unit/pool/LinearInterestRateModelV3.unit.t.sol @@ -31,7 +31,7 @@ contract LinearInterestRateModelV3UnitTest is TestHelper { // /// @notice U:[LIM-1]: start parameters are correct - function test_U_LIM_01_start_parameters_correct() public { + function test_U_LIM_01_start_parameters_correct() public view { (uint16 U_1, uint16 U_2, uint16 R_base, uint16 R_slope1, uint16 R_slope2, uint16 R_slope3) = irm.getModelParameters(); diff --git a/contracts/test/unit/pool/PoolQuotaKeeperV3.unit.t.sol b/contracts/test/unit/pool/PoolQuotaKeeperV3.unit.t.sol index f5e248af..559cd847 100644 --- a/contracts/test/unit/pool/PoolQuotaKeeperV3.unit.t.sol +++ b/contracts/test/unit/pool/PoolQuotaKeeperV3.unit.t.sol @@ -91,7 +91,7 @@ contract PoolQuotaKeeperV3UnitTest is TestHelper, BalanceHelper, IPoolQuotaKeepe // /// @notice U:[PQK-1]: constructor sets parameters correctly - function test_U_PQK_01_constructor_sets_parameters_correctly() public { + function test_U_PQK_01_constructor_sets_parameters_correctly() public view { assertEq(address(poolMock), pqk.pool(), "Incorrect poolMock address"); assertEq(underlying, pqk.underlying(), "Incorrect poolMock address"); } diff --git a/contracts/test/unit/pool/TumblerV3.unit.t.sol b/contracts/test/unit/pool/TumblerV3.unit.t.sol index 4eab10af..900a8156 100644 --- a/contracts/test/unit/pool/TumblerV3.unit.t.sol +++ b/contracts/test/unit/pool/TumblerV3.unit.t.sol @@ -44,7 +44,7 @@ contract TumblerV3UnitTest is Test, ITumblerV3Events { } /// @notice U:[TU-1]: Constructor works as expected - function test_U_TU_01_constructor_works_as_expected() public { + function test_U_TU_01_constructor_works_as_expected() public view { assertEq(tumbler.pool(), address(pool), "Incorrect pool"); assertEq(tumbler.underlying(), underlying, "Incorrect underlying"); assertEq(tumbler.poolQuotaKeeper(), address(poolQuotaKeeper), "Incorrect poolQuotaKeeper"); From bcc99c19506629d489b2e4fd9411c31de2fb5027 Mon Sep 17 00:00:00 2001 From: Dima Lekhovitsky Date: Wed, 21 Aug 2024 14:22:40 +0300 Subject: [PATCH 3/3] fix: add `withdraw` to `IWETH` --- contracts/interfaces/external/IWETH.sol | 1 + 1 file changed, 1 insertion(+) diff --git a/contracts/interfaces/external/IWETH.sol b/contracts/interfaces/external/IWETH.sol index fcdb9bd3..3445f0c2 100644 --- a/contracts/interfaces/external/IWETH.sol +++ b/contracts/interfaces/external/IWETH.sol @@ -5,4 +5,5 @@ pragma solidity ^0.8.17; interface IWETH { function deposit() external payable; + function withdraw(uint256 amount) external; }