Uniswap / docs

📓 Uniswap V3 docs website
https://docs.uniswap.org
317 stars 526 forks source link

add BeforeSwapDelta reference guide with mdx formatting #762

Closed krisoshea-eth closed 1 month ago

krisoshea-eth commented 1 month ago

This PR introduces a reference guide on the BeforeSwapDelta type in Uniswap V4.

Key Features of the Document:

  1. Detailed explanation of BeforeSwapDelta and its role in Uniswap V4 swap operations
  2. Overview of the purpose and importance of BeforeSwapDelta in the Uniswap V4 ecosystem
  3. Technical breakdown of the BeforeSwapDelta type definition and associated functions
  4. Explanation of how BeforeSwapDelta is used within the PoolManager contract
  5. Detailed description of the interaction between BeforeSwapDelta and swap amounts
  6. Discussion on the relationship between beforeSwap and afterSwap hooks
  7. Comprehensive list of key purposes served by BeforeSwapDelta
  8. Implementation details and considerations, including gas optimization techniques
  9. Comparison with BalanceDelta and best practices for working with BeforeSwapDelta
  10. Two detailed examples demonstrating BeforeSwapDelta usage in hooks:
    • A basic example showing the minimal structure of a beforeSwap hook
    • An advanced example implementing a fee mechanism

Document Structure:

Impact and Importance:

Understanding BeforeSwapDelta is essential for implementing custom swap logic, fee structures, and other advanced features in Uniswap V4 pools. The detailed examples provide practical guidance for developers looking to leverage this powerful feature.

vercel[bot] commented 1 month ago

@krisoshea-eth is attempting to deploy a commit to the Uniswap Team on Vercel.

A member of the Team first needs to authorize it.