The Connect Market Map Updater indexes market data from exchanges (or market providers) into the format of Connect's Market Map module. It converts that market map into transactions that can update the market map on-chain.
The Updater is split into multiple stages for easier debugging.
Some configurations are provided for you, but you need a CoinMarketCap API key to index asset data from CoinMarketCap's API. Once you have a key, add it to the JSON config under index.coinmarketcap.api_key. Alternatively, you can set an environment variable CMC_API_KEY to your API key.
The available configurations are:
./local/config-dydx-localnet.json
./local/config-dydx-devnet.json
./local/config-dydx-testnet.json
./local/config-dydx-mainnet.json
The localnet configuration is meant for a locally running testnet. You can configure the chain details under the chain key in the config, such as API endpoints.
- Extra Flags: Additional command flags are available in
flags.go, or use--helpfrom the CLI to see all options. - Output Directory: By default, all generated files are saved in the
./tmpdirectory.
export CMC_API_KEY='...'
go run ./cmd/mmu index --config ./local/config-dydx-testnet.json
go run ./cmd/mmu generate --config ./local/config-dydx-testnet.json
go run ./cmd/mmu override --config ./local/config-dydx-testnet.json
go run ./cmd/mmu upserts --config ./local/config-dydx-testnet.json --warn-on-invalid-market-map # Market map on chain is invalid on testnet
go run ./cmd/mmu dispatch --config ./local/config-dydx-testnet.json --simulateexport CMC_API_KEY='...'
go run ./cmd/mmu index --config ./local/config-dydx-mainnet.json
go run ./cmd/mmu generate --config ./local/config-dydx-mainnet.json
go run ./cmd/mmu override --config ./local/config-dydx-mainnet.json
go run ./cmd/mmu upserts --config ./local/config-dydx-mainnet.json
go run ./cmd/mmu dispatch --config ./local/config-dydx-mainnet.json --simulate- Run
indexandgeneratecommands. - Validate the generated data.
- Apply override rules if necessary.
- Run
upsertsand inspect the output. - Use
dispatchwith--simulateto test the transactions. - If simulations are successful, run
dispatchto submit transactions to the blockchain.
In addition to running locally, the MMU also runs as an automated pipeline via AWS Step Functions + Lambda (triggered on a schedule by EventBridge). The AWS pipeline reports newly available MM transactions, validation errors, etc. to Slack.
The AWS pipeline consists of 3 components:
- MMU Lambda: Contains the core
cmdmodule functionality. Command-specific flags (ex. config file paths) are hardcoded in the Lambda for each command, for consistency between runs. Requires the following params:command: Which command to run, either{index | generate | override | validate | upserts | diff | dispatch}network: Target network to run MMU on, either{testnet | mainnet}timestamp: Timestamp with which to prefix output files in S3 (auto-generated at current time forindexcommand)
- MMU Step Function: Coordinates the pipeline E2E by invoking the MMU Lambda for each command sequentially. The final command,
dispatch, writes the latest transaction data to{network}-transactions-latest.jsonin S3. - API Lambda: Serves the latest transaction data from S3, using a query param
?network={testnet | mainnet}.
To deploy a new version of the MMU Lambda, Step Function, or API Lambda:
- Merge a PR to
main.- To test before merging, get your PR approved and use the
deploy-stagingworkflow button that appears after approval.
- To test before merging, get your PR approved and use the
- Wait for the
deployworkflows to finish running in GitHub Actions.- The
deploy-mmuworkflows build and push the latest MMU Lambda source code image to ECR. - The
deploy-apiworkflows build and push the latest API Lambda source code.zipto S3 (market-map-updater-sourcebucket).
- The
- To deploy
staging: Runterraform applyfrom themarket_map_updatersubdir inv4-terraformrepo, or use the HCP Terraform web UI to kick off a new apply on themarket-map-updater-stagingworkspace.- You will have to authenticate in AWS CLI w/ your user credentials for the
stagingAWS account.
- You will have to authenticate in AWS CLI w/ your user credentials for the
- To deploy
mainnet: Use the HCP Terraform web UI to kick off a new apply on themarket-map-updater-mainnetworkspace.
- When running in AWS, MMU requires a CMC API key in AWS Secrets Manager, with the name
{env}-market-map-updater-cmc-api-key. See 1Password for the CMC login credentials.
go run ./cmd/mmu index --config ./local/config-dydx-mainnet.jsonThe index job collects asset data from CoinMarketCap and market data from supported providers like Coinbase, Binance, and Uniswap. Its goal is to compile a list of all available markets from these providers.
- Providers Configuration: Providers are specified under the
index.ingesterskey in the provider configuration file (e.g.,ingesters,coinmarketcap). - API Keys: Ensure you add your CoinMarketCap API key in the configuration file.
go run ./cmd/mmu generate --config ./local/config-dydx-mainnet.jsonThe generate job converts provider data into a market map—a collection of base/quote asset pairs (markets). Each market includes metadata (like reference prices) and a list of providers offering prices for that market, each with configuration details. The output is saved as generated-market-map.
- Note:
generated-market-map-removalsis an additional artifact from the indexing job that contains markets filtered out due to not meeting certain criteria. This is useful for debugging and understanding why some markets were not included.
Validates configurations and generated market maps. This helps ensure configurations are correct and identifies any transient failures (e.g., API downtime).
# Clone the Connect repository and checkout the branch or tag you want to install
# Run make install-sentry and add the go binard directory to your shell's PATH
# Run `make install` in the Connect repository and link to Go environment
# sentry in validator/cmd/sentry
# ln -s $(go env GOBIN)/slinky $(go env GOBIN)/connect
go run ./cmd/mmu validate --market-map ./tmp/generated-market-map.json --oracle-config ./local/fixtures/e2e/oracle.json --start-delay 10s --duration 1mgo run ./cmd/mmu override --config ./local/config-dydx-mainnet.jsonThe override job compares the generated market map with the current on-chain market map and modifies it based on specific rules. This ensures that certain markets remain unchanged or are updated according to the overrides.
Optional flags to override default behavior:
--update-enabled: Updates the on-chain values of enabled markets.--existing-only: Removes new markets from the market map to prevent adding them.--overwrite-providers: Maintains existing providers (e.g., Uniswap) without altering their on-chain configurations. Use this to avoid modifying properly configured providers.
go run ./cmd/mmu upserts --config ./local/config-dydx-mainnet.jsonThe upserts job examines the market map to identify changed markets and outputs them to a file. These markets are prepared for inclusion in a transaction to update the market map on-chain. This transaction will be submitted as part of the dispatch job.
go run ./cmd/mmu dispatch --config ./local/config-dydx-mainnet.jsonThe dispatch job prepares and submits transactions to the blockchain, splitting updates into multiple transactions if necessary due to size constraints.
- Simulation Recommended: It's advisable to simulate the transaction before actual submission.
- Signing Transactions: Transactions can be signed with local keys saved to disk, but it's recommended to use your own robust signing service.
Flags:
--simulate: Simulates the transaction without submitting it. Uses the address configured indispatch.signing.--simulate-address <address>: Uses a specified address for simulation.
go run ./cmd/mmu index --config ./local/config-dydx-mainnet.json
go run ./cmd/mmu generate --config ./local/config-dydx-mainnet.json
go run ./cmd/mmu override --config ./local/config-dydx-mainnet.json
go run ./cmd/mmu upserts --config ./local/config-dydx-mainnet.json
go run ./cmd/mmu dispatch --config ./local/config-dydx-mainnet.jsonTo designate a market as being launchable with cross-margin:
- Add that market's CMC ID to the
cross-launch-list.jsonconfig file - Submit a PR and merge to main
- Redeploy the MMU via Terraform (
market_map_updatermodule) This will add across_launch=trueflag to that market'smetadata_jsonstring in Market Map.
This module incorporates code from the Cosmos Labs /connect-mmu module, which is subject to this License https://github.com/skip-mev/connect-mmu?tab=Apache-2.0-1-ov-file and has been modified by us.
Copyright for connect-mmu public infrastructure attributed to 2025 Cosmos Labs.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.