Skip to content

Commit

Permalink
Merge pull request #27 from GenerationSoftware/gen-1180-claimer-shoul…
Browse files Browse the repository at this point in the history
…d-validate-_timetoreachmaxfee

Gen 1180 claimer should validate  timetoreachmaxfee
  • Loading branch information
asselstine committed Mar 1, 2024
2 parents 9719308 + a544618 commit 499bef4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
14 changes: 10 additions & 4 deletions src/Claimer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,25 @@ import { IClaimable } from "pt-v5-claimable-interface/interfaces/IClaimable.sol"
/// @param prizeIndicesLength Length of the prize indices array
error ClaimArraySizeMismatch(uint256 winnersLength, uint256 prizeIndicesLength);

/// @notice Emitted when the minimum fee is greater than or equal to the max fee
/// @notice Thrown when the minimum fee is greater than or equal to the max fee
/// @param minFee The minimum fee passed
/// @param maxFee The maximum fee passed
error MinFeeGeMax(uint256 minFee, uint256 maxFee);

/// @notice Emitted when the VRGDA fee is below the minimum fee
/// @notice Thrown when the VRGDA fee is below the minimum fee
/// @param minFee The minimum fee requested by the user
/// @param fee The actual VRGDA fee
error VrgdaClaimFeeBelowMin(uint256 minFee, uint256 fee);

/// @notice Emitted when the prize pool is set the the zero address
/// @notice Thrown when the prize pool is set the the zero address
error PrizePoolZeroAddress();

/// @notice Emitted when someone tries to claim a prizes with a fee, but sets the fee recipient address to the zero address.
/// @notice Thrown when someone tries to claim a prizes with a fee, but sets the fee recipient address to the zero address.
error FeeRecipientZeroAddress();

/// @notice Thrown when the time to reach the max fee is zero
error TimeToReachMaxFeeZero();

/// @title Variable Rate Gradual Dutch Auction (VRGDA) Claimer
/// @author G9 Software Inc.
/// @notice This contract uses a variable rate gradual dutch auction to incentivize prize claims on behalf of others. Fees for each canary tier is set to the respective tier's prize size.
Expand Down Expand Up @@ -92,6 +95,9 @@ contract Claimer {
if (_minimumFee >= _maximumFee) {
revert MinFeeGeMax(_minimumFee, _maximumFee);
}
if (_timeToReachMaxFee == 0) {
revert TimeToReachMaxFeeZero();
}
prizePool = _prizePool;
maxFeePortionOfPrize = _maxFeePortionOfPrize;
decayConstant = LinearVRGDALib.getDecayConstant(
Expand Down
20 changes: 19 additions & 1 deletion test/Claimer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ pragma solidity >=0.8.19;

import "forge-std/Test.sol";

import { Claimer, MinFeeGeMax, VrgdaClaimFeeBelowMin, PrizePoolZeroAddress, FeeRecipientZeroAddress } from "../src/Claimer.sol";
import {
Claimer,
MinFeeGeMax,
VrgdaClaimFeeBelowMin,
PrizePoolZeroAddress,
FeeRecipientZeroAddress,
TimeToReachMaxFeeZero
} from "../src/Claimer.sol";
import { UD2x18, ud2x18 } from "prb-math/UD2x18.sol";
import { SD59x18 } from "prb-math/SD59x18.sol";

Expand Down Expand Up @@ -82,6 +89,17 @@ contract ClaimerTest is Test {
assertEq(claimer.decayConstant().unwrap(), decayConstant.unwrap());
}

function testConstructor_TimeToReachMaxFeeZero() public {
vm.expectRevert(abi.encodeWithSelector(TimeToReachMaxFeeZero.selector));
new Claimer(
prizePool, // zero address
MINIMUM_FEE,
MAXIMUM_FEE,
0,
ud2x18(MAX_FEE_PERCENTAGE_OF_PRIZE)
);
}

function testConstructor_PrizePoolZeroAddress() public {
vm.expectRevert(abi.encodeWithSelector(PrizePoolZeroAddress.selector));
new Claimer(
Expand Down

0 comments on commit 499bef4

Please sign in to comment.