This runbook describes what you need to do to deploy and use the **EnhancedSwapRouter** (multi-protocol swap: Uniswap V3, Dodoex, Curve, Balancer, 1inch) on Ethereum Mainnet.
---
## 1. Prerequisites
- **Chain**: Ethereum Mainnet (Chain ID 1) only (script enforces this).
- **.env** (in `smom-dbis-138/` or project root) with:
-`PRIVATE_KEY` — deployer key (has mainnet ETH for gas).
**Save the deployed address** from the script output and add to `.env`:
```bash
ENHANCED_SWAP_ROUTER=0x...
```
---
## 3. Configure Balancer pool IDs (optional)
EnhancedSwapRouter uses Balancer for medium/large swaps. If you use those tiers, set pool IDs for the pairs you need (e.g. WETH–USDC, WETH–USDT):
```bash
# Example: WETH–USDT Balancer pool ID (replace <poolId> with actual bytes32)
cast send $ENHANCED_SWAP_ROUTER \
"setBalancerPoolId(address,address,bytes32)" \
0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 \
0xdAC17F958D2ee523a2206206994597C13D831ec7 \
<poolId> \
--rpc-url "$ETHEREUM_MAINNET_RPC" \
--private-key "$PRIVATE_KEY"
```
Find pool IDs from [Balancer](https://app.balancer.fi/) or their subgraph for mainnet.
---
## 4. Grant COORDINATOR_ROLE (for future coordinator use)
If you later deploy a coordinator that uses EnhancedSwapRouter (see §6), that coordinator must have `COORDINATOR_ROLE` on EnhancedSwapRouter. You can grant it to the **existing** BridgeSwapCoordinator so it’s ready if you switch to a coordinator that calls EnhancedSwapRouter:
```bash
# Role hash (COORDINATOR_ROLE)
cast keccak "COORDINATOR_ROLE"
# Grant to BridgeSwapCoordinator (replace with your BRIDGE_SWAP_COORDINATOR address)
To change providers per size category (e.g. `setRoutingConfig`), use the contract’s `setRoutingConfig(sizeCategory, providers[])` with the provider enum values (see `EnhancedSwapRouter.SwapProvider`).
---
## 6. Important: BridgeSwapCoordinator and EnhancedSwapRouter
The **current****BridgeSwapCoordinator** (trustless bridge payout) is wired to the **basic SwapRouter** in code:
- It calls `swapRouter.swapToStablecoin(..., bytes calldata routeData)` and expects a single `uint256` return.
- **EnhancedSwapRouter** exposes `swapToStablecoin(..., SwapProvider preferredProvider)` and returns `(uint256, SwapProvider)`.
So the existing coordinator **cannot** call EnhancedSwapRouter without a contract change. Today:
- **bridgeAndSwap** (Lockbox → claim → release → swap to USDT/USDC) still uses the **basic SwapRouter** only.
- Deploying EnhancedSwapRouter gives you:
- Multi-protocol routing for **other** callers (e.g. quote services, liquidity engine, or direct `EnhancedSwapRouter.swapToStablecoin` calls).
- A path ready for a **future** coordinator (or upgraded coordinator) that uses EnhancedSwapRouter once one is implemented and deployed.
To actually use EnhancedSwapRouter for the trustless payout flow you would need to:
- Implement and deploy a new coordinator (or upgrade) that takes an EnhancedSwapRouter-compatible interface and calls `swapToStablecoin(..., preferredProvider)` with the right parameters and return handling, and
- Point the LP’s authorized releaser (or users) at that new coordinator instead of the current BridgeSwapCoordinator.
---
## 7. Summary checklist
| Step | Action |
|------|--------|
| 1 | Set `PRIVATE_KEY`, `ETHEREUM_MAINNET_RPC`, `ETHERSCAN_API_KEY` in `.env`. |
| 2 | Run `DeployEnhancedSwapRouter.s.sol` (or `phase3-deploy-router.sh`) on mainnet. |
| 3 | Add `ENHANCED_SWAP_ROUTER=<address>` to `.env`. |
| 4 | (Optional) Configure Balancer pool IDs for WETH–stable pairs. |
| 5 | (Optional) Grant `COORDINATOR_ROLE` on EnhancedSwapRouter to BridgeSwapCoordinator for future use. |
| 6 | (Optional) Adjust routing via `setRoutingConfig` if needed. |
- **COORDINATOR_ROLE** granted to BridgeSwapCoordinator (`0xF51581eee46f5A7Ef2A035C5B3Ac4a89bF6FbaAa`).
- **Balancer pool IDs**: optional; set via `setBalancerPoolId(tokenA, tokenB, poolId)` when you have pool IDs from [Balancer](https://app.balancer.fi/) or the Balancer subgraph.
---
## 9. DualRouterBridgeSwapCoordinator (bridgeAndSwap with basic or enhanced router)
A **DualRouterBridgeSwapCoordinator** contract is deployed so that one coordinator can perform `bridgeAndSwap` using either the basic SwapRouter or the EnhancedSwapRouter.
- **Wiring**: After deploy, the script calls `LiquidityPoolETH.authorizeRelease(coordinator)` and `EnhancedSwapRouter.grantRole(COORDINATOR_ROLE, coordinator)`.
- **.env**: Set `DUAL_ROUTER_BRIDGE_SWAP_COORDINATOR` to the deployed address.