From e8531a852ebefae2e3edb4dbf489d7ef1bd7d536 Mon Sep 17 00:00:00 2001 From: lumoswiz Date: Wed, 12 Feb 2025 23:34:14 +0100 Subject: [PATCH 1/4] refactor: addresses to script utils --- cow-trader/bot.py | 2 +- smart-contract-infra/script/03_Deploy_MasterCopy.s.sol | 3 --- .../script/04_Deploy_TradingModuleProxy.s.sol | 3 --- smart-contract-infra/script/05_Enable_TradingModule.s.sol | 2 -- smart-contract-infra/script/ScriptUtils.sol | 6 ++++++ 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/cow-trader/bot.py b/cow-trader/bot.py index 23a4220..0ea7036 100644 --- a/cow-trader/bot.py +++ b/cow-trader/bot.py @@ -28,7 +28,7 @@ REASONING_FILEPATH = os.environ.get("REASONING_FILEPATH", ".db/reasoning.csv") # Addresses -SAFE_ADDRESS = "0xE1eB9cF168DB37c31B4bDf73511Bf44E2B8027Ef" # PLACEHOLDER +SAFE_ADDRESS = "0xbc3c7818177dA740292659b574D48B699Fdf0816" TOKEN_ALLOWLIST_ADDRESS = "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512" GPV2_SETTLEMENT_ADDRESS = "0x9008D19f58AAbD9eD0D60971565AA8510560ab41" diff --git a/smart-contract-infra/script/03_Deploy_MasterCopy.s.sol b/smart-contract-infra/script/03_Deploy_MasterCopy.s.sol index 0bb364d..b9c5eb1 100644 --- a/smart-contract-infra/script/03_Deploy_MasterCopy.s.sol +++ b/smart-contract-infra/script/03_Deploy_MasterCopy.s.sol @@ -27,9 +27,6 @@ interface ISingletonFactory { */ contract DeployMasterCopy is ScriptUtils { - address internal constant SINGLETON_FACTORY = 0xce0042B868300000d44A59004Da54A005ffdcf9f; - address internal constant ZERO_ADDRESS = address(0); - function run() external { uint256 pk = vm.envUint("PRIVATE_KEY"); diff --git a/smart-contract-infra/script/04_Deploy_TradingModuleProxy.s.sol b/smart-contract-infra/script/04_Deploy_TradingModuleProxy.s.sol index e67badd..32f766d 100644 --- a/smart-contract-infra/script/04_Deploy_TradingModuleProxy.s.sol +++ b/smart-contract-infra/script/04_Deploy_TradingModuleProxy.s.sol @@ -26,9 +26,6 @@ interface IModuleProxyFactory { --broadcast -vvvv */ contract DeployTradingModuleProxy is ScriptUtils { - address internal constant MODULE_PROXY_FACTORY = 0x000000000000aDdB49795b0f9bA5BC298cDda236; - address internal constant SAFE = 0x5aFE3855358E112B5647B952709E6165e1c1eEEe; - function run() external { uint256 pk = vm.envUint("PRIVATE_KEY"); diff --git a/smart-contract-infra/script/05_Enable_TradingModule.s.sol b/smart-contract-infra/script/05_Enable_TradingModule.s.sol index f05dcc2..04d9326 100644 --- a/smart-contract-infra/script/05_Enable_TradingModule.s.sol +++ b/smart-contract-infra/script/05_Enable_TradingModule.s.sol @@ -24,8 +24,6 @@ interface ISafe { --broadcast -vvvv */ contract EnableTradingModule is ScriptUtils { - address internal constant SAFE = 0x5aFE3855358E112B5647B952709E6165e1c1eEEe; - function run() external { uint256 pk = vm.envUint("PRIVATE_KEY"); diff --git a/smart-contract-infra/script/ScriptUtils.sol b/smart-contract-infra/script/ScriptUtils.sol index dc92932..1f52f41 100644 --- a/smart-contract-infra/script/ScriptUtils.sol +++ b/smart-contract-infra/script/ScriptUtils.sol @@ -9,6 +9,12 @@ contract ScriptUtils is Script { error AddressNotFound(string key); + address internal constant SAFE = 0xbc3c7818177dA740292659b574D48B699Fdf0816; + + address internal constant SINGLETON_FACTORY = 0xce0042B868300000d44A59004Da54A005ffdcf9f; + address internal constant MODULE_PROXY_FACTORY = 0x000000000000aDdB49795b0f9bA5BC298cDda236; + address internal constant ZERO_ADDRESS = address(0); + function _writeDeploymentAddress(address addr, string memory key) internal { string memory root = vm.projectRoot(); string memory path = string.concat(root, "/deployments/contracts.json"); From d21145dcccc2e57cd7828288ead889ff33740084 Mon Sep 17 00:00:00 2001 From: lumoswiz Date: Wed, 12 Feb 2025 23:41:54 +0100 Subject: [PATCH 2/4] feat: add tokens to allowlist script --- .../script/06_AddTokens_Allowlist.s.sol | 33 +++++++++++++++++++ smart-contract-infra/script/ScriptUtils.sol | 4 +++ 2 files changed, 37 insertions(+) create mode 100644 smart-contract-infra/script/06_AddTokens_Allowlist.s.sol diff --git a/smart-contract-infra/script/06_AddTokens_Allowlist.s.sol b/smart-contract-infra/script/06_AddTokens_Allowlist.s.sol new file mode 100644 index 0000000..7e7537f --- /dev/null +++ b/smart-contract-infra/script/06_AddTokens_Allowlist.s.sol @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.28; + +import { console2 } from "forge-std/Script.sol"; +import { ScriptUtils } from "script/ScriptUtils.sol"; +import { TokenAllowlist } from "src/TokenAllowlist.sol"; + +// Without verification: +/* + forge script script/06_AddTokens_Allowlist.s.sol \ + --rpc-url gnosis \ + --private-key $PRIVATE_KEY \ + --broadcast -vvvv +*/ + +contract AddTokensScript is ScriptUtils { + function run() external { + uint256 pk = vm.envUint("PRIVATE_KEY"); + + vm.startBroadcast(pk); + + TokenAllowlist allowlist = TokenAllowlist(_getDeploymentAddress(".allowlist")); + + address[] memory tokens = new address[](3); + tokens[0] = GNO; + tokens[1] = COW; + tokens[2] = WXDAI; + + allowlist.addTokensBatch(tokens); + + vm.stopBroadcast(); + } +} diff --git a/smart-contract-infra/script/ScriptUtils.sol b/smart-contract-infra/script/ScriptUtils.sol index 1f52f41..42708fc 100644 --- a/smart-contract-infra/script/ScriptUtils.sol +++ b/smart-contract-infra/script/ScriptUtils.sol @@ -15,6 +15,10 @@ contract ScriptUtils is Script { address internal constant MODULE_PROXY_FACTORY = 0x000000000000aDdB49795b0f9bA5BC298cDda236; address internal constant ZERO_ADDRESS = address(0); + address internal constant GNO = 0x9C58BAcC331c9aa871AFD802DB6379a98e80CEdb; + address internal constant COW = 0x177127622c4A00F3d409B75571e12cB3c8973d3c; + address internal constant WXDAI = 0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d; + function _writeDeploymentAddress(address addr, string memory key) internal { string memory root = vm.projectRoot(); string memory path = string.concat(root, "/deployments/contracts.json"); From 07ba24a376981fb5f4917013aac770875359f99b Mon Sep 17 00:00:00 2001 From: lumoswiz Date: Thu, 13 Feb 2025 00:31:46 +0100 Subject: [PATCH 3/4] chore: deployments + refactored scripts --- .../deployments/contracts.json | 19 ++++++--- .../script/03_Deploy_MasterCopy.s.sol | 2 +- ...ist.s.sol => 05_AddTokens_Allowlist.s.sol} | 2 +- .../script/05_Enable_TradingModule.s.sol | 39 ------------------- smart-contract-infra/src/TradingModule.sol | 3 -- 5 files changed, 15 insertions(+), 50 deletions(-) rename smart-contract-infra/script/{06_AddTokens_Allowlist.s.sol => 05_AddTokens_Allowlist.s.sol} (93%) delete mode 100644 smart-contract-infra/script/05_Enable_TradingModule.s.sol diff --git a/smart-contract-infra/deployments/contracts.json b/smart-contract-infra/deployments/contracts.json index df30277..b903e25 100644 --- a/smart-contract-infra/deployments/contracts.json +++ b/smart-contract-infra/deployments/contracts.json @@ -1,5 +1,12 @@ { - "deployedChains": [1, 100, 8453, 31337, 42161, 11155111], + "deployedChains": [ + 1, + 100, + 8453, + 31337, + 42161, + 11155111 + ], "chains": { "1": { "allowlist": "0x0000000000000000000000000000000000000000", @@ -8,10 +15,10 @@ "tradingModuleProxy": "0x0000000000000000000000000000000000000000" }, "100": { - "allowlist": "0x0000000000000000000000000000000000000000", - "guard": "0x0000000000000000000000000000000000000000", - "tradingModuleMasterCopy": "0x0000000000000000000000000000000000000000", - "tradingModuleProxy": "0x0000000000000000000000000000000000000000" + "allowlist": "0x98a4351d926e6274829c3807f39D9a7037462589", + "guard": "0xcab68170145d593F15BF398670876CcCBFe173e2", + "tradingModuleMasterCopy": "0xE0e75802Fb63B1a3b55862D9e217f902bd4e33f8", + "tradingModuleProxy": "0x920b3D833E5663CF700B17DcF119Ac697E340621" }, "8453": { "allowlist": "0x0000000000000000000000000000000000000000", @@ -38,4 +45,4 @@ "tradingModuleProxy": "0x0000000000000000000000000000000000000000" } } -} +} \ No newline at end of file diff --git a/smart-contract-infra/script/03_Deploy_MasterCopy.s.sol b/smart-contract-infra/script/03_Deploy_MasterCopy.s.sol index b9c5eb1..3477ac3 100644 --- a/smart-contract-infra/script/03_Deploy_MasterCopy.s.sol +++ b/smart-contract-infra/script/03_Deploy_MasterCopy.s.sol @@ -31,7 +31,7 @@ contract DeployMasterCopy is ScriptUtils { uint256 pk = vm.envUint("PRIVATE_KEY"); bytes memory creationCode = type(TradingModule).creationCode; - bytes memory constructorArgs = abi.encode(ZERO_ADDRESS, ZERO_ADDRESS, ZERO_ADDRESS); + bytes memory constructorArgs = abi.encode(vm.addr(pk), ZERO_ADDRESS, ZERO_ADDRESS); bytes memory initCode = abi.encodePacked(creationCode, constructorArgs); bytes32 salt = keccak256(abi.encodePacked("TradingModuleV1")); diff --git a/smart-contract-infra/script/06_AddTokens_Allowlist.s.sol b/smart-contract-infra/script/05_AddTokens_Allowlist.s.sol similarity index 93% rename from smart-contract-infra/script/06_AddTokens_Allowlist.s.sol rename to smart-contract-infra/script/05_AddTokens_Allowlist.s.sol index 7e7537f..f9d4f95 100644 --- a/smart-contract-infra/script/06_AddTokens_Allowlist.s.sol +++ b/smart-contract-infra/script/05_AddTokens_Allowlist.s.sol @@ -7,7 +7,7 @@ import { TokenAllowlist } from "src/TokenAllowlist.sol"; // Without verification: /* - forge script script/06_AddTokens_Allowlist.s.sol \ + forge script script/05_AddTokens_Allowlist.s.sol \ --rpc-url gnosis \ --private-key $PRIVATE_KEY \ --broadcast -vvvv diff --git a/smart-contract-infra/script/05_Enable_TradingModule.s.sol b/smart-contract-infra/script/05_Enable_TradingModule.s.sol deleted file mode 100644 index 04d9326..0000000 --- a/smart-contract-infra/script/05_Enable_TradingModule.s.sol +++ /dev/null @@ -1,39 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.28; - -import { console2 } from "forge-std/Script.sol"; -import { ScriptUtils } from "script/ScriptUtils.sol"; - -interface ISafe { - function enableModule(address module) external; -} - -// With verification: -/* - forge script script/05_Enable_TradingModule.s.sol \ - --rpc-url gnosis \ - --private-key $PRIVATE_KEY \ - --broadcast -vvvv -*/ - -// Without verification: -/* - forge script script/05_Enable_TradingModule.s.sol \ - --rpc-url gnosis \ - --private-key $PRIVATE_KEY \ - --broadcast -vvvv -*/ -contract EnableTradingModule is ScriptUtils { - function run() external { - uint256 pk = vm.envUint("PRIVATE_KEY"); - - address tradingModuleProxy = _getDeploymentAddress(".tradingModuleProxy"); - - vm.startBroadcast(pk); - - ISafe(SAFE).enableModule(tradingModuleProxy); - console2.log("Enabled TradingModule:", tradingModuleProxy); - - vm.stopBroadcast(); - } -} diff --git a/smart-contract-infra/src/TradingModule.sol b/smart-contract-infra/src/TradingModule.sol index c7265f8..fd9a10c 100644 --- a/smart-contract-infra/src/TradingModule.sol +++ b/smart-contract-infra/src/TradingModule.sol @@ -40,9 +40,6 @@ contract TradingModule is Module, Guardable { function setUp(bytes memory initParams) public override initializer { (address _owner, address _avatar, address _target) = abi.decode(initParams, (address, address, address)); - require(_avatar != address(0)); - require(_target != address(0)); - __Ownable_init(msg.sender); setAvatar(_avatar); From 49955a99ca1dbafbb979cb1ca33eede8f4afce1f Mon Sep 17 00:00:00 2001 From: lumoswiz Date: Thu, 13 Feb 2025 00:35:16 +0100 Subject: [PATCH 4/4] fix: linting --- smart-contract-infra/deployments/contracts.json | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/smart-contract-infra/deployments/contracts.json b/smart-contract-infra/deployments/contracts.json index b903e25..22fe17d 100644 --- a/smart-contract-infra/deployments/contracts.json +++ b/smart-contract-infra/deployments/contracts.json @@ -1,12 +1,5 @@ { - "deployedChains": [ - 1, - 100, - 8453, - 31337, - 42161, - 11155111 - ], + "deployedChains": [1, 100, 8453, 31337, 42161, 11155111], "chains": { "1": { "allowlist": "0x0000000000000000000000000000000000000000", @@ -45,4 +38,4 @@ "tradingModuleProxy": "0x0000000000000000000000000000000000000000" } } -} \ No newline at end of file +}