Skip to content

Commit

Permalink
Add reason to protocol rewards and improve upgrade script
Browse files Browse the repository at this point in the history
  • Loading branch information
neokry committed Jan 29, 2024
1 parent 989291a commit 48540bb
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 24 deletions.
2 changes: 2 additions & 0 deletions addresses/1.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"BuilderDAO": "0x7498e6e471f31e869f038D8DBffbDFdf650c3F95",
"ProtocolRewards": "0x7777777F279eba3d3Ad8F4E708545291A6fDBA8B",
"Manager": "0xd310a3041dfcf14def5ccbc508668974b5da7174",
"ManagerImpl": "0x138D8Aef5Cbbbb9Ea8da98CC0847FE0F3b573b40",
"WETH": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
Expand Down
3 changes: 3 additions & 0 deletions addresses/420.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"BuilderDAO": "0x7498e6e471f31e869f038D8DBffbDFdf650c3F95",
"ProtocolRewards": "0x7777777F279eba3d3Ad8F4E708545291A6fDBA8B",
"CrossDomainMessenger": "0x4200000000000000000000000000000000000007",
"Manager": "0x5f9c1e7e31875beaa6ba6b0ab573a4abecc95d67",
"ManagerImpl": "0x93f9d43a7bd751f8546a54785ae48d049ddd2697",
"WETH": "0x4200000000000000000000000000000000000006",
Expand Down
16 changes: 7 additions & 9 deletions addresses/84531.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
"WETH": "0x4200000000000000000000000000000000000006",
"CrossDomainMessenger": "0x4200000000000000000000000000000000000007",
"ProtocolRewards": "0x7777777F279eba3d3Ad8F4E708545291A6fDBA8B",
"Manager": "0xcce64c2b4c51c2894fe5df0dda3e34e4d850b699",
"ManagerImpl": "0x2474f9cbaf0d44192eeb28bd2f0646832f69b3e9",
"Auction": "0x4220f838ff74091c89118e815675116a0b9c3bb1",
"Token": "0xea48534d98dbf46cee0456f14f6bc4ac3bb8c101",
"MetadataRenderer": "0xf81bbb4d924496c4976f745fc758cf54d0496777",
"Treasury": "0x76aa112e12d6ad7cbc7cf40be254f279b73abfae",
"Governor": "0xe6eed6d0cad0af9e611c026c32b38c177db28f61",
"MerkleReserveMinter": "0xa2d7e55f87f1913d5da10807cf695dc35bc29b12",
"MigrationDeployer": "0xed98171590dba48f6596f4743c2b7300a7091f9e"
"Manager": "0x550c326d688fD51ae65AC6A2d48749E631023A03",
"ManagerImpl": "0xA644bA2dD0740ACD6FE6f9a031C6b7B2Ce466299",
"Auction": "0x3fb5d8E80835D07056c12757A183Ab659B1a44BF",
"Token": "0x3CC6ba057f394B00aC1fF48707d5C04DE29504C6",
"MetadataRenderer": "0x0B3a22E5C5824d9d227986F76190f504c0906aD6",
"Treasury": "0x047B1E00EB4726aFc57d559f851146e84E31d1dC",
"Governor": "0x2EFf3083Bff979C349C59C14cE3945AfEA023927"
}
3 changes: 3 additions & 0 deletions addresses/999.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"BuilderDAO": "0x7498e6e471f31e869f038D8DBffbDFdf650c3F95",
"ProtocolRewards": "0x7777777F279eba3d3Ad8F4E708545291A6fDBA8B",
"CrossDomainMessenger": "0x4200000000000000000000000000000000000007",
"Manager": "0xc521f85613985b7e417fccd5b348f64263d79397",
"ManagerImpl": "0x50704311b9732bf7dd7d892859c4a60f752e736b",
"WETH": "0x4200000000000000000000000000000000000006",
Expand Down
2 changes: 2 additions & 0 deletions deploys/420.version2_new.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Merkle Reserve Minter: 0x397f575356d25c8a2b255360507a80024ed64938
Migration Deployer: 0x07ade0c8adaa0cf6f68a6772db12818922729f70
4 changes: 4 additions & 0 deletions deploys/420.version2_upgrade.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Token implementation: 0xef49483419bc5516ec4c6d601adfac4a359ef8a6
Auction implementation: 0xdd908dfaf5e13bac01abe96e4b6d992f92c1fca0
Governor implementation: 0xef36580d07a0649e616d8dff968762ec703e12bb
Manager implementation: 0x5f94ae9dca1d215331d627f38a721c6f3f7e9872
4 changes: 2 additions & 2 deletions deploys/84531.version2_new.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Merkle Reserve Minter: 0xa2d7e55f87f1913d5da10807cf695dc35bc29b12
Migration Deployer: 0xed98171590dba48f6596f4743c2b7300a7091f9e
Merkle Reserve Minter: 0x088b9066b765d47e56d477d78bd0d5400aead99e
Migration Deployer: 0x3a4996be5586e55c165c7ce2666cee61ca0deebe
4 changes: 4 additions & 0 deletions deploys/84531.version2_upgrade.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Token implementation: 0x7c64ffb35304eac2255c82ed1f59336372488c88
Auction implementation: 0x0a7d1e9d45f258f39721b23b53c856bac1326c3c
Governor implementation: 0x2586bf7af4d4857e703e02d56045b9d717cfb10c
Manager implementation: 0x94523d59e37c44bdf093f4adf2bcd4092e921a2d
2 changes: 2 additions & 0 deletions deploys/999.version2_new.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Merkle Reserve Minter: 0x7a1857b438a05f08aed1dbe8138bb02bb1f01c4d
Migration Deployer: 0x76253481603b3411f94217fd086b0b5cc70da522
4 changes: 4 additions & 0 deletions deploys/999.version2_upgrade.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Token implementation: 0xAF80f93d2c4FE567959cd9d0C923f1c114cdef36.
Auction implementation: 0x7bc86F0a10Fb91c2f8e00264E1f2dD591b1Fd2C9.
Governor implementation: 0x359c7bC065acD51EB2b053a7a09F7C5274734BAe.
Manager implementation: 0x0B11E81948b528688d17B81E8F1E2c2B6C45f0e6.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@
"deploy:local": "source .env && forge script script/DeployContracts.s.sol:DeployContracts --private-key $PRIVATE_KEY --broadcast --rpc-url $RPC_URL",
"deploy:v2-local": "source .env && forge script script/DeployContractsV2.s.sol:DeployContracts --private-key $PRIVATE_KEY --broadcast --rpc-url $RPC_URL",
"deploy:v2-core": "source .env && forge script script/DeployV2Core.s.sol:DeployContracts --private-key $PRIVATE_KEY --rpc-url $RPC_URL --broadcast --verify --etherscan-api-key $ETHERSCAN_API_KEY",
"deploy:v2-upgrade": "source .env && forge script script/DeployV2Upgrade.s.sol:DeployContracts --private-key $PRIVATE_KEY --rpc-url $RPC_URL --resume --verify --etherscan-api-key $ETHERSCAN_API_KEY",
"deploy:v2-new": "source .env && forge script script/DeployV2New.s.sol:DeployContracts --private-key $PRIVATE_KEY --rpc-url $RPC_URL --broadcast --verify --etherscan-api-key $ETHERSCAN_API_KEY",
"deploy:zora": "source .env && forge script script/DeployContracts.s.sol:DeployContracts --private-key $PRIVATE_KEY --rpc-url $RPC_URL --broadcast --verify --verifier blockscout --verifier-url https://explorer.zora.energy/api? -vvvv",
"deploy:zora": "source .env && forge script script/DeployV2New.s.sol:DeployContracts --private-key $PRIVATE_KEY --rpc-url $RPC_URL --broadcast --verify --verifier blockscout --verifier-url https://testnet.explorer.zora.energy/api? -vvvv",
"test": "echo 'temporarily skipping metadata tests, remove this when fixed' && forge test --no-match-test 'WithAddress' -vvv",
"typechain": "typechain --target=ethers-v5 'dist/artifacts/*/*.json' --out-dir dist/typechain",
"storage-inspect:check": "./script/storage-check.sh check Manager Auction Governor Treasury Token",
Expand Down
60 changes: 48 additions & 12 deletions script/DeployV2Upgrade.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,39 +24,75 @@ contract DeployContracts is Script {

function run() public {
uint256 chainID = vm.envUint("CHAIN_ID");
uint256 key = vm.envUint("PRIVATE_KEY");
address weth = vm.envAddress("WETH_ADDRESS");

configFile = vm.readFile(string.concat("./addresses/", Strings.toString(chainID), ".json"));

address deployerAddress = vm.addr(key);
address deployerAddress = vm.addr(vm.envUint("PRIVATE_KEY"));
address managerProxy = _getKey("Manager");
address protocolRewards = _getKey("ProtocolRewards");
address builderDAO = _getKey("BuilderDAO");
address treasuryImpl = _getKey("Treasury");
address metadataImpl = _getKey("MetadataRenderer");

uint16 BUILDER_REWARDS = chainID == 1 || chainID == 5 ? 0 : 250;
uint16 REFERRAL_REWARDS = chainID == 1 || chainID == 5 ? 0 : 250;
_deployUpgrade(deployerAddress, managerProxy, protocolRewards, weth, metadataImpl, treasuryImpl, builderDAO, chainID);
}

// workaround for stack too deep
function _deployUpgrade(
address deployerAddress,
address managerProxy,
address protocolRewards,
address weth,
address metadataImpl,
address treasuryImpl,
address builderDAO,
uint256 chainID
) private {
uint16 builderRewardsValue = chainID == 1 || chainID == 5 ? 0 : 250;
uint16 referralRewardsValue = chainID == 1 || chainID == 5 ? 0 : 250;

console2.log("~~~~~~~~~~ CHAIN ID ~~~~~~~~~~~");
console2.log(chainID);

console2.log("~~~~~~~~~~ DEPLOYER ~~~~~~~~~~~");
console2.log(deployerAddress);

vm.startBroadcast(deployerAddress);
console2.log("~~~~~~~~~~ MANAGER PROXY ~~~~~~~~~~~");
console2.logAddress(managerProxy);

console2.log("~~~~~~~~~~ METADATA IMPL ~~~~~~~~~~~");
console2.logAddress(metadataImpl);

console2.log("~~~~~~~~~~ TREASURY IMPL ~~~~~~~~~~~");
console2.logAddress(treasuryImpl);

address manager = _getKey("Manager");
console2.log("~~~~~~~~~~ PROTOCOL REWARDS ~~~~~~~~~~~");
console2.logAddress(protocolRewards);

console2.log("~~~~~~~~~~ BUILDER DAO ~~~~~~~~~~~");
console2.logAddress(builderDAO);

console2.log("~~~~~~~~~~ BUILDER REWARDS VALUE ~~~~~~~~~~~");
console2.logUint(builderRewardsValue);

console2.log("~~~~~~~~~~ REFERRAL REWARDS VALUE ~~~~~~~~~~~");
console2.logUint(referralRewardsValue);
console2.log("");

vm.startBroadcast(deployerAddress);

// Deploy token implementation
address tokenImpl = address(new Token(manager));
address tokenImpl = address(new Token(managerProxy));

// Deploy auction house implementation
address auctionImpl = address(new Auction(manager, _getKey("ProtocolRewards"), weth, BUILDER_REWARDS, REFERRAL_REWARDS));
address auctionImpl = address(new Auction(managerProxy, protocolRewards, weth, builderRewardsValue, referralRewardsValue));

// Deploy governor implementation
address governorImpl = address(new Governor(manager));
address governorImpl = address(new Governor(managerProxy));

// Deploy v2 manager implementation
address managerImpl = address(
new Manager(tokenImpl, _getKey("MetadataRenderer"), auctionImpl, _getKey("Treasury"), governorImpl, _getKey("BuilderDAO"))
);
address managerImpl = address(new Manager(tokenImpl, metadataImpl, auctionImpl, treasuryImpl, governorImpl, builderDAO));

vm.stopBroadcast();

Expand Down
5 changes: 5 additions & 0 deletions src/auction/Auction.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ contract Auction is IAuction, VersionedContract, UUPS, Ownable, ReentrancyGuard,
/// @notice The maximum rewards percentage
uint256 private constant MAX_FOUNDER_REWARD_BPS = 3_000;

bytes4 public constant REWARDS_REASON = bytes4(0x0B411DE6);

/// ///
/// IMMUTABLES ///
/// ///
Expand Down Expand Up @@ -499,19 +501,22 @@ contract Auction is IAuction, VersionedContract, UUPS, Ownable, ReentrancyGuard,
uint256 builderAmount = (_finalBidAmount * builderRewardsBPS) / BPS_PER_100_PERCENT;
split.recipients[0] = builderRecipient;
split.amounts[0] = builderAmount;
split.reasons[0] = REWARDS_REASON;
split.totalRewards += builderAmount;

// Set referral reward
uint256 referralAmount = (_finalBidAmount * referralRewardsBPS) / BPS_PER_100_PERCENT;
split.recipients[1] = _currentBidRefferal != address(0) ? _currentBidRefferal : builderRecipient;
split.amounts[1] = referralAmount;
split.reasons[1] = REWARDS_REASON;
split.totalRewards += referralAmount;

// Set founder reward if enabled
if (hasFounderReward) {
uint256 founderAmount = (_finalBidAmount * _founderRewardBps) / BPS_PER_100_PERCENT;
split.recipients[2] = founderReward.recipient;
split.amounts[2] = founderAmount;
split.reasons[2] = REWARDS_REASON;
split.totalRewards += founderAmount;
}
}
Expand Down

0 comments on commit 48540bb

Please sign in to comment.