From fe01686160e4016177debd48349d29570b7ccb27 Mon Sep 17 00:00:00 2001 From: Duncan Townsend Date: Mon, 16 Dec 2024 11:06:33 -0500 Subject: [PATCH 1/6] Add `rebateClaimer()(address)` function on Mainnet Settlers for gas rebate program --- src/chains/Mainnet/Common.sol | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/chains/Mainnet/Common.sol b/src/chains/Mainnet/Common.sol index 147cae55..9a71576b 100644 --- a/src/chains/Mainnet/Common.sol +++ b/src/chains/Mainnet/Common.sol @@ -36,6 +36,8 @@ import { ISolidlyV3Callback } from "../../core/univ3forks/SolidlyV3.sol"; +import {IOwnable} from "../../deployer/TwoStepOwnable.sol"; + // Solidity inheritance is stupid import {SettlerAbstract} from "../../SettlerAbstract.sol"; @@ -51,6 +53,7 @@ abstract contract MainnetMixin is { constructor() { assert(block.chainid == 1 || block.chainid == 31337); + rebateClaimer = IOwnable(0x00000000000004533Fe15556B1E086BB1A72cEae).owner(); } function _dispatch(uint256 i, uint256 action, bytes calldata data) @@ -137,4 +140,6 @@ abstract contract MainnetMixin is function _curveFactory() internal pure override returns (address) { return 0x0c0e5f2fF0ff18a3be9b835635039256dC4B4963; } + + address public immutable rebateClaimer; } From e2b35f450f14d40474145ca27c329210ff3115a6 Mon Sep 17 00:00:00 2001 From: Duncan Townsend Date: Mon, 16 Dec 2024 11:14:56 -0500 Subject: [PATCH 2/6] Factor-out constant --- src/SettlerBase.sol | 4 +++- src/chains/Blast/Common.sol | 3 ++- src/chains/Mainnet/Common.sol | 3 ++- src/chains/Mode/Common.sol | 3 ++- src/deployer/BlastDeployer.sol | 3 ++- src/deployer/Deployer.sol | 3 ++- src/deployer/DeployerAddress.sol | 4 ++++ src/deployer/ModeDeployer.sol | 5 +++-- src/deployer/SafeModule.sol | 3 ++- test/deployer/Deployer.t.sol | 3 ++- 10 files changed, 24 insertions(+), 10 deletions(-) create mode 100644 src/deployer/DeployerAddress.sol diff --git a/src/SettlerBase.sol b/src/SettlerBase.sol index 2bab07ae..8b8cac9e 100644 --- a/src/SettlerBase.sol +++ b/src/SettlerBase.sol @@ -5,6 +5,8 @@ import {IERC20} from "@forge-std/interfaces/IERC20.sol"; import {IERC721Owner} from "./IERC721Owner.sol"; import {ISignatureTransfer} from "@permit2/interfaces/ISignatureTransfer.sol"; +import {DEPLOYER} from "./deployer/DeployerAddress.sol"; + import {Basic} from "./core/Basic.sol"; import {RfqOrderSettlement} from "./core/RfqOrderSettlement.sol"; import {UniswapV3Fork} from "./core/UniswapV3Fork.sol"; @@ -60,7 +62,7 @@ abstract contract SettlerBase is Basic, RfqOrderSettlement, UniswapV3Fork, Unisw constructor(bytes20 gitCommit, uint256 tokenId) { if (block.chainid != 31337) { emit GitCommit(gitCommit); - assert(IERC721Owner(0x00000000000004533Fe15556B1E086BB1A72cEae).ownerOf(tokenId) == address(this)); + assert(IERC721Owner(DEPLOYER).ownerOf(tokenId) == address(this)); } else { assert(gitCommit == bytes20(0)); } diff --git a/src/chains/Blast/Common.sol b/src/chains/Blast/Common.sol index 26a9449b..f371ed9e 100644 --- a/src/chains/Blast/Common.sol +++ b/src/chains/Blast/Common.sol @@ -36,6 +36,7 @@ import { rogueXV1Factory, rogueXV1InitHash, rogueXV1ForkId, IRoxSpotSwapCallback } from "../../core/univ3forks/RogueXV1.sol"; +import {DEPLOYER} from "../../deployer/DeployerAddress.sol"; import {IOwnable} from "../../deployer/TwoStepOwnable.sol"; import {BLAST, BLAST_USDB, BLAST_WETH, BlastYieldMode, BlastGasMode} from "./IBlast.sol"; @@ -49,7 +50,7 @@ abstract contract BlastMixin is FreeMemory, SettlerBase { BLAST.configure( BlastYieldMode.AUTOMATIC, BlastGasMode.CLAIMABLE, - IOwnable(0x00000000000004533Fe15556B1E086BB1A72cEae).owner() + IOwnable(DEPLOYER).owner() ); BLAST_USDB.configure(BlastYieldMode.VOID); BLAST_WETH.configure(BlastYieldMode.VOID); diff --git a/src/chains/Mainnet/Common.sol b/src/chains/Mainnet/Common.sol index 9a71576b..d7163842 100644 --- a/src/chains/Mainnet/Common.sol +++ b/src/chains/Mainnet/Common.sol @@ -36,6 +36,7 @@ import { ISolidlyV3Callback } from "../../core/univ3forks/SolidlyV3.sol"; +import {DEPLOYER} from "../../deployer/DeployerAddress.sol"; import {IOwnable} from "../../deployer/TwoStepOwnable.sol"; // Solidity inheritance is stupid @@ -53,7 +54,7 @@ abstract contract MainnetMixin is { constructor() { assert(block.chainid == 1 || block.chainid == 31337); - rebateClaimer = IOwnable(0x00000000000004533Fe15556B1E086BB1A72cEae).owner(); + rebateClaimer = IOwnable(DEPLOYER).owner(); } function _dispatch(uint256 i, uint256 action, bytes calldata data) diff --git a/src/chains/Mode/Common.sol b/src/chains/Mode/Common.sol index 2ee850fb..b13c1efa 100644 --- a/src/chains/Mode/Common.sol +++ b/src/chains/Mode/Common.sol @@ -19,6 +19,7 @@ import {IAlgebraCallback} from "../../core/univ3forks/Algebra.sol"; import {swapModeV3Factory, swapModeV3InitHash, swapModeV3ForkId} from "../../core/univ3forks/SwapModeV3.sol"; import {IUniswapV3Callback} from "../../core/univ3forks/UniswapV3.sol"; +import {DEPLOYER} from "../../deployer/DeployerAddress.sol"; import {MODE_SFS} from "./IModeSFS.sol"; // Solidity inheritance is stupid @@ -27,7 +28,7 @@ import {Permit2PaymentAbstract} from "../../core/Permit2PaymentAbstract.sol"; abstract contract ModeMixin is FreeMemory, SettlerBase { constructor() { assert(block.chainid == 34443 || block.chainid == 31337); - MODE_SFS.assign(MODE_SFS.getTokenId(0x00000000000004533Fe15556B1E086BB1A72cEae)); + MODE_SFS.assign(MODE_SFS.getTokenId(DEPLOYER)); } function _isRestrictedTarget(address target) diff --git a/src/deployer/BlastDeployer.sol b/src/deployer/BlastDeployer.sol index 4e31a071..d3d4d736 100644 --- a/src/deployer/BlastDeployer.sol +++ b/src/deployer/BlastDeployer.sol @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity =0.8.25; +import {DEPLOYER} from "./DeployerAddress.sol"; import {Deployer} from "./Deployer.sol"; import {BLAST, BlastYieldMode, BlastGasMode} from "../chains/Blast/IBlast.sol"; @@ -11,7 +12,7 @@ contract BlastDeployer is Deployer { BLAST.configure( BlastYieldMode.AUTOMATIC, BlastGasMode.CLAIMABLE, - BlastDeployer(0x00000000000004533Fe15556B1E086BB1A72cEae).owner() + BlastDeployer(DEPLOYER).owner() ); } diff --git a/src/deployer/Deployer.sol b/src/deployer/Deployer.sol index 2965636c..73037f06 100644 --- a/src/deployer/Deployer.sol +++ b/src/deployer/Deployer.sol @@ -15,6 +15,7 @@ import {ProxyMultiCall} from "../utils/ProxyMultiCall.sol"; import {Feature, wrap, isNull} from "./Feature.sol"; import {Nonce, zero, isNull} from "./Nonce.sol"; import {IDeployer, IERC721ViewMetadata} from "./IDeployer.sol"; +import {DEPLOYER} from "./DeployerAddress.sol"; library NonceList { struct ListElem { @@ -149,7 +150,7 @@ contract Deployer is IDeployer, ERC1967UUPSUpgradeable, Context, ERC1967TwoStepO } function initialize(address initialOwner) public virtual { - require(address(this) == 0x00000000000004533Fe15556B1E086BB1A72cEae || block.chainid == 31337); + require(address(this) == DEPLOYER || block.chainid == 31337); if (_implVersion == 1) { _setPendingOwner(initialOwner); } else { diff --git a/src/deployer/DeployerAddress.sol b/src/deployer/DeployerAddress.sol new file mode 100644 index 00000000..27082984 --- /dev/null +++ b/src/deployer/DeployerAddress.sol @@ -0,0 +1,4 @@ +// SPDX-License-Identifier: MIT +pragma solidity =0.8.25; + +address constant DEPLOYER = 0x00000000000004533Fe15556B1E086BB1A72cEae; diff --git a/src/deployer/ModeDeployer.sol b/src/deployer/ModeDeployer.sol index d2760022..1b1893e3 100644 --- a/src/deployer/ModeDeployer.sol +++ b/src/deployer/ModeDeployer.sol @@ -2,6 +2,7 @@ pragma solidity =0.8.25; import {Deployer} from "./Deployer.sol"; +import {DEPLOYER} from "./DeployerAddress.sol"; import {MODE_SFS} from "../chains/Mode/IModeSFS.sol"; /// @custom:security-contact security@0x.org @@ -10,11 +11,11 @@ contract ModeDeployer is Deployer { constructor(uint256 version) Deployer(version) { assert(block.chainid == 34443); - if (0x00000000000004533Fe15556B1E086BB1A72cEae.code.length == 0) { + if (DEPLOYER.code.length == 0) { assert(_implVersion == 1); sfsTokenId = MODE_SFS.register(0xf36b9f50E59870A24F42F9Ba43b2aD0A4b8f2F51); } else { - MODE_SFS.assign(sfsTokenId = MODE_SFS.getTokenId(0x00000000000004533Fe15556B1E086BB1A72cEae)); + MODE_SFS.assign(sfsTokenId = MODE_SFS.getTokenId(DEPLOYER)); } } diff --git a/src/deployer/SafeModule.sol b/src/deployer/SafeModule.sol index eed32ffa..a5172fae 100644 --- a/src/deployer/SafeModule.sol +++ b/src/deployer/SafeModule.sol @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.25; +import {DEPLOYER} from "./DeployerAddress.sol"; import {IDeployer, IDeployerRemove} from "./IDeployer.sol"; import {Feature} from "./Feature.sol"; import {Nonce} from "./Nonce.sol"; @@ -23,7 +24,7 @@ contract ZeroExSettlerDeployerSafeModule is IDeployerRemove { using Revert for bool; ISafeMinimal public immutable safe; - IDeployer public constant deployer = IDeployer(0x00000000000004533Fe15556B1E086BB1A72cEae); + IDeployer public constant deployer = IDeployer(DEPLOYER); constructor(address _safe) { assert(address(this) == 0x1CeC01DC0fFEE5eB5aF47DbEc1809F2A7c601C30 || block.chainid == 31337); diff --git a/test/deployer/Deployer.t.sol b/test/deployer/Deployer.t.sol index c36772bf..fbb22fe6 100644 --- a/test/deployer/Deployer.t.sol +++ b/test/deployer/Deployer.t.sol @@ -7,6 +7,7 @@ import {ERC1967UUPSProxy} from "src/proxy/ERC1967UUPSProxy.sol"; import {AddressDerivation} from "src/utils/AddressDerivation.sol"; import {Create3} from "src/utils/Create3.sol"; import {IERC1967Proxy} from "src/proxy/ERC1967UUPSUpgradeable.sol"; +import {DEPLOYER} from "src/deployer/DeployerAddress.sol"; import "@forge-std/Test.sol"; @@ -19,7 +20,7 @@ contract DeployerTest is Test { function setUp() public { vm.createSelectFork(vm.envString("MAINNET_RPC_URL"), 19921675); - deployer = Deployer(0x00000000000004533Fe15556B1E086BB1A72cEae); + deployer = Deployer(DEPLOYER); vm.label(address(deployer), "Deployer (proxy)"); vm.prank(deployer.owner()); From abd18dd44199648da103e219380cd2c3c5a586a0 Mon Sep 17 00:00:00 2001 From: Duncan Townsend Date: Mon, 16 Dec 2024 11:15:23 -0500 Subject: [PATCH 3/6] `forge fmt` --- src/chains/Blast/Common.sol | 6 +----- src/deployer/BlastDeployer.sol | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/chains/Blast/Common.sol b/src/chains/Blast/Common.sol index f371ed9e..eb92235a 100644 --- a/src/chains/Blast/Common.sol +++ b/src/chains/Blast/Common.sol @@ -47,11 +47,7 @@ abstract contract BlastMixin is FreeMemory, SettlerBase { constructor() { if (block.chainid != 31337) { assert(block.chainid == 81457); - BLAST.configure( - BlastYieldMode.AUTOMATIC, - BlastGasMode.CLAIMABLE, - IOwnable(DEPLOYER).owner() - ); + BLAST.configure(BlastYieldMode.AUTOMATIC, BlastGasMode.CLAIMABLE, IOwnable(DEPLOYER).owner()); BLAST_USDB.configure(BlastYieldMode.VOID); BLAST_WETH.configure(BlastYieldMode.VOID); } diff --git a/src/deployer/BlastDeployer.sol b/src/deployer/BlastDeployer.sol index d3d4d736..feb80e99 100644 --- a/src/deployer/BlastDeployer.sol +++ b/src/deployer/BlastDeployer.sol @@ -9,11 +9,7 @@ import {BLAST, BlastYieldMode, BlastGasMode} from "../chains/Blast/IBlast.sol"; contract BlastDeployer is Deployer { constructor(uint256 version) Deployer(version) { assert(block.chainid == 81457); - BLAST.configure( - BlastYieldMode.AUTOMATIC, - BlastGasMode.CLAIMABLE, - BlastDeployer(DEPLOYER).owner() - ); + BLAST.configure(BlastYieldMode.AUTOMATIC, BlastGasMode.CLAIMABLE, BlastDeployer(DEPLOYER).owner()); } function initialize(address initialOwner) public override { From 5a65bf57036250b36322f9993a50c58501e06dc7 Mon Sep 17 00:00:00 2001 From: Duncan Townsend Date: Mon, 16 Dec 2024 11:18:46 -0500 Subject: [PATCH 4/6] Make tests pass by making `rebateClaimer()` dynamically retrieve the deployer owner --- src/chains/Mainnet/Common.sol | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/chains/Mainnet/Common.sol b/src/chains/Mainnet/Common.sol index d7163842..9ec8f176 100644 --- a/src/chains/Mainnet/Common.sol +++ b/src/chains/Mainnet/Common.sol @@ -54,7 +54,6 @@ abstract contract MainnetMixin is { constructor() { assert(block.chainid == 1 || block.chainid == 31337); - rebateClaimer = IOwnable(DEPLOYER).owner(); } function _dispatch(uint256 i, uint256 action, bytes calldata data) @@ -142,5 +141,7 @@ abstract contract MainnetMixin is return 0x0c0e5f2fF0ff18a3be9b835635039256dC4B4963; } - address public immutable rebateClaimer; + function rebateClaimer() external view returns (address) { + return IOwnable(DEPLOYER).owner(); + } } From 81ee13d713f9b1dd49c0c0a6136c950ee4236bcd Mon Sep 17 00:00:00 2001 From: Duncan Townsend Date: Mon, 16 Dec 2024 11:20:14 -0500 Subject: [PATCH 5/6] `CHANGELOG.md` --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68d5f921..334ff2de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,7 @@ Master list of UniV3 forks: * Add `DODOV1` action to Mantle * Add `DODOV1` action to Polygon * Add `DODOV1` action to Scroll +* Add `rebateClaimer()(address)` function on Mainnet Settlers for gas rebate program ## 2024-12-14 From dfe3d72385e8e599ba000643ca45aef9b8e15729 Mon Sep 17 00:00:00 2001 From: Duncan Townsend Date: Mon, 16 Dec 2024 12:39:29 -0500 Subject: [PATCH 6/6] Relax solc version --- src/deployer/DeployerAddress.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/deployer/DeployerAddress.sol b/src/deployer/DeployerAddress.sol index 27082984..1cb28fa2 100644 --- a/src/deployer/DeployerAddress.sol +++ b/src/deployer/DeployerAddress.sol @@ -1,4 +1,4 @@ // SPDX-License-Identifier: MIT -pragma solidity =0.8.25; +pragma solidity ^0.8.25; address constant DEPLOYER = 0x00000000000004533Fe15556B1E086BB1A72cEae;