From 13120cafe249c93adfb2cf001f6e52b63a0f0ebf Mon Sep 17 00:00:00 2001 From: vicnaum Date: Tue, 18 Apr 2023 20:27:47 +0200 Subject: [PATCH 1/4] deploy: SimpleFeeCollect Module deployed on all networks --- addresses.json | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addresses.json b/addresses.json index 42e5376..e5fa8c8 100644 --- a/addresses.json +++ b/addresses.json @@ -11,7 +11,8 @@ "StepwiseCollectModule": "0x210c94877dcfceda8238acd382372278844a54d7", "ERC4626FeeCollectModule": "0x394fd100b13197787023ef4cf318cde456545db7", "AaveFeeCollectModule": "0xa94713d0688c8a483c3352635cec4e0ce88d6a29", - "TokenGatedReferenceModule": "0x3d7f4f71a90fe5a9d13fab2716080f2917cf88f3" + "TokenGatedReferenceModule": "0x3d7f4f71a90fe5a9d13fab2716080f2917cf88f3", + "SimpleFeeCollectModule": "0x54325d507ed1b3776c146700eff61a98b45aec76" }, "testnet": { "chainId": 80001, @@ -25,7 +26,8 @@ "StepwiseCollectModule": "0x7a7b8e7699e0492da1d3c7eab7e2f3bf1065aa40", "ERC4626FeeCollectModule": "0x79697402bd2caa19a53d615fb1a30a98e35b84d5", "AaveFeeCollectModule": "0x912860ed4ed6160c48a52d52fcab5c059d34fe5a", - "TokenGatedReferenceModule": "0xb4ba8dccd35bd3dcc5d58dbb9c7dff9c9268add9" + "TokenGatedReferenceModule": "0xb4ba8dccd35bd3dcc5d58dbb9c7dff9c9268add9", + "SimpleFeeCollectModule": "0xb4a9874adc790eec88fd086e43d329bbc9520efd" }, "sandbox": { "chainId": 80001, @@ -39,6 +41,7 @@ "StepwiseCollectModule": "0x6928d6127dfa0da401737e6ff421fcf62d5617a3", "ERC4626FeeCollectModule": "0x31126c602cf88193825a99dcd1d17bf1124b1b4f", "AaveFeeCollectModule": "0x666e06215747879ee68b3e5a317dcd8411de1897", - "TokenGatedReferenceModule": "0x86d35562ceb9f10d7c2c23c098dfeacb02f53853" + "TokenGatedReferenceModule": "0x86d35562ceb9f10d7c2c23c098dfeacb02f53853", + "SimpleFeeCollectModule": "0xbeac9c00383d04054dbc82a44f8dc8d9be995fd8" } } From 704b5ce2a74b1c62b5039d40dcbc58ee42366fd4 Mon Sep 17 00:00:00 2001 From: vicnaum Date: Tue, 18 Apr 2023 20:29:03 +0200 Subject: [PATCH 2/4] misc: Add SimpleFeeCollect deployment script --- script/deploy-module.s.sol | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/script/deploy-module.s.sol b/script/deploy-module.s.sol index fbce422..0de6854 100644 --- a/script/deploy-module.s.sol +++ b/script/deploy-module.s.sol @@ -4,6 +4,7 @@ pragma solidity ^0.8.10; import 'forge-std/Script.sol'; import 'forge-std/StdJson.sol'; import {StepwiseCollectModule} from 'contracts/collect/StepwiseCollectModule.sol'; +import {SimpleFeeCollectModule} from 'contracts/collect/SimpleFeeCollectModule.sol'; import {MultirecipientFeeCollectModule} from 'contracts/collect/MultirecipientFeeCollectModule.sol'; import {AaveFeeCollectModule} from 'contracts/collect/AaveFeeCollectModule.sol'; import {ERC4626FeeCollectModule} from 'contracts/collect/ERC4626FeeCollectModule.sol'; @@ -94,6 +95,24 @@ contract DeployMultirecipientFeeCollectModule is DeployBase { } } +contract DeploySimpleFeeCollectModule is DeployBase { + function deploy() internal override returns (address) { + console.log('\nContract: SimpleFeeCollectModule'); + console.log('Init params:'); + console.log('\tLensHubProxy:', lensHubProxy); + console.log('\tModuleGlobals:', moduleGlobals); + + vm.startBroadcast(deployerPrivateKey); + SimpleFeeCollectModule module = new SimpleFeeCollectModule(lensHubProxy, moduleGlobals); + vm.stopBroadcast(); + + console.log('Constructor arguments:'); + console.logBytes(abi.encode(lensHubProxy, moduleGlobals)); + + return address(module); + } +} + import {IPoolAddressesProvider} from '@aave/core-v3/contracts/interfaces/IPoolAddressesProvider.sol'; contract DeployAaveFeeCollectModule is DeployBase { From 78600341e44f66990547feb43bb08ad0f600cee1 Mon Sep 17 00:00:00 2001 From: vicnaum Date: Tue, 18 Apr 2023 20:29:35 +0200 Subject: [PATCH 3/4] test: Fix tests to work with sandbox and refactor SimpleFeeCollect test --- test/foundry/BaseSetup.t.sol | 5 ++++- .../collect/BaseFeeCollectModule.base.sol | 21 +++++++++++++++---- .../collect/BaseFeeCollectModule.test.sol | 4 ++-- .../collect/StepwiseCollectModule.test.sol | 6 +++--- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/test/foundry/BaseSetup.t.sol b/test/foundry/BaseSetup.t.sol index 8608ed3..b6eb170 100644 --- a/test/foundry/BaseSetup.t.sol +++ b/test/foundry/BaseSetup.t.sol @@ -29,6 +29,7 @@ contract BaseSetup is Test, ForkManagement { uint256 firstProfileId; address deployer; address governance; + address modulesGovernance; address treasury; address constant publisher = address(4); @@ -109,6 +110,7 @@ contract BaseSetup is Test, ForkManagement { governance = hub.getGovernance(); treasury = moduleGlobals.getTreasury(); + modulesGovernance = moduleGlobals.getGovernance(); TREASURY_FEE_BPS = moduleGlobals.getTreasuryFee(); } @@ -118,6 +120,7 @@ contract BaseSetup is Test, ForkManagement { deployer = address(1); governance = address(2); treasury = address(3); + modulesGovernance = address(4); TREASURY_FEE_BPS = 50; @@ -149,7 +152,7 @@ contract BaseSetup is Test, ForkManagement { // Deploy the FreeCollectModule. freeCollectModule = new FreeCollectModule(hubProxyAddr); - moduleGlobals = new ModuleGlobals(governance, treasury, TREASURY_FEE_BPS); + moduleGlobals = new ModuleGlobals(modulesGovernance, treasury, TREASURY_FEE_BPS); currency = new Currency(); nft = new NFT(); diff --git a/test/foundry/collect/BaseFeeCollectModule.base.sol b/test/foundry/collect/BaseFeeCollectModule.base.sol index 0079c09..f173d87 100644 --- a/test/foundry/collect/BaseFeeCollectModule.base.sol +++ b/test/foundry/collect/BaseFeeCollectModule.base.sol @@ -7,7 +7,9 @@ import {SimpleFeeCollectModule} from 'contracts/collect/SimpleFeeCollectModule.s import {BaseFeeCollectModuleInitData} from 'contracts/collect/base/IBaseFeeCollectModule.sol'; contract BaseFeeCollectModuleBase is BaseSetup { + using stdJson for string; address baseFeeCollectModule; + SimpleFeeCollectModule simpleFeeCollectModule; BaseFeeCollectModuleInitData exampleInitData; @@ -16,10 +18,21 @@ contract BaseFeeCollectModuleBase is BaseSetup { // Deploy & Whitelist BaseFeeCollectModule constructor() BaseSetup() { - vm.prank(deployer); - baseFeeCollectModule = address( - new SimpleFeeCollectModule(hubProxyAddr, address(moduleGlobals)) - ); + if (fork && keyExists(string(abi.encodePacked('.', forkEnv, '.SimpleFeeCollectModule')))) { + simpleFeeCollectModule = SimpleFeeCollectModule( + json.readAddress(string(abi.encodePacked('.', forkEnv, '.SimpleFeeCollectModule'))) + ); + baseFeeCollectModule = address(simpleFeeCollectModule); + console.log( + 'Testing against already deployed module at:', + address(baseFeeCollectModule) + ); + } else { + vm.prank(deployer); + baseFeeCollectModule = address( + new SimpleFeeCollectModule(hubProxyAddr, address(moduleGlobals)) + ); + } vm.prank(governance); hub.whitelistCollectModule(address(baseFeeCollectModule), true); } diff --git a/test/foundry/collect/BaseFeeCollectModule.test.sol b/test/foundry/collect/BaseFeeCollectModule.test.sol index 26a76f9..8d20503 100644 --- a/test/foundry/collect/BaseFeeCollectModule.test.sol +++ b/test/foundry/collect/BaseFeeCollectModule.test.sol @@ -609,7 +609,7 @@ contract BaseFeeCollectModule_FeeDistribution is BaseFeeCollectModuleBase { } function verifyFeesWithoutMirror(uint16 treasuryFee, uint128 amount) public { - vm.prank(governance); + vm.prank(modulesGovernance); moduleGlobals.setTreasuryFee(treasuryFee); (uint256 pubId, ) = hubPostAndMirror(0, amount); @@ -676,7 +676,7 @@ contract BaseFeeCollectModule_FeeDistribution is BaseFeeCollectModuleBase { uint16 referralFee, uint128 amount ) public { - vm.prank(governance); + vm.prank(modulesGovernance); moduleGlobals.setTreasuryFee(treasuryFee); (, uint256 mirrorId) = hubPostAndMirror(referralFee, amount); diff --git a/test/foundry/collect/StepwiseCollectModule.test.sol b/test/foundry/collect/StepwiseCollectModule.test.sol index 53539f5..476708d 100644 --- a/test/foundry/collect/StepwiseCollectModule.test.sol +++ b/test/foundry/collect/StepwiseCollectModule.test.sol @@ -651,7 +651,7 @@ contract StepwiseCollectModule_FeeDistribution is StepwiseCollectModuleBase { } function verifyFeesWithoutMirror(uint16 treasuryFee, uint128 amount) public { - vm.prank(governance); + vm.prank(modulesGovernance); moduleGlobals.setTreasuryFee(treasuryFee); (uint256 pubId, ) = hubPostAndMirror(exampleInitData, 0, amount); @@ -718,7 +718,7 @@ contract StepwiseCollectModule_FeeDistribution is StepwiseCollectModuleBase { uint16 referralFee, uint128 amount ) public { - vm.prank(governance); + vm.prank(modulesGovernance); moduleGlobals.setTreasuryFee(treasuryFee); (uint256 pubId, uint256 mirrorId) = hubPostAndMirror(exampleInitData, referralFee, amount); @@ -903,7 +903,7 @@ contract StepwiseCollectModule_StepwiseCurveFormula is StepwiseCollectModuleBase }) ); - vm.prank(governance); + vm.prank(modulesGovernance); moduleGlobals.setTreasuryFee(0); } From 45dfd20caf57d3918ad61b7c37d21ce8526b6727 Mon Sep 17 00:00:00 2001 From: vicnaum Date: Tue, 18 Apr 2023 20:44:50 +0200 Subject: [PATCH 4/4] test: fix module governance prank --- test/foundry/BaseSetup.t.sol | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/foundry/BaseSetup.t.sol b/test/foundry/BaseSetup.t.sol index b6eb170..75781a4 100644 --- a/test/foundry/BaseSetup.t.sol +++ b/test/foundry/BaseSetup.t.sol @@ -192,11 +192,12 @@ contract BaseSetup is Test, ForkManagement { // Whitelist the test contract as a profile creator hub.whitelistProfileCreator(me, true); + vm.stopPrank(); // Whitelist mock currency in ModuleGlobals + vm.prank(modulesGovernance); moduleGlobals.whitelistCurrency(address(currency), true); - vm.stopPrank(); ///////////////////////////////////////// End governance actions. }