Skip to content

Conversation

@ad-0xpp
Copy link

@ad-0xpp ad-0xpp commented Oct 30, 2025

feat: Migrate all markets to USDC-based pricing

Eliminates USD and USDT dependencies from price feeds by normalizing all market prices through USDC. This change creates helper markets for normalization and updates all existing markets to use USDC-based pricing in a 4-step sequence.

1. protocol/marketmap_updates/step1_msg_upsert_markets_core.json

  • Creates 4 helper markets: BTC/USDC, ETH/USDC, SOL/USDC, USDT/USDC (all enabled: false)
  • Rationale: Helper markets provide pure USDC-based normalization paths; created with enabled: false per ante handler requirements

2. protocol/marketmap_updates/step2_msg_create_oracle_markets_fixed.json

  • Enables helper markets in x/prices module (auto-enables in marketmap)
  • Sets min_price_change_ppm: BTC/ETH/SOL-USDC = 500 ppm (matches mainnet standards), USDT-USDC = 10 ppm (stablecoin sensitivity)
  • Rationale: Markets must exist in x/prices and be enabled to be used for price aggregation. 10 ppm for USDT-USDC captures typical 1-5 bps stablecoin spreads.

3. protocol/marketmap_updates/step3_msg_update_usdc_usd_market.json

  • Updates USDC/USD market with 6 providers (2 direct USD, 4 normalized by helper markets)
  • Adds: kraken_btc_usd (normalize by BTC/USDC), raydium_api (normalize by SOL/USDC), uniswapv3_api (normalize by ETH/USDC)
  • Rationale: USDC/USD update separated from step1 to avoid dependency issues on markets being added in step1

4. protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch{1-22}of22.json (22 files)

  • Updates 326 markets across platform (expanded from 20 to 22 batches to accommodate all markets)
  • Changes 1522 USDT/USD normalizations to USDT/USDC
  • Adds 402 USDC/USD normalizations for USD-quoted providers
  • Rationale: Converts all pricing to USDC denomination; batched to stay under gas limits (~1.5M gas per message, 22 messages in single proposal)

All markets now price in USDC. No fiat USD or USDT dependencies remain.

Testnet Validation:

  1. Step 1: 4 helper markets created (enabled: false) ✅
  2. Step 2: Helper markets enabled via x/prices with optimized min_price_change_ppm ✅
  3. Step 3: USDC/USD market updated with 6 providers ✅
  4. Step 4: All 22 batches executed successfully in single proposal (22 messages) ✅
  5. Gas optimization: Single proposal with 22 messages approach validated (vs single message requiring 32.5M gas which was rejected)

Deployment:

  • Execute transactions in strict sequence (step1 → step2 → step3 → step4 batches 1-22)
  • Step 4 uses single proposal with 22 messages (not 22 separate proposals)
  • Verification: Query market_map state to confirm normalizations applied correctly

Summary by CodeRabbit

  • New Features
    • Added a comprehensive set of governance proposals to upsert and enable market configurations for USDC/USDT normalization across hundreds of assets.
    • Included multi-step batched updates covering core markets (BTC, ETH, SOL, USDT, USDC) plus many additional pairs.
    • Expanded provider mappings to incorporate numerous exchange and oracle feeds for improved normalization and price discovery.
  • Chores
    • Bundled market creations and updates into governed proposal payloads for staged deployment.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 30, 2025

Walkthrough

Adds 25 new JSON governance-proposal payloads under protocol/marketmap_updates/: core USDC markets, fixed oracle market creations, a USDC/USD market update, and 22 batched MsgUpsertMarkets payloads to migrate many markets to USDC/USDT normalization mappings.

Changes

Cohort / File(s) Summary
Initialization (steps 1–3)
protocol/marketmap_updates/step1_msg_upsert_markets_core.json, protocol/marketmap_updates/step2_msg_create_oracle_markets_fixed.json, protocol/marketmap_updates/step3_msg_update_usdc_usd_market.json
Add governance payloads: upsert core USDC markets (BTC/USDC, ETH/USDC, SOL/USDC, USDT/USDC), create fixed oracle markets (ids 9000–9003), and update USDC/USD market with provider_configs and metadata.
Batched market upserts — Part A
protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch{1,2,3,4,5,6,7,8,9,10,11}of22.json
Add MsgSubmitProposal payloads (batches 1–11), each carrying a MsgUpsertMarkets array: per-market ticker, decimals, min_provider_count, enabled flag, metadata_JSON, and provider_configs with normalize_by_pair/invert rules.
Batched market upserts — Part B
protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch{12,13,14,15,16}of22.json
Add MsgUpsertMarkets proposals for batches 12–16 with extensive provider lists and some complex provider metadata (Raydium / Uniswap v3 integrations, vault/AMM addresses).
Batched market upserts — Part C
protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch{17,18,19,20,21,22}of22.json
Add final MsgUpsertMarkets proposals for batches 17–22 completing USDC/USDT normalization migration; same per-market structure and provider normalization mappings across remaining markets.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Proposer as Off‑chain proposer
  participant Gov as Cosmos Gov Module
  participant Marketmap as Marketmap Module
  Note over Proposer,Gov: Submit governance proposal JSON (MsgSubmitProposal)
  Proposer->>Gov: MsgSubmitProposal (messages: MsgUpsertMarkets / MsgCreateOracleMarket)
  Gov->>Marketmap: Deliver inner messages
  Marketmap->>Marketmap: Validate each market & provider_configs
  alt validation success
    Marketmap-->>Gov: Acknowledge upsert/create results
  else validation failure
    Marketmap-->>Gov: Return validation errors
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Focus review on files with on‑chain metadata and complex provider entries:
    • step1_msg_upsert_markets_core.json
    • step2_msg_create_oracle_markets_fixed.json
    • step3_msg_update_usdc_usd_market.json
    • Any batch files containing Raydium / Uniswap v3 metadata or explicit vault/AMM addresses (e.g., batches 12–16)

Possibly related PRs

Suggested reviewers

  • shrenujb
  • jusbar23

Poem

🐰 I hopped through JSON fields so bright,

Markets queued up in tidy sight,
Core to batch the mappings hum,
USDC trails make prices come —
A rabbit cheers this migration night!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description provides comprehensive context (four-step migration with rationale, testnet validation, and deployment instructions) but lacks the required template structure: missing explicit 'Changelist', 'Test Plan' sections, and author/reviewer checklist. Restructure description using the provided template: add 'Changelist' section, 'Test Plan' section with explicit testing details, and include the author/reviewer checklist with appropriate labels.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'feat: Migrate price feeds to USDC-based denomination' accurately captures the main objective: normalizing all market prices to USDC denomination and removing USD/USDT dependencies.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/update-usdc-price-sources

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 10a2d95 and 83a233a.

📒 Files selected for processing (22)
  • protocol/marketmap_updates/step1_msg_upsert_markets_core.json (1 hunks)
  • protocol/marketmap_updates/step2_msg_create_oracle_markets_fixed.json (1 hunks)
  • protocol/marketmap_updates/step3_msg_update_usdc_usd_market.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch10of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch11of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch12of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch13of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch14of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch15of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch16of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch17of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch18of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch19of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch1of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch20of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch21of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch22of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch2of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch3of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch4of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch5of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch6of22.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch21of22.json
🚧 Files skipped from review as they are similar to previous changes (9)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch18of22.json
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch11of22.json
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch20of22.json
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch22of22.json
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch16of22.json
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch10of22.json
  • protocol/marketmap_updates/step2_msg_create_oracle_markets_fixed.json
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch4of22.json
  • protocol/marketmap_updates/step3_msg_update_usdc_usd_market.json
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024-11-22T18:12:04.606Z
Learnt from: hwray
Repo: dydxprotocol/v4-chain PR: 2597
File: indexer/services/ender/src/scripts/handlers/dydx_update_perpetual_v1_handler.sql:16-20
Timestamp: 2024-11-22T18:12:04.606Z
Learning: Avoid suggesting changes to deprecated functions such as `dydx_update_perpetual_v1_handler` in `indexer/services/ender/src/scripts/handlers/dydx_update_perpetual_v1_handler.sql` if they are unchanged in the PR.

Applied to files:

  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch13of22.json
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch12of22.json
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch15of22.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (28)
  • GitHub Check: (Mainnet) Build and Push ECS Services / call-build-and-push-vulcan / (vulcan) Build and Push
  • GitHub Check: (Mainnet) Build and Push ECS Services / call-build-and-push-bazooka-lambda / (bazooka) Build and Push Lambda
  • GitHub Check: (Mainnet) Build and Push ECS Services / call-build-and-push-ecs-service-roundtable / (roundtable) Build and Push
  • GitHub Check: (Mainnet) Build and Push ECS Services / call-build-and-push-ecs-service-ender / (ender) Build and Push
  • GitHub Check: (Mainnet) Build and Push ECS Services / call-build-and-push-ecs-service-comlink / (comlink) Build and Push
  • GitHub Check: (Mainnet) Build and Push ECS Services / call-build-and-push-ecs-service-socks / (socks) Build and Push
  • GitHub Check: (Mainnet) Build and Push ECS Services / call-build-and-push-auxo-lambda / (auxo) Build and Push Lambda
  • GitHub Check: (Public Testnet) Build and Push ECS Services / call-build-and-push-auxo-lambda / (auxo) Build and Push Lambda
  • GitHub Check: (Public Testnet) Build and Push ECS Services / call-build-and-push-ecs-service-roundtable / (roundtable) Build and Push
  • GitHub Check: (Public Testnet) Build and Push ECS Services / call-build-and-push-ecs-service-comlink / (comlink) Build and Push
  • GitHub Check: (Public Testnet) Build and Push ECS Services / call-build-and-push-bazooka-lambda / (bazooka) Build and Push Lambda
  • GitHub Check: (Public Testnet) Build and Push ECS Services / call-build-and-push-vulcan / (vulcan) Build and Push
  • GitHub Check: (Public Testnet) Build and Push ECS Services / call-build-and-push-ecs-service-socks / (socks) Build and Push
  • GitHub Check: (Public Testnet) Build and Push ECS Services / call-build-and-push-ecs-service-ender / (ender) Build and Push
  • GitHub Check: container-tests
  • GitHub Check: build-and-push-testnet
  • GitHub Check: benchmark
  • GitHub Check: check-sample-pregenesis-up-to-date
  • GitHub Check: build
  • GitHub Check: golangci-lint
  • GitHub Check: build-and-push-mainnet
  • GitHub Check: liveness-test
  • GitHub Check: test-race
  • GitHub Check: test-coverage-upload
  • GitHub Check: unit-end-to-end-and-integration
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
  • GitHub Check: Summary
🔇 Additional comments (4)
protocol/marketmap_updates/step1_msg_upsert_markets_core.json (3)

8-49: BTC/USDC, ETH/USDC, SOL/USDC configurations are well‑structured.

All three markets are consistently configured with non-inverted provider pairs and exchange-specific off-chain ticker formats. Decimal precision choices are appropriate: BTC/USDC (5), ETH/USDC (6), SOL/USDC (8) align with market value ranges and exchange conventions. The min_provider_count of 3 ensures adequate redundancy for price feeds.

Also applies to: 50-91, 92-140


207-210: Governance proposal metadata and deposit are appropriate.

Title, summary, and metadata clearly communicate the proposal intent. The deposit of "10000000adv4tnt" (10 DYDX testnet equivalent) is suitable for the testnet environment. For mainnet deployment, ensure the deposit meets the 2,000 DYDX minimum governance requirement.


168-173: No action required — configuration is correct.

The verification confirms that Coinbase Advanced Trade API does provide a direct USDT-USDC trading pair, making the current configuration with invert: false and ticker "USDT-USDC" correct. The difference from other providers (which use invert: true) reflects the actual market pairs each exchange exposes—this is appropriate and not an error.

protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch5of22.json (1)

815-818: Batch metadata now consistent with filename.

The batch count metadata has been corrected to reflect "batch 5 of 22", aligning with the filename and the overall 22-batch structure of the step 4 migration.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (13)
protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch5of22.json (1)

815-819: Batch count mismatch: metadata and title still say "of 20" but should be "of 22".

This issue was flagged in a prior review and remains unresolved. Per the PR objectives, the migration includes 22 total batches. Align the metadata and title to match the filename and PR scope.

Apply this diff:

-  "metadata": "USDC migration batch 5 of 20: Markets 81-100",
+  "metadata": "USDC migration batch 5 of 22: Markets 81-100",
   "deposit": "10000000adv4tnt",
-  "title": "USDC Migration - Batch 5/20",
+  "title": "USDC Migration - Batch 5/22",
   "summary": "Update markets to use USDC/USD and USDT/USDC normalizations"
protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch12of22.json (1)

873-876: Fix batch header: 12 of 22 (not 12 of 20).

Align with filename and PR description stating this is a 22-batch series.

-  "metadata": "USDC migration batch 12 of 20: Markets 221-240",
+  "metadata": "USDC migration batch 12 of 22: Markets 221-240",
-  "title": "USDC Migration - Batch 12/20",
+  "title": "USDC Migration - Batch 12/22",
protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch3of22.json (1)

907-909: Fix batch count metadata to align with "of 22".

Line 907 and 909 show "of 20" and "Batch 3/20", but the filename and PR indicate this is batch 3 of 22 total batches. Update both fields to reflect the correct total:

-  "metadata": "USDC migration batch 3 of 20: Markets 41-60",
+  "metadata": "USDC migration batch 3 of 22: Markets 41-60",
   ...
-  "title": "USDC Migration - Batch 3/20",
+  "title": "USDC Migration - Batch 3/22",
protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch1of22.json (3)

1059-1061: Fix batch count metadata to align with "of 22".

Line 1059 and 1061 show "of 20" and "Batch 1/20", but the filename and PR indicate this is batch 1 of 22 total batches. Update both fields to reflect the correct total:

-  "metadata": "USDC migration batch 1 of 20: Markets 1-20",
+  "metadata": "USDC migration batch 1 of 22: Markets 1-20",
   ...
-  "title": "USDC Migration - Batch 1/20",
+  "title": "USDC Migration - Batch 1/22",

159-167: AAVE via AAVEBTC breaks USDC-first normalization goal.

Line 159–167 uses binance_ws with "off_chain_ticker": "AAVEBTC" normalized by "Base": "BTC", "Quote": "USDC". This adds an unnecessary BTC dependency and breaks the stated goal of USDC/USDT-only normalization rails.

Since this is a USDC batch, replace with a USDT-based provider normalized to USDC, or remove AAVE entirely:

-    {
-      "name": "binance_ws",
-      "off_chain_ticker": "AAVEBTC",
-      "normalize_by_pair": { "Base": "BTC", "Quote": "USDC" },
+    {
+      "name": "binance_ws",
+      "off_chain_ticker": "AAVEUSDT",
+      "normalize_by_pair": { "Base": "USDT", "Quote": "USDC" },

499-507: ADA uses USDT-based ticker on gate_ws instead of native USDC pair.

Line 499–507: gate_ws entry uses "off_chain_ticker": "ADA_USDT" with a normalize_by_pair workaround (Base=USDT, Quote=USDC). Since this is explicitly a USDC batch, prefer the native USDC pair if available on gate.io:

-    {
-      "name": "gate_ws",
-      "off_chain_ticker": "ADA_USDT",
-      "normalize_by_pair": { "Base": "USDT", "Quote": "USDC" },
+    {
+      "name": "gate_ws",
+      "off_chain_ticker": "ADA_USDC",
+      "normalize_by_pair": { "Base": "USDC", "Quote": "USD" },

If gate.io does not offer ADA_USDC natively, remove ADA from this USDC batch.

protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch6of22.json (2)

1127-1129: Fix batch count metadata to align with "of 22".

Line 1127 and 1129 show "of 20" and "Batch 6/20", but the filename and PR indicate this is batch 6 of 22 total batches. Update both fields to reflect the correct total:

-  "metadata": "USDC migration batch 6 of 20: Markets 101-120",
+  "metadata": "USDC migration batch 6 of 22: Markets 101-120",
   ...
-  "title": "USDC Migration - Batch 6/20",
+  "title": "USDC Migration - Batch 6/22",

1009-1017: Fix OKX EUR ticker symbol and invert flag.

Line 1009–1017: okx_ws uses "off_chain_ticker": "USDT-EUR" with "invert": true. Per prior verification via OKX API documentation, the correct pair is EUR-USDT (base=EUR, quote=USDT) with no inversion:

-    {
-      "name": "okx_ws",
-      "off_chain_ticker": "USDT-EUR",
-      "normalize_by_pair": { "Base": "USDT", "Quote": "USDC" },
-      "invert": true,
+    {
+      "name": "okx_ws",
+      "off_chain_ticker": "EUR-USDT",
+      "normalize_by_pair": { "Base": "USDT", "Quote": "USDC" },
+      "invert": false,
protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch16of22.json (1)

981-981: Batch count mismatch persists: "batch 16 of 20" should be "batch 16 of 22".

Per PR objectives, there are 22 batches total. The filename correctly indicates batch16of22, but the metadata and title fields still incorrectly reference "20" instead of "22".

Apply this diff to correct both fields:

- "metadata": "USDC migration batch 16 of 20: Markets 301-320",
+ "metadata": "USDC migration batch 16 of 22: Markets 301-320",
  "deposit": "10000000adv4tnt",
- "title": "USDC Migration - Batch 16/20",
+ "title": "USDC Migration - Batch 16/22",

Also applies to: 983-983

protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch15of22.json (2)

1125-1125: Batch count mismatch persists: "batch 15 of 20" should be "batch 15 of 22".

Per PR objectives, there are 22 batches total. The filename correctly indicates batch15of22, but the metadata and title fields still incorrectly reference "20" instead of "22".

Apply this diff to correct both fields:

- "metadata": "USDC migration batch 15 of 20: Markets 281-300",
+ "metadata": "USDC migration batch 15 of 22: Markets 281-300",
  "deposit": "10000000adv4tnt",
- "title": "USDC Migration - Batch 15/20",
+ "title": "USDC Migration - Batch 15/22",

Also applies to: 1127-1127


233-241: Remove Kraken SUSD provider—it maps to the sUSD stablecoin, not the S token.

Kraken's "SUSD" ticker refers to the sUSD stablecoin on Ethereum, not the S token (Synthetic token). Including this provider contaminates the S/USD price feed with stablecoin pricing data.

Remove the Kraken provider entirely:

            {
              "name": "kucoin_ws",
              "off_chain_ticker": "S-USDT",
              "normalize_by_pair": {
                "Base": "USDT",
                "Quote": "USDC"
              },
              "invert": false,
              "metadata_JSON": ""
            },
-           {
-             "name": "kraken_api",
-             "off_chain_ticker": "SUSD",
-             "normalize_by_pair": {
-               "Base": "USDC",
-               "Quote": "USD"
-             },
-             "invert": false,
-             "metadata_JSON": ""
-           },
            {
              "name": "mexc_ws",
              "off_chain_ticker": "SUSDT",
protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch18of22.json (2)

427-435: Fix double inversion in uniswapv3_api-ethereum provider.

This provider has invert: true at the provider config level (line 433) AND "invert": true in the metadata_JSON (line 434). This causes double inversion that cancels out and produces incorrect pricing for USDC/USD derivation through ETH/USDC.

Remove the redundant invert flag from metadata_JSON:

  {
    "name": "uniswapv3_api-ethereum",
    "off_chain_ticker": "WETH,UNISWAP_V3,0XC02AAA39B223FE8D0A0E5C4F27EAD9083C756CC2/USDC,UNISWAP_V3,0XA0B86991C6218B36C1D19D4A2E9EB0CE3606EB48",
    "normalize_by_pair": {
      "Base": "ETH",
      "Quote": "USDC"
    },
    "invert": true,
-   "metadata_JSON": "{\"address\":\"0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640\",\"base_decimals\":18,\"quote_decimals\":6,\"invert\":true}"
+   "metadata_JSON": "{\"address\":\"0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640\",\"base_decimals\":18,\"quote_decimals\":6}"
  }

493-574: Update USDT/USD market to use pure USDC-based normalization per PR objective.

The PR explicitly states the goal is to "migrate all markets to USDC-based pricing" and "eliminate USD and USDT dependencies." The USDT/USD market currently violates this by using USD-quoted and derivatively-normalized providers:

  • Line 516 (coinbase_ws): "USDT-USD" uses USD pair instead of USDC
  • Line 526 (huobi_ws): "ethusdt" uses derived ETH path instead of direct USDT/USDC pair
  • Line 536 (kraken_api): "USDTZUSD" uses USD pair instead of USDC
  • Line 546 (kucoin_ws): "BTC-USDT" uses derived BTC path instead of direct USDT/USDC pair
  • Line 573 (crypto_dot_com_ws): "USDT_USD" uses USD pair instead of USDC

Replace with pure USDT/USDC pairs:

-   { "name": "coinbase_ws", "off_chain_ticker": "USDT-USD",
+   { "name": "coinbase_ws", "off_chain_ticker": "USDT-USDC",
     "normalize_by_pair": { "Base": "USDC", "Quote": "USD" },
-    "invert": false,
+    "invert": true,
     "metadata_JSON": "" },
     
-   { "name": "huobi_ws", "off_chain_ticker": "ethusdt",
-    "normalize_by_pair": { "Base": "ETH", "Quote": "USDC" },
+   { "name": "huobi_ws", "off_chain_ticker": "usdcusdt",
+    "normalize_by_pair": { "Base": "USDC", "Quote": "USD" },
     "invert": true,
     "metadata_JSON": "" },
     
-   { "name": "kraken_api", "off_chain_ticker": "USDTZUSD",
+   { "name": "kraken_api", "off_chain_ticker": "USDCUSDT",
     "normalize_by_pair": { "Base": "USDC", "Quote": "USD" },
-    "invert": false,
+    "invert": true,
     "metadata_JSON": "" },
     
-   { "name": "kucoin_ws", "off_chain_ticker": "BTC-USDT",
-    "normalize_by_pair": { "Base": "BTC", "Quote": "USDC" },
+   { "name": "kucoin_ws", "off_chain_ticker": "USDC-USDT",
+    "normalize_by_pair": { "Base": "USDC", "Quote": "USD" },
     "invert": true,
     "metadata_JSON": "" },
     
-   { "name": "crypto_dot_com_ws", "off_chain_ticker": "USDT_USD",
+   { "name": "crypto_dot_com_ws", "off_chain_ticker": "USDC_USDT",
     "normalize_by_pair": { "Base": "USDC", "Quote": "USD" },
-    "invert": false,
+    "invert": true,
     "metadata_JSON": "" }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6f7fecc and 10a2d95.

📒 Files selected for processing (22)
  • protocol/marketmap_updates/step1_msg_upsert_markets_core.json (1 hunks)
  • protocol/marketmap_updates/step2_msg_create_oracle_markets_fixed.json (1 hunks)
  • protocol/marketmap_updates/step3_msg_update_usdc_usd_market.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch10of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch11of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch12of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch13of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch14of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch15of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch16of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch17of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch18of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch19of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch1of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch20of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch21of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch22of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch2of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch3of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch4of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch5of22.json (1 hunks)
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch6of22.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (9)
  • protocol/marketmap_updates/step2_msg_create_oracle_markets_fixed.json
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch10of22.json
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch14of22.json
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch13of22.json
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch11of22.json
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch4of22.json
  • protocol/marketmap_updates/step1_msg_upsert_markets_core.json
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch2of22.json
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch21of22.json
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024-11-22T18:12:04.606Z
Learnt from: hwray
Repo: dydxprotocol/v4-chain PR: 2597
File: indexer/services/ender/src/scripts/handlers/dydx_update_perpetual_v1_handler.sql:16-20
Timestamp: 2024-11-22T18:12:04.606Z
Learning: Avoid suggesting changes to deprecated functions such as `dydx_update_perpetual_v1_handler` in `indexer/services/ender/src/scripts/handlers/dydx_update_perpetual_v1_handler.sql` if they are unchanged in the PR.

Applied to files:

  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch15of22.json
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch18of22.json
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch12of22.json
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch16of22.json
  • protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch6of22.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (28)
  • GitHub Check: (Public Testnet) Build and Push ECS Services / call-build-and-push-auxo-lambda / (auxo) Build and Push Lambda
  • GitHub Check: (Public Testnet) Build and Push ECS Services / call-build-and-push-ecs-service-socks / (socks) Build and Push
  • GitHub Check: (Public Testnet) Build and Push ECS Services / call-build-and-push-ecs-service-comlink / (comlink) Build and Push
  • GitHub Check: (Public Testnet) Build and Push ECS Services / call-build-and-push-vulcan / (vulcan) Build and Push
  • GitHub Check: (Public Testnet) Build and Push ECS Services / call-build-and-push-ecs-service-roundtable / (roundtable) Build and Push
  • GitHub Check: (Public Testnet) Build and Push ECS Services / call-build-and-push-ecs-service-ender / (ender) Build and Push
  • GitHub Check: (Public Testnet) Build and Push ECS Services / call-build-and-push-bazooka-lambda / (bazooka) Build and Push Lambda
  • GitHub Check: (Mainnet) Build and Push ECS Services / call-build-and-push-auxo-lambda / (auxo) Build and Push Lambda
  • GitHub Check: (Mainnet) Build and Push ECS Services / call-build-and-push-bazooka-lambda / (bazooka) Build and Push Lambda
  • GitHub Check: (Mainnet) Build and Push ECS Services / call-build-and-push-vulcan / (vulcan) Build and Push
  • GitHub Check: (Mainnet) Build and Push ECS Services / call-build-and-push-ecs-service-comlink / (comlink) Build and Push
  • GitHub Check: (Mainnet) Build and Push ECS Services / call-build-and-push-ecs-service-roundtable / (roundtable) Build and Push
  • GitHub Check: (Mainnet) Build and Push ECS Services / call-build-and-push-ecs-service-ender / (ender) Build and Push
  • GitHub Check: (Mainnet) Build and Push ECS Services / call-build-and-push-ecs-service-socks / (socks) Build and Push
  • GitHub Check: build-and-push-testnet
  • GitHub Check: container-tests
  • GitHub Check: golangci-lint
  • GitHub Check: liveness-test
  • GitHub Check: test-race
  • GitHub Check: test-coverage-upload
  • GitHub Check: check-sample-pregenesis-up-to-date
  • GitHub Check: unit-end-to-end-and-integration
  • GitHub Check: build
  • GitHub Check: benchmark
  • GitHub Check: build-and-push-mainnet
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
  • GitHub Check: Summary
🔇 Additional comments (12)
protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch17of22.json (1)

1-1015: Previous feedback incorporated; file is well-formed and consistent.

Both prior review issues have been successfully addressed:

  • Line 355: TONBTC now correctly normalizes via BTC/USDC (not USD).
  • Lines 1011, 1013: Batch header corrected to "17 of 22" (not "17 of 20").

The normalization patterns throughout are consistent: USDT-quoted tickers map via USDT/USDC, and USD-quoted tickers map via USDC/USD. All 20 markets follow the expected structure. JSON is valid and governance proposal fields are properly populated.

protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch19of22.json (1)

1-991: All prior issues resolved — file ready to merge.

All three issues flagged in previous reviews have been corrected:

  • Lines 340–349: WIF/WIFBTC now correctly normalizes via BTC/USDC ✓
  • Lines 548–557: WLFI/WLFI_USD now correctly normalizes via USDC/USD ✓
  • Lines 987–991: Batch header now correctly states "19 of 22" ✓

Verified across all 14 markets: USDT-quoted providers normalize via USDT/USDC, USD-quoted providers via USDC/USD, and crypto pairs via their respective /USDC helpers. JSON structure is valid, all required fields present, and the batch aligns with the USDC migration strategy.

protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch20of22.json (1)

8-953: LGTM on normalization patterns and market configurations.

The market definitions follow the correct USDC migration pattern:

  • USDT-quoted exchange tickers normalize via {"Base": "USDT", "Quote": "USDC"}
  • USD-quoted exchange tickers normalize via {"Base": "USDC", "Quote": "USD"}
  • Special case for ZEREBRO with raydium_api SOL/USDC normalization (line 559–566) is consistent with the cross-chain bridging strategy

Enabled/disabled status distribution aligns with a phased rollout strategy.

protocol/marketmap_updates/step3_msg_update_usdc_usd_market.json (4)

1-19: Proposal structure and market configuration look correct.

The MsgSubmitProposal wrapping MsgUpsertMarkets follows standard Cosmos governance format, and the USDC/USD market definition (10 decimals, enabled) aligns with the PR's USDC normalization objective.


34-43: Verify kraken_btc_usd normalization semantics.

The normalization of BTC/USD via BTC/USDC to produce USDC/USD requires careful verification. The expected formula should be: USDC/USD = BTC/USD ÷ BTC/USDC (or equivalent with inversions). Please confirm that the normalization engine applies this correctly, especially given the invert: false setting.

Is the normalization logic in the slinky price oracle correctly computing USDC/USD from BTC/USD normalized by BTC/USDC? Please share the normalization algorithm or validation results from testnet execution.


44-73: Verify invert flag semantics and consistency in normalized AMM providers.

Three concerns identified in the AMM-based normalized providers:

  1. raydium_api (line 51): invert: true with SOL/USDC normalization — confirm this correctly derives USDC/USD and that the invert flag aligns with how the Raydium SOL/USDC pair is quoted.

  2. uniswapv3_api-base (lines 54-63): Inconsistent invert flags — provider config has invert: false (line 61) but metadata_JSON has "invert": true (line 62). Clarify: do these operate independently, or should they match? Which takes precedence?

  3. uniswapv3_api-ethereum (lines 64-73): Both provider config (line 71) and metadata (line 72) set invert: true. Confirm this double-invert is intentional (e.g., to correct pair direction twice) rather than a redundant error.

Please verify these invert semantics against the slinky oracle's normalization engine. Share documentation or testnet validation logs confirming correct USDC/USD derivation from each provider.


79-82: Governance metadata is clear and accurately describes the change.

Title and summary correctly convey the USDC/USD market update with BTC/USDC, ETH/USDC, and SOL/USDC normalization paths. Metadata is descriptive and will be useful for governance tracking.

protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch22of22.json (3)

867-869: Market count discrepancy: metadata claims 22 markets but file contains 20.

The metadata field states "New markets batch 22 of 22" and the summary mentions "Update markets," but the markets array contains exactly 20 market entries (TLOS, MELANIA, TROY, CLV, DODGERSWIN, ALPACA, XNO, STBL, MNRY, FARTCOIN, PI, THE, MET, XYO, BARD, 2Z, ELX, KRL, CC, ID), not 22.

Given the PR context (326 markets ÷ 22 batches ≈ 14.8 markets per batch), this may be intentional batch-size variation to respect gas limits. However, the metadata should reflect the actual content or clarify the batch scope.

Please confirm:

  • Is this batch intentionally sized to 20 markets?
  • Should the metadata/summary text be updated to reflect 20 markets instead of 22?

8-862: All 20 markets follow consistent USDC normalization patterns and have valid structure.

Each market correctly implements the migration objective:

  • Markets with USD-quoted providers (e.g., crypto_dot_com_ws, coinbase_ws, kraken_api) use normalize_by_pair: null and will be normalized via USDC/USD elsewhere.
  • Markets with USDT-quoted providers use normalize_by_pair: { "Base": "USDT", "Quote": "USDC" } to normalize through USDT/USDC.
  • One DEX-specific entry (FARTCOIN, line 383–391) uses raydium_api with SOL/USDC normalization and invert: true, coupled with detailed vault/AMM metadata.
  • Disabled markets (DODGERSWIN, XNO, STBL, MET, CC) appear intentional for cross-launch or pending activation.

All normalization paths correctly terminate in USDC. JSON syntax is valid, provider names are recognized, and required fields are present. Market configuration is consistent across the batch.


329-329: Unusual but intentional composite currency identifiers and DEX-specific metadata.

Markets like FARTCOIN (base: FARTCOIN,RAYDIUM,9BB6NFECJBCTNNLFKO2FQVQBQ8HHM13KCYYCDQBGPUMP) and DODGERSWIN's polymarket off-chain ticker include blockchain addresses and venue prefixes. This is consistent with the Solana DEX indexing use case (raydium_api) and prediction market sources (polymarket_api).

The raydium_api entry embeds full vault and AMM info (token addresses, decimals, AMM contract). These composite IDs and metadata appear intentional for reliable DEX/AMM resolution and are not errors.

Also applies to: 384-384, 390-390

protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch18of22.json (2)

941-946: Metadata batch count is now consistent.

The metadata correctly reflects "batch 18 of 22" and the title shows "Batch 18/22", matching the filename batch18of22. This appears to address the prior batch numbering concern.


316-325: ****

The ticker "UDCUSD" for bitfinex_ws is not a typo. Bitfinex uses "UDC" for USDC, so the USDC/USD price uses "UDC/USD" on Bitfinex. The off_chain_ticker field correctly reflects Bitfinex's native ticker naming convention. No change needed.

Likely an incorrect or invalid review comment.

Comment on lines 957 to 960
"metadata": "USDC migration batch 20 of 20: Markets 381-399",
"deposit": "10000000adv4tnt",
"title": "USDC Migration - Batch 20/20",
"summary": "Update markets to use USDC/USD and USDT/USDC normalizations"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix batch numbering in proposal metadata.

The proposal metadata contains incorrect batch numbering. According to the PR objectives, this is batch 20 of 22, not 20 of 20. This inconsistency could cause confusion during the sequenced deployment of the 22 batch proposals.

Apply this diff to correct the metadata and title:

- "metadata": "USDC migration batch 20 of 20: Markets 381-399",
+ "metadata": "USDC migration batch 20 of 22: Markets 381-399",
  "deposit": "10000000adv4tnt",
- "title": "USDC Migration - Batch 20/20",
+ "title": "USDC Migration - Batch 20/22",
  "summary": "Update markets to use USDC/USD and USDT/USDC normalizations"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"metadata": "USDC migration batch 20 of 20: Markets 381-399",
"deposit": "10000000adv4tnt",
"title": "USDC Migration - Batch 20/20",
"summary": "Update markets to use USDC/USD and USDT/USDC normalizations"
"metadata": "USDC migration batch 20 of 22: Markets 381-399",
"deposit": "10000000adv4tnt",
"title": "USDC Migration - Batch 20/22",
"summary": "Update markets to use USDC/USD and USDT/USDC normalizations"
🤖 Prompt for AI Agents
In protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch20of22.json
around lines 957-960, the proposal metadata and title incorrectly state "batch
20 of 20"; update the "metadata" value to "USDC migration batch 20 of 22:
Markets 381-399" and the "title" to "USDC Migration - Batch 20/22" so the batch
numbering matches the PR objective; keep the deposit and summary unchanged.

Eliminates USD and USDT dependencies from price feeds by normalizing all market prices through USDC. This change creates helper markets for normalization and updates all existing markets to use USDC-based pricing in a 4-step sequence.

**1. protocol/marketmap_updates/step1_msg_upsert_markets_core.json**
- Creates 4 helper markets: BTC/USDC, ETH/USDC, SOL/USDC, USDT/USDC (all enabled: false)
- Rationale: Helper markets provide pure USDC-based normalization paths; created with enabled: false per ante handler requirements

**2. protocol/marketmap_updates/step2_msg_create_oracle_markets_fixed.json**
- Enables helper markets in x/prices module (auto-enables in marketmap)
- Sets min_price_change_ppm: BTC/ETH/SOL-USDC = 500 ppm (matches mainnet standards), USDT-USDC = 10 ppm (stablecoin sensitivity)
- Rationale: Markets must exist in x/prices and be enabled to be used for price aggregation. 10 ppm for USDT-USDC captures typical 1-5 bps stablecoin spreads.

**3. protocol/marketmap_updates/step3_msg_update_usdc_usd_market.json**
- Updates USDC/USD market with 6 providers (2 direct USD, 4 normalized by helper markets)
- Adds: kraken_btc_usd (normalize by BTC/USDC), raydium_api (normalize by SOL/USDC), uniswapv3_api (normalize by ETH/USDC)
- Rationale: USDC/USD update separated from step1 to avoid dependency issues on markets being added in step1

**4. protocol/marketmap_updates/step4_msg_upsert_markets_usdc_batch{1-22}of22.json** (22 files)
- Updates 326 markets across platform (expanded from 20 to 22 batches to accommodate all markets)
- Changes 1522 USDT/USD normalizations to USDT/USDC
- Adds 402 USDC/USD normalizations for USD-quoted providers
- Rationale: Converts all pricing to USDC denomination; batched to stay under gas limits (~1.5M gas per message, 22 messages in single proposal)

All markets now price in USDC. No fiat USD or USDT dependencies remain.

**Testnet Validation:**
1. Step 1: 4 helper markets created (enabled: false) ✅
2. Step 2: Helper markets enabled via x/prices with optimized min_price_change_ppm ✅
3. Step 3: USDC/USD market updated with 6 providers ✅
4. Step 4: All 22 batches executed successfully in single proposal (22 messages) ✅
5. Gas optimization: Single proposal with 22 messages approach validated (vs single message requiring 32.5M gas which was rejected)

**Deployment:**
- Execute transactions in strict sequence (step1 → step2 → step3 → step4 batches 1-22)
- Step 4 uses single proposal with 22 messages (not 22 separate proposals)
- Verification: Query market_map state to confirm normalizations applied correctly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants