🪝Hooks

Overview

Hooks are smart contract interfaces that provide privileged access to the internal mechanics of Ociswap liquidity pools. They enable developers to build plugins that can execute code at specific points during pool operations.

Key Features

  • Hooks can execute before and after swaps, or during liquidity updates.

  • They have their own component address and functions.

  • Hooks can be imported at the creation of a liquidity pool.

  • They open up new possibilities for innovation without building a complete DEX from scratch.

Implementation

  1. Hooks must implement standard methods (specifics to be provided).

  2. Developers can customize the logic to suit their application.

  3. Hooks are added to new pools at creation (cannot be added to existing pools).

Limitations

  • Hooks cannot call their own pools (reentrancy protection).

  • Hooks can only be added to new pools, not existing ones.

Use Cases

Hooks can be used for various applications, including but not limited to:

  1. Dynamic Fee Pools

  2. Lending Liquidation (LLAMMA)

  3. Conditional Access Control

  4. Automated Portfolio Rebalancing

  5. Time-Weighted Average Market Maker (TWAMM)

  6. Limit / Range Orders

  7. Arbitrage for Price Stabilization

Best Practices

  • Focus on unique ideas and let Ociswap handle core DEX functionality

  • Consider computational efficiency in hook design

  • Ensure hooks don't introduce security vulnerabilities

Last updated