Accessing price data on "all" decentralized exchanges

I am currently working on a project that relies on me accessing up to date and accurate price data for ERC20 tokens on decentralized exchanges. From reading your documentation I notice I can either use the web3 API or I can access data by calling the getTokenPrice() method and passing it an exchange. I was just wondering what all the possible exchanges are, as I received an email today stating that you can pass “any” decentralized exchange, however the API documentation seems to indicate that the only valid options are ‘uniswap-v3’, ‘sushiswap’, ‘uniswap-v2’. It would be useful for me to be able to
access other exchanges such as bancor or balancer etc.

It looks like these are the only exchanges supported by now:

> exchange_name (optional): The factory name or address of the token exchange. Possible exchanges, for different chains are: 
> ETH mainnet: uniswap-v3, sushiswap, uniswap-v2
> BSC mainnet: pancakeswap-v2, pancakeswap-v1
> Polygon mainnet: quickswap

But maybe it is not complicated to add new exchanges in the future in Moralis processing.

Could it be possible that the docs are inaccurate, as uniswap-v2 is now deprecated and the email I received today stated that you could access “all” decentralized exchanges and the claim that if the data is on chain they can access it.

Introducing the Moralis Price API 🥳
 
The Moralis Price API lets you get the price of any asset, on any chain, on any decentralized exchange.
 
You just input what token, what network and what exchange - and you'll get both the USD price and native price of that token. Instantly, and with only a single line of code.
 
The endpoint can be found in the Deep Index API. 

/ERC20/{address}/price
 
It supports all tokens on Ethereum, BSC and Polygon. 
 
You can also see this API in action in one of our YouTube videos: Get The Price of Any Asset 📺

Give it a try on your project today! 
 
If you have any questions or need help, just reply back and we'll be here for you :)
 
The Moralis Team

I know that uniswap-v2 still works if you set it explicitly as a parameter.

That may be so but it isn’t possible to access the v2 dapp.

You could try to see if the SDK API works with other exchanges, like bancor or balancer if you know their addresses.

I have attempted this but not of the contract addresses I have used have worked.

this is an example for uniswap v2 by using exchange address:

    price = await Moralis.Web3API.token.getTokenPrice(
         {address: "0x1614f18fc94f47967a3fbe5ffcd46d4e7da3d787", 
          exchange: "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", 
          chain: "eth"});

The data is clearly still on chain but if you can’t access it then it defeats the purpose.

My project requires me to have price data from as many exchanges as possible, as I want to create a crypto arbitrage bot that will identify a price discrepency for a particular token across multiple exchanges.

e.g. If uniswap will swap 1 eth for 3500 dai but bancor will swap 1 eth for 3600 dai then the 100 difference (minus gas and dex fees) can be taken as profit if I buy on uniswap and sell on bancor. In addition to this I want to make use of flash loans to increase the amount of profit I can make, and will also mean I do not need to provide any capital up front.

We are launching a plugin today for this, it will solve your issues

1 Like

That’s great. Is there anywhere I can read about this plugin, or will a video about it be released?

video coming today (latest tomorrow)

1 Like

Is there any update for when the plugin and video will be released?

This may be the video: https://www.youtube.com/watch?v=5MlTnoBm7YQ&ab_channel=MoralisWeb3

That video is about the fiat gateway plugin, not the one that will solve my issues.

not done yet, hope to get it out next few days, was a bit too optimistic

2 Likes

Will the plugin include functionality to pass a currency pair (e.g. dai/eth, dai/uni)?

Hi Ivan, is there any update on the release of this price plugin?

We released the plugin

Plugin docs to see all features (get price quotes, swap, get all tokens etc):

Are there any plans to release plugins to access other dex? Ideally I would need access to data from as many dex as possible.