@@ -5,7 +5,7 @@ pragma solidity ^0.8.24;
55import {KlerosCore, KlerosCoreBase, IDisputeKit, ISortitionModule} from "../KlerosCore.sol " ;
66import {Initializable} from "../../proxy/Initializable.sol " ;
77import {UUPSProxiable} from "../../proxy/UUPSProxiable.sol " ;
8- import {WethLike, SafeSend} from "../../libraries/SafeSend.sol " ;
8+ import {SafeSend} from "../../libraries/SafeSend.sol " ;
99
1010/// @title DisputeKitClassicBase
1111/// Abstract Dispute kit classic implementation of the Kleros v1 features including:
@@ -59,7 +59,7 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
5959 uint256 public constant ONE_BASIS_POINT = 10000 ; // One basis point, for scaling.
6060
6161 address public governor; // The governor of the contract.
62- address public wNative ; // The address for WETH tranfers.
62+ address immutable W_NATIVE ; // The address for WETH tranfers.
6363 KlerosCore public core; // The Kleros Core arbitrator
6464 Dispute[] public disputes; // Array of the locally created disputes.
6565 mapping (uint256 => uint256 ) public coreDisputeIDToLocal; // Maps the dispute ID in Kleros Core to the local dispute ID.
@@ -142,18 +142,23 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
142142 // * Constructor * //
143143 // ************************************* //
144144
145+ /**
146+ * @dev This contract is deployed only once per chain, as the logic master contract.
147+ * New instances are created with minimal proxy from the factory.
148+ * This is only needed to set the wrapped native token, which is used in SafeSend.
149+ * Since it is constant per chain, it can be safely set as immutable to optimize gas usage.
150+ * @param _wNative The Wrapped Native Token on this chain.
151+ */
152+ constructor (address _wNative ) {
153+ W_NATIVE = _wNative;
154+ }
155+
145156 /// @dev Initializer.
146157 /// @param _governor The governor's address.
147158 /// @param _core The KlerosCore arbitrator.
148- /// @param _wNative The address of the WETH used by SafeSend for fallback transfers.
149- function __DisputeKitClassicBase_initialize (
150- address _governor ,
151- KlerosCore _core ,
152- address _wNative
153- ) internal onlyInitializing {
159+ function __DisputeKitClassicBase_initialize (address _governor , KlerosCore _core ) internal onlyInitializing {
154160 governor = _governor;
155161 core = _core;
156- wNative = _wNative;
157162 }
158163
159164 // ************************ //
@@ -418,7 +423,7 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
418423 core.appeal {value: appealCost}(_coreDisputeID, dispute.numberOfChoices, dispute.extraData);
419424 }
420425
421- if (msg .value > contribution) SafeSend.safeSend (payable (msg .sender ), msg .value - contribution, wNative );
426+ if (msg .value > contribution) SafeSend.safeSend (payable (msg .sender ), msg .value - contribution, W_NATIVE );
422427 }
423428
424429 /// @dev Allows those contributors who attempted to fund an appeal round to withdraw any reimbursable fees or rewards after the dispute gets resolved.
@@ -463,7 +468,7 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
463468 round.contributions[_beneficiary][_choice] = 0 ;
464469
465470 if (amount != 0 ) {
466- SafeSend.safeSend (_beneficiary, amount, wNative ); // Deliberate use of send to prevent reverting fallback. It's the user's responsibility to accept ETH.
471+ SafeSend.safeSend (_beneficiary, amount, W_NATIVE ); // Deliberate use of send to prevent reverting fallback. It's the user's responsibility to accept ETH.
467472 emit Withdrawal (_coreDisputeID, _coreRoundID, _choice, _beneficiary, amount);
468473 }
469474 }
0 commit comments