How a DEX on TON works: STON.fi, DeDust and liquidity pools

A hand holding a gold-coloured coin over a laptop keyboard
A hand holding a gold-coloured coin over a laptop keyboard. Photo: Shixart1985, CC BY 2.0, via Wikimedia Commons.

The old KAKAXA page sent visitors to a decentralised exchange. Here is what a DEX on TON actually does: liquidity pools, automated prices, slippage and fees, in plain words.

The original KAKAXA landing page had a button that sent visitors to STON.fi, one of the decentralised exchanges, or DEXs, on TON. We are not a shop and do not have buy buttons, but the machine behind that button is fascinating, so here is how it works.

An exchange without an order book

A traditional exchange matches buyers and sellers through an order book: one person offers to sell at a price, another agrees to buy. Most DEXs work differently. They use an automated market maker, a smart contract that holds two tokens in a pool and sets the price by a formula.

The pool and the formula

Imagine a pool holding Toncoin on one side and a meme token on the other. The most common formula keeps the product of the two amounts constant. When you buy the meme token, you add Toncoin to the pool and take meme tokens out. The meme token becomes scarcer in the pool, so its price rises. Sell, and the opposite happens. No human sets the price; the formula does.

Who fills the pool?

Anyone can deposit both tokens into a pool and become a liquidity provider. In return they earn a share of the trading fees. The risk is that if prices move a lot, providers can end up with less value than if they had simply held the tokens, an effect known as impermanent loss.

Slippage and thin pools

  • Deep pools hold a lot of liquidity, so a trade barely moves the price.
  • Shallow pools hold little, so even a modest trade can move the price sharply. This difference between the expected and actual price is called slippage.
  • Locked liquidity means the pool cannot be withdrawn by its creators, which matters a great deal for meme coins, as we explain in rug pulls and honeypots.

STON.fi and DeDust

STON.fi and DeDust are among the best-known DEXs on TON. Both use liquidity pools and can be reached from wallets inside Telegram. Most small TON tokens, KAKAXA's namesake among them, started life in pools like these before any centralised exchange took notice.

A market that moves like a betting pool

An automated market maker behaves a bit like the pari-mutuel pools used in horse racing. At the track, the more money that goes on one horse, the shorter its odds become, because the pool has to pay everyone from the same pot. In a DEX pool, the more people buy a token, the higher its price climbs, because the pool has fewer tokens left. In both cases the price is simply the crowd's money, rearranged by a formula.