Skip to content

Conversation

@Neros0
Copy link
Member

@Neros0 Neros0 commented Oct 1, 2025

Description

This PR adds full liquidity withdrawal support to the TestAMMContract by introducing the removeLiquidity external function. This complements the previously implemented addLiquidity function and enables users to safely exit their positions while preserving pool accounting.


✅ Key Features

Feature Description
Proportional Withdrawal Calculates token amounts based on user’s share of total liquidity
Slippage Protection Enforces _amount0Min / _amount1Min thresholds to prevent MEV/front-running issues
Reserve & User Accounting Updates both pool reserves and userLiquidity tracking
Token Transfers Sends withdrawn tokens back to _user
Event Emission Emits existing LiquidityRemoved event for indexing

🧠 Function Summary

function removeLiquidity(
    bytes32 _marketId,
    address _user,
    uint128 _liquidity,
    uint256 _amount0Min,
    uint256 _amount1Min
)
    external
    returns (uint256 amount0Decreased, uint256 amount1Decreased, uint256 amount0Collected, uint256 amount1Collected)

@Neros0 Neros0 self-assigned this Oct 1, 2025
@Neros0 Neros0 added documentation Improvements or additions to documentation enhancement New feature or request labels Oct 1, 2025
@Neros0 Neros0 merged commit 2606f64 into main Oct 1, 2025
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants