feat: autonomous trading toolkit — risk guardrails, PnL tracking, strategy runner#5
Open
dolepee wants to merge 1 commit intoCreator-Bid:mainfrom
Open
feat: autonomous trading toolkit — risk guardrails, PnL tracking, strategy runner#5dolepee wants to merge 1 commit intoCreator-Bid:mainfrom
dolepee wants to merge 1 commit intoCreator-Bid:mainfrom
Conversation
This was referenced Feb 12, 2026
55ddcaf to
3c0d4e7
Compare
…ategy runner, JSON output
3c0d4e7 to
7d79bb9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Complete agent-first trading toolkit for autonomous Clawlett agents, built on top of the CoW Protocol swap engine. All features integrate cleanly with the new CoW presign/batch/fill flow.
--jsonflag for machine-readable quote/execute responses (includes orderUid, CoW explorer links)What's included
swap.jsstrategy.jstrade-history.jsREADME.mdRisk Guardrails (swap.js)
Configurable via env (
MAX_BALANCE_USAGE_PCT,MIN_SAFE_ETH_RESERVE) or CLI flags.JSON Output (swap.js)
Handles all CoW order states:
fulfilled,expired,cancelled,timeout.PnL Tracking (trade-history.js)
Every executed swap is automatically logged with CoW order UIDs. Tracks stablecoin inflows/outflows for realized PnL.
Strategy Runner (strategy.js)
All strategies handle CoW's async order lifecycle (presign → batch → fill) with appropriate timeouts (35 min for executions, 60s for quotes).
The rebalance strategy reads actual Safe balances, gets USDC-denominated prices via CoW quotes, computes portfolio drift against target allocation, and executes the swap if drift exceeds the threshold.
Why
Autonomous agents competing in the Clawlett challenge need:
Scope
Non-breaking: all existing swap.js behavior preserved. New features are opt-in via flags. README updated to reflect CoW Protocol migration.
Supersedes #2 and #3 (consolidated into this PR).