Skip to content

Feature Request: Implement Swap Functionality Using Dynamic Liquidity DepositsΒ #2

@Vib-UX

Description

@Vib-UX

Overview

Following the implementation of dynamic liquidity deposits in the pool, this issue tracks the creation of a swap function that uses the Constant Product Formula (x * y = k) to facilitate token swaps while preserving pool invariants. The swap should also support slippage protection to guard users against unfavorable price movements.


πŸ” Swap Logic

  • Implement core swap logic using the formula:
    x * y = k

where x and y are reserves of two assets in the pool, and k is constant.

  • Accept input amount and calculate corresponding output using:

outputAmount = y - (k / (x + inputAmount))

  • Ensure slippage is accounted

✨ Desired Features

  • Swap respects the dynamic liquidity and adjusts reserves accordingly
  • Includes input/output validation and failure conditions
  • Supports a frontend-calculable quote API using same formula

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions