V2 support

This commit is contained in:
Daniel Sapkota
2026-07-05 18:07:28 -04:00
parent c7b686116e
commit b3f25e0fa7
24 changed files with 73 additions and 1287 deletions
+1 -1
View File
@@ -62,7 +62,7 @@ class GammaClient:
Uses the offset `/markets` endpoint because it reliably supports
`tag_id` filtering today. (Keyset is the go-forward per docs; switch when
it supports tag filtering. See docs/scoping/03-api-layer.md §4.)
it supports tag filtering. See the README.)
"""
offset = 0
for _ in range(max_pages):
+2 -2
View File
@@ -4,7 +4,7 @@ Verifies the environment is ready to trade WITHOUT posting any order:
config + secrets, CLOB/Gamma reachable, wallet auth (L1->L2 creds), collateral
balance + positions ON THE FUNDER (deposit/developer wallet, where funds live),
a live market-WS book frame, and an authenticated user-WS connection. This is
the gate before the live $5 round-trip (docs/scoping/06 Phase 2).
the gate before the live $5 round-trip (the README).
"""
from __future__ import annotations
@@ -84,7 +84,7 @@ async def run_doctor(cfg: Config, console: Console) -> bool:
except Exception as e: # noqa: BLE001
check("wallet auth (L2 creds derived)", False, str(e))
console.print(" [yellow]! signature-type mismatch? deposit wallets use sig_type=3 "
"(config.toml). See docs 03 §9.[/yellow]")
"(config.toml). See the README.[/yellow]")
else:
console.print(" [yellow]! skipping wallet checks (no secrets)[/yellow]")
+1 -1
View File
@@ -24,7 +24,7 @@ class Side(str, Enum):
class Regime(str, Enum):
"""Per-market quoting regime (see docs/scoping/04-strategy.md §5)."""
"""Per-market quoting regime (see the README)."""
QUIET = "QUIET" # farming posture: in-band, layered, full size
TRENDING = "TRENDING" # persistent one-sided flow: lean + widen + half size
+1 -1
View File
@@ -1,6 +1,6 @@
"""Append-only JSONL event journal.
Captures raw WS-in and orders-out so the replay backtester (docs 04 §9) can
Captures raw WS-in and orders-out so the replay backtester (see the README) can
reconstruct books and re-run the strategy. Also the substrate for post-mortems.
Cheap: one line per event, flushed, rotated by day.
"""
+2 -2
View File
@@ -1,4 +1,4 @@
"""Live wallet round-trip test — the Phase-2 wallet spike (docs 06).
"""Live wallet round-trip test — the Phase-2 wallet spike (see the README).
Proves the full V2 order path against the real exchange with minimal risk:
places ONE post-only BUY well below the touch (so it rests and cannot fill),
@@ -50,7 +50,7 @@ async def run_livetest(cfg: Config, console: Console, notional_usdc: float = 5.0
console.print(f" [green]✓[/green] wallet auth — address {gw.address[:12]}")
except Exception as e: # noqa: BLE001
console.print(f" [red]✗ wallet auth failed:[/red] {e}")
console.print(" [yellow]Auth/signature-type mismatch (docs 03 §9). If your account has a "
console.print(" [yellow]Auth/signature-type mismatch (see the README). If your account has a "
"'deposit address', set signature_type=3 (POLY_1271) in config.toml and use the "
"deposit address as BROWSER_ADDRESS. Errors like 'maker address not allowed, use "
"the deposit wallet flow' or 'signer must be the API key address' mean the type is "
+1 -1
View File
@@ -1,7 +1,7 @@
"""Pure parsers for market-WS wire messages -> structured updates.
Kept separate from the socket so they're unit-testable against captured frames.
Verified against live frames on 2026-07-05 (docs/scoping/03-api-layer.md §5):
Verified against live frames on 2026-07-05 (the README):
book: {market, asset_id, bids:[{price,size}], asks:[...], timestamp, hash, tick_size}
price_change:{market, timestamp, price_changes:[{asset_id, price, size, side, hash}]}
+1 -1
View File
@@ -6,7 +6,7 @@ collateral (1 USDC/pUSD per pair) — a maker-only exit with zero market impact.
Two execution paths:
* EOA wallet (signature_type=0): direct contract call, fully implemented here.
* Proxy/Safe wallet (signature_type 1/2): the merge tx must be routed through
the Safe. That path is gated on the Phase-2 wallet spike (docs 03 §6) — until
the Safe. That path is gated on the Phase-2 wallet spike (see the README) — until
then merging is skipped (logged), and inventory is exited via limit sells
instead. The bot is fully functional without it; merging just frees capital
sooner.
+1 -1
View File
@@ -1,4 +1,4 @@
"""RiskManager: pre-trade gates and circuit breakers (docs 04 §6, 02).
"""RiskManager: pre-trade gates and circuit breakers (see the README).
Consulted by the engine before every quote set. Returns a per-market decision
(size scale / reduce-only / halt) and owns the global kill switches. Position
+1 -1
View File
@@ -1,7 +1,7 @@
"""StateStore: the single owner of positions and open orders.
Replaces v1's module-level global dicts + the `performing`/`last_trade_update`
races. Three inputs, one arbitration rule (docs/scoping/02-architecture.md):
races. Three inputs, one arbitration rule (the README):
* WS fill events apply immediately (optimistic),
* REST reconciliation corrects drift ONLY for tokens with no in-flight trades,
+1 -1
View File
@@ -2,7 +2,7 @@
Consumes *normalized* user-stream events (the wire-format extraction lives in
userstream/, so this is unit-testable with synthetic events) and drives the
state machine from docs/scoping/02-architecture.md:
state machine from the README:
Trade: MATCHED -> MINED -> CONFIRMED
-> FAILED (roll back the optimistic fill, reconcile)
+1 -1
View File
@@ -3,7 +3,7 @@
This is the deterministic core of the strategy. No I/O, no wall-clock reads
except values passed in. Everything here is exercised directly by unit tests.
Model (see docs/scoping/04-strategy.md):
Model (see the README):
reservation r = FV - skew(inventory)
half-spread δ = base + c_vol·σ + c_tox·toxicity (clamped to reward band in QUIET)
YES entry bid = r - δ (BUY YES, USDC-collateralized)
+1 -1
View File
@@ -1,4 +1,4 @@
"""Per-market regime decision (see docs/scoping/04-strategy.md §5).
"""Per-market regime decision (see the README).
Priority order, highest first:
HALTED kill switch / stale data / resolved / past halt-before window
+1 -1
View File
@@ -8,7 +8,7 @@ always the maker):
* maker & taker on DIFFERENT outcomes -> a mint: we BUY the opposite token
NOTE: exact field names must be reconfirmed in the Phase-2 wallet spike
(docs/scoping/03-api-layer.md §9); this is coded to the v1-observed shape.
(the README); this is coded to the v1-observed shape.
"""
from __future__ import annotations