Files
proxmox/docs/00-meta/TASKS_ROUTING_SWAP_CROSSCHAIN.md
defiQUG dbd517b279 Sync workspace: config, docs, scripts, CI, operator rules, and submodule pointers.
- Update dbis_core, cross-chain-pmm-lps, explorer-monorepo, metamask-integration, pr-workspace/chains
- Omit embedded publish git dirs and empty placeholders from index

Made-with: Cursor
2026-04-12 06:12:20 -07:00

162 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.
# Tasks: Routing, Swapping, and Cross-Chain Ops
**Last Updated:** 2026-03-06
**Purpose:** Single list of tasks that affect **routing**, **swapping**, and **cross-chain operations** only. For the full task list see [ALL_TASKS_INCLUDING_OPTIONAL.md](ALL_TASKS_INCLUDING_OPTIONAL.md).
**Key docs:** [DEX_AND_AGGREGATORS_CHAIN138_EXPLAINER](../04-configuration/DEX_AND_AGGREGATORS_CHAIN138_EXPLAINER.md), [PMM_DEX_ROUTING_STATUS](../11-references/PMM_DEX_ROUTING_STATUS.md), [DEPLOYED_TOKENS_BRIDGES_LPS_AND_ROUTING_STATUS](../11-references/DEPLOYED_TOKENS_BRIDGES_LPS_AND_ROUTING_STATUS.md), [CONFIG_READY_CHAINS_COMPLETION_RUNBOOK](../07-ccip/CONFIG_READY_CHAINS_COMPLETION_RUNBOOK.md).
---
## 1. Current state (whats live)
| Area | Status | Notes |
|------|--------|--------|
| **Same-chain swap (138)** | ✅ Pools + API | DODO PMM: cUSDT↔cUSDC pool live; DODOPMMProvider deployed. Add liquidity blocked (deployer 0 c*/WETH). `GET /api/v1/quote` single-hop. |
| **Bridge 138 → dest** | ✅ CCIP + Alltra | WETH9/WETH10 to 1, 56, 137, 10, 42161, 43114, 8453, 100, 25, 42220 (Celo ✅); Wemix ⏳ (need 0.4 WEMIX). Alltra 138↔651940. |
| **Routing registry** | ✅ | `config/routing-registry.json` — WETH routes 138↔dest; ALT for 138↔651940. |
| **Token mapping API** | ✅ | `GET /api/v1/token-mapping`, `/resolve`; source: `config/token-mapping-multichain.json`. |
| **Bridge quote API** | Partial | `POST /api/bridge/quote` — sourceSwapQuote / destinationSwapQuote when configured. |
| **Swapbridgeswap** | Partial | QuoteService exists; SwapBridgeSwapCoordinator deployable; destination DEX/aggregator not wired per chain. |
| **cW* edge pools** | ❌ | cW* token addresses and bridge availability exist on active chains, but PMM pool arrays are still empty; no public-chain cW* edge pools are live yet. |
| **N-hop / multi-provider** | ✅ Partial | `EnhancedSwapRouterV2` plus funded pilot-compatible `Uniswap_v3`, `Balancer`, `Curve_3`, and `1inch` venues are live on Chain 138; public planner resolves the canonical `WETH -> USDT` lane. Broader N-hop expansion remains optional future work. |
---
## 2. Same-chain routing & swap (Chain 138)
### 2.1 Prerequisites for swap execution
| # | Task | Command / doc |
|---|------|----------------|
| A1 | Add liquidity to PMM pools (cUSDT/cUSDC first) | Fund deployer with cUSDT/cUSDC/WETH (or mint); [ADD_LIQUIDITY_PMM_CHAIN138_RUNBOOK](../03-deployment/ADD_LIQUIDITY_PMM_CHAIN138_RUNBOOK.md); `mint-for-liquidity.sh --add-liquidity` |
| A2 | Ensure token-aggregation indexes DODO on 138 | Set `CHAIN_138_DODO_PMM_INTEGRATION` in env; indexer running so `GET /api/v1/quote` returns DODO quotes. |
| A3 | Expose token-aggregation API for dApps/Snap | Proxy `/api/v1/*` (e.g. explorer.d-bis.org) to token-aggregation; or `GATSBY_SNAP_API_BASE_URL`. |
### 2.2 Optional (same-chain)
| # | Task | Notes |
|---|------|--------|
| A4 | Keep router-v2 and the pilot venue layer verified on 138 | ✅ Live. Use `bash scripts/verify/check-chain138-pilot-dex-venues.sh` after venue funding, planner, or publication changes. |
| A5 | N-hop quote/pathfinding in token-aggregation | Today single-hop only; add graph A→B→C if needed. |
---
## 3. Cross-chain: bridges & routing
### 3.1 Bridge coverage (138 ↔ all 13 chains)
| # | Task | Command / doc |
|---|------|----------------|
| B1 | Cronos (25): deploy CCIP bridges + complete-config | Fund deployer ~15 CRO ([acquire-cro-and-wemix-gas.sh](../../scripts/deployment/acquire-cro-and-wemix-gas.sh)); set CRONOS_RPC, CCIP_ROUTER_CRONOS; `deploy-bridges-config-ready-chains.sh cronos`; `complete-config-ready-chains.sh`. |
| B2 | Wemix (1111): deploy CCIP bridges + complete-config | Fund deployer ~0.4 WEMIX (manual/aggregator); [WEMIX_ACQUISITION_TABLED](../03-deployment/WEMIX_ACQUISITION_TABLED.md); `deploy-bridges-config-ready-chains.sh wemix`; complete-config. |
| B3 | Fund all CCIP bridges with LINK | `./scripts/deployment/fund-ccip-bridges-with-link.sh` (dry-run first). |
| B4 | Ensure routing registry and token-mapping include new chains | Update `config/routing-registry.json` and `config/token-mapping-multichain.json` when adding Cronos/Wemix; run `validate-config-files.sh`. |
### 3.2 Token mapping & route config
| # | Task | Notes |
|---|------|--------|
| B5 | Wemix (1111) token addresses | Confirm WETH, USDT, USDC on scan.wemix.com; update token-mapping and WEMIX_TOKEN_VERIFICATION.md; validate-config-files.sh. |
| B6 | Token-aggregation: GET /api/v1/bridge/routes returns Chain 138 bridges | Set BRIDGE_LIST_JSON_URL or built-in routes; verify response has chain138Bridges. |
| B7 | Token mapping API for 138↔destination | Ensure token-mapping-multichain.json (or loader) includes 138 and all target chains for bridge UIs. |
### 3.3 Alltra (138 ↔ 651940)
| # | Task | Notes |
|---|------|--------|
| B8 | AlltraAdapter setBridgeFee | Call `setBridgeFee(uint256)` after deploy; set ALLTRA_BRIDGE_FEE, ALLTRA_ADAPTER_CHAIN138 in .env. |
---
## 4. Swapbridgeswap (full path)
### 4.1 Orchestration & quote
| # | Task | Command / doc |
|---|------|----------------|
| C1 | Complete Flow A (liquidity + quote on 138) | Prerequisite: §2.1. |
| C2 | Complete Flow B (bridge configured + LINK funded) | Prerequisite: §3.13.2. |
| C3 | POST /api/bridge/quote returns sourceSwapQuote and destinationSwapQuote | Set BRIDGE_REGISTRY_ADDRESS; optional ENHANCED_SWAP_ROUTER_ADDRESS (source), DESTINATION_RPC_URL, DESTINATION_SWAP_ROUTER_ADDRESS. [QuoteService already supports optional swap quotes.] |
| C4 | Destination-chain DEX/aggregator for destinationSwapQuote | Wire QuoteService to destination DEX or aggregator API per chain for destinationSwapQuote. |
| C5 | (Optional) Deploy SwapBridgeSwapCoordinator on-chain | One tx: swap (source) → bridge → swap (destination). [DODO_PMM_NEXT_STEPS](../../smom-dbis-138/docs/bridge/DODO_PMM_NEXT_STEPS.md). |
### 4.2 Frontend & E2E
| # | Task | Notes |
|---|------|--------|
| C6 | Frontend: wire Bridge UI to routes + token mapping | Use GET /api/v1/bridge/routes and /api/v1/token-mapping/resolve. |
| C7 | Frontend: “Get full path quote” and execute | Call POST /api/bridge/quote; show sourceSwapQuote, destinationSwapQuote; execute steps or coordinator. |
| C8 | E2E test: swap 138 → bridge → swap destination | Automated or manual; document tx hashes. |
---
## 5. Public-chain cW* and edge pools (Phase C)
Enables swapbridgeswap and arbitrage on **destination** chains via cW* tokens and PMM edge pools.
| # | Task | Command / doc |
|---|------|----------------|
| D1 | Deploy or bridge cW* tokens per chain (1, 56, 137, 10, 42161, 8453, 43114, 100, 25, 42220, 1111) | [PHASE_C_CW_AND_EDGE_POOLS_RUNBOOK](../03-deployment/PHASE_C_CW_AND_EDGE_POOLS_RUNBOOK.md); cross-chain-pmm-lps token-map and deployment recipe; record in deployment-status.json and .env. |
| D2 | Create and fund PMM edge pools (cW*/USDC, cW*/USDT) per pool-matrix | Same runbook; [pool-matrix.json](../../cross-chain-pmm-lps/config/pool-matrix.json); populate deployment-status.json with pool addresses. |
| D3 | (Optional) Stabilization bot / peg bands for cW* | cross-chain-pmm-lps. |
---
## 6. Deployer gas routing (ops)
Relevant only for **funding deployer** with native gas on each chain so bridge/deploy ops can run.
| # | Task | Command / doc |
|---|------|----------------|
| E1 | Deployer gas auto-route (Protocolink + 138 + manual) | `./scripts/deployment/deployer-gas-auto-route.sh` (optional `--dry-run`). [DEPLOYER_GAS_AUTO_ROUTE_RUNBOOK](../03-deployment/DEPLOYER_GAS_AUTO_ROUTE_RUNBOOK.md). |
| E2 | Acquire CRO and WEMIX (manual routes) | `./scripts/deployment/acquire-cro-and-wemix-gas.sh` (lists aggregator links); config: `config/cro-wemix-swap-routes.json`. |
---
## 7. Config and code references
| Config / code | Purpose |
|---------------|---------|
| `config/routing-registry.json` | (fromChain, toChain, asset) → pathType, bridgeAddress; used by UI/indexer. |
| `config/token-mapping-multichain.json` | Token pairs 138↔651940 (and other chains); addressFrom, addressTo for bridge UIs. |
| `config/deployer-gas-routes.json` | Deployer gas strategy per chain (protocolink, chain138, manual). |
| `config/cro-wemix-swap-routes.json` | Manual swap routes for CRO/WEMIX (aggregator links). |
| `smom-dbis-138/services/token-aggregation/src/config/cross-chain-bridges.ts` | CHAIN_138_BRIDGES, getRouteFromRegistry(). |
| `smom-dbis-138/real-robinhood/data/routing-matrix-13x13.json` | 13×13 chain matrix (B/SBS, ALT, via 138). |
---
## 8. Quick command reference (routing / swap / cross-chain)
| Task | Command |
|------|---------|
| Validate config (routing, token-mapping) | `./scripts/validation/validate-config-files.sh` |
| Preflight config-ready chains | `cd smom-dbis-138 && ./scripts/deployment/preflight-config-ready-chains.sh [celo\|wemix\|cronos\|all]` |
| Deploy bridges (Cronos/Wemix) | `./scripts/deployment/deploy-bridges-config-ready-chains.sh [cronos\|wemix]` |
| Complete CCIP destinations (138↔chain) | `./scripts/deployment/complete-config-ready-chains.sh` |
| Fund CCIP with LINK | `./scripts/deployment/fund-ccip-bridges-with-link.sh` |
| Deployer gas report (dry-run) | `./scripts/deployment/deployer-gas-auto-route.sh --dry-run` |
| List CRO/WEMIX swap routes | `./scripts/deployment/acquire-cro-and-wemix-gas.sh` or `--list` / `--json` |
---
## 9. Summary: routing/swap/cross-chain task order
1. **Same-chain swap:** Add liquidity (A1) → token-aggregation DODO index (A2) → expose API (A3). Optional: EnhancedSwapRouter (A4), N-hop (A5).
2. **Cross-chain:** Cronos/Wemix bridges (B1B2) → fund LINK (B3) → registry/token-mapping (B4B7) → Alltra setBridgeFee (B8).
3. **Swapbridgeswap:** Complete A + B → quote API (C3) → destination DEX wiring (C4) → optional coordinator (C5) → frontend (C6C7) → E2E test (C8).
4. **cW* mesh (Phase C):** Deploy cW* (D1) → edge pools (D2) → optional bot (D3).
5. **Ops:** Deployer gas auto-route (E1); CRO/WEMIX via acquire script (E2) when needed.
---
## References
- [DEX_AND_AGGREGATORS_CHAIN138_EXPLAINER](../04-configuration/DEX_AND_AGGREGATORS_CHAIN138_EXPLAINER.md) — flows A/B/C, API, routing
- [PMM_DEX_ROUTING_STATUS](../11-references/PMM_DEX_ROUTING_STATUS.md) — DODO/EnhancedSwapRouter status
- [DEPLOYED_TOKENS_BRIDGES_LPS_AND_ROUTING_STATUS](../11-references/DEPLOYED_TOKENS_BRIDGES_LPS_AND_ROUTING_STATUS.md) — §5 full routing map
- [CONFIG_READY_CHAINS_COMPLETION_RUNBOOK](../07-ccip/CONFIG_READY_CHAINS_COMPLETION_RUNBOOK.md) — CCIP bridge deploy + complete-config
- [PHASE_C_CW_AND_EDGE_POOLS_RUNBOOK](../03-deployment/PHASE_C_CW_AND_EDGE_POOLS_RUNBOOK.md) — cW* and edge pools
- [DEPLOYER_GAS_AUTO_ROUTE_RUNBOOK](../03-deployment/DEPLOYER_GAS_AUTO_ROUTE_RUNBOOK.md) — deployer gas routing
- [TASKS_TO_INCREASE_ALL_E2E_FLOWS](TASKS_TO_INCREASE_ALL_E2E_FLOWS.md) — Flow A/B/C task list