Files
proxmox/scripts/lib/source_to_cex_execution_plan.py
defiQUG 4fab998e51
All checks were successful
Deploy to Phoenix / deploy (push) Successful in 9s
chore: sync workspace docs, configs, and submodules
2026-04-18 12:07:15 -07:00

64 lines
6.0 KiB
Python

#!/usr/bin/env python3
from pathlib import Path
import json, time
ROOT = Path(__file__).resolve().parents[2]
REPORTS = ROOT / "reports" / "extraction"
DOCS = ROOT / "docs" / "03-deployment"
CONFIG = ROOT / "config" / "extraction"
def load(p): return json.loads(p.read_text())
def write(p, data): p.parent.mkdir(parents=True, exist_ok=True); p.write_text(json.dumps(data, indent=2)+"\n")
def write_text(p, text): p.parent.mkdir(parents=True, exist_ok=True); p.write_text(text.rstrip()+"\n")
def now(): return time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
review = load(REPORTS / "immediate-and-same-day-corridor-assets-latest.json")
strict = load(REPORTS / "strict-operator-public-liquidity-table-latest.json")
inv = load(CONFIG / "additional-wallet-inventory.json")
policy = load(CONFIG / "source-to-cex-production-policy.json")
sinks = [a for a in inv.get("offchain_accounts", []) if a.get("include_in_baseline")]
payload = {
"generated_at": now(),
"strategy_frame": policy["default_route_model"],
"operator_rule": "treat on-chain Mainnet cW/canonical pools as bounded conversion handshakes before external execution",
"production_enabled": policy.get("production_enabled", False),
"mainnet_funding_posture": {
"mode": "dual-rail",
"required_deployer_assets": ["cWUSDC", "cWUSDT"],
"primary_normalization_rail": "cWUSDC -> USDC",
"support_normalization_rail": "cWUSDT -> cWUSDC -> USDC",
"preferred_final_settlement_asset": "USDC",
"notes": [
"The deployer wallet should maintain both Mainnet wrapped stables.",
"This dual-rail funding posture supports both the primary USDC settlement path and the cUSDT support rail."
]
},
"source_bucket_totals_usd": review["bucket_subtotals_usd"],
"source_bucket_counts": review["bucket_counts"],
"production_sinks": sinks,
"entries": [
{"source_asset":"cUSDC","source_location":"Chain 138","source_bucket":"same_day_corridor","bridge_output":"cWUSDC on Ethereum Mainnet","preferred_normalization":"cWUSDC -> USDC","aggregator_decision_set":["direct cWUSDC -> USDC","independent USDC sink if live","RFQ wrapped-to-USDC if available"],"preferred_cex_deposit_asset":"USDC","fallback_path":"bridge cUSDC -> cWUSDC, then use best available Mainnet USDC normalization route with capped public-pool usage","execution_model":"bridge first, normalize on Mainnet, then deposit USDC to CEX"},
{"source_asset":"cUSDT","source_location":"Chain 138","source_bucket":"same_day_corridor","bridge_output":"cWUSDT on Ethereum Mainnet","preferred_normalization":"cWUSDT -> cWUSDC -> USDC","aggregator_decision_set":["direct cWUSDT -> USDT","cWUSDT -> cWUSDC -> USDC","RFQ wrapped-to-stable conversion if available"],"preferred_cex_deposit_asset":"USDC","fallback_path":"use direct cWUSDT -> USDT only for tiny packets or explicit override; otherwise route through USDC normalization","execution_model":"bridge first, compare direct USDT vs USDC-normalization path on Mainnet, then deposit the settlement stable to CEX"},
{"source_asset":"LP:cUSDT/cUSDC","source_location":"Chain 138","source_bucket":"same_day_corridor","bridge_output":"cUSDT and cUSDC after LP withdrawal","preferred_normalization":"withdraw LP -> prefer cUSDC feeder -> bridge -> cWUSDC -> USDC","aggregator_decision_set":["post-withdrawal normalization","direct cWUSDC -> USDC","cWUSDT -> cWUSDC -> USDC if needed"],"preferred_cex_deposit_asset":"USDC","fallback_path":"withdraw LP, split outputs by best feeder path, avoid forcing whole ticket through direct USDT sink","execution_model":"LP unwind is feeder preparation, not terminal execution"},
{"source_asset":"cWUSDC","source_location":"Ethereum Mainnet","source_bucket":"immediate","bridge_output":"none","preferred_normalization":"cWUSDC -> USDC","aggregator_decision_set":["direct cWUSDC -> USDC","alternative independent USDC sinks","RFQ wrapped-to-USDC conversion"],"preferred_cex_deposit_asset":"USDC","fallback_path":"split size, cap pool usage, treat on-chain conversion strictly as deposit preparation","execution_model":"same-hour handshake into USDC, then immediate CEX handoff"},
{"source_asset":"cWUSDT","source_location":"Ethereum Mainnet","source_bucket":"immediate","bridge_output":"none","preferred_normalization":"cWUSDT -> cWUSDC -> USDC","aggregator_decision_set":["direct cWUSDT -> USDT","cWUSDT -> cWUSDC -> USDC","RFQ wrapped-to-stable conversion"],"preferred_cex_deposit_asset":"USDC","fallback_path":"direct USDT path is last-resort and tiny; practical size should flow through USDC-normalization","execution_model":"same-hour normalization decision on Mainnet, then CEX handoff"}
],
"source_artifacts": [
"reports/extraction/immediate-and-same-day-corridor-assets-latest.json",
"reports/extraction/strict-operator-public-liquidity-table-latest.json",
"config/extraction/additional-wallet-inventory.json",
"config/extraction/source-to-cex-production-policy.json"
]
}
write(REPORTS / "source-to-cex-execution-plan-latest.json", payload)
lines = [
"# Source To CEX Execution Plan","",
f"- Generated: `{payload['generated_at']}`",
f"- Strategy frame: {payload['strategy_frame']}",
f"- Mainnet funding posture: `{payload['mainnet_funding_posture']['mode']}` via `{', '.join(payload['mainnet_funding_posture']['required_deployer_assets'])}`",
"","## Operator Table","","| Source Asset | Bridge Output | Preferred Normalization | CEX Deposit Asset | Fallback Path |","|---|---|---|---|---|"
]
for row in payload['entries']:
lines.append(f"| `{row['source_asset']}` | {row['bridge_output']} | {row['preferred_normalization']} | `{row['preferred_cex_deposit_asset']}` | {row['fallback_path']} |")
lines += ["","## Notes","","- `cUSDC` is the cleanest same-day corridor feeder.","- `cUSDT` should usually normalize through USDC until direct USDT depth improves.","- Stable LP claims are feeder-preparation assets.","- Mainnet `cWUSDC` and `cWUSDT` are immediate in mechanics, but not deep enough to absorb large tickets on-chain."]
write_text(DOCS / "SOURCE_TO_CEX_EXECUTION_PLAN.md", "\n".join(lines))
print(REPORTS / "source-to-cex-execution-plan-latest.json")