@@ -74,6 +74,35 @@ contract OriumSftMarketplace is Initializable, OwnableUpgradeable, PausableUpgra
74
74
bytes [] rolesData
75
75
);
76
76
77
+ /**
78
+ * @param nonce The nonce of the rental offer
79
+ * @param tokenAddress The address of the contract of the SFT to rent
80
+ * @param tokenId The tokenId of the SFT to rent
81
+ * @param tokenAmount The amount of SFT to rent
82
+ * @param commitmentId The commitmentId of the SFT to rent
83
+ * @param lender The address of the user lending the SFT
84
+ * @param borrower The address of the user renting the SFT
85
+ * @param feeTokenAddress The address of the ERC20 token for rental fees
86
+ * @param feeAmountPerSecond The amount of fee per second
87
+ * @param deadline The deadline until when the rental offer is valid
88
+ * @param roles The array of roles to be assigned to the borrower
89
+ * @param rolesData The array of data for each role
90
+ */
91
+ event RentalOfferCreated (
92
+ uint256 indexed nonce ,
93
+ address indexed tokenAddress ,
94
+ uint256 indexed tokenId ,
95
+ uint256 tokenAmount ,
96
+ uint256 commitmentId ,
97
+ address lender ,
98
+ address borrower ,
99
+ address feeTokenAddress ,
100
+ uint256 feeAmountPerSecond ,
101
+ uint256 deadline ,
102
+ bytes32 [] roles ,
103
+ bytes [] rolesData
104
+ );
105
+
77
106
/**
78
107
* @param lender The address of the lender
79
108
* @param nonce The nonce of the rental offer
@@ -132,17 +161,48 @@ contract OriumSftMarketplace is Initializable, OwnableUpgradeable, PausableUpgra
132
161
feeTokenAddress: _offer.feeTokenAddress,
133
162
feeAmountPerSecond: _offer.feeAmountPerSecond,
134
163
deadline: _offer.deadline,
135
- minDuration: 1 ,
164
+ minDuration: 0 ,
136
165
roles: _offer.roles,
137
166
rolesData: _offer.rolesData
138
167
});
139
- _createRentalOffer (_parsedOffer);
168
+ uint256 _commitmentId = _createRentalOffer (_parsedOffer);
169
+
170
+ emit RentalOfferCreated (
171
+ _offer.nonce,
172
+ _offer.tokenAddress,
173
+ _offer.tokenId,
174
+ _offer.tokenAmount,
175
+ _commitmentId,
176
+ _offer.lender,
177
+ _offer.borrower,
178
+ _offer.feeTokenAddress,
179
+ _offer.feeAmountPerSecond,
180
+ _offer.deadline,
181
+ _offer.roles,
182
+ _offer.rolesData
183
+ );
140
184
}
141
185
142
186
function createRentalOffer (RentalOffer calldata _offer ) external whenNotPaused {
143
- _createRentalOffer (_offer);
187
+ uint256 _commitmentId = _createRentalOffer (_offer);
188
+
189
+ emit RentalOfferCreated (
190
+ _offer.nonce,
191
+ _offer.tokenAddress,
192
+ _offer.tokenId,
193
+ _offer.tokenAmount,
194
+ _commitmentId,
195
+ _offer.lender,
196
+ _offer.borrower,
197
+ _offer.feeTokenAddress,
198
+ _offer.feeAmountPerSecond,
199
+ _offer.deadline,
200
+ _offer.minDuration,
201
+ _offer.roles,
202
+ _offer.rolesData
203
+ );
144
204
}
145
- function _createRentalOffer (RentalOffer memory _offer ) internal {
205
+ function _createRentalOffer (RentalOffer memory _offer ) internal returns ( uint256 ) {
146
206
address _rolesRegistryAddress = IOriumMarketplaceRoyalties (oriumMarketplaceRoyalties).sftRolesRegistryOf (
147
207
_offer.tokenAddress
148
208
);
@@ -161,21 +221,7 @@ contract OriumSftMarketplace is Initializable, OwnableUpgradeable, PausableUpgra
161
221
isCreated[LibOriumSftMarketplace.hashRentalOffer (_offer)] = true ;
162
222
commitmentIdToNonce[_rolesRegistryAddress][_offer.commitmentId] = _offer.nonce;
163
223
164
- emit RentalOfferCreated (
165
- _offer.nonce,
166
- _offer.tokenAddress,
167
- _offer.tokenId,
168
- _offer.tokenAmount,
169
- _offer.commitmentId,
170
- _offer.lender,
171
- _offer.borrower,
172
- _offer.feeTokenAddress,
173
- _offer.feeAmountPerSecond,
174
- _offer.deadline,
175
- _offer.minDuration,
176
- _offer.roles,
177
- _offer.rolesData
178
- );
224
+ return _offer.commitmentId;
179
225
}
180
226
181
227
/**
@@ -208,10 +254,11 @@ contract OriumSftMarketplace is Initializable, OwnableUpgradeable, PausableUpgra
208
254
_acceptRentalOffer (_parsedOffer, _duration);
209
255
}
210
256
function _acceptRentalOffer (RentalOffer memory _offer , uint64 _duration ) internal {
211
- bytes32 _offerHash = LibOriumSftMarketplace.hashRentalOfferLegacy (_offer);
257
+ bytes32 _offerHash = LibOriumSftMarketplace.hashRentalOffer (_offer);
212
258
uint64 _expirationDate = uint64 (block .timestamp + _duration);
213
- LibOriumSftMarketplace.validateAcceptRentalOffer (
214
- _offer,
259
+ LibOriumSftMarketplace.validateAcceptRentalOffer (
260
+ _offer.borrower,
261
+ _offer.minDuration,
215
262
isCreated[_offerHash],
216
263
rentals[_offerHash].expirationDate,
217
264
_duration,
@@ -267,7 +314,7 @@ contract OriumSftMarketplace is Initializable, OwnableUpgradeable, PausableUpgra
267
314
_cancelRentalOffer (_parsedOffer);
268
315
}
269
316
function _cancelRentalOffer (RentalOffer memory _offer ) internal {
270
- bytes32 _offerHash = LibOriumSftMarketplace.hashRentalOfferLegacy (_offer);
317
+ bytes32 _offerHash = LibOriumSftMarketplace.hashRentalOffer (_offer);
271
318
require (isCreated[_offerHash], "OriumSftMarketplace: Offer not created " );
272
319
require (msg .sender == _offer.lender, "OriumSftMarketplace: Only lender can cancel a rental offer " );
273
320
require (
@@ -320,7 +367,7 @@ contract OriumSftMarketplace is Initializable, OwnableUpgradeable, PausableUpgra
320
367
}
321
368
322
369
function _endRental (RentalOffer memory _offer ) internal {
323
- bytes32 _offerHash = LibOriumSftMarketplace.hashRentalOfferLegacy (_offer);
370
+ bytes32 _offerHash = LibOriumSftMarketplace.hashRentalOffer (_offer);
324
371
325
372
require (isCreated[_offerHash], "OriumSftMarketplace: Offer not created " );
326
373
require (msg .sender == rentals[_offerHash].borrower, "OriumSftMarketplace: Only borrower can end a rental " );
0 commit comments