Skip to content

Commit 6ab8e62

Browse files
committed
tweaks to keep code as close to existing as possible, update OfferCreated event to include maxDuration.
1 parent 049f3a7 commit 6ab8e62

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

src/EscrowSupplierNFT.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,16 @@ contract EscrowSupplierNFT is IEscrowSupplierNFT, BaseNFT {
201201
offerId = nextOfferId++;
202202
offers[offerId] = OfferStored({
203203
supplier: msg.sender,
204+
maxDuration: SafeCast.toUint32(maxDuration),
204205
gracePeriod: SafeCast.toUint32(gracePeriod),
205206
interestAPR: SafeCast.toUint24(interestAPR),
206207
lateFeeAPR: SafeCast.toUint24(lateFeeAPR),
207208
minEscrow: minEscrow,
208-
available: amount,
209-
maxDuration: maxDuration
209+
available: amount
210210
});
211211
asset.safeTransferFrom(msg.sender, address(this), amount);
212212
emit OfferCreated(
213-
msg.sender, interestAPR, gracePeriod, lateFeeAPR, amount, offerId, minEscrow
213+
msg.sender, interestAPR, maxDuration, gracePeriod, lateFeeAPR, amount, offerId, minEscrow
214214
);
215215
}
216216

@@ -443,7 +443,7 @@ contract EscrowSupplierNFT is IEscrowSupplierNFT, BaseNFT {
443443
// check params are supported
444444
require(configHub.isValidCollarDuration(duration), "escrow: unsupported duration");
445445

446-
(uint expectedFees,,) = _upfrontFees(offerId, escrowed, duration);
446+
(uint expectedFees,,) = upfrontFees(offerId, escrowed, duration);
447447
// we don't check equality to avoid revert due to minor inaccuracies to the upside,
448448
// even though exact value should be used from the view.
449449
// The overpayment is refunded when escrow is properly released (but not when seized).
@@ -461,13 +461,13 @@ contract EscrowSupplierNFT is IEscrowSupplierNFT, BaseNFT {
461461
escrows[escrowId] = EscrowStored({
462462
offerId: SafeCast.toUint64(offerId),
463463
loanId: SafeCast.toUint64(loanId),
464+
duration: SafeCast.toUint32(duration),
464465
expiration: SafeCast.toUint32(block.timestamp + duration),
465466
released: false, // unset until release
466467
loans: msg.sender,
467468
escrowed: escrowed,
468469
feesHeld: fees,
469-
withdrawable: 0, // unset until release
470-
duration: SafeCast.toUint32(duration)
470+
withdrawable: 0 // unset until release
471471
});
472472

473473
// emit before token transfer event in mint for easier indexing

src/interfaces/IEscrowSupplierNFT.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { ConfigHub } from "../ConfigHub.sol";
77
interface IEscrowSupplierNFT {
88
struct OfferStored {
99
// packed first slot
10-
uint maxDuration;
10+
uint32 maxDuration;
1111
uint32 gracePeriod;
1212
uint24 interestAPR; // allows up to 167,772%, must allow MAX_INTEREST_APR_BIPS
1313
uint24 lateFeeAPR; // allows up to 167,772%, must allow MAX_LATE_FEE_APR_BIPS
@@ -69,6 +69,7 @@ interface IEscrowSupplierNFT {
6969
event OfferCreated(
7070
address indexed supplier,
7171
uint indexed interestAPR,
72+
uint indexed maxDuration,
7273
uint gracePeriod,
7374
uint lateFeeAPR,
7475
uint available,

0 commit comments

Comments
 (0)