Skip to content

feat: TWAP minimum per-part USD value warning - #202

Merged
premiumjibles merged 1 commit into
mainfrom
feat/twap-min-value-validation
Mar 9, 2026
Merged

premiumjibles merged 1 commit into
mainfrom
feat/twap-min-value-validation

Conversation

@premiumjibles

@premiumjibles premiumjibles commented Mar 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds per-part USD value validation to TWAP order creation — warns (not blocks) when each part is below $10 (Ethereum) or $2 (L2s), since CoW solvers silently ignore unprofitable orders
  • Renders warnings as amber text in the TWAP UI card between order details and the execution stepper
  • Updates system prompt to instruct the LLM to surface warnings and suggest increasing amount or reducing intervals

Test plan

  • Create a TWAP with a small total amount (e.g. $1 USDC split into 10 parts on Arbitrum) and verify warning appears in tool output
  • Verify warning renders in amber in the UI card
  • Create a TWAP with sufficient per-part value and verify no warning appears
  • bun run lint passes
  • npx tsc --noEmit passes

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • TWAP orders now display warnings when per-interval amounts fall below minimum execution thresholds.
    • Added detection to alert users when individual part amounts are too small to be filled by solvers.
  • Documentation

    • Updated user guidance with information about minimum viable amounts across different blockchain networks and recommendations for order parameter adjustment.

TWAP orders with very small per-part amounts get created on-chain but
are silently ignored by CoW Protocol solvers. This adds a warning when
per-part value is below $10 (Ethereum) or $2 (L2s), surfaced in both
the tool output and UI card.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel

vercel Bot commented Mar 9, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
shapeshift-agentic Ready Ready Preview, Comment Mar 9, 2026 2:16am

Request Review

@coderabbitai

coderabbitai Bot commented Mar 9, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 26fe4e5d-c3ff-4959-b7c4-06e09122859e

📥 Commits

Reviewing files that changed from the base of the PR and between 0ca0c10 and cd331e8.

📒 Files selected for processing (3)
  • apps/agentic-chat/src/components/tools/TwapUI.tsx
  • apps/agentic-server/src/routes/chat.ts
  • apps/agentic-server/src/tools/twap/createTwap.ts

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


📝 Walkthrough

Walkthrough

The PR adds a warning system to the TWAP trading tool that alerts users when per-interval transaction amounts fall below viable thresholds. Warnings are computed based on chain type and part value, surfaced to the UI, and documented in user guidance.

Changes

Cohort / File(s) Summary
TWAP Warning Computation
apps/agentic-server/src/tools/twap/createTwap.ts
Added warnings?: string[] field to CreateTwapOutput interface. Implemented runtime logic to calculate per-interval minimum USD thresholds based on chain type, evaluate per-part sell amounts, and accumulate warnings when part values fall below chain-specific minimums (approximately $2 on L2s, $10 on Ethereum).
TWAP UI Rendering
apps/agentic-chat/src/components/tools/TwapUI.tsx
Added conditional rendering of orderData?.warnings as a list of warning messages styled with amber text, positioned beneath order details and above the stepper component.
User Guidance Documentation
apps/agentic-server/src/routes/chat.ts
Added two guidance bullets in Cow Protocol TWAP/DCA notes: one directing users to observe tool output warnings and adjust parameters (increase total amount or reduce intervals), another explaining per-part amount viability thresholds.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A warning system hops into view,
For TWAP amounts both small and true,
When parts are weak upon the chain,
Our rabbits squeak to ease the pain,
With thresholds clear and UI bright! ✨

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/twap-min-value-validation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@premiumjibles
premiumjibles marked this pull request as ready for review March 9, 2026 02:32
@premiumjibles
premiumjibles merged commit 22368d2 into main Mar 9, 2026
4 checks passed
@premiumjibles
premiumjibles deleted the feat/twap-min-value-validation branch March 9, 2026 02:32

This branch was successfully deployed

1 active deployment
Preview — cd331e81 Deployed Mar 9, 2026 by vercel[bot]
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