Skip to content

Commit cfaf9f5

Browse files
committed
fix: added missing token transfers and other small improvements
1 parent 5c21d38 commit cfaf9f5

15 files changed

+387
-185
lines changed

contracts/deploy/00-home-chain-arbitration.ts

+7-16
Original file line numberDiff line numberDiff line change
@@ -113,22 +113,13 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
113113
await execute("DisputeKitClassic", { from: deployer, log: true }, "changeCore", klerosCore.address);
114114
}
115115

116-
await execute(
117-
"KlerosCore",
118-
{ from: deployer, log: true },
119-
"changeAcceptedFeeTokens",
120-
[pnk, dai, weth],
121-
[true, true, true]
122-
);
123-
124-
await execute(
125-
"KlerosCore",
126-
{ from: deployer, log: true },
127-
"changeCurrencyRates",
128-
[pnk, dai, weth],
129-
[12225583, 60327783, 1],
130-
[12, 11, 1]
131-
);
116+
await execute("KlerosCore", { from: deployer, log: true }, "changeAcceptedFeeTokens", pnk, true);
117+
await execute("KlerosCore", { from: deployer, log: true }, "changeAcceptedFeeTokens", dai, true);
118+
await execute("KlerosCore", { from: deployer, log: true }, "changeAcceptedFeeTokens", weth, true);
119+
120+
await execute("KlerosCore", { from: deployer, log: true }, "changeCurrencyRates", pnk, 12225583, 12);
121+
await execute("KlerosCore", { from: deployer, log: true }, "changeCurrencyRates", dai, 60327783, 11);
122+
await execute("KlerosCore", { from: deployer, log: true }, "changeCurrencyRates", weth, 1, 1);
132123

133124
await deploy("DisputeResolver", {
134125
from: deployer,

contracts/deploy/03-vea-mock.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,14 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
3838
await deploy("HomeGatewayToEthereum", {
3939
from: deployer,
4040
contract: "HomeGateway",
41-
args: [deployer, klerosCore.address, vea.address, HARDHAT_NETWORK, foreignGateway.address],
41+
args: [
42+
deployer,
43+
klerosCore.address,
44+
vea.address,
45+
HARDHAT_NETWORK,
46+
foreignGateway.address,
47+
ethers.constants.AddressZero, // feeToken
48+
],
4249
gasLimit: 4000000,
4350
log: true,
4451
}); // nonce+1

contracts/src/arbitration/CentralizedArbitrator.sol

+11-4
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ contract CentralizedArbitrator is IArbitrator {
182182
function createDispute(
183183
uint256 /*_choices*/,
184184
bytes calldata /*_extraData*/,
185-
address /*_feeToken*/,
185+
IERC20 /*_feeToken*/,
186186
uint256 /*_feeAmount*/
187-
) external override returns (uint256) {
187+
) external pure override returns (uint256) {
188188
revert("Not supported");
189189
}
190190

@@ -326,12 +326,19 @@ contract CentralizedArbitrator is IArbitrator {
326326
// * Public Views * //
327327
// ************************************* //
328328

329-
/// @dev Cost of arbitration.
330-
/// @return fee The required amount.
329+
/// @inheritdoc IArbitrator
331330
function arbitrationCost(bytes calldata /*_extraData*/) public view override returns (uint256 fee) {
332331
return arbitrationFee;
333332
}
334333

334+
/// @inheritdoc IArbitrator
335+
function arbitrationCost(
336+
bytes calldata /*_extraData*/,
337+
IERC20 /*_feeToken*/
338+
) public pure override returns (uint256 /*cost*/) {
339+
revert("Not supported");
340+
}
341+
335342
/// @dev Return the funded amount and funding goal for one of the choices.
336343
/// @param _disputeID The ID of the dispute to appeal.
337344
/// @param _choice The choice to check the funding status of.

contracts/src/arbitration/IArbitrator.sol

+18-8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
pragma solidity 0.8.18;
44

5+
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
56
import "./IArbitrable.sol";
67

78
/// @title Arbitrator
@@ -26,9 +27,10 @@ interface IArbitrator {
2627
/// @dev To be emitted when an ERC20 token is added or removed as a method to pay fees.
2728
/// @param _token The ERC20 token.
2829
/// @param _accepted Whether the token is accepted or not.
29-
event AcceptedFeeToken(address indexed _token, bool indexed _accepted);
30+
event AcceptedFeeToken(IERC20 indexed _token, bool indexed _accepted);
3031

31-
/// @dev Create a dispute. Must be called by the arbitrable contract.
32+
/// @dev Create a dispute and pay for the fees in the native currency, typically ETH.
33+
/// Must be called by the arbitrable contract.
3234
/// Must pay at least arbitrationCost(_extraData).
3335
/// @param _numberOfChoices The number of choices the arbitrator can choose from in this dispute.
3436
/// @param _extraData Additional info about the dispute. We use it to pass the ID of the dispute's court (first 32 bytes), the minimum number of jurors required (next 32 bytes) and the ID of the specific dispute kit (last 32 bytes).
@@ -38,23 +40,31 @@ interface IArbitrator {
3840
bytes calldata _extraData
3941
) external payable returns (uint256 disputeID);
4042

41-
/// @dev Create a dispute with the fees paid in a supported ERC20 token.
43+
/// @dev Create a dispute and pay for the fees in a supported ERC20 token.
4244
/// Must be called by the arbitrable contract.
4345
/// Must pay at least arbitrationCost(_extraData).
4446
/// @param _numberOfChoices The number of choices the arbitrator can choose from in this dispute.
4547
/// @param _extraData Additional info about the dispute. We use it to pass the ID of the dispute's court (first 32 bytes), the minimum number of jurors required (next 32 bytes) and the ID of the specific dispute kit (last 32 bytes).
46-
/// @param _feeToken Address of the ERC20 token used to pay fees.
48+
/// @param _feeToken The ERC20 token used to pay fees.
4749
/// @param _feeAmount Amount of the ERC20 token used to pay fees.
4850
/// @return disputeID ID of the dispute created.
4951
function createDispute(
5052
uint256 _numberOfChoices,
5153
bytes calldata _extraData,
52-
address _feeToken,
54+
IERC20 _feeToken,
5355
uint256 _feeAmount
5456
) external returns (uint256 disputeID);
5557

56-
/// @dev Compute the cost of arbitration. It is recommended not to increase it often, as it can be highly time and gas consuming for the arbitrated contracts to cope with fee augmentation.
57-
/// @param _extraData Can be used to give additional info on the dispute to be created.
58-
/// @return cost Required cost of arbitration.
58+
/// @dev Compute the cost of arbitration denominated in ETH.
59+
/// It is recommended not to increase it often, as it can be highly time and gas consuming for the arbitrated contracts to cope with fee augmentation.
60+
/// @param _extraData Additional info about the dispute. We use it to pass the ID of the dispute's court (first 32 bytes), the minimum number of jurors required (next 32 bytes) and the ID of the specific dispute kit (last 32 bytes).
61+
/// @return cost The arbitration cost in ETH.
5962
function arbitrationCost(bytes calldata _extraData) external view returns (uint256 cost);
63+
64+
/// @dev Compute the cost of arbitration denominated in `_feeToken`.
65+
/// It is recommended not to increase it often, as it can be highly time and gas consuming for the arbitrated contracts to cope with fee augmentation.
66+
/// @param _extraData Additional info about the dispute. We use it to pass the ID of the dispute's court (first 32 bytes), the minimum number of jurors required (next 32 bytes) and the ID of the specific dispute kit (last 32 bytes).
67+
/// @param _feeToken The ERC20 token used to pay fees.
68+
/// @return cost The arbitration cost in `_feeToken`.
69+
function arbitrationCost(bytes calldata _extraData, IERC20 _feeToken) external view returns (uint256 cost);
6070
}

0 commit comments

Comments
 (0)