question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Matcha & 0x Aggregator Trades overcounted in dex.trades

See original GitHub issue

Here is a query corresponding to this transaction demonstrating that a “single” token swap is being counted 6x in the dex.trades table.

  1. There is double accounting for the same aggregator (0x and Matcha)
  2. Each of the 3 “hops” of the trade is being counted on both aggregators.

Realistically, it makes sense to count each of the DEX trades, but for an aggregator protocol, this should only be counted a single trade for the user 0xd3f8f55b6b244afd86f2d0fb7f2de445cc0c10a8 who swapped ICE for USDC.

Or, at the very least only counted as a single aggregator (not two).

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
fleupoldcommented, Dec 10, 2021

why wouldn’t we necessarily think multi-legs on multi-hop should be all counted? by all aggregators?

My feeling is that aggregators primarily serve users (not liquidity providers) and should therefore report volume based on the user intent (Swap A for B regardless of whether it goes through C). Otherwise an aggregator who is serving the user better (e.g. not using a longer route if the trade execution cost is not worth the price improvement, or matching against a direct market maker) may be represented as worse (they used less hops) when looking at the top line metric.

For Meta DEX Aggregators like CowSwap counting the sum of all hops would also raise the question if we should then count the 0x Volume + underlying AMM volume together (seems silly)? For CowSwap in particular it is better to use less AMMs as this means less potential for MEV (similar to 0x RFQ orders).

1reaction
sui414commented, Dec 10, 2021

thank you both for the comments & elaboration🙏 . currently at team offsite so might have delay respond until mid next week.

one thing to note tho - 0x has both aggregator portion (labeled as “0x API”) and DEX portion (labeled “0x Native”, rfq & open orders i.e. limit orders) - the DEX portion is where we see overlap with paraswap above and is not included in that dash. for that dash, we only count “0x API” /swap endpoint volume. (limit order volume is thru another endpoint orderbook).

appreciate your research in depth on this! we currently don’t log multi-hop events and might need to decode from traces, or do extra clean up on those trades – if we agree to dedup on those cases.

why wouldn’t we necessarily think multi-legs on multi-hop should be all counted? by all aggregators? it does 1: accrue fees; 2: have counterparties if we count LPs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Matcha & 0x Aggregator Trades overcounted in dex.trades #610
Here is a query corresponding to this transaction demonstrating that a "single" token swap is being counted 6x in the dex.trades table.
Read more >
Does Matcha have a trading API?
Matcha uses the 0x API, which aggregates liquidity from numerous decentralized exchanges, or DEXs, and applies smart order routing to ensure that you...
Read more >
0x Ecosystem Spotlight: Matcha - Blog
Matcha is a decentralized exchange (DEX) aggregator and the best-designed best place to trade in DeFi. When you shop for flights you probably ......
Read more >
How to Trade on Matcha DEX Aggregator - YouTube
UPDATE as of 2021: This tutorial was made before we implemented the same 0x API that powers Matcha into Zapper Exchange.
Read more >
0x's first consumer product is an aggregator of decentralized ...
When a trader places an order on the new service, called Matcha, it splits the trade across several different networks — including 0x...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found