From 4669a4fcf37b59982bce25d4308ba06c792e319a Mon Sep 17 00:00:00 2001 From: Ricardo Guilherme Schmidt <3esmit@gmail.com> Date: Fri, 8 Nov 2024 00:56:09 -0300 Subject: [PATCH] Update specs and interface --- .gas-report | 127 ------------------ .github/workflows/ci.yml | 2 +- .solhint.json | 2 +- certora/confs/MaxMPRule.conf | 2 +- certora/confs/StakeManager.conf | 2 +- certora/confs/StakeManagerProcess.conf | 2 +- certora/confs/StakeManagerStartMigration.conf | 2 +- certora/confs/StakeVault.conf | 2 +- certora/harness/StakeManagerNew.sol | 6 +- certora/helpers/ERC20A.sol | 4 +- certora/helpers/ExpiredStakeStorageA.sol | 2 +- contracts/IStakeManager.sol | 33 ----- contracts/StakeVault.sol | 19 +-- contracts/VaultFactory.sol | 4 +- contracts/access/TrustedCodehashAccess.sol | 4 +- contracts/factory/Create2FactoryLib.sol | 43 ++++++ contracts/factory/SingletonFactory.sol | 2 +- contracts/interfaces/IStakeManager.sol | 28 ++++ .../ITrustedCodehashAccess.sol | 2 +- contracts/storage/ExpiredStakeStorage.sol | 2 +- foundry.toml | 2 +- script/Base.s.sol | 2 +- script/Deploy.s.sol | 2 +- script/DeployMigrationStakeManager.s.sol | 4 +- script/DeploymentConfig.s.sol | 2 +- test/DynamicTest.t.sol | 2 +- test/StakeManager.t.sol | 6 +- test/StakeVault.t.sol | 4 +- test/VaultFactory.t.sol | 8 +- test/mocks/BrokenERC20.s.sol | 2 +- test/mocks/MockERC20.sol | 2 +- test/script/DeployBroken.s.sol | 2 +- 32 files changed, 120 insertions(+), 208 deletions(-) delete mode 100644 contracts/IStakeManager.sol create mode 100644 contracts/factory/Create2FactoryLib.sol create mode 100644 contracts/interfaces/IStakeManager.sol rename contracts/{access => interfaces}/ITrustedCodehashAccess.sol (97%) diff --git a/.gas-report b/.gas-report index 2db355e..e69de29 100644 --- a/.gas-report +++ b/.gas-report @@ -1,127 +0,0 @@ -| contracts/StakeManager.sol:StakeManager contract | | | | | | -|--------------------------------------------------|-----------------|--------|--------|--------|---------| -| Deployment Cost | Deployment Size | | | | | -| 2512529 | 13257 | | | | | -| Function Name | min | avg | median | max | # calls | -| EPOCH_SIZE | 285 | 285 | 285 | 285 | 1498 | -| MAX_LOCKUP_PERIOD | 361 | 361 | 361 | 361 | 4 | -| MAX_MULTIPLIER | 307 | 307 | 307 | 307 | 637 | -| MIN_LOCKUP_PERIOD | 264 | 264 | 264 | 264 | 12 | -| YEAR | 307 | 307 | 307 | 307 | 637 | -| acceptUpdate | 23632 | 23632 | 23632 | 23632 | 1 | -| accounts | 1572 | 1572 | 1572 | 1572 | 144273 | -| calculateMP | 738 | 738 | 738 | 738 | 1276 | -| currentEpoch | 406 | 1072 | 406 | 2406 | 54 | -| epochEnd | 627 | 627 | 627 | 2627 | 23675 | -| epochReward | 1381 | 2881 | 1381 | 5881 | 3 | -| executeAccount(address) | 149349 | 149349 | 149349 | 149349 | 2 | -| executeAccount(address,uint256) | 26540 | 72264 | 74140 | 200389 | 141860 | -| executeEpoch() | 23458 | 120684 | 121843 | 900358 | 23564 | -| executeEpoch(uint256) | 23905 | 24541 | 23905 | 26134 | 7 | -| expiredStakeStorage | 394 | 2303 | 2394 | 2394 | 22 | -| isTrustedCodehash | 541 | 949 | 541 | 2541 | 680 | -| leave | 23631 | 23631 | 23631 | 23631 | 1 | -| lock | 23862 | 23862 | 23862 | 23862 | 1 | -| migration | 417 | 1417 | 1417 | 2417 | 4 | -| migrationInitialize | 24624 | 24624 | 24624 | 24624 | 1 | -| newEpoch | 441 | 441 | 441 | 441 | 5 | -| owner | 2410 | 2410 | 2410 | 2410 | 13 | -| pendingReward | 408 | 1442 | 2408 | 2408 | 29 | -| potentialMP | 408 | 408 | 408 | 408 | 46432 | -| previousManager | 275 | 275 | 275 | 275 | 13 | -| rewardToken | 293 | 293 | 293 | 293 | 696 | -| setTrustedCodehash | 47960 | 47960 | 47960 | 47960 | 139 | -| stake | 24005 | 24005 | 24005 | 24005 | 1 | -| startMigration | 103624 | 103632 | 103636 | 103636 | 3 | -| startTime | 264 | 264 | 264 | 264 | 21 | -| totalMP | 385 | 385 | 385 | 2385 | 46453 | -| totalStaked | 385 | 1785 | 2385 | 2385 | 20 | -| totalSupply | 784 | 1965 | 2784 | 2784 | 22 | -| unstake | 23841 | 23841 | 23841 | 23841 | 1 | - - -| contracts/StakeVault.sol:StakeVault contract | | | | | | -|----------------------------------------------|-----------------|--------|--------|--------|---------| -| Deployment Cost | Deployment Size | | | | | -| 0 | 0 | | | | | -| Function Name | min | avg | median | max | # calls | -| acceptMigration | 35140 | 35140 | 35140 | 35140 | 2 | -| leave | 35152 | 35152 | 35152 | 35152 | 1 | -| lock | 43329 | 90544 | 61982 | 180383 | 7 | -| owner | 351 | 351 | 351 | 351 | 679 | -| stake | 27265 | 282111 | 265792 | 351743 | 684 | -| stakedToken | 215 | 215 | 215 | 215 | 2 | -| unstake | 40157 | 96345 | 78682 | 229644 | 11 | - - -| contracts/VaultFactory.sol:VaultFactory contract | | | | | | -|--------------------------------------------------|-----------------|--------|--------|--------|---------| -| Deployment Cost | Deployment Size | | | | | -| 0 | 0 | | | | | -| Function Name | min | avg | median | max | # calls | -| createVault | 682103 | 682103 | 682103 | 682103 | 683 | -| setStakeManager | 23710 | 26669 | 26076 | 30222 | 3 | -| stakeManager | 368 | 1868 | 2368 | 2368 | 4 | - - -| contracts/storage/ExpiredStakeStorage.sol:ExpiredStakeStorage contract | | | | | | -|------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| -| Deployment Cost | Deployment Size | | | | | -| 0 | 0 | | | | | -| Function Name | min | avg | median | max | # calls | -| getExpiredMP | 2427 | 2427 | 2427 | 2427 | 23725 | -| transferOwnership | 28533 | 28533 | 28533 | 28533 | 1 | - - -| lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol:ERC20 contract | | | | | | -|---------------------------------------------------------------------------|-----------------|-------|--------|-------|---------| -| Deployment Cost | Deployment Size | | | | | -| 0 | 0 | | | | | -| Function Name | min | avg | median | max | # calls | -| approve | 46175 | 46241 | 46199 | 46367 | 679 | -| balanceOf | 561 | 2107 | 2561 | 2561 | 30744 | - - -| script/Deploy.s.sol:Deploy contract | | | | | | -|-------------------------------------|-----------------|---------|---------|---------|---------| -| Deployment Cost | Deployment Size | | | | | -| 6149710 | 29676 | | | | | -| Function Name | min | avg | median | max | # calls | -| run | 5343984 | 5343984 | 5343984 | 5343984 | 66 | - - -| script/DeployMigrationStakeManager.s.sol:DeployMigrationStakeManager contract | | | | | | -|-------------------------------------------------------------------------------|-----------------|---------|---------|---------|---------| -| Deployment Cost | Deployment Size | | | | | -| 3329385 | 16522 | | | | | -| Function Name | min | avg | median | max | # calls | -| run | 2345854 | 2345854 | 2345854 | 2345854 | 19 | - - -| script/DeploymentConfig.s.sol:DeploymentConfig contract | | | | | | -|---------------------------------------------------------|-----------------|-----|--------|-----|---------| -| Deployment Cost | Deployment Size | | | | | -| 0 | 0 | | | | | -| Function Name | min | avg | median | max | # calls | -| activeNetworkConfig | 455 | 455 | 455 | 455 | 132 | - - -| test/mocks/BrokenERC20.s.sol:BrokenERC20 contract | | | | | | -|---------------------------------------------------|-----------------|-------|--------|-------|---------| -| Deployment Cost | Deployment Size | | | | | -| 0 | 0 | | | | | -| Function Name | min | avg | median | max | # calls | -| approve | 46175 | 46175 | 46175 | 46175 | 1 | -| balanceOf | 561 | 1227 | 561 | 2561 | 3 | - - -| test/script/DeployBroken.s.sol:DeployBroken contract | | | | | | -|------------------------------------------------------|-----------------|---------|---------|---------|---------| -| Deployment Cost | Deployment Size | | | | | -| 4834448 | 23474 | | | | | -| Function Name | min | avg | median | max | # calls | -| run | 4183805 | 4183805 | 4183805 | 4183805 | 1 | - - - - diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d874ba2..7339c6d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -140,7 +140,7 @@ jobs: - name: Install Solidity run: | - wget https://github.com/ethereum/solidity/releases/download/v0.8.19/solc-static-linux + wget https://github.com/ethereum/solidity/releases/download/v0.8.26/solc-static-linux chmod +x solc-static-linux sudo mv solc-static-linux /usr/local/bin/solc diff --git a/.solhint.json b/.solhint.json index ac7469e..25923e8 100644 --- a/.solhint.json +++ b/.solhint.json @@ -2,7 +2,7 @@ "extends": "solhint:recommended", "rules": { "code-complexity": ["error", 8], - "compiler-version": ["error", ">=0.8.19"], + "compiler-version": ["error", ">=0.8.27"], "func-name-mixedcase": "off", "func-visibility": ["error", { "ignoreConstructors": true }], "max-line-length": ["error", 120], diff --git a/certora/confs/MaxMPRule.conf b/certora/confs/MaxMPRule.conf index 73399f0..f37d5f3 100644 --- a/certora/confs/MaxMPRule.conf +++ b/certora/confs/MaxMPRule.conf @@ -6,7 +6,7 @@ ], "global_timeout": "7200", "link": [ - "StakeManager:stakedToken=ERC20A", + "StakeManager:STAKING_TOKEN=ERC20A", "StakeManager:expiredStakeStorage=ExpiredStakeStorageA", ], "loop_iter": "3", diff --git a/certora/confs/StakeManager.conf b/certora/confs/StakeManager.conf index 85d9f73..ce3f004 100644 --- a/certora/confs/StakeManager.conf +++ b/certora/confs/StakeManager.conf @@ -5,7 +5,7 @@ "certora/helpers/ERC20A.sol" ], "link" : [ - "StakeManager:rewardToken=ERC20A", + "StakeManager:REWARD_TOKEN=ERC20A", "StakeManager:expiredStakeStorage=ExpiredStakeStorageA" ], "msg": "Verifying StakeManager.sol", diff --git a/certora/confs/StakeManagerProcess.conf b/certora/confs/StakeManagerProcess.conf index 0c949c1..67b061d 100644 --- a/certora/confs/StakeManagerProcess.conf +++ b/certora/confs/StakeManagerProcess.conf @@ -5,7 +5,7 @@ "certora/helpers/ExpiredStakeStorageA.sol" ], "link" : [ - "StakeManager:rewardToken=ERC20A", + "StakeManager:REWARD_TOKEN=ERC20A", "StakeManager:expiredStakeStorage=ExpiredStakeStorageA" ], "msg": "Verifying StakeManager ProcessAccount", diff --git a/certora/confs/StakeManagerStartMigration.conf b/certora/confs/StakeManagerStartMigration.conf index 12f382a..e6e6761 100644 --- a/certora/confs/StakeManagerStartMigration.conf +++ b/certora/confs/StakeManagerStartMigration.conf @@ -6,7 +6,7 @@ "certora/helpers/ERC20A.sol" ], "link" : [ - "StakeManager:rewardToken=ERC20A", + "StakeManager:REWARD_TOKEN=ERC20A", "StakeManager:expiredStakeStorage=ExpiredStakeStorageA", ], "msg": "Verifying StakeManager.sol", diff --git a/certora/confs/StakeVault.conf b/certora/confs/StakeVault.conf index 3bf9483..f78f918 100644 --- a/certora/confs/StakeVault.conf +++ b/certora/confs/StakeVault.conf @@ -7,7 +7,7 @@ ], "link" : [ "StakeVault:STAKED_TOKEN=ERC20A", - "StakeManager:rewardToken=ERC20A", + "StakeManager:REWARD_TOKEN=ERC20A", "StakeManager:expiredStakeStorage=ExpiredStakeStorageA", "StakeVault:stakeManager=StakeManager" ], diff --git a/certora/harness/StakeManagerNew.sol b/certora/harness/StakeManagerNew.sol index 1080a26..1899408 100644 --- a/certora/harness/StakeManagerNew.sol +++ b/certora/harness/StakeManagerNew.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.19; +pragma solidity ^0.8.26; -import {StakeManager} from "../../contracts/StakeManager.sol"; +import { StakeManager } from "../../contracts/StakeManager.sol"; contract StakeManagerNew is StakeManager { - constructor(address token, address oldManager) StakeManager(token, oldManager) {} + constructor(address token, address oldManager) StakeManager(token, oldManager) { } } diff --git a/certora/helpers/ERC20A.sol b/certora/helpers/ERC20A.sol index cabfa08..0078928 100644 --- a/certora/helpers/ERC20A.sol +++ b/certora/helpers/ERC20A.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.19; +pragma solidity ^0.8.26; import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract ERC20A is ERC20 { - constructor(string memory name_, string memory symbol_) ERC20(name_, symbol_) {} + constructor(string memory name_, string memory symbol_) ERC20(name_, symbol_) { } } diff --git a/certora/helpers/ExpiredStakeStorageA.sol b/certora/helpers/ExpiredStakeStorageA.sol index 9787836..741fb68 100644 --- a/certora/helpers/ExpiredStakeStorageA.sol +++ b/certora/helpers/ExpiredStakeStorageA.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.19; +pragma solidity ^0.8.26; import { ExpiredStakeStorage } from "./../../contracts/storage/ExpiredStakeStorage.sol"; diff --git a/contracts/IStakeManager.sol b/contracts/IStakeManager.sol deleted file mode 100644 index e2f9cf6..0000000 --- a/contracts/IStakeManager.sol +++ /dev/null @@ -1,33 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.18; - -import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import { ITrustedCodehashAccess } from "./access/ITrustedCodehashAccess.sol"; - -interface IStakeManager is ITrustedCodehashAccess { - error StakeManager__FundsLocked(); - error StakeManager__InvalidLockTime(); - error StakeManager__InsufficientFunds(); - error StakeManager__StakeIsTooLow(); - - function MIN_LOCKUP_PERIOD() external pure returns (uint256); - function MAX_LOCKUP_PERIOD() external pure returns (uint256); - - function stake(uint256 _amount, uint256 _seconds) external; - function unstake(uint256 _amount) external; - function lock(uint256 _secondsIncrease) external; - - function acceptUpdate() external returns (IStakeManager _migrated); - function leave() external returns (bool _leaveAccepted); - - function totalStaked() external view returns (uint256 _totalStaked); - function getStakedBalance(address _vault) external view returns (uint256 _balance); - function potentialMP() external view returns (uint256 _potentialMP); - function totalMP() external view returns (uint256 _totalMP); - - function totalSupply() external view returns (uint256 _totalSupply); - function totalSupplyMinted() external view returns (uint256 _totalSupply); - function pendingReward() external view returns (uint256 _pendingReward); - - function calculateMP(uint256 _balance, uint256 _deltaTime) external pure returns (uint256); -} diff --git a/contracts/StakeVault.sol b/contracts/StakeVault.sol index f4603a1..b62b229 100644 --- a/contracts/StakeVault.sol +++ b/contracts/StakeVault.sol @@ -1,10 +1,11 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.18; +pragma solidity ^0.8.26; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { IStakeManager } from "./IStakeManager.sol"; +import { StakeManager } from "./StakeManager.sol"; /** * @title StakeVault @@ -20,18 +21,18 @@ contract StakeVault is Ownable { IStakeManager private stakeManager; - IERC20 public immutable stakedToken; + IERC20 public immutable STAKING_TOKEN; event Staked(address from, address to, uint256 _amount, uint256 time); - constructor(address _owner, IERC20 _stakedToken, IStakeManager _stakeManager) { + constructor(address _owner, IERC20 _STAKING_TOKEN, IStakeManager _stakeManager) { _transferOwnership(_owner); - stakedToken = _stakedToken; + STAKING_TOKEN = _STAKING_TOKEN; stakeManager = _stakeManager; } function stake(uint256 _amount, uint256 _time) external onlyOwner { - bool success = stakedToken.transferFrom(msg.sender, address(this), _amount); + bool success = STAKING_TOKEN.transferFrom(msg.sender, address(this), _amount); if (!success) { revert StakeVault__StakingFailed(); } @@ -46,15 +47,15 @@ contract StakeVault is Ownable { function unstake(uint256 _amount) external onlyOwner { stakeManager.unstake(_amount); - bool success = stakedToken.transfer(msg.sender, _amount); + bool success = STAKING_TOKEN.transfer(msg.sender, _amount); if (!success) { revert StakeVault__UnstakingFailed(); } } function leave() external onlyOwner { - if (stakeManager.leave()) { - stakedToken.transferFrom(address(this), msg.sender, stakedToken.balanceOf(address(this))); + if (StakeManager(stakeManager).leave()) { + STAKING_TOKEN.transferFrom(address(this), msg.sender, STAKING_TOKEN.balanceOf(address(this))); } } @@ -62,7 +63,7 @@ contract StakeVault is Ownable { * @notice Opt-in migration to a new IStakeManager contract. */ function acceptMigration() external onlyOwner { - IStakeManager migrated = stakeManager.acceptUpdate(); + IStakeManager migrated = StakeManager(stakeManager).acceptUpdate(); if (address(migrated) == address(0)) revert StakeVault__MigrationNotAvailable(); stakeManager = migrated; } diff --git a/contracts/VaultFactory.sol b/contracts/VaultFactory.sol index b165bad..f80880f 100644 --- a/contracts/VaultFactory.sol +++ b/contracts/VaultFactory.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.18; +pragma solidity ^0.8.26; import { Ownable2Step } from "@openzeppelin/contracts/access/Ownable2Step.sol"; import { StakeManager } from "./StakeManager.sol"; @@ -57,7 +57,7 @@ contract VaultFactory is Ownable2Step { /// @dev Anyone can call this function. /// @dev Emits a {VaultCreated} event. function createVault() external returns (StakeVault) { - StakeVault vault = new StakeVault(msg.sender, stakeManager.rewardToken(), stakeManager); + StakeVault vault = new StakeVault(msg.sender, stakeManager.REWARD_TOKEN(), stakeManager); emit VaultCreated(address(vault), msg.sender); return vault; } diff --git a/contracts/access/TrustedCodehashAccess.sol b/contracts/access/TrustedCodehashAccess.sol index 3d3c4f2..e5f5de6 100644 --- a/contracts/access/TrustedCodehashAccess.sol +++ b/contracts/access/TrustedCodehashAccess.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.18; +pragma solidity ^0.8.26; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; -import { ITrustedCodehashAccess } from "./ITrustedCodehashAccess.sol"; +import { ITrustedCodehashAccess } from "../interfaces/ITrustedCodehashAccess.sol"; /** * @title TrustedCodehashAccess diff --git a/contracts/factory/Create2FactoryLib.sol b/contracts/factory/Create2FactoryLib.sol new file mode 100644 index 0000000..4039364 --- /dev/null +++ b/contracts/factory/Create2FactoryLib.sol @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: CC0-1.0 + +pragma solidity ^0.8.26; + +/** + * @title Singleton Factory (EIP-2470) + * @notice Exposes CREATE2 (EIP-1014) to deploy bytecode on deterministic addresses based on initialization code and + * salt. + * @author Ricardo Guilherme Schmidt (Status Research & Development GmbH) + */ +library AddressLib { + error ERC2470__CREATE2Failed(); + error ERC2470__CREATE2BadCall(); + + function deploy(bytes memory _initCode, bytes32 _salt) internal returns (address payable createdContract) { + assembly { + createdContract := create2(callvalue(), add(_initCode, 0x20), mload(_initCode), _salt) + } + if (createdContract == address(0)) { + revert ERC2470__CREATE2Failed(); + } + } + + function computeAddress(bytes memory, bytes32 _salt) public view returns (address payable) { + return payable(hashToAddress(abi.encodePacked(bytes1(0xff), address(this), _salt, _initCode))); + } + + function computeAddress(address _deployer, bytes32 _salt, bytes memory _initCode) public pure returns (address) { + return hashToAddress(abi.encodePacked(bytes1(0xff), _deployer, _salt, _initCode)); + } + + function hashToAddress(bytes memory b) private pure returns (address addr) { + return address(uint160(uint256(keccak256(b)))); + } + + function addressToBytes(address a) internal pure returns (bytes memory) { + return abi.encodePacked(a); + } + + function bytesToAddress(bytes memory b) external pure returns (address addr) { + return abi.decode(b, (address)); + } +} diff --git a/contracts/factory/SingletonFactory.sol b/contracts/factory/SingletonFactory.sol index fc436ad..6882ef6 100644 --- a/contracts/factory/SingletonFactory.sol +++ b/contracts/factory/SingletonFactory.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: CC0-1.0 -pragma solidity ^0.8.18; +pragma solidity ^0.8.26; /** * @title Singleton Factory (EIP-2470) diff --git a/contracts/interfaces/IStakeManager.sol b/contracts/interfaces/IStakeManager.sol new file mode 100644 index 0000000..ac75683 --- /dev/null +++ b/contracts/interfaces/IStakeManager.sol @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.26; + +import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; +import { ITrustedCodehashAccess } from "./ITrustedCodehashAccess.sol"; + +interface IStakeManager is ITrustedCodehashAccess { + error StakeManager__FundsLocked(); + error StakeManager__InvalidLockTime(); + error StakeManager__InsufficientFunds(); + error StakeManager__StakeIsTooLow(); + + function stake(uint256 _amount, uint256 _seconds) external; + function lock(uint256 _seconds) external; + function unstake(uint256 _amount) external; + + function totalStaked() external view returns (uint256); + function totalMP() external view returns (uint256); + function totalMaxMP() external view returns (uint256); + function getStakedBalance(address _vault) external view returns (uint256 _balance); + + function STAKING_TOKEN() external view returns (IERC20); + function REWARD_TOKEN() external view returns (IERC20); + function MIN_LOCKUP_PERIOD() external view returns (uint256); + function MAX_LOCKUP_PERIOD() external view returns (uint256); + function MP_RATE_PER_YEAR() external view returns (uint256); + function MAX_MULTIPLIER() external view returns (uint256); +} diff --git a/contracts/access/ITrustedCodehashAccess.sol b/contracts/interfaces/ITrustedCodehashAccess.sol similarity index 97% rename from contracts/access/ITrustedCodehashAccess.sol rename to contracts/interfaces/ITrustedCodehashAccess.sol index 66ae6a5..303b002 100644 --- a/contracts/access/ITrustedCodehashAccess.sol +++ b/contracts/interfaces/ITrustedCodehashAccess.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.18; +pragma solidity ^0.8.26; /** * @title TrustedCodehashAccess diff --git a/contracts/storage/ExpiredStakeStorage.sol b/contracts/storage/ExpiredStakeStorage.sol index 656effa..a544ff4 100644 --- a/contracts/storage/ExpiredStakeStorage.sol +++ b/contracts/storage/ExpiredStakeStorage.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity ^0.8.18; +pragma solidity ^0.8.26; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; diff --git a/foundry.toml b/foundry.toml index ab51352..6caf35c 100644 --- a/foundry.toml +++ b/foundry.toml @@ -13,7 +13,7 @@ optimizer_runs = 10_000 out = "out" script = "script" - solc = "0.8.20" + solc = "0.8.26" src = "contracts" test = "test" diff --git a/script/Base.s.sol b/script/Base.s.sol index 2a106d7..ad9234c 100644 --- a/script/Base.s.sol +++ b/script/Base.s.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: MIT -pragma solidity >=0.8.19 <=0.9.0; +pragma solidity >=0.8.26 <=0.9.0; import { Script } from "forge-std/Script.sol"; diff --git a/script/Deploy.s.sol b/script/Deploy.s.sol index 5130227..15417e5 100644 --- a/script/Deploy.s.sol +++ b/script/Deploy.s.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.8.19 <=0.9.0; +pragma solidity >=0.8.26 <=0.9.0; import { BaseScript } from "./Base.s.sol"; import { DeploymentConfig } from "./DeploymentConfig.s.sol"; diff --git a/script/DeployMigrationStakeManager.s.sol b/script/DeployMigrationStakeManager.s.sol index 1b2dfd8..60b42bb 100644 --- a/script/DeployMigrationStakeManager.s.sol +++ b/script/DeployMigrationStakeManager.s.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.8.19 <=0.9.0; +pragma solidity >=0.8.26 <=0.9.0; import { BaseScript } from "./Base.s.sol"; import { StakeManager } from "../contracts/StakeManager.sol"; @@ -18,7 +18,7 @@ contract DeployMigrationStakeManager is BaseScript { function run() public returns (StakeManager) { prevStakeManager = vm.envOr({ name: "PREV_STAKE_MANAGER", defaultValue: prevStakeManager }); - stakeToken = vm.envOr({ name: "STAKE_TOKEN_ADDRESS", defaultValue: stakeToken }); + stakeToken = vm.envOr({ name: "STAKING_TOKEN_ADDRESS", defaultValue: stakeToken }); if (stakeToken == address(0)) { revert DeployMigrationStakeManager_InvalidStakeTokenAddress(); diff --git a/script/DeploymentConfig.s.sol b/script/DeploymentConfig.s.sol index 68a22f2..6012c1e 100644 --- a/script/DeploymentConfig.s.sol +++ b/script/DeploymentConfig.s.sol @@ -1,6 +1,6 @@ //// SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.8.19 <=0.9.0; +pragma solidity >=0.8.26 <=0.9.0; import { Script } from "forge-std/Script.sol"; import { MockERC20 } from "../test/mocks/MockERC20.sol"; diff --git a/test/DynamicTest.t.sol b/test/DynamicTest.t.sol index ed607e4..983ba45 100644 --- a/test/DynamicTest.t.sol +++ b/test/DynamicTest.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: CC0-1.0 -pragma solidity ^0.8.19; +pragma solidity ^0.8.26; import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; diff --git a/test/StakeManager.t.sol b/test/StakeManager.t.sol index b72fdc3..802406d 100644 --- a/test/StakeManager.t.sol +++ b/test/StakeManager.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.19; +pragma solidity ^0.8.26; import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; @@ -35,7 +35,7 @@ contract StakeManagerTest is Test { assertEq(stakeManager.pendingReward(), 0); assertEq(stakeManager.totalMP(), 0); assertEq(stakeManager.totalStaked(), 0); - assertEq(address(stakeManager.rewardToken()), stakeToken); + assertEq(address(stakeManager.REWARD_TOKEN()), stakeToken); assertEq(address(stakeManager.previousManager()), address(0)); assertEq(stakeManager.totalSupply(), 0); } @@ -770,7 +770,7 @@ contract MigrationStakeManagerTest is StakeManagerTest { assertEq(newStakeManager.pendingReward(), 0); assertEq(newStakeManager.totalMP(), 0); assertEq(newStakeManager.totalStaked(), 0); - assertEq(address(newStakeManager.rewardToken()), stakeToken); + assertEq(address(newStakeManager.REWARD_TOKEN()), stakeToken); assertEq(address(newStakeManager.previousManager()), address(stakeManager)); assertEq(newStakeManager.totalSupply(), 0); } diff --git a/test/StakeVault.t.sol b/test/StakeVault.t.sol index bd7841b..38270d5 100644 --- a/test/StakeVault.t.sol +++ b/test/StakeVault.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.19; +pragma solidity ^0.8.26; import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; @@ -42,7 +42,7 @@ contract StakedTokenTest is StakeVaultTest { } function testStakeToken() public { - assertEq(address(stakeVault.stakedToken()), stakeToken); + assertEq(address(stakeVault.STAKING_TOKEN()), stakeToken); } } diff --git a/test/VaultFactory.t.sol b/test/VaultFactory.t.sol index 2a0a333..48550d9 100644 --- a/test/VaultFactory.t.sol +++ b/test/VaultFactory.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.19; +pragma solidity ^0.8.26; import { Test } from "forge-std/Test.sol"; import { Deploy } from "../script/Deploy.s.sol"; @@ -18,14 +18,14 @@ contract VaultFactoryTest is Test { address internal deployer; - address internal stakedToken; + address internal STAKING_TOKEN; address internal testUser = makeAddr("testUser"); function setUp() public virtual { Deploy deployment = new Deploy(); (vaultFactory, stakeManager, deploymentConfig) = deployment.run(); - (deployer, stakedToken) = deploymentConfig.activeNetworkConfig(); + (deployer, STAKING_TOKEN) = deploymentConfig.activeNetworkConfig(); } function testDeployment() public { @@ -67,6 +67,6 @@ contract CreateVaultTest is VaultFactoryTest { emit VaultCreated(makeAddr("some address"), testUser); StakeVault vault = vaultFactory.createVault(); assertEq(vault.owner(), testUser); - assertEq(address(vault.stakedToken()), address(stakedToken)); + assertEq(address(vault.STAKING_TOKEN()), address(STAKING_TOKEN)); } } diff --git a/test/mocks/BrokenERC20.s.sol b/test/mocks/BrokenERC20.s.sol index 4b31604..6d11323 100644 --- a/test/mocks/BrokenERC20.s.sol +++ b/test/mocks/BrokenERC20.s.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.19; +pragma solidity ^0.8.26; import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; diff --git a/test/mocks/MockERC20.sol b/test/mocks/MockERC20.sol index dcff6c5..81927ee 100644 --- a/test/mocks/MockERC20.sol +++ b/test/mocks/MockERC20.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.19; +pragma solidity ^0.8.26; import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; diff --git a/test/script/DeployBroken.s.sol b/test/script/DeployBroken.s.sol index e2105e1..17b4b76 100644 --- a/test/script/DeployBroken.s.sol +++ b/test/script/DeployBroken.s.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.19; +pragma solidity ^0.8.26; import { BaseScript } from "../../script/Base.s.sol"; import { StakeManager } from "../../contracts/StakeManager.sol";