From 6280ced2480719f45cb5dd42c64f8f2a9090e651 Mon Sep 17 00:00:00 2001 From: Ivan Zhelyazkov Date: Fri, 10 Jan 2025 16:01:48 +0200 Subject: [PATCH] Carbon Batcher - minor fixes --- contracts/utility/CarbonBatcher.sol | 8 +++----- deploy/scripts/mainnet/0018-CarbonBatcher.ts | 3 +-- test/forge/CarbonBatcher.t.sol | 2 +- test/forge/TestFixture.t.sol | 4 ++-- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/contracts/utility/CarbonBatcher.sol b/contracts/utility/CarbonBatcher.sol index d8eba6fa..602f4671 100644 --- a/contracts/utility/CarbonBatcher.sol +++ b/contracts/utility/CarbonBatcher.sol @@ -32,12 +32,9 @@ contract CarbonBatcher is Upgradeable, Utils, ReentrancyGuard, IERC721Receiver { */ event FundsWithdrawn(Token indexed token, address indexed caller, address indexed target, uint256 amount); - constructor( - ICarbonController carbonControllerInit, - IVoucher voucherInit - ) validAddress(address(carbonControllerInit)) validAddress(address(voucherInit)) { - _carbonController = carbonControllerInit; + constructor(IVoucher voucherInit) validAddress(address(voucherInit)) { _voucher = voucherInit; + _carbonController = ICarbonController(_voucher.controller()); _disableInitializers(); } @@ -127,6 +124,7 @@ contract CarbonBatcher is Upgradeable, Utils, ReentrancyGuard, IERC721Receiver { /** * @notice withdraws funds held by the contract and sends them to an account + * @notice note that this is a safety mechanism, shouldn't be necessary in normal operation * * requirements: * diff --git a/deploy/scripts/mainnet/0018-CarbonBatcher.ts b/deploy/scripts/mainnet/0018-CarbonBatcher.ts index 1bd8f1d7..61f63ecc 100644 --- a/deploy/scripts/mainnet/0018-CarbonBatcher.ts +++ b/deploy/scripts/mainnet/0018-CarbonBatcher.ts @@ -5,13 +5,12 @@ import { HardhatRuntimeEnvironment } from 'hardhat/types'; const func: DeployFunction = async ({ getNamedAccounts }: HardhatRuntimeEnvironment) => { const { deployer } = await getNamedAccounts(); - const carbonController = await DeployedContracts.CarbonController.deployed(); const voucher = await DeployedContracts.Voucher.deployed(); await deployProxy({ name: InstanceName.CarbonBatcher, from: deployer, - args: [carbonController.address, voucher.address] + args: [voucher.address] }); return true; diff --git a/test/forge/CarbonBatcher.t.sol b/test/forge/CarbonBatcher.t.sol index 4973d514..f2654e28 100644 --- a/test/forge/CarbonBatcher.t.sol +++ b/test/forge/CarbonBatcher.t.sol @@ -43,7 +43,7 @@ contract CarbonBatcherTest is TestFixture { // Deploy Carbon Controller and Voucher setupCarbonController(); // Deploy Carbon Batcher - deployCarbonBatcher(carbonController, voucher); + deployCarbonBatcher(voucher); } /** diff --git a/test/forge/TestFixture.t.sol b/test/forge/TestFixture.t.sol index 086aa62d..2001cb8d 100644 --- a/test/forge/TestFixture.t.sol +++ b/test/forge/TestFixture.t.sol @@ -226,12 +226,12 @@ contract TestFixture is Test { /** * @dev deploys carbon batch strategies */ - function deployCarbonBatcher(TestCarbonController _carbonController, TestVoucher _voucher) internal { + function deployCarbonBatcher(TestVoucher _voucher) internal { // deploy contracts from admin vm.startPrank(admin); // Deploy Carbon Batch Strategies - carbonBatcher = new CarbonBatcher(ICarbonController(address(_carbonController)), IVoucher(address(_voucher))); + carbonBatcher = new CarbonBatcher(IVoucher(address(_voucher))); bytes memory initData = abi.encodeWithSelector(carbonBatcher.initialize.selector); // Deploy Carbon Batcher proxy