From b9a3dfd681007bf58e436d8d7d596f7b56a07d90 Mon Sep 17 00:00:00 2001 From: neokry Date: Thu, 2 Nov 2023 13:14:33 +0700 Subject: [PATCH] use protocol rewards in merkle minter --- addresses/84531.json | 4 ++-- script/DeployV2New.s.sol | 8 +++----- src/minters/MerkleReserveMinter.sol | 25 +++++++++++-------------- test/L2MigrationDeployer.t.sol | 2 +- test/MerkleReserveMinter.t.sol | 2 +- 5 files changed, 18 insertions(+), 23 deletions(-) diff --git a/addresses/84531.json b/addresses/84531.json index 8df0853..ff0675d 100644 --- a/addresses/84531.json +++ b/addresses/84531.json @@ -3,8 +3,8 @@ "WETH": "0x4200000000000000000000000000000000000006", "CrossDomainMessenger": "0x4200000000000000000000000000000000000007", "ProtocolRewards": "0x7777777F279eba3d3Ad8F4E708545291A6fDBA8B", - "Manager": "0x5e89c0d43b47af1855b1033fc5b80845ba859c3f", - "ManagerImpl": "0x2c3b472e6f7bafa4f1bd3c5728388e1c046a3a73", + "Manager": "0x5d5a243a69128db6fab3a65d9929ff85a7774571", + "ManagerImpl": "0x5e89c0d43b47af1855b1033fc5b80845ba859c3f", "Auction": "0x6199de26c88d3630e3cf2758b20fb6f59d595092", "Token": "0x3175bcde4eb750952d030079fea1acf3055101df", "MetadataRenderer": "0x05938e558a8d73ea0685e305c82edf115bb55121", diff --git a/script/DeployV2New.s.sol b/script/DeployV2New.s.sol index a2c26a0..0bcab41 100644 --- a/script/DeployV2New.s.sol +++ b/script/DeployV2New.s.sol @@ -26,7 +26,7 @@ contract DeployContracts is Script { address deployerAddress = vm.addr(key); address managerAddress = _getKey("Manager"); - address builderAddress = _getKey("BuilderDAO"); + address protocolRewards = _getKey("ProtocolRewards"); address crossDomainMessenger = _getKey("CrossDomainMessenger"); console2.log("~~~~~~~~~~ CHAIN ID ~~~~~~~~~~~"); @@ -38,13 +38,11 @@ contract DeployContracts is Script { console2.log("~~~~~~~~~~ MANAGER ~~~~~~~~~~~"); console2.log(managerAddress); - Manager manager = Manager(managerAddress); - vm.startBroadcast(deployerAddress); - address merkleMinter = address(new MerkleReserveMinter(manager, builderAddress)); + address merkleMinter = address(new MerkleReserveMinter(managerAddress, protocolRewards)); - address migrationDeployer = address(new L2MigrationDeployer(address(manager), merkleMinter, crossDomainMessenger)); + address migrationDeployer = address(new L2MigrationDeployer(managerAddress, merkleMinter, crossDomainMessenger)); vm.stopBroadcast(); diff --git a/src/minters/MerkleReserveMinter.sol b/src/minters/MerkleReserveMinter.sol index 3f89e1d..3017825 100644 --- a/src/minters/MerkleReserveMinter.sol +++ b/src/minters/MerkleReserveMinter.sol @@ -4,7 +4,8 @@ pragma solidity 0.8.16; import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; import { IOwnable } from "../lib/interfaces/IOwnable.sol"; import { IToken } from "../token/IToken.sol"; -import { IManager } from "../manager/IManager.sol"; +import { Manager } from "../manager/Manager.sol"; +import { IProtocolRewards } from "../lib/interfaces/IProtocolRewards.sol"; /// @title MerkleReserveMinter /// @notice A mint strategy that mints reserved tokens based on a merkle tree @@ -83,10 +84,10 @@ contract MerkleReserveMinter { /// /// /// @notice Manager contract - IManager immutable manager; + Manager immutable manager; - /// @notice Address to send BuilderDAO fees - address immutable builderFundsRecipent; + /// @notice Protocol rewards contract + IProtocolRewards immutable protocolRewards; /// /// /// STORAGE /// @@ -113,9 +114,9 @@ contract MerkleReserveMinter { /// CONSTRUCTOR /// /// /// - constructor(IManager _manager, address _builderFundsRecipent) { - manager = _manager; - builderFundsRecipent = _builderFundsRecipent; + constructor(address _manager, address _protocolRewards) { + manager = Manager(_manager); + protocolRewards = IProtocolRewards(_protocolRewards); } /// /// @@ -190,21 +191,17 @@ contract MerkleReserveMinter { uint256 value = msg.value; (, , address treasury, ) = manager.getAddresses(tokenContract); + address builderRecipient = manager.builderRewardsRecipient(); // Pay out fees to the Builder DAO - (bool builderSuccess, ) = builderFundsRecipent.call{ value: builderFee }(""); - - // Revert if Builder DAO recipent cannot accept funds - if (!builderSuccess) { - revert TRANSFER_FAILED(); - } + protocolRewards.deposit{ value: builderFee }(builderRecipient, hex"00", ""); // Pay out remaining funds to the treasury if (value > builderFee) { (bool treasurySuccess, ) = treasury.call{ value: value - builderFee }(""); // Revert if treasury cannot accept funds - if (!builderSuccess || !treasurySuccess) { + if (!treasurySuccess) { revert TRANSFER_FAILED(); } } diff --git a/test/L2MigrationDeployer.t.sol b/test/L2MigrationDeployer.t.sol index 0000284..b04b41b 100644 --- a/test/L2MigrationDeployer.t.sol +++ b/test/L2MigrationDeployer.t.sol @@ -22,7 +22,7 @@ contract L2MigrationDeployerTest is NounsBuilderTest { function setUp() public virtual override { super.setUp(); - minter = new MerkleReserveMinter(manager, zoraDAO); + minter = new MerkleReserveMinter(address(manager), rewards); xDomainMessenger = new MockCrossDomainMessenger(founder); deployer = new L2MigrationDeployer(address(manager), address(minter), address(xDomainMessenger)); } diff --git a/test/MerkleReserveMinter.t.sol b/test/MerkleReserveMinter.t.sol index 3da5d1b..37457ca 100644 --- a/test/MerkleReserveMinter.t.sol +++ b/test/MerkleReserveMinter.t.sol @@ -14,7 +14,7 @@ contract MerkleReserveMinterTest is NounsBuilderTest { function setUp() public virtual override { super.setUp(); - minter = new MerkleReserveMinter(manager, zoraDAO); + minter = new MerkleReserveMinter(address(manager), rewards); claimer1 = address(0xC1); claimer2 = address(0xC2); }