Skip to content

Commit 84e6284

Browse files
committed
Merge branch 'v1.1-merge'
2 parents c7fa2fa + e44bdcd commit 84e6284

92 files changed

Lines changed: 3239 additions & 27634 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

contracts/contract/dao/node/RocketDAONodeTrustedActions.sol

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,14 @@ contract RocketDAONodeTrustedActions is RocketBase, RocketDAONodeTrustedActionsI
3636
// Construct
3737
constructor(RocketStorageInterface _rocketStorageAddress) RocketBase(_rocketStorageAddress) {
3838
// Version
39-
version = 1;
39+
version = 2;
4040
}
4141

4242
/*** Internal Methods **********************/
4343

4444
// Add a new member to the DAO
4545
function _memberAdd(address _nodeAddress, uint256 _rplBondAmountPaid) private onlyRegisteredNode(_nodeAddress) {
4646
// Load contracts
47-
RocketClaimTrustedNodeInterface rocketClaimTrustedNode = RocketClaimTrustedNodeInterface(getContractAddress("rocketClaimTrustedNode"));
4847
RocketDAONodeTrustedInterface rocketDAONode = RocketDAONodeTrustedInterface(getContractAddress("rocketDAONodeTrusted"));
4948
AddressSetStorageInterface addressSetStorage = AddressSetStorageInterface(getContractAddress("addressSetStorage"));
5049
// Check current node status
@@ -57,17 +56,12 @@ contract RocketDAONodeTrustedActions is RocketBase, RocketDAONodeTrustedActionsI
5756
setUint(keccak256(abi.encodePacked(daoNameSpace, "member.joined.time", _nodeAddress)), block.timestamp);
5857
// Add to member index now
5958
addressSetStorage.addItem(keccak256(abi.encodePacked(daoNameSpace, "member.index")), _nodeAddress);
60-
// Register for them to receive rewards now
61-
rocketClaimTrustedNode.register(_nodeAddress, true);
6259
}
6360

6461
// Remove a member from the DAO
6562
function _memberRemove(address _nodeAddress) private onlyTrustedNode(_nodeAddress) {
6663
// Load contracts
67-
RocketClaimTrustedNodeInterface rocketClaimTrustedNode = RocketClaimTrustedNodeInterface(getContractAddress("rocketClaimTrustedNode"));
6864
AddressSetStorageInterface addressSetStorage = AddressSetStorageInterface(getContractAddress("addressSetStorage"));
69-
// Deregister them from receiving rewards now
70-
rocketClaimTrustedNode.register(_nodeAddress, false);
7165
// Remove their membership now
7266
deleteBool(keccak256(abi.encodePacked(daoNameSpace, "member", _nodeAddress)));
7367
deleteAddress(keccak256(abi.encodePacked(daoNameSpace, "member.address", _nodeAddress)));
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
pragma solidity 0.7.6;
2+
3+
// SPDX-License-Identifier: GPL-3.0-only
4+
5+
import "@openzeppelin/contracts/math/SafeMath.sol";
6+
7+
import "./RocketDAONodeTrustedSettings.sol";
8+
import "../../../../interface/dao/node/settings/RocketDAONodeTrustedSettingsRewardsInterface.sol";
9+
import "../../../../interface/dao/protocol/settings/RocketDAOProtocolSettingsRewardsInterface.sol";
10+
11+
12+
// The Trusted Node DAO Rewards settings
13+
14+
contract RocketDAONodeTrustedSettingsRewards is RocketDAONodeTrustedSettings, RocketDAONodeTrustedSettingsRewardsInterface {
15+
16+
using SafeMath for uint;
17+
18+
// Construct
19+
constructor(RocketStorageInterface _rocketStorageAddress) RocketDAONodeTrustedSettings(_rocketStorageAddress, "rewards") {
20+
// Set version
21+
version = 2;
22+
// Initialize settings on deployment
23+
if(!getBool(keccak256(abi.encodePacked(settingNameSpace, "deployed")))) {
24+
// Init settings
25+
setSettingBool("rewards.network.enabled", true);
26+
// Settings initialised
27+
setBool(keccak256(abi.encodePacked(settingNameSpace, "deployed")), true);
28+
}
29+
}
30+
31+
// Update a setting, overrides inherited setting method with extra checks for this contract
32+
function setSettingBool(string memory _settingPath, bool _value) override public onlyDAONodeTrustedProposal {
33+
// Some safety guards for certain settings
34+
if(getBool(keccak256(abi.encodePacked(settingNameSpace, "deployed")))) {
35+
// oDAO should never disable main net rewards
36+
if(keccak256(abi.encodePacked(_settingPath)) == keccak256(abi.encodePacked("rewards.network.enabled", uint256(0)))) {
37+
revert("Cannot disable network 0");
38+
}
39+
}
40+
// Update setting now
41+
setBool(keccak256(abi.encodePacked(settingNameSpace, _settingPath)), _value);
42+
}
43+
44+
45+
// Getters
46+
47+
function getNetworkEnabled(uint256 _network) override external view returns (bool) {
48+
return getBool(keccak256(abi.encodePacked(settingNameSpace, "rewards.network.enabled", _network)));
49+
}
50+
}

contracts/contract/dao/protocol/RocketDAOProtocol.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ contract RocketDAOProtocol is RocketBase, RocketDAOProtocolInterface {
7171

7272
// Bootstrap mode -Spend DAO treasury
7373
function bootstrapSpendTreasury(string memory _invoiceID, address _recipientAddress, uint256 _amount) override external onlyGuardian onlyBootstrapMode onlyLatestContract("rocketDAOProtocol", address(this)) {
74-
// Ok good to go, lets update the rewards claiming contract amount
7574
RocketDAOProtocolProposalsInterface(getContractAddress("rocketDAOProtocolProposals")).proposalSpendTreasury(_invoiceID, _recipientAddress, _amount);
7675
}
7776

contracts/contract/dao/protocol/settings/RocketDAOProtocolSettingsDeposit.sol

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ contract RocketDAOProtocolSettingsDeposit is RocketDAOProtocolSettings, RocketDA
1212
// Construct
1313
constructor(RocketStorageInterface _rocketStorageAddress) RocketDAOProtocolSettings(_rocketStorageAddress, "deposit") {
1414
// Set version
15-
version = 1;
15+
version = 2;
1616
// Initialize settings on deployment
1717
if(!getBool(keccak256(abi.encodePacked(settingNameSpace, "deployed")))) {
1818
// Apply settings
@@ -21,6 +21,7 @@ contract RocketDAOProtocolSettingsDeposit is RocketDAOProtocolSettings, RocketDA
2121
setSettingUint("deposit.minimum", 0.01 ether);
2222
setSettingUint("deposit.pool.maximum", 160 ether);
2323
setSettingUint("deposit.assign.maximum", 2);
24+
setSettingUint("deposit.fee", 0.0005 ether); // Set to approx. 1 day of rewards at 18.25% APR
2425
// Settings initialised
2526
setBool(keccak256(abi.encodePacked(settingNameSpace, "deployed")), true);
2627
}
@@ -51,4 +52,8 @@ contract RocketDAOProtocolSettingsDeposit is RocketDAOProtocolSettings, RocketDA
5152
return getSettingUint("deposit.assign.maximum");
5253
}
5354

55+
// Get the fee paid on deposits
56+
function getDepositFee() override external view returns (uint256) {
57+
return getSettingUint("deposit.fee");
58+
}
5459
}

contracts/contract/dao/protocol/settings/RocketDAOProtocolSettingsNetwork.sol

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ import "../../../../interface/dao/protocol/settings/RocketDAOProtocolSettingsNet
88
// Network auction settings
99

1010
contract RocketDAOProtocolSettingsNetwork is RocketDAOProtocolSettings, RocketDAOProtocolSettingsNetworkInterface {
11-
1211
// Construct
1312
constructor(RocketStorageInterface _rocketStorageAddress) RocketDAOProtocolSettings(_rocketStorageAddress, "network") {
1413
// Set version
15-
version = 1;
14+
version = 2;
1615
// Initialize settings on deployment
1716
if(!getBool(keccak256(abi.encodePacked(settingNameSpace, "deployed")))) {
1817
// Apply settings
@@ -26,7 +25,9 @@ contract RocketDAOProtocolSettingsNetwork is RocketDAOProtocolSettings, RocketDA
2625
setSettingUint("network.node.fee.maximum", 0.15 ether); // 15%
2726
setSettingUint("network.node.fee.demand.range", 160 ether);
2827
setSettingUint("network.reth.collateral.target", 0.1 ether);
29-
setSettingUint("network.reth.deposit.delay", 5760); // ~24 hours
28+
setSettingUint("network.penalty.threshold", 0.51 ether); // Consensus for penalties requires 51% vote
29+
setSettingUint("network.penalty.per.rate", 0.1 ether); // 10% per penalty
30+
setSettingBool("network.submit.rewards.enabled", true); // Enable reward submission
3031
// Settings initialised
3132
setBool(keccak256(abi.encodePacked(settingNameSpace, "deployed")), true);
3233
}
@@ -49,7 +50,17 @@ contract RocketDAOProtocolSettingsNetwork is RocketDAOProtocolSettings, RocketDA
4950
return getSettingUint("network.consensus.threshold");
5051
}
5152

52-
// Submit balances currently enabled (trusted nodes only)
53+
// The threshold of trusted nodes that must reach consensus on a penalty
54+
function getNodePenaltyThreshold() override external view returns (uint256) {
55+
return getSettingUint("network.penalty.threshold");
56+
}
57+
58+
// The amount to penalise a minipool for each feeDistributor infraction
59+
function getPerPenaltyRate() override external view returns (uint256) {
60+
return getSettingUint("network.penalty.per.rate");
61+
}
62+
63+
// Submit balances currently enabled (trusted nodes only)
5364
function getSubmitBalancesEnabled() override external view returns (bool) {
5465
return getSettingBool("network.submit.balances.enabled");
5566
}
@@ -98,4 +109,9 @@ contract RocketDAOProtocolSettingsNetwork is RocketDAOProtocolSettings, RocketDA
98109
function getRethDepositDelay() override external view returns (uint256) {
99110
return getSettingUint("network.reth.deposit.delay");
100111
}
112+
113+
// Submit reward snapshots currently enabled (trusted nodes only)
114+
function getSubmitRewardsEnabled() override external view returns (bool) {
115+
return getSettingBool("network.submit.rewards.enabled");
116+
}
101117
}

contracts/contract/dao/protocol/settings/RocketDAOProtocolSettingsNode.sol

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ contract RocketDAOProtocolSettingsNode is RocketDAOProtocolSettings, RocketDAOPr
1212
// Construct
1313
constructor(RocketStorageInterface _rocketStorageAddress) RocketDAOProtocolSettings(_rocketStorageAddress, "node") {
1414
// Set version
15-
version = 1;
15+
version = 2;
1616
// Initialize settings on deployment
1717
if(!getBool(keccak256(abi.encodePacked(settingNameSpace, "deployed")))) {
1818
// Apply settings
1919
setSettingBool("node.registration.enabled", false);
20+
setSettingBool("node.smoothing.pool.registration.enabled", true);
2021
setSettingBool("node.deposit.enabled", false);
2122
setSettingUint("node.per.minipool.stake.minimum", 0.1 ether); // 10% of user ETH value
2223
setSettingUint("node.per.minipool.stake.maximum", 1.5 ether); // 150% of user ETH value
@@ -30,6 +31,11 @@ contract RocketDAOProtocolSettingsNode is RocketDAOProtocolSettings, RocketDAOPr
3031
return getSettingBool("node.registration.enabled");
3132
}
3233

34+
// Node smoothing pool registrations currently enabled
35+
function getSmoothingPoolRegistrationEnabled() override external view returns (bool) {
36+
return getSettingBool("node.smoothing.pool.registration.enabled");
37+
}
38+
3339
// Node deposits currently enabled
3440
function getDepositEnabled() override external view returns (bool) {
3541
return getSettingBool("node.deposit.enabled");

contracts/contract/deposit/RocketDepositPool.sol

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import "../../interface/minipool/RocketMinipoolInterface.sol";
1212
import "../../interface/minipool/RocketMinipoolQueueInterface.sol";
1313
import "../../interface/dao/protocol/settings/RocketDAOProtocolSettingsDepositInterface.sol";
1414
import "../../interface/dao/protocol/settings/RocketDAOProtocolSettingsMinipoolInterface.sol";
15+
import "../../interface/dao/protocol/settings/RocketDAOProtocolSettingsNetworkInterface.sol";
1516
import "../../interface/token/RocketTokenRETHInterface.sol";
1617
import "../../types/MinipoolDeposit.sol";
1718

@@ -45,7 +46,7 @@ contract RocketDepositPool is RocketBase, RocketDepositPoolInterface, RocketVaul
4546

4647
// Construct
4748
constructor(RocketStorageInterface _rocketStorageAddress) RocketBase(_rocketStorageAddress) {
48-
version = 1;
49+
version = 2;
4950
}
5051

5152
// Current deposit pool balance
@@ -77,11 +78,12 @@ contract RocketDepositPool is RocketBase, RocketDepositPoolInterface, RocketVaul
7778
require(msg.value >= rocketDAOProtocolSettingsDeposit.getMinimumDeposit(), "The deposited amount is less than the minimum deposit size");
7879
RocketVaultInterface rocketVault = RocketVaultInterface(getContractAddress("rocketVault"));
7980
require(rocketVault.balanceOf("rocketDepositPool").add(msg.value) <= rocketDAOProtocolSettingsDeposit.getMaximumDepositPoolSize(), "The deposit pool size after depositing exceeds the maximum size");
80-
// Record last deposit to time delay ability to withdraw
81-
setUint(keccak256(abi.encodePacked("user.deposit.block", msg.sender)), block.number);
81+
// Calculate deposit fee
82+
uint256 depositFee = msg.value.mul(rocketDAOProtocolSettingsDeposit.getDepositFee()).div(calcBase);
83+
uint256 depositNet = msg.value.sub(depositFee);
8284
// Mint rETH to user account
8385
RocketTokenRETHInterface rocketTokenRETH = RocketTokenRETHInterface(getContractAddress("rocketTokenRETH"));
84-
rocketTokenRETH.mint(msg.value, msg.sender);
86+
rocketTokenRETH.mint(depositNet, msg.sender);
8587
// Emit deposit received event
8688
emit DepositReceived(msg.sender, msg.value, block.timestamp);
8789
// Process deposit
@@ -121,11 +123,11 @@ contract RocketDepositPool is RocketBase, RocketDepositPoolInterface, RocketVaul
121123
}
122124

123125
// Process a deposit
124-
function processDeposit(RocketVaultInterface rocketVault, RocketDAOProtocolSettingsDepositInterface rocketDAOProtocolSettingsDeposit) private {
126+
function processDeposit(RocketVaultInterface _rocketVault, RocketDAOProtocolSettingsDepositInterface _rocketDAOProtocolSettingsDeposit) private {
125127
// Transfer ETH to vault
126-
rocketVault.depositEther{value: msg.value}();
128+
_rocketVault.depositEther{value: msg.value}();
127129
// Assign deposits if enabled
128-
_assignDeposits(rocketVault, rocketDAOProtocolSettingsDeposit);
130+
_assignDeposits(_rocketVault, _rocketDAOProtocolSettingsDeposit);
129131
}
130132

131133
// Assign deposits to available minipools
@@ -138,19 +140,19 @@ contract RocketDepositPool is RocketBase, RocketDepositPoolInterface, RocketVaul
138140
}
139141

140142
// Assigns deposits to available minipools, returns false if assignment is currently disabled
141-
function _assignDeposits(RocketVaultInterface rocketVault, RocketDAOProtocolSettingsDepositInterface rocketDAOProtocolSettingsDeposit) private returns (bool) {
143+
function _assignDeposits(RocketVaultInterface _rocketVault, RocketDAOProtocolSettingsDepositInterface _rocketDAOProtocolSettingsDeposit) private returns (bool) {
142144
// Check if assigning deposits is enabled
143-
if (!rocketDAOProtocolSettingsDeposit.getAssignDepositsEnabled()) {
145+
if (!_rocketDAOProtocolSettingsDeposit.getAssignDepositsEnabled()) {
144146
return false;
145147
}
146148
// Load contracts
147149
RocketDAOProtocolSettingsMinipoolInterface rocketDAOProtocolSettingsMinipool = RocketDAOProtocolSettingsMinipoolInterface(getContractAddress("rocketDAOProtocolSettingsMinipool"));
148150
RocketMinipoolQueueInterface rocketMinipoolQueue = RocketMinipoolQueueInterface(getContractAddress("rocketMinipoolQueue"));
149151
// Setup initial variable values
150-
uint256 balance = rocketVault.balanceOf("rocketDepositPool");
152+
uint256 balance = _rocketVault.balanceOf("rocketDepositPool");
151153
uint256 totalEther = 0;
152154
// Calculate minipool assignments
153-
uint256 maxAssignments = rocketDAOProtocolSettingsDeposit.getMaximumDepositAssignments();
155+
uint256 maxAssignments = _rocketDAOProtocolSettingsDeposit.getMaximumDepositAssignments();
154156
MinipoolAssignment[] memory assignments = new MinipoolAssignment[](maxAssignments);
155157
MinipoolDeposit depositType = MinipoolDeposit.None;
156158
uint256 count = 0;
@@ -174,7 +176,7 @@ contract RocketDepositPool is RocketBase, RocketDepositPoolInterface, RocketVaul
174176
}
175177
if (totalEther > 0) {
176178
// Withdraw ETH from vault
177-
rocketVault.withdrawEther(totalEther);
179+
_rocketVault.withdrawEther(totalEther);
178180
// Perform assignments
179181
for (uint256 i = 0; i < maxAssignments; ++i) {
180182
if (assignments[i].etherAssigned == 0) { break; }
@@ -202,9 +204,4 @@ contract RocketDepositPool is RocketBase, RocketDepositPoolInterface, RocketVaul
202204
// Emit excess withdrawn event
203205
emit ExcessWithdrawn(msg.sender, _amount, block.timestamp);
204206
}
205-
206-
// Returns the block that _address last deposited ether on
207-
function getUserLastDepositBlock(address _address) override external view returns (uint256) {
208-
return getUint(keccak256(abi.encodePacked("user.deposit.block", _address)));
209-
}
210207
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
pragma solidity 0.7.6;
2+
3+
// SPDX-License-Identifier: GPL-3.0-only
4+
5+
import "@openzeppelin/contracts/math/SafeMath.sol";
6+
7+
import "./RocketMinipool.sol";
8+
import "../RocketBase.sol";
9+
import "../../types/MinipoolStatus.sol";
10+
import "../../types/MinipoolDeposit.sol";
11+
import "../../interface/dao/node/RocketDAONodeTrustedInterface.sol";
12+
import "../../interface/minipool/RocketMinipoolInterface.sol";
13+
import "../../interface/minipool/RocketMinipoolManagerInterface.sol";
14+
import "../../interface/minipool/RocketMinipoolQueueInterface.sol";
15+
import "../../interface/node/RocketNodeStakingInterface.sol";
16+
import "../../interface/util/AddressSetStorageInterface.sol";
17+
import "../../interface/node/RocketNodeManagerInterface.sol";
18+
import "../../interface/network/RocketNetworkPricesInterface.sol";
19+
import "../../interface/dao/protocol/settings/RocketDAOProtocolSettingsMinipoolInterface.sol";
20+
import "../../interface/dao/protocol/settings/RocketDAOProtocolSettingsNodeInterface.sol";
21+
import "../../interface/dao/protocol/settings/RocketDAOProtocolSettingsNodeInterface.sol";
22+
import "../../interface/minipool/RocketMinipoolFactoryInterface.sol";
23+
24+
// Minipool creation, removal and management
25+
26+
contract RocketMinipoolFactory is RocketBase, RocketMinipoolFactoryInterface {
27+
28+
// Libs
29+
using SafeMath for uint;
30+
31+
// Construct
32+
constructor(RocketStorageInterface _rocketStorageAddress) RocketBase(_rocketStorageAddress) {
33+
version = 1;
34+
}
35+
36+
// Returns the bytecode for RocketMinipool
37+
function getMinipoolBytecode() override public pure returns (bytes memory) {
38+
return type(RocketMinipool).creationCode;
39+
}
40+
41+
// Performs a CREATE2 deployment of a minipool contract with given salt
42+
function deployContract(address _nodeAddress, MinipoolDeposit _depositType, uint256 _salt) override external onlyLatestContract("rocketMinipoolFactory", address(this)) onlyLatestContract("rocketMinipoolManager", msg.sender) returns (address) {
43+
// Construct deployment bytecode
44+
bytes memory creationCode = getMinipoolBytecode();
45+
bytes memory bytecode = abi.encodePacked(creationCode, abi.encode(rocketStorage, _nodeAddress, _depositType));
46+
// Construct final salt
47+
uint256 salt = uint256(keccak256(abi.encodePacked(_nodeAddress, _salt)));
48+
// CREATE2 deployment
49+
address contractAddress;
50+
uint256 codeSize;
51+
assembly {
52+
contractAddress := create2(
53+
0,
54+
add(bytecode, 0x20),
55+
mload(bytecode),
56+
salt
57+
)
58+
59+
codeSize := extcodesize(contractAddress)
60+
}
61+
// Ensure deployment was successful
62+
require(codeSize > 0, "Contract creation failed");
63+
// Return address
64+
return contractAddress;
65+
}
66+
67+
}

0 commit comments

Comments
 (0)