A decentralized AMM protocol for swapping ERC-20 tokens with liquidity management . The app, built in Solidity and React, follows Uniswap-like principles, providing users with easy token swaps and liquidity addition/removal via a user-friendly interface.
-
Liquidity Provision:
Users can provide liquidity to the pool by depositing two tokens in a specified ratio, earning shares that represent their stake in the pool . -
Liquidity Removal:
Users can withdraw their liquidity from the pool, receiving their proportional share of both tokens. -
Token Swapping:
Users can swap between the two tokens in the pool with a 0.3% fee applied to each swap. -
Fee Mechanism:
A 0.3% fee is charged on swaps, which is retained in the pool to benefit liquidity providers. -
Fair Share Calculation:
Liquidity shares are calculated proportionally based on the constant product formula, ensuring fairness.
-
Token Compatibility:
The pool supports any two ERC-20 tokens. -
Mathematical Formula:
The contract uses the constant product formula ( x \cdot y = k ), where ( x ) and ( y ) are the reserves of token1 and token2, respectively, and ( k ) is the constant product. -
Fee Handling:
Fees are subtracted before calculating the output amount during a swap. -
Events:
LiquidityAdded: Emitted when a user adds liquidity to the pool.LiquidityRemoved: Emitted when a user removes liquidity from the pool.Swapped: Emitted when a user swaps one token for another.
- Frontend: React.js
- Blockchain Framework: Hardhat
- Ethereum Interaction: Ethers.js
- Backend Infrastructure: Infura
- Smart Contract Standards: Solidity with OpenZeppelin libraries
Users can deposit equal-value amounts of token1 and token2 into the pool, receiving shares proportional to their contribution.
Users can redeem their shares to withdraw their proportional amounts of token1 and token2.
Users can swap one token for another, subject to a 0.3% fee.
-
Clone this repository:
git clone https://github.com/yourusername/liquidity-pool cd liquidity-pool -
Install dependencies:
npm install
-
Compile the contract:
npx hardhat compile
-
Deploy the contract:
npx hardhat run scripts/deploy.js
- Introduce advanced fee mechanisms to incentivize long-term liquidity provision.
This project is licensed under the MIT License. See the LICENSE file for more details.