-
Notifications
You must be signed in to change notification settings - Fork 202
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Problem
When placing limit orders for sub-dollar tokens (e.g. ARB → USDC), SellAmount shows a massive base-unit number like "230,000,000,000..." instead of human-readable amounts. Users could sign orders with wildly wrong amounts.
tk ticket: sa-lhbw
Repro: Place a limit order for ARB → USDC (or any sub-dollar token).
Root Cause
Server-side code is structurally correct (summary.sellAsset.amount uses human-readable values). The bug is most likely an LLM reasoning error for sub-dollar tokens where:
- LLM passes base-unit value as
sellAmountafter seeingprecision: 18 orderParams.sellAmount(base unit) leaks into LLM's text response- LLM inverts
limitPricefor sub-dollar tokens, producing enormous numbers
Fix
- Input validation — reject
sellAmountwith >15 digits (defense in depth) - Sanity check — validate sellAmount * limitPrice vs market price (>1000x = error)
- Schema description — explicit base-unit warning with sub-dollar token examples
- Reduce leakage — filter
orderParamsfrom LLM-visible output - Apply to all tools — same fixes for
createStopLoss.tsandcreateTwap.ts
Key Files
apps/agentic-server/src/tools/limitOrder/createLimitOrder.tsapps/agentic-server/src/tools/stopLoss/createStopLoss.tsapps/agentic-server/src/tools/twap/createTwap.tsapps/agentic-server/src/routes/chat.ts
Acceptance Criteria
- Input validation rejects >15 digit sellAmount values
- Sanity check on sellAmount * limitPrice vs market price
- Schema descriptions warn about base-unit vs human-readable
- Manual test: ARB → USDC limit order shows correct amounts
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
Backlog