code-423n4 / 2024-03-gitcoin-mitigation-findings

0 stars 0 forks source link

PR10 MitigationConfirmed #16

Open liveactionllama opened 7 months ago

liveactionllama commented 7 months ago

This adds convenience functions to handle multiple community stakes in 1 call: multipleCommunityStakes, extendMultipleCommunityStake and withdrawMultipleCommunityStake

Overall there is not much for review on this changes, we are implementing a simple function on top of an old which was previously audited.

  function multipleCommunityStakes(
    address[] calldata stakees,
    uint88[] calldata amounts,
    uint64[] calldata durations
  ) external whenNotPaused {
    if (stakees.length != amounts.length || stakees.length != durations.length) {
      revert ArrayLengthMismatch();
    }

    for (uint i = 0; i < stakees.length; i++) {
      _communityStake(stakees[i], amounts[i], durations[i]);
    }
  }
  function extendMultipleCommunityStakes(
    address[] calldata stakees,
    uint64[] calldata durations
  ) external whenNotPaused {
    if (stakees.length != durations.length) {
      revert ArrayLengthMismatch();
    }

    for (uint i = 0; i < stakees.length; i++) {
      _extendCommunityStake(stakees[i], durations[i]);
    }
  }
  function withdrawMultipleCommunityStakes(
    address[] calldata stakees,
    uint88[] calldata amounts
  ) external whenNotPaused {
    if (stakees.length != amounts.length) {
      revert ArrayLengthMismatch();
    }
    uint88 totalAmountToWithdraw = 0;

    for (uint i = 0; i < stakees.length; i++) {
      _prepareWithdrawCommunityStake(stakees[i], amounts[i]);

      totalAmountToWithdraw += amounts[i];
    }

    if (!token.transfer(msg.sender, totalAmountToWithdraw)) {
      revert FailedTransfer();
    }
  }

By looking at the code l can confirm by implementing this changes there is no issues occurring.

liveactionllama commented 7 months ago

Note: per discussion with the judge, sponsor, and participating wardens, the full scope for this competition was initially a bit unclear. As such, the participating wardens have all agreed to review items outside of the original active competition phase. Adding their work to this findings repo for further review by all parties.

c4-judge commented 7 months ago

GalloDaSballo marked the issue as satisfactory