Skip to content

Commit

Permalink
Get token prices from our API instead of CoinGecko
Browse files Browse the repository at this point in the history
CoinGecko is planning on retiring their `/simple/token_price` endpoint
soon. This endpoint is critical for us, as we use to fetch prices for
tokens. This commit removes all code related to CoinGecko in
TokenRatesController so that it hits an internal API instead.

This is set up in such a way that we can upgrade to newer versions of
the API (or even other services) in the future without breaking backward
compatibility. However, at the moment it does introduce breaking
changes to TokenRatesController.
  • Loading branch information
mcmire committed Dec 1, 2023
1 parent d63bac6 commit 0a9c0a7
Show file tree
Hide file tree
Showing 11 changed files with 1,063 additions and 517 deletions.
21 changes: 21 additions & 0 deletions packages/assets-controllers/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- Add `codefiTokenPricesServiceV2`
- This object can be used for the aforementioned `tokenPricesService` argument for TokenRatesController. It uses an internal API to fetch prices for tokens instead of CoinGecko.

### Changed
- **BREAKING:** TokenRatesController now takes a required argument `tokenPricesService` ([#3600](https://github.com/MetaMask/core/pull/3600))
- This object is responsible for fetching the prices for tokens held by this controller.
- **BREAKING:** Update signature of `TokenRatesController.updateExchangeRatesByChainId` ([#3600](https://github.com/MetaMask/core/pull/3600))
- Rename `tokenAddresses` argument to `tokenContractAddresses`
- Change the type of `tokenContractAddresses` from `string[]` to `Hex[]`
- **BREAKING:** Change signature of `TokenRatesController.fetchAndMapExchangeRates` ([#3600](https://github.com/MetaMask/core/pull/3600))
- This method now takes an object with shape `{ tokenContractAddresses: Hex[]; chainId: Hex; nativeCurrency: string; }` rather than positional arguments

### Removed
- **BREAKING:** Remove `fetchExchangeRate` method from TokenRatesController ([#3600](https://github.com/MetaMask/core/pull/3600))
- This method was only ever intended to be used internally and should not be accessed directly.
- **BREAKING:** Remove `getChainSlug` method from TokenRatesController ([#3600](https://github.com/MetaMask/core/pull/3600))
- This method was only ever intended to be used internally and should not be accessed directly.
- This method was previously used in conjunction with the CoinGecko API, which has been replaced with an internal API.
- **BREAKING:** Remove `CoinGeckoResponse` and `CoinGeckoPlatform` types ([#3600](https://github.com/MetaMask/core/pull/3600))
- There is no equivalent to these.

## [20.0.0]
### Added
Expand Down
Loading

0 comments on commit 0a9c0a7

Please sign in to comment.