Skip to content

Commit 9facc46

Browse files
fix(LinguoToken): remove challenge multiplier
1 parent fac6f06 commit 9facc46

File tree

2 files changed

+31
-84
lines changed

2 files changed

+31
-84
lines changed

contracts/standard/arbitration/LinguoToken.sol

Lines changed: 21 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,11 @@ contract LinguoToken is Arbitrable {
5555
uint lastInteraction; // The time of the last action performed on the task. Note that lastInteraction is updated only during timeout-related actions such as the creation of the task and the submission of the translation.
5656
address requester; // The party requesting the translation.
5757
uint requesterDeposit; // The deposit requester makes when creating the task. Once a task is assigned this deposit will be partially reimbursed and its value will be replaced by task price.
58-
uint sumDeposit; // The sum of the deposits of translator and challenger, if any. This value (minus arbitration fees) will be paid to the party that wins the dispute.
58+
uint translatorDeposit; // The deposit of the translator, if any. This value will be paid/reimbursed to the party that wins the dispute.
5959
address[3] parties; // Translator and challenger of the task.
6060
uint disputeID; // The ID of the dispute created in arbitrator contract.
6161
Round[] rounds; // Tracks each appeal round of a dispute.
6262
uint ruling; // Ruling given to the dispute of the task by the arbitrator.
63-
uint priceETH; // Price of the task, converted into ETH. We store it for challenger, to make sure the token price for him doesn't differ from translator.
6463
}
6564

6665
// Rounds are only used in appeal funding.
@@ -77,7 +76,6 @@ contract LinguoToken is Arbitrable {
7776
address public governor; // The governor of the contract.
7877
uint public reviewTimeout; // Time in seconds, during which the submitted translation can be challenged.
7978
uint public translationMultiplier; // Multiplier for calculating the value of the deposit translator must pay to self-assign a task.
80-
uint public challengeMultiplier; // Multiplier for calculating the value of the deposit challenger must pay to challenge a translation.
8179

8280
// All multipliers below are in basis points.
8381
uint public sharedStakeMultiplier; // Multiplier for calculating the appeal fee that must be paid by submitter in the case where there is no winner or loser (e.g. when the arbitrator ruled "refuse to arbitrate").
@@ -144,7 +142,6 @@ contract LinguoToken is Arbitrable {
144142
* @param _uniswapFactory Address of the UniswapPair factory contract.
145143
* @param _reviewTimeout Time in seconds during which a translation can be challenged.
146144
* @param _translationMultiplier Multiplier for calculating translator's deposit. In basis points.
147-
* @param _challengeMultiplier Multiplier for calculating challenger's deposit. In basis points.
148145
* @param _sharedStakeMultiplier Multiplier of the appeal cost that submitter must pay for a round when there is no winner/loser in the previous round. In basis points.
149146
* @param _winnerStakeMultiplier Multiplier of the appeal cost that the winner has to pay for a round. In basis points.
150147
* @param _loserStakeMultiplier Multiplier of the appeal cost that the loser has to pay for a round. In basis points.
@@ -156,7 +153,6 @@ contract LinguoToken is Arbitrable {
156153
address _uniswapFactory,
157154
uint _reviewTimeout,
158155
uint _translationMultiplier,
159-
uint _challengeMultiplier,
160156
uint _sharedStakeMultiplier,
161157
uint _winnerStakeMultiplier,
162158
uint _loserStakeMultiplier
@@ -166,7 +162,6 @@ contract LinguoToken is Arbitrable {
166162
uniswapFactory = _uniswapFactory;
167163
reviewTimeout = _reviewTimeout;
168164
translationMultiplier = _translationMultiplier;
169-
challengeMultiplier = _challengeMultiplier;
170165
sharedStakeMultiplier = _sharedStakeMultiplier;
171166
winnerStakeMultiplier = _winnerStakeMultiplier;
172167
loserStakeMultiplier = _loserStakeMultiplier;
@@ -197,13 +192,6 @@ contract LinguoToken is Arbitrable {
197192
translationMultiplier = _translationMultiplier;
198193
}
199194

200-
/** @dev Changes the multiplier for challenger's deposit.
201-
* @param _challengeMultiplier A new value of the multiplier for calculating challenger's deposit. In basis points.
202-
*/
203-
function changeChallengeMultiplier(uint _challengeMultiplier) public onlyGovernor {
204-
challengeMultiplier = _challengeMultiplier;
205-
}
206-
207195
/** @dev Changes the percentage of arbitration fees that must be paid by parties as a fee stake if there was no winner and loser in the previous round.
208196
* @param _sharedStakeMultiplier A new value of the multiplier of the appeal cost in case when there is no winner/loser in previous round. In basis point.
209197
*/
@@ -283,9 +271,7 @@ contract LinguoToken is Arbitrable {
283271

284272
// Update requester's deposit since we reimbursed him the difference between maximal and actual price.
285273
task.requesterDeposit = price;
286-
287-
task.priceETH = priceETH;
288-
task.sumDeposit += translatorDeposit;
274+
task.translatorDeposit = translatorDeposit;
289275

290276
uint remainder = msg.value - translatorDeposit;
291277
msg.sender.send(remainder);
@@ -319,11 +305,11 @@ contract LinguoToken is Arbitrable {
319305
require(now - task.lastInteraction > task.submissionTimeout, "Can't reimburse if the deadline hasn't passed yet.");
320306
task.status = Status.Resolved;
321307
uint requesterDeposit = task.requesterDeposit;
322-
uint sumDeposit = task.sumDeposit;
308+
uint translatorDeposit = task.translatorDeposit;
323309
task.requesterDeposit = 0;
324-
task.sumDeposit = 0;
325-
// Requester gets his deposit back and also the deposit of the translator, if there was one. Note that sumDeposit can't contain challenger's deposit until the task is in DisputeCreated status.
326-
task.requester.send(sumDeposit);
310+
task.translatorDeposit = 0;
311+
// Requester gets his deposit back and also the deposit of the translator, if there was one.
312+
task.requester.send(translatorDeposit);
327313
require(task.token.transfer(task.requester, requesterDeposit), "The token transfer was unsuccessful.");
328314

329315
emit TaskResolved(_taskID, "requester-reimbursed", now);
@@ -337,13 +323,13 @@ contract LinguoToken is Arbitrable {
337323
require(task.status == Status.AwaitingReview, "The task is in the wrong status.");
338324
require(now - task.lastInteraction > reviewTimeout, "The review phase hasn't passed yet.");
339325
task.status = Status.Resolved;
340-
// Translator gets the price of the task and his deposit back. Note that sumDeposit can't contain challenger's deposit until the task is in DisputeCreated status.
326+
// Translator gets the price of the task and his deposit back.
341327
address translator = task.parties[uint(Party.Translator)];
342328
uint requesterDeposit = task.requesterDeposit;
343-
uint sumDeposit = task.sumDeposit;
329+
uint translatorDeposit = task.translatorDeposit;
344330
task.requesterDeposit = 0;
345-
task.sumDeposit = 0;
346-
translator.send(sumDeposit);
331+
task.translatorDeposit = 0;
332+
translator.send(translatorDeposit);
347333
require(task.token.transfer(translator, requesterDeposit), "The token transfer was unsuccessful.");
348334

349335
emit TaskResolved(_taskID, "translation-accepted", now);
@@ -356,22 +342,21 @@ contract LinguoToken is Arbitrable {
356342
function challengeTranslation(uint _taskID, string _evidence) external payable {
357343
Task storage task = tasks[_taskID];
358344

345+
// The challenger should only deposit the value of arbitration cost.
359346
uint arbitrationCost = arbitrator.arbitrationCost(arbitratorExtraData);
360-
uint challengeDeposit = arbitrationCost.addCap((challengeMultiplier.mulCap(task.priceETH)) / MULTIPLIER_DIVISOR);
361347

362348
require(task.status == Status.AwaitingReview, "The task is in the wrong status.");
363349
require(now - task.lastInteraction <= reviewTimeout, "The review phase has already passed.");
364-
require(msg.value >= challengeDeposit, "Not enough ETH to cover challenge deposit.");
350+
require(msg.value >= arbitrationCost, "Not enough ETH to cover challenge deposit.");
365351

366352
task.status = Status.DisputeCreated;
367353
task.parties[uint(Party.Challenger)] = msg.sender;
368354

369355
task.disputeID = arbitrator.createDispute.value(arbitrationCost)(2, arbitratorExtraData);
370356
disputeIDtoTaskID[task.disputeID] = _taskID;
371357
task.rounds.length++;
372-
task.sumDeposit = task.sumDeposit.addCap(challengeDeposit).subCap(arbitrationCost);
373358

374-
uint remainder = msg.value - challengeDeposit;
359+
uint remainder = msg.value - arbitrationCost;
375360
msg.sender.send(remainder);
376361

377362
emit Dispute(arbitrator, task.disputeID, _taskID, _taskID);
@@ -536,22 +521,22 @@ contract LinguoToken is Arbitrable {
536521
Task storage task = tasks[taskID];
537522
task.status = Status.Resolved;
538523
task.ruling = _ruling;
539-
uint sumDeposit = task.sumDeposit;
524+
uint translatorDeposit = task.translatorDeposit;
540525
uint requesterDeposit = task.requesterDeposit;
541526
task.requesterDeposit = 0;
542-
task.sumDeposit = 0;
527+
task.translatorDeposit = 0;
543528

544529
if(_ruling == uint(Party.None)){
545-
// The value of sumDeposit is split among parties in this case. If the sum is uneven the value of 1 wei can be burnt.
546-
sumDeposit = sumDeposit / 2;
547-
task.parties[uint(Party.Translator)].send(sumDeposit);
548-
task.parties[uint(Party.Challenger)].send(sumDeposit);
530+
// The value of translatorDeposit is split among parties in this case. If it's uneven the value of 1 wei can be burnt.
531+
translatorDeposit = translatorDeposit / 2;
532+
task.parties[uint(Party.Translator)].send(translatorDeposit);
533+
task.parties[uint(Party.Challenger)].send(translatorDeposit);
549534
require(task.token.transfer(task.requester, requesterDeposit), "Could not transfer tokens to requester.");
550535
} else if (_ruling == uint(Party.Translator)) {
551-
task.parties[uint(Party.Translator)].send(sumDeposit);
536+
task.parties[uint(Party.Translator)].send(translatorDeposit);
552537
require(task.token.transfer(task.parties[uint(Party.Translator)], requesterDeposit), "Could not transfer tokens to translator.");
553538
} else {
554-
task.parties[uint(Party.Challenger)].send(sumDeposit);
539+
task.parties[uint(Party.Challenger)].send(translatorDeposit);
555540
require(task.token.transfer(task.requester, requesterDeposit), "Could not transfer tokens to requester.");
556541
}
557542

@@ -621,20 +606,6 @@ contract LinguoToken is Arbitrable {
621606
}
622607
}
623608

624-
/** @dev Gets the deposit required for challenging the translation.
625-
* @param _taskID The ID of the task.
626-
* @return deposit The challengers's deposit.
627-
*/
628-
function getChallengeValue(uint _taskID) public view returns (uint deposit) {
629-
Task storage task = tasks[_taskID];
630-
if (now - task.lastInteraction > reviewTimeout || task.status != Status.AwaitingReview) {
631-
deposit = NOT_PAYABLE_VALUE;
632-
} else {
633-
uint arbitrationCost = arbitrator.arbitrationCost(arbitratorExtraData);
634-
deposit = arbitrationCost.addCap((challengeMultiplier.mulCap(task.priceETH)) / MULTIPLIER_DIVISOR);
635-
}
636-
}
637-
638609
/** @dev Gets the current price of a specified task. Returns 0 if the task can no longer be assigned.
639610
* @param _taskID The ID of the task.
640611
* @return price The price of the task.

test/linguo-token.js

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ contract('Linguo', function(accounts) {
2828
const appealTimeOut = 100
2929
const reviewTimeout = 2400
3030
const translationMultiplier = 1000
31-
const challengeMultiplier = 2000
3231
const sharedMultiplier = 5000
3332
const winnerMultiplier = 3000
3433
const loserMultiplier = 7000
@@ -65,7 +64,6 @@ contract('Linguo', function(accounts) {
6564
fakeFactory, // uniswapFactory. Can't test the uniswap getters because of the old compiler, so set it random value.
6665
reviewTimeout,
6766
translationMultiplier,
68-
challengeMultiplier,
6967
sharedMultiplier,
7068
winnerMultiplier,
7169
loserMultiplier,
@@ -104,7 +102,6 @@ contract('Linguo', function(accounts) {
104102
assert.equal(await linguo.governor(), governor)
105103
assert.equal(await linguo.reviewTimeout(), reviewTimeout)
106104
assert.equal(await linguo.translationMultiplier(), translationMultiplier)
107-
assert.equal(await linguo.challengeMultiplier(), challengeMultiplier)
108105
assert.equal(await linguo.sharedStakeMultiplier(), sharedMultiplier)
109106
assert.equal(await linguo.winnerStakeMultiplier(), winnerMultiplier)
110107
assert.equal(await linguo.loserStakeMultiplier(), loserMultiplier)
@@ -352,12 +349,6 @@ contract('Linguo', function(accounts) {
352349
Math.abs(task[8].toNumber() - requiredDeposit) <= requiredDeposit / 100,
353350
'The translator deposit was not set up properly'
354351
)
355-
356-
assert.equal(
357-
task[7].toNumber(),
358-
task[11].toNumber(),
359-
'Incorrect price in ETH value'
360-
)
361352
})
362353

363354
it('Should not be possible to submit translation after submission timeout ended', async () => {
@@ -469,7 +460,7 @@ contract('Linguo', function(accounts) {
469460
})
470461

471462
it('Should not be possible to reimburse if submission timeout has not passed', async () => {
472-
await increaseTime(submissionTimeout - secondsPassed - 1)
463+
await increaseTime(submissionTimeout - secondsPassed - 5)
473464
await expectThrow(linguo.reimburseRequester(0))
474465
})
475466

@@ -519,7 +510,7 @@ contract('Linguo', function(accounts) {
519510
await linguo.submitTranslation(0, 'ipfs:/X', { from: translator })
520511
await expectThrow(linguo.acceptTranslation(0))
521512

522-
const challengerDeposit = (await linguo.getChallengeValue(0)).toNumber()
513+
const challengerDeposit = arbitrationFee
523514
await linguo.challengeTranslation(0, '', {
524515
from: challenger,
525516
value: challengerDeposit
@@ -537,7 +528,7 @@ contract('Linguo', function(accounts) {
537528
})
538529
await linguo.submitTranslation(0, 'ipfs:/X', { from: translator })
539530

540-
const challengerDeposit = (await linguo.getChallengeValue(0)).toNumber()
531+
const challengerDeposit = arbitrationFee
541532

542533
// Check that reverts if the deposit is lower than expected
543534
await expectThrow(
@@ -632,7 +623,7 @@ contract('Linguo', function(accounts) {
632623
value: requiredDeposit + 1000
633624
})
634625
await linguo.submitTranslation(0, 'ipfs:/X', { from: translator })
635-
const challengerDeposit = (await linguo.getChallengeValue(0)).toNumber()
626+
const challengerDeposit = arbitrationFee
636627
await increaseTime(reviewTimeout + 1)
637628
await expectThrow(
638629
linguo.challengeTranslation(0, '', {
@@ -652,7 +643,7 @@ contract('Linguo', function(accounts) {
652643

653644
await linguo.submitTranslation(0, 'ipfs:/X', { from: translator })
654645

655-
const challengerDeposit = (await linguo.getChallengeValue(0)).toNumber()
646+
const challengerDeposit = arbitrationFee
656647
await linguo.challengeTranslation(0, '', {
657648
from: challenger,
658649
value: challengerDeposit
@@ -708,7 +699,7 @@ contract('Linguo', function(accounts) {
708699
})
709700
await linguo.submitTranslation(0, 'ipfs:/X', { from: translator })
710701

711-
const challengerDeposit = (await linguo.getChallengeValue(0)).toNumber()
702+
const challengerDeposit = arbitrationFee
712703
await linguo.challengeTranslation(0, '', {
713704
from: challenger,
714705
value: challengerDeposit
@@ -767,7 +758,7 @@ contract('Linguo', function(accounts) {
767758

768759
await linguo.submitTranslation(0, 'ipfs:/X', { from: translator })
769760

770-
const challengerDeposit = (await linguo.getChallengeValue(0)).toNumber()
761+
const challengerDeposit = arbitrationFee
771762
await linguo.challengeTranslation(0, '', {
772763
from: challenger,
773764
value: challengerDeposit
@@ -843,7 +834,7 @@ contract('Linguo', function(accounts) {
843834
})
844835
await linguo.submitTranslation(0, 'ipfs:/X', { from: translator })
845836

846-
const challengerDeposit = (await linguo.getChallengeValue(0)).toNumber()
837+
const challengerDeposit = arbitrationFee
847838
await linguo.challengeTranslation(0, '', {
848839
from: challenger,
849840
value: challengerDeposit
@@ -954,7 +945,7 @@ contract('Linguo', function(accounts) {
954945
})
955946
await linguo.submitTranslation(0, 'ipfs:/X', { from: translator })
956947

957-
const challengerDeposit = (await linguo.getChallengeValue(0)).toNumber()
948+
const challengerDeposit = arbitrationFee
958949
await linguo.challengeTranslation(0, '', {
959950
from: challenger,
960951
value: challengerDeposit
@@ -1020,7 +1011,7 @@ contract('Linguo', function(accounts) {
10201011
})
10211012
await linguo.submitTranslation(0, 'ipfs:/X', { from: translator })
10221013

1023-
const challengerDeposit = (await linguo.getChallengeValue(0)).toNumber()
1014+
const challengerDeposit = arbitrationFee
10241015
await linguo.challengeTranslation(0, '', {
10251016
from: challenger,
10261017
value: challengerDeposit
@@ -1140,21 +1131,6 @@ contract('Linguo', function(accounts) {
11401131
44,
11411132
'Incorrect translationMultiplier value'
11421133
)
1143-
// changeChallengeMultiplier
1144-
await expectThrow(
1145-
linguo.changeChallengeMultiplier(88, {
1146-
from: other
1147-
})
1148-
)
1149-
await linguo.changeChallengeMultiplier(88, {
1150-
from: governor
1151-
})
1152-
1153-
assert.equal(
1154-
(await linguo.challengeMultiplier()).toNumber(),
1155-
88,
1156-
'Incorrect challengeMultiplier value'
1157-
)
11581134
// shared multiplier
11591135
await expectThrow(
11601136
linguo.changeSharedStakeMultiplier(5011, {

0 commit comments

Comments
 (0)