Files
proxmox/docs/03-deployment/RECOMMENDATIONS_AND_FIXES_BEFORE_DEPLOY.md
defiQUG b3a8fe4496
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
chore: sync all changes to Gitea
- Config, docs, scripts, and backup manifests
- Submodule refs unchanged (m = modified content in submodules)

Made-with: Cursor
2026-03-02 11:37:34 -08:00

142 lines
11 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Recommendations and Fixes Before Deploying Smart Contracts and PMM Pools
**Last Updated:** 2026-02-27
**Purpose:** Single checklist of all **recommendations** and **required fixes** to complete before deploying smart contracts and PMM pools on Chain 138 (and related chains). Use this with [DEPLOYMENT_ORDER_OF_OPERATIONS.md](DEPLOYMENT_ORDER_OF_OPERATIONS.md) and [PRE_DEPLOYMENT_CHECKLIST.md](PRE_DEPLOYMENT_CHECKLIST.md).
**Related:** [TODOS_CONSOLIDATED](../00-meta/TODOS_CONSOLIDATED.md) § First (0a0c) | [CONTRACT_DEPLOYMENT_RUNBOOK.md](CONTRACT_DEPLOYMENT_RUNBOOK.md) | [RECOMMENDATIONS_OPERATOR_CHECKLIST](../00-meta/RECOMMENDATIONS_OPERATOR_CHECKLIST.md)
**Run all checkable items:** `./scripts/deployment/run-before-deploy-checks.sh` ([§7](#7-run-all-checkable-items-one-script)).
---
## 1. Mandatory fixes and checks (do first)
These must be satisfied before **any** Chain 138 deployment. Run preflight once; repeat if RPC, env, or nonce change.
| # | Item | Action / fix |
|---|------|--------------|
| **1.1** | **Run preflight** | From repo root: `./scripts/deployment/preflight-chain138-deploy.sh [--cost]`. Verifies: dotenv exists, required env keys, RPC returns chainId 0x8a (138), deployer nonce (warns if stuck). Use `--cost` for gas/cost estimate. |
| **1.2** | **Core RPC = IP:port, not FQDN** | In `smom-dbis-138/.env` set `RPC_URL_138=http://192.168.11.211:8545` (Core RPC, VMID 2101). Do **not** use `https://rpc-core.d-bis.org` for deployment (DNS/tunnel can fail). See [RPC_ENDPOINTS_MASTER](../04-configuration/RPC_ENDPOINTS_MASTER.md), [TODOS_CONSOLIDATED](../00-meta/TODOS_CONSOLIDATED.md) § 0b. |
| **1.3** | **Deployer gas (Chain 138)** | Ensure deployer has ≥ ~0.006 ETH (recommended 12 ETH). Check: `RPC_URL_138=http://192.168.11.211:8545 ./scripts/deployment/check-deployer-balance-chain138-and-funding-plan.sh` or `cd smom-dbis-138 && ./scripts/deployment/check-balances-gas-and-deploy.sh`. |
| **1.4** | **Env from smom-dbis-138/.env only** | All deploy secrets from **`smom-dbis-138/.env`** only. Required: `PRIVATE_KEY`, `RPC_URL_138`. For PMM: `DODO_PMM_INTEGRATION_ADDRESS=0x79cdbaFBaA0FdF9F55D26F360F54cddE5c743F7D`. Optional: `GAS_PRICE_138`, `GAS_PRICE` (default 1 gwei). Verify: `cd smom-dbis-138 && ./scripts/deployment/check-env-required.sh`. |
| **1.5** | **No stuck transactions** | If nonce has pending txs or you see "Replacement transaction underpriced": run `./scripts/clear-all-transaction-pools.sh` then wait **~60s** before deploying. Prefer scripts that check nonce (e.g. `deploy-transaction-mirror-and-pmm-pool-after-txpool-clear.sh`). |
| **1.6** | **RPC 2101 (Core) writable** | If Core was read-only: `./scripts/maintenance/make-rpc-vmids-writable-via-ssh.sh` then `./scripts/maintenance/health-check-rpc-2101.sh`. See [RPC_2101_READONLY_FIX.md](RPC_2101_READONLY_FIX.md). |
| **1.7** | **Test all contracts** | Run **before** any deploy: `./scripts/deployment/test-all-contracts-before-deploy.sh`. Use `--dry-run` to print commands; `--no-match "Fork|Mainnet|Integration|e2e"` for unit-only; `--alltra` to include alltra-lifi-settlement. See [DEPLOYMENT_ORDER_OF_OPERATIONS](DEPLOYMENT_ORDER_OF_OPERATIONS.md) § Phase 0.8. |
| **1.8** | **Gas / cost estimate** | Before deploying: `cd smom-dbis-138 && ./scripts/deployment/calculate-costs-consolidated.sh` (Chain 138 min gas 1 gwei). See [DEPLOYMENT_GAS_COSTS_REALTIME](../11-references/DEPLOYMENT_GAS_COSTS_REALTIME.md). |
| **1.9** | **POOL_MANAGER_ROLE** | Deployer must have `POOL_MANAGER_ROLE` on DODOPMMIntegration for pool creation and DODOPMMProvider registration. |
| **1.10** | **Foundry** | `forge` in PATH; `cd smom-dbis-138 && forge build` succeeds. |
---
## 2. Deployment safety (four rules)
| Rule | Requirement |
|------|-------------|
| **Correct RPC** | Use **only** `RPC_URL_138` from `smom-dbis-138/.env` for deployments. Must point to **Core RPC** (VMID 2101, `http://192.168.11.211:8545`). Never use Public RPC for deploying. |
| **Correct dotenv** | All deployment secrets from **`smom-dbis-138/.env`** only. Do not source a different .env for deploy. |
| **Gas / cost** | Run gas/cost estimation before deploying (e.g. `calculate-costs-consolidated.sh`). Chain 138 minimum gas 1 gwei. |
| **Do not deploy when stuck** | Clear tx pool, wait ~60s; use scripts that check nonce when available. |
---
## 3. Identified gaps to fix or confirm before deploy
| Gap | Location / scope | Fix / action |
|-----|------------------|--------------|
| **Wemix (1111) token addresses** | config/token-mapping-multichain.json | Confirm WETH, USDT, USDC on [scan.wemix.com/tokens](https://scan.wemix.com/tokens); update config and WEMIX_TOKEN_VERIFICATION.md if different; run `validate-config-files.sh`. |
| **Canonical addresses** | token-aggregation, .env | Canonical token addresses (e.g. CUSDC_ADDRESS_138, CUSDT_ADDRESS_138) in env or smart-contracts-master.json; token-aggregation uses env override. See [REQUIRED_FIXES_UPDATES_GAPS](../REQUIRED_FIXES_UPDATES_GAPS.md) §3. |
| **AlltraAdapter setBridgeFee** | AlltraAdapter.sol | Fee configurable via `setBridgeFee(uint256)`; operator calls after deploy. Set `ALLTRA_BRIDGE_FEE`, `ALLTRA_ADAPTER_CHAIN138` in .env. |
| **Smart accounts / Paymaster** | DeploySmartAccountsKit | Script reads `ENTRY_POINT`, `SMART_ACCOUNT_FACTORY`, `PAYMASTER` from env. Deploy ERC-4337 contracts separately and set in .env. |
| **Quote service FABRIC_CHAIN_ID** | bridge/quote-service | Uses `FABRIC_CHAIN_ID` from env (default 999). Set when Fabric is live. |
| **CCIPWETH9Bridge** | Env / runbook | Use only canonical bridge (e.g. `0x971c...`); do **not** use deprecated `0x89dd...`. Set `CCIPWETH9_BRIDGE_CHAIN138` in env. See RECOMMENDATIONS_OPERATOR_CHECKLIST R4. |
| **Token mapping** | config/token-mapping.json | Single source of truth for 138↔Mainnet; when adding tokens update token-mapping.json and optionally CHAIN138_TOKEN_ADDRESSES. R24. |
---
## 4. Token deployments remaining (prerequisites for full token/PMM coverage)
If you plan to deploy **additional** tokens or vaults after core + PMM, ensure prerequisites and order. Full list: [TOKEN_CONTRACT_DEPLOYMENTS_REMAINING](../11-references/TOKEN_CONTRACT_DEPLOYMENTS_REMAINING.md).
| Category | Prerequisite | Notes |
|----------|-------------|--------|
| **DeployCompliantFiatTokens (cEURC, cEURT, cGBP*, cAUD*, cJPY*, cCHF*, cCADC, cXAU*)** | `CREATE2_FACTORY_ADDRESS` (e.g. from DeployDeterministicCore) | Use Core RPC (IP:port). After deploy: update CHAIN138_TOKEN_ADDRESSES and env. |
| **Optional cCADT** | Add to DeployCompliantFiatTokens.s.sol if needed | Tether-style CAD. |
| **Vault ac* / vdc* / sdc*** | Base tokens deployed (e.g. cUSDC, cUSDT, then extra compliant) | DeployAcVdcSdcVaults; extend for each new base. |
| **cW* on public chains** | Per-chain RPC, bridge, pool-matrix | Design in POOLS_AND_NETWORKS_FULL_DESIGN; pool-matrix in cross-chain-pmm-lps. |
| **ACADT / ALL Mainnet** | Alltra ecosystem | No script in repo; address TBD when Alltra adds CAD token. |
---
## 5. PMM-specific: before adding liquidity and provider
| # | Item | Action |
|---|------|--------|
| 5.1 | **DODOPMMIntegration** | Already deployed: `0x79cdbaFBaA0FdF9F55D26F360F54cddE5c743F7D`. Ensure `DODO_PMM_INTEGRATION_ADDRESS` set in .env. |
| 5.2 | **PMM pools (all three)** | cUSDT/cUSDC, cUSDT/USDT, cUSDC/USDC must be **created** (CreateCUSDTCUSDCPool, CreateCUSDTUSDTPool, CreateCUSDCUSDCPool). Use Core RPC only. |
| 5.3 | **DODOPMMProvider** | Deploy via DeployDODOPMMProvider.s.sol; set `DODO_PMM_PROVIDER_ADDRESS` in .env. Register each pool: `provider.registerPool(tokenIn, tokenOut, poolAddress)`. |
| 5.4 | **Liquidity (optional)** | Per pool: approve base/quote to DODOPMMIntegration, then `addLiquidity(pool, baseAmount, quoteAmount)`. See [DODO_PMM_INTEGRATION](../../smom-dbis-138/docs/integration/DODO_PMM_INTEGRATION.md). |
| 5.5 | **Token-aggregation** | Set `CHAIN_138_DODO_PMM_INTEGRATION` where token-aggregation runs so API indexes DODO pools. |
---
## 6. Operator recommendations (R1R24) — before and after deploy
**Before deploy:** R8 (RPC Core), R9 (gas 1 gwei), R10 (phased core order), R11 (nonce if stuck), R19 (forge test).
**After deploy:** R1 (verify on Blockscout), R2 (update CONTRACT_ADDRESSES_REFERENCE, ADDRESS_MATRIX_AND_STATUS), R3 (run check-contracts-on-chain-138.sh), R12R13 (runbooks and per-chain docs).
**Security:** R4 (canonical CCIPWETH9Bridge only), R5 (never commit .env/keys), R7 (restrict deployer and RPC access).
**Ongoing:** R17 (monitor bridge/oracle events), R18 (Blockscout and /api up), R24 (token-mapping.json source of truth).
Full list: [RECOMMENDATIONS_OPERATOR_CHECKLIST](../00-meta/RECOMMENDATIONS_OPERATOR_CHECKLIST.md).
---
## 7. Run all checkable items (one script)
From repo root, run every check that can be automated (preflight, env, forge build, contract tests, config validation). Optionally include gas estimate, alltra e2e, and on-chain verification.
```bash
# All checkable items (unit tests only; ~12 min)
./scripts/deployment/run-before-deploy-checks.sh
# With gas/cost estimate
./scripts/deployment/run-before-deploy-checks.sh --cost
# With alltra-lifi-settlement tests (longer)
./scripts/deployment/run-before-deploy-checks.sh --alltra
# With on-chain verification (Chain 138)
./scripts/deployment/run-before-deploy-checks.sh --on-chain
```
The script reports **PASS** or **FAIL** per step and exits 0 only if all steps pass. Remaining items (deployer gas, POOL_MANAGER_ROLE, RPC writable if needed) require operator/LAN; see §1 and §2.
---
## 8. Quick command reference
| Action | Command |
|--------|---------|
| Preflight (RPC, env, nonce, optional cost) | `./scripts/deployment/preflight-chain138-deploy.sh [--cost]` |
| Deployer balance / funding plan (Chain 138) | `RPC_URL_138=http://192.168.11.211:8545 ./scripts/deployment/check-deployer-balance-chain138-and-funding-plan.sh` |
| Env check (smom-dbis-138) | `cd smom-dbis-138 && ./scripts/deployment/check-env-required.sh` |
| Test all contracts | `./scripts/deployment/test-all-contracts-before-deploy.sh` (options: `--dry-run`, `--no-match "Fork|Mainnet|Integration|e2e"`, `--alltra`) |
| Gas/cost estimate | `cd smom-dbis-138 && ./scripts/deployment/calculate-costs-consolidated.sh` |
| Clear stuck tx pool | `./scripts/clear-all-transaction-pools.sh` then wait ~60s |
| On-chain verification (Chain 138) | `./scripts/verify/check-contracts-on-chain-138.sh [RPC_URL]` |
| Config validation | `bash scripts/validation/validate-config-files.sh` |
---
## 9. References
- [DEPLOYMENT_ORDER_OF_OPERATIONS.md](DEPLOYMENT_ORDER_OF_OPERATIONS.md) — Phase 06 full order
- [PRE_DEPLOYMENT_CHECKLIST.md](PRE_DEPLOYMENT_CHECKLIST.md) — PMM/pools steps and script reference
- [CONTRACT_DEPLOYMENT_RUNBOOK.md](CONTRACT_DEPLOYMENT_RUNBOOK.md) — Per-script detail and test-before-deploy
- [TODOS_CONSOLIDATED](../00-meta/TODOS_CONSOLIDATED.md) — First (0a0c), token deployments (T1T7), high/medium priority
- [REQUIRED_FIXES_UPDATES_GAPS](../REQUIRED_FIXES_UPDATES_GAPS.md) — Build/code placeholders and gaps (all done or documented)
- [TOKEN_CONTRACT_DEPLOYMENTS_REMAINING](../11-references/TOKEN_CONTRACT_DEPLOYMENTS_REMAINING.md) — Remaining token deployments by category
- [OPERATOR_READY_CHECKLIST](../00-meta/OPERATOR_READY_CHECKLIST.md) — Copy-paste commands for operator/LAN tasks