Trading Mechanism

1. Swapping Tokens #

Alpaca DEX lets anyone instantly exchange one token for another within liquidity pools on Keeta.
When you submit a swap:

  1. You choose a trading pair (e.g. KTA / PACA).
  2. You enter the amount you want to swap.
  3. Alpaca’s automated engine calculates how much of the target token you’ll receive.
  4. The transaction is executed, balances are updated, and the trade is recorded on-chain.

No registration or KYC is required — trading happens directly against the shared liquidity pool rather than through a centralized intermediary.

2. How Prices Are Determined #

We use an Automated Market Maker (AMM) model based on the constant-product formula: x×y=kx \times y = kx×y=k

Where:

  • x = the reserve of the base token
  • y = the reserve of the paired token
  • k = a constant that remains unchanged after every trade

When someone swaps tokens, the reserves in the pool shift, but k stays constant.
This mathematical relationship automatically determines the new price after each trade.

🧮 Example #

If a pool starts with 100 KTA and 200 PACA tokens: 100×200=20,000100 \times 200 = 20,000100×200=20,000

If you buy KTA by adding PACA, the y side increases and x decreases.
To keep k constant, the price of KTA rises — this is price impact.

💡 Price Impact #

Price impact measures how much the trade size moves the pool price.
Smaller pools or larger trades cause higher impact.
Alpaca displays this before confirming a swap so you always know your expected rate.

3. Execution Process #

Currently, trades are processed through our automated engine, which:

  • Matches swap requests
  • Calculates output amounts using the AMM formula
  • Updates pool reserves
  • Records every trade and pool update transparently on-chain

Although the execution logic itself runs off-chain for performance, all resulting data (balances, pool states, LP token mints/burns, trade events) is published to Keeta’s distributed ledger, ensuring public verifiability and data integrity.
The eexeuction log will shift to on-chain smart contracts as soon as Keeta’s technology matures — blending speed today with decentralization tomorrow.

4. The Road Toward Full On-Chain Execution #

Alpaca is designed to evolve alongside Keeta.

In the near future, as Keeta’s smart contract layer becomes available, trade and liquidity logic will migrate to fully decentralized on-chain execution — meaning:

  • Swaps, liquidity deposits, and LP token minting will be governed directly by smart contracts.
  • Execution and settlement will no longer rely on Alpaca’s off-chain engine.
  • Transparency, composability, and user control will reach full decentralization.

This transition ensures that Alpaca maintains speed and efficiency today, while being ready for full autonomy tomorrow.

Updated on November 16, 2025