feat: restore operator WIP — PMM JSON sync entrypoint, dotenv RPC trim + secrets, pool env alignment

- Resolve stash: merge load_deployment_env path with secure-secrets and CR/LF RPC strip
- create-pmm-full-mesh-chain138.sh delegates to sync-chain138-pmm-pools-from-json.sh
- env.additions.example: canonical PMM pool defaults (cUSDT/USDT per crosscheck)
- Include Chain138 scripts, official mirror deploy scaffolding, and prior staged changes

Made-with: Cursor
This commit is contained in:
defiQUG
2026-03-27 19:02:30 -07:00
parent c6e7bad15e
commit 2a4753eb2d
200 changed files with 5987 additions and 913 deletions

View File

@@ -12,6 +12,8 @@ Set in project `.env` (and in token-aggregation or relay when they consume oracl
|----------|-------------|
| `ORACLE_AGGREGATOR_ADDRESS` | Oracle aggregator contract on Chain 138 (e.g. from deployment). Used by CCIP and other consumers. |
| `ORACLE_PROXY_ADDRESS` | Oracle proxy contract on Chain 138 when applicable. |
| `ORACLE_PRICE_FEED` | **OraclePriceFeed** wired to **PriceFeedKeeper** and **ReserveSystem** — not the same as `ORACLE_PROXY_ADDRESS`. |
| `CHAIN138_WETH_MOCK_PRICE_FEED` | Optional **MockPriceFeed** for WETH on the keeper path when Besu block time lags the public aggregator `updatedAt`. Sync: `scripts/reserve/sync-weth-mock-price.sh`. |
| `RESERVE_SYSTEM` | ReserveSystem address (Chain 138). Required for DODOPMMIntegration oracle-backed mid price. |
| `RPC_URL_138` / `RPC_URL` | RPC endpoint for Chain 138 (keeper and scripts). |
@@ -38,10 +40,37 @@ References: [DEPLOYMENT_COMPLETE_GUIDE.md](../deployment/DEPLOYMENT_COMPLETE_GUI
4. **Update oracle price script**
One-off or cron-driven update of oracle/oracle proxy with current price:
- `scripts/update-oracle-price.sh` — usage: `[rpc-url] [oracle-address] [private-key]`; uses `AGGREGATOR_ADDRESS` and fetches ETH/USD from CoinGecko.
**CoinGecko Demo keys** (`CG-…`): use `https://api.coingecko.com` with header `x-cg-demo-api-key` (not `pro-api.coingecko.com` with `x-cg-pro-api-key`). Paid Pro uses the pro host and pro header; the script tries demo first, then pro, then unauthenticated public.
Schedule this (or the keeper service) so PMM oracle-backed prices and reporting stay fresh.
---
## PMM mesh automation (6-second tick)
**Policy:** Run off-chain ticks every **6 seconds** so oracle pushes, `PriceFeedKeeper` upkeep, and PMM/WETH read paths stay warm—supporting peg alignment with `DODOPMMIntegration` / optional `ReserveSystem`.
| Component | Role |
|-----------|------|
| `scripts/reserve/pmm-mesh-6s-automation.sh` | Loop: `getPoolPriceOrOracle` on `PMM_MESH_POLL_POOLS`, WETH9/WETH10 `totalSupply` reads, conditional `performUpkeep`, `update-oracle-price.sh`. |
| `PMM_MESH_INTERVAL_SEC` | Default **6**. |
| `PriceFeedKeeper.updateInterval` | Default on **new** deployments is **6s** (`PriceFeedKeeper.sol`). **Existing** keepers: run `scripts/reserve/set-price-feed-keeper-interval.sh 6` as admin. |
| `KEEPER_PRIVATE_KEY` | Wallet with **KEEPER_ROLE** on `PriceFeedKeeper` for `performUpkeep` txs. |
| `MESH_WETH_WRAP_WEI` | Optional tiny `WETH.deposit{value}` on a throttled cadence (`MESH_WETH_WRAP_EVERY_N`); costs gas—default **0** (off). |
**systemd:** `config/systemd/chain138-pmm-mesh-automation.service.example` in the Proxmox repo—copy, fix paths, `enable --now`.
**Bring-up checklist (operator):**
1. `PRICE_FEED_KEEPER_ADDRESS` in `smom-dbis-138/.env` (Chain 138: `0xD3AD6831aacB5386B8A25BB8D8176a6C8a026f04` per explorer docs—verify live).
2. `KEEPER_PRIVATE_KEY` optional if same as `PRIVATE_KEY` (must have `KEEPER_ROLE` on the keeper).
3. `./scripts/reserve/set-price-feed-keeper-interval.sh 6` once if the keeper still used a 30s interval.
4. Oracle: `scripts/update-oracle-price.sh` needs Besu-safe paths (eth_call + explicit `--gas-limit`); set `AGGREGATOR_ADDRESS` / transmitter as deployed.
5. If the keeper uses a **WETH MockPriceFeed** (`CHAIN138_WETH_MOCK_PRICE_FEED`), run `scripts/reserve/sync-weth-mock-price.sh` on a schedule (or from the same cron as the mesh) so ReserveSystem WETH tracks the market.
6. Start: `nohup ./scripts/reserve/pmm-mesh-6s-automation.sh >> logs/pmm-mesh-automation.log 2>&1 &` (optional: `MESH_CAST_GAS_PRICE=2gwei` for Besu)
**Note:** On-chain PMM curves still move on **swaps**; this loop **does not** replace liquidity. It **feeds** oracles/keeper and **observes** PMM/WETH state on a fixed cadence.
---
## PMM and Reporting
- **DODOPMMIntegration**: Optional `setReserveSystem(ReserveSystem)`; then `getPoolPriceOrOracle(pool)` uses ReserveSystem when base/quote are registered.