Swap Program (Constant-Product)
The Swap Program is a lightweight constant-product AMM (βx Β· y = kβ) for secondary trading once pools migrate from launchpad (and for any standard pair you list). It holds two SPL token vaultsβbase and quoteβand prices trades along the invariant, applying standard AMM slippage and fees.
TDEXSo3FBwoMeP6gv7abqPQpEQfwd5ArkzmuGqssjtYCore functions
add_liquidityβ Deposit proportional amounts of base/quote to mint LP shares representing your share of the pool.remove_liquidityβ Burn LP shares to withdraw proportional base/quote (less any accumulated fees already reflected in pool balances).buyβ Swap quote β base at the current invariant price (x*y=k) with slippage protection.sellβ Swap base β quote at the current invariant price (x*y=k) with slippage protection.
Fees
Trades charge a swap fee taken from the input (or output, depending on direction) and left in the pool, benefiting LPs via higher reserves.
Exact fee constants and splits are documented per-network in the Utils / Constants page.
Indexing
On each
buy/sell, the program emits an internallog_trade_internalinstruction with structured fields (e.g., trader, pool, base mint, quote mint, amounts) so your indexer can reconstruct swaps reliably.
Last updated