From b31c1bd224dbe86193b72d2abe4e26e9ab013098 Mon Sep 17 00:00:00 2001 From: Raphael Nembhard <100111587+DeluxeRaph@users.noreply.github.com> Date: Sun, 15 Sep 2024 16:08:24 -0400 Subject: [PATCH] Update README.md --- README.md | 83 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 62 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 102010d..067c4c8 100644 --- a/README.md +++ b/README.md @@ -2,52 +2,93 @@ ## Introduction -DGL (Dynamic Governance Liquidator) is a tool designed for DAOs to manage their governance tokens more effectively. Built on top of the Uniswap v4 protocol, DGL leverages the Time-Weighted Average Market Maker (TWAMM) hook to allow DAOs to buy or sell their governance tokens over time, minimizing market impact and protecting against frontrunning. +DGL (Dynamic Governance Liquidator) is a comprehensive solution tailored for DAOs to manage their governance tokens more effectively and transparently. Built atop the Uniswap v4 protocol, DGL integrates the Time-Weighted Average Market Maker (**TWAMM**), allowing DAOs to dynamically buy or sell governance tokens over extended periods to minimize market impact and mitigate frontrunning risks. Furthermore, DGL embeds governance-specific logic, enabling the liquidation process to be governed by the DAO's voting and participation mechanisms. ## Problem -DAOs often need to buy or sell large quantities of their governance tokens to manage their treasuries. Executing large trades on-chain can significantly impact the market price and expose the transaction to frontrunning, leading to suboptimal execution and potential loss of value. +DAOs often face the challenge of managing large token orders for treasury rebalancing, funding, or operational liquidity. Large on-chain transactions expose these orders to significant **market impact** and **frontrunning** attacks, resulting in undesirable price slippage and inefficient token allocation. Such inefficiencies hinder the DAO's ability to manage its treasury effectively. ## Solution -DGL solves this problem by integrating the TWAMM hook with additional governance-related functionalities. It enables DAOs to: +DGL solves this problem by leveraging Uniswap v4's **TWAMM** technology and extending it with governance-based logic. The solution enables DAOs to: -- **Market Sell/Buys**: Execute large orders over time, minimizing market impact and reducing the risk of frontrunning. -- **Governance Features**: Incorporate governance-specific logic, such as weighted voting, to tailor the liquidation process according to the DAO's rules. +- **Market Buys/Sells**: Execute large token orders gradually over time, reducing market impact and improving price efficiency. +- **Governance-Driven Liquidation**: Incorporate weighted governance voting mechanisms to influence when and how tokens are liquidated based on the DAO’s strategic objectives. ## Features -- **TWAMM Integration**: Utilize the TWAMM hook to split large orders into smaller, time-weighted swaps, ensuring better execution prices. -- **Governance-Specific Logic**: Implement custom governance rules that influence how and when tokens are liquidated. -- **Frontrunning Protection**: Orders executed through TWAMM are always processed as the first pool action in a block, preventing frontrunners from exploiting the transaction. +- **TWAMM Integration**: Splits large orders into smaller, continuous swaps over a specified time interval, smoothing out price fluctuations and protecting against frontrunning. +- **Governance-Specific Logic**: Integrates a governance voting system that determines how and when liquidations occur, adding an additional layer of control for DAOs. +- **Frontrunning Protection**: By executing TWAMM orders as the first pool action in a block, it prevents frontrunners from front-running or sandwiching the order, ensuring optimal execution for DAOs. +- **Yield and Liquidity Options**: Optionally integrate liquidity provision or yield strategies for tokens locked during governance processes. ## Technical Details -DGL is built on the open-source TWAMM contract from Uniswap v4, with added governance features to suit the needs of DAOs. The core functionality relies on the following key components: +DGL is built upon Uniswap v4's **TWAMM** functionality, enhanced with governance-related smart contracts to tailor the liquidation process according to DAO-defined rules. The core components are: -- **TWAMM Hook**: A custom hook that allows DAOs to execute large token orders over time, reducing price impact and protecting against frontrunning. -- **Governance Logic**: Smart contracts that manage the rules and processes for how governance tokens are bought or sold within the DAO. +- **TWAMM Hook**: A smart contract that schedules and manages time-weighted orders, allowing large trades to be executed over long intervals. This minimizes price impact and ensures better execution pricing. +- **Governance Integration**: A custom governance module that controls when and how orders are submitted based on governance vote outcomes. The voting power determines the size and nature of orders, adding decentralization to treasury management. +- **Token Wrapping for Voting**: Users lock governance tokens in the contract and receive **wrapped governance tokens**, which can be paired with other assets (such as ETH or USDC) to provide liquidity and earn yield while voting. +- **Order Execution and Settlement**: Governance orders are executed over time using TWAMM, and at the conclusion of the order, tokens are either released back to voters or sent for settlement based on the voting outcome. ### Contract Architecture -The contract architecture follows the standard Uniswap v4 setup, with additional layers to support DAO-specific governance features. The TWAMM orders are processed in the following steps: +The contract architecture is composed of the following modules: -1. **Order Submission**: DAOs submit an order specifying the amount of tokens to sell or buy, and the duration over which the order should be executed. -2. **TWAMM Execution**: The TWAMM hook splits the order into smaller chunks, which are executed over time, minimizing the market impact. -3. **Governance Integration**: The order execution is influenced by governance rules, ensuring that the liquidation aligns with the DAO's objectives. +1. **TWAMMGovernance Contract**: + - Handles the governance logic and integrates with TWAMM for long-term order execution. + - Manages token locking, wrapped token issuance, and voting for DAO participants. + - Supports the creation of proposals that define token orders (buy/sell) and controls the execution based on voting outcomes. + +2. **TWAMM Hook**: + - This hook connects the DGL system to Uniswap v4’s liquidity pools, allowing token swaps to occur over a defined period. + - Orders submitted by the governance contract are split into smaller trades, distributed evenly over the duration of the proposal. + +3. **WrappedGovernanceToken Contract**: + - Manages the wrapping and unwrapping of governance tokens. Users deposit their governance tokens and receive a wrapped version, which is used in voting and liquidity provisioning. + - This wrapped token can be paired with stable assets such as **USDC** or **ETH** to earn yield while waiting for the proposal execution. + +4. **Order Execution and Liquidation**: + - Upon successful proposal execution, the TWAMM order is created and managed by the hook, gradually executing the trade to ensure minimal price slippage. + - Governance logic dictates when and how liquidations occur, ensuring the DAO's strategic interests are upheld. + +### Process Flow + +1. **Proposal Creation**: + - DAO members submit a proposal to liquidate governance tokens (buy or sell) over a specific duration. The proposal defines the token pair (e.g., governance token/ETH), the amount, and the duration. + +2. **Voting**: + - DAO members lock their governance tokens, receive wrapped governance tokens, and cast votes on the proposal. Votes can be weighted based on the number of tokens staked or other DAO-defined rules. + +3. **TWAMM Execution**: + - If the proposal passes, TWAMM splits the trade into smaller time-weighted transactions, minimizing market impact. These swaps are automatically executed at regular intervals, ensuring an efficient market presence. + +4. **Settlement and Yield**: + - Once the trade completes, tokens are either distributed back to participants or used to fulfill the proposal's objective (e.g., selling for treasury management or liquidity provisioning). + - Locked tokens may also be paired with assets like ETH or USDC in a Uniswap liquidity pool to earn fees during the voting and execution process. ## Usage -To integrate DGL into your DAO's treasury management strategy, follow these steps: +To integrate DGL into your DAO's governance and treasury management process: + +1. **Install Dependencies**: + - Ensure Uniswap v4 and TWAMM-related contracts are available in your environment. + - Install OpenZeppelin libraries for governance and token standards. + +2. **Deploy Contracts**: + - Deploy the `TWAMMGovernance`, `WrappedGovernanceToken`, and `TWAMM Hook` contracts. + - Set up the token pairings (e.g., governance token/ETH) using the **Uniswap v4 PoolManager**. + +3. **Configure Governance Rules**: + - Customize governance rules (e.g., proposal threshold, voting period, participation percentage) to suit the DAO’s needs. -1. **Install Dependencies**: Ensure that your environment is set up with the necessary Uniswap v4 and TWAMM contracts. -2. **Deploy Contracts**: Deploy the DGL contracts, including the TWAMM hook and any governance-related smart contracts. -3. **Configure Governance Rules**: Set up the governance logic to dictate how the TWAMM orders should be managed. -4. **Submit Orders**: Use the DGL interface to submit buy or sell orders for your DAO's governance tokens. +4. **Submit and Vote on Orders**: + - DAO members can propose large token orders and vote using their wrapped tokens. + - Once a proposal is approved, the TWAMM hook will execute the order over time, ensuring minimal market disruption. ## Contribution -We welcome contributions from the community to improve DGL. Please feel free to open issues or submit pull requests. +We welcome contributions from the community to improve DGL's functionality. Whether it's proposing new features, improving efficiency, or enhancing governance integrations, we encourage you to open issues or submit pull requests. ## License