Skip to content

feat(agents): batch-2 Sui "Smart DeFi Summer" — 6 profile-class activities#61

Open
hebbianloop wants to merge 16 commits into
mainfrom
feat/sui-batch2-defi-summer
Open

feat(agents): batch-2 Sui "Smart DeFi Summer" — 6 profile-class activities#61
hebbianloop wants to merge 16 commits into
mainfrom
feat/sui-batch2-defi-summer

Conversation

@hebbianloop

Copy link
Copy Markdown
Member

Lands the SoT activity.json for the six Mysten co-marketed Sui DeFi agents (batch 2). Tracking: #60 · master internal-docs#1346.

Agents (all profile-class — behavior runs on the managed AEX runtime, no scaffold templates)

Slug Protocol Agent
sui-cross-chain-pilot Ika → SuiLend/Haedal bridge-free inbound liquidity (flagship)
sui-liquidation-guardian SuiLend, Navi health-factor protection
sui-yield-autopilot SuiLend/Navi/Scallop/Haedal best-rate routing + auto-compound
sui-stake-and-loop Haedal (+SuiLend) liquid staking + optional loop
sui-deepbook-market-maker DeepBook v3 CLOB maker (post-only, inventory caps)
sui-perp-copilot Bluefin perp stop-loss + funding harvest

Safety posture (every agent)

  • AGENT_MODE=monitor, AGENT_DRY_RUN=1, FARM_MODE=manual by default → read-only / propose-only out of the box.
  • Hard spend caps required before any execution; absent caps ⇒ propose-only.
  • Funds only ever move within the owner's own positions — never to a new/external address.
  • Value actions go propose → Telegram approval → settle.

Validation

  • All 6 validate against ActivitySchema.
  • Registry rebuilds clean (copy-registry + build:registry).
  • registry-coverage updated to expect the 6 as profile-class.
  • CAW test suite green — 63 passed.

Builder-first / next steps (not in this PR)

This is the SoT-landing step. Next, per #60: wire the per-protocol SDK action paths (DeepBook v3, SuiLend, Haedal, Ika dWallets, Bluefin) and record verifiable testnet demos (tx hashes on a Sui explorer) for the Mysten showcase.

🤖 Generated with Claude Code

…ities

Add the SoT activity.json for the six Mysten co-marketed Sui DeFi agents
(profile-class — behavior runs on the managed AEX runtime, no scaffold
templates). All safe-mode by default (AGENT_DRY_RUN=1, FARM_MODE=manual,
AGENT_MODE=monitor), hard spend caps, funds only ever to the owner's own
positions, propose→Telegram-approve before any value action:

- sui-cross-chain-pilot   — flagship; bridge-free inbound via Ika dWallets
- sui-liquidation-guardian — SuiLend/Navi health-factor protection
- sui-yield-autopilot      — best-rate routing across SuiLend/Navi/Scallop/Haedal
- sui-stake-and-loop       — Haedal liquid staking (+ optional SuiLend loop)
- sui-deepbook-market-maker — DeepBook v3 CLOB maker (post-only, inventory caps)
- sui-perp-copilot         — Bluefin perp stop-loss + funding harvest

All 6 validate against ActivitySchema; registry rebuilds clean; coverage
test updated to expect them as profile-class. CAW suite green (63 passed).

Tracking: aex#60, under master internal-docs#1346.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Shady El Damaty <shady@holonym.id>
@vercel

vercel Bot commented Jun 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
aex-agents Ready Ready Preview, Comment Jun 27, 2026 2:07am

Request Review

…ness

Runnable TypeScript demo for the sui-liquidation-guardian agent (the first
batch-2 Sui agent to demo). Builder-first from SuiLend's public SDK docs.

- src/suilend.ts  — read path: obligation → health factor (HF = unhealthy /
  weighted borrow value) + smallest-repay/topup sizing; refuses to act on an
  ambiguous read.
- src/protect.ts  — repay / deposit PTBs, USD→base-unit sizing, executed via
  src/waap.ts (waap-cli send-tx, keyless 2PC-MPC; the existing Sui-agent
  convention).
- src/guardian.ts — one cycle: monitor → warn → propose → (active+live+auto)
  execute within hard caps; emits health_check / liquidation_warning /
  protect_proposed / protect_executed events.
- src/harness.ts  — testnet/beta staging: open (collateral + borrow to LTV) /
  nudge (HF below floor) / reset, signed by a throwaway victim keypair.
- src/state.ts rolling-24h spend cap · src/notify.ts Telegram · README runbook.

Funds only move on the owner's own obligation; safe-mode by default. Market-
agnostic (LENDING_MARKET_ID/TYPE in env) so it runs against the SuiLend beta
market or a provided test market without code changes.

Typechecks against @suilend/sdk@1.1.99 + @mysten/sui@1.42.0. Three SDK
boundaries (parseObligation, reserve price, createObligation/borrow) flagged
in-code to pin on install. Relocated under demos/ so copy-registry doesn't
sweep it into the published registry.

Tracking: aex#60 (LG-1/LG-2/LG-3).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Shady El Damaty <shady@holonym.id>
…uiLend

Wire the real SuiLend parse pipeline (parseLendingMarket → parseObligation)
instead of the placeholder reserve walk. Key coin metadata by
normalizeStructTag(coinType.name) for reserve AND pool-reward coins (the
parsers require an entry for every referenced coin or they throw), with a
mintDecimals fallback.

Validated read-only against Sui mainnet (no funds, no login):
  SUI  $0.6786  decimals 9  closeLtv 0.75
  USDC $0.9997  decimals 6  closeLtv 0.80

Health factor = unhealthyBorrowValueUsd / weightedBorrowsUsd; protect.ts now
sizes actions off the parsed reserve price/decimals via getReserveInfo().
Typecheck clean. Harness create/borrow paths remain to verify on first funded
on-chain run.

Tracking: aex#60.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Shady El Damaty <shady@holonym.id>
…-discovers obligation

The Liquidation Guardian's own waap sub-wallet both stages and guards the
position, so the harness now signs staging txns through waap-cli by default
(local keypair stays as a fallback for a separate victim wallet). stage open
auto-discovers / creates the obligation + owner-cap via getObligationOwnerCaps
and persists OBLIGATION_ID/CAP to .env, so open → nudge → reset → guardian runs
as one smooth pass. Typecheck clean.

Tracking: aex#60.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Shady El Damaty <shady@holonym.id>
`npm run dryrun` projects the full staged-liquidation flow against live
mainnet SuiLend and simulates the one self-contained step on-chain
(createObligation via dryRunTransactionBlock) — signing/broadcasting nothing.
Surfaces live prices, the projected HF at each stage, the protocol's
borrow-cap buffer (closeLtv/openLtv — you can't borrow into liquidation), the
recommended Guardian thresholds, and the repay it would make.

Also: harness send() honors AGENT_DRY_RUN=1 (simulate, never broadcast);
borrow now targets a fraction of real borrow CAPACITY (not deposit value) so
it never exceeds the open-LTV limit; getHealth exposes borrowLimitUsd and
getReserveInfo exposes openLtv + borrowWeight.

Verified live: SUI $0.70 (openLtv 0.7 / closeLtv 0.75), createObligation sim
succeeds for the funded agent wallet. Typecheck clean.

Tracking: aex#60.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Shady El Damaty <shady@holonym.id>
Validated end-to-end on Sui mainnet:
- waap send-tx timeout 120s→300s (room to approve a 2FA email mid-tx)
- stage open retries owner-cap discovery after createObligation (indexing lag)
- stage reset repays the wallet's actual debt-asset balance instead of
  debt×1.01 (the buffer overshot the balance → InsufficientCoinBalance)

Live proof (mainnet): agent detected HF 1.491 < floor and repaid USDC on
SuiLend to restore HF 1.70 — tx 4Fpevq1op4CiaQT79ZSvrQE8Jcc8reh8zvp5kjCPgiMG.

Tracking: aex#60.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Shady El Damaty <shady@holonym.id>
…dian

- GUIDE.md — case study / tutorial structured to split into waap docs (keyless
  signing + policy + 2FA) and aex docs (the agent + safe-mode + Sui), with the
  verifiable mainnet tx hashes.
- recording/ — demo.gif + demo.mp4 (vhs): a faithful playback of the real
  mainnet run (real tx hashes / numbers), embeddable in docs. replay.{sh,tape}
  are the source.

Tracking: aex#60.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Shady El Damaty <shady@holonym.id>
recording/reel.mp4 (~43s) — title card → live terminal flow (lower-third bug) →
on-chain verify card → the operator's 2FA-approval splice → outro, in AEX brand.
Built drawtext-free (this ffmpeg lacks libfreetype): PIL renders the cards +
lower-thirds, ffmpeg loops/overlays/concats. build-reel.sh + gen_cards.py are
self-contained and regenerate it; SCREEN-STUDIO.md is the directing script for a
higher-end Screen Studio cut. Raw 2FA clip + fonts stay local (gitignored).

This pipeline is the basis for a reusable "record a recipe demo" skill.

Tracking: aex#60.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Shady El Damaty <shady@holonym.id>
The 2FA clip was tacked on at the end and unexplained. Honest fix: it actually
fired when we ARMED the $20/day cap (a policy change), not on the $0.93 repay
(under the risk threshold). New order: title -> "You arm the agent" 2FA
explainer card -> the approval clip -> the agent runs -> verify -> outro. The
gate is now shown where it happens and captioned accurately.

Tracking: aex#60.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Shady El Damaty <shady@holonym.id>
Replaces the explainer card with a terminal 'set the cap' beat
(waap-cli policy set --daily-spend-limit 20 -> needs 2FA) immediately before
the approval clip, so the order reads correctly: set rules -> 2FA -> agent runs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Shady El Damaty <shady@holonym.id>
…irst of many'

Adds a 'Create the agent's wallet' beat (waap-cli signup, password masked, keyless
2PC-MPC on Sui) as step 0, before setting the cap. Outro now says the Liquidation
Guardian is the first of many agents. Sui-first framing; no em dashes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Shady El Damaty <shady@holonym.id>
Clones the Liquidation Guardian pattern. Real: ETH/BTC idle-balance reads
(JSON-RPC + Blockstream), CoinGecko prices, SuiLend dest-APY read, cap/slippage
enforcement, safe-mode + dry-run gating, Sui PTB signing via waap-cli. Flagged
SDK INTEGRATION BOUNDARYs (alpha): Ika dWallet multi-chain whoami fields +
send-tx --chain interface, cross-chain move tx bytes, Sui deposit PTB, Haedal
APY. Typecheck clean. First of the batch-2 'while you sleep' builds.

Tracking: aex#60.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Shady El Damaty <shady@holonym.id>
Clones the Liquidation Guardian pattern with @mysten/deepbook-v3. Real + verified
against the SDK typings: midPrice, getLevel2TicksFromMid, accountOpenOrders,
decodeOrderId, checkManagerBalance, poolBookParams, placeLimitOrder (POST_ONLY),
cancelOrders. Two-sided quotes (mid +/- SPREAD_BPS) with inventory skew + hard
MAX_INVENTORY_USD cap, post-only (never crosses), re-quote on drift, pull on
empty/stale book. PTBs signed via waap-cli. Safe-mode + dryrun. Typecheck clean.
Flagged: coin/pool defaults, balance units, non-stable quote pricing (Pyth, pass 2).

Tracking: aex#60.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Shady El Damaty <shady@holonym.id>
Clones the Liquidation Guardian pattern. Real: SuiLend rate read + deposit
(@suilend/sdk pipeline, mainnet-validated) and Navi rate read (navi-sdk open
API). Common ProtocolRate interface; Scallop + Haedal are flagged SDK
INTEGRATION BOUNDARY adapters (return unavailable, not faked). Rebalance honors
allowlist + REBALANCE_MAX_USD + daily cap + MIN_APY_DELTA_BPS hysteresis; funds
only between owner positions on allowlisted protocols. Safe-mode + dryrun.
Typecheck clean. Pass 2: wire Navi/Scallop/Haedal PTBs, position tracking, compounding.

Tracking: aex#60.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Shady El Damaty <shady@holonym.id>
Clones the guardian pattern with @bluefin-exchange/pro-sdk. Real + verified
types: ExchangeApi.getMarketTicker (public), AccountDataApi.getAccountDetails,
Position/Ticker e9 fields, OrderType/OrderSide. Stop-loss / take-profit /
funding-harvest logic with MAX_POSITION_USD + daily cap; stop-loss may fire
promptly when live (mirrors guardian). Secrets via env, never logged. Safe-mode
+ dryrun. Typecheck clean. Flagged for pass 2: waap signer for Bluefin order
auth + createOrder() (off-chain orderbook boundary).

Tracking: aex#60.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Shady El Damaty <shady@holonym.id>
Clones the guardian pattern. Real: Aftermath staking SDK (getApy, exchange
rate, getStakeTransaction) for SUI->afSUI, and the reference @suilend/sdk path
for the loop (deposit afSUI collateral, borrow SUI to target LTV, re-stake).
STAKE_MAX_USD + LOOP_TARGET_LTV hard caps; liquidation buffer preserved;
safe-mode + dryrun (live read + on-chain sim). Typecheck clean. Flagged: built
on Aftermath afSUI (no Haedal npm SDK found) with the native-Haedal swap
documented; afSUI-as-SuiLend-collateral + claimRewards method to verify on pass 2.

Tracking: aex#60.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Shady El Damaty <shady@holonym.id>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant