- ADD_CHAIN138_TO_LEDGER_LIVE: Ledger form done; public code review repo bis-innovations/LedgerLive; init/push commands - CONTRACT_DEPLOYMENT_RUNBOOK: Chain 138 gas price 1 gwei, 36-addr check, TransactionMirror workaround - CONTRACT_*: AddressMapper, MirrorManager deployed 2026-02-12; 36-address on-chain check - NEXT_STEPS_FOR_YOU: Ledger done; steps completable now (no LAN); run-completable-tasks-from-anywhere - MASTER_INDEX, OPERATOR_OPTIONAL, SMART_CONTRACTS_INVENTORY_SIMPLE: updates - LEDGER_BLOCKCHAIN_INTEGRATION_COMPLETE: bis-innovations/LedgerLive reference Co-authored-by: Cursor <cursoragent@cursor.com>
5.1 KiB
Custom MetaMask Snap — Implementation Roadmap (Optional)
Last Updated: 2026-01-31
Document Version: 1.0
Status: Active Documentation
Purpose: Outline what is needed to build a custom MetaMask Snap for Chain 138 (DeFi Oracle Meta Mainnet) so users get in-wallet swap quotes, bridge routes, and pricing. This is optional; basic connectivity already works via RPC and the dual-chain provider.
When to use: If you want in-MetaMask UX for swaps, bridge, and USD values for Chain 138 without waiting for Consensys to add native support. See METAMASK_CHAIN138_FEATURE_PARITY_ANALYSIS.md for gaps and options.
1. What the Snap Would Do
| Feature | Snap responsibility | Backend / data source |
|---|---|---|
| Swap quotes | UI and user flow; request quotes when user selects Chain 138. | Your swap/quote API (DEX aggregator or indexer for Chain 138). |
| Bridge routes | Show routes and initiate tx; user signs in MetaMask. | Your bridge API (CCIP + custom routes for Chain 138 ↔ mainnets). |
| Real-time pricing | Display USD values for Chain 138 tokens in Snap UI. | Your pricing API (on-chain oracle and/or token-aggregation service). |
| Market data | Volume, charts, token list. | Token-aggregation REST API (already documented). |
2. Backend APIs (Already or Partially in Place)
| API | Purpose | Status / doc |
|---|---|---|
| GET /api/v1/networks | Full EIP-3085 chain params (138, 1, 651940) + oracles for Snap/dApps. | ✅ Implemented; see REST_API_REFERENCE.md. |
| GET /api/v1/config | Oracles per chain (ETH/USD addresses). | ✅ Implemented. |
| Market data / pricing | Tokens, pools, prices, volume, OHLCV for Chain 138 and ALL Mainnet. | ✅ Documented: REST_API_REFERENCE.md. |
| On-chain oracle (ETH/USD) | dApps and Snap can read ETH/USD from Chain 138. | ✅ Deployed; see ORACLE_PRICE_FEED_SETUP.md. |
| Quote / swap | DEX quotes for Chain 138. | Build or integrate (indexer or DEX aggregator that supports Chain 138). |
| Bridge | CCIP and custom routes; transaction building. | Existing CCIP + bridge UI; expose as bridge API for Snap (routes + tx payloads). |
Dynamic Snap RPCs (implemented): The Snap reads all config from the API. RPCs: get_networks (full chain params + oracles), get_chain138_config (Chain 138 from API), get_token_list, get_token_list_url, get_oracles, show_dynamic_info (in-Snap dialog with networks and token list URL from API).
3. Snap Implementation Phases
-
Scaffold and permissions — Done. Snap has network access and chain 138 support.
-
Market data and pricing — Done. Snap RPCs
get_market_summaryandshow_market_data; companion site Market data and Market summary cards; token-aggregation tokens endpoint. -
Swap flow — Done. Quote API
GET /api/v1/quotein token-aggregation; Snap RPCsget_swap_quoteandshow_swap_quote; companion site Swap quote card with token In/Out and amount. -
Bridge flow — Done. Bridge routes API
GET /api/v1/bridge/routesin token-aggregation; Snap RPCsget_bridge_routesandshow_bridge_routes; companion site Bridge card. -
Testing and distribution — E2E checklist in TESTING_INSTRUCTIONS.md; submit to Snap directory when ready (see Publishing in TESTING_INSTRUCTIONS.md).
4. MetaMask Snap SDK
The Snap targets the latest stable MetaMask Snap SDK (@metamask/snaps-sdk). Dependencies use a caret range (e.g. ^10.3.0) so minors and patches are picked up. Dependabot (.github/dependabot.yml) is configured for @metamask/* packages; Renovate (renovate.json) is optional for grouping MetaMask updates. CI (build and Snap unit tests) runs on dependency updates.
Package manager: The Snap monorepo uses pnpm as the default package manager; yarn is a supported alternative. See metamask-integration/chain138-snap/PACKAGE_MANAGER.md for setup and CI.
5. References
| Resource | Use |
|---|---|
| METAMASK_CHAIN138_FEATURE_PARITY_ANALYSIS.md | Gaps, options, and recommended approach. |
| smom-dbis-138/services/token-aggregation/docs/REST_API_REFERENCE.md | Market data API for Snap. |
| DUAL_CHAIN_PROVIDER_README.md | Chain params, token list, oracle helpers (dApp/Snap can reuse). |
| metamask-integration/docs/CONSENSYS_OUTREACH_PACKAGE.md | Alternative: request native Swaps/Bridge from Consensys. |
| MetaMask Snaps | Official Snap development. |
Last updated: 2026-01-30
Status: Optional roadmap; implement when in-wallet swap/bridge/pricing for Chain 138 is a priority.