adshao Publications
repository·master·Indexed 42 days ago
https://github.com/adshao/publicationsA collection of technical publications and deep dives focusing on DeFi protocols, including Uniswap (V2, V3, V4), Gnosis Conditional Tokens, and the VRGDA (Variable Rate Gradual Dutch Auctions) algorithm used in Art Gobblers. Also includes documentation for OpenClaw's memory management and Pi-mono LLM runtime integration.
What's inside adshao-publications
- Yield Basis is a research project focused on analyzing yield and risk-return profiles, specifically in the context of automated market makers (AMMs) and curve mechanics. It includes detailed analysis of impermanent loss and risk-return trade-offs.
Overview of Uniswap v2 Core features
masterUniswap v2 is an evolution of the Uniswap v1 AMM (Automated Market Maker) protocol. While both use the constant product formula $x imes y = k$, Uniswap v2 introduces several key improvements over v1:
- ERC-20 Pairs: Unlike v1, which only supported ERC-20/ETH pairs, v2 supports trading pairs for any two ERC-20 tokens.
- Price Oracles: v2 accumulates the relative price of two tokens at the start of each block, allowing other smart contracts to retrieve the Time-Weighted Average Price (TWAP) over any period.
- Flash Swaps: Enables users to borrow tokens on-chain for the duration of a single transaction, provided the tokens are returned by the end of the transaction along with a fee.
- Protocol Fee Mechanism: While contracts are non-upgradeable, the Factory contract allows a variable to be toggled to enable a 0.05% protocol fee. When enabled, the total fee is 0.3%, but liquidity providers receive 0.25% (the remaining 0.05% goes to the protocol).
Overview of Uniswap v4 core contracts
masterThe
v4-corerepository contains the fundamental smart contracts for Uniswap v4. The architecture is centered around a singleton pattern to manage all pools efficiently. The primary components are:- PoolManager.sol: The central singleton contract. It manages all Uniswap v4 pools and serves as the primary external interface for all pool-related operations, including pool creation, liquidity modification, and trading.
- Library Contracts: Specialized contracts used to execute specific logic for pools, positions, hooks, and accounting:
Pool.sol: Handles pool-specific operations like trading and liquidity modification.Position.sol: Manages position-related operations such as updating liquidity and fees.Hooks.sol: Executes Hooks functions within the Uniswap v4 ecosystem.CurrencyDelta.sol: Manages operations related to Flash Accounting.BalanceDelta.sol: Defines the types of balance deltas used for accounting purposes.
Overview of the PoolManager contract
masterThePoolManageris the core singleton contract of Uniswap v4. It is responsible for managing all Uniswap v4 pools and provides the primary external interfaces for pool operations, including creation, destruction, liquidity modification, and trading. Because it uses a singleton model, it maintains the state of all pools within a single contract instance.Overview of OpenClaw
masterOpenClaw (also tagged asclawdbotormoltbot) is a project focused on memory management and LLM (Large Language Model) runtime capabilities. It provides specialized mechanisms for how an agent manages its memory and interacts with LLM runtimes, specifically utilizingPi-mono.Overview of the Deep Dive into Uniswap v2 Whitepaper
masterThis documentation series provides a technical deep dive into the Uniswap v2 whitepaper. It covers the design philosophy, mathematical formula derivations ($x \cdot y = k$), and engineering implementations of the protocol. It is intended for developers looking to understand the foundational AMM (Automated Market Maker) mechanics used by Uniswap and many other EVM-based forks.Overview of Uniswap v3 features
masterUniswap v3 is an unregulated automated market maker (AMM) on the Ethereum Virtual Machine (EVM) designed to improve capital efficiency. Key improvements over previous versions include:
- Concentrated liquidity: Allows liquidity providers (LPs) to concentrate capital within specific price ranges.
- Flexible fees: Fee tiers are set at pool initialization. Supported tiers include 0.05%, 0.30%, and 1% (with 0.01% implemented via governance for stablecoins).
- Protocol fee governance: UNI governance can set the protocol's share of transaction fees.
- Improved price oracle: Provides a way to query recent cumulative prices for easier TWAP (time-weighted average price) calculation.
- Liquidity oracle: Offers a time-weighted average liquidity oracle.
Overview of Uniswap v3
masterUniswap v3 is an unregulated Automated Market Maker (AMM) implemented on the Ethereum Virtual Machine (EVM). It improves upon previous versions by increasing capital efficiency, providing liquidity providers (LPs) with more control, improving price oracle accuracy, and offering a flexible fee structure.
Key features include:
- Concentrated Liquidity: Allows LPs to provide liquidity within specific price ranges.
- Flexible Fees: Fee tiers are set during pool initialization. Supported tiers include 0.05%, 0.30%, and 1% (with a 0.01% tier available for stablecoin pairs via governance).
- Protocol Fee Governance: UNI governance can adjust the portion of transaction fees allocated to the protocol.
- Improved Price Oracles: Provides a way to query cumulative recent prices, simplifying Time-Weighted Average Price (TWAP) calculations.
- Liquidity Oracles: Provides a time-weighted average liquidity oracle.
Explore Art Gobblers and Yield Basis analyses
masterTechnical analyses of the VRGDA algorithm used in Art Gobblers and risk-return analysis for Yield Basis.
### Art Gobblers * [VRGDA Algorithm Analysis](./artgobblers/vrgda/README.md) ### Yield Basis * [Yield Basis Risk Return Analysis](./yield-basis/en/yield-basis-risk-return-analysis.md)Use PositionManager for liquidity and position management
masterThe
PositionManagercontract is the primary interface for managing liquidity positions in Uniswap v4. It handles creating positions, modifying existing liquidity, deleting positions, and settling balances.It exposes two main interfaces for liquidity modification:
initializePool: Used to initialize a pool.modifyLiquidities: Used to modify liquidity.modifyLiquiditiesWithoutUnlock: Used to modify liquidity without triggering an unlock mechanism.
Both
modifyLiquiditiesandmodifyLiquiditiesWithoutUnlockutilize the internal_handleActionmethod viaBaseActionsRouter._executeActionsWithoutUnlockto perform specific user-defined operations.Explore Uniswap technical deep dives
masterThis repository contains detailed technical analyses and deep dives into the Uniswap protocol across multiple versions (V2, V3, and V4). You can access documentation covering both the theoretical whitepapers and the practical implementation of the smart contracts.
### Uniswap V4 * [Deep Dive into Uniswap v4 Whitepaper](./uniswap/dive-into-uniswap-v4-whitepaper/README.md) * [Deep Dive into Uniswap v4 Smart Contracts](./uniswap/dive-into-uniswap-v4-contracts/README.md) ### Uniswap V3 * [Deep Dive into Uniswap v3 Whitepaper](./uniswap/dive-into-uniswap-v3-whitepaper/README.md) * [Deep Dive into Uniswap v3 Smart Contracts (Part 1)](./uniswap/dive-into-uniswap-v3-contracts/README.md) * [Deep Dive Into Uniswap v3 Smart Contracts (Part 2)](./uniswap/dive-into-uniswap-v3-contracts-2/README.md) ### Uniswap V2 * [Deep Dive into Uniswap v2 Whitepaper](./uniswap/dive-into-uniswap-v2-whitepaper/README.md) * [Deep Dive into Uniswap v2 Smart Contracts](./uniswap/dive-into-uniswap-v2-contracts/README.md) * [Flashloan fee of Uniswap v2](https://hackmd.io/@adshao/SJptXNaI9)Explore Gnosis Prediction Markets documentation
masterThe Gnosis section of this repository contains research and publications related to Gnosis-based prediction markets. The primary focus is on the Conditional Tokens framework, which is used by platforms like Polymarket to enable prediction market functionality.