Skip to content

Alexka-Dev/Liquidity_Pool-App

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Universal Liquidity Pool

Liquidity Pool App is a professional solution for decentralized asset swapping and liquidity management. Built upon the Uniswap V2 standard, this protocol acts as an optimized gateway that adds layers of security, governance, and a configurable monetization model.

🚀 Key Features

  • Universal Swaps: Exchange any pair of ERC20 tokens with support for custom routing .
  • Universal Liquidity Management: Add and remove liquidity from any Uniswap V2/SushiSwap compatible pool without being restricted to fixed token pairs.
  • Fee Model (Monetization):
    • Swap Fee: A percentage-based fee applied to the amountIn of every exchange.
    • Liquidity Fee: Fees collected in the form of LP Tokens (Protocol Owned Liquidity).
    • Security: Global maximum fee cap (300 BPS / 3%) to ensure user protection and trust.
  • Advanced Governance:
    • Access Control: Critical administrative functions protected by OpenZeppelin's Ownable.
    • Pausable: Emergency "circuit breaker" to halt operations if anomalies are detected.
    • Rescue Function: Ability to recover any tokens accidentally sent directly to the contract.
    • Withdraw System: Dedicated function for the feeRecipient to claim accumulated earnings.

🛠 Technical Architecture

The contract utilizes immutable variables for the Router and Factory addresses, reducing gas consumption and eliminating re-configuration attack vectors.

Component Function
V2Router02 Executes core swap and liquidity provision logic.
UniswapFactory Validates pairs and fetches LP Token addresses.
SafeERC20 Ensures secure transfers for non-standard or "weird" ERC20 tokens.
Pausable Provides flow control for risk mitigation.

🔧 Installation & Development

This project uses Foundry as the development environment.

Prerequisites

curl -L [https://foundry.paradigm.xyz](https://foundry.paradigm.xyz) | bash
foundryup

Clone the repository:

git clone https://github.com/<your-username>/<your-repo>.git
cd <your-repo>

Install dependencies:

forge install

🌐 Environment Setup

Create a .env file in the project root:

ARBITRUM_RPC="https://arb1.arbitrum.io/rpc"

Ensure your foundry.toml includes: [profile.default] src = "src" out = "out" libs = ["lib"] via_ir = true optimizer = true optimizer_runs = 200 dotenv = ".env"

🧪 Running Tests

Run all tests:

forge test --match-test [name-of-the-test]

Run coverage:

forge coverage --ir-minimum

Example output: File | % Lines | % Statements | % Branches | % Funcs


src/SwapApp.sol | 95.77% | 96.10% | 27.27% | 100.00%

 This level of coverage is excellent for a production DeFi protocol.

🔧 Usage

  1. Swapping Tokens app.swapTokens( amountIn, amountOutMin, path, // e.g., [USDT, WETH, DAI] deadline );

  2. Adding Liquidity app.addLiquidityUniversal( tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin, deadline );

  3. Removing Liquidity app.removeLiquidityUniversal( tokenA, tokenB, liquidityAmount, amountAMin, amountBMin, recipient, deadline );

🛡️ Security Considerations

  • All token transfers use SafeERC20
  • Contract can be paused in emergencies
  • Owner can update fees but cannot exceed MAX_FEE_BPS
  • POL is retained inside the contract
  • No upgradeability (simple, auditable architecture)

🧠 Design Philosophy

SwapApp Universal is built with:

  • Simplicity — minimal assumptions, no token hardcoding
  • Universality — works with any ERC‑20 pair
  • Security — strict validation and safe transfers
  • Auditability — clean architecture, high test coverage
  • Extensibility — easy to integrate into larger protocols

📜 License

MIT License. Feel free to use, modify, and build upon this project.

🤝 Contributing

Pull requests and issues are welcome. If you want to extend SwapApp with:

  • Multi-router routing
  • Permit (EIP‑2612) support
  • Gas-optimized batching
  • Oracle-based slippage protection Feel free to open a discussion.

📬 Contact

For questions, improvements, or audits: <alexk.dev89@gmail.com or https://github.com/Alexka-Dev>


About

Is a professional solution for decentralized asset swapping and liquidity management.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors