Skip to content
This repository was archived by the owner on Jun 15, 2026. It is now read-only.

USD price feed. Pulse and guard rail trading strategies - #1

Open
anomit wants to merge 20 commits into
mainfrom
develop
Open

anomit wants to merge 20 commits into
mainfrom
develop

Conversation

@anomit

@anomit anomit commented May 28, 2026 •

Copy link
Copy Markdown
Member

Checklist

  • My branch is up-to-date with upstream/develop branch.
  • Everything works and tested for Python 3.12+ (requires-python = ">=3.12,<3.14" in pyproject.toml; not 3.8).
  • Pre-commit: uv run pre-commit install → ruff --fix on src/bds_agent/ (see .pre-commit-config.yaml).
  • I've written tests against my changes and all the current present tests are passing (201 passed locally).

Current behaviour

On main, bds-agent covers signup, credits, run / query / create, MCP, and declarative rules/sinks. There is no first-class CLI for:

  • BDS USD price feed queries (/mpp/token/price/, /mpp/tokenPrices/)
  • Pulse momentum trading on Uniswap V3 from BDS epochs
  • Threshold Guard bracket trading on pool-scoped USD prices
  • Credits usage breakdown against the metering API
  • On-chain EVM swap helpers (router quotes, slippage, pending-tx handling)

New expected behaviour

develop adds production-oriented trading and guard rails on top of the existing agent CLI, wired to BDS metering and snapshotter HTTP:

Surface Command group Behaviour
USD prices bds-agent prices Pool-scoped and catalog USD price queries (docs/PRICES.md)
Pulse trader bds-agent trade SSE epochs → Pulse confluence → Uniswap V3 swaps; multi-pool, positions, exit strategies (docs/TRADE.md)
Threshold Guard bds-agent guard Spot mode (default): %% take-profit / optional stop / dip re-entry from BDS spot; explicit mode: fixed USD high/low bands; optional --enter; .guard.json + sync to trader.json (docs/GUARD.md)
Credits usage bds-agent credits usage Summary and per-endpoint usage from metering API
EVM layer evm_swap, evm_tx, active_markets On-chain pool fee() / token0 / token1 / decimals enrichment; USDC-capped buys; slippage retry; pending-tx wait before enter

Guard — 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.

Flag Default Role
--enter / --no-enter on (spot); off (explicit) Swap --size USDC → base at startup spot (--no-enter if already holding or resuming from reserve)
--take-profit-pct 0.03 (+3%) Sell when price rises this fraction above entry (e.g. 0.003 = +0.3%)
--stop-loss-pct (off) Optional: sell when price falls this fraction below entry (e.g. 0.02 = −2%)
--reentry-retrace-pct 0.5 After exit, dip re-entry on cross down through reentry_below (half the gain after TP, or half the loss depth after SL)
--reserve-max-minutes 0 In USDC after exit, stop process if no dip re-entry within N min (guard_exit_reason=reserve_idle_timeout for orchestrators)
--pool, --token — Pool + base token for GET /mpp/token/price/{token}/{pool}
--size, --poll, --slippage 25, 15s, 0.005 Notional, poll interval, swap slippage
--dry-run, -v off, off Cross detection without swaps; verbose ticks

Explicit mode (compose / fixed bands): pass both --threshold-high and --threshold-low; optional --reentry-on-breakout. Default --no-enter unless you pass --enter.

Guard-specific expectations after merge:

  • Spot default when thresholds omitted; persisted pricing_mode, reference_entry_usd, last_exit_usd in .guard.json.
  • Startup logs chain_id, wallet balances, resolved pool_fee after enrich_watched_pool_fee().
  • Trades fire on threshold crosses between polls, not while price sits inside a band.
  • After take-profit/stop: position=reserve; no startup re-buy while in reserve (waits for dip band).
  • guard reset clears cycle anchors; next leg uses guard run … --enter (or guard reset + enter).
  • Swap failures do not force exit; pending_action + backoff; BDS price 502/503/504/429 retry with logged [PRICE RETRY].
  • HTTP 402 on USD price routes raises with top-up hint (https://bds-metering.powerloom.io/metering or bds-agent credits topup) — no silent hold.
  • Fills mirrored to trader.json / trades log (trade status, history, pnl); guard status for bracket fields.
  • Operators reinstall from repo or PyPI after merge (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 stack — evm_swap.py, evm_tx.py, active_markets.py (WatchedPool, on-chain enrich).
  • Docs — docs/TRADE.md, docs/GUARD.md, docs/PRICES.md; README.md, PYPI_README.md, SKILL.md, docs/USER_GUIDE.md.
  • Tests — guard spot, reserve idle, trade sync, Codex reviews 1–10, USD retry/402, pre-commit path; 201 total.
  • Pre-commit — local ruff --fix on src/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 (BdsClientError not 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; dev pre-commit; version 0.1.1.
  • .github/workflows/publish-pypi.yml — Action bumps.

Fixed (Codex reviews 1–10 + operator hotfixes)

Area Fix
Trade exits Multi-pool exit sells position token_balance only; single-pool entry records WETH buy delta; _cap_sell_amount_atomic prevents float rounding over-balance sells
Guard pool/EVM Resolve base_token after enrich_watched_pool_fee; dry-run skips signing key; on-chain fee before live entry (no default 3000)
Guard state Skip --enter when position=reserve; guard enter works in reserve; pending initial entry retries; reserve_since from exit time not stale updated_at; guard reset + fresh_leg
Guard/trade sync guard enter → record_guard_fill → trader.json; re-entry fill price not stale reference; dry-run exit does not drop live positions
USD price feed 401/5xx surfaced (not silent hold); HTTP retry 502/503/504/429; 402 raises with credits_exhausted_hint() (metering UI + credits topup); current_price() uses latest sample not full-buffer median
Slippage / swaps Too little received treated as slippage retry; actual USDC spend persisted from swap tuple
Trade lifecycle Dry-run exit / paper positions excluded from live daily loss limit; strip_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
Pulse robustness Unknown --price-source validated (usd/trades); whitespace-normalized; live single-pool swap errors continue not 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
Explicit guard mode Default --no-enter unless --enter; reject stop_loss_pct >= take_profit_pct
Namespace cleanup Guard price = GET /mpp/token/price/{token}/{pool} only; last_finalized_epoch 401/402/403/404 → log-only (no guard death)
Metering URL metering_ui_url() → https://bds-metering.powerloom.io/metering in 402 hints (origin vs UI path)

Removed

  • (none — net additive release)

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

cd bds-agent-py && uv cache clean && uv tool install -e .
export BDS_AGENT_SIGNUP_URL=https://bds-metering.powerloom.io   # metering API origin (not /metering)

# API key + BDS origin (pick one path)
bds-agent signup --profile mytest
# or: bds-agent signup-pay --profile mytest --plan-id … --chain-id … --token-symbol …

bds-agent config init --profile mytest    # sets bds_base_url + catalog defaults
bds-agent config show --profile mytest
bds-agent credits balance --profile mytest

Files created under ~/.config/bds-agent/:

File Purpose
profiles/mytest.json API key, signup_base_url, optional bds_base_url
active_profile Default profile name
profiles/mytest.evm.env Billing wallet (credits setup-evm) — optional
profiles/mytest.trade.env Swap wallet (trade setup-evm) — required for live trade/guard

1. Setup trading wallet

# Writes TRADE_EVM_PRIVATE_KEY, TRADE_EVM_RPC_URL, TRADE_EVM chain ID
# to ~/.config/bds-agent/profiles/mytest.trade.env (0600)
bds-agent trade setup-evm --profile mytest

Fund that wallet: USDC (swap size) + ETH (gas). Do not use .evm.env for swaps.

Probe BDS price route (uses API credits):

bds-agent prices at 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 \
  --pool 0xE0554a476A092703abdB3Ef35c80e0D76d32939F \
  --profile mytest

2. Pulse trader (trade run)

Dry-run first (no on-chain swaps; paper positions in trader.json):

# Single-pair WETH/USDC — trade-implied or USD price gate
bds-agent trade run --profile mytest --dry-run --verbose \
  --price-source usd --size 25

# Multi-pool (production path): watches dailyActivePools, USD price gate
bds-agent trade run --profile mytest --dry-run --multi-pool --verbose \
  --price-source usd --size 25 --max-open-positions 5
Flag group Meaning
--dry-run Log signals and paper entries/exits only
--multi-pool Top USDC pools from dailyActivePools (not WETH-only)
--price-source usd|trades USD feed (/mpp/tokenPrices/) vs swap-implied from stream
--size, --slippage USDC notional per entry; router tolerance
--verbose Per-epoch heartbeat (gates, position, exit checks)
--daily-loss-limit Block new entries when today's realized P/L ≤ −$N (UTC)

Ops 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 7

Live (drop --dry-run; same flags otherwise):

bds-agent trade run --profile mytest --multi-pool --price-source usd --size 25

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 with BdsClientError (no infinite reconnect).

3. Threshold Guard (guard run, enter, reset)

Spot mode dry-run (default %% bands; --enter on by default):

bds-agent guard run --profile mytest \
  --pool 0xE0554a476A092703abdB3Ef35c80e0D76d32939F \
  --token 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 \
  --size 5 --take-profit-pct 0.003 --stop-loss-pct 0.002 \
  --reentry-retrace-pct 0.5 --reserve-max-minutes 30 --poll 5 \
  --dry-run -v
Flag group Meaning
--enter / --no-enter Startup USDC→base at spot (default on in spot mode)
--take-profit-pct, --stop-loss-pct %% sell bands from entry
--reentry-retrace-pct Dip re-buy after partial giveback of last exit
--reserve-max-minutes Exit process in USDC if no dip re-entry; sets guard_exit_reason=reserve_idle_timeout
--poll, --slippage, --size Poll interval, swap tolerance, USDC notional
--dry-run Cross detection without swaps or signing key

One-shot entry:

bds-agent guard enter --profile mytest \
  --pool 0xE0554a476A092703abdB3Ef35c80e0D76d32939F \
  --token 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 \
  --size 5

Status + orchestrator hook:

bds-agent guard status --profile mytest    # .guard.json incl. guard_exit_reason
bds-agent trade status --profile mytest    # mirrored LONG/FLAT from guard fills

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 --enter

Explicit USD bands (fixed levels; default no startup enter):

bds-agent guard run --profile mytest \
  --pool 0xE0554a476A092703abdB3Ef35c80e0D76d32939F \
  --token 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 \
  --threshold-high 2022 --threshold-low 2020 \
  --no-enter --poll 5 --slippage 0.007

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-agent

Operators (VPS / local — not workspace layout)

cd bds-agent-py
git checkout develop && git pull
uv cache clean
uv tool install --force .
bds-agent --version

Profiles (per docs/TRADE.md / docs/GUARD.md):

File Purpose
profiles/<name>.json BDS API key, bds_base_url, market name
profiles/<name>.trade.env Swap wallet (trade + guard)
profiles/<name>.evm.env Billing wallet (signup-pay)
profiles/<name>.tempo.env Tempo top-up (optional)
profiles/<name>.guard.json Guard bracket state
profiles/<name>.trader.json Pulse + mirrored guard positions

Env (minimum for guard/trade on mainnet):

  • BDS_BASE_URL — snapshotter API origin (e.g. https://bds.powerloom.io/api)
  • Trade RPC + keys in profiles/<profile>.trade.env via bds-agent trade setup-evm

anomit added 5 commits May 18, 2026 12:23
…for checkout, setup-python, setup-uv, upload-artifact, and download-artifact
… 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.
@anomit
anomit requested a review from SwaroopH May 28, 2026 18:24
@anomit anomit self-assigned this May 28, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/bds_agent/trade.py Resolved
Comment thread src/bds_agent/guard.py Resolved
Comment thread src/bds_agent/evm_swap.py Resolved
Comment thread src/bds_agent/usd_prices.py Resolved
Comment thread src/bds_agent/trade.py Resolved
Comment thread src/bds_agent/guard.py Resolved
…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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/bds_agent/trade.py Resolved
Comment thread src/bds_agent/exit_strategies.py Resolved
Comment thread src/bds_agent/cli.py Resolved
Comment thread src/bds_agent/active_markets.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/bds_agent/guard.py Resolved
Comment thread src/bds_agent/guard.py Resolved
Comment thread src/bds_agent/guard_trade_sync.py Resolved
Comment thread src/bds_agent/trade.py Resolved
Comment thread src/bds_agent/trade.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

v = env_or_profile("POWERLOOM_PROTOCOL_STATE")

P2 Badge Allow verification defaults to be reached

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".

Comment thread src/bds_agent/trade.py Resolved
Comment thread src/bds_agent/trader_state.py Resolved
Comment thread src/bds_agent/trader_state.py Resolved
- 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/bds_agent/evm_swap.py Resolved
Comment thread src/bds_agent/guard.py Resolved
Comment thread src/bds_agent/guard_trade_sync.py Resolved
Comment thread src/bds_agent/cli.py Resolved
Comment thread src/bds_agent/trader_state.py Resolved
- 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/bds_agent/cli.py Resolved
Comment thread src/bds_agent/trade.py Resolved
Comment thread src/bds_agent/trade.py Resolved
…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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/bds_agent/guard.py Resolved
Comment thread src/bds_agent/trade.py Resolved
Comment thread src/bds_agent/pulse.py Resolved
…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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/bds_agent/trade.py Resolved
Comment thread src/bds_agent/trade.py Resolved
Comment thread src/bds_agent/trade.py Resolved
Comment thread src/bds_agent/usd_prices.py Resolved
Comment thread src/bds_agent/pulse.py Resolved
- 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.
@SwaroopH

SwaroopH commented Jun 1, 2026

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/bds_agent/trade.py Resolved
Comment thread src/bds_agent/guard.py Resolved
Comment thread src/bds_agent/guard_state.py Resolved
- 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/bds_agent/guard_trade_sync.py Resolved
Comment thread src/bds_agent/guard_trade_sync.py Resolved
Comment thread src/bds_agent/guard_trade_sync.py Resolved
Comment thread src/bds_agent/guard.py Resolved
…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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/bds_agent/evm_swap.py Resolved
Comment thread src/bds_agent/pulse.py Resolved
Comment thread src/bds_agent/guard_trade_sync.py Resolved
Comment thread src/bds_agent/cli.py Resolved
Comment thread src/bds_agent/multi_pool.py Resolved
…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.

@SwaroopH SwaroopH left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

This branch was previously deployed

1 inactive deployment
testpypi — d15808e6 Deployed Jun 4, 2026 by anomit via Publish to TestPyPI #41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants