Skip to content

Commit

Permalink
use protocol rewards in merkle minter
Browse files Browse the repository at this point in the history
  • Loading branch information
neokry committed Nov 2, 2023
1 parent d324922 commit b9a3dfd
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 23 deletions.
4 changes: 2 additions & 2 deletions addresses/84531.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"WETH": "0x4200000000000000000000000000000000000006",
"CrossDomainMessenger": "0x4200000000000000000000000000000000000007",
"ProtocolRewards": "0x7777777F279eba3d3Ad8F4E708545291A6fDBA8B",
"Manager": "0x5e89c0d43b47af1855b1033fc5b80845ba859c3f",
"ManagerImpl": "0x2c3b472e6f7bafa4f1bd3c5728388e1c046a3a73",
"Manager": "0x5d5a243a69128db6fab3a65d9929ff85a7774571",
"ManagerImpl": "0x5e89c0d43b47af1855b1033fc5b80845ba859c3f",
"Auction": "0x6199de26c88d3630e3cf2758b20fb6f59d595092",
"Token": "0x3175bcde4eb750952d030079fea1acf3055101df",
"MetadataRenderer": "0x05938e558a8d73ea0685e305c82edf115bb55121",
Expand Down
8 changes: 3 additions & 5 deletions script/DeployV2New.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 ~~~~~~~~~~~");
Expand All @@ -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();

Expand Down
25 changes: 11 additions & 14 deletions src/minters/MerkleReserveMinter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ///
Expand All @@ -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);
}

/// ///
Expand Down Expand Up @@ -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();
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/L2MigrationDeployer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion test/MerkleReserveMinter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit b9a3dfd

Please sign in to comment.