Skip to content

Commit

Permalink
Fix slither issues
Browse files Browse the repository at this point in the history
  • Loading branch information
evercoinx committed Sep 13, 2024
1 parent efb8d1e commit 40557da
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ jobs:
- name: Check contracts with linter
run: npm run check

# - name: Analyze contracts with static analyzer
# run: npm run analyze:ci
- name: Analyze contracts with static analyzer
run: npm run analyze:ci

- name: Run unit tests
run: npm run test:ci
Expand Down
30 changes: 25 additions & 5 deletions contracts/MaticX.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,24 @@ contract MaticX is
__Pausable_init();
__ERC20_init("Liquid Staking Matic", "MaticX");

require(_manager != address(0), "Zero manager address");
_setupRole(DEFAULT_ADMIN_ROLE, _manager);

require(
_validatorRegistry != address(0),
"Zero validator registry address"
);
validatorRegistry = _validatorRegistry;

require(_stakeManager != address(0), "Zero stake manager address");
stakeManager = _stakeManager;

require(_treasury != address(0), "Zero treasury address");
treasury = _treasury;

require(_maticToken != address(0), "Zero matic token address");
maticToken = _maticToken;

feePercent = 5;

IERC20Upgradeable(maticToken).safeApprove(
Expand All @@ -89,6 +101,8 @@ contract MaticX is
onlyRole(DEFAULT_ADMIN_ROLE)
{
_setRoleAdmin(BOT, DEFAULT_ADMIN_ROLE);

emit SetupBotAdmin();
}

////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -361,7 +375,7 @@ contract MaticX is
*/
function withdrawRewards(
uint256 _validatorId
) public override whenNotPaused returns (uint256) {
) external override whenNotPaused returns (uint256) {
return _withdrawRewards(_validatorId, false);
}

Expand All @@ -371,7 +385,7 @@ contract MaticX is
*/
function withdrawValidatorsReward(
uint256[] calldata _validatorIds
) public override whenNotPaused returns (uint256[] memory) {
) external override whenNotPaused returns (uint256[] memory) {
uint256[] memory rewards = new uint256[](_validatorIds.length);
for (uint256 i = 0; i < _validatorIds.length; i++) {
rewards[i] = _withdrawRewards(_validatorIds[i], false);
Expand All @@ -385,7 +399,7 @@ contract MaticX is
*/
function withdrawValidatorsRewardPOL(
uint256[] calldata _validatorIds
) public override whenNotPaused returns (uint256[] memory) {
) external override whenNotPaused returns (uint256[] memory) {
uint256[] memory rewards = new uint256[](_validatorIds.length);
for (uint256 i = 0; i < _validatorIds.length; i++) {
rewards[i] = _withdrawRewards(_validatorIds[i], true);
Expand Down Expand Up @@ -720,7 +734,13 @@ contract MaticX is
polToken = _address;
emit SetPOLToken(_address);

IERC20Upgradeable(polToken).approve(stakeManager, type(uint256).max);
require(
IERC20Upgradeable(polToken).approve(
stakeManager,
type(uint256).max
),
"Unable to approve POL token on StakeManager"
);
}

////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -760,7 +780,7 @@ contract MaticX is
* This function is deprecated.
* @return Total pooled stake tokens
*/
function getTotalPooledMatic() public view override returns (uint256) {
function getTotalPooledMatic() external view override returns (uint256) {
return getTotalStakeAcrossAllValidators();
}

Expand Down
2 changes: 2 additions & 0 deletions contracts/interfaces/IMaticX.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ interface IMaticX is IERC20Upgradeable {
address validatorAddress;
}

event SetupBotAdmin();

event Submit(address indexed _from, uint256 _amount);

event Delegate(uint256 indexed _validatorId, uint256 _amountDelegated);
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"cover": "rimraf coverage && hardhat coverage",
"gas": "cross-env REPORT_GAS=true npm run test",
"size": "hardhat size-contracts",
"analyze": "slitherin . --slither",
"analyze:ci": "slitherin --separated . --skip-clean --ignore-compile",
"analyze": "slither .",
"analyze:ci": "slither . --skip-clean --ignore-compile",
"clean": "hardhat clean && rimraf coverage cache crytic-{corpus,export} mochaOutput.json testMatrix.json",
"node": "hardat node",
"deploy:main": "cross-env NODE_ENV=main hardhat run ./scripts/deploy.ts --network mainnet",
Expand Down
3 changes: 2 additions & 1 deletion slither.config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compile_force_framework": "hardhat",
"detectors_to_exclude": "pragma,solc-version",
"detectors_to_exclude": "calls-loop,constable-states,naming-convention,pragma,reentrancy-benign,reentrancy-events,reentrancy-no-eth,solc-version,unused-return",
"include_paths": "(MaticX.sol)",
"filter_paths": "(@openzeppelin/|lib/|mocks/|state-transfer/|tunnel/)"
}

0 comments on commit 40557da

Please sign in to comment.