Welcome to the Automated Market Maker (AMM) implementation on Solana, built using the Anchor framework. This project provides essential functionalities for decentralized trading, enabling users to initialize a market, deposit tokens, swap between different tokens, and withdraw their assets. Below is a detailed overview of the key features of this AMM.
- Description: This function initializes the AMM by setting up the necessary accounts and liquidity pools. It establishes the foundation for users to deposit tokens and start trading.
- Functionality:
- Sets up liquidity pools for the supported token pairs.
- Initializes the necessary accounts and program state.
- Prepares the AMM for deposits, swaps, and withdrawals.
- Description: This function allows users to deposit tokens into the liquidity pool. In return, users receive LP (Liquidity Provider) tokens, representing their share in the pool.
- Functionality:
- Deposits the user's tokens into the specified liquidity pool.
- Mints and transfers LP tokens to the user as proof of their contribution.
- Updates the pool's state to reflect the new liquidity.
- Description: This function facilitates the swapping of one token for another within the AMM. It uses the constant product formula to determine the swap rate, ensuring a decentralized and automated trading experience.
- Functionality:
- Allows users to swap between supported tokens in the liquidity pool.
- Calculates the swap rate based on the current pool reserves and the constant product formula.
- Updates the pool's reserves and user's balances accordingly.
- Description: This function enables users to withdraw their tokens from the liquidity pool. Users can redeem their LP tokens to receive their share of the pool's reserves, plus any accrued fees.
- Functionality:
- Burns the user's LP tokens in exchange for their share of the liquidity pool.
- Transfers the corresponding tokens from the pool to the user.
- Updates the pool's state to reflect the withdrawal.