@@ -9,12 +9,9 @@ pragma solidity 0.8.24;
9
9
10
10
import {IArbitrableV2, IArbitratorV2} from "./interfaces/IArbitrableV2.sol " ;
11
11
import "./interfaces/IDisputeTemplateRegistry.sol " ;
12
- import "../libraries/CappedMath.sol " ;
13
12
14
13
/// @title KlerosGovernor for V2. Note that appeal functionality and evidence submission will be handled by the court.
15
14
contract KlerosGovernor is IArbitrableV2 {
16
- using CappedMath for uint256 ;
17
-
18
15
// ************************************* //
19
16
// * Enums / Structs * //
20
17
// ************************************* //
@@ -74,16 +71,13 @@ contract KlerosGovernor is IArbitrableV2 {
74
71
75
72
modifier duringSubmissionPeriod () {
76
73
uint256 offset = sessions[sessions.length - 1 ].durationOffset;
77
- require (block .timestamp - lastApprovalTime <= submissionTimeout. addCap ( offset) , "Submission time has ended. " );
74
+ require (block .timestamp - lastApprovalTime <= submissionTimeout + offset, "Submission time has ended. " );
78
75
_;
79
76
}
80
77
81
78
modifier duringApprovalPeriod () {
82
79
uint256 offset = sessions[sessions.length - 1 ].durationOffset;
83
- require (
84
- block .timestamp - lastApprovalTime > submissionTimeout.addCap (offset),
85
- "Approval time not started yet. "
86
- );
80
+ require (block .timestamp - lastApprovalTime > submissionTimeout + offset, "Approval time not started yet. " );
87
81
_;
88
82
}
89
83
@@ -248,7 +242,7 @@ contract KlerosGovernor is IArbitrableV2 {
248
242
submission.submissionTime = block .timestamp ;
249
243
session.sumDeposit += submission.deposit;
250
244
session.submittedLists.push (submissions.length - 1 );
251
- if (session.submittedLists.length == 1 ) session.durationOffset = block .timestamp . subCap ( lastApprovalTime) ;
245
+ if (session.submittedLists.length == 1 ) session.durationOffset = block .timestamp - lastApprovalTime;
252
246
253
247
emit ListSubmitted (submissions.length - 1 , msg .sender , sessions.length - 1 , _description);
254
248
@@ -273,10 +267,10 @@ contract KlerosGovernor is IArbitrableV2 {
273
267
session.submittedLists[_submissionID] = session.submittedLists[session.submittedLists.length - 1 ];
274
268
session.alreadySubmitted[_listHash] = false ;
275
269
session.submittedLists.pop ();
276
- session.sumDeposit = session.sumDeposit. subCap ( submission.deposit) ;
270
+ session.sumDeposit = session.sumDeposit - submission.deposit;
277
271
payable (msg .sender ).transfer (submission.deposit);
278
272
279
- reservedETH = reservedETH. subCap ( submission.deposit) ;
273
+ reservedETH = reservedETH - submission.deposit;
280
274
}
281
275
282
276
/// @dev Approves a transaction list or creates a dispute if more than one list was submitted.
@@ -299,17 +293,17 @@ contract KlerosGovernor is IArbitrableV2 {
299
293
session.status = Status.Resolved;
300
294
sessions.push ();
301
295
302
- reservedETH = reservedETH. subCap ( sumDeposit) ;
296
+ reservedETH = reservedETH - sumDeposit;
303
297
} else {
304
298
session.status = Status.DisputeCreated;
305
299
uint256 arbitrationCost = arbitrator.arbitrationCost (arbitratorExtraData);
306
300
session.disputeID = arbitrator.createDispute {value: arbitrationCost}(
307
301
session.submittedLists.length ,
308
302
arbitratorExtraData
309
303
);
310
- session.sumDeposit = session.sumDeposit. subCap (arbitrationCost);
311
-
312
- reservedETH = reservedETH. subCap ( arbitrationCost) ;
304
+ // Check in case arbitration cost increased after the submission. It's unlikely that its increase won't be covered by the base deposit, but technically possible.
305
+ session.sumDeposit = session.sumDeposit > arbitrationCost ? session.sumDeposit - arbitrationCost : 0 ;
306
+ reservedETH = reservedETH > arbitrationCost ? reservedETH - arbitrationCost : 0 ;
313
307
emit DisputeRequest (arbitrator, session.disputeID, sessions.length - 1 , templateId, "" );
314
308
}
315
309
}
@@ -331,7 +325,7 @@ contract KlerosGovernor is IArbitrableV2 {
331
325
submission.submitter.send (session.sumDeposit);
332
326
}
333
327
// If the ruling is "0" the reserved funds of this session become expendable.
334
- reservedETH = reservedETH. subCap ( session.sumDeposit) ;
328
+ reservedETH = reservedETH - session.sumDeposit;
335
329
336
330
session.sumDeposit = 0 ;
337
331
lastApprovalTime = block .timestamp ;
@@ -370,7 +364,7 @@ contract KlerosGovernor is IArbitrableV2 {
370
364
/// @dev Gets the sum of contract funds that are used for the execution of transactions.
371
365
/// @return Contract balance without reserved ETH.
372
366
function getExpendableFunds () public view returns (uint256 ) {
373
- return address (this ).balance. subCap ( reservedETH) ;
367
+ return address (this ).balance - reservedETH;
374
368
}
375
369
376
370
/// @dev Gets the info of the specific transaction in the specific list.
0 commit comments