MetaMask / MetaMask/core

Inconsistent token price from CryptoCompare API

Open
#5,055 0 comments 0 reactions 0 assignees View on GitHub
team-assets
Dominant language
TypeScript
Stars
413
Forks
308
Avg merge
1d 4h
Merged PRs (30d)
253

Description

## Issue

We noticed inconsistent token price for IOTX (and possibly for other tokens) when using the CryptoCompare API. The returned price via the direct IOTX/USD trading pair is outdated, resulting in incorrect token price information being displayed in MetaMask. The current API at the time of opening the issue returns a price of **$0.056**, whereas the accurate price should be **$0.045**.

## Cause

The issue arises because the CryptoCompare API's direct **IOTX/USD** trading pair is not up-to-date. The returned price is sourced from a limited set of markets that no longer reflect current market data. This leads to discrepancies in the displayed price.

## Proposed Solutions

1. **Use the CADLI Index:** (recommended by CCData team after reaching out to their support team)
To resolve the outdated price issue, we can switch to CryptoCompare's new **CADLI index**. CADLI consolidates all available markets for a given cryptocurrency and returns a 24-hour volume-weighted average USD price.

2. **Update the API Call:**
Instead of querying the direct pairs, use the following API endpoint to get the updated token price:

```plaintext
https://data-api.cryptocompare.com/index/cc/v1/latest/tick?market=cadli&instruments=ETH-USD&apply_mapping=true&groups=VALUE
```

which also supports fetching prices directly for multiple tokens:

```plaintext
https://data-api.cryptocompare.com/index/cc/v1/latest/tick?market=cadli&instruments=ETH-USD,IOTX-USD&apply_mapping=true&groups=VALUE
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Locate the existing CryptoCompare price request in the TypeScript code and compare its current direct-pair parameters with the CADLI endpoint described here. Update the request to support the required token instruments, then verify that IOTX and other fetched tokens use the current volume-weighted USD price.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.