From cc7667c5c9acae6aa15904a69105173512a38ff9 Mon Sep 17 00:00:00 2001 From: 0xchin Date: Wed, 20 Nov 2024 04:32:47 -0300 Subject: [PATCH] feat: send owner as constructor arg --- script/Deploy.sol | 15 +++++++++++++-- src/contracts/Grateful.sol | 6 ++++-- test/integration/IntegrationBase.sol | 6 ++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/script/Deploy.sol b/script/Deploy.sol index bcd1041..08f3a27 100644 --- a/script/Deploy.sol +++ b/script/Deploy.sol @@ -28,6 +28,7 @@ contract Deploy is Script { uint256 public constant CHAIN_ARBITRUM_SEPOLIA = 421_614; address public constant GRATEFUL_MULTISIG = 0xbC4d66e4FA462d4deeb77495E7Aa51Bb8034710b; + address public constant DEV_ADDRESS = 0xe84DbC4EE14b0360B7bF87c7d30Cd0604E0e1E0F; /*////////////////////////////////////////////////////////////// STRUCTS @@ -41,6 +42,7 @@ contract Deploy is Script { struct DeploymentParams { address[] tokens; + address owner; IPool aavePool; uint256 initialFee; uint256 initialPerformanceFee; @@ -84,6 +86,7 @@ contract Deploy is Script { params = DeploymentParams({ tokens: _tokens, + owner: GRATEFUL_MULTISIG, aavePool: IPool(0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2), initialFee: 0.01 ether, // 1% initialPerformanceFee: 0.05 ether, // 5% @@ -117,6 +120,7 @@ contract Deploy is Script { params = DeploymentParams({ tokens: _tokens, + owner: GRATEFUL_MULTISIG, aavePool: IPool(0x794a61358D6845594F94dc1DB02A252b5b4814aD), initialFee: 0.01 ether, // 1% initialPerformanceFee: 0.05 ether, // 5% @@ -150,6 +154,7 @@ contract Deploy is Script { params = DeploymentParams({ tokens: _tokens, + owner: GRATEFUL_MULTISIG, aavePool: IPool(0x794a61358D6845594F94dc1DB02A252b5b4814aD), initialFee: 0.01 ether, // 1% initialPerformanceFee: 0.05 ether, // 5% @@ -183,6 +188,7 @@ contract Deploy is Script { params = DeploymentParams({ tokens: _tokens, + owner: GRATEFUL_MULTISIG, aavePool: IPool(0x794a61358D6845594F94dc1DB02A252b5b4814aD), initialFee: 0.01 ether, // 1% initialPerformanceFee: 0.05 ether, // 5% @@ -210,6 +216,7 @@ contract Deploy is Script { params = DeploymentParams({ tokens: _tokens, + owner: GRATEFUL_MULTISIG, aavePool: IPool(0x6807dc923806fE8Fd134338EABCA509979a7e0cB), initialFee: 0.01 ether, // 1% initialPerformanceFee: 0.05 ether, // 5% @@ -228,6 +235,7 @@ contract Deploy is Script { params = DeploymentParams({ tokens: _tokens, + owner: GRATEFUL_MULTISIG, aavePool: IPool(0xb50201558B00496A145fE76f7424749556E326D8), initialFee: 0.01 ether, // 1% initialPerformanceFee: 0.05 ether, // 5% @@ -249,6 +257,7 @@ contract Deploy is Script { params = DeploymentParams({ tokens: _tokens, + owner: GRATEFUL_MULTISIG, aavePool: IPool(0xA238Dd80C259a72e81d7e4664a9801593F98d1c5), initialFee: 0.01 ether, // 1% initialPerformanceFee: 0.05 ether, // 5% @@ -267,6 +276,7 @@ contract Deploy is Script { params = DeploymentParams({ tokens: _tokens, + owner: DEV_ADDRESS, aavePool: IPool(0xb50201558B00496A145fE76f7424749556E326D8), initialFee: 0.01 ether, // 1% initialPerformanceFee: 0.05 ether, // 5% @@ -285,6 +295,7 @@ contract Deploy is Script { params = DeploymentParams({ tokens: _tokens, + owner: DEV_ADDRESS, aavePool: IPool(0xBfC91D59fdAA134A4ED45f7B584cAf96D7792Eff), initialFee: 0.01 ether, // 1% initialPerformanceFee: 0.05 ether, // 5% @@ -302,8 +313,8 @@ contract Deploy is Script { vm.startBroadcast(); } - grateful = new Grateful(_params.tokens, _params.aavePool, _params.initialFee, _params.initialPerformanceFee); - grateful.transferOwnership(GRATEFUL_MULTISIG); + grateful = + new Grateful(_params.tokens, _params.aavePool, _params.initialFee, _params.initialPerformanceFee, _params.owner); // Deploy vaults and add them to Grateful uint256 vaultsLength = _params.vaults.length; diff --git a/src/contracts/Grateful.sol b/src/contracts/Grateful.sol index f2dd445..f85dd0f 100644 --- a/src/contracts/Grateful.sol +++ b/src/contracts/Grateful.sol @@ -103,13 +103,15 @@ contract Grateful is IGrateful, Ownable2Step, ReentrancyGuard { * @param _tokens Array of token addresses to whitelist. * @param _aavePool Address of the Aave V3 pool. * @param _initialFee Initial fee in fixed-point (1 ether = 100%). + * @param _owner Address of the contract owner. */ constructor( address[] memory _tokens, IPool _aavePool, uint256 _initialFee, - uint256 _initialPerformanceFee - ) Ownable(msg.sender) { + uint256 _initialPerformanceFee, + address _owner + ) Ownable(_owner) { if (address(_aavePool) == address(0)) { revert Grateful_InvalidAddress(); } diff --git a/test/integration/IntegrationBase.sol b/test/integration/IntegrationBase.sol index e1d40f0..9aa9fb8 100644 --- a/test/integration/IntegrationBase.sol +++ b/test/integration/IntegrationBase.sol @@ -39,7 +39,7 @@ contract IntegrationBase is Test, Deploy { address internal _user = makeAddr("user"); address internal _merchant = makeAddr("merchant"); address internal _merchant2 = makeAddr("user2"); - address internal _owner = makeAddr("owner"); + address internal _owner; address internal _gratefulAutomation = makeAddr("gratefulAutomation"); // Tokens array @@ -64,11 +64,13 @@ contract IntegrationBase is Test, Deploy { // Use fork block from deployment parameters vm.createSelectFork(vm.rpcUrl(forkedNetwork), forkBlock); - vm.startPrank(_owner); // Get deployment parameters DeploymentParams memory params = getDeploymentParams(block.chainid); + _owner = params.owner; + vm.startPrank(_owner); + // Copy tokens to storage variable _tokens uint256 tokensLength = params.tokens.length; _tokens = new address[](tokensLength);