Add cW M1 PMM stabilization mesh: docs, config, spec, peg bands, pool matrix
Made-with: Cursor
This commit is contained in:
37
spec/bot-pseudo-code.md
Normal file
37
spec/bot-pseudo-code.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# Bot Pseudo-Code (Watcher + Rebalance)
|
||||
|
||||
## Per-pool loop (v1)
|
||||
|
||||
```
|
||||
for each pool (cW* / quote):
|
||||
P_oracle = getOraclePrice(T)
|
||||
P_pool = getPoolMidPrice(T)
|
||||
δ = (P_pool - P_oracle) / P_oracle
|
||||
inv = getInventoryImbalance(T)
|
||||
|
||||
if |δ| > circuitBreakBps:
|
||||
setState(CIRCUIT_BREAK)
|
||||
continue
|
||||
|
||||
if inCooldown(pool):
|
||||
continue
|
||||
|
||||
if δ > normalBandBps:
|
||||
sell T into pool (size within budget)
|
||||
setCooldown(pool)
|
||||
else if δ < -normalBandBps:
|
||||
buy T from pool (size within budget)
|
||||
setCooldown(pool)
|
||||
|
||||
if inv outside threshold:
|
||||
schedule inventory re-center (add/remove single-sided T, or bridge)
|
||||
```
|
||||
|
||||
## v2 additions
|
||||
|
||||
- **Route selection**: Among pools for same T (e.g. T/USDC, T/USDT, T/DAI), choose edge with lowest slippage + fee; execute there; optionally rebalance quote via DEX.
|
||||
- **Bridge throttle**: If bridge backlog or risk flag, widen bands or skip trade.
|
||||
- **Global budget**: Before any trade, check per-token trade budget for current window; skip if exhausted.
|
||||
- **Min improvement**: Only trade if expected |δ| improvement net of fees ≥ minImprovementBps.
|
||||
|
||||
Thresholds and bands from [../config/peg-bands.json](../config/peg-bands.json). Mesh reflexivity from [../docs/07-mesh-reflexivity.md](../docs/07-mesh-reflexivity.md).
|
||||
Reference in New Issue
Block a user