IPOR Protocol
  • The IPOR Protocol Documentation
  • IPOR Protocol V2
  • Research / Whitepapers
    • Conceptual Whitepaper
  • Audits
  • Community Links
  • IPOR Protocol Roadmap
  • IPOR FAQ
    • About the IPOR Protocol
    • Using the IPOR Protocol
    • Liquidity Mining
    • Swaps VS Perps
    • $FUSN Snapshot
  • About IPOR
    • Who Uses IPOR and for What?
    • Why IPOR?
    • IPOR Manifesto
  • IPOR Fusion ⚛️
    • Fusion Introduction
      • Defragmenting DeFi Yield
    • Why Fusion?
    • Users
    • Use Cases
    • Architecture Overview
      • Atomists
      • Alphas
    • Vaults
      • Access Management
    • Fuses
    • Security
      • For Liquidity Providers
      • For Vault Owners
      • Testing
    • Open-source Repository
    • Aragon Integration
  • IPOR Index
    • What is the IPOR Index
    • Working with the IPOR Index
    • IPOR stETH Index
  • Interest Rate Derivatives
    • Interest Rate Derivative
    • Index Calculation
    • IPOR Publication
    • IBT
    • Indicative Term Sheet
  • Automated Market Maker
    • The Automated Market Maker
    • Liquidity Provisioning
    • IPOR Swaps
      • Hedging example with Morpho protocol
    • Spread
      • Math behind the demand spread
    • Risk oracle
    • SOAP
    • Liquidations
    • Asset Management
  • Tokenomics
    • IPOR Token
    • Token distribution model
    • Power IPOR
    • Liquidity mining
      • Math behind the rewards contract
    • Power Token Liquidity Mining for Developers
  • IPOR DAO
    • IPOR DAO Governance
      • Discord - All Channels
      • Discord - Open Governance Forum
      • Discord - Formal Governance
      • Snapshot - Formal Governance
      • Governing Multisig wallets
    • Decentralizing IPOR
      • Configuration Parameters
  • Developers Docs
    • Fusion
      • Developing а Fuse
      • Configuring Pre-hooks
    • Deployed Contracts
      • Ethereum
      • Arbitrum
      • Base
    • Working with IPOR Router
    • ABI
    • V2 changes
    • IPOR Oracle
    • Vault Wrapper
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. Developers Docs
  2. Fusion

Configuring Pre-hooks

PreviousDeveloping а FuseNextDeployed Contracts

Last updated 1 month ago

Was this helpful?

Pre-hooks are very powerful feature of the Fusion Vaults. They allow an execution of an additional functions before invoking a primary action.

Because the pre-hooks are very powerful functionality their management should always be done by user with a long timelock. IPOR web app will be alerting liquidity providers about the use of unverified pre-hooks.

What is a pre-hook

Fusion vault allows for an execution of a code when invoking restricted methods on the core vault. Pre-hooks are not available to methods on managers.

Pre-hooks are smart contracts with an access to the memory of the contract and authority to execute functions. They can be used for various applications such as:

  • updating balance cache on markets

  • raising exceptions (effectively pausing functions)

  • triggering auto-withdrawals from complex strategies

  • etc.

Due to that power and flexibility it is important that the user allowed to modify the prehooks has timelock configured

To add pre-hook to the vault use setPreHookImplementaions

PlasmaVaultGovernance(PLASMA_VAULT)
    .setPreHookImplementations(selectors, preHooks, substrates);

where selectors are the signatures of restricted methods on the vault, pre-hooks are addresses of implementations and substrates are the params required by the pre-hooks.

Example implementation can be found in below test case: . It demonstrates the use of the pre-hook that rebalances the cache of the vault before deposit and withdrawal while ignoring balances with dust.

List of the deployed prehooks:

https://github.com/IPOR-Labs/ipor-fusion/blob/main/test/pre_hooks/UpdateBalancesIgnoreDustPreHookTest.t.sol
https://github.com/IPOR-Labs/ipor-abi?tab=readme-ov-file#prehooks-list