This file is a merged representation of a subset of the codebase, containing files not matching ignore patterns, combined into a single document by Repomix. The content has been processed where content has been compressed (code blocks are separated by ⋮---- delimiter). # File Summary ## Purpose This file contains a packed representation of a subset of the repository's contents that is considered the most important context. It is designed to be easily consumable by AI systems for analysis, code review, or other automated processes. ## File Format The content is organized as follows: 1. This summary section 2. Repository information 3. Directory structure 4. Repository files (if enabled) 5. Multiple file entries, each consisting of: a. A header with the file path (## File: path/to/file) b. The full contents of the file in a code block ## Usage Guidelines - This file should be treated as read-only. Any changes should be made to the original repository files, not this packed version. - When processing this file, use the file path to distinguish between different files in the repository. - Be aware that this file may contain sensitive information. Handle it with the same level of security as you would the original repository. ## Notes - Some files may have been excluded based on .gitignore rules and Repomix's configuration - Binary files are not included in this packed representation. Please refer to the Repository Structure section for a complete list of file paths, including binary files - Files matching these patterns are excluded: docs/ - Files matching patterns in .gitignore are excluded - Files matching default ignore patterns are excluded - Content has been compressed - code blocks are separated by ⋮---- delimiter - Files are sorted by Git change count (files with more changes are at the bottom) # Directory Structure ``` .github/ workflows/ lint.yml test.yml audits/ Statemind-Hooks.pdf script/ deploy/ FullRestakeDecreaseHook.s.sol FullRestakeResetHook.s.sol Hooks.s.sol NetworkRestakeDecreaseHook.s.sol NetworkRestakeRedistributeHook.s.sol NetworkRestakeResetHook.s.sol OperatorSpecificDecreaseHook.s.sol OperatorSpecificResetHook.s.sol specs/ FullRestakeDelegatorHooks.md NetworkRestakeDelegatorHooks.md OperatorSpecificDelegatorHooks.md src/ contracts/ fullRestakeDelegator/ FullRestakeDecreaseHook.sol FullRestakeResetHook.sol networkRestakeDelegator/ NetworkRestakeDecreaseHook.sol NetworkRestakeRedistributeHook.sol NetworkRestakeResetHook.sol operatorSpecificDelegator/ OperatorSpecificDecreaseHook.sol OperatorSpecificResetHook.sol interfaces/ fullRestakeDelegator/ IFullRestakeDecreaseHook.sol IFullRestakeResetHook.sol networkRestakeDelegator/ INetworkRestakeDecreaseHook.sol INetworkRestakeRedistributeHook.sol INetworkRestakeResetHook.sol operatorSpecificDelegator/ IOperatorSpecificDecreaseHook.sol IOperatorSpecificResetHook.sol test/ fullRestakeDelegator/ FullRestakeDecreaseHook.t.sol FullRestakeResetHook.t.sol integration/ SymbioticHooksBindings.sol SymbioticHooksConstants.sol SymbioticHooksImports.sol SymbioticHooksImportsContracts.sol SymbioticHooksInit.sol SymbioticHooksIntegration.sol SymbioticHooksIntegrationExample.sol mocks/ FakeDelegator.sol networkRestakeDelegator/ NetworkRestakeDecreaseHook.t.sol NetworkRestakeRedistributeHook.t.sol NetworkRestakeResetHook.t.sol operatorSpecificDelegator/ OperatorSpecificDecreaseHook.t.sol OperatorSpecificResetHook.t.sol .env.example .gitignore .gitmodules foundry.toml LICENSE package.json README.md remappings.txt ``` # Files ## File: .github/workflows/lint.yml ````yaml name: lint on: push: branches: - main pull_request: jobs: run-linters: name: Run linters runs-on: ubuntu-latest steps: - name: Check out Git repository uses: actions/checkout@v3 - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 with: version: nightly - name: Lint run: forge fmt --check ```` ## File: .github/workflows/test.yml ````yaml name: test on: push: branches: - main pull_request: jobs: run-tests: name: Run tests runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: submodules: recursive - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 with: version: nightly - name: Run Forge tests run: | forge test -vvv id: test ```` ## File: script/deploy/FullRestakeDecreaseHook.s.sol ```` // SPDX-License-Identifier: BUSL-1.1 ⋮---- import {Script, console2} from "forge-std/Script.sol"; ⋮---- import {FullRestakeDecreaseHook} from "../../src/contracts/fullRestakeDelegator/FullRestakeDecreaseHook.sol"; ⋮---- contract FullRestakeDecreaseHookScript is Script { function run() public { ```` ## File: script/deploy/FullRestakeResetHook.s.sol ```` // SPDX-License-Identifier: BUSL-1.1 ⋮---- import {Script, console2} from "forge-std/Script.sol"; ⋮---- import {FullRestakeResetHook} from "../../src/contracts/fullRestakeDelegator/FullRestakeResetHook.sol"; ⋮---- contract FullRestakeResetHookScript is Script { function run(uint48 period, uint256 slashCount) public { ```` ## File: script/deploy/Hooks.s.sol ```` // SPDX-License-Identifier: BUSL-1.1 ⋮---- import {Script, console2} from "forge-std/Script.sol"; ⋮---- import {FullRestakeDecreaseHook} from "../../src/contracts/fullRestakeDelegator/FullRestakeDecreaseHook.sol"; import {NetworkRestakeDecreaseHook} from "../../src/contracts/networkRestakeDelegator/NetworkRestakeDecreaseHook.sol"; import {NetworkRestakeRedistributeHook} from "../../src/contracts/networkRestakeDelegator/NetworkRestakeRedistributeHook.sol"; import {OperatorSpecificDecreaseHook} from "../../src/contracts/operatorSpecificDelegator/OperatorSpecificDecreaseHook.sol"; ⋮---- contract HooksScript is Script { function run() public { ```` ## File: script/deploy/NetworkRestakeDecreaseHook.s.sol ```` // SPDX-License-Identifier: BUSL-1.1 ⋮---- import {Script, console2} from "forge-std/Script.sol"; ⋮---- import {NetworkRestakeDecreaseHook} from "../../src/contracts/networkRestakeDelegator/NetworkRestakeDecreaseHook.sol"; ⋮---- contract NetworkRestakeDecreaseHookScript is Script { function run() public { ```` ## File: script/deploy/NetworkRestakeRedistributeHook.s.sol ```` // SPDX-License-Identifier: BUSL-1.1 ⋮---- import {Script, console2} from "forge-std/Script.sol"; ⋮---- import {NetworkRestakeRedistributeHook} from "../../src/contracts/networkRestakeDelegator/NetworkRestakeRedistributeHook.sol"; ⋮---- contract NetworkRestakeRedistributeHookScript is Script { function run() public { ```` ## File: script/deploy/NetworkRestakeResetHook.s.sol ```` // SPDX-License-Identifier: BUSL-1.1 ⋮---- import {Script, console2} from "forge-std/Script.sol"; ⋮---- import {NetworkRestakeResetHook} from "../../src/contracts/networkRestakeDelegator/NetworkRestakeResetHook.sol"; ⋮---- contract NetworkRestakeResetHookScript is Script { function run(uint48 period, uint256 slashCount) public { ```` ## File: script/deploy/OperatorSpecificDecreaseHook.s.sol ```` // SPDX-License-Identifier: BUSL-1.1 ⋮---- import {Script, console2} from "forge-std/Script.sol"; ⋮---- import {OperatorSpecificDecreaseHook} from "../../src/contracts/operatorSpecificDelegator/OperatorSpecificDecreaseHook.sol"; ⋮---- contract OperatorSpecificDecreaseHookScript is Script { function run() public { ```` ## File: script/deploy/OperatorSpecificResetHook.s.sol ```` // SPDX-License-Identifier: BUSL-1.1 ⋮---- import {Script, console2} from "forge-std/Script.sol"; ⋮---- import {OperatorSpecificResetHook} from "../../src/contracts/operatorSpecificDelegator/OperatorSpecificResetHook.sol"; ⋮---- contract OperatorSpecificResetHookScript is Script { function run(uint48 period, uint256 slashCount) public { ```` ## File: specs/FullRestakeDelegatorHooks.md ````markdown ## Hooks ### FullRestakeDecreaseHook FullRestakeDecreaseHook supports `onSlash()` calls only from `FullRestakeDelegator`. This hook decreases the network's limit by the slashed amount and decreases the operator's limit also by the slashed amount. It doesn't change stake amounts for other operators. ### FullRestakeResetHook FullRestakeResetHook supports `onSlash()` calls only from `FullRestakeDelegator`. This hook resets the slashed operator's limit to zero in case it was slashed a configured number of times during a configured period of time. ```` ## File: specs/NetworkRestakeDelegatorHooks.md ````markdown ## Hooks ### NetworkRestakeDecreaseHook NetworkRestakeDecreaseHook supports `onSlash()` calls only from `NetworkRestakeDelegator`. This hook decreases the network’s limit by the slashed amount and decreases the slashed operator’s shares (in case of network limit less than or equal to the active deposits, the stake will be decreased by the slashed amount, not changing other operators' stakes, otherwise, the stake changes depend on the active deposits). ### NetworkRestakeRedistributeHook NetworkRestakeRedistributeHook supports `onSlash()` calls only from `NetworkRestakeDelegator`. This hook decreases the slashed operator's shares by slashed percent from the given stake, redistributing the decreased stake to other operators. ### NetworkRestakeResetHook NetworkRestakeResetHook supports `onSlash()` calls only from `NetworkRestakeDelegator`. This hook resets the slashed operator's shares to zero in case it was slashed a configured number of times during a configured period of time. ```` ## File: specs/OperatorSpecificDelegatorHooks.md ````markdown ## Hooks ### OperatorSpecificDecreaseHook OperatorSpecificDecreaseHook supports `onSlash()` calls only from `OperatorSpecificDelegator`. This hook decreases the network's limit by the slashed amount. ### OperatorSpecificResetHook OperatorSpecificResetHook supports `onSlash()` calls only from `OperatorSpecificDelegator`. This hook resets the slashing network's limit to zero in case it was slashed a configured number of times during a configured period of time. ```` ## File: src/contracts/fullRestakeDelegator/FullRestakeDecreaseHook.sol ```` // SPDX-License-Identifier: MIT ⋮---- import {IFullRestakeDecreaseHook} from "../../interfaces/fullRestakeDelegator/IFullRestakeDecreaseHook.sol"; ⋮---- import {IDelegatorHook} from "@symbioticfi/core/src/interfaces/delegator/IDelegatorHook.sol"; import {IEntity} from "@symbioticfi/core/src/interfaces/common/IEntity.sol"; import {IFullRestakeDelegator} from "@symbioticfi/core/src/interfaces/delegator/IFullRestakeDelegator.sol"; ⋮---- import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; ⋮---- contract FullRestakeDecreaseHook is IFullRestakeDecreaseHook { ⋮---- /** * @inheritdoc IDelegatorHook */ function onSlash( ⋮---- uint48, /* captureTimestamp */ bytes calldata /* data */ ```` ## File: src/contracts/fullRestakeDelegator/FullRestakeResetHook.sol ```` // SPDX-License-Identifier: MIT ⋮---- import {IFullRestakeResetHook} from "../../interfaces/fullRestakeDelegator/IFullRestakeResetHook.sol"; ⋮---- import {IDelegatorHook} from "@symbioticfi/core/src/interfaces/delegator/IDelegatorHook.sol"; import {IEntity} from "@symbioticfi/core/src/interfaces/common/IEntity.sol"; import {IFullRestakeDelegator} from "@symbioticfi/core/src/interfaces/delegator/IFullRestakeDelegator.sol"; import {IVault} from "@symbioticfi/core/src/interfaces/vault/IVault.sol"; ⋮---- import {CircularBuffer} from "@openzeppelin/contracts/utils/structs/CircularBuffer.sol"; import {Time} from "@openzeppelin/contracts/utils/types/Time.sol"; ⋮---- contract FullRestakeResetHook is IFullRestakeResetHook { ⋮---- /** * @inheritdoc IFullRestakeResetHook */ ⋮---- /** * @inheritdoc IDelegatorHook */ function onSlash( ⋮---- uint256, /* slashedAmount */ uint48, /* captureTimestamp */ bytes calldata /* data */ ```` ## File: src/contracts/networkRestakeDelegator/NetworkRestakeDecreaseHook.sol ```` // SPDX-License-Identifier: MIT ⋮---- import {INetworkRestakeDecreaseHook} from "../../interfaces/networkRestakeDelegator/INetworkRestakeDecreaseHook.sol"; ⋮---- import {IDelegatorHook} from "@symbioticfi/core/src/interfaces/delegator/IDelegatorHook.sol"; import {IEntity} from "@symbioticfi/core/src/interfaces/common/IEntity.sol"; import {INetworkRestakeDelegator} from "@symbioticfi/core/src/interfaces/delegator/INetworkRestakeDelegator.sol"; import {IBaseSlasher} from "@symbioticfi/core/src/interfaces/slasher/IBaseSlasher.sol"; import {ISlasher} from "@symbioticfi/core/src/interfaces/slasher/ISlasher.sol"; import {IVetoSlasher} from "@symbioticfi/core/src/interfaces/slasher/IVetoSlasher.sol"; ⋮---- import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; ⋮---- contract NetworkRestakeDecreaseHook is INetworkRestakeDecreaseHook { ⋮---- /** * @inheritdoc IDelegatorHook */ function onSlash( ```` ## File: src/contracts/networkRestakeDelegator/NetworkRestakeRedistributeHook.sol ```` // SPDX-License-Identifier: MIT ⋮---- import {INetworkRestakeRedistributeHook} from "../../interfaces/networkRestakeDelegator/INetworkRestakeRedistributeHook.sol"; ⋮---- import {IDelegatorHook} from "@symbioticfi/core/src/interfaces/delegator/IDelegatorHook.sol"; import {IEntity} from "@symbioticfi/core/src/interfaces/common/IEntity.sol"; import {INetworkRestakeDelegator} from "@symbioticfi/core/src/interfaces/delegator/INetworkRestakeDelegator.sol"; import {IVault} from "@symbioticfi/core/src/interfaces/vault/IVault.sol"; import {IBaseSlasher} from "@symbioticfi/core/src/interfaces/slasher/IBaseSlasher.sol"; import {ISlasher} from "@symbioticfi/core/src/interfaces/slasher/ISlasher.sol"; import {IVetoSlasher} from "@symbioticfi/core/src/interfaces/slasher/IVetoSlasher.sol"; ⋮---- import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; ⋮---- contract NetworkRestakeRedistributeHook is INetworkRestakeRedistributeHook { ⋮---- /** * @inheritdoc IDelegatorHook */ function onSlash( ```` ## File: src/contracts/networkRestakeDelegator/NetworkRestakeResetHook.sol ```` // SPDX-License-Identifier: MIT ⋮---- import {INetworkRestakeResetHook} from "../../interfaces/networkRestakeDelegator/INetworkRestakeResetHook.sol"; ⋮---- import {IDelegatorHook} from "@symbioticfi/core/src/interfaces/delegator/IDelegatorHook.sol"; import {IEntity} from "@symbioticfi/core/src/interfaces/common/IEntity.sol"; import {INetworkRestakeDelegator} from "@symbioticfi/core/src/interfaces/delegator/INetworkRestakeDelegator.sol"; import {IVault} from "@symbioticfi/core/src/interfaces/vault/IVault.sol"; ⋮---- import {CircularBuffer} from "@openzeppelin/contracts/utils/structs/CircularBuffer.sol"; import {Time} from "@openzeppelin/contracts/utils/types/Time.sol"; ⋮---- contract NetworkRestakeResetHook is INetworkRestakeResetHook { ⋮---- /** * @inheritdoc INetworkRestakeResetHook */ ⋮---- /** * @inheritdoc IDelegatorHook */ function onSlash( ⋮---- uint256, /* slashedAmount */ uint48, /* captureTimestamp */ bytes calldata /* data */ ```` ## File: src/contracts/operatorSpecificDelegator/OperatorSpecificDecreaseHook.sol ```` // SPDX-License-Identifier: MIT ⋮---- import {IOperatorSpecificDecreaseHook} from "../../interfaces/operatorSpecificDelegator/IOperatorSpecificDecreaseHook.sol"; ⋮---- import {IDelegatorHook} from "@symbioticfi/core/src/interfaces/delegator/IDelegatorHook.sol"; import {IEntity} from "@symbioticfi/core/src/interfaces/common/IEntity.sol"; import {IOperatorSpecificDelegator} from "@symbioticfi/core/src/interfaces/delegator/IOperatorSpecificDelegator.sol"; ⋮---- import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; ⋮---- contract OperatorSpecificDecreaseHook is IOperatorSpecificDecreaseHook { ⋮---- /** * @inheritdoc IDelegatorHook */ function onSlash( ⋮---- address, /* operator */ ⋮---- uint48, /* captureTimestamp */ bytes calldata /* data */ ```` ## File: src/contracts/operatorSpecificDelegator/OperatorSpecificResetHook.sol ```` // SPDX-License-Identifier: MIT ⋮---- import {IOperatorSpecificResetHook} from "../../interfaces/operatorSpecificDelegator/IOperatorSpecificResetHook.sol"; ⋮---- import {IDelegatorHook} from "@symbioticfi/core/src/interfaces/delegator/IDelegatorHook.sol"; import {IEntity} from "@symbioticfi/core/src/interfaces/common/IEntity.sol"; import {IOperatorSpecificDelegator} from "@symbioticfi/core/src/interfaces/delegator/IOperatorSpecificDelegator.sol"; import {IVault} from "@symbioticfi/core/src/interfaces/vault/IVault.sol"; ⋮---- import {CircularBuffer} from "@openzeppelin/contracts/utils/structs/CircularBuffer.sol"; import {Time} from "@openzeppelin/contracts/utils/types/Time.sol"; ⋮---- contract OperatorSpecificResetHook is IOperatorSpecificResetHook { ⋮---- /** * @inheritdoc IOperatorSpecificResetHook */ ⋮---- /** * @inheritdoc IDelegatorHook */ function onSlash( ⋮---- address, /* operator */ uint256, /* slashedAmount */ uint48, /* captureTimestamp */ bytes calldata /* data */ ```` ## File: src/interfaces/fullRestakeDelegator/IFullRestakeDecreaseHook.sol ```` // SPDX-License-Identifier: MIT ⋮---- import {IDelegatorHook} from "@symbioticfi/core/src/interfaces/delegator/IDelegatorHook.sol"; ⋮---- interface IFullRestakeDecreaseHook is IDelegatorHook { ```` ## File: src/interfaces/fullRestakeDelegator/IFullRestakeResetHook.sol ```` // SPDX-License-Identifier: MIT ⋮---- import {IDelegatorHook} from "@symbioticfi/core/src/interfaces/delegator/IDelegatorHook.sol"; ⋮---- interface IFullRestakeResetHook is IDelegatorHook { ⋮---- /** * @notice Get a period during which the slashing should occur to reset the operator's stake. * @return threshold period */ function PERIOD() external view returns (uint48); ⋮---- /** * @notice Get a number of slashes that should occur during the PERIOD to reset the operator's stake. * @return threshold count */ function SLASH_COUNT() external view returns (uint256); ```` ## File: src/interfaces/networkRestakeDelegator/INetworkRestakeDecreaseHook.sol ```` // SPDX-License-Identifier: MIT ⋮---- import {IDelegatorHook} from "@symbioticfi/core/src/interfaces/delegator/IDelegatorHook.sol"; ⋮---- interface INetworkRestakeDecreaseHook is IDelegatorHook { ```` ## File: src/interfaces/networkRestakeDelegator/INetworkRestakeRedistributeHook.sol ```` // SPDX-License-Identifier: MIT ⋮---- import {IDelegatorHook} from "@symbioticfi/core/src/interfaces/delegator/IDelegatorHook.sol"; ⋮---- interface INetworkRestakeRedistributeHook is IDelegatorHook { ```` ## File: src/interfaces/networkRestakeDelegator/INetworkRestakeResetHook.sol ```` // SPDX-License-Identifier: MIT ⋮---- import {IDelegatorHook} from "@symbioticfi/core/src/interfaces/delegator/IDelegatorHook.sol"; ⋮---- interface INetworkRestakeResetHook is IDelegatorHook { ⋮---- /** * @notice Get a period during which the slashing should occur to reset the operator's stake. * @return threshold period */ function PERIOD() external view returns (uint48); ⋮---- /** * @notice Get a number of slashes that should occur during the PERIOD to reset the operator's stake. * @return threshold count */ function SLASH_COUNT() external view returns (uint256); ```` ## File: src/interfaces/operatorSpecificDelegator/IOperatorSpecificDecreaseHook.sol ```` // SPDX-License-Identifier: MIT ⋮---- import {IDelegatorHook} from "@symbioticfi/core/src/interfaces/delegator/IDelegatorHook.sol"; ⋮---- interface IOperatorSpecificDecreaseHook is IDelegatorHook { ```` ## File: src/interfaces/operatorSpecificDelegator/IOperatorSpecificResetHook.sol ```` // SPDX-License-Identifier: MIT ⋮---- import {IDelegatorHook} from "@symbioticfi/core/src/interfaces/delegator/IDelegatorHook.sol"; ⋮---- interface IOperatorSpecificResetHook is IDelegatorHook { ⋮---- /** * @notice Get a period during which the slashing should occur to reset the operator's stake. * @return threshold period */ function PERIOD() external view returns (uint48); ⋮---- /** * @notice Get a number of slashes that should occur during the PERIOD to reset the operator's stake. * @return threshold count */ function SLASH_COUNT() external view returns (uint256); ```` ## File: test/fullRestakeDelegator/FullRestakeDecreaseHook.t.sol ```` // SPDX-License-Identifier: MIT ⋮---- import {POCBaseTest} from "@symbioticfi/core/test/POCBase.t.sol"; import {Vault} from "@symbioticfi/core/src/contracts/vault/Vault.sol"; import {FullRestakeDelegator} from "@symbioticfi/core/src/contracts/delegator/FullRestakeDelegator.sol"; import {Slasher} from "@symbioticfi/core/src/contracts/slasher/Slasher.sol"; import {IBaseSlasher} from "@symbioticfi/core/src/interfaces/slasher/IBaseSlasher.sol"; import {ISlasher} from "@symbioticfi/core/src/interfaces/slasher/ISlasher.sol"; import {IBaseDelegator} from "@symbioticfi/core/src/interfaces/delegator/IBaseDelegator.sol"; import {IFullRestakeDelegator} from "@symbioticfi/core/src/interfaces/delegator/IFullRestakeDelegator.sol"; import {IVault} from "@symbioticfi/core/src/interfaces/vault/IVault.sol"; import {IVaultConfigurator} from "@symbioticfi/core/src/interfaces/IVaultConfigurator.sol"; ⋮---- import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; import {Subnetwork} from "@symbioticfi/core/src/contracts/libraries/Subnetwork.sol"; ⋮---- import {FullRestakeDecreaseHook} from "../../src/contracts/fullRestakeDelegator/FullRestakeDecreaseHook.sol"; ⋮---- contract FullRestakeDecreaseHookTest is POCBaseTest { ⋮---- function setUp() public override { ⋮---- function test_SlashWithHook( ⋮---- function test_SlashWithHookRevertNotFullRestakeDelegator( ```` ## File: test/fullRestakeDelegator/FullRestakeResetHook.t.sol ```` // SPDX-License-Identifier: MIT ⋮---- import {POCBaseTest} from "@symbioticfi/core/test/POCBase.t.sol"; import {Vault} from "@symbioticfi/core/src/contracts/vault/Vault.sol"; import {FullRestakeDelegator} from "@symbioticfi/core/src/contracts/delegator/FullRestakeDelegator.sol"; import {Slasher} from "@symbioticfi/core/src/contracts/slasher/Slasher.sol"; import {IBaseSlasher} from "@symbioticfi/core/src/interfaces/slasher/IBaseSlasher.sol"; import {ISlasher} from "@symbioticfi/core/src/interfaces/slasher/ISlasher.sol"; import {IBaseDelegator} from "@symbioticfi/core/src/interfaces/delegator/IBaseDelegator.sol"; import {IFullRestakeDelegator} from "@symbioticfi/core/src/interfaces/delegator/IFullRestakeDelegator.sol"; import {IVault} from "@symbioticfi/core/src/interfaces/vault/IVault.sol"; import {IVaultConfigurator} from "@symbioticfi/core/src/interfaces/IVaultConfigurator.sol"; ⋮---- import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; import {Subnetwork} from "@symbioticfi/core/src/contracts/libraries/Subnetwork.sol"; ⋮---- import {FullRestakeResetHook} from "../../src/contracts/fullRestakeDelegator/FullRestakeResetHook.sol"; import {IFullRestakeResetHook} from "../../src/interfaces/fullRestakeDelegator/IFullRestakeResetHook.sol"; import {FakeDelegator} from "../mocks/FakeDelegator.sol"; ⋮---- contract FullRestakeResetHookTest is POCBaseTest { ⋮---- function setUp() public override { ⋮---- function test_SlashWithHook( ⋮---- function test_SlashWithHookRevertNotFullRestakeDelegator( ⋮---- function test_SlashWithHookRevertNotVaultDelegator( ```` ## File: test/integration/SymbioticHooksBindings.sol ```` // SPDX-License-Identifier: MIT ⋮---- import "./SymbioticHooksImports.sol"; ⋮---- import {Test} from "forge-std/Test.sol"; ⋮---- contract SymbioticHooksBindings is Test {} ```` ## File: test/integration/SymbioticHooksConstants.sol ```` // SPDX-License-Identifier: MIT ⋮---- import "./SymbioticHooksImports.sol"; ⋮---- function networkRestakeDecreaseHook() internal view returns (address) { ⋮---- // mainnet ⋮---- // holesky ⋮---- // sepolia ⋮---- // hoodi ⋮---- function networkRestakeRedistributeHook() internal view returns (address) { ⋮---- function fullRestakeDecreaseHook() internal view returns (address) { ⋮---- function operatorSpecificDecreaseHook() internal view returns (address) { ```` ## File: test/integration/SymbioticHooksImports.sol ```` // SPDX-License-Identifier: MIT ⋮---- import {IFullRestakeDecreaseHook as ISymbioticFullRestakeDecreaseHook} from "../../src/interfaces/fullRestakeDelegator/IFullRestakeDecreaseHook.sol"; import {IFullRestakeResetHook as ISymbioticFullRestakeResetHook} from "../../src/interfaces/fullRestakeDelegator/IFullRestakeResetHook.sol"; import {INetworkRestakeDecreaseHook as ISymbioticNetworkRestakeDecreaseHook} from "../../src/interfaces/networkRestakeDelegator/INetworkRestakeDecreaseHook.sol"; import {INetworkRestakeResetHook as ISymbioticNetworkRestakeResetHook} from "../../src/interfaces/networkRestakeDelegator/INetworkRestakeResetHook.sol"; import {INetworkRestakeRedistributeHook as ISymbioticNetworkRestakeRedistributeHook} from "../../src/interfaces/networkRestakeDelegator/INetworkRestakeRedistributeHook.sol"; import {IOperatorSpecificDecreaseHook as ISymbioticOperatorSpecificDecreaseHook} from "../../src/interfaces/operatorSpecificDelegator/IOperatorSpecificDecreaseHook.sol"; import {IOperatorSpecificResetHook as ISymbioticOperatorSpecificResetHook} from "../../src/interfaces/operatorSpecificDelegator/IOperatorSpecificResetHook.sol"; ⋮---- interface SymbioticHooksImports {} ```` ## File: test/integration/SymbioticHooksImportsContracts.sol ```` // SPDX-License-Identifier: MIT ⋮---- import {FullRestakeDecreaseHook as SymbioticFullRestakeDecreaseHook} from "../../src/contracts/fullRestakeDelegator/FullRestakeDecreaseHook.sol"; import {FullRestakeResetHook as SymbioticFullRestakeResetHook} from "../../src/contracts/fullRestakeDelegator/FullRestakeResetHook.sol"; import {NetworkRestakeDecreaseHook as SymbioticNetworkRestakeDecreaseHook} from "../../src/contracts/networkRestakeDelegator/NetworkRestakeDecreaseHook.sol"; import {NetworkRestakeResetHook as SymbioticNetworkRestakeResetHook} from "../../src/contracts/networkRestakeDelegator/NetworkRestakeResetHook.sol"; import {NetworkRestakeRedistributeHook as SymbioticNetworkRestakeRedistributeHook} from "../../src/contracts/networkRestakeDelegator/NetworkRestakeRedistributeHook.sol"; import {OperatorSpecificDecreaseHook as SymbioticOperatorSpecificDecreaseHook} from "../../src/contracts/operatorSpecificDelegator/OperatorSpecificDecreaseHook.sol"; import {OperatorSpecificResetHook as SymbioticOperatorSpecificResetHook} from "../../src/contracts/operatorSpecificDelegator/OperatorSpecificResetHook.sol"; ⋮---- interface SymbioticHooksImportsContracts {} ```` ## File: test/integration/SymbioticHooksInit.sol ```` // SPDX-License-Identifier: MIT ⋮---- import "@symbioticfi/core/test/integration/SymbioticCoreInit.sol"; ⋮---- import "./SymbioticHooksImports.sol"; ⋮---- import {SymbioticHooksConstants} from "./SymbioticHooksConstants.sol"; import {SymbioticHooksBindings} from "./SymbioticHooksBindings.sol"; ⋮---- import {SafeERC20, IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; ⋮---- contract SymbioticHooksInit is SymbioticCoreInit, SymbioticHooksBindings { ⋮---- // General config ⋮---- function setUp() public virtual override { ⋮---- // ------------------------------------------------------------ HOOKS-RELATED HELPERS ------------------------------------------------------------ // ⋮---- function _getNetworkRestakeDecreaseHook_SymbioticHooks( ⋮---- function _getNetworkRestakeRedistributeHook_SymbioticHooks( ⋮---- function _getNetworkRestakeResetHook_SymbioticHooks( ⋮---- function _getNetworkRestakeResetHook_SymbioticHooks() internal virtual returns (address) { ⋮---- function _getFullRestakeDecreaseHook_SymbioticHooks( ⋮---- function _getFullRestakeResetHook_SymbioticHooks( ⋮---- function _getFullRestakeResetHook_SymbioticHooks() internal virtual returns (address) { ⋮---- function _getOperatorSpecificDecreaseHook_SymbioticHooks( ⋮---- function _getOperatorSpecificResetHook_SymbioticHooks( ⋮---- function _getOperatorSpecificResetHook_SymbioticHooks() internal virtual returns (address) { ⋮---- function _getDecreaseHook_SymbioticHooks( ⋮---- function _getRedistributionHook_SymbioticHooks( ⋮---- function _getResetHook_SymbioticHooks( ⋮---- function _getHookRandom_SymbioticHooks( ```` ## File: test/integration/SymbioticHooksIntegration.sol ```` // SPDX-License-Identifier: MIT ⋮---- import "@symbioticfi/core/test/integration/SymbioticCoreIntegration.sol"; ⋮---- import "./SymbioticHooksInit.sol"; ⋮---- contract SymbioticHooksIntegration is SymbioticHooksInit, SymbioticCoreIntegration { function setUp() public virtual override(SymbioticHooksInit, SymbioticCoreIntegration) { ⋮---- function _getVaultRandom_SymbioticCore( ⋮---- // New code ```` ## File: test/integration/SymbioticHooksIntegrationExample.sol ```` // SPDX-License-Identifier: MIT ⋮---- import "./SymbioticHooksIntegration.sol"; ⋮---- import {console2} from "forge-std/Test.sol"; ⋮---- contract SymbioticHooksIntegrationExample is SymbioticHooksIntegration { ⋮---- uint256 public SELECT_OPERATOR_CHANCE = 1; // lower -> higher probability ⋮---- function setUp() public override { ⋮---- // vm.selectFork(vm.createFork(vm.rpcUrl("holesky"))); // SYMBIOTIC_INIT_BLOCK = 2_727_202; // SYMBIOTIC_CORE_USE_EXISTING_DEPLOYMENT = true; ⋮---- function test_NetworkWithHooks() public { ⋮---- function _logAllocations(address vault, bytes32 subnetwork, address operator) internal { ```` ## File: test/mocks/FakeDelegator.sol ```` // SPDX-License-Identifier: MIT ⋮---- import {IDelegatorHook} from "@symbioticfi/core/src/interfaces/delegator/IDelegatorHook.sol"; ⋮---- contract FakeDelegator { ⋮---- function onSlash( ```` ## File: test/networkRestakeDelegator/NetworkRestakeDecreaseHook.t.sol ```` // SPDX-License-Identifier: MIT ⋮---- import {POCBaseTest} from "@symbioticfi/core/test/POCBase.t.sol"; import {Vault} from "@symbioticfi/core/src/contracts/vault/Vault.sol"; import {NetworkRestakeDelegator} from "@symbioticfi/core/src/contracts/delegator/NetworkRestakeDelegator.sol"; import {Slasher} from "@symbioticfi/core/src/contracts/slasher/Slasher.sol"; import {IBaseSlasher} from "@symbioticfi/core/src/interfaces/slasher/IBaseSlasher.sol"; import {ISlasher} from "@symbioticfi/core/src/interfaces/slasher/ISlasher.sol"; import {IBaseDelegator} from "@symbioticfi/core/src/interfaces/delegator/IBaseDelegator.sol"; import {INetworkRestakeDelegator} from "@symbioticfi/core/src/interfaces/delegator/INetworkRestakeDelegator.sol"; import {IVault} from "@symbioticfi/core/src/interfaces/vault/IVault.sol"; import {IVaultConfigurator} from "@symbioticfi/core/src/interfaces/IVaultConfigurator.sol"; ⋮---- import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; import {Subnetwork} from "@symbioticfi/core/src/contracts/libraries/Subnetwork.sol"; ⋮---- import {NetworkRestakeDecreaseHook} from "../../src/contracts/networkRestakeDelegator/NetworkRestakeDecreaseHook.sol"; ⋮---- contract NetworkRestakeDecreaseHookTest is POCBaseTest { ⋮---- function setUp() public override { ⋮---- function test_SlashWithHook( ⋮---- function test_SlashWithHookRevertNotNetworkRestakeDelegator( ```` ## File: test/networkRestakeDelegator/NetworkRestakeRedistributeHook.t.sol ```` // SPDX-License-Identifier: MIT ⋮---- import {POCBaseTest} from "@symbioticfi/core/test/POCBase.t.sol"; import {Vault} from "@symbioticfi/core/src/contracts/vault/Vault.sol"; import {NetworkRestakeDelegator} from "@symbioticfi/core/src/contracts/delegator/NetworkRestakeDelegator.sol"; import {Slasher} from "@symbioticfi/core/src/contracts/slasher/Slasher.sol"; import {IBaseSlasher} from "@symbioticfi/core/src/interfaces/slasher/IBaseSlasher.sol"; import {ISlasher} from "@symbioticfi/core/src/interfaces/slasher/ISlasher.sol"; import {IBaseDelegator} from "@symbioticfi/core/src/interfaces/delegator/IBaseDelegator.sol"; import {INetworkRestakeDelegator} from "@symbioticfi/core/src/interfaces/delegator/INetworkRestakeDelegator.sol"; import {IVault} from "@symbioticfi/core/src/interfaces/vault/IVault.sol"; import {IVaultConfigurator} from "@symbioticfi/core/src/interfaces/IVaultConfigurator.sol"; ⋮---- import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; import {Subnetwork} from "@symbioticfi/core/src/contracts/libraries/Subnetwork.sol"; ⋮---- import {NetworkRestakeRedistributeHook} from "../../src/contracts/networkRestakeDelegator/NetworkRestakeRedistributeHook.sol"; ⋮---- contract NetworkRestakeRedistributeHookTest is POCBaseTest { ⋮---- function setUp() public override { ⋮---- function test_SlashWithHook( ⋮---- function test_SlashWithHookRevertNotNetworkRestakeDelegator( ```` ## File: test/networkRestakeDelegator/NetworkRestakeResetHook.t.sol ```` // SPDX-License-Identifier: MIT ⋮---- import {POCBaseTest} from "@symbioticfi/core/test/POCBase.t.sol"; import {Vault} from "@symbioticfi/core/src/contracts/vault/Vault.sol"; import {NetworkRestakeDelegator} from "@symbioticfi/core/src/contracts/delegator/NetworkRestakeDelegator.sol"; import {Slasher} from "@symbioticfi/core/src/contracts/slasher/Slasher.sol"; import {IBaseSlasher} from "@symbioticfi/core/src/interfaces/slasher/IBaseSlasher.sol"; import {ISlasher} from "@symbioticfi/core/src/interfaces/slasher/ISlasher.sol"; import {IBaseDelegator} from "@symbioticfi/core/src/interfaces/delegator/IBaseDelegator.sol"; import {INetworkRestakeDelegator} from "@symbioticfi/core/src/interfaces/delegator/INetworkRestakeDelegator.sol"; import {IVault} from "@symbioticfi/core/src/interfaces/vault/IVault.sol"; import {IVaultConfigurator} from "@symbioticfi/core/src/interfaces/IVaultConfigurator.sol"; ⋮---- import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; import {Subnetwork} from "@symbioticfi/core/src/contracts/libraries/Subnetwork.sol"; ⋮---- import {NetworkRestakeResetHook} from "../../src/contracts/networkRestakeDelegator/NetworkRestakeResetHook.sol"; import {INetworkRestakeResetHook} from "../../src/interfaces/networkRestakeDelegator/INetworkRestakeResetHook.sol"; import {FakeDelegator} from "../mocks/FakeDelegator.sol"; ⋮---- contract NetworkRestakeResetHookTest is POCBaseTest { ⋮---- function setUp() public override { ⋮---- function test_SlashWithHook( ⋮---- function test_SlashWithHookRevertNotNetworkRestakeDelegator( ⋮---- function test_SlashWithHookRevertNotVaultDelegator( ```` ## File: test/operatorSpecificDelegator/OperatorSpecificDecreaseHook.t.sol ```` // SPDX-License-Identifier: MIT ⋮---- import {POCBaseTest} from "@symbioticfi/core/test/POCBase.t.sol"; import {Vault} from "@symbioticfi/core/src/contracts/vault/Vault.sol"; import {OperatorSpecificDelegator} from "@symbioticfi/core/src/contracts/delegator/OperatorSpecificDelegator.sol"; import {Slasher} from "@symbioticfi/core/src/contracts/slasher/Slasher.sol"; import {IBaseSlasher} from "@symbioticfi/core/src/interfaces/slasher/IBaseSlasher.sol"; import {ISlasher} from "@symbioticfi/core/src/interfaces/slasher/ISlasher.sol"; import {IBaseDelegator} from "@symbioticfi/core/src/interfaces/delegator/IBaseDelegator.sol"; import {IOperatorSpecificDelegator} from "@symbioticfi/core/src/interfaces/delegator/IOperatorSpecificDelegator.sol"; import {IVault} from "@symbioticfi/core/src/interfaces/vault/IVault.sol"; import {IVaultConfigurator} from "@symbioticfi/core/src/interfaces/IVaultConfigurator.sol"; ⋮---- import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; import {Subnetwork} from "@symbioticfi/core/src/contracts/libraries/Subnetwork.sol"; ⋮---- import {OperatorSpecificDecreaseHook} from "../../src/contracts/operatorSpecificDelegator/OperatorSpecificDecreaseHook.sol"; ⋮---- contract OperatorSpecificDecreaseHookTest is POCBaseTest { ⋮---- function setUp() public override { ⋮---- function test_SlashWithHook( ⋮---- function test_SlashWithHookRevertNotOperatorSpecificDelegator( ⋮---- function _setNetworkLimitOperator( ```` ## File: test/operatorSpecificDelegator/OperatorSpecificResetHook.t.sol ```` // SPDX-License-Identifier: MIT ⋮---- import {POCBaseTest} from "@symbioticfi/core/test/POCBase.t.sol"; import {Vault} from "@symbioticfi/core/src/contracts/vault/Vault.sol"; import {OperatorSpecificDelegator} from "@symbioticfi/core/src/contracts/delegator/OperatorSpecificDelegator.sol"; import {Slasher} from "@symbioticfi/core/src/contracts/slasher/Slasher.sol"; import {IBaseSlasher} from "@symbioticfi/core/src/interfaces/slasher/IBaseSlasher.sol"; import {ISlasher} from "@symbioticfi/core/src/interfaces/slasher/ISlasher.sol"; import {IBaseDelegator} from "@symbioticfi/core/src/interfaces/delegator/IBaseDelegator.sol"; import {IOperatorSpecificDelegator} from "@symbioticfi/core/src/interfaces/delegator/IOperatorSpecificDelegator.sol"; import {IVault} from "@symbioticfi/core/src/interfaces/vault/IVault.sol"; import {IVaultConfigurator} from "@symbioticfi/core/src/interfaces/IVaultConfigurator.sol"; ⋮---- import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; import {Subnetwork} from "@symbioticfi/core/src/contracts/libraries/Subnetwork.sol"; ⋮---- import {OperatorSpecificResetHook} from "../../src/contracts/operatorSpecificDelegator/OperatorSpecificResetHook.sol"; import {IOperatorSpecificResetHook} from "../../src/interfaces/operatorSpecificDelegator/IOperatorSpecificResetHook.sol"; import {FakeDelegator} from "../mocks/FakeDelegator.sol"; ⋮---- contract OperatorSpecificResetHookTest is POCBaseTest { ⋮---- function setUp() public override { ⋮---- function test_SlashWithHook( ⋮---- function test_SlashWithHookRevertNotOperatorSpecificDelegator( ⋮---- function test_SlashWithHookRevertNotVaultDelegator( ⋮---- function _setNetworkLimitOperator( ```` ## File: .env.example ```` ETH_RPC_URL= ETH_RPC_URL_HOLESKY= ETHERSCAN_API_KEY= ```` ## File: .gitignore ```` # Compiler files cache/ out/**/ !out/FullRestakeDecreaseHook.sol/ !out/FullRestakeResetHook.sol/ !out/NetworkRestakeDecreaseHook.sol/ !out/NetworkRestakeRedistributeHook.sol/ !out/NetworkRestakeResetHook.sol/ !out/OperatorSpecificDecreaseHook.sol/ !out/OperatorSpecificResetHook.sol/ # Ignores development broadcast logs !/broadcast /broadcast/*/31337/ /broadcast/*/11155111/ /broadcast/**/dry-run/ # Docs docs/ # Dotenv file .env # Other files .gas-snapshot lcov.info node_modules package-lock.json ```` ## File: .gitmodules ```` [submodule "lib/forge-std"] path = lib/forge-std url = https://github.com/foundry-rs/forge-std [submodule "lib/openzeppelin-contracts"] path = lib/openzeppelin-contracts url = https://github.com/OpenZeppelin/openzeppelin-contracts [submodule "lib/openzeppelin-contracts-upgradeable"] path = lib/openzeppelin-contracts-upgradeable url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable [submodule "lib/core"] path = lib/core url = https://github.com/symbioticfi/core ```` ## File: foundry.toml ````toml [profile.default] evm_version = "cancun" solc = "0.8.25" optimizer = true optimizer_runs = 200 via_ir = true src = "src" out = "out" libs = ["lib"] fs_permissions = [{ access = "read-write", path = "./"}] gas_reports = ["*"] gas_limit = "18446744073709551615" [rpc_endpoints] mainnet = "${ETH_RPC_URL}" holesky = "${ETH_RPC_URL_HOLESKY}" [fmt] bracket_spacing = false int_types = "long" line_length = 120 multiline_func_header = "params_first" number_underscore = "thousands" quote_style = "double" tab_width = 4 [fuzz] runs = 4096 max_test_rejects = 262144 # See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options ```` ## File: LICENSE ```` MIT License Copyright (c) 2024 Symbiotic Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ```` ## File: package.json ````json { "name": "@symbioticfi/hooks", "version": "1.0.0", "description": "Symbiotic Hooks repository contains several basic on-slash hook implementations for different delegator types.", "homepage": "https://symbiotic.fi/", "bugs": "https://github.com/symbioticfi/hooks/issues", "license": "MIT", "author": "Symbiotic Team", "files": [ "src/**/*", "test/mocks/**/*", "out/**/*.json" ], "repository": { "type": "git", "url": "https://github.com/symbioticfi/hooks.git" }, "keywords": [ "solidity", "ethereum", "smart", "contracts", "security" ], "dependencies": { "@openzeppelin/contracts": "5.1.0", "@openzeppelin/contracts-upgradeable": "5.1.0", "@symbioticfi/core": "1.0.0-devnet.9" } } ```` ## File: README.md ````markdown **[Symbiotic Protocol](https://symbiotic.fi) is an extremely flexible and permissionless shared security system.** This repository contains default on-slash hooks. [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/symbioticfi/hooks) ## Technical Documentation Can be found [here](./specs). ## Security Security audits can be found [here](./audits). ## Usage ### Env Create `.env` file using a template: ``` ETH_RPC_URL= ETH_RPC_URL_HOLESKY= ETHERSCAN_API_KEY= ``` \* ETH_RPC_URL is optional.
\* ETH_RPC_URL_HOLESKY is optional.
\* ETHERSCAN_API_KEY is optional. ### Build ```shell forge build ``` ### Test ```shell forge test ``` ### Format ```shell forge fmt ``` ### Gas Snapshots ```shell forge snapshot ``` ```` ## File: remappings.txt ```` forge-std/=lib/forge-std/src/ @openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/ @openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/ @symbioticfi/core/=lib/core/ ````