Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added initial version for rocket pool recipient #140

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
75 changes: 75 additions & 0 deletions script/DeployRocketPoolRecipient.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import "forge-std/Script.sol";
import {ObolRocketPoolRecipientFactory} from "src/rocket-pool/ObolRocketPoolRecipientFactory.sol";
import {ISplitMain, SplitConfiguration} from "src/interfaces/ISplitMain.sol";
import {SplitterConfiguration} from "./SplitterConfiguration.sol";

contract DeployRocketPoolRecipient is Script, SplitterConfiguration {
error Invalid_PrincipalRecipient();

struct ConfigurationData {
address principalRecipient;
JsonSplitData split;
}

/// @param jsonFilePath the data format can be seen in ./data/deploy-otwr-sample.json
/// @param splitMain address for 0xsplits splitMain
/// @param rpRecipientFactory address for factory
/// @param stakeSize in normal numbers e.g. 32 for 32 ether
function run(string memory jsonFilePath, address splitMain, address rpRecipientFactory, uint256 stakeSize)
external
{
uint256 privKey = vm.envUint("PRIVATE_KEY");
bytes memory parsedJson = vm.parseJson(vm.readFile(jsonFilePath));

ConfigurationData[] memory data = abi.decode(parsedJson, (ConfigurationData[]));
_validateInputJson(data);

// deploy the split and obol script
string memory jsonKey = "rocketPoolDeploy";
string memory finalJSON;

uint256 stakeAmount = stakeSize * 1 ether;

for (uint256 i = 0; i < data.length; i++) {
// deploy split
ConfigurationData memory currentConfiguration = data[i];

vm.startBroadcast(privKey);

address split = ISplitMain(splitMain).createSplit(
currentConfiguration.split.accounts,
currentConfiguration.split.percentAllocations,
currentConfiguration.split.distributorFee,
currentConfiguration.split.controller
);

// create obol split
address rocketPoolRecipientAddress = address(
ObolRocketPoolRecipientFactory(rpRecipientFactory).createObolRocketPoolRecipient(
address(0), currentConfiguration.principalRecipient, split, stakeAmount
)
);

vm.stopBroadcast();

string memory objKey = vm.toString(i);

vm.serializeAddress(objKey, "splitAddress", split);
string memory repsonse = vm.serializeAddress(objKey, "RocketPoolRecipientAddress", rocketPoolRecipientAddress);

finalJSON = vm.serializeString(jsonKey, objKey, repsonse);
}

vm.writeJson(finalJSON, "./rocket-pool-recipient-split.json");
}

function _validateInputJson(ConfigurationData[] memory configuration) internal pure {
for (uint256 i = 0; i < configuration.length; i++) {
if (configuration[i].principalRecipient == address(0)) revert Invalid_PrincipalRecipient();
_validateSplitInputJson(configuration[i].split);
}
}
}
33 changes: 33 additions & 0 deletions script/DeployRocketPoolRecipientTest.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import "forge-std/Script.sol";
import {ObolRocketPoolRecipientFactory} from "src/rocket-pool/ObolRocketPoolRecipientFactory.sol";
import {ISplitMain, SplitConfiguration} from "src/interfaces/ISplitMain.sol";
import {SplitterConfiguration} from "./SplitterConfiguration.sol";

contract DeployRocketPoolRecipientTest is Script, SplitterConfiguration {
error Invalid_PrincipalRecipient();

function run()
external
{
address rpRecipientFactory = 0xd1B952171DF38A209326f8DF6C8Da1226C18995A;
uint256 privKey = vm.envUint("PRIVATE_KEY");

address recipient = vm.envAddress("PUBLIC_KEY");

vm.startBroadcast(privKey);

address rocketPoolRecipientAddress = address(
ObolRocketPoolRecipientFactory(rpRecipientFactory).createObolRocketPoolRecipient(
recipient, recipient, recipient, 8 ether
)
);
vm.stopBroadcast();

string memory repsonse = vm.serializeAddress("rpRecipient", "ObolRocketPoolRecipient", rocketPoolRecipientAddress);
string memory finalJSON = vm.serializeString("rocket-pool-deployment", "rpRecipient", repsonse);
vm.writeJson(finalJSON, "./rocket-pool-recipient-split.json");
}
}
40 changes: 40 additions & 0 deletions script/RocketPoolRecipientFactoryScript.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import "forge-std/Script.sol";
import {ObolRocketPoolRecipientFactory} from "src/rocket-pool/ObolRocketPoolRecipientFactory.sol";
import {RPMinipoolManagerMock} from "src/test/rocket-pool/mocks/RPMinipoolManagerMock.sol";
import {RPMinipoolMock} from "src/test/rocket-pool/mocks/RPMinipoolMock.sol";
import {RPStorageMock} from "src/test/rocket-pool/mocks/RPStorageMock.sol";

contract RocketPoolRecipientFactoryScript is Script {
uint256 constant ETH_STAKE_THRESHOLD = 16 ether;
uint256 constant GNO_STAKE_THRESHOLD = 0.8 ether;

function run(string memory _name, address _ensReverseRegistrar, address _ensOwner, bool _test) external {
uint256 privKey = vm.envUint("PRIVATE_KEY");

vm.startBroadcast(privKey);

address rpStorage;
if (_test) {
// deploy mock minipool manager
new RPMinipoolManagerMock{salt: keccak256("obol.RPMinipoolManagerMock.v1.0")}();

// deploy mock minipool
new RPMinipoolMock{salt: keccak256("obol.RPMinipoolMock.v1.0")}();

// deploy mock storage
rpStorage = address(new RPStorageMock{salt: keccak256("obol.RPStorageMock.v1.0")}());
} else {
rpStorage = vm.envAddress("ROCKET_POOL_STORAGE");
}

new ObolRocketPoolRecipientFactory{salt: keccak256("obol.rocketPoolRecipientFactoryWithToken.v1.0")}(
rpStorage, _name, _ensReverseRegistrar, _ensOwner
);


vm.stopBroadcast();
}
}
Binary file added src/interfaces/external/.DS_Store
Binary file not shown.
6 changes: 6 additions & 0 deletions src/interfaces/external/rocketPool/IRETH.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

interface IRETH {
function burn(uint256 _rethAmount) external;
}
11 changes: 11 additions & 0 deletions src/interfaces/external/rocketPool/IRocketDepositPool.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

interface IRocketDepositPool {
function getBalance() external view returns (uint256);
function getNodeBalance() external view returns (uint256);
function getUserBalance() external view returns (int256);
function getExcessBalance() external view returns (uint256);
function deposit() external payable;
function getMaximumDepositAmount() external view returns (uint256);
}
7 changes: 7 additions & 0 deletions src/interfaces/external/rocketPool/IRocketMinipoolBase.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

interface IRocketMinipoolBase {
// IRocketMiniPoolDelegate
function getEffectiveDelegate() external view returns (address);
}
50 changes: 50 additions & 0 deletions src/interfaces/external/rocketPool/IRocketMinipoolDelegate.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

interface IRocketMinipoolDelegate {
function version() external view returns (uint8);
function initialise(address _nodeAddress) external;
function getFinalised() external view returns (bool);
function getStatusBlock() external view returns (uint256);
function getStatusTime() external view returns (uint256);
function getScrubVoted(address _member) external view returns (bool);
function getNodeAddress() external view returns (address);
function getNodeFee() external view returns (uint256);
function getNodeDepositBalance() external view returns (uint256);
function getNodeRefundBalance() external view returns (uint256);
function getNodeDepositAssigned() external view returns (bool);
function getPreLaunchValue() external view returns (uint256);
function getNodeTopUpValue() external view returns (uint256);
function getVacant() external view returns (bool);
function getPreMigrationBalance() external view returns (uint256);
function getUserDistributed() external view returns (bool);
function getUserDepositBalance() external view returns (uint256);
function getUserDepositAssigned() external view returns (bool);
function getUserDepositAssignedTime() external view returns (uint256);
function getTotalScrubVotes() external view returns (uint256);
function calculateNodeShare(uint256 _balance) external view returns (uint256);
function calculateUserShare(uint256 _balance) external view returns (uint256);
function preDeposit(
uint256 _bondingValue,
bytes calldata _validatorPubkey,
bytes calldata _validatorSignature,
bytes32 _depositDataRoot
) external payable;
function deposit() external payable;
function userDeposit() external payable;
function distributeBalance(bool _rewardsOnly) external;
function beginUserDistribute() external;
function userDistributeAllowed() external view returns (bool);
function refund() external;
function slash() external;
function finalise() external;
function canStake() external view returns (bool);
function canPromote() external view returns (bool);
function stake(bytes calldata _validatorSignature, bytes32 _depositDataRoot) external;
function prepareVacancy(uint256 _bondAmount, uint256 _currentBalance) external;
function promote() external;
function dissolve() external;
function close() external;
function voteScrub() external;
function reduceBondAmount() external;
}
15 changes: 15 additions & 0 deletions src/interfaces/external/rocketPool/IRocketMinipoolQueue.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

interface IRocketMinipoolQueue {
function getTotalLength() external view returns (uint256);
function getContainsLegacy() external view returns (bool);
function getLength() external view returns (uint256);
function getTotalCapacity() external view returns (uint256);
function getEffectiveCapacity() external view returns (uint256);
function getNextCapacityLegacy() external view returns (uint256);
function enqueueMinipool(address _minipool) external;
function dequeueMinipools(uint256 _maxToDequeue) external returns (address[] memory minipoolAddress);
function getMinipoolAt(uint256 _index) external view returns (address);
function getMinipoolPosition(address _minipool) external view returns (int256);
}
11 changes: 11 additions & 0 deletions src/interfaces/external/rocketPool/IRocketPoolMinipoolManager.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

interface IRocketPoolMinipoolManager {
function getMinipoolExists(address _minipoolAddress) external view returns (bool);
function getMinipoolByPubkey(bytes memory _pubkey) external view returns (address);
function getMinipoolWithdrawalCredentials(address _minipoolAddress) external pure returns (bytes memory);
function getVacantMinipoolCount() external view returns (uint256);
function getVacantMinipoolAt(uint256 _index) external view returns (address);
function setMinipoolPubkey(bytes calldata _pubkey) external;
}
14 changes: 14 additions & 0 deletions src/interfaces/external/rocketPool/IRocketPoolStorage.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

// address internal constant RP_DEPOSIT = 0xDD3f50F8A6CafbE9b31a427582963f465E745AF8;
// address internal constant RP_STORAGE = 0x1d8f8f00cfa6758d7bE78336684788Fb0ee0Fa46;
interface IRocketPoolStorage {
function getAddress(bytes32 _key) external view returns (address r);
function getUint(bytes32 _key) external view returns (uint256 r);
function getString(bytes32 _key) external view returns (string memory);
function getBytes(bytes32 _key) external view returns (bytes memory);
function getBool(bytes32 _key) external view returns (bool r);
function getInt(bytes32 _key) external view returns (int256 r);
function getBytes32(bytes32 _key) external view returns (bytes32 r);
}
Loading
Loading