1inch aggregates most DEXes. by using 1inch plugin you use most dexes
Is it possible to access the dex prices individually? e.g. if I specifically wanted the uniswap or bancor price?
Hey @b7011343
If you look at the documentation that Ivan posted, you will find the function:
async function getQuote() {
const quote = await Moralis.Plugins.oneInch.quote({
chain: 'bsc', // The blockchain you want to use (eth/bsc/polygon)
fromTokenAddress: '0x0da6ed8b13214ff28e9ca979dd37439e8a88f6c4', // The token you want to swap
toTokenAddress: '0x6fd7c98458a943f469e1cf4ea85b173f5cd342f4', // The token you want to receive
amount: 1000,
});
console.log(quote);
}
You can try to specify protocols
option:
async function getQuote() {
const quote = await Moralis.Plugins.oneInch.quote({
chain: 'bsc', // The blockchain you want to use (eth/bsc/polygon)
fromTokenAddress: '0x0da6ed8b13214ff28e9ca979dd37439e8a88f6c4', // The token you want to swap
toTokenAddress: '0x6fd7c98458a943f469e1cf4ea85b173f5cd342f4', // The token you want to receive
amount: 1000,
protocols: ""
});
console.log(quote);
}
Protocols list you can find on 1 inch swagger by calling this API:
Let me know how it will work for you
not individually - you get the best price across all exchanges
EDIT: I see @Yomoo posted about protocols
variable, it may be able to filer exchanges like you want
Anyway Iβm not sure it is the best solution. Beacuse itβs more for specifying swap routing and not for fetching prices @b7011343
Is there a better solution you could suggest?
You have really tricky case. If you want to create arbitrage bot I donβt think that using not on-chain data is a good idea. You will probably need to call prices from the smart contracts at least to check the information received from the api. And it should be really fast. Speed is important to successful arbitrage. So the most convenient solution is to use a custom smart contract and get only on-chain data
Ok I will look into this. If I do it this way I imagine I will need to implement the logic for each dex individually.