Uniswap v4 Periphery

repository·main·Indexed 21 days ago

https://github.com/uniswap/v4-periphery

Peripheral smart contracts for interacting with Uniswap v4, providing logic that builds on top of the core pool, including hook contracts, position managers, and integration libraries.

Tokens
370
Snippets
2
Records
2
Agent score
25%

What's inside uniswap-v4-periphery

  1. How to build hooks using BaseHook

    main

    When developing custom hooks for Uniswap v4, it is recommended to inherit from the BaseHook contract provided by the v4-hooks-public repository. You can implement custom logic by overriding specific hook callbacks (e.g., _beforeAddLiquidity). Ensure that your overridden functions return the appropriate selector from the BaseHook to maintain correct hook execution flow.

    contract CoolHook is BaseHook {
        // Override the hook callbacks you want on your hook
        function _beforeAddLiquidity(
            address,
            PoolKey calldata key,
            ModifyLiquidityParams calldata params,
            bytes calldata hookData
        ) internal override returns (bytes4) {
            // hook logic
            return BaseHook.beforeAddLiquidity.selector;
        }
    }
  2. Install Uniswap v4 Periphery via Forge

    main

    To use the Uniswap v4 Periphery contracts in your own project and deploy them to a local testnet, install the repository directly into your project using forge install.

    forge install https://github.com/Uniswap/v4-periphery