Repository navigation
Conversation
…for checkout, setup-python, setup-uv, upload-artifact, and download-artifact
…rt latest credit metering usage
… retrieval - Added support for retrying swaps with relaxed slippage and `amountOutMinimum` in case of STF errors. - Implemented on-chain retrieval of pool fee and token order to ensure accurate trading parameters. - Updated guard state to manage pending actions and errors more effectively. - Enhanced logging for pool fee and wallet balances during guard operations.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 08903319e0
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…rategies and time based exit with status return codes to be picked up by composing agent frameworks - Updated the guard command to support spot mode with take-profit and stop-loss percentages. - Introduced parameters for re-entry strategies and idle exit timing. - Enhanced documentation for guard commands and user guide to reflect new features. - Improved state management for guard actions, including logging of trades and wallet balances.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e320b97526
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f468ff165b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
bds-agent-py/src/bds_agent/verify.py
Line 129 in 24b39a0
The new fallback defaults are documented as applying after the stream payload, but run_agent only calls this resolver after parse_verification() succeeds, and that parser still rejects events where verification.protocolState or verification.dataMarket are absent. For BDS events that include cid/projectId but rely on the packaged alpha defaults, verify: true silently skips verification instead of using this default; loosen the parser to carry empty addresses through to these fallback branches.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
- Introduced `is_paper_position` function to identify paper positions. - Updated `is_dry_run_open` to utilize the new function for clarity. - Added `strip_dry_run_positions` to remove paper positions while retaining live LONGs, with a count of removed positions. - Modified `reconcile_live_trader_state` and `prepare_live_trader_state` to integrate the new stripping functionality, ensuring live positions are preserved. - Updated `daily_realized_pnl_usd` to exclude dry-run trades when specified. - Added tests to verify the new behavior for handling dry-run positions and their impact on live trading state.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f0d23318e0
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
- Added `guard reset` command to clear exit/entry anchors and set a fresh leg for new trades. - Updated `guard run` to support entering a new leg after a reserve idle timeout. - Introduced logic to manage state transitions between reserve and active trading modes. - Enhanced documentation for guard commands to reflect new features and usage. - Added tests to validate the new reset functionality and its impact on trading behavior.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8bce6b660f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…ement - Introduced `_normalize_price_source` function to standardize price source input in trading configurations. - Updated `_trade_thresholds` and `_trade_config` to utilize the new normalization function for consistent price source handling. - Added `_merge_watchlist_open_positions` to include held pools in the watchlist, ensuring accurate tracking of open positions. - Enhanced tests to validate the new normalization and merging functionalities, improving robustness in trading operations.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1713dd3b6b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…ub tokens - Enhanced command descriptions for `prices at` and `prices token`, indicating preferred usage and limitations for major tokens like USDC and WETH. - Added instructions for discovering pools before pricing for tokens with more than 20 pools. - Updated example commands to reflect the new token addresses and usage scenarios.
… guard modules - Updated `sync_reserve_since` to directly use the current time instead of `updated_at` for setting `reserve_since`. - Simplified logic in `_after_guard_fill` to manage `reserve_since` based on new position. - Introduced `_price_usable` function to validate price inputs. - Enhanced `_consume_pulse_signal` to manage cooldowns effectively after signal consumption. - Added tests to validate changes in state management and signal handling, ensuring robustness in trading operations.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 85928ea5c3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
- Updated `PulseBuffer` to return the latest trade price instead of the median for improved accuracy. - Introduced `credits_exhausted_hint` function in `signup_api` to provide user guidance when credit balance is zero. - Enhanced error handling in `fetch_token_usd_in_pool` and `fetch_all_token_prices` to raise exceptions with helpful messages on credit exhaustion. - Added tests to validate the new price retrieval logic and error handling for credit-related scenarios, ensuring robustness in trading operations.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2f903ed31f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- Updated command descriptions for `guard enter`, `guard status`, and `guard reset` to clarify their functionalities and usage. - Added new sections in documentation to address orchestrators, failure modes, and credit management hints for HTTP 402 errors. - Improved error handling in the guard and trade modules to provide clearer messages regarding insufficient USDC and API key issues. - Introduced tests to validate the new documentation and error handling features, ensuring robustness in user guidance and operational clarity.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 200c6f787f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…position even against RPC failure - Removed the `has_open_pool` function and integrated its logic into the `_record_guard_entry` function to streamline position checks. - Introduced `position_sell_tokens` function to encapsulate logic for determining the amount of tokens to sell based on wallet balance and recorded position. - Updated `_record_guard_entry` and `_record_guard_exit` functions to improve error handling and ensure state persistence during balance retrieval failures. - Added tests to validate the new position management logic and ensure robustness in trading operations.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: db5dbcbec6
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…in_attempts`, `evaluate_pulse` function to utilize epoch-based timing for price evaluations - Updated the `_record_guard_entry` function to correctly use fill price for initial entries and improved handling of fresh leg state. - Simplified the `_amount_out_min_attempts` function to honor the configured slippage floor without silent relaxations. - Enhanced the `evaluate_pulse` function to utilize epoch-based timing for price evaluations, ensuring accurate diagnostics. - Adjusted tests to validate the new logic for entry price handling and slippage configurations, ensuring robustness in trading operations.
Checklist
requires-python = ">=3.12,<3.14"inpyproject.toml; not 3.8).uv run pre-commit install→ ruff--fixonsrc/bds_agent/(see.pre-commit-config.yaml).201 passedlocally).Current behaviour
On
main,bds-agentcovers signup, credits,run/query/create, MCP, and declarative rules/sinks. There is no first-class CLI for:/mpp/token/price/,/mpp/tokenPrices/)New expected behaviour
developadds production-oriented trading and guard rails on top of the existing agent CLI, wired to BDS metering and snapshotter HTTP:bds-agent pricesdocs/PRICES.md)bds-agent tradedocs/TRADE.md)bds-agent guard--enter;.guard.json+ sync totrader.json(docs/GUARD.md)bds-agent credits usageevm_swap,evm_tx,active_marketsfee()/token0/token1/ decimals enrichment; USDC-capped buys; slippage retry; pending-tx wait before enterGuard — spot trading (default)
No fixed USD levels required: buy at current BDS spot, sell on percent moves, re-enter after partial giveback of the last exit.
--enter/--no-enter--sizeUSDC → base at startup spot (--no-enterif already holding or resuming from reserve)--take-profit-pct0.003= +0.3%)--stop-loss-pct0.02= −2%)--reentry-retrace-pctreentry_below(half the gain after TP, or half the loss depth after SL)--reserve-max-minutesguard_exit_reason=reserve_idle_timeoutfor orchestrators)--pool,--tokenGET /mpp/token/price/{token}/{pool}--size,--poll,--slippage--dry-run,-vExplicit mode (compose / fixed bands): pass both
--threshold-highand--threshold-low; optional--reentry-on-breakout. Default--no-enterunless you pass--enter.Guard-specific expectations after merge:
pricing_mode,reference_entry_usd,last_exit_usdin.guard.json.chain_id, wallet balances, resolvedpool_feeafterenrich_watched_pool_fee().position=reserve; no startup re-buy while in reserve (waits for dip band).guard resetclears cycle anchors; next leg usesguard run … --enter(orguard reset+ enter).pending_action+ backoff; BDS price 502/503/504/429 retry with logged[PRICE RETRY].https://bds-metering.powerloom.io/meteringorbds-agent credits topup) — no silent hold.trader.json/ trades log (trade status,history,pnl);guard statusfor bracket fields.uv tool install --force .).Change logs
Added
bds-agent trade— Pulse self-contained trader:setup-evm,run,status,history,pnl,exit,reconcile; multi-pool, positions, exit strategies.bds-agent guard— Spot %% brackets (default) + explicit USD bands;run,enter,status,reset; edge-triggered crosses;guard_trade_sync; reserve idle exit; colored UTC logs (guard.py,guard_state.py,guard_trade_sync.py,tty_console.py).bds-agent prices— USD Price Feed CLI (prices_cmd.py,usd_prices.py).bds-agent credits usage— Metering usage summary and by-endpoint (credits_api.py).evm_swap.py,evm_tx.py,active_markets.py(WatchedPool, on-chain enrich).docs/TRADE.md,docs/GUARD.md,docs/PRICES.md;README.md,PYPI_README.md,SKILL.md,docs/USER_GUIDE.md.--fixonsrc/bds_agent/(.pre-commit-config.yaml).Changed
cli.py— Trade, guard (spot flags,reset), prices, credits usage command trees.runner.py,client.py,credentials.py,paths.py,secrets.py,evm_config.py,evm_erc20.py— Profile paths, trade wallet, secrets handling; stream fail-fast on invalid API key (BdsClientErrornot swallowed).pulse.py,multi_pool.py,usd_prices.py,signup_api.py— Price-source normalization, latest-sample pricing, metering UI URL in 402 hints.pyproject.toml— Trade + guard keywords; devpre-commit; version0.1.1..github/workflows/publish-pypi.yml— Action bumps.Fixed (Codex reviews 1–10 + operator hotfixes)
token_balanceonly; single-pool entry records WETH buy delta;_cap_sell_amount_atomicprevents float rounding over-balance sellsbase_tokenafterenrich_watched_pool_fee; dry-run skips signing key; on-chain fee before live entry (no default 3000)--enterwhenposition=reserve;guard enterworks in reserve; pending initial entry retries;reserve_sincefrom exit time not staleupdated_at;guard reset+fresh_legguard enter→record_guard_fill→trader.json; re-entry fill price not stale reference; dry-run exit does not drop live positionscredits_exhausted_hint()(metering UI +credits topup);current_price()uses latest sample not full-buffer medianToo little receivedtreated as slippage retry; actual USDC spend persisted from swap tuplestrip_dry_run_positions()on live start; manual exit uses BDS market price for P/L; swap vs bookkeeping split when balance RPC fails post-exit--price-sourcevalidated (usd/trades); whitespace-normalized; live single-pool swap errorscontinuenot crash; multi-pool enrich before live tracker; watchlist refresh drops stale pools; open positions merged back onto watchlist; ignored SHORT/LONG does not advance signal cooldown; exits require usable pool price--no-enterunless--enter; rejectstop_loss_pct >= take_profit_pctGET /mpp/token/price/{token}/{pool}only;last_finalized_epoch401/402/403/404 → log-only (no guard death)metering_ui_url()→https://bds-metering.powerloom.io/meteringin 402 hints (origin vs UI path)Removed
Manual test checklist
Run in order against an active profile (replace
mytest). Metering origin:https://bds-metering.powerloom.io· Billing UI:https://bds-metering.powerloom.io/metering· BDS API:https://bds.powerloom.io/api.0. Prerequisites
Files created under
~/.config/bds-agent/:profiles/mytest.jsonsignup_base_url, optionalbds_base_urlactive_profileprofiles/mytest.evm.envcredits setup-evm) — optionalprofiles/mytest.trade.envtrade setup-evm) — required for live trade/guard1. Setup trading wallet
Fund that wallet: USDC (swap size) + ETH (gas). Do not use
.evm.envfor swaps.Probe BDS price route (uses API credits):
2. Pulse trader (
trade run)Dry-run first (no on-chain swaps; paper positions in
trader.json):--dry-run--multi-pooldailyActivePools(not WETH-only)--price-source usd|trades/mpp/tokenPrices/) vs swap-implied from stream--size,--slippage--verbose--daily-loss-limitOps while running or after Ctrl+C:
bds-agent trade status --profile mytest bds-agent trade history --profile mytest bds-agent trade pnl --profile mytest bds-agent credits usage by-endpoint --profile mytest --days 7Live (drop
--dry-run; same flags otherwise):On HTTP 402 / zero credits, expect:
BDS credits exhausted (HTTP 402) — add credits at https://bds-metering.powerloom.io/metering or run bds-agent credits topup. Invalid API key on stream exits withBdsClientError(no infinite reconnect).3. Threshold Guard (
guard run,enter,reset)Spot mode dry-run (default %% bands;
--enteron by default):--enter/--no-enter--take-profit-pct,--stop-loss-pct--reentry-retrace-pct--reserve-max-minutesguard_exit_reason=reserve_idle_timeout--poll,--slippage,--size--dry-runOne-shot entry:
Status + orchestrator hook:
After
reserve_idle_timeout— start fresh leg:bds-agent guard reset --profile mytest # clears anchors; keeps pool; fresh_leg=True bds-agent guard run --profile mytest \ --pool 0xE0554a476A092703abdB3Ef35c80e0D76d32939F \ --token 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 \ --size 5 --take-profit-pct 0.003 --reserve-max-minutes 30 --poll 5 --enterExplicit USD bands (fixed levels; default no startup enter):
Deployment Instructions
PyPI (maintainers)
After merge to
main, tag/release per.github/workflows/publish-pypi.yml. Consumers:uv tool upgrade bds-agent # or pipx upgrade bds-agentOperators (VPS / local — not workspace layout)
Profiles (per
docs/TRADE.md/docs/GUARD.md):profiles/<name>.jsonbds_base_url, market nameprofiles/<name>.trade.envprofiles/<name>.evm.envsignup-pay)profiles/<name>.tempo.envprofiles/<name>.guard.jsonprofiles/<name>.trader.jsonEnv (minimum for guard/trade on mainnet):
BDS_BASE_URL— snapshotter API origin (e.g.https://bds.powerloom.io/api)profiles/<profile>.trade.envviabds-agent trade setup-evm