StopSui

Non-custodial stop-loss & take-profit orders for Sui DeFi. Set triggers, auto-swap to USDC

StopSui

Created At

HackMoney 2026

Project Description

StopSui brings institutional-grade risk management to Sui DeFi. Users deposit SUI into a non-custodial vault and set price triggers—when SUI drops to their stop-loss or rises to their take-profit, an automated keeper executes a swap to USDC via the Cetus DEX aggregator.

The Problem: On centralized exchanges, stop-loss orders are standard. On Sui DeFi? Nothing. A 20% overnight crash means waking up to a destroyed portfolio with no protection. Fast finality (~400ms) makes this worse—by the time you see the price move, it's already happened.

The Solution: StopSui monitors Pyth oracle prices 24/7 and executes when conditions are met. Your funds stay in an on-chain vault with capability-based access control—only you can cancel, only the keeper can execute (and only when the trigger is actually hit). When triggered, Cetus aggregator routes across all major Sui DEXes for optimal execution, converting your SUI to USDC in a single atomic transaction.

Key Features:

  • Non-custodial vault architecture (verify on-chain, not "trust us")
  • Pyth Network oracle integration for reliable price feeds
  • Cetus aggregator for multi-DEX routing (up to 13 hops for best rates)
  • ~3 second execution time from trigger to USDC in wallet
  • Scaling orders for DCA-style multi-level exits
  • Live on Sui Mainnet with real money

How it's Made

How It's Made

Smart Contracts (Move): Built three composable modules following Sui's capability pattern:

  • vault.move: Escrow using Table<ID, Deposit> for O(1) lookups. Deposits are locked per order ID. Only owner can cancel (sender validation), only ExecutorCap holder can withdraw for execution.
  • order_registry.move: State machine (Pending→Executed/Cancelled) with shared order objects so keepers can access them. Emits OrderCreated, OrderExecuted, OrderCancelled events for indexing.
  • executor.move: Validates trigger conditions on-chain (price ≤ stopLoss OR price ≥ takeProfit) before authorizing withdrawal. Price sanity checks prevent manipulation ($0.001-$1000 range).
  • entry.move: Atomic execution via PTB—calls execute_order_for_swap to get SUI coin, pipes it to Cetus routerSwap, then complete_swap_execution transfers USDC to user. All in one transaction = no MEV extraction between steps.

Keeper Bot (TypeScript):

  • Polls Pyth Hermes API every 5 seconds for SUI/USD price (no on-chain oracle updates needed—saves gas)
  • Queries OrderCreated events via suix_queryEvents to find pending orders
  • Fetches order objects via multiGetObjects for current state
  • For triggered orders: Uses @cetusprotocol/aggregator-sdk to find optimal swap route, builds PTB combining contract calls + Cetus swap, signs with Ed25519Keypair

Hacky/Notable:

  1. Cetus over DeepBook: Originally built for DeepBook v3, but SDK version mismatches and DEEP token fee requirements made it impractical. Pivoted to Cetus aggregator which handles routing across ALL Sui DEXes (including DeepBook) and manages fees automatically—actually better UX.
  2. PTB Composition: The swap execution chains execute_order_for_swap → aggregator.routerSwap → complete_swap_execution in a single PTB. The Move function returns the SUI coin which gets piped directly into Cetus, then the output USDC coin goes to the completion function. Zero intermediate custody.
  3. Event-based order discovery: Instead of maintaining an on-chain order list (expensive), we query OrderCreated events and filter by status. Scales to thousands of orders without gas overhead.

Stack: Move (Sui), TypeScript, Next.js 16, @mysten/sui SDK, @mysten/dapp-kit, @cetusprotocol/aggregator-sdk, Pyth Hermes API, Tailwind CSS

background image mobile

Join the mailing list

Get the latest news and updates