Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove already claimed check to match prize pool changes #28

Merged
merged 2 commits into from Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitmodules
Expand Up @@ -16,8 +16,8 @@
[submodule "lib/pt-v5-claimable-interface"]
path = lib/pt-v5-claimable-interface
url = https://github.com/GenerationSoftware/pt-v5-claimable-interface
branch = prod-deploy-2
branch = main
[submodule "lib/pt-v5-prize-pool"]
path = lib/pt-v5-prize-pool
url = https://github.com/GenerationSoftware/pt-v5-prize-pool
branch = prod-deploy-2
branch = main
2 changes: 1 addition & 1 deletion lib/prb-math
Submodule prb-math updated 42 files
+0 −9 .github/ISSUE_TEMPLATE/1-bug-report.yml
+27 −3 .github/workflows/ci.yml
+0 −8 .gitmodules
+22 −0 CHANGELOG.md
+16 −20 README.md
+0 −1 foundry.toml
+0 −1 lib/forge-std
+0 −1 lib/prb-test
+6 −6 package.json
+314 −37 pnpm-lock.yaml
+2 −2 remappings.txt
+1 −1 src/Common.sol
+1 −1 src/sd59x18/Errors.sol
+0 −5 src/test/Assertions.sol
+0 −5 src/test/Utils.sol
+0 −1 src/ud2x18/Casting.sol
+1 −1 src/ud60x18/Math.sol
+2 −9 test/Base.t.sol
+0 −1 test/fuzz/sd1x18/casting/Casting.t.sol
+0 −2 test/fuzz/sd59x18/casting/Casting.t.sol
+0 −3 test/fuzz/sd59x18/helpers/Helpers.t.sol
+1 −2 test/fuzz/ud60x18/helpers/Helpers.t.sol
+2 −3 test/unit/sd59x18/SD59x18.t.sol
+0 −1 test/unit/sd59x18/conversion/convert-from/convertFrom.t.sol
+1 −1 test/unit/sd59x18/math/div/div.t.sol
+0 −1 test/unit/sd59x18/math/frac/frac.t.sol
+2 −2 test/unit/sd59x18/math/inv/inv.t.sol
+0 −2 test/unit/sd59x18/math/mul/mul.t.sol
+0 −1 test/unit/sd59x18/math/pow/pow.t.sol
+1 −1 test/unit/sd59x18/math/sqrt/sqrt.t.sol
+2 −3 test/unit/ud60x18/UD60x18.t.sol
+0 −1 test/unit/ud60x18/conversion/convert-from/convertFrom.t.sol
+1 −1 test/unit/ud60x18/math/div/div.t.sol
+1 −1 test/unit/ud60x18/math/gm/gm.t.sol
+1 −1 test/unit/ud60x18/math/inv/inv.t.sol
+0 −2 test/unit/ud60x18/math/ln/ln.t.sol
+0 −2 test/unit/ud60x18/math/log10/log10.t.sol
+0 −2 test/unit/ud60x18/math/log2/log2.t.sol
+0 −2 test/unit/ud60x18/math/mul/mul.t.sol
+0 −1 test/unit/ud60x18/math/pow/pow.t.sol
+1 −1 test/utils/Assertions.sol
+65 −65 test/utils/Utils.sol
2 changes: 1 addition & 1 deletion lib/pt-v5-claimable-interface
14 changes: 2 additions & 12 deletions src/Claimer.sol
Expand Up @@ -39,12 +39,6 @@ error TimeToReachMaxFeeZero();
/// @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
/// @param prizeIndex The prize index
event AlreadyClaimed(address winner, uint8 tier, uint32 prizeIndex);

/// @notice Emitted when a claim reverts
/// @param vault The vault for which the claim failed
/// @param tier The tier for which the claim failed
Expand Down Expand Up @@ -190,12 +184,8 @@ contract Claimer {
for (uint256 p = 0; p < prizeIndicesLength; p++) {
try
_vault.claimPrize(_winners[w], _tier, _prizeIndices[w][p], _feePerClaim, _feeRecipient)
returns (uint256 prizeSize) {
if (0 != prizeSize) {
actualClaimCount++;
} else {
emit AlreadyClaimed(_winners[w], _tier, _prizeIndices[w][p]);
}
returns (uint256 /* prizeSize */) {
actualClaimCount++;
} catch (bytes memory reason) {
emit ClaimError(_vault, _tier, _winners[w], _prizeIndices[w][p], reason);
}
Expand Down
23 changes: 16 additions & 7 deletions test/Claimer.t.sol
Expand Up @@ -14,16 +14,14 @@ import {
import { UD2x18, ud2x18 } from "prb-math/UD2x18.sol";
import { SD59x18 } from "prb-math/SD59x18.sol";

import { PrizePool } from "pt-v5-prize-pool/PrizePool.sol";
import { PrizePool, AlreadyClaimed } from "pt-v5-prize-pool/PrizePool.sol";
import { IClaimable } from "pt-v5-claimable-interface/interfaces/IClaimable.sol";
import { LinearVRGDALib } from "../src/libraries/LinearVRGDALib.sol";

// Custom Errors
error ClaimArraySizeMismatch(uint256 winnersLength, uint256 prizeIndicesLength);

contract ClaimerTest is Test {
event AlreadyClaimed(address winner, uint8 tier, uint32 prizeIndex);

event ClaimError(
IClaimable indexed vault,
uint8 indexed tier,
Expand Down Expand Up @@ -209,14 +207,25 @@ contract ClaimerTest is Test {
assertEq(claimer.claimPrizes(vault, 1, winners, prizeIndices, address(this), 100e18), 0);
}

function testClaimPrizes_alreadyClaimed() public {
function testClaimPrizes_alreadyClaimedError() public {
address[] memory winners = newWinners(winner1);
uint32[][] memory prizeIndices = newPrizeIndices(1, 1);
mockPrizePool(1, -100, 0);
mockClaimPrize(1, winner1, 0, uint96(UNSOLD_100_SECONDS_IN_FEE), address(this), 0);
vm.mockCallRevert(
address(vault),
abi.encodeWithSelector(
vault.claimPrize.selector,
winner1,
1,
0,
uint96(UNSOLD_100_SECONDS_IN_FEE),
address(this)
),
abi.encodeWithSelector(AlreadyClaimed.selector, address(vault), winner1, 1, 0)
);
vm.expectEmit(true, true, true, true);
emit AlreadyClaimed(winner1, 1, 0);
assertEq(claimer.claimPrizes(vault, 1, winners, prizeIndices, address(this), 0), 0);
emit ClaimError(vault, 1, winner1, 0, abi.encodeWithSelector(AlreadyClaimed.selector, address(vault), winner1, 1, 0));
claimer.claimPrizes(vault, 1, winners, prizeIndices, address(this), 0);
}

function testClaimPrizes_maxFee() public {
Expand Down