How Swapping Works on Keeta
Alpaca DEX is the native decentralized exchange layer for the Keeta network. It allows anyone to instantly exchange one token for another within liquidity pools on the Keeta network. Unlike centralized exchanges, there are no order books, no registration, and no intermediaries.
Alpaca DEX is permissionless. You do not need to create an account or pass KYC. You simply connect your wallet and trade directly against the trade directly against liquidity pools managed by Alpaca’s Liquidity Engine.
The Swapping Process
Trading on Alpaca is designed to be one-click simple. Behind the scenes, the protocol handles the complexity:
- Select Pair: You choose the tokens you wish to trade (e.g.,
KTA/PACA). - Input Amount: You specify how much you want to sell.
- Auto-Calculation: The automated engine calculates exactly how many tokens you will receive based on the current pool reserves.
- Instant Settlement: Once confirmed, the transaction is executed, your wallet balance updates immediately, and the trade is permanently recorded on the Keeta ledger.
How Prices Are Determined
Alpaca DEX uses an Automated Market Maker (AMM) model. Instead of relying on buyers and sellers to agree on a price, the price is set mathematically by the ratio of tokens in the pool.
We utilize the standard Constant Product Formula:
- : The total amount of Token A in the pool (e.g., KTA)
- : The total amount of Token B in the pool (e.g., PACA)
- : A fixed constant value
How it works in practice
When you buy Token A, you add Token B to the pool. This increases and decreases . To keep constant, the price of Token A effectively rises as it becomes scarcer in the pool.
🧮 Example Calculation
Imagine a pool with 100 KTA and 200 PACA.
If you want to buy KTA by depositing PACA:
- The pool now has more PACA and less KTA.
- Because KTA is now scarcer in the pool, the next person must pay a slightly higher price for it.
- This automatic adjustment ensures there is always liquidity available, no matter the trade size.
Price Impact is the difference between the market price and the actual price you pay due to your trade size.
- Small Trades: Minimal impact (you get a price close to market rate).
- Large Trades: Higher impact (you shift the pool ratio significantly).
Alpaca DEX always displays your Expected Output and Price Impact before you confirm a transaction.
Hybrid Execution Architecture
To deliver the fastest possible experience on the Keeta network today, Alpaca DEX currently utilizes a Hybrid Execution Model.
1. The Engine (Off-Chain)
To ensure instant responsiveness and complex matching, the trade calculation engine runs off-chain. It:
- Matches swap requests.
- Calculates precise output amounts using the AMM formula.
- Updates the virtual state of liquidity pools.
2. The Settlement (On-Chain)
Crucially, data integrity remains decentralized. Every resulting action is verified and published to Keeta’s distributed ledger:
- ✅ User balances are settled on-chain.
- ✅ Liquidity Pool updates are recorded on-chain.
- ✅ Trade history is publicly verifiable.
This approach blends the speed of Web2 performance with the transparency of Web3 data.
Roadmap to Full Decentralization
Alpaca is built to evolve. Our architecture is designed to transition seamlessly alongside the maturation of the Keeta network.
The Vision: Native Smart Contracts
As Keeta introduces its native smart contract layer, Alpaca will migrate trade and liquidity logic to fully on-chain execution. Today, the Liquidity Engine is operated by Alpaca with transparent, deterministic rules and public settlement on Keeta verifyable on each pool's address via explorer.keeta.com .
| Current Phase | Future Phase |
|---|---|
| Hybrid Engine | Smart Contracts |
| Pricing Logic runs on high-performance servers | Logic runs autonomously on-chain |
| Data settled on public ledger | Execution & Settlement on public ledger |
| High Speed / High Integrity | Maximum Censorship Resistance |
This roadmap ensures Alpaca DEX remains the most efficient venue for liquidity today while guaranteeing a future of complete autonomy and immutability.