You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: contracts/src/arbitration/CentralizedArbitrator.sol
+28-45
Original file line number
Diff line number
Diff line change
@@ -5,10 +5,8 @@ pragma solidity ^0.8;
5
5
import"./IArbitrator.sol";
6
6
7
7
/** @title Centralized Arbitrator
8
-
* @dev This is a centralized arbitrator deciding alone on the result of disputes. It illustrates how the appeals can be handled on the arbitrator level.
9
-
* In this particular contract the rulings can be appealed by crowdfunding a desired choice.
10
-
* Note that normally the arbitrator should use a Dispute Kit contract which will define the algorithm for appeals/withdrawals.
11
-
* However to avoid complexity the code of the Dispute Kit is inlined within this contract.
8
+
* @dev This is a centralized arbitrator deciding alone on the result of disputes. It illustrates how IArbitrator interface can be implemented.
9
+
* Note that this contract supports appeals. The ruling given by the arbitrator can be appealed by crowdfunding a desired choice.
12
10
*/
13
11
contractCentralizedArbitratorisIArbitrator {
14
12
/* Constants */
@@ -19,6 +17,14 @@ contract CentralizedArbitrator is IArbitrator {
19
17
uint256public constant LOSER_APPEAL_PERIOD_MULTIPLIER =5000; // Multiplier of the appeal period for the choice that wasn't voted for in the previous round, in basis points. Default is 1/2 of original appeal period.
20
18
uint256public constant MULTIPLIER_DIVISOR =10000;
21
19
20
+
/* Enums */
21
+
22
+
enum DisputeStatus {
23
+
Waiting, // The dispute is waiting for the ruling or not created.
24
+
Appealable, // The dispute can be appealed.
25
+
Solved // The dispute is resolved.
26
+
}
27
+
22
28
/* Structs */
23
29
24
30
struct DisputeStruct {
@@ -44,7 +50,7 @@ contract CentralizedArbitrator is IArbitrator {
44
50
addresspublic owner =msg.sender; // Owner of the contract.
45
51
uint256public appealDuration; // The duration of the appeal period.
46
52
47
-
uint256private arbitrationFee; // The cost to create a dispute. Made private because of the arbitrationCost() getter.
53
+
uint256private arbitrationFee; // The cost to create a dispute. Made private because of the cost() getter.
48
54
uint256public appealFee; // The cost to fund one of the choices, not counting the additional fee stake amount.
49
55
50
56
DisputeStruct[] public disputes; // Stores the dispute info. disputes[disputeID].
@@ -149,7 +155,7 @@ contract CentralizedArbitrator is IArbitrator {
149
155
}
150
156
151
157
/** @dev Create a dispute. Must be called by the arbitrable contract.
152
-
* Must be paid at least arbitrationCost().
158
+
* Must be paid at least cost().
153
159
* @param _choices Amount of choices the arbitrator can make in this dispute.
154
160
* @param _extraData Can be used to give additional info on the dispute to be created.
155
161
* @return disputeID ID of the dispute created.
@@ -160,8 +166,8 @@ contract CentralizedArbitrator is IArbitrator {
@@ -248,7 +251,7 @@ contract CentralizedArbitrator is IArbitrator {
248
251
/** @dev Give a ruling to a dispute. Once it's given the dispute can be appealed, and after the appeal period has passed this function should be called again to finalize the ruling.
249
252
* Accounts for the situation where the winner loses a case due to paying less appeal fees than expected.
250
253
* @param _disputeID ID of the dispute to rule.
251
-
* @param _ruling Ruling given by the arbitrator. Note that 0 means "Not able/wanting to make a decision".
254
+
* @param _ruling Ruling given by the arbitrator. Note that 0 means that arbitrator chose "Refused to rule".
252
255
*/
253
256
function giveRuling(uint256_disputeID, uint256_ruling) external onlyOwner {
Copy file name to clipboardExpand all lines: contracts/src/arbitration/IArbitrator.sol
+4-24
Original file line number
Diff line number
Diff line change
@@ -6,20 +6,14 @@ import "./IArbitrable.sol";
6
6
7
7
/**
8
8
* @title Arbitrator
9
-
* Arbitrator interface for CourtV2.
9
+
* Arbitrator interface that implements the new arbitration standard.
10
10
* Unlike the ERC-792 this standard doesn't have anything related to appeals, so each arbitrator can implement an appeal system that suits it the most.
11
11
* When developing arbitrator contracts we need to:
12
12
* - Define the functions for dispute creation (createDispute). Don't forget to store the arbitrated contract and the disputeID (which should be unique, may nbDisputes).
13
-
* - Define the functions for cost display (arbitrationCost).
13
+
* - Define the functions for cost display (cost).
14
14
* - Allow giving rulings. For this a function must call arbitrable.rule(disputeID, ruling).
15
15
*/
16
16
interfaceIArbitrator {
17
-
enum DisputeStatus {
18
-
Waiting,
19
-
Appealable,
20
-
Solved
21
-
}
22
-
23
17
/**
24
18
* @dev To be emitted when a dispute is created.
25
19
* @param _disputeID ID of the dispute.
@@ -29,7 +23,7 @@ interface IArbitrator {
29
23
30
24
/**
31
25
* @dev Create a dispute. Must be called by the arbitrable contract.
32
-
* Must pay at least arbitrationCost(_extraData).
26
+
* Must pay at least cost(_extraData).
33
27
* @param _choices Amount of choices the arbitrator can make in this dispute.
34
28
* @param _extraData Can be used to give additional info on the dispute to be created.
35
29
* @return disputeID ID of the dispute created.
@@ -41,19 +35,5 @@ interface IArbitrator {
41
35
* @param _extraData Can be used to give additional info on the dispute to be created.
42
36
* @return cost Required cost of arbitration.
43
37
*/
44
-
function arbitrationCost(bytescalldata_extraData) externalviewreturns (uint256cost);
45
-
46
-
/**
47
-
* @dev Return the status of a dispute.
48
-
* @param _disputeID ID of the dispute to rule.
49
-
* @return status The status of the dispute.
50
-
*/
51
-
function disputeStatus(uint256_disputeID) externalviewreturns (DisputeStatus status);
52
-
53
-
/**
54
-
* @dev Return the current ruling of a dispute. This is useful for parties to know if they should appeal.
55
-
* @param _disputeID ID of the dispute.
56
-
* @return ruling The ruling which has been given or the one which will be given if there is no appeal.
57
-
*/
58
-
function currentRuling(uint256_disputeID) externalviewreturns (uint256ruling);
38
+
function cost(bytescalldata_extraData) externalviewreturns (uint256cost);
0 commit comments