Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libraries/BullaClaimValidationLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ library BullaClaimValidationLib {

// Validate grace period requirements
if (claim.dueBy == 0) revert NoDueBy();
if (block.timestamp < claim.dueBy + claim.impairmentGracePeriod) revert StillInGracePeriod();
if (block.timestamp <= claim.dueBy + claim.impairmentGracePeriod) revert StillInGracePeriod();
}

/// @notice Validates mark as paid parameters
Expand Down
32 changes: 32 additions & 0 deletions test/foundry/BullaClaim/ImpairClaim.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -590,4 +590,36 @@ contract TestImpairClaim is BullaClaimTestHelper {
Claim memory claim = bullaClaim.getClaim(claimId);
assertEq(uint256(claim.status), uint256(Status.Impaired), "Claim should be impaired");
}

function testCannotImpairClaim_ExactlyAtGracePeriodEnd() public {
// Create claim with due date and grace period
uint256 dueBy = block.timestamp + 30 days;
uint256 gracePeriod = 7 days;

CreateClaimParams memory params = new CreateClaimParamsBuilder().withCreditor(creditor).withDebtor(debtor)
.withToken(address(weth)).withDueBy(dueBy).withImpairmentGracePeriod(gracePeriod).build();

vm.prank(creditor);
uint256 claimId = bullaClaim.createClaim(params);

// Move to exactly dueBy + gracePeriod (still within grace period)
vm.warp(dueBy + gracePeriod);

// Should still revert with StillInGracePeriod at the exact boundary
vm.prank(creditor);
vm.expectRevert(abi.encodeWithSelector(BullaClaimValidationLib.StillInGracePeriod.selector));
bullaClaim.impairClaim(claimId);

// Move 1 second past the grace period - now impairment should succeed
vm.warp(dueBy + gracePeriod + 1);

vm.expectEmit(true, true, false, true);
emit ClaimImpaired(claimId);

vm.prank(creditor);
bullaClaim.impairClaim(claimId);

Claim memory claim = bullaClaim.getClaim(claimId);
assertEq(uint256(claim.status), uint256(Status.Impaired), "Claim should be impaired after grace period");
}
}