0

I just found out about 0x and therefore have a few questions:

Using the https://bsc.api.0x.org/swap/v1/quote API endpoint, I'm experiencing a big variation in response time, usually between 400ms and 1000ms, what is the reason for this?

In the 0x docs you can find the following statement: "The current limit is approximately 3 Requests Per Second (RPS)/40 Requests Per Minute (RPM) with a short burst of up to 5 times allowed." What is considered a short burst? Is sending 10 Requests Per Second for 3 seconds possible?

When I'm sending a GET request to bsc.api.0x.org/swap/v1/quote I can read the following in the response.data.data field. I broke it down for better readability.

0xc43c9ef6
0000000000000000000000000000000000000000000000000000000000000080
00000000000000000000000000000000000000000000000000071afd498d0000   => sellAmount
000000000000000000000000000000000000000000000000041ba44fec23a6a4   => minBuyAmount
0000000000000000000000000000000000000000000000000000000000000001
0000000000000000000000000000000000000000000000000000000000000002
000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee   => sellToken
000000000000000000000000e9e7cea3dedca5984780bafc599bd69add087d56   => buyToken
869584cd
0000000000000000000000001000000000000000000000000000000000000011
0000000000000000000000000000000000000000000000121bf9b37f629a06bd   => decodedUniqueID

Now, regarding the decodedUniqueID, the first part is a random hex and the second part is a sequential numbering based on the number of the request. Can you further explain to me, how the decodedUniqueID is used for the transaction?

Thank you very much in advance!

EDIT:

The request looks like this:

const params = {
    sellToken: "BNB",
    buyToken: "BUSD",
    sellAmount: '1000000000000000000',
    slippagePercentage: 0.01,
    gasPrice: "5000000000",
    excludedSources: "BakerySwap,Belt,DODO,DODO_V2,Ellipsis,Mooniswap,MultiHop,Nerve,Synapse,PancakeSwap,SushiSwap,Smoothy,ApeSwap,CafeSwap,CheeseSwap,JulSwap,LiquidityProvider,WaultSwap,FirebirdOneSwap,JetSwap,ACryptoS,KyberDMM,BiSwap",
};
const response = await axios(`https://bsc.api.0x.org/swap/v1/quote?${qs.stringify(params)}`);
console.log(response.data.data);

And the response data looks like this (some fields omitted):

{
  chainId: 56,
  to: '0xdef1c0ded9bec7f1a1670819833240f027b25eff',
  data: '0xc43c9ef600000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000008047ee9c87df3e45d00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000e9e7cea3dedca5984780bafc599bd69add087d56869584cd000000000000000000000000100000000000000000000000000000000000001100000000000000000000000000000000000000000000007bf13fb7bc629ab613',
  value: '1000000000000000000',
  gas: '136000',
  gasPrice: '5000000000',
  buyTokenAddress: '0xe9e7cea3dedca5984780bafc599bd69add087d56',
  sellTokenAddress: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
  buyAmount: '295795811720419068090',
  sellAmount: '1000000000000000000',
  allowanceTarget: '0x0000000000000000000000000000000000000000',
  decodedUniqueId: '7bf13fb7bc-1654306323',
}

You can see now that the first part of the decodedUniqueID (before the dash), which seems to be a random hex, combined with the second part of the decodedUniqueID (after the dash), which is a consecutive number as decimal, is identical with the last 18 characters of the data field (after you converted the consecutive number to a hex).

Now, back to my question:

What relevance does this decodedUniqueID have for the transaction, when this is clearly send with the transaction, since it appears in the data field? Is it maybe relevant for the 0x Exchange Proxy? Does it have any purpose at all?

1 Answer 1

0

The variation in response time depends on a number of factors, including traffic on the network at the time, the availability of our backend services, etc. This is why we give a range, so 10 Requests Per Second for 3 seconds possible might be possible, just depends on the circumstances.

The expectation is that most folks just playing around with the API won't reach the limit you've listed above (from our docs), but if they do, we'd prefer to fill out the integration request form so we can have a conversation with them about their project's needs and we can discuss their needs accordingly.

As for your second question about the response for the quote endpoint, can you post the full request query you're making? I'm surprised the response is a hex, since the expected behavior is to return a JSON object with these fields.

1
  • Please check out my EDIT in the initial post, thank you very much!
    – user101817
    Jun 4, 2022 at 2:00

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.