Skip to main content

Contracts

Virtual contracts

These are contracts that are not directly deployed, but used as building blocks for higher-level contracts:

  • Registry - allows storage of all the added/created addresses to be able to fetch them later

  • Entity (inherits Initializable) - an initializable contract (assumed to be used with a proxy mechanic) having immutable FACTORY and immutable TYPE variables

  • Factory (inherits Registry and Ownable) - allows the creation of entities with implementations (a.k.a., types) proposed by Owner

  • MigratableEntity (inherits Ownable and Initializable) - an initializable contract (assumed to be used as with a proxy mechanic) having immutable FACTORY and versioning via migration mechanic

  • MigratableEntityProxy - a simple, pretty cheap ERC1967 proxy

  • MigratablesFactory (inherits Registry and Ownable) - allows the creation of entities with implementations (a.k.a., versions) proposed by Owner and migration of existing entities to newer versions (by MigratableEntity:Owner)

  • StaticDelegateCallable - allows the creation of any helper contracts to access the whole storage of the inheriting contract on-chain

Visible contracts

These are contracts that are deployed and can be used for on-chain and off-chain integrations:

  • Vault (inherits MigratableEntity and StaticDelegateCallable) - the most crucial part of the Vault responsible for deposits accounting and migration control

  • NetworkRestakeDelegator/FullRestakeDelegator (inherits Entity and StaticDelegateCallable) - a part of the Vault responsible for a stake delegation mechanism

    • NetworkRestakeDelegator - allows a restaking across Subnetworks
    • FullRestakeDelegator - allows a restaking across Subnetworks and across Operators inside the Subnetworks (e.g., can be used to create an insurance mechanic)
  • Slasher/VetoSlasher (inherits Entity and StaticDelegateCallable) - a part of the Vault responsible for a stake slashing

    • Slasher - slashing requests are processed instantly
    • VetoSlasher - slashing requests can be vetoed (if a resolver is set by a slashing Subnetwork) or executed after a veto period
  • VaultFactory (inherits MigratablesFactory) - pure Vaults' creator with the functionality of their migrations

  • DelegatorFactory (inherits Factory) - pure Delegators' creator

  • SlasherFactory (inherits Factory) - pure Slashers' creator

  • NetworkRegistry (inherits Registry) - Networks' managing addresses (e.g., DAO, multi-sig, etc.) registrator

  • NetworkMiddlewareService - Networks' middleware addresses setter

  • OperatorRegistry (inherits Registry) - Operators' managing addresses (e.g., DAO, multi-sig, etc.) registrator

  • MetadataService - metadata setter for "who"

    • NetworkMetadataService - Networks' metadata setter
    • OperatorMetadataService - Operators' metadata setter
  • OptInService (inherits StaticDelegateCallable) - a contract for "who"s opt-ins to "where"s providing services like:

    • VaultOptInService - allows Operators to opt-in to Vaults
    • NetworkOptInService - allows Operators to opt-in to Networks
  • VaultConfigurator - ready-to-work Vaults' creator

  • DefaultStakerRewards - allows Network Middlewares to ditribute rewards, and Stakers to claim them

  • DefaultStakerRewardsFactory (inherits Registry) - DefaultStakerRewards creator

  • DefaultOperatorRewards - allows Network Middlewares to ditribute rewards, and Operators to claim them

  • DefaultOperatorRewardsFactory (inherits Registry) - DefaultOperatorRewards creator


Contracts Assumptions

These are purely technical assumptions the contracts have on each other, and that will break the standard flow if not followed:

  • MigratablesFactory - assumes a whitelisted implementation:

    • to have an owner() returning 20 bytes function
    • to process versioning only through MigratableEntityProxy.migrate(), and to return a correct version through MigratableEntity.version()
    • to have initialize(uint64,address,bytes) and migrate(uint64,bytes) functions
  • MigratableEntityProxy - assumes an implementation:

    • to not contain a function with a selector - 4f1ef286 (from function upgradeToAndCall(address,bytes))
  • Factory - assumes a whitelisted implementation:

    • to have initialize(bytes) function
  • Slasher/VetoSlasher - assumes Slasher.vault()/VetoSlasher.vault():

    • to have slasher() returning 20 bytes function
    • to have activeStake() returning 32 bytes and activeStakeAt(uint48,bytes) returning 32 bytes functions
  • Slasher/VetoSlasher - assumes Vault.delegator():

    • to have stakeAt(bytes32,address,uint48,bytes) returning 32 bytes function which considers Operator opt-ins
    • to have onSlash(bytes32,address,uint256,uint48,bytes) function
  • VetoSlasher - assumes Vault.resolverSetEpochsDelay():

    • to be meaningfully less than 2 ** 48 - 1
  • NetworkRestakeDelegator/FullRestakeDelegator - assumes NetworkRestakeDelegator.vault()/FullRestakeDelegator.vault():

    • to have delegator() returning 20 bytes function
    • to have epochDuration() returning 6 bytes function
  • NetworkRestakeDelegator/FullRestakeDelegator - assumes Vault.slasher():

    • to call onSlash(subnetwork, operator, slashedAmount, captureTimestamp, data) with slashedAmount less or equal to stakeAt(subnetwork, operator, captureTimestamp, new bytes(0))
  • Vault - assumes Vault.collateral():

    • to be ERC20 contract
  • Vault - assumes Vault.epochDuration():

    • to be meaningfully less than 2 ** 48 - 1

Invalid/Deprecative Contracts' States

These are states when the contracts become useless (e.g., nobody is able to deposit new funds) or meaningless (e.g., admin fees are accumulated but not claimable):

  • For Vault:

    • There is no Vault:DEFAULT_ADMIN_ROLE holders, and:
        • deposit whitelist is enabled
        • no whitelisted depositors
        • no Vault:DEPOSIT_WHITELIST_SET_ROLE holders
        • no Vault:DEPOSITOR_WHITELIST_ROLE holders
        • deposit limit is enabled
        • deposit limit is zero
        • no Vault:IS_DEPOSIT_LIMIT_SET_ROLE holders
        • no Vault:DEPOSIT_LIMIT_SET_ROLE holders
  • For NetworkRestakeDelegator:

    • There is no NetworkRestakeDelegator:DEFAULT_ADMIN_ROLE holders, and:
      • networks limits / operator-network shares are zero
      • no NetworkRestakeDelegator:NETWORK_LIMIT_SET_ROLE holders
      • no NetworkRestakeDelegator:OPERATOR_NETWORK_SHARES_SET_ROLE holders
  • For FullRestakeDelegator:

    • There is no FullRestakeDelegator:DEFAULT_ADMIN_ROLE holders, and:
      • networks limits / operator-network limits are zero
      • no FullRestakeDelegator:NETWORK_LIMIT_SET_ROLE holders
      • no FullRestakeDelegator:OPERATOR_NETWORK_LIMIT_SET_ROLE holders
  • For DefaultStakerRewards:

    • There is no DefaultStakerRewards:DEFAULT_ADMIN_ROLE holders, and:
      • admin fee is not zero
      • no DefaultStakerRewards:ADMIN_FEE_CLAIM_ROLE holders
      • no DefaultStakerRewards:ADMIN_FEE_SET_ROLE holders