Conditional Micro-Swap Execution Engine for TON DeFi
Kaskade is a Rust-based, non-custodial execution engine for the TON blockchain that performs condition-based micro-swaps.
Instead of executing swaps on a fixed schedule, Kaskade executes only when market conditions are favorable — based on real-time liquidity, spread, trend, and slippage signals.
At its core, Kaskade introduces a pulse-driven execution primitive for TON DeFi.
Most TON DeFi users execute swaps during sub-optimal conditions:
- Spread widens → worse price
- Slippage spikes → lower output
- Local downtrend → buying into weakness
- Thin liquidity → high price impact
Existing tools (wallets, bots, DCA strategies) are time-based, not market-condition-based.
Kaskade executes trades when the market itself signals “now is a good moment.”
Kaskade continuously ingests market data and computes pulses.
A pulse is a short-lived market signal indicating favorable execution conditions.
“A pulse means the market is currently safe and efficient to trade.”
Each user defines constraints (spread, trend, slippage), and Kaskade executes micro-swaps only when all constraints are satisfied.
| Pulse | Purpose |
|---|---|
| Spread | Avoids wide bid–ask spreads |
| Slippage | Ensures acceptable execution output |
| Trend | Avoids buying into local downturns |
| Depth | Ensures sufficient liquidity |
| Time-Decay | Safety fallback to guarantee progress |
| Volatility | Avoids chaotic market conditions |
| Imbalance | Detects directional liquidity pressure |
Kaskade is composed of four coordinated subsystems:
Market data ingestion and signal computation.
- Polls STON.fi pool state
- Consumes Omniston RFQ data
- Maintains rolling windows
- Computes spread, trend, and depth pulses
- Normalizes metrics for scheduling
Decides when to execute.
- Applies pulse-based eligibility filters
- Fair selection (round-robin / DRR)
- Cooldowns and per-tick caps
- Emits execution intents
Turns decisions into real swaps.
- Re-validates market conditions
- Builds swaps using Omniston gRPC
- Produces TonConnect payloads
- Tracks execution outcomes
A non-custodial on-chain contract.
- Holds user-approved tokens
- Executes swaps directly against STON.fi
- Enforces user constraints on-chain
- Allows withdrawal at any time
All swaps are executed by the contract — never by backend-signed transactions.
The Execution Manager Contract (EMC) enables fully automated execution without custody.
- User deploys EMC via TonConnect
- User deposits Jettons + TON for gas
- Execution parameters are locked on-chain
- Backend detects pulses
- Executor sends authorized messages
- EMC executes swaps against STON.fi
- Output tokens are returned to the user
- User can withdraw remaining funds anytime
- RFQ WebSocket
- Route-aware pricing
- gRPC
buildTransfer - Multi-hop routing
- Pool liquidity polling
- Swap simulation
- DEX-level execution via EMC
- Rust (stable)
- Cargo
- SQLite
- SQLx CLI
Install SQLx CLI:
cargo install sqlx-cli --no-default-features --features sqlitegit clone https://github.com/your-org/kaskade.git
cd kaskade
cargo buildFrom the repo root:
export DATABASE_URL="sqlite://$(pwd)/backend/dev/kaskade_dev.db"Verify:
echo $DATABASE_URLmkdir -p backend/dev
touch backend/dev/kaskade_dev.dbcargo sqlx migrate runVerify tables:
sqlite3 backend/dev/kaskade_dev.db ".tables"If you have seed migrations, they will run automatically. To inspect:
sqlite3 backend/dev/kaskade_dev.db "SELECT * FROM sessions LIMIT 5;"cargo run -p backendYou should see logs indicating:
- Market pollers started
- Scheduler ticks
- Market metrics updates
cargo testFor backend only:
cargo test -p backend