Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,12 @@ contract CompoundingStakingSSVStrategy is
address _recipient,
address _asset,
uint256 _amount
) external override onlyVault nonReentrant {
) external override nonReentrant {
require(_asset == WETH, "Unsupported asset");
require(
msg.sender == vaultAddress || msg.sender == validatorRegistrator,
"Caller not Vault or Registrator"
);

_withdraw(_recipient, _amount, address(this).balance);
}
Expand All @@ -128,7 +132,7 @@ contract CompoundingStakingSSVStrategy is
uint256 _ethBalance
) internal {
require(_withdrawAmount > 0, "Must withdraw something");
require(_recipient != address(0), "Must specify recipient");
require(_recipient == vaultAddress, "Recipient not Vault");

// Convert any ETH from validator partial withdrawals, exits
// or execution rewards to WETH and do the necessary accounting.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ abstract contract CompoundingValidatorManager is Governable, Pausable {
/// @notice The address of the beacon chain deposit contract
address internal immutable BEACON_CHAIN_DEPOSIT_CONTRACT;
/// @notice The address of the SSV Network contract used to interface with
address public immutable SSV_NETWORK;
address internal immutable SSV_NETWORK;
/// @notice Address of the OETH Vault proxy contract
address internal immutable VAULT_ADDRESS;
/// @notice Address of the Beacon Proofs contract that verifies beacon chain data
Expand Down
15 changes: 15 additions & 0 deletions contracts/deploy/hoodi/031_upgrade_staking_contracts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const { upgradeCompoundingStakingSSVStrategy } = require("../deployActions");

const mainExport = async () => {
await upgradeCompoundingStakingSSVStrategy();

console.log("Running 031 deployment done");
return true;
};

mainExport.id = "031_upgrade_staking_contract";
mainExport.tags = [];
mainExport.dependencies = [];
mainExport.skip = () => false;

module.exports = mainExport;
3 changes: 2 additions & 1 deletion contracts/deployments/hoodi/.migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
"027_upgrade_staking_contract": 1757382067,
"028_deploy_new_staking_contracts": 1757935264,
"029_upgrade_staking_contract": 1758151852,
"030_upgrade_staking_contract": 1758515961
"030_upgrade_staking_contract": 1758515961,
"031_upgrade_staking_contract": 1760330143
}
167 changes: 69 additions & 98 deletions contracts/deployments/hoodi/CompoundingStakingSSVStrategy.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions contracts/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const SONIC_DEPLOYER = MAINNET_DEPLOYER;
const SONIC_ADMIN = "0xAdDEA7933Db7d83855786EB43a238111C69B00b6";
// 2/8 multi-sig that controls fund allocations. Aka "Guardian".
const SONIC_STRATEGIST = "0x63cdd3072F25664eeC6FAEFf6dAeB668Ea4de94a";
const MAINNET_RELAYER = "0x4b91827516f79d6F6a1F292eD99671663b09169a";

const MULTICHAIN_STRATEGIST = "0x4FF1b9D9ba8558F5EAfCec096318eA0d8b541971";

Expand Down Expand Up @@ -201,6 +202,13 @@ const localEnvStrategist =
: MULTICHAIN_STRATEGIST
: 0;

const localEnvRegistrator =
process.env.FORK === "true"
? isHoodiFork
? HOODI_RELAYER
: MAINNET_RELAYER
: 1; // signer at index 2

module.exports = {
solidity: {
version: "0.8.28",
Expand Down Expand Up @@ -407,6 +415,12 @@ module.exports = {
multichainStrategistAddr: {
default: MULTICHAIN_STRATEGIST,
},
registratorAddr: {
default: 2,
localhost: localEnvRegistrator,
mainnet: MAINNET_RELAYER,
hoodi: HOODI_RELAYER,
},
},
contractSizer: {
alphaSort: true,
Expand Down
9 changes: 9 additions & 0 deletions contracts/tasks/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,18 @@ const concatKDF = (secret, s1, keyLen) => {
return hashSum.slice(0, keyLen);
};

const signMessage = async ({ signer, message }) => {
console.log(`Message: ${message}`);
console.log(`Signer: ${await signer.getAddress()}`);

const hash = await signer.signMessage(message);
console.log(`Hash: ${hash}`);
};

module.exports = {
genECDHKey,
decryptValidatorKey,
decryptValidatorKeyWithMasterKey,
decryptValidatorKeyFromStorage,
signMessage,
};
40 changes: 40 additions & 0 deletions contracts/tasks/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const {
genECDHKey,
decryptValidatorKey,
decryptValidatorKeyWithMasterKey,
signMessage,
} = require("./crypto");
const { advanceBlocks } = require("./block");
const {
Expand Down Expand Up @@ -110,6 +111,7 @@ const {
stakeValidator,
withdrawValidator,
removeValidator,
autoValidatorWithdrawals,
setRegistrator,
} = require("./validatorCompound");
const { tenderlySync, tenderlyUpload } = require("./tenderly");
Expand Down Expand Up @@ -1651,6 +1653,20 @@ task("masterDecrypt").setAction(async (_, __, runSuper) => {
return runSuper();
});

subtask(
"signMessage",
"Sign a message using a Elliptic-curve Diffie–Hellman (ECDH) private key"
)
.addParam("message", "Message to be signed", undefined, types.string)
.setAction(async (taskArgs) => {
const signer = await getSigner();

await signMessage({ ...taskArgs, signer });
});
task("signMessage").setAction(async (_, __, runSuper) => {
return runSuper();
});

// Defender
subtask(
"setActionVars",
Expand Down Expand Up @@ -2121,6 +2137,30 @@ task("removeValidator").setAction(async (_, __, runSuper) => {
return runSuper();
});

subtask(
"autoValidatorWithdrawals",
"Automatically withdraws funds from a validator"
)
.addParam(
"buffer",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BufferBp could be a better name?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like to keep the Hardhat option short. bufferBp would become --buffer-bp. The option description should say its in basis points

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point 👍

"Withdrawal buffer in basis points. 100 = 1%",
100,
types.int
)
.addParam(
"dryrun",
"Do not send any txs to the staking strategy contract",
false,
types.boolean
)
.setAction(async (taskArgs) => {
const signer = await getSigner();
await autoValidatorWithdrawals({ ...taskArgs, signer });
});
task("autoValidatorWithdrawals").setAction(async (_, __, runSuper) => {
return runSuper();
});

subtask(
"stakeValidatorUuid",
"Converts WETH to ETH and deposits to a validator from the Compounding Staking Strategy"
Expand Down
Loading
Loading