0

I am able to call the 0x /swap/v1/quote? endpoint without any issue (I know that is not hard). But passing in multiple exchanges, I thought, would return the swap prices on those exchanges. But it only returns a single price. Is it possible to return multiple prices from 0x or is it used for "best price"?

My code example:

  const multiExchangeQuote = async (inputToken, outputToken, value) => {
const exchangeList = '0x,Uniswap,Uniswap_V2,Eth2Dai,Kyber,Curve,Balancer, Balancer_V2,Bancor,mStable,Mooniswap,Swerve,SnowSwap,SushiSwap,Shell MultiHop, DODO,DODO_V2,CREAM,LiquidityProvider,CryptoCom,Linkswap,Lido,MakerPsm,KyberDMM,Smoothy,Component,Saddle,xSigma,Uniswap_V3,Curve_V2'
const params = {
  buyToken: 'DAI',
  sellToken: 'ETH',
  sellAmount: 0.05 * Math.pow(10, 18).toString(), // Always denominated in wei
  includedSources: exchangeList,
}
let response
try {
  response = await axios.get(
    `${URL}${qs.stringify(params)}`,
  )
} catch (err) {
  console.error(err)
}
console.log("Multi Exchange Quote",)
console.log(response.data);
//console.log("%O",response.data.sources)

}

Thanks

1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Commented Mar 21, 2022 at 10:27

1 Answer 1

0

Yeah, 0x API is an aggregation service, so it's designed to return a combined quote across all sources available to it (not just best price). You can sometimes get the price from a single source by using the includedSources= request param, but even that will get aggregated across different pools on that source, so it may not be what you're looking for.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.