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.
- 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
amountInof 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.
- Swap Fee: A percentage-based fee applied to the
- 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
feeRecipientto claim accumulated earnings.
- Access Control: Critical administrative functions protected by OpenZeppelin's
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. |
This project uses Foundry as the development environment.
curl -L [https://foundry.paradigm.xyz](https://foundry.paradigm.xyz) | bash
foundryupgit clone https://github.com/<your-username>/<your-repo>.git
cd <your-repo>forge installCreate 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"
Run all tests:
forge test --match-test [name-of-the-test]Run coverage:
forge coverage --ir-minimumExample 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.
-
Swapping Tokens app.swapTokens( amountIn, amountOutMin, path, // e.g., [USDT, WETH, DAI] deadline );
-
Adding Liquidity app.addLiquidityUniversal( tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin, deadline );
-
Removing Liquidity app.removeLiquidityUniversal( tokenA, tokenB, liquidityAmount, amountAMin, amountBMin, recipient, deadline );
- 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)
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
MIT License. Feel free to use, modify, and build upon this project.
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.
For questions, improvements, or audits: <alexk.dev89@gmail.com or https://github.com/Alexka-Dev>