An on-chain constant product invariant ($x \cdot y = k$) decentralized exchange routing mechanism. The program enables permissionless pool creation, liquidity provisioning (LPing), and token asset swaps directly against liquidity state accounts. The architecture enforces mathematical balance checks natively within the Solana Sealevel runtime
initialize_pool: Configures the global pool state, instantiates the token vaults, and initializes a dedicated liquidity pool (LP) token mint. It establishes unique mint authorities via Program Derived Addresses (PDAs) to securely control LP token configurations.deposit_liquidity: Implements fractional mint operations. It calculates the exact amount of LP tokens to issue based on current pool reserve ratios, accepts the dual-asset deposit tokens into the vault, and executes a Cross-Program Invocation (CPI) to mint LP supply back to the liquidity provider.withdraw_liquidity: Executes the inverse LP token loop. It burns incoming LP tokens from the user, computes the proportional volume of underlying token assets to release, and routes the vault funds back to the user while maintaining the invariant.swap: Executes the core mathematical execution loop. It validates input token balances, applies predefined protocol fee margins, computes the exact output amount based on the constant product formula, and dispatches the tokens from the program-controlled vaults natively using safe math rules to block overflow vectorsThe program utilizes strict Anchor constraints and Program Derived Addresses (PDAs) to isolate state space and block unauthorized system interactions:
Config: Global state account tracking the administrative configurations, pool authorities, fee structures, and seed parameters.vault_x, vault_y): Program-derived token accounts that safely isolate and secure the locked trading pairs under the direct authority of the AMM program.[b"amm", pool_id] or [b"vault", pool_id] to enforce strict access controls and validate signatures during Cross-Program Invocations (CPIs) to the SPL Token Program