Skip to content

Commit cf071ec

Browse files
author
hurstelm
committed
fix(arbitration): commit post first review. W_NATIVE has been made immutable
1 parent 20ca1c6 commit cf071ec

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

contracts/src/arbitration/KlerosCoreBase.sol

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable
101101
Dispute[] public disputes; // The disputes.
102102
mapping(IERC20 => CurrencyRate) public currencyRates; // The price of each token in ETH.
103103
bool public paused; // Whether asset withdrawals are paused.
104-
address public wNative; // The address for WETH tranfers.
104+
address immutable W_NATIVE; // The address for WETH tranfers.
105105

106106
// ************************************* //
107107
// * Events * //
@@ -192,6 +192,17 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable
192192
// * Constructor * //
193193
// ************************************* //
194194

195+
/**
196+
* @dev This contract is deployed only once per chain, as the logic master contract.
197+
* New instances are created with minimal proxy from the factory.
198+
* This is only needed to set the wrapped native token, which is used in SafeSend.
199+
* Since it is constant per chain, it can be safely set as immutable to optimize gas usage.
200+
* @param _wNative The Wrapped Native Token on this chain.
201+
*/
202+
constructor(address _wNative) {
203+
W_NATIVE = _wNative;
204+
}
205+
195206
function __KlerosCoreBase_initialize(
196207
address _governor,
197208
address _guardian,
@@ -203,14 +214,12 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable
203214
uint256[4] memory _timesPerPeriod,
204215
bytes memory _sortitionExtraData,
205216
ISortitionModule _sortitionModuleAddress,
206-
address _wNative
207217
) internal onlyInitializing {
208218
governor = _governor;
209219
guardian = _guardian;
210220
pinakion = _pinakion;
211221
jurorProsecutionModule = _jurorProsecutionModule;
212222
sortitionModule = _sortitionModuleAddress;
213-
wNative = _wNative;
214223

215224
// NULL_DISPUTE_KIT: an empty element at index 0 to indicate when a dispute kit is not supported.
216225
disputeKits.push();
@@ -805,7 +814,7 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable
805814
// No one was coherent, send the rewards to the governor.
806815
if (round.feeToken == NATIVE_CURRENCY) {
807816
// The dispute fees were paid in ETH
808-
SafeSend.safeSend(payable(governor), round.totalFeesForJurors, wNative);
817+
SafeSend.safeSend(payable(governor), round.totalFeesForJurors, W_NATIVE);
809818
} else {
810819
// The dispute fees were paid in ERC20
811820
round.feeToken.safeTransfer(governor, round.totalFeesForJurors);
@@ -862,7 +871,7 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable
862871
pinakion.safeTransfer(account, pnkReward);
863872
if (round.feeToken == NATIVE_CURRENCY) {
864873
// The dispute fees were paid in ETH
865-
SafeSend.safeSend(payable(account), feeReward, wNative);
874+
SafeSend.safeSend(payable(account), feeReward, W_NATIVE);
866875
} else {
867876
// The dispute fees were paid in ERC20
868877
round.feeToken.safeTransfer(account, feeReward);
@@ -888,7 +897,7 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable
888897
if (leftoverFeeReward != 0) {
889898
if (round.feeToken == NATIVE_CURRENCY) {
890899
// The dispute fees were paid in ETH
891-
SafeSend.safeSend(payable(governor), leftoverFeeReward, wNative);
900+
SafeSend.safeSend(payable(governor), leftoverFeeReward, W_NATIVE);
892901
} else {
893902
// The dispute fees were paid in ERC20
894903
round.feeToken.safeTransfer(governor, leftoverFeeReward);

0 commit comments

Comments
 (0)