Skip to content

Commit d8d18e8

Browse files
authored
feat: delete claim transfer param on payment (#88)
1 parent 436c478 commit d8d18e8

16 files changed

Lines changed: 23 additions & 78 deletions

src/BullaClaimV2.sol

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ contract BullaClaimV2 is ERC721, Ownable, BoringBatchable, IBullaClaimV2 {
159159
if (params.token != address(0)) claim.token = params.token;
160160
if (controller != address(0)) claim.controller = controller;
161161
if (params.binding != ClaimBinding.Unbound) claim.binding = params.binding;
162-
if (params.payerReceivesClaimOnPayment) claim.payerReceivesClaimOnPayment = true;
163162
if (params.dueBy != 0) claim.dueBy = uint40(params.dueBy);
164163
if (params.impairmentGracePeriod != 0) claim.impairmentGracePeriod = uint40(params.impairmentGracePeriod);
165164
}
@@ -268,9 +267,6 @@ contract BullaClaimV2 is ERC721, Ownable, BoringBatchable, IBullaClaimV2 {
268267
claimStorage.status = claimPaid ? Status.Paid : Status.Repaying;
269268

270269
emit ClaimPayment(claimId, from, paymentAmount, totalPaidAmount);
271-
272-
// transfer the ownership of the claim NFT to the payee as a receipt of their completed payment
273-
if (claim.payerReceivesClaimOnPayment && claimPaid) _transfer(claim.creditor, from, claimId);
274270
}
275271

276272
/**
@@ -465,7 +461,6 @@ contract BullaClaimV2 is ERC721, Ownable, BoringBatchable, IBullaClaimV2 {
465461
paidAmount: uint256(claimStorage.paidAmount),
466462
status: claimStorage.status,
467463
binding: claimStorage.binding,
468-
payerReceivesClaimOnPayment: claimStorage.payerReceivesClaimOnPayment,
469464
debtor: claimStorage.debtor,
470465
creditor: _ownerOf(claimId),
471466
token: claimStorage.token,

src/BullaFrendLendV2.sol

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ contract BullaFrendLendV2 is BullaClaimControllerBase, BoringBatchable, ERC165,
128128
paidAmount: claim.paidAmount,
129129
status: claim.status,
130130
binding: claim.binding,
131-
payerReceivesClaimOnPayment: claim.payerReceivesClaimOnPayment,
132131
debtor: claim.debtor,
133132
creditor: claim.creditor,
134133
token: claim.token,
@@ -295,7 +294,6 @@ contract BullaFrendLendV2 is BullaClaimControllerBase, BoringBatchable, ERC165,
295294
description: offer.params.description,
296295
token: offer.params.token,
297296
binding: ClaimBinding.Bound, // Loans are bound claims, avoiding the 1 wei transfer used in V1
298-
payerReceivesClaimOnPayment: true,
299297
dueBy: block.timestamp + offer.params.termLength,
300298
impairmentGracePeriod: offer.params.impairmentGracePeriod
301299
});

src/BullaInvoice.sol

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ contract BullaInvoice is BullaClaimControllerBase, BoringBatchable, ERC165, IBul
8989
paidAmount: claim.paidAmount,
9090
status: claim.status,
9191
binding: claim.binding,
92-
payerReceivesClaimOnPayment: claim.payerReceivesClaimOnPayment,
9392
debtor: claim.debtor,
9493
creditor: claim.creditor,
9594
token: claim.token,
@@ -199,7 +198,6 @@ contract BullaInvoice is BullaClaimControllerBase, BoringBatchable, ERC165, IBul
199198
description: params.description,
200199
token: params.token,
201200
binding: params.binding,
202-
payerReceivesClaimOnPayment: params.payerReceivesClaimOnPayment,
203201
dueBy: params.dueBy,
204202
impairmentGracePeriod: params.impairmentGracePeriod
205203
});
@@ -286,7 +284,7 @@ contract BullaInvoice is BullaClaimControllerBase, BoringBatchable, ERC165, IBul
286284
revert PayingZero();
287285
}
288286

289-
// need to check this because calling bulla claim since it might transfer the claim to the creditor if `payerReceivesClaimOnPayment` is true
287+
// Store the creditor address before making the payment
290288
address creditor = _bullaClaim.ownerOf(claimId);
291289

292290
// Calculate protocol fee from interest only

src/interfaces/IBullaFrendLendV2.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ struct Loan {
3636
uint256 paidAmount;
3737
Status status;
3838
ClaimBinding binding;
39-
bool payerReceivesClaimOnPayment;
4039
address debtor;
4140
address creditor;
4241
address token;

src/interfaces/IBullaInvoice.sol

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ struct Invoice {
1414
address token;
1515
Status status;
1616
ClaimBinding binding;
17-
bool payerReceivesClaimOnPayment;
1817
PurchaseOrderState purchaseOrder;
1918
InterestConfig lateFeeConfig;
2019
InterestComputationState interestComputationState;
@@ -44,7 +43,6 @@ struct CreateInvoiceParams {
4443
string description;
4544
address token;
4645
ClaimBinding binding;
47-
bool payerReceivesClaimOnPayment;
4846
InterestConfig lateFeeConfig;
4947
uint256 impairmentGracePeriod;
5048
uint256 depositAmount;

src/types/Types.sol

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ struct CreateClaimParams {
4242
string description;
4343
address token;
4444
ClaimBinding binding;
45-
bool payerReceivesClaimOnPayment;
4645
uint256 dueBy;
4746
uint256 impairmentGracePeriod; // seconds after dueBy that claim cannot be impaired
4847
}
@@ -61,7 +60,6 @@ struct ClaimStorage {
6160
address controller;
6261
Status status;
6362
ClaimBinding binding; // the debtor can allow themselves to be bound to a claim, which makes a claim unrejectable
64-
bool payerReceivesClaimOnPayment; // an optional flag which allows the token to be transferred to the payer, acting as a "receipt NFT"
6563
uint40 dueBy; // when the claim is due (0 means no due date)
6664
uint40 impairmentGracePeriod; // seconds after dueBy that claim cannot be impaired
6765
} // takes 5 storage slots
@@ -79,7 +77,6 @@ struct Claim {
7977
address controller;
8078
Status status;
8179
ClaimBinding binding;
82-
bool payerReceivesClaimOnPayment;
8380
}
8481

8582
////// APPROVALS //////

test/foundry/BullaClaim/BatchFunctionality.t.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,10 @@ contract TestBatchFunctionality is BullaClaimTestHelper {
210210
assertEq(uint256(claim2.status), uint256(Status.Paid));
211211
assertEq(uint256(claim3.status), uint256(Status.Paid));
212212

213-
// Verify NFT ownership transferred to payer
214-
assertEq(bullaClaim.ownerOf(claimId1), debtor);
215-
assertEq(bullaClaim.ownerOf(claimId2), debtor);
216-
assertEq(bullaClaim.ownerOf(claimId3), debtor);
213+
// Verify NFT ownership remains with creditor
214+
assertEq(bullaClaim.ownerOf(claimId1), creditor);
215+
assertEq(bullaClaim.ownerOf(claimId2), creditor);
216+
assertEq(bullaClaim.ownerOf(claimId3), creditor);
217217
}
218218

219219
function testBatch_PayMultipleClaims_ETH() public {

test/foundry/BullaClaim/BullaClaimTestHelper.sol

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ contract BullaClaimTestHelper is Test {
2626
description: "",
2727
binding: ClaimBinding.Unbound,
2828
claimAmount: 1 ether,
29-
payerReceivesClaimOnPayment: true,
3029
dueBy: 0,
3130
impairmentGracePeriod: 0
3231
})
@@ -44,7 +43,6 @@ contract BullaClaimTestHelper is Test {
4443
description: "",
4544
binding: ClaimBinding.Unbound,
4645
claimAmount: 1 ether,
47-
payerReceivesClaimOnPayment: true,
4846
dueBy: 0,
4947
impairmentGracePeriod: 0
5048
})
@@ -64,7 +62,6 @@ contract BullaClaimTestHelper is Test {
6462
description: "",
6563
binding: ClaimBinding.Unbound,
6664
claimAmount: 1 ether,
67-
payerReceivesClaimOnPayment: true,
6865
dueBy: 0,
6966
impairmentGracePeriod: 0
7067
}),

test/foundry/BullaClaim/CreateClaim/CreateClaim.t.sol

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,7 @@ contract TestCreateClaim is BullaClaimTestHelper {
232232
address _debtor,
233233
uint128 claimAmount,
234234
address token,
235-
uint8 binding,
236-
bool payerReceivesClaimOnPayment
235+
uint8 binding
237236
) public {
238237
vm.assume(_creditor != address(0));
239238
vm.assume(claimAmount > 0);
@@ -249,7 +248,7 @@ contract TestCreateClaim is BullaClaimTestHelper {
249248
CreateClaimParams memory params = new CreateClaimParamsBuilder().withCreditor(_creditor).withDebtor(_debtor)
250249
.withClaimAmount(claimAmount).withToken(token).withDescription("test description").withBinding(
251250
ClaimBinding(binding)
252-
).withPayerReceivesClaimOnPayment(payerReceivesClaimOnPayment).build();
251+
).build();
253252

254253
vm.startPrank(creator);
255254
vm.expectEmit(true, true, true, true);
@@ -278,7 +277,7 @@ contract TestCreateClaim is BullaClaimTestHelper {
278277
assertTrue(claim.status == Status.Pending);
279278
assertEq(claim.claimAmount, claimAmount);
280279
assertEq(claim.debtor, _debtor);
281-
assertEq(claim.payerReceivesClaimOnPayment, payerReceivesClaimOnPayment);
280+
282281
assertTrue(claim.binding == ClaimBinding(binding));
283282
assertEq(claim.token, token);
284283
assertEq(bullaClaim.balanceOf(_creditor), creditorBalanceBefore + 1);

test/foundry/BullaClaim/CreateClaimParamsBuilder.sol

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ contract CreateClaimParamsBuilder {
1010
string private _description;
1111
address private _token;
1212
ClaimBinding private _binding;
13-
bool private _payerReceivesClaimOnPayment;
1413
uint256 private _dueBy;
1514
uint256 private _impairmentGracePeriod;
1615

@@ -22,7 +21,6 @@ contract CreateClaimParamsBuilder {
2221
_description = "Test Claim";
2322
_token = address(0); // ETH by default
2423
_binding = ClaimBinding.Unbound;
25-
_payerReceivesClaimOnPayment = true;
2624
_dueBy = 0; // No due date by default
2725
_impairmentGracePeriod = 7 days; // 7 days grace period by default
2826
}
@@ -57,11 +55,6 @@ contract CreateClaimParamsBuilder {
5755
return this;
5856
}
5957

60-
function withPayerReceivesClaimOnPayment(bool payerReceivesClaim) public returns (CreateClaimParamsBuilder) {
61-
_payerReceivesClaimOnPayment = payerReceivesClaim;
62-
return this;
63-
}
64-
6558
function withDueBy(uint256 dueBy) public returns (CreateClaimParamsBuilder) {
6659
_dueBy = dueBy;
6760
return this;
@@ -80,7 +73,6 @@ contract CreateClaimParamsBuilder {
8073
description: _description,
8174
token: _token,
8275
binding: _binding,
83-
payerReceivesClaimOnPayment: _payerReceivesClaimOnPayment,
8476
dueBy: _dueBy,
8577
impairmentGracePeriod: _impairmentGracePeriod
8678
});

0 commit comments

Comments
 (0)