Skip to content

Commit

Permalink
Merge pull request #8 from symbioticfi/refactor
Browse files Browse the repository at this point in the history
Refactor
  • Loading branch information
1kresh authored Dec 23, 2024
2 parents ca76425 + 805ebc1 commit 2d75430
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 24 deletions.
15 changes: 7 additions & 8 deletions src/contracts/fullRestakeDelegator/FullRestakeResetHook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ contract FullRestakeResetHook is IFullRestakeResetHook {
mapping(address vault => mapping(address operator => CircularBuffer.Bytes32CircularBuffer buffer)) private
_slashings;

constructor(uint48 period_, uint256 slashCount_) {
if (slashCount_ == 0) {
constructor(uint48 period, uint256 slashCount) {
if (slashCount == 0) {
revert InvalidSlashCount();
}

PERIOD = period_;
SLASH_COUNT = slashCount_;
PERIOD = period;
SLASH_COUNT = slashCount;
}

/**
Expand All @@ -56,9 +56,8 @@ contract FullRestakeResetHook is IFullRestakeResetHook {
revert NotVaultDelegator();
}

uint256 slashCount_ = SLASH_COUNT;
if (_slashings[vault][operator].count() == 0) {
_slashings[vault][operator].setup(slashCount_);
_slashings[vault][operator].setup(SLASH_COUNT);
}

if (IFullRestakeDelegator(msg.sender).operatorNetworkLimit(subnetwork, operator) == 0) {
Expand All @@ -68,8 +67,8 @@ contract FullRestakeResetHook is IFullRestakeResetHook {
_slashings[vault][operator].push(bytes32(uint256(Time.timestamp())));

if (
_slashings[vault][operator].count() == slashCount_
&& Time.timestamp() - uint256(_slashings[vault][operator].last(slashCount_ - 1)) <= PERIOD
_slashings[vault][operator].count() == SLASH_COUNT
&& Time.timestamp() - uint256(_slashings[vault][operator].last(SLASH_COUNT - 1)) <= PERIOD
) {
IFullRestakeDelegator(msg.sender).setOperatorNetworkLimit(subnetwork, operator, 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ contract NetworkRestakeResetHook is INetworkRestakeResetHook {
mapping(address vault => mapping(address operator => CircularBuffer.Bytes32CircularBuffer buffer)) private
_slashings;

constructor(uint48 period_, uint256 slashCount_) {
if (slashCount_ == 0) {
constructor(uint48 period, uint256 slashCount) {
if (slashCount == 0) {
revert InvalidSlashCount();
}

PERIOD = period_;
SLASH_COUNT = slashCount_;
PERIOD = period;
SLASH_COUNT = slashCount;
}

/**
Expand All @@ -56,9 +56,8 @@ contract NetworkRestakeResetHook is INetworkRestakeResetHook {
revert NotVaultDelegator();
}

uint256 slashCount_ = SLASH_COUNT;
if (_slashings[vault][operator].count() == 0) {
_slashings[vault][operator].setup(slashCount_);
_slashings[vault][operator].setup(SLASH_COUNT);
}

if (INetworkRestakeDelegator(msg.sender).operatorNetworkShares(subnetwork, operator) == 0) {
Expand All @@ -68,8 +67,8 @@ contract NetworkRestakeResetHook is INetworkRestakeResetHook {
_slashings[vault][operator].push(bytes32(uint256(Time.timestamp())));

if (
_slashings[vault][operator].count() == slashCount_
&& Time.timestamp() - uint256(_slashings[vault][operator].last(slashCount_ - 1)) <= PERIOD
_slashings[vault][operator].count() == SLASH_COUNT
&& Time.timestamp() - uint256(_slashings[vault][operator].last(SLASH_COUNT - 1)) <= PERIOD
) {
INetworkRestakeDelegator(msg.sender).setOperatorNetworkShares(subnetwork, operator, 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ contract OperatorSpecificResetHook is IOperatorSpecificResetHook {

mapping(address vault => CircularBuffer.Bytes32CircularBuffer buffer) private _slashings;

constructor(uint48 period_, uint256 slashCount_) {
if (slashCount_ == 0) {
constructor(uint48 period, uint256 slashCount) {
if (slashCount == 0) {
revert InvalidSlashCount();
}

PERIOD = period_;
SLASH_COUNT = slashCount_;
PERIOD = period;
SLASH_COUNT = slashCount;
}

/**
Expand All @@ -55,9 +55,8 @@ contract OperatorSpecificResetHook is IOperatorSpecificResetHook {
revert NotVaultDelegator();
}

uint256 slashCount_ = SLASH_COUNT;
if (_slashings[vault].count() == 0) {
_slashings[vault].setup(slashCount_);
_slashings[vault].setup(SLASH_COUNT);
}

if (IOperatorSpecificDelegator(msg.sender).networkLimit(subnetwork) == 0) {
Expand All @@ -67,8 +66,8 @@ contract OperatorSpecificResetHook is IOperatorSpecificResetHook {
_slashings[vault].push(bytes32(uint256(Time.timestamp())));

if (
_slashings[vault].count() == slashCount_
&& Time.timestamp() - uint256(_slashings[vault].last(slashCount_ - 1)) <= PERIOD
_slashings[vault].count() == SLASH_COUNT
&& Time.timestamp() - uint256(_slashings[vault].last(SLASH_COUNT - 1)) <= PERIOD
) {
IOperatorSpecificDelegator(msg.sender).setNetworkLimit(subnetwork, 0);
}
Expand Down

0 comments on commit 2d75430

Please sign in to comment.