0

good day!

I'm exploring the 0x API documentation but wasn't able to find the clear reference, but I'm wondering how can we know the fees breakdown especially related different/multiple liquidity providers?

I'm using the Matcha UI as an example here, what does the Network Fee map to in the API response? Also, is there a way to get a clear breakdown of the fees (be it the provider fee or the network fee) when the quote comes from multiple sources?

To give more context, in the example of the image I want to be able to show something like:

Source 1
Sell : 250 USDC
Buy : 442 ENJ
Fees : 2 ENJ

What you get : 440 ENJ
Network Fees : $3.37


Source 2
Sell : 550 USDC
Buy : 1003.1249 ENJ
Fees : 3 ENJ

What you get : 1000.1249 ENJ
Network Fees : $4

And when we summarize it, it becomes like how it's shown in the image.

AFAIK from the /quote API response we can only see the sources field but even that only defines proportions in a rough percentage

Matcha UI Image

1 Answer 1

0

ZRX api takes quotes from multiple onchain and offchain sources to find the best price even if network cost is higher, more sources more it will in theory the network fee, because the swapCallData needs to have more bytes. The API returns gasPrice and gas, so, your total network fee will be multiplication between gasPrice and gas.

Regarding the breakdown of each onchain source fee, I think at the moment the api not returns these values, however you can estimate that based on the onchain source fee, for instance, uniswap v2 takes 0.3% fee, other sources have other fees, so you can take the breakdown and multiply the amount from the source and multiply by their fee.

Regarding the network fee from each source, ZRX API not returns that value, however here as well you can do a estimation checking how much gas individually these sources takes, this will be a estimation because you need as well to add the routing logic that is done by ZRX contracts in the gas calculation. It's not an easy task, but it is possible.

1
  • Understood, so we'll need to figure out the details of the sources individually and map it to the breakdown I guess. Do you know any aggregator API of some kind that can provide the info of the source? Like for example, in some video tutorial they highlighted (and in the docs as well), they recommend using 3rd party API like CoinGecko to show the list of ERC20 tokens to the user to choose from, so I'm thinking of doing the same thing for the sources if the 0x API didn't provide it readily
    – Elli Anto
    Sep 14, 2022 at 8:07

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.