Updated Adapter - Curve 0.1.4

I’m proposing an update to the Curve adapter:

The previous adapter relied on a now deprecated subgraph with the following limitations:

  • Relied on a single registry for its list of pools, therefore not tracking many pools
  • Did not track v2 pools for volatile assets
  • Approximated fees by multiplying swap volume with fees, but did not take into consideration fees charged on liquidity additions and removal
  • Did not track newer deployments on chains like Optimism and xDai
  • Excluded pools with rebasing tokens and lending tokens, which are some of the protocol’s largest source of fess

This adapter uses a newer version of the Curve subgraph (https://github.com/curvefi/volume-subgraphs) which tracks all of the protocol pools across all the chains where Curve is deployed and which are supported by the Graph.

The subgraph uses the growth rate of the pool’s virtual price (i.e. revenue to LPs from fees) for v1 (stable swap) pools and the growth rate of ((xcp_profit + xcp_profit_a) / 1e18 - 1) for v2 (crypto swap) pools. In both cases it deducts from this the profits accrued from rebases and interest for lending pools so as to only account for revenue generated from trading fees.

Note that the fees are an estimate of the fees generated by the pool and therefore may differ, on a day to day basis, from the amount of fees actually claimed by the protocol (as claims on some pools may only happen once a week for instance). On the whole, however, the two values (estimated and claimed) converge toward the same amount of total accumulated fees.

1 Like

Hey @benny, thanks so much for building this adapter! And so sorry for the delayed response, been a busy few weeks for me!

Took a look over the adapter, and looks good overall, but I’ve got a couple concerns:

Aggregating all the pool values in the adapter isn’t ideal for multiple reasons:

  • Fetching all pool snapshots is slow for the subgraph to return data
  • Iterating over all pools is slow for the adapter
  • The adapter is limited to only 1000 pools

Ideally, the subgraph would create global daily snapshots. However, I took a look at the subgraph repository, and it doesn’t appear to be up-to-date, as I don’t see any of the newest fee elements there.

I’d also like to review the subgraph code to understand how these snapshots are generated. We’ve had issues with snapshot-based subgraphs for other AMMs (Uniswap, SushiSwap, Balancer) which has lead to under-reporting for these protocols.

Are you the developer of the subgraph or do you now who else is?

Given that it may take a bit for the new updated subgraph to get working (the current deployment is broken, and even a working deployment will take time to sync), I think we should get your current implementation working, as it’s already a significant improvement on the existing Curve adapter.

One potential bug i’ve noticed is I believe the current adapter is returning data for the incorrect day. Given that snapshots are taken at midnight, the fee data stored by a snapshot is actually the fees for the previous day, correct?

This is also noticeable by the fact that it’s possible to query fee data for the current day (which should be incomplete).

Done, offset all the dates by 1 in query to address this:

The update has been verified, and I cleared the data cache on CryptoFees.info.

Thanks so much for your contribution @benny! I know how hard it is to get accurate Curve data, so I really appreciate the work you put into this!