Skip to content

Add dry-run GoodChain arbitrage bot scaffold#2

Open
kc-zero-lab wants to merge 1 commit into
GoodDollar:mainfrom
kc-zero-lab:goodchain-arb-bot-scaffold
Open

Add dry-run GoodChain arbitrage bot scaffold#2
kc-zero-lab wants to merge 1 commit into
GoodDollar:mainfrom
kc-zero-lab:goodchain-arb-bot-scaffold

Conversation

@kc-zero-lab
Copy link
Copy Markdown

Summary

Adds an isolated, dry-run-first GoodChain arbitrage bot scaffold under backend/arb-bot.

This is intended as a local operator/developer tool for:

  • checking GoodChain RPC and GoodSwap status health
  • loading venue/market definitions from JSON
  • normalizing quotes from GoodSwap / GoodPerps / GoodPredict-style venues
  • detecting cross-market opportunities without risking funds
  • reviewing opportunities in a small local web UI
  • providing a safe adapter surface for future live execution work

Market-making / arbitrage logic

The bot is designed as a conservative cross-market market maker for the GoodChain app suite. Each venue adapter emits normalized MarketQuote objects, then the opportunity engine compares them under common risk limits.

Initial strategy families:

  1. Spot ↔ spot cross-venue arbitrage

    • Buy where a spot asset is cheaper and sell where it is richer.
    • Helps tighten prices and improve effective liquidity across spot venues.
  2. Spot ↔ perp basis market making

    • Long spot / short perp when the perp trades above spot.
    • Designed to narrow basis between GoodSwap spot and GoodPerps markets.
    • The engine explicitly labels funding, oracle/index, liquidation, and non-atomic execution risks.
  3. Prediction-market basket arbitrage

    • Detects binary YES + NO baskets priced below 1.0.
    • Helps keep GoodPredict markets internally consistent.
    • The engine calls out resolution, invalidation, liquidity, and settlement-delay risks.

The key design choice is quote normalization + risk-gated execution, not hardcoded trading scripts. Live execution remains blocked unless every leg includes explicit transaction target/calldata.

Safety model

  • Defaults to DRY_RUN=true.
  • Refuses live execution without a private key.
  • Even with live mode enabled, refuses any leg missing to + calldata.
  • Isolated package; does not modify contracts, deployed PM2 services, frontend routes, or SDK exports.
  • Existing live GoodChain endpoints are defaults:
    • RPC: https://rpc.goodclaw.org
    • Chain ID: 42069
    • Status API: https://goodswap.goodclaw.org/api/status

Verification

From backend/arb-bot:

  • npm run check
  • npm run build

I also attempted npm run health, but the current environment timed out connecting to rpc.goodclaw.org; the code path previously passed against the same endpoint before the timeout and remains covered by typecheck/build here.

Follow-up work

  • Fill markets.example.json with concrete GoodSwap / GoodPerps / GoodPredict contracts or quote APIs.
  • Implement live venue adapters once machine-readable quote/execution contracts are confirmed.
  • Add reverse perp-basis and prediction overpricing strategies.
  • Add inventory/risk accounting before any non-atomic live execution.

yoniassia pushed a commit that referenced this pull request May 24, 2026
`docs/ETORO_GOODCHAIN_ADAPTER.md` documented three behaviors that the
code stopped doing in iteration #2:

- `ETORO_MODE` "unknown values fall back to mock" — actually throws
  `InvalidModeError` (task #0003).
- Notional "falling back to amount (USD-stake)" — actually throws
  `MissingNotionalError` (task #2).
- `loadInstrumentOverrides()` "unknown symbols are dropped" — actually
  throws `InvalidInstrumentOverridesError` (task #0006).

The doc has been rewritten to describe the loud-failure contract
honestly, and a new "Error taxonomy" section enumerates every typed
error the SDK can raise (8 total, mirroring `index.ts` re-exports) with
the module + constructor responsible. Operators can now grep this one
section to map a thrown error back to its source.

Docs-only change. Full etoro-client suite stays green. The three
forbidden phrases from the PRD's verification step now return zero
grep hits.

Co-authored-by: Cursor <cursoragent@cursor.com>
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