Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
asselstine committed Feb 29, 2024
1 parent 880bb94 commit 364b4c5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ In PoolTogether V5 prizes are awarded every "Draw". When a user wins a prize a t
- Prizes come from the Prize Pool.
- All depositors in Vaults that have contributed yield through a Liquidator recently are elgigible to win a prize.

Anyone may capture fees by claiming prizes through the Claimer contract. The claimer contract will price fees according to a VRGDA algorithm. The fees for the two canary tiers are always set to the prize size; meaning that the claimers can capture the whole prize.

## Development

### Installation
Expand Down
7 changes: 6 additions & 1 deletion src/Claimer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ error FeeRecipientZeroAddress();

/// @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
/// @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.
contract Claimer {

/// @notice Emitted when a prize has already been claimed
/// @param winner The winner of the prize
/// @param tier The prize tier
Expand Down Expand Up @@ -219,6 +220,10 @@ contract Claimer {
return _computeFeePerClaim(_tier, _claimCount, _claimedCount) * _claimCount;
}

/// @notice Computes the fee per claim for the given tier and number of claims
/// @param _tier The tier to claim prizes from
/// @param _claimCount The number of claims
/// @return The fee that will be taken per claim
function computeFeePerClaim(uint8 _tier, uint256 _claimCount) external view returns (uint256) {
return _computeFeePerClaim(_tier, _claimCount, prizePool.claimCount());
}
Expand Down
11 changes: 11 additions & 0 deletions test/Claimer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,17 @@ contract ClaimerTest is Test {
assertEq(claimer.computeTotalFees(1, 2, 10), 169295709060728);
}

function testComputeTotalFees_canary() public {
mockIsCanaryTier(1, true);
mockGetTierPrizeSize(1, 100e18);
vm.mockCall(
address(prizePool),
abi.encodeWithSelector(prizePool.claimCount.selector),
abi.encode(0)
);
assertEq(claimer.computeTotalFees(1, 1), 100e18);
}

function testComputeMaxFee_normalPrizes() public {
mockGetTierPrizeSize(0, 10e18);
mockGetTierPrizeSize(1, SMALLEST_PRIZE_SIZE);
Expand Down

0 comments on commit 364b4c5

Please sign in to comment.