LIVE PORTAL Telegram v11.8 API Synchronized Free Animated Stickers
admin_panel_settings ADMIN CONTROLS Web3 Article #416 • Mini-Apps
edit Edit Article edit_square Write Post list_alt Admin Board
Telegram DEX Trading Terminals: STON.fi & DeDust Routing, Limit Orders, and Sniping Bot APIs
candlestick_chart DeFi & High-Speed Trading currency_exchange STON.fi & DeDust APIs schedule 14 Min Read shield MEV Protection Engine

Telegram DEX Trading Terminals: STON.fi & DeDust Routing, Limit Orders, and Sniping Bot APIs

Build enterprise-grade decentralized exchange (DEX) trading terminals directly inside Telegram Mini Apps. Learn how to aggregate liquidity across STON.fi and DeDust AMM pools, protect traders against malicious front-running and MEV sandwich attacks, construct raw Bag of Cells (BOC) payloads, and execute sub-second limit order swaps over TON Connect 2.0.

Dual Routing
STON.fi & DeDust
< 150ms
Mempool Stream Latency
Sub-Second
BOC Payload Sign Time
0% Spread
Split Routing Efficiency

hub Why Embedded Telegram DEXs Outperform Web Terminals

Traditional decentralized exchange interfaces require desktop web browsers, third-party wallet browser extensions, and repetitive approval prompts that cause traders to miss fast-moving price breakouts. By embedding DEX terminals inside Telegram Mini Apps, traders receive real-time price alerts in chat, click an inline link, and execute non-custodial swaps with pre-authorized TON Connect session keys in less than two seconds.

account_tree 1. Telegram DEX Terminal Pipeline

Executing reliable, low-slippage swaps inside Telegram requires coordinating four high-frequency infrastructure layers.

analytics

1. Mempool Liquidity Aggregator

Query live pool reserves across STON.fi v2 and DeDust simultaneously. Split large volume trades across multiple liquidity pools to minimize market price impact.

security

2. Slippage & MEV Guard

Set tight min_ask_amount parameters to ensure that if a sandwich bot attempts to front-run the trade, the contract automatically aborts and returns funds safely.

key

3. TON Connect 2.0 BOC Signer

Compile the swap message into a binary Bag of Cells (BOC) and dispatch it via TON Connect. The user's mobile wallet signs the transaction with biometrics in one tap.

task_alt

4. Real-Time Settlement Telemetry

Track block confirmations over TonAPI WebSocket streams, push dynamic PnL updates to the user's chat, and update portfolio balances instantly.

currency_exchange DEX ROUTING ENGINE

TON DEX Swap Slippage & Routing Simulator

Live AMM Execution Model
Swap Trade Size (TON) 250 TON
DEX Pool Liquidity Depth $250,000
Slippage Tolerance (%) 1.0%
Routing Strategy Split 60% STON / 40% DeDust
Expected Price Impact: 0.65%
Guaranteed Minimum Output: 1,608.75 Jettons
Split Routing Arbitrage Savings: +$18.40 USD
Estimated Gas Fee: ~0.08 TON ($0.52)
MEV Protection Status: Safe (Low Sandwich Risk)

code 2. Constructing the STON.fi Swap Cell in TypeScript

Mini-App trading bots construct binary smart contract swap payloads using @ton/core and pass them directly to the TON Connect provider.

// Construct STON.fi Swap Forward Payload in TypeScript
import { beginCell, toNano, Address } from "@ton/core";

export function buildDexSwapMessage(
  jettonToReceive: Address,
  minAskAmount: bigint,
  recipientAddress: Address
) {
  const forwardPayload = beginCell()
    .storeUint(0x25938561, 32) // STON.fi swap op code
    .storeAddress(jettonToReceive)
    .storeCoins(minAskAmount)
    .storeAddress(recipientAddress)
    .storeUint(0, 1) // has_ref
    .endCell();

  return {
    validUntil: Math.floor(Date.now() / 1000) + 300, // 5 min TTL
    messages: [
      {
        address: "EQB3ncyBUTjZUA5EnFKR5_ioIppmErdr2o79wpNTsvOcVCwU", // Router
        amount: toNano("0.3").toString(), // Gas attachment
        payload: forwardPayload.toBoc().toString("base64")
      }
    ]
  };
}

task_alt 3. Production Trading Bot Checklist

  • Short Transaction TTL: Never set transaction validity longer than 3 minutes to avoid stale executions after sharp market reversals.
  • Excess Gas Refund: Always specify the user's personal wallet address in the response address field so unspent gas returns automatically.
  • Private RPC Endpoints: Route high-speed sniping transactions through private TON Lite-Servers to bypass public node mempool congestion.
  • Zero-Spread Split Routing: Automatically partition trades over $1,000 USD across both STON.fi and DeDust to secure optimal blended execution prices.
EXECUTIVE BLUEPRINT

One-Page Technical Summary Infographic

Click the poster below to inspect the complete 4-tier trading engine: mempool liquidity aggregator, MEV sandwich guard, TON Connect 2.0 batch signer, and real-time on-chain execution telemetry.

Telegram DEX Terminal Architecture Blueprint
zoom_in Click to Enlarge

auto_stories Related Web3 Masterclasses

Mini-Apps

Telegram Enterprise Mini-Apps: Supergroup CRM, Multi-Signature DAO Governance, and Collaborative Workspaces

arrow_forward Read Guide
Mini-Apps

Telegram Mini-App E-Commerce & Subscription Portals: Physical Goods, Delivery Webhooks, and Stars Invoicing

arrow_forward Read Guide
Mini-Apps

Telegram Web3 Gaming & Tap-to-Earn: Energy Mechanics, Anti-Bot Rate Limiting, and On-Chain Airdrop Claims

arrow_forward Read Guide
arrow_back Back to Web3 & Mini-Apps Directory
Enlarged Preview
Click anywhere outside or press ESC to close viewer