Files
proxmox/scripts/lib/promod_uniswap_v2_phase1_funding_actions.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

203 lines
7.6 KiB
Python

#!/usr/bin/env python3
from __future__ import annotations
import json
import time
from decimal import Decimal
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
FUNDING = ROOT / "reports" / "extraction" / "promod-uniswap-v2-phase1-funding-bundle-latest.json"
REPORT = ROOT / "reports" / "extraction" / "promod-uniswap-v2-phase1-funding-actions-latest.json"
DOC = ROOT / "docs" / "03-deployment" / "PROMOD_UNISWAP_V2_PHASE1_FUNDING_ACTIONS.md"
CHAIN_SUFFIX = {
1: "MAINNET",
10: "OPTIMISM",
25: "CRONOS",
56: "BSC",
100: "GNOSIS",
137: "POLYGON",
8453: "BASE",
42161: "ARBITRUM",
42220: "CELO",
43114: "AVALANCHE",
}
RPC_ENV = {
1: "ETHEREUM_MAINNET_RPC",
10: "OPTIMISM_MAINNET_RPC",
25: "CRONOS_RPC_URL",
56: "BSC_RPC_URL",
100: "GNOSIS_MAINNET_RPC",
137: "POLYGON_MAINNET_RPC",
8453: "BASE_MAINNET_RPC",
42161: "ARBITRUM_MAINNET_RPC",
42220: "CELO_MAINNET_RPC",
43114: "AVALANCHE_RPC_URL",
}
def now() -> str:
return time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
def load(path: Path):
return json.loads(path.read_text())
def write_json(path: Path, payload) -> None:
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(json.dumps(payload, indent=2) + "\n")
def write_text(path: Path, text: str) -> None:
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(text.rstrip() + "\n")
def mint_block(chain_id: int, token_symbol: str, token_address: str, amount_raw: int) -> str:
rpc_var = RPC_ENV[chain_id]
lines = [
"source smom-dbis-138/scripts/load-env.sh >/dev/null",
f'cast send "{token_address}" \'mint(address,uint256)\' "$(cast wallet address --private-key "$PRIVATE_KEY")" "{amount_raw}" \\',
f' --rpc-url "${{{rpc_var}}}" --private-key "$PRIVATE_KEY" --legacy --gas-limit 100000',
]
return "\n".join(lines)
def gas_topup_note(chain_id: int) -> str:
if chain_id == 10:
return "Top up native gas on Optimism before minting or seeding; current balance is below the 0.001 safety threshold."
if chain_id == 8453:
return "Top up native gas on Base before minting or seeding; current balance is below the 0.001 safety threshold."
return "No minimum gas top-up issue from the latest preflight snapshot."
def bridge_note(chain_id: int) -> str:
suffix = CHAIN_SUFFIX[chain_id]
return (
f"Bridge path is structurally available for chain `{chain_id}` via `CW_BRIDGE_{suffix}` and `bridgeAvailable=true`, "
"but the repo-native executable path today is destination-side cW minting. Cross-chain c* -> cW delivery still follows "
"`docs/07-ccip/CW_DEPLOY_AND_WIRE_RUNBOOK.md` and `docs/07-ccip/CW_BRIDGE_APPROACH.md` rather than a single helper script."
)
def main() -> None:
bundle = load(FUNDING)
entries = []
for entry in bundle["entries"]:
chain_id = entry["chain_id"]
tokens_missing = entry["tokens_missing"]
max_seed = Decimal(entry["max_equal_seed_human"])
if entry["funding_ready_now"]:
action = "seed_now"
recommended_seed_human = str(max_seed)
mint_steps = []
else:
if chain_id == 43114 and tokens_missing == ["cWUSDC"]:
action = "mint_missing_side_then_seed"
recommended_seed_human = "0.8"
mint_steps = [
{
"token": "cWUSDC",
"amount_human": "0.8",
"amount_raw": 800000,
"exact_mint_block": mint_block(chain_id, "cWUSDC", entry["token_addresses"]["cWUSDC"], 800000),
}
]
else:
action = "mint_destination_then_seed"
recommended_seed_human = "1000"
mint_steps = []
for token in tokens_missing:
mint_steps.append(
{
"token": token,
"amount_human": "1000",
"amount_raw": 1000000000,
"exact_mint_block": mint_block(chain_id, token, entry["token_addresses"][token], 1000000000),
}
)
entries.append(
{
"chain_id": chain_id,
"network": entry["network"],
"phase_1_pair": entry["phase_1_pair"],
"action_type": action,
"tokens_missing": tokens_missing,
"minimum_gas_issue": entry["minimum_gas_issue"],
"gas_topup_note": gas_topup_note(chain_id),
"recommended_seed_human": recommended_seed_human,
"bridge_possible": True,
"bridge_note": bridge_note(chain_id),
"mint_steps": mint_steps,
"exact_post_funding_deploy_block": entry["exact_post_funding_deploy_block"],
}
)
payload = {
"generated_at": now(),
"program_name": "Mr. Promod Uniswap V2 phase 1 funding actions",
"purpose": "Strict phase-1 funding actions: seed-now, mint-then-seed, and bridge-possible notes for each target chain.",
"signer": bundle["signer"],
"entries": entries,
"source_artifacts": [
"reports/extraction/promod-uniswap-v2-phase1-funding-bundle-latest.json",
"docs/07-ccip/CW_DEPLOY_AND_WIRE_RUNBOOK.md",
"docs/07-ccip/CW_BRIDGE_APPROACH.md",
],
}
write_json(REPORT, payload)
lines = [
"# Mr. Promod Uniswap V2 Phase 1 Funding Actions",
"",
f"- Generated: `{payload['generated_at']}`",
f"- Signer: `{payload['signer']}`",
"- Purpose: strict per-chain action plan for phase-1 funding and deployment.",
"",
"| Chain | Network | Action | Tokens Missing | Gas Issue | Recommended Seed |",
"|---|---|---|---|---|---:|",
]
for entry in entries:
missing = ", ".join(f"`{t}`" for t in entry["tokens_missing"]) or "`none`"
lines.append(
f"| `{entry['chain_id']}` | {entry['network']} | `{entry['action_type']}` | {missing} | "
f"`{str(entry['minimum_gas_issue']).lower()}` | `{entry['recommended_seed_human']}` |"
)
lines.extend(["", "## Per-Chain Actions", ""])
for entry in entries:
lines.append(f"### Chain `{entry['chain_id']}` — {entry['network']}")
lines.append("")
lines.append(f"- Action: `{entry['action_type']}`")
lines.append(f"- Tokens missing: {', '.join(f'`{t}`' for t in entry['tokens_missing']) or '`none`'}")
lines.append(f"- Gas issue: `{str(entry['minimum_gas_issue']).lower()}`")
lines.append(f"- Gas note: {entry['gas_topup_note']}")
lines.append(f"- Bridge possible: `{str(entry['bridge_possible']).lower()}`")
lines.append(f"- Bridge note: {entry['bridge_note']}")
lines.append("")
if entry["mint_steps"]:
lines.append("Mint steps:")
for step in entry["mint_steps"]:
lines.append(f"- Mint `{step['token']}` `{step['amount_human']}` with:")
lines.append("```bash")
lines.append(step["exact_mint_block"])
lines.append("```")
if entry["exact_post_funding_deploy_block"]:
lines.append("Post-funding deploy block:")
lines.append("```bash")
lines.append(entry["exact_post_funding_deploy_block"])
lines.append("```")
lines.append("")
write_text(DOC, "\n".join(lines))
print(REPORT)
if __name__ == "__main__":
main()